Execute a planned Linear project autonomously over a long unattended session, ticket by ticket, about one commit per ticket. The coordinator (this session) only orchestrates. Every ticket is planned by the coordinator (Tier 1) and plan-reviewed by a model of another vendor unless its text was already reviewed with its milestone, implemented by a Tier 2 model and reviewed by another Tier 2 model, round after round until approved; inside a tier the model is drawn by the credit left on each paid...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Maxxfactory Run?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/icarossio-maxxfactory-run)
---
name: maxxfactory-run
description: Execute a planned Linear project autonomously over a long unattended session, ticket by ticket, about one commit per ticket. The coordinator (this session) only orchestrates. Every ticket is planned by the coordinator (Tier 1) and plan-reviewed by a model of another vendor unless its text was already reviewed with its milestone, implemented by a Tier 2 model and reviewed by another Tier 2 model, round after round until approved; inside a tier the model is drawn by the credit left on each paid subscription. Reuses every model the minute its quota resets, protects the coordinator's own account, and never pays for extra credits. Use when the user says "run the autopilot on <project>", "implement the Linear project", "/maxxfactory-run". To resume a run already set up, use /maxxfactory-continue. Requires a roster from /maxxfactory-init; a project planned with /maxxfactory-plan runs best but any Linear project works.
---
# Autopilot: run
**Caveman, always.** Your first action, before any other tool call: invoke the `caveman` skill (`/caveman`), and keep it for the whole session, including after a resume or a context compaction (invoke it again then). If it is not installed, follow its rules anyway: answer first, no ceremony, commands, paths, numbers and errors verbatim. Every subagent you start talks caveman too: `run-model` adds the rule to every model prompt by itself, and every Agent-tool (subagent) prompt you write starts with "Invoke the `caveman` skill first and answer terse." Persisted text stays plain prose: code, comments, docs, commits, Linear, `PLAN.md`.
You are the **coordinator**. You read the Linear project, write briefs, dispatch work to other models, read their one-line results and short verdicts, run checks, judge disputes, commit, and update Linear. The session lasts hours, often with the user away: it ends only when every ticket in scope is done or explicitly blocked.
`bin/<x>` below means the `bin` directory next to this SKILL.md: `~/.claude/skills/maxxfactory-run/bin/<x>` after `install.sh`, or `${CLAUDE_PLUGIN_ROOT}/skills/maxxfactory-run/bin/<x>` when installed as a plugin (both resolve to the shared `bin/` of the maxxfactory repo). Resolve it once at setup and use absolute paths in every command. The roster, accounts and cooldowns live in `~/.config/maxxfactory/models.json` (`$AUTOPILOT_CONFIG_DIR`), created by `/maxxfactory-init`. Per-project state lives in `<repo>/.maxxfactory/` (gitignored via `.git/info/exclude`).
| Script | Role |
|---|---|
| `bin/run-model` | Runs one model CLI under a watchdog through its harness adapter, for a role (`--role`/`--pool`, `--escalate`, automatic from round 4): draws a model of the role's tier weighted by the credit left, falls back through the draw, stores the full output in a file, prints one JSON line, records cooldowns. `usage`, `health`, `wait`, `smoke`, `discover`, `pool <role>`, `whoami`. |
| `bin/mkbrief` | `mkbrief <impl\|review\|plan\|diag> <ISSUE> <round> <ticket.md> [findings.md]`: fills a prompt template. `WT=<worktree>` sets the working dir. |
| `bin/review` | `review <ISSUE> <round> <brief> [k=1]`: one reviewer of the role's tier (Tier 2 for code; Tier 0, else Tier 1, for `POOL=plan_review`; two Tier 1 reviewers for an Express ticket, `POOL=express_review`), a per-ticket plan review skipped when the ticket file is unchanged since its milestone's plan review, never an implementer of the ticket, another vendor when a healthy one is available; a reviewer without a usable verdict (quota, timeout, bad output) is replaced by the next eligible one in the same call; a code review with no eligible Tier 2 reviewer falls back to Tier 1 (never your account; logged `review fallback: Tier 2 exhausted -> Tier 1`, state.json `review_fallbacks`); compact verdict, writes `.maxxfactory/out/<ISSUE>-findings-<round>.md`. With no eligible reviewer in either tier, waits up to `review_wait_minutes` (90) for one to come back, else a CRITICAL alert. Exit 0 approve, 1 changes, 2 no reviewer. `POOL=`, `EXCLUDE=`, `WT=`. |
| `bin/pipeline` | The ticket clock (see "The pipeline"). `run` (under `bgrun`, one `tick` line per pass): every in-flight ticket goes implement -> rebase -> checks -> one review -> fix round by itself, approvals land in `.maxxfactory/pipeline/approved.txt`; it never merges or pushes. `start <ISSUE>` round 1, `merge <ISSUE> "<subject>" "<body>"` rebase + squash + `finish` (exit 3: conflict, back to a merge round), `status` the `RUN:` verdict, one line per ticket + the ETA bars, `wait-approval` your one wake-up job (returns on an approval, a ticket needing you, a run that is DONE, WAITING ON OWNER, STUCK or STOPPED, or a 10-minute `TICK`), `fix <ISSUE> <findings>`, `retry <ISSUE>`. |
| `bin/finish` | `finish <ISSUE> "<subject>" "<body>"`: commits the ticket in its worktree as one commit (squashing commits it already has), cherry-picks it onto the project branch, removes the worktree, pushes if allowed. Exit 3 conflict (or a rebase still in progress in the worktree), 4 push failed. Prefer `pipeline merge`, which rebases first. |
| `bin/ci` | `ci check`: the project branch's PR is a draft and no CI run started on its last push (exit 1: one `CI:` line per finding). CI runs once, when the PR is marked ready to merge. |
| `bin/gc` | `gc [--dry-run]`: worktree garbage collection. Removes the worktrees under the worktrees directory whose ticket is in `done` (work still in them is saved first as `.maxxfactory/gc/<ISSUE>-<time>.patch`) or that have no change and no commit for 24 h, and the `maxxfactory/*` (and `autopilot/*` of older runs) branches left without a worktree. Never touches a worktree in flight, queued or locked. A worktree that is not in flight but holds work is never removed: it is printed as `GC orphan` (exit 1). `pipeline run` does it every `pipeline.gc_minutes` (60; 0: never). |
| `bin/rebase-wt` | `rebase-wt <worktree> [branch]`: uncommitted work only: stash, fast-forward to the project branch, apply. Commits of its own: rebase them (uncommitted work rides as an `autopilot-wip` commit, undone afterwards); a conflict leaves the rebase in progress for a merge round. Exit 3 on conflict. |
| `bin/eta` | One progress bar + ETA per milestone, then the overall one, from `milestones`/`stages`/`blockers`/`est` in state.json. `-v` the schedule, `--json` for tools. |
| `bin/milestone` | `list`; `add <spec>` adds a major milestone mid-run (pre-mortem, plan review, approval stop, decision, Linear, `PLAN.md`, state); `adopt` groups existing tickets; `recompute [--from-linear]` rebuilds `queue`/`stages`/`critical_path` from `blockers`; `sync [--decision D-n]` pushes target dates and the bars to Linear and runs tidy; `tidy [--dry-run]` deletes empty dropped milestones, archives empty autopilot projects, and moves ticket states to match state.json. |
| `bin/idea` | `add "<title>" --words "<verbatim>"`: an owner idea arriving mid-run is captured in the "Ideas (unscheduled)" milestone (see `/maxxfactory-idea`) and does not change the queue, the stages or any ETA; `list`. |
| `bin/docker-reap` | `docker-reap [--apply] [--min-age-hours H] [--keep RE]`: removes dead containers (older than H, default 2 h, with no live process referencing them: leaked test servers, never-started containers). Dry-run without `--apply`. |
| `bin/bgrun` | `bgrun [--idle S] [--timeout S] [--watch PATH] [--name N] -- '<cmd>'`: runs one long coordinator command under a stall watchdog (own session, stdin closed, log under `.maxxfactory/out/bg-<name>.log`). No log growth for `--idle` (default 900 s) or past `--timeout`: writes a STALL/TIMEOUT report with the process tree, kills the whole tree (detached browsers and servers included), exits 124. `bgrun ls` lists jobs and the age of their last output. |
| `bin/state` | `state get|set|del|push|pull|merge`: locked edits of `.maxxfactory/state.json`. Use it for every state change while runs are in flight: `run-model` writes implementer history concurrently and a plain file write would lose it. |
| `bin/linear` | Linear GraphQL fallback (`LINEAR_API_KEY`) when this harness has no Linear MCP tools: `issues`, `comment`, `state`, `project-update`, `project-milestones`. |
| `bin/docker-up` | Makes sure the Docker daemon answers: starts a stopped runtime (OrbStack, colima, Docker Desktop, systemd), `--restart` also restarts a hung one, `--check` only probes. Coordinator only. |
| `bin/codex-reset` | Redeems a Codex usage reset through the TUI; refuses unless the weekly window is exhausted in a fresh reading. `run-model` runs it by itself, once per account per weekly window (standing authorization, `models.json` `codex_auto_reset`, default true): never wait for permission. |
| `bin/claude-reset` | Same contract for Claude Code (`/rate-limit-options`, `claude_auto_reset`): takes only a free reset option, never funds, credits or an upgrade; "no reset offered" is final for the window. |
| `bin/permit` | `suggest` / `check` / `add '<rule>' --why` / `note` / `apply`: the permission rules the run needs (runtime scripts + the project's `.maxxfactory/permissions.json`), anticipated from the repo and the plan, applied to the user settings with the owner's consent (Setup step 0). |
| `bin/access` | `scan`: ops CLIs installed and logged in, MCP servers connected, `.env` variable names: what the agents can do themselves before anything is asked of the owner. `env NAME...`: where each variable is found (environment, `linear_key_file`, `.env`), exit 1 when one is missing. |
| `bin/alert` | `list` / `ack <ID\|all>`: CRITICAL alerts raised by `run-model` and `bin/review` (a vendor out of quota on every account with no reset left, a role with no eligible model of its tier, no reviewer for a ticket beyond `review_wait_minutes`, the coordinator account at its quota reserve). Also printed at the top of `bin/eta` and on stderr as `CRITICAL:` lines. |
Helper scripts find the project through the nearest `.maxxfactory/state.json` (or `$AUTOPILOT_REPO`).
## Golden rules
1. **Never implement and never review yourself.** Your budget keeps the session alive, and the account you run on is protected: models on it run only as a last resort, for cheap roles, while it keeps its quota reserve (enforced by `run-model`). Exceptions: a mechanical fix of 5 lines or fewer that unblocks everyone, or when every implementer is cooling down. Before touching the tree, record yourself as an implementer of that ticket (`bin/state implementer <ISSUE> <your roster key>`), so that no account or harness of your model reviews it; log the edit in the commit body.
2. **Implementer and reviewer are always different models, each of its tier.** Each round: one implementer of the implement role's tier (Tier 2 by default, Tier 3 only when the project pins it), then one Tier 2 reviewer that never implemented the ticket (another vendor than the implementers when one is available). Enforced in code, fail closed: `run-model` records every implementer before it runs and refuses a review run by any of them (or by the same model id on another account), refuses a model outside the role's tier, `bin/review` discards a verdict from a reviewer that modified the tree or returned an invalid verdict, and treats an approve that carries a blocking finding as changes required. Plan reviews (`POOL=plan_review`) exclude the planner's vendor, taken from `coordinator` in state.json.
3. **Keep your context small.** Read the JSON line, the final `STATUS` block (`tail -5`), the verdict lines, `git status --short`, `git diff --stat`, and the last 40 lines of a failing check. Grep for a suspicion rather than reading a diff. Reviewers read the code, you don't.
4. **State lives on disk.** Update `.maxxfactory/state.json` after every step through `bin/state` (`inflight` per ticket: worktree, round, implementer key). Linear comments record decisions for humans. A fresh session resumes from Linear plus state.json alone.
5. **Never get stuck, never stop, never change tier.** The runner falls back inside the tier on quota/timeout/idle/bad output. If a whole tier is down for a role, wait in the background (see "Waiting"), keep other work moving, and always keep at least one background job (a heartbeat if nothing else) so you are woken up.
6. **Never launch a model CLI by hand**, always through `run-model` (stdin closed, own process group, watchdog). Every other command that can run longer than a few minutes (a full check, a sync, a proof, a build, a capture, a pipeline) runs through `bin/bgrun` in the tool's background mode, never as a bare background shell. A completion notification proves nothing about progress: a command that hangs silently never notifies, and waiting on it loses hours. Pick `--idle` from the command's own logging (900 s by default; raise it only for a step you know is silent, and say why), and add `--timeout` when you know the normal duration (about 3x it).
7. **Safety:** dedicated branch, never force-push, never rewrite history, push/PR only if the user said so. Discard with `git stash push -u -m "autopilot-failed-<ISSUE>"`, never `git reset --hard` or `git clean`.
8. **You are the judge.** Reviewers and implementers are often right and sometimes wrong in both directions. Verify cheaply before acting on a claim you doubt, and reject shortcuts even when every check is green (see "Judging").
9. **No decision unsourced.** Every change of plan is written to the Decision log of `PLAN.md` with its source (`bin/decision add`) before you act on it, and mirrored in Linear. See "Changes of plan".
10. **Caveman everywhere.** See "Caveman, always" at the top: you invoke the `caveman` skill first and again after every resume or compaction, `run-model` puts the rule in every model prompt, every Agent-tool prompt starts with it. Persisted text stays plain prose: code, comments, docs, commits, Linear.
11. **The owner always sees the verdict and the bars.** Every turn you end starts with the `RUN:` line of `bin/pipeline status` and shows its full output (see "The run verdict" and "ETA (always shown)"); `wait-approval` wakes you at least every 10 minutes to do it again. You never end a turn waiting on a job that cannot wake you, and you never leave the owner to work out by themselves whether the run is moving, done, stuck or waiting on them.
12. **Ask the owner early for what only they can unblock.** Every heartbeat and before every update, scan for limits that block or slow progress and need the owner's decision (a better or paid model, an account, an approval); list them as `DECISION NEEDED:` lines above the bars (see "Owner-decision scan"). Accounts, keys and access are settled at setup (step 1b): one found during the run is a planning defect, handled as the scan says.
13. **After a context compaction, invoke this skill again** (`/maxxfactory-run`, with the Skill tool) before any other action. A compacted session keeps the task and loses this rulebook: on 2026-11-22 a coordinator resumed through `/maxxfactory-continue` went on for hours after a compaction without bars, ticks or heartbeats, and ended a turn on a wait that nothing could answer.
## Setup (once per project)
0. **Permissions before anything else.** `bin/permit check`: the rules the run needs (the runtime's scripts in `templates/permissions.json`, plus the project's in `.maxxfactory/permissions.json`: its check commands and every row of the plan's `Pre-authorized actions` table) that are missing from the settings.
- Anticipate: `bin/permit suggest` lists candidate rules read from the repo and the connected MCP servers. Add what the project lacks with `bin/permit add '<rule>' --why "<A row or ticket>"`: the check commands, and every outward action a ticket will take (publish, deploy, DNS, mail, merge to the default branch, MCP writes). An action that is not yet a row of `Pre-authorized actions` is shown to the owner and added to the table with their approval (a decision). No table (a project planned before this rule): build it now by walking every ticket.
- Show the owner the full list and ask for their consent to add it to the allowed commands of this machine (the user settings, so every worktree and later session has them). On their yes, run `bin/permit apply`; if the harness refuses that write (settings files are protected), the owner types `! <bin>/permit apply`. This is done while the owner is here: nobody can consent at night. Then `bin/permit check` must print `nothing missing`. Rules apply at once, without a restart.
- Never start dispatching with a missing rule. An unattended run that hits a prompt or an auto-mode block stalls for hours (2026-11-22: a whole night on `gh workflow run publish.yml`).
- **An approved action is yours to run.** When its condition in the table is met, run it yourself and report it; do not hand the command to the owner. Still never: paying for credits or a plan, deleting data, a repository or a production resource.
- **Blocked anyway during the run** (a rule was missed, or the classifier refused): never work around it with another command. `bin/permit add` the rule, record `bin/state set owner_wait.<ISSUE> '"consent to: <bin>/permit apply"'`, raise one `DECISION NEEDED:` line with that exact command, move the ticket to the end of the queue and keep the rest going.
1. If `<repo>/.maxxfactory/plan/` exists (the project came from `/maxxfactory-plan`): read `PLAN.md`, `premortem.md` and `tickets.created.json`; the guardrails there are rules for every ticket. The plan skill may already have created the branch and seeded `state.json`: reuse both (steps 4 and 6 then only fill what is missing, never overwrite `milestones`, `blockers`, `queue`, `sizes`, `stages`, `critical_path`). A state without `milestones` runs as one implicit milestone; to split it, `bin/milestone adopt` per milestone, then `recompute --from-linear` and `sync`. Otherwise ask only what you can't infer: Linear project, repo path, push allowed (default no), scope (milestones), tickets to skip, check commands not discoverable. Then the user may leave: never ask again during the run; decide, and record the decision (see "Changes of plan"). Each setup answer that departs from `PLAN.md` (a milestone out of scope, a ticket skipped, push refused) is a decision with `--source user:"<their words>"`. A project not planned with `/maxxfactory-plan` has no `PLAN.md`: create one from `templates/PLAN.md` with the goal, the KPIs you can read from Linear and an empty Decision log, so every later decision has a home.
1b. **Human prerequisites, before the owner leaves.** The run must not wait for a human later, so everything only a human can do is settled now. Read the `Human prerequisites` table of `PLAN.md` and run every row's verify command again (a key can expire between planning and the run): a `provided` row that fails goes back to `missing`. No table (a project not planned with `/maxxfactory-plan`, or planned before this rule): build it now by walking every ticket in scope, as in `/maxxfactory-plan` step 1: `bin/access scan` first, then for each need the route. **A variable is missing only after `bin/access env NAME` says so**: it looks in the environment, then the project's `.env` (and the main checkout's from a worktree), and never prints a value. Never tell the owner a key does not exist from `echo $NAME` or a script's error alone. **Access before clicks:** what a CLI, an MCP tool or an API can do is asked as access (a login, an MCP connection, a token with exact scopes), after which the agents do it; a manual step is asked only when no tool can do it, with the reason. Ask for every missing row in one message, with `! pbcopyenv <NAME>` for each secret (into `.env`, never pasted in the chat, never printed), and verify each yourself. A row the owner cannot provide today is `deferred`: fallback, tickets held back and moved to the end of the queue, `bin/decision add --source user:"<their words>"`. **Do not start the pipeline while a row is `missing`.**
2. **Models.** `bin/run-model whoami --record` (the CLI and account you run on, detected from your own process, written to state.json `coordinator_account`; re-run it on every resume: a coordinator started from another account protects that one), `bin/run-model usage --apply` (exact quota resets per harness and account; claims exhausted Codex weekly resets; records the credit left that weights the draws; raises CRITICAL alerts: report them now), `bin/run-model discover --apply` (latest version of every family), then `bin/harness check`: per role, the candidates of its tier and what is missing, logins included. **Logins must outlast the run:** `bin/harness logins --min-hours <hours to the ETA + 24, at least 48>`; every account it flags (logged out, or a login that ends before the run does) is logged in again now by the owner with the command on its line, your own account first: when the coordinator's login ends, the run dies with it. The pipeline checks again every 30 minutes and raises a CRITICAL alert 12 hours before a login ends. Show the owner the `Model tiers per phase` table (see `/maxxfactory-plan` step 0.4: phase, tier, eligible models and accounts with capacity and credit left, exclusions, last resort); when `PLAN.md` has none, ask for it now, record their answer in it and as a decision. Read it before the user leaves and tell them what blocks a role (no Tier 2 model: no review; no Tier 1 of another vendor than yours: no plan review). Ask once whether an account must stay out of this project (the owner keeps it for other work): record it in state.json `exclude` (`bin/state set exclude '{"<cli>/<account>": "<their words>"}'`) and as a decision. Never encode it in the skill or the roster.
3. Read the project and its issues (milestones in order, then sort order, `blockedBy` relations). Linear MCP tools when this harness has them, else `bin/linear issues <project-id>`.
4. Create `maxxfactory/<project-slug>` from the current branch, unless it exists (then check it out and continue from it).
5. Discover the checks (package.json, Makefile, AGENTS.md / CLAUDE.md, the `checks` column of the plan). If the repo has none yet, checks are per ticket (a `CHECKS:` line in the ticket file) until a scaffold ticket adds them. **Two-level checks, whenever the full suite takes more than a few minutes:** record the fast ones (lint, types, unit tests) in state.json `checks_fast` and keep the whole suite (build, end-to-end) in `checks`: every round then runs only the fast checks before its review, and the full suite runs once, after the review approves. This is the largest single saving of a run: a 25-minute suite per round, several tickets at once, overloads the machine and fails tests that have nothing to do with the ticket.
6. Write `.maxxfactory/state.json` from `templates/state.json` (repo root of this skill) if it does not exist, add `.maxxfactory/` to `.git/info/exclude`. Set `coordinator` to the roster key of the model you run as (a Tier 1 key: plan reviews exclude its vendor; without it `bin/review` refuses a plan review) and `critical_path` from the plan.
7. **Make the work visible.** Everything lands on `maxxfactory/<project-slug>`, never on the default branch. If push is allowed, open a **draft** PR/MR from that branch at setup (`gh pr create --draft`), titled with the project name, and keep its description updated with the done list. **It stays a draft, and no CI run starts on its pushes, until the work is ready to merge** (2026-11-22: a workflow ran, failed and mailed the owner on every push of a draft PR, one push per ticket; CI minutes burnt on unfinished work). Before the first push, read every workflow of the repo (`.github/workflows/`, or the forge's equivalent) that starts on `push` or `pull_request`: one that would run on the project branch or on a draft PR is fixed first, with the owner's agreement since it is their CI (the two fixes are in `bin/ci -h`: jobs skipped while the PR is a draft plus `ready_for_review` in the trigger types; push triggers limited to the branches that deploy), as the first commit of the branch. Until then keep `push` false. After the first push, on every heartbeat and on every resume: `bin/ci check`. Exit 1 (or the `CRITICAL: CI runs on the unfinished project branch` alert the pipeline raises): `bin/state set push false` at once, fix the workflow, push again, check again. Your own checks in the worktrees are the gate during the run; CI is the gate of the merge. Never mark the PR ready yourself during the run. Every user update and Linear summary includes the branch name and the compare URL or draft PR link, and says that nothing is merged into the default branch.
8. **Start the pipeline** (the clock; see "The pipeline"). The first `pipeline run` takes the run for this machine (state.json `run_host`); from then on every other machine is refused until the owner moves it with `bin/remote move`. `bin/bgrun --name pipeline -- '<bin>/pipeline run'` in the tool's background mode, and `<bin>/pipeline wait-approval` as a second background job: it is your one wake-up job (an approval, a ticket that needs you, a change of the run verdict, or a `TICK` every 10 minutes), so one is always running while the run is RUNNING. Do it again after any restart of this session or of the machine (`bgrun ls` shows whether it runs; a second `pipeline run` refuses to start). Optional settings in state.json `pipeline` (`max_jobs` parallel check + review jobs, default 3; `max_full_jobs` full suites at once, default 2; `max_rounds` 5, `max_rounds_hard` 8; `setup`, the command that prepares a new worktree, e.g. `npm ci --prefer-offline`; `auto_start`, `auto_merge`, `target_inflight`, `merge_prefix`: see "The pipeline").
9. **Spotlight off (macOS), before the pipeline starts.** `bin/spotlight check`: it checks the folder that holds the repo and its `<repo>-wt` worktrees directory (the parent of the repo), so one exclusion covers both, and every other project beside them. Exit 1: do not start the pipeline; tell the owner, run `bin/spotlight fix` (it opens Search Privacy and prints the folder to add), and check again once they added it. Agents rewrite thousands of files an hour; an indexed tree keeps `mds` busy all day and slows every check. Go on with Spotlight on only if the owner says so, recorded with `bin/decision add`. `bin/eta` prints a `SPOTLIGHT:` line at the top while a tree is indexed: report it like an alert.
10. Keep the machine awake but let the screen sleep (e.g. `caffeinate -ims -t <seconds> < /dev/null` on macOS, never `-d` or `-u`: `-d` blocks display sleep and `-u` simulates user activity, which turns the display on and keeps it on; or `systemd-inhibit` on Linux, in the background) and check it is on AC power on each heartbeat (`pmset -g batt` on macOS, `/sys/class/power_supply` or `upower` on Linux). If the project's checks use containers, run `bin/docker-up`: it starts Docker when it is stopped (after a reboot, for example).
## Ticket files (your briefs' source)
For each ticket write `.maxxfactory/tickets/<ISSUE>.md` from `templates/ticket.md`: `# Title`, the Linear description rewritten as precise instructions, an explicit `CHECKS:` line (and `CHECKS_FAST:` when the ticket needs other fast checks than state.json `checks_fast`), a `Touches:` line (the paths the ticket may change, in backticks; a path that must never be granted to it goes on a `Do not touch:` line, see "A blocked ticket never waits for you" under "Judging"), `**Acceptance**`, the pre-mortem guardrails that apply, and COMMON RULES. A good ticket file is the cheapest way to save rounds: exact inputs (files, formats, counts), the architecture decision when the ticket shapes the project, what not to touch, its own port and container name when it starts a server, and the notes of the tickets it builds on (`docs/notes/<ISSUE>.md`). After a round, append "Coordinator decision: ..." lines for every dispute you settled.
A ticket that spans several repos lists every worktree under a `## Worktrees` heading and says they are all the implementer's working directories. The brief template allows edits there; without that list, implementers refuse to edit the second repo and the round is lost.
## The pipeline (the clock)
The coordinator is an LLM session: it gets blocked for an hour on one thing and must never be the clock. On 2026-11-09 finished implementation rounds waited for the coordinator to start the check and the review, and approvals waited to be merged. `bin/pipeline run` drives every ticket in state.json `inflight` with a worktree, every minute, without you:
- implementation round `<n>` done (`.maxxfactory/out/<ISSUE>-impl-<n>.json` ok) -> `rebase-wt` onto the project branch -> a conflict dispatches a merge-only round (`--no-escalate`, same round number, brief `<ISSUE>-impl-<n>m<k>.md`); otherwise the round's checks (the fast ones with two-level checks: ticket `CHECKS_FAST:` line, else state.json `checks_fast`; without them the full ones: ticket `CHECKS:` line, else state.json `checks`) then ONE `bin/review` (`inflight.<ISSUE>.pool` when set), in the background, progress in `.maxxfactory/pipeline/<ISSUE>-<n>.check`;
- checks failed -> fix round `<n+1>` with the check output; changes -> fix round `<n+1>` with the findings file; no verdict -> the review again (bounded, then `stuck` and a CRITICAL alert); approved -> with two-level checks, stage `final` first: the full suite once (`max_full_jobs` at a time, progress in `<ISSUE>-<n>.final`), a failure there is a fix round with its output; then `.maxxfactory/pipeline/approved.txt` (`<ISSUE> r<n>`), stage `approved`;
- a round that cannot succeed never pays checks and a review: an implementer that answers `STATUS: blocked` goes to `triage` at once with its NOTES; a round that changed nothing is run again one tier up, and goes to `triage` the second time;
- the review brief lists what the round was asked to fix: reviewers of later rounds verify those findings first, and block only on a finding not fixed, a regression of the fix, a real correctness or security defect, or an unmet acceptance criterion. A finding raised late on code earlier rounds passed is `minor`;
- fix rounds are `run-model run implement --role fix` with the brief `<ISSUE>-impl-<n>.md`, so the escalation after round 3 applies, and every fix brief ends with "run the full checks and make them pass; a round with failing checks is rejected";
- past `max_rounds` (5) the ticket goes to `triage` instead of a new round, unless the review converges (fewer findings than the previous one): then it goes on by itself, up to `max_rounds_hard` (8); `triage` and `stuck` tickets are listed in `.maxxfactory/pipeline/attention.txt`;
- a run or job that died without a result (machine asleep, killed session) is started again, a failed run retried after `retry_minutes`, both bounded; a check that writes nothing for `check_silence_minutes` (25) is stopped with every process running in its worktree, and `finish` stops what a worktree left running before removing it;
- check slots count this project's jobs only (other projects on the machine run the same script);
- **`auto_start`** (opt-in, `bin/state set pipeline.auto_start true`): a queued ticket starts by itself, in queue order, once its `blockers` are all in `done`, its ticket file exists and its `Touches` overlap neither the `Touches` of a ticket in flight nor the files that ticket really changed in its worktree (shared test and docs paths excepted), up to `target_inflight` (default 2 x `max_jobs`); the worktree is created and `setup` run for it. The ticket file is the gate: write it only once it is planned and plan-reviewed (steps 1-3 of the loop), ahead of time, so no slot waits for you. Turn it on as soon as a few ticket files are ready;
- **`auto_merge`** (opt-in, the owner's decision, recorded with `bin/decision add`): an approved ticket is merged by the loop (`<merge_prefix>: <ticket title> [<ISSUE>]`, logged in `.maxxfactory/pipeline/merged.txt`). You no longer judge each ticket before it lands: sample the findings and the diffs of merged tickets on every heartbeat instead, and the milestone review still gates the milestone. Without two-level checks, run the full checks on the project branch after each batch;
- unless those two are on, it never merges; it never pushes, never touches the shared stack (Docker, servers, the main checkout), never starts a live gate. Log: `.maxxfactory/pipeline/pipeline.log`.
Your part:
- **Start a ticket** after planning it (steps 1-3 below) and creating its worktree (`bin/pipeline wt <ISSUE>`): `bin/pipeline start <ISSUE> [--pool <review pool>]` (round 1 brief, implementer of the implement role's tier, `inflight` entry; refused while one of its `blockers` is not merged, `--force` overrides). From there the pipeline owns it.
- **Merge approvals at once.** When `wait-approval` returns, for each `<ISSUE> r<n>` line: `bin/pipeline merge <ISSUE> "<type>(<scope>): <title>" "<body as in step 8 of the loop>"`. It rebases the worktree onto the branch, squashes the ticket's commits and uncommitted work into one change (`git reset --soft <branch>`), runs `bin/finish`, and marks the ticket done in state. Exit 3: the rebase or the cherry-pick conflicted; the cherry-pick is aborted, the rebase is left in progress in the worktree and a merge round is already dispatched: nothing to do, the ticket comes back approved. Then the full checks on the project branch, Linear (step 9 of the loop), and `wait-approval` again in the background.
- **`TICK` and `RUN:` lines.** `wait-approval` also returns with `TICK` plus the `RUN:` line every 10 minutes (the progress tick: see "Waiting"), and with the `RUN:` line alone once the run is DONE or WAITING ON OWNER, or has been STUCK or STOPPED for 5 minutes. Act as "The run verdict" says, and start `wait-approval` again only while the verdict is RUNNING or after you fixed a STUCK.
- **Attention lines** (`ATTENTION: <ISSUE> r<n> triage|stuck: ...`): settle a triage (accept the approval and merge, or write your own findings and `bin/pipeline fix <ISSUE> <findings.md>`), or look at a stuck step and `bin/pipeline retry <ISSUE>` (or `fix`). Any stage the pipeline does not drive (`hold`, `plan`, ...) is left alone: `bin/state set inflight.<ISSUE>.stage '"hold"'` takes a ticket out of the clock. **A ticket you hold is yours to keep alive**: every long step of it runs under `bin/bgrun` (the verdict counts a held ticket as moving only while a `bgrun` job of the project or a model run for that ticket exists), and it gets an estimate you renew at each step (`bin/state set est.<ISSUE> '{"min": <minutes left>, "at": "<ISO now>"}'`): without one its ETA is a constant added to "now", which moves forward at every reading and never arrives (`REPLAN: ... driven by hand and has no estimate`).
- **No message to the owner without the ETA (enforced).** While tickets are in flight or queued, every message you end a turn on carries the `RUN:` line, the bar of every milestone that is not at 100% and the overall bar of `bin/pipeline status` (or `bin/eta`), verbatim and fresh (never only the nearest milestone and the total; finished milestones may be left out): run it for that message, never quote a date from memory. `bin/eta-guard` is a Stop hook that sends you back with those lines when a message lacks them; at setup, with the owner's consent, `bin/eta-guard install` (user settings; `--project` for this repo only; `bin/eta-guard status`).
- **The date is the project's own record, not your estimate.** A ticket never counts for less than this project measured (start to merge, every round), and the date shown is corrected by how far the schedule moved over the last 6 to 48 hours: stretched by that rate, and when it moved 0.8 hours or more per hour, forecast from what the run really finished in those hours (tickets left / tickets done per hour). The bars always carry one date in one format; why it moved is said once, in the `REPLAN:` line. Each open milestone's bar ends with `left: N direct, N express, N full`: the lanes of the tickets it still has. Show the bars as printed. Never set `est` to bring a date in: `est` can only add time. Say what is not in the bars (an owner sign-off, a publish step).
- **Every update proposes optimizations (enforced by `bin/eta-guard`).** Each message that shows the bars ends with a section "Optimizations": what you did or will do about each `ACCELERATE:` line, then what you see yourself that the tools do not: a ticket on the full lane that is small and safe (size it, `bin/milestone lanes --apply`), a queued ticket to split, a blocker that is only ordering, tickets to start in parallel, scope the owner could cut. When there is nothing, say what you checked. A message with the bars and no such section is sent back.
- **Every new ticket gets its lane.** A ticket you add, or one the owner asks for, is created with `lines` and under the plan's `risk` list (`bin/milestone add`), so `lib.ticket_lane` gives it direct, express or full; a ticket created by hand in Linear has no size and runs on full until you size it. `bin/milestone lanes` lists the queued tickets that could run on a faster lane.
- **Accelerate at every update (ACCELERATE and ASK OWNER lines).** After the REPLAN lines, `bin/eta` prints what would shorten the run now, each with its command: automation left off (`auto_merge`, `auto_start`, stacked starts), approved tickets not merged, tickets held outside the clock, tickets past round 5, queued tickets that could run on a faster lane or that have no size, and ready tickets not started, the ones with the most work behind them first. For each ACCELERATE line, do it in the same turn or say in one line why not (a decision when it changes the plan). Each `ASK OWNER:` line is a question you put to the owner in that message, with your recommendation: a ticket past round 5 (keep going, cut the criterion that does not converge, drop it), scope to cut when the date does not converge, a ticket that waits on them. Do not wait for the owner to ask for speed.
- **Progress and ETA: `bin/pipeline status`.** The `RUN:` verdict first, then one line per in-flight ticket (issue, milestone, round, stage, current or last model with its tier, minutes in that stage), then the ETA bar of every milestone, then the `REPLAN:` lines (see "Re-plan for speed, regularly"). Show it whenever the owner asks for progress or an ETA and in every progress update, under the `bin/eta` lines.
- You still judge: read a sample of findings, reject wrong ones by editing the next round with `pipeline fix`, and keep the plan, Linear and decisions current.
## The loop (one ticket)
Steps 5-7 are what `bin/pipeline` does for you; run them by hand only for a ticket you took out of the clock.
1. **Pick** a ticket whose blockers are Done (or ordering-only, or in flight with their checks passed: a stacked start, see "Parallelism"). Linear: In Progress. Create the worktree (`bin/pipeline wt <ISSUE>`, or `bin/pipeline wt <ISSUE> --on <BLOCKER>`). It gets the main checkout's `node_modules` as a copy-on-write clone when the lockfiles are identical (`deps cloned: ...` on stderr): install dependencies only when it says nothing.
2. **Plan** (you, Tier 1). The ticket file `.maxxfactory/tickets/<ISSUE>.md` is already there when the ticket came through `bin/milestone add` (written from the approved spec): read it, and edit it only when the repo has moved since. An unchanged file is not plan-reviewed again (`bin/review` prints `SKIPPED ... unchanged since the milestone plan review` and exits 0), and an Express ticket never is. Otherwise you write the ticket file; then a model of another vendor (Tier 0, else Tier 1) reviews it adversarially before any code: `bin/mkbrief plan <ISSUE> 1 <ticket.md>` then `POOL=plan_review EXCLUDE=<your key> WT=<wt> bin/review <ISSUE> plan-1 <brief> 1`. Fold accepted findings into the ticket file, reject the rest in writing, at most 2 plan rounds. Before writing a plan, check the repo's real conventions with a few greps: wrong paths are the most common plan blocker. Skip the plan review only for mechanical tickets.
3. **Size it.** Split a ticket that needs more than ~400 changed lines or several independent parts into sub-steps (one commit each); group tiny tickets that touch the same files. One ticket per commit when reasonable, never at the cost of a clean history.
4. **Brief:** `WT=<wt> bin/mkbrief impl <ISSUE> <n> .maxxfactory/tickets/<ISSUE>.md [findings]`.
5. **Implement** (the implement role's tier, Tier 2 by default; a project pinned to Tier 3 escalates to Tier 2 from round 4): `bin/run-model run implement <brief> .maxxfactory/out/<ISSUE>-impl-<n>.md --cwd <wt> --issue <ISSUE> [--role fix] [--no-escalate]` in the background (`--issue` is what ties the implementer to the ticket for the review exclusions; the brief name `<ISSUE>-impl-<n>.md` works too). The round comes from the brief name (or `--round <n>` for a brief named otherwise): past `escalate_after_round` (3) the run escalates by itself. Statuses: `ok`, `quota`, `timeout`, `idle`, `waiting_input`, `error`, `bad_output`, `unavailable`, `all_failed` (see "Waiting"), `docker_hung`. Note the implementer key from `tried`.
6. **Check** yourself in the worktree, quietly (`> .maxxfactory/out/check-<ISSUE>.log 2>&1; echo rc=$?`). Look at `git status --short`: unexpected files are the cheapest early warning. Failure: next round with the log tail as findings.
7. **Review** (one Tier 2 reviewer): `WT=<wt> bin/mkbrief review <ISSUE> <n> <ticket.md>` then `WT=<wt> bin/review <ISSUE> <n> <brief>` in the background. Exit 0 (valid approval): step 8. Exit 1: next round with `.maxxfactory/out/<ISSUE>-findings-<n>.md` (edited by you: drop findings you rejected, add coordinator decisions). `bin/review` replaces a failing reviewer by the next eligible healthy one itself, and when Tier 2 has no eligible healthy reviewer (e.g. escalation made every Tier 2 model an implementer) it draws a Tier 1 reviewer as the logged backup (never your account). Exit 2 (`NO_REVIEWER`: no eligible reviewer in Tier 2 nor Tier 1, after waiting up to `review_wait_minutes` for one to come back, and a CRITICAL alert raised; or `INCOMPLETE`: every eligible reviewer was tried without a valid verdict): tell the user now, keep other tickets moving, retry behind `bin/run-model wait review <implementer keys>`. Never pick a Tier 1 reviewer by hand (`bin/review` alone decides the backup), never Tier 4, and never yourself. Plan reviews are Tier 1 only (the old `ALLOW_MID=1` is refused). Exit 3: a reviewer committed or moved HEAD (`HISTORY CHANGED`, nothing is rewritten automatically) or the tree could not be restored; inspect the worktree before anything else. Never edit the worktree yourself while a review runs there: the modified-tree check covers the whole directory.
8. **Commit:** `bin/pipeline merge <ISSUE> "<type>(<scope>): <title>" "<body>"` (rebase, squash, finish), or `bin/finish <ISSUE> "<type>(<scope>): <title>" "<what changed. Implementer: <models>. Approved by <models> after <n> rounds.>"` (the worktree must exist; `NO_WT=1` commits in the repo itself). Exit 3: see "Merging". Exit 4: fix the push before anything else. Then run the full checks on the project branch: a merge can break what each worktree passed alone.
9. **Linear:** comment (commit, what was built, decisions, numbers, implementer and reviewers, rounds) and move to Done. Update state and `bin/eta` inputs.
**Rounds:** one implementer, one reviewer, and again. Policy: at most one implementation and two fixes by a cheap model, then escalate. With the default Tier 2 implement role every round is a Tier 2 implementer and a different Tier 2 reviewer, and escalation has no tier above to go to. In a project pinned to Tier 3: round 1 = a Tier 3 implementer; rounds 2 and 3 (a review asked for changes) = fix rounds by a Tier 3 implementer (`--role fix`; the draw picks the same or another model by the credit left); from round 4 on the implementer is drawn from Tier 2: `run-model` escalates by itself when the round (brief name `<ISSUE>-impl-<n>.md` or `--round <n>`) is above models.json `escalate_after_round` (default 3), logs it in state.json `escalations`, and never goes to Tier 1. Keep the same command (`--role fix`) and number the briefs by round; do not pass `--escalate` before round 4. Every round ends with one Tier 2 reviewer that never implemented the ticket in any round: an escalated Tier 2 implementer is thereby excluded from that ticket's reviews, and `bin/review` draws another Tier 2 model, of another vendor when one is available. 5 rounds in total (3 on Tier 3, 2 on Tier 2); after round 5 you triage the remaining findings yourself (accept, reject in writing, or a follow-up ticket). A merge-only round after a rebase does not count: give it `--no-escalate` (it stays on Tier 3) and do not advance the round number. `run-model`, not you, picks the model: never pin (`--model`) or reorder to change a tier, never hand-edit pools (there are none).
## Changes of plan (no decision unsourced)
The user is away, so you take decisions the plan did not foresee. Each one must be traceable to its cause by someone who reads only `PLAN.md` and Linear the next morning.
**What counts as a change of plan:** a ticket added, split, merged, dropped, deferred or reordered against its `blocked_by`; a ticket started early on an ordering-only blocker; scope, a KPI, a non-goal, an acceptance criterion or a guardrail changed or waived; an architecture choice from `PLAN.md` reversed or refined by a plan review; a degraded mode taken (a role waiting on a reset, a review by the implementer's vendor when no other vendor was eligible); an open human decision settled by a safe default; a reviewer's finding rejected when it asked for something `PLAN.md` requires; a re-plan that changes `stages` or `critical_path`. Not a change of plan: a settled dispute that stays inside the ticket's acceptance criteria (it goes in the ticket file as "Coordinator decision" and in the ticket's Linear comment, as today), a retry, a model fallback.
**How, every time, in this order:**
1. `bin/decision add --change "<before -> after>" --source <kind>:<ref> --by <your roster key | owner> --why "..." --affects "<issues, K#, PM-#>"`. The source is the thing that caused the decision, precise enough to check: `review:ENG-12 round 2 finding 3`, `plan-review:ENG-12 plan-1`, `replan:<the REPLAN line>`, `quota:<pool> down until <time>`, `human-default:<the open decision>`, `check:<command> -> <result>`, `premortem:PM-2`, `user:"<their words>"`. Your own judgement is `coordinator:` plus the evidence (a command and its output, a file, a number), never a bare opinion.
2. Edit `PLAN.md` (ticket table, KPIs, rules, open decisions) to match. If `PLAN.md` is tracked on the project branch, commit it alone: `git commit -m "docs(plan): D-<n> <summary>" -- PLAN.md`.
3. Linear: create, update, cancel or re-link the affected issues (description and `blocks` relations follow the new plan); comment on each affected issue `D-<n>: <change>. Why: <why>. Source: <source>.`; re-sync the project content (`bin/linear project-content <project-id> PLAN.md` or the MCP project update). Then `bin/decision synced D-<n> <comment url>`.
3b. **No ticket outside a milestone (enforced).** Whoever adds a ticket (you in a re-plan, the planner, the owner by hand in Linear), it joins the milestone it serves best: the one whose outcome (its KPIs in `PLAN.md`) it moves; on a tie, the one its blockers and files sit in (`bin/milestone file <ISSUE>` prints that ranking and changes nothing). When no milestone fits, a new one is planned for it (`/maxxfactory-plan-more`): never stretch a milestone to avoid that, and never leave the ticket loose. A ticket you create goes through `bin/milestone add` with `"into"` (it is filed at creation), or, when it already exists, `bin/milestone file <ISSUE> --into <milestone id> --by <you> --source <kind:ref>` (decision, Linear move, state, schedule). `bin/milestone unfiled --from-linear` lists what is loose, including issues the owner created by hand in the Linear project: run it at every re-plan and whenever `bin/eta` prints `REPLAN: N ticket(s) in no milestone`, and file each one in the same turn.
4. Update the ticket files, `state.json` (the milestone `issues` lists, `blockers`, `sizes`, `est`), then `bin/milestone recompute` (rebuilds `queue`, `stages`, `critical_path`; never hand-edit them while `blockers` exist) and `bin/milestone sync --decision D-<n>` (Linear target dates and bars move with the plan).
**A new major milestone mid-run is normal** (the owner extends the project): it goes through `/maxxfactory-plan-more` (intake, pre-mortem and plan review of the delta, owner approval, then `bin/milestone add --approved`), usually in a separate session while this run continues. The same skill adds tickets the owner asks for to a milestone that exists (one ticket, a few, a QA pass: a spec with `"into"`, plan review and approval, no pre-mortem); tickets you add yourself during a re-plan stay a decision of this section. Keep the current milestones running; never pause the run for it. The new tickets appear in `state.json` (`milestones`, `blockers`, recomputed `queue` and `stages`): pick them up at the next re-plan. The owner away: the milestone waits for their approval; do not add one yourself. **An idea is not a milestone**: when the owner drops an idea ("idea: ...", "for later ..."), capture it with `bin/idea add` (`/maxxfactory-idea`) and keep running; it is not a change of plan of the current scope and never enters the queue.
`bin/decision check` runs at every heartbeat and before every user update or handoff comment: a `pending` entry is fixed before anything else. The handoff comment and the end-of-session summary list the decisions taken since the previous one (`bin/decision list`).
## Resuming after the coordinator session ends
**Linear is the restart source.** At every phase change keep Linear in sync: ticket status, a short status comment on in-flight tickets (stage, worktree, round, model), and a project-level "handoff / resume point" comment (done, in flight, next in order, where state.json lives, decisions). Secrets are never written to Linear.
**Changing coordinator on purpose** (another session, account, harness or model; this session close to the end of its context or quota): `/maxxfactory-handoff`. `bin/handoff check` lists what must be settled or written down first, `bin/handoff prompt` prints the prompt for the next session and refuses while a `BLOCK` line is left; after it you stop acting on the project. The clock is not stopped.
A new coordinator session first restarts the pipeline (`bgrun ls`; if `pipeline` is not running, start it as in Setup step 8, and `wait-approval` again): it dispatches again the runs and the check + review jobs that died with the old session, and merges nothing. For a ticket outside the clock, whose model run died with the old session (no process for it in `ps`): `rebase-wt`, then a new round whose findings say "the previous round was interrupted, not rejected: keep the correct partial work in the tree and finish". Count it as a round. After switching accounts, cooldowns recorded under the old account are stale: `reset` + `smoke`. Run `bin/run-model whoami --record` first: a new session may run on another account, which then becomes the protected one (the previous one is an ordinary account again).
## Parallelism
- Run independent tickets at the same time, each in its own worktree: `bin/pipeline wt <ISSUE>` creates `<repo>-wt/<ISSUE>` (branch `maxxfactory/<ISSUE>` from the project branch) and prints its path. **Every worktree lives in `<repo>-wt`, next to the repo, nowhere else** (2026-11-22: a path recorded in state.json pointed at the repo's old location, and new worktrees landed in a folder Spotlight indexed): the path is derived from where the repo is now, a `worktrees_dir` in state.json is ignored, and `pipeline start` refuses a worktree outside it. A scratch checkout (a suite, a measurement, a plan review) is `bin/pipeline wt <name> --detach [--from <ref>]`; never `git worktree add` to a path you chose. A ticket that spans several repos follows the same rule in each (`<that repo>-wt/<ISSUE>`). 3 to 6 in flight is a good level; the bottleneck is review capacity and quotas.
- **Tokens are spent in parallel, never in series (stacked starts, 2026-11-25).** A ticket whose one open blocker is in flight with its checks passed does not wait for that blocker's review and merge: `bin/pipeline wt <ISSUE> --on <BLOCKER>` (and `auto_start` by itself; `pipeline.stack`, on by default) creates its worktree on a snapshot commit of the blocker's worktree (`maxxfactory-stack <BLOCKER> r<n>`). Its implementation, checks and review run while the blocker is still in review. Nothing unreviewed reaches the project branch: a stacked ticket whose review approved waits in stage `stacked`; once the blocker is merged the snapshot commit is dropped (`rebase-wt`, `STACK_DROP=1`), the full checks run once on the result, and only then it is approved and merged. What the blocker's fix rounds changed meets the ticket's work in that rebase; a conflict is a merge round. A chain of N tickets takes about N implementations plus one review, instead of N times (implementation plus review rounds). Why: six serial stages of about 1.6 h each made a small change a two-day ETA.
- **Express tickets** (state.json `lanes`, written by `bin/milestone add` and `seed`: a whole small change, or an Express part of a bigger plan, slug `xp-...`): the pipeline gives every round to a Tier 1 implementer and each review to two Tier 1 reviewers of two vendors at once. You start them like any ticket; there is no plan review to run.
- Spread implementers (`--prefer <key>`) across models and accounts; a model may run several tickets concurrently.
- Parallel tickets must not edit shared docs: they write `docs/notes/<ISSUE>.md`. Merge the notes into the agent docs in a dedicated docs step later.
- **Start early on ordering-only blockers, to keep every milestone moving in parallel.** At every re-plan, have in flight one ticket per milestone chain head plus any ready ticket. A ticket whose Linear blocker is only an ordering preference (it would rebase on the blocker's result, not need its output) starts now: say so in a Linear comment and in the ticket file ("started before <blocker>; rebase after it lands"), and log it as a decision (it is a change of plan, `--source replan:...`); the pipeline's rebase and merge rounds absorb the later merge.
- Before a later round of a worktree ticket, and before checks that depend on newly merged code, `bin/rebase-wt <wt>` (serialised across worktrees by a repo-level lock; the stash is found by its own message, never by stack position); then check that every untracked file of the ticket came back (a path that now exists on the branch is silently not restored by `stash apply`; recover it from the kept stash's untracked tree).
- Never run a review in parallel with your own checks in the same worktree (reviewers may start or stop servers there). Check first, then review.
- Before running checks, make sure nothing of the implementer still runs (no process with the worktree path in `ps`; remove its containers).
- **Dead containers are removed automatically** (standing rule). The reaper only removes containers of this project: set state.json `docker_reap_only` to a regex of the project's container names at setup (e.g. `^(myapp|shop)`); without it, `docker-reap --apply` only reports. Other projects share the Docker daemon. Run `bin/docker-reap --apply` at every heartbeat and before each full check. Leaked test servers keep their fixed names and make later browser tests fail on name collisions. The reaper never touches a container younger than 2 h or one that a live process references, so in-flight runs are safe. Orphaned host processes reparented to PID 1 (init / launchd / systemd) from dead test runs in a ticket's worktree should also be checked and stopped when older than 1 h.
- **Nothing a ticket started outlives it, and no check runs forever** (2026-11-20: 13 leaked `next-server` processes from merged worktrees and 7 orphaned `just check` runs, up to 6 h old, drove the load past 300 and kept every check of a milestone blocked for an hour while the pipeline showed them as "checks"). The harness enforces it; the coordinator verifies it:
- `bin/finish` stops every process running in the worktree (`lib.reap_worktree`) before removing it.
- **Only the worktrees in flight stay.** `pipeline run` collects the others every `gc_minutes` (`bin/gc`, lines `gc removed ...` in `pipeline.log`): finished and never-started worktrees and their branches are removed with the processes running in them. A `gc orphan` line names a worktree that holds work but is not in flight (a ticket dropped from state, a worktree made by hand): at the next heartbeat merge it, put it back in flight, or remove it. Never leave an orphan across two heartbeats, and never start work in a worktree that is not in `inflight`.
- `bin/pipeline` treats a check whose `.check` log is silent for `check_silence_minutes` (25) as hung: it kills the job and the worktree's processes, then reruns the check (bounded by `review_retries`). Before restarting a dead job it reaps the dead job's orphans.
- `bin/pipeline` counts only this project's jobs against `max_jobs`: several projects run the same pipeline script on one machine, and another project's jobs must never take this project's check slots.
- A project with its own clock script (a custom `loop.py` or night driver) must apply the same three rules; at setup, prefer `bin/pipeline run`.
- Every heartbeat: a ticket whose stage and round have not moved across two heartbeats is investigated at once (`bgrun ls`, the age of its `.check` file, `ps` for its worktree), never reported as "in checks" again. Stop any `just check` older than `check_timeout_minutes` + 15 and any process running in a merged ticket's worktree.
- Collisions to prevent up front: fixed ports and container names, shared generated files, two tickets editing the same layout or manifest. When the merged branch fails because parallel tickets disagree, create a small integration follow-up ticket in Linear with `blocks` and log it as a decision (`--source check:<the failing check>`); don't hide it in the next ticket.
### Re-plan for speed, regularly
Fewer tickets in flight than the machine and quotas allow is lost time. Don't wait for the user to ask "can't you go faster?". Re-plan when a ticket lands, when a review sends one back, when fewer than 3 tickets are in flight, and at least at every heartbeat.
**`REPLAN:` lines are mandatory triggers.** `bin/eta` and `bin/pipeline status` (the view of every update) both print them after the bars; never filter them out (`| head`, `| grep` on the bars). Act on every `REPLAN:` line before you send the update, and quote each one in the update with what you did about it, or the limit that stops you.
- A slip of more than 30 min against the reading 1–3 h ago.
- Two or more single-item stages in a row. A serial tail is usually an untested assumption, not a real dependency chain.
- Fewer in-flight tickets than `parallel_target` (default 6) while work is queued.
- A blocker that shares no file with the ticket it blocks (from the milestone specs' `touches` and the `Touches` line of each ticket file). Drop it when the ticket does not need the blocker's output (a decision, then `bin/milestone recompute`). When it does need the output, record the pair in state.json `needs_output` (`{ticket: [blockers]}`) and write why in the ticket file. Three such blockers had kept a milestone at one ticket in flight for hours, because `pipeline status` cut the `REPLAN:` lines and nothing named the blockers.
A slipping ETA means the plan is stale. Recompute the plan, not just the estimate: an ETA that only grows means nobody re-checked the order.
Two cases are never a reason to leave a ticket idle:
- **Blocked on the owner** (a token, an export, an approval): build and test the offline part now, with fixtures sampled from real data, and leave only the live run for later.
- **Blocked on a plan review because Tier 1 is cooling down:** run a read-only diagnosis brief on a Tier 3 model now (`mkbrief diag`, `run-model run implement ... --role fix`), so the plan is ready to review the minute the quota resets.
The steps:
1. **List what is idle.** List every queued ticket and what really blocks it: a file the in-flight work edits, an output it needs, or only ordering. Most "waits for X" are partial: only one part of the ticket needs X.
2. **Split to unblock.** Cut the part that doesn't depend on the blocker into its own sub-ticket and start it now. Examples:
- docs, investigations or tooling ahead of the code they describe;
- the implementation half of a ticket whose measurement needs a quiet machine;
- a fix found during a review, as its own ticket in another worktree.
3. **Overlap your own steps.** Run the next ticket's plan review while the current one implements or reviews. Run checks of ticket A while ticket B's review runs, in other worktrees. Write the next ticket file while you wait.
4. **Attack the shared bottleneck.** If every cycle waits on the same slow suite, a flaky test or a cooled-down pool, a ticket that fixes it pays back on every later ticket. Examples: test-suite speed, a flake, ephemeral ports that remove collisions, another account login (`/maxxfactory-init`). Schedule it early, not at the end.
5. **Keep the schedule honest.** `stages` must show real parallelism: a side ticket goes in a parallel stage that doesn't gate the critical path. An item already done or still blocked on the owner does not sit in the current stage. With `blockers` in state, change the blockers (an ordering-only one dropped is a decision), then `bin/milestone recompute`; a `REPLAN: stages out of step with blockers` line means someone hand-edited `stages`. Re-check `bin/eta -v` after every change.
6. **Respect the limits.** Machine load (watch `uptime`: past roughly 2× the core count, runs slow down and flakes appear), review capacity, and quota. Add parallel work only while the load average and healthy pools allow it. Say which limit stops you, so the user can lift it.
State each re-plan in one line in the user update: what you started, or which limit stops you. A re-plan that splits, adds, reorders or defers a ticket is a change of plan: log it (see "Changes of plan") with `--source replan:<the REPLAN line or the blocker you found>`.
### Owner-decision scan (what only the owner can unblock)
Some limits cannot be re-planned away: only the owner can lift them. On 2026-11-11 the certification failed three times on free-model daily limits before anyone asked the owner for a paid model; one question would have saved a day. So on every heartbeat, before every user update, and at once when the owner says they are leaving, ask yourself: **what blocks or slows progress right now, and needs a decision from the owner?**
Look for:
- **Models and spend:** a free or daily quota that fails runs (429, `free-models-per-day`); a ticket past round 3 whose findings repeat, where a stronger model or tier would converge; a role waiting more than 30 min for a tier; a paid cap or a "no paid" decision that a run keeps hitting.
- **Accounts and access:** a `CRITICAL: ... login expires` alert (tell the owner at once, with its command: they can only log in while awake); a missing login, subscription, token, credential, export, or a repository or service the run cannot reach; an account the owner excluded that would unblock a role.
- **Approvals and choices:** an open gate or KPI waiting for sign-off, a pending decision (`D-<n>` with a question), a scope or product choice, a merge, publish or deploy that is not a row of `Pre-authorized actions` (one that is, you run yourself).
- **Repeated slowdowns:** the same external failure twice, an ETA that slips for a reason outside the plan.
For each, write one line, the recommended option first:
```
DECISION NEEDED: <what> | blocks/slows <tickets or milestones, and roughly how much time> | options: <A (recommended), cost> / <B, cost> | until then: <what you do meanwhile>
```
**A human prerequisite found during the run** (a ticket stops on a missing account, key, access or data that setup step 1b should have caught): first check whether a tool can do it (`bin/access scan`, the provider's API): if so, do it, or ask for the access rather than the manual step. Do not ask for that one alone. Walk every remaining ticket for others of the same kind first, add the rows to the `Human prerequisites` table, then raise them all in one `DECISION NEEDED:` line with the `! pbcopyenv <NAME>` line for each secret. Meanwhile move the tickets held back to the end of the queue and keep the rest going; log it with `bin/decision add --source coordinator:<the failing command or log>`.
**Record every ticket that waits on the owner**, the moment you know it: `bin/state set owner_wait.<ISSUE> '"<what the owner must do, in a few words>"'` (and `bin/state del owner_wait.<ISSUE>` when they did it). This is what lets the tools tell "waiting on you" from "running": such a ticket and everything queued behind it leave the ETA (shown as `+N waiting on owner`), never start by themselves, and when nothing else is left the verdict is `RUN: WAITING ON OWNER | <what> (<tickets>)` with no ETA. A ticket that waits on the owner and is missing from `owner_wait` keeps a false ETA alive and a false `REPLAN: start an independent ticket`.
Keep the open asks in `.maxxfactory/owner-decisions.md`, one line each with the date first raised. Show them at the top of every user update, above the bars, until the owner answers; ask again only if their impact changes. When the owner announces an absence, put every open ask in one message before they go. Never act on an ask without the answer (no spending, no excluded account, no merge). Meanwhile, apply the re-plan rules above to the parts that do not depend on it. The answer is a decision: log it with `--source user:"<their words>"` and remove the line.
## Merging (cherry-pick conflicts)
- `package.json` / lockfiles: take the **union** of both sides' scripts and dependencies, dedupe, then reinstall to regenerate the lockfile. `.gitignore`: union.
- `bin/pipeline merge` avoids most of them: it rebases the worktree first and squashes the ticket into one change, and on a conflict aborts the cherry-pick and hands the ticket to a merge round by itself (exit 3).
- Anything else: resolve if trivial and obvious, otherwise `git cherry-pick --abort`, then `bin/rebase-wt <wt>` (the ticket is already committed in its worktree: it rebases that commit onto the project branch, exit 3 with the conflicting files if it cannot), re-dispatch a merge round if needed (`mkbrief` then reviews the committed work plus the fixes, from the merge-base), and `finish` again: it integrates every commit of the ticket branch that is not on the project branch, and commits nothing when there is nothing new.
- After resolving: `git add`, `GIT_EDITOR=true git cherry-pick --continue`, remove the worktree and branch, run the full checks, push.
## Judging (what makes the night succeed)
- **A blocked ticket never waits for you** (2026-11-23: four tickets blocked on a file outside `Touches` and two approved ones waited 4 h 20 while the coordinator session was silent; the loop ticked the whole time). The stop is right, it keeps two tickets off one file; the wait was the defect. So the loop settles what it can: a blocked implementer that only asks for files (`NEEDS:` line) gets them from `bin/pipeline` within one tick (`implementer blocked on files -> granted ...` in the log, a `Pipeline grant` line in the ticket file), up to `pipeline.max_grants` (3) per ticket, unless a path is under `.maxxfactory/`, matches `pipeline.reserved_paths` (set it at setup to what the project reserves, e.g. its dependency manifest and lockfile), is on the ticket's `Do not touch:` line, or is claimed by another ticket in flight. Only those, and blocks on a decision, an access or an input, reach triage. Turn `pipeline.auto_merge` on as soon as the merges are routine, so approvals do not wait either. Whatever still waits for you for `pipeline.attention_minutes` (20) raises the CRITICAL alert `coordinator_silent`, which the owner sees. Never write a project rule that lets implementers edit outside `Touches` unasked: two tickets in flight then meet on one file.
- **Shortcuts are blockers even when checks pass:** copied expected outputs or snapshots, hard-coded test answers, checks that pass by construction, test-only code shipped in the product, a harness that reads the expected output to shape what it captures, a literal list of cases that changes behaviour for exactly the failing ones. Send it back with a precise "coordinator blocker" finding, and ask for a test that makes that class of shortcut fail.
- **Fix the class, not the instance:** when a reviewer finds a bug a harness should have caught, ask for the harness change and a test that covers the class.
- **Invented fixtures pass by construction.** Require fixtures sampled verbatim from the real data, plus one test that round-trips a real record.
- **Reviewers can be wrong.** Typical false positives: claims about a library contradicted by a quick run, findings that contradict a documented coordinator decision, demands outside the ticket's scope. Verify with one command, reject in writing (Linear comment + ticket file), approve on the remaining verdict. Hypothetical inputs absent from the real data are `minor`; don't spend more than one round on them.
- **Suggested patches are findings, not commands.** They get the same check as any other finding before they go into a findings file.
- **Skip the review when you already found a blocker.** Reviews cost as much as implementations.
- **Flaky checks are defects.** Ask for determinism and the root cause.
- **Human decisions:** when a requirement needs information no model can have, ship the safe default, list it as an open human decision in Linear and the agent docs, log the default as a decision (`--source human-default:<the question>`), and approve.
- **A plan review or code review that changes the plan** (another architecture, a ticket split, a criterion dropped as impossible) is accepted only through `bin/decision add --source plan-review:...` or `review:...`; the ticket file alone is not enough.
- **Ugly is not done.** For every ticket that changes something a user sees, open its screenshots yourself (they are images: read them) before it merges, next to the references in `PLAN.md` "Design bar". Raw ids or markup on screen, wrapped identifiers, clipped or overflowing content, cramped or bloated layouts, missing states, or a clear gap with the references: send it back with a "coordinator visual blocker" finding that lists each defect concretely (what, where, what it should look like), even when every check and reviewer passes. A driver that merges approvals without you (a night driver) holds UI tickets until you have looked. Why: on 2026-11-16 a tables milestone passed every KPI (query speed, panel sections, accessibility) while its own gate screenshot showed a column wrapping one character per line and raw ids, and a dashboard round passed its tests while clipped and missing half the requested widgets; the owner had asked for tables and a dashboard as good as named reference products.
- **A UI milestone closes only with the owner's sign-off** on full-page screenshots side by side with the references. A gate that passes on screenshots nobody looked at is a failed gate.
- **Pre-mortem guardrails are acceptance criteria.** A ticket that violates a guardrail from `PLAN.md` is not done, whatever the reviewers say.
## Roles, tiers and quotas
The owner's policy (README, "Tiers"); `run-model` and `bin/review` enforce it, you never reshuffle it:
| Role | Tier | Who | How |
|---|---|---|---|
| Plan a project or a milestone (`/maxxfactory-plan`, `/maxxfactory-plan-more`) | 0 | the planner session | `/model`, then `--planner <key>` |
| Coordinate, plan the tickets | 1 | you | this session |
| Plan review, pre-mortem, milestone adversarial review | 0, else 1 (logged) | another vendor than the planner | `POOL=plan_review bin/review`, `bin/premortem`, `bin/milestone add` |
| Express ticket: implement and fix | 1 | drawn, never an entry flagged `no_implement` | the pipeline (`--role express_implement`) |
| Express ticket: review the final diff | 1 | two vendors, neither the implementer's, in parallel | the pipeline (`POOL=express_review bin/review ... 2`) |
| Direct ticket (state.json `lanes` = `direct`: a small safe ticket of a plan, or the owner's choice for a whole change) | 1 | one implementer, one reviewer of another vendor, once; the same implementer fixes; then the full checks decide, with no second review | the pipeline |
| Implement, fix | 3 | drawn | `run-model run implement` (`--role fix` for a fix round) |
| Review each round of code | 2 | drawn, never an implementer of the ticket | `bin/review` (one reviewer) |
| Implement rounds 4 and 5 of a ticket (escalation) | 2 | drawn, automatic past `escalate_after_round` (3) | `run-model run implement` (same command; the round comes from the brief name or `--round`) |
| Trivial tasks (rename, format, a lookup) | 4 | drawn | `run-model run implement --role trivial` |
| Tier 0 in any other role | 0 | only when the owner asks, for that run | `--model <key> --allow-tier0` |
- **Who is drawn.** Every valid roster model of the role's tier whose CLI is installed and that is not excluded (roster `excluded`, `subscription: reserved`, or this project's state.json `exclude`), at random, weighted by the credit left on its account (`usage --apply` readings) and its subscription (paid > unconfirmed > free plan). Usage spreads over every paid subscription, so each is used up before it resets. `bin/run-model pool <role>` shows the current draw; `--prefer <key>` only spreads parallel runs inside the tier.
- **Your own account is protected.** It is detected from your process (`run-model whoami`), never configured. Models on it run last, as the fallback of last resort for implementation and review (and for any other role only when it has no other model at all), and only while it keeps `coordinator_reserve` (30% of the 5-hour window, 20% of the weekly one): below that `run-model` refuses (`coordinator_reserve`) and raises a CRITICAL alert. Another login of your CLI is a normal paid account.
- **Vendor -> CLI.** Anthropic only through `claude`, OpenAI only through `codex`, Google only through `agy`, Mistral only through `vibe`, xAI through `grok`, everyone else through `pi` or `opencode`. An entry that breaks it is refused everywhere; fix the roster (`/maxxfactory-init`), never route around it.
- **No speed variants.** A `-fast` / `build-fast` / "Fast" variant of a model family (e.g. `grok-4.7-build-fast`) is never drawn, whatever its tier: more expensive, no quality gain. The roster refuses it in every pool and by `--model`, and `discover` never switches to one. Never pass `--allow-fast` yourself: only the owner does. "Flash" / "Flash-Lite" are model families, not speed variants.
- **Never pay more.** Subscriptions and free tiers only, never top-ups or paid per-token ids. The one exception is credits the owner already holds and declares (`bin/harness credits <cli> <account> on --source "<their words>" [--until DATE]`): they are the last resort for ticket implementation, fixes and code reviews, Express tickets included, used only when no healthy model of the role is left (for a review, after the Tier 1 backup), never for planning, and every such run is logged (state.json `credit_runs`). The runtime still never buys anything. A model that misbehaves (empty runs, ignores the output format, edits during review, loops) is cooled down automatically; if it repeats, exclude it with a reason (`bin/harness set <key> excluded "..."`) and log it in `changelog`.
Watch quotas with `bin/run-model usage` (the `/maxxfactory-status` skill explains the output). Expect whole accounts to go down together; `bin/harness check` says which roles are thin.
## Waiting (never stop because of credits)
- `all_failed` or `review` exit 2: `bin/run-model health` shows the first cooldown end. Meanwhile do anything else.
- **Reuse every model the minute it is back.** Cooldowns hold the exact reset (from `usage --apply` or parsed from the quota error). Put blocked work behind `bin/run-model wait <role> [EXCLUDE]` in a background job: it sleeps until the earliest cooldown end of the role's tier and prints the first healthy key, e.g. `bin/run-model wait review <implementer keys> >/dev/null && ... bin/review ...` with the tool's background mode. `bin/review` itself already waits up to `review_wait_minutes` (90) for a reviewer. Never a foreground sleep.
- Quota cooldowns without a known reset last 60 min; when the user says a model works again, `reset` + `smoke`.
- **Out of quota with no reset is a critical failure: tell the user at once.** On 2026-11-09 all three Codex accounts ran out, the run went on degraded for hours (plan reviews `NO_REVIEWER`, every review behind one free model) and the owner learnt it by chance. Now:
- `run-model` claims a Codex account's reset by itself when its WEEKLY window is at 100% (`usage --apply`, or a run that hits its quota), once per account per window, then smoke-tests it and clears its cooldowns. Never ask for permission; never claim one for a 5-hour limit.
- When a vendor is still down on every account (no reset left, reset failed, auto-reset disabled), a role has no eligible model of its tier for longer than `alert_min_outage_minutes`, a ticket has no eligible reviewer beyond `review_wait_minutes`, or your own account reaches its reserve, a CRITICAL alert is raised: `CRITICAL:` on stderr, `.maxxfactory/alerts.jsonl`, a Linear project update "CRITICAL: <vendor> out of quota", and `CRITICAL:` lines at the top of `bin/eta`.
- Run `bin/alert list` on every heartbeat and before every user update. Any unacknowledged alert is reported to the user **in your very next message**, first, before the ETA: what is down, which accounts and reset results, what it blocks (plan reviews, pre-mortems, review capacity), when the earliest window resets, and what you do meanwhile. Send a push notification too when the harness offers one. Then `bin/alert ack <ID>`. A `CRITICAL:` line on a run's stderr counts the same.
- Never keep running degraded for hours without telling the user. Log the degraded mode you take as a decision (`--source quota:<vendor> down until <time>`).
- The **progress tick** is `wait-approval` itself: it returns with `TICK` every 10 minutes (no separate `sleep 600`; a tick you have to remember is a tick you forget). On every tick: `bin/alert list`, then show `bin/pipeline status` (see "ETA (always shown)"), then start `wait-approval` again. Every third tick (about 30 min) is also a **heartbeat**: run `bin/alert list` first (see above), `bin/decision check`, `bin/bgrun ls` and check every in-flight model log (`run-model` has its own idle watchdog): any job whose last output is older than its idle limit is a stall to act on now, not later; run `usage --apply`, run `bin/docker-up` when the checks use containers, `bin/milestone sync`.
- When a CLI announces its reset time, don't smoke it before: schedule one background job that sleeps until just after the reset, then `reset` + `smoke`.
- macOS BSD userland has no `timeout` command by default: use `bin/bgrun --timeout` (it also kills descendants that left the process group), never a hand-written `until` loop.
- **Never buffer a `bgrun` command's output.** A pipe to `tail`, `grep` or `sort` inside the command holds every line until the end, so a healthy run looks silent and is killed (seen: a 30 min full check killed as a STALL). Stream the output (`grep --line-buffered`), and filter it only outside `bgrun` (`bgrun ... | tail -15`). For a command that writes its progress to other files (per-lane check logs), add each one with `--watch`. For a step that is silent by design but bounded elsewhere (a review: `run-model` caps it at 1800 s), set `--idle` above that bound.
- **A long command that logs nothing is a defect of that command.** When `bgrun` reports a STALL, the fix is not a bigger `--idle`: send the tool back with findings to add per-step progress lines and a bounded timeout on every wait (browser, server, child process) that fails closed with the step named, plus a test with a step that never finishes.
- A run that returns `docker_hung` is an environment stall, not a model failure: run `bin/docker-up --restart` (it restarts the runtime only when the daemon is hung; see `references/lessons.md` if that fails), `reset` any model cooled during the hang, relaunch.
- Background jobs launched with `&` inside a command don't notify you; use the tool's background mode, or wrap the job with a background `until` loop that waits for its result file.
## The run verdict (RUNNING, DONE, STUCK, WAITING ON OWNER, STOPPED)
The first line of `bin/pipeline status` and `bin/eta` is `RUN: <STATE> | <why>`. It is computed from facts (state.json, the clock's lock, live `bgrun` jobs, model runs), not from what you believe, and it decides whether an ETA is shown at all. **Your last message of every turn starts with that line, verbatim and in bold, before anything else**; the owner must never read a table to learn that the run is over or stopped.
| Verdict | Means | You |
|---|---|---|
| `RUNNING` | A ticket really moves: the live clock drives it, or a `bgrun` job or model run exists for a ticket you hold. | Keep going; `wait-approval` runs in the background. |
| `DONE` | Nothing is left in scope. | "End of session", then say in one plain sentence that the run is done and nothing is running. Stop the clock (`bgrun ls`, kill `pipeline`), no new `wait-approval`. |
| `WAITING ON OWNER` | Every ticket left needs the owner (`owner_wait`, `blocked`, or queued behind them). No ETA is shown. | Say exactly what the owner must do, as a numbered list with the tickets each item releases, and that nothing runs until then. Send a push notification when the harness offers one. No new `wait-approval`: their answer wakes you. |
| `STUCK` | Work is left, nothing moves, and it is not the owner's turn: a triage or approval waiting for you, a held ticket with no job, a dead clock, a ready ticket nobody started. No ETA is shown. | Fix it in this turn (merge, `pipeline fix`/`retry`, restart the clock, start the ticket, relaunch the job under `bgrun`), then read the verdict again. If you cannot, the turn ends with **RUN: STUCK** and the reason, never with a soothing summary; if the real cause is the owner, record `owner_wait` so the verdict says so. |
| `STOPPED` | No clock and nothing in flight: planned and not started, or the session ended between tickets. | Setup step 8. |
Two rules follow. **Never end a turn on RUNNING without a live `wait-approval`** (check the harness's background jobs): it is the only thing that wakes you. **Never report a verdict the tool did not print**: "almost done", "final QA running", "ready after X" are not states. If the verdict is wrong, the state is wrong: fix `inflight`, `owner_wait`, `est` or `done`, then read it again.
## ETA (always shown)
**Proposed milestones are bars too.** A milestone drafted with `/maxxfactory-plan-more` (any `bin/milestone add` before approval; tickets proposed into an existing milestone show on its bar as "(+N proposed)") shows in `bin/eta` and `bin/pipeline status` as "<name> (proposed) ... (awaiting approval)" on a what-if schedule; it never needs a separate dry-run to be visible, and such a reading records no ETA history or slip. `bin/milestone proposed` lists them, `--drop <id>` removes a rejected draft.
**Every turn you end shows the bars**: whatever woke you (a progress tick, a heartbeat, an approval, an `ATTENTION:` line, a finished background job, a merge, the owner), your last message before you go back to waiting is the `RUN:` line in bold, the open `DECISION NEEDED:` lines from `.maxxfactory/owner-decisions.md` (if any), then the output of `bin/pipeline status` in a code block, plus one line on what changed since the previous one. Never end a turn silently, never end it with only "waiting". With the 10-minute `TICK` of `wait-approval` the owner sees fresh bars at least every 10 minutes while the run is RUNNING. An ETA is printed only then (and for a STOPPED plan); `done`, `no ETA: stuck` and `no ETA: waiting on owner` replace it otherwise, and `ETA ~... (±N, guess)` marks a date that rests on a held ticket without a fresh `est` (a `REPLAN:` line names the ticket).
Every handoff comment and every Linear project summary also starts with the `bin/eta` lines before the first `REPLAN:` in a code block (one bar per milestone, then the overall line; run it, never guess). In every message to the owner, use `bin/pipeline status` for it: the same bars, preceded by one line per in-flight ticket, so the owner sees what is in progress and what is executing right now. Each heartbeat also runs `bin/milestone sync`, so Linear's milestone target dates and bars follow. Every sync runs tidy, and tidy runs again after every merge: it deletes empty milestones that are not in state.json (never the "Ideas (unscheduled)" milestone, never a milestone that still has an issue), archives an empty Linear project this autopilot created when that project is not the current one, and moves ticket states to match state.json (in flight is In Progress, done is Done, a ticket waiting in the queue stays unstarted or backlog). The coordinator never leaves an empty milestone or an empty autopilot project behind. The line carries the machine's timezone: convert it to the user's timezone when they differ, and say so. When the ETA moves, give the cause in one line (a review sent a ticket back, a lost run, a new ticket) and what the re-plan changed. Keep its inputs current in state.json: `stages` (ordered list of parallel groups, including your own final steps), `est` per ticket (`{"min": minutes left, "at": ISO}`, set when a round starts and re-set when a review sends the ticket back), `sizes`, and `blockers` + the milestone issue lists, from which `bin/milestone recompute` derives `queue` and `stages`. When asked for a tighter bound, name what drives the error rather than inventing precision.
## Self-update
- **Latest version always.** `bin/run-model discover --apply` at setup and on "model not found"; `usage --apply` runs it once a day by itself. It finds a newer id of every versioned family (listing command, or generated next-version ids for a CLI without a listing, such as Claude), smoke-tests it through the entry's own account, switches every entry of that id, keeps the level unless the owner's tier table names the new id, and logs it in `changelog`. Report the upgrades to the user.
- Improve the procedure during the session when you learn something (a failure pattern, a better prompt, a missing helper): edit this skill, `prompts/`, `bin/`, keep changes small, log them in `models.json` `changelog`. Project-specific lessons go to `references/lessons.md`, not here. Edit `models.json` atomically (temp file + rename); `run-model` reloads it before saving health.
## run-model behaviour (reference)
- Watchdog: kills a run that waits for input (its last line is a CLI prompt, not code, after 30 s of silence; adapter `waiting_patterns`), exceeds its timeout (`implement` 4800 s, `review` 1800 s), or stays silent for `idle` (900 s) while nothing changes in the working directory.
- `bad_output`: exit 0 but no `STATUS: done|partial|blocked` (implement) or `"verdict"` (review) at the end. The model is cooled down and the next one runs.
- Environment: `CI=1 NO_COLOR=1 TERM=dumb PYTHONDONTWRITEBYTECODE=1`, plus the adapter env and the account env (e.g. `CODEX_HOME`).
- Reviewers run with full rights but must not change the tree; `bin/review` snapshots the tree and restores it (`TREE RESTORED`). Discard the verdict of a reviewer flagged `modified tree`.
- How each CLI is invoked: `bin/harness adapters` (one JSON per harness, user overrides in `~/.config/maxxfactory/harnesses/`).
## When something looks familiar
`references/lessons.md` (in the skill repo) holds the failure patterns met on real runs, by symptom: ghost sessions editing finished worktrees, Docker hangs under parallel capture runs, the machine sleeping on battery, stash pops dropping untracked files, invented fixtures, per-case harness tuning. `references/lessons-codex-resets.md`: every Codex account out of quota, automatic resets, stale usage readings. `references/fanout-qa.md` is the procedure for big failure lists (parallel read-only diagnosers, one todo list by root cause, sub-tickets). Read the matching section when a symptom appears; don't load them up front.
## End of session
When the scope is done, or the user is about to come back: run all checks on the branch, leave the PR a draft (the owner marks it ready, or tells you to: then `bin/state set pr_ready true` and `gh pr ready`, which starts CI once on the finished work; follow that run to its end and report it), make sure the agent docs describe the current state (dispatch a docs ticket that merges `docs/notes/*`), run `bin/decision check`, post a summary on the Linear project (done, in progress, not started, blocked with reasons, open human decisions, the decisions taken during the run with their sources, KPI status from `PLAN.md`, models used, commit range, branch + compare URL or draft PR link), and tell the user the same in a few lines. Keep working on what is still unblocked unless the user says stop.