mediacap

package
v0.206.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mediacap DERIVES this machine's media capability from its config, using the same bindings the pipeline routes on — so no surface has to DECLARE what the box can do.

A declared capability map is not merely stale, it is worse than none: it was wrong the moment a box changed engines. `offload_status` hardcoded "image_engine": "ComfyUI (local)" and handed that to an autonomous planner on a node whose `imagegen_engine` is "sdcpp" and which has no ComfyUI at all; doctor checked model aliases only, so it reported green while `generate_image` deferred on a render script that was not on disk. Both surfaces now read from here.

Three verdicts, and the middle one is the whole point:

  • CONFIGURED — bound, and every file it names exists. For the render-script routes that includes what the script loads: the model files of its graph, the custom-node classes it names, and the TTS python + weights for voice (routeneeds.go) — a script on disk over missing weights is not a capability.
  • NOT CONFIGURED — no binding on this box. The task defers by design; that is a legitimate state, not a fault.
  • BOUND-BUT-MISSING — the config names a file that is not there. The task defers at call time with a runner error, and until now nothing reported it.

Existence is checked the way the runners resolve it: a relative script path against the EXECUTABLE's directory (gpugen.ResolveScript's rule — an MCP host spawns the server with no meaningful cwd), an executable binding by stat when it is a path and by PATH lookup when it is a bare name ("node", "ffmpeg").

sdcppdevice.go — doctor-only diagnostic: which Vulkan device an sdcpp render on THIS box will actually use.

render/sdcpp-generate.mjs used to pin GGML_VK_VISIBLE_DEVICES=0 whenever the environment left it unset, on the assumption that device 0 is the render GPU. On a box with an enabled integrated GPU, ggml-Vulkan enumerates it FIRST: the <node-e> remediation (2026-09-23) measured Vulkan0 = Intel(R) UHD Graphics 630, Vulkan1 = NVIDIA GeForce RTX 5060 — every Z-Image render silently ran on the iGPU at 565-608 s/step (the same recipe runs 4.85 s/step on the RTX). The render script now auto-picks the first discrete adapter `sd-cli --list-devices` reports (see that file's header); DetectSdcppDevice mirrors the SAME resolution order in Go so `doctor` can report, without guessing, which device a render will actually land on and flag it when that device is an iGPU.

This is deliberately NOT part of mediacap.Routes/RoutesChecked: those stay a pure config+filesystem derivation for callers that run on every offload_status and acceptance pass (mediacap.go's own doc comment: "neither may make a network call per route" — a live subprocess spawn is the same class of cost). `doctor` already makes a live call for ComfyUI's /object_info (LiveNodeChecker); this is the same kind of doctor-only probe, invoked directly from runDoctor.

Index

Constants

View Source
const (
	// FingerprintPending: the file is being (or is about to be) hashed on this machine.
	FingerprintPending = "pending"
	// FingerprintUnreadable: the file is there but its content could not be read, or it changed while it was read.
	FingerprintUnreadable = "unreadable"
)

The two states a fingerprint takes besides a hash. A recipe file with either is never a match.

View Source
const (
	LaneVideo   = "video-gen"
	LaneAnimate = "animate"
	LaneAudio   = "audio-gen"
)

The lanes of a row: the fleet task types they belong to.

View Source
const (
	AnimateRowName = "wan-animate2"
	MusicRowName   = "acestep"
)

The names of the animation and music rows: the families the node advertises for those lanes.

View Source
const (
	RecipeRefusalCauseKey = "cause"
	// RecipeRefusalPending: every weight file the node lacks a fingerprint for is still being read, so it cannot say yet whether
	// the family is what it was sent. It has made no finding that anything changed.
	RecipeRefusalPending = "pending"
	// RecipeRefusalUnreadable: a weight file is there and could not be read, so the node cannot vouch for the family.
	RecipeRefusalUnreadable = "unreadable"
	// RecipeRefusalChanged: the family the node holds no longer digests to the digest it was sent, or the node no longer serves it.
	RecipeRefusalChanged = "changed"
)

The wire words of a node's 412. A node refuses an image dispatch whose recipe_digest is not the digest of the family it names with 412, and the JSON body of that refusal carries, beside "status" and "error", the member RecipeRefusalCauseKey with one of the causes below. The node writes it (fleetnode/image_recipe.go) and the delegator reads it (mediaremote/place.go), both from these constants, so a delegator can tell a node that has only not finished reading its weight files (a wait) from one whose files or binding are not what it published (a difference) without matching a sentence. A cause is a word of the wire: a test pins the values, because a node and a delegator of two builds must read them alike.

View Source
const (
	RecipeRoleCkpt = "ckpt"
	RecipeRoleClip = "clip"
	RecipeRoleVAE  = "vae"
	RecipeRoleLoRA = "lora"
	// RecipeRoleUpsampler is the prompt upsampler a flux3-klein graph runs before it renders (imagegen_upsampler): it writes the
	// caption the DiT renders, so another upsampler file is another picture.
	RecipeRoleUpsampler = "upsampler"
)

The file roles of a recipe.

View Source
const EngineComfyUI = "comfyui"

EngineComfyUI is the only engine a recipe is defined for: an sd.cpp binding renders other pixels for the same weights, so a ComfyUI recipe never matches it and a recipe is not built for it.

View Source
const RecipeVersion = 2

RecipeVersion is stamped into the digest, so a change to what a recipe digests can never collide with an older one. 2: each present weight file carries its content fingerprint (F59).

Variables

This section is empty.

Functions

func CheckManifestModels

func CheckManifestModels(manifest []byte) error

CheckManifestModels refuses a run-graph manifest whose models[] names an entry the node will not provision, with a *ManifestModelRefusedError naming the first one. A manifest with no models is fine. The keys are read exactly as the runner reads them (case-sensitively), so a spelling the runner would ignore cannot carry a value this check read.

func CheckManifestNodePacks

func CheckManifestNodePacks(manifest []byte) error

CheckManifestNodePacks refuses a run-graph manifest whose node_packs names anything but an allowlisted pack, with a *NodePackRefusedError naming the first one that is not. A manifest with no node_packs is fine. The keys are read exactly as the runner reads them (case-sensitively), so a spelling the runner would ignore cannot carry a value this check read.

func EditFamilyRoute

func EditFamilyRoute(name string) string

func ExecSdcppDeviceLister

func ExecSdcppDeviceLister(bin string) (string, error)

ExecSdcppDeviceLister is the real lister: `<bin> --list-devices`, combined stdout+stderr (sd.cpp release builds have printed device enumeration to either stream across versions), bounded by sdcppDeviceListTimeout so a wedged binary cannot hang doctor.

func FingerprintFile

func FingerprintFile(path string, size int64) (string, error)

FingerprintFile computes the fingerprint of the file at path, which must be size bytes long. It reads up to 64 MiB and is for a cache that runs it off the request path (Fingerprinter) and for a test.

func ImageFamilyRoute

func ImageFamilyRoute(name string) string

ImageFamilyRoute / EditFamilyRoute name a family's route in Routes/Map.

func IsDiscreteGpuName

func IsDiscreteGpuName(name string) bool

IsDiscreteGpuName reports whether name is a discrete NVIDIA/AMD adapter, or a discrete Intel Arc card (see discreteIntelArcRe above).

func IsFingerprint

func IsFingerprint(s string) bool

IsFingerprint reports whether s is a real fingerprint (a sha256 in hex) and not a state or garbage.

func IsIntegratedGpuName

func IsIntegratedGpuName(name string) bool

IsIntegratedGpuName reports whether name is a known Intel-integrated part — never the adapter to pick for a diffusion render (measured 2026-09-23: 565-608 s/step on an Intel UHD 630 vs 4.85 s/step on the same box's RTX 5060).

func KnownSize

func KnownSize(name string) (int64, bool)

KnownSize returns the byte size the installer recorded for a model file at download time, read from $OFFLOAD_HOME/installed.json (schema 2: components.<key>.{version,digest,size,source,installed_at}). ok is false when no manifest exists, it does not parse, or no component records a size for that file name — the overwhelming majority of ComfyUI-class weights on the fleet are sourced ad hoc from a peer box rather than this installer, and for those doctor keeps the exists-only verdict: it must never fabricate a size.

resolveBinding uses it to catch a file that is only PARTWAY copied into place: a bare os.Stat reports FOUND the instant a same-named file of ANY size exists in the right class directory, which is exactly what happened on <node-b> during the 2026-09-23 media-route remediation — doctor printed `animate_character: OK CONFIGURED` while a 16.65 GB unet was still ~70% written (register F-38). INCOMPLETE means the file is SMALLER than the size recorded when it was downloaded; a larger file (a newer, hand-placed build of the same name) is never flagged.

There is deliberately no literal size table in this package: a table here would be a second pin store that rots on every model update (ADR 0099 — floors never pins). This is also deliberately NOT a hash: comparing a size is one already-open os.Stat's Size() field, free; hashing a multi-GB file on every doctor run is the opposite of what doctor is for (F-38).

func ManifestSourcedModels

func ManifestSourcedModels(manifest []byte) map[string]bool

ManifestSourcedModels is the set of model names (the part after models/<class>/) that a run-graph manifest tells the node to FETCH: the entries with a source_url. The node's satisfier downloads them before it starts ComfyUI, so a graph that names one is not missing it. An entry without a source_url is not in the set: the satisfier defers when such a file is absent. A manifest that does not parse provisions nothing.

func Map

func Map(routes []Route) map[string]any

Map renders routes as the JSON media block offload_status returns: one entry per route name, each carrying its verdict, engine and bindings.

func MissingModelFiles

func MissingModelFiles(roots []ModelRoot, names []string) []string

MissingModelFiles returns, in order, the names that do not resolve under ANY class directory of ANY root. The class is not read from the node that loads the file: the harness does not know every loader (a custom node names its own class), and a node holding the file under a class its loader will not open fails in ComfyUI's own preflight, which stays the authority. A name that is not a safe relative path is missing.

It lists every missing name; MissingModelFilesUpTo is the form that stops looking.

func MissingModelFilesUpTo

func MissingModelFilesUpTo(roots []ModelRoot, names []string, limit int) (missing []string, more bool)

MissingModelFilesUpTo is MissingModelFiles for a caller that shows only the first few: it returns at most limit of the missing names, in order, and more is true when there was a further one (it looks no further than the limit+1th missing name). A limit of 0 or less means no limit, and more is then false.

The cost of a call is bounded by the limit and not by the graph. A graph can name thousands of files (a dispatch body may be 1 MiB), the door that asks answers any holder of the fleet bearer on the tailnet, and a name that is missing costs one stat per class directory of every root, so a name-by-name resolve of a 16,875-name graph took 3.5 s on a 20-class-directory tree (a scratch measurement, 2026-10-10, one host) before it ruled. Two things bound it now: each root's class directories are listed ONCE per call, not once per name (the listing of a root is a directory read plus a stat for every entry that is not itself a directory), and the search stops at the limit+1th missing name. The count of the missing names beyond that is therefore not known, and a caller says "more" and not a number.

func ModelExtensions

func ModelExtensions() []string

ModelExtensions are the weight file extensions the scan reads a loader's file by (a copy: the list is the scan's own).

func ModelFileSizes

func ModelFileSizes(roots []ModelRoot, names []string, stat func(path string) (size int64, ok bool)) (sizes []int64, missing string, ok bool)

ModelFileSizes returns the size in bytes of each of names, in order: the reading of a graph's weight files for the one reader that needs their SIZES, the host-RAM estimate of a graph (internal/hostneed.ForGraph). A name is looked up exactly as MissingModelFiles looks it up, under every class directory of every root and only as a safe relative path (a graph carries no class, see the top of this file), and the roots are listed once per call.

It is all or nothing: the first name that does not resolve ends the look and is returned in missing, with ok false and no sizes, because a sum that leaves a file out is a figure that shrinks, and the caller keeps what it had. A file of no length is not a size and reads as unresolved. A name held under more than one class directory is sized as the LARGER of them: the graph does not say which the loader opens, and the smaller would shrink the figure. stat is os.Stat unless a test supplies a table.

func ModelSourceHosts

func ModelSourceHosts() []string

ModelSourceHosts returns the hosts a manifest model may be fetched from.

func PickDiscreteVulkanDevice

func PickDiscreteVulkanDevice(devices []VulkanDevice) string

PickDiscreteVulkanDevice returns the first discrete adapter's index in listed order, "" when none of devices is discrete.

func ResolveModelFile

func ResolveModelFile(roots []ModelRoot, f ModelFile, stat func(path string) (size int64, ok bool)) (int64, bool)

ResolveModelFile finds f under the class directories of roots and returns its size in bytes. The name is tried as the ComfyUI-relative path the loader would open (subfolders included); it never walks a tree looking for the basename, because the host-RAM estimate runs at every grant and a walk of a 70 GiB model tree is not free. stat is os.Stat unless a test supplies a table.

func ResolveModelFilePath

func ResolveModelFilePath(roots []ModelRoot, f ModelFile, stat func(path string) (size int64, ok bool)) (path string, size int64, ok bool)

ResolveModelFilePath is ResolveModelFile that also says WHICH file it found, for a reader that must open it (the recipe's content fingerprint).

func VideoBinding

func VideoBinding(cfg config.Config, family string) (runnerFamily string, fb config.VideoFamilyBinding)

VideoBinding is the runner family and the EFFECTIVE binding a video render of the named family ("" = this box's default family) loads with: config.ResolveVideoFamilyBinding, the resolution the pipeline renders with. wan22, ltx25, h3 and hunyuan; anything else is Wan 2.2, as the runner treats it.

func VideoFamilyRoute

func VideoFamilyRoute(name string) string

VideoFamilyRoute names a non-default sdcpp video family's route.

Types

type AllowedNodePack

type AllowedNodePack struct {
	Name string
	Repo string
}

AllowedNodePack is one pack a manifest may name: the directory it installs under and the repository to clone.

func AllowedNodePacks

func AllowedNodePacks() []AllowedNodePack

AllowedNodePacks returns the allowlisted packs.

type Binding

type Binding struct {
	Key      string       // config key ("imagegen_ckpt")
	Name     string       // configured value (ComfyUI-relative name)
	Expected []string     // class directories the render scripts load it from
	FoundIn  []string     // class directories that hold it (any root)
	State    BindingState // FOUND / MISSING / MISPLACED
	Detail   string
}

Binding is one configured model file and where it was (or was not) found.

func ModelBindings

func ModelBindings(cfg config.Config) []Binding

ModelBindings resolves every configured ComfyUI model name against the class directories of every models root. Nil when the box has no models root.

type BindingState

type BindingState string

BindingState is a model binding's verdict.

const (
	// BindingFound — the file exists in a class directory the graph loads from.
	BindingFound BindingState = "FOUND"
	// BindingMissing — the file exists in no class directory of any models root.
	BindingMissing BindingState = "MISSING"
	// BindingMisplaced — the file exists under a models root, but only in a
	// class directory the graph never loads from (the 2026-08-31 krea2 shape).
	BindingMisplaced BindingState = "MISPLACED"
	// BindingIncomplete — a file of this name sits at the expected path, but its
	// size is below the size KnownSize recorded: a copy or download still in progress
	// (or a truncated one), not a usable weight file. Only reported for a name
	// KnownSize actually records — F-38.
	BindingIncomplete BindingState = "INCOMPLETE"
)

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache memoizes a route derivation per config for at most its TTL.

func NewCache

func NewCache(ttl time.Duration, now func() time.Time, derive func(config.Config) []Route) *Cache

NewCache builds a Cache. now and derive are seams: production passes time.Now and Routes.

func (*Cache) Reset

func (c *Cache) Reset()

Reset drops every cached verdict, so the next read goes to the disk again.

func (*Cache) Routes

func (c *Cache) Routes(cfg config.Config) []Route

Routes returns cfg's routes, at most the TTL old.

func (*Cache) RoutesKeyed

func (c *Cache) RoutesKeyed(k Key, cfg config.Config) []Route

RoutesKeyed is Routes for a caller that already holds cfg's key (KeyOf(cfg)); the key is trusted.

type FamilyRow

type FamilyRow struct {
	Name          string  `json:"name"`
	Family        string  `json:"family"`
	Engine        string  `json:"engine"`
	Ckpt          string  `json:"ckpt"`
	License       *string `json:"license"`
	CommercialUse *bool   `json:"commercial_use"`
	Default       bool    `json:"default"`
	State         string  `json:"state"`
}

FamilyRow is one binding a request's `family` param can select, as offload_status (media.image_families / media.edit_families) and /fleet/health publish it. The default binding comes first. License and CommercialUse are null when the binding declares none (a default binding that never set imagegen_license): a reader must treat that as UNKNOWN, never as commercial-safe. State is the binding's route verdict from the same derivation as media.routes.

func EditFamilyRows

func EditFamilyRows(cfg config.Config, routes []Route) []FamilyRow

EditFamilyRows is ImageFamilyRows for the generative edit route.

func ImageFamilyRows

func ImageFamilyRows(cfg config.Config, routes []Route) []FamilyRow

ImageFamilyRows lists this box's image bindings with their verdicts (routes is Routes(cfg), passed in so one status call derives the filesystem view once).

type FingerprintFunc

type FingerprintFunc func(path string, size int64) string

FingerprintFunc answers the fingerprint of the weight file at path whose size is size: a hash, or FingerprintPending or FingerprintUnreadable. It is how ImageRecipeWith reads content, so a caller picks the blocking behaviour and a test supplies its own.

type Fingerprinter

type Fingerprinter struct {
	// contains filtered or unexported fields
}

Fingerprinter caches weight-file fingerprints and hashes them one at a time.

func NewFingerprinter

func NewFingerprinter() *Fingerprinter

NewFingerprinter builds a Fingerprinter that reads the real files.

func NewFingerprinterWith

func NewFingerprinterWith(hash func(path string, size int64) (string, error)) *Fingerprinter

NewFingerprinterWith is NewFingerprinter over a different hash, for a test that must count, delay or fail the read.

func SharedFingerprints

func SharedFingerprints() *Fingerprinter

SharedFingerprints is the process-wide Fingerprinter. A fingerprint is a property of the file, not of a server or a config, so one cache serves the node's health, its 412 re-check and a delegator running in the same process.

func (*Fingerprinter) Await

func (f *Fingerprinter) Await(path string, size int64) string

Await is AwaitContext for a caller with no context of its own: it still ends at awaitMax.

func (*Fingerprinter) AwaitContext

func (f *Fingerprinter) AwaitContext(ctx context.Context, path string, size int64) string

AwaitContext answers with the file's fingerprint, reading it when it is not cached (behind any read already running). It answers FingerprintUnreadable for a file it cannot read, and FingerprintPending when the read has not settled by the time awaitMax has passed or ctx is done: the read goes on and a later call finds its result. One deadline covers the whole call, the retry-at-once below included.

func (*Fingerprinter) Generation

func (f *Fingerprinter) Generation() uint64

Generation counts the reads that have settled. A caller that memoises what Peek told it can tell that a pending answer may have become a hash.

func (*Fingerprinter) Peek

func (f *Fingerprinter) Peek(path string, size int64) string

Peek answers from the cache and never reads the file's content on the caller's goroutine. A file not yet hashed starts a background read and answers FingerprintPending; the hash is there on a later call. A read that failed is remembered for fingerprintRetry (FingerprintUnreadable), then tried again.

type GraphFiles

type GraphFiles struct {
	// Models are the weight file names, each once, ordered by node id and then input key.
	Models []string
	// Inputs are the files an input loader reads (LoadImage, LoadVideo, LoadAudio), in node id order.
	Inputs []GraphInput
}

GraphFiles is what a graph names.

func ScanGraph

func ScanGraph(graph []byte) (GraphFiles, error)

ScanGraph reads the files a graph names. It is an error only for a document that is not a JSON object; a node or an input it cannot read is skipped (ComfyUI's own preflight is the authority on a malformed graph).

type GraphInput

type GraphInput struct {
	Name string
	// Dir is "input", "output" or "temp": the annotation on the name, "input" when it has none.
	Dir string
}

GraphInput is an input file (an image, a video or an audio clip) that an input loader of a graph reads: the name, and which of ComfyUI's directories it is in.

func MissingInputFiles

func MissingInputFiles(comfyDir string, inputs []GraphInput) []GraphInput

MissingInputFiles returns, in order, the input files that are not under comfyDir's input, output or temp directory (as each one's annotation says). An empty comfyDir holds nothing. By name only (see the top of this file).

type Key

type Key [sha256.Size]byte

Key identifies a config for the cache: the hash of its JSON form.

func KeyOf

func KeyOf(cfg config.Config) (key Key, ok bool)

KeyOf computes cfg's Key. ok is false for a config that cannot be encoded: such a config has no key and is never cached (what cannot be told apart is never shared). A caller that holds one config for its whole life computes the key once and uses RoutesKeyed, so a hot path never encodes the config again.

type LaneRow

type LaneRow struct {
	// Lane is the fleet task type (LaneVideo, LaneAnimate, LaneAudio).
	Lane string `json:"lane"`
	// Name is the name a caller reaches the family by: a video row carries the value of the `model` parameter (wan22, ltx25,
	// h3, hunyuan, or an sd.cpp family's own name), an animation row the family the node advertises for it (wan-animate2), an
	// audio row the family of its music lane (acestep).
	Name    string `json:"name"`
	Default bool   `json:"default"`
	// Engine is comfyui or sdcpp.
	Engine string `json:"engine"`
	// Digest is empty in this release: a row built from sizes is never an identity.
	Digest string `json:"digest"`
	// Files are the weight files, in the order the family's graph loads them. Name is the ComfyUI-relative name (subfolders
	// included) for a ComfyUI row and the bare file name for an sd.cpp row; never an absolute path.
	Files         []RecipeFile `json:"files"`
	License       string       `json:"license,omitempty"`
	CommercialUse *bool        `json:"commercial_use,omitempty"`
}

LaneRow is one row of /fleet/health media_recipes.

func LaneRows

func LaneRows(cfg config.Config) []LaneRow

LaneRows lists the rows of this machine's video, animation and audio bindings: video first (the default family, then the other ComfyUI families, then the sd.cpp ones), then animation, then music. A lane is listed when its binding NAMES a renderer this release can describe: a ComfyUI script on a machine that HAS a ComfyUI install (comfy_dir is a directory here), or an sd.cpp video family. The shipped default config binds the three ComfyUI scripts on every machine, so a script alone says nothing about this one, and a machine with no install publishes no ComfyUI row. Whether the node can serve a lane right now is the route state's business (media_routes), and a row of a binding whose weights are gone is still listed, with bytes -1, so that a refusal can name them. The audio.cpp engines, the sd.cpp animation lane and voice have no row: a reader takes that as unknown.

type ManifestModelRefusedError

type ManifestModelRefusedError struct {
	// Model is the entry as the manifest named it (its path, else its place in the list).
	Model string
	// Reason says which part of the entry did not pass.
	Reason string
}

ManifestModelRefusedError is a manifest's refusal for a models[] entry the node will not provision.

func (*ManifestModelRefusedError) Error

func (e *ManifestModelRefusedError) Error() string

type ModelFile

type ModelFile struct {
	// Label says where the name came from (a config key, or "<builder> default").
	Label string
	// Name is the ComfyUI-relative filename.
	Name string
	// Classes are the class directories the loader opens it from.
	Classes []string
	Role    ModelRole
}

ModelFile is one weight file a route's graph loads.

func AnimateModelFiles

func AnimateModelFiles(cfg config.Config) []ModelFile

AnimateModelFiles is WAN-Animate-2's four files.

func EditModelFiles

func EditModelFiles(cfg config.Config) []ModelFile

EditModelFiles is ImageModelFiles for the generative edit route: the UNet and the text encoder (the 2511 graph has a builder default for it; the 2.1 graph has none and requires the binding).

func ImageModelFiles

func ImageModelFiles(cfg config.Config) []ModelFile

ImageModelFiles is what the image route's graph loads for this (effective) binding: the checkpoint or UNet the binding names and the text encoder, bound or the builder's default for a family that has one (qwen-image, krea2). A binding that names nothing contributes nothing: the caller falls back to a per-family default size.

func InpaintModelFiles

func InpaintModelFiles(cfg config.Config) []ModelFile

InpaintModelFiles is the SDXL inpaint checkpoint (inpaint_ckpt).

func MusicModelFiles

func MusicModelFiles() []ModelFile

MusicModelFiles is ACE-Step 1.5's files (no config key binds them).

func VideoModelFiles

func VideoModelFiles(cfg config.Config, family string) []ModelFile

VideoModelFiles is what the video route loads for the named runner family ("" = this box's default family), by the same binding the render resolves (VideoBinding).

func VideoModelFilesFor

func VideoModelFilesFor(runnerFamily string, fb config.VideoFamilyBinding) []ModelFile

VideoModelFilesFor is what the video graph of runnerFamily loads with the binding fb: the files fb names and, for every one it leaves unset, the builder's default. The binding is the caller's to adjust first (a request that names its own transformer, a hand-run helper whose flags are its whole binding); VideoModelFiles is this over the binding the box resolves.

type ModelRole

type ModelRole string

ModelRole says what a weight file is to the host-RAM estimate.

const (
	// RoleDiffusion is the denoiser: a checkpoint, a UNet, a transformer, an expert.
	RoleDiffusion ModelRole = "diffusion"
	// RoleTextEncoder is the text (or text+vision) encoder the graph loads beside it.
	RoleTextEncoder ModelRole = "text-encoder"
	// RoleOther is everything small: VAEs, LoRAs, upscalers, vision towers. Not counted.
	RoleOther ModelRole = "other"
)

type ModelRoot

type ModelRoot struct {
	Label   string
	Dir     string
	Classes map[string][]string // nil = every subdirectory of Dir is a class
}

ModelRoot is one place ComfyUI resolves class directories: the install's own models/ (every subdirectory is a class) or one extra_model_paths.yaml entry (base_path plus an explicit class -> subdirectories map, exactly as ComfyUI's folder_paths reads it).

func ModelRoots

func ModelRoots(comfyDir string) []ModelRoot

ModelRoots lists the models roots ComfyUI would search for comfyDir: its models/ directory when present, then every entry of extra_model_paths.yaml beside it (a relative base_path resolves against comfyDir). Nil when neither exists — a box without ComfyUI has nothing to bind.

type MulticardRow

type MulticardRow struct {
	ID, Route, Family, Quant string
	// UnetMatch and ClipMatch are case-insensitive regular expressions on the DiT file and the text-encoder file; DefaultClip stands in for a call
	// that names no text encoder (the builder's own).
	UnetMatch, ClipMatch, DefaultClip string
	// UnetLoader is plain (the whole DiT on the compute card), distorch2 or gguf-distorch2 (a split DiT); ClipLoader is plain (the encoder whole on
	// the storage card), distorch2 (a split encoder that fits one card while it is built) or distorch2-host (a bf16 encoder too big for one card, built off
	// the cards and split over both by the harness's own loader).
	UnetLoader, ClipLoader string
	// ResidentGiB is the share of a split DiT kept on the compute card; ClipResidentGiB the share of a split text encoder.
	ResidentGiB, ClipResidentGiB float64
	// ComputeGiB and StorageGiB are the per-card VRAM peaks a call on this row is held to.
	ComputeGiB, StorageGiB float64
	// Measured: the row's host growth was read in a run that used the read-only loader.
	Measured bool
	// MaxMegapixels is the largest edit canvas the compute peak is scaled to (0 = the row has none). The runner refuses a pinned canvas above it
	// (render/comfy-edit.mjs planEdit), and so does the typed door before it leases the pair (internal/pipeline multicardNeed).
	MaxMegapixels float64
	// MaxPixels is the largest canvas (width times height) a call on this row may ask for (0 = the row has none). It is the JSON's "maxPixels", pinned by
	// TestTheMulticardRowsAreTheRunnersRecipes, and the number is chosen, not measured (the JSON's "maxPixelsNote"). The runner refuses a larger canvas
	// (render/multicard-recipes.mjs canvasRefusal) only after the pair was held; the typed door refuses it first (internal/pipeline mediaNeed.forCanvas).
	// For the two qwen-image-2.1 edit rows it is the DiT-sequence cap, judged by the runner alone (render/comfy-edit.mjs planEdit); the typed door's forCanvas is image-only.
	MaxPixels int64
	// Blocked is why the row may not launch (empty = it may): the row stays in the table, but it is no recipe to FindMulticardRow, so the estimate, the
	// doctor and the typed doors treat the binding as one without a recipe, and the runner refuses it by name (render/multicard-recipes.mjs findRecipe).
	// The sentence is the JSON's "blocked", pinned by TestTheMulticardRowsAreTheRunnersRecipes.
	Blocked string
	// LoraLoader is the node class that applies a LoRA to the DiT under this recipe ("" = the recipe has none to name).
	LoraLoader string
	// Packs are the custom-node packs the recipe's loaders need: multigpu, and gguf for a GGUF DiT.
	Packs []string
}

MulticardRow is one recipe: the identity of the call it serves, how the runner loads it and the figures that decide a declaration.

func BlockedMulticardRow

func BlockedMulticardRow(route, family string, files []ModelFile) *MulticardRow

BlockedMulticardRow is the row a call matches when that row is held back (Blocked), else nil: a call with no row at all, or a launchable one, has none. The typed door uses it to say which row and why when it refuses the binding.

func FindMulticardRow

func FindMulticardRow(route, family string, files []ModelFile) *MulticardRow

FindMulticardRow finds the recipe for a call: the route ("image" or "edit"), the graph family, the DiT file and the text-encoder file (the binding's own, else the builder's default), taken from the call's model files. nil = no recipe (a row that is held back is no recipe); the runner refuses such a call by name, and everything else sizes it as it always did.

func MulticardRows

func MulticardRows() []MulticardRow

MulticardRows is a copy of the recipe table, for the tests that pin it to the runner's file and for the docs.

func (MulticardRow) NodeClasses

func (r MulticardRow) NodeClasses() []string

NodeClasses are the node classes the runner's graph names for this recipe's loaders (render/multicard-recipes.mjs multicardLoaders): the DiT's, the text encoder's and the VAE's. All of them come from ComfyUI-MultiGPU, and the GGUF DisTorch2 loader needs ComfyUI-GGUF beside it. A distorch2-host text encoder is the runner's OffloadCLIPLoaderDisTorch2, a class of the harness's own pack (never in custom_nodes: the launch the runner makes loads it, and its preflight asks for it by name); it wraps ComfyUI-MultiGPU's CLIPLoaderDisTorch2MultiGPU, so that is the class named here for the doctor to check.

func (MulticardRow) Plain

func (r MulticardRow) Plain() bool

Plain reports a recipe that puts the whole DiT on the compute card (no resident share to set).

type NodeCheck

type NodeCheck struct {
	Missing []string // classes this install cannot build
	Via     string   // how it was decided: live /object_info, or custom_nodes on disk
}

NodeCheck answers "can this ComfyUI build these node classes?".

func DiskNodeCheck

func DiskNodeCheck(comfyDir string, classes []string) NodeCheck

DiskNodeCheck decides from <comfy_dir>/custom_nodes: a class is present when every pack it needs is an active pack directory there (not disabled, has __init__.py) — matched by name, or by the pack's marker class in its python source when the directory was renamed. A class no pack provides is core ComfyUI. Import errors are invisible from disk; the live check sees those.

type NodeChecker

type NodeChecker func(comfyDir string, classes []string) NodeCheck

NodeChecker decides a set of classes for the ComfyUI install at comfyDir.

func LiveNodeChecker

func LiveNodeChecker(api string, timeout time.Duration) NodeChecker

LiveNodeChecker asks a RUNNING ComfyUI (GET /object_info/<class>), which also sees a pack that is on disk but failed to import. It never starts one: when api does not answer (or answers something that is not the object map), it falls back to DiskNodeCheck and says so, for this call and every later one in the process.

type NodePackRefusedError

type NodePackRefusedError struct {
	// Pack is the pack as the manifest named it (its name, else the name its repository gives it, else its place in the list).
	Pack string
	// Reason says which part of the pack did not match.
	Reason string
}

NodePackRefusedError is a manifest's refusal: it names a pack whose repository this node does not allowlist.

func (*NodePackRefusedError) Error

func (e *NodePackRefusedError) Error() string

type Recipe

type Recipe struct {
	Engine string       `json:"engine"`
	Graph  string       `json:"graph"`
	Files  []RecipeFile `json:"files"`
	Preset string       `json:"preset,omitempty"`
	// The sampling the render uses. For a graph family in builderSampling a key the binding leaves unset is the
	// builder's default (Explicit says which keys the binding actually set); for any other graph family an unset
	// key stays unset, which is stricter, never looser.
	Steps        int     `json:"steps,omitempty"`
	CFG          float64 `json:"cfg,omitempty"`
	Sampler      string  `json:"sampler,omitempty"`
	Scheduler    string  `json:"scheduler,omitempty"`
	Schedule     string  `json:"schedule,omitempty"`
	Shift        float64 `json:"shift,omitempty"`
	LoRAStrength float64 `json:"lora_strength,omitempty"`
	// UpsamplerModel is a flux3-klein binding's llama-swap upsampler (imagegen_upsampler in its model form): another model writes another
	// caption, so it is part of what renders alike. By NAME only: the model's weights live in llama-swap, not in the ComfyUI roots.
	UpsamplerModel string `json:"upsampler_model,omitempty"`
	License        string `json:"license,omitempty"`
	CommercialUse  *bool  `json:"commercial_use,omitempty"`
	// Explicit lists the sampling keys (steps, cfg, sampler, scheduler, schedule) the binding SET, as opposed to
	// taking the builder's default. It is NOT in the digest. It exists for the one place the two spellings render
	// differently: a request that carries its own `steps` is only valid on a graph that takes steps and cfg
	// together when the binding set cfg too (see PairsStepsAndCFG).
	Explicit []string `json:"explicit,omitempty"`
}

Recipe is the resolved identity of one image binding.

func ImageRecipe

func ImageRecipe(cfg config.Config, fi config.FamilyInfo, roots []ModelRoot, stat func(path string) (int64, bool)) (Recipe, bool)

ImageRecipe is the recipe of an EFFECTIVE image binding (the config a request's family resolved to, with fi its FamilyInfo). roots are the models roots the files are looked up under (ModelRoots of the ComfyUI directory) and stat reads a size (nil = the file system); both are the caller's so a test needs no model tree. ok is false for a binding that is not a ComfyUI one: no recipe is defined for it, and it never matches another.

ImageRecipe WAITS for each present file's content fingerprint (SharedFingerprints().Await). NO PRODUCTION CODE CALLS IT any more: the callers that need the answer read through ImageRecipeWith with the AwaitContext of their own request, so that the wait ends with the request (the delegator's own identity, mediaremote.localIdentity, and the node's 412 re-check, fleetnode.checkRecipe), and the node's health uses ImageRecipeWith with Peek, which never waits. ImageRecipe stays as the blocking spelling for tests and for a caller with no request to bound the wait by (the wait still ends at the fingerprinter's own bound).

func ImageRecipeWith

func ImageRecipeWith(cfg config.Config, fi config.FamilyInfo, roots []ModelRoot, stat func(path string) (int64, bool), fp FingerprintFunc) (Recipe, bool)

ImageRecipeWith is ImageRecipe with the source of the content fingerprints chosen by the caller. A nil fp leaves every present file FingerprintPending, which is never a match: a caller that has no way to read content gets a recipe that cannot be mistaken for an identity.

func (Recipe) Diff

func (r Recipe) Diff(o Recipe) []string

Diff names, in the config keys' own words and a fixed order, every way o differs from r ("imagegen_ckpt: a vs b"). Empty when the two digest alike. It is what a refusal prints so the operator sees WHICH key to change, or which family to name instead.

func (Recipe) Digest

func (r Recipe) Digest() string

Digest is the sha256 of the canonical JSON of the resolved recipe (hex). Explicit is not in it.

func (Recipe) Missing

func (r Recipe) Missing() []string

Missing names the files that were not found on the machine that built the recipe. A recipe that is missing a file is never a match, on either side of the comparison: nothing can be said to render alike from a weight that is not there.

func (Recipe) PairsStepsAndCFG

func (r Recipe) PairsStepsAndCFG() bool

PairsStepsAndCFG reports whether this recipe's graph takes steps and cfg together, so that a per-request `steps` renders only when the binding also set cfg. A node whose binding leaves cfg to the builder's default is a correct target for a request without `steps` and a failing one for a request with it.

func (Recipe) SetsCFG

func (r Recipe) SetsCFG() bool

SetsCFG reports whether the binding set cfg itself (rather than taking the builder's default).

func (Recipe) Unfingerprinted

func (r Recipe) Unfingerprinted() []string

Unfingerprinted names, with the state each is in, the files that are there but have no content fingerprint yet ("name (pending)", "name (unreadable)"). A recipe that has any is not an identity: it is never a match, on either side of the comparison, and a node publishes no digest for it. Missing files are Missing's, not these.

func (Recipe) WithoutContent

func (r Recipe) WithoutContent() Recipe

WithoutContent is the recipe with every file's fingerprint dropped: what it says by name, size and sampling alone. A delegator uses it to tell a node that holds this machine's build but has not finished hashing it (a named wait) from one that holds another build.

type RecipeFile

type RecipeFile struct {
	Role        string `json:"role"`
	Name        string `json:"name"`
	Bytes       int64  `json:"bytes"`
	Fingerprint string `json:"fingerprint,omitempty"`
}

RecipeFile is one weight file the graph loads: its role, its ComfyUI-relative name, its size on this machine (-1 when it is not found: a recipe with a missing file is never a match) and its content fingerprint (fingerprint.go): a sha256 in hex, FingerprintPending while this machine is still hashing it, FingerprintUnreadable when it could not be read, and absent for a file that is not there. Only a hash is an identity.

type Route

type Route struct {
	// Name is the offload task this route serves ("generate_image",
	// "generate_audio:music", ...) — the vocabulary a caller already has.
	Name string
	// Engine is what actually runs it on this box ("sdcpp", "comfyui",
	// "chatterbox-tts", "acestep", "pil", "gimp", "ffmpeg", "runtime").
	Engine string
	State  State
	// Detail names the bindings behind the verdict: what resolved, or exactly
	// which path is absent / which config key is empty.
	Detail string
	// Prereq marks a shared dependency (the node runtime, the ComfyUI install)
	// rather than a task route. A missing prereq breaks the CONFIGURED routes
	// above it, which is precisely why it is reported next to them.
	Prereq bool
}

Route is one file-backed media capability on THIS machine. Model-alias routes (vision/stt) are deliberately absent: their reachability is a live /v1/models question, answered by doctor's alias diff and offload_status's roster probe.

func Missing

func Missing(routes []Route) []Route

Missing returns the routes whose configured files are absent — the actionable subset (a caller's exit code, an operator's fix list). NOT CONFIGURED is never in it: deferring a task this box was never bound for is correct behavior.

func Routes

func Routes(cfg config.Config) []Route

Routes derives every file-backed media route for cfg against the real filesystem, resolving relative script paths against the running executable's directory exactly like the pipeline does. Custom-node classes are decided from <comfy_dir>/custom_nodes on disk (DiskNodeCheck): offload_status and acceptance call this, and neither may make a network call per route.

func RoutesChecked

func RoutesChecked(cfg config.Config, nodes NodeChecker) []Route

RoutesChecked is Routes with the custom-node decision injected: `doctor` passes LiveNodeChecker, which asks a ComfyUI that is already running and falls back to disk.

func (Route) OK

func (r Route) OK() bool

OK reports whether this route can run right now.

type SdcppDevice

type SdcppDevice struct {
	Index       string // the GGML_VK_VISIBLE_DEVICES value that will be in effect
	Name        string // the adapter name at that index; "" when --list-devices could not say
	EnvOverride bool   // GGML_VK_VISIBLE_DEVICES was already set in the environment
	IsIGPU      bool   // Name matches a known integrated-GPU pattern
	ProbeErr    string // non-empty when --list-devices could not be run or listed nothing
}

SdcppDevice is doctor's report of which Vulkan device an sdcpp render will use.

func DetectSdcppDevice

func DetectSdcppDevice(bin, envOverride string, list sdcppDeviceLister) SdcppDevice

DetectSdcppDevice resolves which Vulkan device an sdcpp render will use on this box, mirroring render/sdcpp-generate.mjs's own resolution order exactly: an explicit env override always wins (never guessed around); otherwise the first discrete adapter `--list-devices` reports; otherwise device 0 (ggml-Vulkan's own default) — flagged as an iGPU when it is one, so the FAIL case an operator cares about (a render about to run on the integrated part) is never silent.

type State

type State string

State is a route's derived verdict.

const (
	Configured      State = "CONFIGURED"
	NotConfigured   State = "NOT CONFIGURED"
	BoundButMissing State = "BOUND-BUT-MISSING"
)

type VideoFamilyBindingRow

type VideoFamilyBindingRow struct {
	Family  string            `json:"family"`
	Default bool              `json:"default"`
	Files   map[string]string `json:"files"`
	// License and CommercialUse are the family's declared pair (videogen_families[name],
	// CT-47), null when it declares none: a reader treats that as UNKNOWN, never as
	// commercial-safe — the same contract FamilyRow keeps for the image families.
	License       *string `json:"license"`
	CommercialUse *bool   `json:"commercial_use"`
}

VideoFamilyBindingRow is one video family's resolved model bindings — what THIS machine would actually load if a request rendered that family, independent of which family is the box's own default (cfg.VideoGenFamily). Doctor/offload_status report one row per videoFamilyNames entry (gap: every videogen_* weight key used to be a single machine-wide value silently applied to whichever family actually rendered — bigger-models-2026-09-24.md "Interim Phase 2 round 2" — these rows are what makes the fix's effect provable from the outside, not just from the diff).

func VideoFamilyBindingRows

func VideoFamilyBindingRows(cfg config.Config) []VideoFamilyBindingRow

VideoFamilyBindingRows lists the resolved per-family video bindings (label -> file name) for every family in videoFamilyNames, marking this box's own configured default family (cfg.VideoGenFamily, "" meaning wan22).

type VulkanDevice

type VulkanDevice struct {
	Index string
	Name  string
}

VulkanDevice is one line of `sd-cli --list-devices` output.

func ParseVulkanDeviceList

func ParseVulkanDeviceList(text string) []VulkanDevice

ParseVulkanDeviceList parses `sd-cli --list-devices` output ("VulkanN <adapter name>" lines; anything else is ignored) into index/name pairs, in listed order. Pure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL