Skip to content

fix(cron): prevent maintenance from dropping scheduled runs during model setup - #115804

Merged
steipete merged 1 commit into
mainfrom
codex/fix-cron-maintenance-claim-114573
Jul 29, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-cron-maintenance-claim-114573

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #114573

What Problem This Solves

Fixes an issue where users running isolated scheduled jobs on busy gateways would lose every scheduled run when session maintenance deleted its unprotected cron session during asynchronous model preparation.

Why This Change Was Made

Claim and protect the exact original session generation immediately after cron session resolution, before asynchronous model selection, provider preflight, delivery preparation, or skill loading. Keep the existing missing-row, archived-session, replacement-owner, and lifecycle-generation fences completely unchanged. Release the early admission on both non-executing model-selection/provider-preflight returns and on preparation exceptions.

This fixes the actual create-to-claim race rather than recreating deleted rows, so an older run cannot resurrect a row after a newer lifecycle owner was removed.

User Impact

Isolated scheduled runs survive concurrent session maintenance and reach the model instead of repeatedly failing with CronSessionLifecycleClaimError. Persistent and user-owned sessions still fail closed on deletion or takeover. Existing model fallback, unavailable-provider skips, detached exact-run state, cleanup, and delivery keep their behavior.

Evidence

  • Reproduced the exact issue against unchanged main on a fresh Blacksmith Testbox: the full isolated cron run aborted at the late admission after the session row vanished; the authoritative guarded persistence path separately rejected the missing row.
  • Added a deterministic full isolated-run regression proving the original cron key, original session identity, and exact-run identity are already actively protected while provider preflight is suspended, and proving the embedded run completes.
  • Added a fail-closed deletion regression for explicitly bound persistent/user sessions and updated pre-admission rotation proof so stale owners are rejected before model calls.
  • Fresh Blacksmith proof: 217/217 tests across 11 files and 3 actual Vitest project shards, including the complete isolated cron lifecycle, model-provider fallback and skip, session-state generation fencing, hidden run keys, SQLite session-registry maintenance, cap pruning, lifecycle mutation admission, session reaping, scheduler restart recovery, and retry classification.
  • Full unsuppressed pnpm check:changed on Blacksmith: passed; both core and core-test tsgo, changed-file format and lint, production/full-tree/script Knip scans (all zero), SDK and owner-boundary guards, database-first/state-schema guards, and runtime import-cycle guard all passed.
  • Fresh independent gpt-5.6-sol xhigh autoreview: clean, 0.96. Its earlier ABA finding against an exploratory recreate-on-missing approach was accepted; this submitted solution preserves the existing generation fences and eliminates that approach.

AI-assisted; source, lifecycle invariants, production owner boundaries, and proof were reviewed against the actual repository.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Jul 29, 2026
@steipete
steipete merged commit 56e488a into main Jul 29, 2026
122 of 124 checks passed
@steipete
steipete deleted the codex/fix-cron-maintenance-claim-114573 branch July 29, 2026 09:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

pull Bot pushed a commit to yann0001/openclaw that referenced this pull request Jul 29, 2026
* origin/main:
  fix(gateway): keep Responses replacement streams consistent (openclaw#115799)
  fix(gateway): hosted setup exits no longer stop the gateway (openclaw#115671)
  fix(cron): protect sessions throughout model preparation (openclaw#115804)
  fix(ui): preserve model names alongside aliases (openclaw#115789)
  fix(qa): prepare shared Slack live flows
  fix(ui): stabilize memory engine selection (openclaw#115750)
  fix(web-fetch): release abandoned fallback response bodies (openclaw#115759)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* origin/main:
  fix(gateway): keep Responses replacement streams consistent (openclaw#115799)
  fix(gateway): hosted setup exits no longer stop the gateway (openclaw#115671)
  fix(cron): protect sessions throughout model preparation (openclaw#115804)
  fix(ui): preserve model names alongside aliases (openclaw#115789)
  fix(qa): prepare shared Slack live flows
  fix(ui): stabilize memory engine selection (openclaw#115750)
  fix(web-fetch): release abandoned fallback response bodies (openclaw#115759)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cron session row is unprotected during the create → claim window, and the claim treats maintenance deletion as an ownership takeover

1 participant