Workflows
A workflow-file is an optional YAML document that layers project-specific
behavior on top of a compiled pipeline at run time. A workflow can inject a
top-level prompt, override the agent or prompt of specific stages, attach
per-stage environment variables via env, expand
a stage into N chained copies via loop, skip (delete) a stage,
declare per-stage auto-approval via approve, force or cancel a stage's
manual launch mode via manual, attach note buttons to a stage via
notes, declaratively add new stages to the pipeline via extend,
configure project-memory participation via the top-level memory block
and the per-stage reflect / memory instructions (see
Project memory (memory, reflect)),
author collaboration with helper agents via the top-level assistants
catalog, the delegation block, and the per-stage assistants instruction
(see Collaboration (assistants, delegation)),
tune repeating run cycles via the top-level repeat block
(see Run cycles (repeat)),
declare stage-completion quality gates via the top-level gates block
and the per-stage gates check-step list
(see Quality gates (gates)),
and adapt the whole file per contributor through profile-driven rendering
(see Profiles) plus a build: block that configures nested
goga build runs.
Stage names in workflow.stages are matched strictly: a name that does not
match any pipeline step or extend-stage is a compile error. Workflows that
reference names absent from the target pipeline must be split or pruned.
Workflow-files live at:
They are project-only — there is no user-level workflow directory. The
name must be a bare filename resolved inside .goga/workflows/; path
traversal via .. or an absolute prefix is rejected.
Document shape
A workflow-file is a YAML mapping with up to twelve top-level keys (the whole file is first rendered as a Jinja2 template with the active profile's content as context — see Profiles):
prompt: |
Top-level prompt injected as the first directive of the compiled pipeline.
agent: claude # optional run-wide agent (see Global run settings)
env: # optional run-wide environment layer (str → str)
CURSOR_MODEL: pro
stages:
<stage-name>:
agent: codex # optional per-stage agent override
prompt: | # optional per-stage prompt override
Additional per-stage instruction.
loop: 2 # optional iteration count (>= 1)
skills: [web-search] # optional skills merged with the pipeline stage's skills
approve: auto # optional auto-approval directive: auto | plan | dialog
notes: # optional note buttons attached to the stage
fix: Fix the failure and continue
reflect: # optional memory-reflection instruction (reflect method only)
file: shared.md
memory: true # optional memory participation (alignment method only; never together with reflect)
assistants: # optional stage assistant attachments (a name-keyed map)
reviewer:
when: finish
gates: # optional quality-gate check steps (a list)
- name: tests
script: pytest -q
assistants: # optional catalog of run-level assistants (a name-keyed map)
reviewer:
prompt: Review the stage changes.
delegation: # optional delegation-bounds block
depth: 3
max_tasks: 50
repeat: # optional run-cycle tuning block (repeatable pipelines only)
max_cycles: 3
gates: # optional quality-gate settings block (see Quality gates)
max_iterations: 2
memory: # optional workflow-memory configuration block
method: reflect # reflect | alignment (the instruction vocabulary selector)
max_rules: 25 # optional rule cap (>= 1)
extend:
<new-stage-name>:
after: [specify] # position the new stage relative to existing ones
title: Warmup # optional display label; defaults to the entry key
prompt: | # any other stage field passes through verbatim
Bootstrap instruction for the new stage.
| Key | Type | Required | Description |
|---|---|---|---|
prompt |
string | no* | Top-level prompt emitted as the first key of the output. |
stages |
map | no* | Per-stage override instructions keyed by stage name. |
extend |
map | no* | New stages to add to the pipeline, keyed by new stage name. |
memory |
map | no* | Workflow-memory configuration (see Project memory). |
profile |
string | no | Default profile name activated when no --profile/GOGA_PROFILE channel provided one. Must be a literal (a templated default does not participate in activation). A profile:-only workflow is invalid — activation is not content. |
build |
map | no* | Configuration layered onto the build section for nested goga build runs (see the build documentation). A build:-only workflow is valid. |
assistants |
map | no* | Catalog of run-level assistants keyed by assistant name (see Collaboration). An assistants:-only workflow is valid. |
delegation |
map | no* | Delegation bounds — depth and max_tasks (see Collaboration). A delegation:-only workflow is valid. |
repeat |
map | no* | Run-cycle tuning for a repeatable pipeline — max_cycles / keep_runs (see Run cycles). A repeat:-only workflow is valid. |
gates |
map | no* | Quality-gate retry tuning — patience / max_iterations / fresh_correction (see Quality gates). A gates:-only workflow is valid (and inert without gated stages). |
agent |
string | no* | Global run setting — the run's global CLI agent: the effective global agent (this value, else pipeline.agent) runs the afm client command, the per-stage env wrapper fallback, and the assistant fallback (see Global run settings). An agent:-only workflow is valid (a blank value equals absence). |
env |
map of str→str | no* | Global run setting — the run's global environment layer: merged key-wise above pipeline.env into the afm launch env (this map wins per key) and layered under every pass env of nested goga build runs (see Global run settings). An env:-only workflow is valid (an empty map equals absence). |
* At least one of prompt, a non-empty stages block, a non-empty
extend block, a memory block, a build block, an assistants
block, a delegation block, a repeat block, a gates block, the
agent key (a blank value equals absence), or a non-empty env block
must be present; an empty workflow is rejected with a structural error.
profile does not count — a profile:-only workflow is invalid.
Unknown top-level keys are rejected with
unknown key in workflow: <KEY>; valid keys: prompt, stages, extend, memory, profile, build, assistants, delegation, repeat, gates, agent, env.
Global run settings (agent, env)
The two top-level run settings configure the run globally — no per-stage authoring required:
agent: codex # the run's global CLI agent
env: # the run's global environment layer (str → str)
CURSOR_MODEL: pro
agent names the effective global agent of the run: this value when
the workflow carries one (an empty or whitespace-only value equals
absence), else the configuration's pipeline.agent. The effective
global agent runs exactly three things — the afm client command, the
per-stage env wrapper fallback (see Stage entries),
and the assistants catalog fallback (an assistant without its own
agent launches under it — see
Collaboration). Gate AI-review
steps keep their own strict agent requirement — the global agent is
never their fallback. A non-string value is a structural error
(non-str value in workflow.agent).
env is the run's global environment layer, merged key-wise above
pipeline.env into the afm launch env (this map wins per key;
-e KEY=VALUE still wins above both, and the engine keys are dropped —
see Pipelines — Configuration). It reaches every
stage ambiently through the launch layer — a per-stage env closure
exports only the stage's own values above it. The map must be str → str
(non-mapping env in workflow, non-str key in workflow.env,
non-str value in workflow.env.<KEY>); an empty map equals absence.
Both keys ride the Jinja2 profile rendering like the rest of the file,
and both are active only through the run's workflow — --no-workflow,
a silent auto-match miss, or no workflow file changes nothing.
The build layering
When a nested goga build runs with this workflow in effect, the two
globals layer onto the build configuration as the middle layer of
config < workflow global < workflow build: < CLI — with or without a
build: block. Per pass (tasks, review, additional), the agent resolves
build-block > global > configuration, and the env merges key-wise
configuration < global < block (see the
build documentation).
Stage entries
Each entry under stages is keyed by stage name and accepts up to thirteen
fields:
| Field | Type | Default | Description |
|---|---|---|---|
agent |
string | — | CLI agent name (e.g. codex, claude, cursor, opencode, qwen). Selects which agent runs this stage; forbidden on a script stage — a structural error at compile time (agent is forbidden on a script stage in workflow.<NAME>), the same exclusivity family as gates and assistants on a script stage. See Workflow agent — choosing the CLI agent. |
env |
map of str→str | — | Per-stage environment variables, exported verbatim by a generated sh closure wrapping the stage's execution target — the entry's own agent, else the extend-entry agent of the same name, else the effective global agent (the workflow's global agent when present, else pipeline.agent). On an agent stage the closure replaces the stage's command; on a script stage the authored script becomes the closure's payload (the compiled script: field is patched to the wrapper, which re-executes the script inside the exported environment). Every loop-expanded copy gets its own closure carrying the same values; keys must be legal environment variable names and values are shell-quoted in the closure. An empty map equals absence. Allowed ONLY in stages — it is a structural error under extend (env is forbidden in workflow.extend.<NAME>). |
prompt |
string | — | Per-stage context prompt. Lower precedence than the stage's own prompt — closer to a section description than to a direct instruction. See Workflow prompt — context, not command. |
loop |
int | — | Positive iteration count (>= 1). When >= 2, the stage is expanded into N chained copies. |
skills |
string list | — | Skill names merged with the pipeline stage's own skills (pipeline-first, deduplicated by value). See Skills merge. |
skip |
bool | — | When true, the compiler DELETES this stage from the compiled pipeline (the stage is absent from the flow-file entirely). Dependents of the skipped stage are transparently reconnected to its predecessors (no dangling references). false (or an absent key) leaves the stage in place. skip is allowed ONLY in the stages block — it is a structural error under extend. skip wins over agent/prompt/loop/skills overrides on the same entry. |
approve |
string | — | Auto-approval directive. Accepted values are auto, plan, and dialog; any other value (or a non-string) is a structural error. Each value drives a subset of two INDEPENDENT effects the compiler applies to the stage body (see Auto-approval (approve: auto/plan/dialog)): (1) communication effect — if the body has communication: true, the stage's interactive output is SUPPRESSED (omitted, not false); (2) roles effect — if the body's raw roles contain planner, the stage emits auto_approve: true. auto drives BOTH effects; plan drives only the communication effect; dialog drives only the roles effect. Allowed in both stages and extend (inline default override; a stages entry wins per-field). |
manual |
bool | — | Manual-launch instruction, stages block only. true forces the manual launch mode for the stage, overriding any authored trigger in its body. false cancels a manual state coming from either body source (a pipeline-file trigger: manual or an extend body trigger: manual) and is a structural error (manual: false on non-manual stage <NAME>) when the stage is not manual. An absent key means no instruction — the stage's own trigger decides. The three states (true/false/absent) are distinct; a non-bool value (including null) is a structural error. Allowed ONLY in stages — it is a structural error under extend (a new stage's launch mode is authored in its body via trigger). skip wins over manual: a skipped stage is removed before the manual instruction is applied. See Manual launch (manual and trigger). |
notes |
map of str→str | — | Note buttons — a map of "note name → prompt text" attached verbatim to the stage. Single-line texts serialize as plain scalars, multi-line texts as block literals. An empty map equals absence (no buttons emitted). Allowed ONLY in stages — it is a structural error under extend (an extend-stage receives its buttons through the stages block by name). Every loop-expanded copy carries the same buttons; skip wins over notes. How the buttons surface during the run is owned by the pipeline runtime — the compiler only assembles them. See Note buttons (notes). |
reflect |
map | — | Memory-reflection instruction (reflect method): {file: <path>, mode: r\|w\|rw} naming which memory file the stage reflects into. file is required and must be a relative, non-escaping path shape; mode defaults to rw. Allowed ONLY in stages — it is a structural error under extend. See Project memory (memory, reflect). |
memory |
bool | — | Memory-participation instruction (alignment method): true marks the stage as participating in project memory. An explicit false equals absence. Allowed ONLY in stages — it is a structural error under extend. See Project memory (memory, reflect). |
assistants |
map | — | Stage assistant entries keyed by assistant name — each entry a reference (gate/when), a full inline declaration, an extension of a pipeline-declared name (may omit when), or a {skip: true} veto; an empty map equals absence. Allowed ONLY in stages — it is a structural error under extend. See Collaboration (assistants, delegation). |
gates |
list | — | Quality-gate check steps the stage must pass before it counts as done — a list of {name, script xor agent, timeout?, prompt?, env?} mappings; an empty list equals absence. Allowed ONLY in stages — it is a structural error under extend and in any stage body. See Quality gates (gates). |
Rules:
- Only
agent,env,prompt,loop,skills,skip,approve,manual,notes,reflect,memory,assistants,gatesare valid. An unknown key is rejected withunknown key in workflow.stages.<NAME>: <KEY>; valid keys: agent, env, prompt, loop, skills, skip, approve, manual, notes, reflect, memory, assistants, gates. loopmust be an int>= 1. Zero, negative values, and non-int types raise a structural error.skillsmust be alist[str]. A non-list (or a list with non-string elements) raisesnon-list-of-str skills in workflow.stages.<NAME>.skip(when present) must be abool. A non-bool value raisesnon-bool value in workflow.stages.<NAME>.skip.skipis allowed only in thestagesblock — it is a structural error underextend(see Skipping a stage).approve(when present) must be one of the stringsauto,plan, ordialog. A non-string value raisesnon-str value in workflow.stages.<NAME>.approve; any other string raisesapprove must be one of: auto, plan, dialog in workflow.stages.<NAME>(see Auto-approval (approve: auto/plan/dialog)).manual(when present) must be abool. A non-bool value (including an explicitnull) raisesnon-bool value in workflow.stages.<NAME>.manual.manualis allowed only in thestagesblock — it is a structural error underextend.notes(when present) must be a mapping with string values. A non-mapping value (including an explicitnull) raisesnon-mapping notes in workflow.stages.<NAME>; a non-string value raisesnon-str value in workflow.stages.<NAME>.notes.<KEY>. An empty map is treated as absence.notesis allowed only in thestagesblock — it is a structural error underextend(see Note buttons (notes)).reflect(when present) must be a mapping with a key set within{file, mode};fileis required and must be a valid path shape,modeone ofr/w/rw.reflectis allowed only in thestagesblock — it is a structural error underextend(see Project memory (memory,reflect)).memory(when present) must be a bool; an explicitfalseequals absence.memoryis allowed only in thestagesblock — it is a structural error underextend(see Project memory (memory,reflect)).- The stage value must be a mapping. Non-mapping values raise
non-mapping stage <NAME> in workflow.stages. - Stage names are validated against the target pipeline: a name that does not
match any step in the pipeline or any
extend-stage is a structural error. agentis not validated against a known agent set. Absence of the corresponding wrapper file is surfaced at run time.
Workflow agent — choosing the CLI agent
Two different
agentconcepts. The pipeline-file stage fieldrolesnames the roles that organize the work inside a stage —planner,executor,reviewer(plus the always-onsummaryreport). See stage modes. The workflow-file stage fieldagent(singular) is a different concept: it names the CLI agent that runs the stage —claude,codex,cursor,opencode, or any other installed wrapper. The two are orthogonal.
A workflow's per-stage agent field lets the same pipeline run different
stages on different CLI agents. This is what makes a pipeline portable
across CLI tools: you keep one pipeline-file (the work to be done) and
express "stage X should run on codex, stage Y on claude" in a
project-level workflow-file, without forking the pipeline.
Each agent value resolves to a wrapper script installed in the goga image
at /home/goga/bin/<agent>-as-claude.sh. The wrapper presents the named
CLI agent to the pipeline runner in a uniform invocation shape, so the
pipeline itself does not care which concrete CLI is underneath.
The canonical baseline wrappers shipped with the image — claude, codex,
cursor, opencode, qwen — and their per-agent environment variables are
documented in Agents under
the Configuration reference. This page keeps the workflow-scoped agent
semantics (per-stage override, inline-extend agent); the wrapper set
itself is shared with build and pipeline.
Any other value is permitted as long as the corresponding wrapper file exists in the image — absence is surfaced at run time, not at validation time.
When a stage does not specify an agent in the workflow, the pipeline
falls back to the extend-entry agent of the same stage name (the inline
default an extend entry may carry), and then to the effective global
agent — the workflow's global agent key (see
Global run settings) when the workflow
carries one, else the pipeline's global default agent (typically
claude). Setting agent per-stage overrides both fallbacks for the
named stage only; other stages keep the global default.
Workflow prompt — context, not command
The per-stage prompt in a workflow-file is not a direct instruction
to the agent. Its weight is lower than the stage's own prompt field
declared in the pipeline-file, and it is
closer in role to a section description: it sets context, frames the
stage's intent, and gives the agent additional background to interpret the
stage's main prompt against.
Two consequences follow from this lower precedence:
- The workflow
promptdoes not override or replace the stage's ownprompt. The stage's declared prompt remains the authoritative instruction; the workflowpromptsits beside it as additional context. - The workflow
promptdoes not by itself command the agent to take specific actions. Free-form prose is interpreted as background, not as a directive.
To make a workflow prompt carry actual requirements, follow the
explicit labeled format the goga prompts already use — sections like
Requirements:, Constraints:, Algorithm:. Labeled blocks are
recognized as instructions and are honored as such; unstructured prose is
not.
Example — descriptive context only (no enforceable requirements):
stages:
specify:
prompt: |
This stage formalizes the user's request into a task document.
It runs early in the lifecycle and shapes the rest of the pipeline.
Example — context with enforceable requirements (the labeled block is honored as an instruction):
stages:
specify:
prompt: |
Task formalization process.
Requirements:
- Examine all link connections between cells carefully.
- Do not write code examples in the task.
Constraints:
- Do not build architecture in the task.
In the second form, the Requirements: and Constraints: blocks are the
load-bearing parts — the leading paragraph is still just context.
Skipping a stage
A stages entry may set skip: true to remove the named stage from the
compiled pipeline. The stage disappears from the flow-file entirely, and its
dependents are transparently reconnected: any stage that depended on the
skipped stage instead depends on the skipped stage's own predecessors. Chains
are resolved transitively — in A → B → C, skipping B makes C depend on
A; skipping both A and B makes C depend on whatever A depended on
(nothing, in the limit). For a phases pipeline, removal is positional (the
next stage simply chains to the new predecessor). skip wins over
agent/prompt/loop/skills overrides on the same entry, and removing
every stage is a structural error (empty body).
Auto-approval (approve: auto, plan, dialog)
A stages (or extend) entry may set an approve directive to drive the
stage's auto-approval behavior at compile time. The directive is one of
three values — auto, plan, or dialog — chosen from a closed set, not a
free-form flag, so any other string (or a non-string) is a structural error.
The compiler applies two independent effects to the stage body, and each directive drives a subset of them:
- User-input suppression (the communication effect) — if the stage
body has
communication: true, the stage's user-input pause is SUPPRESSED entirely. This makes an otherwise user-prompting stage run non-interactively.communication: false(or nocommunicationkey) is unaffected — suppression fires only whencommunication is True. - Auto-approval (the roles effect) — if the stage body's raw
roleslist containsplanner, the stage's agent actions are auto-approved. The match is against the authored role aliasplanner.
approve |
communication effect (suppress user input) | roles effect (auto-approve actions) |
|---|---|---|
| (absent) | — | — |
auto |
✓ | ✓ |
plan |
✓ | — |
dialog |
— | ✓ |
So auto is the full directive (both effects, as before); plan keeps the
communication effect but turns the roles effect OFF (a planner stage does
NOT auto-approve); dialog keeps the roles effect but turns the
communication effect OFF (communication: true still pauses for input).
The two effects are independent: each fires on its own trigger AND its
own directive subset. With neither trigger present, the directive is a no-op on
the body (it still threads through; it just has nothing to act on).
Under extend, approve is an inline default override exactly like inline
agent/loop (see Inline agent, loop, and approve overrides):
it is extracted from the entry (never reaches the body), and a stages entry
naming the same stage wins per-field.
Manual launch (manual and trigger)
A stage's launch mode has two authoring surfaces that meet in the compiler:
- The stage body (a pipeline-file stage or an
extendbody) carries atriggerfield —on_success(the default) ormanual.trigger: manualforces the manual launch mode (see Pipeline files): the stage pauses when reached and runs only when launched manually. An authoringauto_runkey in a body is a structural error — the launch mode is assembled by the compiler, never authored. - The workflow
stagesblock carriesmanual— a force/cancel instruction applied ON TOP of the body, without editing the pipeline-file:
manual |
Effect on the stage |
|---|---|
| (absent) | No instruction — the body's own trigger decides. |
true |
Forces manual launch, overriding any authored trigger. Idempotent on a stage that is already manual. |
false |
Cancels manual: an effective trigger: manual (from the pipeline-file body or an extend body) is rewritten to on_success, so the stage launches automatically. A structural error when the stage is NOT manual (manual: false on non-manual stage <NAME>) — cancelling a state that does not exist is an authoring mistake, not a no-op. |
manual is allowed ONLY in the stages block — under extend it is a
structural error (manual is forbidden in workflow.extend.<NAME>): a new
stage's launch mode is authored in its own body via trigger, never via a
workflow instruction. skip wins over manual: a skipped stage is removed
before the manual instruction is applied, so skip: true + manual: true
on one entry simply deletes the stage. On a loop-expanded stage every copy
carries the launch mode of the original.
Note buttons (notes)
A workflow's per-stage notes field attaches note buttons to a stage: a
map of "note name → prompt text" that the compiler attaches verbatim to
the stage as its note buttons.
stages:
deploy:
notes:
fix: Fix the failure and continue
investigate: |
Gather diagnostics for the failure.
Include the last 50 log lines.
- The map passes through verbatim — keys and values unchanged, authoring order preserved. Single-line texts serialize as plain scalars (quoted as needed); multi-line texts serialize as block literals.
- Buttons are authored ONLY through this instruction. An authoring
buttonskey in a stage body (a pipeline-file stage or anextendbody) is a structural error (buttons key is forbidden in stage body; use notes in workflow.stages) — there is exactly one authoring source, so the compiler-assembled field can never collide with an authored one. notesis allowed ONLY in thestagesblock — underextendit is a structural error (notes is forbidden in workflow.extend.<NAME>). An extend-stage receives its buttons through thestagesblock by its name, like any other stage.- An empty map (
notes: {}) equals absence — nobuttonskey is emitted.noteschanges nothing else: a workflow whose entries are all empty compiles byte-identically to compiling without a workflow, while any other instruction (prompt,agent,loop,skip, ...) changes the output as usual — notes or not. - Every
loop-expanded copy carries the same buttons, andskipwins overnotes: a skipped stage is removed before the buttons are resolved, so its notes never leak into a survivor. - How the buttons surface during the run is owned by the pipeline runtime — the compiler only assembles them.
Project memory (memory, reflect)
A workflow can wire its stages into the runner's project memory: a
top-level memory block selects the method and the block-level settings,
and the per-stage instructions mark which stages participate.
memory:
method: reflect # reflect (default) | alignment
max_rules: 40 # rule cap, >= 1, default 25
commit: false # whether memory changes are committed
stages:
prototype:
reflect: # reflect method: which file the stage reflects into
file: shared.md
mode: rw # r | w | rw, default rw
accept:
reflect:
file: shared.md
Under method: alignment the participating stages carry memory: true instead — see the key table below.
The top-level block accepts these keys:
| Key | Type | Default | Description |
|---|---|---|---|
method |
string | reflect |
The instruction vocabulary: reflect pairs with the per-stage reflect instruction, alignment with the per-stage memory instruction. Never part of any output. |
path |
string | — | Suffix inside the fixed memory root .goga/memory. Must be a relative, non-escaping path shape. |
max_rules |
int | 25 |
The maximum number of memory rules (>= 1). |
commit |
bool | false |
Whether memory changes are committed. |
mode |
string | rw under alignment |
The project-memory access mode (r/w/rw). Authored ONLY under method: alignment — an authored mode together with method: reflect is a structural error. |
Behavior rules:
- The method selects the instruction vocabulary. Under
reflect(the default when no block is authored) a stage participates by carrying areflect: {file, mode?}instruction; underalignmentit participates by carryingmemory: true. The two vocabularies never mix: areflectinstruction underalignment, or amemory: trueinstruction underreflect(including with no block at all), is a structural error. - The block is emitted iff at least one stage participates. A memory
configuration without participation is a silent no-op — no block, no stage
keys, not even an opting-out stage key. A workflow consisting of the
memoryblock alone is still valid (it counts as content). - Participation is counted over the working body — after skip removal
and loop expansion, embedded extend-stages included. A skipped stage's
instructions die with it: skipping the only participating stage disables
the block entirely. Every
loop-expanded copy carries the same memory keys as its original. - Project memory lives under the fixed root
.goga/memory(plus the authoredpathsuffix when one is set). How the memory settings and the per-stage participation are encoded into the compiled pipeline is an internal contract of the compiler; this documentation intentionally does not pin the compiled form. - Both instructions are allowed ONLY in the
stagesblock — underextendthey are structural errors. A new stage participates through astages-block entry authored under its name. Authoring areflectormemory_usekey in any stage body (a pipeline-file stage or an extend body) is likewise a structural error — the memory stage keys come from the workflow instructions alone. - The memory mechanism is executed by the pipeline runtime inside the
container — goga authors and compiles the instructions. If your image
predates the mechanism, refresh it with
--update.
Collaboration (assistants, delegation)
A workflow can attach helper agents to its stages and add run-level
team agents through the runner's collaboration mechanism: a top-level
assistants catalog declares the named assistants, a top-level
delegation block bounds helper delegation, and the per-stage
assistants instruction attaches assistants to stages.
Workflow collaboration requires afm 2.0+ (the shipped image carries it); a
gated finish attachment (gate: true + when: finish) compiles to the
engine's pre_completion review round and requires afm 2.2.9+. Such a stage
also carries the computed correction budget pre_completion.max_failures =
(the stage's gate assistants × 10) — without it the engine default (1) caps
the gate assistants at one round's worth of findings. The budget is compiled,
never authored. An older
image predating the mechanism must be refreshed with --update.
assistants: # the catalog — run-level assistants (a name-keyed map)
reviewer:
agent: claude # optional; defaults to the effective global agent
delegate: true # optional; may create child tasks
skills: [code-audit] # the assistant's own skills
prompt: |
Review the stage changes and report concrete findings.
delegation: # optional delegation bounds
depth: 3 # max delegation depth (>= 0); 0 forbids helpers
max_tasks: 50 # whole-run helper task budget (>= 1)
stages:
build:
assistants:
reviewer: # 1) reference — the declaration comes from the catalog
when: finish
accept:
assistants:
reviewer: # 2) reference with the gate override
gate: true
when: finish
security: # 3) full inline declaration
prompt: Audit the diff.
when: checkpoints
The top-level assistants: catalog is a name-keyed map: each key IS the
assistant name — it must match [A-Za-z0-9._-], assistant is reserved
(its dashboard handle is), and it is unique across the catalog and every
inline declaration. Each entry value accepts these keys:
| Key | Type | Default | Description |
|---|---|---|---|
prompt |
string | — | The assistant's instruction. Not required at parse time — see the effective-content rule below. |
skills |
list of strings | — | The assistant's own skills. Not required at parse time — see the effective-content rule below. |
agent |
string | effective global agent | A CLI agent name, resolved implicitly at delivery — no wrapper path is authored. The fallback is the effective global agent (the workflow's global agent when present, else pipeline.agent). |
delegate |
bool | not authored | Whether the assistant may create child tasks. Tri-state at parse time: unset inherits from a tool-delivered base in the override merge and materializes false at delivery; an explicit false opts out. |
env |
map of str→str | — | The assistant's environment variables, delivered through a generated closure that wraps the assistant's launch command (the same mechanism as per-stage env). An authored empty map (env: {}) is an explicit override that clears the field — not an absence. |
An entry may carry none of the five content fields — an override-style
entry whose effective content resolves through the assistant
overrides at compilation. The requirement is on the
effective entry: after the tool contributions merge, every assistant in
the namespace must resolve a prompt or a skills list, or compilation
stops with assistant <name> at <site> resolves neither prompt nor skills
naming the authoring site (workflow.assistants.<name> or
workflow.stages.<stage>.assistants.<name>). The check covers the whole
namespace — an entry no stage references, or one declared on a skip: true
stage, is still authored content and still checked.
name, gate, when, and skip never appear in a catalog entry value —
the map key is the name itself, and gate/when/skip are attachment
parameters (authoring any of them in the catalog is a structural error).
The top-level delegation: block accepts:
| Key | Type | Default | Description |
|---|---|---|---|
depth |
int >= 0 |
not authored | Maximum delegation depth; 0 forbids helper creation entirely. Travels into the compiled flow as the collaboration depth. Verified engine behavior (afm v2.0.9): at depth: 0 the engine also declines run-level team-agent creation (delegation_depth_exceeded warnings) — team agents start at depth >= 1. |
max_tasks |
int >= 1 |
50 |
Whole-run helper task budget — every helper, run agent, and child task counts against it. Written into the engine configuration only when the block is authored. |
Both keys are optional; an empty block is valid and materializes
max_tasks: 50. A workflow consisting of the delegation: block alone —
or of the assistants: catalog alone — is valid.
The per-stage assistants instruction is a name-keyed map — each key names
the assistant (identifying the catalog entry for a reference, or the
declaration itself for an inline entry), and each value carries the
attachment parameters. Four entry forms:
- A reference — a value carrying only
gate/when: the agent, prompt, skills, delegate permission, and env come from the catalog entry; onlygateandwhenare the attachment's own. - A full inline declaration — a value carrying any further key
(
prompt,skills,agent,delegate,env, plusgate/when). Independent of the catalog; no content field is required at parse time (the effective-content rule above applies after the merge). Note:skillsauthored here has no effect — the engine accepts skills only on run-level team entries, and only catalog entries and pipeline-file stage declarations become team members (see the behavior rules below). - An extension of a pipeline-declared name — a value carrying
declaration keys (
prompt,skills,agent,delegate,env) whose name the addressed stage's pipeline-file body declares. May omitwhen/gate— an omitted one inherits the declaration's (an authoredgate: falsedowngrades it); see Governing pipeline-shipped assistants. - A
{skip: true}veto — the key alone, dropping the pipeline declaration's attachment, team member, and profile for this workflow (the stage still runs).
| Attachment key | Type | Default | Description |
|---|---|---|---|
when |
start | checkpoints | finish | message |
not authored | When the assistant engages. message is the resting engagement: the engine sends no initial request — the helper waits for messages and stays attached after each answer (one turn per message). |
gate |
bool | not authored | true — the assistant's verdict must pass (or be waived by a human) before the stage may finish; false is advisory. With when: finish the gate engages as the engine's pre-completion review round (pre_completion, afm 2.2.9+); an ungated finish keeps the final-turn engagement. A gated finish also compiles the stage's correction budget — pre_completion.max_failures = (gate assistants × 10), computed, never authored. |
skip |
bool | not authored | true ALONE — veto one pipeline-declared assistant of this stage (see Governing pipeline-shipped assistants). |
when is required on an entry that names an assistant declared in the
workflow-file — the entry key already names the assistant, so its
engagement timing is authored explicitly. A when-less entry is legal
authoring when the name is declared by the pipeline-file stage the entry
addresses (an extension); compilation raises "when is required" for a
when-less entry naming no such declaration. An unknown attachment key is
a structural error (valid keys: prompt, skills, agent, delegate, env,
gate, when).
Behavior rules:
- Names form one namespace. The catalog and every inline declaration
share a single namespace with the pipeline-file stage declarations of
the compiled pipeline — a name collision between any two sources is a
compilation error naming both authoring sites, and the name
assistantis rejected (assistant name is reserved). - References resolve at compile time. A reference naming no catalog
entry and no inline declaration of the effective document is a compile
error (
unknown assistant reference in workflow.stages.<NAME>). The same assistant attached twice to one stage is a compile error — reachable only through a programmatic (tool) contribution, since an authored map cannot repeat a key — as is an attachment on a stage whose body carriesscriptor whose agents value is exactly["planning"]— helpers attach to execution stages only. - Attachments live only under
stages.<name>. Authoringassistantsinside anextend-entry is a structural error — the attachments of a new stage are authored in thestagesblock under its name. A pipeline-file stage body declares its own helpers through itsassistantsmap (see Pipeline file — Stage assistants); anassistantsmap in a workflow extend-entry body is a structural error. - Defaults are materialized, never invented.
gateandmax_tasksalways carry their materialized values into the compiled output;whenhas no default of its own — it is authored on every entry naming a workflow-declared assistant, and an extension of a pipeline-declared assistant inherits the pipeline'swhenwhen omitted; the compiled engagement value is always written explicitly.delegatematerializesfalseonly at delivery: while authoring it stays tri-state, so an unset value can inherit from a tool-delivered base in the assistant overrides — an authoredfalseopts out and never inherits. The engine's own defaults (aone_shottrigger, a 20-task budget) are never relied upon. - Skills deliver through the team. The engine accepts
skillsonly on run-level team entries, and the team is built from theassistants:catalog plus the pipeline-file stage declarations — soskillsauthored on a catalog entry or a pipeline declaration reaches the engine, whileskillsauthored on a full inline declaration has no channel: the compiler logs a warning naming the stage and the assistant and drops the value. Declare the assistant in the catalog (and attach it by reference) to deliver its skills. - Every
loop-expanded copy carries its stage's attachments; a skipped stage attaches nothing. - No profile concept is user-visible. The engine requires each helper
to reference a profile; goga generates and maintains that plumbing
(
goga-<name>bindings and their launch commands) from the compiled flow on every launch. There is nothing to author or manage, and a user-authored profile with the samegoga--prefixed id deliberately replaces goga's plumbing. - Authored configuration applies on every launch. The engine configuration is rewritten per run and the helper plumbing (including env closures) is regenerated with it — the workflow-file is the durable source, so the same authoring takes effect on consecutive runs.
- If the environment disables collaboration, declared helpers are skipped with engine warnings and the run proceeds.
Governing pipeline-shipped assistants
A stage of the pipeline-file may ship its own helper declarations (authored
in the pipeline-file stage body). The
workflow addresses such a shipped assistant through the same
stages.<stage>.assistants.<name> entry, keyed by the name's origin:
Skip — the veto. {skip: true} alone removes the assistant from that
stage for this project: no attachment, no team membership, no generated
profile — the stage itself still runs. skip targets exactly one pipeline
declaration of that stage; skipping a name no pipeline declaration of that
stage declares is a compilation error (a catalog or inline name is governed
by not authoring an attachment, never by skip). skip: false alone
authoring nothing is a structural error, and skip mixed with any other
key is a contradictory-authoring error.
Extension — additive configuration. Any other entry addressing a pipeline-declared name extends it:
| Key | Effect |
|---|---|
when |
overrides the pipeline engagement (omitted — the pipeline value stands) |
gate |
overrides the pipeline gate (omitted — stands; explicit false deliberately downgrades a gated helper to advisory) |
agent / env / delegate |
configure delivery for this project |
prompt |
APPENDED to the pipeline text — pipeline text first, one blank line, then this text |
skills |
EXPANDS the pipeline list — pipeline entries first, then these, deduplicated by value |
An extension may omit when — the pipeline engagement stands. A workflow
that mentions a shipped assistant not at all leaves it exactly as the
pipeline authored it — it attaches on every run, with or without a
workflow-file.
Visibility. A pipeline-declared name is visible only to its own stage's entry: addressing it from another stage is an unknown-assistant error. The name must not collide with the workflow's catalog or any inline declaration — one global namespace, enforced at compilation.
stages:
review:
assistants:
auditor: # declared by the pipeline-file stage 'review'
skip: true # veto — does not run in this project
notifier: # declared by the pipeline-file stage 'review'
when: checkpoints # re-time: pipeline 'finish' overridden
agent: codex # delivery retargeted for this project
Assistant overrides
An authored entry — catalog or inline — whose name matches an assistant a
tool delivered overrides it field by field: every field the author set
wins whole (prompt, skills, agent, delegate, env; presence
decides, never truthiness — skills: [] and env: {} are authored values
that clear the field), and every field the author left unset flows from the
tool's delivery. gate/when are always the authored ones. The authored
entry keeps its position — a catalog entry stays a catalog entry (and a
team member), an inline declaration stays on its stage.
This is the authoring surface over the tool contributions: a tool that
delivers an assistant through its pipeline.amend_workflow contribution
(see Hooks) can be retuned per project without forgoing the
delivery — author a same-named entry and set only the fields you want to
change.
# the tool delivers "reviewer" with its own prompt, skills, and env;
# the workflow-file overrides the agent and clears the env, the rest flows
assistants:
reviewer:
agent: codex
env: {}
An override naming an assistant no tool delivered carries no base to
flow from — its unset fields stay unset, and the effective-content rule
above stops compilation (assistant <name> at <site> resolves neither
prompt nor skills) naming the authoring site. Give the entry a prompt
or a skills list, or drop the entry.
Run cycles (repeat)
A workflow can put a repeatable pipeline into a running cycle: the
pipeline-file header declares the capability (repeatable: true — see
Pipeline File — Header), and the workflow-file
authors the tuning through the top-level repeat block. The engine (afm
2.0.9+; the shipped image carries it) then runs the complete stage
sequence in cycles until a stop condition.
repeat:
max_cycles: 3 # at most 3 complete passes
keep_runs: 5 # keep the 5 most recent cycle run-directories
The block carries the engine's vocabulary verbatim — goga materializes no defaults, and both keys are optional:
| Key | Type | Default | Description |
|---|---|---|---|
max_cycles |
int >= 0 |
— | At most N complete passes. 0 is an authored value carried verbatim; its cycle meaning belongs to the engine. |
keep_runs |
int >= 0 |
— | How many recent cycle run-directories to keep (the engine default is 2). |
Rules:
- The block belongs to a repeatable pipeline. A
repeat:block in the workflow of a pipeline whose header does not declarerepeatable: trueis a compile-time structural error (workflow repeat block requires a repeatable pipeline; author repeatable: true in the pipeline header). - A repeatable pipeline always compiles a
repeatkey. Authored keys ride verbatim (max_cycles: 0compiles as0); with no block, no workflow-file, or--no-workflow, the compiled output carries the scalarrepeat: true(unlimited cycles, engine defaults). The compiled key sits immediately afterdescription. A non-repeatable pipeline compiles norepeatkey at all. - Structural validation at parse time. A non-mapping value — including
the scalar
repeat: true, which belongs to the compiled flow-file, not to the authoring surface — raisesnon-mapping repeat block in workflow; an unknown key raisesunknown key in workflow.repeat: <KEY>; valid keys: max_cycles, keep_runs; a non-int value raisesnon-int value in workflow.repeat.<KEY>; a negative value raises<KEY> must be >= 0 in workflow.repeat. A boolean is not an integer for these checks. - An empty block (
repeat: {}) equals absence — the document carries no repeat instruction. A workflow consisting of the block alone is valid. The workflow-level way to pin a repeatable pipeline to a single pass isrepeat: {max_cycles: 1}. - goga owns no cycle logic. Cycle counting, stop-on-failed-cycle (a
cycle that ends with a failed stage stops the repeat — no next cycle),
run-directory pruning, and the
flow_repeatedevents the engine emits between cycles all belong to afm — the run stays a singleafm runinvocation.
Quality gates (gates)
A workflow can attach quality gates to its stages: a per-stage list of
check steps the stage must pass before it counts as done, plus an
optional top-level settings block tuning the correction retries. Gates
compile one-directionally into the engine's stage-completion gate — the
verify field of the flow-file (afm 2.0+; the shipped image carries it).
goga never runs the checks: the engine executes the compiled gate and owns
every retry semantic.
gates: # optional workflow-level settings block
max_iterations: 2 # bound of failed correction attempts
fresh_correction: true # whether a correction session starts fresh
stages:
implementation:
gates: # the check steps of this stage, in authored order
- name: Unit tests # the dashboard label; required on every step
script: pytest -q # a shell check step (script xor agent)
timeout: 30m # optional; carried verbatim
env: # optional; environment variables of the step
FOO: bar
- name: Code review # an AI-review step
agent: codex
prompt: | # the review instruction — agent steps only
Review the diff for correctness.
env: # valid on agent steps too
REVIEW_STRICTNESS: strict
The top-level gates: block accepts these keys — authored keys only; goga
materializes no settings defaults, and the engine defaults apply for
unauthored keys:
| Key | Type | Default | Description |
|---|---|---|---|
patience |
int >= 0 |
— | Tolerance for an unchanged correction stalemate. Compiles to review_patience. |
max_iterations |
int >= 0 |
— | Bound of failed correction attempts. Compiles to max_failures. |
fresh_correction |
bool | — | Whether a correction session starts fresh. Compiles verbatim. |
The workflow vocabulary maps one-directionally onto the engine's stage
verify vocabulary:
Workflow (gates) |
Engine (verify) |
Notes |
|---|---|---|
patience |
review_patience |
Setting keys translate; absent keys stay absent. |
max_iterations |
max_failures |
An authored 0 is a value, not an omission. |
fresh_correction |
fresh_correction |
Unchanged. |
step script |
step run |
A shell check step — gated on the exit status. |
step agent |
step command |
Agent-aware: claude → the bare alias claude; any other agent → the wrapper path /home/goga/bin/<agent>-as-claude.sh (the same template as the per-stage agent override; no agent-name existence check). See Gate step env for why. |
step name / prompt / timeout |
same names | Carried verbatim. |
step env |
— (no emitted key) | Never reaches the flow-file — see Gate step env below. |
Each check step is a mapping with up to six keys:
| Key | Type | Required | Description |
|---|---|---|---|
name |
string | yes | The step's dashboard label — required on every step. |
script |
non-empty string, or a non-empty list of non-empty strings | xor agent |
A shell check step. A list is the script's lines, joined with newlines into one multi-line script — identical in shell semantics to writing the same lines as a block scalar. |
agent |
non-empty string | xor script |
An AI-review step — the same agent-name vocabulary as the per-stage agent override. A single string, never a list. |
timeout |
string | no | Carried verbatim; the duration grammar is engine-owned. |
prompt |
string | no | The review instruction of an AI step — forbidden on a script step (prompt is forbidden on a script gate step in workflow.stages.<NAME>.gates[<i>]). |
env |
map of string → string | no | Environment variables of the step — valid on both step kinds; an empty map equals absence. |
A shell step without an authored timeout carries the materialized default
1h; an AI step materializes no timeout default. The 1h is a goga-side
product default, not an engine contract.
A multi-command check authors as the script's lines — a list, joined with newlines into one multi-line script at parse time:
Rules:
- Exactly one of
script/agentper step. Both or neither is a structural error (gates step must carry exactly one of script/agent in workflow.stages.<NAME>.gates[<i>]); a missingnameraisesgates step without name in workflow.stages.<NAME>.gates[<i>]. A scalarscript/agentdefect raisesscript must be a non-empty string in workflow.stages.<NAME>.gates[<i>](and theagentcounterpart); a list-formscriptthat is empty or carries a non-string/empty element raisesscript must be a non-empty list of non-empty strings in workflow.stages.<NAME>.gates[<i>]. - Empty equals absence. An empty settings block (
gates: {}) and an empty step list (gates: []) are treated as absent keys. - The settings block alone is inert. A workflow consisting of the
gates:block alone is valid — but the settings travel only with stages that declare check steps: without a gated stage nothing is emitted, no error is raised. - The settings ride on every gated stage when authored. When the
settings block authored at least one key, every gated stage's
verifycarries the steps plus the authored settings (the container form); with no settings block authored, a gated stage carries the steps alone (the list form). - Gates attach to execution stages only. A gate on a stage whose body
carries
scriptraisesgates are forbidden on a script stage in workflow.stages.<NAME>; a gate on a planning-only stage raisesgates are forbidden on a planning-only stage in workflow.stages.<NAME>— the engine rejects both. - Gates are authored ONLY in the
stagesblock. Agateskey in anextend-entry is a structural error (gates is forbidden in workflow.extend.<NAME>) — the checks of a new stage are authored in thestagesblock under its name, like any other stage. Authoringgatesor a rawverifykey in any stage body (a pipeline-file stage or anextendbody) is likewise a structural error —verifyis a compiled-only key. - Structural validation at parse time. A non-mapping settings value
raises
non-mapping gates block in workflow; an unknown settings key raisesunknown key in workflow.gates: <KEY>; valid keys: patience, max_iterations, fresh_correction; a non-int or negative value raisesnon-int value in workflow.gates.<KEY>/<KEY> must be >= 0 in workflow.gates; a non-list stage value raisesnon-list gates in workflow.stages.<NAME>. A boolean is not an integer for these checks. - Every
loop-expanded copy carries the same gate; a skipped stage attaches nothing — skip removal runs first, so the gates of a skipped stage drop silently. - Engine-owned semantics. Step sequencing (in order, fail-fast),
full-list re-runs after a correction, the correction budget and
stalemate rules, verdict parsing, and human waiver all belong to the
engine — the run stays a single
afm runinvocation. Older engines reject a gated flow at load (a downgrade is never silent); a malformedtimeoutor a whitespace-onlynamepasses verbatim and surfaces at engine load/preflight.
Gate step env
Each check step may carry an env map — environment variables for that
step's execution, valid on both step kinds (a shell script step and an
AI agent step alike):
stages:
implementation:
gates:
- name: Unit tests
script: pytest -q
env:
FOO: bar
- name: Code review
agent: codex
prompt: Review the diff.
env:
REVIEW_STRICTNESS: strict
The engine's verify-step schema has no env field, so the map never
reaches the flow-file as an emitted key. Instead goga delivers it through
the same mechanism as the per-stage env instruction (see the
env row of the stage-entries table):
after compilation, one generated sh closure wrapper per env-declaring step
exports the values verbatim and carries the payload (the authored script
lines on a shell step, or the exec of the agent wrapper on an AI step), and
the step's run/command line in the written flow-file is patched to
point at the wrapper. Every other byte of the flow-file stays untouched; a
workflow whose gates declare no step env compiles byte-identically.
One engine rule shapes the AI-step form: afm withholds the author's Claude
credentials — exactly ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL — from
any AI verifier whose command is not exactly the bare alias claude (a
bare claude verifier keeps them; everything else is expected to carry
its own auth). goga honors it both ways:
- an env-free
agent: claudestep compiles to the barecommand: claude, so the engine passes the credentials natively; - an env-carrying
agent: claudestep gets its closure with the pair re-injected: the values present in the goga process environment are captured at wrapper-generation time and exported beneath the authored env (a key the authored env also sets is not re-injected — the authored value wins; a key absent from the environment contributes no line). The pair lives only in the owner-only closure file (/tmp/goga-gate-env, per-launch, container-local) and never in logs.
Other agents (codex, cursor, opencode, qwen, custom) are unaffected:
their wrappers are format converters their CLI needs, and their own auth
environment reaches the verifier through the engine untouched.
Keys must be legal environment variable names (POSIX shape) — anything else is a strict pre-run error naming the stage, the step, and the key, raised before any wrapper is written. Values layer above every global env layer.
Worked example
A stages-format pipeline whose implementation stage is gated by two check steps
(a shell step with an authored timeout, an AI-review step), with the
settings block authoring a correction budget:
gates:
max_iterations: 2
fresh_correction: true
stages:
implementation:
gates:
- name: Unit tests
script: pytest -q
timeout: 30m
- name: Code review
agent: codex
prompt: |
Review the diff for correctness.
Compiled effect — the stage carries a verify block (after agents) in
the container form, steps in authored order, then the authored settings in
the fixed order max_failures, review_patience, fresh_correction
(exactly as emitted, stage fields at two spaces):
verify:
steps:
- name: Unit tests
run: pytest -q
timeout: 30m
- name: Code review
command: /home/goga/bin/codex-as-claude.sh
prompt: |
Review the diff for correctness.
max_failures: 2
fresh_correction: true
Without the settings block the same gate compiles to the list form, with the shell default timeout materialized:
Extending the pipeline with new stages
The stages block only overrides stages that already exist in the target
pipeline. The extend block does the complementary thing: it adds brand-new
stages that are not in the pipeline-file at all. Each extend entry is one
new stage, positioned relative to existing stages via before / after:
extend:
<new-stage-name>:
before: [plan] # place this new stage BEFORE the named stage(s)
after: [specify] # place this new stage AFTER the named stage(s)
agent: codex # optional: default agent override for the new stage
loop: 2 # optional: default loop override (>= 2 expands)
title: Warmup # optional; any other stage field passes through
prompt: | # verbatim stage body — same fields as a pipeline stage
Bootstrap the environment before the pipeline runs.
Positioning (before / after), default overrides (agent / loop /
approve), and the stage body are separate concerns:
beforeandafterare lists of existing stage names. The new stage is declared to run before thebeforenames and after theafternames. At least one of the two must be present — an entry with neither is rejected.agent,loop, andapproveare optional default overrides extracted from the entry (see Inline agent, loop, and approve overrides).- Everything else in the entry (
title,prompt,skills,roles,communication,trigger, or any other stage field) is the verbatim body of the new stage. It is carried through unchanged and embedded as an ordinary stage in the compiled output.before,after,agent,loop,approve, anddepends_onare never part of the body —agent/loop/approveare extracted as override fields, anddepends_onis forbidden here (positioning is declared structurally, not as a dependency edge).triggerIS part of the body: a new stage's launch mode is authored right there (trigger: manualcompiles toauto_run: false), which is why the workflowmanualkey is forbidden in anextendentry (see Manual launch (manualandtrigger));skipis likewise forbidden (a new stage has nothing to skip), and so isenv(env is forbidden in workflow.extend.<NAME>— per-stage env instructions are declared only for existing stages, understages). - The
titlefield, when omitted, falls back to the entry key — so a stage declared underextend: warmup:without atitleis still labeledwarmupin the output.
Extend-stage names are first-class members of the workflow's name set:
they are valid targets for stages entries and for other extend-entries'
before/after refs (cross-references between extend-stages resolve). The
new stage is always inserted; if a name collides with an existing stage, the
duplicate surfaces at run time. Dangling before/after refs —
names in neither the original pipeline body nor any extend-stage — are
structural errors raised before the embed (see
How the compiler applies a workflow — Validate references).
Positioning semantics by body format
How before / after translate into run order depends on the compiled
body format of the target pipeline:
- Stages format — the compiler derives
depends_onedges from the names. Eachaftername is added to the new stage'sdepends_on(so the new stage runs after it), and the new stage's name is added to thedepends_onof eachbeforetarget (so they run after it). Existingdepends_onon the targets is preserved — the new edge is appended, not overwritten. Execution order is then governed entirely bydepends_on, exactly as for any other stage. - Phases format — the compiler inserts the new stage positionally:
immediately after the last
aftertarget and/or immediately before the firstbeforetarget. Run order comes from list position, notdepends_on. Whenafterandbeforetargets place the stage inconsistently, theafterposition wins. Everybefore/aftertarget is guaranteed to exist by the reference validation (see How the compiler applies a workflow).
Inline agent, loop, and approve overrides
Alongside positioning, an extend entry may carry inline agent, loop, and
approve fields. They are extracted from the body exactly like
before/after — they never reach the compiled stage as separate fields — and
act as default overrides for the new stage, mirroring what a stages entry
provides for an existing stage:
agent(a string) is composed into the stage'scommandwrapper path by the same template as astages-blockagent(/home/goga/bin/<agent>-as-claude.sh).loop(an int>= 1;>= 2expands) expands the new stage into<name>-1..Nchained copies by the same rules as astages-blockloop, including the externalbefore/afterreference rewrite to the last expanded id.approve(one ofauto/plan/dialog) drives the stage's auto-approval effects, same as astages-blockapprove(see Auto-approval (approve: auto/plan/dialog)).
An inline agent/loop/approve is a default: if a stages entry also
names the same stage, the stages value wins per field — an unset stages
field falls back to the inline one. This lets extend declare a sensible
default that a stages override can selectively tighten. An inline
agent: null, loop: null, or approve: null is a structural type error, not
an absence — omit the key to express absence (symmetric with the per-stage
agent/loop/approve).
Examples
A stages-format pipeline specify → review with a new warmup stage that runs after
specify, and a new extra stage that runs before review:
extend:
warmup:
after: [specify]
title: Warmup
prompt: |
Bootstrap instruction.
extra:
before: [review]
title: Extra
prompt: |
Additional pass before review.
Compiled effect (stages format): warmup depends on specify, and review
gains extra as an additional dependency —
specify → warmup, extra → review.
The same idea for a phases-format pipeline [a, b, c] — insert x after b:
Compiled effect (phases format): the run order becomes [a, b, x, c].
A workflow can consist of extend alone — this is a valid, non-empty workflow:
Rules and anti-patterns
depends_onis forbidden inside an extend entry. Positioning is declared viabefore/after; the compiler derives the dependency edges.- At least one of
before/aftermust be present. An entry with neither is rejected withextend entry <NAME> requires at least one of before/after. beforeandaftermust each be alist[str]when present. A scalar or a list with non-string elements is rejected withnon-list-of-str before in workflow.extend.<NAME>/non-list-of-str after in workflow.extend.<NAME>.- An inline
agent(when present) must be a string; an inlineloop(when present) must be an int>= 1; an inlineapprove(when present) must be one ofauto/plan/dialog— the same type rules as thestagesblock. A non-stringagentraisesnon-str value in workflow.extend.<NAME>.agent; a non-int or< 1loopraisesnon-int value in workflow.extend.<NAME>.loop/loop must be >= 1 in workflow.extend.<NAME>; a non-stringapproveraisesnon-str value in workflow.extend.<NAME>.approve, and any other string raisesapprove must be one of: auto, plan, dialog in workflow.extend.<NAME>. Inlineagent/loop/approveare default overrides — astagesentry for the same name wins per field. - An extend entry that names a
before/aftertarget that does not exist in the pipeline (and is not another extend-stage) is a dangling reference — a structural error raised by the reference validation (unknown stage name in workflow.extend.<NAME>.before: <REF>or the.aftervariant). - Extend-stages are embedded into the compiled
FlowDocument.stagesonly. The originalPipelineDocument.bodyis never modified —extendis a run-time layering, like the rest of a workflow-file.
How the compiler applies a workflow
When a workflow is in scope, the compiler reconstructs the parsed body in
a fixed sequence of steps before building the output stages:
references are validated, extend-stages are embedded, skipped stages are
removed and their dependents reconnected, per-stage overrides are applied,
loops are expanded, external depends_on references are rewritten, agent
modes are resolved, and memory participation is computed over the finished
working body. Embedding early means a per-stage override or a loop
expansion can also target a stage introduced by extend, by name.
Step 1 — Validate references
Before anything is moved, the compiler validates every name a workflow could dangle on — existence only; cycles, self-references, and duplicate refs surface at run time:
- Every
before/afterref inworkflow.extendmust exist in the union of the original pipeline step names and the extend-stage names. A dangling ref is a structural error (unknown stage name in workflow.extend.<NAME>.before: <REF>or the.aftervariant). - Every name in
workflow.stagesmust exist in the same union. An absent name is a structural error (unknown stage name in workflow.stages: <name>). A stage that exists — even if also markedskip: true— is not flagged.
Both checks run before skip removal, so a name or ref pointing at a stage
that also carries skip: true still validates: the stage exists at
validation time and is removed later, at Step 3.
Step 2 — Embed extend-stages
For each entry in workflow.extend, the compiler appends a new stage to
the working step sequence — the verbatim entry body minus title, labeled
with the entry's title (or, falling back, the entry key). Positioning is
then applied by body format:
- Stages format — each
aftername becomes adepends_onentry on the new stage, and the new stage's name is appended to thedepends_onof eachbeforetarget (existing entries preserved; idempotent). Danglingbefore/aftertargets were already rejected at Step 1, so this step only ever sees resolvable names. - Phases format — the new stage is inserted positionally after the
last
aftertarget and/or before the firstbeforetarget, with no explicitdepends_on. Inconsistentafter/beforepositions fall back to theafterposition.
After this step the extend-stages live in the working sequence alongside the originals, so every later step applies to them by the same generic rules.
Step 3 — Remove skipped stages and reconnect dependents
Stages with skip: true are removed from the working body. Dependents'
depends_on are reconnected to the skipped stage's predecessors
(transitively for chains; positional collapse for phases). skip wins
over other overrides — removal precedes the override step. If the
reconstructed body is empty, the compiler raises empty body.
Step 4 — Apply per-stage overrides
The compiler first resolves one effective override map keyed by stage
name, shared by the override and loop-expansion steps: each extend
entry seeds a default override from its inline agent/loop/approve,
and each stages entry then overlays per-field, winning whenever its
field is not None (the inline value is the fallback). A name that
appears only in stages is used verbatim; a name that appears only in
extend carries just its inline agent/loop/approve.
For each (stage_name, effective_stage) pair in the map:
- Find the step in the body whose
nameor id equalsstage_name. - If not found — silent (only an intentionally skipped stage removed at Step 3 reaches here; unknown names already errored at Step 1).
- If found:
- When
effective_stage.agentis not None — set the stage'scommandfield to the composed wrapper path/home/goga/bin/<agent>-as-claude.sh. This applies the inline-extendagenttoo, via the effective map. - When
effective_stage.promptis not None — attach the prompt as per-stage context for the agent running the stage. The prompt has lower precedence than the stage's ownpromptfield and is treated as ambient guidance, not as a direct command. See Workflowprompt— context, not command. - When
effective_stage.skillsis not None — merge the workflow skills with the stage's existingskills(pipeline-first, deduplicated). See Skills merge. - The effective
approvedirective is threaded into the step body under an internal sentinel key (one ofauto/plan/dialog, orNone); it is read and consumed during canonical field assembly to drive the two approve effects (each on its own directive subset) and never reaches the output. See Auto-approval (approve: auto/plan/dialog). - The effective
manualinstruction is applied to the WORKING copy of the body (the parsedPipelineDocumentis never mutated):truesets the working body's trigger tomanualover any authored value (idempotent on an already-manual stage);falserewrites an effectivetrigger: manualback toon_successor raisesmanual: false on non-manual stage <NAME>when the stage is not manual; absent is a no-op. The resulting trigger is translated during canonical field assembly into the stage's launch mode. See Manual launch (manualandtrigger).
Step 5 — Expand loops
For each step, determine loop_count from the effective override's loop
for that stage name when set, else 1. The effective loop folds an
inline-extend loop together with a stages-block loop (the stages
value wins per-field when both are present).
When loop_count >= 2, the compiler appends N copies with ids
<name>-1, ..., <name>-N, each subsequent copy depending on the previous
one. The compiler records an expanded_ids map from base-name to the list
of ids produced.
Expansion interacts with body format:
- Phases format — the expanded copies chain naturally via list position. The first copy inherits the original position; subsequent copies depend on their predecessor; the next original step depends on the last expanded copy.
- Stages format —
depends_onis otherwise passed through as-is. See Step 6 for the external-reference rewrite.
Step 6 — Rewrite external depends_on (stages format only)
For each stage in stages format with a non-empty depends_on, the
compiler replaces any reference to a base name whose loop_count >= 2
with expanded_ids[ref][-1] — i.e. the last expanded id.
For example, if stage review has loop: 2 and another stage declares
depends_on: [review], the compiled output carries
depends_on: [review-2].
Step 7 — Resolve agent modes
After overrides and expansion, the compiler resolves the agent mode for
every stage the same way the no-workflow path does: a stage without an
authored non-empty roles value runs in autonomous mode, and a stage
with an authored non-empty roles value runs in coordinated mode. See
stage modes for the functional description
of each mode.
A workflow-applied command override (from a per-stage agent field) and
the stage's own agent-mode resolution are independent — the override
selects which agent binary runs the stage, while the roles field
selects how the work is organized inside it.
Step 8 — Compute memory participation
After the working body is final (skip removal, loop expansion, and the
external depends_on rewrite have all run), the compiler computes memory
participation from the workflow's effective memory configuration — the
authored memory block when present, else the materialized defaults
(method: reflect, max_rules: 25, commit: false).
- Under the reflect method a stage participates when it carries a
reflectinstruction; under the alignment method when it carriesmemory: true. Participation is looked up per base name in the working body, so everyloop-expanded copy inherits its base's verdict and a skipped stage never counts. - The memory settings apply iff at least one stage participates — a configuration without participants is a silent no-op: the compiled output carries no memory keys at all.
- How the configuration and the per-stage participation are encoded into the compiled pipeline is an internal contract of the compiler — this documentation intentionally does not pin the compiled form.
- Memory application is output-side only — the source pipeline-file is
never touched, and an authoring
reflectormemory_usekey in any stage body is a structural error. A workflow without memory participation compiles byte-identically to the same workflow compiled before the mechanism existed.
Skills merge
A stages-block skills override is merged with the pipeline-file
skills of the matched stage, not replaced:
- Pipeline-file skills come first (their relative order is preserved), then the workflow skills, with any value already seen dropped (deduplication is by value, first-occurrence order).
- A stage with no pipeline
skillsgets the workflow list as-is; a workflow override of[](or a stage with neither side carrying skills) leaves theskillskey absent rather than emitting an empty list. - An
extendentry's own bodyskillsare the new stage's pipeline-side skills — when astagesentry also names that stage, the merge combines the extend-body skills with thestagesoverride. With no matchingstagesentry the extend-body skills pass through verbatim.
Profiles
Before parsing, the whole workflow-file is rendered as a Jinja2
template (trim_blocks, lstrip_blocks, keep_trailing_newline; standard
Undefined) with the active profile's content as its context — a plain file
renders to itself, and templates without activation render with an empty
context. Rendering never bypasses validation: the rendered text passes the
standard structural validation unchanged.
The profile renders two surfaces: the whole workflow-file before parsing, and
the strings of tool contributions — every string leaf and mapping key a tool
commits through the pipeline/amend_workflow hook renders field-level with
the same profile content at the tool's commit, and the same profile reaches
the tool's hook view as a read-only fact (see Hooks).
A profile is a small YAML mapping stored in one of two places, with the project source winning on name conflicts:
| Source | Directory | Notes |
|---|---|---|
| project | <cwd>/.goga/profiles/<name>.yml |
Checked into the repository; wins on name conflict. |
| home | ~/.goga/profiles/<name>.yml |
Personal; the whole bundle rides into the container base64-encoded via the GOGA_HOME_PROFILES engine variable. |
Activation precedence: the --profile CLI flag beats the GOGA_PROFILE
environment variable, which beats the workflow's own top-level profile:
default. The default is peeked from the RAW text — a templated default
(one that materializes only through rendering) does not participate in
activation. Profile names follow the grammar
[A-Za-z0-9][A-Za-z0-9._-]* (with . and .. forbidden).
Strictness: a missing or malformed profile is a clean error naming the
profile; a malformed *.yml file in ~/.goga/profiles/ is a clean
host-side error before any docker activity; a damaged GOGA_HOME_PROFILES
payload is a clean in-container error before any events or launch.
# .goga/workflows/deploy.yml — rendered with the profile as context
{% if worker and worker.agent %}
stages:
build:
agent: {{ worker.agent }}
{% endif %}
The build command consumes the same profiles (see build).
Invocation modes
A pipeline run picks up a workflow in one of three mutually exclusive modes.
The launcher communicates the chosen mode to the container through
docker run argv flags — never through the environment.
| Mode | Invocation | Container argv | Behavior |
|---|---|---|---|
| Auto-match | goga pipeline deploy |
(neither) | If <cwd>/.goga/workflows/deploy.yml exists, it is applied silently. |
| Explicit override | goga pipeline deploy --workflow custom |
-w custom |
Apply <cwd>/.goga/workflows/custom.yml. Host validates existence first. |
| Disable | goga pipeline deploy --no-workflow |
--no-workflow |
Disable workflow application entirely. |
In auto-match mode no host-side validation runs — the workflow-file is opened and parsed inside the container, and a missing file is silently treated as "no workflow". In explicit-override mode the host validates the file exists before launch (exit 1 if missing).
--workflow and --no-workflow are mutually exclusive — passing both
exits with code 1 before launch.
The card form honors the same three modes: goga pipeline deploy --info
[-w <wf> | --no-workflow] resolves the workflow through the identical
rule set, with the same host-side validation. The decision travels as
docker run argv in both forms, and the stage list the card prints
is exactly the composition a run with the same flags executes. See
pipeline.
Log line
When a workflow will actually be applied (explicit --workflow, or an
auto-match file that exists), the in-container goga process prints a single
line before the launch output — extended with the resolved profile when one
activated:
Pipeline running with workflow "<name>"
Pipeline running with workflow "<name>" and profile "<profile>"
When no workflow applies, no workflow line is printed.
Example
A workflow that layers a Russian-language answer directive and two per-stage prompts on top of a pipeline:
prompt: |
Answer in Russian language
stages:
specify:
prompt: |
Task formalization process.
Requirements:
- When setting the task, it is necessary to develop stack technologies more carefully.
- Carefully examine all the link connections between cells
Constraints:
- Don't write code examples in the task
- Don't build architecture in the task
prototype:
prompt: |
Architectural design process.
Requirements:
- Annotations describe the high-level order of actions
- Every usage file is connected through Imports and referenced in annotations
- Usage files are self-contained
- Footer Description describes the responsibility zone
Constraints:
- Annotations must not reference previous functionality
- Annotations do not contain implementation details
- Annotations must not use "X from Imports" phrasing
- Footer Description does not contain details
A workflow that expands a review stage into two passes and pins
its agent to claude:
Compiled effect: the original review stage is replaced by
review-1 and review-2, each depending on the previous
one, both running with the claude wrapper.
A workflow that runs different stages on different CLI agents — authoring
on codex, review on claude — without touching the pipeline-file:
stages:
specify:
agent: codex
prototype:
agent: codex
architecture-review:
agent: claude
plan-review:
agent: claude
Here codex does the heavy authoring (specify, prototype) and claude
runs the reviews. The underlying pipeline-file stays unchanged — every
project can pin its own agent-per-stage matrix in its workflow-file.
A workflow that adds stages which are not in the pipeline-file at all — a
warmup that runs after specify, and an extra review that runs before
plan-review:
extend:
warmup:
after: [specify]
title: Warmup
prompt: |
Boot up tooling context before the pipeline runs.
extra:
before: [plan-review]
title: Extra review
prompt: |
An additional review pass before the plan is finalized.
Compiled effect: two stages absent from the pipeline-file now appear in the
run. In stages format warmup depends on specify, and plan-review gains
extra as an additional dependency; in phases format warmup is inserted
after specify and extra before plan-review. The pipeline-file itself is
untouched — extend layers new stages on top at run time.
See also
- Pipeline File — the base document a workflow layers on top of.
goga pipelineCLI reference — invocation flags for--workflow/--no-workflowand exit codes.