Repository navigation
Conversation
The shutdown subscription test polled the mocked defaultCompleteModel with vi.waitFor under Vitest's default one-second budget while the activity recap ran asynchronously: a 70-message transcript read, model preparation, then the completion call. On a loaded compact-large runner the first completion can land after that budget, the poll reads zero calls, and the case fails on unrelated PRs whose diff does not touch the file. Gate the wait on the mocked completion being invoked instead: a deferred resolved inside the completion mock, awaited through withinTest so a healthy run that is merely slow cannot lose a race against a wall-clock deadline and the wait fails only at the Vitest test timeout. Production code is unchanged. Fixes openclaw#161803
|
🦞👀 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 real behavior proof before merge. Reviewed September 30, 2026, 5:25 PM ET / 21:25 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch changes a Gateway shutdown test to await the activity recap’s model call directly instead of polling for it under a one-second deadline. Merge readiness⛔ Blocked before merge - 2 items remain This is a focused repair for a Gateway test flake that remains on current main. The patch has no identified correctness defect, but the reported runs do not yet meet the repository’s flake-proof bar or resolve the prior review’s concrete proof request. Priority: P2 Review scores
Verification
How this fits togetherGateway subscriptions start background activity recaps from session transcripts. The shutdown test checks that closing a connection aborts an in-flight recap before connection work finishes draining. flowchart LR
A[Session transcript] --> B[Gateway subscriptions]
B --> C[Activity recap]
C --> D[Model call signal]
D --> E[Connection shutdown]
E --> F[Abort and drain assertions]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +13. Total +13 across 1 file. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep the completion-signal wait and shutdown assertions, then establish flake resistance in the original shard order and document why this Gateway-level test needs its measured runtime. Do we have a high-confidence way to reproduce the issue? Yes, the current-main one-second poll and the reported controlled-delay before/after run give a focused way to reproduce the flake. I did not execute the test in this read-only review. Is this the best way to solve the issue? Yes, awaiting the model-call signal addresses the test’s timing race without changing production behavior or weakening its shutdown assertions; the repository’s flake-proof runs remain outstanding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8c39234ebfff. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat 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
History |
…n-await-recap-completion
…n-await-recap-completion
|
Superseded by Both changes correct the same assertion in the same case. Diffing this branch and the merged commit against the shared base blob
The only remaining delta is how the per-test abort signal is obtained: here a Issues: #162114 (this signature reported on its own) and #161803 (both signatures, the activity-recap store assertion fixed by #161824 with merge |
Fixes #161803
Fixes #162114
What Problem This Solves
Fixes:
src/gateway/server-runtime-subscriptions.shutdown.test.ts> "cancels auxiliary model work before inherited connection drain" fails intermittently on thecompact-largeNode shards, reddening unrelated pull requests whose diff never touches this file. The reported assertion is:User Impact
No user-visible change; the behavior under test and its assertion are kept. The impact is on contributors and maintainers: a flaky gateway test currently fails unrelated pull requests, so a red
compact-largeshard can no longer be read as a statement about the PR under test.Why This Change Was Made
The case started subscriptions, requested a recap with
ensure(target), then waited for the mockeddefaultCompleteModelto have been called once:vi.waitForpolls under Vitest's default one-second budget. The completion call runs asynchronously behind a 70-message transcript read and model preparation, so on a loaded runner the first call can land after that budget and the poll reads zero calls: the wait measured host speed rather than the behavior under test.The change gates the wait on the completion call itself. The mock resolves a deferred, and the test awaits it through
withinTest, so there is no wall-clock budget: a healthy run that is merely slow cannot lose the race, and a genuine failure still fails at the Vitest test timeout. Both cases remain and production code is unchanged.This mirrors the fix a maintainer already merged for the sibling recap file in #161824 (
test(gateway): await recap completion instead of polling), which replaced the publication polls insrc/gateway/session-activity-summaries.test.tswith awaits on the owner's publication. It also follows the repository's testing guidance, which rules out real timers, sleeps, and polling in tests (docs/help/testing/writing-tests.md); this change removes the lastvi.waitForin the file.Relationship to CONTRIBUTING
CONTRIBUTING asks contributors not to open test-only PRs for failures already red on
mainCI. This change is test-only, and that is stated plainly: it removes the last live signature in #161803, whose other signature (the activity-recap store assertion) was already fixed onmainby #161824. It is opened deliberately anyway, because the failure is intermittent rather than a standing red, it costs unrelated pull requests real red CI oncompact-large, and the fix follows the pattern a maintainer already merged for its sibling file.Fixes #162114 as well: that issue reports the same signature independently of #161803 - the same file, the same case, and the same
defaultCompleteModel"called once, got 0 times" assertion - so merging this PR closes both.The repository's own AGENTS.md asks for a flaky test seen red on
mainto be fixed by pushing directly tomainrather than through a PR. That route is not available from a fork: the account opening this PR haspullaccess only (push: false), so the fix lands as this PR.Evidence
Environment: Linux x64, Node v24.19.0, one file per invocation through the
gateway-serverconfig.A/B against an injected slow recap path. A 1,500 ms delay was added to the recap
run()insrc/gateway/session-activity-summaries.tsto simulate a loaded runner (scratch, reverted, not in the diff). Same delay, same production code, only the test file differs:AssertionError: expected "defaultCompleteModel" to be called once, but got 0 times;Tests: 1 failed, 1 passed (2)Tests 2 passed (2)The "before startup" case passes in both runs, which is the control: it must not depend on the delayed recap, and does not.
Repeats at the branch head (no injected delay).
Tests 2 passed (2)Tests 2 passed (2)Tests 2 passed (2)After rebasing onto current
main(1bf0175f8c7) the same run passed again:Tests 2 passed (2), 26.6 s.Measured test cost: 2 cases, one worker, 36.6 s wall on the fastest run here (72.9 s including a cold worker build). The change adds no timer, sleep, or poll and removes one.
Gap: the 1,500 ms delay simulates a loaded runner rather than the original hosted-CI job. The original failures and their job links are recorded in #161803.