Repository navigation
test(gateway): wait for the withheld exec result before sweeping a yielded session - #204801
Conversation
…elded session A cancelled exec wake withholds its owed row asynchronously, and since #204265 the yield sweep reads stored owed rows. The test advanced the clock before the row was withheld, so the sweep could still see it and leave the session waiting. Co-authored-by: obviyus <[email protected]>
|
🦞👀 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: passed. What this changesThis PR waits for a cancelled exec wake’s stored result to be withheld before advancing the test’s maintenance clock. Example: The exec-completion case cancels its wake before advancing maintenance by 60,000 milliseconds.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR makes a useful, minimal test synchronization repair still absent from current main; no actionable defects were found. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway maintenance reads parked session lifecycles and their continuation sources, preserving resumable waits and recording failure when no continuation remains. flowchart TD
A[Test cancels exec wake] --> B[Async wake settlement]
B --> C[Stored result withheld]
C --> D[Test observes shouldWake false]
D --> E[Maintenance clock advances]
E --> F[Unreachable lifecycle fails]
Technical reviewBest possible solution: Keep the existing production owners and wait for completed stored-result settlement before advancing this test’s maintenance clock. Do we have a high-confidence way to reproduce the issue? Source establishes the asynchronous settlement window behind the reported intermittent failure; no tests were executed during this read-only review, and a deterministic baseline failure is not established. Is this the best way to solve the issue? The existing stored-state reader provides the necessary synchronization without changing production behavior, adding a production test hook, or weakening the lifecycle assertion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a05d78c633ab. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +4. Total +4 across 1 file. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 29, 2026, 9:49 AM ET / 14:49 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed as 777568e. The exec-completion case of |
…elded session (openclaw#204801) ## Problem `src/gateway/session-yield-sweep.test.ts` > "settles only an unreachable parked lifecycle (exec-completion)" fails intermittently on scheduled `main` (run 45403387860): `expected undefined to be 'failed'` at the final status check. Since openclaw#204265, the yield sweep keeps a yielded session waiting while it has a stored owed exec result (`shouldWake`, `session-yield-sweep.ts:45`). When the exec completion's wake settles as `cancelled`, `settleOwedExecWake` withholds the owed row asynchronously: `readPendingOwed` and then `withhold` on the database worker. The test resolved the wake and advanced the fake clock straight away. When the sweep tick ran before `withhold` committed, the sweep still saw the pending row and correctly left the session waiting, so the status stayed unset. ## Solution Test-only change. After the wake settles, the test waits until `shouldWake` (the stored-row check the sweep itself uses) reports no owed result, then advances the clock. Product behavior is unchanged: the next sweep tick settles the session. openclaw#204609 and openclaw#204621 do not touch this path. openclaw#204609 changes only `session-restart-resume-custody.ts`, which only the restart path imports. openclaw#204621 changes reply-operation backend readiness, which none of these modules use; the test's wake is mocked. ## Impact No change to production code or user behavior. ## Evidence - Before: intermittent red on scheduled `main` with the assertion above: run 45403387860, and again in run 45849028735 (2026-11-26, `checks-node-compact-large-14`, after openclaw#205835), `expected undefined to be 'failed'` in the exec-completion case. The race mechanism (`settleOwedExecWake` withholds the owed row after the wake settles) is unchanged on current `main`. - Negative control (deterministic): with a 500 ms delay inserted before that `withhold` (local throwaway change), current `main` fails the exec-completion case 3/3 with the same assertion; with this change it passes 3/3. - Without the delay, interleaved runs of `session-yield-sweep.test.ts` with this change applied to current `main`: 20/20 green (main alone was also 20/20 locally; the natural race is rare). ## Merge danger Two-way door: test-only, a revert fully undoes it. Blast radius: one test file. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
src/gateway/session-yield-sweep.test.ts> "settles only an unreachable parked lifecycle (exec-completion)" fails intermittently on scheduledmain(run 45403387860):expected undefined to be 'failed'at the final status check.Since #204265, the yield sweep keeps a yielded session waiting while it has a stored owed exec result (
shouldWake,session-yield-sweep.ts:45). When the exec completion's wake settles ascancelled,settleOwedExecWakewithholds the owed row asynchronously:readPendingOwedand thenwithholdon the database worker. The test resolved the wake and advanced the fake clock straight away. When the sweep tick ran beforewithholdcommitted, the sweep still saw the pending row and correctly left the session waiting, so the status stayed unset.Solution
Test-only change. After the wake settles, the test waits until
shouldWake(the stored-row check the sweep itself uses) reports no owed result, then advances the clock. Product behavior is unchanged: the next sweep tick settles the session.#204609 and #204621 do not touch this path. #204609 changes only
session-restart-resume-custody.ts, which only the restart path imports. #204621 changes reply-operation backend readiness, which none of these modules use; the test's wake is mocked.Impact
No change to production code or user behavior.
Evidence
mainwith the assertion above: run 45403387860, and again in run 45849028735 (2026-11-26,checks-node-compact-large-14, after fix: skip idle chats when checking for stranded turns #205835),expected undefined to be 'failed'in the exec-completion case. The race mechanism (settleOwedExecWakewithholds the owed row after the wake settles) is unchanged on currentmain.withhold(local throwaway change), currentmainfails the exec-completion case 3/3 with the same assertion; with this change it passes 3/3.session-yield-sweep.test.tswith this change applied to currentmain: 20/20 green (main alone was also 20/20 locally; the natural race is rare).Merge danger
Two-way door: test-only, a revert fully undoes it. Blast radius: one test file.