Skip to content

fix(cron): declare maintenanceBlocked in runHeartbeatOnce scope - #76028

Closed
JFWaskin wants to merge 7 commits into
openclaw:mainfrom
JFWaskin:fix/maintenance-blocked
Closed

JFWaskin wants to merge 7 commits into
openclaw:mainfrom
JFWaskin:fix/maintenance-blocked

Conversation

@JFWaskin

@JFWaskin JFWaskin commented May 2, 2026

Copy link
Copy Markdown

Summary

TypeScript error fix for #74952. The variable maintenanceBlocked was referenced at three call sites in runHeartbeatOnce but never declared in that function scope — the declaration existed only in the nested replayDeferredRuns closure.

Changes

  • src/infra/heartbeat-runner.ts — Add let maintenanceBlocked = false; alongside let ran = false; in the runHeartbeatOnce function scope.

Root Cause

When maintenance-window role gating was added, maintenanceBlocked = true assignments were added to the outer runHeartbeatOnce function but the variable declaration was only added inside the inner replayDeferredRuns closure. TypeScript flagged Cannot find name maintenanceBlocked at the three outer-scope assignment/usage sites.

Fixes #74952


⚠️ Note for maintainer: This is a targeted fix — once merged, it should be incorporated into the codex/maintenance-window-scheduler-rebased branch before the full PR #74952 is merged.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: XL labels May 2, 2026
@clawsweeper

clawsweeper Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR carries cron maintenance-window role isolation and deferred replay across config, cron runtime, heartbeat scheduling, gateway protocol/UI types, and tests, plus a scoped maintenanceBlocked declaration in runHeartbeatOnce.

Reproducibility: yes. Static inspection of PR head acb7a36fad4c9013e977ef800d42f036c8e30276 shows state.deps.userTimezone is read without a CronServiceDeps field, and the new tests pass requestHeartbeatNow where the contract requires requestHeartbeat.

Next step before merge
An automated repair can address the narrow compile, docs, and changelog blockers on the PR branch, then leave the broader feature semantics for maintainer review.

Security
Cleared: Cleared: the final diff changes TypeScript runtime/config/protocol/UI/test files and does not add dependencies, workflow permissions, install scripts, or secret-handling paths.

Review findings

  • [P1] Declare userTimezone on cron service deps — src/cron/service/timer.ts:763
  • [P1] Use the existing requestHeartbeat dependency name — src/cron/service.manual-run-maintenance.test.ts:54
  • [P2] Document the cron maintenance config — src/config/types.cron.ts:73-76
Review details

Best possible solution:

Make one canonical maintenance-window branch mergeable by fixing the cron dependency contract and test wiring, adding public docs and changelog coverage, then reviewing the scheduler behavior before merge.

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

Yes. Static inspection of PR head acb7a36fad4c9013e977ef800d42f036c8e30276 shows state.deps.userTimezone is read without a CronServiceDeps field, and the new tests pass requestHeartbeatNow where the contract requires requestHeartbeat.

Is this the best way to solve the issue?

No. The maintenanceBlocked declaration is a necessary local fix, but this PR is not the best mergeable solution until the dependency contract, test wiring, docs, changelog, and canonical-branch coordination are handled together.

Full review comments:

  • [P1] Declare userTimezone on cron service deps — src/cron/service/timer.ts:763
    The new maintenance decisions read state.deps.userTimezone in cron timer/status paths, and the gateway passes userTimezone into CronService, but CronServiceDeps still does not declare that field. This leaves the branch with property and excess-property TypeScript errors before it can build.
    Confidence: 0.98
  • [P1] Use the existing requestHeartbeat dependency name — src/cron/service.manual-run-maintenance.test.ts:54
    The added maintenance tests construct the cron service with requestHeartbeatNow, but the dependency contract still requires requestHeartbeat. These object literals are missing the required callback and add an unknown one, so the tests will not typecheck.
    Confidence: 0.96
  • [P2] Document the cron maintenance config — src/config/types.cron.ts:73-76
    This adds public cron.maintenance configuration and new cron/heartbeat behavior, but the final diff does not include docs or CHANGELOG.md. Operators need the config path and behavior documented before this user-facing feature lands.
    Confidence: 0.93

Overall correctness: patch is incorrect
Overall confidence: 0.96

Acceptance criteria:

  • pnpm test src/config/zod-schema.cron-maintenance.test.ts src/cron/service.manual-run-maintenance.test.ts src/cron/service.status-maintenance.test.ts src/cron/service/timer.maintenance-window.test.ts src/infra/maintenance-phase.test.ts src/infra/heartbeat-runner.scheduler.test.ts
  • pnpm config:schema:check
  • pnpm docs:check-mdx docs/automation/cron-jobs.md docs/cli/cron.md
  • pnpm check:changed

What I checked:

  • PR head and current main verified: refs/pull/76028/head is acb7a36fad4c9013e977ef800d42f036c8e30276, related refs/pull/74952/head is ceefb1e30cde21de2473363189a39a29dfb66615, and current main is 8f20d03373f8b2417db41aaf3724ce3720678477. (acb7a36fad4c)
  • Current main lacks the feature: A targeted current-main search found no cron.maintenance, MaintenancePhase, maintenance-phase, or maintenanceBlocked implementation in the relevant runtime/config surfaces; the only hits were existing heartbeat request and timezone docs. (8f20d03373f8)
  • Cron dependency contract mismatch: Current CronServiceDeps declares requestHeartbeat and has no userTimezone; the PR diff adds state.deps.userTimezone reads without adding that dependency field. (src/cron/service/state.ts:44, 8f20d03373f8)
  • PR head reads undeclared dependency: The PR adds state.deps.userTimezone in cron maintenance decisions in timer.ts and ops.ts, so the branch should fail TypeScript until CronServiceDeps is updated consistently. (src/cron/service/timer.ts:763, acb7a36fad4c)
  • New tests use non-contract dependency name: The new maintenance manual-run test passes requestHeartbeatNow, while the service dependency contract requires requestHeartbeat. (src/cron/service.manual-run-maintenance.test.ts:54, acb7a36fad4c)
  • User-facing docs/changelog coverage missing: The PR adds public cron.maintenance config, but the final changed-file list contains no docs/ path and no CHANGELOG.md. (src/config/types.cron.ts:73, acb7a36fad4c)

Likely related people:

  • Peter Steinberger: Recent history shows repeated cron, gateway cron, heartbeat, and config-contract maintenance across the same runtime surfaces touched by this PR. (role: recent maintainer and adjacent owner; confidence: high; commits: 0b1fbeabed8e, 60b61288c40b, 934927fd13ed; files: src/cron/service/timer.ts, src/cron/service/state.ts, src/gateway/server-cron.ts)
  • Vincent Koc: Recent merged work split cron dispatch and task ownership boundaries near the run/session behavior affected by maintenance gating. (role: adjacent scheduler/task-boundary owner; confidence: medium; commits: 1c9053802a98, 74e7b8d47b18, a30214a62494; files: src/cron/service/timer.ts, src/infra/heartbeat-runner.ts)
  • George Zhang: History shows recent heartbeat scheduling work in the same runner path that this PR extends with maintenance deferral and replay. (role: heartbeat scheduler owner; confidence: medium; commits: 9a4a9a5993cc, 2806f2b8786b; files: src/infra/heartbeat-runner.ts)
  • Tak Hoffman: Recent cron stale-run recovery and restart catch-up commits are adjacent to the deferred replay and startup catch-up paths changed here. (role: cron recovery and replay maintainer; confidence: medium; commits: cc5dad81bc70, 28dc2e8a400c, 79d00ae39860; files: src/cron/service/timer.ts)

Remaining risk / open question:

  • The branch is effectively paired with the still-open feat(cron): add maintenance-window role isolation and deferred replay #74952 maintenance-window PR, so maintainers may need to choose one canonical branch after the mechanical blockers are fixed.
  • The scheduler behavior introduces new public config and runtime policy, so compile/docs repairs should not substitute for maintainer review of the feature semantics.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8f20d03373f8.

@JFWaskin

JFWaskin commented May 8, 2026

Copy link
Copy Markdown
Author

Superseded by #79192. This targeted fix branch was useful while the maintenance-window work was being repaired, but the current canonical branch now carries the relevant maintenance-blocking fixes plus protocol/docs/proof coverage. Closing to avoid duplicate stale maintenance-window CI noise.

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

Labels

app: web-ui App: web-ui gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant