feat(ingestion): implement Phase 3 text extraction, OCR, and human review
- Add direct text, DOCX, and PDF text extraction with visual OCR fallback - Implement Gemini and OpenRouter vision adapters with strict bounded retry - Implement extraction envelopes, artifacts, and Unicode/Persian normalization - Add human review workflow, candidate staging, and review repositories - Add migration 0003_extraction_review for audit events and review tracking - Add comprehensive unit and integration tests covering extraction and review contracts
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Extend audit action/replay checks without editing applied ingestion revisions."""
|
||||
from alembic import op
|
||||
|
||||
revision = "0003_extraction_review"
|
||||
down_revision = "0002_worker_artifact"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade(**kwargs):
|
||||
op.execute("ALTER TABLE audit_events DROP CONSTRAINT audit_events_action_check")
|
||||
op.execute("""
|
||||
ALTER TABLE audit_events ADD CONSTRAINT audit_events_action_check CHECK (
|
||||
action IN ('upload','selection_changed','document_deleted','ingestion_retry',
|
||||
'extraction_review','configuration_changed','session_revoked')
|
||||
), ADD CONSTRAINT audit_events_extraction_review_replay CHECK (
|
||||
action <> 'extraction_review' OR (
|
||||
actor_user_id IS NOT NULL AND target_id IS NOT NULL
|
||||
AND idempotency_key IS NOT NULL AND request_hash IS NOT NULL
|
||||
AND response_json IS NOT NULL
|
||||
)
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
def downgrade(**kwargs):
|
||||
op.execute("ALTER TABLE audit_events DROP CONSTRAINT audit_events_extraction_review_replay")
|
||||
op.execute("ALTER TABLE audit_events DROP CONSTRAINT audit_events_action_check")
|
||||
op.execute("""
|
||||
ALTER TABLE audit_events ADD CONSTRAINT audit_events_action_check CHECK (
|
||||
action IN ('upload','selection_changed','document_deleted','ingestion_retry',
|
||||
'configuration_changed','session_revoked')
|
||||
)
|
||||
""")
|
||||
Reference in New Issue
Block a user