treestore-json
The groupant beside tools/treestore/src/json.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 top level of a compact JSON object as written: (key, value byte span) of each member, so a record is cut into an envelope and coded string fields and put back byte for byte without re-serialising the rest. Epoch 2026-11-06.
Approximant
members(s) scans one object: { key : value (, key : value)* } with no whitespace; a string ends at the first
unescaped quote; containers end at depth 0 skipping strings; scalars end before , } ]. plain_string(raw) =
Some(v) iff serde_json reads raw as v and serde_json writes v as raw.
Invariant
For s accepted by members: concatenating {, the members as "key":value joined by ,, and } gives s. plain_string
is a partial inverse of escape: escape(plain_string(r)) = r. Cost O(|s|).
Composition
codec::encode replaces the spans of coded fields by null; codec::decode finds the same keys in the envelope and puts
escape(field) back.
Behavior complement
Does not validate JSON (a malformed scalar is accepted as a span), does not accept whitespace or escaped keys (the record then stays whole in the envelope), does not normalise numbers or key order.
Reverse reconstruction
From the member list and the original string the input is recovered exactly (spans are positions in it); from a decoded string value alone, its raw JSON is recovered only when plain_string holds (canonical escaping).
Tests
json::tests::members_and_strings: nested containers and escaped quotes; negative controls (array, whitespace,
non-canonical escape).
Provenance
This page in Markdown โ https://md.groupants.elamur.ai/free/en/mova/tools/treestore/src/json.rs.groupant/