Skip to content

fix(cron): reject sub-millisecond durations#100311

Closed
qingminglong wants to merge 1 commit into
openclaw:mainfrom
qingminglong:codex/100306-cron-subms-duration
Closed

fix(cron): reject sub-millisecond durations#100311
qingminglong wants to merge 1 commit into
openclaw:mainfrom
qingminglong:codex/100306-cron-subms-duration

Conversation

@qingminglong

@qingminglong qingminglong commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Closes #100306

What Problem This Solves

Fixes an issue where users setting cron CLI duration flags could have positive sub-millisecond values silently treated as 0ms when the value was below one millisecond.

Why This Change Was Made

The cron duration parser now rejects values whose millisecond result is non-finite or non-positive after unit conversion and flooring. This keeps the existing overflow guard while also rejecting tiny positive inputs that would otherwise become zero-duration metadata or cooldowns.

User Impact

Cron schedule and failure-alert duration inputs such as 0.5ms are rejected instead of being accepted as an unintended zero-millisecond value.

Evidence

  • Current head: ab50fb9f03580c368b93e11f26281719c8ebecc3.
  • Claim proved: positive sub-millisecond cron CLI durations are rejected through the real cron CLI paths while the existing duration parser behavior remains covered.
  • Changed files:
    • src/cli/cron-cli/shared.ts
    • src/cli/cron-cli/shared.test.ts
  • Commands / artifacts:
    • git diff --check -> passed after merging current upstream/main (6237580e3cc40d1c05a832428feee048dd3feb44).

ode scripts/run-vitest.mjs src/cli/cron-cli/shared.test.ts -> passed, 1 test file / 30 tests.

  • node scripts/run-vitest.mjs src/scripts/test-projects.test.ts -> passed, 1 test file / 83 tests; this covers the stale checks-node-compact-small-whole-2 log assertion after the branch merge.
  • Real CLI proof with isolated temporary OPENCLAW_HOME, OPENCLAW_STATE_DIR, and OPENCLAW_CONFIG_PATH:
    • node --import tsx src/entry.ts cron create --name subms-proof --every 0.5ms --system-event tick --json -> Error: Invalid --every. Use a duration like 10m, 1h, or 1d., exit code 1.
    • node --import tsx src/entry.ts cron edit proof-job --failure-alert --failure-alert-cooldown 0.5ms --failure-alert-mode announce -> Error: Invalid --failure-alert-cooldown., exit code 1.
  • python .agents\skills\autoreview\scripts\autoreview --mode local -> clean on the earlier local proof pass.
  • GitHub PR checks on current head: rerunning after branch update; Real behavior proof, workflow sanity, dependency guard, labeler, and OpenGrep have already reported success, with CI/CodeQL still in progress.
  • Observed result:
    • The real CLI rejects 0.5ms for both cron schedule creation and failure-alert cooldown before creating persistent user cron state.
    • Focused Vitest passed: cron parser coverage, 1 test file / 30 tests; tooling route coverage, 1 test file / 83 tests.
    • Autoreview clean: no accepted/actionable findings reported.
    • PR is mergeable and maintainer edits are enabled.
  • Not tested / proof gaps:
    • No live cron schedule was created; rejection happens before gateway RPC and before persistent cron state creation.
    • One broad CI shard, checks-node-compact-small-whole-2, failed in src/scripts/test-projects.test.ts:857 because helper routing received test/scripts/package-git-fixture.test.ts. That failure is outside this PR's cron parser diff; this PR only changes src/cli/cron-cli/shared.ts and src/cli/cron-cli/shared.test.ts.

@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 2:09 PM ET / 18:09 UTC.

Summary
The PR updates the cron CLI duration parser to reject floored non-positive millisecond results and adds regression tests for sub-millisecond inputs.

PR surface: Source 0, Tests +2. Total +2 across 2 files.

Reproducibility: yes. at source level: current main's cron parser floors 0.5ms to 0, and schedule/failure-alert callers consume that numeric result. I did not execute a local CLI repro because this review is read-only; the PR body supplies after-fix CLI proof.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #100306
Summary: This PR is the focused candidate fix for the canonical cron sub-millisecond duration parser issue; the broader batch PR overlaps but is not a safe replacement while it has its own blocker.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • No repair lane is needed; the branch already contains the focused fix and tests and should proceed through normal maintainer review or be closed only after a replacement lands.

Security
Cleared: The diff only changes a cron CLI parser condition and colocated tests; it does not touch dependencies, workflows, secrets, package metadata, or code-execution setup.

Review details

Best possible solution:

Land this standalone parser guard with focused regression tests, or close it only if an equivalent fix lands first through the batch PR.

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

Yes, at source level: current main's cron parser floors 0.5ms to 0, and schedule/failure-alert callers consume that numeric result. I did not execute a local CLI repro because this review is read-only; the PR body supplies after-fix CLI proof.

Is this the best way to solve the issue?

Yes. The shared cron parser guard is the narrowest maintainable fix because it preserves caller contracts and avoids duplicating zero-duration checks in each CLI option path.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority CLI parser bug fix with limited blast radius and focused regression coverage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal output showing real cron create and cron edit --failure-alert-cooldown commands reject 0.5ms.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal output showing real cron create and cron edit --failure-alert-cooldown commands reject 0.5ms.
Evidence reviewed

PR surface:

Source 0, Tests +2. Total +2 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 1 2 0 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 4 2 +2

What I checked:

Likely related people:

  • Alix-007: Authored the recent cron parser overflow guard in the same parseDurationMs result-validation block that this PR extends. (role: recent area contributor; confidence: high; commits: 0b807321375f; files: src/cli/cron-cli/shared.ts, src/cli/cron-cli/shared.test.ts)
  • steipete: Path history shows repeated cron CLI schedule and duration-boundary work, and he is the current assignee on this PR. (role: recent area contributor; confidence: high; commits: 2209faef405f, e0248fc11f1a, 660a6dec7f39; files: src/cli/cron-cli/shared.ts, src/cli/cron-cli/schedule-options.ts, src/cli/cron-cli/register.cron-edit.ts)
  • anagnorisis2peripeteia: Recently changed the shared cron CLI and schedule option files while adding the on-exit schedule kind. (role: recent area contributor; confidence: medium; commits: 68bfa42b9bfc; files: src/cli/cron-cli/shared.ts, src/cli/cron-cli/schedule-options.ts)
  • 0xbrak: Introduced the configurable cron failure-alert feature family that includes the affected cooldown path. (role: feature introducer; confidence: medium; commits: 4637b90c070f; files: src/cli/cron-cli/register.cron-edit.ts, packages/gateway-protocol/src/schema/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.
Review history (6 earlier review cycles)
  • reviewed 2026-07-05T12:00:51.228Z sha 32293c0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-05T14:06:31.620Z sha 32293c0 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T15:13:23.194Z sha ab50fb9 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T16:51:23.643Z sha 5cf1cf8 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T17:30:56.177Z sha db1d76d :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T17:47:48.824Z sha 3a993c4 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added 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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 5, 2026
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Jul 5, 2026
@steipete steipete self-assigned this Jul 5, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: ios App: ios app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling extensions: qa-lab extensions: policy size: XL and removed size: XS labels Jul 5, 2026
@steipete
steipete force-pushed the codex/100306-cron-subms-duration branch from 5cf1cf8 to db1d76d Compare July 5, 2026 17:23
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation app: ios App: ios labels Jul 5, 2026
@steipete
steipete force-pushed the codex/100306-cron-subms-duration branch from f19e87b to 3a993c4 Compare July 5, 2026 17:40
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed app: web-ui App: web-ui scripts Repository scripts size: M labels Jul 5, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 5, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 5, 2026
@steipete
steipete force-pushed the codex/100306-cron-subms-duration branch from 3a993c4 to 700adae Compare July 5, 2026 17:57
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thank you, @qingminglong. This exact fix and regression coverage landed on main in #100399 at b22c36f while this PR's squash was racing main.

I rechecked the current files: parseDurationMs now rejects finite values that floor to 0ms, and shared.test.ts covers both 0.5ms and 0.001ms. Closing as superseded by the landed equivalent rather than creating duplicate history.

@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thank you — this fix landed through maintainer batch PR #100399 in commit b22c36f, with contributor credit and changelog thanks preserved. Closing this source PR as superseded.

@steipete steipete closed this Jul 5, 2026
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thanks @qingminglong — this fix and its tests are preserved as the contributor-authored first commit in maintainer takeover #100399, which also carries the changelog credit and broader Testbox proof.

Closing this source PR to avoid two competing branches landing the same cron parser change. #100306 remains open until #100399 actually merges; if that takeover is abandoned, this PR can be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cron CLI accepts sub-millisecond positive durations as 0ms

2 participants