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:
@@ -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
|
||||
|
||||
|
||||
@@ -174,7 +175,7 @@ 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):
|
||||
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={"search_text":
|
||||
normalize_search_text(block.text, processing_profile["normalizer"])}))
|
||||
@@ -182,6 +183,8 @@ class GeminiVision:
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user