Today the artifacts table has a free-text deprecated_reason column
(verified via \d artifacts — column type text, no constraint), and every
deprecation writer writes whatever string it likes. Production has 27
deprecated artifacts with reasons ranging from null to terse-agent prose;
this is unanalyzable. This task introduces a small controlled vocabulary
(8–10 codes), a Postgres CHECK that requires the code, a free-text
deprecated_reason_detail column for the human note, and dashboards that
break down "deprecated this week, by reason code" — directly answering one
of the spec-prompt's required acceptance criteria for governance metrics.
scidex/atlas/lifecycle_constants.py asDEPRECATION_REASON_CODES = {
'superseded', # newer version exists, see superseded_by
'duplicate', # merged into a canonical artifact
'invalidated_by_evidence', # contradicted by later finding
'method_error', # methodological flaw discovered
'data_error', # source data wrong / retracted
'low_quality', # quality_score below threshold
'out_of_scope', # no longer aligned with project scope
'spam_or_abuse', # malicious / off-topic content
'requested_by_owner', # content owner asked for removal
'unmaintained', # no owner / no updates within SLA
} — 10 codes, deliberately small.
migrations/20260428_deprecation_reason_taxonomy.sql:ALTER TABLE artifacts ADD COLUMN IF NOT EXISTS
deprecated_reason_code text (nullable; populated by step below).ALTER TABLE artifacts ADD COLUMN IF NOT EXISTS
deprecated_reason_detail text (free-text, ≤ 2000 chars; renamedeprecated_reason → keep both columns until backfill).lifecycle_state='deprecated' thendeprecated_reason_code IS NOT NULL AND IS IN $codes; allow NULLidx_artifacts_deprecated_reason ON artifacts
(deprecated_reason_code) WHERE lifecycle_state='deprecated'.
scripts/backfill_deprecation_reason_codes.py:deprecated_reason,deprecated_reason_code + copies the original text intodeprecated_reason_detail. For nulls / blanks, code = 'unmaintained'.deprecation_backfill_runs records counts.
lifecycle_state='deprecated'scidex/senate/decision_engine.py:_execute_deprecate,scidex/atlas/artifact_registry.py:deprecate_artifact ~line 3891,_execute_split which deprecates source) takes areason_code: str parameter, validated againstDEPRECATION_REASON_CODES, plus an optional reason_detail: str.'unmaintained' — callers must specify.
POST /api/atlas/artifacts/{id}/deprecate body{reason_code, reason_detail?} returns 422 when code unknown.
scidex/senate/quality_dashboard.py) with a "Deprecations thisdeprecated_reason_code, with sparkline oftests/test_deprecation_taxonomy.py:data_error,superseded.q-gov-lifecycle-state-machine-enforcement — state machine ensures* → deprecated transitions go through the helper that takesreason_code.q-gov-metrics-dashboard — uses the per-code weekly buckets.All acceptance criteria implemented:
scidex/atlas/lifecycle_constants.py — 10-code DEPRECATION_REASON_CODES frozenset + DEPRECATION_REASON_LABELS dict.migrations/20260428_deprecation_reason_taxonomy.sql — adds deprecated_reason_code + deprecated_reason_detail columns; NOT VALID CHECK constraint (avoids blocking existing null rows); partial index; deprecation_backfill_runs audit table.scripts/backfill_deprecation_reason_codes.py — LLM classifier with heuristic fallback; idempotent; --dry-run / --commit / --validate-constraint modes.scidex/atlas/artifact_registry.py — deprecate_artifact() and transition_lifecycle() both accept reason_code + reason_detail; reactivate_artifact() clears both new columns.scidex/senate/decision_engine.py — _execute_deprecate() takes reason_code (default low_quality); _execute_split() passes reason_code="superseded".scidex/senate/quality_dashboard.py — "Deprecations this week by reason code" bar chart + 8-week sparkline table; CSV export section added.api.py — POST /api/atlas/artifacts/{id}/deprecate endpoint; 422 on unknown code.tests/test_deprecation_taxonomy.py — 15 tests (pure-Python + PG-tagged); all pass.