AI media harness for planning, generating, and editing locally
TypeScript
Align Slopfab planning with model metadata
Bittic946644d0975
diff --git a/docs/slopfab-compatibility.md b/docs/slopfab-compatibility.mdnew file mode 100644index 0000000..35a6470--- /dev/null+++ b/docs/slopfab-compatibility.md@@ -0,0 +1,68 @@+# Slopfab 1.12 compatibility++Reviewed on 2026-09-20 against Slopfab commit `50ca721` and the local+`lib/slopfab/slopfab.dll`, which reports C API `1.12.0`.++## ABI and runtime++The refactor preserves the existing C function signatures and the layouts of+`slopfab_plan`, `slopfab_progress` and `slopfab_output`. Slopus's Rust bindings,+callbacks, reference handles and output ownership remain compatible.++The new session and JSON sampling/conditioning setters are additive. Slopus+can continue using the default session through its serialized generation+queue. `slopfab_reused_models_clear` still clears that default session when+the queue drains. Explicit session bindings are optional for future cache+isolation; they are not required for this update.++The C API continues to return pixels and PCM. Slopus still uses WebCodecs and+MP4 muxing; no FFmpeg dependency is introduced.++## Integration corrections++- Preview and execution requests now supply the same configured model paths.+ The planner reads SafeTensors metadata for model capabilities, geometry,+ sampling grids and conditioning policy. Omitting the transformer during+ preview could report different steps or accept a request execution rejects.+- Generation progress uses the resolved model evaluation count. A fixed grid+ from model or LoRA metadata can override the scene's explicit step count.+- The planning boundary message acknowledges metadata reads. Planning does+ not execute inference, but it is no longer accurate to say it opens no files.+- DLL integration tests use valid SafeTensors fixtures and the new Animate+ recipe diagnostics. Added coverage verifies model-driven sampling, early+ conditioning rejection and fixed-grid/MotionCache incompatibility on both+ CUDA and Vulkan requests. Missing model files still allow generic planning.++Scene and LoRA step overrides remain explicit requests, so the change to+Slopfab's inherited step defaults does not change Slopus's configured counts.+Slopus also supplies an explicit canvas; the CLI's new canvas defaults do not+change project resolution. Unsupported metadata combinations now surface+during planning instead of being deferred until generation.++## LoRA asset preparation++Inference no longer downloads a missing AdaLN timestep grid or rewrites the+adapter to embed it. This affects adapters that need rebasing onto an H3 table+model and do not already have an embedded grid. Slopus's current LoRA download+flow downloads the adapter itself; it does not prepare this companion asset.++For legacy H3 adapters, place `h3_silu_temb_grid.safetensors` beside the adapter,+or use Slopfab's explicit preparation command before selecting it in Slopus:++```powershell+slopfab.exe prepare-lora --adapter "D:\weights\adapter.safetensors" --width 2688 --download+```++That command explicitly downloads the pinned legacy grid and embeds it in the+adapter. Omit `--download` to use local assets only. Custom `slopfab.lora_grid`+metadata requires its declared local asset and matching identity/width; the+legacy downloader cannot supply arbitrary grids. Already embedded adapters+need no migration. Automatic asset preparation in Slopus would be a separate+download-workflow enhancement, not a C ABI binding change.++## Validation limits++All 26 Slopus Slopfab integration tests passed with the updated DLL, including+planning for both backends, Animate, MotionCache, video reference ownership,+continuation and still images. These tests do not run a full model inference;+CUDA/Vulkan numerical output and render performance were not revalidated here.diff --git a/src-tauri/src/slopfab/generation.rs b/src-tauri/src/slopfab/generation.rsindex 0ad8355..f06e06f 100644--- a/src-tauri/src/slopfab/generation.rs+++ b/src-tauri/src/slopfab/generation.rs@@ -51,7 +51,7 @@ pub(super) fn run_generation(RequestPurpose::Generate,&item.references,)?;- api.resolve(&request)?;+ let plan = api.resolve(&request)?;diagnostics::debug("slopfab","generation.request_resolved",@@ -66,7 +66,7 @@ pub(super) fn run_generation(canvas_height: item.request.canvas_height,reference_count: item.request.reference_count(),timing_profile: timing_profile.clone(),- planned_steps: (item.request.steps - 1).max(0),+ planned_steps: plan.num_model_evaluations,};let mut generation = request.start(Some(progress_sink(context)))?;diagnostics::debug(diff --git a/src-tauri/src/slopfab/h3.rs b/src-tauri/src/slopfab/h3.rsindex f4a9068..fdf66f6 100644--- a/src-tauri/src/slopfab/h3.rs+++ b/src-tauri/src/slopfab/h3.rs@@ -26,7 +26,7 @@ pub(super) fn configure_request(let video = videos.get(&request.reference_video_ids[0]).ok_or("The prepared reference video no longer exists. Please retry generation.")?;- // The setter selects Euler and four boundaries; explicit step settings follow.+ // Animate supplies recipe defaults; explicit step settings follow.api.set_animate(handle, video.has_audio())?;let source = configuration.prompt_embedding.as_deref().ok_or("Animate conditioning is missing. Download Animate in Settings and select its conditioning additional safetensor.")?;@@ -87,16 +87,18 @@ pub(super) fn configure_request(}if purpose == RequestPurpose::Generate {api.set_reuse_models(handle, true)?;- for (id, _, path) in &configuration.models {- if configuration.animate && (*id == 1 || *id == 2) {- continue;- }- if request.still_image && *id == 4 {- continue;- }- if let Some(path) = path {- api.set_model(handle, *id, path)?;- }+ }+ // Planning reads checkpoint metadata for sampling, conditioning, geometry+ // and reference capabilities. Give it the same model paths as execution.+ for (id, _, path) in &configuration.models {+ if configuration.animate && (*id == 1 || *id == 2) {+ continue;+ }+ if request.still_image && *id == 4 {+ continue;+ }+ if let Some(path) = path {+ api.set_model(handle, *id, path)?;}}for path in &request.reference_paths {diff --git a/src-tauri/src/slopfab/planning.rs b/src-tauri/src/slopfab/planning.rsindex e3f0bdc..850e5eb 100644--- a/src-tauri/src/slopfab/planning.rs+++ b/src-tauri/src/slopfab/planning.rs@@ -49,7 +49,7 @@ pub fn resolve_plan(latent_width: plan.latent_width,latent_height: plan.latent_height,description,- boundary: "Plan only. No weights were opened and no media file was created.",+ boundary: "Plan only. Model and adapter metadata may be read; no inference was run or media file created.",})}diff --git a/src-tauri/src/slopfab/tests.rs b/src-tauri/src/slopfab/tests.rsindex 4401e45..d0f1390 100644--- a/src-tauri/src/slopfab/tests.rs+++ b/src-tauri/src/slopfab/tests.rs@@ -5,6 +5,115 @@ use super::{use crate::project::{ProviderOption, ProviderSetting};use std::collections::BTreeMap;+// Minimal table-model header: planning reads descriptors but never executes+// these fixture tensors. Active LoRAs also need a valid SafeTensors header.+fn metadata_checkpoint(path: &std::path::Path, metadata: serde_json::Value) {+ let header = serde_json::json!({+ "__metadata__": metadata,+ "adaln_t_table": { "dtype": "F32", "shape": [1], "data_offsets": [0, 4] },+ "blocks.0.adaln_proj.linear.weight": { "dtype": "F32", "shape": [1], "data_offsets": [4, 8] }+ }).to_string();+ let mut bytes = (header.len() as u64).to_le_bytes().to_vec();+ bytes.extend_from_slice(header.as_bytes());+ bytes.extend_from_slice(&[0; 8]);+ std::fs::write(path, bytes).unwrap();+}++#[test]+fn model_metadata_is_shared_by_preview_and_execution_requests() {+ let root = tempfile::tempdir().unwrap();+ let transformer = root.path().join("model.safetensors");+ metadata_checkpoint(+ &transformer,+ serde_json::json!({+ "slopfab.sampling": r#"{"version":1,"video_sigma_shift":6,"base_sigmas":[1,0.5,0]}"#+ }),+ );+ let mut configuration = Configuration::from_settings(&BTreeMap::new());+ configuration.models[0].2 = Some(transformer);+ let api = ffi::Api::load(&configuration.dll_path).unwrap();+ let request = GenerationRequest {+ prompt: "A quiet harbour.".into(),+ frames: 48,+ steps: 20,+ canvas_width: 736,+ canvas_height: 416,+ ..Default::default()+ };+ for platform in [ComputePlatform::Cuda13, ComputePlatform::Vulkan] {+ for purpose in [RequestPurpose::Plan, RequestPurpose::Generate] {+ let handle = RequestHandle::new(&api).unwrap();+ configure_request(+ &api,+ &handle,+ &request,+ &configuration,+ platform,+ purpose,+ &ReferenceVideos::default(),+ )+ .unwrap();+ // The model's fixed grid overrides the UI's explicit 20 steps.+ assert_eq!(api.resolve(&handle).unwrap().num_model_evaluations, 2);+ assert!(api.describe(&handle).unwrap().contains("shift 6"));+ api.set_motion_cache(&handle, true).unwrap();+ assert!(+ api.resolve(&handle).is_err(),+ "fixed grids must reject MotionCache during preview too"+ );+ }+ }+}++#[test]+fn preview_enforces_model_conditioning_and_reports_invalid_metadata() {+ let root = tempfile::tempdir().unwrap();+ let transformer = root.path().join("model.safetensors");+ let settings = BTreeMap::from([(+ "slopfab".into(),+ ProviderSetting {+ enabled: true,+ model: None,+ options: BTreeMap::from([+ (+ "transformer".into(),+ ProviderOption::String(transformer.to_string_lossy().into_owned()),+ ),+ (+ "inferenceBackend".into(),+ ProviderOption::String("vulkan".into()),+ ),+ ]),+ },+ )]);+ let request = GenerationRequest {+ prompt: "A quiet harbour.".into(),+ frames: 48,+ steps: 20,+ canvas_width: 736,+ canvas_height: 416,+ ..Default::default()+ };+ let references = ReferenceVideos::default();+ // Undownloaded models still permit a generic geometry preview.+ assert!(resolve_plan(&request, &settings, &references).is_ok());+ metadata_checkpoint(+ &transformer,+ serde_json::json!({+ "slopfab.conditioning": r#"{"version":1,"max_frames":40}"#+ }),+ );+ assert!(resolve_plan(&request, &settings, &references)+ .err()+ .unwrap()+ .contains("max_frames"));+ metadata_checkpoint(+ &transformer,+ serde_json::json!({ "slopfab.sampling": "invalid JSON" }),+ );+ assert!(resolve_plan(&request, &settings, &references).is_err());+}+#[test]fn animate_requires_video_and_prompt_mode_requires_text() {let mut configuration = Configuration::from_settings(&BTreeMap::new());@@ -88,15 +197,18 @@ fn animate_recipe_and_audio_selection_reach_bundled_dll() {)?;assert_eq!(api.resolve(&handle)?.num_model_evaluations, 3);let description = api.describe(&handle)?;- assert!(description- .contains("fixed 362-token embedding; video then repainted image"));- assert!(description.contains("reference short edge 416"));- assert!(description.contains("video 1.000000 .. 0.600000 (shift 3.0)"));- assert!(description.contains(if preserve_audio {- "pinned driving soundtrack"- } else {- "generated; driving reference soundtrack omitted"- }));+ assert!(description.contains("fixed 362-token embedding"));+ // The resolved recipe reports target-canvas preprocessing,+ // omitted reference audio and video-first packing here.+ assert!(description.contains(&format!(+ "conditioning-v1:1:362:2048:768:1032192:1:1:0:1:{}:360",+ i32::from(preserve_audio)+ )));+ assert!(description.contains("video 1.000000 .. 0.600000 (shift 3)"));+ assert_eq!(+ description.contains("pinned driving soundtrack"),+ preserve_audio+ );assert!(description.contains(&format!("prompt {} characters",ANIMATE_PROMPT.len()@@ -181,7 +293,7 @@ fn animate_duration_limit_resolves_with_bundled_dll() {.resolve(&handle).err().unwrap()- .contains("at most 15 seconds"));+ .contains("exceeds conditioning max_frames"));// Other generators keep their existing upward alignment at 15 s.configuration.animate = false;@@ -482,7 +594,7 @@ fn ordered_loras_and_step_override_reach_cuda_and_vulkan_requests() {root.path().join("TaoMate.safetensors"),];for path in &paths {- std::fs::write(path, b"planning does not load weights").unwrap();+ metadata_checkpoint(path, serde_json::json!({}));}let settings = BTreeMap::from([("slopfab".into(),