Validate iterate watch scheduling options#746
Conversation
Greptile SummaryThis PR adds CLI-level input validation for the
Confidence Score: 5/5Safe to merge — the change is additive validation only; no existing data paths are altered. Both parsers are implemented correctly, the regex tightly constrains inputs to digit-only groups before numeric conversion, and the tests cover valid inputs, format errors, and out-of-range values. The wiring in iterate.ts is minimal and correct. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["sh1pt iterate watch --interval N --quiet-hours S-E"] --> B["Commander parses --interval"]
B --> C{"parsePositiveSafeInteger(N)"}
C -- valid --> D[interval stored as number]
C -- invalid --> E["InvalidArgumentError: must be a positive safe integer"]
A --> F["Commander parses --quiet-hours"]
F --> G{"parseQuietHours(S-E)"}
G -- regex fails --> H["InvalidArgumentError: must use start-end format"]
G -- regex ok --> I{"start > 23 or end > 23?"}
I -- yes --> J["InvalidArgumentError: hours must be between 0 and 23"]
I -- no --> K["returns original string value"]
D --> L["WatchConfig persisted to iterate-watch.json"]
K --> L
L --> M["iterate watch --status reads config"]
M --> N["inQuietHours(spec) called for display only"]
Reviews (2): Last reviewed commit: "Validate iterate watch interval" | Re-trigger Greptile |
|
|
||
| export function parseQuietHours(value: string): string { | ||
| const match = value.match(/^(\d{1,2})-(\d{1,2})$/); |
There was a problem hiding this comment.
start === end accepted but creates a permanently-silent quiet window
When start equals end (e.g., 10-10), the validator passes (both values ≤ 23), but inQuietHours evaluates hour >= 10 && hour < 10 — a contradiction that is never true. The watch daemon will never pause, with no error or warning surfaced to the user. Adding if (start === end) throw new InvalidArgumentError('start and end hours must differ'); before returning value would close this gap.
|
CI is green after expanding this PR to validate both Verification:
uGig invoice evidence will be sent after the retry window expires. |
Fixes #745.
Changes
iterate watch --quiet-hoursbefore configuration is persisted--intervalto be a positive safe integer before generating cron configurationVerification
corepack pnpm vitest run packages/cli/src/commands/iterate.test.ts(18 passed)corepack pnpm --filter @profullstack/sh1pt typecheckattempted; it still fails on existing workspace/module-resolution errors unrelated to this PR