latex-ast-stage2
The groupant beside latex/src/ast.rs in the Mova repository: what the code computes, what it never does, how to go back from its outputs, its invariants, cost and checks.
Facts
Implementation material. A Mova code model describes this code at one source revision: partial models, finite checks and their stated scope. It is not a reviewed general exposition, and its labels are shown as written, never raised.
Components
| component | label | where |
|---|---|---|
| approximant | partial | approximant |
| ast | partial | ../syntax.json |
| composition | partial | composition |
| descriptant | present | descriptant |
| invariant | partial | invariant |
| tests | executed bounded checks | tests |
Obernants
The typed relations around the forward model: the behaviour complement (what the code never does), the reverse reconstruction (every input compatible with an output) and specialised views.
| id | type | label | where |
|---|---|---|---|
behavior_complement | behavior_complement | partial source derived model | behavior_complement |
reverse_reconstruction | reverse_reconstruction | partial source derived model | reverse_reconstruction |
unknown_presence | unknown_presence | partial source derived model | unknown_presence |
node_count | node_count | partial source derived model | node_count |
Model text
descriptant
latex-ast-stage2
unknowns runs walk and emits (backslash+command,stored span) or (begin{name},stored span) for unknown environments. has_unknown ORs the same node predicates without short-circuiting walk. size counts each node visit, including root and empty Row.
Epoch 2026-10-31: replaced stage topic lists with concrete transitions, exclusions and compatible antecedents. Four meaningful typed views replace the previous six-view bookkeeping catalog. Shared syntax and source byte bounds are unchanged.
approximant
Scoped forward relation
unknowns runs walk and emits (backslash+command,stored span) or (begin{name},stored span) for unknown environments. has_unknown ORs the same node predicates without short-circuiting walk. size counts each node visit, including root and empty Row.
This is an exact source-derived partial model, not an executable approximate replacement.
invariant
Scoped invariants
An unknown-looking string inside Text cannot itself appear in unknowns. has_unknown cannot be false when unknowns is nonempty for a finite tree. Span-insensitive Node equality cannot establish coordinate equality.
has_unknown(n) iff !unknowns(n).is_empty(), under terminating traversal. Names preserve the spelling stored in Unknown/EnvName; spans are copied rather than recomputed.
size(n)=1+sum(size(child)); empty Row contributes1. Replacing a known leaf by another preserves size; adding a Group increases size by1.
composition
Scoped interaction
These observers use the previous traversal stage. Their output coordinates remain meaningful even though Span::eq returns true for arbitrary coordinates; the appended tests explicitly distinguish those observations.
The manifest binds this stage to the unchanged parent syntax projection and exact source byte range. Parent cost remains an upper accounting context; no independent whole-file invocation or execution count is assigned to this fragment.
models
behavior_complement
An unknown-looking string inside Text cannot itself appear in unknowns. has_unknown cannot be false when unknowns is nonempty for a finite tree. Span-insensitive Node equality cannot establish coordinate equality.
reverse_reconstruction
unknowns=[] is compatible with every tree containing no Unknown node or unknown Env, including empty Row and large known trees. A listed unknown's name/span does not determine its children or surrounding known nodes. size=1 is compatible with any leaf and also empty Row.
unknown_presence
has_unknown(n) iff !unknowns(n).is_empty(), under terminating traversal. Names preserve the spelling stored in Unknown/EnvName; spans are copied rather than recomputed.
node_count
size(n)=1+sum(size(child)); empty Row contributes1. Replacing a known leaf by another preserves size; adding a Group increases size by1.
tests
Evidence โ 2026-10-31
ast::wave28_tests::normalization_and_span_quotient; ast::wave28_tests::traversal_preserves_script_and_unknown_order
Selected library filters ast:: lex:: macros:: parse:: print:: table:: and integration gate excluding document_extraction_with_preamble_macros and random_token_soup_never_panics_and_roundtrips. Direct rustc --test latex/build.rs exercises private helpers. All selected tests twice debug/release with identical sorted names. Four compiled mutants at build/AST/parser/printer boundaries fail assertions then exact restoration passes. These do not individually cover every source. Build-main failure effects, allocation failures and universal roundtrip are unproved. Strict Clippy reports existing lints. No corpus/live VMM/API/GPU/full-school/held-out tests.
This page in Markdown โ https://md.groupants.elamur.ai/free/en/mova/latex/src/ast.rs.groupant/stage2.groupant/