mova-whale-source
The groupant beside tools/whale/src/source.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 | Forward approximant |
| ast | partial | syntax.json |
| composition | partial | Composition |
| cost | partial | Cost |
| descriptant | present | Descriptant |
| invariant | partial | Invariant |
| tests | finite evidence | tests.md |
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 |
Model text
Descriptant
Source adapters: bounded teacher context and full comparison text for UTF-8 text and EPUB. Source: tools/whale/src/source.rs. Public, domain-agnostic: concrete prompts, schemas, gate parameters and deployments come from pinned configuration.
Forward approximant
text: read at most max+4 bytes, keep the longest valid UTF-8 prefix within max bytes, mark partial when file size exceeds it. epub: container.xml rootfile -> OPF manifest/spine; visit spine XHTML members in order, drop script/style, keep entity references literal when unknown, stop at max bytes. full_primary: rehash, extract the whole UTF-8 file or all HTML/XHTML members sorted by name, rehash again.
Invariant
Context length <= max bytes; no member path escapes the archive; no external resource or entity is loaded; full_primary returns text only when the file hash equals the pin before and after extraction.
Cost
O(min(file, max)) for text context; EPUB O(expanded members) bounded at 64 MiB and 4096 members.
Composition
Used by whale::prepare (context) and whale::publish (originality primary); the adapter per item format is chosen by the specification kind.
behavior_complement
Excluded: files above 64 MiB, archives above 4096 members, absolute/percent/backslash/escaping hrefs, non-text spine items, invalid UTF-8 inside the kept prefix. Counterexample: a script element containing instructions never reaches the context (epub test). Evidence status: source-derived model with finite checks, not a proof.
reverse_reconstruction
From a context one recovers a prefix of the visible text; all sources with the same visible prefix (any tail, any markup, any script content) are compatible antecedents. Partial flags separate complete from truncated observations. No unique inverse is claimed.
tests.md
3 tests: EPUB spine order/script removal/path refusal/full primary hash, XML references, text prefix on character boundary.
Command: cargo test --manifest-path tools/whale/Cargo.toml --offline --locked (74 tests, fake teachers/executables; two identical runs on 2026-11-03). These are finite fixtures; no live run, model call or deployment was exercised.
This page in Markdown → https://md.groupants.elamur.ai/free/en/mova/tools/whale/src/source.rs.groupant/