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
+6 -3
View File
@@ -250,7 +250,7 @@ def factual_context_units(blocks):
source_units.append([block.group_id, [block], True])
else:
source_units.append([None, [block], False])
scopes, resolved = [], []
scopes, resolved, preamble = [], [], []
def close_scope():
scope = scopes.pop()
@@ -263,7 +263,7 @@ def factual_context_units(blocks):
raise ExtractionError("Unresolved non-FAQ source group")
# Validate every group, including excluded groups, before selection.
associate_dependencies([(group, unit, True)])
context = [b for scope in scopes for b in scope["blocks"]]
context = preamble + [b for scope in scopes for b in scope["blocks"]]
for scope in scopes:
scope["used"] = True
resolved.append([group, context + unit, True])
@@ -278,10 +278,13 @@ def factual_context_units(blocks):
while scopes and scopes[-1]["level"] >= level:
close_scope()
scopes.append(dict(level=level, blocks=[block], used=False))
elif not scopes and not resolved and block.parent_block_id is None:
# Initial source prose is document-wide context, never pair-local.
preamble.append(block)
elif scopes and not scopes[-1]["used"] and block.parent_block_id is None:
scopes[-1]["blocks"].append(block)
else:
# Unheaded preambles and prose between pairs have no reliable scope.
# Prose after pairs still has no reliable association.
raise ExtractionError("Ambiguous governing context for factual FAQ")
while scopes:
close_scope()