Files
hyperframes/skills
ukimsanov 9abd03e39e fix(skill): assemble-index duration cross-check matches actual w2h root id
Real-AI-test log entry #9 from the heygen-showcase build:

  "assemble-index.mjs emitted 5 anomalies: could not read root
  data-duration from compositions/beat-N.html — skipped duration
  cross-check (one per beat). Non-fatal — the assembler reads
  id='root' but the beat skeleton uses id='beat-N-slug', so the
  cross-check was skipped for all 5 beats."

The duration cross-check exists to catch a real failure class — a
worker writing a `data-duration` on its root <div> that disagrees with
the orchestrator's `group_spec.estimatedDuration_s`. When they
disagree, downstream timing (voice / SFX / captions / shader seams)
silently misaligns. The check is supposed to hard-fail with a clear
mismatch message; what was actually happening was the check silently
skipping for every beat across every w2h project ever built.

Root cause: rootDataDuration() at line 135 matched the literal pattern
`id="root"`:

  const tagM = html.match(/<div\b[^>]*\bid=["']root["'][^>]*>/i);

But w2h beats DON'T use `id="root"`. The canonical pattern across the
starter template in beat-builder-guide.md, the file-copy
_beat-skeleton.html boilerplate, and every real project on disk
(heygen-com, huly, heygen-showcase — verified) is:

  <div id="beat-N-<slug>" data-composition-id="beat-N-<slug>" ...>

So the regex never matched, rootDataDuration() returned null
unconditionally, and the assembler dropped to the "could not read"
anomaly branch every time. The check has effectively never run since
the w2h skill was created.

Fix: take the scene id (sid) from the loop's playOrder iteration —
which the assembler already has at the call site — and match against
EITHER `id="<sid>"` OR `data-composition-id="<sid>"` (they're equal by
contract; matching by either identifies the root unambiguously).

  rootDataDuration(html, sid)  // ← new sid param
    pattern: /<div\b[^>]*\b(?:id|data-composition-id)=["']<sid>["'][^>]*>/is

The sid is regex-escaped first so beat slugs with regex-meta chars
don't break the pattern (defensive; current slug shape is just
[a-z0-9-] so no current beat hits it, but cheap insurance).

Anomaly message also updated to name the expected matchers so future
"could not read" hits explain what they were looking for:

  "could not read root data-duration from compositions/beat-N.html
   (no <div id="beat-N"...> or data-composition-id="beat-N" with
   data-duration) — skipped duration cross-check"

Smoke-tested against three real projects:
  heygen-showcase/beat-1-orb.html  → 3.3  (matches HTML)
  heygen-com/beat-1-hook.html      → 3.46 (matches HTML)
  huly/beat-1-beam.html            → 4.7  (matches HTML)

All three correctly return the worker's data-duration, so the cross-
check now actually fires on real beats and will catch any worker that
writes a data-duration disagreeing with group_spec.

No behavior change for projects where the worker's data-duration
already matches group_spec (which is every working project today). The
fix promotes the SILENT-skip case to ACTIVE-check case, surfacing
mismatches as hard fails the way the assembler originally intended.

Cost in the heygen-showcase run: 5 anomaly lines in the assembler
output (one per beat). Non-fatal but noise; user noted it in the
factual log. With this fix, those anomalies go away on next assemble.
2026-06-12 11:54:59 -07:00
..