Skip to content

test(heartbeat): heartbeat live suite never sees the forced monitor poll - #176715

Merged
steipete merged 2 commits into
mainfrom
codex/heartbeat-forced-poll
Oct 19, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/heartbeat-forced-poll

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: the heartbeat live suite (src/infra/heartbeat-runner.live.test.ts) fails on every run on main. Its success case times out because it never sees the forced heartbeat monitor's main-session poll, even though the Gateway wrote it.

User Impact

User impact: no product change. Maintainers get a heartbeat live suite that passes on a healthy build and still proves that monitor polls stay on the main session and never touch the foreground transcript.

Why This Change Was Made

Three test-side problems, verified offline against a real Gateway with a loopback model:

  1. Stale cached read. The test reads the main session through the in-process exact reader before the child Gateway creates it. Since improve(sessions): reduce repeated database reads during chat turns #168316, those retained exact-row facts are invalidated only by writes in the same process, so the read kept returning [] after the Gateway wrote the poll and reply. Cross-process observations now use exactRead: false.
  2. Rejected tool. The monitor prompt asked for heartbeat_respond. The default automatic-reply heartbeat runtime offers that tool but rejects calls to it, so the prompt now asks for a plain reply.
  3. Snapshot taken too early. An exec-completion turn on an internal session can answer NO_REPLY and then receive the required-result recovery reply in the same run (docs/concepts/messages.md). The test now waits for the session to settle (hasActiveRun: false plus the final reply) before snapshotting the foreground transcript.

The post-monitor transcript-isolation assertion is unchanged.

Noticed but out of scope: when heartbeat_respond is rejected during an actual heartbeat run in automatic-reply mode, its error message says it is "only accepted during a heartbeat run", which misleads the model.

Evidence

  • Live, OpenAI, on main: the success case failed 3/3 (main transcript [] after the forced monitor); the watcher-failure case passed.
  • Live after the fix: both cases pass (85s and 63s).
  • Offline replay: the forced monitor run completes (cron.runs ok/succeeded). A fresh read shows [OpenClaw heartbeat poll] plus the reply on main, while the cached read showed [].
  • Autoreview: scoped-clean at P2.

@clawsweeper

clawsweeper Bot commented Oct 19, 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 19, 2026 00:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T01:14:12.725061Z d67efa1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR refreshes cross-process session reads, corrects heartbeat fixture instructions, and waits for completion settlement before comparing transcripts.

Example: Force the heartbeat monitor for agent:main:main after a foreground command completes.

  • Before: The test can retain an empty main-session lookup and time out despite the Gateway writing the poll.
  • After: Fresh reads observe the poll and reply while the completed foreground transcript must remain unchanged.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused, source-supported repair with no identified defect; live results are reported rather than demonstrated in inspectable output.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test repair is outside the ordinary contributor proof gate; its body reports isolated Gateway runs with a real OpenAI model, but no runtime artifact was available to inspect.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Maintainers encounter a failing heartbeat live suite on otherwise healthy Gateway behavior.
Reason: The maintainer-authored direction restores meaningful existing coverage without changing runtime defaults or expanding scope.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs a source-supported live-test failure still present on main, preserves transcript-isolation coverage, and introduces no identified defect.

Priority: P3
Reviewed head: 726812da8ae8d00b24c6a17ccbdb5837bf3b29cc

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The body reports live red/green runs, but the supplied record contains no inspectable terminal output or runtime artifact.
Agent review details

How this fits together

The live suite starts an isolated Gateway, drives background command completions and scheduled heartbeats, then checks persisted transcripts for correct session routing.

flowchart TD
A[Live test] --> B[Child Gateway]
B --> C[Background command completion]
B --> D[Heartbeat monitor]
C --> E[Foreground session transcript]
D --> F[Main session transcript]
E --> G[Fresh reads and isolation assertions]
F --> G
Loading

Technical review

Best possible solution:

Retain this focused fixture repair using existing reader and session-lifecycle owners.

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

The fixture and reader implementation establish the stale cross-process observation path, while the body reports live failures; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses an existing fresh-read mode and documented reply semantics, strengthens settlement checks, and preserves the routing invariant without additional production machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Cross-process session observation keeps the original intent (cbc53ac: The worker migration moved bundled reads to existing async owners while preserving the Gateway as the state owner; the fixture inherited exact-read defaults.)
  • Completion and heartbeat fixture expectations changes intended behavior with a stated reason (29fa603: The earlier watcher repair expanded busy-sibling completion coverage and retained scheduled-monitor isolation; this PR explains why silent internal replies and structured heartbeat instructions no longer fit the fixture contracts.)

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 29fa603 adds src/infra/heartbeat-runner.live.test.ts:198 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 29fa603709fe; files: src/infra/heartbeat-runner.live.test.ts)

PR surface

Tests +5. Total +5 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 20 15 +5
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 20 15 +5

Labels

Label changes:

  • add P3: This repairs an opt-in live-test fixture without changing shipped product behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This repairs an opt-in live-test fixture without changing shipped product behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 18, 2026, 9:07 PM ET / October 19, 2026, 01:07 UTC.

Read fresh session snapshots when observing the child Gateway. Retained exact-row facts introduced in #168316 use in-process write receipts and can retain the initial absence of main after a forced monitor has written its transcript.

Use an automatic-reply heartbeat prompt for the openclaw runtime instead of invoking its disabled structured response tool. Preserve the main-session poll and reply assertions and the foreground transcript isolation check.
Internal dashboard sessions require a final result. NO_REPLY starts bounded required-result recovery, so observing that row alone can snapshot an unfinished continuation. Request the completion marker and wait for no active run before validating the last reply. Keep the exact post-monitor foreground transcript assertion.

Offline loopback proof reproduced seven-to-eight transcript growth with one exec-completion input and one admitted run ID: NO_REPLY followed by required-result recovery. Main monitoring left the held foreground transcript unchanged. Returning the result directly needed one response and preserved the settled transcript across monitoring. See docs/concepts/messages.md silent replies contract.

Validation: gated loopback cases passed; targeted oxlint, oxfmt, diff check, and independent review passed. The existing source-reply-retry test command stalled during module collection and was stopped without a test verdict. The reported different live run ID was not reproduced offline. No live credentials or operator Gateway used.
@steipete
steipete force-pushed the codex/heartbeat-forced-poll branch from 726812d to d67efa1 Compare October 19, 2026 01:11
@steipete
steipete merged commit 85f11f4 into main Oct 19, 2026
95 checks passed
@steipete
steipete deleted the codex/heartbeat-forced-poll branch October 19, 2026 02:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…oll (openclaw#176715)

* test(heartbeat): fix empty forced-monitor transcript reads

Read fresh session snapshots when observing the child Gateway. Retained exact-row facts introduced in openclaw#168316 use in-process write receipts and can retain the initial absence of main after a forced monitor has written its transcript.

Use an automatic-reply heartbeat prompt for the openclaw runtime instead of invoking its disabled structured response tool. Preserve the main-session poll and reply assertions and the foreground transcript isolation check.

* test(heartbeat): wait for settled internal completion results

Internal dashboard sessions require a final result. NO_REPLY starts bounded required-result recovery, so observing that row alone can snapshot an unfinished continuation. Request the completion marker and wait for no active run before validating the last reply. Keep the exact post-monitor foreground transcript assertion.

Offline loopback proof reproduced seven-to-eight transcript growth with one exec-completion input and one admitted run ID: NO_REPLY followed by required-result recovery. Main monitoring left the held foreground transcript unchanged. Returning the result directly needed one response and preserved the settled transcript across monitoring. See docs/concepts/messages.md silent replies contract.

Validation: gated loopback cases passed; targeted oxlint, oxfmt, diff check, and independent review passed. The existing source-reply-retry test command stalled during module collection and was stopped without a test verdict. The reported different live run ID was not reproduced offline. No live credentials or operator Gateway used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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