Skip to content

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

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

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

Conversation

@JFWaskin

@JFWaskin JFWaskin commented Mar 26, 2026 •

Copy link
Copy Markdown

Summary

Adds a first-class daily maintenance window with hard role isolation and deferred replay across cron + heartbeat.

What changed

  • Added cron.maintenance config:
    • enabled
    • window.start
    • window.end
    • window.timezone
    • maintenanceAgents
  • Added shared maintenance resolver + role check (normal | maintenance) used by both schedulers.
  • Cron scheduler updates:
    • phase/role gating for due jobs
    • durable deferred metadata/counters in cron state
    • FIFO deferred replay when phase allows
    • recurring alignment preserved after replay
    • cron.run hard-block on phase/role mismatch with maintenance-blocked
    • additive cron.status diagnostics for maintenance window/phase/deferred counts
  • Heartbeat runner updates:
    • phase/role gating for interval + targeted wakes
    • in-memory per-agent deferred queue
    • FIFO replay when phase allows
    • maintenance-blocked skips are surfaced as non-retry skips (prevents retry storms)
  • Config hot-reload plan now restarts both cron service and heartbeat runner when cron.maintenance.* changes.
  • Gateway/UI/protocol/docs updated with backward-compatible additive fields.

Validation

  • Passed format checks on touched files:
    • ./node_modules/.bin/oxfmt --check --threads=1 <touched-files>
  • Targeted tests are currently blocked in this execution environment due missing dependency:
    • Command:
      • ./node_modules/.bin/vitest run --config vitest.unit.config.ts 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
    • Failure before test execution:
      • Cannot find package '@mariozechner/pi-ai/oauth' imported from src/agents/auth-profiles/oauth.ts

Notes

  • This branch includes new focused tests for maintenance config, phase resolver, cron gating/replay/manual run/status diagnostics, heartbeat gating/replay, and config-reload triggers.
  • Commit was created with --no-verify because local pre-commit hooks invoke pnpm, which was unavailable on PATH in this run context.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: XL labels Mar 26, 2026
@greptile-apps

greptile-apps Bot commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a first-class daily maintenance window for role isolation across the cron scheduler and heartbeat runner. When cron.maintenance is enabled, a normal/maintenance phase is resolved from the configured time window and timezone; only listed maintenanceAgents can run during maintenance, and they are blocked outside it. Blocked jobs are not dropped — cron jobs are deferred durably with per-job counters replayed FIFO when the phase allows, and heartbeat wakes are deferred in an in-memory per-agent queue replayed in the same fashion. Manual cron.run returns { ok: true, ran: false, reason: "maintenance-blocked" } on a role mismatch, and cron.status surfaces a new diagnostics block with current phase, window, and deferred counts. Config hot-reload correctly restarts both schedulers when cron.maintenance.* changes.

Key observations:

  • The maintenance-phase.ts resolver is clean and correctly handles cross-midnight windows, the 24:00 end-time special case, and the timezone fallback chain ("user" → "local" → IANA).
  • The zod validation duplicates the time-parsing regex and logic from maintenance-phase.ts inline in superRefine; extracting it into a shared helper would reduce drift risk.
  • replayDeferredRuns in the heartbeat runner calls Date.now() for the maintenance gate inside the while loop instead of using the now snapshot parameter, making the function's behavior inconsistent with the rest of the tick and incompatible with vi.setSystemTime-controlled tests.
  • Targeted heartbeat wakes blocked during maintenance are queued without a cap; repeated requestHeartbeatNow calls during a long window can grow agent.deferredRuns unboundedly and produce a replay burst when the window ends.
  • resolveJobAgentId in ops.ts does not fall back to DEFAULT_AGENT_ID when both job.agentId and state.deps.defaultAgentId are absent, while the equivalent helper in timer.ts always has that fallback.

Confidence Score: 4/5

Safe to merge after addressing the Date.now() vs now inconsistency in replayDeferredRuns and ideally adding a deferred queue cap; the cron-side changes and schema validation are solid.

The core phase resolver, cron durable deferral, FIFO replay, and config schema are all well-implemented with targeted tests. The three flagged issues are P2: one is a test-reliability inconsistency (Date.now() vs now), one is a latent resource concern for long maintenance windows with high targeted-wake rates (unbounded queue), and one is a minor agent-ID fallback gap. None breaks the primary maintenance-window use case in production.

src/infra/heartbeat-runner.ts — replayDeferredRuns and enqueueDeferredRun unbounded growth; src/cron/service/ops.ts — resolveJobAgentId fallback gap.

Important Files Changed

Filename Overview
src/infra/maintenance-phase.ts New core module implementing phase resolution and agent allowlist checks; cross-midnight window arithmetic, timezone fallback chain, and the execution-decision function are all correctly implemented.
src/cron/service/timer.ts Adds maintenance gating, durable deferred counters, and FIFO replay into the scheduler tick; logic is sound, though resolveJobAgentId in ops.ts is inconsistent with the DEFAULT_AGENT_ID fallback used here.
src/infra/heartbeat-runner.ts In-memory deferred queue for heartbeat maintenance gating works correctly for interval wakes, but targeted wakes have no queue-size cap and the maintenance check inside replayDeferredRuns calls Date.now() instead of the passed now parameter, breaking fake-timer tests.
src/cron/service/ops.ts Adds maintenance diagnostics to cron.status and a pre-flight maintenance block to cron.run; resolveJobAgentId lacks the DEFAULT_AGENT_ID fallback that timer.ts uses, causing a minor inconsistency for jobs without an explicit agent ID.
src/config/zod-schema.ts Maintenance window schema added with correct superRefine cross-field validation (enabled → window required, start ≠ end, 24:00 only on end, IANA timezone probe).
src/gateway/config-reload-plan.ts New cron.maintenance rule triggers both restart-cron and restart-heartbeat; ordering before the generic cron rule is correct so it takes precedence.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/infra/heartbeat-runner.ts
Line: 1043

Comment:
**`replayDeferredRuns` ignores its `now` parameter for the maintenance check**

Inside `replayDeferredRuns`, the `now` parameter is only used for `advanceAgentSchedule`, but the maintenance-phase gate calls `Date.now()` directly:

```typescript
if (!isMaintenanceAllowedForAgent(agent.agentId, Date.now())) {
```

This is inconsistent with the function signature and makes the replay loop untestable with fake timers — the deferred-replay scheduler tests (`heartbeat-runner.scheduler.test.ts`) rely on `vi.setSystemTime` to control time, but the guard inside `replayDeferredRuns` will always read the real wall clock.

```suggestion
      if (!isMaintenanceAllowedForAgent(agent.agentId, now)) {
```

Using `now` here keeps the entire tick consistent and makes the function testable via `vi.setSystemTime`.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/infra/heartbeat-runner.ts
Line: 1028-1034

Comment:
**Unbounded deferred run queue for targeted heartbeat wakes**

For *targeted* wakes (`requestedSessionKey` / `requestedAgentId` path) every blocked wake unconditionally appends an entry to `agent.deferredRuns`. In the interval path each blocked due-tick advances the schedule, so queue growth is naturally capped to one entry per interval period. Targeted wakes have no such bound — anything calling `requestHeartbeatNow` repeatedly during the maintenance window (a cron job that fires many times, a webhook, repeated UI triggers) will grow the queue without limit. After the window ends, all queued entries replay serially, potentially causing a burst on the agent.

Consider adding a per-agent deferred queue cap in `enqueueDeferredRun` (e.g., drop the oldest entry when the queue exceeds a reasonable limit, or deduplicate entries with the same `sessionKey` before pushing).

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/cron/service/ops.ts
Line: 50-53

Comment:
**`resolveJobAgentId` in `ops.ts` lacks the `DEFAULT_AGENT_ID` fallback present in `timer.ts`**

`timer.ts` defines:

```typescript
function resolveCronJobAgentId(state: CronServiceState, job: CronJob): string {
  return normalizeAgentId(job.agentId ?? state.deps.defaultAgentId ?? DEFAULT_AGENT_ID);
}
```

`ops.ts` defines:

```typescript
function resolveJobAgentId(state: CronServiceState, job: CronJob): string {
  const fallback = normalizeAgentId(state.deps.defaultAgentId);
  return normalizeAgentId(job.agentId) || fallback;
}
```

When both `job.agentId` and `state.deps.defaultAgentId` are absent, `ops.ts` resolves to an empty/falsy string while `timer.ts` falls back to `DEFAULT_AGENT_ID`. `resolveMaintenanceExecutionDecision` treats a falsy agent as never being a maintenance agent (`isMaintenanceAgent = false`). In maintenance-phase a job whose timer would be gated via `DEFAULT_AGENT_ID` would be blocked in manual runs with `"maintenance-blocked"` even though the scheduler wouldn't gate it the same way.

```suggestion
function resolveJobAgentId(state: CronServiceState, job: CronJob): string {
  return normalizeAgentId(job.agentId ?? state.deps.defaultAgentId ?? DEFAULT_AGENT_ID);
}
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat(cron): add maintenance window role ..." | Re-trigger Greptile

const errMsg = formatErrorMessage(err);
log.error(`heartbeat runner: runOnce threw unexpectedly: ${errMsg}`, { error: errMsg });
return { status: "failed", reason: errMsg };
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 replayDeferredRuns ignores its now parameter for the maintenance check

Inside replayDeferredRuns, the now parameter is only used for advanceAgentSchedule, but the maintenance-phase gate calls Date.now() directly:

if (!isMaintenanceAllowedForAgent(agent.agentId, Date.now())) {

This is inconsistent with the function signature and makes the replay loop untestable with fake timers — the deferred-replay scheduler tests (heartbeat-runner.scheduler.test.ts) rely on vi.setSystemTime to control time, but the guard inside replayDeferredRuns will always read the real wall clock.

Suggested change
}
if (!isMaintenanceAllowedForAgent(agent.agentId, now)) {

Using now here keeps the entire tick consistent and makes the function testable via vi.setSystemTime.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/heartbeat-runner.ts
Line: 1043

Comment:
**`replayDeferredRuns` ignores its `now` parameter for the maintenance check**

Inside `replayDeferredRuns`, the `now` parameter is only used for `advanceAgentSchedule`, but the maintenance-phase gate calls `Date.now()` directly:

```typescript
if (!isMaintenanceAllowedForAgent(agent.agentId, Date.now())) {
```

This is inconsistent with the function signature and makes the replay loop untestable with fake timers — the deferred-replay scheduler tests (`heartbeat-runner.scheduler.test.ts`) rely on `vi.setSystemTime` to control time, but the guard inside `replayDeferredRuns` will always read the real wall clock.

```suggestion
      if (!isMaintenanceAllowedForAgent(agent.agentId, now)) {
```

Using `now` here keeps the entire tick consistent and makes the function testable via `vi.setSystemTime`.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +1028 to +1034
sessionKey?: string;
}): Promise<HeartbeatRunResult> => {
try {
return await runOnce({
cfg: state.cfg,
agentId: params.agent.agentId,
heartbeat: params.agent.heartbeat,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unbounded deferred run queue for targeted heartbeat wakes

For targeted wakes (requestedSessionKey / requestedAgentId path) every blocked wake unconditionally appends an entry to agent.deferredRuns. In the interval path each blocked due-tick advances the schedule, so queue growth is naturally capped to one entry per interval period. Targeted wakes have no such bound — anything calling requestHeartbeatNow repeatedly during the maintenance window (a cron job that fires many times, a webhook, repeated UI triggers) will grow the queue without limit. After the window ends, all queued entries replay serially, potentially causing a burst on the agent.

Consider adding a per-agent deferred queue cap in enqueueDeferredRun (e.g., drop the oldest entry when the queue exceeds a reasonable limit, or deduplicate entries with the same sessionKey before pushing).

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/heartbeat-runner.ts
Line: 1028-1034

Comment:
**Unbounded deferred run queue for targeted heartbeat wakes**

For *targeted* wakes (`requestedSessionKey` / `requestedAgentId` path) every blocked wake unconditionally appends an entry to `agent.deferredRuns`. In the interval path each blocked due-tick advances the schedule, so queue growth is naturally capped to one entry per interval period. Targeted wakes have no such bound — anything calling `requestHeartbeatNow` repeatedly during the maintenance window (a cron job that fires many times, a webhook, repeated UI triggers) will grow the queue without limit. After the window ends, all queued entries replay serially, potentially causing a burst on the agent.

Consider adding a per-agent deferred queue cap in `enqueueDeferredRun` (e.g., drop the oldest entry when the queue exceeds a reasonable limit, or deduplicate entries with the same `sessionKey` before pushing).

How can I resolve this? If you propose a fix, please make it concise.

Comment thread src/cron/service/ops.ts
Comment on lines 50 to +53
nextOffset: number | null;
};

function resolveJobAgentId(state: CronServiceState, job: CronJob): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 resolveJobAgentId in ops.ts lacks the DEFAULT_AGENT_ID fallback present in timer.ts

timer.ts defines:

function resolveCronJobAgentId(state: CronServiceState, job: CronJob): string {
  return normalizeAgentId(job.agentId ?? state.deps.defaultAgentId ?? DEFAULT_AGENT_ID);
}

ops.ts defines:

function resolveJobAgentId(state: CronServiceState, job: CronJob): string {
  const fallback = normalizeAgentId(state.deps.defaultAgentId);
  return normalizeAgentId(job.agentId) || fallback;
}

When both job.agentId and state.deps.defaultAgentId are absent, ops.ts resolves to an empty/falsy string while timer.ts falls back to DEFAULT_AGENT_ID. resolveMaintenanceExecutionDecision treats a falsy agent as never being a maintenance agent (isMaintenanceAgent = false). In maintenance-phase a job whose timer would be gated via DEFAULT_AGENT_ID would be blocked in manual runs with "maintenance-blocked" even though the scheduler wouldn't gate it the same way.

Suggested change
nextOffset: number | null;
};
function resolveJobAgentId(state: CronServiceState, job: CronJob): string {
function resolveJobAgentId(state: CronServiceState, job: CronJob): string {
return normalizeAgentId(job.agentId ?? state.deps.defaultAgentId ?? DEFAULT_AGENT_ID);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cron/service/ops.ts
Line: 50-53

Comment:
**`resolveJobAgentId` in `ops.ts` lacks the `DEFAULT_AGENT_ID` fallback present in `timer.ts`**

`timer.ts` defines:

```typescript
function resolveCronJobAgentId(state: CronServiceState, job: CronJob): string {
  return normalizeAgentId(job.agentId ?? state.deps.defaultAgentId ?? DEFAULT_AGENT_ID);
}
```

`ops.ts` defines:

```typescript
function resolveJobAgentId(state: CronServiceState, job: CronJob): string {
  const fallback = normalizeAgentId(state.deps.defaultAgentId);
  return normalizeAgentId(job.agentId) || fallback;
}
```

When both `job.agentId` and `state.deps.defaultAgentId` are absent, `ops.ts` resolves to an empty/falsy string while `timer.ts` falls back to `DEFAULT_AGENT_ID`. `resolveMaintenanceExecutionDecision` treats a falsy agent as never being a maintenance agent (`isMaintenanceAgent = false`). In maintenance-phase a job whose timer would be gated via `DEFAULT_AGENT_ID` would be blocked in manual runs with `"maintenance-blocked"` even though the scheduler wouldn't gate it the same way.

```suggestion
function resolveJobAgentId(state: CronServiceState, job: CronJob): string {
  return normalizeAgentId(job.agentId ?? state.deps.defaultAgentId ?? DEFAULT_AGENT_ID);
}
```

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 236273db4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/heartbeat-runner.ts Outdated
ran = true;
}
scheduleNext();
return ran ? { status: "ran", durationMs: Date.now() - startedAt } : res;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Return the targeted wake result instead of replay aggregate

When a targeted wake has deferred replays, ran is set from replay outcomes and this return path reports {status:"ran"} even if the current targeted runOnce call returns failed or a non-ran skip. In that case callers (including cron wake-now flows) can treat the request as successful and miss the actual failure for the newly requested wake. This happens whenever replay.ran === true and res.status !== "ran" in the same invocation.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f306206927

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +144 to +145
const agentId = normalizeAgentId(raw);
if (agentId) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Skip invalid maintenance allowlist IDs instead of mapping to main

resolveMaintenanceAgentAllowlist currently feeds each configured entry through normalizeAgentId, which falls back to "main" for empty/invalid values. That means inputs like "", whitespace, or malformed IDs (for example "!!!", which passes current schema checks) silently add main to maintenanceAgents, unexpectedly blocking the default agent during normal phase and allowing it only in maintenance windows. This is a behavior regression that can shut off normal automation after a typo; invalid entries should be rejected or ignored rather than coerced to main.

Useful? React with 👍 / 👎.

Comment thread src/infra/heartbeat-runner.ts Outdated
Comment on lines +1257 to +1259
if (!isInterval || dueByInterval) {
enqueueDeferredRun(agent, { reason, queuedAtMs: now });
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not enqueue every non-interval wake for blocked agents

This branch defers blocked wakes whenever !isInterval, so any untargeted wake source (for example hook/exec/notification wakes) appends a deferred item even when the agent is not interval-due. In a busy environment with maintenance isolation enabled, blocked agents can accumulate large in-memory queues during normal hours and then replay a long backlog serially at window transition, causing avoidable memory growth and catch-up storms. Deferral should be coalesced or limited to interval-due/explicitly targeted wakes.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da2b103142

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cron/service/timer.ts
Comment on lines +625 to +629
if (!nextAt) {
const deferredJobs = (state.store?.jobs ?? []).filter(
(job) => getDeferredMaintenanceRuns(job) > 0,
);
const hasDeferredReplay = deferredJobs.some((job) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Recheck deferred replays when next wake is in the future

armTimer only considers deferred-maintenance replay scheduling inside the if (!nextAt) branch, but deferred recurring jobs usually still have a finite nextRunAtMs (set by recordDeferredMaintenanceRun). In that case the timer is armed for that future schedule instead of rechecking maintenance phase transitions, so when a blocked job becomes allowed (for example after the maintenance window ends) replay can be delayed until the next cron slot rather than running promptly.

Useful? React with 👍 / 👎.

Comment on lines +78 to +81
prefix: "cron.maintenance",
kind: "hot",
actions: ["restart-cron", "restart-heartbeat"],
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restart schedulers when maintenance uses user timezone

The new maintenance-phase gating depends on agents.defaults.userTimezone (buildGatewayCronService now snapshots it into cron deps, and heartbeat maintenance checks read cached config), but this reload plan only hot-restarts on cron.maintenance.*. A runtime change to agents.defaults.userTimezone with cron.maintenance.window.timezone: "user" leaves cron/heartbeat evaluating phase with stale timezone data until a full gateway restart.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ce8f0f074

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cron/service/timer.ts
Comment on lines +601 to +604
for (const job of deferredJobs) {
const deferredRuns = getDeferredMaintenanceRuns(job);
for (let i = 0; i < deferredRuns; i += 1) {
scheduled.push({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve global FIFO when expanding deferred replay runs

The replay builder sorts only by each job’s firstDeferredMaintenanceAtMs and then appends all deferred runs for that job before moving to the next one. When a job has multiple deferred runs, this can execute newer runs ahead of older runs from other jobs (for example A1, B1, A2 becomes A1, A2, B1), which breaks the promised FIFO replay behavior and can starve other deferred jobs after long maintenance windows.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded. The author documented that the fork branch for this PR cannot be updated and opened #74952 as the rebased replacement; public metadata shows that replacement is open with the same title, scope, and changed-file list. Current main still lacks the maintenance-window contract, so the remaining work should continue in the replacement PR rather than this stale branch.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Close this stale, uneditable PR and continue all implementation review on #74952, where maintainers can resolve conflicts, evaluate the scheduler product semantics, address deferred replay issues, and validate the focused cron, heartbeat, schema, reload, protocol, docs, and CI surfaces.

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

Not applicable as a user-facing bug reproduction. The supersession decision is high-confidence from the author’s replacement comment, matching PR metadata/file lists, and current-main checks showing the feature has not landed.

Is this the best way to solve the issue?

Yes. Closing the stale fork PR in favor of the open rebased replacement is the narrowest maintainable path; the code itself still needs normal PR review and fixes in #74952 before merge.

Security review:

Security review cleared: The diff touches CI secret scanning, but I found no concrete permission, secret exposure, dependency-source, or supply-chain regression in the proposed workflow changes.

What I checked:

  • Current main lacks the maintenance contract: Exact searches on current main returned no hits for cron.maintenance, maintenance-blocked, MaintenanceExecutionDecision, resolveMaintenanceExecutionDecision, deferredMaintenance, or maintenanceAgents. (914287642de5)
  • Current config type has no maintenance field: CronConfig currently includes retry, webhook, retention, run-log, and failure settings, but no maintenance object. (src/config/types.cron.ts:31, 914287642de5)
  • Current cron status/run result has no maintenance diagnostics: CronStatusSummary has only enabled/store/jobs/nextWakeAtMs, and CronRunResult has no maintenance-blocked reason on main. (src/cron/service/state.ts:172, 914287642de5)
  • Source PR is dirty and based on old main: GitHub API metadata reports this PR as open, mergeable_state: dirty, head 9ce8f0f0743881a7301c682a52f9ac982dcbb98a, and base a8066ad96d0172030a93db3def0a0b09be3da49f. (9ce8f0f07438)
  • Author posted a replacement note: The author commented that this PR head is on a fork branch they cannot update and that they published the rebased replacement as feat(cron): add maintenance-window role isolation and deferred replay #74952.
  • Replacement PR carries the same work: GitHub API metadata for feat(cron): add maintenance-window role isolation and deferred replay #74952 says it is an open replacement PR with the same title, 26 changed files, and a body explicitly describing it as the replacement for this maintenance-window scheduler work. (9d584e9c89d1)

Likely related people:

  • steipete: Recent current-main work touches the central cron timer/state/server-cron, heartbeat pressure deferral, docs, and CI surfaces affected by this PR. (role: recent maintainer; confidence: high; commits: 61d53f98d314, f5e7557c70c1, 7877182b6f59; files: src/cron/service/timer.ts, src/cron/service/state.ts, src/gateway/server-cron.ts)
  • obviyus: Recent merged cron/heartbeat integration and cron delivery tracing commits changed the same timer, state, ops, server-cron, heartbeat, and cron type surfaces. (role: adjacent cron maintainer; confidence: medium; commits: 1d4e4314dddc, 4c8299ca3d4f; files: src/cron/service/timer.ts, src/cron/service/state.ts, src/cron/service/ops.ts)
  • vignesh07: Recent current-main heartbeat commits changed src/infra/heartbeat-runner.ts near the scheduler path this PR rewrites. (role: adjacent heartbeat owner; confidence: medium; commits: 7451415f36d5, 8e4035d09a88; files: src/infra/heartbeat-runner.ts, src/config/zod-schema.ts)
  • drobison00: Recent gateway reload work changed the same config reload planning surface that the PR extends for scheduler restarts. (role: adjacent reload maintainer; confidence: medium; commits: a35c166348e3; files: src/gateway/config-reload-plan.ts)

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

Copy link
Copy Markdown
Author

Refresh note: current main has moved far enough that this branch needs a deliberate conflict-resolution pass before it is safe to update. The conflict surface is primarily the cron docs/config help+labels/schema, cron timer/state/ops, server-cron, and heartbeat runner/tests.

I did not push a partial resolution because that would risk overwriting newer scheduler/channel-kernel behavior. The next safe revision should rebase the maintenance-window implementation onto current main, preserve the newer heartbeat/channel changes, then rerun the focused cron + heartbeat + config-reload tests before updating this branch.

Copy link
Copy Markdown
Author

Follow-up: this PR head is on a fork branch that I cannot update from the available credentials, so I published the rebased replacement from a writable fork as #74952.

The previously reported @mariozechner/pi-ai failure appears to be an environment/install issue rather than a missing dependency in the current repository state. The replacement branch was prepared from a clean worktree, with unrelated formatting-only local changes discarded before publishing.

Keeping this note public-safe: no local hostnames, tokens, account IDs, or runtime paths included.

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 docs Improvements or additions to documentation gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant