Repository navigation
fix(cli): reject a non-numeric recall maintenance --threshold - #1799
Conversation
|
No findings in the specified diff. The parser rejects non-finite values and trailing junk while preserving finite thresholds without adding a range restriction. The PR description documents sufficient testing: a post-build real-CLI subprocess run covering four invalid values and one valid value, plus build, typecheck, and lint results. I did not run, build, or install anything from the PR. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving at 867b5fc.
I reproduced the bug on main with a built CLI: recall maintenance --prune --threshold abc exits 0, reports the knowledge base as healthy and keeps the learning. At this head it exits 1 with ✖ --threshold must be a finite number, and the learning stays. The default 0.15 and decimal values behave the same on both builds.
Hidden scope: none. The refusal is the fix itself. No default, flag or other output changes.
[P2 non-blocking] Number() accepts notations that parseFloat did not. --threshold 0x10 used to read as 0 and prune nothing. Now it reads as 16, which prunes every learning:
Number('0x10') === 16 parseFloat('0x10') === 0
Number('0b1') === 1 parseFloat('0b1') === 0
Nobody is likely to type that, but it can delete files. A decimal-only test, as parseIntOption in src/cli-int.ts does for integers, would close it. So would refusing values outside 0..1, since a confidence above 1 prunes everything anyway.
[P3 nit] The parser could sit beside parseIntOption in src/cli-int.ts instead of inline in index.ts.
The CI review found nothing. I agree, apart from the notation point above.
Summary
teamai recall maintenance --prune --threshold abcparsed the threshold withparseFloat, so it reachedfindPruneCandidatesasNaN.NaNis not nullish, so the default threshold did not apply, andconfidence < NaNis always false: the command pruned nothing and reportedNo learnings below threshold. Knowledge base is healthy.. Same pattern as #1781 and #1782.The option now fails during parsing with
--threshold must be a finite number, through the existing command error path.parseFloatalso accepted0.2abcas 0.2; that is rejected now too. No range restriction is added.Type of Change
Test Plan
Real CLI record, after
npm run build:src/__tests__/maintenance-numeric-options-e2e.test.tsrunsdist/cli.js recall maintenance --prune --threshold <value>as a subprocess.abc,NaN,Infinityand0.2abcexit 1 with the validation error, and failed without the fix;0.2is not rejected by option validation (in the uninitialized test workspace, it proceeds to the normal initialization error).Node 22 Docker verification: the original main parser fails 4 cases and passes the positive case; the fixed parser passes all 5.
npm run build,npm run typecheckandnpm run lintpass.npx tsc --noEmitpassesnpm run lintpassesnpx vitest run --config vitest.e2e.config.ts <test file>)Related Issues
None filed; found next to #1781 and #1782.
Notes for Reviewers
This change was prepared with the assistance of an AI coding tool.