Skip to content

feat(plugins): add cron reconciliation lifecycle hook#104191

Merged
steipete merged 3 commits into
mainfrom
codex/cron-reconciled-hook
Jul 11, 2026
Merged

feat(plugins): add cron reconciliation lifecycle hook#104191
steipete merged 3 commits into
mainfrom
codex/cron-reconciled-hook

Conversation

@steipete

@steipete steipete commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Closes #104082

Related: #103736 (the separate hot-reload publication/atomicity issue is not changed by this PR).

What Problem This Solves

Plugins that project OpenClaw cron jobs into an external scheduler have no authoritative lifecycle point after the Gateway has loaded durable cron state and reconciled exit watchers. gateway_start can run too early, while cron_changed is a coalescible change hint rather than a complete-state baseline.

Why This Change Was Made

This adds a typed cron_reconciled observation hook after scheduler startup and every scheduler replacement on config reload. The event exposes only the reconciliation reason and effective enabled state; plugins read the exact reconciled scheduler through ctx.getCron(). Generation guards, serialized delivery, and shutdown invalidation suppress stale callbacks without introducing retries, durability, or plugin-only replay.

User Impact

Plugin authors can reliably rebuild a complete external cron projection after Gateway startup or scheduler replacement. Disabled cron emits enabled: false, allowing adapters to clear stale external wakes, while cron_changed remains available for low-latency incremental hints.

Evidence

  • Runtime hook head f2976f273c9648010fcde3ed5ff7161c409bfe36: 141 focused gateway/plugin test executions and pnpm plugin-sdk:api:check passed on Blacksmith Testbox tbx_01kx7tqqvxah2ms4g68ek1d7pp (Actions run).
  • SDK export-budget fix: all 10 plugin-sdk-surface-report tests and pnpm plugin-sdk:api:check passed on Blacksmith Testbox tbx_01kx7vcdpjxe3w3vdc5j8g1wk1 (Actions run).
  • Final rebased head 30fdbfa92b1c630f393a000e2cc7bfd2823abac2; the intervening origin/main files are outside this PR's gateway/plugin/SDK surface. Exact-head hosted CI is the landing gate.
  • Pre-rebase full proof on the same patch: pnpm check:changed, pnpm check:docs, and pnpm build passed; the build included the Plugin SDK export check.
  • Exact rebased head docs formatting, Markdown lint, and MDX validation passed. The global link audit currently reports six missing IDENTITY/USER template routes introduced on origin/main; those paths are outside this PR diff.
  • git diff --check passed.
  • Fresh GPT-5.5 autoreview: no accepted or actionable findings.

AI-assisted: yes; maintainer-directed and manually audited.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L 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: b93299d02c

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

},
cron: runtimeState.cronState.cron,
cronState: runtimeState.cronState,
cronReconciliation,

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 Gate startup reconciliation on plugin readiness

When the gateway is started in deferred sidecar mode (the CLI selects this for OPENCLAW_SKIP_CHANNELS/OPENCLAW_SKIP_PROVIDERS), startGatewayPostAttachRuntime returns before plugin sidecars finish loading, but this post-ready timer can still start cron and complete cron_reconciled after only 250ms. If plugin loading takes longer, getGlobalHookRunner() has no newly loaded cron_reconciled handlers yet, so an external scheduler plugin misses its only startup baseline until a later cron reload or gateway restart.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/cron-reconciled-hook branch from b93299d to f2976f2 Compare July 11, 2026 05:37

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

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

if (params.isClosing() || generation !== lifecycleGeneration) {
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.

P2 Badge Add a timeout for serialized cron_reconciled hooks

When a cron_reconciled handler has no configured hooks.timeoutMs and its promise never settles (for example an external scheduler RPC hangs), this await leaves dispatchTail unresolved, so every later startup/reload reconciliation is queued behind it and no plugin receives the fresh cron baseline until the gateway restarts. The hook runner only applies default timeouts to named hooks in DEFAULT_VOID_HOOK_TIMEOUT_MS_BY_HOOK, and this new hook is not one of them, so the serialized lifecycle needs its own bounded timeout or default hook budget.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head f2976f273c9648010fcde3ed5ff7161c409bfe36, but the PR head is now 30fdbfa92b1c630f393a000e2cc7bfd2823abac2. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (1 earlier review cycle)
  • reviewed 2026-07-11T05:49:22.611Z sha f2976f2 :: needs real behavior proof before merge. :: [P2] Gate startup reconciliation on plugin readiness | [P2] Bound serialized cron reconciliation hooks

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 11, 2026
@steipete
steipete force-pushed the codex/cron-reconciled-hook branch from f2976f2 to 30fdbfa Compare July 11, 2026 05:54
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Jul 11, 2026
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready at exact head 30fdbfa92b1c630f393a000e2cc7bfd2823abac2.

The typed cron_reconciled hook now fires only after the Gateway cron scheduler and exit watchers reach a complete startup/reload state. Generation invalidation, shutdown suppression, serialized delivery, disabled-cron reporting, the public SDK surface, and docs are covered. Native review artifacts validate as READY FOR /prepare-pr with zero findings.

Proof:

  • Exact-head CI run 29141941312, attempt 2: success. The first attempt's sole failure was the unrelated src/agents/subagent-orphan-recovery.restart-integration.test.ts; its single-job rerun 86517219141 passed without a code change.
  • Blacksmith Testbox run 29141439667: 141 focused gateway/plugin test executions and pnpm plugin-sdk:api:check passed on the runtime hook head.
  • Blacksmith Testbox run 29141737063: all 10 plugin-sdk-surface-report tests and pnpm plugin-sdk:api:check passed with the SDK export-budget fix.
  • Full patch proof before the final unrelated main sync: pnpm check:changed, pnpm check:docs, pnpm build, and git diff --check passed.
  • Fresh GPT-5.5 autoreview after the budget fix: no accepted/actionable findings.
  • scripts/pr review-validate-artifacts 104191: passed at the exact PR head.

Known proof gaps: none for the core lifecycle contract. An external scheduler adapter is intentionally follow-up work; #103736 remains the separate reload publication/atomicity issue.

@steipete
steipete merged commit 49b5828 into main Jul 11, 2026
172 of 177 checks passed
@steipete
steipete deleted the codex/cron-reconciled-hook branch July 11, 2026 06:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
* feat(plugins): add cron reconciliation lifecycle hook

* chore(plugin-sdk): refresh api baseline

* fix(plugin-sdk): update public export budget
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 P2 Normal backlog priority with limited blast radius. scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add a post-start cron reconciliation lifecycle hook

1 participant