LightRAG retrieval-quality recovery — MC #900176

LightRAG retrieval-quality recovery — MC #900176

Status: LIVE PATCHED / guarded rollout; agent routing and backlog remain disabled Date: 2026-08-23 Worktree: /Users/makinja/system/.claude/worktrees/lightrag-recovery-900176

Verified starting point

The Cloudflare route, authentication, health endpoint, text upload, background processing, and vector write path work. The failure is higher in the stack:

  1. The MC #900165 source is present as a processed full document, two text chunks, and two vector entries.
  2. For the natural query “What does SCR mean in MC 900165 IndyDevDan smart prompting plan?”, the correct chunk ranks third at cosine 0.5319866538.
  3. Retrieval-only output contains the correct definition SCR = simplify/compress/repeat.
  4. Server-side synthesis nevertheless answers Simplify, Clarify, Refine and fabricates /path/to/indidevdan_smart_prompting_plan_section_scr.md.
  5. A generated-answer request poisons a later retrieval-only request for the same query/mode: LightRAG core 1.3.4 computes its response-cache key from only (mode, query), checks that cache before only_need_context, and can therefore return the cached hallucinated answer instead of raw context.
  6. Deployed LightRAG core 1.3.4 accepts only text in POST /documents/text; client-supplied metadata is silently ignored, so current text uploads become unknown_source.
  7. The old ingest queue contains 14,006 stale rows. Its adapters and drain worker remain disabled and must not be enabled or drained as part of this recovery.

Root-cause evidence: /Users/makinja/system/evidence/lightrag-test-2026-08-23/root-cause-after-client-fix.json.

Decision

Repair retrieval and provenance without trusting LightRAG’s answer generator and without mutating the existing corpus destructively. Build and validate against an isolated blue/green canary corpus first. Agent routing remains disabled until the quality gate passes.

Build scope

W1 — Provenance contract

W2 — Agent-safe retrieval

W3 — Evaluation

W4 — Blue/green canary corpus

Non-goals

Acceptance criteria

  1. All changed JavaScript parses and relevant tests pass.
  2. Every new canary document has deterministic source provenance in retrieved context.
  3. The MC #900165 exact query returns the correct source and SCR = simplify/compress/repeat without server synthesis or invented citations.
  4. Controlled-corpus Recall@5 is at least 0.80, provenance coverage is 100%, and exact canaries have zero fabricated references.
  5. Context is bounded and retrieval failures remain non-blocking for agents.
  6. Live LightRAG volumes and the 14,006-row stale queue are unchanged by the canary run.
  7. Pi/Claude global LightRAG routing remains disabled until independent verification passes.
  8. Builder and independent validator evidence are recorded before MC #900176 can move to review.

Rollback

Code rollback is one commit revert. Canary rollback is docker compose down against the dedicated canary compose project; its separate named volumes can be preserved for evidence or deleted only with explicit approval. For the live server cache patch, rollback requires reverting the patch commits and force-recreating only the lightrag container from the image; a plain restart retains the already-patched container filesystem. Live data volumes must never be removed.

AFTER — implementation and guarded live deployment

Shipped

Live commits: c55a98599, a92d8868c, 5010a8ccc, b6d3ad7d6, 79778b950, 2dbebc585, 82eb4641d, 61d23a9df.

Verification

Primary evidence:

Deliberately not enabled

The safe on-demand command is:

node ~/system/tools/lightrag.js safe-query "question" --json

Only this retrieval-only path is approved for advisory use. Generated lightrag.js query answers remain untrusted.


Revision #4
Created 2026-08-23 20:27:59 UTC by John
Updated 2026-08-23 22:36:37 UTC by John