Files
ukimsanov b2755057d5 fix(core/lint): findRootTag ignores <video>-like tokens inside CSS/HTML comments
Real-AI-test log entry #11 from the heygen-showcase build:

  "My own regression: 2 lint errors after I edited beat-3 —
  root_missing_composition_id + root_missing_dimensions. I'd written
  a literal <video> token inside a CSS comment, which trips the
  linter's root-tag regex."

Verified on a synthetic repro of the exact beat shape:

  <template>
    <style>
      /* The card uses <video> as the surface for the generated clip. */
      .b3-root { ... }
    </style>
    <div data-composition-id="beat-3" data-width="1920" data-height="1080" ...>
      ...
    </div>
  </template>

Before the fix, findRootTag scans the template's body for the first
non-style/script tag. extractOpenTags's TAG_PATTERN regex
(/<([a-z][\w:-]*)(\s[^<>]*?)?>/gi) matches `<video>` literally even
when it sits inside CSS comment text inside a <style> block — the
extractor never sees structure, only the byte stream. So it returns
`<video>` as the first non-meta tag, the linter treats that as the
composition root, and emits two cascading false errors:

  root_missing_composition_id  (a CSS-comment <video> has no attrs)
  root_missing_dimensions      (same)

The fix masks comment / <style> / <script> RANGES out of bodyContent
before tag extraction:

  - HTML comments: <!-- ... -->
  - <style> blocks: <style>...</style>  (their content carries CSS
                                         comments that may contain
                                         literal tag tokens)
  - <script> blocks: <script>...</script>  (same reasoning — template
                                            literals, string content,
                                            comments may carry tokens)

Mask uses same-length space substitution so the returned tag's `.index`
offset still points at the real position in the original source — no
downstream rule that reads the source by offset is disturbed.

Test coverage:
  - CSS-comment <video> inside <style>: root now correctly resolves
    to the real <div> (was: <video>).
  - HTML-comment <video> outside <style>: root resolves correctly.
  - Genuinely-broken root (no comments, missing attrs) still picks
    the broken <div> as root, so root_missing_* errors still fire
    correctly for real violations.
  - Well-formed beat (the user's heygen-showcase fix shape): root
    detected with all required attrs intact.

All 18 existing core lint rule tests pass with the fix
(`bun test src/lint/rules/core.test.ts` → 18 pass, 0 fail).

Eliminates one of the four "biggest time sinks" the agent's factual
log called out (the two self-inflicted beat-3 regressions caught only
at verification — the <video>-in-comment case is now structurally
prevented at the linter level instead of relying on the agent to
remember landmine #6 from beat-builder-guide).

The existing landmine #6 ("Don't include literal HTML opening tags
inside HTML comments — linter regex false-positives") stays in the
beat-builder doc as a backstop, but the structural fix here makes it
defensive-in-depth rather than load-bearing.
2026-06-12 12:09:19 -07:00
..
2026-06-11 02:40:36 +00:00
2026-06-11 02:40:36 +00:00
2026-06-11 02:40:36 +00:00
2026-06-11 02:40:36 +00:00
2026-06-11 02:40:36 +00:00
2026-06-11 02:40:36 +00:00