feat(ingestion): add opt-in best-effort document admission

Freeze temporary partial-extraction admission in new uploads. Bypass manual approval, retain recognition warnings, and accept ambiguous legal references during bounded chunking. Preserve strict defaults, immutable evidence and atomic publication. Expose effective policy and safe failure categories with regression coverage.
This commit is contained in:
amirhosein mazaheri
2026-10-13 14:09:21 +03:30
parent 18e595ac93
commit 90a164f5a6
18 changed files with 301 additions and 31 deletions
+4 -1
View File
@@ -13,6 +13,7 @@ from urllib.error import HTTPError, URLError
from pydantic import BaseModel, ConfigDict
from app.modules.documents.extraction import ExtractionError, ExtractionProviderError, unreadable
from app.modules.documents.normalization import normalize_search_text
from app.modules.documents.extraction_artifacts import allow_partial_extraction
from app.modules.documents.types import ExtractedBlock
from app.infrastructure.gemini_vision import Transcription, INSTRUCTION, _TRANSPORT_CAPACITY
@@ -177,7 +178,7 @@ class OpenRouterVision:
blocks = []
for index, block in enumerate(transcript.blocks):
locator = block.source_locator if block.source_locator and block.source_locator.startswith(section + "/") else f"{section}/block/{index + 1}"
if unreadable(block.text):
if unreadable(block.text) and not (allow_partial_extraction(processing_profile) and any(c.isalnum() for c in block.text)):
raise ExtractionError("Vision reports unreadable source regions")
blocks.append(block.model_copy(update={
"ordinal": index,
@@ -191,6 +192,8 @@ class OpenRouterVision:
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]
if allow_partial_extraction(processing_profile):
blocks = [b.model_copy(update={"warnings": b.warnings + (("Unrecognized characters retained",) if unreadable(b.text) else ())}) for b in blocks]
return tuple(blocks)
except (KeyError, TypeError, ValueError, AttributeError) as exc:
if isinstance(exc, ExtractionError):