Files
pipelines/internal/tui/run_model_override_test.go
T
alan fae1005962 Allow launching runs with whole-run and per-stage model overrides
Add `pipelines run --model PROVIDER/MODEL` and repeatable
`--stage-model STAGE=PROVIDER/MODEL`, resolved with precedence
per-stage > whole-run > the model pinned in the pipeline version.

- A shared pure resolver (`pipeline.ParseModelOverride` /
  `pipeline.EffectiveModels`) owns the precedence and validation: every value
  must be a `provider/model` pair (`stage.ValidModel`), every stage key must
  exist in the pinned graph, an unknown key fails naming the valid keys, and a
  per-stage key that names a non-model stage is refused.
- The server validates against the pinned version before admission (no run row
  is ever inserted for an invalid request), persists `model`/`stage_models` on
  the run and `provider`/`model` on each step, applies the effective pair to a
  clone of the stage definition so the stage and its repair/formatter path share
  it, overlays the returned run graph with the effective pair (presentation
  only), and reuses the recorded overrides on retry.
- The run record echoes the overrides it was launched with and each step records
  the provider/model it actually ran with; the TUI Evidence pane renders that
  effective pair. The pinned pipeline version and `show --version N` are never
  modified.
- CLI help, `docs/cli.md` and the packaged authoring skill references document
  the flags and the precedence. A TUI override picker remains a documented
  follow-up; the CLI is the deliverable.

Tests: pure precedence/validation table tests, store round-trip and
request-key-mismatch plus migration, server admission/application/overlay/retry
with a controlled executor, CLI flag/help/malformed-value tests, and a TUI
evidence test.
2026-10-16 23:33:53 +01:00

25 lines
952 B
Go

package tui
import (
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
// TestEvidenceLinesShowEffectiveModel proves the Evidence pane renders the
// provider/model a step actually ran with, so a launch-time override is visible
// rather than the pinned model.
func TestEvidenceLinesShowEffectiveModel(t *testing.T) {
step := protocol.RunStep{Sequence: 1, Stage: "one", Status: "completed", Outcome: "success", Provider: "acme", Model: "strong"}
text := strings.Join(evidenceLines(step), "\n")
if !strings.Contains(text, "acme/strong") {
t.Fatalf("evidence pane omitted the effective model:\n%s", text)
}
// A non-model step records no provider/model and shows no model line.
plain := strings.Join(evidenceLines(protocol.RunStep{Sequence: 2, Stage: "note", Status: "completed", Outcome: "success"}), "\n")
if strings.Contains(plain, "Ran with model:") {
t.Fatalf("non-model step claimed a model:\n%s", plain)
}
}