Pipeline
A graph of steps. Each step has a type and an edge for every outcome. The script follows the edges. No prompt does.
Every key is in the configuration reference. This page is how the graph behaves.
Pipelines are YAML files
The pipelines, the pipes, live in factory/pipes/, next to factory/factory.toml, at the root of the repository. mfactory install writes factory/pipes/default.yaml: the default pipeline, spelled out. Each file declares one or more pipelines. One may extends another and change only what differs. The JSON Schema in .factory/schema/pipe.schema.json says what a file may contain; an editor with a YAML language server completes and checks it, and the factory checks every file against it, then checks each graph, before anything runs.
# factory/pipes/hotfix.yaml
pipes:
hotfix:
description: Small fixes, straight from intake to build
extends: default
steps:
spec: { enabled: false, skip: DONE }
approve: { enabled: false, skip: APPROVE }
A job keeps the pipeline it starts with: /mfactory run 12 --pipe hotfix. Without the flag it runs [run].pipe from factory/factory.toml, or the only pipeline. With several and none named, /mfactory run asks which. mfactory pipes list, mfactory pipes validate, and mfactory graph --pipe NAME show them. [steps.*] left in factory.toml still override default; mfactory migrate pipes moves them to YAML. A factory.toml at the repository root still works; mfactory migrate layout moves it into factory/. The examples below show only the keys that change: edit them in place in factory/pipes/default.yaml.
The default graph
intake agent ACCEPT -> spec | NEEDS-INFO -> ask-author (max 2) | REJECT -> rejected
ask-author human ANSWER -> intake | REJECT -> rejected
spec agent DONE -> spec-approval
spec-approval human off, continues as APPROVE -> build
build agent READY -> gate | BLOCKED -> escalated
gate checks PASS -> review | FAIL -> debug (max 2)
debug agent off, continues as FOUND -> build
review review PASS -> approve | CHANGES -> build (max 2)
approve agent APPROVE -> ready-to-merge | ESCALATE -> escalated
ready-to-merge human FEEDBACK -> build (max 3) | REJECT -> rejected
merge merge off, continues as MERGED -> ready-to-verify
ready-to-verify human off, continues as VERIFY -> verify
verify verify off, continues as PASS -> done
escalated human FEEDBACK -> build | REJECT -> rejected
End states are done, rejected, and failed. A switched-off step is passed through as if it had returned its skip outcome. Several in a row are passed through at once.
Steps and edges
pipes:
default:
steps:
gate:
type: checks
on: { PASS: review, FAIL: { to: debug, max: 2 } }
An edge is a step name, or { to: <step>, max: <n> }.
agenttypeOne agent does the step and writes one file. Its first line is the outcome. Built-in steps have fixed outcomes. A step you add uses the names in on.
checkstypeThe script runs [checks].commands. Outcomes: PASS, FAIL.
reviewtypeEvery reviewer the job needs runs in parallel. PASS if all pass, otherwise CHANGES.
humantypeThe script asks a person and parks the job. Outcomes are whatever you name in on.
mergetypeWhen the step is on, the script merges the base branch in, runs the checks, and merges the pull request. It ships off. Outcomes: MERGED, FAILED.
verifytypeThe script, and optionally an agent, check the merged change. Outcomes: PASS, FAIL, BLOCKED. BLOCKED means the environment could not be reached.
The built-in agent steps:
| Step | Writes | Outcomes |
|---|---|---|
| intake | intake.md: worth building, scope, risk, surfaces | ACCEPT, NEEDS-INFO, REJECT |
| spec | spec.md: what to build and how to tell it works | DONE |
| build | Code on the job's branch, a draft pull request, build.md | READY, BLOCKED |
| debug | round-N/debug-K.md: why the checks fail | FOUND, UNKNOWN |
| approve | decision.md: ready, or ask a maintainer | APPROVE, ESCALATE |
mfactory doctor and every other command refuse a pipeline in which an edge points at a missing step, an outcome has no edge, a step cannot be reached from the start, or a loop has no max and no human step in it.
Loop limits
A max on an edge is how many times in a row a step may send a job that way. The count starts again when the step returns a different outcome.
pipes:
default:
steps:
review:
on: { CHANGES: { max: 2 } }
Those defaults: intake may ask the author twice, the gate may fail twice, review may ask for changes twice, and spec approval may ask for changes three times. When a limit is used up, the job goes to [run].escalate_to (default escalated) and the reason names the edge:
[steps.gate].on.FAIL max = 2 reached
A maintainer's reply on an escalated job clears every count.
Writing an edge as a bare step name changes only its target and keeps the default max. Without that, renaming a target would silently remove a loop limit.
pipes:
default:
steps:
review:
on: { CHANGES: rework } # still max = 2
# on = { CHANGES = { to = "rework", max = 5 } } # to change both
Who merges
By default the factory does not merge. approve leads to ready-to-merge, which marks the pull request ready, labels the issue, and waits without holding a slot. The merge step stays off. Its MERGED edge still says what happens after a person merges.
That wait does not sync the base branch or run the checks again. Branch protection is the gate before the person merges.
To let the factory merge, all three keys are required. Enabling merge alone leaves it unreachable. Leaving ready-to-merge on after retargeting approve does the same.
pipes:
default:
steps:
approve:
on: { APPROVE: merge }
ready-to-merge:
enabled: false
skip: REJECT
merge:
enabled: true
Do that only when a merge to the base branch does not publish a release. The script then syncs the base branch, runs the checks again, and merges. [project] merge_method is squash, merge, or rebase.
Optional steps
spec-approval, debug, ready-to-verify, and verify ship with enabled = false. The merge step does too. Turning that one on is the block above, not a single key.
pipes:
default:
steps:
spec-approval: # a maintainer approves spec.md before anything is built
enabled: true
debug: # after failing checks, a debugger finds the cause
enabled: true
ready-to-verify: # wait until a person says the deploy is live
enabled: true
who: operator
verify: # check the change after it is merged or deployed
enabled: true
commands: ["npm run test:smoke"]
The debugger changes no code. It writes what fails and why, and the next builder reads it. With the debugger off, failing checks send the job straight back to the builder.
Adding a step
Add a block and point one edge at it.
pipes:
default:
steps:
docs:
type: agent
instructions: Update docs/ for the change on this branch.
on: { DONE: gate }
build:
on: { READY: docs }
mfactory sync writes a mfactory-docs agent. It works in the job's worktree, commits to the job's branch, and writes docs.md, whose first line is STATUS: DONE. The outcomes are the names you give in on.
instructions is required for a step you add. writes defaults to <step>.md. context adds project facts to the prompt. skills names project skills. port = true gives the agent a port for a dev server. role reuses a built-in prompt: intake, spec, build, debug, or approve.
Human steps
A human step posts a comment (on the pull request if there is one, otherwise the issue), labels the issue, and parks the job. It holds no slot while it waits.
| Key | Default | Meaning |
|---|---|---|
| who | maintainer | author: the issue's author (the operator may also reply). maintainer: anyone with write access. operator: the signed-in user running the factory. A list of logins: only those accounts. |
| replies | any | any: a comment from someone who allows, or mfactory answer. tool: ignore comments. Only mfactory answer counts. |
| ask | The heading of the comment. | |
| shows | A file from the job folder to include, such as spec.md. | |
| pr_ready | false | Mark the draft pull request ready. The comment then says that merging continues the job. |
Comments from anyone else are ignored. With replies = "tool", every comment is ignored. On a step with an ANSWER outcome, such as ask-author, any comment from the author counts as the answer. Words given with a reply are saved as feedback-<k>.md. REJECT ends the job as rejected and needs a reason. mfactory answer is the person running the factory. who does not filter it.
Validation after merge
Turn verify on to check the change again after it is merged, or after a deploy your own script waits for. Turn ready-to-verify on when a person has to say the deploy is live first: /mfactory verify runs the check, and VERIFY: BLOCKED waits there again. The factory never deploys. A job being validated holds no slot.
pipes:
default:
steps:
verify:
enabled: true
after: deploy
wait: scripts/wait-for-deploy.sh
commands: ["npm run test:smoke"]
agent: true
url: "https://staging.example.com"
on_failure: revert-pr
after = "merge" validates the merge commit straight away. after = "deploy" runs wait until it exits 0, again every 15 seconds, until timeout_minutes (default 20). Commands run in a clean checkout of the merge commit. They receive FACTORY_CHECKOUT (the main checkout), FACTORY_JOB, FACTORY_MERGE_SHA, FACTORY_PR, and FACTORY_DEPLOY_URL.
When validation fails the job ends as failed. on_failure is comment (comment on the pull request), issue (also open a new factory issue), or revert-pr (also open a draft pull request that reverts the merge). The factory never merges that revert.