[Senate] Schema registry — track schemas per artifact type with versions done coding:8 safety:9

← Schema Governance
schema_registry table with JSON Schema definitions, version history, get/list/history functions, API ## REOPENED TASK — CRITICAL CONTEXT This task was previously marked 'done' but the audit could not verify the work actually landed on main. The original work may have been: - Lost to an orphan branch / failed push - Only a spec-file edit (no code changes) - Already addressed by other agents in the meantime - Made obsolete by subsequent work **Before doing anything else:** 1. **Re-evaluate the task in light of CURRENT main state.** Read the spec and the relevant files on origin/main NOW. The original task may have been written against a state of the code that no longer exists. 2. **Verify the task still advances SciDEX's aims.** If the system has evolved past the need for this work (different architecture, different priorities), close the task with reason "obsolete: " instead of doing it. 3. **Check if it's already done.** Run `git log --grep=''` and read the related commits. If real work landed, complete the task with `--no-sha-check --summary 'Already done in '`. 4. **Make sure your changes don't regress recent functionality.** Many agents have been working on this codebase. Before committing, run `git log --since='24 hours ago' -- ` to see what changed in your area, and verify you don't undo any of it. 5. **Stay scoped.** Only do what this specific task asks for. Do not refactor, do not "fix" unrelated issues, do not add features that weren't requested. Scope creep at this point is regression risk. If you cannot do this task safely (because it would regress, conflict with current direction, or the requirements no longer apply), escalate via `orchestra escalate` with a clear explanation instead of committing.

Completion Notes

Auto-completed by supervisor after successful deploy to main

Git Commits (7)

[Atlas/Senate/Agora] Spec: notebook + artifact versioning extensions2026-04-24
Squash merge: orchestra/task/sen-sg-0-schema-registry-track-schemas-per-artifa (1 commits)2026-04-18
Squash merge: orchestra/task/47b17cbf-sen-sg-01-sreg-schema-registry-track-art (1 commits)2026-04-16
[Senate] Add schema registry API: GET /api/schemas and /api/schemas/{type} in api.py [task:sen-sg-01-SREG]2026-04-16
[Senate] Schema registry: migration, seeding, and /senate/schemas UI [task:47b17cbf-a8ac-419e-9368-7a2669da25a8]2026-04-06
[Senate] Holistic prioritization run 2: quest fixes + 3 new CI tasks [task:b4c60959-0fe9-4cba-8893-c88013e85104]2026-04-06
[Senate] Holistic prioritization: 6 tasks created for uncovered P88-P95 quests [task:b4c60959-0fe9-4cba-8893-c88013e85104]2026-04-06
Spec File

Goal

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.

Acceptance Criteria

schema_registry table:
- artifact_type TEXT — which artifact type
- schema_version INTEGER — version number
- schema_json TEXT — JSON Schema definition
- description TEXT — what changed in this version
- is_current BOOLEAN — is this the active schema?
- proposed_by TEXT — who proposed this schema version
- approved_at TEXT — when it was approved
- created_at TEXT
☑ Initial schemas registered for all existing artifact types (experiment, paper, hypothesis, etc.)
get_schema(artifact_type, version=None) — returns current or specific version
list_schemas() — all artifact types with current version numbers
get_schema_history(artifact_type) — version history with diffs
☑ Schemas stored as JSON Schema (draft 2020-12) for standard validation
☑ API: GET /api/schemas — list all schemas
☑ API: GET /api/schemas/{artifact_type} — current schema with version history

Verification (2026-04-16)

Schema 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 functions

Dependencies

  • None (foundation task)

Dependents

  • sen-sg-02-PROP — Proposals reference schema registry
  • sen-sg-03-VALD — Validation uses registered schemas
  • atl-ex-01-SCHM — Experiment schemas registered here

Work Log

  • 2026-04-16 sen-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).

Already Resolved — 2026-04-18 15:39:31Z

Evidence:

  • git show origin/main:api.py contains SCHEMA REGISTRY API at line 70285 with api_list_schemas() and api_get_schema() functions
  • git 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 TABLE
  • Database postgresql://scidex: SELECT COUNT(*) FROM schema_registry returns 22 rows
  • Database has 18 current schemas across artifact types (analysis, authored_paper, code, dashboard, dataset, debate, experiment v3, figure, hypothesis, kg_edge, knowledge_gap, model, notebook, paper, protein_design v3, tabular_dataset, test_artifact, wiki)
  • Commit 1092b29ac ("[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

Payload JSON
{
  "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"
}

Sibling Tasks in Quest (Schema Governance) ↗

Task Dependencies

↓ Referenced by (downstream)