From ac576c6217af9e22d01e467c74ad3b5aecec65c3 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 11 Nov 2026 16:46:16 +0300 Subject: [PATCH 1/3] diffusion: MiniMax-H3-Image needs build 1088 and only creates checkEngineCompatibility holds minimax-h3-image to master-1088-32d516c, the build that added MiniMax-H3-Image upstream (leejet/stable-diffusion.cpp#2324), and names it in the refusal; the other families keep their floors. workflowsForFamily gives it Create only: sd.cpp runs its reference edits (up to 16 pictures), but they are not measured yet. Assisted-by: Claude --- docs/contracts.md | 2 +- docs/testing-critical-flows.md | 2 +- src/diffusion/compat.test.ts | 30 ++++++++++++++++++++++++++++++ src/diffusion/compat.ts | 9 ++++++--- src/diffusion/workflow.test.ts | 2 ++ src/diffusion/workflow.ts | 5 +++-- 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/docs/contracts.md b/docs/contracts.md index 263766ba..da5622a1 100644 --- a/docs/contracts.md +++ b/docs/contracts.md @@ -53,7 +53,7 @@ without a demonstrated consumer. See PLAN.md §5.1 for comparison rules and §8 | Tunnel probe: `GET /openapi.json`, `info.title` = `Atomic Chat API Server Endpoints` | `src/remote-access/probe.ts`, served by `src/server/public/static.ts` | `remote_access/probe.rs` | `probe.test.ts` asserts the marker against the document the public server really serves | | LAN addresses `GET /atomic/v1/lan-addresses` → `{addresses}` (IPv4, default route first, virtual adapters hidden, CGNAT kept) | `src/remote-access/{lan,lan-probe}.ts`, `src/server/control/routes/remote-access.ts` | image-generation line `remote_access/lan.rs` (`get_lan_addresses`) | ported `lan.rs` tables | | Image generation wire types (camelCase; absent vs `null` as the plugin's serde produced), the 23 `DiffusionErrorCode`s incl. `ENGINE_UPDATE_REQUIRED` (409) and `INVALID_OUTPUT` (500) (statuses informational: 400/404/409/429/507/500), `files.llmVision`, events `diffusion:{state,progress,job,error}` | `src/contracts/{diffusion,errors,events}.ts`, `src/diffusion/{parse,errors}.ts`, `src/server/http.ts` | image-generation line `web-app/src/services/diffusion/types.ts`, plugin `tauri-plugin-atomic-diffusion/src/{state,error,events}.rs` at `ec1fd3ea7` | `contracts/errors.test.ts` (code list), `diffusion/parse.test.ts`, `server/http.test.ts` | -| `sd-server` argv (`--llm_vision` after `--llm`) and environment (`GGML_METAL_TENSOR_DISABLE=1` on an M5 with Metal) and `POST /sdcpp/v1/img_gen` body; output parsing (records, step lines, tile passes, diagnostic tail, exit classification, GPU-fault markers); progress tracking; request validation (Qwen-Image on Metal ≤ 1 MP); per-family workflows and `workflowsForSpec`; engine gating (Qwen Image 2.1 and Krea 2 Turbo need build ≥ 883, FLUX.3 Klein ≥ 968, `ENGINE_UPDATE_REQUIRED`) and install selection | `src/diffusion/{args,progress,tracker,validate,workflow,compat}.ts` | plugin `{args,progress,jobs,session}.rs` | the Rust `#[test]` tables ported by hand into the sibling tests; `test/fixtures/sdcpp/required-flags.txt` | +| `sd-server` argv (`--llm_vision` after `--llm`) and environment (`GGML_METAL_TENSOR_DISABLE=1` on an M5 with Metal) and `POST /sdcpp/v1/img_gen` body; output parsing (records, step lines, tile passes, diagnostic tail, exit classification, GPU-fault markers); progress tracking; request validation (Qwen-Image on Metal ≤ 1 MP); per-family workflows and `workflowsForSpec`; engine gating (Qwen Image 2.1 and Krea 2 Turbo need build ≥ 883, FLUX.3 Klein ≥ 968, MiniMax-H3-Image ≥ 1088, `ENGINE_UPDATE_REQUIRED`) and install selection | `src/diffusion/{args,progress,tracker,validate,workflow,compat}.ts` | plugin `{args,progress,jobs,session}.rs` | the Rust `#[test]` tables ported by hand into the sibling tests; `test/fixtures/sdcpp/required-flags.txt` | | Gallery files: `/-.png` with `tEXt` chunks `atomic` (the `ImageRecipe` JSON, every key, `null`s) and `parameters` (A1111 line) right after `IHDR`; `.thumb.png` (≤256 px); `.flags.json` `{id:{pinned,archived}}`. A PNG without a valid `atomic` recipe is foreign: never listed, never deleted. A batch with an all-black or all-white frame is refused before anything is saved (`INVALID_OUTPUT`); such an item an older build saved is hidden when its thumbnail (or PNG) is ≤ 128 KiB | `src/diffusion/{gallery,recipe,png}.ts` | plugin `gallery.rs` at `767ff6350` | ported `gallery.rs` tables; `test/fixtures/png/` (independent encoder, Pillow-checked); read-only run against images written by app v2.0.40 | | Engine installs `/diffusion/backends///` with `.atomic-owned` and `install.json` `{tag,backendId,backend,engine,sha256,installedAtMs}` (written by the core's engine-builds install; the app's `finalize` wrote the same before it); the `--help` probe markers `stable-diffusion.cpp` / `--cfg-scale`; model files under `/diffusion/models/` | `src/diffusion/{install,containment}.ts` | plugin `install.rs` | ported `install.rs` tables; read-only run against the engine installed by app v2.0.40 | | Engine builds (`engine` ∈ `ENGINE_BUILD_IDS`: `sd-cpp`, `audio-cpp`, `mlx`, `foundry-local`, `litert-lm`, `geniex`; change `move-sdcpp-mlx-install-to-core`, ADR 2026-10-07; audio.cpp: ADR 2026-10-29, conf `backends/audiocpp-manifest.json`, `ATOMIC_AUDIOCPP_MANIFEST_URL`, tags `vX.Y.Z[-a]`): `POST /atomic/v1/engine-builds/:engine/catalog {force?, proxy?}` → `{engine, manifest: {tag, published_at?, source: remote\|cache, fetched_at, error}\|null, manifest_error, host_backend_id, host_reason, host_download_bytes, installed[], active}` (`host_download_bytes`: every archive an install of the host build downloads, active build or not; `null` without one or with a size missing from the manifest), `POST …/updates {force?, proxy?}` → `{update_needed, current, target: {tag, backend_id, published_at?, download_bytes}\|null}`, `POST …/install {task_id, force?, proxy?}` (answers when done; `download:progress`/`download:stage` under `task_id`, cancel `POST /downloads/:task_id/cancel`) → `{installed, reason?: already-installed\|active-is-newer, build, retired[], kept_in_use[], failed_backend_ids?}`, `DELETE …/:tag/:backend_id` → `{removed}`; `engine` ∈ `sd-cpp`\|`mlx` (else `INVALID_ARGUMENT`), unknown body fields refused; errors `ENGINE_INSTALL_IN_PROGRESS`, `ENGINE_INSTALL_FAILED`, `BACKEND_INSUFFICIENT_DISK_SPACE` (< 3× the archives free), `CANCELLED`, `BACKEND_IN_USE`, `INVALID_REQUEST` (bundled or unmarked build), `UNSUPPORTED_BACKEND` (no build fits the host), `UPSTREAM_ERROR` (no manifest); event `engine-build:changed {engine, reason: install\|uninstall\|startup-cleanup}`. Manifests: conf `backends/sdcpp-manifest.json` and `backends/mlx-manifest.json`, overridable by `ATOMIC_SDCPP_MANIFEST_URL` / `ATOMIC_MLX_MANIFEST_URL` (`https://`, `file://`), cached at `/diffusion/sdcpp-manifest.cache.json` and `/mlx/mlx-manifest.cache.json`; probe failures remembered in `/diffusion/failed-backends.json`. MLX builds under `/mlx/backends//macos-arm64/` with `install.json {tag, backendId, sha256, installedAtMs, publishedAt}`; the installer's `/mlx-server` described by `mlx-server.json {tag, published_at}`; the newer by `published_at` runs, the installer on a tie | `src/engine-builds/`, `src/server/control/routes/engine-builds.ts`, `src/client/control-client.ts`, `src/contracts/engine-builds.ts` | app `web-app/src/services/diffusion/{install,backendMatrix}.ts` (branch `change/add-vllm-runtime`), conf `backends/{sdcpp,mlx}-schema.json` | `src/engine-builds/*.test.ts`, `routes/engine-builds.test.ts`, `control-client.test.ts`, `test/e2e/engine-builds.test.ts` | diff --git a/docs/testing-critical-flows.md b/docs/testing-critical-flows.md index 59f2d17a..b18070da 100644 --- a/docs/testing-critical-flows.md +++ b/docs/testing-critical-flows.md @@ -40,7 +40,7 @@ Line coverage alone never raises a grade. A PR may not lower a grade. | Server gates: host, api key, CORS, preflight | Strong (contract) | `test/contract/proxy-http.test.ts` (default and trusted hosts, `*`, missing Host, IPv6 loopback refused, Bearer/`X-Api-Key`, whitelisted docs, `/configs` hidden, origin reflection, preflight method/header/host rules), `src/server/public/gates.test.ts`, `http.test.ts` (control listener guards), `test/e2e/public-server.test.ts` (key, trusted hosts, missing Host, hidden `/configs`, 405, preflight and origin reflection configured through control on the compiled binary; Swagger assets served byte-identical from the binary) | maintained | | Dynamic trusted hosts: the tunnel name and the accepted socket's address (stage 7c) | Strong (core) | `src/server/public/dynamic-hosts.test.ts` (the five `dynamic_hosts.rs` tests against the core's `isValidHost`; `*`, URLs, ports and paths can never become the tunnel name; every socket-address spelling: mapped, hex-mapped, zone id, bracketed IPv6, loopback and unspecified in both families), `test/contract/dynamic-hosts.test.ts` on a real listener under Node and Bun (403 → 200 with the origin reflected → 403; another `*.trycloudflare.com` stays a stranger; the same keep-alive connection is refused before and accepted after; preflight; a listener on `0.0.0.0` trusts the dialled LAN address, refuses a rebinding name on that socket and the LAN literal over loopback; a loopback bind gains nothing), `src/core/public-server.test.ts` (a real core, and a repeated start stays idempotent), the `proxy-http` set unchanged | a phone on the same Wi-Fi reaching a running app | | Remote access: the Cloudflare quick tunnel (stage 7d) | Strong (core, fake cloudflared and a stand-in edge), Missing (live) | `src/remote-access/manager.test.ts` (the app's 19 state-machine tests plus: a stuck supervisor loses the state, a second stop joins the first, a process that came up after shutdown is not kept, the process-exit guard), `process.test.ts` on a real child (URL + registration, URL only, silence, early exit, exit after ready, SIGTERM ignored then killed, an exit that cannot be confirmed, Windows goes straight to the kill, a program that cannot start, real argv and no `TUNNEL_*`), `cloudflared-{args,output}.test.ts` (tables), `probe.test.ts` (ours / foreign / unreachable, the marker against the real public server, edge by SNI with certificate verification on the tunnel name, 1033 until the tunnel is there, two silent rounds give up the edge, hostname fallback, abort), `journal.test.ts` (write-then-enrich, never resurrected after a clear, identity *and* name before a kill, start-time fallback, a real child ended and a real non-tunnel spared), `spawner.test.ts`, `wiring.test.ts` (test hooks), `src/core/remote-access.test.ts` on a real core (Host gate 403 → 401 with the key → 403 as the tunnel comes and goes, tunnel ended before `server:stopped`, an unchanged start leaves it alone, HTTP/2 retry with real processes, shutdown kills it, no binary), `src/core/public-server.test.ts`, `routes/remote-access.test.ts`, `control-client.test.ts`; `test/runtime-compat/address-pin.test.ts` under Node and Bun (a Node edge process reports the SNI the client really sent); `test/e2e/remote-access.test.ts` on the compiled app-core binary (refusal, online through the stand-in edge, journal, stop, ordering over SSE, HTTP/2 retry with the real 15 s, missing binary, a crash's journal consumed by the next owner, shutdown), plus stage 7q: a tunnel that exits after coming up reported as `exited` with its name no longer trusted and the public server untouched, a tunnel that ignores SIGTERM killed after the 5 s grace before `stop` answers `off`, and the journal Atomic Chat 2.0.40 left at the data root consumed once with the process it named spared | a real `cloudflared` against Cloudflare from a running app; a phone opening the URL | -| Image generation on stable-diffusion.cpp (stages 7e–7l) | Strong (core, fake engine, compiled binary, real engine), Missing (desktop) | pure ports with the plugin's `#[test]` tables: `src/diffusion/{args,progress,tracker,workflow,parse,validate,errors,recipe}.test.ts` (`args.test.ts` holds the argv to `test/fixtures/sdcpp/required-flags.txt`); disk: `png.test.ts` (fixtures from an independent encoder, Pillow-checked; damaged and unsupported files refused), `gallery.test.ts` (foreign PNGs never listed or deleted, flags file, atomic writes, export), `install.test.ts` (finalize probes a real script, owned trees only, model files inside the root), `containment.test.ts` (symlinks out of and into the root); process and jobs: `server-process.test.ts` on the fake engine (journalled before ready, capabilities, early exit with marked lines first, OOM, timeout kills, foreign listener stopped, abandoned load stopped), `jobs.test.ts` against an HTTP stub (the `jobs.rs` runner tests: completion with outputs and every transition, failures explained by the output, queue full, forgotten job, cancel ladder incl. the second grace, cancel wins over a waiting respawn, crash mid-job with the spec kept, ggml-abort CPU retry, transport errors, ceiling), `session.test.ts`, `idle.test.ts`, `service.test.ts` (the real fake engine: finalize → load → generate with progress → gallery → cancel → respawn → idle unload → shutdown, child dead each time); wiring: `routes/diffusion.test.ts` (every route, envelopes, the 64 MiB job body, 400 with the field named), `control-client.test.ts`, `src/core/create.test.ts` (a real owner: refused foreign data folder, finalize → load → generate over the control API, `processes.json` entry under `diffusion`, no chat session, events on the bus, engine output kept out of the log, the server dead after `shutdown`, then `POST /v1/images/generations` on the public listener: a PNG back, the gallery grown, the image model absent from `/v1/models`, an abandoned request's job cancelled); app v2.0.42 additions (7k–7l): `compat.test.ts` (build ≥ 883 for Qwen Image 2.1 / Krea 2 Turbo, ≥ 968 for FLUX.3 Klein, odd tags fail closed, install selection never switches backends), `workflow.test.ts` / `validate.test.ts` (per-family workflows, Qwen Image 2.1's references only with `llmVision`, Qwen-Image on Metal ≤ 1 MP), `session.test.ts` (a stale spec refused before spawn, `activateInstall`), `service.test.ts` on the fake engine (a Qwen Image 2.1 load blocked on 849 then served by an 883 tree, `llmVision` checked and protected, an engine finalized during a running job cancels it and unloads the old server), `jobs.test.ts` (a blank frame fails the batch before anything is saved, a GPU fault in the attempt's lines retires the server and one printed before the job does not, a respawn reads the spec under the lock), `gallery.test.ts` / `png.test.ts` (blank detection, hidden items, verdicts kept per file), `server-process.test.ts` (`GGML_METAL_TENSOR_DISABLE` reaches the child only on an M5 with Metal); facade: `server/public/images-params.test.ts` (the `images_route.rs` tables), `images.test.ts` (503 before a model, 400 before that, the OpenAI body with the atomic extras, refusals to start, failed jobs, client gone → cancel, 504 with cancel) ; `test/e2e/diffusion.test.ts` on the compiled binary (finalize → load → events over SSE → gallery, flags and export → the OpenAI facade → unload with the journal cleared; a cancel the engine ignores stops the process and the next job respawns it; a crashed owner's `sd-server` is reaped by the next owner); the 7k–7l behaviour on the compiled binary (stage 7o): `test/e2e/diffusion-engine.test.ts` (Qwen Image 2.1 refused on build 849 with `ENGINE_UPDATE_REQUIRED`, nothing spawned, `load-blocked` on the stream, then served by an 883 tree of the same backend; the projector as `--llm_vision` right after `--llm` in the real argv, `reference`/`edit` offered only with it, the projector undeletable while loaded, an edit without it named `SIDE_FILE_MISSING`; a finalized newer engine unloads the resident model with `engine-updated`, the old tree removable only then and its empty tag folder gone, an unowned tree and a path outside the root refused) and `test/e2e/diffusion-failures.test.ts` (a blank frame ends the batch with `INVALID_OUTPUT`, nothing on disk or in the gallery, the same process serving the next seed and the facade answering 500; a GPU fault printed during the job retires the still-running server with `gpu-fault`, the model kept, the next job on a fresh pid; a ggml unsupported-op abort retried once on `--backend cpu` — two pids, the second with `cpuFallback` in the recipe and the status); the rest of the failure modes and the facade on the compiled binary (stage 7p): `diffusion-engine.test.ts` (Qwen-Image past 1 MP refused on a Metal engine before anything runs and the M5 switch absent from the engine's environment on a non-M5, `MODEL_MISSING` / `SIDE_FILE_MISSING` naming the file before any spawn, an early exit read as `OUT_OF_MEMORY` and a foreign listener as `MODEL_LOAD_FAILED` with both engines gone, an unload during a load answering `CANCELLED` with the child gone first), `diffusion-failures.test.ts` (an engine dying mid-job explained by its output, `crashed` then a respawn; a full queue as `QUEUE_FULL` and a failed job as `OUT_OF_MEMORY` with the engine left running, the facade answering 429 `busy` and 500 `insufficient_memory`), `diffusion.test.ts` (the output folder moved with the next picture under it, gallery items deleted with their thumbnails and a foreign PNG never listed or touched, model files listed, protected while loaded and deleted with their empty family folder after; a generation body over 64 MiB refused with the envelope and one below it read whole; the idle unload on the next tick with the spec forgotten), `test/e2e/images-api.test.ts` (OpenAI's envelope: `response_format` refused before the model check, 503 `model_not_loaded`, a broken body and a missing prompt, `size` and `n` named, 429 `busy` behind an Images-page job; a client that hangs up cancels the job with the engine kept — the binary-level case that found Bun's silence, ADR 2026-09-22; the key and Host gates in front, the request reported as `atomic-diffusion` on `images/generations` and the prompt absent from the API events with or without the inspector), `public-server.test.ts` (`/openapi.json` from the binary documents `POST /images/generations`); `test/live/diffusion.test.ts` on a real engine and FLUX.2 Klein (`--help` holds every flag of `required-flags.txt`, load, a 256² generation with parsed sampling progress, PNG + thumbnail + recipe, the facade, a hard cancel, respawn, unload; passed 2026-09-18 on `master-849-d04e895` and again 2026-09-21 on `master-883-137f740`, the build app v2.0.42 ships, on macOS arm64 in ~5 min); `test/live/diffusion-install.test.ts` (a real build installed from a conf-shaped manifest: picked for the host, downloaded, sha256-checked, unpacked, probed; a tampered sha256 refused; `--version` naming the tag's commit); both run per build by `engine-candidate.yml` with `engine=sd-cpp` on linux-x64, linux-arm64 and macos-arm64 (CPU archives), with the surface held to `test/fixtures/sdcpp/engine-contract.json` (`test/contract/sdcpp-{engine-contract,surface}.test.ts`); `src/diffusion/{jobs,service}.test.ts` also checks cancellation during validation/input reads, active owner shutdown, and readiness racing an aborted spawn; `test/e2e/diffusion.test.ts` checks explicit shutdown with an active job and an empty child journal | desktop acceptance from the Images page on the compiled binary and `test/live/diffusion.test.ts` on a real engine (7j), desktop acceptance from the Images page | +| Image generation on stable-diffusion.cpp (stages 7e–7l) | Strong (core, fake engine, compiled binary, real engine), Missing (desktop) | pure ports with the plugin's `#[test]` tables: `src/diffusion/{args,progress,tracker,workflow,parse,validate,errors,recipe}.test.ts` (`args.test.ts` holds the argv to `test/fixtures/sdcpp/required-flags.txt`); disk: `png.test.ts` (fixtures from an independent encoder, Pillow-checked; damaged and unsupported files refused), `gallery.test.ts` (foreign PNGs never listed or deleted, flags file, atomic writes, export), `install.test.ts` (finalize probes a real script, owned trees only, model files inside the root), `containment.test.ts` (symlinks out of and into the root); process and jobs: `server-process.test.ts` on the fake engine (journalled before ready, capabilities, early exit with marked lines first, OOM, timeout kills, foreign listener stopped, abandoned load stopped), `jobs.test.ts` against an HTTP stub (the `jobs.rs` runner tests: completion with outputs and every transition, failures explained by the output, queue full, forgotten job, cancel ladder incl. the second grace, cancel wins over a waiting respawn, crash mid-job with the spec kept, ggml-abort CPU retry, transport errors, ceiling), `session.test.ts`, `idle.test.ts`, `service.test.ts` (the real fake engine: finalize → load → generate with progress → gallery → cancel → respawn → idle unload → shutdown, child dead each time); wiring: `routes/diffusion.test.ts` (every route, envelopes, the 64 MiB job body, 400 with the field named), `control-client.test.ts`, `src/core/create.test.ts` (a real owner: refused foreign data folder, finalize → load → generate over the control API, `processes.json` entry under `diffusion`, no chat session, events on the bus, engine output kept out of the log, the server dead after `shutdown`, then `POST /v1/images/generations` on the public listener: a PNG back, the gallery grown, the image model absent from `/v1/models`, an abandoned request's job cancelled); app v2.0.42 additions (7k–7l): `compat.test.ts` (build ≥ 883 for Qwen Image 2.1 / Krea 2 Turbo, ≥ 968 for FLUX.3 Klein, ≥ 1088 for MiniMax-H3-Image, odd tags fail closed, install selection never switches backends), `workflow.test.ts` / `validate.test.ts` (per-family workflows, Qwen Image 2.1's references only with `llmVision`, Qwen-Image on Metal ≤ 1 MP), `session.test.ts` (a stale spec refused before spawn, `activateInstall`), `service.test.ts` on the fake engine (a Qwen Image 2.1 load blocked on 849 then served by an 883 tree, `llmVision` checked and protected, an engine finalized during a running job cancels it and unloads the old server), `jobs.test.ts` (a blank frame fails the batch before anything is saved, a GPU fault in the attempt's lines retires the server and one printed before the job does not, a respawn reads the spec under the lock), `gallery.test.ts` / `png.test.ts` (blank detection, hidden items, verdicts kept per file), `server-process.test.ts` (`GGML_METAL_TENSOR_DISABLE` reaches the child only on an M5 with Metal); facade: `server/public/images-params.test.ts` (the `images_route.rs` tables), `images.test.ts` (503 before a model, 400 before that, the OpenAI body with the atomic extras, refusals to start, failed jobs, client gone → cancel, 504 with cancel) ; `test/e2e/diffusion.test.ts` on the compiled binary (finalize → load → events over SSE → gallery, flags and export → the OpenAI facade → unload with the journal cleared; a cancel the engine ignores stops the process and the next job respawns it; a crashed owner's `sd-server` is reaped by the next owner); the 7k–7l behaviour on the compiled binary (stage 7o): `test/e2e/diffusion-engine.test.ts` (Qwen Image 2.1 refused on build 849 with `ENGINE_UPDATE_REQUIRED`, nothing spawned, `load-blocked` on the stream, then served by an 883 tree of the same backend; the projector as `--llm_vision` right after `--llm` in the real argv, `reference`/`edit` offered only with it, the projector undeletable while loaded, an edit without it named `SIDE_FILE_MISSING`; a finalized newer engine unloads the resident model with `engine-updated`, the old tree removable only then and its empty tag folder gone, an unowned tree and a path outside the root refused) and `test/e2e/diffusion-failures.test.ts` (a blank frame ends the batch with `INVALID_OUTPUT`, nothing on disk or in the gallery, the same process serving the next seed and the facade answering 500; a GPU fault printed during the job retires the still-running server with `gpu-fault`, the model kept, the next job on a fresh pid; a ggml unsupported-op abort retried once on `--backend cpu` — two pids, the second with `cpuFallback` in the recipe and the status); the rest of the failure modes and the facade on the compiled binary (stage 7p): `diffusion-engine.test.ts` (Qwen-Image past 1 MP refused on a Metal engine before anything runs and the M5 switch absent from the engine's environment on a non-M5, `MODEL_MISSING` / `SIDE_FILE_MISSING` naming the file before any spawn, an early exit read as `OUT_OF_MEMORY` and a foreign listener as `MODEL_LOAD_FAILED` with both engines gone, an unload during a load answering `CANCELLED` with the child gone first), `diffusion-failures.test.ts` (an engine dying mid-job explained by its output, `crashed` then a respawn; a full queue as `QUEUE_FULL` and a failed job as `OUT_OF_MEMORY` with the engine left running, the facade answering 429 `busy` and 500 `insufficient_memory`), `diffusion.test.ts` (the output folder moved with the next picture under it, gallery items deleted with their thumbnails and a foreign PNG never listed or touched, model files listed, protected while loaded and deleted with their empty family folder after; a generation body over 64 MiB refused with the envelope and one below it read whole; the idle unload on the next tick with the spec forgotten), `test/e2e/images-api.test.ts` (OpenAI's envelope: `response_format` refused before the model check, 503 `model_not_loaded`, a broken body and a missing prompt, `size` and `n` named, 429 `busy` behind an Images-page job; a client that hangs up cancels the job with the engine kept — the binary-level case that found Bun's silence, ADR 2026-09-22; the key and Host gates in front, the request reported as `atomic-diffusion` on `images/generations` and the prompt absent from the API events with or without the inspector), `public-server.test.ts` (`/openapi.json` from the binary documents `POST /images/generations`); `test/live/diffusion.test.ts` on a real engine and FLUX.2 Klein (`--help` holds every flag of `required-flags.txt`, load, a 256² generation with parsed sampling progress, PNG + thumbnail + recipe, the facade, a hard cancel, respawn, unload; passed 2026-09-18 on `master-849-d04e895` and again 2026-09-21 on `master-883-137f740`, the build app v2.0.42 ships, on macOS arm64 in ~5 min); `test/live/diffusion-install.test.ts` (a real build installed from a conf-shaped manifest: picked for the host, downloaded, sha256-checked, unpacked, probed; a tampered sha256 refused; `--version` naming the tag's commit); both run per build by `engine-candidate.yml` with `engine=sd-cpp` on linux-x64, linux-arm64 and macos-arm64 (CPU archives), with the surface held to `test/fixtures/sdcpp/engine-contract.json` (`test/contract/sdcpp-{engine-contract,surface}.test.ts`); `src/diffusion/{jobs,service}.test.ts` also checks cancellation during validation/input reads, active owner shutdown, and readiness racing an aborted spawn; `test/e2e/diffusion.test.ts` checks explicit shutdown with an active job and an empty child journal | desktop acceptance from the Images page on the compiled binary and `test/live/diffusion.test.ts` on a real engine (7j), desktop acceptance from the Images page | | Video generation on stable-diffusion.cpp (stage 9a–9f) | Strong (core, fake engine, compiled binary), Missing (real engine, desktop) | pure: `src/diffusion/{parse,validate,args,workflow}.test.ts` (the video parsers, the frame lattice `k·step+offset` and the nearest-point snap, the fixed rate, `--audio-vae`/`--embeddings-connectors` in order, `-M vid_gen` behind its switch, the `vid_gen` body with `custom_sigmas` at the schedule's step count, image-to-video refused), `server-process.test.ts` (capabilities per mode, a mode the spec needs but the engine lacks kills the server: `MODEL_INCOMPATIBLE`), `session.test.ts` (video capabilities, image capabilities refused on a video model), `state.test.ts` (kind-aware records); the seam: `image-job.test.ts`, `video-job.test.ts` (decode, the WebM preflight, the recipe, the events, the plan's decode tiling in the body and the threshold again on the CPU fallback), `jobs.test.ts` (the image suite unchanged after the refactor; a video job through the HTTP stub on its own events with one clip, the wrong modality both ways, the preflight, a native cancel; the estimate on the first event and a failed one that does not stop the job; the plan's decode tiling in the body and the decode's tiles on the progress; the heartbeat through a ten-second step with `elapsedMs` from the job's start, images still on change only); the estimate: `video-estimate.test.ts` (latent tokens per family, the tiled decode and its peak and work per layout, the decode tiling planned by memory — one graph on 24 GB, three strips on 18 GB, the finest on 16 GB, none under `model` offload, on the CPU fallback or on unknown memory —, LTX-2 on a 16 GB Mac `exceeds` with `seconds: null`, memory growing with frames and size, the 80 %/100 % lines, the three pools and both sides of a discrete GPU, the speed table and unknown hardware, CFG passes, ×2/×3 ranges, the history band), `video-tiling.test.ts` (sd.cpp's tile count ported, tile counts to sides and back, the work of a layout, the body's tile counts under both spellings), `video-history.test.ts` (which clips count, a past clip re-planned at its own size, three clips at twice the heuristic double the middle, the median and its clamp, the cache), `video-eta.test.ts` (every ETA and fraction scenario of the progress spec, both slowdown rules and their stickiness; a tiled decode counted down per tile, stretched, restarted on a retried pass, and a stalled tile), `tracker.test.ts` (a lost tile pass ended by `generating video:`; the decode's tiles counted, a retried pass counted from zero); disk: `video-recipe.test.ts` (every key, `null`s, strict on the way back), `video-gallery.test.ts` (EBML/DocType sniff, save writes the sidecar first, foreign `.webm` never listed or deleted, the poster kept verbatim and refused when not a PNG, flags, delete, export); service: `service.test.ts` on the fake in `vid_gen` mode (`estimateVideo`: the job's refusals, an answer while a clip runs with no event, history after the first clip and gone after its delete, no hardware facts refused while the clip still runs; load with the side files, a clip into `/videos` with its sidecar, the poster, the gallery, `cancelVideoJob`, the `VideosBackend` view, a video model on an image-only engine refused with the child dead, a build without WebM refused before submit; the decode tiled by the memory of a 16 GB Mac — one graph for 1024²×9, three strips for 2048²×17 — and its tiles reported); routes: `routes/diffusion-video.test.ts` (the estimate route too), `control-client.test.ts`; facade: `videos-params.test.ts` (seconds → frames, the video object from a job and from a clip, the path matcher, the listing query), `videos.test.ts` on a real listener (503/400/405, the queued object, poll, content and poster streamed, 404s, DELETE cancels or removes, the list merge and cursor, polls not reported); owner: `src/core/create.test.ts` (`/v1/videos` queue → poll → content equals the fixture → gallery → delete; the video model absent from `/v1/models`; only the video events); binary: `test/e2e/video.test.ts` (argv, `videoOutputDir`, the events over SSE, the clip and sidecar on disk, the poster, gallery ops, a cancel the engine ignores stops it and the next clip respawns, wrong modality at load and at generate, a missing side file before any spawn, no-WebM before submit and an unreported build's own 400; the estimate route and its refusal, `job.estimate` on the first event, the heartbeat through a 3 s step, `slowdown` when a step drags past three medians and 20 s; one graph for a clip past the old threshold that fits, and a tiled decode counted down tile by tile), `test/e2e/videos-api.test.ts` (the OpenAI envelope, queue/poll/download/list/DELETE, a finished clip answered after a restart, key and Host gates, reported as `atomic-diffusion` on `videos` without the prompt); live: `test/live/diffusion.test.ts` video block, not run yet (the estimate's coefficients are unmeasured, ADR 2026-09-28); desktop: the app's Video page, not yet | | Remote media: cloud and self-hosted providers' image and video models through the core (ADR 2026-10-13) | Strong (core, fake providers, compiled binary), Missing (live providers, desktop) | adapters: one `src/media/adapters/.test.ts` per provider API on a fake fetch (request shape, auth header, body, success parsing, error mapping, live listing; video submit/poll/download/cancel; key only on the provider origin, redirects off it bare), `registry.test.ts` (one adapter per dialect); pure: `src/media/{catalog,http,mask}.test.ts`, `remote-media.test.ts` (public params, inline images only, alpha masks), `parse.test.ts` (`target`/`remote`); I/O: `catalog-service.test.ts` (live → memory → disk → baseline, newest `catalog_version`, the `file://` hook), `remote-store.test.ts`; service: `src/media/service.test.ts` (catalog and registration adapters, refusals, live listing merged or failed), `src/diffusion/remote-job.test.ts` on the real `DiffusionService` (shared table and events, no busy slot, gallery PNG/JPEG/MP4, provider errors and `diffusion:error`, cancel without touching `sd-server`, the cap, a submit never retried, transient polls retried, a clip resumed after a restart without a second submit, a resumed clip past its ceiling timed out, shutdown keeps the stored job, the facades' `runImageJob`/`runVideoJob`); registry: `cloud/registry.test.ts` (media out of the key binding, absent keeps, `null` clears, other providers untouched), `router/resolve.test.ts`; routes: `routes/media.test.ts`, `control-client.test.ts`, `server/public/{images,videos}.test.ts` (remote generations and edits, 415/404/400, MP4 content), `src/core/create.test.ts` (owner: catalog and a live listing over control); binary: `test/e2e/remote-media.test.ts` (a self-hosted OpenAI-compatible stub registered over control: an image job over control into `/images`, `/v1/images/generations` by `/`, absent from `/v1/models`, a clip over `/v1/videos` saved as MP4, the key sent to the provider; an unconnected provider refused) | live runs against each provider (`test/live`), the app's Images/Video pages | | Audio generation on audio.cpp: builds, load, speech/music/effects jobs, cancel, gallery, `/v1/audio/speech` (ADRs 2026-10-29) | Strong (core, fake engine, compiled binary, real engine: upstream v0.9.3 on macOS Metal and CPU), Missing (fork builds, Windows/Linux real engine, desktop) | pure: `src/audio/{args,config,request,capabilities,wav,parse,output,recipe}.test.ts`, `src/server/public/audio-speech-params.test.ts`; process: `src/audio/server-process.test.ts` (fake `audiocpp_server`: ready, foreign listener, taken port, load failure, missing model), `jobs`/`session`/`service`/`idle` tests (cancel stops the server and keeps the spec, crash then respawn, a cancel under the load lock never deadlocks; replacement loads keep their state after an older teardown, reference reads reject a replaced model, shutdown waits for a loading child and journal cleanup), `gallery.test.ts` (foreign WAVs never listed or deleted); builds: `src/audio/install.test.ts` (probe `--version` + `--list-devices` on v0.9.3 fixtures), `src/engine-builds/{manifest,select,order,service}.test.ts` (shared ggml manifest, ladder without ROCm, failed rungs per engine); compiled binary: `test/e2e/{audio,audio-speech-api,engine-builds,engines}.test.ts` (including owner shutdown during an audio load); contract: `test/contract/audiocpp-*.test.ts` (flags and routes against `--help`, log strings the runtime reads); live: `test/live/audio-install.test.ts`, `test/live/audio.test.ts` (Stable Audio 3 Small SFX and Qwen3-TTS Base with a reference, Metal and CPU, 2026-10-29) | diff --git a/src/diffusion/compat.test.ts b/src/diffusion/compat.test.ts index 03049807..4986c33f 100644 --- a/src/diffusion/compat.test.ts +++ b/src/diffusion/compat.test.ts @@ -54,6 +54,24 @@ describe('checkEngineCompatibility', () => { } }) + it('holds MiniMax-H3-Image to build 1088, the one that added it upstream', () => { + for (const tag of ['unknown', 'master-968-8cd731e', 'master-1079-a3c49b1', 'master-1087-f8417d0']) + expect( + codeOf(() => checkEngineCompatibility('minimax-h3-image', tag)), + tag + ).toBe('ENGINE_UPDATE_REQUIRED') + for (const tag of ['master-1088-32d516c', 'master-1088-32d516c-a1234567', 'master-1100-abcdef0']) + expect(() => checkEngineCompatibility('minimax-h3-image', tag), tag).not.toThrow() + try { + checkEngineCompatibility('minimax-h3-image', 'master-1028-37bc88b-a5f9a63b') + expect.unreachable() + } catch (error) { + expect((error as { details?: string }).details).toBe( + 'installed=master-1028-37bc88b-a5f9a63b; required=master-1088-32d516c or newer' + ) + } + }) + it('leaves the older families on any engine', () => { for (const family of ['qwen-image', 'z-image', 'flux.1', 'flux.2-klein']) expect(() => checkEngineCompatibility(family, 'unknown'), family).not.toThrow() @@ -106,4 +124,16 @@ describe('selectModelInstall', () => { expect(selectModelInstall([current, flux3], 'sd-cpp', 'flux.3-klein').tag).toBe('master-975-95b3090') expect(selectModelInstall([current, flux3], 'sd-cpp', 'qwen-image-2.1').tag).toBe('master-883-137f740') }) + + it('serves MiniMax-H3-Image only from a build of 1088 or newer', () => { + const flux3 = record('master-975-95b3090', 'macos-arm64') + const h3 = record('master-1088-32d516c', 'macos-arm64') + expect(codeOf(() => selectModelInstall([flux3, current], 'sd-cpp', 'minimax-h3-image'))).toBe( + 'ENGINE_UPDATE_REQUIRED' + ) + expect(selectModelInstall([h3, flux3, current], 'sd-cpp', 'minimax-h3-image').tag).toBe( + 'master-1088-32d516c' + ) + expect(selectModelInstall([h3, flux3, current], 'sd-cpp', 'flux.3-klein').tag).toBe('master-1088-32d516c') + }) }) diff --git a/src/diffusion/compat.ts b/src/diffusion/compat.ts index 3ede3ff1..b6b94ef3 100644 --- a/src/diffusion/compat.ts +++ b/src/diffusion/compat.ts @@ -1,7 +1,7 @@ /** * Which installed engine build may serve a model family. `check_engine_compatibility` and * `select_model_install` in `session.rs` of `tauri-plugin-atomic-diffusion` (app commit - * `ec1fd3ea7`); messages verbatim. FLUX.3 Klein's floor came after the plugin. + * `ec1fd3ea7`); messages verbatim. The FLUX.3 Klein and MiniMax-H3-Image floors came after the plugin. */ import type { DiffusionBackendInstallRecord, DiffusionEngineId } from '../contracts/index.js' @@ -14,11 +14,14 @@ type EngineFloor = { build: number; tag: string } const MODERN: EngineFloor = { build: MIN_MODERN_FAMILY_BUILD, tag: 'master-883-137f740' } /** The first upstream build that runs FLUX.3 Image Klein (leejet/stable-diffusion.cpp#2143). */ const FLUX3: EngineFloor = { build: 968, tag: 'master-968-8cd731e' } +/** The first upstream build that runs MiniMax-H3-Image (leejet/stable-diffusion.cpp#2324). */ +const MINIMAX_H3_IMAGE: EngineFloor = { build: 1088, tag: 'master-1088-32d516c' } const ENGINE_FLOORS: ReadonlyMap = new Map([ ['qwen-image-2.1', MODERN], ['qwen-image-2.1-turbo', MODERN], ['krea-2-turbo', MODERN], ['flux.3-klein', FLUX3], + ['minimax-h3-image', MINIMAX_H3_IMAGE], ]) /** `master--` → the build number; anything else → undefined. */ @@ -32,8 +35,8 @@ function buildOf(tag: string): number | undefined { } /** - * Qwen Image 2.1 and Krea 2 Turbo need build 883 or newer, FLUX.3 Klein 968; a tag that does not - * parse fails closed. Every other family keeps whatever engine it has. + * Qwen Image 2.1 and Krea 2 Turbo need build 883 or newer, FLUX.3 Klein 968, MiniMax-H3-Image 1088; + * a tag that does not parse fails closed. Every other family keeps whatever engine it has. */ export function checkEngineCompatibility(family: string, tag: string): void { const floor = ENGINE_FLOORS.get(family) diff --git a/src/diffusion/workflow.test.ts b/src/diffusion/workflow.test.ts index 33b33429..bf051566 100644 --- a/src/diffusion/workflow.test.ts +++ b/src/diffusion/workflow.test.ts @@ -29,6 +29,8 @@ describe('workflowsForFamily', () => { expect(workflowsForFamily('krea-2-turbo')).toEqual(['create']) // sd.cpp runs FLUX.3 Klein's reference edits; they are not measured yet. expect(workflowsForFamily('flux.3-klein')).toEqual(['create']) + // Likewise MiniMax-H3-Image's reference edits (up to 16 pictures in sd.cpp). + expect(workflowsForFamily('minimax-h3-image')).toEqual(['create']) expect(workflowsForFamily('wan2.2-ti2v-5b')).toEqual(['create']) expect(workflowsForFamily('unknown')).toEqual(['create']) }) diff --git a/src/diffusion/workflow.ts b/src/diffusion/workflow.ts index b9a0b602..2b20e246 100644 --- a/src/diffusion/workflow.ts +++ b/src/diffusion/workflow.ts @@ -56,8 +56,8 @@ export function isQwenImage21(family: string): boolean { /** * img2img and masking are generic in sd.cpp (the init image is VAE-encoded and noised to `strength`, * a mask blends latents), so the established base families get them; a distilled model such as - * Krea 2 Turbo keeps to its verified Create, and so does FLUX.3 Klein until its edits are measured - * (sd.cpp runs them). Reference-guided generation and instruction edits need + * Krea 2 Turbo keeps to its verified Create, and so do FLUX.3 Klein and MiniMax-H3-Image until their + * edits are measured (sd.cpp runs them). Reference-guided generation and instruction edits need * a model trained on reference images: FLUX.2 Klein and Qwen Image 2.1 (Turbo included, which the * official checkpoint trains for editing), which also needs its vision projector loaded * (`workflowsForSpec`). Anything else, video families included, only creates. @@ -69,6 +69,7 @@ export function workflowsForFamily(family: string): ImageWorkflowId[] { return ['create', 'transform', 'inpaint', 'extend', 'upscale', 'reference', 'edit'] case 'krea-2-turbo': case 'flux.3-klein': + case 'minimax-h3-image': return ['create'] case 'z-image': case 'qwen-image': From feeb2d54f0f90976054998157c0a1754b56a8cd2 Mon Sep 17 00:00:00 2001 From: Misha Skvortsov Date: Wed, 11 Nov 2026 17:18:36 +0300 Subject: [PATCH 2/3] diffusion: MiniMax-H3-Image creates, references and edits workflowsForFamily gives minimax-h3-image create, reference and edit. stable-diffusion.cpp master-1088-32d516c runs its reference edits (up to 16 pictures, numbered Picture 1, 2, ... in the prompt), and the H3 encoder GGUF in the catalog (leejet/MiniMax-H3-GGUF Q4_K_M) carries the Qwen3-VL vision tower and DeepStack mergers, so unlike Qwen Image 2.1 no llmVision file gates them in workflowsForSpec. The catalog entry lists the same three workflows (AtomicBot-ai/atomic-chat-conf change/add-minimax-h3-image). Co-Authored-By: Claude Opus 5.5 --- src/diffusion/workflow.test.ts | 8 ++++++-- src/diffusion/workflow.ts | 14 ++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/diffusion/workflow.test.ts b/src/diffusion/workflow.test.ts index bf051566..d3183612 100644 --- a/src/diffusion/workflow.test.ts +++ b/src/diffusion/workflow.test.ts @@ -29,8 +29,12 @@ describe('workflowsForFamily', () => { expect(workflowsForFamily('krea-2-turbo')).toEqual(['create']) // sd.cpp runs FLUX.3 Klein's reference edits; they are not measured yet. expect(workflowsForFamily('flux.3-klein')).toEqual(['create']) - // Likewise MiniMax-H3-Image's reference edits (up to 16 pictures in sd.cpp). - expect(workflowsForFamily('minimax-h3-image')).toEqual(['create']) + // MiniMax-H3-Image creates and edits with one checkpoint (up to 16 pictures in sd.cpp); its + // encoder carries the vision tower, so no llmVision file is needed for the references. + expect(workflowsForFamily('minimax-h3-image')).toEqual(['create', 'reference', 'edit']) + expect( + workflowsForSpec({ family: 'minimax-h3-image', files: { diffusionModel: '/m/dit.gguf' } }) + ).toEqual(['create', 'reference', 'edit']) expect(workflowsForFamily('wan2.2-ti2v-5b')).toEqual(['create']) expect(workflowsForFamily('unknown')).toEqual(['create']) }) diff --git a/src/diffusion/workflow.ts b/src/diffusion/workflow.ts index 2b20e246..b41db90a 100644 --- a/src/diffusion/workflow.ts +++ b/src/diffusion/workflow.ts @@ -56,20 +56,22 @@ export function isQwenImage21(family: string): boolean { /** * img2img and masking are generic in sd.cpp (the init image is VAE-encoded and noised to `strength`, * a mask blends latents), so the established base families get them; a distilled model such as - * Krea 2 Turbo keeps to its verified Create, and so do FLUX.3 Klein and MiniMax-H3-Image until their - * edits are measured (sd.cpp runs them). Reference-guided generation and instruction edits need - * a model trained on reference images: FLUX.2 Klein and Qwen Image 2.1 (Turbo included, which the - * official checkpoint trains for editing), which also needs its vision projector loaded - * (`workflowsForSpec`). Anything else, video families included, only creates. + * Krea 2 Turbo keeps to its verified Create, and so does FLUX.3 Klein until its edits are measured + * (sd.cpp runs them). Reference-guided generation and instruction edits need a model trained on + * reference images: FLUX.2 Klein, Qwen Image 2.1 (Turbo included, which the official checkpoint + * trains for editing), which also needs its vision projector loaded (`workflowsForSpec`), and + * MiniMax-H3-Image, one checkpoint for both whose H3 encoder GGUF carries its own vision tower. + * Anything else, video families included, only creates. */ export function workflowsForFamily(family: string): ImageWorkflowId[] { if (isQwenImage21(family)) return ['create', 'reference', 'edit'] switch (family) { case 'flux.2-klein': return ['create', 'transform', 'inpaint', 'extend', 'upscale', 'reference', 'edit'] + case 'minimax-h3-image': + return ['create', 'reference', 'edit'] case 'krea-2-turbo': case 'flux.3-klein': - case 'minimax-h3-image': return ['create'] case 'z-image': case 'qwen-image': From a7e7606e86088160e8c4825bec04ec540b580272 Mon Sep 17 00:00:00 2001 From: Misha Skvortsov Date: Wed, 11 Nov 2026 17:26:09 +0300 Subject: [PATCH 3/3] diffusion: P-H3-Image on the H3 floor, with references and edits P-H3-Image (Pruna AI, leejet/stable-diffusion.cpp#2272) joins MiniMax-H3-Image: checkEngineCompatibility holds it to build 1088 and workflowsForFamily gives it create, reference and edit. Upstream added it in 1048, but the H3 transformer's buffer-limit chunking (#2286, #2292) landed later and 1088 is the build both were checked against, so the two share one floor. Pruna's Comfy text encoder carries Qwen3-VL-4B's vision tower and the P-H3 text connector in one file (sd.cpp detects P-H3 from text_encoders.llm.text_connector), so neither needs llmVision. Co-Authored-By: Claude Opus 5.5 --- docs/contracts.md | 2 +- docs/testing-critical-flows.md | 2 +- src/diffusion/compat.test.ts | 39 +++++++++++++++++++++------------- src/diffusion/compat.ts | 18 ++++++++++------ src/diffusion/workflow.test.ts | 13 ++++++++---- src/diffusion/workflow.ts | 8 ++++--- 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/docs/contracts.md b/docs/contracts.md index da5622a1..94dcd319 100644 --- a/docs/contracts.md +++ b/docs/contracts.md @@ -53,7 +53,7 @@ without a demonstrated consumer. See PLAN.md §5.1 for comparison rules and §8 | Tunnel probe: `GET /openapi.json`, `info.title` = `Atomic Chat API Server Endpoints` | `src/remote-access/probe.ts`, served by `src/server/public/static.ts` | `remote_access/probe.rs` | `probe.test.ts` asserts the marker against the document the public server really serves | | LAN addresses `GET /atomic/v1/lan-addresses` → `{addresses}` (IPv4, default route first, virtual adapters hidden, CGNAT kept) | `src/remote-access/{lan,lan-probe}.ts`, `src/server/control/routes/remote-access.ts` | image-generation line `remote_access/lan.rs` (`get_lan_addresses`) | ported `lan.rs` tables | | Image generation wire types (camelCase; absent vs `null` as the plugin's serde produced), the 23 `DiffusionErrorCode`s incl. `ENGINE_UPDATE_REQUIRED` (409) and `INVALID_OUTPUT` (500) (statuses informational: 400/404/409/429/507/500), `files.llmVision`, events `diffusion:{state,progress,job,error}` | `src/contracts/{diffusion,errors,events}.ts`, `src/diffusion/{parse,errors}.ts`, `src/server/http.ts` | image-generation line `web-app/src/services/diffusion/types.ts`, plugin `tauri-plugin-atomic-diffusion/src/{state,error,events}.rs` at `ec1fd3ea7` | `contracts/errors.test.ts` (code list), `diffusion/parse.test.ts`, `server/http.test.ts` | -| `sd-server` argv (`--llm_vision` after `--llm`) and environment (`GGML_METAL_TENSOR_DISABLE=1` on an M5 with Metal) and `POST /sdcpp/v1/img_gen` body; output parsing (records, step lines, tile passes, diagnostic tail, exit classification, GPU-fault markers); progress tracking; request validation (Qwen-Image on Metal ≤ 1 MP); per-family workflows and `workflowsForSpec`; engine gating (Qwen Image 2.1 and Krea 2 Turbo need build ≥ 883, FLUX.3 Klein ≥ 968, MiniMax-H3-Image ≥ 1088, `ENGINE_UPDATE_REQUIRED`) and install selection | `src/diffusion/{args,progress,tracker,validate,workflow,compat}.ts` | plugin `{args,progress,jobs,session}.rs` | the Rust `#[test]` tables ported by hand into the sibling tests; `test/fixtures/sdcpp/required-flags.txt` | +| `sd-server` argv (`--llm_vision` after `--llm`) and environment (`GGML_METAL_TENSOR_DISABLE=1` on an M5 with Metal) and `POST /sdcpp/v1/img_gen` body; output parsing (records, step lines, tile passes, diagnostic tail, exit classification, GPU-fault markers); progress tracking; request validation (Qwen-Image on Metal ≤ 1 MP); per-family workflows and `workflowsForSpec`; engine gating (Qwen Image 2.1 and Krea 2 Turbo need build ≥ 883, FLUX.3 Klein ≥ 968, MiniMax-H3-Image and P-H3-Image ≥ 1088, `ENGINE_UPDATE_REQUIRED`) and install selection | `src/diffusion/{args,progress,tracker,validate,workflow,compat}.ts` | plugin `{args,progress,jobs,session}.rs` | the Rust `#[test]` tables ported by hand into the sibling tests; `test/fixtures/sdcpp/required-flags.txt` | | Gallery files: `/-.png` with `tEXt` chunks `atomic` (the `ImageRecipe` JSON, every key, `null`s) and `parameters` (A1111 line) right after `IHDR`; `.thumb.png` (≤256 px); `.flags.json` `{id:{pinned,archived}}`. A PNG without a valid `atomic` recipe is foreign: never listed, never deleted. A batch with an all-black or all-white frame is refused before anything is saved (`INVALID_OUTPUT`); such an item an older build saved is hidden when its thumbnail (or PNG) is ≤ 128 KiB | `src/diffusion/{gallery,recipe,png}.ts` | plugin `gallery.rs` at `767ff6350` | ported `gallery.rs` tables; `test/fixtures/png/` (independent encoder, Pillow-checked); read-only run against images written by app v2.0.40 | | Engine installs `/diffusion/backends///` with `.atomic-owned` and `install.json` `{tag,backendId,backend,engine,sha256,installedAtMs}` (written by the core's engine-builds install; the app's `finalize` wrote the same before it); the `--help` probe markers `stable-diffusion.cpp` / `--cfg-scale`; model files under `/diffusion/models/` | `src/diffusion/{install,containment}.ts` | plugin `install.rs` | ported `install.rs` tables; read-only run against the engine installed by app v2.0.40 | | Engine builds (`engine` ∈ `ENGINE_BUILD_IDS`: `sd-cpp`, `audio-cpp`, `mlx`, `foundry-local`, `litert-lm`, `geniex`; change `move-sdcpp-mlx-install-to-core`, ADR 2026-10-07; audio.cpp: ADR 2026-10-29, conf `backends/audiocpp-manifest.json`, `ATOMIC_AUDIOCPP_MANIFEST_URL`, tags `vX.Y.Z[-a]`): `POST /atomic/v1/engine-builds/:engine/catalog {force?, proxy?}` → `{engine, manifest: {tag, published_at?, source: remote\|cache, fetched_at, error}\|null, manifest_error, host_backend_id, host_reason, host_download_bytes, installed[], active}` (`host_download_bytes`: every archive an install of the host build downloads, active build or not; `null` without one or with a size missing from the manifest), `POST …/updates {force?, proxy?}` → `{update_needed, current, target: {tag, backend_id, published_at?, download_bytes}\|null}`, `POST …/install {task_id, force?, proxy?}` (answers when done; `download:progress`/`download:stage` under `task_id`, cancel `POST /downloads/:task_id/cancel`) → `{installed, reason?: already-installed\|active-is-newer, build, retired[], kept_in_use[], failed_backend_ids?}`, `DELETE …/:tag/:backend_id` → `{removed}`; `engine` ∈ `sd-cpp`\|`mlx` (else `INVALID_ARGUMENT`), unknown body fields refused; errors `ENGINE_INSTALL_IN_PROGRESS`, `ENGINE_INSTALL_FAILED`, `BACKEND_INSUFFICIENT_DISK_SPACE` (< 3× the archives free), `CANCELLED`, `BACKEND_IN_USE`, `INVALID_REQUEST` (bundled or unmarked build), `UNSUPPORTED_BACKEND` (no build fits the host), `UPSTREAM_ERROR` (no manifest); event `engine-build:changed {engine, reason: install\|uninstall\|startup-cleanup}`. Manifests: conf `backends/sdcpp-manifest.json` and `backends/mlx-manifest.json`, overridable by `ATOMIC_SDCPP_MANIFEST_URL` / `ATOMIC_MLX_MANIFEST_URL` (`https://`, `file://`), cached at `/diffusion/sdcpp-manifest.cache.json` and `/mlx/mlx-manifest.cache.json`; probe failures remembered in `/diffusion/failed-backends.json`. MLX builds under `/mlx/backends//macos-arm64/` with `install.json {tag, backendId, sha256, installedAtMs, publishedAt}`; the installer's `/mlx-server` described by `mlx-server.json {tag, published_at}`; the newer by `published_at` runs, the installer on a tie | `src/engine-builds/`, `src/server/control/routes/engine-builds.ts`, `src/client/control-client.ts`, `src/contracts/engine-builds.ts` | app `web-app/src/services/diffusion/{install,backendMatrix}.ts` (branch `change/add-vllm-runtime`), conf `backends/{sdcpp,mlx}-schema.json` | `src/engine-builds/*.test.ts`, `routes/engine-builds.test.ts`, `control-client.test.ts`, `test/e2e/engine-builds.test.ts` | diff --git a/docs/testing-critical-flows.md b/docs/testing-critical-flows.md index b18070da..b4593239 100644 --- a/docs/testing-critical-flows.md +++ b/docs/testing-critical-flows.md @@ -40,7 +40,7 @@ Line coverage alone never raises a grade. A PR may not lower a grade. | Server gates: host, api key, CORS, preflight | Strong (contract) | `test/contract/proxy-http.test.ts` (default and trusted hosts, `*`, missing Host, IPv6 loopback refused, Bearer/`X-Api-Key`, whitelisted docs, `/configs` hidden, origin reflection, preflight method/header/host rules), `src/server/public/gates.test.ts`, `http.test.ts` (control listener guards), `test/e2e/public-server.test.ts` (key, trusted hosts, missing Host, hidden `/configs`, 405, preflight and origin reflection configured through control on the compiled binary; Swagger assets served byte-identical from the binary) | maintained | | Dynamic trusted hosts: the tunnel name and the accepted socket's address (stage 7c) | Strong (core) | `src/server/public/dynamic-hosts.test.ts` (the five `dynamic_hosts.rs` tests against the core's `isValidHost`; `*`, URLs, ports and paths can never become the tunnel name; every socket-address spelling: mapped, hex-mapped, zone id, bracketed IPv6, loopback and unspecified in both families), `test/contract/dynamic-hosts.test.ts` on a real listener under Node and Bun (403 → 200 with the origin reflected → 403; another `*.trycloudflare.com` stays a stranger; the same keep-alive connection is refused before and accepted after; preflight; a listener on `0.0.0.0` trusts the dialled LAN address, refuses a rebinding name on that socket and the LAN literal over loopback; a loopback bind gains nothing), `src/core/public-server.test.ts` (a real core, and a repeated start stays idempotent), the `proxy-http` set unchanged | a phone on the same Wi-Fi reaching a running app | | Remote access: the Cloudflare quick tunnel (stage 7d) | Strong (core, fake cloudflared and a stand-in edge), Missing (live) | `src/remote-access/manager.test.ts` (the app's 19 state-machine tests plus: a stuck supervisor loses the state, a second stop joins the first, a process that came up after shutdown is not kept, the process-exit guard), `process.test.ts` on a real child (URL + registration, URL only, silence, early exit, exit after ready, SIGTERM ignored then killed, an exit that cannot be confirmed, Windows goes straight to the kill, a program that cannot start, real argv and no `TUNNEL_*`), `cloudflared-{args,output}.test.ts` (tables), `probe.test.ts` (ours / foreign / unreachable, the marker against the real public server, edge by SNI with certificate verification on the tunnel name, 1033 until the tunnel is there, two silent rounds give up the edge, hostname fallback, abort), `journal.test.ts` (write-then-enrich, never resurrected after a clear, identity *and* name before a kill, start-time fallback, a real child ended and a real non-tunnel spared), `spawner.test.ts`, `wiring.test.ts` (test hooks), `src/core/remote-access.test.ts` on a real core (Host gate 403 → 401 with the key → 403 as the tunnel comes and goes, tunnel ended before `server:stopped`, an unchanged start leaves it alone, HTTP/2 retry with real processes, shutdown kills it, no binary), `src/core/public-server.test.ts`, `routes/remote-access.test.ts`, `control-client.test.ts`; `test/runtime-compat/address-pin.test.ts` under Node and Bun (a Node edge process reports the SNI the client really sent); `test/e2e/remote-access.test.ts` on the compiled app-core binary (refusal, online through the stand-in edge, journal, stop, ordering over SSE, HTTP/2 retry with the real 15 s, missing binary, a crash's journal consumed by the next owner, shutdown), plus stage 7q: a tunnel that exits after coming up reported as `exited` with its name no longer trusted and the public server untouched, a tunnel that ignores SIGTERM killed after the 5 s grace before `stop` answers `off`, and the journal Atomic Chat 2.0.40 left at the data root consumed once with the process it named spared | a real `cloudflared` against Cloudflare from a running app; a phone opening the URL | -| Image generation on stable-diffusion.cpp (stages 7e–7l) | Strong (core, fake engine, compiled binary, real engine), Missing (desktop) | pure ports with the plugin's `#[test]` tables: `src/diffusion/{args,progress,tracker,workflow,parse,validate,errors,recipe}.test.ts` (`args.test.ts` holds the argv to `test/fixtures/sdcpp/required-flags.txt`); disk: `png.test.ts` (fixtures from an independent encoder, Pillow-checked; damaged and unsupported files refused), `gallery.test.ts` (foreign PNGs never listed or deleted, flags file, atomic writes, export), `install.test.ts` (finalize probes a real script, owned trees only, model files inside the root), `containment.test.ts` (symlinks out of and into the root); process and jobs: `server-process.test.ts` on the fake engine (journalled before ready, capabilities, early exit with marked lines first, OOM, timeout kills, foreign listener stopped, abandoned load stopped), `jobs.test.ts` against an HTTP stub (the `jobs.rs` runner tests: completion with outputs and every transition, failures explained by the output, queue full, forgotten job, cancel ladder incl. the second grace, cancel wins over a waiting respawn, crash mid-job with the spec kept, ggml-abort CPU retry, transport errors, ceiling), `session.test.ts`, `idle.test.ts`, `service.test.ts` (the real fake engine: finalize → load → generate with progress → gallery → cancel → respawn → idle unload → shutdown, child dead each time); wiring: `routes/diffusion.test.ts` (every route, envelopes, the 64 MiB job body, 400 with the field named), `control-client.test.ts`, `src/core/create.test.ts` (a real owner: refused foreign data folder, finalize → load → generate over the control API, `processes.json` entry under `diffusion`, no chat session, events on the bus, engine output kept out of the log, the server dead after `shutdown`, then `POST /v1/images/generations` on the public listener: a PNG back, the gallery grown, the image model absent from `/v1/models`, an abandoned request's job cancelled); app v2.0.42 additions (7k–7l): `compat.test.ts` (build ≥ 883 for Qwen Image 2.1 / Krea 2 Turbo, ≥ 968 for FLUX.3 Klein, ≥ 1088 for MiniMax-H3-Image, odd tags fail closed, install selection never switches backends), `workflow.test.ts` / `validate.test.ts` (per-family workflows, Qwen Image 2.1's references only with `llmVision`, Qwen-Image on Metal ≤ 1 MP), `session.test.ts` (a stale spec refused before spawn, `activateInstall`), `service.test.ts` on the fake engine (a Qwen Image 2.1 load blocked on 849 then served by an 883 tree, `llmVision` checked and protected, an engine finalized during a running job cancels it and unloads the old server), `jobs.test.ts` (a blank frame fails the batch before anything is saved, a GPU fault in the attempt's lines retires the server and one printed before the job does not, a respawn reads the spec under the lock), `gallery.test.ts` / `png.test.ts` (blank detection, hidden items, verdicts kept per file), `server-process.test.ts` (`GGML_METAL_TENSOR_DISABLE` reaches the child only on an M5 with Metal); facade: `server/public/images-params.test.ts` (the `images_route.rs` tables), `images.test.ts` (503 before a model, 400 before that, the OpenAI body with the atomic extras, refusals to start, failed jobs, client gone → cancel, 504 with cancel) ; `test/e2e/diffusion.test.ts` on the compiled binary (finalize → load → events over SSE → gallery, flags and export → the OpenAI facade → unload with the journal cleared; a cancel the engine ignores stops the process and the next job respawns it; a crashed owner's `sd-server` is reaped by the next owner); the 7k–7l behaviour on the compiled binary (stage 7o): `test/e2e/diffusion-engine.test.ts` (Qwen Image 2.1 refused on build 849 with `ENGINE_UPDATE_REQUIRED`, nothing spawned, `load-blocked` on the stream, then served by an 883 tree of the same backend; the projector as `--llm_vision` right after `--llm` in the real argv, `reference`/`edit` offered only with it, the projector undeletable while loaded, an edit without it named `SIDE_FILE_MISSING`; a finalized newer engine unloads the resident model with `engine-updated`, the old tree removable only then and its empty tag folder gone, an unowned tree and a path outside the root refused) and `test/e2e/diffusion-failures.test.ts` (a blank frame ends the batch with `INVALID_OUTPUT`, nothing on disk or in the gallery, the same process serving the next seed and the facade answering 500; a GPU fault printed during the job retires the still-running server with `gpu-fault`, the model kept, the next job on a fresh pid; a ggml unsupported-op abort retried once on `--backend cpu` — two pids, the second with `cpuFallback` in the recipe and the status); the rest of the failure modes and the facade on the compiled binary (stage 7p): `diffusion-engine.test.ts` (Qwen-Image past 1 MP refused on a Metal engine before anything runs and the M5 switch absent from the engine's environment on a non-M5, `MODEL_MISSING` / `SIDE_FILE_MISSING` naming the file before any spawn, an early exit read as `OUT_OF_MEMORY` and a foreign listener as `MODEL_LOAD_FAILED` with both engines gone, an unload during a load answering `CANCELLED` with the child gone first), `diffusion-failures.test.ts` (an engine dying mid-job explained by its output, `crashed` then a respawn; a full queue as `QUEUE_FULL` and a failed job as `OUT_OF_MEMORY` with the engine left running, the facade answering 429 `busy` and 500 `insufficient_memory`), `diffusion.test.ts` (the output folder moved with the next picture under it, gallery items deleted with their thumbnails and a foreign PNG never listed or touched, model files listed, protected while loaded and deleted with their empty family folder after; a generation body over 64 MiB refused with the envelope and one below it read whole; the idle unload on the next tick with the spec forgotten), `test/e2e/images-api.test.ts` (OpenAI's envelope: `response_format` refused before the model check, 503 `model_not_loaded`, a broken body and a missing prompt, `size` and `n` named, 429 `busy` behind an Images-page job; a client that hangs up cancels the job with the engine kept — the binary-level case that found Bun's silence, ADR 2026-09-22; the key and Host gates in front, the request reported as `atomic-diffusion` on `images/generations` and the prompt absent from the API events with or without the inspector), `public-server.test.ts` (`/openapi.json` from the binary documents `POST /images/generations`); `test/live/diffusion.test.ts` on a real engine and FLUX.2 Klein (`--help` holds every flag of `required-flags.txt`, load, a 256² generation with parsed sampling progress, PNG + thumbnail + recipe, the facade, a hard cancel, respawn, unload; passed 2026-09-18 on `master-849-d04e895` and again 2026-09-21 on `master-883-137f740`, the build app v2.0.42 ships, on macOS arm64 in ~5 min); `test/live/diffusion-install.test.ts` (a real build installed from a conf-shaped manifest: picked for the host, downloaded, sha256-checked, unpacked, probed; a tampered sha256 refused; `--version` naming the tag's commit); both run per build by `engine-candidate.yml` with `engine=sd-cpp` on linux-x64, linux-arm64 and macos-arm64 (CPU archives), with the surface held to `test/fixtures/sdcpp/engine-contract.json` (`test/contract/sdcpp-{engine-contract,surface}.test.ts`); `src/diffusion/{jobs,service}.test.ts` also checks cancellation during validation/input reads, active owner shutdown, and readiness racing an aborted spawn; `test/e2e/diffusion.test.ts` checks explicit shutdown with an active job and an empty child journal | desktop acceptance from the Images page on the compiled binary and `test/live/diffusion.test.ts` on a real engine (7j), desktop acceptance from the Images page | +| Image generation on stable-diffusion.cpp (stages 7e–7l) | Strong (core, fake engine, compiled binary, real engine), Missing (desktop) | pure ports with the plugin's `#[test]` tables: `src/diffusion/{args,progress,tracker,workflow,parse,validate,errors,recipe}.test.ts` (`args.test.ts` holds the argv to `test/fixtures/sdcpp/required-flags.txt`); disk: `png.test.ts` (fixtures from an independent encoder, Pillow-checked; damaged and unsupported files refused), `gallery.test.ts` (foreign PNGs never listed or deleted, flags file, atomic writes, export), `install.test.ts` (finalize probes a real script, owned trees only, model files inside the root), `containment.test.ts` (symlinks out of and into the root); process and jobs: `server-process.test.ts` on the fake engine (journalled before ready, capabilities, early exit with marked lines first, OOM, timeout kills, foreign listener stopped, abandoned load stopped), `jobs.test.ts` against an HTTP stub (the `jobs.rs` runner tests: completion with outputs and every transition, failures explained by the output, queue full, forgotten job, cancel ladder incl. the second grace, cancel wins over a waiting respawn, crash mid-job with the spec kept, ggml-abort CPU retry, transport errors, ceiling), `session.test.ts`, `idle.test.ts`, `service.test.ts` (the real fake engine: finalize → load → generate with progress → gallery → cancel → respawn → idle unload → shutdown, child dead each time); wiring: `routes/diffusion.test.ts` (every route, envelopes, the 64 MiB job body, 400 with the field named), `control-client.test.ts`, `src/core/create.test.ts` (a real owner: refused foreign data folder, finalize → load → generate over the control API, `processes.json` entry under `diffusion`, no chat session, events on the bus, engine output kept out of the log, the server dead after `shutdown`, then `POST /v1/images/generations` on the public listener: a PNG back, the gallery grown, the image model absent from `/v1/models`, an abandoned request's job cancelled); app v2.0.42 additions (7k–7l): `compat.test.ts` (build ≥ 883 for Qwen Image 2.1 / Krea 2 Turbo, ≥ 968 for FLUX.3 Klein, ≥ 1088 for MiniMax-H3-Image and P-H3-Image, odd tags fail closed, install selection never switches backends), `workflow.test.ts` / `validate.test.ts` (per-family workflows, Qwen Image 2.1's references only with `llmVision`, Qwen-Image on Metal ≤ 1 MP), `session.test.ts` (a stale spec refused before spawn, `activateInstall`), `service.test.ts` on the fake engine (a Qwen Image 2.1 load blocked on 849 then served by an 883 tree, `llmVision` checked and protected, an engine finalized during a running job cancels it and unloads the old server), `jobs.test.ts` (a blank frame fails the batch before anything is saved, a GPU fault in the attempt's lines retires the server and one printed before the job does not, a respawn reads the spec under the lock), `gallery.test.ts` / `png.test.ts` (blank detection, hidden items, verdicts kept per file), `server-process.test.ts` (`GGML_METAL_TENSOR_DISABLE` reaches the child only on an M5 with Metal); facade: `server/public/images-params.test.ts` (the `images_route.rs` tables), `images.test.ts` (503 before a model, 400 before that, the OpenAI body with the atomic extras, refusals to start, failed jobs, client gone → cancel, 504 with cancel) ; `test/e2e/diffusion.test.ts` on the compiled binary (finalize → load → events over SSE → gallery, flags and export → the OpenAI facade → unload with the journal cleared; a cancel the engine ignores stops the process and the next job respawns it; a crashed owner's `sd-server` is reaped by the next owner); the 7k–7l behaviour on the compiled binary (stage 7o): `test/e2e/diffusion-engine.test.ts` (Qwen Image 2.1 refused on build 849 with `ENGINE_UPDATE_REQUIRED`, nothing spawned, `load-blocked` on the stream, then served by an 883 tree of the same backend; the projector as `--llm_vision` right after `--llm` in the real argv, `reference`/`edit` offered only with it, the projector undeletable while loaded, an edit without it named `SIDE_FILE_MISSING`; a finalized newer engine unloads the resident model with `engine-updated`, the old tree removable only then and its empty tag folder gone, an unowned tree and a path outside the root refused) and `test/e2e/diffusion-failures.test.ts` (a blank frame ends the batch with `INVALID_OUTPUT`, nothing on disk or in the gallery, the same process serving the next seed and the facade answering 500; a GPU fault printed during the job retires the still-running server with `gpu-fault`, the model kept, the next job on a fresh pid; a ggml unsupported-op abort retried once on `--backend cpu` — two pids, the second with `cpuFallback` in the recipe and the status); the rest of the failure modes and the facade on the compiled binary (stage 7p): `diffusion-engine.test.ts` (Qwen-Image past 1 MP refused on a Metal engine before anything runs and the M5 switch absent from the engine's environment on a non-M5, `MODEL_MISSING` / `SIDE_FILE_MISSING` naming the file before any spawn, an early exit read as `OUT_OF_MEMORY` and a foreign listener as `MODEL_LOAD_FAILED` with both engines gone, an unload during a load answering `CANCELLED` with the child gone first), `diffusion-failures.test.ts` (an engine dying mid-job explained by its output, `crashed` then a respawn; a full queue as `QUEUE_FULL` and a failed job as `OUT_OF_MEMORY` with the engine left running, the facade answering 429 `busy` and 500 `insufficient_memory`), `diffusion.test.ts` (the output folder moved with the next picture under it, gallery items deleted with their thumbnails and a foreign PNG never listed or touched, model files listed, protected while loaded and deleted with their empty family folder after; a generation body over 64 MiB refused with the envelope and one below it read whole; the idle unload on the next tick with the spec forgotten), `test/e2e/images-api.test.ts` (OpenAI's envelope: `response_format` refused before the model check, 503 `model_not_loaded`, a broken body and a missing prompt, `size` and `n` named, 429 `busy` behind an Images-page job; a client that hangs up cancels the job with the engine kept — the binary-level case that found Bun's silence, ADR 2026-09-22; the key and Host gates in front, the request reported as `atomic-diffusion` on `images/generations` and the prompt absent from the API events with or without the inspector), `public-server.test.ts` (`/openapi.json` from the binary documents `POST /images/generations`); `test/live/diffusion.test.ts` on a real engine and FLUX.2 Klein (`--help` holds every flag of `required-flags.txt`, load, a 256² generation with parsed sampling progress, PNG + thumbnail + recipe, the facade, a hard cancel, respawn, unload; passed 2026-09-18 on `master-849-d04e895` and again 2026-09-21 on `master-883-137f740`, the build app v2.0.42 ships, on macOS arm64 in ~5 min); `test/live/diffusion-install.test.ts` (a real build installed from a conf-shaped manifest: picked for the host, downloaded, sha256-checked, unpacked, probed; a tampered sha256 refused; `--version` naming the tag's commit); both run per build by `engine-candidate.yml` with `engine=sd-cpp` on linux-x64, linux-arm64 and macos-arm64 (CPU archives), with the surface held to `test/fixtures/sdcpp/engine-contract.json` (`test/contract/sdcpp-{engine-contract,surface}.test.ts`); `src/diffusion/{jobs,service}.test.ts` also checks cancellation during validation/input reads, active owner shutdown, and readiness racing an aborted spawn; `test/e2e/diffusion.test.ts` checks explicit shutdown with an active job and an empty child journal | desktop acceptance from the Images page on the compiled binary and `test/live/diffusion.test.ts` on a real engine (7j), desktop acceptance from the Images page | | Video generation on stable-diffusion.cpp (stage 9a–9f) | Strong (core, fake engine, compiled binary), Missing (real engine, desktop) | pure: `src/diffusion/{parse,validate,args,workflow}.test.ts` (the video parsers, the frame lattice `k·step+offset` and the nearest-point snap, the fixed rate, `--audio-vae`/`--embeddings-connectors` in order, `-M vid_gen` behind its switch, the `vid_gen` body with `custom_sigmas` at the schedule's step count, image-to-video refused), `server-process.test.ts` (capabilities per mode, a mode the spec needs but the engine lacks kills the server: `MODEL_INCOMPATIBLE`), `session.test.ts` (video capabilities, image capabilities refused on a video model), `state.test.ts` (kind-aware records); the seam: `image-job.test.ts`, `video-job.test.ts` (decode, the WebM preflight, the recipe, the events, the plan's decode tiling in the body and the threshold again on the CPU fallback), `jobs.test.ts` (the image suite unchanged after the refactor; a video job through the HTTP stub on its own events with one clip, the wrong modality both ways, the preflight, a native cancel; the estimate on the first event and a failed one that does not stop the job; the plan's decode tiling in the body and the decode's tiles on the progress; the heartbeat through a ten-second step with `elapsedMs` from the job's start, images still on change only); the estimate: `video-estimate.test.ts` (latent tokens per family, the tiled decode and its peak and work per layout, the decode tiling planned by memory — one graph on 24 GB, three strips on 18 GB, the finest on 16 GB, none under `model` offload, on the CPU fallback or on unknown memory —, LTX-2 on a 16 GB Mac `exceeds` with `seconds: null`, memory growing with frames and size, the 80 %/100 % lines, the three pools and both sides of a discrete GPU, the speed table and unknown hardware, CFG passes, ×2/×3 ranges, the history band), `video-tiling.test.ts` (sd.cpp's tile count ported, tile counts to sides and back, the work of a layout, the body's tile counts under both spellings), `video-history.test.ts` (which clips count, a past clip re-planned at its own size, three clips at twice the heuristic double the middle, the median and its clamp, the cache), `video-eta.test.ts` (every ETA and fraction scenario of the progress spec, both slowdown rules and their stickiness; a tiled decode counted down per tile, stretched, restarted on a retried pass, and a stalled tile), `tracker.test.ts` (a lost tile pass ended by `generating video:`; the decode's tiles counted, a retried pass counted from zero); disk: `video-recipe.test.ts` (every key, `null`s, strict on the way back), `video-gallery.test.ts` (EBML/DocType sniff, save writes the sidecar first, foreign `.webm` never listed or deleted, the poster kept verbatim and refused when not a PNG, flags, delete, export); service: `service.test.ts` on the fake in `vid_gen` mode (`estimateVideo`: the job's refusals, an answer while a clip runs with no event, history after the first clip and gone after its delete, no hardware facts refused while the clip still runs; load with the side files, a clip into `/videos` with its sidecar, the poster, the gallery, `cancelVideoJob`, the `VideosBackend` view, a video model on an image-only engine refused with the child dead, a build without WebM refused before submit; the decode tiled by the memory of a 16 GB Mac — one graph for 1024²×9, three strips for 2048²×17 — and its tiles reported); routes: `routes/diffusion-video.test.ts` (the estimate route too), `control-client.test.ts`; facade: `videos-params.test.ts` (seconds → frames, the video object from a job and from a clip, the path matcher, the listing query), `videos.test.ts` on a real listener (503/400/405, the queued object, poll, content and poster streamed, 404s, DELETE cancels or removes, the list merge and cursor, polls not reported); owner: `src/core/create.test.ts` (`/v1/videos` queue → poll → content equals the fixture → gallery → delete; the video model absent from `/v1/models`; only the video events); binary: `test/e2e/video.test.ts` (argv, `videoOutputDir`, the events over SSE, the clip and sidecar on disk, the poster, gallery ops, a cancel the engine ignores stops it and the next clip respawns, wrong modality at load and at generate, a missing side file before any spawn, no-WebM before submit and an unreported build's own 400; the estimate route and its refusal, `job.estimate` on the first event, the heartbeat through a 3 s step, `slowdown` when a step drags past three medians and 20 s; one graph for a clip past the old threshold that fits, and a tiled decode counted down tile by tile), `test/e2e/videos-api.test.ts` (the OpenAI envelope, queue/poll/download/list/DELETE, a finished clip answered after a restart, key and Host gates, reported as `atomic-diffusion` on `videos` without the prompt); live: `test/live/diffusion.test.ts` video block, not run yet (the estimate's coefficients are unmeasured, ADR 2026-09-28); desktop: the app's Video page, not yet | | Remote media: cloud and self-hosted providers' image and video models through the core (ADR 2026-10-13) | Strong (core, fake providers, compiled binary), Missing (live providers, desktop) | adapters: one `src/media/adapters/.test.ts` per provider API on a fake fetch (request shape, auth header, body, success parsing, error mapping, live listing; video submit/poll/download/cancel; key only on the provider origin, redirects off it bare), `registry.test.ts` (one adapter per dialect); pure: `src/media/{catalog,http,mask}.test.ts`, `remote-media.test.ts` (public params, inline images only, alpha masks), `parse.test.ts` (`target`/`remote`); I/O: `catalog-service.test.ts` (live → memory → disk → baseline, newest `catalog_version`, the `file://` hook), `remote-store.test.ts`; service: `src/media/service.test.ts` (catalog and registration adapters, refusals, live listing merged or failed), `src/diffusion/remote-job.test.ts` on the real `DiffusionService` (shared table and events, no busy slot, gallery PNG/JPEG/MP4, provider errors and `diffusion:error`, cancel without touching `sd-server`, the cap, a submit never retried, transient polls retried, a clip resumed after a restart without a second submit, a resumed clip past its ceiling timed out, shutdown keeps the stored job, the facades' `runImageJob`/`runVideoJob`); registry: `cloud/registry.test.ts` (media out of the key binding, absent keeps, `null` clears, other providers untouched), `router/resolve.test.ts`; routes: `routes/media.test.ts`, `control-client.test.ts`, `server/public/{images,videos}.test.ts` (remote generations and edits, 415/404/400, MP4 content), `src/core/create.test.ts` (owner: catalog and a live listing over control); binary: `test/e2e/remote-media.test.ts` (a self-hosted OpenAI-compatible stub registered over control: an image job over control into `/images`, `/v1/images/generations` by `/`, absent from `/v1/models`, a clip over `/v1/videos` saved as MP4, the key sent to the provider; an unconnected provider refused) | live runs against each provider (`test/live`), the app's Images/Video pages | | Audio generation on audio.cpp: builds, load, speech/music/effects jobs, cancel, gallery, `/v1/audio/speech` (ADRs 2026-10-29) | Strong (core, fake engine, compiled binary, real engine: upstream v0.9.3 on macOS Metal and CPU), Missing (fork builds, Windows/Linux real engine, desktop) | pure: `src/audio/{args,config,request,capabilities,wav,parse,output,recipe}.test.ts`, `src/server/public/audio-speech-params.test.ts`; process: `src/audio/server-process.test.ts` (fake `audiocpp_server`: ready, foreign listener, taken port, load failure, missing model), `jobs`/`session`/`service`/`idle` tests (cancel stops the server and keeps the spec, crash then respawn, a cancel under the load lock never deadlocks; replacement loads keep their state after an older teardown, reference reads reject a replaced model, shutdown waits for a loading child and journal cleanup), `gallery.test.ts` (foreign WAVs never listed or deleted); builds: `src/audio/install.test.ts` (probe `--version` + `--list-devices` on v0.9.3 fixtures), `src/engine-builds/{manifest,select,order,service}.test.ts` (shared ggml manifest, ladder without ROCm, failed rungs per engine); compiled binary: `test/e2e/{audio,audio-speech-api,engine-builds,engines}.test.ts` (including owner shutdown during an audio load); contract: `test/contract/audiocpp-*.test.ts` (flags and routes against `--help`, log strings the runtime reads); live: `test/live/audio-install.test.ts`, `test/live/audio.test.ts` (Stable Audio 3 Small SFX and Qwen3-TTS Base with a reference, Metal and CPU, 2026-10-29) | diff --git a/src/diffusion/compat.test.ts b/src/diffusion/compat.test.ts index 4986c33f..ee238f19 100644 --- a/src/diffusion/compat.test.ts +++ b/src/diffusion/compat.test.ts @@ -54,21 +54,30 @@ describe('checkEngineCompatibility', () => { } }) - it('holds MiniMax-H3-Image to build 1088, the one that added it upstream', () => { - for (const tag of ['unknown', 'master-968-8cd731e', 'master-1079-a3c49b1', 'master-1087-f8417d0']) - expect( - codeOf(() => checkEngineCompatibility('minimax-h3-image', tag)), - tag - ).toBe('ENGINE_UPDATE_REQUIRED') - for (const tag of ['master-1088-32d516c', 'master-1088-32d516c-a1234567', 'master-1100-abcdef0']) - expect(() => checkEngineCompatibility('minimax-h3-image', tag), tag).not.toThrow() - try { - checkEngineCompatibility('minimax-h3-image', 'master-1028-37bc88b-a5f9a63b') - expect.unreachable() - } catch (error) { - expect((error as { details?: string }).details).toBe( - 'installed=master-1028-37bc88b-a5f9a63b; required=master-1088-32d516c or newer' - ) + it('holds MiniMax-H3-Image and P-H3-Image to build 1088, the one that added MiniMax upstream', () => { + // P-H3-Image arrived in 1048 (#2272) but shares the H3 floor: 1088 is the build it was checked on. + for (const family of ['minimax-h3-image', 'p-h3-image']) { + for (const tag of [ + 'unknown', + 'master-968-8cd731e', + 'master-1048-3e92bf9', + 'master-1079-a3c49b1', + 'master-1087-f8417d0', + ]) + expect( + codeOf(() => checkEngineCompatibility(family, tag)), + `${family} ${tag}` + ).toBe('ENGINE_UPDATE_REQUIRED') + for (const tag of ['master-1088-32d516c', 'master-1088-32d516c-a1234567', 'master-1100-abcdef0']) + expect(() => checkEngineCompatibility(family, tag), `${family} ${tag}`).not.toThrow() + try { + checkEngineCompatibility(family, 'master-1028-37bc88b-a5f9a63b') + expect.unreachable() + } catch (error) { + expect((error as { details?: string }).details).toBe( + 'installed=master-1028-37bc88b-a5f9a63b; required=master-1088-32d516c or newer' + ) + } } }) diff --git a/src/diffusion/compat.ts b/src/diffusion/compat.ts index b6b94ef3..1c194640 100644 --- a/src/diffusion/compat.ts +++ b/src/diffusion/compat.ts @@ -1,7 +1,7 @@ /** * Which installed engine build may serve a model family. `check_engine_compatibility` and * `select_model_install` in `session.rs` of `tauri-plugin-atomic-diffusion` (app commit - * `ec1fd3ea7`); messages verbatim. The FLUX.3 Klein and MiniMax-H3-Image floors came after the plugin. + * `ec1fd3ea7`); messages verbatim. The FLUX.3 Klein and H3 image floors came after the plugin. */ import type { DiffusionBackendInstallRecord, DiffusionEngineId } from '../contracts/index.js' @@ -14,14 +14,19 @@ type EngineFloor = { build: number; tag: string } const MODERN: EngineFloor = { build: MIN_MODERN_FAMILY_BUILD, tag: 'master-883-137f740' } /** The first upstream build that runs FLUX.3 Image Klein (leejet/stable-diffusion.cpp#2143). */ const FLUX3: EngineFloor = { build: 968, tag: 'master-968-8cd731e' } -/** The first upstream build that runs MiniMax-H3-Image (leejet/stable-diffusion.cpp#2324). */ -const MINIMAX_H3_IMAGE: EngineFloor = { build: 1088, tag: 'master-1088-32d516c' } +/** + * The first upstream build that runs MiniMax-H3-Image (leejet/stable-diffusion.cpp#2324). P-H3-Image + * (#2272) arrived in 1048, but the H3 transformer's buffer-limit chunking (#2286, #2292) came later, + * so it shares this floor: the build both were checked against. + */ +const H3_IMAGE: EngineFloor = { build: 1088, tag: 'master-1088-32d516c' } const ENGINE_FLOORS: ReadonlyMap = new Map([ ['qwen-image-2.1', MODERN], ['qwen-image-2.1-turbo', MODERN], ['krea-2-turbo', MODERN], ['flux.3-klein', FLUX3], - ['minimax-h3-image', MINIMAX_H3_IMAGE], + ['minimax-h3-image', H3_IMAGE], + ['p-h3-image', H3_IMAGE], ]) /** `master--` → the build number; anything else → undefined. */ @@ -35,8 +40,9 @@ function buildOf(tag: string): number | undefined { } /** - * Qwen Image 2.1 and Krea 2 Turbo need build 883 or newer, FLUX.3 Klein 968, MiniMax-H3-Image 1088; - * a tag that does not parse fails closed. Every other family keeps whatever engine it has. + * Qwen Image 2.1 and Krea 2 Turbo need build 883 or newer, FLUX.3 Klein 968, MiniMax-H3-Image and + * P-H3-Image 1088; a tag that does not parse fails closed. Every other family keeps whatever engine + * it has. */ export function checkEngineCompatibility(family: string, tag: string): void { const floor = ENGINE_FLOORS.get(family) diff --git a/src/diffusion/workflow.test.ts b/src/diffusion/workflow.test.ts index d3183612..541e667a 100644 --- a/src/diffusion/workflow.test.ts +++ b/src/diffusion/workflow.test.ts @@ -31,10 +31,15 @@ describe('workflowsForFamily', () => { expect(workflowsForFamily('flux.3-klein')).toEqual(['create']) // MiniMax-H3-Image creates and edits with one checkpoint (up to 16 pictures in sd.cpp); its // encoder carries the vision tower, so no llmVision file is needed for the references. - expect(workflowsForFamily('minimax-h3-image')).toEqual(['create', 'reference', 'edit']) - expect( - workflowsForSpec({ family: 'minimax-h3-image', files: { diffusionModel: '/m/dit.gguf' } }) - ).toEqual(['create', 'reference', 'edit']) + // P-H3-Image likewise (up to 8 pictures); Pruna's encoder also carries the text connector. + for (const family of ['minimax-h3-image', 'p-h3-image']) { + expect(workflowsForFamily(family), family).toEqual(['create', 'reference', 'edit']) + expect(workflowsForSpec({ family, files: { diffusionModel: '/m/dit.gguf' } }), family).toEqual([ + 'create', + 'reference', + 'edit', + ]) + } expect(workflowsForFamily('wan2.2-ti2v-5b')).toEqual(['create']) expect(workflowsForFamily('unknown')).toEqual(['create']) }) diff --git a/src/diffusion/workflow.ts b/src/diffusion/workflow.ts index b41db90a..67d01239 100644 --- a/src/diffusion/workflow.ts +++ b/src/diffusion/workflow.ts @@ -59,9 +59,10 @@ export function isQwenImage21(family: string): boolean { * Krea 2 Turbo keeps to its verified Create, and so does FLUX.3 Klein until its edits are measured * (sd.cpp runs them). Reference-guided generation and instruction edits need a model trained on * reference images: FLUX.2 Klein, Qwen Image 2.1 (Turbo included, which the official checkpoint - * trains for editing), which also needs its vision projector loaded (`workflowsForSpec`), and - * MiniMax-H3-Image, one checkpoint for both whose H3 encoder GGUF carries its own vision tower. - * Anything else, video families included, only creates. + * trains for editing), which also needs its vision projector loaded (`workflowsForSpec`), and the + * H3 image models MiniMax-H3-Image and P-H3-Image, one checkpoint each for both, whose catalog text + * encoders carry their own vision tower (and P-H3's text connector). Anything else, video families + * included, only creates. */ export function workflowsForFamily(family: string): ImageWorkflowId[] { if (isQwenImage21(family)) return ['create', 'reference', 'edit'] @@ -69,6 +70,7 @@ export function workflowsForFamily(family: string): ImageWorkflowId[] { case 'flux.2-klein': return ['create', 'transform', 'inpaint', 'extend', 'upscale', 'reference', 'edit'] case 'minimax-h3-image': + case 'p-h3-image': return ['create', 'reference', 'edit'] case 'krea-2-turbo': case 'flux.3-klein':