Repository navigation
fix: zcode exit handoff covers a route written by an in-flight watchdog replacement - #64
Conversation
…og replacement A watchdog replacement tick writes the new route, awaits plugin activation, and only then updates state.origin. A signal in that interval ran the exit handoff with the old origin, got "not-ours", and exited leaving the store pointed at the replacement. A tick still blocked in ensure could also write its route after the handoff had finished. The tick now records the origin it is routing to before it writes, and the exit handoff tries that origin when the adopted one is not the store's owner. Starting the handoff marks the watchdog stopped, and a tick that finds itself stopped after ensure no longer re-routes. The signal path still does not wait for the tick; exit codes 130/143 and the 5000 ms deadline are unchanged. Refs #14 Assisted-by: Cindy (https://cindy.app)
📦 Built Package ArtifactBranch: Download artifact
tar xzf billion-context-pr64.tgz
npm install -g packageInstall instructions are refreshed on each push. |
| const exits: number[] = []; | ||
| let routes = 0; | ||
| const state = { origin: OLD, failures: 2, policy: defaultZcodeRoutePolicy() }; | ||
| await routeZcodeConfig({ origin: OLD, dataDir: dir, log: () => {} }); |
There was a problem hiding this comment.
(ai: openai/gpt-6-astra)
WARNING: Isolate the real store helpers from ambient path overrides
If the test process inherits ZCODE_PERSONAL_PROVIDER_CONFIG_FILE pointing to a valid personal store with a routable custom provider, this call rewrites that real store rather than the scratch fixture. routeZcodeConfig defaults to process.env, and zcodeStoreCandidates explicitly places that override ahead of dataDir (src/zcode/json-edit.ts:64-78); neither test preload clears it. The calls at lines 145 and 153 inherit the same override, so the test can subsequently unroute the real store and remove its routing snapshots while still passing. Pass an isolated env: {} consistently to both routing calls and the handoff, and pass the same environment to every detectCurrentZcodeOrigin assertion, so all reads and writes stay inside the fixture.
| if (ownOrigin === undefined) break; | ||
| tried.add(ownOrigin); | ||
| const outcome = await (deps.handoff ? deps.handoff(ownOrigin) : handoffZcodeRoutingOnExit({ ownOrigin, log })); | ||
| if (outcome !== "not-ours") break; |
There was a problem hiding this comment.
(ai: openai/gpt-6-astra)
WARNING: Add the required negative assertion for the fallback gate
There is no test with both state.origin and a distinct state.routing populated where the first handoff succeeds and the fallback must not run. The new activation case exercises only not-ours followed by fallback; the ensure case and existing single-handoff tests have no pending routing origin. Consequently, removing this success short-circuit would still satisfy their assertions even though it permits a second handoff after a successful transfer. AGENTS.md:53 and the development contract's gate-test discipline require both directions. Add a case with both origins present, return handed-off or reverted-direct for the first origin, and assert that the handoff receives only that origin.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Reviewed the incremental test changes from Files Reviewed (2 files)
Previous Review Summary (commit e98be94)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit e98be94)Status: 2 Issues Found | Recommendation: Address before merge Reviewed both changed files at Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Fix these issues in Kilo Cloud (ai: openai/gpt-6-astra) Reviewed by gpt-6-astra · Input: 33 · Output: 3.1K · Cached: 421.2K Review guidance: REVIEW.md from base branch |
…llback Review of #64: the real-store tests now pass an isolated env to every routing, handoff and read call, so an ambient personal-store override cannot redirect them. Two new cases pin the fallback to the in-flight routing origin: it runs when the adopted origin is not the owner, and does not run after a successful handoff. Refs #14 Assisted-by: Cindy (https://cindy.app)
|
(ai: anthropic/claude-fable-5-2) Correction to this PR's body, after review with the owner on 2026-11-14.
|
(ai: anthropic/claude-fable-5-2)
Closes #14
Decisions for the owner
This PR makes three behaviour choices. They are the conservative options as I read #14, but they are yours to confirm:
What this changes
src/zcode/mcp-entry.tsonly.state.routing) before it writes, and clears it once that origin is adopted asstate.origin.state.originfirst; if the store is not owned by it, it triesstate.routing. Each origin is tried once.state.stopped. A tick that finds itself stopped after proxy start-up logs that and skips the re-route.handofftest seam now receives the origin it is asked to hand off.Exit codes 130 and 143, the 5000 ms deadline, and the single-handoff guarantee are unchanged.
Evidence
Two new tests in
tests/zcode-mcp-eof.test.tsrun the realrouteZcodeConfigandhandoffZcodeRoutingOnExitagainst a scratch store, with the watchdog tick suspended by a controlled promise and SIGTERM delivered through the injected event source:9d4bda8e5)tests/zcode-mcp-eof.test.ts11 of 11,tests/zcode-mcp-entry.test.ts9 of 9,tests/zcode-mcp-degraded.test.ts6 of 6,tests/zcode-native.test.ts35 of 35 (Windows 11, Node v24.14.0).tsc --noEmitclean.third consecutive failure respawns a dead lane proxy (#1821)and its neighbours intests/zcode-mcp-entry.test.tsstill show a normal replacement re-routing when no shutdown is in progress.Limits
Assisted-by: Cindy (https://cindy.app)