cursor set: --total is not NaN-validated, writing an unparseable STATE.md while reporting ok:true #42
Labels
No labels
already-shipped
bug
documentation
duplicate
enhancement
good first issue
help wanted
in progress
invalid
needs-decision
proposal
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: crenshawdev/cadence#42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: medium · Area: planning-seam · surfaced in the post-v1.2.0 cross-model review sweep (reproduced with a fixture).
What happens
cursor setis the seam responsible for keepingSTATE.mdin a valid, parseable format. It validates--phaseas a number but does not validate--total. A non-numeric--totalbecomesNaN, passes every derivation fallback, and is written intoSTATE.mdasPhase: N of NaN. The command reportsok:true. From then on every cursor read failsunparseable-cursor, so/cad-progressand the status/drift section are broken until the file is repaired by hand — the one seam whose job is protecting that file's format is the thing that corrupts it.Mechanism (verified against source)
cadence-core/bin/planning.mjs:176:let total = opts.total ? Number(opts.total) : undefined;--total(e.g.abc) is truthy, soNumber('abc') = NaN.NaNis notundefined, so the ROADMAP-derivation (:181), prior-cursor (:187), andcannot-derive(:190) fallbacks all skip.NaNflows into the cursor object (:194-195) andrenderCursorwritesPhase: 2 of NaN;ok({ cursor })reports success (:199).Reproduction
cursor set --phase 2 --status planned --next /cad-execute --name Foo --total abc→ emits
{"ok":true,...}whileSTATE.mdgainsPhase: 2 of NaN (Foo); the nextcursor getfailsunparseable-cursor.Fix direction
Validate
--totalthe same way--phaseis validated: ifopts.totalis present butNumber(opts.total)isNaN,fail('bad-args', ...)before writing. Type-check--namesimilarly. (See #40 / the input-validation theme — a shared seam-flag validator could cover this and the low-severity--attempt/--reqscases together.)