qagen-gate-normalization
The groupant beside qagen/src/gate.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 source model | forward |
| ast | partial | ../../syntax.json |
| cost | partial source model | cost |
| descriptant | partial source model | epoch-memory |
| invariant | partial source model | invariant |
| tests | finite observation | checks |
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 |
|---|---|---|---|
qagen-gate-normalization-complement | behavior_complement | partial source model | behavior-complement |
qagen-gate-normalization-reconstruction | reverse_reconstruction | partial source model | reverse-reconstruction |
qagen-gate-normalization-specialized | gate_normalization_observation | partial source model | specialization |
Model text
Source SHA-256: 09328f711abf4b6453f95bed3d873deb205c8801d939841974416fe74e3e5806. Domain: finite supplied UTF-8 strings and synthetic Para values; rule V1/V2. Observation is the operation result specified below. Mathematical descriptions are source-level exact relations under stated assumptions, not a certified implementation theorem or numerical approximant.
forward
W and N operate on Unicode scalar values. Lowercase may expand one scalar (İ to i plus combining dot). Whitespace is collapsed only in N. Verbatim chooses the first sentence containing a consecutive token window.
behavior-complement
No nonconsecutive token selection is verbatim. Empty token vector yields None. Distinct punctuation in N can share W; no canonical Unicode normalization is performed.
reverse-reconstruction
Verbatim observation Some(k) constrains all earlier sentence windows to mismatch and one window of sentence k to equal W(answer). Case and punctuation equivalence yield many inputs; None is the no-window fiber.
specialization
first_witness: Option<NonZeroSentenceIndex> over word-vector windows, with earlier indices excluded.
invariant
All accepted anchors are sorted unique local indices; accepted paragraph and question indices are 1-based. span_reason requires equal word/normalized sentence lengths and prevalidated in-range anchors; arbitrary direct callers can violate that precondition. Integer multiplication assumes representable counts; memory exhaustion and usize overflow are outside this model.
composition
Lexical children produce distinct W and N views. Row checks consume both plus parsed anchors; batch classification precedes row checks and paragraph accumulation adds deduplication/cap. Accepted tuples cannot be fed back as full rejection logs: that projection loses information. The lexical node composes normalization followed by boundary matching; it does not identify word equality with span equality.
cost
Let B be supplied bytes, R rows, S total paragraph sentence bytes and A answer length. Lexical normalization is O(B) scalar work/storage (lowercase expansion bounded by Unicode tables). Verbatim window comparisons cost O(total sentence tokens * answer tokens). Span matching with repeated suffix checks is conservatively O(S*A); anchors O(K log K). Batch indexing O(R log N), stored raw/column rows O(B); each row rebuilds answer views and scans relevant sentence views. No measured speed or approximation-error claim.
epoch-memory
2026-10-30: prospective ratio/fold model predicted strict malformed-anchor and single-prefix repairs. Original production accepted 1,,2 and PP1. These are repaired without changing signatures; valid local numbering unchanged. Unicode interval search passed independent finite enumeration, including invalid first occurrence followed by valid occurrence. A test expectation counted six rejects for eleven rows capped at six; corrected to five before final evidence, not a production bug.
checks
Eight gate::wave17_models tests: Unicode interval oracle 341 squared = 116281 comparisons plus two overlap witnesses; batch integer-ratio oracle 220 cases; literal normalization; empty anchors; single prefix; cap/dense numbering; span/implicit composition; accepted-projection reconstruction. Synthetic Para only, no live teacher/parser/corpus/database. Debug/release twice and compiled mutations are recorded in root evidence.md. Finite evidence does not establish all Unicode/grapheme semantics or full source correctness.
This page in Markdown → https://md.groupants.elamur.ai/free/en/mova/qagen/src/gate.rs.groupant/lexical.groupant/normalization.groupant/