Skip to content

feat(cron): add maintenance-window role isolation and deferred replay - #74952

Closed
JFWaskin wants to merge 6 commits into
openclaw:mainfrom
JFWaskin:codex/maintenance-window-scheduler-rebased
Closed

JFWaskin wants to merge 6 commits into
openclaw:mainfrom
JFWaskin:codex/maintenance-window-scheduler-rebased

Conversation

@JFWaskin

Copy link
Copy Markdown

Summary

Replacement PR for the maintenance-window scheduler work originally tracked in #55160. The prior PR head is on a fork branch that this account cannot update, so this branch carries the rebased work from a writable fork.

This adds a first-class daily maintenance window with hard role isolation and deferred replay across cron and heartbeat:

  • cron.maintenance config with daily window and explicit maintenance-agent allowlist
  • shared maintenance phase/role resolver
  • cron gating, durable deferred metadata, FIFO replay, and manual-run hard blocks
  • heartbeat gating, in-memory deferred replay, and non-retry maintenance skips
  • additive cron status diagnostics
  • config hot-reload restart coverage for cron/heartbeat changes
  • docs and focused tests for the new behavior

Validation

  • Local dependency check confirmed the previously reported @mariozechner/pi-ai missing-package error was an environment/install issue, not a missing dependency in the current repository state.
  • Rebased branch was prepared on a clean maintenance worktree.
  • Unrelated formatting-only worktree changes were discarded before publishing this replacement branch.

Notes

This PR intentionally contains only public-safe details. No local paths, hostnames, tokens, account IDs, or private runtime data are included.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: XL labels Apr 30, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR adds cron.maintenance config, shared maintenance phase resolution, cron/heartbeat role gating with deferred replay, status/schema/UI type additions, config reload behavior, and focused tests.

Reproducibility: yes. Source inspection of the PR head shows maintenanceBlocked assigned in outer runHeartbeatOnce without an outer declaration, and userTimezone passed/read without being declared on CronServiceDeps; a targeted TypeScript check should reproduce those failures.

Next step before merge
The remaining blockers are narrow mechanical repairs that automation can attempt on the PR branch or a credited replacement branch; maintainer product review can happen after the branch is clean.

Security
Cleared: The cumulative diff touches config, scheduler/runtime code, protocol/UI types, docs-adjacent help text, and tests only, with no workflow, dependency, lockfile, install, release, or package-publishing surface.

Review findings

  • [P2] Declare maintenanceBlocked in runHeartbeatOnce — src/infra/heartbeat-runner.ts:1887
  • [P2] Declare the cron user timezone dependency — src/gateway/server-cron.ts:234
  • [P3] Add public docs and changelog coverage — src/config/types.cron.ts:77
Review details

Best possible solution:

Rebase or replace the branch onto current main, incorporate the linked heartbeat variable fix, declare the cron timezone dependency, add public cron docs and a changelog entry, then rerun the targeted scheduler/config suites and changed gate.

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

Yes. Source inspection of the PR head shows maintenanceBlocked assigned in outer runHeartbeatOnce without an outer declaration, and userTimezone passed/read without being declared on CronServiceDeps; a targeted TypeScript check should reproduce those failures.

Is this the best way to solve the issue?

No. The scheduler area is the right home for the feature, but this branch is not the best merge path until it is rebased and the mechanical type/docs/changelog blockers are fixed.

Full review comments:

  • [P2] Declare maintenanceBlocked in runHeartbeatOnce — src/infra/heartbeat-runner.ts:1887
    runHeartbeatOnce assigns maintenanceBlocked = true and later reads it, but this branch only declares that variable inside the nested replay helper. Strict TypeScript will fail with Cannot find name 'maintenanceBlocked'; declare it in the outer function next to ran.
    Confidence: 0.96
  • [P2] Declare the cron user timezone dependency — src/gateway/server-cron.ts:234
    userTimezone is passed into new CronService and read from state.deps, but CronServiceDeps does not include that field. This leaves both the object literal and property reads outside the declared contract.
    Confidence: 0.94
  • [P3] Add public docs and changelog coverage — src/config/types.cron.ts:77
    This adds a user-facing cron.maintenance config and scheduler behavior, but the PR does not update CHANGELOG.md or the public cron docs. Operators need the window, allowlist, manual-run block, deferred replay, heartbeat, and status semantics documented before release.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.92

Acceptance criteria:

  • pnpm test src/infra/maintenance-phase.test.ts src/config/zod-schema.cron-maintenance.test.ts src/cron/service/timer.maintenance-window.test.ts src/cron/service.manual-run-maintenance.test.ts src/cron/service.status-maintenance.test.ts src/infra/heartbeat-runner.scheduler.test.ts src/gateway/config-reload.test.ts
  • pnpm exec oxfmt --check --threads=1 src/infra/heartbeat-runner.ts src/cron/service/state.ts src/gateway/server-cron.ts docs/automation/cron-jobs.md CHANGELOG.md
  • pnpm check:changed

What I checked:

  • PR state: GitHub API reports this PR open, non-draft, head ceefb1e30cde21de2473363189a39a29dfb66615, no protected labels, mergeable=false, and mergeable_state=dirty against its base. (ceefb1e30cde)
  • Current main lacks the feature surface: Current main has no cron.maintenance, maintenanceAgents, deferred maintenance state fields, or maintenance-blocked cron result surface. (d122a3492d17)
  • Undefined heartbeat variable on PR head: The PR-head runHeartbeatOnce assigns maintenanceBlocked = true in the outer function, but the only declaration shown nearby is let ran = false; the declaration for maintenanceBlocked exists only inside the nested replay helper. (src/infra/heartbeat-runner.ts:1887, ceefb1e30cde)
  • Cron deps contract mismatch: server-cron.ts passes userTimezone into new CronService, and cron ops/timer read state.deps.userTimezone, but PR-head CronServiceDeps does not declare that property. (src/gateway/server-cron.ts:234, ceefb1e30cde)
  • Docs and changelog gap: The PR file list contains config, cron, gateway, heartbeat, test, and UI type files, but no CHANGELOG.md or docs/ update for the new user-facing cron.maintenance config. (src/config/types.cron.ts:77, ceefb1e30cde)
  • Linked follow-up PR: The timeline cross-references open fix(cron): declare maintenanceBlocked in runHeartbeatOnce scope #76028 from the same author, which fixes the missing maintenanceBlocked declaration but does not make this PR head clean or complete. (acb7a36fad4c)

Likely related people:

  • steipete: Recent main history shows repeated work on cron timer behavior, heartbeat wake typing, missed cron startup deferral, cron cleanup, docs, and config reload paths touched or depended on by this PR. (role: recent maintainer; confidence: high; commits: c06739d773da, 61d53f98d314, 7877182b6f59; files: src/cron/service/timer.ts, src/cron/service/state.ts, src/infra/heartbeat-runner.ts)
  • obviyus: Recent merged cron work covers wake-now retry behavior, delivery traces, and deferred cron heartbeat target preservation in the same cron/heartbeat boundary. (role: adjacent owner; confidence: medium; commits: 9797ae35caa7, 4c8299ca3d4f, 1d4e4314dddc; files: src/cron/service/timer.ts, src/cron/service/state.ts, src/gateway/server-cron.ts)
  • amknight: Recent merged work touched heartbeat active-hours scheduling and the cron changed plugin hook near the scheduler/control-plane surfaces this PR extends. (role: adjacent maintainer; confidence: medium; commits: 10448a0ad14c, f155a5f95593; files: src/infra/heartbeat-runner.ts, src/gateway/server-cron.ts, src/cron/service/timer.ts)

Remaining risk / open question:

  • The branch is dirty against current main, so conflict resolution may expose additional issues beyond the source-visible blockers.
  • No local tests were run because this was a read-only review; PR-head CI already reports multiple failed checks.

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

@JFWaskin
JFWaskin force-pushed the codex/maintenance-window-scheduler-rebased branch from 3cff0b4 to ceefb1e Compare May 1, 2026 14:17
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label May 1, 2026
@JFWaskin

JFWaskin commented May 1, 2026

Copy link
Copy Markdown
Author

Manual relay update:

  • Rebased the branch onto current upstream main and force-updated the PR head to ceefb1e30cde21de2473363189a39a29dfb66615.
  • Preserved the maintenance-window cron/heartbeat replay fixes and refreshed the generated config schema.
  • Local focused validation passed: maintenance phase/config tests, cron gating/replay/manual-run/status tests, heartbeat scheduler tests, gateway config reload, schema help/generated-schema checks.
  • git diff --check and oxfmt --check passed on touched files.
  • PR is currently mergeable; GitHub CI has been retriggered and is pending/in progress.

One local note: the broad test:changed command was not used as the final signal because this local fork's origin/main is stale and pulled in unrelated channel setup tests. The focused affected suites above passed against the rebased branch.

@JFWaskin

JFWaskin commented May 7, 2026

Copy link
Copy Markdown
Author

CI status check

@JFWaskin

JFWaskin commented May 8, 2026

Copy link
Copy Markdown
Author

Opened a clean rebased local-relay replacement PR at #79192. It keeps the final maintenance-window diff to one reviewable commit on current main and fixes the stale conflict state from this branch.

@JFWaskin

JFWaskin commented May 8, 2026

Copy link
Copy Markdown
Author

Superseded by #79192, which is the current canonical maintenance-window branch with the cleaned implementation, current real behavior proof, docs/protocol coverage, and passing current checks. Closing this older rebased branch to reduce duplicate review/CI noise. If maintainers want historical comparison, it can be reopened.

@JFWaskin JFWaskin closed this May 8, 2026
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