Skip to content

fix(decompose): a bare --limit or --max-scrapes is refused, not read as 1 - #277

Merged
StepenkoAnatoli merged 1 commit into
mainfrom
claude/decompose-numeric-flags-20261011
Oct 11, 2026
Merged

StepenkoAnatoli merged 1 commit into
mainfrom
claude/decompose-numeric-flags-20261011

Conversation

@StepenkoAnatoli

Copy link
Copy Markdown
Owner

Closes #269. Supersedes #273 (the remedy is @LetMeSleep8h's, credited with Co-authored-by in the commit).

d2c0d0d — fix(decompose): --limit and --max-scrapes go through the checkFlagValues call at the top of the CLI with { int: true, min: 0 } specs, and the later hand-written Number(raw) loop (plus the numbers object it iterated) is removed. parseFlags reads a bare flag as true, Number(true) is 1, so decompose --dry-run --max-scrapes reported "scrape up to 1" and exited 0, and a real run paid for one page nobody asked for. Now: --max-scrapes needs a value / --limit needs a value, exit 2; --limit abc → --limit must be a whole number of at least 0, not "abc". Three rows added to the bad-value table in cli.test.mjs (test count unchanged, 1786). docs/ARCHITECTURE.md decompose row and CHANGELOG.md updated in the same commit; five-part report in the commit message.

Why not merge #273 as is: right fix, but it left numbers defined and unused, carried no regression test (#269 asked for the two cli.test rows), had no CHANGELOG/map/report, and its README hunk duplicates and conflicts with #275 (which fixes #268 with the test the issue suggested).

Verified:

  • red first: with only the new rows, cli.test.mjs failed on decompose.mjs --dry-run --max-scrapes exited 0 (114 passed / 1 failed).
  • after the fix: selftest.mjs cli.test.mjs decompose.test.mjs → 152 passed / 0 failed / 0 unsupported, 295.3 s, Node 24.20.0 win32.
  • by hand from an empty folder: bare --max-scrapes, bare --limit, --limit abc, --max-scrapes -1 all refused with exit 2; --max-scrapes 0 --topic probe --dry-run runs (exit 0).
  • installed commit gate ran the full offline suite for this commit and allowed it (ADR-0120).
    Untested when opened: this PR's own CI.

Merge is the operator's.

🤖 Generated with Claude Code

…as 1

What changed: bin/decompose.mjs routes --limit and --max-scrapes through the checkFlagValues call at the top of the CLI, with { int: true, min: 0 } specs beside the four value flags, and drops the hand-written Number(raw) loop (and the `numbers` object it iterated) that ran later. The refusal for a flag with no value is "--<name> needs a value"; a non-number or a negative is "--<name> must be a whole number of at least 0, not "<value>"" (it was "must be a whole number, not"). Three rows in cli.test.mjs's bad-value table cover a bare --max-scrapes, a bare --limit and --limit abc; the test count is unchanged (rows in one registration, README stays 1786).

Why: parseFlags reads a flag with no value as `true`, and Number(true) is 1, so the loop accepted it: `decompose --dry-run --max-scrapes` reported "scrape up to 1 of the pages found" and exited 0, and without --dry-run it scraped - and paid for - one page nobody asked for; a bare --limit kept one search result instead of eight (#269, found by the owner 2026-10-11). checkFlagValues exists for exactly this and decompose already called it for its other value flags. This supersedes PR #273's fix of the same defect by LetMeSleep8h, which had the right remedy but left `numbers` defined and unused, carried no regression test, and shared its README hunk with PR #275; the remedy is theirs and is credited below. Alternative set aside: keeping the loop and adding a `=== true` check to it - two validators for one flag, one of them home-made, which is how the gap arose. No ADR: a bug fix with one obvious remedy.

What it touched: research-kit/bin/decompose.mjs (the checkFlagValues specs; the loop removed); research-kit/test/cli.test.mjs (three rows); docs/ARCHITECTURE.md (the decompose.mjs row gains the clause); CHANGELOG.md (Unreleased). No new flag, format, key or check; the documented flags and their defaults are unchanged.

What you verified:
- verified: red first - with only the test rows in place, cli.test.mjs failed on "decompose.mjs --dry-run --max-scrapes exited 0" (114 passed, 1 failed, 270.8 s; red-before-fix.log / red-before-fix-result.json in the evidence dir).
- verified: after the fix, cli.test.mjs + decompose.test.mjs (the cli needle also selects artifact-cli): 152 passed, 0 failed, 0 unsupported, 295.3 s, Node 24.20.0 win32 (focus-after-fix-result.json sha256 1d482d9f5ab6ca4e385148080a85d54574dd00a27c1a87795822c03d38330fcb).
- verified: by hand from an empty folder - `--dry-run --max-scrapes` -> "--max-scrapes needs a value", exit 2; `--dry-run --limit` -> "--limit needs a value", exit 2; `--dry-run --limit abc` -> "--limit must be a whole number of at least 0, not "abc"", exit 2; `--dry-run --max-scrapes -1` -> the same shape, exit 2; `--dry-run --max-scrapes 0 --topic probe` -> the dry run's three "would search" lines, exit 0.
- verified: git diff --check clean; the four files LF-only.
- untested when written: the installed commit gate's full-suite run for this commit, and its all-seven CI.

What you got wrong and fixed: nothing to report.

Co-authored-by: LetMeSleep8h <LetMeSleep8h@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@StepenkoAnatoli
StepenkoAnatoli merged commit a42d216 into main Oct 11, 2026
7 checks passed
@StepenkoAnatoli
StepenkoAnatoli deleted the claude/decompose-numeric-flags-20261011 branch October 11, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decompose: --max-scrapes or --limit with no value silently becomes 1 README: property-replay --case takes a JSON file path, not a case id

1 participant