Browse the documentation
Contract: the assembly gate
Label: specified (rules), implemented (in src/gate.mjs).
Shape
assemblyGate({ validation, verdicts, planId, planDigest?, knownPlanIds? }) → { permitted, held, validation, ledger, verdict }
The gate’s one question
Is automatic assembly of this plan permitted? The answer is composed from the validation and the verdict ledger, in a fixed order:
| Order | Condition | Held reason |
|---|---|---|
| 1 | validation.ok === false |
plan-invalid |
| 2 | the verdict ledger is unsound | ledger-unsound |
| 3 | no verdict exists for the plan | awaiting-verdict |
| 4 | a planDigest was given and the latest verdict names a different one, or none |
review-stale |
| 5 | latest verdict is revise |
revisions-requested |
| — | none of the above: valid plan, sound ledger, latest verdict approve (of this exact version, when a digest was given) |
(permitted) |
The held reasons are closed and exported in this order as HELD_REASONS.
Why the order is the order
- Deterministic outranks judgment. An invalid plan is held even when a reviewer approved. The rule pack’s rejection cannot be overruled by a pen, and this ordering is what makes that principle structural rather than aspirational.
- Judgment counts only from a ledger the gate can trust. The gate checks the whole ledger with the verdict contract’s soundness rules before it reads any verdict. One malformed record anywhere, such as an approval with no judge or a revise with no reason, makes the ledger unsound and holds the gate. When
knownPlanIdsis given, a verdict naming an unknown plan, or a gatedplanIdthat is not itself known, is also unsound. WithoutknownPlanIdsthe gate checks record well-formedness only. - Unreviewed never self-assembles. A valid plan with no verdict waits. Silence is not approval and absence is not consent.
- A review covers the version it read. Given the plan’s
planDigest, the gate holds asreview-stalewhen the latest verdict for the plan names a different digest or none. A step added, removed, or retitled after review changes the digest, so the old approval no longer opens the gate. The latest verdict still counts: a later review of another version leaves this version stale rather than reaching back to an older approval. WithoutplanDigestthe gate does not check versions and answers as before. - Revise is a stop, not a pause of opinion. The latest revise verdict holds assembly until a new proposal earns a new verdict. The title of the held reason names the path out: the revisions were requested, so make them.
Output semantics
permitted: truemeans the two lanes passed over a sound ledger: valid, approved. Nothing more.permitted: falsealways carries aheldreason from the table above. There is no naked refusal.- The gate returns the validation, the ledger soundness result (
{ ok, errors }), and the latest verdict alongside its answer, so a caller never re-derives what the gate already judged. - When the ledger is unsound,
verdictisnull: a verdict from an untrusted ledger is never surfaced as the answer.
Prohibitions
- The gate never ratifies. Permission to assemble is not owner assent; effects exceeding the plan’s scope route the owner’s gate in the harness.
- The gate never judges content. If the rule pack and the reviewers both passed it, the gate opens whether or not a third party would have preferred different work.
- The gate never mutates its inputs. It composes; it does not rewrite the ledger or re-validate with different rules.
Changes
0.2.0— the gate checks ledger soundness, adding held reasonledger-unsound(order 2), the optionalknownPlanIdsinput, theledgeroutput, andHELD_REASONS. Before0.2.0the verdict contract said an unsound ledger is refused by the gate, but the gate read verdicts unchecked, so a hand-built approval with no judge could permit assembly. Gate answers over ledgers built withverdictRecordare unchanged. A caller that matches onheldvalues should handle the new reason.0.3.0— the optionalplanDigestinput and held reasonreview-stale(order 4). A malformedplanDigestis refused with an error. WithoutplanDigest, answers are unchanged. A caller that matches onheldvalues should handle the new reason.