Repository navigation
fix: isolate the daemon test's home and drop the dead peer prompt outcome - #11
Conversation
…home The daemon sends a peer server's prompt outcome as the frame it received, keyed by `type`, but the wrapper still read the runner's `t` field, so another server's failed prompt never notified. The test fed the old shape and hid it. daemon-runtime.test.mjs set HOME at runtime, which Bun's os.homedir() ignores, so the daemon applied cluster configuration into the real ~/.agents and failed where that is a symlink. The test now mocks homedir. Also drops hub.ts's dead check for the runner's hello/session frames. Closes #6
pi never prints prompt_result or prompt_error: it refuses a message command only in that command's response. The daemon now forgets every command at its response and, when pi refuses a message command, tells the other members as a prompt_error peer outcome, so the elected notifier reports the failure. The daemon's routing of child prompt_result/prompt_error frames, which nothing produces, is gone, and with it the message-command entries it kept for them for the channel's life.
Also drops hub.ts's remaining runner `"t"` prefilter and the stale `{t, outcome}` doc.
pi refuses a message command only in that command's response, and the owning server does not notify for its own refusal. Fanning a refusal out as a peer prompt_error made the elected notifier report "Run failed" for a prompt pi merely declined (a bare prompt during another server's run, a compaction) and drop the next completed notice. A refusal now reaches only the server that sent it; the frame, its consumer and their tests are gone.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Closes #6.
Summary
lib/hosts/daemon-runtime.test.mjssetHOMEat runtime, but Bun'sos.homedir()keeps theHOMEit started with. The daemon therefore applied cluster configuration into the real~/.agents, and nine tests failed on machines where that directory is a symlink. The test now mocksnode:oshomedir. The file runs in its own process underbun test --parallel, so the mock needs no restore.tfield frompeer_prompt_outcome, so that path never fired. It cannot fire under pi either: pi never printsprompt_resultorprompt_error, and refuses a message command only in that command'sresponse. Fanning such a refusal out to the other servers would make the elected notifier report "Run failed" for a prompt pi merely declined (a bare prompt during another server's run, or a compaction), and drop the next completed notice. The owning server does not notify for its own refusal either. The frame, its producer, its consumer and their tests are gone.channel.commandswaiting for aprompt_resultthat pi never sends, so every prompt leaked one entry for the channel's life. Every owner is now forgotten at itsresponse.bash_execution_updaterouting is unchanged, because pi answersbashonly after it finishes.hub.tsno longer prefilters or matches the runner's"t":"hello"/"t":"session"lines.The other test files #6 listed already match
pi --mode rpc(no{t: ...}frames orompweb-ompreferences remain).v10-upgrade.integration.test.mjsno longer exists.Verification
npm run release:checkat7d60093: typecheck, lint (0 errors), 4116 tests passing, build and smoke all succeed. At8f7737b: typecheck, lint and the full test suite (4115 pass, 0 fail). Build and smoke are left to CI.Review
Review round 1 (full): adversarial
Scope:
09b43b6e1..7d60093c6(whole change). Tool: adversarial-review.lib/hosts/daemon-channels.ts:366ttotyperename has no effect end to end: pi never emitsprompt_result/prompt_error, so the daemon never builds a peer outcome.lib/hosts/daemon-channels.ts:359channel.commandsfor aprompt_resultthat never comes: one leaked entry per prompt.lib/hosts/hub.ts:1391type:"session"branch is dead under pi as well.lib/hosts/hub.ts:1350"t":"hello"/"t":"session".lib/hosts/link-protocol.ts:69{t, outcome}doc.Mutations: reverting the consumer rename turned the rpc-manager test red; removing the
homedirmock with a symlinked.agentsfailed 9 tests and wrote nothing into the symlink's target.Not checked: Windows
USERPROFILEbehaviour.Review round 1 (full): code review
Scope:
09b43b6e1..7d60093c6(whole change). Tool: code-review-and-quality.lib/hosts/daemon-channels.ts:366lib/notification-events.ts:145prompt_resultstatusbranch is never reached under pi.prompt_result(agentInvoked:false). Left for the planned cleanuplib/hosts/link-protocol.ts:69Not checked: CI.
Review round 1 (full): simplification
Scope:
09b43b6e1..7d60093c6(whole change). Tool: code-simplification.lib/hosts/daemon-runtime.test.mjs:13process.env.HOME.Not using
tests/mock-builtin.mjswas confirmed correct: the mock must run at module top level, before the daemon is imported and outside any test.Review round 2 (light): code review
Scope:
7d60093c6..50621b1b2(since the last reviewed head). Tool: code-review-and-quality.lib/hosts/daemon-channels.ts:364prompt_errormakes the elected notifier report "Run failed" for a refusal (a bare prompt during a run, a compaction,/rename), suppresses the next completed notice, and differs from the owner, which never notifies a refusal.lib/hosts/daemon-channels.test.mjs:238promptwith both members present.Forgetting message-command owners at their response was confirmed safe for
bash,linkGone, channel-lifecycle, extension commands and the write-failure path.Review round 3 (light): code review
Scope:
50621b1b2..8f7737bd4(since the last reviewed head). Tool: code-review-and-quality, by the author.Round head
8f7737bd47cb46002a86a97bb33724bc105dac39. Rounds used: 3 of 3 after the first full review. No further round is due unless a High finding appears.Summary by CodeRabbit