feat(backend): deliver Phase 3 document and voice integration
Add authenticated upload, review, retry and knowledge-selection HTTP flows with bounded JSON processing and frozen OCR policy. Preserve Gemini/OpenAI provider selection and fenced lifecycle semantics; retain FAQ preambles and uncertain vision candidates, and expose opt-in uncalibrated voice transport diagnostics. Include frontend integration examples, aligned contracts and deterministic regressions. Validation: 1767 provider-free tests passed; all 404 PostgreSQL scenarios have passing evidence across the documented runs.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""Fail closed without labelling unavailable authority as verified revocation."""
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from app.modules.knowledge.service import KnowledgeError
|
||||
|
||||
|
||||
def authority_failure_code(exc):
|
||||
if isinstance(exc, KnowledgeError) and exc.code in {'ACTOR_UNAVAILABLE', 'CONTEXT_REVOKED'}:
|
||||
return 'CONTEXT_REVOKED'
|
||||
if isinstance(exc, TimeoutError):
|
||||
return 'SEARCH_TIMEOUT'
|
||||
if isinstance(exc, SQLAlchemyError):
|
||||
return 'DEPENDENCY_UNAVAILABLE'
|
||||
if isinstance(exc, ValueError):
|
||||
if str(exc) == 'SERVICE_BUSY':
|
||||
return 'SEARCH_SATURATED'
|
||||
if str(exc) in {'AUTH_REQUIRED', 'USER_DISABLED', 'ACCOUNT_DISABLED', 'SESSION_REVOKED', 'SESSION_EXPIRED',
|
||||
'CONTEXT_REVOKED', 'CONVERSATION_STALE', 'CONVERSATION_CLOSED',
|
||||
'CONVERSATION_NOT_FOUND', 'SESSION_NOT_FOUND', 'LIVE_SESSION_EXPIRED',
|
||||
'LIVE_SESSION_UNUSABLE'}:
|
||||
return 'CONTEXT_REVOKED'
|
||||
return 'DEPENDENCY_UNAVAILABLE'
|
||||
Reference in New Issue
Block a user