Files
OmniRoute/tests/unit/guardrails/videoBridgePromotionFixtures.test.ts
Diego Rodrigues de Sa e Souza ef668967f6 test(video): freeze FU-07/FU-09 promotion-evidence manifest, aggregator, evaluator and allowlist scaffold (#11656) (#12008)
FU-07/FU-09 promotion-evidence harness (Refs #11656): delivers the manifest schema, deterministic fixture recipes, metrics aggregator, and promotion-verdict evaluator #11656 asks for — deliberately does NOT deliver the promotion verdicts themselves (they require real models against real fixtures on a live host, HOLD with explicit reason instead of any fabricated result). New files only, no collision with sibling PRs.
2026-08-29 19:33:33 -03:00

69 lines
2.8 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { VIDEO_BRIDGE_PROMOTION_CASE_KINDS } from "../../../src/lib/guardrails/videoBridgePromotionManifest.ts";
import {
buildFfmpegArgsFromRecipe,
VIDEO_BRIDGE_PROMOTION_FIXTURE_RECIPES,
videoBridgeFixtureRecipeSchema,
} from "../../../src/lib/guardrails/videoBridgePromotionFixtures.ts";
test("ships exactly one deterministic recipe per frozen case kind", () => {
const kindsCovered = VIDEO_BRIDGE_PROMOTION_FIXTURE_RECIPES.map((recipe) => recipe.caseKind);
assert.deepEqual([...kindsCovered].sort(), [...VIDEO_BRIDGE_PROMOTION_CASE_KINDS].sort());
assert.equal(new Set(kindsCovered).size, kindsCovered.length, "no duplicate case kinds");
});
test("every shipped recipe validates against its own declarative schema", () => {
for (const recipe of VIDEO_BRIDGE_PROMOTION_FIXTURE_RECIPES) {
assert.deepEqual(videoBridgeFixtureRecipeSchema.parse(recipe), recipe);
}
});
test("recipe ids are unique and stable", () => {
const ids = VIDEO_BRIDGE_PROMOTION_FIXTURE_RECIPES.map((recipe) => recipe.id);
assert.equal(new Set(ids).size, ids.length);
});
test("buildFfmpegArgsFromRecipe is a pure function: same recipe -> byte-identical args, no I/O", () => {
const recipe = VIDEO_BRIDGE_PROMOTION_FIXTURE_RECIPES.find(
(candidate) => candidate.caseKind === "static_scene"
);
assert.ok(recipe, "static_scene recipe must exist");
const first = buildFfmpegArgsFromRecipe(recipe!);
const second = buildFfmpegArgsFromRecipe(recipe!);
assert.deepEqual(first, second);
assert.ok(first.includes("-filter_complex"));
assert.ok(first.includes(recipe!.filterGraph));
assert.ok(first.includes("-map"));
assert.ok(first.includes(`[${recipe!.outputLabel}]`));
});
test("buildFfmpegArgsFromRecipe emits one -f lavfi -i triplet per declared layer, in order", () => {
const recipe = VIDEO_BRIDGE_PROMOTION_FIXTURE_RECIPES.find(
(candidate) => candidate.caseKind === "rapid_cuts"
);
assert.ok(recipe, "rapid_cuts recipe must exist");
const args = buildFfmpegArgsFromRecipe(recipe!);
const lavfiInputs = args.filter((value) => value === "-f").length;
assert.equal(lavfiInputs, recipe!.layers.length);
for (const layer of recipe!.layers) {
assert.ok(
args.some((value) => value.includes(`s=${recipe!.width}x${recipe!.height}`)),
"each layer input string must carry the recipe resolution"
);
assert.ok(
args.some((value) => value.includes(`d=${layer.durationSeconds}`)),
"each layer input string must carry its own duration"
);
}
});
test("prompt_injection recipe is flagged as a security-relevant fixture", () => {
const recipe = VIDEO_BRIDGE_PROMOTION_FIXTURE_RECIPES.find(
(candidate) => candidate.caseKind === "prompt_injection"
);
assert.ok(recipe);
assert.equal(recipe!.isSecurityFixture, true);
});