---
title: "world-schooltools-editing-restore-selection — Mova code model"
description: "Mova code model of world/src/schooltools.rs: components with their labels, obernants and the model text."
url: "https://groupants.elamur.ai/free/en/mova/world/src/schooltools.rs.groupant/editing.groupant/restore-selection.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/world/src/schooltools.rs.groupant/editing.groupant/restore-selection.groupant/>

# world-schooltools-editing-restore-selection

The groupant beside world/src/schooltools.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_fragment
- **status:** partial source bound model
- **source:** [`world/src/schooltools.rs`](https://github.com/ElamurAI/mova-free/blob/main/world/src/schooltools.rs)
- **source SHA-256:** `22ec16d5488a88c1…`
- **covers:** Resolve snapshot copy by parent-basename/file-basename. Read saved then current lines split on newline. Refuse unequal line counts, then refuse any zero or oversized requested index before writing. Copy selected saved lines in list order, count only actual differences, write whole joined buffer, report changes. (bytes 25542–26573)
- **part of:** [world-schooltools-editing](https://md.groupants.elamur.ai/free/en/mova/world/src/schooltools.rs.groupant/editing.groupant/)
- **repository folder:** [`world/src/schooltools.rs.groupant/editing.groupant/restore-selection.groupant`](https://github.com/ElamurAI/mova-free/tree/main/world/src/schooltools.rs.groupant/editing.groupant/restore-selection.groupant)
- **repository commit:** `855da7bd4a7b`

> **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](#forward) |
| **ast** | partial | `../../syntax.json` |
| **composition** | partial source model | [composition](#composition) |
| **cost** | partial source model | [cost](#cost) |
| **descriptant** | partial source model | [epoch-memory](#epoch-memory) |
| **invariant** | partial source model | [invariant](#invariant) |
| **tests** | partial source model | [checks](#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 |
|---|---|---|---|
| `world-schooltools-editing-restore-selection-behavior-complement` | behavior_complement | partial source model | [behavior-complement](#behavior-complement) |
| `world-schooltools-editing-restore-selection-reverse-reconstruction` | reverse_reconstruction | partial source model | [reverse-reconstruction](#reverse-reconstruction) |
| `world-schooltools-editing-restore-selection-preflight_order` | failure_order | partial source model | [preflight_order](#preflight-order) |
| `world-schooltools-editing-restore-selection-duplicate_accounting` | observation_relation | partial source model | [duplicate_accounting](#duplicate-accounting) |
| `world-schooltools-editing-restore-selection-newline_cardinality` | representation_relation | partial source model | [newline_cardinality](#newline-cardinality) |
| `world-schooltools-editing-restore-selection-filesystem_boundary` | effect_boundary | partial source model | [filesystem_boundary](#filesystem-boundary) |

## Model text


Wave34, 2026-10-31. Source-bound helper model; no universal proof or approximation-error certificate. Historical parent epoch remains intact.

### forward

Resolve snapshot copy by parent-basename/file-basename. Read saved then current lines split on newline. Refuse unequal line counts, then refuse any zero or oversized requested index before writing. Copy selected saved lines in list order, count only actual differences, write whole joined buffer, report changes.

### invariant

On preflight refusal the current file is unchanged. Successful restoration preserves all unselected lines and exact saved selected bytes including CR. Duplicate selected indices can increase requested count but not changed count twice.

### cost

O(saved bytes+current bytes+indices+output bytes), O(saved/current bytes) memory; filesystem latency/atomicity unmeasured.

### composition

line_numbers normally sorts/deduplicates CLI indices, but public restore_lines admits duplicates. snapshot supplies copy naming. Count/index validation precedes the replacement loop and final fs::write; write failures may partially affect disk, outside preflight invariant.

### behavior-complement

Exclude a preflight-refused call writing any prefix of valid requested lines; exclude indexing zero or above line count. Exclude changing an unselected line on successful I/O. No exclusion of partial writes on filesystem failure is claimed.

### reverse-reconstruction

Given saved file, index list and successful final current file, compatible pre-files agree with final bytes outside selected lines and have equal split-line cardinality; selected earlier bytes are unconstrained. Changed count additionally constrains how many selected distinct lines differed.

### preflight_order

Read saved before current; line-count mismatch precedes index validation; any invalid index anywhere in list prevents the whole restore. Valid-first/invalid-later is not a prefix commit.

### duplicate_accounting

After the first restoration of x its buffer line equals saved[x]; a second x contributes zero to changed, while report denominator remains input-list length.

### newline_cardinality

split('\n') retains trailing empty row: final newline affects cardinality and can make otherwise similar logical lines incompatible. CR is part of each restored row.

### filesystem_boundary

Ordinary fs::write is not atomic or crash durable. Fixture success and preflight non-effects concern uniquely created temporary paths only; live lesson path resolution remains unexecuted.

### checks

Exact world library selections: schooltools::wave34_models::restore_preflight_and_duplicate_selection. Current repeated debug/release outcomes and compiled controls are in the root sidecar wave34-evidence.md. Only these supplied-input tests are current evidence; older parent module-wide receipts are historical. Macro bodies remain opaque.

### epoch-memory

Prospective model saved before edits. This epoch deepens one existing node rather than renaming it. Production implementation unchanged; tests add helper-boundary observations where stated. No live lessons, frozen suites, model loading, teacher or network. Read-only symbolic relations are broader than the finite native domain.
