Repository navigation
fix(tests): prevent session-send callbacks from outliving fixtures - #147167
Conversation
Use the canonical lazy command owner instead of a mutable test dependency bag and global publication. Bind tests to the existing command module and settle returned session-send continuations before fixture cleanup, retaining native failure reporting through the existing QA cleanup owner.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 7:30 PM ET / 23:30 UTC (Revision 7). ClawSweeper reviewWhat this changesSession-send tests now wait for background callbacks before resetting shared fixtures and explicitly complete the synthetic pending-error run during cleanup. Merge readiness✅ Ready for maintainer review The fixture-lifetime repair remains necessary on current main. The refreshed patch resolves the earlier merge-conflict concern, preserves existing coverage, and has no actionable correctness findings. Priority: P3 Review scores
Verification
How this fits togetherSession-send tools can return while background reply handling continues. These test fixtures provide simulated Gateway responses and must remain intact until that background work finishes. flowchart TD
A[Session-send test] --> B[Real session-send tool]
B --> C[Simulated Gateway responses]
B --> D[Background reply callback]
D --> E[Observe completion promise]
E --> F[Join callbacks during cleanup]
F --> G[Reset shared fixtures]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +100. Total +100 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep callback settlement within the existing fixture cleanup lifecycle, preserving production admission behavior and the original test inventory. Do we have a high-confidence way to reproduce the issue? Yes: hold a session-send background RPC across test completion and observe whether fixture reset precedes callback settlement. Current source supports that failure path, and the body reports a failing ordered probe; this review did not execute it. Is this the best way to solve the issue? Yes: observing the original completion promises and joining them through the existing cleanup owner fixes the fixture boundary without adding a production test seam. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 23eb2a6f01a7. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Merge current main and bind session-send test cleanup to its detached continuation owner. Retain the late-reply variants and pending-callback regression.
Merge current main while retaining canonical agent-step dispatch and owned continuation cleanup. Preserve notification, steering, followup, and late-reply test cases.
Merge the pinned main changes while preserving canonical command mocks and completing the pending-run fixture before its continuation cleanup.
Merge pinned main 7034b4a to inherit the QA fixture fix that preserves native process hooks. Keep the reviewed AgentStep command forwarding and continuation-cleanup changes unchanged.
Merge pinned main 4bba146 to inherit the canonical emoji dependency, alias and yield fixture fixes, and archive-read ownership repair. Preserve the reviewed AgentStep command forwarding and continuation cleanup changes, with the required-close retention invariant documented.
Keep the complete sessions case inventory and original import/setup order. Construct the two-channel fixture through its pure sibling factory while leaving registry activation at the existing beforeEach boundary.
Merge pinned main 9a44681 to inherit the canonical UI startup-budget, skill bounded-read, and cold native-fixture dependency fixes. Preserve AgentStep command ownership and the complete sessions registry case inventory with its extracted pure fixture factory.
Merge pinned main 448b774 while preserving canonical AgentStep command ownership and the extracted fresh-per-test registry factory. Compose the full child, peer, and Cron late-reply matrix with tracked continuation settlement and ordered fixture cleanup.
Retain the real A2A completion promises until fixture cleanup can join them, then reset admission, system events, adjusted tool parameters, and the command spy. Finish the synthetic pending-error run during cleanup after its timeout assertions. Keep all 82 sessions cases in their original registration order. The production registry cleanup landed in #155125. This commit preserves the original #147167 ancestry and addresses its remaining primary-suite lifetime bug through the existing test fixture owners. Proof: the actual-tool baseline exposed an unsettled callback after fixture reset. The candidate handshake passed, as did all 82 original sessions cases, 5 AgentStep cases, and 33 child-coordination cases. All 21 selected checks, including all 25 core-test type graphs, passed on Blacksmith Testbox. Fresh Codex P2 review found no actionable findings.
|
Merged via squash.
|
…penclaw#147167) * refactor(agents): remove agent-step test dependency seam Use the canonical lazy command owner instead of a mutable test dependency bag and global publication. Bind tests to the existing command module and settle returned session-send continuations before fixture cleanup, retaining native failure reporting through the existing QA cleanup owner. * test(sessions): extract registry fixture owner Keep the complete sessions case inventory and original import/setup order. Construct the two-channel fixture through its pure sibling factory while leaving registry activation at the existing beforeEach boundary. * test(agents): use command mock for child coordination
What Problem This Solves
Session-send tests could reset shared fixtures while an accepted background callback was still waiting on an RPC.
User Impact
Test teardown now waits for that work before resetting fixtures. There is no user-visible runtime change.
Why This Change Was Made
The production test-registry cleanup already landed in #155125. This refresh addresses the remaining, independently reproduced fixture-lifetime bug.
Observe the actual returned session-send continuation promises and join them through the existing QA cleanup owner before resetting admission, system events, adjusted tool parameters, and the command mock. The synthetic pending-error run becomes terminal only during cleanup, after its original timeout assertions. Its test stays in the same registration position, using the existing timeout fixture module. The current async mock setter and fresh inline plugin fixtures retain their contracts.
Evidence
prior case continuation must settle before fixture reset: expected false to be true. The diagnostic then released and joined the callback. One probe passed and one failed; 82 original cases were intentionally filtered. All 22 recorded source hashes were restored, with a clean remote worktree/index.Measured Linux command costs, including default and JUnit reporters:
pnpm test src/agents/openclaw-tools.sessions.test.ts --maxWorkers=1pnpm test src/agents/tools/agent-step.test.ts --maxWorkers=1pnpm test src/agents/openclaw-tools.sessions-send-child-coordination.test.ts --maxWorkers=1Fresh managed P2 review found no actionable findings on the exact two-file patch. All 21 selected changed checks passed in 1,668.345 s, including all 25 core-test typechecking groups, all three Knip scans with zero entries, and typed lint with no warnings or errors. These are private development results, not a performance comparison.
Published-head CI passed for
9a8f935bd4314cc5703a110832bb0998d27e4231, testing merge42f95e4d7a2c30755fa01e2cb57012480b874486over06ce6c415dd293f139181085c9518abe5d47ce36. Both changed file blobs match the reviewed candidate and the package/lock resolve fs-safe 0.18.0, matching private proof. Hosted selection passed 82 primary cases and 142 boundary cases; the other 38 sibling cases were not selected and remain private proof. Primary cases totaled 3.965s reported test time, with 75.80s Vitest duration and 80.09s wrapper wall on two CPUs. These are CI costs, notpnpmcommand timing or a performance comparison. The run finished with 27 successful jobs and 19 skipped jobs; no failures.The Blacksmith Testbox lifecycle run identifies the environment, not a PR-CI result. Candidate proof binds main
15201542a5356ce563cbaec3c2e0e9847aeffe8cplus the two-file patch to treed92689552e5bfc5d8bcc703b6ebeb75c9502df70, preserved exactly in commit9a8f935bd4314cc5703a110832bb0998d27e4231. All 23 recorded source hashes matched before and after proof and after the normal-hook commit; the originalaf1b7126PR ancestry is retained. The Testbox is stopped and both temporary source capsules are retired.The baseline reporting script encountered a parser error after restoring source; its retained logs were reparsed without rerunning the test. Optional runner-portal synchronization timed out after the successful candidate workload; the candidate wrapper exited zero and its downloaded artifacts were verified independently.
Gateway normal release is already protected. Failure-only shared-suite reset isolation remains a separate source-confirmed, unexecuted follow-up outside this primary-suite repair.