b3c9575fde
- A stage refused for a Claude usage limit no longer fails its run: the runner tries the chats' Claude account auto-switch (per-home setting) and reruns the visit, else parks the run in the new waiting_quota status (persisted, with reset/resume time in run summaries, details and events) and resumes the same visit at reset + 1 min, also after a restart. resume_run / `pipelines resume` resumes now; cancel works on parked runs. The rerun visit gets a "# Previous attempt" interruption note. Subscription limits no longer say "top up the provider account". - run/retry into an account known to be limited are deferred (quota_policy defer/refuse/now; CLI refuses under --json/--yes unless --defer or --now). - failure_class on runs (quota, loop_exhausted, timeout, permission_denied, harness_error, blocked, environment, canceled, interrupted, budget, check_failed, other) in RunSummary/RunDetail/events, CLI inspect/runs/wait/ stats and the app failure line. - Claude permission denials (permission_denials / refused tool results) fail a blocked visit with permission_denied naming the tool use. - Harness failures are classified transient vs deterministic; deterministic ones (and a repeated empty readback) skip error self-loops; transient self-loops back off 15 s, 1 min, 4 min. - Whole-run USD budget: run --budget, server default (run-budget / get/set_run_settings); 80% warning notification, stop with class budget. - App: waiting_quota status/filter with resume time, Resume now and Cancel, failure class wording. Docs and skill references updated. Merges main (check stage, delivery gate, Claude stage restart survival, schedule changes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
315 lines
15 KiB
Markdown
315 lines
15 KiB
Markdown
# Definition format
|
||
|
||
A definition is Markdown made only of `# stage KEY` headings and fenced blocks;
|
||
no prose outside blocks. Blocks: `prompt`, `configs`, `tools`, `skills`, `edges`,
|
||
`checks`, `limits` (`references/control.md`), `permissions`, `notify`
|
||
(`references/notifications.md`) and, on check stages, `commands`. There are no memory, links, input or output
|
||
blocks; stages communicate through `output.md` (`# handoff`) and `public/`.
|
||
Schedules are saved run configurations, never definition blocks
|
||
(`references/schedules.md`).
|
||
|
||
````markdown
|
||
# stage implement
|
||
|
||
```prompt
|
||
Make the change requested in the run task. Run focused checks for the touched
|
||
code only. Return blocked if the request cannot be met.
|
||
```
|
||
|
||
```configs
|
||
provider=default
|
||
model=default
|
||
```
|
||
|
||
```tools
|
||
read
|
||
glob
|
||
grep
|
||
edit
|
||
shell
|
||
```
|
||
|
||
```checks
|
||
none: focused tests only; the land delivery gate runs the suite
|
||
```
|
||
|
||
```edges
|
||
success -> review
|
||
blocked -> #failure
|
||
error -> #failure
|
||
```
|
||
````
|
||
|
||
Stage and outcome keys begin with a letter and contain letters, digits, `_` or
|
||
`-`. Name roles `plan`, `implement`, `review`, `ui-review`, `decide` (human) and
|
||
`land`; other jobs take a plain verb (`draft`, `check`, `act`). Each outcome has exactly one target: another
|
||
stage, `#success` or `#failure`. An omitted `error` edge defaults to `#failure`
|
||
for every stage type, human included. Execution is sequential; an outcome picks
|
||
one edge, never parallel branches. Every stage must be reachable from the entry
|
||
and have a path to a terminal; loops need runner-owned `limits`.
|
||
|
||
## Turn files
|
||
|
||
Each visit gets `input.md`, `memory.md`, `history.md`, `output.md` and `private/`
|
||
in `<run>/stages/<seq>-<stage>/`, plus the run-level shared `public/` addressed by
|
||
its absolute path.
|
||
|
||
- `memory.md` (capped at 4 KB, always inlined in the prompt): the run task, the
|
||
previous stage's `# handoff` with its outcome and `public/` additions, a
|
||
one-line-per-stage outcome ledger and the server-captured changed files.
|
||
- `input.md`: the run task, plus on later turns the previous turn's full output
|
||
(`internal/turn/render.go`). A stage with `read` reads it on demand; a stage
|
||
without `read` gets it inlined (up to 32 KB) on every call, so give `read` to
|
||
stages that follow a large output.
|
||
- `history.md`: every completed turn in full; on demand for stages with `read`,
|
||
never inlined.
|
||
|
||
Keep turn-local files in `private/`; put reports, logs and screenshots for later
|
||
stages in `public/`. `input.md`, `memory.md`, `history.md`, `output.md` and
|
||
`session.html` are server-written evidence, not stage output.
|
||
|
||
## output.md
|
||
|
||
The stage returns the complete `output.md` in this order: `# outcome`, the edge
|
||
word alone on the next non-blank line, then `# handoff` (a few lines: what it did,
|
||
files changed, open findings), then any detail:
|
||
|
||
````markdown
|
||
# outcome
|
||
|
||
success
|
||
|
||
# handoff
|
||
|
||
Fixed both review findings in cache.go; focused tests pass. No open issues.
|
||
|
||
Free-form detail for the operator and later stages.
|
||
````
|
||
|
||
The outcome heading matches case-insensitively at any ATX level, outside fenced
|
||
code. Never add a second heading named Outcome. If the outcome is missing, the
|
||
runner sends one repair follow-up asking only for it; a still-missing, duplicate,
|
||
empty or undeclared outcome fails with `FINAL RESULT VALIDATION`. Every other
|
||
heading is free-form and preserved. The handoff is the `# handoff` section (or,
|
||
without one, the head of the output, marked as such), truncated to fit memory.
|
||
The `{ "outcome": ..., "output": ... }` JSON envelope and its format-repair ladder
|
||
are retired: never ask for JSON fields or invent server sections. Missing tools or
|
||
evidence route to `blocked` when declared, else `error`; never fabricate a result.
|
||
|
||
## Configs
|
||
|
||
- `provider`/`model`: exact IDs validated during server setup. Templates
|
||
(`pipelines new NAME --template KEY`) fill them in; copy those IDs into a
|
||
hand-written draft. Availability needs `pipelines provider-check`.
|
||
- `harness=opencode|pi|claude`; omission means OpenCode (`references/harnesses.md`).
|
||
`claude` needs `provider=anthropic` and a Claude model ID; its `permissions`
|
||
block may hold only a `shell` allow-list (no `edit` patterns or run write
|
||
paths).
|
||
- `retries` 0–100, default 2 (three attempts). Retries cover transport failures
|
||
and timeouts; a stage with `edit`/`shell` (or no tools block) never replays
|
||
admitted work.
|
||
- `timeout` per attempt, default `1h` (e.g. `30m`, `90s`).
|
||
- `reasoning_effort`: `default`, `none` (`off`), `minimal`, `low`, `medium`,
|
||
`high`, `xhigh`, `max`. Omit unless asked; unsupported levels are rejected.
|
||
Do not prompt "think harder" instead.
|
||
- `budget_usd`, `budget_tokens`: positive caps on reported usage, shared across
|
||
attempts and visits of this stage; totals include cache reads and writes. Set
|
||
only when the user asks or a measured visit exists (`references/practices.md`).
|
||
A whole-run cap is not a definition setting: it is the run's `--budget USD` or
|
||
the server default (`pipelines run-budget`), and every stage's cost counts
|
||
towards it (80% warning, stop with failure class `budget` at 100%).
|
||
- `delivery=true`: the landing stage's gate (below), on any harness, or on a
|
||
check stage.
|
||
- `allow_workspace_changes=true`: lets a stage with `shell` but no `edit` leave file changes
|
||
in the run directory (below).
|
||
- `auto_skip=false`: disable the server skip fallback for a stage that declares a
|
||
`skipped` edge (`references/operations.md`, Server skip fallback).
|
||
|
||
## Tools and permissions
|
||
|
||
`tools` lists `read`, `glob`, `grep`, `webfetch`, `websearch`, `edit`, `shell`,
|
||
or (Claude stages only) `mcp:<server>` / `mcp:<server>/<tool>`, one per line;
|
||
an empty block denies all and a missing block grants local
|
||
read/glob/grep/edit/shell (prefer explicit). Roles: `plan` reads (web only when
|
||
external knowledge is needed); `implement` reads, edits and runs shell; `review`
|
||
reads and may use shell for `git diff`, never edits; `land` has read/glob/grep and
|
||
shell, no edit. Planning stages do not return `blocked` merely because edits come
|
||
later. Keep prompts language-neutral unless the task names a language.
|
||
|
||
Optional `permissions` is a JSON object with `edit` (run-directory-relative
|
||
patterns) and `shell` (exact commands) arrays. It narrows declared tools; it never
|
||
enables a missing one. Empty arrays deny; wildcards, chaining, redirects and
|
||
traversal are rejected. With restricted edits and shell enabled, list shell too:
|
||
`{"edit":["README.md","plugin/*.qml"],"shell":["bash -n install.sh"]}`.
|
||
On `harness=claude` only `shell` is accepted; each entry becomes a Claude Code
|
||
rule (`go test ./...` -> `Bash(go test ./...)`) and an entry ending in ` *` is a
|
||
prefix (`git diff *` -> `Bash(git diff:*)`, any arguments; claude only). Claude
|
||
Code checks each part of a chained command, and every other command is
|
||
refused. A read-only reviewer: `{"shell":["git diff *","git log *","go test ./..."]}`.
|
||
|
||
A stage whose `tools` block has `shell` but not `edit` must leave the run directory as it
|
||
found it: the server compares the workspace before and after the visit and
|
||
fails the visit (`permission denied: ... changed the workspace (added x, ...)`,
|
||
following the `error` edge) when any file changed, outside the run's artifact
|
||
directories and a harness state directory inside the workspace. Committing is
|
||
not a change; merging or generating files is. Set
|
||
`allow_workspace_changes=true` on a stage that legitimately writes (for
|
||
example a land stage that merges main itself).
|
||
|
||
Named MCP entries are an explicit allowlist for unattended Claude stages:
|
||
`mcp:ai-memory` allows that server's tools, while `mcp:linear/list_issues`
|
||
allows one tool. Names are the server/tool names Claude Code displays (mapped
|
||
internally to `mcp__<server>__<tool>`; claude.ai connectors may look like
|
||
`claude_ai_Linear`). Other harnesses reject these entries. Prefer read-only
|
||
MCP tools; server configuration is not inspected during validation, so an
|
||
unknown name may fail at runtime.
|
||
|
||
## Skills
|
||
|
||
Optional `skills` (model stages only) turns on skills from the server skill
|
||
library (`pipelines skills list`), one per line: `name` loads the latest version
|
||
at run start, `name@N` pins version N. An empty or missing block loads none.
|
||
Drafts and publications are rejected for an unknown skill, a missing version,
|
||
`@0`/non-numeric versions, a skill listed twice (pinned or not) and a `skills`
|
||
block on a human or ntfy stage.
|
||
|
||
```skills
|
||
review-checklist
|
||
release-notes@3
|
||
```
|
||
|
||
When a run starts every entry is resolved to `name@N` and recorded on the run
|
||
(shown on each step), so a later import never changes a running stage; `retry`
|
||
(resume and restart) reuses the recorded versions for unpinned names. Each visit
|
||
gets a private read-only copy of exactly those bundles under the run's artifact
|
||
directory. Harness notes: Claude loads them as a session plugin (`Skill` tool,
|
||
listed as `pipelines-stage:<name>`); Pi loads them with `--skill` and needs
|
||
`read` in `tools` to open `SKILL.md`; OpenCode attaches each `SKILL.md` as a
|
||
session instruction entry (V2 service only; bundled `references/` are readable
|
||
with `read`).
|
||
|
||
A skills block is not needed for the execution user's own Claude Code skills:
|
||
every model stage can use them with no import. Claude stages see Claude Code's
|
||
bundled skills (`code-review`, `dataviz`, ...), the personal `~/.claude/skills`
|
||
folders as `user:<name>`, claude.ai synced skills as `anthropic-skills:<name>`
|
||
and enabled plugins' skills as `<plugin>:<name>` (skill folders only; user
|
||
settings, hooks and MCP servers stay off). Pi stages get every folder-based one
|
||
with `--skill` (after the block's, which win a name clash) and need `read` to
|
||
use them. OpenCode tool-using stages may load the personal and synced ones with
|
||
OpenCode's own `skill` tool. Bundled skills have no folder, so Pi and OpenCode
|
||
stages cannot use them; OpenCode also cannot use plugin skills or give a
|
||
text-only stage a skill tool. Name a skill in the prompt when a stage must use
|
||
it.
|
||
|
||
## Checks
|
||
|
||
Every model stage that can modify the workspace (`edit` or `shell`, no `tools`
|
||
block, or `delivery=true`) declares `checks`. A `delivery=true` stage lists 1–20
|
||
commands, one per line. Every other stage writes exactly one line,
|
||
`none: <reason>`, e.g. `none: read-only review; shell is used only for git diff`.
|
||
A check must fail when it cannot run: validation rejects `|| true`, `|| :`,
|
||
`|| exit 0`, `|| echo`, negated file tests, `! command -v tool ||`, an `if` with no
|
||
failing else, and `set +e`. Cover every language the run can change.
|
||
|
||
## Check stages
|
||
|
||
`type=check` runs shell commands on the server, without a model, and routes on
|
||
`pass` or `fail`. Use it before review, so a reviewer never sees a red tree, and
|
||
as the landing gate instead of a model stage that runs the suite itself.
|
||
|
||
````markdown
|
||
# stage verify
|
||
|
||
```configs
|
||
type=check
|
||
command_timeout=15m
|
||
```
|
||
|
||
```commands
|
||
uv run ruff check .
|
||
uv run ty check
|
||
uv run pytest -q
|
||
```
|
||
|
||
```edges
|
||
pass -> review
|
||
fail -> implement
|
||
```
|
||
|
||
```limits
|
||
{"max_visits":3}
|
||
```
|
||
````
|
||
|
||
- `commands` (required): 1-20 lines, one `sh -c` command each, run in order
|
||
from the run directory with its workspace environment; blank and `#` lines are
|
||
ignored. The first failure stops the rest (`not_run`) unless `keep_going=true`.
|
||
Lint rejects silent guards (`|| true`) as for `checks`.
|
||
- Configs: `command_timeout` (per command, default `30m`), `timeout` (the whole
|
||
stage, default `1h`), `keep_going=true|false`, `delivery=true`. No prompt,
|
||
tools, model or skills.
|
||
- Edges: `pass` and `fail` are required and are the only outcomes besides
|
||
`error` (an infrastructure failure). A `fail` loop back needs `limits`.
|
||
- Output: the step records each command's status (`passed`, `failed`,
|
||
`timed_out`, `not_run`), exit code, duration and output (64 KB per failing
|
||
command, head and tail kept), plus a one-line summary as its verdict. Its
|
||
`# handoff` names the failing commands with the tail of their output, and the
|
||
full outputs follow, so the next stage sees exactly what failed.
|
||
- `delivery=true` makes it the landing gate: the server commits what the run
|
||
left uncommitted (run worktrees), merges a moved `main`, runs the commands in
|
||
a fresh worktree of the commit and fast-forwards `main` on `pass`. A failing
|
||
command is `fail` with `main` untouched; a gate problem (dirty checkout,
|
||
conflict, refused fast-forward) is `error`.
|
||
|
||
## Human stages
|
||
|
||
`type=human` pauses the run until a person picks one of its non-`error` edges
|
||
(e.g. `approve -> act`, `revise -> plan`, `abort -> #failure`). It needs only
|
||
`prompt` (operator instructions),
|
||
`configs` with `type=human` and `edges`; no model or tools. Decide with
|
||
`pipelines decide RUN_ID [STAGE] --option KEY [--feedback TEXT]` or the apps. The
|
||
wait survives restarts and is never killed by a stage timeout or `max_visits`.
|
||
|
||
## Land stage and delivery gate
|
||
|
||
A workflow that commits its change ends in `land`: either a check stage with
|
||
`delivery=true` (above; no model, the server commits and lands), or a model
|
||
stage with `read`/`glob`/`grep`/`shell`, no `edit`, that commits locally. A model
|
||
land stage's prompt states:
|
||
|
||
1. Commit only this run's changes (server list + git status).
|
||
2. Check the staged diff for unrelated work and secrets.
|
||
3. No empty commit, push, amend or rebase. Report the hash.
|
||
|
||
With `delivery=true` and `checks` commands (any harness), after `land` succeeds
|
||
the server:
|
||
commits whatever the run left uncommitted when the item is the run's own
|
||
worktree (see "Run worktrees" below); requires the item checkout to be clean,
|
||
untracked files included (the main checkout need not be: the final
|
||
fast-forward is Git's `merge --ff-only`, which refuses without touching
|
||
anything when a local change would be overwritten); merges
|
||
a moved `main` into the item (a conflict aborts with the workspace unchanged);
|
||
runs each check with `sh -c` from the root of a fresh detached worktree of the
|
||
commit, so include dependency bootstrap (`npm ci && npm test`); caps each check's
|
||
output at 64 KB; and fast-forwards `main`. A failing check blocks landing. Do not
|
||
check ancestry before the gate runs. Without a gate, the manager merges and
|
||
verifies ancestry; no separate merger pipeline is needed (`references/queue.md`).
|
||
|
||
## Run worktrees
|
||
|
||
A run started from a repository's main checkout runs in its own worktree:
|
||
`<repo>-runs/<date>-<title>-<hex>` next to the repository, on branch
|
||
`pipelines/run-<same>`, from the checkout's current `HEAD`. Runs never share a
|
||
tree, never see the operator's uncommitted work, and any number can run at
|
||
once. A run started inside a linked worktree (an item's tree) and every retry
|
||
use their directory as is. After a successful run whose tree is clean and
|
||
whose branch is on `main`, the server removes the tree and branch; anything
|
||
else (a failed run, unlanded commits, stray files) is kept for recovery.
|
||
|
||
The `notify` block accepts `on`, optional legacy `destination`, optional
|
||
`artifacts=markdown|files`, optional `open=<relative-glob>` and optional
|
||
`link=<relative-glob>`. `open` selects an artifact in the run's shared `public/`;
|
||
without it, one and only one regular file there is selected automatically.
|
||
`link` selects a `public/` file whose first non-empty line is the http(s) tap
|
||
target; that file is never the attached artifact.
|