Repository navigation
test(chat): replace wall-clock polls in the smaller view model suites - #165178
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, 3:56 AM ET / 07:56 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR replaces timed polling in native chat tests with task completion and arrival signals, and consolidates observation-based waits into one shared helper. Merge readiness✅ Ready for maintainer review Keep open: current main still needs these conversions, and the prior unread-ordering finding is resolved. The recorded series-specific decision to defer native validation to hourly main CI addresses the previous shard-run blocker. Priority: P2 Review scores
Verification
How this fits togetherOpenClawKit provides the native chat model used by Apple clients. These tests exercise navigation, attachments, unread state, deletion, and transcript caching through controlled transport and storage fixtures. flowchart TD
A[Chat test scenarios] --> B[Native chat model]
B --> C[Transport and storage fixtures]
C --> D[Request arrival signals]
B --> E[Task completion and observed state]
D --> F[Behavior assertions]
E --> F
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther +12. Total +12 across 9 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Use existing task owners and one shared observation helper to retain precise behavior assertions without runner-load deadlines. Do we have a high-confidence way to reproduce the issue? Yes: the body describes a concrete MainActor saturation reproduction with before/after results, and fetched main still contains the deadline-based waits. This read-only review did not execute the reproduction. Is this the best way to solve the issue? Yes: awaiting owned completion and fixture arrival signals directly repairs the timing assumption while preserving assertions; consolidating the identical observation helpers avoids competing implementations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fbdb27adbe2b. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Await send, bootstrap, and cache-write tasks for owned completion. Use file-private arrival gates and observed state for remaining progress waits. Preserve the existing assertions without changing production behavior.
c087912 to
2662ad1
Compare
|
Merged via squash.
|
…openclaw#165178) * test(chat): replace polling in smaller view model suites Await send, bootstrap, and cache-write tasks for owned completion. Use file-private arrival gates and observed state for remaining progress waits. Preserve the existing assertions without changing production behavior. * test(chat): share the observation-driven wait helper * test(chat): wait for the applied unread observation, not its request * test(chat): capture unread list rows with the call that records them * test(chat): fold the outbox observed-state wait into the shared helper
What Problem This Solves
Fixes:
macos-swift (packages)intermittently fails withTimeout waiting for: …in the smaller chat view model suites (agent navigation, attachments, session deletion, transcript cache, unread) when 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 these suites.Why This Change Was Made
Follows #165157, whose
send()Task this PR uses (rebased onto main after it landed). These suites detected product progress withwaitUntil, a 15 s wall-clock poll, which a MainActor backlog under the full parallel package run can outlive while the work is still queued. #163719 converted the bootstrap waits inChatViewModelAgentNavigationTests; this PR removes the remaining 47 waits across five files:ChatViewModelAgentNavigationTests(13) andChatViewModelSessionDeletionTests(10)ChatViewModelTranscriptCacheTests(6)ChatViewModelAttachmentTests(17, XCTest)ChatViewModelUnreadTests: its singlewaitUntilsat inside thewaitForUnreadStatehelper that every unread test used.Each wait now awaits its owner or an arrival signal:
bootstrapTask, thesend()Task, or a deadline-free arrival signal on the file's own fake. The fakes reuse each file's existing gate style; the unread fake gains awaitForStatewaiter that resumes on recorded mutations. Where no handle reaches, the tests use the Observation-drivenwaitForObservedState. This PR moves that helper fromChatViewModelTests.swiftinto the sharedTestAsyncHelpers.swiftinstead of copying it per file.One conversion needed care. A transport arrival only proves a request started, not that its response was applied. The unread 'fresh observation' test gives the refreshed row a distinct
updatedAtand waits for that row to land before asserting that the local override cleared. The unread fake also captures each list response's rows in the same actor step that records the call, so once a test has seen the call, a latersetSessionscannot leak into that already-started request (ClawSweeper's stale-response ordering finding). This PR also folds #165187'swaitForOutboxObservedStateinto the shared helper. Test-only; no production changes.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, which puts one MainActor hop past 15 s. The flood is held 420 s and starts first. Private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR were used throughout.
<the five suites>|AAMainActorSaturationProbe/). Before, on the base (a44817c): 10 tests fail, with 14 issues, e.g.send reaches selected agent,selected agent primary opens,first catalog starts, andwrite-through stored transcript. After, on2662ad1bfca58b0e9dfa4b9aba8fb53e6ce38b16: all 60 pass (Test run with 61 tests in 5 suites passed after 420.468 seconds).Timeout waiting for: …(e.g.voice note sent,video attachment staged,legacy gateway bootstrap completed). After, on the previously reviewedc087912a0b36: all 11 pass, each finishing behind its flood rather than timing out.Flake-fix proof bar (writing tests, Flake triage step 4), on this head:
2662ad1bfca58b0e9dfa4b9aba8fb53e6ce38b16(18 XCTest cases + 60 Swift Testing tests each run). Measured standalone test time: 0.490–0.516 s for Swift Testing and 0.185–0.322 s for XCTest; 3–6 s command wall time per run.ChatViewModel*andNativeConversation*suite, 552 Swift Testing tests in 15 suites (2.036 s) plus 18 XCTest cases, passed on this head. B6 outbox and outbox settings also passed independently: 63 tests in 2 suites (1.685 s).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. Neither probe is committed: the repro needs a sustained multi-minute flood, far over the test cost budget.Related: #163719, #163792, #165068, #165157