Skip to content

test(chat): await progress, foreground, and capability owners in view model tests - #165170

Merged
steipete merged 3 commits into
mainfrom
steipete/ock-waits-b2
Oct 5, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/ock-waits-b2

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 ChatViewModelTests 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 the chat view model progress-card, foreground, and run-recovery tests.

Why This Change Was Made

Follows #165157 (rebased onto main after it landed; patch-identical to the proven head 5b45958). These tests detected product progress with waitUntil, a 15 s wall-clock poll. In CI the whole package runs in one parallel swift test process, 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 first third of the remaining ChatViewModelTests waits: 68 tests, 122 waits.

Each wait now awaits its owner or an arrival signal, so a backlog can delay it but cannot expire it:

  • Event settling. Tests deliver progress-card, seq-gap, route, and metadata events through handleTransportEvent and await the Task it returns. handleProgressCardChanged now returns the progress-card fetch Task it already scheduled. The metadata event now returns its swarm-capability refresh, which a follow-up PR extends to the model refresh as well.
  • Foreground recovery. resumeFromForeground() now returns the Task it already spawned (@discardableResult; production callers ignore it), and the foreground tests await it.
  • Bootstrap, send, and question refresh. Tests await bootstrapTask, the send() Task, and questionRefreshRetryTask.
  • Request arrivals. Existing hook gates expose waitUntilBlocked(), and the counter and recorder wait(until:) from test(chat): await send and run-event owners instead of wall-clock polls #165157 cover the rest.
  • No reachable owner. Streaming text from emitted deltas and similar cases use the Observation-driven 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 0 lines: the return-plumbing is funded by turning if !matchesCurrentSession, !isOurRun { return nil } into an equivalent guard.

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.

  • Before, on the base (a44817c): 30 of the 68 tests fail, with 47 issues, e.g. remote run is adopted, foreground history applies, new session progress card applies, and failed progress refresh applies its denial outcome.
  • After, on the patch-identical proven head (5b45958): all 68 pass under the identical flood (Test run with 69 tests in 2 suites passed after 420.0 seconds).

Flake-fix proof bar (writing tests, Flake triage step 4), on the patch-identical proven head with a private HOME, CFFIXED_USER_HOME, OPENCLAW_STATE_DIR, and TMPDIR:

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.

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

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

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

Native chat view-model tests await existing task completion and arrival signals instead of deadline-based polling, with small production changes that return existing task handles.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main retains the targeted polling waits. No actionable introduced defect was found, and the latest commit preserves the previously reviewed behavior.

Priority: P2
Reviewed head: 16f6fd6e0ac87c546ce7bf4fc2ac0b933b149094

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable reliability repair with strong targeted saturation evidence and no actionable correctness findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured native Swift saturation results directly exercise the changed test synchronization against the production chat view model, with targeted failures before and all 68 cases passing afterward; rebased-head standalone and sibling results supplement that evidence. The latest head changes only redundant return syntax. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured native Swift saturation results directly exercise the changed test synchronization against the production chat view model, with targeted failures before and all 68 cases passing afterward; rebased-head standalone and sibling results supplement that evidence. The latest head changes only redundant return syntax. No stored-data contract changes.
Evidence reviewed 7 items Introduced production behavior: The pinned introduced delta returns existing progress-card, capability, and foreground tasks without changing their scheduling; the rewritten chat guard is logically equivalent.
Still necessary on current main: Current main still polls for initial and changed progress cards, and foreground activation still returns no completion handle. The merged preceding batches therefore do not supersede this batch.
Review continuity: GitHub's comparison against the previous reviewed head shows only removal of an explicit return from the single-expression foreground method. The previous completed review retained no findings.
Findings None None.
Security None None.

How this fits together

OpenClaw's shared native chat view model turns Gateway events and foreground activation into transcript, progress-card, and capability updates. These tests verify those updates after their owning work settles.

flowchart TD
  A[Gateway events] --> C[Native chat view model]
  B[Foreground activation] --> C
  C --> D[Existing refresh tasks]
  D --> E[Chat and progress state]
  D --> F[Completion and arrival signals]
  F --> G[Test assertions]
  E --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Other -102. Total -102 across 4 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 4 496 598 -102
Total 4 496 598 -102

Review metrics

Metric Value Why it matters
Production versus test growth production net 0 lines; tests net −102 lines The production changes expose existing completion handles without net growth, and the test conversion reduces polling boilerplate.

Technical review

Best possible solution:

Keep native chat assertions synchronized with existing operation owners while preserving production scheduling and session guards.

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

Yes: the supplied saturation scenario targets the actual Swift test process, and current main still has deadline-based waits over queued MainActor work. This read-only review did not execute that scenario.

Is this the best way to solve the issue?

Yes: awaiting existing operation completion and fixture arrival signals removes the scheduling deadline while retaining the behavioral assertions and established production owners.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured native Swift saturation results directly exercise the changed test synchronization against the production chat view model, with targeted failures before and all 68 cases passing afterward; rebased-head standalone and sibling results supplement that evidence. The latest head changes only redundant return syntax. No stored-data contract changes.

Label justifications:

  • P2: This is a bounded native test reliability repair with no demonstrated change to user-visible chat behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured native Swift saturation results directly exercise the changed test synchronization against the production chat view model, with targeted failures before and all 68 cases passing afterward; rebased-head standalone and sibling results supplement that evidence. The latest head changes only redundant return syntax. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured native Swift saturation results directly exercise the changed test synchronization against the production chat view model, with targeted failures before and all 68 cases passing afterward; rebased-head standalone and sibling results supplement that evidence. The latest head changes only redundant return syntax. No stored-data contract changes.

Evidence

What I checked:

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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-04T22:49:18.506Z sha 5b45958 :: needs changes before merge. :: none
  • reviewed 2026-10-04T23:20:48.191Z sha 5b45958 :: needs changes before merge. :: none
  • reviewed 2026-10-05T05:10:34.586Z sha 5b45958 :: blocked before merge. :: none
  • reviewed 2026-10-05T05:21:27.614Z sha 2bdf553 :: needs changes before merge. :: none
  • reviewed 2026-10-05T07:34:39.752Z sha 2bdf553 :: needs maintainer review before merge. :: none

@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 4, 2026
Base automatically changed from steipete/ock-waits-b1-send-helpers to main October 5, 2026 05:05
Await bootstrap, send, foreground, event, and retry tasks or deadline-free
fake arrivals and observed state; isolate periodic recovery in foreground fixtures.
Return existing foreground, chat, progress-card, and Swarm settling tasks
without changing behavior or increasing production line count.
@steipete
steipete force-pushed the steipete/ock-waits-b2 branch from 5b45958 to 2bdf553 Compare October 5, 2026 05:15
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 5, 2026
@steipete
steipete merged commit b658e68 into main Oct 5, 2026
72 checks passed
@steipete
steipete deleted the steipete/ock-waits-b2 branch October 5, 2026 08:15
@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
… model tests (openclaw#165170)

* test(chat): replace polling waits with owned completion signals

Await bootstrap, send, foreground, event, and retry tasks or deadline-free
fake arrivals and observed state; isolate periodic recovery in foreground fixtures.
Return existing foreground, chat, progress-card, and Swarm settling tasks
without changing behavior or increasing production line count.

* test(chat): drop assertions repeated by observed waits

* style(chat): drop the redundant return in resumeFromForeground
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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