Files
amirhosein mazaheri 9663caf48e feat(ingestion): implement Phase 5 background worker, orchestration, and publication
- Add background worker daemon for job lease acquisition and heartbeat maintenance
- Implement atomic document publication, failed job retry backoff, and review resume
- Add WorkerRepository for atomic database claims and lease fencing
- Add migration 0002_worker_artifact for extraction state tracking
- Add extensive unit and integration test coverage for worker orchestration and review resumes
2026-10-07 16:21:34 +03:30

27 lines
1.0 KiB
Python

"""Trusted complete-extraction attachment; foundation revision remains immutable."""
from alembic import op
revision = "0002_worker_artifact"
down_revision = "0001_ingestion_foundation"
branch_labels = None
depends_on = None
def upgrade(**kwargs):
op.execute("""
ALTER TABLE documents ADD COLUMN extraction_state jsonb NOT NULL DEFAULT '{}',
ADD CONSTRAINT documents_extraction_state_object CHECK (
jsonb_typeof(extraction_state) = 'object'
AND (NOT extraction_state ? 'complete_artifact' OR (
jsonb_typeof(extraction_state->'complete_artifact') = 'object'
AND (extraction_state->'complete_artifact') ?& ARRAY['key','sha256','document_id',
'original_sha256','extraction_profile_sha256']
AND extraction_state->'complete_artifact'->>'sha256' ~ '^[0-9a-f]{64}$'
))
)
""")
def downgrade(**kwargs):
op.execute("ALTER TABLE documents DROP COLUMN extraction_state")