ENRU
firm2 · reference

States and labels

~/firm2 $ cat README_statescollapsed

The engine's four status models, the full list of stages and outcomes, every task label with its price, and the table of models per role. One page for questions of the kind «what is happening to this task» and «what will this word in the card cost me».

The lists are taken from the code, not from the documentation: STAGES, EVENT_KINDS, GROOM_STATUSES and statusFromEvents in scripts/lib/firm.mjs, label parsing in workflows/firm2-build.js.

~/firm2 $ cat §1-task-statuscollapsed

§1Task status

The main thing about it is not in the list but in a single property: status is not stored. It is derived from the log, recomputed from scratch every time; what sits in the card's front matter is a cache, and a drift between runs counts as normal, not as an error. You cannot fix a status by fixing the header: the next reconciliation overwrites it with whatever follows from the events.

todo ready in_progress in_test in_review accepted merged released rework blocked superseded cancelled dependencies closed dev/started test/started review/started review/accepted merge/finished release/finished guard/short-lane — test and review never opened dev/started — attempt +1 superseded cancelled review/rejected escalated — from any stage arbitrated cycle from the top
Two transitions on this diagram are made by computation, not by an event: todo → ready means the dependencies are closed, not a record in the log, and the task then waits for a free slot. Everything else arrives as events, and three of them have twins: adjudicate/accepted and adjudicate/rejected behave exactly like the reviewer's decisions, because the state of the task does not depend on who decided.

How it is computed — seven steps

This is the whole algorithm: statusFromEvents plus two statuses filled in by computeBoard. Nothing beyond the log and the depends_on field in the cards affects the status.

  1. Take the events of this task — those whose ticket equals its number — across the whole delivery. Broken files (_broken) are skipped: a log entry that failed to parse must not move the status silently.
  2. Walk them in chronological order with the status as a variable. Each event either assigns it a value or does not. The last word wins: the order of events is the order of decisions.
  3. Three events do not move the status at all. paused and resumed are facts about the run, not about the task (they are written with ticket: MR); an unknown event also passes by rather than resetting anything.
  4. Two events reset the status to «not started»: abandoned (the stage was dropped) and arbitrated (the escalation was resolved). Not «the previous status» but empty — the next run takes the task from the top of the cycle.
  5. Attempts are counted by a separate counter, not by the status: exactly as many as there are dev/started events over the task's whole life. So neither a dropped stage nor a resolved escalation grants a free extra attempt.
  6. If the status is still empty after the walk, the board fills it in, and no longer from the log: an unclosed dependency means todo, none means ready. These two statuses are not in the events and cannot be.
  7. The computed value is compared with the status field in the card header. If they differ, the task raises cache_stale, and the computation wins: the header is a cache here, not the truth (ADR-0001).
StatusWhat it meansHow it is derivedWhat ends the wait
todoWaiting on a dependency: something earlier in the order is not merged yetNot an event but a computation: the status is empty after the walk and depends_on still holds an unclosed task. Only merged or released counts as closed — a withdrawn dependency (superseded, cancelled) does not release it from todo, it has to be re-pointed at the replacementfinish the predecessor
readyReady to work, waiting for a free slotThe same computation, but with all dependencies closed. The «waiting for what» note is added separately and differs: parallel_safe: false with any slot taken means «waiting to run alone»; otherwise it is an exhausted parallelismraise parallelism or wait
in_progressThe Developer writes code in their own worktreedev/started (which is also +1 to the attempt counter) or dev/finished. The end of the development stage does not change the status: the task stays in progress until the test picks it up—
in_testThe Tester writes and runs teststest/started or test/finished — for the same reason—
in_reviewThe Reviewer-QA judges against the criteria; on a risky task, a panel of threereview/started. A panel of three reviewers produces three such events and one status — it is about the task, not about the stage—
reworkRejected, the task is back in workreview/rejected or adjudicate/rejected: adjudicating a split panel continues the review, it is not a separate outcome, and it was deliberately given no status of its ownthe next attempt, if any are left
acceptedAccepted, but not merged yetreview/accepted, adjudicate/accepted, guard/short-lane — and also merge/failed if no merge preceded it: a refused merge returns the task to where it was, because what changed is the state of the delivery, not of the taskthe merge; if it hangs, check doctor
mergedMerged into the delivery branch — proven by the merge commit's second parentmerge/finished. The only status protected against write order: a merge/failed appended after a merge actually happened does not un-merge it — «merged» is proven by the merge commit's second parent, not by the log's last word (ADR-0005)—
releasedShipped in a releaserelease/finished — written by the post-merge git hook on a merge into main—
blockedEscalation: a role hit a wall and stopped honestly, or the attempts ran outAn escalated event from any stage: what matters is the outcome, not who returned it. That is why it has no «stage/outcome» pair — a single name is checkedarbitration — the human decides
supersededWithdrawn and replaced by other taskslifecycle/superseded. Terminal human decisions need no protection against order: they come last in time and win on their own—
cancelledWithdrawn without replacementlifecycle/cancelled — the same thing, without a replacement—
«Closed» and «do not hand to the run» are different sets, and blocked lives between them. There are four closed statuses: merged, released, superseded, cancelled. An escalated task is deliberately not among them: for the cycle it is terminal, for the calendar it is not — a human will untangle it and it will come back (arbitrated). So «who not to hand to the run» is computed not as a second list but from the first one plus blocked. The drift between these sets has already cost a measurement: while superseded was missing from «closed», the plan form counted waves over withdrawn tasks and overstated their number by the number of replacement generations — and that was the number a human used when raising parallelism.
~/firm2 $ cat §2-topic-statuscollapsed

§2Topic status

Discovery has its own model, and it carries a distinction that is easy to lose: the status is declared by the human, the state is derived by the engine from git. «Groomed» is a decision, «the tree is alive» is a fact, and the two must not be glued together. So the engine does not edit the status itself; it names the discrepancies between what was declared and what is.

StatusWhat it meansWhat the engine checks
groomingDiscovery is underway: branch groom/G-XXX-<slug> and a sibling tree existno tree, but the status says «in progress» — there is nowhere to continue grooming
groomedThe dossier is ready and sits in the backlog; the topic waits to be chosen by a human — for as long as it takesdeclared groomed, but there is no dossier directory
plannedA delivery has been opened for this topicalready in planning while the grooming tree is still alive — remove it once the work is merged

Separately the engine catches a topic created around groom new: the number is taken — it appears in a branch or in a directory — but there is no record for it. Such a topic is invisible in the list, discovery stages will not bind to it by marker, and it will not appear in the cost measurement. The engine will not reuse the number anyway, but it will not stay silent about it either: that silence is exactly how two numbers once ended up on two topics each.

~/firm2 $ cat §3-bug-statuscollapsed

§3Bug status

The only model where the status is stored in a file rather than derived: a bug is a separate aggregate and the log knows nothing about it. The links are one-way — a bug has fix_task and tickets, a task has no links to bugs.

StatusWhat it means
openFiled, no fixing started yet
fixingA fix task exists and is in progress
resolvedFixed
deferredDeliberately deferred — we will fix it, but not now
wont_fixDecided not to fix. The record stays anyway: the trace of a defect must outlive the decision about it
~/firm2 $ cat §4-stages-and-outcomescollapsed

§4Stages and outcomes

These two lists multiply out into the language of the log: an event is a stage/outcome pair plus a ticket and a time. The stage name is validated on write, so the vocabulary can no longer fall behind life in silence — record used to accept any name, and the stage gate sat in the log for a year without existing in the code.

Thirteen stages

StageWhose workAbout what
devDevelopercode against the criteria
testTestertests and the run
reviewReviewer-QAverdict against the criteria
adjudicateArchitectarbitration when the QA panel splits
designDesignerthe delivery prototype
docsTech writerspec archive and living documentation
mergeengine codemerging the task branch into the delivery; written by a git hook
demohumanthe demo gate
gatehumana gate inside the task: approving content without which the stage does not proceed
releaseengine codereleasing the delivery
lifecyclehuman, Architectthe fate of the task: superseded, cancelled, returned from escalation
guardengine codea guard fired: short lane, new red, abandoned run
groomPM, Architect, Designerdiscovery of a topic — one stage for three roles, so that it can be measured as a whole

Thirteen outcomes

OutcomeWhat it asserts
startedthe stage began
finishedthe work is done
acceptedaccepted
rejectedrejected, back to work
escalatedthe role stopped honestly: a dead end, a decision is needed
arbitratedthe escalation was resolved, the task returns to the cycle
faileddone and did not pass — a refused merge, for example
abandonedthe stage was running and was cut short: the run was killed, there will never be a finish
supersededthe task was replaced by others
cancelledthe task was cancelled
retractedthe earlier event never happened — it was written by mistake
pauseda human stopped the run
resumeda human resumed the run
Three outcomes are kept apart deliberately, and every distinction was bought with a defect. finished — the work is done; failed — done and did not pass; abandoned — never done at all. You may not invent a «finished» in place of a dropped stage: the timing would get an interval of work that never happened, and that is worse than a gap — it is a lie instead of a gap. retracted stands apart: it adds nothing to the state, it only names the file of a wrong event so that it falls out of the computation. An error cannot be fixed by an event «of the same kind» — a second merge/finished is still one more «merged».
~/firm2 $ cat §5-task-labelscollapsed

§5Task labels

A label is an inline tag at the end of a task line that switches build mechanics. The most expensive words in the whole card live right here: two labels turn on a panel of three reviewers for every attempt, and one of them also raises the Developer to Opus.

LabelWhat it turns onPrice
high-complexity The Developer runs on Opus instead of Sonnet, and the review is carried by a panel of three independent voices. With the tester_high_complexity key filled in, the Tester is raised too the most expensive label: triple review on every attempt plus a strong model on development
fact-sensitive A panel of three reviewers and a fact check ×3 on the review stage, every attempt
security-sensitive A panel of three and a mandatory security axis in the verdict. It cancels the short lane — when both are set, security wins ×3 on review
short-lane Test and review never open at all if the task's real diff stayed inside the short_lane.paths from the config. The diff is checked by the engine, not by a role; the event is guard/short-lane saves two stages. Without the short_lane.paths key the label does nothing, and the engine says so
needs-browser The task's criteria can be closed only by a live run in a browser, a skip does not count. The planner schedules such a task ahead of equally ready ones: its tail determines the end of the whole run needs a harness in browser_harness, otherwise every task writes its own scaffolding again

Card fields that also change the route

FieldWhat it does
ui: trueThe task goes into the Designer's prototype. If there is not a single one, the design step is skipped entirely
parallel_safeWithout it the task runs alone: while others are in progress, it waits. It may be skipped in favour of the next ones — otherwise slots sit idle for nothing
depends_onDependencies, explicitly; the order of lines in tasks.md means the same thing and is read by the planner top to bottom
superseded_byA link to the replacements. This is a link, not a status: the status comes from the lifecycle/superseded event
A label without a measurement is taste. The engine checks this on itself too: a threshold is expressed in what was measured, and a plausible-sounding reason in a prompt teaches a role to guess instead of reading. So when you set high-complexity, you should be able to say what the complexity is confirmed by — otherwise the label just multiplies the bill by three.
~/firm2 $ cat §6-models-per-rolecollapsed

§6Models per role

A role's model is declared in its own description and overridden by the project — in the models section of .firm/config. That is how a project raises or lowers one specific role without touching its general prompt. A missing key or inherit means «the role runs on its own»; an unknown value is discarded with a warning, so that a typo does not turn into an API refusal halfway through a build.

So «by default» means two different defaults, and in one row they disagree. The shipped firm-config.example leaves the PM, the Architect and the Designer on inherit and sets the model explicitly for the rest — and gives the Reviewer sonnet where the role itself declares opus. A project that copied the example gets sonnet; a project with no models section gets opus.

RoleDefaultConfig keyWhy
PMopuspmtalking to the human, and requirements
Architectopusarchitectslicing and arbitration — the most expensive mistakes on the route
Designeropusdesignerone prototype for the whole delivery
Developersonnetdeveloperthe bulk of the work
Developer on high-complexityopusdeveloper_high_complexityan engine rule, not a setting: it applies even when there is no models section at all
Testersonnettestertests for code already written
Tester on high-complexityno keytester_high_complexitythe absence of a default is deliberate: without a key nothing gets more expensive in silence. The argument for setting it — the checker should not be weaker than the checked where complexity is declared explicitly
Reviewer-QAopus by the role, sonnet in the example configreviewer_qathe only role where the declared and the shipped differ on purpose — a money decision taken with open eyes: on a risky task the review is carried by a panel of three on every attempt, and the verdict is given against explicit criteria rather than by taste. A delivery where the cost of a mistake exceeds the cost of a run raises the key back to opus
Tech writersonnetdocwriterthe archive and the living documentation
DevOpshaikudevopsdeterministic commands; measured on both haiku and sonnet — no difference

The value may be an alias (opus, sonnet, haiku), which the runtime resolves to the current version, or a full model name, which pins the role to a specific one. The Developer's escalation on high-complexity is the only place where the engine raises a model by itself: that has been its rule from the start, everything else is the project's choice.