From 10691a60ec8ef3e958e9180437490d56869d83f1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 6 Sep 2026 14:30:26 +0000 Subject: [PATCH] refactor(devx): the three sequential-double-blank comment-mask callers take maskCommentsAndLiterals 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. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Vbw3RPgdtqesx4azk9SbW8 --- scripts/check-keyed-text-bounds.mjs | 10 ++++++---- scripts/check-runner-env-posture.mjs | 11 ++++++----- scripts/check-widget-option-census.mjs | 8 +++++--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/scripts/check-keyed-text-bounds.mjs b/scripts/check-keyed-text-bounds.mjs index cdf0b08aa0..4791dc6f05 100644 --- a/scripts/check-keyed-text-bounds.mjs +++ b/scripts/check-keyed-text-bounds.mjs @@ -171,7 +171,7 @@ import { dirname, join, relative, resolve, sep } from 'node:path'; import { fileURLToPath } from 'node:url'; import { isEntrypoint } from './invoked-as.mjs'; -import { blank, scanSource } from './js-comment-mask.mjs'; +import { blank, maskComments, maskCommentsAndLiterals, scanSource } from './js-comment-mask.mjs'; // ── The self-test's own battery roster and floor (#13489) ────────────────── // @@ -398,11 +398,13 @@ function unhintedFiles(relPaths) { * READ from. `struct` additionally has literal CONTENT blanked, delimiters * kept: it is what brackets are COUNTED on, so a `{` inside a string cannot * move the parse. + * + * Both are `js-comment-mask.mjs`'s own exports (#15776) rather than a + * composition re-derived here. */ function project(source) { - const { comment, literal } = scanSource(source); - const masked = blank(source, comment); - return { masked, struct: blank(masked, literal) }; + const masked = maskComments(source); + return { masked, struct: maskCommentsAndLiterals(source) }; } const OPEN_TO_CLOSE = { '(': ')', '{': '}', '[': ']' }; diff --git a/scripts/check-runner-env-posture.mjs b/scripts/check-runner-env-posture.mjs index a64ad15d9a..559fb70fa1 100644 --- a/scripts/check-runner-env-posture.mjs +++ b/scripts/check-runner-env-posture.mjs @@ -77,7 +77,7 @@ import { readFileSync, readdirSync, statSync, existsSync } from 'node:fs'; import { join, relative, resolve, sep } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { scanSource, blank } from './js-comment-mask.mjs'; +import { maskComments, maskCommentsAndLiterals } from './js-comment-mask.mjs'; import { isEntrypoint } from './invoked-as.mjs'; // ── The self-test's own battery roster and floor (#13489) ────────────────── @@ -254,12 +254,13 @@ export const RUNNER_ENV_BRACKET_PATTERN = * * Offsets are preserved by both maskings, so a reported line number still * points at the real line. + * + * Both are `js-comment-mask.mjs`'s own exports (#15776) rather than a + * composition re-derived here. */ export function findRunnerEnvReads(source) { - const flags = scanSource(source); - - const commentMasked = blank(source, flags.comment); - const bothMasked = blank(commentMasked, flags.literal); + const commentMasked = maskComments(source); + const bothMasked = maskCommentsAndLiterals(source); const seen = new Set(); const out = []; diff --git a/scripts/check-widget-option-census.mjs b/scripts/check-widget-option-census.mjs index 21b2da2421..154f59fca6 100644 --- a/scripts/check-widget-option-census.mjs +++ b/scripts/check-widget-option-census.mjs @@ -119,7 +119,7 @@ import { fileURLToPath } from 'node:url'; import process from 'node:process'; import { isEntrypoint } from './invoked-as.mjs'; -import { blank, scanSource } from './js-comment-mask.mjs'; +import { maskCommentsAndLiterals } from './js-comment-mask.mjs'; const HERE = dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = resolve(HERE, '..'); @@ -179,10 +179,12 @@ const NON_DECLARED_MEMBERS = [ * * Delimiters survive (the scanner flags literal content, not its quotes), so a * quoted object key and an array of string literals are both still locatable. + * + * `js-comment-mask.mjs`'s own `maskCommentsAndLiterals` (#15776), not a + * composition re-derived here. */ export function structureMask(source) { - const flags = scanSource(source); - return blank(blank(source, flags.comment), flags.literal); + return maskCommentsAndLiterals(source); } /**