feat(codex): factory cleanup hook, conformance parity, log line parity - #177
Merged
Conversation
β¦ line Three small parity improvements building on the Codex backend foundation (#174, #175, #176): 1. **Cleanup hook in codex factory.** Kilo/OpenCode return a `cleanup: stopServer` callback from their factory `init` so the dispatcher can clean up on hot-reload or shutdown. Codex now returns a `cleanup` that calls `resetCodexState()` β clearing the cached Codex instance + frontend label + gateway port. Each `runStreamed` spawns a fresh subprocess so there's no long-lived server to stop, but resetting the module-scoped state matters for test isolation and future hot-reload paths. 2. **Backend conformance expanded to cover Codex.** Two of the four conformance tests (`routeDelivery` route parity + synthetic-error label prefix) now drive all three remote-route-using backends (Kilo / OpenCode / Codex) through the same shared `routeDelivery` helper and assert identical decisions + identical `β οΈ <Backend>: <msg>` formatting. The MCP-rotation + SSE event tests stay Kilo/OpenCode-only since Codex's MCP wiring is constructor-time TOML, not HTTP-API registration. 3. **Codex model-resolution log line.** Kilo emits `[chatId] Kilo model resolved: provider=X model=Y`; OpenCode emits the same. Codex now emits `[chatId] Codex model resolved: <model>` on every turn so the agent log has a uniform per-turn fingerprint across all four backends. Tests: 2305 passing, 12 skipped (live-tier), 0 failing.
claudiusthebot
enabled auto-merge (squash)
May 16, 2026 00:08
dylanneve1
pushed a commit
that referenced
this pull request
May 16, 2026
Two new test cases covering the factory wiring blind spots: 1. **Cleanup hook resets state for hot-reload** β verifies that the `cleanup` callback returned from `factory.init()` properly resets the module-scoped state (config + codex instance both null'd). Without this test, a regression that swallowed the resetState() call would silently leak state across hot-reloads. 2. **Init twice with different config re-populates without leakage** β verifies that re-running `init()` with a different frontend/port fully overwrites prior state. Catches the class of bug where one field gets re-set but another lingers from the previous init. Together these close the testable surface of the codex factory beyond the initial registration + method-presence checks (which #176 + #177 already cover). 8/8 codex-factory tests pass locally. π€ Generated with Claude Code (claude.com/claude-code)
claudiusthebot
added a commit
that referenced
this pull request
May 16, 2026
Two new test cases covering the factory wiring blind spots: 1. **Cleanup hook resets state for hot-reload** β verifies that the `cleanup` callback returned from `factory.init()` properly resets the module-scoped state (config + codex instance both null'd). Without this test, a regression that swallowed the resetState() call would silently leak state across hot-reloads. 2. **Init twice with different config re-populates without leakage** β verifies that re-running `init()` with a different frontend/port fully overwrites prior state. Catches the class of bug where one field gets re-set but another lingers from the previous init. Together these close the testable surface of the codex factory beyond the initial registration + method-presence checks (which #176 + #177 already cover). 8/8 codex-factory tests pass locally. π€ Generated with Claude Code (claude.com/claude-code)
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.
Summary
Three small parity improvements building on the Codex backend foundation (#174, #175, #176):
Cleanup hook in codex factory. Kilo/OpenCode return a
cleanup: stopServercallback from their factoryinitso the dispatcher can clean up on hot-reload or shutdown. Codex now returns acleanupthat callsresetCodexState()β clearing the cached Codex instance + frontend label + gateway port. EachrunStreamedspawns a fresh subprocess so there's no long-lived server to stop, but resetting the module-scoped state matters for test isolation and future hot-reload paths.Backend conformance expanded to cover Codex. Two of the four conformance tests (
routeDeliveryroute parity + synthetic-error label prefix) now drive all three remote-route-using backends (Kilo / OpenCode / Codex) through the same sharedrouteDeliveryhelper and assert identical decisions + identicalβ οΈ <Backend>: <msg>formatting. The MCP-rotation + SSE event tests stay Kilo/OpenCode-only since Codex's MCP wiring is constructor-time TOML, not HTTP-API registration.Codex model-resolution log line. Kilo emits
[chatId] Kilo model resolved: provider=X model=Y; OpenCode emits the same. Codex now emits[chatId] Codex model resolved: <model>on every turn so the agent log has a uniform per-turn fingerprint across all four backends.Tests
2305 passing, 12 skipped (live-tier), 0 failing.
π€ Generated with Claude Code