Skip to content

cron: optional custom job id and duplicate-id validation - #75065

Closed
Saitop wants to merge 3 commits into
openclaw:mainfrom
NomiciAI:feat/cron-custom-job-id
Closed

Saitop wants to merge 3 commits into
openclaw:mainfrom
NomiciAI:feat/cron-custom-job-id

Conversation

@Saitop

@Saitop Saitop commented Apr 30, 2026

Copy link
Copy Markdown

Replaces #40218. The previous PR was closed when the old public fork was removed during repo hygiene cleanup; this is the same upstreamable change from the new public contribution fork.

Summary

  • Problem: Cron jobs get random UUIDs; no way to set a stable id or detect duplicate ids on add.
  • Why it matters: Stable ids help config-as-code, idempotent add, and debugging. Duplicate ids would corrupt store expectations.
  • What changed: (1) CronJobCreate accepts optional id (1-128 chars, [a-zA-Z0-9:_-]); when valid, createJob uses it, else crypto.randomUUID(). (2) add() throws if a job with the same id already exists.
  • What did NOT change: No API break; existing callers without id keep UUID behavior. No change to update/remove or list.

Change Type (select all)

  • Feature

Scope (select all touched areas)

  • API / contracts

Linked Issue/PR

User-visible / Behavior Changes

  • Cron job create (CLI/Gateway/API) can pass optional id. If provided and valid, that id is used; otherwise a UUID is assigned.
  • Adding a cron job with an id that already exists now throws: cron job with id "..." already exists.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS
  • Runtime: Node 22
  • Relevant: pnpm build && pnpm check && pnpm test --run src/cron/service.jobs.test.ts src/cron/service.get-job.test.ts

Steps

  1. Add a job with custom id, e.g. openclaw cron add --id my-nightly ... (or via Gateway cron API with id: "my-nightly").
  2. Add another job with the same id.

Expected

  • First add uses id my-nightly. Second add throws.

Actual

  • As expected.

Evidence

  • New tests: createJob custom id (valid/invalid/omit/trim) and uses custom id when provided and rejects duplicate id on add in service.get-job.test.ts.

@Saitop
Saitop requested a review from a team as a code owner April 30, 2026 12:10
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling size: S labels Apr 30, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: the remaining custom cron job ID feature is already tracked by the canonical open issue, while this PR is conflicting, lacks real behavior proof, and no longer updates the active current-main protocol/tool paths cleanly enough to remain the landing target.

Canonical path: Keep the canonical feature issue open and close this stale PR; any implementation should be a current-main port or replacement that updates the active protocol package, CLI, service, generated clients, docs, and agent-tool canonicalizer with real behavior proof.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Keep the canonical feature issue open and close this stale PR; any implementation should be a current-main port or replacement that updates the active protocol package, CLI, service, generated clients, docs, and agent-tool canonicalizer with real behavior proof.

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

Yes for the source-level feature gap: current main has no cron add --id flag, CronJobCreate omits id, the active protocol schema has no id field, and createJob always generates a UUID. I did not run a live CLI/Gateway repro because this was a read-only cleanup review.

Is this the best way to solve the issue?

No as submitted. The feature direction is plausible, but this stale branch misses current protocol/tool paths, is conflicting, and needs maintainer-approved validation plus real behavior proof before it is the best fix.

Security review:

Security review cleared: No concrete security or supply-chain concern was found; the diff touches cron validation, generated models, docs, and tests without dependency, workflow, secret, permission, or package-execution changes.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy read: Root AGENTS.md was read fully, and relevant scoped docs, Gateway, and agent-tool guidance was checked; public CLI/Gateway/API contract changes and contributor PR proof gates affected this review. (AGENTS.md:1, 82dfd8910743)
  • Current main still lacks the CLI flag: Current main defines cron add/create options without --id and builds the cron.add params object without an id field. (src/cli/cron-cli/register.cron-add.ts:87, 82dfd8910743)
  • Current main still lacks the active protocol field: The active CronAddParamsSchema in packages/gateway-protocol is closed with additionalProperties: false and has no id property. (packages/gateway-protocol/src/schema/cron.ts:484, 82dfd8910743)
  • Current main still generates UUIDs on create: CronJobCreate omits id and createJob assigns crypto.randomUUID() unconditionally before persistence. (src/cron/service/jobs.ts:757, 82dfd8910743)
  • Active Gateway path differs from the PR patch: Current Gateway cron handlers import validators from packages/gateway-protocol/src/index.js, while this PR changes the older src/gateway/protocol/schema/cron.ts path; current main has no files under src/gateway/protocol. (src/gateway/server-methods/cron.ts:6, 82dfd8910743)
  • Canonical issue remains open: The open canonical issue requests the same supported cron add --id behavior with validation and collision handling.

Likely related people:

  • 849261680: Recent per-job fallback work changed the cron CLI, active Gateway protocol schema, service creation, and type surfaces that a custom-id implementation must update. (role: recent cron create surface contributor; confidence: medium; commits: 1662b07810eb, cfeaf6897fd8; files: src/cli/cron-cli/register.cron-add.ts, packages/gateway-protocol/src/schema/cron.ts, src/cron/service/jobs.ts)
  • steipete: Recent cron create delivery ergonomics and service refactors touched the same CLI and service owner boundary. (role: historical cron runtime and CLI contributor; confidence: medium; commits: 2209faef405f; files: src/cli/cron-cli/register.cron-add.ts, src/cron/service/jobs.ts)
  • mbelinky: Command-job support changed cron create payloads, protocol schema, service creation, types, and CLI behavior adjacent to the requested custom-id path. (role: adjacent cron feature contributor; confidence: medium; commits: b8adc11977ab; files: src/cli/cron-cli/register.cron-add.ts, packages/gateway-protocol/src/schema/cron.ts, src/cron/service/jobs.ts)
  • zw-xysk: Recent canonicalizer work moved recognized cron job object keys into src/agents/tools/cron-tool-canonicalize.ts, which a current-main implementation would need to update instead of the older cron-tool.ts location. (role: recent cron tool canonicalizer contributor; confidence: medium; commits: 3a32d2439539; files: src/agents/tools/cron-tool-canonicalize.ts)
  • joshavant: Recent agent-scoped cron operations changed Gateway cron handling and agent-tool paths near the API boundary for cron creation. (role: recent adjacent Gateway cron contributor; confidence: medium; commits: cee2aca40912; files: src/gateway/server-methods/cron.ts, src/agents/tools/cron-tool.ts, packages/gateway-protocol/src/cron-validators.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 82dfd8910743.

@Saitop
Saitop force-pushed the feat/cron-custom-job-id branch from 7ba3fab to 76b7ccf Compare May 1, 2026 09:44
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 30, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 31, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

@Saitop thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@clawsweeper clawsweeper Bot added 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. 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. labels Jun 17, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 29, 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: macos App: macos app: web-ui App: web-ui cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant