Pipeline settings

Steps, edges, loop limits, who merges, and the steps a project turns on. How the graph behaves is on the pipeline page. These are the keys.

Also in factory/: Configuration, Reviewers, models and skills, Trackers, planner and telemetry.

Steps

Each step is a mapping under steps: in a pipeline file, with a type and an on mapping. An edge is a step name, or { to: <step>, max: <n> }. End states: done, rejected, failed. How each type behaves is on the pipeline page.

KeyMeaning
typeagent, checks, review, human, merge, or verify.
onThe edges. Every outcome the step can return needs one.
enabledfalse switches the step off. Jobs pass through as if it had returned skip.
skipThe outcome a switched-off step counts as.

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 on a different outcome. When it is used up, the job goes to [run].escalate_to. A bare step name keeps the default max and changes only the target. The rules are on loop limits.

pipes:
  default:
    steps:
      review:
        on: { CHANGES: { max: 2 } }

Who merges

By default merge is off and approve leads to ready-to-merge. A hand merge continues from the merge step's MERGED edge and does not sync the base branch or run the checks again. To let the factory merge, set all three:

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. Enabling merge alone leaves it unreachable.

Optional steps

pipes:
  default:
    steps:
      spec-approval:
        enabled: true
      debug:
        enabled: true
      ready-to-verify:
        enabled: true
        who: operator
      verify:
        enabled: true
        commands: ["npm run test:smoke"]

spec-approval, debug, ready-to-verify, and verify ship off. The debugger writes a diagnosis and changes no code. With it off, failing checks go straight back to the builder. ready-to-verify waits until a person says the deploy is live.

Adding a step

pipes:
  default:
    steps:
      docs:
        type: agent
        instructions: Update docs/ for the change on this branch.
        on: { DONE: gate }
      build:
        on: { READY: docs }
KeyMeaning
instructionsWhat the agent must do. Required for a step you add.
writesThe file in the job folder. Default: <step>.md.
contextProject facts added to the prompt. Works on built-in steps too.
skillsProject skills this agent reads.
porttrue gives the agent a port for a dev server.
roleUse a built-in prompt under another name: intake, spec, build, debug, or approve.

Human steps

pipes:
  default:
    steps:
      release-approval:
        type: human
        who: maintainer
        ask: approve the release
        shows: decision.md
        on: { APPROVE: merge, CHANGES: { to: build, max: 2 }, REJECT: rejected }
KeyDefaultMeaning
whomaintainerauthor: 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.
repliesanyany: a comment from someone who allows, or mfactory answer. tool: ignore comments. Only mfactory answer counts.
askThe heading of the comment.
showsA file from the job folder to include.
pr_readyfalseMark the draft pull request ready. The comment says that merging continues the job.

The reply is /mfactory plus the outcome in lower case. See answering.

Validation

ready-to-verify sits between merge and verify. It ships off, so a merge still lands on verify. Turn it on when a person has to say the deploy is live. /mfactory verify then runs verify. /mfactory reject ends the job. who is the same key as any human step.

pipes:
  default:
    steps:
      ready-to-verify:
        enabled: true
        who: operator
      verify:
        enabled: true
        after: merge
        agent: true
        url: "https://app.example.com"
        commands: ["test \"$(curl -fsS \"$FACTORY_DEPLOY_URL/health\")\" = ok"]

A script that can see the deploy leaves ready-to-verify off and uses wait. Keys of the verify step. The factory never deploys. A job being validated holds no slot.

KeyDefaultMeaning
aftermergemerge: validate the merge commit now. deploy: first run wait until it exits 0.
wait""For deploy: a command that exits 0 once the merge commit is live. Run again every 15 seconds until timeout_minutes.
timeout_minutes20How long to wait for the deploy.
commands[]Commands in a clean checkout of the merge commit. All must exit 0. [checks] timeout_minutes limits them.
agentfalseAfter the commands pass, a verifier checks the spec, including ## Verify after deploy, and writes verify.md.
url""Where the deployed result is. Passed to the commands and the agent.
retries1How many times to run failing commands again.
on_failurecommentcomment, issue, or revert-pr. The factory never merges a revert.

Commands and wait get FACTORY_CHECKOUT (the main checkout), FACTORY_JOB, FACTORY_MERGE_SHA, FACTORY_PR, and FACTORY_DEPLOY_URL. The working directory is a clean checkout of the merge commit. A job file that the worktree does not contain is test -s "$FACTORY_CHECKOUT/.factory/jobs/$FACTORY_JOB/spec.md".

When verify is on, spec.md must include ## Verify after deploy. VERIFY: PASS ends at done. VERIFY: FAIL ends as failed after retries. VERIFY: BLOCKED means the environment could not be reached: the job returns to ready-to-verify. The fourth BLOCKED in a row goes to escalated. It does not comment as a failure, open an issue, or open a revert pull request. If ready-to-verify is off, BLOCKED fails the job through on_failure. A project that replaces steps.verify.on must keep a BLOCKED edge. The default is { to: ready-to-verify, max: 3 }.

Fixing after the merge

The built-in debug step sends a job back to build on its branch, which is gone after the merge. A post-debug step handles problems found after the merge, such as a failed smoke test or slower CI, and keeps the fix in the same job. This recipe asks a maintainer after each merge, who answers /mfactory close, /mfactory test or /mfactory debug <what you saw>:

[project]
issue_link = "refs"
pipes:
  default:
    steps:
      merge:
        on: { MERGED: after-merge, FAILED: escalated }
      after-merge:
        type: human
        who: maintainer
        ask: "merged: close the job, run the post-merge tests, or debug"
        on: { CLOSE: done, TEST: verify, DEBUG: post-debug }
      verify:
        enabled: true
        after: merge
        commands: [pytest -q]
        on: { PASS: after-merge, FAIL: post-debug, BLOCKED: { to: after-merge, max: 3 } }
      post-debug:
        type: agent
        on: { FOUND: { to: build, max: 2 }, UNKNOWN: after-merge }

post-debug is a built-in role with outcomes FOUND and UNKNOWN. A step with another name sets role = "post-debug". The agent gets the merged pull request, its merge commit and a detached checkout of the current base branch. It reads CI and the merged diff and writes round-N/post-debug.md. It changes no code: done refuses its file if the checkout changed.

Any entry to build after the job's pull request merged starts a follow-up. That includes FOUND, and FEEDBACK from escalated. The merged pull request moves to prs in job.json, and the job builds on a new branch <branch_prefix><job>-fix-N from the base, in a new round. The builder opens a new pull request that starts with Refs #<issue>, and the fix goes through the gate, review, approval and merge again. The dashboard lists every pull request of the job. The max on FOUND limits follow-ups. With issue_link = "closes" the issue is closed by then, so FOUND is refused until someone reopens it. Unlike on_failure = "issue", which opens a new job, a follow-up keeps one issue and one history.