Skip to content

Recompile failure on source delete leaves page live with stale content #8

@tuirk

Description

@tuirk

Scenario

A wiki page is built from 3 sources. You delete source #1. The system needs to rewrite the page using only sources #2 and #3, so it no longer reflects source #1's material. That rewrite calls Gemini — an external API that can fail.

Outcomes today

Rewrite succeeds: page gets fresh content from sources #2 + #3. ✅

Rewrite fails (Gemini timeout, rate limit, transient network, etc.) — app/src/app/api/sources/[source_id]/route.ts#L281-L298:

  • Leaves the old page body untouched
  • Appends a footer: Source "X" deleted on YYYY-MM-DD. Rewrite failed.
  • Decrements source_count by 1
  • Logs page_recompile_failed

The page stays visible in the wiki — same title, same position, same content. The only hint anything went wrong is the footer line.

Why this is a problem

The page body still contains material from the deleted source. The user asked the system to remove that source, but its content is still on the page:

  • Chat retrieval will still surface it
  • FTS search will still return it
  • Graph view still shows it live
  • Related-pages still link to it

Proposed behavior — "archive on failure"

Instead of leaving the page live with stale content, hide it:

  • Flip page_type to archived (or let the derived-archive mechanism handle it)
  • Page disappears from the default wiki view
  • Still reachable via "Show Archived" toggle
  • Next successful recompile (manual trigger or retry job) restores it

Simpler framing: "can't rewrite it right now → hide it until we can" instead of "can't rewrite it → leave the wrong version up and hope someone notices the footer."

Open design questions

  1. Archive on first failure, or retry first? Archiving immediately is safer but annoying on transient Gemini blips. Retry-with-grace-period needs a retry queue that doesn't exist yet.
  2. What triggers the un-archive? Manual recompile only, or a background retry job?
  3. Visible degraded badge as a middle ground? Keep page live but stamp a warning banner that the content is stale. Less aggressive than archiving, more visible than a footer.

Related

  • The successful recompilePage path already archives correctly when no sources remain (app/src/lib/recompile.ts#L125-L129).
  • Short-source delete (< 500 chars, >= 2 remaining) intentionally skips recompile — not in scope here.
  • Single-source delete (remainingCount <= 1) hard-deletes the page — working as intended.

Status

Known issue. Deferred pending design decision on #1–#3 above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingup-for-grabsMaintainer isn't actively working on this — open for anyone to pick up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions