Repository navigation
fix(acp): settle Stop without overwriting replacement sessions - #160035
Conversation
Retain accepted-turn cleanup through worker settlement and revalidate current session and global ACP ownership. Bind owner-qualified publication and ensure normalization writes to their runtime locator while preserving admitted runtime cancellation, persistent backend ownership, and shipped synchronous reads.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. Reviewed September 28, 2026, 4:32 AM ET / 08:32 UTC (Revision 5). ClawSweeper reviewWhat this changesThe ACP session manager now waits for accepted Stop cleanup and checks session ownership before cancellation writes runtime metadata or terminal state. Merge readiness⛔ Needs changes before merge - 2 items remain Current main still has the Stop cleanup and stale-publication problem, so this PR remains useful. Source review found no blocking correctness defect; the prior requirement to report the new test suites’ measured cost remains open. Priority: P1 Review scores
Verification
How this fits togetherThe ACP session manager receives Stop requests from OpenClaw’s control paths. It cancels the selected backend runtime and publishes session state through SQLite workers. flowchart LR
A[Stop request] --> B[ACP session manager]
B --> C{Accepted turn?}
C -->|Yes| D[Cancel and join turn]
C -->|No| E[Prepare runtime handle]
D --> F[Worker ownership check]
E --> F
F --> G[Backend and session state]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +836, Tests +2709, Docs +1. Total +3546 across 40 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep Stop settlement and successor-safe publication with the ACP manager and worker owners, while handling the acknowledged manual-cancel and reset paths in separate scoped work. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main does not join accepted-turn settlement and can write state after awaited setup. This read-only review did not execute the reported failing cases. Is this the best way to solve the issue? Yes. The branch uses the existing ACP manager and SQLite worker ownership boundaries for this Stop path and preserves the synchronous SDK read contract. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 809b62cc7e49. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Extract source-read and session-state operation contracts into leaf modules. Preserve runtime behavior and all operation fields while eliminating circular type imports reported by CI.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
#160035 made the ACP manager's default deps bind prepareAcpSessionControlRead and upsertAcpSessionMetaForControl from session-meta. The shared dispatch-from-config harness mocks that module without them, so dispatch-from-config.lifecycle.test.ts fails 10 of 74 tests at module load on main whenever a PR's changed-owner plan selects it. Mirror the control-plane test helper's stub.
…ceed the frame limit (#160071) * fix(ui): admit chat attachments against the chat.send frame budget One chat.send carries every composer attachment base64-encoded in a single WebSocket frame, but the Control UI only checked each file against the per-attachment hello-ok.policy.attachments ceilings. Files that fit one at a time could together exceed the frame, and the send failed late: after the composer cleared and the whole batch was encoded, with a generic payload error from the browser transport. The per-send decoded budget is floor((policy.maxPayload - 256 KiB) * 3/4), the formula the Gateway already used to clamp its advertised ceiling, now owned by src/shared/chat-attachment-frame-budget.ts for both sides. Every composer intake path counts staged attachments plus in-flight reads and rejects the file that would overflow with the existing "Too large to send" toast. handleSendChat, outbox delivery, and new-session submission recheck the batch against the current connection before transmitting, so a stale oversized draft or queued row cannot be replayed. The transport guard remains the final backstop. Advertised Gateway values are unchanged. * fix(ui): admit chat attachments against the chat.send frame budget One chat.send carries every composer attachment base64-encoded in a single WebSocket frame, but the Control UI only checked each file against the per-attachment hello-ok.policy.attachments ceilings. Files that fit one at a time could together exceed the frame, and the send failed late: after the composer cleared and the whole batch was encoded, with a generic payload error from the browser transport. The per-send decoded budget is floor((policy.maxPayload - 256 KiB) * 3/4), the formula the Gateway already used to clamp its advertised ceiling, now owned by src/shared/chat-attachment-frame-budget.ts for both sides. Every composer intake path counts staged attachments plus in-flight reads and rejects the file that would overflow with the existing "Too large to send" toast. handleSendChat, outbox delivery, and new-session submission recheck the batch against the current connection before transmitting, so a stale oversized draft or queued row cannot be replayed. The transport guard remains the final backstop. Advertised Gateway values are unchanged. * refactor(ui): keep attachment read and delivery rejection code with their owners Attachment frame admission pushed the attachment controls, send delivery, and submit tests over their max-lines caps. Move the unchanged FileReader executor into the read lifecycle owner, centralize batch rejection in admission, and keep queued rejection recovery beside failure settlement. Reuse the frame-limited hello and rejected-row fixtures without dropping assertions. Counted lines fall from 730 to 617, 714 to 699, and 1020 to 998; no baseline changes. * fix(ui): break attachment reads/controls type cycle readChatAttachmentFile only needs readSignal, attachmentLimits and uploadConfig. Accept that structural subset instead of importing ChatAttachmentControlsProps, which itself imports this module, so madge no longer reports a cycle. * test(auto-reply): mock ACP control reads in the dispatch harness #160035 made the ACP manager's default deps bind prepareAcpSessionControlRead and upsertAcpSessionMetaForControl from session-meta. The shared dispatch-from-config harness mocks that module without them, so dispatch-from-config.lifecycle.test.ts fails 10 of 74 tests at module load on main whenever a PR's changed-owner plan selects it. Mirror the control-plane test helper's stub. * test(ui): size the durable-draft e2e frame for its near-cap file The coalescing case stages a 25 MiB - 64 KiB draft file with a 25 MiB per-file cap but the mock's default 25 MiB maxPayload, whose frame budget (19,464,192 bytes) cannot carry that file. The per-send batch rule now rejects it at intake, so the draft was never written. A real Gateway clamps maxBytes to the frame budget; give this fixture a frame that can carry the file so it keeps testing draft-write coalescing. * test(ui): use Number.NaN in attachment byte fixtures * refactor(ui): deslop attachment batch admission * docs(ui): state why attachment batches are admitted at intake * test(e2e): expect the raised upgrade-survivor start budget 1fd2ad9 raised OPENCLAW_UPGRADE_SURVIVOR_START_BUDGET_SECONDS' default from 90 to 300 in upgrade-survivor-docker.sh, run.sh and update-restart-auth.sh but left docker-build-helper.test.ts expecting 90, so 'bounds upgrade survivor foreground OpenClaw CLI calls' fails deterministically on main and in PRs whose plan selects the core-tooling shard. Align the three expectations with the committed scripts.
…law#160035) * fix(acp): settle cancellation without overwriting replacement sessions Retain accepted-turn cleanup through worker settlement and revalidate current session and global ACP ownership. Bind owner-qualified publication and ensure normalization writes to their runtime locator while preserving admitted runtime cancellation, persistent backend ownership, and shipped synchronous reads. * fix(acp): remove cancellation worker type cycles Extract source-read and session-state operation contracts into leaf modules. Preserve runtime behavior and all operation fields while eliminating circular type imports reported by CI. * test(acp): join the held producer in fast-abort fixtures
…ceed the frame limit (openclaw#160071) * fix(ui): admit chat attachments against the chat.send frame budget One chat.send carries every composer attachment base64-encoded in a single WebSocket frame, but the Control UI only checked each file against the per-attachment hello-ok.policy.attachments ceilings. Files that fit one at a time could together exceed the frame, and the send failed late: after the composer cleared and the whole batch was encoded, with a generic payload error from the browser transport. The per-send decoded budget is floor((policy.maxPayload - 256 KiB) * 3/4), the formula the Gateway already used to clamp its advertised ceiling, now owned by src/shared/chat-attachment-frame-budget.ts for both sides. Every composer intake path counts staged attachments plus in-flight reads and rejects the file that would overflow with the existing "Too large to send" toast. handleSendChat, outbox delivery, and new-session submission recheck the batch against the current connection before transmitting, so a stale oversized draft or queued row cannot be replayed. The transport guard remains the final backstop. Advertised Gateway values are unchanged. * fix(ui): admit chat attachments against the chat.send frame budget One chat.send carries every composer attachment base64-encoded in a single WebSocket frame, but the Control UI only checked each file against the per-attachment hello-ok.policy.attachments ceilings. Files that fit one at a time could together exceed the frame, and the send failed late: after the composer cleared and the whole batch was encoded, with a generic payload error from the browser transport. The per-send decoded budget is floor((policy.maxPayload - 256 KiB) * 3/4), the formula the Gateway already used to clamp its advertised ceiling, now owned by src/shared/chat-attachment-frame-budget.ts for both sides. Every composer intake path counts staged attachments plus in-flight reads and rejects the file that would overflow with the existing "Too large to send" toast. handleSendChat, outbox delivery, and new-session submission recheck the batch against the current connection before transmitting, so a stale oversized draft or queued row cannot be replayed. The transport guard remains the final backstop. Advertised Gateway values are unchanged. * refactor(ui): keep attachment read and delivery rejection code with their owners Attachment frame admission pushed the attachment controls, send delivery, and submit tests over their max-lines caps. Move the unchanged FileReader executor into the read lifecycle owner, centralize batch rejection in admission, and keep queued rejection recovery beside failure settlement. Reuse the frame-limited hello and rejected-row fixtures without dropping assertions. Counted lines fall from 730 to 617, 714 to 699, and 1020 to 998; no baseline changes. * fix(ui): break attachment reads/controls type cycle readChatAttachmentFile only needs readSignal, attachmentLimits and uploadConfig. Accept that structural subset instead of importing ChatAttachmentControlsProps, which itself imports this module, so madge no longer reports a cycle. * test(auto-reply): mock ACP control reads in the dispatch harness openclaw#160035 made the ACP manager's default deps bind prepareAcpSessionControlRead and upsertAcpSessionMetaForControl from session-meta. The shared dispatch-from-config harness mocks that module without them, so dispatch-from-config.lifecycle.test.ts fails 10 of 74 tests at module load on main whenever a PR's changed-owner plan selects it. Mirror the control-plane test helper's stub. * test(ui): size the durable-draft e2e frame for its near-cap file The coalescing case stages a 25 MiB - 64 KiB draft file with a 25 MiB per-file cap but the mock's default 25 MiB maxPayload, whose frame budget (19,464,192 bytes) cannot carry that file. The per-send batch rule now rejects it at intake, so the draft was never written. A real Gateway clamps maxBytes to the frame budget; give this fixture a frame that can carry the file so it keeps testing draft-write coalescing. * test(ui): use Number.NaN in attachment byte fixtures * refactor(ui): deslop attachment batch admission * docs(ui): state why attachment batches are admitted at intake * test(e2e): expect the raised upgrade-survivor start budget 5c475b6 raised OPENCLAW_UPGRADE_SURVIVOR_START_BUDGET_SECONDS' default from 90 to 300 in upgrade-survivor-docker.sh, run.sh and update-restart-auth.sh but left docker-build-helper.test.ts expecting 90, so 'bounds upgrade survivor foreground OpenClaw CLI calls' fails deterministically on main and in PRs whose plan selects the core-tooling shard. Align the three expectations with the committed scripts.
What Problem This Solves
Fixes ACP Stop finishing before accepted cleanup settles, and cancellation publishing state over a replacement runtime after awaited setup or reads.
User Impact
Stop joins every targeted accepted turn and started cleanup operation. Owner-qualified SDK cancellation preserves replacement metadata while still joining an admitted old-runtime RPC. Idle cancellation refuses a changed backend/runtime-name binding without closing backend-owned persistent state. A refused pre-RPC read can be retried; an active-turn cancellation that already started remains deduplicated.
Public synchronous SDK reads and immediate unqualified abort admission are preserved. The bundled manual-cancel, fast-abort, and Gateway-reset paths still require successor-publication protection in follow-up work; this PR does not claim those paths are complete. Incognito retains its native admission path with fresh global ACP checks; full memory-worker transfer also remains separate required work.
Why This Change Was Made
Cancellation retains exact accepted-turn, actor, and instance ownership across awaited work. Durable metadata and terminal-signal writes validate the physical source, session lifecycle, owner, and canonical global ACP row through the existing worker owner. Control reads bypass inherited discovery snapshots. Started cancellations and turn settlement are joined even when a sibling fails or caller authority is revoked after admission.
Normalization writes are bound to the locator captured before setup; subsequent cancellation and publication use the actual normalized handle. This also covers Stop admitted while ensure or an ordinary metadata write is already pending. Refused setup cannot publish terminal state or identity over its replacement. On control refusal, only the actor's exact cached handle is evicted; persistent backend state is not closed. The locator check covers backend and opaque runtime name, not a separate same-name backend record identity. This follows the task-free runtime and does not restore Tasks or TaskFlow storage.
Evidence
102 distinct affected cases passed in an independent canonical Linux checkout with its own frozen dependency install: 7 setup/publication cases, 60 worker/infra cancellation/control cases, 22 runtime-handle cases, and 13 ordinary cancellation/reset/model-policy cases. Six cold, late-ensure, and delayed-write regressions first failed on actual successor metadata overwrites in both durable and native Incognito storage. Original ordinary error and cancellation assertions remain unchanged; their fixtures now persist ensure normalization through the existing mutable metadata helper.
The registered manager cases use actual SQLite workers and synthetic runtime backends. They also cover lifecycle/source replacement, inherited discovery snapshots, all-started sibling settlement, reentry, pre-RPC retry, caller revocation, successful normalization, durable signal/state readback, and retry without destructive close. Independent-process tests cover replacement at the durable commit boundary.
Strict host data-SQL observations recorded zero data statements during complete durable idle/active cancellation calls, accepted late-handle cleanup, and queued cancellation through both turn settlements. Identity-replacement cases measure separate windows around their deliberate native replacement producer. Incognito cases prove native admission parity and a process-held database, not zero host SQL or live external-backend behavior.
Six existing real channel fast-abort cases also passed in an isolated checkout, for 108 distinct affected cases in total. Their fixture now observes the actual backend cancellation promise settling while the producer remains held, verifies Stop is still pending, then releases the producer before awaiting Stop. The original active row first timed out because the fixture released that producer only after awaiting the newly joined Stop. All immediate-abort, native independence, error, result, and persisted-state assertions remain; scoped messaging types, lint, formatting, and independent review passed. This final correction changes only the fixture, so the qualified production source and build remain unchanged.
Both owning type graphs, typed lint, formatting, the line-cap check, and the full build passed with Node 24.19.0 and pnpm 12.5.0. Fresh independent review returned no actionable P0–P2 findings across all three passes. Source hashes remained unchanged after proof and review. Broader source/export gates from the preceding qualification were reused only for unchanged inputs.
The first CI run caught two circular type imports and cancelled its remaining jobs. A leaf-contract extraction fixed both; the complete architecture suite, both owning type graphs, full dead-code and export scans, lint, formatting, and line-cap checks passed. The repository compiler verified identical emitted JavaScript, so the 102 behavior cases and runtime build remain applicable without repeating them. Fresh scoped review found no actionable issues.
Prior-head CI 36372891015 failed in the standalone private-worker build fixture with
Cannot find module 'vitest/runtime'; the pipeline cancelled remaining jobs. An independent frozen install of untouched main57f1abecc191ea0a54a9af93a6ccb97e6eb87700reproduced the identical failure through the exact fixture command. Main commit7526f600cf104b51ee1ba60a4cf533d9e1449a01made the inherited Vitest preload resolve from the worker entry; the temporary compiled worker has no Vitest dependency. The CI merge and untouched baseline have identical fixture, preload, builder, lockfile, shared-config, and worker-URL blobs. The canonical fixture repair has landed in #160069. The failed and cancelled jobs remain recorded as such; the new test-only correction receives fresh exact-head CI.Current-head CI 36382461130 stopped in preflight because its Node test plan exceeded the 130-job cap. An independent replay of the exact tested merge produced 159 jobs; untouched main with the same recorded 40-path PR request produced 160. The branch adds six test targets and reduces the planned job count by one; this is scoped baseline planner overflow, not a claim that every input is unchanged. The cap and coverage selection were preserved.
The exact tested merge
c819bc67fb9c92c055a2fa5ad4c9e02ffc37843ewas then qualified independently in Linux: all 108 affected cases, nine sharing-acquisition cases, and the three relevant type graphs passed with a clean source tree. Registered worker compilation included the newer canonical acquisition owner. The native pre-existing-CI exception retains the failed preflight and skipped dependent jobs; security and review admission remain separate requirements.