# Inkhaven 1.3.23 — Local Translation: the ConLang Suite learns to translate

_A constructed language can now be **translated** — English → conlang, conlang →
English, and conlang → conlang — fully offline, deterministically, and improving
as you correct it. This is the core of RFC LANG-3, re-architected (Amendment A1)
to be **Python-free, training-free, and zero new dependencies**: a conlang is a
closed, formally-described domain, so translation is mostly orchestration over the
LANG-1 engines plus retrieval over the binary's existing embedding + vector
stack. Reference: [CONLANG.md](../CONLANG.md)._

## Tier 1 — the rule-based translator (RBMT)

The deterministic spine, in `src/conlang/translate/`. Because a LANG-1 language
carries a complete formal description — phonemes, morphology, typology, and a
lexicon whose every headword has an English gloss — translation reuses the
machinery already built:

- **`language translate <lang> "<english>"`** maps each English word to a
  headword by its gloss and hands the clause to the LANG-1 **syntax engine**,
  which orders by `word_order`, case-marks by `alignment`, inflects via the
  morphology spec, and runs agreement. So a translation reorders and inflects for
  free: *the bird sees the stone* → `kira nami pata` (SVO) or `kira pata nami`
  (SOV) from the same lexicon. Parsing is **lexicon-aware** — the verb is found by
  meaning, an attributive adjective is recovered and agrees with its noun, and
  number flows through (*the birds see the stones* → `kirai nami patai`).
- **`language reverse <lang> "<surface>"`** goes back to English, un-inflecting
  each surface word against the lexicon's paradigm forms and re-agreeing English
  number and tense.
- **`language cross <from> <to> "<surface>"`** translates one conlang into another
  through an English pivot (exposed), so an SVO language's `kira nami pata`
  crosses into an SOV language as `turi moki vela`, reordered for free.

Every output carries a per-word **confidence and decision trace**; a word the
lexicon can't cover is marked `«word»` and listed.

## Tier 2 — retrieval (a translation memory), not a trained model

The original plan fine-tuned a neural model (and needed Python to train it).
**Amendment A1** replaces that with **retrieval**: for a closed conlang the corpus
*is* the knowledge, so it is looked up at translation time instead of baked into
weights — and the retrieval stack (`fastembed`, the HNSW vector store,
`tokenizers`, `ort`) already ships in the binary.

- **`language remember <lang> --english … --conlang …`** confirms a translation.
  It is reused **immediately, on the very next call** — no retraining, no
  threshold. An exact remembered pair becomes the primary (the rule-based reading
  is kept as an alternative); nothing is silently overridden.
- Near matches are **semantic**: each remembered source is embedded once (with the
  same model that powers manuscript search) and a translation matches by cosine —
  so *a soldier lifts his blade toward the sun* recalls a remembered *the warrior
  raises his sword to the sun* with no shared content words.
- **`language corpus <lang> [--yes]`** seeds the memory by translating a bundled
  English pool and keeping what the language fully covers; its acceptance rate and
  top-missing words read out lexicon maturity.
- **`language eval <lang>`** measures quality without a human reference:
  round-trip similarity (translate → reverse → compare) and coverage.
- **`language export-translation <lang>`** packages the whole system as a portable
  single-file **`.itm`** bundle (the memory + lexicon + manifest + README) to ship
  alongside a published work — browsable as a phrasebook, re-seedable into another
  project.

## Scripting

The full pipeline scripts from **Bund**: `lang.translate` (memory-aware),
`lang.reverse`, `lang.cross`, `lang.remember`, `lang.memory`, `lang.corpus`,
`lang.eval`, and `lang.export` — all aliased and policy-classified.

## Design notes

- **Python-free, training-free, zero new dependencies, no required downloads.**
  Every piece reuses what was already in the binary: the LANG-1 engines for the
  RBMT, `fastembed` + the vector store for semantic recall, `zip` + `chrono` for
  the export bundle.
- **Deterministic and advisory.** The rule-based core is pure; retrieval surfaces
  *alternatives* and only an author-confirmed exact match overrides — the author
  always sees and chooses.
- **Correction loop beats the original design.** A correction is an immediate
  datastore append, where the fine-tuned plan batched 100 corrections and a
  training run to do less.
- The neural-fluency tiers (a base NLLB via the in-tree `ort`, or candle LoRA) are
  now an **optional** later phase, taken up only if retrieval proves insufficient
  on real conlangs.

Also in this release: a small fix surfacing two previously-unread fields
(`Adaptation.ipa` in `borrow`, `Variety.note` in `varieties`) to clear dead-code
warnings.

Tests 1548 → 1576. Full reference: [CONLANG.md](../CONLANG.md).

## Looking ahead

Routing the TUI translation pane through this pipeline is held for the planned TUI
rearchitecture (the engine/CLI/Bund surface it will route through is complete).
The optional neural-fluency phase
([`LANG-3_PLAN.md`](../PROPOSALS/LANG-3_PLAN.md), P-opt) remains available if the
retrieval pipeline ever needs more fluency than the rule-based engine provides.
