Skip to content

fix(cron): abort superseded reconciliation hooks#104368

Merged
steipete merged 2 commits into
mainfrom
codex/cron-reconcile-abort
Jul 11, 2026
Merged

fix(cron): abort superseded reconciliation hooks#104368
steipete merged 2 commits into
mainfrom
codex/cron-reconcile-abort

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #104363

AI-assisted implementation; maintainer-reviewed and source-verified.

What Problem This Solves

Fixes an issue where operators projecting OpenClaw cron wakes into an external scheduler could retain a stale projection when a startup callback was still retrying during cron reload.

The newer cron_reconciled callback was serialized behind the stale callback, so it could not promptly abort the older durable host write or adopt the replacement scheduler.

Why This Change Was Made

Each reconciled scheduler snapshot now owns an AbortSignal. Arming a newer scheduler or closing the Gateway aborts the previous signal immediately, and the replacement reconciliation dispatches without waiting behind stale observer work.

The public hook context and safe projection example carry that lifecycle-owned signal through durable acceptance. The change does not turn observation hooks into readiness-critical services and does not add a second cron authority.

User Impact

Scale-to-zero and external-scheduler integrations can supersede stale cron projections promptly during reload. A slow or retrying prior callback no longer hides the current scheduler snapshot.

Evidence

  • Regression: a held startup callback receives an aborted signal while reload receives and completes the exact replacement scheduler without waiting.
  • Invalidation regression: shutdown/explicit invalidation aborts an active snapshot.
  • Focused Testbox proof: pnpm test src/gateway/server-cron-reconciled.test.ts src/plugins/wired-hooks-gateway.test.ts (19 assertions passed).
  • Current-head Testbox check:changed gate passed.
  • Fresh structured Codex autoreview: clean; no accepted or actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Jul 11, 2026

@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: e556346961

ℹ️ 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".

) {
return;
}
await params.runHook(event, {

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 Preserve ordered delivery for legacy cron hooks

When an existing cron_reconciled plugin handler performs a durable external projection but has not yet been updated to honor the new abortSignal, a slow startup handler can now continue after a reload handler and overwrite the newer scheduler snapshot. The previous dispatchTail serialized generations so the reload callback ran after the stale callback settled; this call now lets both run concurrently, and abort is only advisory to plugin code. For shipped/external plugins using the existing hook contract, this can turn a reload from current-wins into stale-wins, so keep legacy ordered delivery or make the concurrent/abort-driven behavior opt-in.

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 11, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 6:12 AM ET / 10:12 UTC.

Summary
The branch adds a required abortSignal to the cron_reconciled hook context, aborts superseded scheduler snapshots, dispatches replacement reconciliation without cross-generation serialization, and updates focused tests, plugin docs, and the SDK surface budget.

PR surface: Source +17, Tests +41, Docs +9, Other 0. Total +67 across 8 files.

Reproducibility: yes. Current main's dispatchTail provides a deterministic source-level reproduction: hold the startup hook, arm reload, and observe that reload cannot dispatch until startup settles; the PR adds focused coverage for that sequence.

Review metrics: 1 noteworthy metric.

  • Public hook contract: 1 required context field added before first release. The patch finalizes an unreleased plugin API and replaces its initial serialized lifecycle rather than migrating an established tagged contract.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #104363
Summary: This PR is the direct candidate fix for the linked cron reconciliation bug; the issue should remain open until the PR merges.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • [P1] No automated repair is needed; the patch is review-clean, and the protected maintainer label leaves landing to normal explicit maintainer handling.

Security
Cleared: The diff changes typed hook lifecycle code, tests, documentation, and a checked SDK budget without adding dependencies, permissions, secrets, downloads, package resolution, publishing behavior, or other supply-chain execution paths.

Review details

Best possible solution:

Land a single first-release hook contract in which each exact scheduler snapshot owns an abort signal, newer snapshots dispatch without stale head-of-line blocking, and durable consumers pass the signal through every side effect and reject post-abort acceptance.

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

Yes. Current main's dispatchTail provides a deterministic source-level reproduction: hold the startup hook, arm reload, and observe that reload cannot dispatch until startup settles; the PR adds focused coverage for that sequence.

Is this the best way to solve the issue?

Yes. Because the hook has not shipped, lifecycle-owned cancellation plus immediate replacement dispatch is the narrowest canonical fix; retaining or adding an opt-in legacy ordering mode would preserve the reported bug and create unnecessary parallel behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c702719eda74.

Label changes

Label changes:

  • add P1: The deterministic reload race can leave an external scheduler using stale cron wake state, delaying, missing, or resurrecting scheduled work for affected integrations.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository-specific policy identifies steipete as Peter's maintainer identity, so the external-contributor proof gate does not apply; the reported focused Testbox run and green exact-head checks provide supplemental validation.

Label justifications:

  • P1: The deterministic reload race can leave an external scheduler using stale cron wake state, delaying, missing, or resurrecting scheduled work for affected integrations.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository-specific policy identifies steipete as Peter's maintainer identity, so the external-contributor proof gate does not apply; the reported focused Testbox run and green exact-head checks provide supplemental validation.
Evidence reviewed

PR surface:

Source +17, Tests +41, Docs +9, Other 0. Total +67 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 41 24 +17
Tests 2 50 9 +41
Docs 2 12 3 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 8 104 37 +67

What I checked:

Likely related people:

  • steipete: Authored the merged cron_reconciled feature PR, the linked bug report, and this focused lifecycle correction. (role: feature introducer and recent follow-up owner; confidence: high; commits: 30fdbfa92b1c, e55634696121, 002fc169c2b3; files: src/gateway/server-cron-reconciled.ts, src/gateway/server-cron-reconciled.test.ts, src/plugins/hook-types.ts)
  • Vincent Koc: Recent current-main history touches the gateway reconciliation file in the shallow checkout, making this person a secondary routing candidate, though the grafted boundary prevents precise attribution of the feature lines. (role: recent adjacent gateway contributor; confidence: low; commits: bb65e79ae9b1; files: src/gateway/server-cron-reconciled.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification on the current head 002fc169c2b3494922fea578dde0e693036a49e3:

  • Blacksmith Testbox tbx_01kx87jszcwe6sca2rbge0w4xx: pnpm test src/gateway/server-cron-reconciled.test.ts src/plugins/wired-hooks-gateway.test.ts — 19 assertions passed.
  • Same Testbox: pnpm check:changed — passed.
  • Same Testbox: pnpm test test/scripts/plugin-sdk-surface-report.test.ts — 10 assertions passed after pinning the additive public SDK surface count.
  • Fresh post-fix structured Codex autoreview — clean; no accepted or actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/29148818550
  • git diff --check origin/main...HEAD — passed.

Known proof gaps: none for the OpenClaw hook contract. Host-specific durable projection acceptance remains integration-owned and is not required for this nonblocking lifecycle hook.

@steipete
steipete merged commit 7875dd9 into main Jul 11, 2026
128 of 133 checks passed
@steipete
steipete deleted the codex/cron-reconcile-abort branch July 11, 2026 10:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 11, 2026
* origin/main:
  fix(cron): abort superseded reconciliation hooks (#104368)
  ci(release): expose Telegram runtime preflight stage (#104387)
  fix(status): avoid false shell-wrapper audit warnings (#81778)
  fix: retry live Gateway readiness proof (#104374)
  fix(exec-approval): stop misattributing Allow Always unavailability to policy (#97740)
  fix: preserve Mac bundle during live builds (#104376)
  chore(docs): translate with GPT-5.6 xhigh
  test: wire Control UI suite into CI, fix its broken tests, drop dead harness surface (#104361)
  fix(ui): hide group submenu separator when New group is the only entry (#104370)
  fix(discord): reset progress drafts across queued turns (#102341)
  docs(cli): clarify that exec-policy show and approvals get exclude per-session /exec overrides (#94999)
  fix(discord): single-source thread-binding default placement and guard artifact parity (#104342)
  fix(agents): add tool-activity heartbeat to keep subagent alive during tool calls (#95536)
  fix(maint): reuse recent same-PR hosted gates (#104355)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
* fix(cron): abort superseded reconciliation hooks

* fix(ci): align plugin SDK surface budget
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
* origin/main:
  fix(cron): abort superseded reconciliation hooks (openclaw#104368)
  ci(release): expose Telegram runtime preflight stage (openclaw#104387)
  fix(status): avoid false shell-wrapper audit warnings (openclaw#81778)
  fix: retry live Gateway readiness proof (openclaw#104374)
  fix(exec-approval): stop misattributing Allow Always unavailability to policy (openclaw#97740)
  fix: preserve Mac bundle during live builds (openclaw#104376)
  chore(docs): translate with GPT-5.6 xhigh
  test: wire Control UI suite into CI, fix its broken tests, drop dead harness surface (openclaw#104361)
  fix(ui): hide group submenu separator when New group is the only entry (openclaw#104370)
  fix(discord): reset progress drafts across queued turns (openclaw#102341)
  docs(cli): clarify that exec-policy show and approvals get exclude per-session /exec overrides (openclaw#94999)
  fix(discord): single-source thread-binding default placement and guard artifact parity (openclaw#104342)
  fix(agents): add tool-activity heartbeat to keep subagent alive during tool calls (openclaw#95536)
  fix(maint): reuse recent same-PR hosted gates (openclaw#104355)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Superseded cron reconciliation blocks newer scheduler projections

1 participant