44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
"""Configure the immutable model source registry for governed snapshots.
|
|
|
|
The phase-2 seed intentionally registered model artifacts as unknown. Runtime
|
|
model provenance now records exact immutable snapshots, so the server-owned
|
|
registry must advertise that configured capability. The write guard is only
|
|
disabled for this narrowly-scoped, versioned migration and is restored in the
|
|
same transaction.
|
|
"""
|
|
|
|
from alembic import op
|
|
|
|
|
|
revision = "202608230001"
|
|
down_revision = "202608010001"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def _set_status(*, freshness_status: str, ingest_status: str) -> None:
|
|
op.execute("ALTER TABLE source_registry DISABLE TRIGGER trg_source_registry_write_guard")
|
|
op.execute(
|
|
f"""
|
|
UPDATE source_registry
|
|
SET freshness_status = '{freshness_status}',
|
|
ingest_status = '{ingest_status}',
|
|
registry_metadata_json = (
|
|
registry_metadata_json::jsonb ||
|
|
'{{"runtime_model_contract": {{"key": "geointel.model.pytorch", "version": "1.0.0"}}}}'::jsonb
|
|
)::json,
|
|
updated_at = now()
|
|
WHERE source_key = 'model'
|
|
AND registry_metadata_json ->> 'registry_owner' = 'server'
|
|
"""
|
|
)
|
|
op.execute("ALTER TABLE source_registry ENABLE TRIGGER trg_source_registry_write_guard")
|
|
|
|
|
|
def upgrade() -> None:
|
|
_set_status(freshness_status="current", ingest_status="configured")
|
|
|
|
|
|
def downgrade() -> None:
|
|
_set_status(freshness_status="unknown", ingest_status="registered")
|