Skip to content

fix: same-session inferred commitments can be starved indefinitely when a normal HEARTBEAT.md... - #75469

Closed
clawsweeper[bot] wants to merge 8 commits into
mainfrom
clawsweeper/clawsweeper-commit-openclaw-openclaw-955a0e9c0f7d
Closed

clawsweeper[bot] wants to merge 8 commits into
mainfrom
clawsweeper/clawsweeper-commit-openclaw-openclaw-955a0e9c0f7d

Conversation

@clawsweeper

@clawsweeper clawsweeper Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Found one regression risk: same-session inferred commitments can be starved indefinitely when a normal HEARTBEAT.md task is due on every heartbeat tick.

What ClawSweeper Is Fixing

  • Medium: recurring due heartbeat tasks can prevent same-session commitments from ever delivering (regression)
    • File: src/infra/heartbeat-runner.ts:1024
    • Evidence: firstDueCommitment is now only selected when dueHeartbeatTasks.length === 0 (src/infra/heartbeat-runner.ts:1024). When any task is due, resolveHeartbeatRunPrompt returns the task prompt with hasDueCommitments: false (src/infra/heartbeat-runner.ts:870), so dueCommitmentIds is empty and the commitment is neither attempted nor delivered. The scheduler’s follow-up pass explicitly skips the default session key (src/infra/heartbeat-runner.ts:1866), so same-session commitments depend on a later default heartbeat run with no due tasks. For a documented/common setup like heartbeat.every: "5m" and a tasks: entry with interval: 5m, isTaskDue is true again on every cadence tick because it uses nowMs - lastRunMs >= intervalMs (src/auto-reply/heartbeat.ts:288). The new test covers the first half of this state by asserting the due commitment stays pending with `attempts...
    • Impact: users with opt-in inferred commitments and an every-heartbeat task can stop receiving natural follow-up check-ins for that session until the commitment expires, despite docs saying due commitments are delivered through heartbeat for the same agent/channel scope.
    • Suggested fix: keep task turns tool-capable, but process same-session commitments in a separate no-tools turn after the task run, or add a commitment-only wake/path that bypasses task selection without mixing untrusted commitment metadata into the tool-capable task prompt.
    • Confidence: high

Expected Repair Surface

  • src/infra/heartbeat-runner.ts
  • src/infra/heartbeat-runner.commitments.test.ts

Source And Review Context

Expected validation

  • pnpm check:changed

ClawSweeper already ran:

  • pnpm docs:list completed.
  • git diff --check 173f959613b35195c8e4e662b9e0138831cfb4d2..955a0e9c0f7d969e7d96cade7b383b3306aadf98 passed.
  • Initial focused test run failed because node_modules was missing; pnpm install succeeded.
  • pnpm test src/infra/heartbeat-runner.commitments.test.ts src/infra/heartbeat-runner.returns-default-unset.test.ts passed: 41 tests.

Known review limits:

  • I did not run the broad changed gate.
  • An inline tsx smoke attempt was stopped because importing the runner staged bundled plugin runtime dependencies and did not reach scenario output quickly enough.

ClawSweeper Guardrails

  • Re-check the finding against latest main before changing code.
  • Keep the patch to the narrowest behavior change and matching regression coverage.
  • Do not merge automatically; this PR stays for maintainer review.

ClawSweeper 🐠 replacement reef notes:

  • Cluster: clawsweeper-commit-openclaw-openclaw-955a0e9c0f7d
  • Source PRs: none
  • Credit: Detected by ClawSweeper commit review for 955a0e9.; Original commit author: clawsweeper[bot].
  • Validation: pnpm check:changed

fish notes: model gpt-5.5, reasoning medium; reviewed against 46af05b.

@clawsweeper clawsweeper Bot added clawsweeper Tracked by ClawSweeper automation clawsweeper:commit-finding PR created from a ClawSweeper commit finding labels May 1, 2026
@clawsweeper

clawsweeper Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex review: found issues before merge. Reviewed July 3, 2026, 10:04 PM ET / July 4, 2026, 02:04 UTC.

Summary
The PR adds a post-task commitment-only heartbeat pass and regression tests so due HEARTBEAT.md tasks are followed by same-session inferred commitment delivery.

PR surface: Source +34, Tests +195. Total +229 across 2 files.

Reproducibility: yes. source-reproducible: current main selects task prompts when due tasks exist, keeps due commitments out of that run, and then skips default-session fan-out. I did not run tests because this review is read-only.

Review metrics: 1 noteworthy metric.

  • Internal run-mode surface: 1 stale parallel mode added. The PR adds commitmentOnly while current main already has a closed HeartbeatRunScope, so maintainers should notice the contract drift before merge.

Root-cause cluster
Relationship: canonical
Canonical: #75469
Summary: This PR remains the canonical open item for the narrow same-session post-task commitment starvation; merged run-scope work overlaps but does not close the central behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh the implementation onto current main using runScope: "commitment-only" and remove the commitmentOnly flag path.
  • [P1] Add or keep focused tests for same-session due task delivery, quiet heartbeat_respond task acks, and default-session scheduler behavior.
  • Provide final-head redacted Telegram proof or an explicit maintainer proof override.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body contains tests but no exact-head real behavior proof; a redacted Telegram Desktop recording, terminal output, logs, or maintainer proof override is still needed before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
Native Telegram proof would directly show whether the refreshed branch sends exactly one post-task commitment check-in to the intended target. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify that a due HEARTBEAT.md task is followed by exactly one same-session inferred commitment check-in using the refreshed current-head branch.

Risk before merge

  • [P1] The current PR head is conflicting and uses a stale commitmentOnly boolean instead of current main's HeartbeatRunScope, so direct merge would create or preserve competing internal run-mode contracts.
  • [P1] The fix changes visible commitment check-in delivery after a due heartbeat task, so duplicate, suppressed, or wrong-target delivery still needs final-head Telegram proof or an explicit maintainer waiver before merge.

Maintainer options:

  1. Refresh onto HeartbeatRunScope (recommended)
    Rebase or replace the branch so the post-task same-session commitment pass uses runScope: "commitment-only" and removes the stale commitmentOnly flag path.
  2. Require final-head Telegram proof
    Before merge, capture or waive proof that a due task is followed by exactly one same-session commitment check-in to the intended target.
  3. Pause if proof is not worth pursuing
    If maintainers do not want to invest in transport proof for this visible delivery path, leave this PR paused rather than merging the stale branch.

Next step before merge

  • [P2] The code repair is narrow, but the PR needs a branch refresh plus maintainer-controlled real behavior proof or waiver before any merge path is safe.

Security
Cleared: The PR diff only changes heartbeat runner logic and tests; I found no concrete security or supply-chain regression in the submitted files.

Review findings

  • [P1] Use the current heartbeat run scope — src/infra/heartbeat-runner.ts:1318
Review details

Best possible solution:

Refresh the branch into a narrow heartbeat-runner change that runs a same-session runScope: "commitment-only" pass after a successful due-task turn, keeps the current run-scope abstraction, and includes focused regression coverage plus final-head transport proof or waiver.

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

Yes, source-reproducible: current main selects task prompts when due tasks exist, keeps due commitments out of that run, and then skips default-session fan-out. I did not run tests because this review is read-only.

Is this the best way to solve the issue?

No, this PR is not the best merge vehicle as-is. The requested behavior is still needed, but the implementation should be refreshed onto current main's HeartbeatRunScope instead of preserving the stale commitmentOnly path.

Full review comments:

  • [P1] Use the current heartbeat run scope — src/infra/heartbeat-runner.ts:1318
    Current main already has HeartbeatRunScope and propagates runScope: "commitment-only" through heartbeat scheduling and runtime adapters. Keeping this PR's separate commitmentOnly?: boolean path after conflict resolution would create a second internal mode contract, so refresh the fix onto runScope instead.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded heartbeat/commitment delivery bug with user-visible follow-up impact but no evidence of a core outage.
  • merge-risk: 🚨 session-state: The patch changes heartbeat session scheduling and commitment delivery state after task turns.
  • merge-risk: 🚨 message-delivery: The patch can add a visible Telegram commitment check-in after a due task and must prove target and duplicate behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body contains tests but no exact-head real behavior proof; a redacted Telegram Desktop recording, terminal output, logs, or maintainer proof override is still needed before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change can visibly send a same-session commitment check-in in Telegram after a due heartbeat task, which is well suited to a short desktop proof.
Evidence reviewed

PR surface:

Source +34, Tests +195. Total +229 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 51 17 +34
Tests 1 209 14 +195
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 260 31 +229

What I checked:

  • Current main still suppresses same-session commitments when tasks are due: runHeartbeatOnce resolves due tasks and only selects firstDueCommitment when dueHeartbeatTasks.length === 0, so a task-due normal heartbeat does not include the due commitment in that run. (src/infra/heartbeat-runner.ts:1551, a1063aa4c83f)
  • Current scheduler still skips default-session fan-out: After a normal heartbeat tick, the scheduler lists due commitment session keys but continues when the due session is the default session, leaving the same-session case dependent on a later no-task heartbeat. (src/infra/heartbeat-runner.ts:2685, a1063aa4c83f)
  • Merged scope work is partial overlap, not the same fix: Merged commit 180a970 added a private HeartbeatRunScope and commitment-only isolation across runtime surfaces, but it did not add the post-task same-session commitment pass that this PR targets. (src/infra/heartbeat-run-scope.ts:1, 180a970ac045)
  • PR head has the useful same-session regression coverage: The PR-head test exercises a due task plus a due same-session commitment and expects task delivery first, then the commitment check-in to the commitment target. (src/infra/heartbeat-runner.commitments.test.ts:179, 4d3a6f0323b7)
  • PR head uses a stale run-mode shape: The PR adds commitmentOnly?: boolean and recursively calls runHeartbeatOnce with that flag, while current main has replaced this direction with the closed runScope: "commitment-only" contract. (src/infra/heartbeat-runner.ts:1318, 4d3a6f0323b7)
  • Live PR state blocks direct merge: GitHub reports head 4d3a6f0 as CONFLICTING / DIRTY, so the branch cannot land without a refresh. (4d3a6f0323b7)

Likely related people:

  • bdjben: Authored the merged heartbeat run-scope PR that now owns the current commitment-only contract this PR must refresh onto. (role: recent area contributor; confidence: high; commits: 180a970ac045; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-run-scope.ts, src/infra/heartbeat-runner.commitments.test.ts)
  • RomneyDa: Current blame on the central heartbeat runner lines points to the recent async timing refactor, making this a useful routing signal for current-main conflict resolution. (role: recent adjacent refactor contributor; confidence: medium; commits: c7aca4f02938; files: src/infra/heartbeat-runner.ts)
  • vignesh07: Merged the commitment safety and coverage PR that established due-commitment no-tools handling in the same heartbeat runner/test area. (role: introduced adjacent commitment-safety behavior; confidence: medium; commits: b277ae3f4c40; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.commitments.test.ts, src/commitments/store.ts)
  • clawsweeper[bot]: The merged repair that kept due task runs tool-capable changed the exact task-versus-commitment selection path this PR is trying to follow up on. (role: adjacent repair author; confidence: medium; commits: 955a0e9c0f7d; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.commitments.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper

clawsweeper Bot commented May 1, 2026 •

Copy link
Copy Markdown
Contributor Author

🦞🔧
ClawSweeper picked up the repair feedback.

Source: clawsweeper[bot]
Feedback: structured ClawSweeper needs-human verdict with repairable P-severity findings (sha=4d3a6f0323b7380801f0bf3900b26aced6585510)
Action: repair worker queued. Run: https://github.com/openclaw/clawsweeper/actions/runs/29090510189

I will update this PR branch, or open a safe credited replacement, if the repair worker finds a narrow fix.

Automerge progress:

  • 2026-06-16 00:41:45 UTC review queued 4d3a6f0323b7 (after repair)
  • 2026-07-10 11:15:27 UTC review requested repair 4d3a6f0323b7 (structured ClawSweeper needs-human verdict with repairable P-severity findings...)

@clawsweeper
clawsweeper Bot force-pushed the clawsweeper/clawsweeper-commit-openclaw-openclaw-955a0e9c0f7d branch from 46af05b to 67c8ef1 Compare May 1, 2026 21:40
@clawsweeper
clawsweeper Bot force-pushed the clawsweeper/clawsweeper-commit-openclaw-openclaw-955a0e9c0f7d branch from 4cc80ec to 8a8a40e Compare May 1, 2026 21:55
@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 14, 2026
@clawsweeper
clawsweeper Bot force-pushed the clawsweeper/clawsweeper-commit-openclaw-openclaw-955a0e9c0f7d branch from 8a8a40e to 3823dc1 Compare May 15, 2026 22:56
@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 14, 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. stale Marked as stale due to inactivity labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor Author

ClawSweeper status: this ClawSweeper-authored replacement PR is blocked on real behavior proof.

Reviewed head: e5b86bd2f80b152eb833353bfedee850ea644835
Proof status: not_applicable
Updated: 2026-06-15T12:05:19.018Z

Maintainer decision needed:

  • capture real behavior proof for this head
  • apply proof: override if the proof requirement should be waived
  • pause or close the replacement if proof should not be pursued

Mantis proof suggestion:

@openclaw-mantis telegram desktop proof: verify that a due HEARTBEAT.md task is followed by a same-session inferred commitment check-in.

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. and removed status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 23, 2026
@clawsweeper clawsweeper Bot added status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: needs maintainer proof decision A ClawSweeper-authored PR needs a maintainer proof capture or override decision. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 26, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@steipete

Copy link
Copy Markdown
Contributor

Thank you for identifying the same-session commitment starvation. I independently reproduced it against current main with the actual cron-monitor wake, SQLite commitment store, heartbeat prompts, and Telegram delivery. The canonical scheduler-owner fix has now landed in #115581 (5d55258): pending default-session commitments receive the existing tools-disabled follow-up, while already-delivered commitments are never sent twice. The first-failing regression, 65 cross-surface tests, complete changed gate, and exact-head CI all pass. Closing this older implementation as superseded by the landed canonical fix; thank you for the original report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:commit-finding PR created from a ClawSweeper commit finding clawsweeper Tracked by ClawSweeper automation mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants