fix(cron): guard task liveness during startup#80707
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the startup liveness invariant is still useful on current main, but the live PR branch is conflict-dirty and applies the guard to an older activeJobIds-only active-job model that current main has since replaced with generation-aware active job markers. Canonical path: Close this PR as superseded by #96174. So I’m closing this here and keeping the remaining discussion on #96174. Review detailsBest possible solution: Close this PR as superseded by #96174. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-signal path: gateway task maintenance is runtime-authoritative early, lazy cron startup may not have reconciled active jobs, and hasBackingSession then trusts an empty process-local active-job map. I did not run a local repro because this is a read-only review. Is this the best way to solve the issue? No, this exact branch is not currently the best mergeable fix because it applies the right invariant to an older activeJobIds-only implementation. The best fix is a focused current-main port onto the activeJobs/generation owner model. Security review: Security review cleared: The diff is limited to cron/task runtime code and tests, with no dependency, workflow, secret, permission, or supply-chain surface changes. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 738b2be4b49b. |
|
@clawsweeper re-review Added real behavior proof to the PR body from an isolated local state dir. The proof seeds stale mapped cron task records, runs task maintenance while cron active-job liveness is non-authoritative, then again after liveness is authoritative. Output shows the pre-start task remains |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Moved the isolated local state-dir proof under an explicit |
|
@clawsweeper re-review Structured the real behavior proof section with the checker-required fields: behavior, environment, steps, evidence, observed result, and not tested. The terminal proof remains the same isolated local state-dir run. |
|
@clawsweeper re-review Converted the proof fields to the exact labels accepted by the gate ( |
dc6739b to
3ba4d18
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
3ba4d18 to
d8dd1b7
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper PR egg: 🔥 warming; proof passed, review follow-up or readiness checks remain. Hatch with Rules and detailsHatchability:
About:
|
|
Still ready for maintainer look. No code changes since the last update; the branch was already rebased onto Current state from the live PR:
|
d8dd1b7 to
2cb121d
Compare
|
@clawsweeper re-review Rebased the branch onto current Local verification after the rebase:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…-guard Signed-off-by: Nanook <[email protected]> # Conflicts: # src/cron/service/ops.test.ts
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=a94fcc4e5e73787222a5b1d342da064af230a5f9) Closed:
|
Summary
Task registry maintenance now treats cron active-job liveness as non-authoritative until cron startup reconciliation exits. This prevents a pre-start maintenance sweep from marking persisted cron task records lost while the process-local active-job set is still empty after restart.
The change keeps the boundary narrow:
activeJobIdsstarts non-authoritative after process bootcron.start()marks liveness reconciling at entry and authoritative infinallyThis is AI-assisted.
Proof
Real setup: local checkout of
openclaw/openclaw, branch rebased ontoorigin/mainat435e1a74fa.Commands run after the rebase/conflict resolution:
Observed result:
git diff --check: passedsrc/cron/service/ops.test.ts: 13 passedsrc/tasks/task-registry.maintenance.issue-60299.test.ts: 21 passedsrc/tasks/task-registry.test.ts: 63 passedReal behavior proof
Behavior addressed: Task registry maintenance should preserve mapped stale cron task records while cron active-job liveness is non-authoritative during startup, then resume marking missing mapped cron tasks
lostafter cron startup exits and liveness is authoritative.Real setup tested: Local
openclaw/openclawcheckout on the PR branch, using an isolated temporary state root under/tmp/openclaw-pr-80707-proof-*and the repository's TypeScript runtime vianode --import tsx.Exact steps or command run after this patch:
The script seeds 10-minute-stale mapped cron task records with
runtime: cronandsourceId, runs task maintenance once while cron active-job liveness is non-authoritative, then runs task maintenance again after liveness is marked authoritative.Evidence after fix: Redacted terminal output from the isolated local state-dir run:
{ "stateRoot": "/tmp/openclaw-pr-80707-proof-s9f07s", "scenario": "mapped stale cron task maintenance across cron startup liveness authority", "staleAgeMs": 600000, "beforeStartupExit": { "livenessAuthoritative": false, "maintenance": { "reconciled": 0, "recovered": 0, "cleanupStamped": 0, "pruned": 0 }, "task": { "runtime": "cron", "sourceId": "proof-cron-before-startup-exit", "status": "running", "endedAtPresent": false } }, "afterStartupExit": { "livenessAuthoritative": true, "maintenance": { "reconciled": 2, "recovered": 0, "cleanupStamped": 0, "pruned": 0 }, "task": { "runtime": "cron", "sourceId": "proof-cron-after-startup-exit", "status": "lost", "endedAtPresent": true, "error": "backing session missing" } } }Observed result after fix: The pre-start/non-authoritative maintenance pass left the stale mapped cron task
runningwithreconciled: 0. The post-start/authoritative maintenance pass marked the stale mapped cron tasklostwitherror: "backing session missing".Not tested: I did not run the full monorepo
pnpm build && pnpm check && pnpm testlocally.This shows the fixed behavior: task maintenance does not mark a mapped stale cron task lost during the pre-start/non-authoritative window, and does mark mapped stale cron tasks lost after startup liveness becomes authoritative again.
Also ran a focused Codex review against the rebased diff; it reported no blocker. I did not run the full monorepo
pnpm build && pnpm check && pnpm testlocally.