Repository navigation
fix(provider-acp): commit the approval artifact with its runtime request - #21
Conversation
The ACP adapter emitted node.updated, then runtime_request.updated, then turn_item.updated. The ingestor buffers a request artifact that arrives before its request and commits both in one write, but an artifact that arrives after its request is a second write guarded by writeIfRuntimeRequestCurrent. That guard compares the request's current status against the caller's snapshot, so once the request has been answered the artifact write is dropped without an error and the approval card never reaches the user. Emit the turn item before the runtime request so the artifact is buffered and committed atomically with the request it belongs to, which is what the sibling buffer already does for the node. Adds a regression test that asserts the approval artifact is emitted before the pending runtime request.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
… (follow-up to #21) (#22) ACP adapter 之外的另外四个 adapter(Claude / Muse / OpenCode2 / Pi)有与 #21 相同的 latent 竞争:审批 turn item 发在它所属的 runtime request 之后,审批卡落到第二次独立写,被 request 状态守卫(runtimeRequestIsCurrent)静默丢弃 —— 用户点「允许」后卡片可能当场消失。 上游 pingdotgg/t3code 至今仍是 request 在前(Muse 929→934→935、Pi 1178→1184→1189、OpenCode2 v2 1637→1643、Claude 同理),故这不是上游会自行修掉的项,fork 侧必须自己带。 改法与 #21 一致:恢复代码库约定的 node.updated → turn_item.updated → runtime_request.updated,artifact 与 request 原子提交。gate 语义未改动。 🤖 由 GitHub 运维巡查自动合并
Summary
mainwas red onTest Server 1for the same test in both attempts of run39264953410:The approval card's turn item was never persisted. The runtime request itself was created and
resolved (
status === "resolved",decision === "accept"), and every other assertion in thefixture passed, so the loss was isolated to one turn item.
Root cause: the ACP adapter emitted the approval turn item after the runtime request it
belongs to.
one write (
ProviderEventIngestor.ts, the sibling-buffer path).EventSink.writeIfRuntimeRequestCurrent. That guard compares the request's current statuswith the caller's snapshot (
EventSink.ts:379-397,current.status === expected.status).lands between the ingestor's snapshot and the write's own re-read, the guard fails and the
write is dropped without an error — the approval card silently disappears.
Why
pushfailed andpull_requestpassedThis is not a content difference and not an event-type semantic:
The PR run checked out the synthetic merge commit
5e0a648("Merge 4e00bbf into 5093f0a"),not the PR head — and it has the same tree as the pushed merge commit
33d29707.The shard assignment is also identical, because
WeightedShardSequencersplits on the committedapps/server/src/testUtils/shardWeights.json:Same command (
vp run --filter t3 test --shard 1/3), same Nodev24.22.0, same vitestv5.0.1.⇒ The difference is a timing race, not the event type. The push run lost the race twice; the
PR run won it once. The replay fixture has no replay gate (
tool_call_read_only_on_request/input.tsuses only
approve_next_runtime_request), so nothing pins the ordering.The fix
packages/provider-acp/src/server/adapter.ts— emit the turn item before the runtime request,in both the approval path and the user-input path:
The artifact is now buffered and committed atomically with the request it belongs to, which is
exactly what the sibling buffer already does for the node, and what the existing hoisting comment
in
ProviderEventIngestor.ts("hoist those artifacts ahead of the request") assumes.This also closes a real product bug, not just a test bug: in production the user answers the
approval while the provider's artifact write is in flight, and the card can vanish under them.
Verification
New regression test in
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.tsasserts theapproval artifact is emitted before the pending runtime request. It is deterministic:
Suites run locally on this branch:
Adapters/AcpAdapterV2.test.tsAdapters/GrokAdapterV2.test.tsAdapters/AcpRegistryAdapterV2.test.tstestkit/OrchestratorReplayFixtures.integration.test.tsvpr typecheckexits 0,vp lintreports nothing new on the changed files,vp fmtclean.Sibling adapters still emit the artifact after the request
The artifact-before-request order is already the convention in
CodexAdapterV2.ts(both theapproval path at
5070-5083and the user-input path at4956-4971), which is what the ACPadapter was deviating from. The other adapters still emit request-first and keep the same latent
race, so they can lose an artifact the same way:
provider-acp(Grok, AcpRegistry, Antigravity)CodexAdapterV2ClaudeAdapterV2provider-museprovider-piprovider-opencodev2This PR only changes the adapter whose path actually broke CI. The other four are the same
one-line swap; say the word and I will do them in a follow-up so the fix can be verified per
provider instead of all at once.
Not included: the
ENOTEMPTYflakegitHubChangeRequestTemplate.test.tscleans a scoped temp dir that contains a live.git, andcan fail with
ENOTEMPTYon.git/objects.It is a different class of problem and this PR does not fix it. The adapter emit order has no
effect on filesystem cleanup, and a git-config change would have no effect on provider event
ordering.
It also did not reproduce here: 0 occurrences across all 13 jobs of both attempts of
39264953410and the PR run'sTest Server 1, and 0 in 12 local loop runs ofgitHubChangeRequestTemplate.test.ts.The likely mechanism is
git commit's backgroundgit gc --autowriting into.git/objectswhile the scoped temp dir is being removed. The codebase already documents that hazard and works
around it for
fetchwith--no-auto-gc(apps/server/src/vcs/GitVcsDriverCore.ts:1266), butthe fixtures'
git commitdoes not. The one-line hardening would be["gc.auto", "0"]inapps/server/src/testUtils/gitConfig.setup.ts— the file that already exists to pin git configfor test fixtures. Left out of this PR because it is unverified here; say the word and I will add
it as a separate commit.