Fix ACP topology marker publication race - #2571
Merged
ymichael merged 1 commit intoAug 27, 2026
Merged
Conversation
ymichael
deleted the
bb/ci-flake-fix-acp-topology-empty-sigterm-marker-thr_hipd56hdqv
branch
August 27, 2026 18:42
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.
Human comments
What was wrong
On the independently verified fresh-main baseline
54d6e3ee64f073872766a09a70a474999acb9f68, the ACP topology test treated existence of the fake agent's SIGTERM marker as completed publication and immediately read it.writeFileSync(path, data)creates or truncates the final pathname before writing its bytes, so scheduler contention could let the test observe that intermediate zero-length file. Tagged instrumentation reproduced the exact main CI failure: every empty first read became"SIGTERM\n"shortly afterward, with exactly one fake-agent launch. The runtime timeout and release behavior were correct; the fixture exposed an incomplete marker as if it were complete.What changed
The fake ACP agent now writes the SIGTERM marker to a same-directory, PID-specific staging file and atomically renames it to the observed path only after the marker bytes are complete. Existence of the final path is therefore a real completion boundary, while the existing topology test still covers the 300 ms construction timeout, best-effort release, real SIGTERM lifecycle, child exit, and live bridge. No test clock or assertion changed. PR #2552 changes intentional-stop connection state but retains the same SIGTERM and does not touch this fake-marker seam, so the fixes do not conflict or duplicate one another. This changes no server/daemon wire data, CLI, configuration, or public plugin contract, so no
HOST_DAEMON_PROTOCOL_VERSION, guide, or API documentation update is required.How you verified
expected '' to contain 'SIGTERM'; after, 64/64 passed with zero failures. A tagged diagnostic run reproduced 12/64 exact failures and proved each empty first read later contained"SIGTERM\n"with one child launch.pnpm exec turbo run test --filter=@bb/agent-runtime --force -- --run src/runtime.acp-topology.test.ts -t "releases the thread on the bridge when a construction times out on the runtime's side"— 1 test passed.pnpm exec turbo run test --filter=@bb/provider-bridge-acp --force -- --run src/bridge/bridge.test.ts -t "releases a session still under construction: the agent is reaped and the pending thread/start fails"— 1 focused lifecycle test passed.pnpm exec turbo run test --filter=@bb/agent-runtime --filter=@bb/provider-bridge-acp --force— agent-runtime 22 files / 318 tests and ACP bridge 17 files / 295 tests passed.pnpm exec turbo run typecheck --filter=@bb/agent-runtime --filter=@bb/provider-bridge-acp --force— passed.pnpm exec turbo run build --filter=@bb/agent-runtime --filter=@bb/provider-bridge-acp --force— applicable Turbo build graph passed.pnpm exec prettier --check packages/provider-bridge-acp/src/bridge/fake-acp-agent.mjsandgit diff --check— passed; all temporary[DEBUG-acp-marker]instrumentation was removed.