Repository navigation
test(chat): await outbox owners instead of wall-clock polls in outbox tests - #165187
Conversation
Replace outbox and settings polls with flush-task completion, transport arrival gates, shared store confirmations, and observed view-model state. Preserve delivery, retry, draft, and settings assertions without production changes.
|
🦞👀 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, 1:09 AM ET / 05:09 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR replaces deadline-based polling in native chat outbox tests with task completion, request-arrival gates, store confirmations, and observed state changes. Merge readiness✅ Ready for maintainer review The PR remains useful, with no actionable introduced defect found. The previous blocker is resolved: all three original-shard runs passed on the reviewed head. Likely related people: steipete, a high-confidence routing candidate based on prior merged outbox work. Priority: P2 Review scores
Verification
How this fits togetherThe native chat outbox persists messages while disconnected and delivers them when connectivity returns. These tests exercise its delivery, retry, confirmation, and settings behavior through the chat view model and SQLite store. flowchart TD
A[Test scenarios] --> B[Native chat view model]
B --> C[SQLite outbox]
B --> D[Scripted transport]
C --> E[Completion and confirmation signals]
D --> E
E --> F[Delivery and state assertions]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther +91. Total +91 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use owner completion and arrival signals to synchronize outbox tests while retaining independent delivery and durable-state assertions. Do we have a high-confidence way to reproduce the issue? Yes: the documented saturation scenario targets the source-visible 15-second polling deadline and records before/after failures and recovery. This review inspected the mechanism but did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: waiting for existing task owners and explicit arrivals removes load-sensitive deadlines while preserving the behavioral assertions and production contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1cebb5362f88. 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 (1 earlier review cycle)
|
|
Merged via squash.
|
… tests (openclaw#165187) * test(chat): await outbox owners instead of wall-clock polls Replace outbox and settings polls with flush-task completion, transport arrival gates, shared store confirmations, and observed view-model state. Preserve delivery, retry, draft, and settings assertions without production changes. * test(chat): wake error waits on a change so a wrong message fails * test(chat): wake error waits on the next new error * test(chat): await the reconnect flush that publishes upgrade guidance * test(chat): await coalesced successor flushes after terminal writes
What Problem This Solves
Fixes:
macos-swift (packages)intermittently fails withTimeout waiting for: …inChatViewModelOutboxTestsandChatViewModelOutboxSettingsTestswhen 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 outbox view model tests.Why This Change Was Made
The outbox suites detected product progress with
waitUntil, a 15 s wall-clock poll. Under the full parallel package run, the MainActor backlog makes multi-hop work outlive that deadline while it is still queued. Outbox restore, flush, reconcile, and terminal-write chains each need several hops. #165068 added the owner handles these tests need (outboxFlushTaskand therestoreOutboxMessagesTask) and converted the session-action suite. This PR removes all 115 waits in the two outbox suites.Each wait now awaits its owner or an arrival signal, so a backlog can delay it but cannot expire it:
outboxFlushTask, releases the gate, and awaits it, following the test(chat): await outbox owners instead of wall-clock polling in session action tests #165068 shape (finishOutboxFlush). For coalesced passes, the test also awaits the successor flush before asserting idle.bootstrapTaskand the restore Task.ScriptedOutboxgains a terminal-write gate and a confirmation signal, so terminal-failure, park, and history-confirmation tests wait on the store owner's own write.waitForStatethat wakes on recorded sends, history reads, and branch listings, plus send and history arrival gates and a model-patch arrival wait.isSubmittingDraftclears. Bubble and badge changes that no handle reaches use an Observation-driven wait.After awaiting an owner, each test asserts the condition the old poll checked. No timeouts were lengthened and no retries were added. This is test-only; there are no production changes.
The Observation-driven wait lives here as
waitForOutboxObservedState, because the sharedwaitForObservedStateis introduced by the stacked #165157 series (#165178) and is not onmainyet. Whichever of the two lands second folds this copy into the shared helper.Evidence
Deterministic saturation probe, the same method as #163792 and #165068. 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. It runs in the same
swift test --package-path apps/shared/OpenClawKit --skip-build --disable-sandbox --filter 'ChatViewModelOutboxTests|ChatViewModelOutboxSettingsTests|AAMainActorSaturationProbe/'process, with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR.pre-CAS terminal result settled,offline bootstrap settled,initial outbox restore, andterminal write failure closes health with claim intact.Test run with 64 tests in 3 suites passed after 420.7 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:
20 of 20 clean standalone runs of both outbox suites: 63 tests, 1.52–4.74 s of test time each (median 1.58 s).
Owner siblings: every
ChatViewModel*andNativeConversation*suite (includingNativeConversationOutboxTests, which shares these fakes). 552 tests in 15 suites passed.Original shard: three clean runs of CI's
macos-swift (packages)full-packageswift test --parallelon final headcc7cb9704bd4fcf0ee416a92dd550560a57c7cac: attempt 1 (9m18s), attempt 2 (9m20s), attempt 3 (15m23s), alongsidemacos-swift (tests).Codex autoreview at the P2 threshold, over several rounds. Three findings were fixed:
errorTextcould hang on a different message. The upgrade-guidance test now awaits the reconnect flush that publishes it: the fake's route-lease arrival is gated andoutboxFlushTaskis awaited. The retry test wakes on the next new non-nil error. I first tried a change-based trigger, and it flaked 5–7 of 20 full-suite runs, becauseerrorTextlegitimately passes throughniland other messages.One finding was declined: awaiting both view models' flush handles in the shared-FIFO test. Those flushes start from metadata readiness, reconcile, and the retry scheduler, so no handle reaches them deterministically from the test. The store's change stream emits only on confirmation, so the confirmation wait is the deterministic arrival signal. Like every deadline-free wait, it would hang rather than fail if a send never confirmed.
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.
Related: #163792, #165068, #165157