From 57bc53bff1ce5888ce70868ec7960249707bbac9 Mon Sep 17 00:00:00 2001 From: Peng Peng Date: Sat, 21 Nov 2026 15:06:44 +0800 Subject: [PATCH] fix(config): audio card supports follow MODEL_SUPPORTS on every boot The card sits on the shared cache and outlives the application, so a reinstall or a chart that added a capability kept the first install's supports. Router routed only those while the engine, which mounts its routes from the env, served more, and runtimecfg refuses audio supports edits, so nothing could correct the card short of deleting it. Co-authored-by: Cursor --- CHANGELOG.md | 7 ++++ internal/config/config_load_model.go | 19 +++++++++ internal/config/modelspec.go | 3 ++ internal/config/modelspec_test.go | 62 ++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdc66de..8ed7256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -130,6 +130,13 @@ and the project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2. ### Fixed +- An audio card's `supports` now follow `MODEL_SUPPORTS` on every boot. The + card sits on the shared cache and outlives the application, so a reinstall + or a chart that added a capability kept the first install's supports: + Router routed only those while the engine, which mounts its routes from + the env, served more, and the card could not be corrected at runtime + because audio supports are refused there. This is a third exception to + disk-wins, for audio engines only; other cards keep theirs. - The model card's `extensions.capacity` now follows an engine whose pod an upgrade replaced. The capacity reporter re-read the engine only on a readiness dip or a relaunch this process asked for, and a replaced pod diff --git a/internal/config/config_load_model.go b/internal/config/config_load_model.go index 7de322b..371589c 100644 --- a/internal/config/config_load_model.go +++ b/internal/config/config_load_model.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "maps" "os" "strings" @@ -363,6 +364,24 @@ func reasoningEffortRuleFromEnv(g Getenv) (*ParameterRule, error) { return &rule, nil } +// overlayAudioSupportsFromEnv makes MODEL_SUPPORTS authoritative for an +// audio engine's supports on an existing card. Returns true when spec was +// mutated. +// +// An audio card's supports cannot be edited at runtime (runtimecfg refuses +// it): the engine mounts its routes from MODEL_SUPPORTS, so the card has to +// say the same. The card outlives the application on the shared cache, so +// without this a reinstall or a chart that adds a capability keeps the old +// card, and Router routes only what the first install declared while the +// engine serves more. An unset MODEL_SUPPORTS leaves the card alone. +func overlayAudioSupportsFromEnv(cfg *Config, spec *ModelSpec) bool { + if cfg.Engine.Kind != EngineAudio || len(cfg.Spec.Supports) == 0 || maps.Equal(spec.Supports, cfg.Spec.Supports) { + return false + } + spec.Supports = maps.Clone(cfg.Spec.Supports) + return true +} + // overlayReasoningEffortRuleFromEnv makes the chart authoritative for the // reasoning_effort rule on an existing card, leaving every other rule // alone. Returns true when spec was mutated. diff --git a/internal/config/modelspec.go b/internal/config/modelspec.go index bfe79b0..9baca04 100644 --- a/internal/config/modelspec.go +++ b/internal/config/modelspec.go @@ -320,6 +320,9 @@ func ReconcileModelSpecFile(cfg *Config) error { if overlayReasoningEffortRuleFromEnv(&spec) { rewrote = true } + if overlayAudioSupportsFromEnv(cfg, &spec) { + rewrote = true + } // One-shot backfill only when the on-disk JSON lacks the // engine_args key entirely (legacy files). An explicit empty // string (or null) means the operator cleared the card — do not diff --git a/internal/config/modelspec_test.go b/internal/config/modelspec_test.go index 06e1587..79f187e 100644 --- a/internal/config/modelspec_test.go +++ b/internal/config/modelspec_test.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "log/slog" + "maps" "os" "path/filepath" "strings" @@ -907,3 +908,64 @@ func TestReconcileModelSpecFile_NoWarnWhenCardMatchesChartSeed(t *testing.T) { t.Errorf("identical args must not warn, got: %s", logs) } } + +// An audio card on the shared cache outlives the application, so a reinstall +// that declares more capabilities met the first install's card. Its supports +// follow MODEL_SUPPORTS, which is what the engine mounts its routes from; +// the rest of the card is still the disk's. +func TestReconcileModelSpecFile_AudioSupportsFollowTheEnv(t *testing.T) { + t.Parallel() + path := writeSpec(t, `{"name":"disk","mode":"audio","supports":{"supports_stt":true},"engine_args":""}`) + want := parseSupportsCSV("supports_stt,supports_diar") + cfg := &Config{ + Runtime: Runtime{ModelSpecPath: path}, + Engine: Engine{Kind: EngineAudio}, + Spec: ModelSpec{Name: "seed", Mode: "audio", Supports: maps.Clone(want)}, + } + if err := ReconcileModelSpecFile(cfg); err != nil { + t.Fatalf("reconcile: %v", err) + } + if !maps.Equal(cfg.Spec.Supports, want) { + t.Errorf("supports = %v, want %v", cfg.Spec.Supports, want) + } + got, err := LoadModelSpecFile(path) + if err != nil { + t.Fatalf("reload: %v", err) + } + if !maps.Equal(got.Supports, want) || got.Name != "disk" { + t.Errorf("disk card = %+v, want the env's supports written through and the disk's name kept", got) + } +} + +// Only audio cards: other engines' supports are edited through Router, and +// disk wins for them. An audio deployment without MODEL_SUPPORTS keeps its +// card. +func TestReconcileModelSpecFile_AudioSupportsOverlayIsAudioOnly(t *testing.T) { + t.Parallel() + for name, cfg := range map[string]*Config{ + "chat engine": { + Engine: Engine{Kind: EngineLlamaCpp}, + Spec: ModelSpec{Mode: "chat", Supports: parseSupportsCSV("supports_vision")}, + }, + "audio without MODEL_SUPPORTS": { + Engine: Engine{Kind: EngineAudio}, + Spec: ModelSpec{Mode: "audio"}, + }, + } { + disk := `{"name":"disk","mode":"chat","supports":{"supports_reasoning":true}}` + if cfg.Engine.Kind == EngineAudio { + disk = `{"name":"disk","mode":"audio","supports":{"supports_stt":true},"engine_args":""}` + } + cfg.Runtime.ModelSpecPath = writeSpec(t, disk) + var before ModelSpec + if err := json.Unmarshal([]byte(disk), &before); err != nil { + t.Fatal(err) + } + if err := ReconcileModelSpecFile(cfg); err != nil { + t.Fatalf("%s: reconcile: %v", name, err) + } + if !maps.Equal(cfg.Spec.Supports, before.Supports) { + t.Errorf("%s: supports = %v, want the disk's %v", name, cfg.Spec.Supports, before.Supports) + } + } +}