ENRU
firm2 · engine 0.4.150 · 8 roles

Eight black boxes

~/firm2 $ cat README_rolescollapsed

What each role takes in and what it gives back. We do not look inside: a role is a subagent with its own context window, and the only things tying it to the route are documents, code, journal events and structured output. Everything below is read off the engine source, not off the design.

Words underlined with dots are defined entities, and they lead to the catalogue. This page introduces no terms of its own.

~/firm2 $ cat four-pages-side-by-sidecollapsed

Four pages side by side

The same machinery, cut in different directions. This page is the cut by role. The start is «The firm2 engine»; why it is built this way — decisions and invariants.

~/firm2 $ cat seven-kinds-of-entitycollapsed

Seven kinds of entity

The colour of the stripe on every input and output card is the kind. Exactly these seven kinds travel the route, and exactly they mark up the catalogue: the kind answers the question «who made this and what holds it up».

DocumentMarkdown in the repository: requirements, specs, tasks, ADRs, dossiers. The truth about tasks lives here (ADR-0001).
Code and testsEdits in the task's worktree. Production code is written only by the Developer, tests only by the Tester.
Journal eventOne file per event in .firm/events/, append-only (ADR-0003, 0006). Written by code, not by the model.
Structured outputJSON against the schema the stage prompt supplies. ASCII keys only — a runtime defect.
Configuration and measurement.firm/config, the board, firm-state findings, the code graph. Computed from the journal on every request.
External systemgit, GitHub/GitLab, the OpenSpec CLI, codegraph, the browser harness. The engine calls them but does not store them.
HumanAnswers to questions through relaying, and the «ok» at a gate. A role has no direct channel to a human.
~/firm2 $ cat three-sessions-and-one-entrycollapsed

Three sessions and one entry

Roles do not live on their own: they are launched by a route command, and during the build by the builder script. The marker FIRM2-TICKET in the prompt is what binds the stage event to the task.

/firm-setup DevOps (preflight mode) Empty repository → git, openspec init, .firm/config, the first commit. On an increment the step is skipped.
/firm-discovery PM → Designer → Architect A topic in its own worktree → a dossier at docs/backlog/G-XXX-<slug>/. It does not create a delivery (ADR-0012).
/firm-plan PM → Architect → Designer Dossier → a delivery in openspec/changes/<change>/, tasks T-XXX.md, a prototype. The finale is the human gate.
/firm-build Developer · Tester · Reviewer · Architect · DevOps · Writer A cycle over tasks in parallel worktrees → merge → spec archive → PR/MR.
~/firm2 $ cat planning-rolescollapsed

Planning roles

These three come before a single line of code. Their output is documents, and it is exactly that which the human approves at the gate.

in
A raw request in the human's own words$ARGUMENTS of the command
Live specs and the glossaryopenspec/specs/ · CONTEXT.md
The topic dossier — during planningdocs/backlog/G-XXX-*/…
Human answers, in roundsthrough the Orchestrator: mode "questions" → SendMessage
Free rule numbersfirm-state next-id --kind br

PM

«What and why», never «how». It runs the interview itself, but the one who asks the human is the Orchestrator: the role has no direct channel.

model
opus
stage
writes no events
techniques
firm-interview, firm-domain-model
without
Edit — does not touch production code
{ mode: "questions"|"done", status: "ok"|"fail",
  groom|change, artifact_path, release,
  br_refs, criteria, open_questions }
fail stops the gate; open_questions go to the human as a list
out
Topic requirements + NFRs + business criteria…/requirements.md (in the grooming tree)
The delivery proposalopenspec/changes/<change>/proposal.md
Business rules numbered BR-Ndocs/product/BRD-*.md
Domain termsCONTEXT.md (maintained together with the Architect)
Questions for the human or «done»structured output, read by the Orchestrator

What it does not do: it does not create the delivery folder (ADR-0012), does not cut tasks, does not design. The folder is created by the Orchestrator before the role is launched.

in
PM requirements and the topic dossierrequirements.md · decisions.md
Live specs, the glossary, ADRsopenspec/specs/ · CONTEXT.md · docs/adr/
The project's current codereading only; makes no edits
The code graphcodegraph map · fn-impact · impact
A QA panel disagreement — at adjudicationthe reviewers' verdicts from the run

Architect

«How». Two stages in one prompt — grooming and planning — plus a third role during the build: the adjudicator, when the QA panel splits.

model
opus
stage
adjudicate (adjudication)
techniques
firm-interview, firm-design, firm-domain-model, firm-docs
hatch
«a section per stage»
adjudication: { verdict: "blocker"|"not_blocker",
  bug_path, notes }
blocker → the task returns to the cycle
out
Decisions and code impactdecisions.md · code-impact.md (grooming)
Technical approach, boundaries, C4 diagramsopenspec/changes/<change>/design.md
Spec deltas with scenarios = acceptance criteria…/specs/*/spec.md
Tasks with labels…/tasks/T-XXX.md: ui, measured, br_refs, parallel_safe, labels
A bug and an ADRdocs/bugs/BUG-XXX.md · docs/adr/
adjudicate: started / finished / rejectedwritten by the hook, from the role

The role has exactly one stage in the journal — adjudicate. During grooming and planning the Architect is called WITHOUT a marker, and the reason is written next to the launch: an adjudicate event during planning would attribute to the delivery a stage that never happened — that is not a hole but a lie, and doctor does not catch lies. Since 0.4.96 this is checked: a call without a marker and without a stated reason is a finding.

Tasks are the load-bearing entity of the route. The label ui: true sends the task to the Designer, high-complexity raises the Developer to opus, short-lane closes the task without test and review if the diff stayed inside the declared paths, security-sensitive switches on the QA panel. The price of each label is on the states page.

in
Tasks with ui: true and their scenariostasks/T-*.md · spec deltas
Terms by grep, not wholegrep -n -i "<term>" CONTEXT.md
A selection of interface standardsfirm-state standards → docs/standards/ui.md
A live harness for measurementthe project's browser_harness; a port cannot be opened inside the sandbox

Designer

One prototype for the whole delivery, and the human needs it at the gate — before development. Shown after the build, it influences nothing.

model
opus
stage
design · marker MR
techniques
calls none
measurement
by running it, not by arithmetic
{ status: "ok"|"fail", artifact,
  screens: [{ task, name }],
  measurements: [{ task, value, how }],
  open_questions }
measurements travel into the task's measured key
out
A list of screens and statesdocs/backlog/G-XXX-*/screens.md (grooming)
A self-contained HTML prototypedocs/design/<change>/ui.html — no network, a section per task
Measurements and open questionsread by the planning team at the gate
design: started / finishedonly during planning (marker MR); during grooming there is no stage event — it is said at the launch

A machine check at the gate: firm-state criteria produces a finding if there are ui: true tasks but no mockup; if the mockup has no section for a task; if the mockup pulls a resource from the network. Judgement about the drawing stays with the human (ADR-0009).

~/firm2 $ cat build-rolescollapsed

Build roles

Three stages of the cycle per task, each in its own worktree. The output schema is set by the builder, the prompt carries the markers FIRM2-TICKET / FIRM2-CHANGE / FIRM2-ATTEMPT, and the stage events are written by runtime hooks — not by the model.

in
One ticket and its criteriaT-XXX.md + the spec delta's scenarios
The standards that bear on this editfirm-state standards --ticket T-XXX
Its own worktree../<project>.worktrees/T-XXX, branch task/T-XXX
The code graph, if the project has one builtthe task tree has no database — said out loud, together with the price of building its own
Review remarks from the previous attemptFIRM2-ATTEMPT in the prompt; the adjudication decision — verbatim

Developer

Implements one ticket and nothing else. Tests are not its business: they are written by the Tester — so that the checker is not the checked.

model
sonnet · opus on high-complexity
stage
dev
techniques
firm-tdd
tree
only its own (I-12)
{ status: "ok"|"fail"|"blocked", task,
  files_changed, ports: [3000],
  escalate: bool, notes }
blocked escalates, fail opens neither test nor review
out
Code in its own branchcommits to task/T-XXX, no git add -A
A declaration of what was editedfiles_changed — the Reviewer checks it against the real diff
Occupied portsthey reach the cleanup after the merge
dev: started / finished / escalated+ abandoned, if the run was taken down

Escalation is a mechanism, not a word in a status. Run into bad architecture or bad requirements — escalate: true, and the task goes to adjudication; patching around it is forbidden.

in
The Developer's ticket, criteria and codethe diff of branch task/T-XXX
Test standardsfirm-state standards → common.md §7
A browser harness and a binarychrome-headless-shell --single-process under the sandbox
A payback analysis of the suitetest-audit.mjs (technique firm-test-audit)
The work map — addresses of the editstaken by the engine before the stage: 36% of the stage's moves went into searching the code
The base's red snapshottaken by the engine; the role did not take it and does not judge the comparison

Tester

Writes and runs tests against the criteria. Does not touch production code — otherwise the difference between «works» and «verified» disappears.

model
sonnet · no high-complexity key
stage
test
techniques
firm-tdd, firm-test-audit
mutations
proves that the test can fail
{ status: "ok"|"fail", tests, ports, protocol,
  report: { total, passed, failed, skipped },
  skipped_why, runs, delivery_red,
  mutation_check: { done, evidence, why_not } }
runs and delivery_red are a presentation of the suite run, not a retelling of it
out
Tests in the task's branchnames — in the words of CONTEXT.md
A run report and a mutation checkproof that the test can fail
test: started / finishedthe stage output travels into the event's notes
guard/test_criteria when a check is removeda mark without a reason — the guard refuses

A long run is carried by the engine, not by the role. A 10-minute call ceiling against a 43-minute suite is not cured by asking: the run is started and awaited by a separate command, and the end of a stage while a run is going is written as the event guard/suite-abandoned and returns the role to work. A run is presented not in prose but by an identifier and an exit code.

in
The artefact and the criteria — no correspondenceindependence from the Developer
The task diff, taken by the enginenot the role's retelling: it judges by files
Standards files and the lint policydocs/standards/* · lint-policy.md
The board — for other tasksfirm-state board --json (the task file is a cache)
Running the tests and the linter by handBash for reading/running; no Write/Edit

Reviewer-QA

The supervisory layer: «was it done right». A sceptic — on reasoned doubt it rejects. On a risky task a panel is assembled.

model
opus by the role · sonnet in the example config
stage
review · MR review with the MR marker
techniques
firm-research, firm-test-audit, firm-review, firm-verify
base
judges from the branch point
{ verdict: "accepted"|"rejected",
  escalate: bool, criteria_results, notes }
the verdict certifies content: the event carries the tree's fingerprint (ADR-0013)
out
review: accepted / rejected / escalatedthe verdict is taken from the role's structured output
Remarks along the axesSpec · Standards · security · adequacy of the tests
A comment in the PR/MRgh pr comment · glab mr note
An acceptance receiptthe task tree's fingerprint in the event

What it does not do: it does not fix code — the role has neither Write nor Edit. An axis for which the project has no written file is declared unchecked: a skip named a skip costs dearly once; named a pass, it costs every time afterwards (ADR-0007).

What was taken away from the role. Attributing a new red to the task — a comparison of three lists, two of which the role did not take — is computed by the engine before the review stage: a proven guard/new-red returns the task to work without opening a review. This is not a ban in words but a withdrawn assertion.

~/firm2 $ cat closing-and-framing-rolescollapsed

Closing and framing roles

These two work not with a task but with the whole delivery — which is why they have no ticket, and the prompt says FIRM2-TICKET: MR.

in
The active delivery from the CLI, not from a pathopenspec list --changes --json
Spec deltas and delivery documentsproposal.md · design.md · specs/
The demo gate's «ok» and a green delivery reviewarchiving earlier is not allowed

Technical writer

Closes the delivery documentarily: an immutable snapshot of the spec into the archive, the deltas into the live specs, and the human layer separately.

model
sonnet
stage
docs · marker MR
techniques
firm-docs, firm-human-docs, firm-domain-model
archive
append-only
{ status: "ok"|"fail", archive,
  live_specs_updated: bool,
  validate_specs_ok: bool, human_docs }
a fail or red specs — the merge does not go
out
A spec snapshot in the archiveopenspec/changes/archive/YYYY-MM-DD-<name>/
Updated live specsopenspec/specs/ — read by the Reviewer, not by a human
Human documentation by Diátaxisdocs/ — why the system, how to get a thing done
docs: started / finishedsince 0.4.94
in
Project configuration.firm/config: vcs.host, stack, worktrees_dir
The mode and its recipe$ENGINE/templates/devops-modes.md · definition-of-done.md
A schema from the builder — a different one per callten schemas: PREPARE · LANE · DIFF · WORKMAP · TRUNK · RECORD · MERGE · PAUSE · SETTLED · LEFTOVERS
git and the hostworktree, merge · gh / glab by vcs.host

DevOps

The engine's most frequent role: sixteen call sites in the builder plus the framing of the delivery — preflight at the start and packaging at the end.

model
haiku
stage
has none of its own; writes events itself
techniques
calls none
calls
tree · diff · map · lane · base · journal · merge · pause · cleanup
closing: { status: "ok"|"fail"|"blocked",
  mode: "pr"|"local", mr_url, suite_run,
  dod: { checked, failed }, build_report }
local — no PR was opened, and that is said out loud
out
Worktrees and mergesworktree add · merge task/T-XXX → feature/<change>
Events written by a commandfirm-event record: merge/finished, merge/failed, guard/short-lane
The task diff and the work maptaken by the machine, they travel into the review and test prompts
A PR/MR with a report and linksgh pr create · glab mr create
The project skeleton and the command allowlistpreflight and scaffold: git init, openspec init, .firm/config

The price of visibility: mechanical calls write no events, so the token accounting on the dashboard is understated — about five prompts per task never reach it. That is a choice: journalling them would double the journal for the sake of intervals that contain no decisions.

~/firm2 $ cat entity-to-role-where-the-cuts-meetcollapsed

Entity → role: where the cuts meet

This page is cut by role, the catalogue by things, and at first glance one should lie neatly on the other. It does, exactly up to the middle, and that is the most interesting thing in the table: documents and code have a role as their author, while events, projections and receipts have no role-author at all. They are created by code, and that is precisely why they are believed.

EntityCreated byRead byWhere it lives
Topic dossier PM, Designer, Architectthree stages into one tree the human; PM and Architect during planning docs/backlog/G-XXX-*/
Spec delta Architect Developer, Tester, Reviewer, Technical writerits scenarios are the acceptance criteria changes/<change>/specs/
Task Architect all build roles and the builder itselfthe task's labels decide whom to call and on which model changes/<change>/tasks/
Prototype Designer the human at the gate — before development docs/design/<change>/
Task code Developer Tester, Reviewer branch task/T-XXX
Tests Tester Reviewer, DevOps during packaging the same branch
Standards the human and the project, not a role Developer, Tester, Designer, Reviewernot whole: the engine selects by the diff docs/standards/
Verdict Reviewer, Architect at adjudication the hook (which turns it into an event), DevOps before the merge, the builder structured output → event
Bug Reviewer, Tester, Architect Architect, the human, doctor docs/bugs/
Spec archive Technical writer search across closed deliveries changes/archive/
PR / MR DevOps Reviewer (a comment), the human GitHub or GitLab
Event code: subagent hooks, the git hook, record, the guards all projections .firm/events/
Task diff and work map code (through a DevOps call) Reviewer and Tester — in the stage prompt not stored
Red snapshot code (through a DevOps call) the new-red gate; the Reviewer sees the gate's state not stored
Board and statuses code, from the journal on every request the builder, the Reviewer (about other tasks), the human not stored
Receipt code: the tree's fingerprint in the acceptance event the guard before the merge — a verdict issued to another tree will not pass a field of the event

What follows from this. A role is the author only where judgement is needed: requirements, task cutting, code, tests, a verdict. Everywhere a fact is needed — what exactly changed, what was red before, who accepted what, what it cost — there is no role-author and there must be none: those are exactly the assertions a role can neither carry out nor measure. Hence the boundary in the catalogue too: for half the entities the answer to «who creates it» is not a role but the name of a script.

~/firm2 $ cat who-actually-writes-eventscollapsed

Who actually writes events

No role writes an event itself — that is a load-bearing part of the route (ADR-0002). The model returns structured output, and the event is made out of it by code.

WriterWhenStagesBound by
The SubagentStart / Stop hookthe stage is derived from the agent type the start and finish of any role in the table dev · test · review · adjudicate · design · docs the FIRM2-TICKET marker in the prompt; for a delivery — MR
The git hook post-mergea step inside the engine can be bypassed, the hook cannot a task merge and a delivery release merge · release the second parent of the merge commit (ADR-0005)
firm-event recordthe boundaries the hooks cannot reach the human gate, a manual merge, cancelling a task demo · gate · lifecycle · merge/failed --ticket is mandatory; the stage name is checked against a dictionary
The PreToolUse guardscannot be bypassed: refusal before the tool runs an attempt to do something forbidden guard the task tree or the branch; without a ticket — the label MR
~/firm2 $ cat guards-the-eighth-participant-with-no-promptcollapsed

Guards: the eighth participant, the one with no prompt

Guards stand on PreToolUse and answer with a refusal before the tool has run. That is why they are the only part of the route that does not depend on whether a role read its prompt.

GuardWhat it catchesEvent
write-guarda write outside its own worktree and into the project's shared householdrefusal
bash-guardlifting the sandbox from a task treeguard/sandbox-off
secret-scana secret in a commit or in a fileguard/secret
test-criteria-guardremoving a criterion check without a stated reasonguard/test_criteria
review-receipta merge on a verdict issued to another treeguard/review-stale
egresssending outward — a receipt in the journal (ADR-0014)guard/egress
pausestarting a new task while a pause is in forceguard/pause-held
~/firm2 $ cat what-is-not-on-this-diagramcollapsed

What is not on this diagram

Four things without which the picture would be more convenient and less true.

The contents of the boxesEvery role has its own context window, and it is not a continuation of the session's window: they cannot be added into one number.
Derived stateTask statuses, the board, the dashboard and doctor are stored nowhere — they are computed from the journal on every request. Exactly how — seven steps on the states page.
The conversation with the humanA role's questions and the human's answers go through the Orchestrator and never reach the journal; only the gate intervals remain in it.
The engine's preflight and its stepsThe preflight checks stand on the delivery of the ENGINE, not on the project's route: not one of them runs at any stage of a run. That is a different plane — who releases firm2, not how firm2 runs a delivery.

Where the numbers come from. The formal half of this page — models, tools, stages, call schemas, output keys, techniques and templates — is read off the source by node firm2/scripts/roles.mjs --json; a divergence between a call schema and a role's prompt is caught by the preflight (step 3у), so the page does not go stale silently. The rest — the input cards, the wordings, the «entity → role» map and this section — is judgement, and nothing derives it.