Skip to content

[Feat] Add single-job cron get path - #75117

Merged
steipete merged 3 commits into
openclaw:mainfrom
samzong:feat/cron-get
May 11, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
samzong:feat/cron-get

Conversation

@samzong

@samzong samzong commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: cron jobs are id-addressable for mutation, but single-job inspection still required fetching cron.list and filtering client-side.
  • Why it matters: agent and scripted workflows that already know a job id waste payload and token budget on the full cron job set.
  • What changed: added Gateway cron.get, CLI openclaw cron get <id>, agent-tool get, protocol schema/types/validators, docs, and focused tests.
  • What did NOT change (scope boundary): no scheduling, execution, delivery, or existing cron list / cron show behavior changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: a caller that already knows a cron job id can fetch exactly that stored job through the real CLI/Gateway path instead of listing all jobs and filtering locally.
  • Real environment tested: macOS local checkout, commit 305e7bd1ab, Node/pnpm workspace, isolated temporary HOME, OPENCLAW_STATE_DIR, and OPENCLAW_CONFIG_PATH, foreground Gateway with --auth none on loopback port 19731.
  • Exact steps or command run after this patch:
env HOME=/tmp/openclaw-cron-get-proof-75117/home \
  OPENCLAW_STATE_DIR=/tmp/openclaw-cron-get-proof-75117/state \
  OPENCLAW_CONFIG_PATH=/tmp/openclaw-cron-get-proof-75117/state/config.json \
  pnpm openclaw gateway run --dev --reset --port 19731 --auth none \
  --allow-unconfigured --ws-log compact

env HOME=/tmp/openclaw-cron-get-proof-75117/home \
  OPENCLAW_STATE_DIR=/tmp/openclaw-cron-get-proof-75117/state \
  OPENCLAW_CONFIG_PATH=/tmp/openclaw-cron-get-proof-75117/state/config.json \
  node scripts/run-node.mjs cron add --url ws://127.0.0.1:19731 \
  --token proof-token --name "cron get proof" --every 1h --session isolated \
  --agent main --message "cron get proof message" --no-deliver --json

env HOME=/tmp/openclaw-cron-get-proof-75117/home \
  OPENCLAW_STATE_DIR=/tmp/openclaw-cron-get-proof-75117/state \
  OPENCLAW_CONFIG_PATH=/tmp/openclaw-cron-get-proof-75117/state/config.json \
  node scripts/run-node.mjs cron get --url ws://127.0.0.1:19731 \
  --token proof-token 80ff3623-da2f-415c-9ea9-7bff2905cd7f

env HOME=/tmp/openclaw-cron-get-proof-75117/home \
  OPENCLAW_STATE_DIR=/tmp/openclaw-cron-get-proof-75117/state \
  OPENCLAW_CONFIG_PATH=/tmp/openclaw-cron-get-proof-75117/state/config.json \
  node scripts/run-node.mjs cron get --url ws://127.0.0.1:19731 \
  --token proof-token missing-proof-job
  • Evidence after fix (copied live output):
ADD_OUTPUT
{
  "id": "80ff3623-da2f-415c-9ea9-7bff2905cd7f",
  "agentId": "main",
  "name": "cron get proof",
  "enabled": true,
  "createdAtMs": 1778520004764,
  "updatedAtMs": 1778520004764,
  "schedule": {
    "kind": "every",
    "everyMs": 3600000,
    "anchorMs": 1778520004764
  },
  "sessionTarget": "isolated",
  "wakeMode": "now",
  "payload": {
    "kind": "agentTurn",
    "message": "cron get proof message"
  },
  "delivery": {
    "mode": "none",
    "channel": "last"
  },
  "state": {
    "nextRunAtMs": 1778523604764
  }
}
JOB_ID 80ff3623-da2f-415c-9ea9-7bff2905cd7f
GET_OUTPUT
{
  "id": "80ff3623-da2f-415c-9ea9-7bff2905cd7f",
  "agentId": "main",
  "name": "cron get proof",
  "enabled": true,
  "createdAtMs": 1778520004764,
  "updatedAtMs": 1778520004764,
  "schedule": {
    "kind": "every",
    "everyMs": 3600000,
    "anchorMs": 1778520004764
  },
  "sessionTarget": "isolated",
  "wakeMode": "now",
  "payload": {
    "kind": "agentTurn",
    "message": "cron get proof message"
  },
  "delivery": {
    "mode": "none",
    "channel": "last"
  },
  "state": {
    "nextRunAtMs": 1778523604764
  }
}
VERIFIED cron.get returned 80ff3623-da2f-415c-9ea9-7bff2905cd7f (cron get proof)
MISSING_STDERR
GatewayClientRequestError: cron job not found: missing-proof-job
VERIFIED missing id reports cron job not found
  • Observed result after fix: cron get <id> returned the same stored job id/name/payload created through the live Gateway-backed CLI path; a missing id returned the expected cron job not found error.
  • What was not tested: remote Gateway auth modes, actual due-time execution of the job, cross-platform service-managed Gateway startup, and a packaged release build.
  • Before evidence (optional but encouraged): not captured locally; before this patch there was no openclaw cron get command or cron.get Gateway method to call.

Root Cause (if applicable)

  • Root cause: N/A
  • Missing detection / guardrail: N/A
  • Contributing context (if known): Cron mutation commands already accepted ids, but the read surface only exposed collection listing and local filtering.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • src/cron/service.get-job.test.ts
    • src/gateway/server.cron.test.ts
    • src/gateway/server-methods/cron.validation.test.ts
    • src/gateway/protocol/cron-validators.test.ts
    • src/cli/cron-cli.test.ts
    • src/agents/tools/cron-tool.test.ts
    • src/agents/tools/cron-tool.schema.test.ts
    • src/gateway/server-cron-lazy.test.ts
    • src/plugins/contracts/scheduled-turns.contract.test.ts
  • Scenario the test should lock in: callers can fetch one cron job by id through service, Gateway RPC, CLI routing, and agent tool routing; missing ids fail cleanly; persisted jobs load from a cold disabled scheduler.
  • Why this is the smallest reliable guardrail: the new behavior is a protocol/CLI/tool seam over cron service storage, so these tests cover the contract without changing scheduler behavior.
  • Existing test that already covers this (if any): none before this PR.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Added openclaw cron get <id> for stored cron job JSON inspection.
  • Added Gateway RPC cron.get.
  • Added get action support to the agent cron tool.

Diagram (if applicable)

Before:
[caller knows job id] -> [cron list --json] -> [client filters jobs]

After:
[caller knows job id] -> [cron get <id>] -> [single stored job JSON]

Security Impact (required)

  • New permissions/capabilities? (Yes/No) Yes
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) Yes
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation: cron.get is a new read-only Gateway method and agent-tool action. It uses operator.read, matching cron.list, which already exposes stored cron job definitions. Restricted isolated cron tool grants only allow get for the current job id.

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node/pnpm workspace
  • Model/provider: N/A
  • Integration/channel (if any): cron/Gateway/CLI/agent tool
  • Relevant config (redacted): isolated temporary HOME, OPENCLAW_STATE_DIR, and OPENCLAW_CONFIG_PATH; Gateway auth disabled for loopback proof; dummy CLI token only used because URL overrides require explicit credentials.

Steps

  1. Start a foreground dev Gateway in an isolated temporary home.
  2. Create an isolated cron job with openclaw cron add --json.
  3. Fetch the created job with openclaw cron get <job-id>.
  4. Fetch a missing id with openclaw cron get missing-proof-job.

Expected

  • Existing ids return the stored cron job JSON.
  • Missing ids return a clean invalid request error.
  • Existing cron list and cron show behavior remains unchanged.

Actual

  • Existing id returned the stored cron get proof job JSON.
  • Missing id returned GatewayClientRequestError: cron job not found: missing-proof-job.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Verification run after rebase to origin/main / commit 305e7bd1ab:

pnpm changed:lanes --json
# lanes: core, coreTests, extensions, extensionTests, docs, tooling

pnpm test src/cron/service.get-job.test.ts \
  src/gateway/server-methods/cron.validation.test.ts \
  src/gateway/server.cron.test.ts \
  src/gateway/server-cron-lazy.test.ts \
  src/gateway/protocol/cron-validators.test.ts \
  src/cli/cron-cli.test.ts \
  src/agents/tools/cron-tool.test.ts \
  src/agents/tools/cron-tool.schema.test.ts \
  src/plugins/contracts/scheduled-turns.contract.test.ts -- --reporter=verbose
# passed 6 Vitest shards in 14.48s

pnpm check:docs
# passed: docs formatting, markdownlint, MDX, i18n glossary, and link audit

env -u http_proxy -u https_proxy -u all_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
  OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 \
  pnpm test src/gateway/server.plugin-node-capability-auth.test.ts -- --reporter=verbose
# passed 1 Vitest shard in 3.10s

Known local gate gaps:

pnpm check:changed
# failed in non-diff current-main test type errors:
# src/acp/translator.session-rate-limit.test.ts
# src/acp/translator.stop-reason.test.ts
# src/auto-reply/reply/agent-runner-direct-runtime-config.test.ts
# git diff --name-only origin/main...HEAD -- those files is empty.

pnpm test:changed
# ran 9 passing shards, then failed one unrelated gateway test because local
# proxy env vars routed the IPv6 loopback case through 127.0.0.1:7890.
# The exact failing file passed when proxy env vars were unset, as shown above.

Human Verification (required)

  • AI-assisted: Yes; human-run real behavior proof and local verification are listed above.
  • Verified scenarios: live CLI/Gateway cron add followed by cron get <id>; missing id error path; CLI help registration; service reads existing/missing jobs; cold disabled scheduler loads persisted jobs; Gateway cron.get success/missing paths; CLI routing; protocol validation; agent tool routing.
  • Edge cases checked: id and jobId selectors; cold disabled scheduler store load; restricted isolated cron tool can only get the current job id.
  • What you did not verify: remote Gateway auth modes, actual due-time execution of the job, cross-platform service-managed Gateway startup, packaged release build.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: cron.get could diverge from cron read-store behavior.
    • Mitigation: CronService.readJob() uses the same locked ensureLoadedForRead() path as other async read operations, and cold disabled scheduler coverage locks this in while preserving synchronous getJob() for already-loaded event paths.

@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: M labels Apr 30, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR adds direct single-job cron inspection through Gateway cron.get, openclaw cron get <id>, agent-tool get, protocol/docs updates, changelog, and focused tests.

Reproducibility: not applicable. as a feature PR. The current-main gap is source-confirmed by the absence of cron.get and openclaw cron get, and the PR body supplies after-fix live CLI/Gateway output.

Real behavior proof
Sufficient (live_output): The PR body includes copied live CLI/Gateway output showing a job created through the real path, fetched by cron get <id>, and a missing id returning the expected error.

Next step before merge
The remaining blocker is a narrow generated-protocol artifact sync that an automated repair can attempt safely.

Security
Cleared: The diff adds a read-only cron inspection method under the existing operator.read scope and does not touch dependencies, workflows, secrets, package scripts, or release/install surfaces.

Review findings

  • [P2] Regenerate the Swift protocol model — src/gateway/protocol/schema/protocol-schemas.ts:458
Review details

Best possible solution:

Regenerate and include the tracked protocol artifacts, then land the additive cron.get path after protocol:check, focused cron tests, and normal CI are green.

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

Not applicable as a feature PR. The current-main gap is source-confirmed by the absence of cron.get and openclaw cron get, and the PR body supplies after-fix live CLI/Gateway output.

Is this the best way to solve the issue?

No, not merge-ready as-is. The direct read API is the narrow maintainable approach, but the protocol artifact drift must be fixed before merge.

Full review comments:

  • [P2] Regenerate the Swift protocol model — src/gateway/protocol/schema/protocol-schemas.ts:458
    Adding CronGetParams to ProtocolSchemas changes the generated protocol output, but the tracked Swift model still has no CronGetParams. pnpm protocol:check regenerates and diffs that file, so this leaves the protocol contract out of sync until the generated artifact is updated.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.93

Acceptance criteria:

  • pnpm protocol:check
  • pnpm test src/cron/service.get-job.test.ts src/gateway/server-methods/cron.validation.test.ts src/gateway/server.cron.test.ts src/gateway/server-cron-lazy.test.ts src/gateway/protocol/cron-validators.test.ts src/cli/cron-cli.test.ts src/agents/tools/cron-tool.test.ts src/agents/tools/cron-tool.schema.test.ts -- --reporter=verbose
  • pnpm check:changed

What I checked:

Likely related people:

  • steipete: Recent commits touched cron helper exports, self-scoped cron run inspection, agent cron tooling, and lazy cron Gateway startup, which are central to this PR's read path and lazy-load behavior. (role: recent area contributor; confidence: high; commits: 7e845133346d, a9a70b6e6078, f30dd51d5f7f; files: src/cron/service.ts, src/agents/tools/cron-tool.ts, src/gateway/server-cron-lazy.ts)
  • obviyus: Recent commits touched server-side cron delivery previews, Gateway cron validation behavior, and CLI cron-show pagination around the same list/show/read surface this PR extends. (role: recent cron Gateway and CLI contributor; confidence: high; commits: 0b25a7328880, 9b38606d5c1f, 19e451dc75cc; files: src/gateway/server-methods/cron.ts, src/cli/cron-cli/register.cron-simple.ts)
  • vincentkoc: Recent history shows the split and alignment of the Gateway cron service contract, which this PR extends with the async readJob method. (role: cron contract contributor; confidence: medium; commits: 3e96fdea9fc7, 7204d490aa93; files: src/cron/service-contract.ts, src/cron/service.ts, src/gateway/server-cron-lazy.ts)
  • tyler6204: History and shortlog output show substantial prior work across the cron scheduler, store, CLI, and agent-tool surfaces affected by this feature. (role: major cron subsystem contributor; confidence: medium; commits: 38543d819690, e554c59aac68, 07375a65d898; files: src/cron, src/gateway/server-methods/cron.ts, src/agents/tools/cron-tool.ts)

Remaining risk / open question:

  • The tracked generated Swift protocol model remains out of sync with the new CronGetParams schema until regenerated.

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

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 6, 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: 9f7cd00467

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

Comment thread src/gateway/server-methods/cron.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 11, 2026
@samzong

samzong commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🚀

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

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026

akrimm702 commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Rechecked this against current origin/main (d79a585878). The cron-get implementation itself still looks sound, and the focused PR-head validation passes locally:

  • git diff --check origin/main...HEAD -> passed
  • CI=true pnpm test src/agents/tools/cron-tool.test.ts src/agents/tools/cron-tool.schema.test.ts src/cli/cron-cli.test.ts src/cron/service.get-job.test.ts src/gateway/server.cron.test.ts src/gateway/server-methods/cron.validation.test.ts src/gateway/protocol/cron-validators.test.ts src/gateway/server-cron-lazy.test.ts -- --reporter=verbose -> passed 5 Vitest shards / 215 tests
  • CI=true pnpm check:changed -> passed on the PR head

Current blocker: this is not merge-ready against today’s main because git merge-tree --write-tree origin/main refs/remotes/pr/75117 reports a real content conflict in src/gateway/server-methods/cron.validation.test.ts. Current main added the rejects execution-derived diagnostics in cron.update state patches test in the same area where this PR adds cron.get validation helpers/tests.

The resolution should be mechanical: keep the PR’s readJob test context, invokeCronGet, and the two cron.get validation tests, while also keeping the new current-main diagnostics-rejection test. After rebasing/resolving, rerun at least the targeted command above plus check:changed.

Remote CI’s current failures look unrelated/stale (reset.test.ts / uninstall.test.ts type errors and extension test core-import boundary failures outside this diff), but CI will need a fresh run after the rebase.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 11, 2026
@steipete

Copy link
Copy Markdown
Contributor

Landing verification for the rebased PR head a11b72231a0238c84fb4272f0612bae1700d037f.

  • Rebased onto current main (3775532a29165fd17a6805c76be5e403ac813f42).
  • Local proof: pnpm docs:list; pnpm changed:lanes --json; focused cron suite via pnpm test src/agents/tools/cron-tool.test.ts src/cli/cron-cli.test.ts src/cron/service.get-job.test.ts src/gateway/server-cron-lazy.test.ts src/gateway/server-methods/cron.validation.test.ts src/gateway/protocol/cron-validators.test.ts src/gateway/server.cron.test.ts src/plugins/contracts/scheduled-turns.contract.test.ts -- --reporter=verbose (231 tests passed); git diff --check.
  • Maintainer fixup proof: pnpm check:test-types; pnpm test src/agents/pi-embedded-runner/run.overflow-compaction.test.ts -- --reporter=verbose (22 tests passed).
  • Remote broad proof: AWS Crabbox lease cbx_93c827491e00, hydration Actions run 25686768782, pnpm check:changed passed on the rebased PR head.
  • GitHub proof: Workflow Sanity 25687008223 passed; Real behavior proof 25687027964 passed. Main CI/security workflows for this exact SHA are still queued due runner capacity: CI 25687008219, CodeQL 25687008174, OpenGrep 25687008169, CodeQL Critical Quality 25687008100.
  • Testbox capacity note: Blacksmith Testbox attempts tbx_01krc0m2hkqfy4fppxvqy2nwq9 and tbx_01krc0yj0g0nymhb3a3hd06jqm did not reach usable command execution; both exited before lease while the queue stayed backed up.

Thanks @samzong!

@steipete
steipete merged commit ee07601 into openclaw:main May 11, 2026
90 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

  • Contributor commit on main: 380a67931313b06805eb444a69007b8ba2977e25
  • Changelog commit on main: b9aee95591d81ebd141c8c9834a8f08c4526c41e
  • Maintainer test fix on main: ee0760172db2c0973dd8840c3e81f1c64d43f199

Thanks @samzong!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 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 docs Improvements or additions to documentation gateway Gateway runtime proof: supplied External PR includes structured after-fix real behavior proof. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: add single-job inspection by id

3 participants