layoutcheck

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package layoutcheck holds the UNIVERSAL visual invariants a layout must satisfy no matter its shape — node boxes must not overlap, a routed edge must not cut through or graze a box it is not connected to, edges must not cross/cover, stub badges and chips must keep clear of boxes, and unrelated boxes must not sit at band rhythm so they read as paired. The fitness corpora assert precise per-shape geometry; these checks catch the combinations no fixture anticipates.

It is a DEBUG VIEW (what is visually wrong with THIS diagram) that doubles as a regression harness when run wide against a baseline — one code path, one vocabulary. cmd-dev/layout-debug exposes both:

layout-debug --in c.ipmt --check                    # one diagram, findings
layout-debug --check --baseline <f> <paths…>        # the ratchet

Everything here is a pure function over layout.Graph or a baseline blob — the CLI owns file IO and the engine run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Categorize

func Categorize(findings []string) [4]int

Categorize buckets findings into the four severity classes the ratchet tracks: {node overlaps, edge-through-node family, edge-edge crossings, badge overlaps}. The through-node bucket is everything not one of the three named prefixes — grazes, false pairings, covers, stubs.

func Findings

func Findings(g *layout.Graph, opts Options) []string

Findings runs every universal invariant over g and returns one string per violation, in a deterministic order. An empty slice means the diagram is clean. The strings are the grep/diff vocabulary — their prefixes drive Categorize, so a new finding phrasing must stay consistent with it.

func FormatBaseline

func FormatBaseline(counts map[string][4]int) []byte

FormatBaseline renders the per-file finding counts as the ratchet baseline file: only dirty files, sorted, four counts then the path.

func FormatTotals

func FormatTotals(files int, counts map[string][4]int) string

FormatTotals sums the per-file finding counts into one summary line. files is the count of files considered; dirty counts files with any finding.

func ParseBaseline

func ParseBaseline(data []byte) (map[string][4]int, []string)

ParseBaseline reads a baseline blob into per-file counts. A record is N leading integer counts (3 legacy, 4 current) followed by a file path; the leading integers are parsed greedily and the rest rejoined as the path, so a path containing spaces survives. Unparsable lines are skipped and returned as warnings (line-numbered) rather than failing.

func Regressed

func Regressed(was, n [4]int) bool

Regressed reports whether current counts n are worse than baseline was, using the lexicographic severity order overlaps[0] > through-node[1] > edge-edge[2] > badge[3]: a file regresses when a worse-severity kind grows, or it ties on all worse kinds and a lesser kind grows. This is the ratchet core; any change to the ordering changes which regressions the CI gate catches.

Types

type Options

type Options struct {
	// LegacyAllEdges counts stubbed (hidden) edges like full edges, as
	// before the visibility-aware metrics — kept for A/B measurement.
	LegacyAllEdges bool
}

Options tune the checks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL