Skip to content

[finding] A third residue of #9367's naive stripComments: both canonical-envelope page gates carry the byte-identical regex #12267

Description

@yinlianghui

Filed unassigned by the os-dev seat implementing #11576 (PR #12266). Observation-class; recording the residual, not claiming it.

What

#9367 converted six source-scanning gates off the naive comment-strip regex and onto the string-aware scripts/js-comment-mask.mjs. #10453 then found the same regex surviving in two packages/cli contract tests — "the fix converted the six gates, not the scans that live beside serve.ts".

There is a third residue, in a pair neither card covered. Both canonical-envelope page gates carry the regex, byte-identical to each other and to the family #9367 retired:

  • packages/platform-objects/src/pages/canonical-expression-envelopes.test.ts:94
  • packages/cloud-connection/src/canonical-expression-envelopes.test.ts:94
functionstripComments(source: string): string{returnsource.replace(/\/\*[\s\S]*?\*\//g,'').replace(/^[\t]*\/\/.*$/gm,'');}

Each feeds the export const X: Page = population scan that decides which pages that package's gate audits.

Why it matters here specifically

js-comment-mask's header prices this exact regex: a block-comment opener inside a string literal opens a phantom comment running to the next real terminator, deleting every line of real code in between. Measured over ~4,739 files, 16 disagreed with a real parser, 15 in the FABRICATES direction, up to 10,252 comment bytes handed to a caller as live code in one file.

The consequence for these two gates is the silent-success direction, and it is the same defect their own package gate exists to prevent: a phantom comment swallowing an export const X: Page = declaration removes that page from the gate's population, and the gate then reports green over a page it never audited. That is #11576's defect class re-entering through the detector rather than through the authoring.

Nothing currently catches it: scripts/check-parse-guard.mjs — which exists because "two private stripComments families drifted apart" — scans scripts/, not package test sources, which is exactly why #10453 had to be filed by hand for the packages/cli pair.

Not observed failing

No current page declaration in either package trips the phantom-comment shape, so both gates are green today and correctly so. This is the latent class, not a live break — the same posture #9367 and #10453 were filed in.

Possible closures

No recommendation recorded. Noting only that this is the second hand-filed residue of the same conversion, which is itself the argument for B.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions