Skip to content

Stop ACP inbound dispatch after kill - #2594

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-acp-inbound-requests-after-stop-thr_ymtw8zyhrt
Aug 27, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-acp-inbound-requests-after-stop-thr_ymtw8zyhrt

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

AcpAgentConnection.kill() synchronously stopped bb-to-agent writes, but the ACP stdout listener continued dispatching agent-to-bb JSON-RPC while the child was terminating. An ACP agent could emit a request such as fs/write_text_file from its SIGTERM handler and have bb execute it after the owning session had already been released.

What changed

Added an early stopping guard at the shared ACP stdout-listener boundary, before inbound messages are parsed or classified as responses, requests, or notifications. Updated the lifecycle coverage and added a real-child regression whose SIGTERM handler emits a write request; the test proves neither the request callback nor its filesystem mutation occurs after kill(). No server/daemon wire contract changed, so HOST_DAEMON_PROTOCOL_VERSION remains unchanged.

How you verified

  • Before the production guard, the focused real-child regression failed deterministically on three runs with one post-stop request dispatch and a created late-write.txt file.
  • After rebasing onto current origin/main, force-ran the focused SIGTERM regression three times: all three passed with no cache reuse.
  • Ran pnpm exec turbo run test --filter=@bb/provider-bridge-acp --filter=bb-plugin-provider-acp --force: 299 bridge tests and 76 provider-plugin tests passed.
  • Ran pnpm exec turbo run typecheck --filter=@bb/provider-bridge-acp --filter=bb-plugin-provider-acp --force: passed.
  • Ran pnpm exec turbo run build --filter=@get-bb/plugin-sdk --force: all 17 runtime entries built.
  • Ran targeted oxfmt --check, git diff --check, and a debug-marker search successfully.

AGENT GENERATED

AcpAgentConnection kept dispatching parsed stdout messages after kill latched the stopping state, allowing a SIGTERM-time request to mutate a released workspace. Drop inbound protocol lines while stopping and cover the real child-process race.
@ymichael
ymichael merged commit b629714 into main Aug 27, 2026
15 checks passed
@ymichael
ymichael deleted the bb/fix-acp-inbound-requests-after-stop-thr_ymtw8zyhrt branch August 27, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant