chore(backend): save remaining API and deployment changes
Expose frozen factual review policy, update API descriptions and Swagger settings, and adjust local deployment and embedding connectivity. Include the requested extraction candidates and review-policy regression coverage. Validation: 31 OCR policy tests passed; staged diff whitespace checks passed.
This commit is contained in:
@@ -19,6 +19,14 @@ def ocr_review_required(profile: Mapping) -> bool:
|
||||
return value
|
||||
|
||||
|
||||
def factual_review_required(profile: Mapping) -> bool:
|
||||
"""Fail closed for legacy snapshots; deployment defaults never reinterpret jobs."""
|
||||
value = profile.get("extraction", {}).get("factual_review_required", True)
|
||||
if type(value) is not bool:
|
||||
raise ValueError("Invalid frozen factual review policy")
|
||||
return value
|
||||
|
||||
|
||||
def processing_profile_kind(profile: Mapping) -> str:
|
||||
if "profile_schema" not in profile and profile.get("extractor") == "pypdf-markdown-v1":
|
||||
return "legacy-v1"
|
||||
@@ -29,6 +37,7 @@ def processing_profile_kind(profile: Mapping) -> str:
|
||||
|
||||
def extraction_profile_digest(profile: Mapping) -> str:
|
||||
ocr_review_required(profile)
|
||||
factual_review_required(profile)
|
||||
if processing_profile_kind(profile) == "legacy-v1":
|
||||
raise LegacyProcessingProfile("Legacy extractor requires explicit legacy dispatch; OCR reinterpretation is forbidden")
|
||||
# Faithful extraction is reusable across chunk/embedding/normalization changes.
|
||||
|
||||
@@ -10,6 +10,7 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator, model_valida
|
||||
from .chunking import chunk_extraction, factual_context_units
|
||||
from .embeddings import validate_database_string
|
||||
from .extraction import ExtractionError, PLACEHOLDER, REVIEW_CHECKS
|
||||
from .extraction_artifacts import factual_review_required
|
||||
|
||||
FACTUAL_CHECKS = ("factual_authority", "whole_pair_association", "behavioral_separation", "placeholders")
|
||||
|
||||
@@ -105,7 +106,14 @@ def prepare_chunks(envelope, processing_profile, state, artifact_sha256):
|
||||
"""One boundary for worker staging and publication; faithful artifact stays whole."""
|
||||
if not factual_groups(envelope):
|
||||
return chunk_extraction(envelope, processing_profile)
|
||||
included = included_groups(envelope, state.get("factual_inclusion"), artifact_sha256)
|
||||
if not factual_review_required(processing_profile) and state.get("factual_inclusion") is None:
|
||||
groups = factual_groups(envelope)
|
||||
included = {group for group, blocks, _ in factual_context_units(envelope.blocks)
|
||||
if not any(PLACEHOLDER.search(b.text) for b in blocks) and group in groups}
|
||||
if not included:
|
||||
raise ExtractionError("No eligible factual groups")
|
||||
else:
|
||||
included = included_groups(envelope, state.get("factual_inclusion"), artifact_sha256)
|
||||
return chunk_extraction(envelope, processing_profile, corpus_purpose="approved_factual",
|
||||
included_group_ids=included)
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ class IngestionSettings(BaseSettings):
|
||||
fallback_policy: str = Field(default="affected-pages-v1", min_length=1)
|
||||
quality_policy: str = Field(default="bounded-checks-manual-review-v1", min_length=1)
|
||||
ocr_review_required: bool = True
|
||||
factual_review_required: bool = True
|
||||
normalization_policy: str = Field(default="unicode-line-endings-v1", min_length=1)
|
||||
chunking_policy: str = Field(default="paragraph-v1", min_length=1)
|
||||
render_dpi: int = Field(default=144, gt=0, le=600)
|
||||
@@ -213,6 +214,7 @@ class IngestionSettings(BaseSettings):
|
||||
"model": self.vision_model, "timeout_seconds": self.vision_timeout_seconds},
|
||||
"fallback_policy": self.fallback_policy, "quality_policy": self.quality_policy,
|
||||
"ocr_review_required": self.ocr_review_required,
|
||||
"factual_review_required": self.factual_review_required,
|
||||
"render_dpi": self.render_dpi,
|
||||
"max_rendered_page_pixels": self.max_rendered_page_pixels,
|
||||
"max_pdf_pages": self.max_pdf_pages,
|
||||
|
||||
Reference in New Issue
Block a user