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.
This commit is contained in:
2026-10-16 23:33:53 +01:00
parent 80232a4ffe
commit fae1005962
19 changed files with 912 additions and 31 deletions
@@ -118,6 +118,16 @@ preserved and partial stdout after the grace is never accepted as success.
Stages set `harness=pi` or `harness=opencode` in configs; omission preserves
historical OpenCode behavior. Pi must be configured on the execution server.
A run may override the pinned model at launch: `pipelines run --model
PROVIDER/MODEL` covers every model stage and repeatable `--stage-model
STAGE=PROVIDER/MODEL` overrides one stage, with precedence **per-stage >
whole-run > the model pinned in the pipeline version**. Overrides are validated
against the pinned version before the run starts (an unknown stage key fails
naming the valid keys; a non-model stage cannot be overridden), apply to that run
only, and are recorded on the run so `retry` reproduces them. The effective
provider/model is stamped on the step and exposed by the run's graph, and the
stage's repair/formatter path uses the same resolved model because both read the
stage's effective configs.
The RPC adapter starts new retained sessions per visit with explicit tools and
a Pipelines permission extension. Ambient extensions, skills, context files,
prompt templates, automatic retries/compaction are disabled. Tool gates are not
@@ -126,6 +126,13 @@ Adapt the scope and publishing lines per item; keep the rest.
- Launch with the authoritative `CLI_PREFIX` (`pipelines run`). The brief text is the
run's task; pass it whole. Read `references/operations.md` for the exact flags —
`--json`, confirmation (`--yes`) and `--wait`/`--wait-timeout`.
- **Model overrides at launch.** Use `--model PROVIDER/MODEL` to override the model
for every model stage of that run, and repeatable `--stage-model
STAGE=PROVIDER/MODEL` to override individual stages. Precedence is per-stage >
whole-run > the model pinned in the pipeline version. Overrides apply to that run
only (the pinned pipeline is never edited), are validated before the run starts,
and are recorded on the run; `retry` reuses them. See `references/harnesses.md`
for how a stage's model and its repair path both use the effective model.
- Watch to a **terminal state** (`succeeded`, `failed`, `canceled`, `interrupted`).
Poll `CLI_PREFIX inspect RUN_ID --json` (or use `--wait`) until terminal. A reached
client wait limit is not a run failure: the run stays active; keep waiting or