stage turns: replace JSON results with file-based markdown turns

Each model visit now gets <run>/stages/<seq>-<stage>/ with input.md,
memory.md, output.md, private/ and a shared run-level public/. The model
reads the two input files, follows the stage's instructions verbatim and
returns complete markdown; only the # outcome section is parsed.

- add internal/turn layout, render and output parsing
- write input.md/memory.md before a visit and output.md from the final
  message; inventory all turn files as stage artifacts
- accumulate completed turns and system-written public file additions in
  memory, including across retries and resume
- remove the JSON envelope, strict field validation, line format and the
  repair ladder for model stages
- republish pipeline authoring prompts and docs in the new style

Checks: go build ./..., go vet ./..., go test -count=1 ./..., gofmt -l .
This commit is contained in:
2026-10-19 22:27:44 +01:00
parent b2fd614ba4
commit e37b864c40
66 changed files with 2199 additions and 3028 deletions
+2 -4
View File
@@ -23,11 +23,9 @@ type ModelConfig struct {
BudgetUSD float64
BudgetTokens int64
Budget *Budget
ResultSchema map[string]any
}
type ModelSpec struct {
Output string
Prompt string
Config ModelConfig
}
@@ -52,7 +50,7 @@ func (ModelStage) Spec(def Definition) (ModelSpec, error) {
if EffectiveType(def.Type) != ModelType {
return ModelSpec{}, fmt.Errorf("expected model stage, got %q", def.Type)
}
for _, block := range []string{"output", "prompt", "configs"} {
for _, block := range []string{"prompt", "configs"} {
if strings.TrimSpace(def.Blocks[block]) == "" {
return ModelSpec{}, fmt.Errorf("required block %s is missing or empty", block)
}
@@ -127,7 +125,7 @@ func (ModelStage) Spec(def Definition) (ModelSpec, error) {
return ModelSpec{}, err
}
return ModelSpec{
Output: def.Blocks["output"], Prompt: def.Blocks["prompt"],
Prompt: def.Blocks["prompt"],
Config: ModelConfig{Harness: backend, Provider: def.Configs["provider"], Model: def.Configs["model"], Retries: retries, Timeout: timeout, BudgetUSD: usd, BudgetTokens: tokens},
}, nil
}