Skip to content

test(chat): finish replacing wall-clock polls in the chat suites - #166373

Merged
steipete merged 1 commit into
mainfrom
steipete/ock-waits-b8-chat-tail
Oct 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/ock-waits-b8-chat-tail

Conversation

@steipete

@steipete steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: macos-swift (packages) can fail with Timeout waiting for: … in the remaining chat suites (composer, haptics, stream replay, sidebar previews, voice note recorder) when the full OpenClawKit package runs in parallel on a loaded runner.

User Impact

No user-visible change. With this PR, no chat suite in OpenClawKit uses the 15 s wall-clock waitUntil any more.

Why This Change Was Made

This follows #165157, #165170, #165171, #165172, #165178, and #165187, which converted every ChatViewModel* and NativeConversation* suite. The last 16 chat waits sat in five smaller suites:

  • Stream replay (ChatStreamReplayTests). Its replay bootstrap convergence helper alone timed out 27 times under load. The scripted transport now carries a FIFO barrier: drain() enqueues a marker that resumes only when the view model asks for its next event, which proves that every earlier event was handled. Refreshes those handlers spawn are awaited through the Task handleTransportEvent returns, and bootstrap and send await their owners. No step waits on a clock.
  • Composer, haptics, and replay sends await the send() Task from test(chat): await send and run-event owners instead of wall-clock polls #165157, then assert the exact message, draft, and haptic events.
  • Sidebar previews. The fake gains deadline-free arrival continuations for its cache reads.
  • Voice note recorder. It observes the recording leave the recording state, then asserts the completed recording.

The PR also fixes SwiftFormat findings on test lines the merged series introduced, such as the one-line didSet property bodies on the fake transport state and a few wrapped loop bodies. Only lines that git blame attributes to those six commits changed. Test-only; no production changes.

waitUntil itself stays for now: the gateway node-session suites still use it until the follow-up gateway PR lands and deletes the helper.

Evidence

Deterministic saturation probes, the method from #163792 and #165157. A temporary MainActor flood of 16,000 tasks, each spinning 1 ms, held 420 s, puts one hop past 15 s. A cooperative-pool flood on a one-thread pool and an XCTest twin, which floods from the first XCTest case, were also used, because SwiftPM runs XCTest before Swift Testing. Every run used a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR.

  • Before, on the base (9e56928): under the MainActor flood, 24 tests fail with 38 issues. The issues include replay bootstrap (27), run failed haptic, quoted send accepted, slash send accepted, and old/new cache read starts. The single voice-note XCTest wait did not time out at base, even under its own flood. It is converted anyway because it uses the same 15 s deadline.
  • After, on this head: all 40 Swift Testing tests pass under the MainActor flood (Test run with 41 tests in 6 suites passed after 420.0 seconds) and under the pool flood. The voice-note XCTest passes under its own flood.

Flake-fix proof bar (writing tests, Flake triage step 4), on this head:

  • 20 of 20 clean standalone runs of the five suites (40 Swift Testing tests + 17 XCTest cases each).
  • Owner siblings: every ChatViewModel* and NativeConversation* suite, 20 of 20 clean runs (552 tests each). These also cover the formatting-only edits.
  • 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, same as the earlier series).
  • Codex autoreview at the P2 threshold reported no actionable findings.

Checks. git diff --check is clean, and SwiftFormat lint is clean on every changed line. I did not run the full OpenClawKit suite locally, because its keychain fixtures reach the login keychain on this Mac.

Related: #165157, #165170, #165171, #165172, #165178, #165187

Await send, stream, cache, and recorder progress without wall-clock polling.
Restrict formatting cleanup to lines introduced by the six merged test commits.
Preserve production code and validate batch, sibling, and saturation filters.
@clawsweeper

clawsweeper Bot commented Oct 7, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:07 PM ET / October 7, 2026, 01:07 UTC.

ClawSweeper review

What this changes

The PR replaces remaining clock-based waits in shared Apple chat tests with task completion, stream barriers, cache arrival signals, and observed recorder state, alongside test formatting cleanup.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused test-reliability fix: current main retains the affected polling waits, and no introduced correctness defect was found.

Likely related people: steipete, supported by prior merged work on these suites.

Priority: P2
Reviewed head: 8c3c8e5b16c269cc6a4105c1ffd2b67e738d158c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused synchronization repair with retained assertions, substantial reported flake validation, and no actionable introduced defects.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts ordinary contributor runtime proof. The reported Mac saturation runs exercise the changed test synchronization around the real chat model; no production behavior or 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: Verified repository-admin authorship exempts ordinary contributor runtime proof. The reported Mac saturation runs exercise the changed test synchronization around the real chat model; no production behavior or stored-data contract changes.
Evidence reviewed 8 items Pinned introduced changes: The merge-base-to-head patch changes only test files. Send assertions await existing send tasks; sidebar tests await cache arrivals; the recorder test observes departure from recording before asserting the completed result. Formatting changes preserve existing operations.
Stream barrier matches listener ordering: The production listener awaits MainActor event dispatch before demanding its next stream element. The test transport acknowledges its FIFO marker on that next demand; cases requiring asynchronous reconciliation separately await returned owner tasks.
Work remains on current main: Fetched main still implements replay convergence and send acceptance with waitUntil. The earlier merged series supplies reusable completion handles but does not replace these remaining waits.
Findings None None.
Security None None.

How this fits together

OpenClawKit supplies the shared chat behavior used by the Apple apps. These tests feed scripted sends, events, cache responses, and audio-capture results into that behavior and check the resulting messages and UI state.

flowchart TD
  A[Scripted chat inputs] --> B[Shared Apple chat model]
  C[Cache and audio fixtures] --> B
  B --> D[Owned task completion]
  B --> E[Stream and state signals]
  D --> F[Behavior assertions]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Other +122. Total +122 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 289 167 +122
Total 9 289 167 +122

Review metrics

None.

Technical review

Best possible solution:

Keep chat assertions synchronized with their existing work owners and transport ordering, without adding production seams or extending timeouts.

Do we have a high-confidence way to reproduce the issue?

Yes: current main retains 15-second polling deadlines, and the captured body describes base failures under a sustained MainActor backlog. This review verified the mechanism in source but did not execute the saturation probe.

Is this the best way to solve the issue?

Yes: existing task handles and fixture arrival signals provide narrower, stronger synchronization while preserving behavioral assertions and production code.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c6168a9597e8.

Labels

Label changes:

  • add P2: This repairs reported scheduler-dependent failures in existing Apple chat tests with a bounded test-only change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Verified repository-admin authorship exempts ordinary contributor runtime proof. The reported Mac saturation runs exercise the changed test synchronization around the real chat model; no production behavior or stored-data contract changes.

Label justifications:

  • P2: This repairs reported scheduler-dependent failures in existing Apple chat tests with a bounded test-only 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: Verified repository-admin authorship exempts ordinary contributor runtime proof. The reported Mac saturation runs exercise the changed test synchronization around the real chat model; no production behavior or stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced changes: The merge-base-to-head patch changes only test files. Send assertions await existing send tasks; sidebar tests await cache arrivals; the recorder test observes departure from recording before asserting the completed result. Formatting changes preserve existing operations. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatComposerParityTests.swift:283, 8c3c8e5b16c2)
  • Stream barrier matches listener ordering: The production listener awaits MainActor event dispatch before demanding its next stream element. The test transport acknowledges its FIFO marker on that next demand; cases requiring asynchronous reconciliation separately await returned owner tasks. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift:587, 8c3c8e5b16c2)
  • Work remains on current main: Fetched main still implements replay convergence and send acceptance with waitUntil. The earlier merged series supplies reusable completion handles but does not replace these remaining waits. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatStreamReplayTests.swift:315, c6168a9597e8)
  • Reported flake validation: The captured PR body reports 24 failing base tests with 38 issues under MainActor saturation, passing after-fix saturation runs, 20 clean standalone runs, and 20 clean sibling runs. Voice-note saturation did not reproduce the original timeout, which the body explicitly acknowledges. These results were inspected as reported evidence; this read-only review did not execute Swift tests. (8c3c8e5b16c2)
  • Accepted validation-tier tradeoff: The author records deferring full-package validation to hourly main CI for this series. The supplied merged chore(ci): defer heavy PR jobs to later validation tiers #165231 confirms that macOS Swift jobs were intentionally moved out of ordinary PR selection; skipped Swift PR checks do not establish a patch defect. (28f81543199d)
  • Prior merged area work: Current-main history records Peter Steinberger's merged send-owner conversion and subsequent chat-suite conversions. Haptics history also records earlier structured-haptic and timestamp-flake work. This supports routing to steipete beyond authorship of the proposed branch; source-line introduction attribution was not established. (apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatViewModelTests.swift, 1cebb5362f88)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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.

@steipete
steipete merged commit 63938d8 into main Oct 7, 2026
77 checks passed
@steipete
steipete deleted the steipete/ock-waits-b8-chat-tail branch October 7, 2026 01:26
@steipete

steipete commented Oct 7, 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 7, 2026
…66373)

Await send, stream, cache, and recorder progress without wall-clock polling.
Restrict formatting cleanup to lines introduced by the six merged test commits.
Preserve production code and validate batch, sibling, and saturation filters.
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: M 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