Repository navigation
fix(heartbeat): stop cron wakes from forcing the main session over heartbeat.session - #116373
sloptop-the-terrible wants to merge 11 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 5:55 AM ET / 09:55 UTC. ClawSweeper reviewWhat this changesThe PR lets sessionless interval heartbeat monitor wakes use the configured heartbeat session while retaining explicit and cron-event session targets. Merge readinessThe PR addresses a current-main session-routing bug at the Gateway adapter and has no blocking correctness finding. Keep it open for current-base merge validation because the adapter changed around it after the branch base. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherCron timer execution emits heartbeat wakes, and the Gateway adapter resolves their agent and session before the heartbeat runner consumes queued events. The selected session controls transcript ownership and outbound delivery routing. flowchart LR
A[Heartbeat monitor] --> B[Cron timer execution]
B --> C[Gateway cron adapter]
C --> D[Heartbeat wake queue]
D --> E[Heartbeat session resolver]
E --> F[Transcript and delivery route]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +694. Total +697 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Retain the narrow Gateway-adapter gate, validate it on the current three-way merge result, and preserve the existing explicit-session and cron-event routing contracts. Do we have a high-confidence way to reproduce the issue? Yes—current main’s timer emits a sessionless interval wake, the Gateway forwards a resolved main key, and the resolver honors that forced key before heartbeat.session. Is this the best way to solve the issue? Yes—the adapter is the narrow owner boundary where a missing caller session becomes a forced main key; changing the runner would alter the general explicit-session contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 225aa5a17823. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (20 earlier review cycles; latest 8 shown)
|
3942aa8 to
a478f42
Compare
|
Focused rank-up proof on current head
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review The PR body now includes no-mock before/after runtime evidence from the real gateway cron adapter and heartbeat wake path, covering both configured non-main selection and explicit-session preservation. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
7250b02 to
fb98ac8
Compare
|
Rebased onto current The untargeted-caller gap is now proven, not assumed. The earlier proof exercised only the
The compatibility contract is still a maintainer decision — I have documented the change rather than decided it. Concretely, for any caller that supplies an agent ID and omits
That is the intended repair for the linked bug — the main-session fallback was shadowing |
|
Hoping this lands soon. Cron wakes no longer pull the main session off the heartbeat lane. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Superseded by the workflow-only same-repository replacement #127153, now landed on The accepted source head, replacement head, and landed commit all have stable patch ID Closing this external source PR only after the equivalent replacement landed successfully. |
|
Superseded by the repo-native same-repository replacement #127153, now landed on canonical The landed squash preserves this PR's reviewed patch exactly: The canonical squash credits @sloptop-the-terrible in both the commit message and |
What Problem This Solves
agents.*.heartbeat.sessionis ignored for recurring monitor/task heartbeats. The system-owned monitor is intentionally scheduled withsessionTarget: "main", but its execution request carries onlysource: "interval"plusagentId. The Gateway cron adapter resolved that agent-only request to an explicit main-session key, and the heartbeat runner treated it as caller-forced before consulting the configured heartbeat session.Fixes #116205.
Root Cause and Full Route
src/cron/heartbeat-monitor.tskeepssessionTarget: "main"as scheduling metadata.src/cron/service/timer-execution.tsturns heartbeat monitor/task payloads intosource: "interval"wake requests withagentIdand no caller session.src/gateway/server-cron.tspreviously synthesized the agent's main session and forwarded it into the wake bus.agents.*.heartbeat.session.SessionKey, delivery route, and durable send.The repair stays at the ownership boundary where absence became a forced value: only a sessionless
intervalrequest now reaches the wake bus withsessionKey: undefined. The downstream runner then appliesheartbeat.session(or its existing default). Caller-explicit sessions remain forced.Non-interval cron event wakes are deliberately unchanged. They keep the resolved main/session key because the system event was queued in that session and must be consumed from the same queue.
runHeartbeatOnceis also unchanged for that reason.Evidence
The boundary regression was first run against pre-fix main:
At exact head
5128a65885700e6bd033dbefb0a6c274db5a8b07on basebafa32fd544b5ad8ac0cba75ebb76bef2250e1d7:Exact-head command:
Additional focused proof on the patch-equivalent stack:
git range-diffconfirms all four commits are patch-equivalent after the final current-main rebase. Contributor authorship is preserved on the original three commits.Review and Surface
+4/-1(src/gateway/server-cron.ts)+93/-0(src/gateway/server-cron.test.ts)+97/-1, 2 filesgpt-5.6-sol, high)CLEAN; confirmed the Gateway adapter as the smallest correct boundary and no material residual test gapUser Impact
heartbeat.sessionvalues.heartbeat.sessionretain the existing downstream default.