Skip to content

Two packages/cli scans read serve.ts with no comment/code separator at all, so prose counts as code — the direction js-comment-mask's header calls the worse one #10514

Description

@os-elon

Filed unassigned from the #10453 dev seat (session session_019bmVFqoQPq63zhKrxdYG1r, PR #10513). Found by re-deriving that card's file paths at head instead of trusting them.

How it surfaced

#10453 names two packages/cli contract tests as carrying #9367's naive stripComments. Re-derived at 5c3faa70d by searching for the strip pattern: only one does.serve-email-config-parity.contract.test.ts has no comment handling at all, and git log -S stripComments on that path returns nothing — it never had one. PR #10513 converts the one that really carries it and leaves this alone, because the fix is not the same fix.

But "has no strip" is not the same as "is fine". Two scans in that directory read serve.tsraw, comments included. A naive strip is wrong in the BLINDS direction (real code deleted). Reading raw is wrong in the FABRICATES direction — the one scripts/js-comment-mask.mjs's own header singles out:

the gate reads genuinely commented-out text as live code: it FABRICATES a hit rather than missing one.

Same classification #10427 applies to scanSource's desync. Neither scan is wrong today; both are one ordinary comment away from being wrong.

Subject 1 — packages/cli/src/commands/serve-email-config-parity.contract.test.ts

keysReadFromConfigEmail() matches /cfgEmail\.[A-Za-z_$][\w$]*/g over raw SERVE_SOURCE. Its docblock argues the scan is "an exact measure rather than an approximation" because every read of cfgEmail is a dot access — true, and beside the point: it never considers that a dot access can appear in prose.

Both of its assertions break, in opposite directions. Measured on today's serve.ts:

today: ["apiKey","appName","defaultFrom","defaultTemplateContext","options","persist","provider","queueDelivery","retries"]
+ one COMMENT naming cfgEmail.bogusKey -> undeclared = ["bogusKey"]
('declares every config.email key the resolver reads' asserts [] -> RED, falsely)
reader stops reading `persist`, but a COMMENT still names it
-> persist still counted as read? true
('reads every key it declares' stays GREEN over a declared key nothing reads)

The second is the worse one and it is precisely the defect this file exists to catch: #5447 was a declared-but-unread key, and the file's own docblock explains at length why the DECLARED_BUT_UNREAD registry was deleted so that "a key declared and not read is red the day it lands". A comment mentioning the key restores the exemption silently, with no registry to argue about.

Subject 2 — packages/cli/src/commands/serve-multi-node-cap-advisory.pin.test.ts

Three assertions match regexes against raw SERVE_SOURCE. Reintroducing the exact regression the file pins, while describing the old call in a trailing comment:

not.toMatch(/checkMultiNodeAllowed\(\s*\)/) -> bad shape present? true (correctly red)
toMatch(/checkMultiNodeAllowed\(\s*[^)\s]/) -> good shape present? true (satisfied by the COMMENT alone)

So the negative assertion still holds, but the positive one is satisfiable by prose. A revert spelled without the bare-call shape — say the call deleted outright and quoted in a comment — passes both.

Its interfaceFields() helper does strip comments, with the naive two-regex form, but only over an already brace-matched export interface body. That is a much narrower blast radius than a whole-file strip and is not what this issue is about; it is noted so a future re-derivation does not read it as the same defect.

Not a duplicate

Suggested shape

Route both scans through maskComments from scripts/js-comment-mask.mjs, as #9445 did for the six gates and #10513 does for the parity scan. Notes for whoever takes it:

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions