The LSP cornerstone (TODO §6) and the prerequisite for format-off
fences and range formatting. Convention: node span = code extent
(first to last token; attributes included, comments excluded and
carrying their own spans) — chosen because it makes child-nests-in-
parent a total, assertable invariant. Expr became {kind, span};
element structs carry spans; payload structs whose extent equals
their wrapper's deliberately don't (one fact, one place). LineIndex
maps offset <-> 1-based line:col in UTF-8 bytes, with clamping.
A token-level losslessness test asserts every source byte is covered
by token/trivia spans (whitespace aside) and concatenation
reconstructs the input — it immediately surfaced and documented two
pre-existing lexer normalizations (sized-literal tick spacing,
merged same-line trailing comments), both whitespace-only.
Zero behavior change, proven: corpus TSV md5-identical, and QA
diffed formatter output on all 820 corpus files against a pre-spans
worktree binary — no differences. Mutation-tested by dev and QA;
one unpinned span QA found (GenIf content) is now pinned by a
lead-added slice test. 161 workspace tests.
Dev: Opus agent; QA: Sonnet agent; review in
docs/features/spans/README.md.
Co-Authored-By: Claude Fable 5 <[email protected]>