Repository navigation
test(chat): await session and model refresh owners in view model tests - #165171
Conversation
|
🦞👀 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 maintainer review before merge. Reviewed October 5, 2026, 4:34 AM ET / 08:34 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR replaces native chat test polling with completion and arrival signals, and returns handles for existing session and model refresh work. Merge readiness✅ Ready for maintainer review This remains useful work that current main does not contain. No actionable introduced defect was found, and the prior conflict, timing, and shard-policy concerns are resolved by the current merge result and recorded evidence. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's shared Apple chat view model receives Gateway events and refreshes conversation history, model choices, and capabilities. These tests verify the resulting state after the responsible asynchronous work finishes. flowchart TD
A[Gateway events] --> B[Native chat view model]
B --> C[Session and model refreshes]
C --> D[Conversation and capability state]
C --> E[Completion handles]
F[Test actions and arrival signals] --> B
E --> G[Test assertions]
D --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther -128. Total -128 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep asynchronous work owned by the existing refresh tasks and let tests assert outcomes after completion without wall-clock polling. Do we have a high-confidence way to reproduce the issue? Yes: current source uses 15-second polling deadlines around queued MainActor work, and the recorded saturation run demonstrates the failure mechanism. This read-only review did not execute the native tests. Is this the best way to solve the issue? Yes: awaiting existing work owners and retaining outcome assertions follows the established merged pattern and avoids increasing timeout budgets or adding retries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6272c4760b9d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
5b45958 to
2bdf553
Compare
Replace 121 polls in 64 tests with task, settings-queue, fake-arrival, and Observation completion signals while retaining their assertions. Return existing metadata and model refresh tasks with zero net source growth.
6df213a to
e988b12
Compare
|
Merged via squash.
|
openclaw#165171) * test(chat): replace B3 wall-clock polls with completion signals Replace 121 polls in 64 tests with task, settings-queue, fake-arrival, and Observation completion signals while retaining their assertions. Return existing metadata and model refresh tasks with zero net source growth. * test(chat): settle both metadata refreshes through one handle
What Problem This Solves
Fixes:
macos-swift (packages)intermittently fails withTimeout waiting for: …inChatViewModelTestswhen the full OpenClawKit package runs its tests in parallel on a loaded runner.User Impact
No user-visible change. PRs stop picking up a red
macos-swift (packages)job from the chat view model session-refresh, model-catalog, and history-invalidation tests.Why This Change Was Made
Follows #165170 (rebased onto main after it landed; patch-identical to the proven head 6df213a). These tests detected product progress with
waitUntil, a 15 s wall-clock poll. In CI the whole package runs in one parallelswift testprocess, and the MainActor carries a large backlog there. Work that needs several MainActor hops outlives the deadline while it is still queued. #163719, #163792, and #165157 fixed the same class. This PR converts the second third of the remainingChatViewModelTestswaits: 64 tests, 121 waits.Each wait now awaits its owner or an arrival signal, so a backlog can delay it but cannot expire it:
sessions.changedevent now returns the model-catalog refresh Task it already starts. The metadata and model-selection event returns one Task that settles both its model refresh and its swarm-capability refresh. Both Tasks still start exactly as before, in the same order.waitForPendingSessionSettings,bootstrapTask, and thesend()Task.transport.waitForStateand the counterwait(until:)from test(chat): await send and run-event owners instead of wall-clock polls #165157.waitForObservedState.After awaiting an owner, each test asserts the condition the old poll checked, so a regression fails as an expectation instead of timing out. No timeouts were lengthened and no retries were added. Production code is net −1 line: two adjacent guards in
appendFinalChatMessageIfPresentare merged.Evidence
Deterministic saturation probe, the same method as #163792 and #165157. A temporary suite, not committed, floods the MainActor with 16,000 yielding tasks that each spin 1 ms. That puts one MainActor hop past 15 s. The flood is held 420 s, and the suite is named so it starts first. It runs in the same
swift test --package-path apps/shared/OpenClawKit --skip-build --disable-sandbox --filter '<this batch's tests>|AAMainActorSaturationProbe/'process, with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR.invalidation history read starts,sessions loaded,committed message recovers after invalidation, andcapability lease acquisition started.Test run with 65 tests in 2 suites passed after 420.0 seconds).Flake-fix proof bar (writing tests, Flake triage step 4), on this head with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR:
ChatViewModelTests.swift(ChatViewModelTests+ChatViewModelSessionManagementTests): 347 tests, 1.15–1.47 s of test time each (median 1.19 s).ChatViewModel*andNativeConversation*suite. 552 tests in 15 suites, passed.macos-swift; the full-packagemacos-swift (packages)shard runs in hourly main CI, which covers this change after merge (maintainer decision for this series). test(chat): await send and run-event owners instead of wall-clock polls #165157 and test(chat): await outbox owners instead of wall-clock polls in outbox tests #165187, the same conversion class, each passed three clean shard runs on their heads before landing.Checks.
git diff --checkis clean. I did not run the full OpenClawKit suite locally, because its keychain fixtures reach the login keychain on this Mac.Not committed as a regression test. The repro needs a sustained multi-minute MainActor flood, which is far over the test cost budget. The structural guard is that none of the converted tests has a deadline left.
Related: #163719, #163792, #165068, #165157