Skip to content

Write HTML. Render video. Built for agents.

feat(telemetry): render output-shape, adapter, count, and environment properties (#4017)

miga-heygen71bb88719e10
diff --git a/packages/cli/src/browser/preflight.test.ts b/packages/cli/src/browser/preflight.test.ts
index 02cc2178a4..43abba6454 100644
--- a/packages/cli/src/browser/preflight.test.ts
+++ b/packages/cli/src/browser/preflight.test.ts
@@ -3,7 +3,12 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
-import { checkDisk, parseToolVersion, runEnvironmentChecks } from "./preflight.js";
+import {
+ checkDisk,
+ extractMajorVersion,
+ parseToolVersion,
+ runEnvironmentChecks,
+} from "./preflight.js";
import * as manager from "./manager.js";
import * as linuxDeps from "./linuxDeps.js";
@@ -49,6 +54,7 @@ describe("runEnvironmentChecks", () => {
expect(result.outcomes.find((outcome) => outcome.name === "FFprobe")?.ok).toBe(true);
expect(result.ffmpegPath).toBe(process.execPath);
expect(result.ffprobePath).toBe(process.execPath);
+ expect(result.ffmpegVersionMajor).toBe(7);
expect(runProcess).toHaveBeenCalledTimes(2);
expect(runProcess).toHaveBeenCalledWith(
process.execPath,
@@ -57,6 +63,14 @@ describe("runEnvironmentChecks", () => {
);
});
+ it("omits ffmpegVersionMajor when the version banner has no parseable number", async () => {
+ runProcess.mockResolvedValue({ stdout: "ffmpeg version unknown\n", stderr: "" });
+
+ const result = await runEnvironmentChecks();
+
+ expect(result.ffmpegVersionMajor).toBeUndefined();
+ });
+
it.skipIf(process.platform === "win32")(
"aborts a blocked render probe and waits for its process tree to exit",
async () => {
@@ -156,7 +170,9 @@ describe("runEnvironmentChecks", () => {
expect(result.outcomes.find((outcome) => outcome.name === "Chrome")).toMatchObject({
ok: true,
path: process.execPath,
+ versionMajor: 7,
});
+ expect(result.browserVersionMajor).toBe(7);
});
it("reports Chrome as not found (no throw) when browser discovery throws on a corrupt cache", async () => {
@@ -310,6 +326,22 @@ describe("parseToolVersion", () => {
});
});
+describe("extractMajorVersion", () => {
+ it("reads the major from an ffmpeg banner", () => {
+ expect(extractMajorVersion("ffmpeg version 7.1.1-essentials_build")).toBe(7);
+ });
+
+ it("reads the major from a Chrome/HeadlessShell banner", () => {
+ expect(extractMajorVersion("Google Chrome 119.0.6045.105")).toBe(119);
+ expect(extractMajorVersion("HeadlessShell 119.0.6045.199")).toBe(119);
+ });
+
+ it("returns undefined when no X.Y-shaped number is present", () => {
+ expect(extractMajorVersion("ffmpeg version unknown")).toBeUndefined();
+ expect(extractMajorVersion("")).toBeUndefined();
+ });
+});
+
describe("checkDisk", () => {
it("checks the requested render volume", () => {
const freeDiskMb = vi.fn(() => 512);
diff --git a/packages/cli/src/browser/preflight.ts b/packages/cli/src/browser/preflight.ts
index ac67bf14ab..3f42e15a3b 100644
--- a/packages/cli/src/browser/preflight.ts
+++ b/packages/cli/src/browser/preflight.ts
@@ -22,6 +22,8 @@ export interface EnvironmentCheckOutcome {
title?: string;
hint?: string;
path?: string;
+ /** Major version parsed from the tool's own `-version`/`--version` output, when available. */
+ versionMajor?: number;
}
export interface EnvironmentCheckResult {
@@ -29,6 +31,8 @@ export interface EnvironmentCheckResult {
ffmpegPath?: string;
ffprobePath?: string;
browser?: BrowserResult;
+ ffmpegVersionMajor?: number;
+ browserVersionMajor?: number;
}
export interface EnvironmentCheckOptions {
@@ -46,13 +50,21 @@ export function parseToolVersion(raw: string): string {
return m ? `${m[1]} ${m[2]}` : raw.trim();
}
+/** First `X.Y`-shaped number in a version banner (ffmpeg/ffprobe/Chrome all share this shape). */
+export function extractMajorVersion(raw: string): number | undefined {
+ const m = raw.match(/\b(\d+)\.\d+/);
+ return m?.[1] ? Number(m[1]) : undefined;
+}
+
function configuredMissingDetail(envName: string): string | undefined {
const configured = process.env[envName]?.trim();
if (!configured || existsSync(configured)) return undefined;
return `Configured path does not exist: ${envName}="${configured}"`;
}
-type ToolVersionResult = { ok: true; detail: string } | { ok: false; detail: string };
+type ToolVersionResult =
+ | { ok: true; detail: string; majorVersion?: number }
+ | { ok: false; detail: string };
// fallow-ignore-next-line complexity
async function readToolVersion(
@@ -68,7 +80,11 @@ async function readToolVersion(
).stdout;
const raw = output.split("\n")[0] ?? "";
const version = parseToolVersion(raw);
- return { ok: true, detail: version ? `${version} at ${binaryPath}` : binaryPath };
+ return {
+ ok: true,
+ detail: version ? `${version} at ${binaryPath}` : binaryPath,
+ majorVersion: extractMajorVersion(raw),
+ };
} catch (error) {
if (signal?.aborted) signal.throwIfAborted();
const status =
@@ -108,7 +124,14 @@ async function checkFFmpeg(signal?: AbortSignal): Promise<EnvironmentCheckOutcom
path,
};
}
- return { name: "FFmpeg", ok: true, level: "ok", detail: version.detail, path };
+ return {
+ name: "FFmpeg",
+ ok: true,
+ level: "ok",
+ detail: version.detail,
+ path,
+ versionMajor: version.majorVersion,
+ };
}
return {
@@ -229,12 +252,12 @@ async function chromeLaunchOutcome(
const libraries = await chromeSharedLibOutcome(executablePath, found, signal);
if (!libraries.ok) return libraries;
try {
- await runCancellableProcess(executablePath, ["--version"], {
+ const { stdout } = await runCancellableProcess(executablePath, ["--version"], {
signal,
timeoutMs: 5000,
maxBufferBytes: 64 * 1024,
});
- return found;
+ return { ...found, versionMajor: extractMajorVersion(stdout) };
} catch (error) {
if (signal?.aborted) signal.throwIfAborted();
const details = chromeLaunchFailureDetails(error);
@@ -365,6 +388,7 @@ export async function runEnvironmentChecks(
outcomes.push(ffprobe);
let browser: BrowserResult | undefined;
+ let browserVersionMajor: number | undefined;
if (options.includeBrowser) {
const chrome = await checkChrome(options.browserPath, options.signal);
outcomes.push(chrome);
@@ -374,6 +398,7 @@ export async function runEnvironmentChecks(
source: options.browserPath ? "env" : "cache",
};
}
+ browserVersionMajor = chrome.versionMajor;
}
if (options.includeDisk) {
@@ -391,5 +416,7 @@ export async function runEnvironmentChecks(
...(ffmpeg.ok && ffmpeg.path ? { ffmpegPath: ffmpeg.path } : {}),
...(ffprobe.path ? { ffprobePath: ffprobe.path } : {}),
...(browser ? { browser } : {}),
+ ...(ffmpeg.versionMajor != null ? { ffmpegVersionMajor: ffmpeg.versionMajor } : {}),
+ ...(browserVersionMajor != null ? { browserVersionMajor } : {}),
};
}
diff --git a/packages/cli/src/commands/render.ts b/packages/cli/src/commands/render.ts
index c710fde8ee..a4e32f5fc3 100644
--- a/packages/cli/src/commands/render.ts
+++ b/packages/cli/src/commands/render.ts
@@ -72,6 +72,8 @@ import {
trackRenderComplete,
trackRenderError,
trackRenderObservation,
+ type RenderOutputShapeTelemetryPayload,
+ type RenderEnvironmentTelemetryPayload,
} from "../telemetry/events.js";
import { maybePromptRenderFeedback } from "../telemetry/feedback.js";
import {
@@ -423,6 +425,12 @@ export interface RenderOptions {
quality: "draft" | "standard" | "high";
/** Authoring workflow skill that drove this render (telemetry attribution). */
authoringSkill?: string;
+ /** Which step resolved authoringSkill: an explicit --skill flag, or the project's own config. */
+ authoringSkillSource?: "flag" | "project-config";
+ /** Raw --skill value when it failed normalizeSkillSlug (an unrecognized skill name was passed). */
+ authoringSkillInvalid?: string;
+ /** Names of HF_-/HYPERFRAMES_-prefixed env vars present at plan time (never values), capped at 20. */
+ hfEnvOverrides?: readonly string[];
/**
* Catalog items installed in this project and those the rendered composition
* reaches. Resolved once in the render plan; absent on programmatic callers
@@ -431,6 +439,11 @@ export interface RenderOptions {
catalogUsage?: CatalogUsage;
format: RenderFormat;
gifLoop?: number;
+ /** True when `createRenderPlan` clamped a requested `--fps` above 30 to 30 for `--format gif`. */
+ gifFpsCapped?: boolean;
+ /** Major FFmpeg/Chrome version from local preflight (telemetry only); absent on Docker renders. */
+ ffmpegVersionMajor?: number;
+ browserVersionMajor?: number;
/** HLS target segment length in seconds; ignored unless `format` is `"hls"`. */
hlsSegmentSeconds?: number;
workers?: number;
@@ -818,7 +831,12 @@ async function renderDocker(
docker: true,
gpu: options.gpu,
authoringSkill: options.authoringSkill,
+ authoringSkillSource: options.authoringSkillSource,
+ authoringSkillInvalid: options.authoringSkillInvalid,
+ hfEnvOverrides: options.hfEnvOverrides,
catalogUsage: options.catalogUsage,
+ ...renderOutputShapeTelemetryPayload(options),
+ ...renderEnvironmentTelemetryPayload(options),
...getMemorySnapshot(),
}),
);
@@ -889,6 +907,11 @@ async function executeLocalRender(
includeWindowsUnc: true,
signal: cancellation.signal,
});
+ options = {
+ ...options,
+ ffmpegVersionMajor: preflight.ffmpegVersionMajor,
+ browserVersionMajor: preflight.browserVersionMajor,
+ };
cancellation.checkAncestors();
cancellation.signal.throwIfAborted();
const failedChecks = preflight.outcomes.filter((outcome) => !outcome.ok);
@@ -1131,6 +1154,29 @@ function getMemorySnapshot() {
};
}
+/** Output-shape request facts, resolved before the pipeline starts (survives a pre-perfSummary render_error). */
+function renderOutputShapeTelemetryPayload(
+ options: RenderOptions,
+): RenderOutputShapeTelemetryPayload {
+ return {
+ outputResolutionPreset: options.outputResolution,
+ outputFormat: options.format,
+ hdrMode: options.hdrMode,
+ videoFrameFormat: options.videoFrameFormat,
+ gifFpsCapped: options.gifFpsCapped,
+ };
+}
+
+/** Toolchain facts from local preflight; undefined on Docker renders (the container runs its own). */
+function renderEnvironmentTelemetryPayload(
+ options: RenderOptions,
+): RenderEnvironmentTelemetryPayload {
+ return {
+ ffmpegVersionMajor: options.ffmpegVersionMajor,
+ browserVersionMajor: options.browserVersionMajor,
+ };
+}
+
function metaString(meta: Record<string, unknown> | undefined, key: string): string | undefined {
const value = meta?.[key];
return typeof value === "string" ? value : undefined;
@@ -1587,9 +1633,14 @@ function handleRenderError(
workers: options.workers,
gpu: options.gpu,
authoringSkill: options.authoringSkill,
+ authoringSkillSource: options.authoringSkillSource,
+ authoringSkillInvalid: options.authoringSkillInvalid,
+ hfEnvOverrides: options.hfEnvOverrides,
elapsedMs: Date.now() - startTime,
errorMessage: message,
failedStage,
+ ...renderOutputShapeTelemetryPayload(options),
+ ...renderEnvironmentTelemetryPayload(options),
// A bucketable failure taxonomy alongside the free-text error_message
// above: error.name is one of ~20 typed producer error classes
// (CaptureFailure, DrawElementCaptureError, SwiftShaderAssertionError, …);
@@ -1685,7 +1736,12 @@ function trackRenderMetrics(
docker,
gpu: options.gpu,
authoringSkill: options.authoringSkill,
+ authoringSkillSource: options.authoringSkillSource,
+ authoringSkillInvalid: options.authoringSkillInvalid,
+ hfEnvOverrides: options.hfEnvOverrides,
catalogUsage: options.catalogUsage,
+ ...renderOutputShapeTelemetryPayload(options),
+ ...renderEnvironmentTelemetryPayload(options),
staticDedupEnabled: perf?.staticDedup?.enabled,
staticDedupArmed: perf?.staticDedup?.armed,
staticDedupSkipReason: perf?.staticDedup?.skipReason,
@@ -1703,6 +1759,15 @@ function trackRenderMetrics(
compositionElementTags: perf?.drawElement?.compositionElementTags,
arollVideoCount: perf?.drawElement?.arollVideoCount,
heygenVideoCount: perf?.drawElement?.heygenVideoCount,
+ adaptersUsed: perf?.drawElement?.adaptersUsed,
+ audioCount: perf?.drawElement?.audioCount,
+ imageCount: perf?.drawElement?.imageCount,
+ subCompositionCount: perf?.drawElement?.subCompositionCount,
+ audioGroupCount: perf?.drawElement?.audioGroupCount,
+ colorGradingCount: perf?.drawElement?.colorGradingCount,
+ hasLut: perf?.drawElement?.hasLut,
+ rootBodyMismatch: perf?.drawElement?.rootBodyMismatch,
+ rootBodyDeltaPxBucket: perf?.drawElement?.rootBodyDeltaPxBucket,
deShortBand: perf?.drawElement?.shortBand,
deParallelRouter: perf?.drawElement?.parallelRouter,
dePreRouterWorkers: perf?.drawElement?.preRouterWorkers,
diff --git a/packages/cli/src/commands/render/execute.ts b/packages/cli/src/commands/render/execute.ts
index 1ecd86cd2a..eb4ac70e9c 100644
--- a/packages/cli/src/commands/render/execute.ts
+++ b/packages/cli/src/commands/render/execute.ts
@@ -119,9 +119,13 @@ export async function executeRenderPlan(
fps: plan.fps,
quality: plan.quality,
authoringSkill: plan.authoringSkill,
+ authoringSkillSource: plan.authoringSkillSource,
+ authoringSkillInvalid: plan.invalidAuthoringSkill,
+ hfEnvOverrides: plan.hfEnvOverrides,
catalogUsage: plan.catalogUsage,
format: plan.format,
gifLoop: plan.gifLoop,
+ gifFpsCapped: plan.gifFpsCapped,
hlsSegmentSeconds: plan.hlsSegmentSeconds,
workers: plan.workers,
gpu: plan.useGpu,
@@ -301,9 +305,13 @@ async function executeBatchRender(
fps: plan.fps,
quality: plan.quality,
authoringSkill: plan.authoringSkill,
+ authoringSkillSource: plan.authoringSkillSource,
+ authoringSkillInvalid: plan.invalidAuthoringSkill,
+ hfEnvOverrides: plan.hfEnvOverrides,
catalogUsage: plan.catalogUsage,
format: plan.format,
gifLoop: plan.gifLoop,
+ gifFpsCapped: plan.gifFpsCapped,
hlsSegmentSeconds: plan.hlsSegmentSeconds,
workers: plan.workers,
gpu: plan.useGpu,
diff --git a/packages/cli/src/commands/render/plan.test.ts b/packages/cli/src/commands/render/plan.test.ts
index 8be2e437b9..ea7d620efa 100644
--- a/packages/cli/src/commands/render/plan.test.ts
+++ b/packages/cli/src/commands/render/plan.test.ts
@@ -37,6 +37,43 @@ describe("createRenderPlan", () => {
expect(Object.isFrozen(plan.environment)).toBe(true);
});
+ // GIF's Netscape frame-delay field is stored in centiseconds, so fps above
+ // 30 rounds to visually-indistinguishable delay values. createRenderPlan
+ // clamps and flags it so both the CLI console warning (present.ts) and
+ // render telemetry (gif_fps_capped) can report the same decision.
+ it("caps fps to 30 and flags it for --format gif above the ceiling", () => {
+ const plan = createRenderPlan({
+ dir: projectDir,
+ output: "result.gif",
+ format: "gif",
+ fps: "60",
+ });
+ expect(plan.fps).toEqual({ num: 30, den: 1 });
+ expect(plan.gifFpsCapped).toBe(true);
+ });
+
+ it("does not flag gifFpsCapped for gif fps at or below the ceiling", () => {
+ const plan = createRenderPlan({
+ dir: projectDir,
+ output: "result.gif",
+ format: "gif",
+ fps: "24",
+ });
+ expect(plan.fps).toEqual({ num: 24, den: 1 });
+ expect(plan.gifFpsCapped).toBe(false);
+ });
+
+ it("does not flag gifFpsCapped for non-gif formats regardless of fps", () => {
+ const plan = createRenderPlan({
+ dir: projectDir,
+ output: "result.mp4",
+ format: "mp4",
+ fps: "60",
+ });
+ expect(plan.fps).toEqual({ num: 60, den: 1 });
+ expect(plan.gifFpsCapped).toBe(false);
+ });
+
// The catalog join reaches the render event through the plan, so a plan that
// silently drops it would leave every render reporting no catalog items.
it("resolves catalog usage from the project manifest and the render entry", () => {
@@ -209,6 +246,8 @@ describe("createRenderPlan", () => {
);
const plan = createRenderPlan({ dir: projectDir });
expect(plan.authoringSkill).toBe("product-launch-video");
+ expect(plan.authoringSkillSource).toBe("project-config");
+ expect(plan.invalidAuthoringSkill).toBeUndefined();
});
it("lets an explicit --skill flag override the persisted project owner", () => {
@@ -218,5 +257,83 @@ describe("createRenderPlan", () => {
);
const plan = createRenderPlan({ dir: projectDir, skill: "motion-graphics" });
expect(plan.authoringSkill).toBe("motion-graphics");
+ expect(plan.authoringSkillSource).toBe("flag");
+ });
+
+ it("reports no authoring skill source when neither a flag nor a project config resolved one", () => {
+ const plan = createRenderPlan({ dir: projectDir });
+ expect(plan.authoringSkill).toBeUndefined();
+ expect(plan.authoringSkillSource).toBeUndefined();
+ });
+
+ it("preserves a malformed --skill value for telemetry without adopting it as authoringSkill", () => {
+ writeFileSync(
+ join(projectDir, "hyperframes.json"),
+ JSON.stringify({ authoringSkill: "product-launch-video" }),
+ );
+ // Fails SKILL_SLUG (spaces, uppercase): normalizeSkillSlug rejects the shape,
+ // not a registry of known skill names.
+ const plan = createRenderPlan({ dir: projectDir, skill: "Not A Skill!" });
+ expect(plan.invalidAuthoringSkill).toBe("Not A Skill!");
+ // The invalid flag never wins attribution: the project's own config still does.
+ expect(plan.authoringSkill).toBe("product-launch-video");
+ expect(plan.authoringSkillSource).toBe("project-config");
+ });
+
+ describe("hfEnvOverrides", () => {
+ const savedEnv: Record<string, string | undefined> = {};
+ const OVERRIDE_KEYS = [
+ "HF_DE_VERIFY",
+ "HF_TEST_ENV_INT",
+ "HYPERFRAMES_ZZZ_TEST_OVERRIDE",
+ "HYPERFRAMES_AAA_TEST_OVERRIDE",
+ "HF_SHADER_WORKER_ENTRY",
+ ];
+
+ beforeEach(() => {
+ for (const key of OVERRIDE_KEYS) savedEnv[key] = process.env[key];
+ });
+
+ afterEach(() => {
+ for (const key of OVERRIDE_KEYS) {
+ if (savedEnv[key] === undefined) delete process.env[key];
+ else process.env[key] = savedEnv[key];
+ }
+ });
+
+ it("reports an array (never absent) and never includes a key this test didn't set", () => {
+ for (const key of OVERRIDE_KEYS) delete process.env[key];
+ const plan = createRenderPlan({ dir: projectDir });
+ expect(Array.isArray(plan.hfEnvOverrides)).toBe(true);
+ for (const key of OVERRIDE_KEYS) expect(plan.hfEnvOverrides).not.toContain(key);
+ });
+
+ it("reports the sorted names (never values) of set HF_/HYPERFRAMES_ env vars", () => {
+ process.env.HF_TEST_ENV_INT = "some-path-that-must-not-leak";
+ process.env.HYPERFRAMES_ZZZ_TEST_OVERRIDE = "another-secret-looking-value";
+ const plan = createRenderPlan({ dir: projectDir });
+ expect(plan.hfEnvOverrides).toContain("HF_TEST_ENV_INT");
+ expect(plan.hfEnvOverrides).toContain("HYPERFRAMES_ZZZ_TEST_OVERRIDE");
+ expect(plan.hfEnvOverrides.join(" ")).not.toContain("some-path-that-must-not-leak");
+ expect(plan.hfEnvOverrides.join(" ")).not.toContain("another-secret-looking-value");
+ });
+
+ it("sorts names rather than reporting them in process.env's insertion order", () => {
+ process.env.HYPERFRAMES_ZZZ_TEST_OVERRIDE = "1";
+ process.env.HYPERFRAMES_AAA_TEST_OVERRIDE = "1";
+ const plan = createRenderPlan({ dir: projectDir });
+ const indexOfAaa = plan.hfEnvOverrides.indexOf("HYPERFRAMES_AAA_TEST_OVERRIDE");
+ const indexOfZzz = plan.hfEnvOverrides.indexOf("HYPERFRAMES_ZZZ_TEST_OVERRIDE");
+ expect(indexOfAaa).toBeGreaterThanOrEqual(0);
+ expect(indexOfAaa).toBeLessThan(indexOfZzz);
+ });
+
+ it("never reports the CLI's own shader-worker bootstrap key as an operator override", () => {
+ // A real CLI run reaches this point with the key already set by cli.ts's bootstrap;
+ // no test in this file goes through that bootstrap, so set it here.
+ process.env.HF_SHADER_WORKER_ENTRY = "/some/dist/shaderTransitionWorker.js";
+ const plan = createRenderPlan({ dir: projectDir });
+ expect(plan.hfEnvOverrides).not.toContain("HF_SHADER_WORKER_ENTRY");
+ });
});
});
diff --git a/packages/cli/src/commands/render/plan.ts b/packages/cli/src/commands/render/plan.ts
index 82ba62dce2..509f62574d 100644
--- a/packages/cli/src/commands/render/plan.ts
+++ b/packages/cli/src/commands/render/plan.ts
@@ -113,6 +113,8 @@ export interface RenderPlan {
quality: RenderQuality;
authoringSkill?: string;
invalidAuthoringSkill?: string;
+ /** Which resolution step provided authoringSkill: an explicit --skill flag, or the project's own config. */
+ authoringSkillSource?: "flag" | "project-config";
/** Catalog items installed in this project, and those the entry reaches. */
catalogUsage: CatalogUsage;
format: RenderFormat;
@@ -153,6 +155,8 @@ export interface RenderPlan {
variablesFileArg?: string;
strictVariables: boolean;
environment: Readonly<Record<string, string>>;
+ /** Names of HF_-/HYPERFRAMES_-prefixed env vars present at plan time (never values), capped at 20. */
+ hfEnvOverrides: readonly string[];
}
function formatFpsParseError(
@@ -189,9 +193,30 @@ function positiveInteger(raw: string, title: string, message: string, min = 1):
return parsed;
}
+const HF_ENV_OVERRIDE_RE = /^(HF|HYPERFRAMES)_/;
+const MAX_REPORTED_ENV_OVERRIDES = 20;
+
+/** HF_-prefixed keys the CLI sets for itself during bootstrap rather than keys an operator
+ * set to steer a render: cli.ts points shaderTransitionWorkerPool at the worker bundled
+ * next to cli.js, so that key is present on essentially every built-CLI run and says
+ * nothing about how this render was configured. */
+const CLI_INTERNAL_HF_ENV_KEYS = new Set(["HF_SHADER_WORKER_ENTRY"]);
+
+/** Names (never values, since some could hold paths or secrets) of HF_-/HYPERFRAMES_-prefixed
+ * env vars present when this plan resolves, snapshotted before this render's own preflight
+ * injects its ffmpeg/ffprobe path overrides, which would otherwise always read back as
+ * operator-set. */
+function resolveHfEnvOverrides(): readonly string[] {
+ return Object.keys(process.env)
+ .filter((name) => HF_ENV_OVERRIDE_RE.test(name) && !CLI_INTERNAL_HF_ENV_KEYS.has(name))
+ .sort()
+ .slice(0, MAX_REPORTED_ENV_OVERRIDES);
+}
+
/** Parse and validate command input into an immutable execution plan. */
// fallow-ignore-next-line complexity
export function createRenderPlan(args: RenderCommandArgs, now = new Date()): RenderPlan {
+ const hfEnvOverrides = resolveHfEnvOverrides();
const hasExplicitComposition = hasExplicitCompositionArg(args.composition);
const project = resolveProject(args.dir, { requireIndex: !hasExplicitComposition });
const entryFile = resolveCompositionEntryArg(args.composition, project.dir, statSync);
@@ -220,11 +245,19 @@ export function createRenderPlan(args: RenderCommandArgs, now = new Date()): Ren
// renders, and `npm run render` (which never re-pass the flag) stay
// attributed to the workflow that created the project.
const flagSkill = normalizeSkillSlug(args.skill);
- const authoringSkill = flagSkill ?? loadProjectConfig(project.dir).authoringSkill;
+ const projectConfigSkill = loadProjectConfig(project.dir).authoringSkill;
+ const authoringSkill = flagSkill ?? projectConfigSkill;
const invalidAuthoringSkill =
typeof args.skill === "string" && args.skill.trim() !== "" && !flagSkill
? args.skill
: undefined;
+ // Same flag-then-project-config resolution as authoringSkill above, named
+ // for telemetry (which attribution actually won, not just its value).
+ const authoringSkillSource = flagSkill
+ ? "flag"
+ : projectConfigSkill
+ ? "project-config"
+ : undefined;
// Resolved here, once, from the same entry the render will use: batch rows
// vary only their variables, so every row shares this composition tree.
@@ -477,6 +510,7 @@ export function createRenderPlan(args: RenderCommandArgs, now = new Date()): Ren
quality,
authoringSkill,
invalidAuthoringSkill,
+ authoringSkillSource,
catalogUsage,
format,
gifLoop,
@@ -515,6 +549,7 @@ export function createRenderPlan(args: RenderCommandArgs, now = new Date()): Ren
variablesFileArg: args["variables-file"],
strictVariables: args["strict-variables"] ?? false,
environment: Object.freeze(environment),
+ hfEnvOverrides,
});
}
diff --git a/packages/cli/src/server/studioRenderTelemetry.test.ts b/packages/cli/src/server/studioRenderTelemetry.test.ts
index db89492f70..f5845015ae 100644
--- a/packages/cli/src/server/studioRenderTelemetry.test.ts
+++ b/packages/cli/src/server/studioRenderTelemetry.test.ts
@@ -55,6 +55,11 @@ const fullObservability: NonNullable<RenderPerfSummary["observability"]> = {
protocolTimeoutMs: 300_000,
pageNavigationTimeoutMs: 60_000,
playerReadyTimeoutMs: 45_000,
+ adaptersUsed: ["gsap"],
+ audioCount: 2,
+ imageCount: 3,
+ rootBodyMismatch: true,
+ rootBodyDeltaPxBucket: "11-50",
},
extraction: {
videoCount: 6,
@@ -211,6 +216,15 @@ describe("studioRenderTelemetry", () => {
expect(p.observabilityExtractCacheMisses).toBe(6);
expect(p.observabilityInitDurationMs).toBe(1234);
expect(p.observabilityInitTweenCount).toBe(42);
+ // capture.audioCount / imageCount / rootBodyMismatch / adaptersUsed are the
+ // only source for these on a studio render, since no drawElement resolves here.
+ // events.ts's trackRenderComplete falls back to captureXxx precisely because
+ // this path only ever supplies these, never the direct field.
+ expect(p.captureAdaptersUsed).toEqual(["gsap"]);
+ expect(p.captureAudioCount).toBe(2);
+ expect(p.captureImageCount).toBe(3);
+ expect(p.captureRootBodyMismatch).toBe(true);
+ expect(p.captureRootBodyDeltaPxBucket).toBe("11-50");
});
it("omits all perf-derived fields when perfSummary is undefined", () => {
diff --git a/packages/cli/src/server/studioRenderTelemetry.ts b/packages/cli/src/server/studioRenderTelemetry.ts
index 1feb70e6f4..be4121b3c4 100644
--- a/packages/cli/src/server/studioRenderTelemetry.ts
+++ b/packages/cli/src/server/studioRenderTelemetry.ts
@@ -7,7 +7,7 @@
// ---------------------------------------------------------------------------
import { freemem } from "node:os";
-import type { Fps } from "@hyperframes/core";
+import type { CanvasResolution, Fps } from "@hyperframes/core";
import { fpsToNumber } from "@hyperframes/core";
import type { RenderJob, RenderPerfSummary } from "@hyperframes/producer";
import { trackRenderComplete, trackRenderError } from "../telemetry/events.js";
@@ -20,6 +20,14 @@ import { bytesToMb } from "../telemetry/system.js";
export interface StudioRenderOpts {
fps: Fps;
quality: string;
+ /** Output container format; Studio requests are constrained to these three. */
+ format?: "mp4" | "webm" | "mov";
+ /** Named canvas preset the Studio request asked for; undefined renders at the composition's native dimensions. */
+ outputResolution?: CanvasResolution;
+ // gif_fps_capped/hdr_mode/video_frame_format are deliberately absent: Studio
+ // has no gif/png-sequence option and createRenderJob never receives an
+ // hdrMode or videoFrameFormat from the Studio request type, so there is no
+ // per-request value: see the PR description for the full reasoning.
// Telemetry id of the browser user who triggered the render, so the render
// outcome joins their studio_session_start / studio_render_start events.
// Undefined for older studio clients → falls back to the install anonymousId.
@@ -123,6 +131,8 @@ export function emitStudioRenderError(
failedStage,
errorMessage: err instanceof Error ? err.message : String(err),
elapsedMs,
+ outputFormat: opts.format,
+ outputResolutionPreset: opts.outputResolution,
distinctId: opts.distinctId,
...renderJobObservabilityTelemetryPayload(job),
...memSnapshot(),
@@ -142,6 +152,8 @@ export function emitStudioRenderComplete(
docker: false,
gpu: false,
source: "studio",
+ outputFormat: opts.format,
+ outputResolutionPreset: opts.outputResolution,
distinctId: opts.distinctId,
...perfPayload(perf, elapsedMs),
...memSnapshot(),
diff --git a/packages/cli/src/telemetry/events.test.ts b/packages/cli/src/telemetry/events.test.ts
index f7aa33ae34..7886d2ce4e 100644
--- a/packages/cli/src/telemetry/events.test.ts
+++ b/packages/cli/src/telemetry/events.test.ts
@@ -312,6 +312,294 @@ describe("render telemetry events", () => {
expect(props.registry_blocks_used_count).toBeUndefined();
});
+ // Output-shape request facts are resolved from CLI flags before the
+ // pipeline starts, so both render_complete and render_error must carry
+ // them: a failure before perfSummary exists is exactly the case these
+ // fields (unlike the perfSummary-derived ones) still need to cover.
+ it("carries output-shape request facts on render_complete", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ outputResolutionPreset: "landscape-4k",
+ outputFormat: "gif",
+ hdrMode: "force-sdr",
+ videoFrameFormat: "png",
+ gifFpsCapped: true,
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.output_resolution_preset).toBe("landscape-4k");
+ expect(props.output_format).toBe("gif");
+ expect(props.hdr_mode).toBe("force-sdr");
+ expect(props.video_frame_format).toBe("png");
+ expect(props.gif_fps_capped).toBe(true);
+ });
+
+ it("carries output-shape request facts on render_error", () => {
+ trackRenderError({
+ fps: 30,
+ quality: "high",
+ docker: false,
+ outputResolutionPreset: "portrait",
+ outputFormat: "mp4",
+ hdrMode: "auto",
+ videoFrameFormat: "auto",
+ gifFpsCapped: false,
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.output_resolution_preset).toBe("portrait");
+ expect(props.output_format).toBe("mp4");
+ expect(props.hdr_mode).toBe("auto");
+ expect(props.video_frame_format).toBe("auto");
+ expect(props.gif_fps_capped).toBe(false);
+ });
+
+ it("omits output-shape request facts when the caller never resolved them", () => {
+ trackRenderComplete({ durationMs: 1, fps: 30, quality: "draft", docker: false, gpu: false });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.output_resolution_preset).toBeUndefined();
+ expect(props.output_format).toBeUndefined();
+ expect(props.hdr_mode).toBeUndefined();
+ expect(props.video_frame_format).toBeUndefined();
+ expect(props.gif_fps_capped).toBeUndefined();
+ });
+
+ // Local-preflight toolchain majors; absent on Docker renders (the
+ // container runs its own preflight, never surfaced to the host CLI).
+ it("carries local toolchain majors on render_complete", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ ffmpegVersionMajor: 7,
+ browserVersionMajor: 119,
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.ffmpeg_version_major).toBe(7);
+ expect(props.browser_version_major).toBe(119);
+ });
+
+ it("carries local toolchain majors on render_error", () => {
+ trackRenderError({
+ fps: 30,
+ quality: "high",
+ docker: false,
+ ffmpegVersionMajor: 6,
+ browserVersionMajor: 118,
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.ffmpeg_version_major).toBe(6);
+ expect(props.browser_version_major).toBe(118);
+ });
+
+ it("omits toolchain majors on a Docker render", () => {
+ trackRenderComplete({ durationMs: 1, fps: 30, quality: "draft", docker: true, gpu: false });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.ffmpeg_version_major).toBeUndefined();
+ expect(props.browser_version_major).toBeUndefined();
+ });
+
+ it("reports which step resolved authoring-skill attribution", () => {
+ trackRenderComplete({
+ durationMs: 1,
+ fps: 30,
+ quality: "draft",
+ docker: false,
+ gpu: false,
+ authoringSkill: "product-launch-video",
+ authoringSkillSource: "flag",
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.authoring_skill).toBe("product-launch-video");
+ expect(props.authoring_skill_source).toBe("flag");
+ expect(props.authoring_skill_invalid).toBeUndefined();
+ });
+
+ it("carries a malformed --skill value on render_error without a resolved source", () => {
+ trackRenderError({
+ fps: 30,
+ quality: "draft",
+ docker: false,
+ authoringSkillInvalid: "Not A Skill!",
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.authoring_skill_invalid).toBe("Not A Skill!");
+ expect(props.authoring_skill_source).toBeUndefined();
+ });
+
+ it("carries the root/body scaffold-mismatch measurement from perfSummary on render_complete", () => {
+ trackRenderComplete({
+ durationMs: 1,
+ fps: 30,
+ quality: "draft",
+ docker: false,
+ gpu: false,
+ rootBodyMismatch: true,
+ rootBodyDeltaPxBucket: "51+",
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.root_body_mismatch).toBe(true);
+ expect(props.root_body_delta_px_bucket).toBe("51+");
+ });
+
+ it("falls back to the live capture-observability measurement on render_error (no perfSummary)", () => {
+ trackRenderError({
+ fps: 30,
+ quality: "draft",
+ docker: false,
+ captureRootBodyMismatch: false,
+ captureRootBodyDeltaPxBucket: "0",
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.root_body_mismatch).toBe(false);
+ expect(props.root_body_delta_px_bucket).toBe("0");
+ });
+
+ it("carries the names of HF/HYPERFRAMES env overrides present at plan time", () => {
+ trackRenderComplete({
+ durationMs: 1,
+ fps: 30,
+ quality: "draft",
+ docker: false,
+ gpu: false,
+ hfEnvOverrides: ["HF_DE_VERIFY", "HYPERFRAMES_FONT_CACHE_DIR"],
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.hf_env_overrides).toEqual(["HF_DE_VERIFY", "HYPERFRAMES_FONT_CACHE_DIR"]);
+ });
+
+ it("reports an empty array, not an absent field, when no override was resolved", () => {
+ trackRenderError({ fps: 30, quality: "draft", docker: false });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.hf_env_overrides).toEqual([]);
+ });
+
+ it("names the runtime adapters a render exercised", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ adaptersUsed: ["gsap", "three"],
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.adapters_used).toEqual(["gsap", "three"]);
+ });
+
+ // adaptersUsed is a live+static UNION with no gating role (unlike
+ // compositionElementCount), so "no adapter detected" is a real measurement
+ // and must be reported as one: an absent property is indistinguishable from
+ // an older CLI that never sent it.
+ it("reports an empty adapter list rather than dropping the property", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ adaptersUsed: [],
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.adapters_used).toEqual([]);
+ });
+
+ it("omits adapters_used entirely when the caller never resolved it", () => {
+ trackRenderComplete({ durationMs: 1000, fps: 30, quality: "high", docker: false, gpu: false });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.adapters_used).toBeUndefined();
+ });
+
+ it("carries the composition scan's element/attribute counts and hasLut flag", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ audioCount: 3,
+ imageCount: 5,
+ subCompositionCount: 1,
+ audioGroupCount: 2,
+ colorGradingCount: 4,
+ hasLut: true,
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.audio_count).toBe(3);
+ expect(props.image_count).toBe(5);
+ expect(props.sub_composition_count).toBe(1);
+ expect(props.audio_group_count).toBe(2);
+ expect(props.color_grading_count).toBe(4);
+ expect(props.has_lut).toBe(true);
+ });
+
+ it("reports zero counts and hasLut false rather than dropping the properties", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ audioCount: 0,
+ imageCount: 0,
+ subCompositionCount: 0,
+ audioGroupCount: 0,
+ colorGradingCount: 0,
+ hasLut: false,
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.audio_count).toBe(0);
+ expect(props.image_count).toBe(0);
+ expect(props.sub_composition_count).toBe(0);
+ expect(props.audio_group_count).toBe(0);
+ expect(props.color_grading_count).toBe(0);
+ expect(props.has_lut).toBe(false);
+ });
+
+ // emitStudioRenderComplete never resolves perfSummary.drawElement, only the
+ // observability capture fields (captureAudioCount/captureRootBodyMismatch/etc),
+ // so these must fall back to the capture value or a studio render reports none
+ // of them despite having computed and sent it.
+ it("falls back to the observability capture value for a studio render, which never resolves the direct field", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ source: "studio",
+ captureAudioCount: 2,
+ captureImageCount: 1,
+ captureRootBodyMismatch: true,
+ captureRootBodyDeltaPxBucket: "11-50",
+ captureAdaptersUsed: ["gsap"],
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.audio_count).toBe(2);
+ expect(props.image_count).toBe(1);
+ expect(props.root_body_mismatch).toBe(true);
+ expect(props.root_body_delta_px_bucket).toBe("11-50");
+ expect(props.adapters_used).toEqual(["gsap"]);
+ });
+
+ it("prefers the direct drawElement-sourced value over the capture fallback when both are present", () => {
+ trackRenderComplete({
+ durationMs: 1000,
+ fps: 30,
+ quality: "high",
+ docker: false,
+ gpu: false,
+ audioCount: 3,
+ captureAudioCount: 99,
+ });
+ const props = trackEvent.mock.calls[0]?.[1] as Record<string, unknown>;
+ expect(props.audio_count).toBe(3);
+ });
+
it("flushes immediately after render_complete and render_error (exit races the lazy flush)", () => {
trackRenderComplete({ durationMs: 1000, fps: 30, quality: "draft", docker: false, gpu: false });
expect(flush).toHaveBeenCalledTimes(1);
diff --git a/packages/cli/src/telemetry/events.ts b/packages/cli/src/telemetry/events.ts
index a996748c20..1a4733429b 100644
--- a/packages/cli/src/telemetry/events.ts
+++ b/packages/cli/src/telemetry/events.ts
@@ -78,6 +78,15 @@ export interface RenderObservabilityTelemetryPayload {
captureCompositionElementTags?: Readonly<Record<string, number>>;
captureArollVideoCount?: number;
captureHeygenVideoCount?: number;
+ captureAdaptersUsed?: readonly string[];
+ captureAudioCount?: number;
+ captureImageCount?: number;
+ captureSubCompositionCount?: number;
+ captureAudioGroupCount?: number;
+ captureColorGradingCount?: number;
+ captureHasLut?: boolean;
+ captureRootBodyMismatch?: boolean;
+ captureRootBodyDeltaPxBucket?: string;
captureDeShortBand?: string;
captureDeParallelRouter?: string;
captureDeGpuRenderer?: string;
@@ -143,6 +152,15 @@ function renderObservabilityEventProperties(props: RenderObservabilityTelemetryP
composition_element_tags: props.captureCompositionElementTags,
aroll_video_count: props.captureArollVideoCount,
heygen_video_count: props.captureHeygenVideoCount,
+ adapters_used: props.captureAdaptersUsed,
+ audio_count: props.captureAudioCount,
+ image_count: props.captureImageCount,
+ sub_composition_count: props.captureSubCompositionCount,
+ audio_group_count: props.captureAudioGroupCount,
+ color_grading_count: props.captureColorGradingCount,
+ has_lut: props.captureHasLut,
+ root_body_mismatch: props.captureRootBodyMismatch,
+ root_body_delta_px_bucket: props.captureRootBodyDeltaPxBucket,
de_short_band: props.captureDeShortBand,
de_parallel_router: props.captureDeParallelRouter,
gpu_renderer: props.captureDeGpuRenderer,
@@ -169,6 +187,49 @@ function renderObservabilityEventProperties(props: RenderObservabilityTelemetryP
};
}
+/** The direct drawElement-sourced value when render.ts's own path resolved one, else the
+ * observability-capture fallback studioRenderTelemetry.ts's path resolves instead. */
+function directOrCapture<T>(direct: T | undefined, capture: T | undefined): T | undefined {
+ return direct ?? capture;
+}
+
+/** Output-shape request facts, resolved before the pipeline starts, shared by render_complete/render_error. */
+export interface RenderOutputShapeTelemetryPayload {
+ /** Named canvas preset from `--resolution`; undefined when rendering at the composition's native dimensions. */
+ outputResolutionPreset?: string;
+ /** Container/output format: mp4 | webm | mov | gif | png-sequence. */
+ outputFormat?: string;
+ /** Requested HDR mode (the CLI flag value, not the resolved per-render outcome): auto | force-hdr | force-sdr. */
+ hdrMode?: string;
+ /** Intermediate frame format used when extracting source video frames: auto | jpg | png. */
+ videoFrameFormat?: string;
+ /** True when a requested --fps > 30 was clamped to 30 for --format gif (createRenderPlan's gifFpsCapped). */
+ gifFpsCapped?: boolean;
+}
+
+function renderOutputShapeEventProperties(props: RenderOutputShapeTelemetryPayload) {
+ return {
+ output_resolution_preset: props.outputResolutionPreset,
+ output_format: props.outputFormat,
+ hdr_mode: props.hdrMode,
+ video_frame_format: props.videoFrameFormat,
+ gif_fps_capped: props.gifFpsCapped,
+ };
+}
+
+/** Local-preflight toolchain majors, shared by render_complete/render_error; absent on Docker renders. */
+export interface RenderEnvironmentTelemetryPayload {
+ ffmpegVersionMajor?: number;
+ browserVersionMajor?: number;
+}
+
+function renderEnvironmentEventProperties(props: RenderEnvironmentTelemetryPayload) {
+ return {
+ ffmpeg_version_major: props.ffmpegVersionMajor,
+ browser_version_major: props.browserVersionMajor,
+ };
+}
+
function redactTelemetryMessage(value: string): string {
return redactTelemetryString(value);
}
@@ -241,6 +302,12 @@ export function trackRenderComplete(
quality: string;
/** Authoring workflow skill that drove this render (e.g. "product-launch-video"). */
authoringSkill?: string;
+ /** Which step resolved authoringSkill: an explicit --skill flag, or the project's own config. */
+ authoringSkillSource?: string;
+ /** Raw --skill value when it failed skill-slug normalization (an unrecognized skill name). */
+ authoringSkillInvalid?: string;
+ /** Names of HF_-/HYPERFRAMES_-prefixed env vars present at plan time (never values), capped at 20. */
+ hfEnvOverrides?: readonly string[];
/**
* Catalog items installed in this project, and those the rendered
* composition reaches. The pair is what joins `registry_item_added` to a
@@ -285,6 +352,15 @@ export function trackRenderComplete(
compositionElementTags?: Readonly<Record<string, number>>;
arollVideoCount?: number;
heygenVideoCount?: number;
+ adaptersUsed?: readonly string[];
+ audioCount?: number;
+ imageCount?: number;
+ subCompositionCount?: number;
+ audioGroupCount?: number;
+ colorGradingCount?: number;
+ hasLut?: boolean;
+ rootBodyMismatch?: boolean;
+ rootBodyDeltaPxBucket?: string;
deShortBand?: string;
deParallelRouter?: string;
dePreRouterWorkers?: number;
@@ -350,20 +426,25 @@ export function trackRenderComplete(
// Attribute this event to a specific user (e.g. the browser user who
// triggered a studio render); defaults to the install anonymousId.
distinctId?: string;
- } & RenderObservabilityTelemetryPayload,
+ } & RenderObservabilityTelemetryPayload &
+ RenderOutputShapeTelemetryPayload &
+ RenderEnvironmentTelemetryPayload,
): void {
trackEvent(
"render_complete",
{
- // Spread first: explicit de_* keys below (sourced from the more
- // authoritative perfSummary.drawElement, always present on this
- // success path) must win over the observability-capture fallback
- // this shares with trackRenderError's failure path.
+ // Spread first: fields below wrapped in directOrCapture() prefer
+ // perfSummary.drawElement, present only on the CLI's own render.ts path.
+ // studioRenderTelemetry.ts never populates drawElement, so without the
+ // fallback the explicit key still wins the spread with an undefined.
...renderObservabilityEventProperties(props),
duration_ms: props.durationMs,
fps: props.fps,
quality: props.quality,
authoring_skill: props.authoringSkill,
+ authoring_skill_source: props.authoringSkillSource,
+ authoring_skill_invalid: props.authoringSkillInvalid,
+ hf_env_overrides: props.hfEnvOverrides ?? [],
...catalogEventProperties(props.catalogUsage),
workers: props.workers,
workers_bound_by: props.workersBoundBy,
@@ -385,28 +466,70 @@ export function trackRenderComplete(
de_capture_mode: props.deCaptureMode,
de_compile_gate: props.deCompileGate,
de_clamp_reason: props.deClampReason,
- de_worker_inversion: props.deWorkerInversion,
- de_pre_inversion_workers: props.dePreInversionWorkers,
- composition_element_count: props.compositionElementCount,
- composition_element_count_source: props.compositionElementCountSource,
- composition_element_tags: props.compositionElementTags,
- aroll_video_count: props.arollVideoCount,
- heygen_video_count: props.heygenVideoCount,
- de_short_band: props.deShortBand,
- de_parallel_router: props.deParallelRouter,
- de_pre_router_workers: props.dePreRouterWorkers,
+ de_worker_inversion: directOrCapture(props.deWorkerInversion, props.captureDeWorkerInversion),
+ de_pre_inversion_workers: directOrCapture(
+ props.dePreInversionWorkers,
+ props.captureDePreInversionWorkers,
+ ),
+ composition_element_count: directOrCapture(
+ props.compositionElementCount,
+ props.captureCompositionElementCount,
+ ),
+ composition_element_count_source: directOrCapture(
+ props.compositionElementCountSource,
+ props.captureCompositionElementCountSource,
+ ),
+ composition_element_tags: directOrCapture(
+ props.compositionElementTags,
+ props.captureCompositionElementTags,
+ ),
+ aroll_video_count: directOrCapture(props.arollVideoCount, props.captureArollVideoCount),
+ heygen_video_count: directOrCapture(props.heygenVideoCount, props.captureHeygenVideoCount),
+ adapters_used: directOrCapture(props.adaptersUsed, props.captureAdaptersUsed),
+ audio_count: directOrCapture(props.audioCount, props.captureAudioCount),
+ image_count: directOrCapture(props.imageCount, props.captureImageCount),
+ sub_composition_count: directOrCapture(
+ props.subCompositionCount,
+ props.captureSubCompositionCount,
+ ),
+ audio_group_count: directOrCapture(props.audioGroupCount, props.captureAudioGroupCount),
+ color_grading_count: directOrCapture(props.colorGradingCount, props.captureColorGradingCount),
+ has_lut: directOrCapture(props.hasLut, props.captureHasLut),
+ root_body_mismatch: directOrCapture(props.rootBodyMismatch, props.captureRootBodyMismatch),
+ root_body_delta_px_bucket: directOrCapture(
+ props.rootBodyDeltaPxBucket,
+ props.captureRootBodyDeltaPxBucket,
+ ),
+ de_short_band: directOrCapture(props.deShortBand, props.captureDeShortBand),
+ de_parallel_router: directOrCapture(props.deParallelRouter, props.captureDeParallelRouter),
+ de_pre_router_workers: directOrCapture(
+ props.dePreRouterWorkers,
+ props.captureDePreRouterWorkers,
+ ),
de_gate_reason: props.deGateReason,
- gpu_renderer: props.gpuRenderer,
+ gpu_renderer: directOrCapture(props.gpuRenderer, props.captureDeGpuRenderer),
de_worker_encode: props.deWorkerEncode,
de_verify_armed: props.deVerifyArmed,
de_verify_checked: props.deVerifyChecked,
de_verify_min_db: props.deVerifyMinDb,
de_verify_init_ms: props.deVerifyInitMs,
- de_self_verify_fallback: props.deSelfVerifyFallback,
- de_fallback_reason: props.deFallbackReason,
- de_fallback_failed_db: props.deFallbackFailedDb,
- de_fallback_frame_index: props.deFallbackFrameIndex,
- de_fallback_threshold_db: props.deFallbackThresholdDb,
+ de_self_verify_fallback: directOrCapture(
+ props.deSelfVerifyFallback,
+ props.captureDeSelfVerifyFallback,
+ ),
+ de_fallback_reason: directOrCapture(props.deFallbackReason, props.captureDeFallbackReason),
+ de_fallback_failed_db: directOrCapture(
+ props.deFallbackFailedDb,
+ props.captureDeFallbackFailedDb,
+ ),
+ de_fallback_frame_index: directOrCapture(
+ props.deFallbackFrameIndex,
+ props.captureDeFallbackFrameIndex,
+ ),
+ de_fallback_threshold_db: directOrCapture(
+ props.deFallbackThresholdDb,
+ props.captureDeFallbackThresholdDb,
+ ),
de_blank_suspects: props.deBlankSuspects,
de_blank_deterministic_accepts: props.deBlankDeterministicAccepts,
de_blank_recaptures: props.deBlankRecaptures,
@@ -415,6 +538,8 @@ export function trackRenderComplete(
de_frame_timeouts: props.deFrameTimeouts,
...powerStateFields(),
source: props.source ?? "cli",
+ ...renderOutputShapeEventProperties(props),
+ ...renderEnvironmentEventProperties(props),
composition_duration_ms: props.compositionDurationMs,
composition_width: props.compositionWidth,
composition_height: props.compositionHeight,
@@ -464,6 +589,12 @@ export function trackRenderError(
quality: string;
/** Authoring workflow skill that drove this render (e.g. "product-launch-video"). */
authoringSkill?: string;
+ /** Which step resolved authoringSkill: an explicit --skill flag, or the project's own config. */
+ authoringSkillSource?: string;
+ /** Raw --skill value when it failed skill-slug normalization (an unrecognized skill name). */
+ authoringSkillInvalid?: string;
+ /** Names of HF_-/HYPERFRAMES_-prefixed env vars present at plan time (never values), capped at 20. */
+ hfEnvOverrides?: readonly string[];
docker: boolean;
workers?: number;
gpu?: boolean;
@@ -480,7 +611,9 @@ export function trackRenderError(
// Attribute this event to a specific user (e.g. the browser user who
// triggered a studio render); defaults to the install anonymousId.
distinctId?: string;
- } & RenderObservabilityTelemetryPayload,
+ } & RenderObservabilityTelemetryPayload &
+ RenderOutputShapeTelemetryPayload &
+ RenderEnvironmentTelemetryPayload,
): void {
trackEvent(
"render_error",
@@ -488,6 +621,9 @@ export function trackRenderError(
fps: props.fps,
quality: props.quality,
authoring_skill: props.authoringSkill,
+ authoring_skill_source: props.authoringSkillSource,
+ authoring_skill_invalid: props.authoringSkillInvalid,
+ hf_env_overrides: props.hfEnvOverrides ?? [],
docker: props.docker,
workers: props.workers,
gpu: props.gpu,
@@ -497,6 +633,8 @@ export function trackRenderError(
failed_stage_code: props.failedStageCode,
error_message: props.errorMessage ? redactTelemetryMessage(props.errorMessage) : undefined,
elapsed_ms: props.elapsedMs,
+ ...renderOutputShapeEventProperties(props),
+ ...renderEnvironmentEventProperties(props),
peak_memory_mb: props.peakMemoryMb,
memory_free_mb: props.memoryFreeMb,
...powerStateFields(),
diff --git a/packages/cli/src/telemetry/renderObservability.ts b/packages/cli/src/telemetry/renderObservability.ts
index 40afe4de42..30c247e7a0 100644
--- a/packages/cli/src/telemetry/renderObservability.ts
+++ b/packages/cli/src/telemetry/renderObservability.ts
@@ -47,6 +47,15 @@ export function renderObservabilityTelemetryPayload(
captureCompositionElementTags: capture.compositionElementTags,
captureArollVideoCount: capture.arollVideoCount,
captureHeygenVideoCount: capture.heygenVideoCount,
+ captureAdaptersUsed: capture.adaptersUsed,
+ captureAudioCount: capture.audioCount,
+ captureImageCount: capture.imageCount,
+ captureSubCompositionCount: capture.subCompositionCount,
+ captureAudioGroupCount: capture.audioGroupCount,
+ captureColorGradingCount: capture.colorGradingCount,
+ captureHasLut: capture.hasLut,
+ captureRootBodyMismatch: capture.rootBodyMismatch,
+ captureRootBodyDeltaPxBucket: capture.rootBodyDeltaPxBucket,
captureDeShortBand: capture.deShortBand,
captureDeParallelRouter: capture.deParallelRouter,
captureDeGpuRenderer: capture.deGpuRenderer,
diff --git a/packages/producer/src/services/render/observability.ts b/packages/producer/src/services/render/observability.ts
index 0b77548363..705756b66a 100644
--- a/packages/producer/src/services/render/observability.ts
+++ b/packages/producer/src/services/render/observability.ts
@@ -117,6 +117,18 @@ export interface RenderCaptureObservability {
* provider. Only set when `compositionElementCountSource` is "static".
*/
heygenVideoCount?: number;
+ /** Runtime adapters exercised (see `KNOWN_RUNTIME_ADAPTERS`), a live+static union, always set. */
+ adaptersUsed?: readonly string[];
+ /** Element/attribute counts from the same static scan; only set when the source above is "static". */
+ audioCount?: number;
+ imageCount?: number;
+ subCompositionCount?: number;
+ audioGroupCount?: number;
+ colorGradingCount?: number;
+ hasLut?: boolean;
+ /** Authored root data-width/height vs. the scaffold's html/body CSS size; absent when either is undetectable. */
+ rootBodyMismatch?: boolean;
+ rootBodyDeltaPxBucket?: "0" | "1-10" | "11-50" | "51+";
/**
* Short-comp band decision, emitted only when the band is DECISIVE — every
* other inversion-eligibility condition passed and only the floor (250 vs
diff --git a/packages/producer/src/services/render/perfSummary.ts b/packages/producer/src/services/render/perfSummary.ts
index 6a3b1558c9..187a462839 100644
--- a/packages/producer/src/services/render/perfSummary.ts
+++ b/packages/producer/src/services/render/perfSummary.ts
@@ -96,6 +96,18 @@ export interface DrawElementPerfInput {
arollVideoCount?: number;
/** `<video data-media-source="heygen">` count from the same static scan; only set when compositionElementCountSource is "static". */
heygenVideoCount?: number;
+ /** Runtime adapters exercised (live+static union); always set (possibly empty). */
+ adaptersUsed?: readonly string[];
+ /** Audio/image/sub-comp/color-grading counts, same static scan; only set when the source above is "static". */
+ audioCount?: number;
+ imageCount?: number;
+ subCompositionCount?: number;
+ audioGroupCount?: number;
+ colorGradingCount?: number;
+ hasLut?: boolean;
+ /** Authored root data-width/height vs. the scaffold's html/body CSS size; absent when either is undetectable. */
+ rootBodyMismatch?: boolean;
+ rootBodyDeltaPxBucket?: "0" | "1-10" | "11-50" | "51+";
/** Short-comp band decision when the band was DECISIVE: "applied" (inverts once HF_DE_SHORT_BAND_ROUTE is on; counterfactual in the baseline release) | "skipped_elements" (element ceiling was the only blocker); unset when the band could not have affected this render. */
shortBand?: "applied" | "skipped_elements" | "unmeasured";
parallelRouter?: "routed" | "reverted";
@@ -144,6 +156,15 @@ function aggregateDrawElement(
compositionElementTags: de.compositionElementTags,
arollVideoCount: de.arollVideoCount,
heygenVideoCount: de.heygenVideoCount,
+ adaptersUsed: de.adaptersUsed,
+ audioCount: de.audioCount,
+ imageCount: de.imageCount,
+ subCompositionCount: de.subCompositionCount,
+ audioGroupCount: de.audioGroupCount,
+ colorGradingCount: de.colorGradingCount,
+ hasLut: de.hasLut,
+ rootBodyMismatch: de.rootBodyMismatch,
+ rootBodyDeltaPxBucket: de.rootBodyDeltaPxBucket,
shortBand: de.shortBand,
parallelRouter: de.parallelRouter ?? "none",
preRouterWorkers: de.preRouterWorkers,
diff --git a/packages/producer/src/services/renderOrchestrator.test.ts b/packages/producer/src/services/renderOrchestrator.test.ts
index 760d97be45..1a50fa2f18 100644
--- a/packages/producer/src/services/renderOrchestrator.test.ts
+++ b/packages/producer/src/services/renderOrchestrator.test.ts
@@ -46,6 +46,8 @@ import {
isDeParallelRouterEnabled,
mergeWorkerInitObservability,
resolveCompositionElementCount,
+ detectAdaptersStatic,
+ resolveAdaptersUsed,
resolveDeShortBand,
shouldClampDefaultDrawElement,
shouldPreferParallelDrawElement,
@@ -2227,12 +2229,157 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
expect(scanElementTags(html).heygenVideoCount).toBe(1);
});
- it("reports zero (not undefined) arollVideoCount/heygenVideoCount and an empty byTag when nothing matches", () => {
+ it("counts audio/image/audio-group elements from the uncapped Map, not the capped byTag", () => {
+ // 55 distinct single-use filler tags, each ranked (tied count=1) ahead
+ // of audio/img/hf-audio-group by insertion order in a stable sort,
+ // push all three past the 50-tag cap into "other" in byTag, but the
+ // dedicated counts must still report the true number.
+ const distinctTags = Array.from({ length: 55 }, (_, i) => `hf-tag-${i}`);
+ const html =
+ distinctTags.map((t) => `<${t}></${t}>`).join("") +
+ "<audio></audio><img/><hf-audio-group></hf-audio-group>";
+ const scan = scanElementTags(html);
+ expect(scan.audioCount).toBe(1);
+ expect(scan.imageCount).toBe(1);
+ expect(scan.audioGroupCount).toBe(1);
+ expect(scan.byTag.audio).toBeUndefined();
+ expect(scan.byTag.img).toBeUndefined();
+ expect(scan.byTag["hf-audio-group"]).toBeUndefined();
+ });
+
+ it("counts data-composition-src sub-composition mounts", () => {
+ const html =
+ '<div data-composition-src="a.html" data-duration="2"></div>' +
+ '<section data-composition-src="b.html"></section><div></div>';
+ expect(scanElementTags(html).subCompositionCount).toBe(2);
+ });
+
+ it("counts data-color-grading elements and detects a LUT reference", () => {
+ const html =
+ '<img data-color-grading=\'{"lut":{"src":"a.cube","intensity":0.5}}\'>' +
+ '<video data-color-grading=\'{"exposure":0.2,"lut":null}\'></video>';
+ const scan = scanElementTags(html);
+ expect(scan.colorGradingCount).toBe(2);
+ expect(scan.hasLut).toBe(true);
+ });
+
+ it("reports hasLut false when no color-grading element references a LUT", () => {
+ const html = '<img data-color-grading=\'{"exposure":0.2,"lut":null}\'>';
+ const scan = scanElementTags(html);
+ expect(scan.colorGradingCount).toBe(1);
+ expect(scan.hasLut).toBe(false);
+ });
+
+ it("decodes the &quot;-escaped attribute form the compile pipeline actually emits", () => {
+ // linkedom's serializer re-emits this attribute &quot;-escaped on every
+ // compile round-trip, the real mainstream shape, not single-quoted.
+ const html = '<img data-color-grading="{&quot;lut&quot;:&quot;a.cube&quot;}">';
+ const scan = scanElementTags(html);
+ expect(scan.colorGradingCount).toBe(1);
+ expect(scan.hasLut).toBe(true);
+ });
+
+ // Mirrors normalizeLut (@hyperframes/core colorGrading.ts): an empty
+ // string, an object with no `src`, or a blank `src` are all "no LUT",
+ // matching the runtime consumer, not just "the key is present".
+ it("reports hasLut false for an empty-string, srcless, or blank-src lut value", () => {
+ const html =
+ '<img data-color-grading=\'{"lut":""}\'>' +
+ "<img data-color-grading='{\"lut\":{}}'>" +
+ '<img data-color-grading=\'{"lut":{"src":" "}}\'>';
+ const scan = scanElementTags(html);
+ expect(scan.colorGradingCount).toBe(3);
+ expect(scan.hasLut).toBe(false);
+ });
+
+ it("does not crash on malformed data-color-grading JSON, counts the element, no LUT signal", () => {
+ const html = "<img data-color-grading='{not json'>";
+ const scan = scanElementTags(html);
+ expect(scan.colorGradingCount).toBe(1);
+ expect(scan.hasLut).toBe(false);
+ });
+
+ it("reports zero (not undefined) for every count and an empty byTag when nothing matches", () => {
const scan = scanElementTags("plain text, no tags at all");
expect(scan.arollVideoCount).toBe(0);
expect(scan.heygenVideoCount).toBe(0);
+ expect(scan.audioCount).toBe(0);
+ expect(scan.imageCount).toBe(0);
+ expect(scan.subCompositionCount).toBe(0);
+ expect(scan.audioGroupCount).toBe(0);
+ expect(scan.colorGradingCount).toBe(0);
+ expect(scan.hasLut).toBe(false);
expect(scan.byTag).toEqual({});
expect(scan.total).toBe(0);
+ // Unlike the counts above, this pair reports absent (not a false/"0"
+ // default) when there's no root tag at all to compare against.
+ expect(scan.rootBodyMismatch).toBeUndefined();
+ expect(scan.rootBodyDeltaPxBucket).toBeUndefined();
+ });
+
+ describe("rootBodyMismatch / rootBodyDeltaPxBucket", () => {
+ function html(rootWidth: number, rootHeight: number, css: string): string {
+ return (
+ `<style>${css}</style>` +
+ `<body><div data-composition-id="c1" data-width="${rootWidth}" data-height="${rootHeight}"></div></body>`
+ );
+ }
+
+ it("reports no mismatch and bucket 0 when the scaffold's html/body CSS matches the root exactly", () => {
+ const scan = scanElementTags(
+ html(1080, 1920, "html, body { width: 1080px; height: 1920px; }"),
+ );
+ expect(scan.rootBodyMismatch).toBe(false);
+ expect(scan.rootBodyDeltaPxBucket).toBe("0");
+ });
+
+ it("buckets a small stale-scaffold delta as 1-10", () => {
+ const scan = scanElementTags(
+ html(1080, 1920, "html, body { width: 1085px; height: 1920px; }"),
+ );
+ expect(scan.rootBodyMismatch).toBe(true);
+ expect(scan.rootBodyDeltaPxBucket).toBe("1-10");
+ });
+
+ it("buckets a mid-size delta as 11-50", () => {
+ const scan = scanElementTags(
+ html(1080, 1920, "html, body { width: 1080px; height: 1950px; }"),
+ );
+ expect(scan.rootBodyMismatch).toBe(true);
+ expect(scan.rootBodyDeltaPxBucket).toBe("11-50");
+ });
+
+ it("buckets a landscape-scaffold-under-portrait-root delta as 51+ (the real #4001 shape)", () => {
+ const scan = scanElementTags(
+ html(1080, 1920, "html, body { width: 1920px; height: 1080px; }"),
+ );
+ expect(scan.rootBodyMismatch).toBe(true);
+ expect(scan.rootBodyDeltaPxBucket).toBe("51+");
+ });
+
+ it("reads a height-authored-before-width CSS block the same way", () => {
+ const scan = scanElementTags(
+ html(1080, 1920, "html, body { height: 1920px; width: 1080px; }"),
+ );
+ expect(scan.rootBodyMismatch).toBe(false);
+ expect(scan.rootBodyDeltaPxBucket).toBe("0");
+ });
+
+ it("reports absent, not a false default, when there is no composition root to read", () => {
+ const scan = scanElementTags(
+ "<style>html, body { width: 1080px; height: 1920px; }</style><p>no root</p>",
+ );
+ expect(scan.rootBodyMismatch).toBeUndefined();
+ expect(scan.rootBodyDeltaPxBucket).toBeUndefined();
+ });
+
+ it("reports absent, not a false default, when the scaffold has no html/body CSS block at all", () => {
+ const scan = scanElementTags(
+ '<body><div data-composition-id="c1" data-width="1080" data-height="1920"></div></body>',
+ );
+ expect(scan.rootBodyMismatch).toBeUndefined();
+ expect(scan.rootBodyDeltaPxBucket).toBeUndefined();
+ });
});
});
@@ -2262,6 +2409,12 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
byTag: { div: 1, span: 1 },
arollVideoCount: 0,
heygenVideoCount: 0,
+ audioCount: 0,
+ imageCount: 0,
+ subCompositionCount: 0,
+ audioGroupCount: 0,
+ colorGradingCount: 0,
+ hasLut: false,
});
});
@@ -2273,6 +2426,12 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
byTag: { div: 1 },
arollVideoCount: 0,
heygenVideoCount: 0,
+ audioCount: 0,
+ imageCount: 0,
+ subCompositionCount: 0,
+ audioGroupCount: 0,
+ colorGradingCount: 0,
+ hasLut: false,
});
});
@@ -2291,6 +2450,12 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
byTag: { div: 1, span: 1 },
arollVideoCount: 0,
heygenVideoCount: 0,
+ audioCount: 0,
+ imageCount: 0,
+ subCompositionCount: 0,
+ audioGroupCount: 0,
+ colorGradingCount: 0,
+ hasLut: false,
});
});
@@ -2302,6 +2467,12 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
byTag: { div: 1 },
arollVideoCount: 0,
heygenVideoCount: 0,
+ audioCount: 0,
+ imageCount: 0,
+ subCompositionCount: 0,
+ audioGroupCount: 0,
+ colorGradingCount: 0,
+ hasLut: false,
});
});
@@ -2314,6 +2485,112 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
});
});
+ describe("detectAdaptersStatic", () => {
+ it("returns empty for a composition using no tracked adapter", () => {
+ expect(detectAdaptersStatic("<div><span>hello</span></div>")).toEqual([]);
+ });
+
+ it("detects gsap from a timeline call, not a bare mention", () => {
+ expect(detectAdaptersStatic("<script>const gsap = 1;</script>")).toEqual([]);
+ expect(detectAdaptersStatic("<script>gsap.timeline().to('.a', {x:1});</script>")).toEqual([
+ "gsap",
+ ]);
+ });
+
+ it("detects the __hf<Name> registration token for each array-registered adapter", () => {
+ expect(detectAdaptersStatic("<script>window.__hfLottie.push(anim);</script>")).toEqual([
+ "lottie",
+ ]);
+ expect(detectAdaptersStatic("<script>window.__hfAnime.push(tl);</script>")).toEqual([
+ "animejs",
+ ]);
+ expect(detectAdaptersStatic("<script>window.__hfD3 = [t];</script>")).toEqual(["d3"]);
+ expect(detectAdaptersStatic("<script>window.__hfLeaflet.push(m);</script>")).toEqual([
+ "leaflet",
+ ]);
+ expect(detectAdaptersStatic("<script>window.__hfMapbox.push(m);</script>")).toEqual([
+ "mapbox",
+ ]);
+ expect(detectAdaptersStatic("<script>window.__hfMaplibre.push(m);</script>")).toEqual([
+ "maplibre",
+ ]);
+ expect(detectAdaptersStatic("<script>window.__hfGoogleMaps.push(m);</script>")).toEqual([
+ "google-maps",
+ ]);
+ });
+
+ it("detects three from a THREE global reference", () => {
+ expect(
+ detectAdaptersStatic("<script>const mgr = THREE.DefaultLoadingManager;</script>"),
+ ).toEqual(["three"]);
+ });
+
+ it("detects typegpu from the data-requires-webgpu authoring attribute", () => {
+ expect(
+ detectAdaptersStatic('<div data-composition-id="a" data-requires-webgpu></div>'),
+ ).toEqual(["typegpu"]);
+ });
+
+ it("detects css from an authored @keyframes rule", () => {
+ expect(detectAdaptersStatic("<style>@keyframes spin { to { opacity: 1; } }</style>")).toEqual(
+ ["css"],
+ );
+ });
+
+ it("detects waapi from an element.animate keyframe-array call", () => {
+ expect(
+ detectAdaptersStatic("<script>el.animate([{opacity:0},{opacity:1}], 500);</script>"),
+ ).toEqual(["waapi"]);
+ });
+
+ it("reports multiple adapters in KNOWN_RUNTIME_ADAPTERS order, not detection order", () => {
+ const html = "<script>gsap.timeline();window.__hfLottie.push(a);window.__hfD3=[t];</script>";
+ expect(detectAdaptersStatic(html)).toEqual(["d3", "gsap", "lottie"]);
+ });
+ });
+
+ describe("resolveAdaptersUsed", () => {
+ it("falls back to the static scan when there is no probe session", async () => {
+ const html = "<script>gsap.timeline();</script>";
+ expect(await resolveAdaptersUsed(null, html)).toEqual(["gsap"]);
+ });
+
+ it("falls back to the static scan when the probe session is not yet initialized", async () => {
+ const session = { isInitialized: false, page: { evaluate: async () => ["three"] } };
+ const html = "<script>gsap.timeline();</script>";
+ expect(await resolveAdaptersUsed(session, html)).toEqual(["gsap"]);
+ });
+
+ it("unions the live probe result with the static scan, deduped and canonically ordered", async () => {
+ const session = { isInitialized: true, page: { evaluate: async () => ["three", "lottie"] } };
+ const html = "<script>gsap.timeline();window.__hfLottie.push(a);</script>";
+ expect(await resolveAdaptersUsed(session, html)).toEqual(["gsap", "lottie", "three"]);
+ });
+
+ it("falls back to the static scan when page.evaluate throws", async () => {
+ const session = {
+ isInitialized: true,
+ page: {
+ evaluate: async () => {
+ throw new Error("Execution context was destroyed");
+ },
+ },
+ };
+ const html = "<script>gsap.timeline();</script>";
+ expect(await resolveAdaptersUsed(session, html)).toEqual(["gsap"]);
+ });
+
+ it("ignores unknown values the live probe might return", async () => {
+ const session = { isInitialized: true, page: { evaluate: async () => ["gsap", "bogus"] } };
+ expect(await resolveAdaptersUsed(session, "<div></div>")).toEqual(["gsap"]);
+ });
+
+ it("reports an empty list, not absent, when nothing is detected", async () => {
+ const session = { isInitialized: true, page: { evaluate: async () => [] } };
+ expect(await resolveAdaptersUsed(session, "<div></div>")).toEqual([]);
+ });
+ });
+
describe("envInt", () => {
afterEach(() => {
delete process.env.HF_TEST_ENV_INT;
diff --git a/packages/producer/src/services/renderOrchestrator.ts b/packages/producer/src/services/renderOrchestrator.ts
index 1f6877cf02..ef4faddd2a 100644
--- a/packages/producer/src/services/renderOrchestrator.ts
+++ b/packages/producer/src/services/renderOrchestrator.ts
@@ -50,9 +50,12 @@ import {
type Fps,
type FpsInput,
fpsToNumber,
+ HF_COLOR_GRADING_ATTR,
redactTelemetryString,
toFps,
} from "@hyperframes/core";
+import { HF_AUDIO_GROUP_TAG } from "@hyperframes/core/audio-groups";
+import { HTML_BODY_CSS_HEIGHT_FIRST_RE, HTML_BODY_CSS_WIDTH_FIRST_RE } from "@hyperframes/parsers";
import {
type EngineConfig,
resolveConfig,
@@ -556,6 +559,18 @@ export interface RenderPerfSummary {
arollVideoCount?: number;
/** `<video data-media-source="heygen">` elements from the same static scan. Only set when compositionElementCountSource is "static". */
heygenVideoCount?: number;
+ /** Runtime adapters exercised (see `KNOWN_RUNTIME_ADAPTERS`), a live+static union, always set (possibly empty). */
+ adaptersUsed?: readonly string[];
+ /** Audio/image/sub-comp/color-grading counts, same static scan; only set when the source above is "static". */
+ audioCount?: number;
+ imageCount?: number;
+ subCompositionCount?: number;
+ audioGroupCount?: number;
+ colorGradingCount?: number;
+ hasLut?: boolean;
+ /** Authored root data-width/height vs. the scaffold's html/body CSS size; absent when either is undetectable. */
+ rootBodyMismatch?: boolean;
+ rootBodyDeltaPxBucket?: "0" | "1-10" | "11-50" | "51+";
/** Short-comp band attribution: "applied" | "skipped_elements" | "unmeasured"; unset when the frame count made the band irrelevant. */
shortBand?: "applied" | "skipped_elements" | "unmeasured";
/** DE parallel-router outcome: "routed" (fired, held), "reverted" (fired, self-verify retry rolled back), "none". Mutually exclusive with workerInversion. */
@@ -1446,10 +1461,56 @@ export interface ElementTagScan {
byTag: Readonly<Record<string, number>>;
arollVideoCount: number;
heygenVideoCount: number;
+ audioCount: number;
+ imageCount: number;
+ subCompositionCount: number;
+ audioGroupCount: number;
+ colorGradingCount: number;
+ hasLut: boolean;
+ /** Authored root data-width/height vs. the scaffold's html/body CSS size; absent when either is undetectable. */
+ rootBodyMismatch?: boolean;
+ rootBodyDeltaPxBucket?: "0" | "1-10" | "11-50" | "51+";
}
const MAX_REPORTED_ELEMENT_TAGS = 50;
+/** First element carrying data-composition-id, the same root marker other `[data-composition-id]` queries here use. */
+const ROOT_COMPOSITION_TAG_RE =
+ /<[a-zA-Z][-a-zA-Z0-9]*\b[^>]*\bdata-composition-id=["'][^"']*["'][^>]*>/i;
+
+function bucketPxDelta(delta: number): NonNullable<ElementTagScan["rootBodyDeltaPxBucket"]> {
+ if (delta === 0) return "0";
+ if (delta <= 10) return "1-10";
+ if (delta <= 50) return "11-50";
+ return "51+";
+}
+
+/** Authored root size vs. the scaffold's html/body CSS size, a source-level fact this HTML
+ * string carries whether or not init.ts's runtime DOM correction ran. Undefined, not a false/"0"
+ * default, when either side can't be read; a lighter root-tag heuristic than lint's findRootTag. */
+function detectRootBodySizeMismatch(
+ html: string,
+): Pick<ElementTagScan, "rootBodyMismatch" | "rootBodyDeltaPxBucket"> {
+ const rootTag = html.match(ROOT_COMPOSITION_TAG_RE)?.[0];
+ const dataWidth = rootTag && Number(rootTag.match(/\bdata-width=["'](\d+)["']/i)?.[1]);
+ const dataHeight = rootTag && Number(rootTag.match(/\bdata-height=["'](\d+)["']/i)?.[1]);
+ if (!dataWidth || !dataHeight) return {};
+
+ // Groups 1 and 3 are prefix text for applyResolutionPreset's in-place
+ // replace; this read-only comparison only needs the digit groups (2 and 4).
+ const widthFirst = html.match(HTML_BODY_CSS_WIDTH_FIRST_RE);
+ const heightFirst = widthFirst ? undefined : html.match(HTML_BODY_CSS_HEIGHT_FIRST_RE);
+ const [cssWidth, cssHeight] = widthFirst
+ ? [Number(widthFirst[2]), Number(widthFirst[4])]
+ : heightFirst
+ ? [Number(heightFirst[4]), Number(heightFirst[2])]
+ : [undefined, undefined];
+ if (!cssWidth || !cssHeight) return {};
+
+ const delta = Math.max(Math.abs(dataWidth - cssWidth), Math.abs(dataHeight - cssHeight));
+ return { rootBodyMismatch: delta > 0, rootBodyDeltaPxBucket: bucketPxDelta(delta) };
+}
+
/**
* Rough element count (and per-tag breakdown) for compiled composition HTML.
*
@@ -1481,9 +1542,9 @@ const MAX_REPORTED_ELEMENT_TAGS = 50;
* literal closing marker (`</`, a void name at a word boundary, or `/>`), so
* ordinary JS comparisons and divisions don't qualify — verified by test.
*
- * `byTag`/`arollVideoCount`/`heygenVideoCount` derive from the SAME matched set and the SAME
- * script/style-stripped markup as `total` — one scan feeds every property
- * this function returns, so none of them can drift apart from each other.
+ * Every other property derives from the SAME script/style-stripped markup as
+ * `total`, and the per-tag counts come from the SAME matched set, so one scan
+ * feeds everything this function returns and none of them can drift apart.
*
* FALLBACK ONLY as of the live-DOM fix below — a string scan of the SOURCE
* markup cannot see elements a composition's own script creates at runtime
@@ -1547,7 +1608,63 @@ export function scanElementTags(html: string): ElementTagScan {
// or value, so a plain presence check is exact, not a substring guess.
const heygenVideoCount =
markup.match(/<video\b[^>]*\bdata-media-source=["']heygen["'][^>]*>/gi)?.length ?? 0;
- return { total, byTag, arollVideoCount, heygenVideoCount };
+ // Uncapped `counts` Map, not `byTag`: 50+ distinct tags could push these
+ // into the "other" bucket, zeroing a named field the cap shouldn't affect.
+ const audioCount = counts.get("audio") ?? 0;
+ const imageCount = counts.get("img") ?? 0;
+ const audioGroupCount = counts.get(HF_AUDIO_GROUP_TAG) ?? 0;
+ // Not collectSubCompositionSrcs (@hyperframes/parsers/asset-resolution):
+ // that dedupes by src and drops placeholder/remote mounts, so its length is
+ // distinct resolvable sub-comps, not this field's mount-element count.
+ const subCompositionCount =
+ markup.match(/<[a-zA-Z][-a-zA-Z0-9]*\b[^>]*\bdata-composition-src=["'][^"']*["']/gi)?.length ??
+ 0;
+ let colorGradingCount = 0;
+ let hasLut = false;
+ for (const m of markup.matchAll(
+ new RegExp(`\\b${HF_COLOR_GRADING_ATTR}=(?:"([^"]*)"|'([^']*)')`, "gi"),
+ )) {
+ colorGradingCount++;
+ // Guarded, not unconditional: one LUT anywhere settles the flag, so the
+ // JSON parse stops running for every element after the first hit.
+ if (!hasLut) hasLut = colorGradingValueHasLut(m[1] ?? m[2] ?? "");
+ }
+ return {
+ total,
+ byTag,
+ arollVideoCount,
+ heygenVideoCount,
+ audioCount,
+ imageCount,
+ subCompositionCount,
+ audioGroupCount,
+ colorGradingCount,
+ hasLut,
+ ...detectRootBodySizeMismatch(html),
+ };
+}
+
+/** `data-color-grading`'s JSON `lut` field means "has a LUT" (see `HF_COLOR_GRADING_ATTR`).
+ * Decode is load-bearing: linkedom re-serializes this `&quot;`-escaped, or `JSON.parse` throws. */
+function colorGradingValueHasLut(rawAttributeValue: string): boolean {
+ const decoded = rawAttributeValue
+ .replace(/&quot;/g, '"')
+ .replace(/&#39;/g, "'")
+ .replace(/&amp;/g, "&");
+ try {
+ const parsed: unknown = JSON.parse(decoded);
+ if (typeof parsed !== "object" || parsed === null || !("lut" in parsed)) return false;
+ const lut = parsed.lut;
+ // Mirrors normalizeLut (@hyperframes/core colorGrading.ts): a bare
+ // non-blank string, or an object with a non-blank string `src`, counts.
+ // null/absent/empty-string/blank-src does not.
+ if (typeof lut === "string") return lut.trim() !== "";
+ if (typeof lut !== "object" || lut === null) return false;
+ const src = (lut as { src?: unknown }).src;
+ return typeof src === "string" && src.trim() !== "";
+ } catch {
+ return false;
+ }
}
/**
@@ -1581,6 +1698,14 @@ export async function resolveCompositionElementCount(
byTag?: Readonly<Record<string, number>>;
arollVideoCount?: number;
heygenVideoCount?: number;
+ audioCount?: number;
+ imageCount?: number;
+ subCompositionCount?: number;
+ audioGroupCount?: number;
+ colorGradingCount?: number;
+ hasLut?: boolean;
+ rootBodyMismatch?: boolean;
+ rootBodyDeltaPxBucket?: ElementTagScan["rootBodyDeltaPxBucket"];
}> {
if (probeSession?.isInitialized) {
try {
@@ -1598,9 +1723,9 @@ export async function resolveCompositionElementCount(
// render on a routing-gate measurement.
}
}
- // byTag/arollVideoCount/heygenVideoCount are static-only: the live path
- // measures a real DOM node count and never runs this string scan, so it
- // has nothing to report.
+ // Every field below `source` is static-only: the live path measures a real
+ // DOM node count and never runs this string scan, so it has nothing to
+ // report for any of them.
const scan = scanElementTags(html);
return {
count: scan.total,
@@ -1608,9 +1733,137 @@ export async function resolveCompositionElementCount(
byTag: scan.byTag,
arollVideoCount: scan.arollVideoCount,
heygenVideoCount: scan.heygenVideoCount,
+ audioCount: scan.audioCount,
+ imageCount: scan.imageCount,
+ subCompositionCount: scan.subCompositionCount,
+ audioGroupCount: scan.audioGroupCount,
+ colorGradingCount: scan.colorGradingCount,
+ hasLut: scan.hasLut,
+ rootBodyMismatch: scan.rootBodyMismatch,
+ rootBodyDeltaPxBucket: scan.rootBodyDeltaPxBucket,
};
}
+/**
+ * All 12 real runtime adapters registered by `runtime/init.ts`, including the
+ * map/data-source ones (d3/leaflet/mapbox/maplibre/google-maps) alongside animation ones.
+ */
+const KNOWN_RUNTIME_ADAPTERS = [
+ "animejs",
+ "css",
+ "d3",
+ "google-maps",
+ "gsap",
+ "leaflet",
+ "lottie",
+ "mapbox",
+ "maplibre",
+ "three",
+ "typegpu",
+ "waapi",
+] as const;
+
+export type RuntimeAdapterName = (typeof KNOWN_RUNTIME_ADAPTERS)[number];
+
+/**
+ * Static, authoring-time signature per adapter. Most match the adapter's own
+ * `window.__hf<Name>` registration token; gsap/three/css/waapi match a library-specific shape.
+ */
+const ADAPTER_STATIC_SIGNATURES: Readonly<Record<RuntimeAdapterName, RegExp>> = {
+ animejs: /\b__hfAnime\b/,
+ css: /@keyframes\s+[\w-]/,
+ d3: /\b__hfD3\b/,
+ "google-maps": /\b__hfGoogleMaps\b/,
+ gsap: /\bgsap\.(timeline|to|from|fromTo|set)\s*\(/,
+ leaflet: /\b__hfLeaflet\b/,
+ lottie: /\b__hfLottie\b/,
+ mapbox: /\b__hfMapbox\b/,
+ maplibre: /\b__hfMaplibre\b/,
+ three:
+ /\bwindow\.THREE\b|\bTHREE\.(Scene|WebGLRenderer|PerspectiveCamera|DefaultLoadingManager)\b/,
+ typegpu: /\bdata-requires-webgpu\b|\b__hfTypegpuTime\b/,
+ waapi: /\.animate\s*\(\s*\[/,
+};
+
+/**
+ * Static regex fallback for `resolveAdaptersUsed`, the sole signal with no probe session.
+ * Scans inline `<script>` bodies too, unlike `scanElementTags`, which strips them.
+ */
+export function detectAdaptersStatic(html: string): RuntimeAdapterName[] {
+ return KNOWN_RUNTIME_ADAPTERS.filter((name) => ADAPTER_STATIC_SIGNATURES[name].test(html));
+}
+
+/**
+ * Live-DOM probe body for `resolveAdaptersUsed`. Self-contained since `page.evaluate` serializes it.
+ * css/waapi split verified against `runtime/adapters/css.ts` (happy-dom can't exercise it here).
+ */
+function probeAdaptersUsed(): string[] {
+ const used: string[] = [];
+ const w = window as unknown as Record<string, unknown>;
+ const isNonEmptyArray = (value: unknown): boolean => Array.isArray(value) && value.length > 0;
+ // Libraries the adapter auto-detects from their own global.
+ if (typeof w.gsap !== "undefined") used.push("gsap");
+ if (typeof w.THREE !== "undefined") used.push("three");
+ // Adapters whose authoring convention is to push each instance onto a
+ // `window.__hf<Name>` registration array.
+ if (isNonEmptyArray(w.__hfAnime)) used.push("animejs");
+ if (isNonEmptyArray(w.__hfD3)) used.push("d3");
+ if (isNonEmptyArray(w.__hfGoogleMaps)) used.push("google-maps");
+ if (isNonEmptyArray(w.__hfLeaflet)) used.push("leaflet");
+ if (isNonEmptyArray(w.__hfLottie)) used.push("lottie");
+ if (isNonEmptyArray(w.__hfMapbox)) used.push("mapbox");
+ if (isNonEmptyArray(w.__hfMaplibre)) used.push("maplibre");
+ // typegpu registers a scalar clock rather than an instance array.
+ if (
+ typeof w.__hfTypegpuTime === "number" ||
+ document.querySelector("[data-composition-id][data-requires-webgpu]")
+ ) {
+ used.push("typegpu");
+ }
+ let liveAnimations: Animation[] = [];
+ try {
+ if (typeof document.getAnimations === "function") liveAnimations = document.getAnimations();
+ } catch {
+ // Detached or mid-navigation document: leave the list empty so the
+ // adapters resolved above are still reported.
+ }
+ // The real "css" adapter only discovers @keyframes-driven animations, never
+ // CSS `transition:`. A `CSSTransition` instance is neither adapter-managed
+ // "css" nor an imperative "waapi" call, so it is excluded from both.
+ const isKeyframesCss = (animation: Animation): boolean =>
+ typeof CSSAnimation !== "undefined" && animation instanceof CSSAnimation;
+ const isTransition = (animation: Animation): boolean =>
+ typeof CSSTransition !== "undefined" && animation instanceof CSSTransition;
+ if (liveAnimations.some(isKeyframesCss)) used.push("css");
+ if (liveAnimations.some((animation) => !isKeyframesCss(animation) && !isTransition(animation))) {
+ used.push("waapi");
+ }
+ return used;
+}
+
+/**
+ * Runtime adapters a composition exercises. Unlike `resolveCompositionElementCount`
+ * (one source of truth, for gating), this is observational: unions live + static every render.
+ */
+export async function resolveAdaptersUsed(
+ probeSession: Pick<CaptureSession, "isInitialized" | "page"> | null,
+ html: string,
+): Promise<readonly RuntimeAdapterName[]> {
+ const staticAdapters = detectAdaptersStatic(html);
+ if (!probeSession?.isInitialized) return staticAdapters;
+ try {
+ const live = await probeSession.page.evaluate(probeAdaptersUsed);
+ if (!Array.isArray(live)) return staticAdapters;
+ const detected = new Set<string>([...staticAdapters, ...live]);
+ return KNOWN_RUNTIME_ADAPTERS.filter((name) => detected.has(name));
+ } catch {
+ // Probe page evaluate can fail (navigation mid-flight, detached frame,
+ // page crash), so fall back to the static-only signal rather than block
+ // the render on a purely observational telemetry probe.
+ return staticAdapters;
+ }
+}
+
/**
* Max-merge init telemetry across per-worker capture perf summaries — the
* success-path channel for PARALLEL renders, whose worker console buffers
@@ -3066,7 +3319,16 @@ async function executeRenderPipeline(input: {
byTag: compositionElementTags,
arollVideoCount,
heygenVideoCount,
+ audioCount,
+ imageCount,
+ subCompositionCount,
+ audioGroupCount,
+ colorGradingCount,
+ hasLut,
+ rootBodyMismatch,
+ rootBodyDeltaPxBucket,
} = await resolveCompositionElementCount(probeSession, compiled.html);
+ const adaptersUsed = await resolveAdaptersUsed(probeSession, compiled.html);
// HF_DE_SHORT_MAX_ELEMENTS=0 is the documented kill switch (symmetric
// with HF_DE_SHORT_MIN_FRAMES=0, which disables via the predicate's own
// minFrames > 0 guard). Gated explicitly here too — without it, a fired
@@ -3412,6 +3674,15 @@ async function executeRenderPipeline(input: {
compositionElementTags,
arollVideoCount,
heygenVideoCount,
+ adaptersUsed,
+ audioCount,
+ imageCount,
+ subCompositionCount,
+ audioGroupCount,
+ colorGradingCount,
+ hasLut,
+ rootBodyMismatch,
+ rootBodyDeltaPxBucket,
deShortBand,
// Same rationale as the counters above: carried on live capture
// observability, not only the success-path perfSummary, so a crash /
@@ -4341,6 +4612,15 @@ async function executeRenderPipeline(input: {
compositionElementTags,
arollVideoCount,
heygenVideoCount,
+ adaptersUsed,
+ audioCount,
+ imageCount,
+ subCompositionCount,
+ audioGroupCount,
+ colorGradingCount,
+ hasLut,
+ rootBodyMismatch,
+ rootBodyDeltaPxBucket,
shortBand: deShortBand,
parallelRouter: deParallelRouter,
preRouterWorkers: deParallelRouter ? preRoutingWorkerCount : undefined,