treestore-model
The groupant beside tools/treestore/src/model.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 |
| Cost | symbolic source derived | Invariant |
| 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.
| relation | type | label | where |
|---|---|---|---|
| Behavior complement | behavior complement | partial source derived model | Behavior complement |
| Reverse reconstruction | reverse reconstruction | partial source derived model | Reverse reconstruction |
Model text
Descriptant
The store model: frozen value tables (headers, sections, tag tuples, relations, lemma edit scripts, frame pieces, pragmatics tuples), shapes, split exceptions, the fragment meta-dictionary, one trained zstd dictionary and one primed context model per stream. Named by the first 16 hex of its file's SHA-256. Epoch 2026-11-06: the tier-1 model (250 sample articles of 10 shards) is 2.97 MB, trained in 28 s, peak 825 MB.
Approximant
train: pass 1 counts table values and the chunks the split rule gets wrong; pass 2 counts shapes (≥ 3) and learns fragments; pass 3 encodes the sample and trains a zstd dictionary (≤ dict bytes, ≤ 1/10 of the samples) and primes a context model per stream. Serialisation is a fixed field order of varints and byte strings.
Invariant
from_bytes ∘ to_bytes = id; train is deterministic (BTreeMap counts, ties by bytes). A store file names the model id, so a different model is refused. Cost O(sample bytes) plus fragment learning and dictionary training.
Composition
Read by codec (tables, shapes, fragments, splits) and store (dictionaries, context models).
Behavior complement
Does not adapt after training (values outside the tables go to literals), does not version tables inside a store (one model per store directory), and does not guarantee good ratios for text unlike the sample.
Reverse reconstruction
Tables cannot be recovered from a store's data without the model file; the model file is the dictionary of the format.
Tests
In tests/roundtrip.rs: model bytes round-trip and training twice gives the same bytes, in three modes.
Provenance
This page in Markdown → https://md.groupants.elamur.ai/free/en/mova/tools/treestore/src/model.rs.groupant/