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.

refactor(v2): separate host and video distribution boundaries

kashorin71f50ead3fa3
diff --git a/README.md b/README.md
index cca07edf..8373a5af 100644
--- a/README.md
+++ b/README.md
@@ -162,9 +162,14 @@ community Parser/Producer/Validator execution still needs a real isolation and p
```text
packages/protocol immutable wire contracts
+packages/artifact domain-neutral content-addressed byte Type
packages/core domain-neutral Demand compiler and Build state machine
packages/elaborator author declarations and hygienic Fragment expansion
packages/compiler-node reference Node compiler Host
+packages/compiler-text-node optional official Text compiler assembly
+packages/package-loader-node syntax-neutral trusted physical-package loading
+packages/cli generic commands requiring an explicit Distribution
+packages/video-cli official Text/video command Distribution
packages/run official human-readable Run Graph frontend
packages/runtime environment-neutral scheduling and Store ports
packages/driver-node trusted Node command execution
diff --git a/docs/README.md b/docs/README.md
index e4a5e01a..c7b9e9c3 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -21,7 +21,7 @@ the working tree contains only documents that should inform current implementati
- [`graph-first-value-boundary-v1.md`](./graph-first-value-boundary-v1.md) — graph edges own
dependency truth; values contain only intrinsic meaning.
- [`node-package-activation-v1.md`](./node-package-activation-v1.md) — trusted installed package
- locking and facet activation.
+ locking, contributions and Host-selected facet activation.
- [`local-developer-runtime-v1.md`](./local-developer-runtime-v1.md) — local SQLite/filesystem
Runtime, recovery and environment replacement.
- [`build-archive-and-egress-v1.md`](./build-archive-and-egress-v1.md) — Targets, durable Records,
diff --git a/package.json b/package.json
index 252ed930..e952f773 100644
--- a/package.json
+++ b/package.json
@@ -13,11 +13,11 @@
"check:v2": "tsc -p tsconfig.v2.json --noEmit",
"test": "pnpm test:v1 && pnpm test:v2",
"test:v1": "node --import tsx --test 'test/**/*.test.ts'",
- "test:v2": "node --import tsx --test 'packages/*/test/**/*.test.ts'",
+ "test:v2": "node --import tsx --test 'packages/*/test/**/*.test.ts' 'tools/*.test.mjs'",
"test:whisperx-service": "uv run --project services/whisperx --frozen python -m unittest discover -s services/whisperx/tests -p 'test_*.py'",
"smoke:kie": "node --import tsx packages/provider-kie/test/live-smoke.ts",
"svml": "node --import tsx src/cli.ts",
- "svml:v2": "node --import tsx packages/cli/src/cli.ts"
+ "svml:v2": "node --import tsx packages/video-cli/src/cli.ts"
},
"files": [
"dist/src",
diff --git a/packages/artifact/README.md b/packages/artifact/README.md
new file mode 100644
index 00000000..cd306e8c
--- /dev/null
+++ b/packages/artifact/README.md
@@ -0,0 +1,10 @@
+# `@svml/artifact`
+
+Domain-neutral nominal contract for one content-addressed byte Artifact.
+
+`BlobArtifact` wraps the Protocol `BlobRef` storage form in an owner-defined `TypeRef`, allowing any
+domain to place files, model outputs or other immutable bytes on Graph edges without borrowing a
+media/video type. Artifact storage and transfer remain separate Runtime ports implemented by
+packages such as `@svml/artifact-store-fs` and `@svml/artifact-store-s3`.
+
+The package has no filesystem, network, media or Provider behavior.
diff --git a/packages/artifact/package.json b/packages/artifact/package.json
new file mode 100644
index 00000000..67e13d11
--- /dev/null
+++ b/packages/artifact/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "@svml/artifact",
+ "version": "0.0.0-dev",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "dependencies": {
+ "@svml/protocol": "workspace:*"
+ }
+}
diff --git a/packages/artifact/src/index.ts b/packages/artifact/src/index.ts
new file mode 100644
index 00000000..0f4d7c64
--- /dev/null
+++ b/packages/artifact/src/index.ts
@@ -0,0 +1,32 @@
+import { digestOf } from "@svml/protocol";
+import type {
+ ModuleManifest,
+ TypeRef,
+ ValueSchema,
+} from "@svml/protocol";
+
+export const artifactModuleRef = { name: "@svml/artifact", version: "0.0.0-dev" } as const;
+
+export const artifactTypes = {
+ blob: { module: artifactModuleRef, name: "BlobArtifact" },
+} satisfies Record<string, TypeRef>;
+
+/** StoredValue.kind=blob already performs exact BlobRef structural validation in Protocol/Core. */
+export const blobArtifactValueSchema: ValueSchema = { kind: "blob" };
+
+export const artifactManifest: ModuleManifest = {
+ format: "svml.module@0",
+ name: artifactModuleRef.name,
+ version: artifactModuleRef.version,
+ dependencies: [],
+ types: [{ name: artifactTypes.blob.name, schema: blobArtifactValueSchema }],
+ capabilities: [],
+ surfaces: [],
+ producers: [],
+};
+
+export const artifactManifestDigest = digestOf(artifactManifest);
+export const artifactDependency = {
+ module: artifactModuleRef,
+ digest: artifactManifestDigest,
+} as const;
diff --git a/packages/broll/package.json b/packages/broll/package.json
index bb715551..02fc2ad4 100644
--- a/packages/broll/package.json
+++ b/packages/broll/package.json
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/artifact": "workspace:*",
"@svml/component-kit": "workspace:*",
"@svml/contracts": "workspace:*",
"@svml/elaborator": "workspace:*",
diff --git a/packages/broll/src/manifest.ts b/packages/broll/src/manifest.ts
index fbb818e2..775c8fdd 100644
--- a/packages/broll/src/manifest.ts
+++ b/packages/broll/src/manifest.ts
@@ -1,3 +1,4 @@
+import { artifactDependency } from "@svml/artifact";
import {
audioTrackSchema,
completeSemanticMapSchema,
@@ -154,6 +155,7 @@ export const brollManifest: ModuleManifest = {
name: brollModuleRef.name,
version: brollModuleRef.version,
dependencies: [
+ artifactDependency,
videoContractDependencies.narrative,
videoContractDependencies.media,
videoContractDependencies.semanticTime,
diff --git a/packages/broll/src/surface.ts b/packages/broll/src/surface.ts
index 01a49513..845ced9e 100644
--- a/packages/broll/src/surface.ts
+++ b/packages/broll/src/surface.ts
@@ -1,3 +1,4 @@
+import { artifactTypes } from "@svml/artifact";
import { contractTypes } from "@svml/contracts";
import { sealGraphFragment } from "@svml/elaborator";
import type { FragmentOperation } from "@svml/elaborator";
@@ -120,7 +121,7 @@ export const decodeBrollTrackSurface: StructuredSurfaceHandler = ({ element, res
if (!child.name.endsWith(":Item") && child.name !== "Item") throw new Error(`${element.name} accepts only Item children`);
itemIndex += 1;
exact(child, ["source", "during", "appearance"]);
- const source = ref(child, "source", contractTypes.blobArtifact, resolveReference);
+ const source = ref(child, "source", artifactTypes.blob, resolveReference);
const selection = ref(child, "during", contractTypes.narrativeSelection, resolveReference);
const appearance = recipe(ref(child, "appearance", svsRecipeType, resolveReference));
const expected = ["background", "enter", "exit", "fit", "height", "radius", "stack-order", "width", "x", "y"];
diff --git a/packages/cli/README.md b/packages/cli/README.md
index 24d4f22e..084e0a3d 100644
--- a/packages/cli/README.md
+++ b/packages/cli/README.md
@@ -1,80 +1,21 @@
# `@svml/cli`
-Official v2 command-line assembly.
-
-Unlike `@svml/compiler-node`, this application is allowed to choose a trusted default prelude. It
-depends on the one ordinary `@svml/prelude-video` aggregate rather than importing each video package
-itself. The current prelude contributes:
-
-- the official Text Frontend;
-- the Script raw Surface and its audiovisual Narrative contract dependency;
-- the SVS alternate Frontend and generic Recipe manifest;
-- the official Speech, WhisperX, provider-free Caption, B-roll, Text, Film and HyperFrames Render
- Structured Surfaces plus their exact static dependencies.
-
-It does not place these packages in Core and does not grant source imports network, credential or
-process permissions.
-
-From the repository:
-
-```bash
-pnpm svml:v2 check path/to/main.svml
-pnpm svml:v2 lock-packages ./svml.packages.lock --package @example/cards --root .
-pnpm svml:v2 check path/to/main.svml --package-lock ./svml.packages.lock --root .
-pnpm svml:v2 plan path/to/main.svml --target component.result
-pnpm svml:v2 check path/to/build.svrun
-pnpm svml:v2 plan path/to/build.svrun
-pnpm svml:v2 build path/to/build.svrun --runtime ./svml.runtime.json --build-id delivery-01 --follow
-pnpm svml:v2 build path/to/main.svml --target final.video --runtime ./svml.runtime.ts --pin shot=<prior-build-id> --accept-substitute --build-id variant-01 --follow
-pnpm svml:v2 status <build-id> --runtime ./svml.runtime.json
-pnpm svml:v2 builds --runtime ./svml.runtime.json
-pnpm svml:v2 inspect <build-id> --runtime ./svml.runtime.json
-pnpm svml:v2 get <build-id> --name final.video --runtime ./svml.runtime.json --to ./final.mp4
-pnpm svml:v2 cancel <build-id> --runtime ./svml.runtime.json
+Domain-neutral command engine for Build compilation, execution, inspection and egress.
+
+The engine implements `lock-packages`, `check`, `plan`, `build`, `status`, `builds`, `inspect`, `get`
+and `cancel`, but owns no default author vocabulary, entry Frontend or Provider adapter. Its caller
+must pass one explicit `CliDistribution`:
+
+```ts
+type CliDistribution = {
+ name: string;
+ builtInPackageContributions: readonly NodePackageContribution[];
+ createCompiler(options): NodeCompiler;
+ createRuntimeFromConfig(path): Promise<LocalRuntime>;
+};
```
-`check` is usable for the complete provider-free author graph in
-`examples/talking-film-graph-check`. `plan` is fully implemented by the generic Node compiler. The
-live example now executes the explicit Vertex Gemini Caption package and real local/remote
-Endpoints; the CLI never fabricates missing facts.
-
-`build` compiles the same locked BuildState and passes it to a trusted local Runtime Profile.
-The default Build identity is content-derived, so the same invocation resumes durable local state;
-`--build-id take-02` names an explicit take. JSON Profiles resolve only adapters registered by the
-Host and contain no executable callback. A TypeScript config module remains trusted deployment code
-with normal Node authority. Neither form is discovered from a source import.
-
-Without `--follow`, a pending remote job returns `paused` and a later identical command resumes it.
-With `--follow`, the CLI stays attached and follows endpoint `wakeAt` hints until completion, a
-non-retryable failure, cancellation or `--max-wait-ms`. `status` reads durable verified state;
-`cancel` invokes active endpoints and then records the resulting terminal Build failure. None of
-these commands creates a second ready-command queue.
-
-`build` archives every accepted Record in the demanded closure and every referenced byte Artifact,
-whether or not the user wants a conventional filesystem copy. `inspect` lists Targets, demanded
-Logical Outputs, accepted Records and their Artifact references. `get` reads one accepted Record;
-without a selector it requires one distinct target, while `--name`, `--record` and `--output` select
-a source output alias, accepted Record or demanded Logical Output. `--artifact` selects any nested
-BlobRef that the Build actually references. `--to` copies an Artifact or writes an inline structured
-value as JSON. It is Host egress only and never changes Build identity or retention.
-
-`builds` and source aliases come from an optional Host `BuildCatalog`. The Catalog contains paths
-and presentation names only. It is not Core truth or a Runtime Closure facet; `inspect` and `get`
-always resolve the alias back through the verified BuildState before accepting it.
-
-`--pin output=<prior-build-id>` is temporary CLI compatibility language, not a Core primitive. The Host
-verifies the prior Build only to extract a typed Record, attaches it as an ordinary zero-input
-`substitute` Candidate, and adds an explicit Satisfaction to a newly compiled BuildRequest. It does not
-prove that the old Graph, prompt or semantic meaning matches the current output. Consequently the
-command requires `--accept-substitute`. Upstream work behind that selected Candidate is not
-demanded, while every unbound reachable output follows the ordinary graph. The prior artifact must
-still exist in the ArtifactStore selected by the Runtime. This is a new Build with a new identity;
-it never resumes or copies the prior Build's outstanding Commands. `.svrun` is now the general Run
-Graph, Target and Satisfaction language; this narrow flag remains only migration compatibility.
-
-`@svml/package-loader-node` supports explicitly trusted installed implementation packages. It
-verifies the complete physical dependency closure before executing an activation entry, then checks
-exact Module, Frontend, Surface, Producer and Validator identities. `plan` and `build` bind the lock
-digest into `BuildRequest.implementationClosure`. It never installs a package because source
-requested it and does not activate Provider or privileged Runtime facets. Arbitrary untrusted
-community execution remains absent until an isolated Worker and real permission boundary exist.
+A Distribution is trusted application assembly, not Core data or source-import authority. The
+official `@svml/video-cli` selects `@svml/compiler-text-node`, `@svml/prelude-video` and the current
+video Runtime adapters. Another domain can reuse this command engine without installing those
+packages.
diff --git a/packages/cli/package.json b/packages/cli/package.json
index dfdc26f6..af536a43 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -8,15 +8,8 @@
},
"dependencies": {
"@svml/compiler-node": "workspace:*",
- "@svml/artifact-store-s3": "workspace:*",
"@svml/local": "workspace:*",
"@svml/package-loader-node": "workspace:*",
- "@svml/prelude-video": "workspace:*",
- "@svml/provider-google-vertex": "workspace:*",
- "@svml/provider-hyperframes-local": "workspace:*",
- "@svml/provider-kie": "workspace:*",
- "@svml/provider-media-local": "workspace:*",
- "@svml/provider-whisperx-local": "workspace:*",
"@svml/protocol": "workspace:*",
"@svml/realization": "workspace:*",
"@svml/run": "workspace:*",
diff --git a/packages/cli/src/distribution.ts b/packages/cli/src/distribution.ts
new file mode 100644
index 00000000..9e5ad0ca
--- /dev/null
+++ b/packages/cli/src/distribution.ts
@@ -0,0 +1,21 @@
+import type { NodeCompiler } from "@svml/compiler-node";
+import type { LocalRuntime } from "@svml/local";
+import type { NodePackageContribution } from "@svml/package-loader-node";
+
+export type CliCompilerOptions = {
+ readonly root?: string;
+ readonly packageContributions: readonly NodePackageContribution[];
+};
+
+/**
+ * Explicit application assembly for the generic command engine.
+ *
+ * A Distribution selects author vocabulary/compiler semantics and trusted Runtime-config adapters.
+ * It is Host configuration, never Core state or source-import authority.
+ */
+export type CliDistribution = {
+ readonly name: string;
+ readonly builtInPackageContributions: readonly NodePackageContribution[];
+ createCompiler(options: CliCompilerOptions): NodeCompiler;
+ createRuntimeFromConfig(path: string): Promise<LocalRuntime>;
+};
diff --git a/packages/cli/src/host.ts b/packages/cli/src/host.ts
deleted file mode 100644
index 674c2b23..00000000
--- a/packages/cli/src/host.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { NodeCompiler } from "@svml/compiler-node";
-import {
- createActivatedNodeCompiler,
-} from "@svml/package-loader-node";
-import type { NodePackageActivation } from "@svml/package-loader-node";
-import { svmlPackage as videoPrelude } from "@svml/prelude-video";
-
-export type OfficialCompilerOptions = {
- readonly root?: string;
- /** Replaces the ordinary official prelude with an exact trusted package activation set. */
- readonly packages?: readonly NodePackageActivation[];
-};
-
-export function officialNodePackages(
- packages?: readonly NodePackageActivation[],
-): readonly NodePackageActivation[] {
- return packages ?? [videoPrelude];
-}
-
-/** The CLI names only an ordinary replaceable prelude; no domain package is registered here. */
-export function createOfficialNodeCompiler(options: OfficialCompilerOptions = {}): NodeCompiler {
- return createActivatedNodeCompiler(officialNodePackages(options.packages), {
- ...(options.root === undefined ? {} : { root: options.root }),
- });
-}
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index b8415eed..a5914a6f 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -1,4 +1,6 @@
-export { createOfficialNodeCompiler } from "./host.js";
-export type { OfficialCompilerOptions } from "./host.js";
export { materializeArtifact, materializeRecord } from "./archive.js";
export { runCli } from "./main.js";
+export type {
+ CliCompilerOptions,
+ CliDistribution,
+} from "./distribution.js";
diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts
index e924a088..5ea08da7 100644
--- a/packages/cli/src/main.ts
+++ b/packages/cli/src/main.ts
@@ -14,7 +14,6 @@ import {
writeNodePackageLock,
} from "@svml/package-loader-node";
-import { createOfficialNodeCompiler, officialNodePackages } from "./host.js";
import {
collectArtifacts,
findArchivedArtifact,
@@ -25,7 +24,7 @@ import {
summarizeBuildCatalog,
} from "./archive.js";
import { loadRunFile } from "./run-file.js";
-import { createOfficialRuntimeFromConfig } from "./runtime-config.js";
+import type { CliDistribution } from "./distribution.js";
type CliIo = {
readonly write: (text: string) => void;
@@ -259,8 +258,8 @@ function createCatalogDescriptor(options: {
};
}
-async function loadLocalRuntime(path: string): Promise<LocalRuntime> {
- if (extname(path) === ".json") return await createOfficialRuntimeFromConfig(path);
+async function loadLocalRuntime(path: string, distribution: CliDistribution): Promise<LocalRuntime> {
+ if (extname(path) === ".json") return await distribution.createRuntimeFromConfig(path);
// A Runtime config is trusted executable deployment code, never an Author Frontend or .svml import.
const imported = await import(pathToFileURL(path).href) as {
readonly default?: unknown;
@@ -275,7 +274,11 @@ async function loadLocalRuntime(path: string): Promise<LocalRuntime> {
return candidate;
}
-export async function runCli(argv: readonly string[], io: CliIo): Promise<void> {
+export async function runCli(
+ argv: readonly string[],
+ io: CliIo,
+ distribution: CliDistribution,
+): Promise<void> {
const args = parseArgs(argv);
const known = args.command === "lock-packages" || args.command === "check" || args.command === "plan"
|| args.command === "build" || args.command === "status" || args.command === "builds"
@@ -305,7 +308,7 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<void>
if (args.command === "status" || args.command === "builds" || args.command === "inspect"
|| args.command === "get" || args.command === "cancel") {
if (args.runtime === undefined) throw new Error(`${args.command} requires --runtime`);
- const runtime = await loadLocalRuntime(args.runtime);
+ const runtime = await loadLocalRuntime(args.runtime, distribution);
try {
if (args.command === "builds") {
const entries = await runtime.builds();
@@ -425,30 +428,30 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<void>
if (runMode && (args.targets.length > 0 || args.substitute || args.pins.length > 0)) {
throw new Error(".svrun owns Targets, Candidate selections and fidelity; do not combine it with --target, --pin or --accept-substitute");
}
- const activated = args.packageLock === undefined
+ const loadedPackageSet = args.packageLock === undefined
? undefined
: await loadNodePackageSet(args.packageLock, args.root ?? dirname(args.packageLock));
- const packages = officialNodePackages(activated?.packages);
- const compiler = createOfficialNodeCompiler({
+ const packageContributions = loadedPackageSet?.contributions ?? distribution.builtInPackageContributions;
+ const compiler = distribution.createCompiler({
...(args.root === undefined ? {} : { root: args.root }),
- packages,
+ packageContributions,
});
if (args.command === "check") {
let runtime: LocalRuntime | undefined;
try {
- runtime = args.runtime === undefined ? undefined : await loadLocalRuntime(args.runtime);
+ runtime = args.runtime === undefined ? undefined : await loadLocalRuntime(args.runtime, distribution);
if (runMode) {
const loaded = await loadRunFile({
path: args.file!,
compiler,
- packages,
+ packageContributions,
...(runtime === undefined ? {} : { runtime }),
});
const planned = compiler.planCompilation(loaded.compilation, {
targets: loaded.run.targets,
satisfactions: loaded.run.satisfactions,
realizations: loaded.run.graphs,
- ...(activated === undefined ? {} : { implementationClosure: activated.lock.digest }),
+ ...(loadedPackageSet === undefined ? {} : { implementationClosure: loadedPackageSet.lock.digest }),
});
io.write(`${JSON.stringify({
ok: true,
@@ -482,23 +485,23 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<void>
}
if (args.command === "build") {
if (args.runtime === undefined) throw new Error("build requires --runtime with a Runtime Profile or trusted local config module");
- const runtime = await loadLocalRuntime(args.runtime);
+ const runtime = await loadLocalRuntime(args.runtime, distribution);
try {
const planOptions = {
targets: args.targets,
accepts: args.substitute ? "substitute" as const : "exact" as const,
- ...(activated === undefined ? {} : { implementationClosure: activated.lock.digest }),
+ ...(loadedPackageSet === undefined ? {} : { implementationClosure: loadedPackageSet.lock.digest }),
};
let pinSummary: readonly { readonly output: string; readonly build: string; readonly candidate: string }[] = [];
const loadedRun = runMode
- ? await loadRunFile({ path: args.file!, compiler, packages, runtime })
+ ? await loadRunFile({ path: args.file!, compiler, packageContributions, runtime })
: undefined;
const result = loadedRun !== undefined
? compiler.planCompilation(loadedRun.compilation, {
targets: loadedRun.run.targets,
satisfactions: loadedRun.run.satisfactions,
realizations: loadedRun.run.graphs,
- ...(activated === undefined ? {} : { implementationClosure: activated.lock.digest }),
+ ...(loadedPackageSet === undefined ? {} : { implementationClosure: loadedPackageSet.lock.digest }),
})
: args.pins.length === 0
? await compiler.planFile(args.file!, planOptions)
@@ -579,26 +582,26 @@ export async function runCli(argv: readonly string[], io: CliIo): Promise<void>
}
let runtime: LocalRuntime | undefined;
try {
- runtime = args.runtime === undefined ? undefined : await loadLocalRuntime(args.runtime);
+ runtime = args.runtime === undefined ? undefined : await loadLocalRuntime(args.runtime, distribution);
const result = runMode
? await (async () => {
const loaded = await loadRunFile({
path: args.file!,
compiler,
- packages,
+ packageContributions,
...(runtime === undefined ? {} : { runtime }),
});
return compiler.planCompilation(loaded.compilation, {
targets: loaded.run.targets,
satisfactions: loaded.run.satisfactions,
realizations: loaded.run.graphs,
- ...(activated === undefined ? {} : { implementationClosure: activated.lock.digest }),
+ ...(loadedPackageSet === undefined ? {} : { implementationClosure: loadedPackageSet.lock.digest }),
});
})()
: await compiler.planFile(args.file!, {
targets: args.targets,
accepts: args.substitute ? "substitute" : "exact",
- ...(activated === undefined ? {} : { implementationClosure: activated.lock.digest }),
+ ...(loadedPackageSet === undefined ? {} : { implementationClosure: loadedPackageSet.lock.digest }),
});
io.write(`${JSON.stringify(result.plan, null, 2)}\n`);
} finally {
diff --git a/packages/cli/src/run-file.ts b/packages/cli/src/run-file.ts
index 463f9963..60aeee5d 100644
--- a/packages/cli/src/run-file.ts
+++ b/packages/cli/src/run-file.ts
@@ -3,7 +3,7 @@ import { dirname, resolve } from "node:path";
import type { NodeCompiler, NodeCompiledSourceClosure } from "@svml/compiler-node";
import type { LocalRuntime } from "@svml/local";
-import type { NodePackageActivation } from "@svml/package-loader-node";
+import type { NodePackageContribution } from "@svml/package-loader-node";
import {
parseRunDocument,
resolveRunDocument,
@@ -22,7 +22,7 @@ export type LoadedRunFile = {
export async function loadRunFile(options: {
readonly path: string;
readonly compiler: NodeCompiler;
- readonly packages: readonly NodePackageActivation[];
+ readonly packageContributions: readonly NodePackageContribution[];
readonly runtime?: Pick<LocalRuntime, "status">;
}): Promise<LoadedRunFile> {
const path = resolve(options.path);
@@ -31,7 +31,7 @@ export async function loadRunFile(options: {
const source = resolve(directory, document.source);
const compilation = await options.compiler.compileFile(source);
const fragments = new RunFragmentRegistry();
- for (const item of options.packages) {
+ for (const item of options.packageContributions) {
if (item.runFragments === undefined || Object.keys(item.runFragments).length === 0) continue;
fragments.register({ name: item.name, fragments: item.runFragments });
}
diff --git a/packages/compiler-text-node/README.md b/packages/compiler-text-node/README.md
new file mode 100644
index 00000000..416f3cda
--- /dev/null
+++ b/packages/compiler-text-node/README.md
@@ -0,0 +1,11 @@
+# `@svml/compiler-text-node`
+
+Reference Node compiler assembly for the official `@svml/text` authoring language.
+
+The package selects the Text Frontend ABI, installs Text Surface Host facets from already trusted
+package contributions, and combines them with the syntax-neutral `@svml/compiler-node`. It does not
+discover packages, grant Runtime authority or know any video component by name.
+
+Use `@svml/compiler-node` directly for another entry Frontend. Use
+`@svml/package-loader-node` independently when a Runtime only needs locked deterministic compute
+facets and no author syntax.
diff --git a/packages/compiler-text-node/package.json b/packages/compiler-text-node/package.json
new file mode 100644
index 00000000..576ad271
--- /dev/null
+++ b/packages/compiler-text-node/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "@svml/compiler-text-node",
+ "version": "0.0.0-dev",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "dependencies": {
+ "@svml/compiler-node": "workspace:*",
+ "@svml/component-kit": "workspace:*",
+ "@svml/elaborator": "workspace:*",
+ "@svml/host": "workspace:*",
+ "@svml/package-loader-node": "workspace:*",
+ "@svml/text": "workspace:*",
+ "@svml/validation": "workspace:*"
+ },
+ "devDependencies": {
+ "@svml/protocol": "workspace:*"
+ }
+}
diff --git a/packages/compiler-text-node/src/index.ts b/packages/compiler-text-node/src/index.ts
new file mode 100644
index 00000000..b92767fa
--- /dev/null
+++ b/packages/compiler-text-node/src/index.ts
@@ -0,0 +1,67 @@
+import { registerTypeValidatorFacets } from "@svml/component-kit";
+import {
+ ModulePackageRegistry,
+ NodeCompiler,
+} from "@svml/compiler-node";
+import { AuthorFrontendRegistry } from "@svml/elaborator";
+import type { Workspace } from "@svml/host";
+import {
+ assertNodePackageContribution,
+ collectNodePackageComponents,
+} from "@svml/package-loader-node";
+import type { NodePackageContribution } from "@svml/package-loader-node";
+import {
+ createTextAuthorFrontend,
+ installTextSurfaceHostFacets,
+ TextSurfaceRegistry,
+ textAuthorFrontendId,
+} from "@svml/text";
+import { TypeValidatorRegistry } from "@svml/validation";
+
+export type CreateTextNodeCompilerOptions = {
+ readonly root?: string;
+ readonly workspace?: Workspace;
+};
+
+/** Assemble the official Text authoring environment from already trusted package facets. */
+export function createTextNodeCompiler(
+ packages: readonly NodePackageContribution[],
+ options: CreateTextNodeCompilerOptions = {},
+): NodeCompiler {
+ const names = new Set<string>();
+ const modules = new ModulePackageRegistry();
+ const surfaces = new TextSurfaceRegistry();
+ const frontends = new AuthorFrontendRegistry();
+ const validators = new TypeValidatorRegistry();
+
+ for (const item of packages) {
+ assertNodePackageContribution(item);
+ if (names.has(item.name)) throw new Error(`Node package contribution ${item.name} is listed twice`);
+ names.add(item.name);
+ for (const module of item.modules ?? []) modules.register(module);
+ installTextSurfaceHostFacets(item.hostFacets ?? [], surfaces);
+ for (const frontend of item.frontends ?? []) frontends.register(frontend);
+ }
+
+ for (const component of collectNodePackageComponents(packages)) {
+ registerTypeValidatorFacets(validators, component.validators ?? []);
+ }
+
+ frontends.register(createTextAuthorFrontend({
+ registry: surfaces,
+ resolveModule(request) {
+ const resolved = modules.resolve(request.from);
+ if (resolved === undefined) throw new Error(`No selected author package satisfies ${request.from}`);
+ return resolved;
+ },
+ }));
+
+ return new NodeCompiler({
+ modules,
+ frontends,
+ validators,
+ entryFrontend: textAuthorFrontendId,
+ ...(options.root === undefined ? {} : { root: options.root }),
+ ...(options.workspace === undefined ? {} : { workspace: options.workspace }),
+ });
+}
diff --git a/packages/compiler-text-node/test/compiler.test.ts b/packages/compiler-text-node/test/compiler.test.ts
new file mode 100644
index 00000000..ad3dd8b8
--- /dev/null
+++ b/packages/compiler-text-node/test/compiler.test.ts
@@ -0,0 +1,92 @@
+import assert from "node:assert/strict";
+import {
+ mkdtemp,
+ rm,
+ writeFile,
+} from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import test from "node:test";
+
+import { createTextNodeCompiler } from "@svml/compiler-text-node";
+import type { NodePackageContribution } from "@svml/package-loader-node";
+import { digestOf } from "@svml/protocol";
+import { createTextSurfaceHostFacet } from "@svml/text";
+
+const module = { name: "example.card", version: "1" } as const;
+const resultType = { module, name: "CardResult" } as const;
+const implementationDigest = digestOf("example.card/card-surface@1");
+
+const installedPackage: NodePackageContribution = {
+ format: "svml.node-package@1",
+ name: "example-card",
+ modules: [{
+ manifest: {
+ format: "svml.module@0",
+ name: module.name,
+ version: module.version,
+ dependencies: [],
+ types: [{ name: resultType.name, schema: { kind: "string", minLength: 1 } }],
+ capabilities: [],
+ surfaces: [{
+ name: "card",
+ tag: "Card",
+ mode: "structured",
+ outputs: [resultType],
+ implementation: {
+ kind: "trusted-frontend-surface",
+ locator: "example.card/card",
+ digest: implementationDigest,
+ },
+ }],
+ producers: [],
+ },
+ specifiers: ["example.card@1"],
+ }],
+ hostFacets: [
+ createTextSurfaceHostFacet({
+ module,
+ surface: "card",
+ mode: "structured",
+ implementationDigest,
+ handler({ element }) {
+ return {
+ records: [{
+ id: "card-result",
+ type: resultType,
+ value: { kind: "inline", value: "accepted" },
+ range: element.range,
+ }],
+ components: [],
+ fragments: [],
+ };
+ },
+ }),
+ {
+ abi: "example.unselected-host@1",
+ identity: { name: "must-remain-inert" },
+ implementation() {
+ throw new Error("an unselected Host facet executed");
+ },
+ },
+ ],
+};
+
+test("Text compiler alone selects Text Surface Host facets from a generic package contribution", async () => {
+ const root = await mkdtemp(join(tmpdir(), "svml-text-compiler-"));
+ try {
+ const source = join(root, "main.svml");
+ await writeFile(source, `<svml>
+ <import as="example" from="example.card@1"/>
+ <example:Card/>
+ </svml>`, "utf8");
+ const compiler = createTextNodeCompiler([installedPackage], { root });
+ const result = await compiler.compileFile(source);
+
+ assert.deepEqual(result.program.closure.modules.map((item) => item.ref), [module]);
+ assert.equal(result.module.records[0]?.value.kind, "inline");
+ assert.equal(result.elaboration.graph.operations.length, 0);
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
diff --git a/packages/contracts/README.md b/packages/contracts/README.md
index e32ab5c0..126c1bf8 100644
--- a/packages/contracts/README.md
+++ b/packages/contracts/README.md
@@ -14,6 +14,10 @@ and may later become `@svml/video` without changing those logical identities. Th
contains Provider- and Frontend-neutral data contracts, identity validators and static schemas
only. It does not parse SVML, execute external services, align speech or render Tracks.
+The domain-neutral `BlobArtifact` owner is `@svml/artifact`, not `@svml/media`. This video
+distribution depends on that module and re-exports its symbols only as a migration convenience;
+video packages that put byte Artifacts on Graph edges declare the Artifact dependency directly.
+
The Narrative module provides distinct narrow views instead of making every consumer depend on one
parser-specific object: `NarrativeExcerpt` associates a Take with a Segment,
`NarrativeDialogueExcerpt` carries Role-aware spoken prompt text,
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index bfa721bc..08d3d880 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/artifact": "workspace:*",
"@svml/component-kit": "workspace:*",
"@svml/protocol": "workspace:*"
},
diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts
index 4ae6ef34..64c93d06 100644
--- a/packages/contracts/src/index.ts
+++ b/packages/contracts/src/index.ts
@@ -1,3 +1,10 @@
+export {
+ artifactManifest,
+ artifactManifestDigest,
+ artifactModuleRef,
+ artifactTypes,
+ blobArtifactValueSchema,
+} from "@svml/artifact";
export {
assertProgramSpaceIdentity,
assertSpeechDurationIdentity,
@@ -73,8 +80,8 @@ export {
speechModuleRef,
videoContractDependencies,
videoContractManifests,
+ videoDomainManifests,
mediaArtifactSchema,
- blobArtifactValueSchema,
mediaInspectionSchema,
mediaStreamSelectionSchema,
muxedMediaSchema,
diff --git a/packages/contracts/src/manifest.ts b/packages/contracts/src/manifest.ts
index fee8c6ca..737bd6e4 100644
--- a/packages/contracts/src/manifest.ts
+++ b/packages/contracts/src/manifest.ts
@@ -1,3 +1,9 @@
+import {
+ artifactDependency,
+ artifactManifest,
+ artifactTypes,
+ blobArtifactValueSchema,
+} from "@svml/artifact";
import { digestOf } from "@svml/protocol";
import type { ModuleManifest, TypeRef, ValueSchema } from "@svml/protocol";
@@ -21,7 +27,7 @@ export const contractTypes = {
narrativeSpeechExcerpt: { module: narrativeModuleRef, name: "NarrativeSpeechExcerpt" },
narrativeSelection: { module: narrativeModuleRef, name: "NarrativeSelection" },
captionProjection: { module: narrativeModuleRef, name: "CaptionProjection" },
- blobArtifact: { module: mediaModuleRef, name: "BlobArtifact" },
+ blobArtifact: artifactTypes.blob,
mediaArtifact: { module: mediaModuleRef, name: "MediaArtifactRef" },
mediaInspection: { module: mediaModuleRef, name: "MediaInspection" },
mediaStreamSelection: { module: mediaModuleRef, name: "MediaStreamSelection" },
@@ -186,8 +192,6 @@ const blobArtifactSchema = (mediaTypes?: readonly string[]): ValueSchema => obje
size: { schema: integer },
mediaType: { schema: mediaTypes === undefined ? string : { kind: "string", enum: mediaTypes } },
});
-export const blobArtifactValueSchema: ValueSchema = { kind: "blob" };
-
const mediaRationalSchema = object({
numerator: { schema: { kind: "number", integer: true, minimum: 1 } },
denominator: { schema: { kind: "number", integer: true, minimum: 1 } },
@@ -630,9 +634,8 @@ export const mediaManifest: ModuleManifest = {
format: "svml.module@0",
name: mediaModuleRef.name,
version: mediaModuleRef.version,
- dependencies: [],
+ dependencies: [artifactDependency],
types: [
- { name: contractTypes.blobArtifact.name, schema: blobArtifactValueSchema },
{ name: contractTypes.mediaArtifact.name, schema: mediaArtifactSchema },
{
name: contractTypes.mediaInspection.name,
@@ -839,7 +842,7 @@ export const compositionManifest: ModuleManifest = {
export const semanticTimeManifestDigest = digestOf(semanticTimeManifest);
export const compositionManifestDigest = digestOf(compositionManifest);
-export const videoContractManifests = [
+export const videoDomainManifests = [
narrativeManifest,
mediaManifest,
programSpaceManifest,
@@ -848,6 +851,12 @@ export const videoContractManifests = [
compositionManifest,
] as const;
+/** Complete Manifest set required to instantiate the video-domain contracts. */
+export const videoContractManifests = [
+ artifactManifest,
+ ...videoDomainManifests,
+] as const;
+
export const videoContractDependencies = {
narrative: { module: narrativeModuleRef, digest: narrativeManifestDigest },
media: { module: mediaModuleRef, digest: mediaManifestDigest },
diff --git a/packages/contracts/test/manifest.test.ts b/packages/contracts/test/manifest.test.ts
index 93e50b6c..e611bfe9 100644
--- a/packages/contracts/test/manifest.test.ts
+++ b/packages/contracts/test/manifest.test.ts
@@ -8,11 +8,11 @@ import {
contractTypes,
narrativeManifest,
narrativeManifestDigest,
- videoContractManifests,
+ videoDomainManifests,
} from "../src/index.js";
test("the physical video distribution carries six independently identified logical modules", () => {
- assert.deepEqual(videoContractManifests.map((manifest) => manifest.name), [
+ assert.deepEqual(videoDomainManifests.map((manifest) => manifest.name), [
"@svml/narrative",
"@svml/media",
"@svml/program-space",
@@ -20,7 +20,7 @@ test("the physical video distribution carries six independently identified logic
"@svml/semantic-time",
"@svml/composition",
]);
- assert.equal(new Set(videoContractManifests.map((manifest) => digestOf(manifest))).size, 6);
+ assert.equal(new Set(videoDomainManifests.map((manifest) => digestOf(manifest))).size, 6);
assert.equal(narrativeManifestDigest, digestOf(narrativeManifest));
});
diff --git a/packages/generation/package.json b/packages/generation/package.json
index 1def7e89..c092db96 100644
--- a/packages/generation/package.json
+++ b/packages/generation/package.json
@@ -7,8 +7,8 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/artifact": "workspace:*",
"@svml/component-kit": "workspace:*",
- "@svml/contracts": "workspace:*",
"@svml/protocol": "workspace:*"
},
"devDependencies": {
diff --git a/packages/generation/src/manifest.ts b/packages/generation/src/manifest.ts
index dd6735f8..5d7dadec 100644
--- a/packages/generation/src/manifest.ts
+++ b/packages/generation/src/manifest.ts
@@ -1,7 +1,7 @@
import {
- contractTypes,
- videoContractDependencies,
-} from "@svml/contracts";
+ artifactDependency,
+ artifactTypes,
+} from "@svml/artifact";
import { digestOf } from "@svml/protocol";
import type { ModuleManifest, ProducerRef, TypeRef } from "@svml/protocol";
@@ -32,7 +32,7 @@ export const generationManifest: ModuleManifest = {
format: "svml.module@0",
name: generationModuleRef.name,
version: generationModuleRef.version,
- dependencies: [videoContractDependencies.media],
+ dependencies: [artifactDependency],
types: [
{
name: generationTypes.imageSet.name,
@@ -67,7 +67,7 @@ export const generationManifest: ModuleManifest = {
inputs: [{ name: "set", type: generationTypes.imageSet }],
outputs: [{
name: "image",
- type: contractTypes.blobArtifact,
+ type: artifactTypes.blob,
affinity: [{ resultPointer: "/digest", input: "set", inputPointer: "/images/0/digest" }],
}],
needs: [],
@@ -82,7 +82,7 @@ export const generationManifest: ModuleManifest = {
inputs: [{ name: "set", type: generationTypes.videoSet }],
outputs: [{
name: "video",
- type: contractTypes.blobArtifact,
+ type: artifactTypes.blob,
affinity: [{ resultPointer: "/digest", input: "set", inputPointer: "/videos/0/digest" }],
}],
needs: [],
diff --git a/packages/host/src/facet.ts b/packages/host/src/facet.ts
new file mode 100644
index 00000000..8c7dfd12
--- /dev/null
+++ b/packages/host/src/facet.ts
@@ -0,0 +1,13 @@
+import type { CanonicalValue } from "@svml/protocol";
+
+/**
+ * One executable package facet understood by an exact Host ABI.
+ *
+ * Package loading binds the ABI and canonical identity without interpreting the implementation.
+ * Only the selected Host may validate and install the opaque implementation value.
+ */
+export type HostFacet = {
+ readonly abi: string;
+ readonly identity: CanonicalValue;
+ readonly implementation: unknown;
+};
diff --git a/packages/host/src/index.ts b/packages/host/src/index.ts
index bcb8e6af..6fd2a022 100644
--- a/packages/host/src/index.ts
+++ b/packages/host/src/index.ts
@@ -6,6 +6,8 @@ import type {
} from "@svml/elaborator";
import type { BlobRef } from "@svml/protocol";
+export type { HostFacet } from "./facet.js";
+
/** Host transfer bytes. Their origin is deliberately absent from the Runtime contract. */
export type ArtifactAttachment = {
readonly artifact: BlobRef;
diff --git a/packages/local/README.md b/packages/local/README.md
index 32f3b0f6..5e29145a 100644
--- a/packages/local/README.md
+++ b/packages/local/README.md
@@ -14,6 +14,9 @@ The convenience assembly uses:
- an exact implementation package lock for deterministic component packages;
- separately selected external Endpoint packages.
+Package loading is syntax-neutral. The local Runtime activates only locked deterministic Producer
+and Validator facets; it neither depends on `@svml/text` nor installs any package Host facet.
+
Normal CLI projects may express the same assembly as closed data:
```json
diff --git a/packages/local/src/runtime.ts b/packages/local/src/runtime.ts
index c23b4a44..839cf095 100644
--- a/packages/local/src/runtime.ts
+++ b/packages/local/src/runtime.ts
@@ -11,7 +11,7 @@ import {
} from "@svml/driver-node";
import {
loadNodePackageSet,
- nodePackageComponents,
+ collectNodePackageComponents,
} from "@svml/package-loader-node";
import {
LocalBuildScheduler,
@@ -264,7 +264,7 @@ export async function createProjectLocalRuntime(
: await loadNodePackageSet(resolve(root, options.packageLock), root);
const lockedComponents = lockedPackageSet === undefined
? []
- : nodePackageComponents(lockedPackageSet.packages);
+ : collectNodePackageComponents(lockedPackageSet.contributions);
const configuredComponents = [...lockedComponents, ...(options.components ?? [])];
const projectServices = await createProjectRuntimeServices(root, options);
const services = projectServices.assembly;
diff --git a/packages/local/test/local.test.ts b/packages/local/test/local.test.ts
index f3b5193b..cbcc7594 100644
--- a/packages/local/test/local.test.ts
+++ b/packages/local/test/local.test.ts
@@ -162,7 +162,7 @@ test("project local runtime resumes durable work while component and endpoint pa
components: [components],
endpoints: [endpointPackage],
});
- const first = await firstRuntime.build({ id: "client-video", state: initial, catalog });
+ const first = await firstRuntime.build({ id: "greeting-build", state: initial, catalog });
assert.equal(first.status, "paused");
assert.equal(starts, 1);
assert.equal(resumes, 0);
@@ -173,32 +173,32 @@ test("project local runtime resumes durable work while component and endpoint pa
components: [components],
endpoints: [endpointPackage],
});
- const second = await secondRuntime.build({ id: "client-video", state: createGreetingBuild(), catalog });
+ const second = await secondRuntime.build({ id: "greeting-build", state: createGreetingBuild(), catalog });
assert.equal(second.status, "complete");
assert.equal(starts, 1);
assert.equal(resumes, 1);
assert.equal(promptCalls, 1, "persisted Core facts stop deterministic upstream replay");
assert.equal(requestCalls, 1, "the Need request Producer is also persisted");
assert.equal(assembleCalls, 1);
- const clientStatus = await secondRuntime.status("client-video");
+ const clientStatus = await secondRuntime.status("greeting-build");
assert.equal(clientStatus.catalog?.core, initial.id);
assert.equal(clientStatus.catalog?.aliases[0]?.name, "final.document");
- assert.deepEqual((await secondRuntime.builds()).map((item) => item.build), ["client-video"]);
+ assert.deepEqual((await secondRuntime.builds()).map((item) => item.build), ["greeting-build"]);
const followed = await secondRuntime.build(
- { id: "follow-video", state: createGreetingBuild() },
+ { id: "greeting-follow", state: createGreetingBuild() },
{ follow: true, pollIntervalMs: 1, maxWaitMs: 1_000 },
);
assert.equal(followed.status, "complete");
assert.equal(starts, 2);
assert.equal(resumes, 2);
- const followedStatus = await secondRuntime.status("follow-video");
+ const followedStatus = await secondRuntime.status("greeting-follow");
assert.equal(followedStatus.build?.state.status, "complete");
assert.equal(followedStatus.operations.length, 1);
- const waiting = await secondRuntime.build({ id: "cancel-video", state: createGreetingBuild() });
+ const waiting = await secondRuntime.build({ id: "greeting-cancel", state: createGreetingBuild() });
assert.equal(waiting.status, "paused");
- const cancelled = await secondRuntime.cancel("cancel-video");
+ const cancelled = await secondRuntime.cancel("greeting-cancel");
assert.equal(cancelled?.status, "failed");
assert.equal(cancels, 1);
await secondRuntime.close();
diff --git a/packages/media-pipeline/package.json b/packages/media-pipeline/package.json
index 7b0dacba..cfa4dbed 100644
--- a/packages/media-pipeline/package.json
+++ b/packages/media-pipeline/package.json
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/artifact": "workspace:*",
"@svml/component-kit": "workspace:*",
"@svml/contracts": "workspace:*",
"@svml/elaborator": "workspace:*",
diff --git a/packages/media-pipeline/src/fragment.ts b/packages/media-pipeline/src/fragment.ts
index 63e5f0b6..a336a1ea 100644
--- a/packages/media-pipeline/src/fragment.ts
+++ b/packages/media-pipeline/src/fragment.ts
@@ -1,3 +1,4 @@
+import { artifactTypes } from "@svml/artifact";
import { contractTypes } from "@svml/contracts";
import { sealGraphFragment } from "@svml/elaborator";
@@ -12,7 +13,7 @@ const operation = (id: string) => ({ kind: "fragment-operation" as const, operat
export const synchronizedMediaFragment = sealGraphFragment({
name: "@svml/media-pipeline/synchronized-media@1",
inputs: [
- { name: "source", type: contractTypes.blobArtifact },
+ { name: "source", type: artifactTypes.blob },
{ name: "request", type: mediaPipelineTypes.selectionRequest },
],
operations: [
diff --git a/packages/media-pipeline/src/manifest.ts b/packages/media-pipeline/src/manifest.ts
index 436d2fde..6723c5fb 100644
--- a/packages/media-pipeline/src/manifest.ts
+++ b/packages/media-pipeline/src/manifest.ts
@@ -1,3 +1,4 @@
+import { artifactDependency, artifactTypes } from "@svml/artifact";
import {
contractTypes,
videoContractDependencies,
@@ -132,6 +133,7 @@ export const mediaPipelineManifest: ModuleManifest = {
name: mediaPipelineModuleRef.name,
version: mediaPipelineModuleRef.version,
dependencies: [
+ artifactDependency,
videoContractDependencies.media,
videoContractDependencies.speech,
videoContractDependencies.composition,
@@ -173,7 +175,7 @@ export const mediaPipelineManifest: ModuleManifest = {
producers: [
{
name: mediaPipelineProducers.inspect.name,
- inputs: [{ name: "source", type: contractTypes.blobArtifact }],
+ inputs: [{ name: "source", type: artifactTypes.blob }],
outputs: [],
needs: [{
name: "inspection",
@@ -207,7 +209,7 @@ export const mediaPipelineManifest: ModuleManifest = {
{
name: mediaPipelineProducers.normalize.name,
inputs: [
- { name: "source", type: contractTypes.blobArtifact },
+ { name: "source", type: artifactTypes.blob },
{ name: "inspection", type: contractTypes.mediaInspection },
{ name: "selection", type: contractTypes.mediaStreamSelection },
{ name: "request", type: mediaPipelineTypes.selectionRequest },
diff --git a/packages/media/package.json b/packages/media/package.json
index 1d033fb0..4aa1f913 100644
--- a/packages/media/package.json
+++ b/packages/media/package.json
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/artifact": "workspace:*",
"@svml/contracts": "workspace:*",
"@svml/text": "workspace:*"
}
diff --git a/packages/media/src/surface.ts b/packages/media/src/surface.ts
index e0ea421a..09aafa97 100644
--- a/packages/media/src/surface.ts
+++ b/packages/media/src/surface.ts
@@ -1,6 +1,4 @@
-import {
- contractTypes,
-} from "@svml/contracts";
+import { artifactTypes } from "@svml/artifact";
import type {
StructuredElement,
StructuredSurfaceHandler,
@@ -63,7 +61,7 @@ export const decodeMediaImageSurface: StructuredSurfaceHandler = async ({ elemen
return {
records: [{
id,
- type: contractTypes.blobArtifact,
+ type: artifactTypes.blob,
value: resolved.artifact,
range: element.range,
}],
diff --git a/packages/package-loader-node/README.md b/packages/package-loader-node/README.md
index e7cf2315..58fc967c 100644
--- a/packages/package-loader-node/README.md
+++ b/packages/package-loader-node/README.md
@@ -1,18 +1,17 @@
# `@svml/package-loader-node`
-Trusted installed-package activation for the Node Compiler and deterministic compute Host. One
-package lock binds every selected physical package and declared dependency byte plus Module,
-Frontend, Text Surface, Producer and Type Validator identities. Loading verifies all artifacts and
-checks compute facets against their static Manifests before granting a Host registry.
+Trusted installed-package locking and loading for Node Hosts. One package lock binds every selected
+physical package and declared dependency byte plus Module, Frontend, Host-facet, Producer and Type
+Validator identities. Loading verifies all artifacts and checks deterministic compute facets
+against their static Manifests before returning verified `NodePackageContribution` values.
-The current convenience assembly always installs the official `@svml/text` entry Frontend and Text
-Surface registry. Its lock/verification rules are domain-neutral, but its assembled compiler is a
-Text-authoring Node Host. Core and `@svml/compiler-node` do not require Text; this package must be
-split or named more narrowly before claiming a frontend-neutral public loader.
+This package does not select an author syntax. Syntax-specific executable facets remain inert until
+an exact Host ABI installs them. `@svml/compiler-text-node` selects the official Text Surface ABI;
+`@svml/local` can load the same package's deterministic compute facets without depending on Text.
This package is deliberately not an npm client and does not activate Provider or privileged Runtime
-services. Source `<import>` can select only an already activated author module; trusted deployment
-configuration independently chooses whether to grant author or deterministic compute registries.
+services. Source `<import>` can select only an already installed author contribution; trusted
+deployment configuration independently chooses whether to grant author or deterministic compute registries.
Executable plans bind the package-lock digest as `BuildRequest.implementationClosure`.
```bash
diff --git a/packages/package-loader-node/package.json b/packages/package-loader-node/package.json
index a1f3a0b8..caa7152d 100644
--- a/packages/package-loader-node/package.json
+++ b/packages/package-loader-node/package.json
@@ -12,7 +12,6 @@
"@svml/elaborator": "workspace:*",
"@svml/host": "workspace:*",
"@svml/protocol": "workspace:*",
- "@svml/text": "workspace:*",
"@svml/validation": "workspace:*"
}
}
diff --git a/packages/package-loader-node/src/activation.ts b/packages/package-loader-node/src/contribution.ts
similarity index 56%
rename from packages/package-loader-node/src/activation.ts
rename to packages/package-loader-node/src/contribution.ts
index 9cc0cc98..50b14c4b 100644
--- a/packages/package-loader-node/src/activation.ts
+++ b/packages/package-loader-node/src/contribution.ts
@@ -6,36 +6,30 @@ import type {
ComponentPackage,
ProducerRegistrar,
} from "@svml/component-kit";
-import {
- ModulePackageRegistry,
- NodeCompiler,
-} from "@svml/compiler-node";
+import { ModulePackageRegistry } from "@svml/compiler-node";
import type { RegisteredModulePackage } from "@svml/compiler-node";
-import { AuthorFrontendRegistry } from "@svml/elaborator";
-import type { Workspace } from "@svml/host";
-import { isDigest } from "@svml/protocol";
-import {
- createTextAuthorFrontend,
- TextSurfaceRegistry,
- textAuthorFrontendId,
-} from "@svml/text";
-import { TypeValidatorRegistry } from "@svml/validation";
+import { canonicalize } from "@svml/protocol";
import type { TypeValidatorRegistrar } from "@svml/validation";
-import type { NodePackageActivation } from "./types.js";
-
-export type CreateActivatedNodeCompilerOptions = {
- readonly root?: string;
- readonly workspace?: Workspace;
-};
+import type { NodePackageContribution } from "./types.js";
-function assertPackage(value: NodePackageActivation): void {
+function assertPackage(value: NodePackageContribution): void {
if (value.format !== "svml.node-package@1") {
throw new Error(`${value.name || "Node package"} has an unsupported format`);
}
if (value.name.trim().length === 0) throw new Error("Node package name must not be empty");
+ const hostFacets = new Set<string>();
+ for (const facet of value.hostFacets ?? []) {
+ if (facet.abi.trim().length === 0) throw new Error(`${value.name} has an empty Host facet ABI`);
+ const identity = canonicalize(facet.identity);
+ const key = `${facet.abi}:${JSON.stringify(identity)}`;
+ if (hostFacets.has(key)) throw new Error(`${value.name} repeats Host facet ${facet.abi}`);
+ hostFacets.add(key);
+ }
}
+export { assertPackage as assertNodePackageContribution };
+
function facetKey(
ref: { readonly module: { readonly name: string; readonly version: string }; readonly name: string },
): string {
@@ -43,8 +37,8 @@ function facetKey(
}
/** Verify package-local facet identities before any Host registry receives executable handlers. */
-export function nodePackageComponents(
- packages: readonly NodePackageActivation[],
+export function collectNodePackageComponents(
+ packages: readonly NodePackageContribution[],
): readonly ComponentPackage[] {
const packageNames = new Set<string>();
const moduleRegistry = new ModulePackageRegistry();
@@ -54,7 +48,7 @@ export function nodePackageComponents(
const validators = new Set<string>();
for (const item of packages) {
assertPackage(item);
- if (packageNames.has(item.name)) throw new Error(`Node package ${item.name} is activated twice`);
+ if (packageNames.has(item.name)) throw new Error(`Node package contribution ${item.name} is listed twice`);
packageNames.add(item.name);
for (const module of item.modules ?? []) {
const key = `${module.manifest.name}@${module.manifest.version}`;
@@ -99,75 +93,13 @@ export function nodePackageComponents(
return [...components.values()];
}
-export function activateNodeComponents(
- packages: readonly NodePackageActivation[],
+export function installNodePackageComponents(
+ packages: readonly NodePackageContribution[],
producers: ProducerRegistrar,
validators: TypeValidatorRegistrar,
): void {
- for (const component of nodePackageComponents(packages)) {
+ for (const component of collectNodePackageComponents(packages)) {
registerTypeValidatorFacets(validators, component.validators ?? []);
registerProducerFacets(producers, component.producers ?? []);
}
}
-
-/** Assemble already trusted author facets without knowing any domain component by name. */
-export function createActivatedNodeCompiler(
- packages: readonly NodePackageActivation[],
- options: CreateActivatedNodeCompilerOptions = {},
-): NodeCompiler {
- const names = new Set<string>();
- const modules = new ModulePackageRegistry();
- const surfaces = new TextSurfaceRegistry();
- const frontends = new AuthorFrontendRegistry();
- const validators = new TypeValidatorRegistry();
-
- for (const item of packages) {
- assertPackage(item);
- if (names.has(item.name)) throw new Error(`Node package ${item.name} is activated twice`);
- names.add(item.name);
- for (const module of item.modules ?? []) modules.register(module);
- for (const surface of item.textSurfaces ?? []) {
- if (!isDigest(surface.implementationDigest)) {
- throw new Error(`${item.name} Surface ${surface.surface} has an invalid implementation digest`);
- }
- if (surface.mode === "raw") {
- surfaces.registerRaw(
- surface.module,
- surface.surface,
- surface.implementationDigest,
- surface.handler,
- );
- } else {
- surfaces.registerStructured(
- surface.module,
- surface.surface,
- surface.implementationDigest,
- surface.handler,
- );
- }
- }
- for (const frontend of item.frontends ?? []) frontends.register(frontend);
- }
-
- for (const component of nodePackageComponents(packages)) {
- registerTypeValidatorFacets(validators, component.validators ?? []);
- }
-
- frontends.register(createTextAuthorFrontend({
- registry: surfaces,
- resolveModule(request) {
- const resolved = modules.resolve(request.from);
- if (resolved === undefined) throw new Error(`No activated author package satisfies ${request.from}`);
- return resolved;
- },
- }));
-
- return new NodeCompiler({
- modules,
- frontends,
- validators,
- entryFrontend: textAuthorFrontendId,
- ...(options.root === undefined ? {} : { root: options.root }),
- ...(options.workspace === undefined ? {} : { workspace: options.workspace }),
- });
-}
diff --git a/packages/package-loader-node/src/index.ts b/packages/package-loader-node/src/index.ts
index a632d7bf..c1563144 100644
--- a/packages/package-loader-node/src/index.ts
+++ b/packages/package-loader-node/src/index.ts
@@ -1,13 +1,12 @@
export {
- activateNodeComponents,
- createActivatedNodeCompiler,
- nodePackageComponents,
-} from "./activation.js";
-export type { CreateActivatedNodeCompilerOptions } from "./activation.js";
+ assertNodePackageContribution,
+ collectNodePackageComponents,
+ installNodePackageComponents,
+} from "./contribution.js";
export {
createNodePackageLock,
loadNodePackageSet,
- loadNodePackages,
+ loadNodePackageContributions,
writeNodePackageLock,
} from "./lock.js";
export type * from "./types.js";
diff --git a/packages/package-loader-node/src/lock.ts b/packages/package-loader-node/src/lock.ts
index 5efdd5f3..f0a6af17 100644
--- a/packages/package-loader-node/src/lock.ts
+++ b/packages/package-loader-node/src/lock.ts
@@ -19,12 +19,12 @@ import { pathToFileURL } from "node:url";
import { digestOf, isDigest } from "@svml/protocol";
-import { nodePackageComponents } from "./activation.js";
+import { collectNodePackageComponents } from "./contribution.js";
import type {
LockedNodePackage,
LockedPackageArtifact,
LoadedNodePackageSet,
- NodePackageActivation,
+ NodePackageContribution,
NodePackageLock,
} from "./types.js";
@@ -180,9 +180,9 @@ function activationPath(item: ResolvedPhysicalPackage): string {
return target;
}
-function activationMetadata(value: NodePackageActivation): unknown {
- assert(value.format === "svml.node-package@1", "Node package activation has an unsupported format");
- assert(value.name.trim().length > 0, "Node package activation name is empty");
+function contributionMetadata(value: NodePackageContribution): unknown {
+ assert(value.format === "svml.node-package@1", "Node package contribution has an unsupported format");
+ assert(value.name.trim().length > 0, "Node package contribution name is empty");
return {
format: value.format,
name: value.name,
@@ -194,14 +194,11 @@ function activationMetadata(value: NodePackageActivation): unknown {
id: item.id,
implementationDigest: item.implementationDigest,
})).sort((left, right) => left.id.localeCompare(right.id)),
- textSurfaces: [...(value.textSurfaces ?? [])].map((item) => ({
- module: item.module,
- surface: item.surface,
- mode: item.mode,
- implementationDigest: item.implementationDigest,
+ hostFacets: [...(value.hostFacets ?? [])].map((item) => ({
+ abi: item.abi,
+ identity: item.identity,
})).sort((left, right) =>
- `${left.module.name}@${left.module.version}#${left.surface}`
- .localeCompare(`${right.module.name}@${right.module.version}#${right.surface}`),
+ `${left.abi}:${digestOf(left.identity)}`.localeCompare(`${right.abi}:${digestOf(right.identity)}`),
),
components: [...(value.components ?? [])].map((component) => ({
name: component.name,
@@ -226,7 +223,7 @@ function activationMetadata(value: NodePackageActivation): unknown {
};
}
-async function importActivation(item: ResolvedPhysicalPackage): Promise<NodePackageActivation> {
+async function importContribution(item: ResolvedPhysicalPackage): Promise<NodePackageContribution> {
const target = activationPath(item);
assert((await stat(target)).isFile(), `${item.json.name} activation is not a file`);
const imported = await import(pathToFileURL(target).href) as {
@@ -235,11 +232,11 @@ async function importActivation(item: ResolvedPhysicalPackage): Promise<NodePack
};
const value = imported.default ?? imported.svmlPackage;
assert(value !== null && typeof value === "object", `${item.json.name} activation exports no package`);
- const activation = value as NodePackageActivation;
- assert(activation.name === item.json.name,
- `${item.json.name} activation claims physical package ${activation.name}`);
- nodePackageComponents([activation]);
- return activation;
+ const contribution = value as NodePackageContribution;
+ assert(contribution.name === item.json.name,
+ `${item.json.name} activation claims physical package ${contribution.name}`);
+ collectNodePackageComponents([contribution]);
+ return contribution;
}
function lockContent(lock: Omit<NodePackageLock, "digest">): Omit<NodePackageLock, "digest"> {
@@ -317,11 +314,11 @@ export async function createNodePackageLock(
const packages: LockedNodePackage[] = [];
for (const specifier of unique) {
const physical = await resolvePhysicalPackage(specifier, root);
- const activation = await importActivation(physical);
+ const contribution = await importContribution(physical);
packages.push({
specifier,
package: { name: physical.json.name, version: physical.json.version },
- facetsDigest: digestOf(activationMetadata(activation)),
+ facetsDigest: digestOf(contributionMetadata(contribution)),
});
}
return sealLock({
@@ -346,22 +343,22 @@ export async function loadNodePackageSet(
const artifacts = await resolvedArtifacts(closure);
assert(sameArtifacts(artifacts, lock.artifacts), "installed Node package bytes do not match the lock");
const byName = new Map(closure.map((item) => [`${item.json.name}@${item.json.version}`, item]));
- const values: NodePackageActivation[] = [];
+ const values: NodePackageContribution[] = [];
for (const expected of lock.packages) {
const physical = byName.get(`${expected.package.name}@${expected.package.version}`);
assert(physical !== undefined, `${expected.package.name}@${expected.package.version} is not installed`);
assert(physical.json.name === expected.specifier, `${expected.specifier} resolved to another package`);
- const activation = await importActivation(physical);
- assert(digestOf(activationMetadata(activation)) === expected.facetsDigest,
+ const contribution = await importContribution(physical);
+ assert(digestOf(contributionMetadata(contribution)) === expected.facetsDigest,
`${expected.specifier} facets do not match the lock`);
- values.push(activation);
+ values.push(contribution);
}
- return { lock, packages: values };
+ return { lock, contributions: values };
}
-export async function loadNodePackages(
+export async function loadNodePackageContributions(
path: string,
root = dirname(resolve(path)),
-): Promise<readonly NodePackageActivation[]> {
- return (await loadNodePackageSet(path, root)).packages;
+): Promise<readonly NodePackageContribution[]> {
+ return (await loadNodePackageSet(path, root)).contributions;
}
diff --git a/packages/package-loader-node/src/types.ts b/packages/package-loader-node/src/types.ts
index beca91ea..ca41e854 100644
--- a/packages/package-loader-node/src/types.ts
+++ b/packages/package-loader-node/src/types.ts
@@ -2,39 +2,21 @@ import type { RegisteredModulePackage } from "@svml/compiler-node";
import type { ComponentPackage } from "@svml/component-kit";
import type { AuthorFrontend } from "@svml/elaborator";
import type { GraphFragment } from "@svml/elaborator";
-import type { Digest, ModuleRef } from "@svml/protocol";
-import type {
- RawSurfaceHandler,
- StructuredSurfaceHandler,
-} from "@svml/text";
-
-export type NodeTextSurfaceFacet =
- | {
- readonly module: ModuleRef;
- readonly surface: string;
- readonly mode: "raw";
- readonly implementationDigest: Digest;
- readonly handler: RawSurfaceHandler;
- }
- | {
- readonly module: ModuleRef;
- readonly surface: string;
- readonly mode: "structured";
- readonly implementationDigest: Digest;
- readonly handler: StructuredSurfaceHandler;
- };
+import type { HostFacet } from "@svml/host";
+import type { Digest } from "@svml/protocol";
/**
* Trusted executable facets exported by one installed physical package. The Host independently
* grants author registries or deterministic compute registries; this descriptor has no Provider,
* credential, store, queue or Runtime facet.
*/
-export type NodePackageActivation = {
+export type NodePackageContribution = {
readonly format: "svml.node-package@1";
readonly name: string;
readonly modules?: readonly RegisteredModulePackage[];
readonly frontends?: readonly AuthorFrontend[];
- readonly textSurfaces?: readonly NodeTextSurfaceFacet[];
+ /** Syntax- or Host-specific executable facets, inert until their exact Host ABI selects them. */
+ readonly hostFacets?: readonly HostFacet[];
readonly components?: readonly ComponentPackage[];
/** Trusted Run-Graph Fragments, addressable from `.svrun` imports by package and export name. */
readonly runFragments?: Readonly<Record<string, GraphFragment>>;
@@ -66,5 +48,5 @@ export type NodePackageLock = {
export type LoadedNodePackageSet = {
readonly lock: NodePackageLock;
- readonly packages: readonly NodePackageActivation[];
+ readonly contributions: readonly NodePackageContribution[];
};
diff --git a/packages/package-loader-node/test/loader.test.ts b/packages/package-loader-node/test/loader.test.ts
index b9e89d07..05c77b15 100644
--- a/packages/package-loader-node/test/loader.test.ts
+++ b/packages/package-loader-node/test/loader.test.ts
@@ -10,10 +10,9 @@ import { join } from "node:path";
import test from "node:test";
import {
- activateNodeComponents,
- createActivatedNodeCompiler,
createNodePackageLock,
- loadNodePackages,
+ installNodePackageComponents,
+ loadNodePackageContributions,
writeNodePackageLock,
} from "@svml/package-loader-node";
import { TypeValidatorRegistry } from "@svml/validation";
@@ -104,12 +103,16 @@ async function fixture(): Promise<{
},
specifiers: ["example.card@1"],
}],
- textSurfaces: [{
- module,
- surface: "card",
- mode: "structured",
- implementationDigest: digest,
- handler({ element }) {
+ hostFacets: [{
+ abi: "svml.text-surface-host@1",
+ identity: {
+ contract: "svml.text-surface-host-facet@1",
+ module,
+ surface: "card",
+ mode: "structured",
+ implementationDigest: digest,
+ },
+ implementation({ element }) {
return {
records: [{
id: "card-result",
@@ -156,25 +159,18 @@ async function fixture(): Promise<{
return { root, activation, dependency, source, lock: join(root, "svml.packages.lock") };
}
-test("an installed locked package adds a Surface without an official CLI registration", async () => {
+test("an installed locked package carries inert Host facets and activatable compute", async () => {
const item = await fixture();
const lock = await createNodePackageLock(["example-card"], item.root);
assert.deepEqual(lock.artifacts.map((artifact) => artifact.name), ["example-card", "example-helper"]);
await writeNodePackageLock(item.lock, lock);
- const packages = await loadNodePackages(item.lock, item.root);
- const compiler = createActivatedNodeCompiler(packages, { root: item.root });
- const result = await compiler.compileFile(item.source);
+ const packages = await loadNodePackageContributions(item.lock, item.root);
assert.equal(packages[0]?.name, "example-card");
- assert.deepEqual(result.program.closure.modules.map((module) => module.ref), [
- { name: "example.card", version: "1" },
- ]);
- assert.equal(result.module.records[0]?.value.kind, "inline");
- assert.equal(result.module.records[0]?.validation?.validatorDigest, implementationDigest);
- assert.equal(result.elaboration.graph.operations.length, 0);
+ assert.equal(packages[0]?.hostFacets?.[0]?.abi, "svml.text-surface-host@1");
const registered: Array<{ readonly producer: ProducerRef; readonly digest: string }> = [];
- activateNodeComponents(packages, {
+ installNodePackageComponents(packages, {
registerProducer(producer, digest) {
registered.push({ producer, digest });
},
@@ -185,14 +181,14 @@ test("an installed locked package adds a Surface without an official CLI registr
}]);
});
-test("dependency bytes are rejected before a locked activation is reused", async () => {
+test("dependency bytes are rejected before a locked contribution entry is reused", async () => {
const item = await fixture();
const lock = await createNodePackageLock(["example-card"], item.root);
await writeNodePackageLock(item.lock, lock);
await writeFile(item.dependency, `${await readFile(item.dependency, "utf8")}\n// changed bytes\n`, "utf8");
await assert.rejects(
- async () => await loadNodePackages(item.lock, item.root),
+ async () => await loadNodePackageContributions(item.lock, item.root),
/installed Node package bytes do not match the lock/,
);
});
diff --git a/packages/prelude-video/package.json b/packages/prelude-video/package.json
index 9f8ce93a..fb1df546 100644
--- a/packages/prelude-video/package.json
+++ b/packages/prelude-video/package.json
@@ -27,6 +27,7 @@
"@svml/speech-program": "workspace:*",
"@svml/speech-take": "workspace:*",
"@svml/svs": "workspace:*",
+ "@svml/text": "workspace:*",
"@svml/text-track": "workspace:*",
"@svml/whisperx": "workspace:*"
},
diff --git a/packages/prelude-video/src/index.ts b/packages/prelude-video/src/index.ts
index b162c663..d9c1f5a4 100644
--- a/packages/prelude-video/src/index.ts
+++ b/packages/prelude-video/src/index.ts
@@ -65,7 +65,7 @@ import {
mediaModuleRef,
mediaSurfaceImplementationDigests,
} from "@svml/media";
-import type { NodePackageActivation } from "@svml/package-loader-node";
+import type { NodePackageContribution } from "@svml/package-loader-node";
import {
decodeScriptSurface,
scriptManifest,
@@ -97,6 +97,10 @@ import {
speechSpineSurfaceImplementationDigest,
} from "@svml/speech-program";
import { svsFrontend, svsManifest } from "@svml/svs";
+import {
+ createTextSurfaceHostFacet,
+} from "@svml/text";
+import type { TextSurfaceHostFacetOptions } from "@svml/text";
import {
decodeTextTrackSurface,
textTrackComponent,
@@ -112,7 +116,7 @@ import {
whisperXModuleRef,
} from "@svml/whisperx";
-export const svmlPackage: NodePackageActivation = {
+export const svmlPackage: NodePackageContribution = {
format: "svml.node-package@1",
name: "@svml/prelude-video",
modules: [
@@ -165,7 +169,7 @@ export const svmlPackage: NodePackageActivation = {
hyperframesComponent,
hyperframesRenderComponent,
],
- textSurfaces: [
+ hostFacets: ([
{
module: estimateModuleRef,
surface: "speech",
@@ -278,7 +282,7 @@ export const svmlPackage: NodePackageActivation = {
implementationDigest: hyperframesRenderSurfaceImplementationDigest,
handler: decodeHyperframesRenderSurface,
},
- ],
+ ] satisfies readonly TextSurfaceHostFacetOptions[]).map(createTextSurfaceHostFacet),
};
export default svmlPackage;
diff --git a/packages/prelude-video/test/activation.test.ts b/packages/prelude-video/test/activation.test.ts
index 40cefc5a..5932ade2 100644
--- a/packages/prelude-video/test/activation.test.ts
+++ b/packages/prelude-video/test/activation.test.ts
@@ -15,8 +15,8 @@ import {
import { generationComponent } from "@svml/generation";
import {
createNodePackageLock,
- loadNodePackages,
- nodePackageComponents,
+ collectNodePackageComponents,
+ loadNodePackageContributions,
writeNodePackageLock,
} from "@svml/package-loader-node";
import {
@@ -32,7 +32,7 @@ import { seedanceComponent } from "@svml/seedance";
import { svmlPackage } from "../src/index.js";
test("the official prelude activates SpeechTake compute without teaching the Host its name", () => {
- const components = nodePackageComponents([svmlPackage]);
+ const components = collectNodePackageComponents([svmlPackage]);
assert.equal(
svmlPackage.modules?.some((module) => module.manifest === speechTakeManifest),
true,
@@ -45,7 +45,7 @@ test("the official prelude activates SpeechTake compute without teaching the Hos
});
test("the official prelude activates Speech Align compute without teaching the Host its name", () => {
- const components = nodePackageComponents([svmlPackage]);
+ const components = collectNodePackageComponents([svmlPackage]);
assert.equal(
svmlPackage.modules?.some((module) => module.manifest === speechAlignManifest),
true,
@@ -58,7 +58,7 @@ test("the official prelude activates Speech Align compute without teaching the H
});
test("the official prelude activates Caption compute and owner validators without Host special cases", () => {
- const components = nodePackageComponents([svmlPackage]);
+ const components = collectNodePackageComponents([svmlPackage]);
assert.equal(
svmlPackage.modules?.some((module) => module.manifest === captionManifest),
true,
@@ -87,8 +87,8 @@ test("the installed official package lock physically contains speech and Caption
assert.equal(lock.artifacts.some((artifact) => artifact.name === "@svml/generation"), true);
assert.equal(lock.artifacts.some((artifact) => artifact.name === "@svml/seedance"), true);
await writeNodePackageLock(lockPath, lock);
- const packages = await loadNodePackages(lockPath, installedRoot);
- const components = nodePackageComponents(packages);
+ const packages = await loadNodePackageContributions(lockPath, installedRoot);
+ const components = collectNodePackageComponents(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);
diff --git a/packages/seedance/package.json b/packages/seedance/package.json
index fa4e4146..9e652f30 100644
--- a/packages/seedance/package.json
+++ b/packages/seedance/package.json
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/artifact": "workspace:*",
"@svml/contracts": "workspace:*",
"@svml/elaborator": "workspace:*",
"@svml/generation": "workspace:*",
diff --git a/packages/seedance/src/fragment.ts b/packages/seedance/src/fragment.ts
index 7cf1d7ec..0025330c 100644
--- a/packages/seedance/src/fragment.ts
+++ b/packages/seedance/src/fragment.ts
@@ -1,3 +1,4 @@
+import { artifactTypes } from "@svml/artifact";
import { contractTypes } from "@svml/contracts";
import { sealGraphFragment } from "@svml/elaborator";
import { generationProducers } from "@svml/generation";
@@ -31,7 +32,7 @@ export function createSeedanceGenerationFragment(endpoint: ExactModelEndpoint) {
],
exports: [{
name: "video",
- type: contractTypes.blobArtifact,
+ type: artifactTypes.blob,
root: operation("select-primary-video"),
semanticInputs: ["request"],
affinity: [{
@@ -76,7 +77,7 @@ export function createSeedanceSpeechGenerationFragment(
],
exports: [{
name: "video",
- type: contractTypes.blobArtifact,
+ type: artifactTypes.blob,
root: operation("select-primary-video"),
semanticInputs: ["program", "duration"],
affinity: [{
diff --git a/packages/seedance/src/index.ts b/packages/seedance/src/index.ts
index 059dd507..ece3d2ff 100644
--- a/packages/seedance/src/index.ts
+++ b/packages/seedance/src/index.ts
@@ -1,3 +1,4 @@
+import { artifactDependency } from "@svml/artifact";
import {
assertGenerationBlobRef,
generationBlobRefSchema,
@@ -329,6 +330,7 @@ export const seedanceManifest = {
...seedanceBaseDefinition.manifest,
dependencies: [
...seedanceBaseDefinition.manifest.dependencies,
+ artifactDependency,
videoContractDependencies.narrative,
videoContractDependencies.speech,
],
diff --git a/packages/seedance/src/surface.ts b/packages/seedance/src/surface.ts
index 00c15e09..90cc8577 100644
--- a/packages/seedance/src/surface.ts
+++ b/packages/seedance/src/surface.ts
@@ -1,6 +1,5 @@
-import {
- contractTypes,
-} from "@svml/contracts";
+import { artifactTypes } from "@svml/artifact";
+import { contractTypes } from "@svml/contracts";
import { digestOf } from "@svml/protocol";
import type { BlobRef, CanonicalValue } from "@svml/protocol";
import type {
@@ -106,7 +105,7 @@ function prompt(reference: SurfaceResolvedReference, subject: string): SeedanceP
}
function blob(reference: SurfaceResolvedReference, subject: string): BlobRef {
- if (!sameType(reference.type, contractTypes.blobArtifact)) throw new Error(`${subject} must reference a BlobArtifact`);
+ if (!sameType(reference.type, artifactTypes.blob)) throw new Error(`${subject} must reference a BlobArtifact`);
const value = reference.record?.value;
if (value?.kind !== "blob") throw new Error(`${subject} must reference an authored artifact declared before use`);
return value;
diff --git a/packages/speech-program/package.json b/packages/speech-program/package.json
index 78ec82be..05af37fd 100644
--- a/packages/speech-program/package.json
+++ b/packages/speech-program/package.json
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"dependencies": {
+ "@svml/artifact": "workspace:*",
"@svml/caption": "workspace:*",
"@svml/component-kit": "workspace:*",
"@svml/contracts": "workspace:*",
diff --git a/packages/speech-program/src/manifest.ts b/packages/speech-program/src/manifest.ts
index 491e5148..7fa327ea 100644
--- a/packages/speech-program/src/manifest.ts
+++ b/packages/speech-program/src/manifest.ts
@@ -1,3 +1,4 @@
+import { artifactDependency } from "@svml/artifact";
import {
contractTypes,
narrativeExcerptSchema,
@@ -69,6 +70,7 @@ export const speechProgramManifest: ModuleManifest = {
name: speechProgramModuleRef.name,
version: speechProgramModuleRef.version,
dependencies: [
+ artifactDependency,
videoContractDependencies.narrative,
videoContractDependencies.media,
videoContractDependencies.programSpace,
diff --git a/packages/speech-program/src/surface.ts b/packages/speech-program/src/surface.ts
index b4c9ad70..d63d089c 100644
--- a/packages/speech-program/src/surface.ts
+++ b/packages/speech-program/src/surface.ts
@@ -1,3 +1,4 @@
+import { artifactTypes } from "@svml/artifact";
import { contractTypes } from "@svml/contracts";
import {
sealMediaSelectionRequest,
@@ -76,7 +77,7 @@ export const decodeSpeechSpineSurface: StructuredSurfaceHandler = ({ element, re
const declaredTakes = takes(element).map((take, index) => ({
mediaName: `take-${String(index + 1).padStart(4, "0")}-media`,
segmentName: `take-${String(index + 1).padStart(4, "0")}-segment`,
- source: resolve(take, "source", contractTypes.blobArtifact, resolveReference),
+ source: resolve(take, "source", artifactTypes.blob, resolveReference),
segment: resolve(take, "segment", contractTypes.narrativeExcerpt, resolveReference),
range: take.range,
}));
diff --git a/packages/speech-program/test/surface.test.ts b/packages/speech-program/test/surface.test.ts
index 4cf770a8..6d5bdacd 100644
--- a/packages/speech-program/test/surface.test.ts
+++ b/packages/speech-program/test/surface.test.ts
@@ -1,6 +1,7 @@
import assert from "node:assert/strict";
import test from "node:test";
+import { artifactDependency, artifactTypes } from "@svml/artifact";
import { registerTypeValidatorFacets } from "@svml/component-kit";
import {
contractTypes,
@@ -47,10 +48,10 @@ const fixtureManifest: ModuleManifest = {
format: "svml.module@0",
name: fixtureModule.name,
version: fixtureModule.version,
- dependencies: [videoContractDependencies.media],
+ dependencies: [artifactDependency, videoContractDependencies.media],
types: [], capabilities: [], producers: [],
surfaces: [{
- name: "media", tag: "Media", mode: "structured", outputs: [contractTypes.blobArtifact],
+ name: "media", tag: "Media", mode: "structured", outputs: [artifactTypes.blob],
implementation: { kind: "trusted-frontend-surface", locator: "example.speech-media/surface", digest: fixtureSurfaceDigest },
}],
};
@@ -73,7 +74,7 @@ test("Speech Spine lowers ordered Takes into media normalization, one audio plan
surfaces.registerStructured(speechProgramModuleRef, "spine", speechSpineSurfaceImplementationDigest, decodeSpeechSpineSurface);
surfaces.registerStructured(fixtureModule, "media", fixtureSurfaceDigest, ({ element }) => ({
records: ["take-one", "take-two"].map((id) => ({
- id, type: contractTypes.blobArtifact,
+ id, type: artifactTypes.blob,
value: { kind: "blob" as const, digest: digestOf(id), size: 128, mediaType: "video/mp4" },
range: element.range,
})),
diff --git a/packages/text/package.json b/packages/text/package.json
index fa2f7a02..ef3a7222 100644
--- a/packages/text/package.json
+++ b/packages/text/package.json
@@ -9,6 +9,7 @@
"dependencies": {
"@svml/core": "workspace:*",
"@svml/elaborator": "workspace:*",
+ "@svml/host": "workspace:*",
"@svml/protocol": "workspace:*"
},
"devDependencies": {
diff --git a/packages/text/src/host-facet.ts b/packages/text/src/host-facet.ts
new file mode 100644
index 00000000..68b62eb7
--- /dev/null
+++ b/packages/text/src/host-facet.ts
@@ -0,0 +1,123 @@
+import type { HostFacet } from "@svml/host";
+import { isDigest } from "@svml/protocol";
+import type { Digest, ModuleRef } from "@svml/protocol";
+
+import type {
+ RawSurfaceHandler,
+ StructuredSurfaceHandler,
+ TextSurfaceRegistryLike,
+} from "./types.js";
+
+export const textSurfaceHostFacetAbi = "svml.text-surface-host@1";
+
+export type TextSurfaceHostFacetOptions =
+ | {
+ readonly module: ModuleRef;
+ readonly surface: string;
+ readonly mode: "raw";
+ readonly implementationDigest: Digest;
+ readonly handler: RawSurfaceHandler;
+ }
+ | {
+ readonly module: ModuleRef;
+ readonly surface: string;
+ readonly mode: "structured";
+ readonly implementationDigest: Digest;
+ readonly handler: StructuredSurfaceHandler;
+ };
+
+type MutableTextSurfaceRegistry = TextSurfaceRegistryLike & {
+ registerRaw(
+ module: ModuleRef,
+ surface: string,
+ implementationDigest: Digest,
+ handler: RawSurfaceHandler,
+ ): void;
+ registerStructured(
+ module: ModuleRef,
+ surface: string,
+ implementationDigest: Digest,
+ handler: StructuredSurfaceHandler,
+ ): void;
+};
+
+function assert(condition: unknown, message: string): asserts condition {
+ if (!condition) throw new Error(message);
+}
+
+function object(value: unknown, subject: string): Record<string, unknown> {
+ assert(value !== null && typeof value === "object" && !Array.isArray(value), `${subject} must be an object`);
+ return value as Record<string, unknown>;
+}
+
+function exact(value: Record<string, unknown>, allowed: readonly string[], subject: string): void {
+ const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
+ assert(unknown.length === 0, `${subject} does not accept ${unknown[0]}`);
+}
+
+function nonEmptyString(value: unknown, subject: string): string {
+ assert(typeof value === "string" && value.trim().length > 0, `${subject} must be a non-empty string`);
+ return value;
+}
+
+/** Package-owned Text Surface declaration carried through the syntax-neutral package loader. */
+export function createTextSurfaceHostFacet(options: TextSurfaceHostFacetOptions): HostFacet {
+ assert(options.module.name.trim().length > 0 && options.module.version.trim().length > 0,
+ "Text Surface module identity is invalid");
+ assert(options.surface.trim().length > 0, "Text Surface name is empty");
+ assert(isDigest(options.implementationDigest), "Text Surface implementation digest is invalid");
+ return {
+ abi: textSurfaceHostFacetAbi,
+ identity: {
+ contract: "svml.text-surface-host-facet@1",
+ module: options.module,
+ surface: options.surface,
+ mode: options.mode,
+ implementationDigest: options.implementationDigest,
+ },
+ implementation: options.handler,
+ };
+}
+
+/** Install only facets owned by the Text Host ABI; unrelated Host facets remain inert. */
+export function installTextSurfaceHostFacets(
+ facets: readonly HostFacet[],
+ registry: MutableTextSurfaceRegistry,
+): void {
+ for (const facet of facets) {
+ if (facet.abi !== textSurfaceHostFacetAbi) continue;
+ const identity = object(facet.identity, "Text Surface Host facet identity");
+ exact(identity, ["contract", "module", "surface", "mode", "implementationDigest"],
+ "Text Surface Host facet identity");
+ assert(identity.contract === "svml.text-surface-host-facet@1", "Text Surface Host facet contract is invalid");
+ const module = object(identity.module, "Text Surface Host facet module");
+ exact(module, ["name", "version"], "Text Surface Host facet module");
+ const moduleRef = {
+ name: nonEmptyString(module.name, "Text Surface Host facet module name"),
+ version: nonEmptyString(module.version, "Text Surface Host facet module version"),
+ };
+ const surface = nonEmptyString(identity.surface, "Text Surface Host facet surface");
+ const implementationDigest = nonEmptyString(
+ identity.implementationDigest,
+ "Text Surface Host facet implementation digest",
+ );
+ assert(isDigest(implementationDigest), "Text Surface Host facet implementation digest is invalid");
+ assert(typeof facet.implementation === "function", "Text Surface Host facet implementation must be a function");
+ if (identity.mode === "raw") {
+ registry.registerRaw(
+ moduleRef,
+ surface,
+ implementationDigest,
+ facet.implementation as RawSurfaceHandler,
+ );
+ } else {
+ assert(identity.mode === "structured", "Text Surface Host facet mode is invalid");
+ registry.registerStructured(
+ moduleRef,
+ surface,
+ implementationDigest,
+ facet.implementation as StructuredSurfaceHandler,
+ );
+ }
+ }
+}
diff --git a/packages/text/src/index.ts b/packages/text/src/index.ts
index a7a4e2d5..466b0a5e 100644
--- a/packages/text/src/index.ts
+++ b/packages/text/src/index.ts
@@ -8,6 +8,12 @@ export {
textFrontendRef,
} from "./frontend.js";
export { TextSurfaceRegistry } from "./registry.js";
+export {
+ createTextSurfaceHostFacet,
+ installTextSurfaceHostFacets,
+ textSurfaceHostFacetAbi,
+} from "./host-facet.js";
+export type { TextSurfaceHostFacetOptions } from "./host-facet.js";
export {
closeDocument,
discoverText,
diff --git a/packages/video-cli/README.md b/packages/video-cli/README.md
new file mode 100644
index 00000000..3ab7fb73
--- /dev/null
+++ b/packages/video-cli/README.md
@@ -0,0 +1,81 @@
+# `@svml/video-cli`
+
+Official v2 video command-line Distribution.
+
+Unlike the generic `@svml/cli` engine, this application is allowed to choose a trusted default prelude. It
+depends on the one ordinary `@svml/prelude-video` aggregate rather than importing each video package
+itself. The current prelude contributes:
+
+- package-owned Text Surface Host facets consumed by `@svml/compiler-text-node`;
+- the Script raw Surface and its audiovisual Narrative contract dependency;
+- the SVS alternate Frontend and generic Recipe manifest;
+- the official Speech, WhisperX, provider-free Caption, B-roll, Text, Film and HyperFrames Render
+ Structured Surfaces plus their exact static dependencies.
+
+It does not place these packages in Core and does not grant source imports network, credential or
+process permissions.
+
+From the repository:
+
+```bash
+pnpm svml:v2 check path/to/main.svml
+pnpm svml:v2 lock-packages ./svml.packages.lock --package @example/cards --root .
+pnpm svml:v2 check path/to/main.svml --package-lock ./svml.packages.lock --root .
+pnpm svml:v2 plan path/to/main.svml --target component.result
+pnpm svml:v2 check path/to/build.svrun
+pnpm svml:v2 plan path/to/build.svrun
+pnpm svml:v2 build path/to/build.svrun --runtime ./svml.runtime.json --build-id delivery-01 --follow
+pnpm svml:v2 build path/to/main.svml --target final.video --runtime ./svml.runtime.ts --pin shot=<prior-build-id> --accept-substitute --build-id variant-01 --follow
+pnpm svml:v2 status <build-id> --runtime ./svml.runtime.json
+pnpm svml:v2 builds --runtime ./svml.runtime.json
+pnpm svml:v2 inspect <build-id> --runtime ./svml.runtime.json
+pnpm svml:v2 get <build-id> --name final.video --runtime ./svml.runtime.json --to ./final.mp4
+pnpm svml:v2 cancel <build-id> --runtime ./svml.runtime.json
+```
+
+`check` is usable for the complete provider-free author graph in
+`examples/talking-film-graph-check`. `plan` is fully implemented by the generic Node compiler. The
+live example now executes the explicit Vertex Gemini Caption package and real local/remote
+Endpoints; the CLI never fabricates missing facts.
+
+`build` compiles the same locked BuildState and passes it to a trusted local Runtime Profile.
+The default Build identity is content-derived, so the same invocation resumes durable local state;
+`--build-id take-02` names an explicit take. JSON Profiles resolve only adapters registered by the
+Host and contain no executable callback. A TypeScript config module remains trusted deployment code
+with normal Node authority. Neither form is discovered from a source import.
+
+Without `--follow`, a pending remote job returns `paused` and a later identical command resumes it.
+With `--follow`, the CLI stays attached and follows endpoint `wakeAt` hints until completion, a
+non-retryable failure, cancellation or `--max-wait-ms`. `status` reads durable verified state;
+`cancel` invokes active endpoints and then records the resulting terminal Build failure. None of
+these commands creates a second ready-command queue.
+
+`build` archives every accepted Record in the demanded closure and every referenced byte Artifact,
+whether or not the user wants a conventional filesystem copy. `inspect` lists Targets, demanded
+Logical Outputs, accepted Records and their Artifact references. `get` reads one accepted Record;
+without a selector it requires one distinct target, while `--name`, `--record` and `--output` select
+a source output alias, accepted Record or demanded Logical Output. `--artifact` selects any nested
+BlobRef that the Build actually references. `--to` copies an Artifact or writes an inline structured
+value as JSON. It is Host egress only and never changes Build identity or retention.
+
+`builds` and source aliases come from an optional Host `BuildCatalog`. The Catalog contains paths
+and presentation names only. It is not Core truth or a Runtime Closure facet; `inspect` and `get`
+always resolve the alias back through the verified BuildState before accepting it.
+
+`--pin output=<prior-build-id>` is temporary CLI compatibility language, not a Core primitive. The Host
+verifies the prior Build only to extract a typed Record, attaches it as an ordinary zero-input
+`substitute` Candidate, and adds an explicit Satisfaction to a newly compiled BuildRequest. It does not
+prove that the old Graph, prompt or semantic meaning matches the current output. Consequently the
+command requires `--accept-substitute`. Upstream work behind that selected Candidate is not
+demanded, while every unbound reachable output follows the ordinary graph. The prior artifact must
+still exist in the ArtifactStore selected by the Runtime. This is a new Build with a new identity;
+it never resumes or copies the prior Build's outstanding Commands. `.svrun` is now the general Run
+Graph, Target and Satisfaction language; this narrow flag remains only migration compatibility.
+
+`@svml/package-loader-node` supports explicitly trusted installed implementation packages. It
+verifies the complete physical dependency closure before executing an activation entry, then checks
+exact Module, Frontend, Host-facet, Producer and Validator identities. The Loader does not select a
+syntax; this Distribution explicitly chooses `@svml/compiler-text-node`. `plan` and `build` bind the
+lock digest into `BuildRequest.implementationClosure`. Source cannot install a package or activate
+Provider/Runtime authority. Arbitrary untrusted community execution remains absent until an
+isolated Worker and real permission boundary exist.
diff --git a/packages/video-cli/package.json b/packages/video-cli/package.json
new file mode 100644
index 00000000..e3896e71
--- /dev/null
+++ b/packages/video-cli/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "@svml/video-cli",
+ "version": "0.0.0-dev",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "dependencies": {
+ "@svml/artifact-store-s3": "workspace:*",
+ "@svml/cli": "workspace:*",
+ "@svml/compiler-text-node": "workspace:*",
+ "@svml/local": "workspace:*",
+ "@svml/prelude-video": "workspace:*",
+ "@svml/provider-google-vertex": "workspace:*",
+ "@svml/provider-hyperframes-local": "workspace:*",
+ "@svml/provider-kie": "workspace:*",
+ "@svml/provider-media-local": "workspace:*",
+ "@svml/provider-whisperx-local": "workspace:*",
+ "@svml/protocol": "workspace:*",
+ "@svml/runtime": "workspace:*"
+ }
+}
diff --git a/packages/cli/src/cli.ts b/packages/video-cli/src/cli.ts
similarity index 51%
rename from packages/cli/src/cli.ts
rename to packages/video-cli/src/cli.ts
index 78f63156..11eb3ae5 100644
--- a/packages/cli/src/cli.ts
+++ b/packages/video-cli/src/cli.ts
@@ -1,7 +1,7 @@
#!/usr/bin/env node
-import { runCli } from "./main.js";
+import { runVideoCli } from "./index.js";
-runCli(process.argv.slice(2), { write: (text) => process.stdout.write(text) }).catch((error: unknown) => {
+runVideoCli(process.argv.slice(2), { write: (text) => process.stdout.write(text) }).catch((error: unknown) => {
const message = error instanceof Error ? error.message : String(error);
process.stderr.write(`${message}\n`);
process.exitCode = 1;
diff --git a/packages/video-cli/src/compiler.ts b/packages/video-cli/src/compiler.ts
new file mode 100644
index 00000000..8ad08bad
--- /dev/null
+++ b/packages/video-cli/src/compiler.ts
@@ -0,0 +1,12 @@
+import type { CliCompilerOptions } from "@svml/cli";
+import { createTextNodeCompiler } from "@svml/compiler-text-node";
+import { svmlPackage as videoPrelude } from "@svml/prelude-video";
+
+export const videoBuiltInPackageContributions = [videoPrelude] as const;
+
+/** Video Distribution chooses Text authoring and one ordinary replaceable video Prelude. */
+export function createVideoCompiler(options: CliCompilerOptions) {
+ return createTextNodeCompiler(options.packageContributions, {
+ ...(options.root === undefined ? {} : { root: options.root }),
+ });
+}
diff --git a/packages/video-cli/src/distribution.ts b/packages/video-cli/src/distribution.ts
new file mode 100644
index 00000000..07662099
--- /dev/null
+++ b/packages/video-cli/src/distribution.ts
@@ -0,0 +1,15 @@
+import type { CliDistribution } from "@svml/cli";
+
+import {
+ createVideoCompiler,
+ videoBuiltInPackageContributions,
+} from "./compiler.js";
+import { createVideoRuntimeFromConfig } from "./runtime-config.js";
+
+/** Official video authoring and local Runtime-adapter assembly for the generic CLI engine. */
+export const videoCliDistribution: CliDistribution = {
+ name: "@svml/video-cli",
+ builtInPackageContributions: videoBuiltInPackageContributions,
+ createCompiler: createVideoCompiler,
+ createRuntimeFromConfig: createVideoRuntimeFromConfig,
+};
diff --git a/packages/video-cli/src/index.ts b/packages/video-cli/src/index.ts
new file mode 100644
index 00000000..6ccfb472
--- /dev/null
+++ b/packages/video-cli/src/index.ts
@@ -0,0 +1,25 @@
+import {
+ materializeArtifact,
+ materializeRecord,
+ runCli,
+} from "@svml/cli";
+
+import { videoCliDistribution } from "./distribution.js";
+
+export { materializeArtifact, materializeRecord };
+export {
+ createVideoCompiler,
+ videoBuiltInPackageContributions,
+} from "./compiler.js";
+export {
+ createVideoRuntimeConfigRegistry,
+ createVideoRuntimeFromConfig,
+} from "./runtime-config.js";
+export { videoCliDistribution } from "./distribution.js";
+
+export function runVideoCli(
+ argv: readonly string[],
+ io: { readonly write: (text: string) => void },
+): Promise<void> {
+ return runCli(argv, io, videoCliDistribution);
+}
diff --git a/packages/cli/src/runtime-config.ts b/packages/video-cli/src/runtime-config.ts
similarity index 98%
rename from packages/cli/src/runtime-config.ts
rename to packages/video-cli/src/runtime-config.ts
index 1471d0da..0a51ba43 100644
--- a/packages/cli/src/runtime-config.ts
+++ b/packages/video-cli/src/runtime-config.ts
@@ -45,7 +45,7 @@ function common(context: RuntimeConfigFactoryContext): { readonly instance: stri
return { instance: context.instance, ...(context.lane === undefined ? {} : { lane: context.lane }) };
}
-export function createOfficialRuntimeConfigRegistry(): RuntimeConfigRegistry {
+export function createVideoRuntimeConfigRegistry(): RuntimeConfigRegistry {
const registry = new RuntimeConfigRegistry();
registry.registerEndpoint("@svml/provider-kie", (context) => {
const config = object(context.config, "KIE");
@@ -164,9 +164,9 @@ export function createOfficialRuntimeConfigRegistry(): RuntimeConfigRegistry {
return registry;
}
-export async function createOfficialRuntimeFromConfig(path: string) {
+export async function createVideoRuntimeFromConfig(path: string) {
return await createRuntimeFromConfig(path, {
- registry: createOfficialRuntimeConfigRegistry(),
+ registry: createVideoRuntimeConfigRegistry(),
components: videoPrelude.components ?? [],
});
}
diff --git a/packages/cli/test/cli.test.ts b/packages/video-cli/test/cli.test.ts
similarity index 98%
rename from packages/cli/test/cli.test.ts
rename to packages/video-cli/test/cli.test.ts
index bbf0130e..4f2006c0 100644
--- a/packages/cli/test/cli.test.ts
+++ b/packages/video-cli/test/cli.test.ts
@@ -5,7 +5,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import test from "node:test";
-import { materializeRecord, runCli } from "@svml/cli";
+import { materializeRecord, runVideoCli as runCli } from "@svml/video-cli";
test("CLI Pin is explicit substitute selection rather than an exact-history privilege", async () => {
await assert.rejects(
@@ -346,6 +346,7 @@ test("official v2 CLI closes the explicit HyperFrames render package without loa
};
assert.equal(result.ok, true);
assert.deepEqual([...result.modules].sort(), [
@@ -382,8 +383,12 @@ test("CLI package lock activates an installed package without changing the offic
surfaces: [{ name: "empty", tag: "Empty", mode: "structured", outputs: [],
implementation: { kind: "trusted-frontend-surface", locator: "example/empty", digest } }],
}, specifiers: ["example.empty@1"] }],
- textSurfaces: [{ module, surface: "empty", mode: "structured", implementationDigest: digest,
- handler() { return { records: [], components: [], fragments: [] }; } }],
+ hostFacets: [{
+ abi: "svml.text-surface-host@1",
+ identity: { contract: "svml.text-surface-host-facet@1", module, surface: "empty",
+ mode: "structured", implementationDigest: digest },
+ implementation() { return { records: [], components: [], fragments: [] }; },
+ }],
};
`, "utf8");
const file = join(root, "main.svml");
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9bf5cda4..a3de8adb 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -43,6 +43,12 @@ importers:
specifier: 5.9.3
version: 5.9.3
+ packages/artifact:
+ dependencies:
+ '@svml/protocol':
+ specifier: workspace:*
+ version: link:../protocol
+
packages/artifact-store-fs:
dependencies:
'@svml/protocol':
@@ -66,6 +72,9 @@ importers:
packages/broll:
dependencies:
+ '@svml/artifact':
+ specifier: workspace:*
+ version: link:../artifact
'@svml/component-kit':
specifier: workspace:*
version: link:../component-kit
@@ -147,9 +156,6 @@ importers:
packages/cli:
dependencies:
- '@svml/artifact-store-s3':
- specifier: workspace:*
- version: link:../artifact-store-s3
'@svml/compiler-node':
specifier: workspace:*
version: link:../compiler-node
@@ -159,27 +165,9 @@ importers:
'@svml/package-loader-node':
specifier: workspace:*
version: link:../package-loader-node
- '@svml/prelude-video':
- specifier: workspace:*
- version: link:../prelude-video
'@svml/protocol':
specifier: workspace:*
version: link:../protocol
- '@svml/provider-google-vertex':
- specifier: workspace:*
- version: link:../provider-google-vertex
- '@svml/provider-hyperframes-local':
- specifier: workspace:*
- version: link:../provider-hyperframes-local
- '@svml/provider-kie':
- specifier: workspace:*
- version: link:../provider-kie
- '@svml/provider-media-local':
- specifier: workspace:*
- version: link:../provider-media-local
- '@svml/provider-whisperx-local':
- specifier: workspace:*
- version: link:../provider-whisperx-local
'@svml/realization':
specifier: workspace:*
version: link:../realization
@@ -218,6 +206,34 @@ importers:
specifier: workspace:*
version: link:../text
+ packages/compiler-text-node:
+ dependencies:
+ '@svml/compiler-node':
+ specifier: workspace:*
+ version: link:../compiler-node
+ '@svml/component-kit':
+ specifier: workspace:*
+ version: link:../component-kit
+ '@svml/elaborator':
+ specifier: workspace:*
+ version: link:../elaborator
+ '@svml/host':
+ specifier: workspace:*
+ version: link:../host
+ '@svml/package-loader-node':
+ specifier: workspace:*
+ version: link:../package-loader-node
+ '@svml/text':
+ specifier: workspace:*
+ version: link:../text
+ '@svml/validation':
+ specifier: workspace:*
+ version: link:../validation
+ devDependencies:
+ '@svml/protocol':
+ specifier: workspace:*
+ version: link:../protocol
+
packages/component-kit:
dependencies:
'@svml/protocol':
@@ -229,6 +245,9 @@ importers:
packages/contracts:
dependencies:
+ '@svml/artifact':
+ specifier: workspace:*
+ version: link:../artifact
'@svml/component-kit':
specifier: workspace:*
version: link:../component-kit
@@ -386,12 +405,12 @@ importers:
packages/generation:
dependencies:
+ '@svml/artifact':
+ specifier: workspace:*
+ version: link:../artifact
'@svml/component-kit':
specifier: workspace:*
version: link:../component-kit
- '@svml/contracts':
- specifier: workspace:*
- version: link:../contracts
'@svml/protocol':
specifier: workspace:*
version: link:../protocol
@@ -527,6 +546,9 @@ importers:
packages/media:
dependencies:
+ '@svml/artifact':
+ specifier: workspace:*
+ version: link:../artifact
'@svml/contracts':
specifier: workspace:*
version: link:../contracts
@@ -536,6 +558,9 @@ importers:
packages/media-pipeline:
dependencies:
+ '@svml/artifact':
+ specifier: workspace:*
+ version: link:../artifact
'@svml/component-kit':
specifier: workspace:*
version: link:../component-kit
@@ -612,9 +637,6 @@ importers:
'@svml/protocol':
specifier: workspace:*
version: link:../protocol
- '@svml/text':
- specifier: workspace:*
- version: link:../text
'@svml/validation':
specifier: workspace:*
version: link:../validation
@@ -672,6 +694,9 @@ importers:
'@svml/svs':
specifier: workspace:*
version: link:../svs
+ '@svml/text':
+ specifier: workspace:*
+ version: link:../text
'@svml/text-track':
specifier: workspace:*
version: link:../text-track
@@ -913,6 +938,9 @@ importers:
packages/seedance:
dependencies:
+ '@svml/artifact':
+ specifier: workspace:*
+ version: link:../artifact
'@svml/contracts':
specifier: workspace:*
version: link:../contracts
@@ -962,6 +990,9 @@ importers:
packages/speech-program:
dependencies:
+ '@svml/artifact':
+ specifier: workspace:*
+ version: link:../artifact
'@svml/caption':
specifier: workspace:*
version: link:../caption
@@ -1067,6 +1098,9 @@ importers:
'@svml/elaborator':
specifier: workspace:*
version: link:../elaborator
+ '@svml/host':
+ specifier: workspace:*
+ version: link:../host
'@svml/protocol':
specifier: workspace:*
version: link:../protocol
@@ -1139,6 +1173,45 @@ importers:
specifier: workspace:*
version: link:../protocol
+ packages/video-cli:
+ dependencies:
+ '@svml/artifact-store-s3':
+ specifier: workspace:*
+ version: link:../artifact-store-s3
+ '@svml/cli':
+ specifier: workspace:*
+ version: link:../cli
+ '@svml/compiler-text-node':
+ specifier: workspace:*
+ version: link:../compiler-text-node
+ '@svml/local':
+ specifier: workspace:*
+ version: link:../local
+ '@svml/prelude-video':
+ specifier: workspace:*
+ version: link:../prelude-video
+ '@svml/protocol':
+ specifier: workspace:*
+ version: link:../protocol
+ '@svml/provider-google-vertex':
+ specifier: workspace:*
+ version: link:../provider-google-vertex
+ '@svml/provider-hyperframes-local':
+ specifier: workspace:*
+ version: link:../provider-hyperframes-local
+ '@svml/provider-kie':
+ specifier: workspace:*
+ version: link:../provider-kie
+ '@svml/provider-media-local':
+ specifier: workspace:*
+ version: link:../provider-media-local
+ '@svml/provider-whisperx-local':
+ specifier: workspace:*
+ version: link:../provider-whisperx-local
+ '@svml/runtime':
+ specifier: workspace:*
+ version: link:../runtime
+
packages/whisperx:
dependencies:
'@svml/component-kit':
diff --git a/tools/package-boundaries.test.mjs b/tools/package-boundaries.test.mjs
new file mode 100644
index 00000000..666f1f5c
--- /dev/null
+++ b/tools/package-boundaries.test.mjs
@@ -0,0 +1,123 @@
+import assert from "node:assert/strict";
+import {
+ readdir,
+ readFile,
+} from "node:fs/promises";
+import test from "node:test";
+
+const packageRoot = new URL("../packages/", import.meta.url);
+
+async function workspacePackages() {
+ const manifests = new Map();
+ for (const entry of await readdir(packageRoot, { withFileTypes: true })) {
+ if (!entry.isDirectory()) continue;
+ const path = new URL(`./${entry.name}/package.json`, packageRoot);
+ let manifest;
+ try {
+ manifest = JSON.parse(await readFile(path, "utf8"));
+ } catch (error) {
+ if (error?.code === "ENOENT") continue;
+ throw error;
+ }
+ manifests.set(manifest.name, manifest);
+ }
+ return manifests;
+}
+
+function productionGraph(packages) {
+ return new Map([...packages].map(([name, manifest]) => [
+ name,
+ Object.keys({
+ ...(manifest.dependencies ?? {}),
+ ...(manifest.optionalDependencies ?? {}),
+ }).filter((dependency) => packages.has(dependency)),
+ ]));
+}
+
+function transitive(graph, entry) {
+ const found = new Set();
+ const visit = (name) => {
+ for (const dependency of graph.get(name) ?? []) {
+ if (found.has(dependency)) continue;
+ found.add(dependency);
+ visit(dependency);
+ }
+ };
+ visit(entry);
+ return found;
+}
+
+const domainNeutralPackages = new Set([
+ "@svml/protocol",
+ "@svml/artifact",
+ "@svml/core",
+ "@svml/elaborator",
+ "@svml/realization",
+ "@svml/validation",
+ "@svml/host",
+ "@svml/compiler-node",
+ "@svml/workspace-fs-node",
+ "@svml/component-kit",
+ "@svml/runtime",
+ "@svml/endpoint-kit",
+ "@svml/driver-node",
+ "@svml/package-loader-node",
+ "@svml/store-sqlite",
+ "@svml/artifact-store-fs",
+ "@svml/artifact-store-s3",
+ "@svml/credential-store-env",
+ "@svml/transport",
+ "@svml/transport-process",
+ "@svml/transport-aws-lambda",
+ "@svml/local",
+]);
+
+test("official production packages have no dependency cycle", async () => {
+ const graph = productionGraph(await workspacePackages());
+ const visiting = new Set();
+ const complete = new Set();
+ const visit = (name, trail) => {
+ if (visiting.has(name)) assert.fail(`production dependency cycle: ${[...trail, name].join(" -> ")}`);
+ if (complete.has(name)) return;
+ visiting.add(name);
+ for (const dependency of graph.get(name) ?? []) visit(dependency, [...trail, name]);
+ visiting.delete(name);
+ complete.add(name);
+ };
+ for (const name of graph.keys()) visit(name, []);
+});
+
+test("the declared domain-neutral distribution closes without syntax, AIGC or video packages", async () => {
+ const packages = await workspacePackages();
+ const graph = productionGraph(packages);
+ for (const name of domainNeutralPackages) {
+ assert.ok(packages.has(name), `domain-neutral package ${name} is absent`);
+ const outside = [...transitive(graph, name)].filter((dependency) =>
+ dependency.startsWith("@svml/") && !domainNeutralPackages.has(dependency));
+ assert.deepEqual(outside, [], `${name} reaches packages outside the domain-neutral distribution`);
+ }
+ assert.deepEqual(graph.get("@svml/core"), ["@svml/protocol"]);
+});
+
+test("Text compilation is one explicit leaf assembly, not a Package Loader or Local Runtime dependency", async () => {
+ const graph = productionGraph(await workspacePackages());
+ assert.ok(transitive(graph, "@svml/compiler-text-node").has("@svml/text"));
+ assert.ok(!transitive(graph, "@svml/package-loader-node").has("@svml/text"));
+ assert.ok(!transitive(graph, "@svml/local").has("@svml/text"));
+});
+
+test("the generic CLI engine reaches no video Prelude or Endpoint package", async () => {
+ const graph = productionGraph(await workspacePackages());
+ const dependencies = transitive(graph, "@svml/cli");
+ const videoAssembly = [
+ "@svml/prelude-video",
+ "@svml/provider-google-vertex",
+ "@svml/provider-hyperframes-local",
+ "@svml/provider-kie",
+ "@svml/provider-media-local",
+ "@svml/provider-whisperx-local",
+ ];
+ assert.deepEqual(videoAssembly.filter((name) => dependencies.has(name)), []);
+ assert.ok(transitive(graph, "@svml/video-cli").has("@svml/prelude-video"));
+ assert.ok(transitive(graph, "@svml/video-cli").has("@svml/cli"));
+});