- 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
27 lines
1.0 KiB
Python
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")
|