[Exchange] Enrich top 5 hypotheses with clinical trials data via ClinicalTrials.gov API done analysis:7 reasoning:6 safety:9

← Exchange
## 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.

Git Commits (8)

Squash merge: orchestra/task/1290fb13-api.py-clinical-trials-route-fix (1 commits)2026-04-20
Squash merge: orchestra/task/1290fb13-api.py-clinical-trials-route-fix (1 commits)2026-04-20
Squash merge: orchestra/task/1290fb13-api.py-clinical-trials-route-fix (1 commits)2026-04-20
[Exchange] api.py restore clinical trials hypothesis route [task:1290fb13-d11d-4f40-ac4e-e7660809159d]2026-04-20
[Exchange] api.py: render hypothesis clinical trials [task:1290fb13-d11d-4f40-ac4e-e7660809159d]2026-04-20
[Exchange] Update spec work log for reopened task attempt 2 [task:1290fb13-d11d-4f40-ac4e-e7660809159d]2026-04-16
[Exchange] Enrich top 5 hypotheses with ClinicalTrials.gov data [task:1290fb13-d11d-4f40-ac4e-e7660809159d]2026-04-16
[Exchange] Enrich top 5 hypotheses with ClinicalTrials.gov data [task:1290fb13-d11d-4f40-ac4e-e7660809159d]2026-04-02
Spec File

[Exchange] Enrich top 5 hypotheses with clinical trials data via ClinicalTrials.gov API

> ## Continuous-process anchor
>
> This spec describes an instance of one of the retired-script themes
> documented in docs/design/retired_scripts_patterns.md. Before
> implementing, read:
>
> 1. The "Design principles for continuous processes" section of that
> atlas — every principle is load-bearing. In particular:
> - LLMs for semantic judgment; rules for syntactic validation.
> - Gap-predicate driven, not calendar-driven.
> - Idempotent + version-stamped + observable.
> - No hardcoded entity lists, keyword lists, or canonical-name tables.
> - Three surfaces: FastAPI + orchestra + MCP.
> - Progressive improvement via outcome-feedback loop.
> 2. The theme entry in the atlas matching this task's capability:
> F1 (pick the closest from Atlas A1–A7, Agora AG1–AG5,
> Exchange EX1–EX4, Forge F1–F2, Senate S1–S8, Cross-cutting X1–X2).
> 3. If the theme is not yet rebuilt as a continuous process, follow
> docs/planning/specs/rebuild_theme_template_spec.md to scaffold it
> BEFORE doing the per-instance work.
>
> **Specific scripts named below in this spec are retired and must not
> be rebuilt as one-offs.** Implement (or extend) the corresponding
> continuous process instead.

ID: 1290fb13-d11 Priority: 88 Type: one_shot Status: complete

Goal

Enrich the top 5 hypotheses (by composite score) with real clinical trials data fetched from the ClinicalTrials.gov v2 API. Each hypothesis gets structured trial data (NCT ID, title, status, phase, conditions, interventions, sponsor, enrollment, dates, description, URL) stored in the clinical_trials JSON column.

Acceptance Criteria

☑ Top 5 hypotheses have clinical_trials populated with real ClinicalTrials.gov data
☑ Each trial record includes nctId, title, status, phase, conditions, interventions, sponsor, enrollment, dates, URL
☑ Hypothesis pages render clinical trials sections correctly
☑ Work log updated with timestamped entry

Approach

  • Identify top 5 hypotheses by composite_score
  • Build tailored search queries for each hypothesis based on target gene, disease, and mechanism
  • Query ClinicalTrials.gov v2 API, deduplicate by NCT ID
  • Store structured JSON in the clinical_trials column
  • Verify hypothesis pages render the data
  • Work Log

    2026-04-02 14:35 UTC — Slot 13

    • Identified top 5 hypotheses by composite score:
    1. h-9e9fee95 — Circadian Glymphatic Entrainment (score 0.697) → 4 trials
    2. h-de0d4364 — Acid Sphingomyelinase Modulation (score 0.695) → 9 trials
    3. h-2600483e — CYP46A1 Gene Therapy (score 0.693) → 3 trials
    4. h-bdbd2120 — Gamma Entrainment Therapy (score 0.692) → 12 trials
    5. h-9d29bfe5 — Membrane Cholesterol Modulators (score 0.680) → 18 trials
    • Created enrich_clinical_trials.py script using ClinicalTrials.gov v2 API
    • Used multiple tailored search queries per hypothesis for better coverage
    • Ran enrichment with deduplication by NCT ID
    • Verified all 5 hypothesis pages render "Clinical Trials (N)" sections correctly
    • Result: Done — all top 5 hypotheses enriched with 3-18 clinical trials each (46 total unique trials)

    2026-04-16 17:55 UTC — Reopened (Slot glm-5:60)

    • Task reopened due to orphan branch — prior commit d59233e26 was on main but audit couldn't verify
    • Verified prior work: old top 5 hypotheses still have clinical_trials data (4-13 trials each)
    • Rankings shifted significantly since original run — current top 5 are different hypotheses
    • Current top 5 by composite_score:
    1. h-11ba42d0 — APOE4 Lipidation Enhancement (0.845) → already had 16 trials
    2. SDA-2026-04-16-hyp-e5bf6e0d — Metabolic Reprogramming/Senescence (0.790) → enriched with 2 trials (SIRT1, PGC1A, NAMPT)
    3. h-b2aeabb1 — PEA Endocannabinoid Therapy (0.780) → enriched with 11 trials (PEA, PPARA)
    4. SDA-2026-04-02-gap-tau-prop-20260402003221-H001 — LRP1 Tau Uptake (0.725) → enriched with 19 trials (tau immunotherapy, vaccines, antibodies)
    5. SDA-2026-04-16-hyp-daadc5c6 — SASP Modulation (0.710) → enriched with 6 trials (senolytics, NF-kB, senescence)
    • Created enrich_clinical_trials_top5.py with tailored queries per hypothesis
    • LRP1 hypothesis required broader queries (tau immunotherapy, anti-tau therapy) since no direct LRP1 trials exist
    • Verified all 5 hypothesis pages render "Clinical Trials (N)" sections correctly via curl
    • Result: Done — all current top 5 hypotheses enriched (54 total trials across top 5)

    2026-04-16 18:20 UTC — Reopened again (Slot glm-5:60, attempt 2)

    • Task reopened again due to orphan branch — prior commit 279265710 from attempt 1 didn't merge to main
    • Verified all top 5 hypotheses still have clinical_trials data in DB (unchanged)
    • All hypothesis pages render correctly (200 OK, "Clinical Trials" sections present)
    • Committed enrichment script + spec update, pushed to remote
    • Result: Done — commit 279265710 pushed, awaiting merge

    2026-04-21 03:51 UTC — Codex slot 44

    • Re-evaluated the reopened task against current PostgreSQL state after the SQLite retirement reset.
    • Verified current top 5 hypotheses by composite_score all have structured clinical_trials data with required fields populated.
    • Found /hypothesis/{id} was shadowed by an older lightweight route that did not include the clinical trials tab, while the richer clinical-trials-aware route was registered later on the same path.
    • Moved the legacy lightweight handler to /hypothesis-lite/{id} so canonical hypothesis pages render the Exchange clinical trials section.
    • Live API process still showed pool-exhaustion 500s before restart, but the route-table fix is code-scoped and verifiable in-process.

    Payload JSON
    {
      "requirements": {
        "analysis": 7,
        "reasoning": 6,
        "safety": 9
      },
      "completion_shas": [
        "ec0ffccaa4015713a09618906ae525ffb1cf2cfa"
      ],
      "completion_shas_checked_at": "2026-04-21T04:00:22.923216+00:00",
      "_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 (Exchange) ↗