Repository navigation
fix(devx): check-comment-mask-corpus no longer drops argv[0] when --masker is absent - #17352
Merged
Merged
Conversation
…asker is absent
`argv.indexOf('--masker')` returns -1 when the flag is absent, and
-1 + 1 === 0, so the filter computing `rest` treated "no --masker
anywhere" as "drop index 0" -- removing the first argument from the
very list the unknown-option check reads next. An unknown option in
first position (e.g. --no-such-flag) was silently dropped, the usage
check never fired, and the script fell through to a full 6,484-file
sweep, exiting 0 instead of refusing with EXIT_USAGE.
Extracts the computation into argvAfterMasker(argv, maskerFlag),
guarded so `rest` is argv itself (not a filtered copy) when --masker
is absent. --masker in first position is unaffected and unchanged.
Adds 9 --self-test cases (floor 17 -> 26): argvAfterMasker exercised
directly for an unknown option at argv[0], a middle position, and the
position right after --masker, plus real spawned-process assertions
(following the objectui port's approach) pinning the exit code as an
actual number returned by the OS.
Measured before deciding: the issue's suggested patch carried
`&& arg !== '--self-test'`, but --self-test is dispatched by the
entrypoint before main() is ever called, so that clause would be dead
code here -- not ported.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012GKcPZbMoGq7WPzKLfRBTU
baozhoutao
marked this pull request as ready for review
September 10, 2026 08:22
baozhoutao
enabled auto-merge
September 10, 2026 08:22
This was referenced Sep 10, 2026
This was referenced Sep 10, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16540
The bug
scripts/check-comment-mask-corpus.mjs'smain()computed the argv left over after--masker PATHas:argv.indexOf('--masker')returns-1when the flag is absent, and-1 + 1 === 0— so the filter treated "no--maskeranywhere" the same as "drop index 0", removingargv[0]from the very list the unknown-option check reads next. An unknown option typed in first position (--no-such-flag, or any future--json/--shard/--since) was silently dropped, the usage check never fired, and the script fell through to the full 6,484-file sweep and exited 0.The fix
Extracted the computation into a pure, directly-testable
argvAfterMasker(argv, maskerFlag)and guarded the sentinel:When
--maskeris absent,restis nowargvitself (same reference), not a filtered copy missing its first element.--self-test— dead-code check on the issue's suggested patchThe issue's suggested patch appended
&& arg !== '--self-test'to the unknown-option filter. Measured before writing anything:--self-testis dispatched by the entrypoint block —— so
main()(where theunknownfilter lives) never receives--self-testwhen invoked via the CLI; that path is prevented from ever reachingmain()at all. The clause would be dead code here, so it was not ported.Before / after measurement
Run in a fresh worktree after
pnpm install(@typescript-eslint/parserpresent), same tree (origin/main@cca1dc0bfb):node scripts/check-comment-mask-corpus.mjs --no-such-flagnode scripts/check-comment-mask-corpus.mjs --no-such-flagEXIT_USAGE)After:
Reverse control — the untouched half did not move
--maskerin first position is the one shape the bug never affected (maskerFlagis a real index there, so the filter always behaved). Run both before and after the fix, under this container's shared verify lock (scripts/pm/os-verify-lock.sh), same command:Same shape (0 disagree, 0 unparseable,
EXIT0) both times — the difference is only the self-test case count, which is the intended change (9 new--self-testcases added for #16540), not a regression. The half this PR didn't touch didn't move.--self-testAdded 9 cases (floor raised
17 → 26, per this repo's assertion-floor culture, #13799):argvAfterMasker()(no process spawn, fast):rest === argv(same reference) when--maskeris absent--maskerin first position still drops exactly its flag and value (regression)argv[0]with--maskerabsent--maskerabsent--maskerconsumes its two slots--no-such-flagatargv[0]exitsEXIT_USAGE(typeof status === 'number' && status === 2)--maskeralso exitsEXIT_USAGEas a numberFull run:
Scope and other gates
Only
scripts/check-comment-mask-corpus.mjswas touched. Thedispatch-gates.mjs-derived family for this diff is 31 commands; all 31 ran and passed (node scripts/pm/dispatch-gates.mjs --ran FILE→ "31 derived famil(ies) accounted for — 31 run, 0 NOT-MEASURED"), including the gate itself (node scripts/check-comment-mask-corpus.mjs— the production sweep, exit 0) and its--self-test.No package under
packages/*publishes anything underscripts/(measured: nopackage.jsonin the workspace has afiles[]entry naming ascriptspath, and the repo rootpackage.jsonis"private": true), so this diff carries no published surface.Changeset
skip-changeset— measured, not assumed:scripts/check-comment-mask-corpus.mjsis a repo-root dev-tooling script, no workspace package'sfiles[]publishes anything underscripts/, and the root package itself isprivate: true. Nothing shipped moved.Clause-②: no
Generated by Claude Code