Skip to content

feat(cron): support command jobs#89712

Merged
vincentkoc merged 11 commits into
mainfrom
codex/cron-command-payload
Jun 8, 2026
Merged

feat(cron): support command jobs#89712
vincentkoc merged 11 commits into
mainfrom
codex/cron-command-payload

Conversation

@mbelinky

@mbelinky mbelinky commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

What problem does this PR solve?

Scheduled shell-style cron work currently has to go through an isolated agent/model run, which adds setup pressure and makes simple command jobs more expensive and more fragile than they need to be.

Why does this matter now?

Gateway cron pressure is visible in production-style scheduled workloads. Staggering existing schedules is still the right immediate load-reduction step, but OpenClaw also needs a first-class path for jobs that are command execution rather than agent reasoning.

What is the intended outcome?

Command cron jobs can be stored, edited, and executed by the gateway scheduler as command payloads, with stdout/stderr capture, timeout handling, output limits, failure reporting, and NO_REPLY suppression. openclaw doctor --fix can convert exact legacy command-template agent jobs only when they already had shell-capable tool access, and it warns on mixed shell-style agent prompts that still need manual conversion.

What is intentionally out of scope?

Command authoring remains CLI-first in this PR. The UI preserves and displays existing command cron jobs, but it does not add a full command-job authoring flow. This PR also does not rewrite arbitrary natural-language agent cron prompts into commands.

What does success look like?

Existing agent cron jobs keep working, command cron payloads round-trip through schema/store/CLI/UI surfaces, the gateway cron runner executes command jobs without starting an isolated agent/model run, and doctor does not silently turn restricted agent prompts into gateway shell execution.

What should reviewers focus on?

Cron payload compatibility, command execution boundaries, output suppression semantics, timeout/error behavior, doctor migration safety, and whether the CLI/API surface is narrow enough for this first step.

Linked context

Which issue does this close?

No closing issue yet. Candidate canonical tracker is #18160, but this PR leaves it as related until maintainers decide whether CLI/API-first command jobs are enough to close the broader direct-exec cron request.

Which issues, PRs, or discussions are related?

Related #18160, #62789, #64598, #69455, #61152, #63107, #82662, #84567, #86893, #89055, #89442.

Was this requested by a maintainer or owner?

Owner/maintainer requested in response to production cron pressure and the need to run shell-style scheduled work inside OpenClaw instead of as separate OS cron jobs.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Scheduled command jobs can be stored and executed as command payloads by the gateway cron runner, including stdout/stderr capture, timeout handling, output limits, and NO_REPLY suppression. Doctor also distinguishes safe exact command-template conversion from unresolved shell-style agent prompts.
  • Real environment tested: Local OpenClaw source checkout on macOS; representative command cron jobs on a deployed maintainer gateway.
  • Exact steps or command run after this patch: git diff --check origin/main...HEAD; node scripts/run-vitest.mjs src/commands/doctor/cron/store-migration.test.ts src/commands/doctor/cron/index.test.ts src/cron/command-runner.test.ts src/cron/normalize.test.ts; AUTOREVIEW_AUTO_TESTS=0 .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --prompt 'Only report P0/P1 correctness, data-loss, security, or production-breakage findings. Omit P2/P3 findings entirely. Focus on command cron execution boundaries, doctor migration false positives/false negatives, delivery semantics, and whether unresolved shell-style agentTurn jobs are handled safely.'; deployed gateway openclaw cron run --wait on representative command cron jobs that cover silent NO_REPLY, announced media output, and delivery suppression.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): Focused Vitest shards passed: unit-fast 23 tests, cron 56 tests, commands 25 tests. git diff --check origin/main...HEAD passed. P0/P1-scoped autoreview reported autoreview clean: no accepted/actionable findings reported. Deployed command cron runs returned status: ok for silent NO_REPLY jobs and for an announced media-output job; the announced run delivered successfully, while silent runs were not delivered.
  • Observed result after fix: Command cron payloads validate, persist, normalize, execute, report output, suppress silent output, and round-trip through the tested CLI/store/UI surfaces. Doctor converts exact legacy command templates only when the legacy job already had shell-capable tool access; restricted command-shaped prompts and mixed shell-style agent prompts are left as agent jobs and reported for manual conversion.
  • What was not tested: Full CI has not completed on this refreshed head. The deployed gateway proof used existing representative command jobs rather than a newly created public demo job.
  • Proof limitations or environment constraints: Live proof is redacted to avoid publishing private gateway identifiers, job names, chat targets, or workflow details. Local tests cover the doctor migration safety cases added after the live incident.
  • Before evidence (optional but encouraged): Existing scheduled shell-style work had no first-class cron command payload path and had to be represented as agent/model work or moved outside OpenClaw.

Tests and validation

Which commands did you run?

git diff --check origin/main...HEAD

node scripts/run-vitest.mjs src/commands/doctor/cron/store-migration.test.ts src/commands/doctor/cron/index.test.ts src/cron/command-runner.test.ts src/cron/normalize.test.ts

AUTOREVIEW_AUTO_TESTS=0 .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --prompt 'Only report P0/P1 correctness, data-loss, security, or production-breakage findings. Omit P2/P3 findings entirely. Focus on command cron execution boundaries, doctor migration false positives/false negatives, delivery semantics, and whether unresolved shell-style agentTurn jobs are handled safely.'

Deployed gateway openclaw cron run --wait on representative command cron jobs covering silent output, media output, and delivery suppression.

What regression coverage was added or updated?

Protocol cron validators, cron store/normalization, command runner, gateway cron execution, CLI cron add/edit behavior, agent cron tool rejection of command payloads, UI cron controller preservation/display coverage, and doctor migration coverage for exact command-template conversion versus unresolved shell-style agent prompts. Follow-up coverage pins command timeout/no-output/abort failures as cron errors, keeps delivery-only / timeout-only CLI edits from corrupting existing command payloads, prevents restricted agent prompts from being auto-converted into gateway shell commands, and warns on omitted/wildcard shell-capable tool allowlists.

What failed before this fix, if known?

Command cron payloads were not a supported first-class scheduled job type, so the gateway cron runner could not execute shell-style work directly as a cron command payload. Legacy shell-style agent prompts could also remain model-mediated and fail in isolated cron sessions without shell/process tools.

If no test was added, why not?

N/A. Focused regression coverage was added/updated across the touched surfaces.

Risk checklist

Did user-visible behavior change? (Yes/No)

Yes. CLI/API cron jobs can now include command payloads, existing command jobs are preserved/displayed by the UI, and doctor can repair or flag legacy shell-style cron payloads.

Did config, environment, or migration behavior change? (Yes/No)

Yes. openclaw doctor --fix now performs bounded command-cron payload repair for exact legacy templates and reports unresolved shell-style agent prompts that require manual conversion.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

Yes. This adds a first-class scheduled command execution path inside the gateway cron runner.

What is the highest-risk area?

Command execution semantics and migration safety: command jobs must be explicit command payloads, bounded by timeout/output limits, and doctor must not silently escalate restricted agent prompts into gateway shell execution.

How is that risk mitigated?

The implementation keeps command authoring CLI/API scoped, rejects command payloads from the agent cron tool, runs commands through bounded command-runner coverage, caps output, records stderr/stdout, reports failures, preserves NO_REPLY suppression behavior, converts only exact command-template legacy jobs with shell-capable tool access, and warns rather than auto-converting ambiguous shell-style agent prompts.

Current review state

What is the next action?

Maintainer review and GitHub CI. The PR remains draft because this touches command execution and migration behavior and should get explicit maintainer review before being marked ready.

What is still waiting on author, maintainer, CI, or external proof?

Waiting on CI for the refreshed head and maintainer judgment on the command execution boundary. No known P0/P1 autoreview findings remain.

Which bot or reviewer comments were addressed?

P0/P1-scoped autoreview initially found two doctor migration safety issues: restricted command-shaped prompts could be auto-converted, and omitted/wildcard tool allowlists were not reported as shell-capable. Both were fixed with regression tests, and the final P0/P1-scoped autoreview run was clean.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Jun 3, 2026
@clawsweeper

clawsweeper Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed June 7, 2026, 10:51 PM ET / 02:51 UTC.

Summary
The PR adds command cron payload support across protocol schema, CLI create/edit, cron storage/normalization/execution, gateway delivery, doctor migration, Control UI preservation/display, docs, and tests.

PR surface: Source +1091, Tests +776, Docs +78. Total +1945 across 45 files.

Reproducibility: not applicable. as a bug reproduction; this is a feature PR. Source inspection confirms current main lacks a command cron payload variant and rejects non-agentTurn isolated cron payloads.

Review metrics: 3 noteworthy metrics.

  • Cron payload API surface: 1 payload kind added. payload.kind="command" is a new stored/protocol runtime variant, so compatibility and upgrade behavior need explicit review.
  • Command CLI options: 7 command-specific options added. The new create/edit flags expose process argv, cwd, env, stdin, no-output timeout, and output cap controls to operators.
  • Doctor migration behavior: 1 conversion path, 1 warning path. Doctor can now mutate legacy cron payloads into command jobs or report unresolved shell prompts, which affects upgrades.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
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:

  • Replace the hardcoded Control UI Command labels with locale-backed strings.
  • [P2] Get explicit maintainer acceptance of the command-execution and doctor-migration boundary before merge.

Risk before merge

  • [P1] Merging creates a new operator-admin scheduled host-command execution path in the Gateway process, outside model-visible tools.exec approvals and per-agent tool allowlists.
  • [P1] Doctor can migrate exact legacy agent-turn command templates into direct command payloads, so upgrade safety depends on the shell-tool-access and template heuristic staying narrow.
  • [P2] Command cron jobs can hold Gateway CPU, child processes, and I/O until timeout, no-output timeout, abort, output caps, and process-tree termination do their job.

Maintainer options:

  1. Require maintainer boundary signoff (recommended)
    Have an owner explicitly accept the Gateway admin command-execution boundary, the doctor conversion heuristic, and the process-tree termination behavior before merge.
  2. Narrow the migration path
    If maintainers are not comfortable with automatic conversion, keep command payload support but change doctor to warn only or require an explicit operator opt-in for legacy agent prompt conversion.
  3. Pause if direct execution is too broad
    Close or split the PR if the desired product direction is a smaller argv-only or no-migration command cron primitive rather than the current CLI/API plus doctor repair surface.

Next step before merge

  • [P2] This PR should stay in maintainer review because the remaining blocker is product/security acceptance of scheduled Gateway command execution and migration behavior, not a narrow automated repair.

Security
Needs attention: The diff intentionally adds a new scheduled Gateway host-command execution surface; no concrete exploit was found, but the boundary needs maintainer security review before merge.

Review findings

  • [P3] Localize command cron labels — ui/src/ui/views/cron.ts:928
Review details

Best possible solution:

Land only after maintainer security/upgrade review accepts the admin command-execution boundary and the doctor migration heuristic, with the small Control UI i18n cleanup addressed or explicitly deferred.

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

Not applicable as a bug reproduction; this is a feature PR. Source inspection confirms current main lacks a command cron payload variant and rejects non-agentTurn isolated cron payloads.

Is this the best way to solve the issue?

Mostly yes, but not fully merge-ready. CLI/API-first command payloads are a bounded core solution for deterministic cron work, while the security boundary and doctor conversion heuristic need maintainer acceptance and the new Control UI labels should use the i18n source strings.

Full review comments:

  • [P3] Localize command cron labels — ui/src/ui/views/cron.ts:928
    This adds new user-visible Control UI copy as raw Command strings while ui/AGENTS.md keeps English UI strings in the locale source maps. Please add a cron form label key and use t(...) for the locked command payload labels so i18n generation can track the new copy.
    Confidence: 0.86

Overall correctness: patch is correct
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 4780546c124d.

Label changes

Label justifications:

  • P2: This is a normal-priority but high-surface feature: valuable cron reliability work with bounded affected users and explicit maintainer review needed.
  • merge-risk: 🚨 compatibility: The PR adds a new persisted cron payload kind, CLI/API fields, and doctor migration behavior that existing installs may encounter during upgrade.
  • merge-risk: 🚨 security-boundary: The PR adds scheduled Gateway host-command execution that is intentionally outside agent tools.exec approval and tool-allowlist policy.
  • merge-risk: 🚨 availability: Command jobs can consume Gateway process, CPU, child-process, and output resources until the new timeout and kill paths recover them.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies after-fix local test output plus redacted deployed Gateway command-cron runs covering NO_REPLY, announced output, and delivery suppression.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix local test output plus redacted deployed Gateway command-cron runs covering NO_REPLY, announced output, and delivery suppression.
Evidence reviewed

PR surface:

Source +1091, Tests +776, Docs +78. Total +1945 across 45 files.

View PR surface stats
Area Files Added Removed Net
Source 31 1188 97 +1091
Tests 12 784 8 +776
Docs 2 78 0 +78
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 45 2050 105 +1945

Security concerns:

  • [medium] New Gateway command execution boundary — src/gateway/server-cron.ts:391
    Command cron jobs execute argv in the Gateway process as admin-authored automation, explicitly outside agent tools.exec approval policy; maintainers should confirm this is the intended trust boundary.
    Confidence: 0.9
  • [low] Immediate process-group kill needs owner acceptance — src/process/exec.ts:470
    The new timeout cleanup can send SIGKILL to the command process group; this is reasonable for availability, but GitHub Advanced Security also flagged it for review of graceful shutdown and process ownership assumptions.
    Confidence: 0.78

What I checked:

  • Repository policy: Root and scoped AGENTS.md files for docs, agent tools, gateway, and UI were read; the review applied the compatibility/security guidance for command execution, migrations, CLI/API surfaces, and user-visible UI copy. (AGENTS.md:1, 4780546c124d)
  • Current main behavior: Current main defines cron payloads as only systemEvent or agentTurn, so the requested command-payload capability is not already implemented on main. (src/cron/types.ts:224, 4780546c124d)
  • Current main validation: Current main rejects isolated/current/session cron jobs unless payload.kind is agentTurn, confirming command jobs need new runtime/schema support rather than being a duplicate of an existing supported path. (src/cron/service/jobs.ts:289, 4780546c124d)
  • PR command payload schema: The PR adds a command cron payload variant with argv/cwd/env/input/timeout/output-limit fields to the gateway protocol validators. (packages/gateway-protocol/src/schema/cron.ts:30, 1fa471349f8a)
  • PR command runtime: The PR adds runCronCommandJob, executing argv through runCommandWithTimeout, capturing stdout/stderr, applying output limits, and returning cron run status/diagnostics without starting an agent/model run. (src/cron/command-runner.ts:87, 1fa471349f8a)
  • PR Gateway wiring: The Gateway cron service wires command jobs into the scheduler and handles silent-token suppression plus announce delivery around the command result. (src/gateway/server-cron.ts:391, 1fa471349f8a)

Likely related people:

  • steipete: GitHub commit history shows repeated recent work on cron timer, Gateway cron, SQLite cron runtime paths, and doctor cron repair helpers, which are the central surfaces touched by this PR. (role: recent cron/gateway/doctor area contributor; confidence: high; commits: 77f09f25751a, 9d31cbbd6ad8, 2bd07eead7e7; files: src/cron/service/timer.ts, src/gateway/server-cron.ts, src/commands/doctor/cron/store-migration.ts)
  • vincentkoc: Current-main blame in this shallow checkout maps central cron timer and delivery-plan lines to a recent Vincent Koc commit, and GitHub history also shows recent Control UI cron work by this handle. (role: recent adjacent contributor and reviewer; confidence: medium; commits: 0f855ea71acc, 8bd4736f03bc; files: src/cron/service/timer.ts, src/cron/delivery-plan.ts, ui/src/ui/controllers/cron.ts)
  • Jerry-Xin: Recent Gateway cron cleanup work retired isolated cron MCP runtimes on timeout, which is adjacent to this PR's command-process timeout and availability boundary. (role: adjacent availability contributor; confidence: medium; commits: dc344a33fbfc; files: src/gateway/server-cron.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.

@mbelinky mbelinky self-assigned this Jun 3, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. 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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 3, 2026
@mbelinky
mbelinky force-pushed the codex/cron-command-payload branch from d38c43b to 732cead Compare June 3, 2026 17:46
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Jun 3, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants