Skip to content

Stabilize: elision analyzer masks comments/strings (no false signals from prose) #179

@vivek7405

Description

@vivek7405

Problem

The elision analyser scans RAW source, comments and strings included, when it looks for rendered tags (extractRenderedTags) and cross-module observation signals (WHEN_DEFINED_RE / TAG_DEFINED_RE / INSTANCEOF_RE, from #169). So prose that happens to contain tag-in-angle-brackets or a whenDefined('tag') / instanceof Class call is read as a real signal and skews the verdict.

Found while adding the #169 e2e probe (#175): a doc comment in a fixture component that mentioned <build-stamp> and whenDefined('observed-badge') caused extractRenderedTags to treat build-stamp as a rendered tag (forcing build-stamp to ship via the render rule) and the observation regex to match the commented whenDefined. A real test (build-stamp module is never downloaded) failed as a result. The workaround was to reword the comments, but the analyser should not be fooled by comments at all.

This is the same class of issue as #159 (the import scanner counting imports shown as code), which was fixed by masking string/template/comment content via redactStringsAndTemplates before matching.

Design / approach

Apply the same position-preserving redaction mask to the elision scanners before matching: run redactStringsAndTemplates (or an equivalent) over the source, and only count a rendered-tag / whenDefined / :defined / instanceof match whose position survives redaction (i.e. is real code, not inside a comment or string). Keep it verdict-safe; today the miss only ever OVER-ships (safe direction), but it also caused a genuine false-positive that broke a test, so it is worth fixing.

Acceptance criteria

  • extractRenderedTags ignores tags written inside comments/strings
  • The Close the cross-module-registration blind spot in display-only elision #169 observation regexes ignore whenDefined/:defined/instanceof written inside comments/strings
  • A unit test: a component whose comment mentions another tag or a whenDefined call does NOT force that tag to ship (counterfactual: fails without the mask)

Labels: bug

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions