Skip to content

Commit 055848e

Browse files
baozhoutaoclaude
andauthored
refactor(devx): the three sequential-double-blank comment-mask callers take maskCommentsAndLiterals (#16336)
PR #16300 converted the eight callers the card named that spelled the comments+literals projection as `comment[i] | literal[i]` -> `blank`. Three more files spell the identical projection as a SEQUENTIAL double `blank` -- `blank(source, comment)` then `blank(masked, literal)` -- a shape the card's grep could not match, measured in the Release (0 disagreements over 6,206 files vs the export, live control 6,176). - `check-keyed-text-bounds.mjs`'s `project` keeps its pair-return shape `{ masked, struct }` as a wrapper over `maskComments` / `maskCommentsAndLiterals` called separately, following PR #16300's own precedent. - `check-runner-env-posture.mjs`'s `findRunnerEnvReads` composes the two masks inline; both are now the module's own exports. - `check-widget-option-census.mjs`'s exported `structureMask` is a straight substitution (no external importers). `js-comment-mask.mjs` untouched: no new export, no semantics change. Behaviour byte-identical, proven per gate by diffing plain and `--self-test` output on origin/main before and after: 6 runs, 6 empty diffs, exit 0 on every side. Ablation control (literal half dropped; identity mask) moves at least one reading for every gate except `check-widget-option-census`'s plain run, which is unmoved by both legs -- a pre-existing property of today's real spec/parser corpus content, not introduced by this conversion (behaviour is provably identical to the deleted code). Closed by a differential proof: the deleted sequential-double-blank spelling vs the replacement over 6,192 files (106,979,676 chars), 0 disagreements, live control (comments-only vs comments+literals) disagreeing on 6,167 files. Part of #15776. Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4108347 commit 055848e

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

scripts/check-keyed-text-bounds.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ import { dirname, join, relative, resolve, sep } from 'node:path';
171171
import { fileURLToPath } from 'node:url';
172172

173173
import { isEntrypoint } from './invoked-as.mjs';
174-
import { blank, scanSource } from './js-comment-mask.mjs';
174+
import { blank, maskComments, maskCommentsAndLiterals, scanSource } from './js-comment-mask.mjs';
175175

176176
// ── The self-test's own battery roster and floor (#13489) ──────────────────
177177
//
@@ -398,11 +398,13 @@ function unhintedFiles(relPaths) {
398398
* READ from. `struct` additionally has literal CONTENT blanked, delimiters
399399
* kept: it is what brackets are COUNTED on, so a `{` inside a string cannot
400400
* move the parse.
401+
*
402+
* Both are `js-comment-mask.mjs`'s own exports (#15776) rather than a
403+
* composition re-derived here.
401404
*/
402405
function project(source) {
403-
const { comment, literal } = scanSource(source);
404-
const masked = blank(source, comment);
405-
return { masked, struct: blank(masked, literal) };
406+
const masked = maskComments(source);
407+
return { masked, struct: maskCommentsAndLiterals(source) };
406408
}
407409

408410
const OPEN_TO_CLOSE = { '(': ')', '{': '}', '[': ']' };

scripts/check-runner-env-posture.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import { readFileSync, readdirSync, statSync, existsSync } from 'node:fs';
7777
import { join, relative, resolve, sep } from 'node:path';
7878
import { fileURLToPath } from 'node:url';
7979

80-
import { scanSource, blank } from './js-comment-mask.mjs';
80+
import { maskComments, maskCommentsAndLiterals } from './js-comment-mask.mjs';
8181
import { isEntrypoint } from './invoked-as.mjs';
8282

8383
// ── The self-test's own battery roster and floor (#13489) ──────────────────
@@ -254,12 +254,13 @@ export const RUNNER_ENV_BRACKET_PATTERN =
254254
*
255255
* Offsets are preserved by both maskings, so a reported line number still
256256
* points at the real line.
257+
*
258+
* Both are `js-comment-mask.mjs`'s own exports (#15776) rather than a
259+
* composition re-derived here.
257260
*/
258261
export function findRunnerEnvReads(source) {
259-
const flags = scanSource(source);
260-
261-
const commentMasked = blank(source, flags.comment);
262-
const bothMasked = blank(commentMasked, flags.literal);
262+
const commentMasked = maskComments(source);
263+
const bothMasked = maskCommentsAndLiterals(source);
263264

264265
const seen = new Set();
265266
const out = [];

scripts/check-widget-option-census.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ import { fileURLToPath } from 'node:url';
119119
import process from 'node:process';
120120

121121
import { isEntrypoint } from './invoked-as.mjs';
122-
import { blank, scanSource } from './js-comment-mask.mjs';
122+
import { maskCommentsAndLiterals } from './js-comment-mask.mjs';
123123

124124
const HERE = dirname(fileURLToPath(import.meta.url));
125125
const REPO_ROOT = resolve(HERE, '..');
@@ -179,10 +179,12 @@ const NON_DECLARED_MEMBERS = [
179179
*
180180
* Delimiters survive (the scanner flags literal content, not its quotes), so a
181181
* quoted object key and an array of string literals are both still locatable.
182+
*
183+
* `js-comment-mask.mjs`'s own `maskCommentsAndLiterals` (#15776), not a
184+
* composition re-derived here.
182185
*/
183186
export function structureMask(source) {
184-
const flags = scanSource(source);
185-
return blank(blank(source, flags.comment), flags.literal);
187+
return maskCommentsAndLiterals(source);
186188
}
187189

188190
/**

0 commit comments

Comments
 (0)