Documentation
¶
Overview ¶
formwork-anchor-census — no `go/per-func-count-relation` arm may go unanchored: it must declare either the funcs it applies to or the side of the relation that constrains.
Usage: go run -C tools/formwork-anchor-census . <repo-root>
Product enforcement is formwork type:command (.formwork/rules/count-relation-arm-is-anchored.yaml) with origin on this file. Exit 0 = no unanchored arms, 1 = offenders listed, 2 = usage/env error.
The hole ¶
A name-anchored rule that skips whatever its anchor does not match, and then reports nothing, cannot tell an empty anchor set from full compliance. The rule passes its fixture, somebody renames the subject for an unrelated reason, and the invariant is retired with no signal — a gate that is green because it can no longer see its own subject, which is worse than a missing gate because the dashboard says the invariant is held (#10517).
The ENGINE closes that for the anchors it can see. `go/call-order-in-func` and `dart/method-delegates` take their anchors as REQUIRED params, so an arm of those types cannot exist without one and the engine's scope-wide existence verdict covers every arm by construction — a census over them could never fire and would be vacuous. `go/per-func-count-relation` is the one type an author can leave genuinely unanchored: `funcs:` is optional, and an arm without it constrains only through its `left`/`right` selectors, where `count(left) <= count(right)` holds vacuously at 0 <= 0. Rename the left symbol and the arm goes silent exactly the way a renamed func does.
The engine cannot infer the symbol assertion, which is why it is the opt-in `require_symbol:` and why this census exists to make the opt-in mandatory. Absence is sometimes the COMPLIANT state: the forbidden-call-in-func idiom (`funcs:` plus a banned `left:` and a never-matching `right:` sentinel at `relation: <=`) is satisfied precisely by `left` matching nothing. Which side constrains is the author's judgment, so it has to be declared.
The detector ¶
The engine's scanner skips .formwork (spec §11), so no declarative rule can read the rule corpus — that is why this is an external tool like the vacuity census and the universal-cure census, not a forbidden-pattern arm. Per rule file, an arm FLAGS when its `type:` is `go/per-func-count-relation` and its `params:` block carries neither `funcs:` nor `require_symbol:`. Both halves are arm-local, and the anchor keys must sit in the arm's own params block — not in a comment, not in a sibling arm — so the params block is walked explicitly rather than the whole arm text. Block and flow mappings both occur in the corpus (`params: {left: X, right: Y, relation: <=}`), so both are parsed.
Known debt ¶
First-run census (2026-07-29): NONE. All eleven pre-existing unanchored arms were cured with `require_symbol: left` in the change that installed this ratchet, so #15103 ABOLISHED the known-debt list: every unanchored arm is a finding and there is nowhere to record an exception.