Skip to content

test(chat): replace wall-clock polls in the smaller view model suites - #165178

Merged
steipete merged 5 commits into
mainfrom
steipete/ock-waits-b5-small-files
Oct 5, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/ock-waits-b5-small-files

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: macos-swift (packages) intermittently fails with Timeout 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 with waitUntil, 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 in ChatViewModelAgentNavigationTests; this PR removes the remaining 47 waits across five files:

  • ChatViewModelAgentNavigationTests (13) and ChatViewModelSessionDeletionTests (10)
  • ChatViewModelTranscriptCacheTests (6)
  • ChatViewModelAttachmentTests (17, XCTest)
  • ChatViewModelUnreadTests: its single waitUntil sat inside the waitForUnreadState helper that every unread test used.

Each wait now awaits its owner or an arrival signal: bootstrapTask, the send() 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 a waitForState waiter that resumes on recorded mutations. Where no handle reaches, the tests use the Observation-driven waitForObservedState. This PR moves that helper from ChatViewModelTests.swift into the shared TestAsyncHelpers.swift instead 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 updatedAt and 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 later setSessions cannot leak into that already-started request (ClawSweeper's stale-response ordering finding). This PR also folds #165187's waitForOutboxObservedState into 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.

  • Swift Testing suites (agent navigation, session deletion, transcript cache, unread; filter <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, and write-through stored transcript. After, on 2662ad1bfca58b0e9dfa4b9aba8fb53e6ce38b16: all 60 pass (Test run with 61 tests in 5 suites passed after 420.468 seconds).
  • XCTest attachments. SwiftPM runs XCTest cases before Swift Testing in the same process, so the Swift Testing probe never overlaps them. A temporary XCTest twin of the probe floods from the first case instead. A single flood is absorbed by the first case it delays, so each of the 11 converted attachment cases ran alone under a 150 s flood, which is still ten times the old deadline. Before, on the base: 9 of 11 fail with Timeout waiting for: … (e.g. voice note sent, video attachment staged, legacy gateway bootstrap completed). After, on the previously reviewed c087912a0b36: 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:

  • 20 of 20 clean standalone runs on 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.
  • Owner siblings: every ChatViewModel* and NativeConversation* 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).
  • Original shard: since chore(ci): defer heavy PR jobs to later validation tiers #165231, PR CI no longer selects macos-swift; the full-package macos-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.
  • Codex autoreview at the P2 threshold flagged the unread arrival-versus-applied race above; after the fix it reported no actionable findings. Fresh P2 autoreview of the shared outbox-helper consolidation also reported no actionable findings.

Checks. git diff --check is 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

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 4, 2026 22:56
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 3:56 AM ET / 07:56 UTC (Revision 5).

ClawSweeper review

What this changes

The 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
Reviewed head: 2662ad1bfca58b0e9dfa4b9aba8fb53e6ce38b16

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test reliability repair with the prior ordering defect fixed and substantial reported native validation.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies MEMBER-authored test maintenance, so external-contributor runtime proof is exempt. Reported native saturation runs exercise the chat model's changed test synchronization, with current-head repetitions and sibling coverage; the accepted hourly-native validation tradeoff is recorded separately. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies MEMBER-authored test maintenance, so external-contributor runtime proof is exempt. Reported native saturation runs exercise the chat model's changed test synchronization, with current-head repetitions and sibling coverage; the accepted hourly-native validation tradeoff is recorded separately. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduction and merge scope: The pinned introduction changes Swift tests and test support only. The verified test-merge comparison preserves the same scope; production plumbing and unrelated base changes are not introduced by this PR.
Prior unread finding resolved: The fake captures response rows in the actor operation that records list arrival. The fresh-observation test installs distinct updatedAt rows before releasing the patch gate, then waits for that timestamp to appear before asserting override clearance.
Production ordering checked: Unread success is recorded before scheduling the session refresh. Session-list application rejects older responses and updates the unread guard before publishing rows, supporting the repaired test's distinction between arrival and applied state.
Findings None None.
Security None None.

How this fits together

OpenClawKit 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Other +12. Total +12 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 9 374 362 +12
Total 9 374 362 +12

Review metrics

None.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded native-test reliability repair with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies MEMBER-authored test maintenance, so external-contributor runtime proof is exempt. Reported native saturation runs exercise the chat model's changed test synchronization, with current-head repetitions and sibling coverage; the accepted hourly-native validation tradeoff is recorded separately. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge scope: The pinned introduction changes Swift tests and test support only. The verified test-merge comparison preserves the same scope; production plumbing and unrelated base changes are not introduced by this PR. (2662ad1bfca5)
  • Prior unread finding resolved: The fake captures response rows in the actor operation that records list arrival. The fresh-observation test installs distinct updatedAt rows before releasing the patch gate, then waits for that timestamp to appear before asserting override clearance. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelUnreadTests.swift:207, 2662ad1bfca5)
  • Production ordering checked: Unread success is recorded before scheduling the session refresh. Session-list application rejects older responses and updates the unread guard before publishing rows, supporting the repaired test's distinction between arrival and applied state. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift:1057, 2662ad1bfca5)
  • Current main still needs the work: Fetched main retains the unread suite's timed waits and lacks the relocated observation helper in shared test support. The merged send and outbox follow-ups supply complementary facilities rather than superseding these smaller-suite conversions. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/TestAsyncHelpers.swift:11, fbdb27adbe2b)
  • Reported native validation: The captured body reports current-head saturation recovery for 60 Swift tests, 20 clean standalone repetitions, and 552 sibling tests passing. Attachment saturation results are explicitly from the earlier reviewed head; current-head standalone and sibling results are separately recorded. These are reported results, not reviewer-executed tests. (2662ad1bfca5)
  • Accepted native-validation deferral: The captured body explicitly records a maintainer decision for this series to rely on hourly main native validation. Repository State identifies the author as MEMBER. GitHub verifies chore(ci): defer heavy PR jobs to later validation tiers #165231 merged with the explicit tradeoff that native-only defects may be detected after merge. This covers the current test-only native change and supplies the exception to the previous repeated pre-merge shard request; sibling-PR runs are not treated as current-head runs. (28f81543199d)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-04T23:02:20.037Z sha c087912 :: blocked before merge. :: [P2] Finish the stale list response before publishing the fresh timestamp
  • reviewed 2026-10-04T23:20:51.166Z sha c087912 :: blocked before merge. :: [P2] Finish the stale list response before publishing the fresh timestamp
  • reviewed 2026-10-05T05:11:24.018Z sha c087912 :: blocked before merge. :: [P2] Finish the stale list response before publishing the fresh timestamp
  • reviewed 2026-10-05T05:49:37.832Z sha 2662ad1 :: blocked before merge. :: none

Base automatically changed from steipete/ock-waits-b1-send-helpers to main October 5, 2026 05:05
@steipete
steipete force-pushed the steipete/ock-waits-b5-small-files branch from c087912 to 2662ad1 Compare October 5, 2026 05:38
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 5, 2026
@steipete
steipete merged commit 58a53e6 into main Oct 5, 2026
108 of 111 checks passed
@steipete
steipete deleted the steipete/ock-waits-b5-small-files branch October 5, 2026 08:02
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant