Skip to content

Code organization

Use functions in a concept-named module for pure transformations. Use an instance class only when several operations share state, that state has a clear lifetime, and the class protects an invariant.

Current stateful lifetimes:

  • FamilyRegistry: one configured family catalogue;
  • ChannelRoutingSession: one routing run;
  • ClusterLayoutSession: one recursive cluster placement;
  • TreePackingSession: one packing attempt.

There are no static utility classes.

A file owns one concept or algorithm phase—not one helper function and not an entire subsystem. Split when independent responsibilities can be named, tested, or documented separately. Do not split to satisfy an arbitrary line count.

All control-flow bodies use multiline braces:

if (route.points.length < 2) {
return fallback;
}

Subsystem READMEs explain inputs, outputs, phases, invariants, tuned constants, and deterministic tie-breaking. Source comments explain why a rule exists and which visual failure it prevents; they do not narrate syntax.

Move mechanics while preserving geometry first. Change policy separately and review the affected renders. A structural refactor should not require a snapshot update unless it also deliberately repairs an output contract.