fix(cli): warn when a --stock entry matches no @use (audit C4) #69

Merged
abiwab merged 3 commits from fix/audit-c4 into main 2026-09-30 20:26:26 +02:00
Owner

Audit C4, present since 1.3.0. --stock ./bases/x.gram is resolved from the directory the command is typed in (deliberate: a path tab-completed in a shell), so run from another directory it matches no @use — and only gram build and gram shop said so. view, cook, check, scale, export and print accepted the flag and silently ignored it, as they did for a file that does not exist.

Reproduced on a small project: from the project directory the base collapses into one line, from a sibling directory the full breakdown comes back with no word.

  • each of the six commands now reports the unused entry on stderr through the existing reportUnusedStock; usedStock is threaded from runPipeline the way build/shop already do (checker result, view model, and an onUsedStock callback in the export/print options so no return type changes)
  • the warning now says where it looked and why: (a relative path is resolved from the current directory, not from the recipe)
  • the resolution rule itself is unchanged (cwd-relative, a shell convention)

Not done on purpose: gram watch checks one file at a time, so an entry used by another file of the watched folder would look unused: a warning there would be wrong.

Tests: 10 end-to-end cases through the real CLI (4 commands from another directory, silence from the right one, a file that does not exist, stderr only); 5 fail on the previous code. cook and print are implemented but not run by the tests (terminal UI / opens a browser). New patch changeset. ci (1335 tests) and conformance 98/98 pass.

Audit C4, present since 1.3.0. `--stock ./bases/x.gram` is resolved from the directory the command is typed in (deliberate: a path tab-completed in a shell), so run from another directory it matches no `@use` — and only `gram build` and `gram shop` said so. `view`, `cook`, `check`, `scale`, `export` and `print` accepted the flag and silently ignored it, as they did for a file that does not exist. Reproduced on a small project: from the project directory the base collapses into one line, from a sibling directory the full breakdown comes back with no word. - each of the six commands now reports the unused entry on stderr through the existing `reportUnusedStock`; `usedStock` is threaded from `runPipeline` the way build/shop already do (checker result, view model, and an `onUsedStock` callback in the export/print options so no return type changes) - the warning now says where it looked and why: `(a relative path is resolved from the current directory, not from the recipe)` - the resolution rule itself is unchanged (cwd-relative, a shell convention) Not done on purpose: `gram watch` checks one file at a time, so an entry used by another file of the watched folder would look unused: a warning there would be wrong. Tests: 10 end-to-end cases through the real CLI (4 commands from another directory, silence from the right one, a file that does not exist, stderr only); 5 fail on the previous code. `cook` and `print` are implemented but not run by the tests (terminal UI / opens a browser). New patch changeset. ci (1335 tests) and conformance 98/98 pass.
abiwab merged commit 4af26a896a into main 2026-09-30 20:26:26 +02:00
abiwab deleted branch fix/audit-c4 2026-09-30 20:26:27 +02:00
Sign in to join this conversation.
No description provided.