Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

feat: activate caption lowering

kashorin8b854a316dd8
diff --git a/examples/talking-film-golden/README.md b/examples/talking-film-golden/README.md
index 103308b3..65606cb0 100644
--- a/examples/talking-film-golden/README.md
+++ b/examples/talking-film-golden/README.md
@@ -78,7 +78,7 @@ Candidates and Operations.
| `whisperx:Alignment` | `@svml/whisperx` | 48k speech master -> explicit 16k evidence Need -> WhisperX -> provider-neutral `@svml/speech-align` -> Map | Graph Fragment, locked deterministic components, local media projection and local Provider/service implemented; Surface missing |
| `seedance:Video model="mini"` | `@svml/seedance` | explicit Seedance Mini video Need | missing |
| `broll:Track` | `@svml/broll` | semantic windows + media + recipe -> peer Visual/Audio Tracks | Program/lowering implemented; Surface missing |
-| `caption:Track` | `@svml/caption-gemini` | timed projection + Gemini cue grouping + role recipe -> VisualTrack | base timing/lowering implemented; Gemini/role Surface missing |
+| `caption:Track` | `@svml/caption-gemini` | timed projection + Gemini cue grouping + role recipe -> VisualTrack | timing/lowering and owner validators are locked components; complete Recipe audit and Gemini/role Surface missing |
| `text:Track` | `@svml/text-track` | package Program -> VisualTrack | Program/lowering implemented; Surface/exact-font use missing |
| `film:Film` | `@svml/film` | finite TrackSet fold -> Composition | Graph Fragment and official Surface implemented |
| `render:Video` | `@svml/hyperframes-render` | Composition -> silent HyperframesDocument render + explicit program audio + mux -> final video Artifact + Receipt | Surface, Fragment and all local execution Providers implemented |
diff --git a/packages/caption/README.md b/packages/caption/README.md
index ed69d735..dc21afbb 100644
--- a/packages/caption/README.md
+++ b/packages/caption/README.md
@@ -8,3 +8,17 @@ until a track explicitly chooses a local presentation policy.
`planCaptionPresentation()` is that optional track-local policy. `whole` preserves each authored
region; `proportional-word` and `character-flow` create visibly labelled estimates. They never
write those estimates back into the global speech map or Caption Projection.
+
+`captionComponent` exposes two enumerable deterministic Producers:
+
+- `temporalize-caption`: `Narrative + CompleteSemanticMap -> TimedCaptionProjection`;
+- `render-caption-track`: `TimedCaptionProjection + CaptionTrackProgram -> VisualTrack`.
+
+It also owns and validates both Caption-specific Types. Their validator identities and both
+Producer implementations are checked against `captionManifest` and enter the installed package
+lock. The package has no Provider, LLM, queue, credential or Core authority.
+
+The current `CaptionTrackProgram` is an executable vertical-slice program, not the frozen public
+style language. Exact font Artifacts, the complete production positioning/style matrix, role
+overrides, package-owned SVS Recipes, Gemini cue grouping and the final author Surface require a
+separate capability audit before compatibility freeze.
diff --git a/packages/caption/package.json b/packages/caption/package.json
index c8f37c02..c8d509a3 100644
--- a/packages/caption/package.json
+++ b/packages/caption/package.json
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/component-kit": "workspace:*",
"@svml/contracts": "workspace:*",
"@svml/protocol": "workspace:*"
},
diff --git a/packages/caption/src/component.ts b/packages/caption/src/component.ts
new file mode 100644
index 00000000..eda6cd21
--- /dev/null
+++ b/packages/caption/src/component.ts
@@ -0,0 +1,85 @@
+import type { ComponentPackage } from "@svml/component-kit";
+import type {
+ CompleteSemanticMap,
+ Narrative,
+} from "@svml/contracts";
+import type { StoredValue } from "@svml/protocol";
+import { canonicalize } from "@svml/protocol";
+
+import {
+ captionImplementationDigest,
+ captionProducers,
+ captionTypes,
+ captionValidatorDigests,
+} from "./manifest.js";
+import { temporalizeCaption } from "./temporalize.js";
+import {
+ assertCaptionTrackProgram,
+ assertTimedCaptionProjection,
+ renderCaptionTrack,
+ renderCaptionTrackImplementationDigest,
+} from "./track.js";
+import type {
+ CaptionTrackProgram,
+ TimedCaptionProjection,
+} from "./types.js";
+
+function inline<T>(value: StoredValue | undefined, subject: string): T {
+ if (value?.kind !== "inline") throw new Error(`${subject} must be inline`);
+ return value.value as T;
+}
+
+/** Deterministic timing and VisualTrack lowering only; cue generation and author styling stay outside. */
+export const captionComponent = {
+ name: "@svml/caption",
+ producers: [
+ {
+ producer: captionProducers.temporalize,
+ implementationDigest: captionImplementationDigest,
+ handler: ({ inputs }) => ({
+ outputs: {
+ caption: {
+ kind: "inline",
+ value: canonicalize(temporalizeCaption(
+ inline<Narrative>(inputs.narrative?.value, "Narrative"),
+ inline<CompleteSemanticMap>(inputs.map?.value, "CompleteSemanticMap"),
+ )),
+ },
+ },
+ needs: {},
+ }),
+ },
+ {
+ producer: captionProducers.renderTrack,
+ implementationDigest: renderCaptionTrackImplementationDigest,
+ handler: ({ inputs }) => ({
+ outputs: {
+ track: {
+ kind: "inline",
+ value: canonicalize(renderCaptionTrack(
+ inline<TimedCaptionProjection>(inputs.caption?.value, "TimedCaptionProjection"),
+ inline<CaptionTrackProgram>(inputs.program?.value, "CaptionTrackProgram"),
+ )),
+ },
+ },
+ needs: {},
+ }),
+ },
+ ],
+ validators: [
+ {
+ type: captionTypes.timedProjection,
+ implementationDigest: captionValidatorDigests.timedProjection,
+ handler: ({ value }) => assertTimedCaptionProjection(
+ inline<TimedCaptionProjection>(value, "TimedCaptionProjection"),
+ ),
+ },
+ {
+ type: captionTypes.trackProgram,
+ implementationDigest: captionValidatorDigests.trackProgram,
+ handler: ({ value }) => assertCaptionTrackProgram(
+ inline<CaptionTrackProgram>(value, "CaptionTrackProgram"),
+ ),
+ },
+ ],
+} satisfies ComponentPackage;
diff --git a/packages/caption/src/index.ts b/packages/caption/src/index.ts
index 67465814..a269037f 100644
--- a/packages/caption/src/index.ts
+++ b/packages/caption/src/index.ts
@@ -1,4 +1,5 @@
export { CaptionProjectionError } from "./error.js";
+export { captionComponent } from "./component.js";
export {
captionImplementationDigest,
captionManifest,
@@ -6,12 +7,14 @@ export {
captionProducers,
captionTrackProgramSchema,
captionTypes,
+ captionValidatorDigests,
timedCaptionProjectionSchema,
} from "./manifest.js";
export { planCaptionPresentation } from "./presentation.js";
export { temporalizeCaption } from "./temporalize.js";
export {
assertCaptionTrackProgram,
+ assertTimedCaptionProjection,
computeCaptionTrackProgramDigest,
defaultCaptionTrackProgram,
renderCaptionTrack,
diff --git a/packages/caption/src/manifest.ts b/packages/caption/src/manifest.ts
index 1bca6b57..e590202c 100644
--- a/packages/caption/src/manifest.ts
+++ b/packages/caption/src/manifest.ts
@@ -18,6 +18,10 @@ export const captionTypes = {
trackProgram: { module: captionModuleRef, name: "CaptionTrackProgram" },
} satisfies Record<string, TypeRef>;
export const captionImplementationDigest = digestOf("@svml/caption/temporalize@1");
+export const captionValidatorDigests = {
+ timedProjection: digestOf("@svml/caption/validate-timed-projection@1"),
+ trackProgram: digestOf("@svml/caption/validate-track-program@1"),
+} as const;
const string = { kind: "string", minLength: 1 } as const;
const number = { kind: "number", minimum: 0 } as const;
@@ -94,8 +98,30 @@ export const captionManifest: ModuleManifest = {
videoContractDependencies.composition,
],
types: [
- { name: captionTypes.timedProjection.name, schema: timedCaptionProjectionSchema },
- { name: captionTypes.trackProgram.name, schema: captionTrackProgramSchema },
+ {
+ name: captionTypes.timedProjection.name,
+ schema: timedCaptionProjectionSchema,
+ validator: {
+ abi: "svml.type-validator@1",
+ implementation: {
+ kind: "registered",
+ locator: "@svml/caption/validate-timed-projection",
+ digest: captionValidatorDigests.timedProjection,
+ },
+ },
+ },
+ {
+ name: captionTypes.trackProgram.name,
+ schema: captionTrackProgramSchema,
+ validator: {
+ abi: "svml.type-validator@1",
+ implementation: {
+ kind: "registered",
+ locator: "@svml/caption/validate-track-program",
+ digest: captionValidatorDigests.trackProgram,
+ },
+ },
+ },
],
capabilities: [],
surfaces: [],
diff --git a/packages/caption/src/track.ts b/packages/caption/src/track.ts
index e16fb5af..d22a59ec 100644
--- a/packages/caption/src/track.ts
+++ b/packages/caption/src/track.ts
@@ -88,7 +88,7 @@ export function assertCaptionTrackProgram(program: CaptionTrackProgram): void {
}
}
-function assertProjection(projection: TimedCaptionProjection): void {
+export function assertTimedCaptionProjection(projection: TimedCaptionProjection): void {
if (projection.contract !== "svml.timed-caption-projection@1") {
throw new Error("Unsupported TimedCaptionProjection contract.");
}
@@ -123,7 +123,7 @@ export function renderCaptionTrack(
projection: TimedCaptionProjection,
program: CaptionTrackProgram,
): VisualTrack {
- assertProjection(projection);
+ assertTimedCaptionProjection(projection);
assertCaptionTrackProgram(program);
const totalFrames = programSpaceFrameCount(projection.programSpace);
const plan = planCaptionPresentation(projection, program.mode);
diff --git a/packages/caption/test/caption.test.ts b/packages/caption/test/caption.test.ts
index 35929bfc..23bb1eb8 100644
--- a/packages/caption/test/caption.test.ts
+++ b/packages/caption/test/caption.test.ts
@@ -2,6 +2,8 @@ import assert from "node:assert/strict";
import test from "node:test";
import {
+ captionComponent,
+ captionManifest,
defaultCaptionTrackProgram,
planCaptionPresentation,
renderCaptionTrack,
@@ -18,6 +20,29 @@ import { digestOf } from "@svml/protocol";
import { parseScript } from "@svml/script";
import { locateSpeechTiming } from "@svml/speech-align";
+test("the component enumerates every Manifest Producer and owned Type validator", () => {
+ assert.deepEqual(
+ captionComponent.producers.map((facet) => ({
+ name: facet.producer.name,
+ digest: facet.implementationDigest,
+ })),
+ captionManifest.producers.map((producer) => ({
+ name: producer.name,
+ digest: producer.implementation.digest,
+ })),
+ );
+ assert.deepEqual(
+ captionComponent.validators?.map((facet) => ({
+ name: facet.type.name,
+ digest: facet.implementationDigest,
+ })),
+ captionManifest.types.map((type) => ({
+ name: type.name,
+ digest: type.validator?.implementation.digest,
+ })),
+ );
+});
+
function locate(narrative: Narrative, durationSec: number, segments: readonly AlignedTranscriptSegment[]) {
const programSpace = sealProgramSpace({
contract: "svml.program-space@0",
@@ -69,6 +94,38 @@ function locate(narrative: Narrative, durationSec: number, segments: readonly Al
return locateSpeechTiming(narrative, audioBasis, evidence);
}
+test("Caption-owned validators reject digest-preserving shape tampering", () => {
+ const narrative = parseScript("validator.svml", "<line>Hello.</line>");
+ const projection = temporalizeCaption(narrative, locate(narrative, 1, [{
+ sourceSegmentId: "line",
+ startSec: 0,
+ endSec: 1,
+ words: [{ text: "Hello", startSec: 0.1, endSec: 0.6 }],
+ chars: [],
+ }]));
+ const program = defaultCaptionTrackProgram("validator-caption");
+ const projectionValidator = captionComponent.validators?.find((facet) =>
+ facet.type.name === "TimedCaptionProjection");
+ const programValidator = captionComponent.validators?.find((facet) =>
+ facet.type.name === "CaptionTrackProgram");
+ assert(projectionValidator);
+ assert(programValidator);
+ assert.throws(
+ () => projectionValidator.handler({
+ type: projectionValidator.type,
+ value: { kind: "inline", value: { ...projection, text: "tampered" } },
+ }),
+ /digest does not match/u,
+ );
+ assert.throws(
+ () => programValidator.handler({
+ type: programValidator.type,
+ value: { kind: "inline", value: { ...program, id: "tampered" } },
+ }),
+ /digest does not match/u,
+ );
+});
+
test("Caption temporalization preserves evidence envelopes and labels local estimates", () => {
const narrative = parseScript(
"caption.svml",
diff --git a/packages/prelude-video/README.md b/packages/prelude-video/README.md
index 6afef682..f2e6e321 100644
--- a/packages/prelude-video/README.md
+++ b/packages/prelude-video/README.md
@@ -5,10 +5,11 @@ Manifests, the SVS Frontend, official Text Surfaces and the deterministic comput
owned by those modules. Compiler and Runtime Hosts grant those facets independently. The package
has no Provider, credential, store, queue, network or rendering authority.
-The aggregate now carries the complete `@svml/speech-take` and `@svml/speech-align` Manifests,
-including four deterministic Product projections and the provider-neutral timing locator. A
-physical package-lock test proves that both dependencies are discovered from the installed package
-closure rather than from a CLI or Runtime registration list.
+The aggregate now carries the complete `@svml/speech-take`, `@svml/speech-align` and
+`@svml/caption` Manifests, including four Product projections, the provider-neutral timing locator,
+Caption temporalization, VisualTrack lowering and Caption-owned validators. A physical package-lock
+test proves that these dependencies are discovered from the installed package closure rather than
+from a CLI or Runtime registration list.
The CLI depends only on this replaceable prelude rather than enumerating Script, Film or
HyperFrames packages itself.
diff --git a/packages/prelude-video/package.json b/packages/prelude-video/package.json
index 2e84bf9d..a67dca18 100644
--- a/packages/prelude-video/package.json
+++ b/packages/prelude-video/package.json
@@ -10,6 +10,7 @@
"activation": "./src/index.ts"
},
"dependencies": {
+ "@svml/caption": "workspace:*",
"@svml/contracts": "workspace:*",
"@svml/film": "workspace:*",
"@svml/hyperframes": "workspace:*",
diff --git a/packages/prelude-video/src/index.ts b/packages/prelude-video/src/index.ts
index c20ab11c..d847e849 100644
--- a/packages/prelude-video/src/index.ts
+++ b/packages/prelude-video/src/index.ts
@@ -2,6 +2,10 @@ import {
videoContractManifests,
videoContractsComponents,
} from "@svml/contracts";
+import {
+ captionComponent,
+ captionManifest,
+} from "@svml/caption";
import {
decodeFilmSurface,
filmManifest,
@@ -49,6 +53,7 @@ export const svmlPackage: NodePackageActivation = {
{ manifest: svsManifest },
{ manifest: hyperframesManifest },
{ manifest: mediaPipelineManifest },
+ { manifest: captionManifest },
{ manifest: speechAlignManifest },
{ manifest: speechTakeManifest },
{ manifest: filmManifest, specifiers: ["@svml/film", "@svml/film@1"] },
@@ -60,6 +65,7 @@ export const svmlPackage: NodePackageActivation = {
frontends: [svsFrontend],
components: [
...videoContractsComponents,
+ captionComponent,
mediaPipelineComponent,
speechAlignComponent,
speechTakeComponent,
diff --git a/packages/prelude-video/test/activation.test.ts b/packages/prelude-video/test/activation.test.ts
index 3971f3e7..41dc06ea 100644
--- a/packages/prelude-video/test/activation.test.ts
+++ b/packages/prelude-video/test/activation.test.ts
@@ -8,6 +8,10 @@ import { join } from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";
+import {
+ captionComponent,
+ captionManifest,
+} from "@svml/caption";
import {
createNodePackageLock,
loadNodePackages,
@@ -51,7 +55,24 @@ test("the official prelude activates Speech Align compute without teaching the H
);
});
-test("the installed official package lock physically contains deterministic speech compute", async () => {
+test("the official prelude activates Caption compute and owner validators without Host special cases", () => {
+ const components = nodePackageComponents([svmlPackage]);
+ assert.equal(
+ svmlPackage.modules?.some((module) => module.manifest === captionManifest),
+ true,
+ );
+ assert.equal(components.includes(captionComponent), true);
+ assert.deepEqual(
+ captionComponent.producers.map((facet) => facet.producer.name),
+ ["temporalize-caption", "render-caption-track"],
+ );
+ assert.deepEqual(
+ captionComponent.validators?.map((facet) => facet.type.name),
+ ["TimedCaptionProjection", "CaptionTrackProgram"],
+ );
+});
+
+test("the installed official package lock physically contains speech and Caption compute", async () => {
const directory = await mkdtemp(join(tmpdir(), "svml-prelude-lock-"));
const lockPath = join(directory, "svml.packages.lock");
const installedRoot = fileURLToPath(new URL("../../cli/", import.meta.url));
@@ -59,11 +80,13 @@ test("the installed official package lock physically contains deterministic spee
const lock = await createNodePackageLock(["@svml/prelude-video"], installedRoot);
assert.equal(lock.artifacts.some((artifact) => artifact.name === "@svml/speech-take"), true);
assert.equal(lock.artifacts.some((artifact) => artifact.name === "@svml/speech-align"), true);
+ assert.equal(lock.artifacts.some((artifact) => artifact.name === "@svml/caption"), true);
await writeNodePackageLock(lockPath, lock);
const packages = await loadNodePackages(lockPath, installedRoot);
const components = nodePackageComponents(packages);
assert.equal(components.some((component) => component.name === "@svml/speech-take"), true);
assert.equal(components.some((component) => component.name === "@svml/speech-align"), true);
+ assert.equal(components.some((component) => component.name === "@svml/caption"), true);
} finally {
await rm(directory, { recursive: true, force: true });
}
diff --git a/packages/speech-program/test/video-pipeline.test.ts b/packages/speech-program/test/video-pipeline.test.ts
index b1d4736a..78d36d7e 100644
--- a/packages/speech-program/test/video-pipeline.test.ts
+++ b/packages/speech-program/test/video-pipeline.test.ts
@@ -6,9 +6,8 @@ import {
registerTypeValidatorFacets,
} from "@svml/component-kit";
import {
- captionImplementationDigest,
+ captionComponent,
captionProducers,
- temporalizeCaption,
} from "@svml/caption";
import type { TimedCaptionProjection } from "@svml/caption";
import {
@@ -20,7 +19,6 @@ import {
sealVisualTrack,
} from "@svml/contracts";
import type {
- CompleteSemanticMap,
Narrative,
SpeechAudioBasis,
SpeechBasis,
@@ -87,6 +85,7 @@ function inlineObject(value: unknown): Readonly<Record<string, unknown>> {
function validatorRegistry(): TypeValidatorRegistry {
const registry = new TypeValidatorRegistry();
+ registerTypeValidatorFacets(registry, captionComponent.validators ?? []);
registerTypeValidatorFacets(registry, compositionContractsComponent.validators);
return registry;
}
@@ -126,7 +125,6 @@ test("the Speech Program pipeline resumes without repeating paid calls", async (
evidenceAudioRequest: 0,
whisperRequest: 0,
whisperNormalize: 0,
- caption: 0,
};
host.registerProducer(videoProducers.requestEstimate, videoImplementations.requestEstimate, ({ inputs }) => {
@@ -279,16 +277,7 @@ test("the Speech Program pipeline resumes without repeating paid calls", async (
return { outputs: { evidence: { kind: "inline", value: evidence } }, needs: {} };
});
registerProducerFacets(host, speechAlignComponent.producers);
- host.registerProducer(captionProducers.temporalize, captionImplementationDigest, ({ inputs }) => {
- calls.caption += 1;
- assert.equal(inputs.narrative?.value.kind, "inline");
- assert.equal(inputs.map?.value.kind, "inline");
- const caption = temporalizeCaption(
- inlineValue<Narrative>(inputs.narrative.value.value),
- inlineValue<CompleteSemanticMap>(inputs.map.value.value),
- );
- return { outputs: { caption: { kind: "inline", value: caption } }, needs: {} };
- });
+ registerProducerFacets(host, captionComponent.producers);
const driver = new NodeDriver({ registry: host, providers, validators: validatorRegistry() });
const atEstimate = await driver.run(createVideoBuild());
@@ -472,7 +461,6 @@ test("the Speech Program pipeline resumes without repeating paid calls", async (
evidenceAudioRequest: 1,
whisperRequest: 1,
whisperNormalize: 1,
- caption: 1,
});
assert.deepEqual(completed.state.receipts.map((receipt) => receipt.fulfiller), [
"runtime:official-estimate",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 59710fc8..ccfb2487 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -58,6 +58,9 @@ importers:
packages/caption:
dependencies:
+ '@svml/component-kit':
+ specifier: workspace:*
+ version: link:../component-kit
'@svml/contracts':
specifier: workspace:*
version: link:../contracts
@@ -452,6 +455,9 @@ importers:
packages/prelude-video:
dependencies:
+ '@svml/caption':
+ specifier: workspace:*
+ version: link:../caption
'@svml/contracts':
specifier: workspace:*
version: link:../contracts