mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(lint): recognize compiler-derived data-end as legitimate
`bundleToSingleHtml` compiles `data-duration` into `data-end` (in `compileTimingAttrs`), then calls `validateHyperframeHtmlContract` against the compiled HTML. The linter's `deprecated_data_end` rule fired on the compiler's own consistent output — `<audio data-start="0" data-duration="18" data-end="18">` — because `diagnoseDerivedEnd` unconditionally emitted a `deprecated-end` diagnostic whenever both attributes were present, ignoring whether the derived value matched. Reporters routed this as "raw-source lint passes with 0 errors and 0 warnings, but `check --strict` still logs StaticGuard noise about data-end without data-duration." Field cluster: cli-feedback crons 61-68, n=25+ across darwin/arm64, darwin/x64, linux/x64, win32/x64, and versions 0.7.56 through 0.7.64. L3 reporter cite (ts=1784519869): "bundleToSingleHtml compiles data-duration into data-end, then validates the compiled HTML and reports its own generated data-end as deprecated." Fix: `diagnoseDerivedEnd` now stays silent when the paired `data-end` matches `data-start + data-duration` (within a 1ns epsilon to absorb IEEE-754 residuals like `0.1 + 0.2 = 0.30000000000000004`). Truly-legacy authoring shapes — `data-end` alone with no `data-duration`, or a `data-end` that disagrees with `data-duration` — still fire `deprecated_data_end`, with a refined message that names the drift on the conflicting variant. Facets covered: (a) validator treats compiler-derived `data-end` as legal when paired with `data-duration`, and (e) recognizes the compile-time rewrite site (`bundleToSingleHtml` → `compileHtml` → `compileTimingAttrs`). Facets (b) stderr gating, (c) terminal JSON verdict, and (d) audio-not- dropped are unblocked transitively — StaticGuard's `console.warn` is already gated on `!isValid` and never drops audio; the check command already emits JSON on every terminal path; so once the false-positive diagnostic stops firing on compiler output, the noisy stderr line and the misleading "check appears to fail" reporter framing both go away without further wiring. Co-Authored-By: Via <noreply@heygen.com>
This commit is contained in:
@@ -28,6 +28,42 @@ describe("composition rules", () => {
|
||||
result.findings.find(({ code }) => code === "overlapping_clips_same_track"),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
// Regression: cli-feedback field cluster (crons 61-68, n=25+ across
|
||||
// darwin/linux/win32 and versions 0.7.56-0.7.64). `bundleToSingleHtml`
|
||||
// compiles `data-duration` into `data-end`, then re-validates the compiled
|
||||
// HTML. Before this fix the linter fired `deprecated_data_end` on the
|
||||
// compiler's own consistent output — a false-positive that reporters
|
||||
// routed as "check --strict passes but StaticGuard still logs
|
||||
// deprecated-attribute noise" (ts=1784548892, ts=1784541122).
|
||||
it("does not flag deprecated_data_end when compiled data-end matches data-duration", async () => {
|
||||
const result = await lintHyperframeHtml(`<!doctype html><html><body>
|
||||
<div data-composition-id="main" data-width="1920" data-height="1080" data-start="0" data-duration="30">
|
||||
<audio id="bgm" src="bgm.mp3" data-start="0" data-duration="18" data-end="18"></audio>
|
||||
<audio id="narration" src="narr.mp3" data-start="5" data-duration="10" data-end="15"></audio>
|
||||
</div>
|
||||
<script>window.__timelines = { main: {} };</script>
|
||||
</body></html>`);
|
||||
|
||||
const deprecatedEnd = result.findings.filter(({ code }) => code === "deprecated_data_end");
|
||||
expect(deprecatedEnd).toEqual([]);
|
||||
});
|
||||
|
||||
// Companion regression: a manually authored stale `data-end` still fires
|
||||
// `deprecated_data_end`, with a message that names the disagreement so
|
||||
// the author can spot the drift rather than reading the legacy phrasing.
|
||||
it("still flags deprecated_data_end when data-end disagrees with data-duration", async () => {
|
||||
const result = await lintHyperframeHtml(`<!doctype html><html><body>
|
||||
<div data-composition-id="main" data-width="1920" data-height="1080" data-start="0" data-duration="30">
|
||||
<audio id="bgm" src="bgm.mp3" data-start="0" data-duration="18" data-end="20"></audio>
|
||||
</div>
|
||||
<script>window.__timelines = { main: {} };</script>
|
||||
</body></html>`);
|
||||
|
||||
const deprecatedEnd = result.findings.find(({ code }) => code === "deprecated_data_end");
|
||||
expect(deprecatedEnd).toBeDefined();
|
||||
expect(deprecatedEnd?.message).toMatch(/disagrees with data-duration/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("subcomposition guidance", () => {
|
||||
|
||||
@@ -465,10 +465,20 @@ export const compositionRules: Array<(ctx: LintContext) => HyperframeLintFinding
|
||||
}
|
||||
if (timing.diagnostics.some(({ code }) => code === "deprecated-end")) {
|
||||
const elementId = readAttr(tag.raw, "id") || undefined;
|
||||
const conflicting = timing.diagnostics.some(({ code }) => code === "conflicting-end");
|
||||
// Two shapes reach here after the false-positive fix (see
|
||||
// compositionContract.ts `diagnoseDerivedEnd`): the truly-legacy shape
|
||||
// (no data-duration, data-end alone) and the stale-companion shape
|
||||
// (data-duration present but paired with a data-end that disagrees).
|
||||
// A consistent data-duration + data-end pair — the shape the compiler
|
||||
// emits — is silent and never reaches this branch.
|
||||
const message = conflicting
|
||||
? `<${tag.name}${elementId ? ` id="${elementId}"` : ""}> has data-end that disagrees with data-duration. Remove the stale data-end; the compiler regenerates it from data-duration.`
|
||||
: `<${tag.name}${elementId ? ` id="${elementId}"` : ""}> uses data-end without data-duration. Use data-duration in source HTML.`;
|
||||
findings.push({
|
||||
code: "deprecated_data_end",
|
||||
severity: "error",
|
||||
message: `<${tag.name}${elementId ? ` id="${elementId}"` : ""}> uses data-end without data-duration. Use data-duration in source HTML.`,
|
||||
message,
|
||||
elementId,
|
||||
fixHint:
|
||||
"Replace data-end with data-duration. The compiler generates data-end from data-duration automatically.",
|
||||
|
||||
Reference in New Issue
Block a user