Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Empty imported reference description; generate wire fixtures

Bitti37c5871ef205
diff --git a/fixtures/rust-serialized-complete.json b/fixtures/rust-serialized-complete.json
new file mode 100644
index 0000000..bb9a75d
--- /dev/null
+++ b/fixtures/rust-serialized-complete.json
@@ -0,0 +1,142 @@
+{
+ "schemaVersion": 1,
+ "id": "project-complete",
+ "name": "Portable Launch Film",
+ "createdAt": "2026-01-01T00:00:00.000Z",
+ "updatedAt": "2026-01-02T03:04:05.000Z",
+ "thumbnail": "thumbnails/launch.webp",
+ "settings": {
+ "aspectRatio": "16:9",
+ "resolution": "4k",
+ "frameRate": 30,
+ "backgroundColor": "#10131a"
+ },
+ "brief": {
+ "prompt": "A tactile product launch",
+ "status": "ready",
+ "targetDurationSeconds": 60,
+ "aspectRatio": "16:9",
+ "resolution": "4k"
+ },
+ "assets": [
+ {
+ "id": "asset-imported",
+ "kind": "video",
+ "name": "Macro footage",
+ "relativePath": "media/imported/macro.mp4",
+ "mimeType": "video/mp4",
+ "durationMs": 12000,
+ "width": 3840,
+ "height": 2160,
+ "createdAt": "2026-01-01T00:10:00.000Z"
+ },
+ {
+ "id": "asset-generated",
+ "kind": "generated",
+ "name": "Generated opener",
+ "relativePath": "media/generated/opener.mp4",
+ "mimeType": "video/mp4",
+ "durationMs": 8000,
+ "width": 3840,
+ "height": 2160,
+ "createdAt": "2026-01-01T00:20:00.000Z"
+ }
+ ],
+ "timeline": {
+ "tracks": [
+ {
+ "id": "track-video",
+ "kind": "video",
+ "name": "Video 1",
+ "locked": false,
+ "muted": false,
+ "clips": [
+ {
+ "id": "clip-opener",
+ "assetId": "asset-generated",
+ "trackId": "track-video",
+ "startMs": 0,
+ "durationMs": 8000,
+ "sourceStartMs": 0,
+ "label": "Opening shot",
+ "status": "approved"
+ }
+ ]
+ }
+ ]
+ },
+ "references": [
+ {
+ "id": "reference-tone",
+ "kind": "text",
+ "name": "Tone",
+ "description": "Precise, tactile, quietly optimistic.",
+ "content": "Precise, tactile, quietly optimistic.",
+ "relativePath": null,
+ "intendedUse": [
+ "style"
+ ],
+ "createdAt": "2026-01-01T00:05:00.000Z"
+ },
+ {
+ "id": "reference-product",
+ "kind": "image",
+ "name": "Product hero",
+ "description": "The product hero image defines the product's shape, materials, and markings.",
+ "content": null,
+ "relativePath": "references/product-hero.png",
+ "intendedUse": [
+ "product"
+ ],
+ "createdAt": "2026-01-01T00:06:00.000Z"
+ }
+ ],
+ "generationJobs": [
+ {
+ "id": "job-opener",
+ "title": "Generated opener",
+ "prompt": "Reveal the product through a slow macro push.",
+ "status": "ready",
+ "stage": "completed",
+ "progress": 1.0,
+ "providerId": "minimax-h3",
+ "creativeBrief": "Reveal the product through a slow macro push.",
+ "compiledPrompt": "integrated_multimodal_description: [Shot 1] Slow macro push toward the product.",
+ "referenceIds": [
+ "reference-product",
+ "reference-tone"
+ ],
+ "outputRelativePath": "media/generated/opener.mp4",
+ "error": null,
+ "createdAt": "2026-01-01T00:15:00.000Z",
+ "updatedAt": "2026-01-01T00:20:00.000Z"
+ }
+ ],
+ "agentConversation": {
+ "messages": [
+ {
+ "id": "message-user",
+ "role": "user",
+ "content": "Make the opening feel more tactile.",
+ "createdAt": "2026-01-01T00:11:00.000Z"
+ },
+ {
+ "id": "message-assistant",
+ "role": "assistant",
+ "content": "I will use a slower macro push and restrained highlights.",
+ "createdAt": "2026-01-01T00:12:00.000Z"
+ }
+ ]
+ },
+ "providerSettings": {
+ "minimax-h3": {
+ "enabled": true,
+ "model": "MiniMax-H3",
+ "options": {
+ "includeAudio": true,
+ "quality": "high",
+ "seed": 42.0
+ }
+ }
+ }
+}
diff --git a/fixtures/rust-serialized-created.json b/fixtures/rust-serialized-created.json
new file mode 100644
index 0000000..32390e0
--- /dev/null
+++ b/fixtures/rust-serialized-created.json
@@ -0,0 +1,73 @@
+{
+ "schemaVersion": 1,
+ "id": "project-created-1",
+ "name": "Freshly created project",
+ "createdAt": "2026-01-01T00:00:00.000Z",
+ "updatedAt": "2026-01-01T00:00:00.000Z",
+ "thumbnail": null,
+ "settings": {
+ "aspectRatio": "16:9",
+ "resolution": "1080p",
+ "frameRate": 30,
+ "backgroundColor": "#10131a"
+ },
+ "brief": {
+ "prompt": "a rocket launch over the ocean at dawn",
+ "status": "draft",
+ "targetDurationSeconds": 60,
+ "aspectRatio": "16:9",
+ "resolution": "1080p"
+ },
+ "assets": [],
+ "timeline": {
+ "tracks": [
+ {
+ "id": "track-story",
+ "kind": "video",
+ "name": "Story",
+ "locked": false,
+ "muted": false,
+ "clips": []
+ },
+ {
+ "id": "track-voice-over",
+ "kind": "audio",
+ "name": "Voice-over",
+ "locked": false,
+ "muted": false,
+ "clips": []
+ },
+ {
+ "id": "track-music",
+ "kind": "audio",
+ "name": "Music",
+ "locked": false,
+ "muted": false,
+ "clips": []
+ }
+ ]
+ },
+ "references": [],
+ "generationJobs": [
+ {
+ "id": "job-initial-brief",
+ "title": "First scene",
+ "prompt": "a rocket launch over the ocean at dawn",
+ "status": "draft",
+ "stage": "queued",
+ "progress": 0.0,
+ "providerId": "minimax-h3",
+ "creativeBrief": "a rocket launch over the ocean at dawn",
+ "compiledPrompt": "integrated_multimodal_description: [Shot 1] Live-action, cinematic, a rocket launch over the ocean at dawn\n\noverall_soundscape: The ambient sound and physical action sounds are those the scene and actions described above naturally produce. Nothing beyond what that description already establishes is added.\n\nnon_diegetic_music: N/A",
+ "referenceIds": [],
+ "outputRelativePath": null,
+ "error": null,
+ "createdAt": "2026-01-01T00:00:00.000Z",
+ "updatedAt": "2026-01-01T00:00:00.000Z"
+ }
+ ],
+ "agentConversation": {
+ "messages": []
+ },
+ "providerSettings": {}
+}
diff --git a/fixtures/rust-serialized-initial-reference.json b/fixtures/rust-serialized-initial-reference.json
new file mode 100644
index 0000000..c26c9f3
--- /dev/null
+++ b/fixtures/rust-serialized-initial-reference.json
@@ -0,0 +1,88 @@
+{
+ "schemaVersion": 1,
+ "id": "project-created-1",
+ "name": "Freshly created project",
+ "createdAt": "2026-01-01T00:00:00.000Z",
+ "updatedAt": "2026-01-01T00:00:00.000Z",
+ "thumbnail": null,
+ "settings": {
+ "aspectRatio": "16:9",
+ "resolution": "1080p",
+ "frameRate": 30,
+ "backgroundColor": "#10131a"
+ },
+ "brief": {
+ "prompt": "a rocket launch over the ocean at dawn",
+ "status": "draft",
+ "targetDurationSeconds": 60,
+ "aspectRatio": "16:9",
+ "resolution": "1080p"
+ },
+ "assets": [],
+ "timeline": {
+ "tracks": [
+ {
+ "id": "track-story",
+ "kind": "video",
+ "name": "Story",
+ "locked": false,
+ "muted": false,
+ "clips": []
+ },
+ {
+ "id": "track-voice-over",
+ "kind": "audio",
+ "name": "Voice-over",
+ "locked": false,
+ "muted": false,
+ "clips": []
+ },
+ {
+ "id": "track-music",
+ "kind": "audio",
+ "name": "Music",
+ "locked": false,
+ "muted": false,
+ "clips": []
+ }
+ ]
+ },
+ "references": [
+ {
+ "id": "ref-initial-1",
+ "kind": "image",
+ "name": "harbor facade",
+ "description": "",
+ "content": null,
+ "relativePath": "references/harbor facade.png",
+ "intendedUse": [
+ "style"
+ ],
+ "createdAt": "2026-01-01T00:00:00.000Z"
+ }
+ ],
+ "generationJobs": [
+ {
+ "id": "job-initial-brief",
+ "title": "First scene",
+ "prompt": "a rocket launch over the ocean at dawn",
+ "status": "draft",
+ "stage": "queued",
+ "progress": 0.0,
+ "providerId": "minimax-h3",
+ "creativeBrief": "a rocket launch over the ocean at dawn",
+ "compiledPrompt": "integrated_multimodal_description: [Shot 1] Live-action, cinematic, a rocket launch over the ocean at dawn\n\noverall_soundscape: The ambient sound and physical action sounds are those the scene and actions described above naturally produce. Nothing beyond what that description already establishes is added.\n\nnon_diegetic_music: N/A",
+ "referenceIds": [
+ "ref-initial-1"
+ ],
+ "outputRelativePath": null,
+ "error": null,
+ "createdAt": "2026-01-01T00:00:00.000Z",
+ "updatedAt": "2026-01-01T00:00:00.000Z"
+ }
+ ],
+ "agentConversation": {
+ "messages": []
+ },
+ "providerSettings": {}
+}
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 2703d59..2657cef 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -4,6 +4,9 @@ version = "0.1.0"
description = "Agentic video creation workspace"
authors = ["Pol Studio"]
edition = "2021"
+# `u32::is_multiple_of` (used by the date validator) stabilised in 1.87; an
+# older toolchain otherwise fails with a confusing "no method named".
+rust-version = "1.87"
[lib]
name = "pol_studio_lib"
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index e2c10af..a160d80 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -1015,7 +1015,12 @@ fn create_project_in_with_references(
id: reference_id.clone(),
kind: "image".into(),
name: imported.name,
- description: "Visual reference supplied with the initial project brief.".into(),
+ // MUST stay empty. The prompt compiler emits a reference's
+ // description as the subject's own traits in the text sent to
+ // the paid model, so any sentence written here is presented to
+ // the model as if the user had described the image that way.
+ // Same hazard the text path documents at src/lib/project.ts:87.
+ description: String::new(),
content: None,
relative_path: Some(imported.relative_path),
intended_use: vec!["style".into()],
@@ -1146,6 +1151,14 @@ mod tests {
/// (src/lib/project.ts lines 42-44, 56, 109). zod's `.optional()` rejects
/// `null`, so an explicit null under any of these names makes the whole
/// config unparseable in the UI — the key has to be absent instead.
+ ///
+ /// This list is hand-maintained and therefore NOT the authority: a new
+ /// `Option` field missing `skip_serializing_if` is invisible here until
+ /// someone remembers to add its name. The authority is the generated
+ /// `fixtures/rust-serialized-*.json` written by
+ /// `serialized_wire_format_fixtures_are_regenerated_for_the_frontend`,
+ /// which the frontend test suite parses with the real zod schema — a
+ /// forgotten field fails there without anyone editing this array.
const NON_NULLABLE_OPTIONAL_KEYS: [&str; 5] =
["clipId", "durationMs", "width", "height", "color"];
@@ -1214,6 +1227,129 @@ mod tests {
assert!(!json.contains("\"clipId\""), "clipId leaked into {json}");
}
+ /// Writes the REAL serialised output of `validate_and_normalize_config`
+ /// into `fixtures/rust-serialized-*.json`, which the frontend test suite
+ /// parses with its own zod schema. This is how the two-validator contract
+ /// stops being hand-maintained: a field added to Rust as an `Option`
+ /// without `skip_serializing_if` (or added to zod as a bare `.optional()`)
+ /// changes these bytes and fails on the frontend side, with nobody having
+ /// to remember to extend `NON_NULLABLE_OPTIONAL_KEYS`.
+ ///
+ /// THESE FILES ARE GENERATED BY `cargo test` AND COMMITTED ON PURPOSE. If
+ /// `git status` is dirty after a test run, the wire format changed: re-run
+ /// the frontend schema tests against the new bytes before committing them.
+ ///
+ /// The output is deterministic — every input is a checked-in fixture or is
+ /// derived from one. The imported-reference case runs the real product code
+ /// path inside a `tempfile::tempdir()`, but the temp path cannot leak into
+ /// the JSON because references store project-relative paths only
+ /// (`references/<file>`); the assertion below proves it per run.
+ #[test]
+ fn serialized_wire_format_fixtures_are_regenerated_for_the_frontend() {
+ fn serialize(config: &ProjectConfig) -> String {
+ let mut json = serde_json::to_string_pretty(config).unwrap();
+ // Trailing newline so the committed bytes are stable under editors
+ // and `git diff` alike.
+ json.push('\n');
+ json
+ }
+
+ fn write_fixture(name: &str, json: &str) {
+ let path = Path::new(env!("CARGO_MANIFEST_DIR"))
+ .join("../fixtures")
+ .join(name);
+ fs::write(&path, json)
+ .unwrap_or_else(|error| panic!("could not write {}: {error}", path.display()));
+ }
+
+ write_fixture(
+ "rust-serialized-created.json",
+ &serialize(&validate_and_normalize_config(created_fixture()).unwrap()),
+ );
+ write_fixture(
+ "rust-serialized-complete.json",
+ &serialize(&validate_and_normalize_config(fixture()).unwrap()),
+ );
+
+ // An ACTUALLY IMPORTED reference: produced by the same function the
+ // create-project command calls, not a hand-written fixture record.
+ let root = tempfile::tempdir().unwrap();
+ let source = root.path().join("harbor facade.png");
+ fs::write(&source, b"\x89PNG\r\n\x1a\n").unwrap();
+ let imported = create_project_in_with_references(
+ root.path(),
+ &created_fixture(),
+ std::slice::from_ref(&source),
+ )
+ .unwrap();
+ assert_eq!(
+ imported.config.references[0].relative_path.as_deref(),
+ Some("references/harbor facade.png"),
+ "the imported reference must be stored as a project-relative path"
+ );
+ let json = serialize(&imported.config);
+ // The randomly named temp directory is the only non-deterministic input
+ // in this test; if any part of it reached the JSON the committed file
+ // would change on every run and dirty the tree at random.
+ let temp_marker = root
+ .path()
+ .file_name()
+ .unwrap()
+ .to_string_lossy()
+ .into_owned();
+ assert!(
+ !json.contains(&temp_marker),
+ "the temp directory name '{temp_marker}' leaked into the generated fixture: {json}"
+ );
+ write_fixture("rust-serialized-initial-reference.json", &json);
+ }
+
+ #[test]
+ fn is_iso_datetime_agrees_with_real_zod_on_every_recorded_case() {
+ // fixtures/iso-datetime-cases.json is a differential harness: 932
+ // strings (single-character mutations, insertions, deletions and
+ // truncations of valid stamps, plus calendar and time boundaries),
+ // each labelled with the verdict of the frontend's real
+ // `z.string().datetime()` from the installed zod 3.25.76. The
+ // hand-written table above documents intent readably; THIS test is the
+ // one that proves parity, and it is committed rather than run once as
+ // a throwaway so a regression is caught by `cargo test`.
+ let cases: Vec<(String, bool)> =
+ serde_json::from_str(include_str!("../../fixtures/iso-datetime-cases.json"))
+ .expect("fixtures/iso-datetime-cases.json is not a [string, bool] array");
+ assert!(
+ cases.len() > 900,
+ "the harness lost cases: only {} remain",
+ cases.len()
+ );
+
+ // Collect every disagreement before failing: one assert per iteration
+ // would report a single string and hide the shape of the regression.
+ let mut disagreements = Vec::new();
+ for (value, zod_accepts) in &cases {
+ if is_iso_datetime(value) != *zod_accepts {
+ disagreements.push(format!(
+ "'{value}': zod {}, rust {}",
+ if *zod_accepts { "accepts" } else { "rejects" },
+ if *zod_accepts { "rejects" } else { "accepts" }
+ ));
+ }
+ }
+ assert!(
+ disagreements.is_empty(),
+ "{} of {} cases disagree with zod; first {}:\n{}",
+ disagreements.len(),
+ cases.len(),
+ disagreements.len().min(10),
+ disagreements
+ .iter()
+ .take(10)
+ .cloned()
+ .collect::<Vec<_>>()
+ .join("\n")
+ );
+ }
+
#[test]
fn both_fixtures_round_trip_losslessly_through_json() {
for (name, config) in [("created", created_fixture()), ("complete", fixture())] {
@@ -1593,6 +1729,18 @@ mod tests {
assert_eq!(reference.kind, "image");
assert_eq!(reference.intended_use, vec!["style"]);
+ // The description must stay EMPTY. `compileMiniMaxH3Prompt` emits a
+ // reference's description as the subject's traits in the prompt sent to
+ // the paid model, so app-authored filing boilerplate here is shipped to
+ // the model as if the user had written it about their own image
+ // ("<Subject 1> is harbor-facade, shown in <Picture 1>. Visual
+ // reference supplied with the initial project brief."). The app never
+ // invents words and presents them as the user's description — the text
+ // path documents the same rule at src/lib/project.ts:87.
+ assert_eq!(
+ reference.description, "",
+ "an imported reference must carry no app-authored description"
+ );
assert!(created
.config
.generation_jobs