[Atlas] Fix wiki_page artifact links pointing to broken /entity/<slug> URLs

← All Specs

[Atlas] Fix wiki_page artifact links pointing to broken /entity/<slug> URLs

Problem

/entity/convergence-synthesis-neuroinflammation-core (and ~most wiki_page cards on /artifacts?artifact_type=wiki_page) return HTTP 404. The wiki pages themselves
are intact in wiki_pages and render correctly at /wiki/<slug> and /artifact/wiki-<slug> — only the URL emitters are wrong.

Two emitters strip the wiki- prefix from a wiki_page artifact id and route
the resulting slug to /entity/<slug>. The /entity/{name} handler resolves
names against wiki_entities / knowledge_edges / hypotheses, so composite
slugs like convergence-synthesis-, gaps-, mechanisms-, ai-tool-
never match and 404. The existing slug-fallback only catches <type>-<symbol>
shapes whose suffix-after-first-dash matches a wiki_entities.entity_name.

This affects the artifacts gallery and any callsite of _infer_local_url
(exports, atproto/ap publishes, RSS, share links).

Fix

Three edits in api.py:

  • api.py:30034-30037 — artifacts gallery card link: emit /wiki/<slug> instead of /entity/<slug> for wiki_page artifacts.
  • api.py:93134-93136_infer_local_url: same change; this propagates the canonical URL outward to all consumers.
  • api.py:77254 (after the existing slug-fallback block) — /entity/{name} defence-in-depth: when no wiki_entities/KG/hypothesis match exists but wiki_pages.slug = entity_name, 301-redirect to /wiki/<slug>. Catches external bookmarks and any emitter we haven't found.
  • Plus _clear_all_caches() post-deploy (page cache holds entity: and artifacts: keys).

    Acceptance criteria

    • /entity/convergence-synthesis-neuroinflammation-core → 301 → /wiki/convergence-synthesis-neuroinflammation-core (HTTP 200)
    • /entity/gaps-research-priorities → 301 → /wiki/...
    • /entity/mechanisms-er-mitochondria-contact-sites → 301 → /wiki/...
    • Sample of 100 random wiki_page slugs via /entity/<slug> → none return 404
    • /entity/APOE, /entity/MAPT, /entity/TREM2 → still 200 (primary handler unchanged)
    • /entity/genes-foxp3 → still 301 → /entity/FOXP3 (existing <type>-<symbol> fallback runs first)
    • Artifacts gallery /artifacts?artifact_type=wiki_page — every card href targets /wiki/<slug>

    Out of scope (follow-on)

    Duplicate consolidation: 17,470 paired wiki-<slug> + <slug> artifact rows.
    Tracked separately — needs its own audit + LLM-assisted merge plan to avoid
    content loss in differing-title and non-default-metadata cases.

    File: fix-wiki-page-entity-links-2026-05-13_spec.md
    Modified: 2026-05-18 04:17
    Size: 2.6 KB