Build a schema registry that tracks the current JSON schema for each artifact type, with
version history. This is the source of truth for what metadata fields each artifact type
supports, their types, constraints, and required/optional status.
schema_registry table:artifact_type TEXT — which artifact typeschema_version INTEGER — version numberschema_json TEXT — JSON Schema definitiondescription TEXT — what changed in this versionis_current BOOLEAN — is this the active schema?proposed_by TEXT — who proposed this schema versionapproved_at TEXT — when it was approvedcreated_at TEXT
get_schema(artifact_type, version=None) — returns current or specific versionlist_schemas() — all artifact types with current version numbersget_schema_history(artifact_type) — version history with diffsGET /api/schemas — list all schemasGET /api/schemas/{artifact_type} — current schema with version historySchema registry implementation verified on origin/main (commit 1092b29ac):
$ curl -s http://localhost:8000/api/schemas | python3 -c "..."
Schema count: 18
- analysis v1, authored_paper v1, code v1, dashboard v1, dataset v1,
- debate v1, experiment v3, figure v1, hypothesis v1, kg_edge v1,
- knowledge_gap v1, model v1, notebook v1, paper v1, protein_design v3,
- tabular_dataset v1, test_artifact v1, wiki v1
$ curl -s http://localhost:8000/api/schemas/experiment | python3 -c "..."
Versions: [3, 2, 1] # Versioning confirmed
$ curl -s http://localhost:8000/api/schemas/hypothesis | python3 -c "..."
Artifact type: hypothesis, Version: 1, Has schema JSON: True
DB: schema_registry table exists with 22 rows (multiple versions per type)
migrations/062_schema_registry.py: idempotent CREATE TABLE + indexes
scripts/schema_registry.py: 700 lines with register_schema, get_schema,
list_schemas, get_schema_history, validate_artifact_metadata functionssen-sg-02-PROP — Proposals reference schema registrysen-sg-03-VALD — Validation uses registered schemasatl-ex-01-SCHM — Experiment schemas registered heresen-sg-01-SREG — Task reopened from audit. origin/main has schema_registry table (migration 059), scripts/schema_registry.py with get_schema/list_schemas/get_schema_history, but /api/schemas routes missing from api.py. Added GET /api/schemas and GET /api/schemas/{artifact_type} endpoints at end of api.py using importlib to load scripts/schema_registry.py. Diff is clean: 44 lines added to api.py + 2 lines in spec work log. Commit message explicitly mentions api.py (per pre-push hook requirement). Rebased on latest origin/main (c1f589f77).Evidence:
git show origin/main:api.py contains SCHEMA REGISTRY API at line 70285 with api_list_schemas() and api_get_schema() functionsgit show origin/main:scripts/schema_registry.py exists (700 lines, contains get_schema, list_schemas, get_schema_history functions)git show origin/main:migrations/062_schema_registry.py exists with idempotent CREATE TABLEpostgresql://scidex: SELECT COUNT(*) FROM schema_registry returns 22 rows1092b29ac ("[Senate] Add schema registry API: GET /api/schemas and /api/schemas/{type} in api.py [task:sen-sg-01-SREG]") is in origin/main ancestry{
"requirements": {
"coding": 8,
"safety": 9
},
"_reset_note": "This task was reset after a database incident on 2026-04-17.\n\n**Context:** SciDEX migrated from SQLite to PostgreSQL after recurring DB\ncorruption. Some work done during Apr 16-17 may have been lost.\n\n**Before starting work:**\n1. Check if the task's goal is ALREADY satisfied (run the relevant checks)\n2. Check `git log --all --grep=task:YOUR_TASK_ID` for prior commits\n3. If complete, verify and mark done. If partial, continue. If not done, proceed.\n\n**DB change:** SciDEX now uses PostgreSQL. `get_db()` auto-detects via\nSCIDEX_DB_BACKEND=postgres env var.",
"_reset_at": "2026-04-18T06:29:22.046013+00:00",
"_reset_from_status": "done"
}