Skip to content

fix(loop-cost): reject zero cadence intervals - #526

Merged
cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
Iams4kura:bugfix/reject-zero-cadence-20260815t160156z
Aug 17, 2026
Merged

fix(loop-cost): reject zero cadence intervals#526
cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
Iams4kura:bugfix/reject-zero-cadence-20260815t160156z

Conversation

@Iams4kura

Copy link
Copy Markdown
Contributor

Summary

Reject zero-length cadence intervals so loop-cost fails clearly instead of emitting Infinity runs/day and null JSON estimates.

The parser previously accepted 0m as zero milliseconds, which made the runs-per-day calculation divide by zero.

Related issue

No existing issue or pull request matched the exact 0m symptom or the affected parseInterval path.

Changes

  • New pattern or starter (followed templates/pattern-template.md + updated registry.yaml)

  • Doc / example / story improvement

  • Tool / CLI change under tools/

  • Test only

  • Other

  • Validate that a parsed cadence is greater than zero before converting it to milliseconds.

  • Add a regression test that rejects 0m.

  • Keep the repository-tracked dist runtime synchronized with the TypeScript source.

Checklist (from CONTRIBUTING)

  • Links work from README or the relevant index (no links changed)
  • No secrets, tokens, or internal company URLs
  • STATE.md* examples use .example suffix (no state examples changed)
  • Safety-related content references docs/safety.md (no safety content changed)
  • If you touched a package under tools/<pkg>: cd tools/<pkg> && npm ci && npm test
  • If you touched the registry: root npm ci && npm run validate:registry (registry not changed; the repository validation gate passed)

Testing / Dogfood

  • cd tools/loop-cost && npm test — 13 tests passed
  • bash scripts/ci-validate-gates.sh
  • bash scripts/ci-audit-gates.sh
  • Manual review of generated state / skill output if scaffolding changed (no scaffolding changed)

Regression evidence

  • Before: cd tools/loop-cost && npm test exited 1 because the new test did not observe an exception.
  • After: cd tools/loop-cost && npm test exited 0.
  • CLI behavior after the fix: --cadence 0m exits 1 with The interval value must be greater than zero.

Scope

  • 3 files changed, +14 / -2 lines

Docs, stories, adopters, and small tests: maintainers aim to review within 48 hours (same-day when possible).

@cobusgreyling cobusgreyling left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero cadence (0m) should be rejected. Check is cheap and the existing regex already only allows digits+unit; the extra value<=0 guard plus test is correct.

@cobusgreyling
cobusgreyling merged commit dd2ac8a into cobusgreyling:main Aug 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants