Skip to content

fix(test): control heartbeat typing intervals during dispatch - #159980

Merged
steipete merged 1 commit into
mainfrom
codex/ci-heartbeat-typing-clock
Sep 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/ci-heartbeat-typing-clock

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes intermittent heartbeat typing-test failures when slow storage or dispatch work crosses the intentional six-second typing refresh interval.

User Impact

CI checks the initial typing and cleanup behavior independently of worker speed. Runtime typing behavior is unchanged.

Why This Change Was Made

The two affected tests now control only setInterval and clearInterval while the heartbeat operation runs, restoring them in finally. Fixture preparation and cleanup, Date, and timeouts remain real. Existing typing-cadence tests continue to verify the six-second refresh behavior.

Evidence

  • Repeated observed failures: CI run 36353552973 and CI run 36353044715. Calls took roughly nine seconds and legitimately produced two typing notifications while the tests expected one.
  • Blacksmith verification: 20/20 complete-file runs (5 tests each), median 14.93 seconds wall, range 14.17–16.17 seconds.
  • 3/3 original 30-file heartbeat shards passed all 469 tests, preserving the original three-worker limit. Shard walls: 268.56, 277.44, and 270.25 seconds.
  • The separate heartbeat cadence test and 27 channel typing lifecycle tests passed. Full selected checks against the verified pre-patch base and independent P0–P2 review passed.
  • The original file passed its standalone baseline replay; the linked CI failures provide the observed flake evidence. No timeout increases, retries, or assertion relaxations.
  • Current-head PR CI: run 36361263343 passed (610s workflow elapsed). Selected test-job walls: checks-node-changed-boundary: 115s, checks-node-changed: 120s. Job walls include setup and cleanup; standalone file timings are reported above.

Virtualize only interval scheduling around the heartbeat operation so real storage and dispatch latency cannot trigger an unrelated keepalive in the exactly-once assertions. Keep setup, cleanup, Date and timeouts real, and retain separate cadence coverage. Twenty standalone runs, three original shards, siblings, selected checks and independent review passed.
@clawsweeper

clawsweeper Bot commented Sep 28, 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 September 28, 2026 00:11
@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 Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 27, 2026, 10:57 PM ET / September 28, 2026, 02:57 UTC (Revision 3).

ClawSweeper review

What this changes

The PR prevents interval refreshes from firing during two heartbeat typing tests so their start and cleanup assertions do not depend on dispatch speed.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open for human review. Current main still has the timing-sensitive tests, and I found no introduced correctness defect. Exact-head CI passed, but the author's stop command paused automerge.

Priority: P2
Reviewed head: 07d33ba514d4ae5a3fe395c4ff61409bef09a14b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch has no actionable finding and has repeated, relevant validation reported alongside successful exact-head CI.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The supplied MEMBER association exempts this test-only PR from the external-contributor real-setup gate. The changed test still calls the production heartbeat runner with synthetic channel hooks; PR-reported repeats and successful exact-head CI support the flake fix, and no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this test-only PR from the external-contributor real-setup gate. The changed test still calls the production heartbeat runner with synthetic channel hooks; PR-reported repeats and successful exact-head CI support the flake fix, and no stored-data contract changes.
Evidence reviewed 8 items Introduced test change: The pinned introduction changes only two runner-test calls and adds a helper that fakes interval scheduling during the heartbeat operation, restoring real timers in finally.
Still needed on main: Current main still calls the runner with real intervals before asserting exactly one initial typing call; the proposed helper is absent.
Production interval boundary: The production typing controller starts a setInterval keepalive and clears it on stop. The heartbeat runner starts typing before dispatch and calls cleanup in finally.
Findings None None.
Security None None.

How this fits together

OpenClaw's heartbeat runner selects a chat delivery target and starts its typing indicator while an agent reply is dispatched. The shared typing controller refreshes that indicator on an interval and stops it during cleanup.

flowchart LR
  A[Heartbeat trigger] --> B[Delivery target]
  B --> C[Heartbeat runner]
  C --> D[Typing controller]
  D --> E[Channel typing signal]
  C --> F[Reply dispatch]
  F --> G[Typing cleanup]
Loading

Decision needed

Question Recommendation
May this paused heartbeat typing test fix be merged after human review of the current head? Review and land: Confirm the interval isolation and merge the green current head through human review.

Why: The author explicitly stopped automerge, and the live human-review label leaves merge authorization to a person.

Before merge

  • Complete next step (P2) - Have a human reviewer decide whether to land the paused current-head PR.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Tests +10. Total +10 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 12 2 +10
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 12 2 +10

Review metrics

None.

Technical review

Best possible solution:

Keep runner start and cleanup coverage separate from the six-second cadence test, then land the scoped fix through the requested human-review lane.

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

Yes, at the source level: a dispatch lasting beyond the six-second refresh can produce a second typing call before current main's once-only assertion. Two linked CI runs failed the affected shard; this read-only review did not run the test.

Is this the best way to solve the issue?

Yes. Limiting fake timers to interval scheduling during these two assertions addresses the timing assumption while separate coverage still checks the refresh cadence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7526f600cf10.

Labels

Label changes:

  • remove status: 👀 ready for maintainer look: Current PR status no longer selects a status label.

Label justifications:

  • P2: The intermittent test failure affects CI reliability, while the patch changes no production behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.

Evidence

What I checked:

  • Introduced test change: The pinned introduction changes only two runner-test calls and adds a helper that fakes interval scheduling during the heartbeat operation, restoring real timers in finally. (src/infra/heartbeat-runner.typing.test.ts:86, 07d33ba514d4)
  • Still needed on main: Current main still calls the runner with real intervals before asserting exactly one initial typing call; the proposed helper is absent. (src/infra/heartbeat-runner.typing.test.ts:100, 7526f600cf10)
  • Production interval boundary: The production typing controller starts a setInterval keepalive and clears it on stop. The heartbeat runner starts typing before dispatch and calls cleanup in finally. (src/channels/typing-lifecycle.ts:24, 07d33ba514d4)
  • Cadence remains covered: A separate heartbeat typing test advances a controlled clock through 5,999 ms and then 6,000 ms, expecting the second typing call only at the latter point. (src/infra/heartbeat-typing.test.ts:17, 07d33ba514d4)
  • Observed CI failures: Both linked earlier CI runs failed the same compact-large test job. The PR body identifies slow dispatch and a second typing notification as the failure; detailed Actions logs were blocked by this review host's network allowlist. (e91e75226123)
  • Exact-head validation: The current-head CI workflow completed successfully. The PR additionally reports 20 complete-file runs and three original-shard runs; its linked Blacksmith workflow is cancelled overall, so those counts remain PR-reported evidence. (07d33ba514d4)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • pashpashpash: 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 (2 earlier review cycles)
  • reviewed 2026-09-28T00:18:22.348Z sha 07d33ba :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T00:51:44.094Z sha 07d33ba :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper automerge is enabled.

  • Head: 07d33ba514d4
  • Label: clawsweeper:automerge
  • Action: exact-head review queued (workflow sweep.yml, event repository_dispatch).
  • Flow: review this head, repair/rebase only if needed, then re-review the exact repaired head before merge.

Draft PRs stay fix-only until GitHub marks them ready for review. Pause with /clawsweeper stop.

Automerge progress:

  • 2026-09-28 01:15:22 UTC review queued 07d33ba514d4 (queued)

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge label Sep 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper stop

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
Got it. ClawSweeper will leave this item for human review.

I added clawsweeper:human-review, removed clawsweeper:automerge, and paused the automation trail until a maintainer asks again.

@clawsweeper clawsweeper Bot added clawsweeper:human-review Needs maintainer review before ClawSweeper can continue and removed clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@steipete
steipete merged commit 79ef742 into main Sep 28, 2026
189 of 200 checks passed
@steipete
steipete deleted the codex/ci-heartbeat-typing-clock branch September 28, 2026 05:36
steipete added a commit that referenced this pull request Sep 28, 2026
Main's #159980 already wraps the heartbeat run in fake setInterval and
restores real timers in its finally block. Merging it with this branch's
file-level fake timers left a post-run clock advance running after real
timers were restored, which failed CI.

Keep the merged helper as the only timer lifecycle, drop the file-level
fakes and the post-run advance, and keep the added coverage: the
configured typingIntervalSeconds refreshes typing once while the reply is
in flight, and the run clears typing exactly once.
steipete added a commit that referenced this pull request Sep 28, 2026
…nfig (#160229)

* test(infra): drive heartbeat typing keepalive from the test clock

The runner typing test used real timers while runHeartbeatOnce starts the
heartbeat typing keepalive (6 s default interval). Any run slower than one
interval correctly refreshed typing a second time and failed
toHaveBeenCalledOnce on loaded CI runners; the failed-run case shared the
same wall-clock assumption.

Fake only setInterval/clearInterval for the file so keepalive ticks follow
the test clock, configure typingIntervalSeconds, and assert the contract
explicitly: typing starts before the reply, refreshes once per interval
while the reply is in flight, clears once, and stops after the run.

* test(infra): share one fake-interval lifecycle for heartbeat typing

Main's #159980 already wraps the heartbeat run in fake setInterval and
restores real timers in its finally block. Merging it with this branch's
file-level fake timers left a post-run clock advance running after real
timers were restored, which failed CI.

Keep the merged helper as the only timer lifecycle, drop the file-level
fakes and the post-run advance, and keep the added coverage: the
configured typingIntervalSeconds refreshes typing once while the reply is
in flight, and the run clears typing exactly once.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…aw#159980)

Virtualize only interval scheduling around the heartbeat operation so real storage and dispatch latency cannot trigger an unrelated keepalive in the exactly-once assertions. Keep setup, cleanup, Date and timeouts real, and retain separate cadence coverage. Twenty standalone runs, three original shards, siblings, selected checks and independent review passed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…nfig (openclaw#160229)

* test(infra): drive heartbeat typing keepalive from the test clock

The runner typing test used real timers while runHeartbeatOnce starts the
heartbeat typing keepalive (6 s default interval). Any run slower than one
interval correctly refreshed typing a second time and failed
toHaveBeenCalledOnce on loaded CI runners; the failed-run case shared the
same wall-clock assumption.

Fake only setInterval/clearInterval for the file so keepalive ticks follow
the test clock, configure typingIntervalSeconds, and assert the contract
explicitly: typing starts before the reply, refreshes once per interval
while the reply is in flight, clears once, and stops after the run.

* test(infra): share one fake-interval lifecycle for heartbeat typing

Main's openclaw#159980 already wraps the heartbeat run in fake setInterval and
restores real timers in its finally block. Merging it with this branch's
file-level fake timers left a post-run clock advance running after real
timers were restored, which failed CI.

Keep the merged helper as the only timer lifecycle, drop the file-level
fakes and the post-run advance, and keep the added coverage: the
configured typingIntervalSeconds refreshes typing once while the reply is
in flight, and the run clears typing exactly once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:human-review Needs maintainer review before ClawSweeper can continue P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant