One canonical traversal per tree, not ad hoc recursion.

Canonical walkers (one traversal per tree)

Intent — Give each tree exactly one canonical walker that owns its traversal invariants, and route all traversal through it instead of ad hoc recursion, so those invariants live in one place (our instances: one walker for the PDF structure tree, one for the checking pass, one per Office part: PdfStructTreeWalker, the RuleWalkers, DocxTopLevelPartWalker).

SummaryOne canonical traversal per tree, not ad hoc recursion.
TargetProduct · Canonical models & seams
Formtyped-ir
Movepackage — a constraint shipped with its sensors
Modelis-a-model — a structured model you check a system property against
EnforcementHard (deterministic) · blocking — routed via the model ban-lints; raw recursion / regex-into-tree is banned alongside raw library access
Derivationmodel-from-code — induced from the code, reconciled at build

Its place in the environment — a variant / known-use of One Door Enforced, under CONSTRAIN · Constrain where and how agents act. Preserved here for its technical texture; the construction kit shows how it folds.

Motivation — the failure it kills

Ad hoc tree recursion re-implements traversal at every site, and each copy is subtly wrong in its own way. One misses a node type, another visits in the wrong order, a third forgets link annotations. The same traversal bug recurs per site, and because each is hand-rolled, a fix to one never reaches the others.

Why it's not just "recurse the tree where you need it"

Hand-rolled recursion duplicates the traversal logic, and duplicated logic drifts: the invariants (visit every node type, in the right order, resolving indirect references) get re-derived, badly, at each site. A canonical walker centralizes the traversal so those invariants are fixed once and inherited everywhere. N ad hoc recursions each re-introduce the same class of omission; one canonical walker cannot, because there is only one copy of the traversal to get right. A standard DRY-plus-walker-discipline move, it keeps the structured models usable without re-opening the raw-access door.

Mechanism

Each tree type has one canonical walker that owns its traversal shape: one for the PDF structure tree, one for the checking pass, one per Office part (our instances: PdfStructTreeWalker, the RuleWalkers, DocxTopLevelPartWalker). The canonical-walker discipline routes all traversal through them; regexing into the tree or hand-recursing is banned together with raw library access.

Prerequisites

Consequences & costs

Known uses

Related mechanisms

Governed by

The mechanisms that hold this model true — inverted from their Governs edges at build time, never hand-written. A direct governor names this model; a trunk mechanism governs every model.