From the ticket to the merge request: who does what, on which model, and where the engineer steps in. One overview in a single graph, the agents one by one, then four detailed views in the order of a run.
The whole factory in one graph: a ticket comes in, a merge request comes out, and the factory corrects itself when a run went wrong. It reads left to right on two lines, and each arrow says what goes from one node to the next. In every diagram, hover an agent or a script to see what it does. The views below detail each part.
flowchart LR
oSwe1("Software Engineer
pastes the ticket URLs"):::swe
oVigie{"vigie
proposes tickets"}:::script
oConsole{"registry.ts
queue, conflicts,
run worktree"}:::script
oSched["Ticket scheduler
Sonnet"]:::agent
oGuard{"guard.mjs
checks every
tool call"}:::script
oPilot["Pilot /implement
Opus"]:::agent
oSwe2("Software Engineer
answers the questions"):::swe
oPlanner["Planner
Opus"]:::agent
oDev["Dev × N
Sonnet or Opus"]:::agent
oGate{"gate.mjs
typecheck, lint,
tests"}:::script
oOrch["Review orchestrator
Sonnet"]:::agent
oSenior["Senior reviewer
Opus or Sonnet"]:::agent
oDesigner["Designer
Sonnet"]:::agent
oQa["QA
Opus or Sonnet"]:::agent
oSwe1 -- "URL" --> oConsole
oVigie -- "tickets" --> oConsole
oConsole -. "batch" .-> oSched
oSched -. "order" .-> oConsole
oConsole -- "worktree, session" --> oPilot
oPilot -. "tool calls" .-> oGuard
oPilot -- "questions" --> oSwe2
oSwe2 -- "answers" --> oPilot
oPilot -- "ticket, criteria" --> oPlanner
oPlanner -- "plan" --> oDev
oDev -- "agent stops" --> oGate
oGate -- "fail" --> oDev
oGate -- "committed code" --> oSenior
oGate -. "large diff" .-> oOrch -. "sequences" .-> oSenior
oSenior -- "corrections" --> oDesigner -- "deviations" --> oQa
oQa -- "P0 / P1 : rework" --> oDev
classDef agent fill:#3a2210,stroke:#ff9d3c,stroke-width:1.6px,color:#c9cddb
classDef script fill:#12301f,stroke:#4ade80,stroke-width:1.6px,color:#c9cddb
classDef swe fill:#3a310a,stroke:#facc15,stroke-width:1.6px,color:#c9cddb
flowchart LR
oAccept{"acceptance-runtime.ts
review-confidence.ts
criteria coverage,
review confidence"}:::script
oMr["Pilot · Opus
opens the MR"]:::agent
oSwe3("Software Engineer
reviews and merges"):::swe
oWatch{"merge-watch.ts
watches the MR,
frees the queue"}:::script
oAudit{"self-improvement.ts
self-audit
of the run"}:::script
oImprove["Session /improve
Opus"]:::agent
oAuto{"auto-merge.ts
rules and checks"}:::script
oJudge["Session /judge-improvement
Opus"]:::agent
oRetry(("pending/
tried again")):::script
oAccept -- "coverage" --> oMr
oMr -- "merge request" --> oSwe3
oSwe3 -- "merge" --> oWatch
oMr -- "run ends" --> oAudit
oAudit -- "defect observed" --> oImprove
oImprove -- "branch" --> oAuto -- "passes" --> oJudge
oAuto -- "rejected" --> oRetry
oJudge -- "rejected" --> oRetry
oJudge -- "merge" --> oMain(("main"))
classDef agent fill:#3a2210,stroke:#ff9d3c,stroke-width:1.6px,color:#c9cddb
classDef script fill:#12301f,stroke:#4ade80,stroke-width:1.6px,color:#c9cddb
classDef swe fill:#3a310a,stroke:#facc15,stroke-width:1.6px,color:#c9cddb
Eleven roles, all played by Claude Code: seven agents, the pilot that drives them, and three headless sessions the console starts to improve the factory itself. Click one to see its model and what it does.
A ticket arrives through pasted URLs or through the file vigie keeps up to date. The console decides when it may start, then opens a Claude Code session in a dedicated worktree.
flowchart LR
sweA("Software Engineer
pastes one or more ticket URLs"):::swe
vigie{"vigie
watches the forge,
writes ticket-proposals.json"}:::script
impl{"impl
starts the console
in the background"}:::script
proposals{"ticket-proposals.ts
reads the proposed tickets
every 5 s"}:::script
source{"ticket-source.ts
resolves each URL
to its checkout"}:::script
sweB("Software Engineer
picks the target repository
when no checkout is found"):::swe
registry{"registry.ts
queue,
one lock per ticket, slots"}:::script
analysis{"schedule-analysis.ts
opens the batch analysis,
outside the run slots, 5 min limit,
validates output.json"}:::script
scheduler["Ticket scheduler
Sonnet"]:::agent
links{"ticket.ts
reads the blocking links
on the forge, kept if
the analysis fails"}:::script
sweP("Software Engineer
dismisses a proposed ticket or
launches a refused one
on chosen checkouts"):::swe
sweC("Software Engineer
forces (base or stacked),
reorders or cancels an entry"):::swe
order{"domain.ts
conflicts, dependencies, start order;
failed analysis or low confidence
keeps a ticket apart"}:::script
impl -- "starts" --> registry
sweA -- "URL" --> source
vigie -- "file" --> proposals -- "tickets" --> source
source -. "no checkout" .-> sweB
sweB -. "target repository" .-> source
source -- "resolved ticket" --> registry
registry -- "2 tickets or more, or a lone one
beside known predictions" --> analysis
analysis -- "batch" --> scheduler -- "overlaps" --> order
analysis -- "links read
beside it" --> links -- "dependencies" --> order
registry -- "lone ticket, no known
prediction: links only" --> links
proposals -. "refused ticket" .-> sweP -. "dismiss, or launch" .-> registry
sweC -. "priority" .-> order
classDef agent fill:#3a2210,stroke:#ff9d3c,stroke-width:1.6px,color:#c9cddb
classDef script fill:#12301f,stroke:#4ade80,stroke-width:1.6px,color:#c9cddb
classDef swe fill:#3a310a,stroke:#facc15,stroke-width:1.6px,color:#c9cddb
flowchart LR
worktree{"run-worktrees.ts
creates the run worktree, copies node_modules
and .env, checks node_modules against the lockfile"}:::script
seed{"runtime-recipe.ts, review-findings.ts
review-guide.ts
restores the recipe, the recurring defects
and the repository's REVIEW.md"}:::script
fixes{"finding-fixes.ts
proposes a source fix when a defect
kind spans enough runs"}:::script
sweE("Software Engineer
accepts or dismisses
the proposed source fix"):::swe
engine{"engine/claude-code.ts
starts claude
in a PTY"}:::script
sweD("Software Engineer
trusts the folder
when Claude Code asks"):::swe
pilot["Pilot /implement
Opus"]:::agent
fixes -- "proposal" --> sweE -. "accepted: written in
CLAUDE.md or AGENTS.md" .-> seed
worktree -- "worktree ready" --> seed -- "recipe, defects" --> engine
engine -. "trust?" .-> sweD -. "accepts" .-> pilot
engine -- "session" --> pilot
classDef agent fill:#3a2210,stroke:#ff9d3c,stroke-width:1.6px,color:#c9cddb
classDef script fill:#12301f,stroke:#4ade80,stroke-width:1.6px,color:#c9cddb
classDef swe fill:#3a310a,stroke:#facc15,stroke-width:1.6px,color:#c9cddb
The pilot owns git and the dialogue with the engineer, and never writes the ticket's code. The review is sized to the diff and to its risk: three tiers, only one with an orchestrator, and every tier is bounded in time (no new round once the review has run as long as the implementation, no single reviewer past about 15 minutes, 10 at tier 0).
flowchart TD p1["Pilot · Opus
1. reads the ticket, Figma,
attachments, lists the gaps"]:::agent swe2("Software Engineer
answers the questions the run
could not settle, if any"):::swe p3["Pilot · Opus
2-3. writes the acceptance criteria,
creates the ticket branch"]:::agent planner["Planner
Opus"]:::agent p4["Pilot · Opus
writes a one-task plan
itself"]:::agent subgraph impl ["Step 5 · one task per agent"] direction TB dev["Dev × N
Sonnet, Opus for an L task
in parallel when files are disjoint"]:::agent gate{"gate.mjs
typecheck, lint, related tests
when the agent stops"}:::script p5["Pilot · Opus
reads gate-log.jsonl, runs the repository
checks, one commit per task"]:::agent dev --> gate gate -- "fail: sent back
once" --> dev gate -- "verdict" --> p5 p5 -- "next task" --> dev end sweQ("Software Engineer
settles a specification
question"):::swe p6["Pilot · Opus
6. starts the app, measures
the change in the browser"]:::agent snap{"code-snapshot.mjs
identifies the code
each piece of evidence measured"}:::script tier["Pilot · Opus
7. picks the review tier
from the diff and its risk"]:::agent subgraph t0 ["Tier 0 · under 30 lines"] direction TB s0["Senior reviewer
Sonnet, one pass"]:::agent q0["QA
Sonnet, focused pass
if the senior corrected"]:::agent d0["Designer
Sonnet, with a mockup
or on a shared UI change"]:::agent s0 -.-> d0 -.-> q0 end subgraph t1 ["Tier 1 · a few files"] direction TB s1["Senior reviewer
Sonnet"]:::agent d1["Designer
Sonnet, with a mockup
or on a shared UI change"]:::agent q1["QA
Sonnet"]:::agent r1["Dev rework
Sonnet, P0 and P1 only"]:::agent s1 --> d1 --> q1 q1 -. "P0 / P1" .-> r1 -. "focused QA pass" .-> q1 end subgraph t2 ["Tier 2 · large diff"] direction TB orch["Review orchestrator
Sonnet"]:::agent s2["Senior reviewer
Opus"]:::agent d2["Designer
Sonnet"]:::agent q2["QA
Opus"]:::agent r2["Dev rework
Sonnet"]:::agent orch --> s2 --> d2 --> q2 q2 -- "P0 / P1" --> r2 r2 -- "2 rework rounds at most" --> s2 q2 -- "review-summary.md" --> orch end accept{"acceptance-runtime.ts
review-confidence.ts
derive the criteria coverage
and the review confidence (0 to 5),
write acceptance-summary.md"}:::script p8["Pilot · Opus
8-9. pushes the branch, opens the MR,
publishes the consolidated review"]:::agent p10["Pilot · Opus
10. final report,
cleans .claude/tasks"]:::agent archive{"evidence-archive.ts
archives the evidence
before the cleanup"}:::script p1 --> swe2 --> p3 p3 -- "complex ticket" --> planner --> dev p3 -- "ticket simple" --> p4 --> dev dev -. "product question" .-> sweQ -.-> dev p5 -- "every task
has its report" --> p6 p6 --> tier snap -.-> p6 tier --> s0 tier --> s1 tier --> orch snap -.-> d0 snap -.-> d1 snap -.-> d2 q0 --> accept s0 --> accept q1 --> accept orch --> accept accept --> p8 p8 -- "open P0 or inconclusive QA:
draft MR" --> p10 p10 --> archive classDef agent fill:#3a2210,stroke:#ff9d3c,stroke-width:1.6px,color:#c9cddb classDef script fill:#12301f,stroke:#4ade80,stroke-width:1.6px,color:#c9cddb classDef swe fill:#3a310a,stroke:#facc15,stroke-width:1.6px,color:#c9cddb
Every tool call of the session goes through the hooks before it reaches the console. The safety rules are decided there, not in a prompt.
flowchart LR session["Pilot and its agents
a tool call,
an agent stop"]:::agent emit{"emit.mjs
receives every hook,
sends it to the console"}:::script guard{"guard.mjs
refuses eight kinds of call: bare agent name, wrong Dev model,
no integration or end-to-end decision, review too early or under the tier floor,
session trailer, published secret, destructive git"}:::script gate{"gate.mjs
typecheck, lint, tests
when Dev and Senior stop"}:::script bridge{"hook-bridge.ts
hooks.ts
applies the event
to the run state"}:::script monitor{"run-monitor.ts
run-health.ts
detects a stalled run,
opens an incident"}:::script artifacts{"artifacts.ts
copies the run documents
into the archive"}:::script usage{"engine/usage.ts
counts the tokens
in the transcripts"}:::script ui{"Next.js console
shows steps, agents,
questions, evidence"}:::script pause{"workflow-state.ts
reads the declared state:
paused takes no slot"}:::script sweP("Software Engineer
asks the pilot to wait, then
resumes the paused run"):::swe sweQ("Software Engineer
answers a question
asked by the pilot"):::swe sweI("Software Engineer
handles an incident,
sends an instruction, stops the run"):::swe session --> emit --> guard guard -- "refused" --> session guard -- "allowed" --> gate gate -- "fail: the agent
goes back once" --> session gate --> bridge --> ui session -. "written files" .-> artifacts --> ui session -. "transcripts" .-> usage --> ui bridge --> monitor --> ui session -. "state: paused" .-> pause --> ui ui -- "paused" --> sweP -- "message" --> session ui -- "AskUserQuestion" --> sweQ -- "answer" --> session ui -- "incident" --> sweI --> session classDef agent fill:#3a2210,stroke:#ff9d3c,stroke-width:1.6px,color:#c9cddb classDef script fill:#12301f,stroke:#4ade80,stroke-width:1.6px,color:#c9cddb classDef swe fill:#3a310a,stroke:#facc15,stroke-width:1.6px,color:#c9cddb
The MR waits for the engineer's review, the queue is released at the merge, and the factory audits itself only when it observed something going wrong.
flowchart LR done["Pilot · Opus
MR open, final report"]:::agent metrics{"run-metrics-runtime.ts
tokens, durations, diff,
review confidence
in metrics.json"}:::script settle{"run-worktrees.ts
removes the worktree when the run completed with a non-draft MR,
the workflow is not blocked, the archive is synced,
the tree is clean and HEAD is on a remote ref"}:::script sweR("Software Engineer
reviews the MR,
merges it or asks for a change"):::swe reopen["Pilot · Opus
reopens the run"]:::agent devR["Dev rework
Sonnet"]:::agent review["Review
at the tier of the new diff"]:::agent watch{"merge-watch.ts
polls the forge every 60 s while
a queued entry waits, then releases it"}:::script queue{"registry.ts
starts the next ticket"}:::script audit{"self-improvement.ts
writes the self-audit,
looks for proof of a defect"}:::script sweF("Software Engineer
leaves feedback
on the run"):::swe improve["Session /improve
Opus"]:::agent rebase["Session /rebase
Sonnet"]:::agent auto{"auto-merge.ts
protected files, 15 files or 400 lines,
deleted or skipped test,
checks rerun by the console"}:::script judge["Session /judge-improvement
Opus, read-only"]:::agent retry{"auto-merge.ts
discards the branch,
feedback back in pending/"}:::script restart{"impl restart
rebuilds and reloads the console
once no run works"}:::script done --> metrics --> settle done --> sweR sweR -- "change requested" --> reopen --> devR --> review --> sweR sweR -- "merge" --> watch --> queue done --> audit sweF --> audit audit -- "incident, failed criterion,
abnormal cost, feedback" --> improve audit -. "nothing observed:
no session" .-> stop(("end")) improve -- "main moved,
git alone cannot rebase" --> rebase --> auto improve --> auto auto -- "passes" --> judge auto -- "rejected" --> retry judge -- "rejected" --> retry retry -. "next run,
2 attempts at most" .-> improve judge -- "merge,
console/ or bin/ changed" --> restart classDef agent fill:#3a2210,stroke:#ff9d3c,stroke-width:1.6px,color:#c9cddb classDef script fill:#12301f,stroke:#4ade80,stroke-width:1.6px,color:#c9cddb classDef swe fill:#3a310a,stroke:#facc15,stroke-width:1.6px,color:#c9cddb