Expand description
The word session: one owned word at a time, advanced only by verified acknowledgements.
While a word is typed, the adapter keeps it in the host as an owned composition, marked text
that Keyrill inserted and can still replace as a whole. The session is the Rust record of
that word; it never touches the host. For each event the adapter asks for a Plan, performs
the one native action the plan permits, verifies it and reports the Outcome. Proposing
changes nothing the session has confirmed: the proposed state waits in the session until
Session::acknowledge receives a verified outcome for that plan’s id, and a newer proposal
makes an older plan stale.
adapter Session
key event --- propose_*(event) --------> plan the event against the confirmed state
<-- Plan { id: n, .. } ------- keep the proposed state as pending
the mark still holds `expected`?
no: report Refused, nothing written
perform `action` with `text`, at most one write
read the result back
--- acknowledge(n, outcome) --> Verified: adopt the pending state
Refused or Unknown: Invalidated
pass the key, consume it or propose it again, as `disposition` saysThe word moves through four states. ARCHITECTURE.md uses these names; in the code Composing
and BoundaryRetained are one Owned state with the boundary flag clear or set.
letter at a boundary: Mark
+------+ ---------------------------------> +-----------+ letter, Backspace,
| Idle | | Composing | Manual, Reverse: Mark
+------+ <--------------------------------- +-----------+
^ Backspace to empty: Mark (empty) |
| Escape or any other event: Finish | Space: infer, then Mark the word
| v and the Space
| Escape or any other event: Finish +------------------+
+---------------------------------------- | BoundaryRetained | Manual, Reverse: Mark
(a letter is then planned again) +------------------+
Idle passes every other event. Manual or Reverse with nothing to act on is consumed
without a write, in every state.
From any state, a Refused or Unknown outcome, a mode change while a word is owned or an
exhausted token counter leads to Invalidated, which refuses every proposal; reset()
returns to Idle, except after exhaustion.A receipt is the text the word had before the session first converted it, automatically at Space or by a manual command. While the same word is owned, Reverse restores it once, and Escape restores it and finishes the word; an edit expires it, and so does finishing. Manual and Reverse also set explicit intent, which stops inference for the rest of that word, so inference never undoes a choice the user made. A Backspace is not intent, and a corrected typo still converts.
Language context comes from the session’s own finished words, never from the document. A word that ends in its Space and is finished by the letter that starts the next word is appended once that finish is verified, up to 256 UTF-16 units. Any other finish, and any event the host handles, clears it, because the host can then move the caret or edit the text; so do a mode change, a refused or unknown outcome and reset.
Structs§
- Plan
- Copied proposal for native validation and a single native effect. It owns its text and borrows nothing from the session, the model or the vocabulary snapshots.
- Session
- One controller’s bounded word state; contains no native objects or callbacks. It holds at
most one word of
MAX_WORDunits plus its Space, the word’s receipt, and 256 UTF-16 units of history.
Enums§
- Action
- The one native operation a plan permits.
- Context
- What the adapter verified before the caret. It matters only when no word is owned: a letter
starts a word only at
Context::Boundary, so the session never takes over the tail of a token already in the document. - Disposition
- What happens to the key event once the plan’s action is verified.
- Error
- Session protocol errors; no raw text is included.
- Event
- Input supplied by the native controller, without document offsets.
- Mode
- Input mode: the layout Keyrill types in.
- Outcome
- Native effect acknowledgement.
Constants§
- MAX_
WORD - Maximum composing word length in UTF-16 units, excluding retained Space.