mova-whale-gates
The groupant beside tools/whale/src/gates.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
Anti-padding gates of a Whale's own description: word bounds, near-duplicate sentences, verbatim run against the whole paper, n-gram overlap with any terminal answer (unless the paper has it), traceability of every content word to its basis or the frame vocabulary, and the share of structural sentences. Source: tools/whale/src/gates.rs.
Forward approximant
Guard::new(paper, answers, params): token positions of the paper, paper n-grams, answer n-grams (n = answer_ngram). verbatim(s): longest run of s's tokens consecutive in the paper (position DP). answer_overlap(s): n-grams in answers and not in the paper. check(draft, reading, knowledge, guard, min, max): duplicates (exact or Jaccard >= near_duplicate on >= 4 content words), verbatim (structure sentences without «…» quotations), overlap, traceability (source/reading: source sentence texts + cited knowledge; explain: knowledge basis; structure: stated basis; plus FRAME), structure share; pass iff all.
Invariant
A gate that cannot fail is not a gate: each has a red control in tests; deterministic; defaults verbatim_max 12, answer_ngram 6, near_duplicate 0.8, structure_share_max 0.2 (validated ranges 4..40, 3..20, 0.5..1, 0..1).
Cost
Guard build O(paper tokens + answer tokens); verbatim O(sentence tokens x occurrences); duplicates O(items^2); milliseconds per draft (2026-11-04).
Composition
Parent: whale-workers; used by compose.rs (admits) while writing and by learn.rs (check) after writing.
behavior_complement
Not done: semantic paraphrase detection, factual correctness, originality against other papers or the web, judging that a structural sentence is informative. A paper-wide repeated phrase longer than the cap counts against the description even where the paper repeats itself. Evidence status: source-derived model with finite checks, not a proof.
reverse_reconstruction
gates.json names every failing item (index, run length, first overlapping n-gram, untraceable text, duplicate pairs) so the failing sentence and the gate are recovered; the passing set is not reconstructible from the report alone.
Epoch 2026-11-04 (grammar gate)
New gate grammar: every source/reading sentence passes clause::grammatical; red control on the ma-2018 fragments. Traceability compares normalized forms (a term may be written as «MRFs» for an item keyed «MRF»).
tests.md
gates::tests::a_clean_draft_passes_and_every_gate_has_a_red_control and guard_counts_runs_anywhere_in_the_paper (2026-11-04). Every gate has its red control in the same test. Finite fixtures, not a proof.
2026-11-04: tests of the batched/pod/stall/review/grammar/filter/selection changes listed in the crate README «Checks»; negative controls (grammar gate always passing, pod claim ignored, stall off, extraction check off) each turned their tests red, restored.
This page in Markdown → https://md.groupants.elamur.ai/free/en/mova/tools/whale/src/gates.rs.groupant/