think
16px
820px

Integration prompt — ai-ahu-chatbot: delete the dead RAG /sessions passthrough (close the last DMZ→Internal thread-history call)

Paste into a Claude Code session inside the ai-ahu-chatbot repo. This is a small cleanup, not a feature. It removes a dead cross-zone call path — there is no gateway change and no new behavior for real users.

Why (read first — this is a deletion, verified dead)

The public-web thread-history routes still contain a legacy passthrough to ai-ahu-document-rag's /sessions endpoints. That path is dead on three independent counts, so it should be removed rather than kept (or proxied):

  1. The RAG endpoints are stubs. In ai-ahu-document-rag, GET /sessions and GET /sessions/{session_id}/runs both return [] — not implemented, no data.
  2. Thread history already moved to the local ThreadStore (2026-07-08): both routes read an authenticated user's real history from getThreadStore() (written by /api/orchestrate, ownership-enforced). The RAG calls are already labelled "legacy … stays for cookie-less callers."
  3. The UI never triggers the RAG branch. apps/public-web/src/components/chat/doc/TanyaSidebar.tsx gates loadThreads("doc") to Akun users only (the isAnon guard) — the cookie-less branch that reaches RAG is unreachable from the app.

Post production-split, public-web runs in the DMZ and RAG in Internal; that legacy fetch is a latent DMZ→Internal call. Since it's dead and already superseded, deleting it closes the zone boundary properly — no /search-style gateway proxy needed for a path with no data and no caller. (We chose delete over proxy deliberately: proxying would add surface to keep a dead path alive across the boundary.)

Behavior change for real users: none. Cookie-less callers already got [] (RAG returns [], and the catch blocks return [] on any failure), and the UI never routes there. This only removes the cross-zone fetch attempt.

Scope — two route files

1. apps/public-web/src/app/api/threads/doc/route.ts (GET — thread list)

Keep the authenticated (Akun) branch exactly as-is: valid PUBLIC_SESSION_COOKIEgetThreadStore().listThreads(session.email) → map to Thread[] → return.
Remove the trailing cookie-less RAG passthrough (the try { fetch(${UPSTREAM}/sessions?...) … } catch { return NextResponse.json([]) } block). Replace the whole cookie-less tail with a direct honest empty response:

  // No account session → no server-side history. (Real history is per-account,
  // in the local ThreadStore; the RAG /sessions passthrough was a dead
  // cross-zone path — stub upstream, UI never routed guests here — removed to
  // close the DMZ→Internal boundary.)
  return NextResponse.json([] as Thread[]);

2. apps/public-web/src/app/api/threads/doc/[id]/route.ts (GET — one thread's history)

Keep the Akun branch (getThreadStore().getMessages(id, session.email){ id, history }).
Remove the cookie-less fetch(${UPSTREAM}/sessions/${id}/runs) passthrough and replace its tail with:

  return NextResponse.json({ id, history: [] });

3. Clean up what those deletions orphan (let the typechecker guide you)

  • The UPSTREAM const + the NEXT_PUBLIC_DOC_RAG_API_URL / NEXT_PUBLIC_AGNO_API_URL reads in these two files (delete the const; it's now unused here).
  • Now-unused imports in these two files: mapSessionToThread, unwrapList, ServerSession, runToMessages, ServerRun (from @ahu/ui/lib/threads-upstream).
  • Then check whether @ahu/ui/lib/threads-upstream has any remaining importer (grep -rn "threads-upstream" apps packages). If these two routes were its only consumers, delete the lib (and its test) too — dead code. If anything else imports it, leave it.
  • Do NOT blindly delete NEXT_PUBLIC_DOC_RAG_API_URL / NEXT_PUBLIC_AGNO_API_URL from .env* / compose files yet — first confirm nothing else references them (grep -rn "NEXT_PUBLIC_DOC_RAG_API_URL\|NEXT_PUBLIC_AGNO_API_URL" apps packages infra). Note that NEXT_PUBLIC_AGNO_API_URL may be used by the DataTool/agent path — if so, keep it. Remove only env entries that end up with zero references, and say which you removed.

Verification

  • pnpm check green (typecheck will fail loudly on any orphaned import you missed — that's the safety net).
  • grep -rn "/sessions" apps/public-web/src returns no runtime fetch to a RAG /sessions* path (comments/docstrings referencing the history are fine to leave or tidy).
  • Sanity: with an Akun cookie, /api/threads/doc and /api/threads/doc/[id] still return the local ThreadStore history unchanged; without a cookie, both return empty ([] / {id, history: []}) with no outbound RAG call.

Report back

The two routes trimmed; whether threads-upstream (+ test) was orphaned and deleted or kept (and why); which NEXT_PUBLIC_* env entries you removed vs. kept (with the reference that kept them); and confirmation pnpm check is green and no runtime /sessions fetch remains.