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:
11linear11
2026-10-09 17:43:52 -04:00
parent 9be47191d6
commit a73a496c54
67 changed files with 5988 additions and 234 deletions
+7 -3
View File
@@ -165,8 +165,8 @@ class GeminiVision:
if any("text" not in p for p in parts):
raise ExtractionError("Unexpected vision response parts")
transcript = Transcription.model_validate_json("".join(p["text"] for p in parts))
if not transcript.complete or transcript.warnings or not transcript.blocks:
raise ExtractionError("Vision transcription incomplete or uncertain")
if not transcript.blocks:
raise ExtractionError("Vision transcription has no candidate blocks")
if len(transcript.blocks) > extraction["max_extracted_blocks"]:
raise ExtractionError("Vision block limit exceeded")
blocks = []
@@ -174,10 +174,14 @@ class GeminiVision:
if (block.ordinal != index or block.method != "vision" or block.actual_model != self.model or block.page != page
or not block.source_locator.startswith(section + "/")):
raise ExtractionError("Vision returned incompatible evidence provenance")
if unreadable(block.text) or any("unreadable" in w.lower() or "ناخوانا" in w for w in block.warnings):
if unreadable(block.text):
raise ExtractionError("Vision reports unreadable source regions")
blocks.append(block.model_copy(update={"search_text":
normalize_search_text(block.text, processing_profile["normalizer"])}))
# Recognition diagnostics belong to the exact review candidate.
warnings = transcript.warnings + (() if transcript.complete else ("Vision recognition incomplete; completeness review required",))
if warnings:
blocks = [b.model_copy(update={"warnings": b.warnings + warnings}) for b in blocks]
return tuple(blocks)
except (KeyError, TypeError, ValueError, AttributeError) as exc:
if isinstance(exc, ExtractionError):