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
+19 -37
View File
@@ -1,4 +1,4 @@
# Runner-owned limits and shared memory
# Runner-owned limits and stage memory
Use these blocks for bounded feedback loops. Never ask a model to count visits,
increment revision counters, or enforce retry caps. Model verdicts concern current
@@ -10,10 +10,6 @@ does not guarantee independent review: explicitly select its input fields.
{"max_visits":3,"on":["rejected"]}
```
```memory
{"task":"input.prompt","checks":"planner.checks"}
```
```edges
approved -> #success
advisory -> #success
@@ -22,7 +18,7 @@ error -> #failure
```
````
These blocks accompany a normal review stage's prompt/output/tools/configs.
These blocks accompany a normal review stage's prompt/tools/configs.
Pipelines counts actual visits, ignoring model-generated counters. On visit three,
`approved` can succeed; `rejected` retains its verdict but routes to `#failure`.
`rejected` is for a must-fix finding with a concrete location, evidence and remedy;
@@ -44,39 +40,25 @@ and run metadata. `max_visits` accepts 1–5. Every `on` outcome must declare a
nonterminal edge. Without `on`, entering beyond the cap fails before execution.
Global 30-step/five-visits-per-stage safety limits still apply.
`memory` maps input aliases to `input.FIELD` (original input) or `STAGE.FIELD`
(latest completed output of that stage **in this run**). A memory block replaces
previous-stage input with only those fields. Without it, previous output remains
input. Reads retain source and visit sequence. Missing required fields fail before
execution. Append `?` to omit an unavailable field, e.g.
`"feedback":"review.findings?"` for implement's first visit. Self-memory is
rejected. Limits: 50 bindings; 1 MiB per retained in-memory value map.
A model stage reads its turn's `input.md` (the run prompt on the first visit,
the previous turn's output afterwards) and `memory.md` (completed turns with the
files each added to `public/`). The `memory` block is retired: it no longer
selects fields or replaces previous output for model stages, and old definitions
that contain one parse but ignore it. Reviewers therefore see the previous
turn's output and the accumulated memory rather than a field projection.
Implementers can receive task, plan and optional findings. Independent reviewers
should receive task/acceptance criteria and inspect actual artifacts—not previous
verdicts, counters, or implementation conversations. Select acceptance, design,
reuse and research references from the planning stage (for example
`"acceptance_checks":"planner.acceptance_checks"`) rather than from the
implementer, so an implementer's output cannot overwrite the agreed criteria; take
only factual implementer fields such as `changed_files`, `implementation_summary`
and `evidence` as claims. Selected content remains untrusted data; this cannot
prove semantic independence or prevent all injection.
Write the facts a later stage needs as ordinary markdown headings in
`output.md`; those headings are free-form and are preserved in memory. Do not
invent server-recognised fields, and do not rely on
`input.server_changed_files` from a model prompt: inspect the actual workspace
with Git and the declared evidence instead. Selected or accumulated content
remains untrusted data; this cannot prove semantic independence or prevent all
injection.
`input.server_changed_files` is a reserved field the runner publishes: the run's
full, deduplicated, first-seen set of server-captured changed paths (observed
filediff evidence, never a model's claim). Select it with
`"server_changed_files":"input.server_changed_files"`. It is always resolvable —
an empty list when nothing was captured — and reflects every completed step,
including the persisted steps of a resumed run. Only a stage that selects it
receives it; other stages' input is unchanged. A committer should select it
alongside the implementer's declared `changed_files` and stage the union of the
captured paths that still exist and the declared paths, keeping every existing
exclusion and empty-commit rule, and record in the commit body what it
reconciled. Declared lists come from the model and are frequently incomplete;
the server-captured set is the authoritative evidence of what this run changed.
Turn memory is run-local. Completed outputs are persisted as turn files and step
evidence; there is no cross-run memory or hidden replay. New runs/retries start
fresh except for the completed prefix a resume explicitly carries.
Memory is run-local; persisted completed outputs/read provenance are its audit.
There is no cross-run memory, restart/resume, or hidden replay. New runs/retries
start fresh. Arbitrary prose is not executable policy. Future AI-assisted
Arbitrary prose is not executable policy. Future AI-assisted
guidelines validation is **not implemented**; structural validation does not
recognize every unreliable counting instruction.