[Senate] Create automated quality checks for new hypotheses, wiki pages, KG edges done coding:8 safety:9

← Work Governance
## 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 (12)

[Senate] Update spec work log: quality checks implemented [task:b340fd5d9dd9]2026-04-20
[Senate] Wire quality checks into db_writes and add /api/quality/validate endpoint; update api.py [task:b340fd5d9dd9]2026-04-20
[Senate] Add quality_checks module with validators for hypotheses, wiki pages, KG edges [task:b340fd5d9dd9]2026-04-20
[Senate] Update spec work log: quality checks implemented [task:b340fd5d9dd9]2026-04-20
[Senate] Wire quality checks into db_writes and add /api/quality/validate endpoint; update api.py [task:b340fd5d9dd9]2026-04-20
[Senate] Add quality_checks module with validators for hypotheses, wiki pages, KG edges [task:b340fd5d9dd9]2026-04-20
[Senate] Update spec work log: quality checks implemented [task:b340fd5d9dd9]2026-04-20
[Senate] Wire quality checks into db_writes and add /api/quality/validate endpoint; update api.py [task:b340fd5d9dd9]2026-04-20
[Senate] Add quality_checks module with validators for hypotheses, wiki pages, KG edges [task:b340fd5d9dd9]2026-04-20
[Senate] Update spec work log: quality checks implemented [task:b340fd5d9dd9]2026-04-20
[Senate] Wire quality checks into db_writes and add /api/quality/validate endpoint; update api.py [task:b340fd5d9dd9]2026-04-20
[Senate] Add quality_checks module with validators for hypotheses, wiki pages, KG edges [task:b340fd5d9dd9]2026-04-20
Spec File

[Senate] Create automated quality checks for new hypotheses, wiki pages, KG edges

Quest: Work Governance Priority: P3 Status: open

Goal

Create automated quality checks for new hypotheses, wiki pages, KG edges

Context

This task is part of the Work Governance quest (Senate layer). It contributes to the broader goal of building out SciDEX's senate capabilities.

Acceptance Criteria

☐ Implementation complete and tested
☐ All affected pages load (200 status)
☐ Work visible on the website frontend
☐ No broken links introduced
☐ Code follows existing patterns

Approach

  • Read relevant source files to understand current state
  • Plan implementation based on existing architecture
  • Implement changes
  • Test affected pages with curl
  • Commit with descriptive message and push
  • Work Log

    2026-04-20 14:30 PT — Slot 0

    • Re-evaluated task: confirmed no prior commits reference task ID b340fd5d9dd9
    • Found existing quality gates in api.py (/api/quality-gates) and post_process.py (evidence/score/specificity gates)
    • Created scidex/senate/quality_checks.py with three runnable validators: check_hypothesis, check_wiki_page, check_knowledge_edge
    • Integrated quality guard-rail calls into db_writes.py: insert_knowledge_edge, create_wiki_page, upsert_wiki_page
    • Added /api/quality/validate endpoint for on-demand entity validation
    • Rebased on origin/main (da089b65c), resolved no conflicts
    • Committed: [Senate] Add quality_checks module... (a6ac0df21), [Senate] Wire quality checks into db_writes... (b19e43202)
    • All unit tests passed (hypothesis, wiki page, KG edge checks)

    Already Resolved — 2026-04-20T14:35:00Z

    The task goal (automated quality checks) was partially addressed by pre-existing quality gates:

    • post_process.py gates (evidence_gate, score_gate, specificity_gate) run after every debate
    • api.py /api/quality-gates endpoint provides batch quality reporting
    • epistemic_health.py monitors KG trust scores and auto-proposes Senate reviews

    The new implementation extends these with:
  • A standalone scidex/senate/quality_checks.py module (runnable as CLI, usable by any code)
  • Guard-rail integration into db_writes.py for real-time validation at write time
  • /api/quality/validate endpoint for on-demand single-entity validation
  • Committed: a6ac0df21, b19e43202 (task:b340fd5d9dd9)

    Payload JSON
    {
      "requirements": {
        "coding": 8,
        "safety": 9
      },
      "auto_tagged_at": "2026-04-03T22:29:52.519439"
    }

    Sibling Tasks in Quest (Work Governance) ↗