Skip to content

test(infra): cover heartbeat typing keepalive refresh and interval config - #160229

Merged
steipete merged 3 commits into
mainfrom
steipete/heartbeat-typing-fake-clock
Sep 28, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/heartbeat-typing-fake-clock

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #159980

What Problem This Solves

Heartbeat typing has no runner-level test that the typing indicator refreshes while a heartbeat reply is still running, or that agents.defaults.typingIntervalSeconds reaches the heartbeat typing keepalive. If either broke, the typing indicator would lapse during long heartbeat replies or ignore the configured interval, and no test would fail.

User Impact

No user-visible change. Test coverage only.

Why This Change Was Made

This PR started as a fix for the timing flake in runHeartbeatOnce heartbeat typing › starts and clears typing around a heartbeat run (run 36377844500). #159980 landed a fix for that flake first: it wraps only the heartbeat run in fake setInterval/clearInterval. The first revision here faked intervals for the whole file, and GitHub merged it with #159980 without a conflict. The combined test restored real timers before its post-run clock advance, so CI failed. After merging main, this PR uses #159980's helper as the only fake-timer lifecycle and keeps only the coverage it adds.

The main typing case now configures typingIntervalSeconds: 2 and advances the fake clock by one interval while the reply is in flight. It then records typing counts at three points: when the reply starts (one start, no clear), after one configured interval (one keepalive refresh, no clear), and after the run (no further refresh, exactly one clear). The failed-run and no-typing cases are unchanged from main. The default 6 s cadence stays covered by src/infra/heartbeat-typing.test.ts.

Evidence

Merged-head proof (local, after merging main and removing the second timer lifecycle):

  • Focused file: 5/5 pass on a warm run. One earlier cold run timed out the first test at 120 s while the worker compile cache missed (208 s compile at load average about 44); tests that never type took 27–65 s in that run. The warm rerun passed with every test in the file at 33–50 s, load average about 73.
  • Throwaway variant holding the reply and the failed reply for 6.5 s of real time: passes, so the added assertions stay independent of wall-clock speed under fix(test): control heartbeat typing intervals during dispatch #159980's helper.
  • Owner cadence test src/infra/heartbeat-typing.test.ts: passes.
  • Mutation, runner drops the typingIntervalSeconds wiring: fails as intended with the in-flight snapshot { sent: 1 } instead of { sent: 2 }. On the first revision, dropping typing.onCleanup() also failed (cleared: 0); main's exactly-once clear assertion already catches that.
  • Codex autoreview of the net diff against the merged main commit: no remaining P0–P2 findings in the working tree. Its one finding was index-only, the pre-fix merge state this commit replaces.
  • Local check-changed: format and all ratchets pass. The core tsgo graph boundary failed on ui-other: 721 test roots exceeds the advisory 720 limit, which comes from main (the merge brought in ui/src/lib/sessions/session-describe.test.ts), not from this infra-only test change. Local oxlint timed out preparing plugin-sdk boundary artifacts at load average about 70, so lint and typecheck are rerun on Testbox below.

First-revision Testbox proof (tbx_01m3kdxkk1mv8p2ackvk74qby7, 4 vCPU): 20/20 standalone runs of the file (24–27 s wall warm), 3/3 replays of the core-runtime-infra-heartbeat-runner shard, and owner tests passed. On the same host the original file passed 3/3, consistent with the flake needing a run slower than 6 s.

Final-head Testbox proof (infra typecheck, changed-file oxlint, 20 standalone runs, owner test, one shard replay) is running; results will be added here.

Test cost: the unchanged file's five tests took 29.9 s of test time in the original failing CI job; final-head wall time and CI seconds will be added here.

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

@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 6:45 AM ET / 10:45 UTC (Revision 2).

ClawSweeper review

What this changes

Extends the heartbeat runner test to check that a configured two-second interval refreshes typing during a reply and that typing clears when the run finishes.

Merge readiness

✅ Ready for maintainer review

Keep open. The merged timing-flake fix stabilizes the existing test, but current main still lacks this runner-level check for configured typing refresh. The prior review’s timer-lifecycle concern is resolved in the current head.

Priority: P2
Reviewed head: cdbd357d6274302b6b7b6b748e35bfd1953d7a9d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused runner-boundary test adds distinct coverage and resolves the prior review finding; final-head validation was still in progress in the captured context.
Proof confidence 🌊 off-meta tidepool Not applicable: This trusted-author, test-only PR exercises production heartbeat dispatch through an injected reply and mocked chat plugin; the captured body reports passing focused runs, while final-head Testbox results were pending. 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: This trusted-author, test-only PR exercises production heartbeat dispatch through an injected reply and mocked chat plugin; the captured body reports passing focused runs, while final-head Testbox results were pending. No stored-data contract changes.
Evidence reviewed 9 items Introduced coverage: The introduced hunk configures a two-second interval and records typing counts before the reply, after advancing the interval during the reply, and after the run.
Current-main gap: Current main uses a fake-interval helper for the start-and-clear test, but does not assert that a configured interval reaches the runner keepalive.
Production boundary: The production runner passes the configured typing interval to heartbeat typing callbacks before dispatching the reply.
Findings None None.
Security None None.

How this fits together

The heartbeat runner starts an automated agent turn and asks the destination chat plugin to show typing while it runs. Agent settings determine the refresh cadence; runner cleanup stops the indicator.

flowchart LR
A[Heartbeat starts] --> B[Runner starts agent turn]
C[Typing interval setting] --> B
B --> D{Chat supports typing?}
D -->|Yes| E[Start and refresh typing]
E --> F[Clear typing at finish]
D -->|No| G[No typing signal]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +18. Total +18 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 27 9 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 27 9 +18

Review metrics

None.

Technical review

Best possible solution:

Keep one runner-level check for configured refresh and cleanup alongside the existing callback test for the default cadence.

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

Not applicable: this PR adds coverage rather than reporting a current product defect. Comparing current main with the patch identifies the missing runner assertion.

Is this the best way to solve the issue?

Yes. Exercising the production heartbeat runner with a controlled interval checks setting propagation and cleanup at the relevant boundary; the existing callback test covers the default cadence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 14f65626bd25.

Labels

Label changes:

  • 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: This trusted-author, test-only PR exercises production heartbeat dispatch through an injected reply and mocked chat plugin; the captured body reports passing focused runs, while final-head Testbox results were pending. No stored-data contract changes.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This focused test protects the established heartbeat typing setting against a runner-level regression without changing runtime behavior.
  • 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: This trusted-author, test-only PR exercises production heartbeat dispatch through an injected reply and mocked chat plugin; the captured body reports passing focused runs, while final-head Testbox results were pending. No stored-data contract changes.

Evidence

What I checked:

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 (1 earlier review cycle)
  • reviewed 2026-09-28T07:05:07.523Z sha 123da3c :: needs changes before merge. :: [P1] Keep the fake clock active through the post-run assertion

@steipete
steipete enabled auto-merge (squash) September 28, 2026 09:00
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 steipete changed the title test(infra): drive heartbeat typing keepalive from the test clock test(infra): cover heartbeat typing keepalive refresh and interval config Sep 28, 2026
@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 Sep 28, 2026
@steipete
steipete merged commit 988be48 into main Sep 28, 2026
112 of 113 checks passed
@steipete
steipete deleted the steipete/heartbeat-typing-fake-clock branch September 28, 2026 10:51
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

P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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