Repository navigation
Fix/heartbeat task due clock skew - #64611
Rahulkumar070 wants to merge 3 commits into
Conversation
Greptile SummaryThis PR adds a Confidence Score: 5/5This PR is safe to merge — the fix is minimal, correctly scoped, and fully tested. The one-line guard is logically correct, preserves all existing behavior for normal clock progression, and is well-covered by the new unit tests. No P0 or P1 findings. No files require special attention. Reviews (1): Last reviewed commit: "fix: treat future lastRunMs as never-run..." | Re-trigger Greptile |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: current main and v2026.6.11 still lack the clock-skew guard, and the PR is a narrow, source-correct fix, but it needs real behavior proof, current-base validation, and maintainer acceptance of the heartbeat task-state semantic change before merge. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main and v2026.6.11 compute Is this the best way to solve the issue? Yes for the code shape: the shared Security review: Security review cleared: Security review cleared: the diff only changes a local heartbeat due-time helper and colocated unit tests, with no dependency, CI, credential, network, permission, or code-execution surface changes. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against c5afa92c1f8a. |
|
Codex review: needs maintainer review before merge. What this changes: This PR changes heartbeat task due calculation to treat a future Maintainer follow-up before merge: This is already an open contributor implementation PR; the remaining action is maintainer review, rebase or cherry-pick, and validation rather than an automated replacement fix PR. Review detailsBest possible solution: Heartbeat task due checks should treat future last-run timestamps as due, preserve normal elapsed/not-elapsed behavior, and keep the regression locked in with focused Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against acae48b790fa. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
Heads up: this PR needs to be updated against current |
|
This pull request has been automatically marked as stale due to inactivity. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: Fix/heartbeat task due clock skew This is item 1/1 in the current shard. Shard 9/22. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Thank you for identifying and testing the backward-clock edge case; that insight is valid. This particular implementation has since been superseded by the merged heartbeat-task migration in #113165 (commit b23c7bd0f84), which removes both legacy isTaskDue and parseHeartbeatTasks rather than retaining the old in-prompt task scheduler. Current heartbeat tasks are independently scheduled cron jobs; the system-owned heartbeat-monitor path and src/infra/heartbeat-runner.scheduler.test.ts cover canonical cadence and execution. The remaining far-future cron run-marker case is separately tracked and addressed by #111743. Because this branch changes and tests a helper that no longer exists on main, closing this PR as superseded rather than merging dead API back into the current scheduler. Thank you again for the original regression tests and analysis. |
Summary
isTaskDuesilently fails when system clock moves backward (NTP correction, VM resume, timezone change).nowMs - lastRunMsbecomes negative so the task never runs.lastRunMs + interval, which could be 30+ minutes with no error or warning.lastRunMs > nowMsguard that treats a futurelastRunMsthe same asundefined(never run).Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
isTaskDuecomputesnowMs - lastRunMswithout checking iflastRunMsis in the future. A backward clock jump makes this negative, so the condition>= intervalMsis never true.lastRunMs > nowMs(clock skew scenario).Regression Test Plan (if applicable)
src/auto-reply/heartbeat.test.tsisTaskDuereturnstruewhenlastRunMs > nowMsisTaskDuehad zero tests before this PR.User-visible / Behavior Changes
Heartbeat tasks now resume immediately after a clock correction instead of being stuck for up to
intervalminutes.Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
Steps
lastRunMsto a future timestamp (simulating clock skew)isTaskDue(futureMs, "30m", nowMs)Expected
true(task should run)Actual (before fix)
false(task permanently stuck)Evidence
Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations