[Atlas] Cross-link hypotheses to wiki pages via target genes done

← Atlas
Create artifact_links between hypotheses and wiki pages for their target genes. This enables the 'Wiki Pages' section on hypothesis detail pages. Currently hypothesis pages show 'No linked wiki pages' even when relevant wiki content exists. ## 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 (5)

[Atlas] Work log: migration 098 PG compatibility fix results [task:353da173-093c-46eb-a78d-882e1cc29a55]2026-04-20
[Atlas] Fix migration 098 PostgreSQL compatibility: remove sqlite3 dep, %s placeholders, ON CONFLICT DO NOTHING [task:353da173-093c-46eb-a78d-882e1cc29a55]2026-04-20
[Atlas] Work log: migration 098 PG compatibility fix results [task:353da173-093c-46eb-a78d-882e1cc29a55]2026-04-20
[Atlas] Fix migration 098 PostgreSQL compatibility: remove sqlite3 dep, %s placeholders, ON CONFLICT DO NOTHING [task:353da173-093c-46eb-a78d-882e1cc29a55]2026-04-20
Squash merge: orchestra/task/353da173-cross-link-hypotheses-to-wiki-pages-via (1 commits)2026-04-16
Spec File

[Atlas] Cross-link hypotheses to wiki pages via target genes

ID: 353da173-093 Priority: 88 Type: one_shot Status: open

Goal

Create artifact_links between hypotheses and wiki pages for their target genes. This enables the 'Wiki Pages' section on hypothesis detail pages. Currently hypothesis pages show 'No linked wiki pages' even when relevant wiki content exists.

Acceptance Criteria

☐ Concrete deliverables created
☐ Work log updated with timestamped entry

Work Log

2026-04-20 17:47 UTC — PostgreSQL compatibility fix + migration run

Problem: Migration 098 on origin/main used SQLite-specific code (PRAGMA journal_mode=WAL, sqlite3.Row row factory, ? placeholders) that fails on PostgreSQL.

Fix: Updated migrations/098_crosslink_hypotheses_target_genes.py:

  • Removed PRAGMA journal_mode=WAL (PostgreSQL has WAL naturally)
  • Removed sqlite3.Row row factory (PGShimConnection already sets _pg_row_factory)
  • Replaced ? placeholders with %s
  • Replaced INSERT OR IGNORE with INSERT ... ON CONFLICT DO NOTHING
  • Removed cursor = conn.cursor() pattern; use conn directly
Results: Created 1,328 new cross-links (805 wiki→hypothesis + 523 wiki→analysis):
  • Before: 199/581 hypotheses with wiki links
  • After: 524/581 hypotheses with wiki links
  • Remaining hypotheses: those whose parsed genes don't have wiki pages (e.g., lncRNA-9969, non-gene descriptors)
Verification: SELECT COUNT(DISTINCT h.id) FROM hypotheses h JOIN artifact_links al ON al.target_artifact_id = 'hypothesis-' || h.id WHERE al.source_artifact_id LIKE 'wiki-' || '%' → 524

2026-04-16 — Enhanced cross-linking migration

Problem: Migration 033 (crosslink_wiki_hypotheses) used strict exact-match on LOWER(target_gene) and only handled single-gene targets. 137 of 521 hypotheses with target genes were missing wiki links due to:

  • Multi-gene targets (comma-separated: IL10, CSF1R, CD40)
  • Slash-separated complexes (PIKFYVE/MCOLN1/PPP3CB/TFEB)
  • Plus-separated (ABCA7 + TREM2)
  • Dash-separated gene pairs (CSF1R-TREM2)
  • Parenthetical aliases (MFSD2A (SLC59A1))
  • Descriptive qualifiers (CLU-APOE-TREM2 axis (LXR/RXR pathway))
Solution: Created migrations/098_crosslink_hypotheses_target_genes.py with enhanced gene parser that:
  • Splits on comma, slash, plus, and dash separators
  • Strips parenthetical descriptions and trailing qualifiers
  • Matches wiki pages under genes-, proteins-, and entities-* slug prefixes
Results: Created 292 new artifact_links (282 wiki→hypothesis + 10 wiki→analysis).
  • Before: 384/521 hypotheses with wiki links (74%)
  • After: 504/521 hypotheses with wiki links (97%)
  • Remaining 17: genes without wiki pages (HCAR2, GZMB, PADI4, etc.) or non-gene targets ("MULTIPLE", "COMPOSITE_BIOMARKER")

Payload JSON
{
  "_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 (Atlas) ↗