Repository navigation
feat(plugins): keep requester command schedules across Gateway restarts - #180844
fuller-stack-dev merged 2 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves bounded requester-command schedules across Gateway restarts when the same captured plugin code is available. Example: A plugin schedules three follow-up runs and the Gateway restarts after the first.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR delivers the planned restart-continuity feature; the earlier finding and upgrade blocker are resolved, and no introduced blocking defect remains. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherAuthenticated plugin commands create requester-bound cron jobs; the worker claims occurrences, and the Gateway restores current authority before dispatching plugin commands and native children. flowchart TD
A[Authenticated requester command] --> B[Native schedule creation]
B --> C[Cron job and private binding]
D[Loaded plugin code identity] --> E[Worker occurrence claim]
C --> E
E --> F[Gateway authority checks]
F --> G[Plugin command]
G --> H[Native child provider transport]
Technical reviewBest possible solution: Use the existing cron claim owner to re-arm matching captured plugin code while preserving budgets, terminal retirement and current-authority checks. Do we have a high-confidence way to reproduce the issue? Current main explicitly rejects schedules from a previous Gateway process, establishing the designed limitation without executing target code during this review. Is this the best way to solve the issue? The change extends existing cron and plugin lifecycle owners, uses captured source identity instead of metadata alone, and keeps per-occurrence authorization independent of persistence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 70b25401a70a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +353, Tests +1038, Docs +31. Total +1422 across 37 files. Added test files: 4. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 22, 2026, 3:24 PM ET / 19:24 UTC (Revision 3). |
Requester-admitted scheduled command turns (openclaw#180282) ended when the Gateway restarted. Accepted schedules now survive a restart, within their original bounds and under the same per-occurrence authority checks. - A schedule accepted from a plugin whose loaded source has a captured digest records a private restart binding in job state: the serving Gateway process and plugin instance, plus that source digest. The released `pluginCommand` envelope and payload kind are unchanged; no table, column or schema version is added. - After a restart, the scheduler's launch claim re-arms the schedule onto the newly loaded instance only if it runs the same code: the same plugin ID, source, root and version, the exact captured source digest, and the target command still registered. The re-arm, the budget check, the receipt and the charge share one state transaction. The Gateway thread supplies the loaded instances. - The deadline, maxRuns and spent attempts carry over. Expired, exhausted, disabled, removed and completed schedules are never re-armed. Without a matching instance (disabled, uninstalled or changed plugin) the claim retires the schedule before running plugin code or spending an attempt. - Each occurrence still restores the original requester and rechecks the operator, parent session, plugin instance and code, command and tool ceiling; a demoted or removed requester is refused before the command runs. - In-process plugin reloads still retire schedules bound to the replaced instance. Core-bundled plugins have no captured digest and keep restart-scoped schedules. - The active cap also counts unexpired restartable schedules of the same code left by an earlier process. - `command-scheduled-turns-restart-v1` advertises continuity, and `schedule()` returns `survivesRestart` for each accepted schedule. - Released openclaw#180282 readers decode the unchanged envelope, ignore the binding and end the schedule at its next occurrence; that ended schedule stays ended after upgrading again.
7dc20d2 to
6b3dabf
Compare
Remove the test-only process identity setter from the scheduler module. The in-process restart tests now replace the identity the Gateway thread reports to the scheduler with a module mock; the claim, plugins and state database stay real, and real Gateway processes cover the same restart in the E2E.
|
Responses to the review of
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Data-model compatibility: latest-stable upgrade. I added a run from npm
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Remove redundant observation and audit forwarding paths and the obsolete message-tool-outcome schema module. Preserve synchronous warm dispatch, cold input capture before recovery, receiver binding, no-replay behavior, and the existing audit writer ownership. SQL, transactions, schemas, request counts, public SDK surfaces and effect-authority checks are unchanged. Production +22/-45 (net -23); total net -25. Direct commands allocate one fewer adapter and forwarding closure; no timing claim. Validation: focused schema, audit, Workboard/observation and wrapper-inventory tests; type-aware lint, types, source/architecture guards, Knip/Madge and database ratchets. All three exact-head PostgreSQL conformance shards passed. The CI owner-selection assertion introduced on newer main by #180844 reproduces identically on main dfe0396; recorded for main repair. Independent component reviews and exact-head coordinator/PostgreSQL review approved the change. Source provenance: #170138, #165561 and #177694 (Peter Steinberger).
…ts (openclaw#180844) * feat(plugins): keep requester command schedules across Gateway restarts Requester-admitted scheduled command turns (openclaw#180282) ended when the Gateway restarted. Accepted schedules now survive a restart, within their original bounds and under the same per-occurrence authority checks. - A schedule accepted from a plugin whose loaded source has a captured digest records a private restart binding in job state: the serving Gateway process and plugin instance, plus that source digest. The released `pluginCommand` envelope and payload kind are unchanged; no table, column or schema version is added. - After a restart, the scheduler's launch claim re-arms the schedule onto the newly loaded instance only if it runs the same code: the same plugin ID, source, root and version, the exact captured source digest, and the target command still registered. The re-arm, the budget check, the receipt and the charge share one state transaction. The Gateway thread supplies the loaded instances. - The deadline, maxRuns and spent attempts carry over. Expired, exhausted, disabled, removed and completed schedules are never re-armed. Without a matching instance (disabled, uninstalled or changed plugin) the claim retires the schedule before running plugin code or spending an attempt. - Each occurrence still restores the original requester and rechecks the operator, parent session, plugin instance and code, command and tool ceiling; a demoted or removed requester is refused before the command runs. - In-process plugin reloads still retire schedules bound to the replaced instance. Core-bundled plugins have no captured digest and keep restart-scoped schedules. - The active cap also counts unexpired restartable schedules of the same code left by an earlier process. - `command-scheduled-turns-restart-v1` advertises continuity, and `schedule()` returns `survivesRestart` for each accepted schedule. - Released openclaw#180282 readers decode the unchanged envelope, ignore the binding and end the schedule at its next occurrence; that ended schedule stays ended after upgrading again. * test(plugins): simulate the restarted process without a production hook Remove the test-only process identity setter from the scheduler module. The in-process restart tests now replace the identity the Gateway thread reports to the scheduler with a module mock; the claim, plugins and state database stay real, and real Gateway processes cover the same restart in the E2E.
…w#180928) Remove redundant observation and audit forwarding paths and the obsolete message-tool-outcome schema module. Preserve synchronous warm dispatch, cold input capture before recovery, receiver binding, no-replay behavior, and the existing audit writer ownership. SQL, transactions, schemas, request counts, public SDK surfaces and effect-authority checks are unchanged. Production +22/-45 (net -23); total net -25. Direct commands allocate one fewer adapter and forwarding closure; no timing claim. Validation: focused schema, audit, Workboard/observation and wrapper-inventory tests; type-aware lint, types, source/architecture guards, Knip/Madge and database ratchets. All three exact-head PostgreSQL conformance shards passed. The CI owner-selection assertion introduced on newer main by openclaw#180844 reproduces identically on main d41e3f8; recorded for main repair. Independent component reviews and exact-head coordinator/PostgreSQL review approved the change. Source provenance: openclaw#170138, openclaw#165561 and openclaw#177694 (Peter Steinberger).
… the same build Requester-command schedules from core-bundled plugins ended at every Gateway restart because those plugins load host-owned modules without a captured source digest (openclaw#180844). Give them a code identity derived from the exact loaded OpenClaw build: the build ID in that build's dist/build-info.json, read once at process start, plus the plugin ID and the real root and entry inside the build's own dist or dist-runtime extensions. They then re-arm under the same rules as installed plugins. Any other build, a disabled plugin, a source run without a build record, or bundled code outside the build's output ends the schedule as before.
… the same build (#181331) Requester-command schedules from core-bundled plugins ended at every Gateway restart because those plugins load host-owned modules without a captured source digest (#180844). Give them a code identity derived from the exact loaded OpenClaw build: the build ID in that build's dist/build-info.json, read once at process start, plus the plugin ID and the real root and entry inside the build's own dist or dist-runtime extensions. They then re-arm under the same rules as installed plugins. Any other build, a disabled plugin, a source run without a build record, or bundled code outside the build's output ends the schedule as before.
… the same build (openclaw#181331) Requester-command schedules from core-bundled plugins ended at every Gateway restart because those plugins load host-owned modules without a captured source digest (openclaw#180844). Give them a code identity derived from the exact loaded OpenClaw build: the build ID in that build's dist/build-info.json, read once at process start, plus the plugin ID and the real root and entry inside the build's own dist or dist-runtime extensions. They then re-arm under the same rules as installed plugins. Any other build, a disabled plugin, a source run without a build record, or bundled code outside the build's output ends the schedule as before.
Summary
Requester-admitted scheduled command turns (#180282) currently end when the Gateway restarts. #180282 shipped that as v1 and listed restart continuity as a follow-up. This PR implements that follow-up: an accepted schedule now survives a Gateway restart, within its original bounds and under the same per-occurrence authority checks.
Behavior
pluginCommandBinding) in the job's runtime state. The binding holds the Gateway process and plugin instance serving it, and the plugin generation's capturedsourceDigest. The stored schedule (pluginCommandenvelope, payload kindpluginCommand) keeps the shape released in feat(plugins): let requester commands schedule bounded follow-up turns #180282. No table, column or schema version is added.schedule()now returnssurvivesRestartso a plugin knows which case applies.resolvePluginCommandScheduleHosts), so the worker never reads plugin state itself.maxRunsand spent attempts carry over unchanged. Expired or exhausted schedules are never re-armed; the claim retires them.command-scheduled-turns-restart-v1advertises restart continuity, and each accepted schedule reportssurvivesRestart. When it is true, plugins should not re-enroll that schedule after a restart. Otherwise they keep the feat(plugins): let requester commands schedule bounded follow-up turns #180282 behavior and re-enroll from a later requester command.Rollback and older readers
pluginCommandpayload kind and never run it as a model prompt (unchanged).Tests
src/cron/store/plugin-command-schedule.worker.test.ts)src/cron/store/plugin-command-schedule-rollback.worker.test.ts)src/auto-reply/reply/commands-plugin.scheduled-turns-restart.test.ts)commands-plugin.scheduled-turns.test-support.ts, unchanged apart from the restart hook.test/plugin-command-scheduled-restart.e2e.test.ts)crashGateway), and the remaining budget runs in the new process. It ticks exactlymaxRunstimes, then retires.Evidence
Head
660d137c8f1f9fa7fe1a921d1ba6366e1b360fed, on maina8be68fc0d6746996e540a25fa8a271966b8613f. None of the 23 later commits on main touches this PR's files. Every run used private HOME, TMPDIR and state, with inheritedOPENCLAW_*variables stripped. Nothing ran against a live Gateway.Real Gateway processes: authority after a restart, through to provider I/O
Setup:
[email protected], whose role grantsoperator.admin. A separate admin identity performs the demotion.models.providersentry, so the real embedded runner and provider transport run.tools.swarm.maxConcurrentis 1.chat.send/proof-schedule(Gateway pid 8803)survivesRestart: true,maxRuns: 3crashGateway, then a new Gateway (pid 8830)cron.runforce)S6V2-CHILD-TASKrequest), andcollectreturneddone,S6V2-CHILD-DONEagent.waitreturnedtimeout, with no provider requestusers.setRole→ member (demotion), then release the holdersubagent run terminated. Target ended terminalRestart recovery operator authority changed; start a new user turn., with noacceptedAtorstartedAt. The provider never receivedS6V2-QUEUED-TASKerror: Restart recovery operator identity changed.(4 ms). No plugin effect and no provider requestReal Gateway processes: upgrade, rollback and upgrade again
One state directory alternates between the released command-schedule build (main
a8be68fwithout this PR, which has #180282) and this PR's build.survivesRestartfield) and ticked once. An ordinary disabled automation was addedended with its Gateway process) without running. A new schedule reportssurvivesRestart: trueand ticksended with its Gateway process) without runningcron.rundoes not run it. The ordinary automation is intact. 0 provider requestsReal Gateway processes: upgrade from the latest stable release
Latest stable is npm
[email protected](fe06181, which predates scheduled command turns).STABLE_PRE_UPGRADE_REPLY), an enabledagentTurnjob, a disabled job, the managedheartbeat-mainjob, and the settingagents.defaults.timeoutSeconds: 321openclaw doctor --fix --non-interactive --yes, against that profile onlylaunchctlshim on PATH recorded no service callsagentTurn.chat.historystill has the stable reply, andtimeoutSecondsis still 321survivesRestart: true. It ticked in pid 60703, the Gateway crashed, and it ticked again in pid 61994Tests and checks
test/plugin-command-scheduled-restart.e2e.test.tssrc/cronon the previous basetsgo:coreand core test shardsEach new check fails without its production change:
Production code has no test-only hook. The in-process restart tests replace, with a module mock, only the process identity the Gateway thread reports to the scheduler. The claim, plugin loader and state database are real, and the E2E repeats the restart with real processes.
E2E timing. The first CI run killed the E2E at CI's 300 s no-output limit. Its 4 s interval made every restart miss a slot, and each missed slot waits out the scheduler's two-minute startup deferral. The E2E now uses a 20 s interval, so the next slot comes after the restart, and it claims the disabled-plugin occurrence directly with
cron.run.Rollback test. As in #180274,
plugin-command-schedule-rollback.worker.test.tskeeps a frozen copy of the released reader's strict envelope and claim rule, so a future envelope change fails in CI. The real released build above provides the corresponding process-level proof.Docs
docs/plugins/sdk-runtime/background-work.mdnow describes restart continuity, rollback behavior and the cap accounting, replacing the restart-scoped v1 wording.docs/plugins/manifest/capabilities.mdlists the new capability.