fix(loop-cost): reject zero cadence intervals - #526
Merged
cobusgreyling merged 1 commit intoAug 17, 2026
Merged
Conversation
cobusgreyling
approved these changes
Aug 17, 2026
cobusgreyling
left a comment
Owner
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject zero-length cadence intervals so
loop-costfails clearly instead of emittingInfinityruns/day andnullJSON estimates.The parser previously accepted
0mas zero milliseconds, which made the runs-per-day calculation divide by zero.Related issue
No existing issue or pull request matched the exact
0msymptom or the affectedparseIntervalpath.Changes
New pattern or starter (followed
templates/pattern-template.md+ updatedregistry.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
distruntime synchronized with the TypeScript source.Checklist (from CONTRIBUTING)
STATE.md*examples use.examplesuffix (no state examples changed)docs/safety.md(no safety content changed)tools/<pkg>:cd tools/<pkg> && npm ci && npm testnpm ci && npm run validate:registry(registry not changed; the repository validation gate passed)Testing / Dogfood
cd tools/loop-cost && npm test— 13 tests passedbash scripts/ci-validate-gates.shbash scripts/ci-audit-gates.shRegression evidence
cd tools/loop-cost && npm testexited1because the new test did not observe an exception.cd tools/loop-cost && npm testexited0.--cadence 0mexits1withThe interval value must be greater than zero.Scope
Docs, stories, adopters, and small tests: maintainers aim to review within 48 hours (same-day when possible).