ENRU
firm2 · reference

Decisions and invariants

~/firm2 $ cat README_decisionscollapsed

Fourteen hard-to-reverse decisions and fifteen statements that must hold at all times. This is the answer to «why this way and not otherwise» — and the only place it is written down: the code merely carries the decisions out.

You may depart from them, but deliberately: first the decision is amended, then the code — never silently the other way round. An invariant is not amended at all; it either holds or is broken, and each one names the price of breaking it.

~/firm2 $ cat §1-fourteen-decisionscollapsed

§1Fourteen decisions

A decision lands on this list when undoing it costs more than making it: it changes the shape of the log, of access rights, or of delivery. Each one lives in its own file together with the rejected alternatives — here you get only the decision itself.

Eight of them (0004…0010) were written after the first live runs: the decisions already existed in the code as comments, but not as decisions, and there is no arguing with a comment.

~/firm2 $ ls docs/adr/

0001Truth about tasks lives in repository files; the board is read-only0001-состояние-в-файлах… 0002Status transitions are written by orchestrator code, not by hooks0002-события-пишет-оркестратор… 0003One file per event instead of a shared log0003-один-файл-на-событие… 0004An event is bound to its task by a marker in the prompt, not by an agent id0004-привязка-события… 0005«Merged» is confirmed by the merge commit's second parent; unconfirmed means no event0005-признак-влито… 0006The log is append-only: a correction is a new event, a cancellation is its own outcome0006-журнал-только-дописывается… 0007Uncertainty stops the action and demands a question0007-неопределённость… 0008The plugin version is the delivery mechanism, and delivery goes through the preflight0008-версия-плагина… 0009The engine does not close someone else's stage and does not spend someone else's time0009-движок-не-закрывает-стадию… 0010Engine code has no external dependencies; checking tools live in development only0010-движок-без-зависимостей… 0011A skill-wrapper isolates an external skill; a native one is for when there is nothing to isolate0011-приём-изолирует-скил… 0012Discovery does not materialise a delivery: grooming ends with a dossier in the backlog0012-разведка-не-материализует… 0013A review verdict is bound to the tree fingerprint, not to the ticket alone0013-вердикт-привязан-к-отпечатку… 0014Sending outside leaves a receipt in the log, and the chain is counted per task0014-расписка-об-отправке…
A decision and a rule are different things, and you can tell by how they break. A rule is broken once at a time and repaired with a prompt. A decision taken wrongly breaks everything standing on it — which is why each file records the rejected options and the argument against them. The most expensive lesson of these fourteen is 0005: «merged» used to be established by a role's word, and a false «merged» made the next run skip the task as done.
~/firm2 $ cat §2-fifteen-invariantscollapsed

§2Fifteen invariants

An invariant is a statement about the route, numbered so that code and defect write-ups can refer to it. They turned out to be needed not for rigour: three defects in a single day were mistakes in the language, not in the code — «merged», «abandoned» and «event time» did not mean what the code thought they meant. Until the words were defined, there was nothing to argue about in the implementation.

They are held by tests and preflight steps, and six of them are checked against live data as well — doctor looks for violations in a project's log.

~/firm2 $ grep -n 'I-' docs/domain-model.md

№StatementWhat holds itPrice of breaking it
I-1A task's status is derived from events only; the front matter is a cachestatusFromEvents, ADR-0001two sources of truth drift apart, the board lies
I-2The log is append-onlyADR-0006, the --corrects flaghistory is rewritten, and the defect write-up rests on fiction
I-3One event, one fileADR-0003a merge conflict on every parallel commit
I-4A task merge is confirmed by a merge commit whose second parent is the tip of the task branch; unconfirmed means no eventreconcileMerges, ADR-0005a false «merged»: the next run skips the task as done
I-5An event's time is the time of what happened, not of when it was writtenwriteEvent, the --ts flagdelivery timing stretches over hours of waiting
I-6All times are UTC with a ZwriteEventevent order breaks, intervals turn negative
I-7An event with no ticket binding is a gap, not a normthe prompt marker, ADR-0004the stage is invisible to the board, to timing and to doctor
I-8A slot is held by a task, not by an agentcomputeBoardthe parallelism ceiling stops limiting anything
I-9A stage writes only into its own worktreewrite-guard.mjsedits from two tasks get mixed together in the main tree
I-9aA merge or release event belongs to the branch, not to the tree: it is written where that branch is checked outjournalRootForrecords go to a branch they do not belong to and arrive nowhere — that is how 35 release events once went to an already dead delivery branch
I-10An archived spec snapshot never changestasksDira closed delivery loses its history
I-11The engine does not close someone else's stage and does not spend someone else's time; but any recorded outcome closes an interval in the timingADR-0009, timingan invented «finished» damages the timing more than an open interval does
I-12Uncertainty stops the action and demands a question: the unproven is neither done nor logged, but it is always named to the humanADR-0007either the engine confidently does the wrong thing, or it freezes in silence — and silence is indistinguishable from work
I-13A verdict certifies content: the acceptance event carries the tree fingerprint, and only an accepted tree may be mergedADR-0013, review-receipt.mjscode the review never saw ships into the delivery — and counts as accepted
I-14Sending outside leaves a receipt, and one task's receipts are chained by hashes — as a tree, not a line: one receipt may have several successorsADR-0014, egress.mjsthe question «what left the project, and when» has no answer, and a deleted receipt is indistinguishable from a send that never happened
Why I-9 has an «a» rather than the number 10. The invariant was written after the others, and the numbers are cited in code and in write-ups — shifting them would mean rewriting every reference. A letter is cheaper: it says «this refines the ninth», and no old reference breaks. The same move by which the log is append-only.