Repository navigation
feat(plugins): let requester commands schedule bounded follow-up turns - #180282
fuller-stack-dev merged 5 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 real behavior proof before merge. What this changesThis PR lets authenticated plugin commands schedule bounded follow-up commands under the original requester's current authority. Example: An authenticated /review-pr command requests a follow-up every 60 seconds for 30 minutes, capped at 10 attempts.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain The native-child list regression is fixed, and no new concrete correctness defect was found; this useful maintainer-authored PR should remain open. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe command runtime captures requester and parent-session facts, the existing cron worker stores and charges occurrences, and the Gateway restores current authority before dispatching the command and admitting native children. flowchart TD
A[Authenticated requester command] --> B[Command runtime capability]
B --> C[Cron creation owner]
C --> D[SQLite scheduler worker]
D --> E[Gateway authority restoration]
E --> F[Scheduled plugin command]
F --> G[Native child admission]
G --> H[Model provider]
Technical reviewBest possible solution: Provide bounded requester-owned follow-ups through the existing cron and native-child owners, with explicit retirement on restart or plugin replacement. Do we have a high-confidence way to reproduce the issue? This is an additive capability; source inspection confirms current main lacks requester-bound scheduled command turns, and the previous list-helper regression is repaired on the reviewed head. Is this the best way to solve the issue? The design uses the existing cron persistence, worker accounting, command dispatch, and native admission owners; its new adapters serve distinct creation and execution boundaries rather than introducing another scheduler. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 47eaf429b321. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Deferred requester execution composes live operator, session, plugin, and occurrence authority checks, with no concrete bypass established. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1704, Tests +2172, Docs +114. Total +3990 across 59 files. Added test files: 7. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (4 earlier review cycles)
Reviewed October 22, 2026, 2:27 AM ET / 06:27 UTC (Revision 5). |
|
Addressed the ClawSweeper review of ca0e27e2 in commit 2e1a75a8, then rebased onto main
|
|
@clawsweeper re-review The import-cycle repair and upgrade-compatibility evidence are current on head 2e1a75a836396316d0d4895fb20643a80a12c346; please review this revision. |
|
🦞👀 Re-review progress:
|
2e1a75a to
711441e
Compare
|
Follow-up for the ClawSweeper review of 2e1a75a8 (current head a21b3b3, rebased onto main
|
|
@clawsweeper re-review The queued-child authority proof, the #180283 merge and the upgrade evidence are current on head ec2e15c34b6f2a3cd2696d20435a47f50d7ace2c; please review this revision. |
|
🦞👀 Re-review progress:
|
Authenticated requester commands that opt into `scheduledTurns` can schedule bounded follow-up turns of the same command. Each occurrence restores the original requester under current policy, rechecks the exact parent session and loaded plugin instance, refuses direct model calls, and must route model work through admitted native subagents. - Bounds: deadline at most 7 days, maxRuns 1-100, 4 schedules per invocation and 8 active schedules per loaded plugin instance and parent session. Only enabled schedules of the same instance in the current Gateway process count. - Retirement: the scheduler disables the job and clears its next run in the same transaction that launches the final allowed attempt or finds it expired, exhausted, invalid or from a previous process. A replaced plugin instance retires the schedule on its first refusal. - v1 scope: schedules end when the Gateway restarts or the plugin reloads; plugins re-enroll from a later requester command. - Rows persist under a dedicated `pluginCommand` payload kind so hosts without this feature quarantine them instead of running a model prompt. - `command-scheduled-turns-v1` advertises support. - The session-event route predicates move to `timer-session-route.ts` so a scheduled occurrence can never prepare parent notices or prompt the model.
Move the stored schedule contract and its reserved message into `src/cron/plugin-command-schedule.types.ts`, and the native subagent request source into `src/agents/plugin-native-subagent.types.ts`, so cron types, creation and storage, and the native subagent runtime and scheduled turns no longer import each other. No behavior change.
A scheduled occurrence queues a native child, settles, and the child launches later through the real Gateway instance runtime. While the requester stays authorized the child passes the agent turn's admission revalidation; after the requester is demoted (committed and published as `users.setRole` does), the next queued child is refused at that admission, before any model runner.
ec2e15c to
b8f6e2e
Compare
|
@clawsweeper re-review Rebased onto main after #180274 landed; the queued-child authority proof, conflict resolution and upgrade evidence are current on head b8f6e2e. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review The native-child list regression is fixed on head 7c28cbe; please review this revision. |
|
🦞👀 Re-review progress:
|
|
Merging at
Every other check passes or was skipped, including the security-sensitive review, dependency review and all Security High boundary checks. ClawSweeper at this head reports no findings. Its remaining requests are proof items that the PR body lists under "Not proved": provider I/O for a scheduled queued child, and a completed |
|
Follow-up evidence for the three proof gaps ClawSweeper flagged on this PR. All runs used current Isolation for every run:
(a) A scheduled child performs a real provider call; a demoted requester's queued child is refused before any callSetup:
The queued-child refusal through the channel ingress path is already covered by the harness test ( (b) Upgrade from v2026.10.5, rollback reader
(c) Harness order dependence: fixed in #180818This was a test-harness flaw, not a product cache. The capacity blocker's
Two mutation checks back it: dropping the pin fails the three hold-dependent tests, and skipping the queued authority recheck fails the demotion test. Observations, not addressed here
|
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.
…ts (#180844) * feat(plugins): keep requester command schedules across Gateway restarts Requester-admitted scheduled command turns (#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 #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.
Plugin commands typed in Slack, Discord and other channels never received the command-scoped native subagents (openclaw#180173) or scheduled turns (openclaw#180282), although the docs describe authorized channel senders as eligible. Channel ingress already binds the verified sender's operator authority, but the native gate also required a Gateway chat.send run id and user-turn recorder, which channel dispatch never supplies. For channel ingress only, the host now mints that run id and recorder, and only for the operator authority host ingress bound to the message's verified principal. The existing gate is unchanged: command authorization, the declared capability, the requester's native tool policy, admission and per-call authority rechecks still decide. Unlinked, unverified, demoted or unauthorized senders keep seeing no capability. The committed input uses the message's route-scoped source turn id, so a continuing agent turn and restart recovery join it, and it stores the same redacted form the delivered-command transcript mirror records. That mirror now records only the reply once a native command committed the input.
…#180968) Plugin commands typed in Slack, Discord and other channels never received the command-scoped native subagents (#180173) or scheduled turns (#180282), although the docs describe authorized channel senders as eligible. Channel ingress already binds the verified sender's operator authority, but the native gate also required a Gateway chat.send run id and user-turn recorder, which channel dispatch never supplies. For channel ingress only, the host now mints that run id and recorder, and only for the operator authority host ingress bound to the message's verified principal. The existing gate is unchanged: command authorization, the declared capability, the requester's native tool policy, admission and per-call authority rechecks still decide. Unlinked, unverified, demoted or unauthorized senders keep seeing no capability. The committed input uses the message's route-scoped source turn id, so a continuing agent turn and restart recovery join it, and it stores the same redacted form the delivered-command transcript mirror records. That mirror now records only the reply once a native command committed the input.
openclaw#180282) * feat(plugins): let requester commands schedule bounded follow-up turns Authenticated requester commands that opt into `scheduledTurns` can schedule bounded follow-up turns of the same command. Each occurrence restores the original requester under current policy, rechecks the exact parent session and loaded plugin instance, refuses direct model calls, and must route model work through admitted native subagents. - Bounds: deadline at most 7 days, maxRuns 1-100, 4 schedules per invocation and 8 active schedules per loaded plugin instance and parent session. Only enabled schedules of the same instance in the current Gateway process count. - Retirement: the scheduler disables the job and clears its next run in the same transaction that launches the final allowed attempt or finds it expired, exhausted, invalid or from a previous process. A replaced plugin instance retires the schedule on its first refusal. - v1 scope: schedules end when the Gateway restarts or the plugin reloads; plugins re-enroll from a later requester command. - Rows persist under a dedicated `pluginCommand` payload kind so hosts without this feature quarantine them instead of running a model prompt. - `command-scheduled-turns-v1` advertises support. - The session-event route predicates move to `timer-session-route.ts` so a scheduled occurrence can never prepare parent notices or prompt the model. * refactor(plugins): break scheduled command import cycles Move the stored schedule contract and its reserved message into `src/cron/plugin-command-schedule.types.ts`, and the native subagent request source into `src/agents/plugin-native-subagent.types.ts`, so cron types, creation and storage, and the native subagent runtime and scheduled turns no longer import each other. No behavior change. * test(plugins): prove queued scheduled children re-admit their requester A scheduled occurrence queues a native child, settles, and the child launches later through the real Gateway instance runtime. While the requester stays authorized the child passes the agent turn's admission revalidation; after the requester is demoted (committed and published as `users.setRole` does), the next queued child is refused at that admission, before any model runner. * test(plugins): close the agent turn runtime without awaiting a void result * fix(plugins): keep the native child list helper in command runtimes The command runtime projected `subagents` to spawn and collect so scheduling stays outside that object, which dropped the optional `list` helper added by openclaw#180274 for every command. Forward `list` when the native runtime provides it, and pin the exact helper set through a real command invocation.
…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.
…openclaw#180968) Plugin commands typed in Slack, Discord and other channels never received the command-scoped native subagents (openclaw#180173) or scheduled turns (openclaw#180282), although the docs describe authorized channel senders as eligible. Channel ingress already binds the verified sender's operator authority, but the native gate also required a Gateway chat.send run id and user-turn recorder, which channel dispatch never supplies. For channel ingress only, the host now mints that run id and recorder, and only for the operator authority host ingress bound to the message's verified principal. The existing gate is unchanged: command authorization, the declared capability, the requester's native tool policy, admission and per-call authority rechecks still decide. Unlinked, unverified, demoted or unauthorized senders keep seeing no capability. The committed input uses the message's route-scoped source turn id, so a continuing agent turn and restart recovery join it, and it stores the same redacted form the delivered-command transcript mirror records. That mirror now records only the reply once a native command committed the input.
Depends on #180173 (plugin commands launch native subagents), now merged; this PR is based on it.
What Problem This Solves
Plugin commands that start native subagents have no host-owned way to continue unattended later (for example a watch-PR follow-up or a long review that hands off and resumes): a plugin must either fall back to an ordinary cron job, which runs with system or operator authority and prompts the model, or lose the continuation.
User Impact
Plugin authors can call
ctx.runtimeContext.scheduledTurns.schedule(...)from an eligible authenticated requester command to schedule bounded follow-up turns of that same command. Each occurrence runs as the original requester under current policy, and model work must go through admitted native subagents.v1 scope: schedules end when the Gateway restarts. A schedule never survives a Gateway restart or a plugin reload. It is retired at its next occurrence without running plugin code, and the plugin must re-enroll from a later requester command (for example an explicit resume command). Restart continuity was a follow-up, not part of this PR; it is implemented in #180844.
Operators see these schedules as cron jobs. There is no configuration change and no migration. Plugins can detect support through the
command-scheduled-turns-v1runtime capability and register a variant without scheduled turns on older hosts.Why This Change Was Made
runtimeCapabilities: ["subagents", "scheduledTurns"], the matching manifest contracts (commandRuntimeCapabilities,sessionScheduledTurns: ["requester-command"]) andrequireAuth: true. The cron store keeps the requester's invocation facts privately. Each occurrence restores the original requester, rechecks the exact parent session and the exact loaded plugin instance against the live registry, and refusesllm.completeandcontinueAgent.maxRuns1–100.pluginCommandpayload kind, never as an ordinaryagentTurn. A host without this feature that opens the same state schema rejects the unknown payload kind through its row codec (invalid-payload, recorded in its quarantine audit records), so the row is never loaded or run as a model prompt. Hosts with an older state schema refuse to open the database at all; that boundary comes from main.src/cron/service/timer-session-route.ts, which keepstimer-execution.tswithin the line cap.This adds a plugin SDK surface and changes cron security boundaries; none of the changed paths are listed in
.github/CODEOWNERS. The sibling owned-native-children change (#180274) landed first; its capability constant and list entry insrc/plugins/runtime/runtime-base.tsare kept alongside this one.Evidence
Head
7c28cbee34b4e66db567c8e418ce0b8098e2c560on mainf2fccc2d677c7b354689fced0d4bae706350562b(which includes #180173, #180283 and #180274). Commands ran with inheritedOPENCLAW_*stripped and private HOME, state, TMPDIR and handoff-store paths. Dependencies came from the shared pnpm store.subagent-spawn, requester model catalog and native subagent contextpnpm test src/cron2e1a75a8(on main7ba05b68); the one failure,isolated-agent/run.meta-error-status.test.ts, is outside this change and passed in three isolated reruns711441edtsgo:coreand core test graphsopenai-responses-websocket.tsTS2353;ui/srcin the four Gateway graphs)git diff --check, line-cap ratchet, import cycles (including madge), plugin SDK surface and export checksusers.setRoledoes), that child is refused at admission withQueued channel operator authority changed; submit a new request., before any model runner.operator-run-recovery.tsmakes the test fail.subagent-spawn.production-boundarytest separately proves that an admitted queued child reaches the embedded model runner. Running the two cases as separate fixtures in one worker showed a cross-fixture owner-authority state leak (fresh state directory, same synthetic sender), so they share one fixture; within one fixture the demotion is enforced.agentTurn, or trusting a storedagentTurncopy;requestIdpinned to its rejection;run(..., "force")returnedunknown cron job id, no isolated, session-event or system-event run happened, and the ordinary job still loaded. With the row persisted asagentTurninstead, the same host loaded it and ran it through the session-event prompt path. Neither harness read the quarantine audit record itself; that part rests on main's row-codec code path. This was run before the rebase, and storage has not changed since.build:plugin-sdk:strict-smokeand an external consumer compiled only against the built package exports passed before the rebase; the SDK surface has not changed since.src/cron/plugin-command-schedule.types.ts, and the native subagent request source insrc/agents/plugin-native-subagent.types.ts. No behavior change; madge reports 0 cycles.7ba05b68(immediately before this PR) with five ordinary jobs was loaded by this head and by that host, each on its own copy: an isolated job with a provider model, thinking level, timeout and tool allowlist on a cron expression with a time zone; a main-session system event; asession:agent turn; a one-shotatjob withdeleteAfterRun; and a disabled job. The loaded configuration, listing, next-run times, force-run results and runner routing (including the model and thinking passed to the isolated runner) were identical, and the one-shot job was removed after its run on both.v2026.10.5needs main's pending state-schema and client-credential migration (openclaw doctor --fix) before either main7ba05b68or this head opens it; both refuse with the identical message, so this PR does not change that upgrade path. The doctor migration itself was not run here because it can manage the Gateway service on the host.prepareCurrentCapabilityProfileto the native subagent request source, which now lives in the leafplugin-native-subagent.types.ts. The command runtime keepsscheduledTurnsoutsidectx.runtimeContext.subagentsand forwards feat(plugins): let plugins recover native subagents they launched #180274's optionallistthere. A real command invocation pins the helper set (collect,list,spawn) and fails without the forwarding (flagged by ClawSweeper).scheduledTurnsto it (requires auth and a manifest contract, and still requiressubagents), advertises bothrequester-model-catalog-v1andcommand-scheduled-turns-v1, and exposesmodelsandscheduledTurnsside by side. A scheduled occurrence still receives no direct model access: the scheduled runner does not supply the interactive catalog factory.server-cron.ts,timer-execution.tsandjob-mutations.ts(including the retired monitor guard) and drops therequestHeartbeatstubs from the two new test files; S6 behavior is unchanged.122cdd8d44e73a754077074cb790c6dc033eea66ready for an upstream PR. In its own isolated worktree it ran: focused 101 passed;src/cron2178 passed; affected (33 files) 582 passed; merged with mainb3245a24, 266 passed;merge-treeclean against main175ded9d. Its own probes and mutation checks confirmed the cap and retirement behavior. The rebase changed only the base and moved the two route predicates into a sibling module, with no behavior change.src/auto-reply/reply/commands-plugin.scheduled-turns.test.tsexceeds the 30 s budget: 23 tests, about 48–63 s. Each case loads a third-party plugin from disk, real admin ingress and a real cron service, because the behaviors under test (requester restoration, plugin-instance binding, reload refusal, transcript commitment, native child lineage) live in those layers. Sharing one plugin load is unsafe because several cases reload or retire the plugin registry, reset the parent session or revoke the operator.CI failures on the first head not caused by this PR:
checks-node-changed-compact-large-30-2fails insrc/plugins/memory-background-reload.test.ts(four 120 s timeouts in the Bun agentic-plugins shard); the same three tests also time out locally on maind20b7fbc, and #180173 failed them identically.checks-ui-e2e (1/9)failsui/src/pages/plugins/plugins-lifecycle.e2e.test.ts; this PR changes no UI.Not proved:
v2026.10.5doctor migration run end to end on a fresh state copy;check-openclaw-package-tarball, or a Docker package install;Follow-ups (optional):