docs(backends): architecture guide + Codex cache invalidation - #178
Merged
Conversation
claudiusthebot
enabled auto-merge (squash)
May 16, 2026 00:13
Two improvements:
1. **`docs/backends.md`** β comprehensive guide to Talon's backend
architecture:
- Backend selection matrix (claude/kilo/opencode/codex).
- `backend/shared/` helper inventory + what each does.
- `backend/remote-server/` for HTTP-server backends (Kilo +
OpenCode shared infrastructure).
- Full `QueryBackend` interface annotated.
- Per-backend implementation notes (transport, auth, MCP wiring).
- "Adding a new backend" walkthrough β minimum surface + wiring
+ factory registration + config schema + tests.
- Backend conformance tests rationale.
2. **Codex cache invalidation on re-init.** `initCodexAgent` now
clears `state.codex = null` so a follow-up call (e.g. plugin
reload, hot-reload, test isolation) doesn't return a stale Codex
instance built with the previous MCP / API-key / frontend config.
The next `ensureCodex(chatId)` rebuilds from scratch.
Tests: 2305 passing, 12 skipped, 0 failing.
claudiusthebot
force-pushed
the
feat/codex-polish-3
branch
from
May 16, 2026 00:14
ae0f898 to
46e0c1a
Compare
claudiusthebot
added a commit
that referenced
this pull request
May 16, 2026
9 new tests in `codex-init.test.ts` covering the Codex backend's state-lifecycle invariants that aren't exercisable through the factory test alone: - `ensureCodex` throws if called before `initCodexAgent` - Same chat id β cached instance returned - Different chat id β fresh instance built - Same chat id after chat-switch β cached again - `initCodexAgent` re-invocation invalidates the cached instance (this is the new behaviour from `docs/backends.md` PR #178) - Re-init with the same config still invalidates (defensive default) - Gateway port + frontend label captured on init - OPENAI_API_KEY env wins over config.openaiApiKey - Falls back to config.openaiApiKey when env is absent - Uses env-only when no config key provided Total: 2314 passing (was 2305), 12 skipped (live), 0 failing. tsc clean, lint 0 errors / 15 pre-existing warnings.
claudiusthebot
added a commit
that referenced
this pull request
May 16, 2026
9 new tests in `codex-init.test.ts` covering the Codex backend's state-lifecycle invariants that aren't exercisable through the factory test alone: - `ensureCodex` throws if called before `initCodexAgent` - Same chat id β cached instance returned - Different chat id β fresh instance built - Same chat id after chat-switch β cached again - `initCodexAgent` re-invocation invalidates the cached instance (this is the new behaviour from `docs/backends.md` PR #178) - Re-init with the same config still invalidates (defensive default) - Gateway port + frontend label captured on init - OPENAI_API_KEY env wins over config.openaiApiKey - Falls back to config.openaiApiKey when env is absent - Uses env-only when no config key provided Total: 2314 passing (was 2305), 12 skipped (live), 0 failing. tsc clean, lint 0 errors / 15 pre-existing warnings.
claudiusthebot
added a commit
that referenced
this pull request
May 16, 2026
β¦#179) * test(codex): init lifecycle + cache invalidation + API-key resolution 9 new tests in `codex-init.test.ts` covering the Codex backend's state-lifecycle invariants that aren't exercisable through the factory test alone: - `ensureCodex` throws if called before `initCodexAgent` - Same chat id β cached instance returned - Different chat id β fresh instance built - Same chat id after chat-switch β cached again - `initCodexAgent` re-invocation invalidates the cached instance (this is the new behaviour from `docs/backends.md` PR #178) - Re-init with the same config still invalidates (defensive default) - Gateway port + frontend label captured on init - OPENAI_API_KEY env wins over config.openaiApiKey - Falls back to config.openaiApiKey when env is absent - Uses env-only when no config key provided Total: 2314 passing (was 2305), 12 skipped (live), 0 failing. tsc clean, lint 0 errors / 15 pre-existing warnings. * feat(cli): make \`talon doctor\` backend-aware Previously `talon doctor` always checked for the Claude Code CLI on PATH, even when the active backend was `kilo` / `opencode` / `codex`. Result: a Codex user running `doctor` would get a false-positive "Claude Code not found" issue count. Now the doctor reads `backend` from the config and checks the right thing: - `claude`: looks for `claude` on PATH (or honours `claudeBinary` config). Same as before. - `codex`: looks for `codex` on PATH (`npm i -g @openai/codex` hint if missing). Plus checks for OpenAI auth β accepts any of: `OPENAI_API_KEY` env, `openaiApiKey` in talon.json, or `~/.codex/auth.json` (left behind by `codex login`). - `kilo` / `opencode`: notes that the SDK is bundled (no external binary to check). `Config` type in cli.ts gained `backend?: ... | "codex"` and `openaiApiKey?: string` to match the runtime schema in `util/config.ts`. Tests: 2314 passing (unchanged), 12 skipped, 0 failing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
docs/backends.mdwith full backend-architecture documentation (backend selection matrix, shared helpers inventory, remote-server family, QueryBackend interface annotated, per-backend notes, adding-a-new-backend walkthrough). Also fixes a subtle bug where re-initialising the Codex backend would keep returning a stale cachedCodexinstance βinitCodexAgentnow clearsstate.codex = nullso the nextensureCodex(chatId)rebuilds with the new config.Test plan
π€ Generated with Claude Code