---
title: "mova-whale-contract — Mova code model"
description: "Mova code model of tools/whale/src/contract.rs: components with their labels, obernants and the model text."
url: "https://groupants.elamur.ai/free/en/mova/tools/whale/src/contract.rs.groupant/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Research](https://md.research.elamur.ai/free/en/) · **Groupants**

This page as HTML: <https://groupants.elamur.ai/free/en/mova/tools/whale/src/contract.rs.groupant/>

# mova-whale-contract

The groupant beside tools/whale/src/contract.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

- **kind:** groupant
- **status:** partial source bound model
- **source:** [`tools/whale/src/contract.rs`](https://github.com/ElamurAI/mova-free/blob/main/tools/whale/src/contract.rs)
- **source SHA-256:** `7bdb7e35733e05c7…`
- **repository folder:** [`tools/whale/src/contract.rs.groupant`](https://github.com/ElamurAI/mova-free/tree/main/tools/whale/src/contract.rs.groupant)
- **repository commit:** `48f2e6f74146`

> **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](#forward-approximant) |
| **ast** | partial | `syntax.json` |
| **composition** | partial | [Composition](#composition) |
| **cost** | partial | [Cost](#cost) |
| **descriptant** | present | [Descriptant](#descriptant) |
| **invariant** | partial | [Invariant](#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](#behavior-complement) |
| `reverse_reconstruction` | reverse_reconstruction | partial source derived model | [reverse_reconstruction](#reverse-reconstruction) |

## Model text


### Descriptant

Configured output contract: length measure and projection, field rules, verbatim guard and bundle rendering. Source: `tools/whale/src/contract.rs`. Public, domain-agnostic: concrete prompts, schemas, gate parameters and deployments come from pinned configuration.

### Forward approximant

`validate`: length field count in [min,max] in the configured unit without forbidden substrings (error prefix `length gate:`), then each field rule (equals; nonempty bounded text; bounded nonempty string lists; object lists with text/list/enum fields, distinctness and required member values), reply byte budget and verbatim context run. `project`: for an oversized field cut at the last paragraph break, else last sentence end, whose prefix count is admitted; record a trace. `rewrite_statuses` keeps the claimed value and downgrades the rest; `artifacts` renders text, bullet lists, JSON projections and the metadata file.

### Invariant

A validated body satisfies every configured rule; a projection output is a byte prefix of the input whose count is in [min,max] and never pads or rewrites; status rewrites retain the teacher claim; artifact order follows the specification.

### Cost

Word counting O(n); projection O(n * boundaries * n) worst case from recounting prefixes; validation O(reply); verbatim guard O(tokens) BTreeSet.

### Composition

Called by whale::admit and whale::project_quarantined_lengths; publish renders artifacts after validation.

### behavior_complement

Excluded: out-of-range length, blank or oversized fields, duplicates by distinct_by, missing required members, values outside enums, equality mismatches, replies above budget, configured verbatim runs, oversized fields without an admitted boundary or with forbidden substrings. Counterexample: an oversized field with no paragraph/sentence boundary is not projected. Evidence status: source-derived model with finite checks, not a proof.

### reverse_reconstruction

From a projected field all originals with the same prefix and a longer tail are compatible; the trace pins input/output hashes and boundary, so the original is recovered only with the retained reply. A validated count admits many texts. No unique inverse is claimed.

### Epoch 2026-11-04 (Whales in English)

Epoch 2026-11-04: tests of word bounds on a fixture spec (4000..5000: 3999 and 5001 refused; 5002 with a sentence end projected to 5000; 5001 without one refused) and an opt-in MOVA_WHALE_SPEC_CHECK test of a deployment spec. No production change.

### tests.md


6 tests: word/scalar units, equality and fence refusal, object rules, verbatim runs, projection boundaries, status rewrite and artifact order.

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.

2026-11-04: cargo test --manifest-path tools/whale/Cargo.toml --offline --locked with MOVA_OCTOPUS_TEST_MODEL=$MOVA_DATA/download/0/0.4/en.bin (unit tests incl. 5 service tests, 2 realizer tests, 3 length-gate tests; 2 English tests: 18 prompts, 10 refusals, a served end-to-end run with the real mova-whale child and a fake Codex executable; two identical runs on 2026-11-04)
