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:
@@ -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.
|
||||
|
||||
@@ -2,23 +2,19 @@
|
||||
|
||||
Definitions are Markdown made only of `# stage KEY` headings and fenced blocks.
|
||||
An optional `# settings` section precedes all stages. No unrelated prose outside
|
||||
blocks. The first stage receives `input.prompt` from the runtime user's task
|
||||
and `input.pwd`, the resolved run directory recorded by the server;
|
||||
later stages receive previous output unless `memory` explicitly selects fields
|
||||
from run-local context. There are no stage `input` blocks. Read
|
||||
`references/control.md` for selected memory and runner-enforced limits.
|
||||
blocks. The first stage receives the run prompt in its `input.md`; later stages receive
|
||||
the previous turn's output. Every visit also gets a `memory.md` of completed
|
||||
turns. There are no stage `input`, `output`, or `memory` blocks: the model reads
|
||||
the turn files and writes free-form markdown, and only the `# outcome` section is
|
||||
interpreted. Read `references/control.md` for runner-enforced limits.
|
||||
|
||||
Each model stage requires nonempty `output`, `prompt`, `configs`, and `edges` blocks:
|
||||
Each model stage requires nonempty `prompt`, `configs`, and `edges` blocks:
|
||||
|
||||
````markdown
|
||||
# stage worker
|
||||
|
||||
```output
|
||||
{ summary, evidence, artifacts }
|
||||
```
|
||||
|
||||
```prompt
|
||||
Perform the task supplied in input.prompt. Return evidence, not invented success.
|
||||
Perform the task. Write the complete output.md markdown; only `# outcome` is required.
|
||||
```
|
||||
|
||||
```configs
|
||||
@@ -49,36 +45,30 @@ prompts/outputs. Read `references/control.md` for the exact format.
|
||||
|
||||
## Result format
|
||||
|
||||
A model or agent stage returns a line-oriented document: the first non-empty line
|
||||
is the declared outcome (one of the stage's non-error `edges` keys), sections begin
|
||||
with `# <heading>`, and the required `# output` section holds one JSON object — the
|
||||
output map that later stages and `memory` select from. Every other heading becomes
|
||||
an evidence field keyed by its normalised heading (lowercased, spaces to
|
||||
underscores) and is retained verbatim, so prose, code fences, quotes and embedded
|
||||
JSON need no escaping. Extra sections are best-effort and never fail the stage.
|
||||
Each visit gets `input.md`, `memory.md`, `output.md` and `private/` in
|
||||
`<run>/stages/<seq>-<stage>/`, plus the run-level shared `public/`. The model
|
||||
reads input and memory and returns the complete `output.md` markdown. The only
|
||||
required section is the outcome heading, followed by one of the stage's declared
|
||||
edge words:
|
||||
|
||||
````markdown
|
||||
# outcome
|
||||
|
||||
success
|
||||
|
||||
# output
|
||||
{"task": "x", "changed_files": ["a.go"]}
|
||||
# Result
|
||||
|
||||
# evidence
|
||||
go test ./... — PASS (observed output)
|
||||
Free-form markdown for the next stage and the operator.
|
||||
````
|
||||
|
||||
The legacy single JSON envelope `{ "outcome": "...", "output": {...} }` is still
|
||||
accepted unchanged. The parser chooses by precedence: a response whose first
|
||||
non-empty character is `{` (after an optional surrounding fence) uses the JSON path;
|
||||
a `# ` heading that appears before any `{` uses the line path. A missing outcome, an
|
||||
undeclared outcome, or a missing/invalid `# output` fails the stage with
|
||||
`FINAL RESULT VALIDATION`; salvageable sections are retained and the parse status is
|
||||
recorded under the reserved key `result_parse` (`parsed`, `partial`, `failed`). The
|
||||
full raw response is saved as `raw-output.md` in the stage's artifacts directory. Use
|
||||
the line form when the evidence is prose, logs or code; never fabricate a result,
|
||||
never flatten the output fields alongside the outcome, and save any reports, logs or
|
||||
screenshots you produce into the artifacts directory the runtime names
|
||||
(`references/delivery.md`).
|
||||
`internal/turn.ParseOutput` matches the heading case-insensitively at any ATX
|
||||
level and ignores headings or words inside fenced code blocks. A missing,
|
||||
duplicate, empty or undeclared outcome fails the stage with
|
||||
`FINAL RESULT VALIDATION`. Every other heading is uninterpreted and preserved
|
||||
verbatim in the body. There is no JSON envelope, output schema, field selection
|
||||
or format-repair pass: do not ask for JSON fields or invent server sections.
|
||||
Keep turn-local files in `private/`; put reports, logs and screenshots for later
|
||||
stages in `public/`. Never fabricate a result.
|
||||
|
||||
Model configs may set `harness=opencode` or `harness=pi`; omission preserves
|
||||
historical OpenCode execution. Read `references/harnesses.md` for setup/limits.
|
||||
@@ -94,7 +84,7 @@ timeouts; an explicit read-only stage may additionally retry a post-admission
|
||||
deadline or transport failure, while a stage with `edit`/`shell` (or no tools
|
||||
block) never replays admitted work. Optional `budget_usd=1.50` and
|
||||
`budget_tokens=50000` independently cap reported usage.
|
||||
They accumulate across attempts, format repair sessions, and repeated visits
|
||||
They accumulate across attempts and repeated visits
|
||||
to this stage in the same run. Omit either budget to leave that resource unlimited.
|
||||
Both budgets must be positive; tokens include input, output, reasoning and cache
|
||||
reads/writes. Accounting failures stop budget-limited stages. In-flight requests
|
||||
@@ -151,10 +141,6 @@ not a choice. It validates, renders, exports and imports like every other type.
|
||||
````markdown
|
||||
# stage gate
|
||||
|
||||
```output
|
||||
The operator's decision evidence.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Review the screenshots and artifacts above, then choose where the run goes.
|
||||
```
|
||||
@@ -195,10 +181,6 @@ declared list:
|
||||
Commit this run's change locally; never push.
|
||||
```
|
||||
|
||||
```memory
|
||||
{"changed_files":"implementer.changed_files","server_changed_files":"input.server_changed_files"}
|
||||
```
|
||||
|
||||
```tools
|
||||
read
|
||||
glob
|
||||
@@ -215,10 +197,9 @@ error -> #failure
|
||||
|
||||
State this pre-commit checklist in the prompt:
|
||||
|
||||
1. Stage the union of `input.server_changed_files` (the authoritative,
|
||||
server-captured set) and the declared `changed_files`, restricted to paths that
|
||||
still exist, keeping every exclusion. A declared list can be incomplete, and a
|
||||
captured path it omitted is still this run's change (`references/control.md`).
|
||||
1. Inspect `git status` and the full diff. Stage this run's change, including
|
||||
inherited work, restricted to paths that still exist, and keep every
|
||||
exclusion. Do not rely on a model-declared file list.
|
||||
2. Inspect the staged diff before committing; never commit unrelated work, secrets
|
||||
or generated artifacts.
|
||||
3. Run the repository's required checks and record the exact commands and observed
|
||||
@@ -244,27 +225,10 @@ stage returns success; do not run the post-landing ancestry check beforehand.
|
||||
Without a delivery gate, the original workflow or manager completes the merge
|
||||
and verifies ancestry. No separate merger pipeline is required (`references/queue.md`).
|
||||
|
||||
Malformed final JSON has bounded recovery even with `retries=0`; it never changes
|
||||
verdict/evidence. Recovery tries a deterministic local pass first (append missing
|
||||
closing delimiters, drop one trailing comma, or insert the single comma/colon the
|
||||
parser expected), then at most one deny-all formatter request whose deadline is
|
||||
derived from the payload size and the attempt's remaining budget rather than a
|
||||
fixed short constant. Every path records `repaired`, `partial` or `unrecoverable`
|
||||
in `format_repairs`; a partial or unrecoverable result is never returned as
|
||||
complete, and an ambiguous payload (an unescaped quote/colon inside a string
|
||||
value) is never guessed at. On an explicit read-only stage a rejected malformed
|
||||
result may be re-emitted up to `retries`; a stage with `edit`/`shell` or no tools
|
||||
block never replays stage tools or re-emits the result, though the deterministic
|
||||
pass and the fresh deny-all, tool-free formatter session still apply. Compatible
|
||||
native stable backends request schema output with schema retries disabled; a
|
||||
retained deny-all, no-inference compatibility probe identifies known format
|
||||
incompatibility. Incompatible native backends and V2 require strict local envelope
|
||||
validation. Do not promise recovery of truncated strings, missing evidence or
|
||||
invalid outcomes.
|
||||
Return the line-oriented result format above, or the strict
|
||||
`{ "outcome": "declared-edge-key", "output": { ... } }` envelope. Do not treat
|
||||
tool-call/DSML markup, plain prose or flattened output as success, or rerun tool
|
||||
work to fix a response's formatting.
|
||||
A stage returns the markdown above, never the retired
|
||||
`{ "outcome": ..., "output": ... }` envelope. Do not treat tool-call/DSML markup,
|
||||
plain prose, or a missing outcome as success, and never rerun tool work merely to
|
||||
fix a response's formatting.
|
||||
|
||||
## Scheduling
|
||||
|
||||
|
||||
@@ -205,24 +205,31 @@ file diffs: current capture is server-owned. Do not promise full files/rollback.
|
||||
|
||||
## Retained stage artifacts
|
||||
|
||||
Every agent visit gets a per-run/step artifacts directory under the data
|
||||
directory (`<data>/artifacts/<run>/<step>/`); the root is configurable and
|
||||
defaults next to the database. The directory is passed as
|
||||
`PIPELINES_ARTIFACTS_DIR` to a locally spawned Pi process and exported to the
|
||||
OpenCode CLI where controllable, and it is stated in the agent prompt next to
|
||||
`Run directory:` for every harness. OpenCode V2 tools run inside the shared serve
|
||||
process, so there the prompt line, not the environment, is the reliable carrier.
|
||||
The instruction is general: save images, screenshots, reports and logs there.
|
||||
Every model visit gets a file-based turn under the data directory
|
||||
(`<data>/artifacts/<run>/stages/<seq>-<stage>/`) with `input.md`, `memory.md`,
|
||||
`output.md` and `private/`; `public/` is run-level and shared by every stage.
|
||||
The root is configurable and defaults next to the database. The writable
|
||||
`private/` and shared `public/` directories are stated in the agent prompt for
|
||||
every harness, and `PIPELINES_ARTIFACTS_DIR` points at the turn directory for a
|
||||
locally spawned Pi process. OpenCode V2 tools run inside the shared serve
|
||||
process, so there the prompt, not the environment, is the reliable carrier.
|
||||
Turn-local files belong in `private/`; reports, logs and screenshots for later
|
||||
stages belong in `public/`. The server owns `input.md`, `memory.md` and
|
||||
`output.md` and never asks the model to write them directly.
|
||||
|
||||
After the visit the server makes one bounded inventory and records each file's
|
||||
name, size, content type (extension, sniff fallback) and a relative url; these
|
||||
appear under each step's `artifacts` in `inspect RUN_ID --json` and the TUI's
|
||||
`A` artifacts view, which groups them by stage and visit, marks images and shows
|
||||
the recorded count, capture-pending/not-recorded wording and partial-capture
|
||||
notes.
|
||||
After the visit the server makes one bounded inventory of the turn and public
|
||||
directories and records each file's name, size, content type (extension, sniff
|
||||
fallback) and a relative url; these appear under each step's `artifacts` in
|
||||
`inspect RUN_ID --json` and the TUI's `A` artifacts view, which groups them by
|
||||
stage and visit, marks images and shows the recorded count,
|
||||
capture-pending/not-recorded wording and partial-capture notes. Public entries
|
||||
carry a `public/` prefix. `input.md`, `memory.md` and `output.md` are the primary
|
||||
artifacts of every model visit.
|
||||
`GET /artifacts/<run>/<step>/<name>` serves the bytes (correct Content-Type and
|
||||
Content-Length, HEAD, and Range/206/416 via `http.ServeContent`), refusing
|
||||
traversal, absolute paths, symlink escapes and unknown runs/steps.
|
||||
traversal, absolute paths, symlink escapes and unknown runs/steps. A pre-turn
|
||||
`<run>/<step>/` path stays readable for runs recorded before the file protocol
|
||||
landed.
|
||||
|
||||
- Limits: 200 files, 8 MiB/file, 64 MiB total per visit; over-cap files are
|
||||
skipped and counted; symlinks and non-regular files are excluded.
|
||||
@@ -236,7 +243,7 @@ traversal, absolute paths, symlink escapes and unknown runs/steps.
|
||||
|
||||
- When an OpenCode-harness model stage finishes, the server exports its real
|
||||
session read-only (v1 `opencode export <id>`, v2 `opencode session export <id>`)
|
||||
and writes exactly one file, `session.html`, into the same `<run>/<step>` artifacts
|
||||
and writes exactly one file, `session.html`, into the same turn artifacts
|
||||
directory; it lists and serves like any other artifact.
|
||||
- The `session.md` export is retired: nothing writes it any more and it is never
|
||||
presented. A run recorded before the HTML-only change still lists `session.md`
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Verification, accounting and real-provider evidence
|
||||
|
||||
Historical note: model stages now use file-based turns and parse only the
|
||||
`# outcome` section. The JSON/line-format envelope and format-repair ladder
|
||||
described in the dated sections below are retired; see `docs/model-results.md`
|
||||
for the current contract. The dated evidence remains as a record.
|
||||
|
||||
Structural validation is not inference, tool execution, correct task completion,
|
||||
phone delivery or correct billing. Distinguish observed artifacts/command results
|
||||
from model-written reports. State the command/check actually run and say **not
|
||||
@@ -8,7 +13,8 @@ evidence or a different backend/model as already validated.
|
||||
|
||||
## Authoring useful verification
|
||||
|
||||
Preserve explicit output handoffs and evidence fields. Implementer/reviewer stages
|
||||
Preserve the facts later stages need in free-form output headings; only the
|
||||
`# outcome` section is interpreted. Implementer/reviewer stages
|
||||
can use appropriate permitted commands; do not accept a preceding stage's success
|
||||
summary as independent proof. Actual file bytes, command exit status, retained tool
|
||||
parts and server-captured diffs are stronger evidence than prose. A read failure
|
||||
@@ -29,7 +35,7 @@ credentials; a client-side check is not proof of a remote server's provider heal
|
||||
|
||||
Defaults remain two retries and one hour per stage attempt; a run-level wall-clock
|
||||
deadline is not added. Budgets are optional, positive and independent USD/token
|
||||
reported-usage limits shared across attempts, format repairs and repeat visits.
|
||||
reported-usage limits shared across attempts and repeat visits.
|
||||
Accounting failures stop budget-limited stages. In-flight calls can overshoot;
|
||||
these are **not provider-side hard caps or a guaranteed bill ceiling**. Reported
|
||||
USD may validly be zero; do not fabricate prices/accounting from output length.
|
||||
|
||||
Reference in New Issue
Block a user