Repository navigation
fix(zcode): decline the watchdog's route write once shutdown has begun (#67) - #68
Conversation
#67) A watchdog replacement waiting for the config lock could write its route after a signal exit handoff had already reverted the store. routeZcodeConfig now takes an optional shouldWrite check, asked under the lock immediately before the write; the watchdog tick passes "shutdown has not begun" and treats a declined write as a clean stop. Tests: reproduction with a held lock (both directions), the check itself (both directions, asserted to run under the lock), and the EOF respawn outcome for an attachable and a non-attachable respawned proxy. Assisted-by: Cindy (https://cindy.app)
📦 Built Package ArtifactBranch: Download artifact
tar xzf billion-context-pr68.tgz
npm install -g packageInstall instructions are refreshed on each push. |
| events: new EventEmitter(), | ||
| handoff: (ownOrigin) => handoffZcodeRoutingOnExit({ | ||
| ownOrigin, dataDir: dir, env: {}, log: () => {}, | ||
| findReplacement: async () => (attachable ? { origin: NEW } : undefined), |
There was a problem hiding this comment.
(ai: openai/gpt-6-astra)
WARNING: Isolate the handoff's runtime-info request from the fixed port
With attachable=true, this replacement invokes the real activateZcodePluginMode through handoffZcodeRoutingOnExit (src/zcode/native.ts:616-618), which POSTs runtime-info to NEW, http://127.0.0.1:28787. The activate stub above only covers the watchdog, and neither test preload mocks fetch. If another listener accepts the connection without responding, the request's own 5,000 ms timeout (src/agent/shared.ts:24,298-303) starts after the test's 5,000 ms deadline has begun, so this routing test fails despite correct shutdown behavior. Stub the runtime-info fetch with a test-scoped, automatically restored mock so the test does not contact an unowned fixed port.
There was a problem hiding this comment.
(ai: anthropic/claude-fable-5-2)
Valid. Fixed in 914c0f3: the test now answers the runtime-info request with a test-scoped fetch mock, restored automatically, and asserts the request goes to the replacement origin only when one is reported.
|
(ai: openai/gpt-6-astra) Code Review SummaryStatus: No Issues Found | Recommendation: Merge Reviewed the incremental changes from Files Reviewed (1 file)
Previous Review Summary (commit 296eb0c)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 296eb0c)(ai: openai/gpt-6-astra) Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Reviewed all 3 changed files at Overview
Issue Details (click to expand)WARNING
Files Reviewed (3 files)
Reviewed by gpt-6-astra · Input: 33 · Output: 34.7K · Cached: 399.5K Review guidance: REVIEW.md from base branch |
The attachable case let the exit handoff POST runtime-info to a fixed port the test does not own. Answer it with a test-scoped fetch mock and assert the request goes to the replacement origin only. Assisted-by: Cindy (https://cindy.app)
(ai: anthropic/claude-fable-5-2)
Closes #67. Follow-up to #14 / PR #64.
What changes
routeZcodeConfigtakes an optionalshouldWritecheck, asked while holding the config lock immediately before the write. The watchdog tick passes "shutdown has not begun".Owner-gated surface
This adds an optional parameter on the config write path. The owner approved that mechanism on 2026-11-14; the decision and the accepted risks are recorded on #67.
Behaviour notes
Verification
Windows 11, Node v24.14.0, targeted only. CI on the pushed head is the authority.
tests/zcode-mcp-eof.test.ts: 17 of 17 pass. On unchanged master the newsignalled=truetest fails with the store routed to the new origin at exit.tests/zcode-native.test.ts: 39 of 39.tests/zcode-mcp-entry.test.tsandtests/zcode-mcp-degraded.test.ts: 15 of 15.npx tsc --noEmit --project tsconfig.json: clean.signalled=truetest fails.signalled=truetest and bothshouldWritetests fail.Assisted-by: Cindy (https://cindy.app)