Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing

A native API call that returns success is not a document result, a controlled NSTextView is not system IMK, and a generated event in a real editor is not physical input. Record which of these a result is. Results belong to the binary that produced them, not to later builds.

flowchart TD
    A["API call<br/>returned success"] --> B["Controlled client:<br/>scripted IMK, whole document"]
    B --> C["Generated events<br/>in a real editor"]
    C --> D["Physical keys<br/>in a real editor"]

Each step to the right is stronger evidence, and only the last one shows that an application works.

Layers

LayerWhereCovers
Unit and propertycrates/*/src, crates/keyrill-core/testsMapping, vocabulary flags, policy, session transitions, ABI bounds; fixed proptest seeds
Reference vectorstests/fixtures/engine-vectors.jsonl1,217 mapping, vocabulary, context and inference outputs, see engine
Negative settests/fixtures/negative-words.jsonl, tests/negative_words.rs766 words automatic correction must leave alone
Evaluation./tools/verify evaluateSession replays and a negative set over held-out corpora, with recall and false-correction gates
C ABI smokecrates/keyrill-ffi/tests/abi_smoke.cThe plan, check, write, commit loop from C against an in-memory document
Fuzz and Mirifuzz/, ./tools/verify miriParsers, state, model asset, FFI pointer contract
Controlled nativenative/macos/testsScripted IMK clients with whole-document oracles; ASan/UBSan
Browser fixturenative/macos/tests/browser-fixture.htmlField and caret oracle for physical browser runs
PhysicalReal applications, real keysThe only evidence that an application works

The controlled native tests drive KRSession, the compatibility session and the controller with scripted clients that hold a whole document, and an offscreen NSTextView for the readback commit after a failed check. They check correction, protection, forbidden targets, reversal, reentrant callbacks that change generation or client, unknown effects, empty composition, dictionary reload and adoption deferral, key disposition, and compatibility rewrites including missing echoes and a terminal that forwards consumed keys. One test, compatibility_known_interleaving_hazard, keeps a schedule where a typed character is deleted and the word corrupted; it documents the backend’s limit and is not integrity evidence.

Regression schedules

regressions.json lists sixteen schedules (R01–R16) any adapter has to answer. R01–R04 are negative controls for the rejected transports: a test passes by showing the damage in the rejected mechanism or by refusing the schedule, never by reproducing the unsafe edit. The rest cover reentrant invalidation, foreign marks on reused proxies, caret disagreement, empty composition, manual boundaries, rapid continuation, focus reuse, source selection versus delivery, dictionary reload, key disposition, TSF grants, and secure fields and shutdown. Use deterministic barriers and callbacks, not shorter sleeps.

Invariants and evidence

Each safety invariant guards against one hazard. The table ties it to the regression schedules above, the tests that would catch a violation today, the strongest evidence obtained so far and what is still missing. Controlled means the native tests’ scripted IMK clients with whole-document oracles; physical means the maintainer typing in a real application, as recorded under Status. The compatibility backend gives up S1, S4 and S6 by design (ADR 006); its compatibility_* tests record that, and it has no physical result yet.

IDHazardSchedulesTestsStrongest evidenceOpen gap
S1A correction deletes, doubles or reorders text outside the wordR03, R08, R10, R13model_whole_document_en, model_whole_document_ru, empty_composition, reenter_*, throw_*; session property testsPhysical, v0.1.0: TextEdit, Safari, FirefoxNothing physical after v0.1.0; rapid typing across a boundary (V06) and two fields (V08) not recorded; Safari’s fixture once came out one unit short
S2Keyrill edits a mark it doesn’t own: another input method’s, a reused proxy’s, or one a focus change left behindR06, R07, R11foreign_mark, foreign_mark_after_context, moved_caret, caret_moved_after_context, client_changeControlledA foreign mark in a reused client (V09) not run physically
S3A write lands after a callback moved focus or changed the generation mid-callR05, R15reenter_*, throw_*, owner_release_during_callback, secure_input_during_client_calls; exercise 9Controlled, also under ASan and UBSanNested commands and source changes during a request (V10) not run physically; Windows (R15) has no adapter
S4A key is lost, doubled, sent elsewhere or reorderedR10, R14unknown_finish_then_letter, unknown_finish_then_shortcut, unknown_escape_consumed, ignored_write, readback_commit_after_failed_checkControlled; ordinary typing physically at v0.1.0Navigation, shortcuts, Tab and Enter (V12) not recorded physically
S5An API’s success return is taken as a document editR07, R12ignored_write, finish_altered_text, lifecycle_commit_unreadable_text, typed_finish_unreadable_text; the C ABI smoke test; exercise 8ControlledA physical test shows only the result, so this stays a controlled-test property
S6Committed text is rewritten on the composition pathR01–R04No code path exists; R01 to R04 are the negative controls for the rejected transportsSource reviewNone while those transports stay absent
S7A late reversal edits a word Keyrill no longer ownsR09manual_reversal_expiry, escape_restores_original, kept_mark_across_mode_change, model_reversal_dictionary_change, runtime_reload_whole_document_and_receiptPhysical, v0.1.0: Control+Option+Z in all three applicationsReversal after continued typing (V05) not recorded physically
S8Typed text reaches disk, a log or the networkR16input_status, controller_status_line; error messages carry no user data; there is no network codeSource review and controlledA crash dump can still hold text; compatibility mode holds typing in memory while Secure Input is off
S9A native or FFI object is used after it is freed, or across a panicNoneMiri, fuzzing, the C ABI smoke test, ASan and UBSan runs of the native tests, owner_release_during_callbackSanitizers and MiriQuitting the application and server termination (V13) not recorded physically
S10A refusal changes the document or switches transport silentlyR16secure_input, unlisted_client, controller_secure_input_before_characters, lifecycle_interruption_status, compatibility_refusal_interruption_secureControlledRead-only, password and custom controls (V14) not run physically

Physical scenarios

Observe whole synthetic documents or fields, prefix and suffix, and the UTF-16 caret; for two-field cases observe both. Native readback is the client’s view: prefer an independent oracle such as a saved file or the browser fixture. Classify each result as passed, failed, unsupported, untested or setup-blocked. A permission or activation problem with no keys typed is not a correction failure, and input that never reached Rust is not an abstention.

IDScenarioExpected
V01EN mode: ghbdtn Space hello Space ghbdtn Spaceпривет hello привет , caret after the last Space; repeat without restarting
V02RU mode: руддщ Space цщкдв Spacehello world
V03Ghbdtn, all-caps, acronyms, identifiers, URLsTitle case converted; the rest unchanged
V04Manual before Space and right after the boundaryDeterministic conversion; inference never undoes it
V05Reversal before and after Space, then keep typingExact original restored; no re-correction at that boundary
V06Rapid typing straight through a boundary, repeatedNo lost, duplicated or reordered characters
V07Backspace inside a word and to empty, then typeOnly owned units removed
V08Half a word in field A, click B, correct in B, return to ABoth fields intact; nothing carried across
V09Foreign mark in a reused client; caret and mark disagreeRefusal, no new writes
V10Generation change inside a query, nested commands, source switchNo stale follow-on effect or revived receipt
V11Clamped or ignored range, partial write, delayed readback, exceptionUnknown result; no rollback or replay
V12Navigation, selection, punctuation, Tab, Enter, shortcutsHost action happens once; no trigger, no stale receipt
V13Escape, host cancel, app quit, server quit, source away and backDocuments stable; lifetimes drained
V14Read-only, password, custom, code, terminal, remote controlsNo prohibited read or write; input not swallowed
V15Emoji, non-BMP, combining marks, multi-line textPreserved exactly
V16Dictionary edit, Learn Spelling and Unlearn, atomic save, symlink, missing, invalid, oversized, restoreLast good data kept; manual conversion unaffected
V17Fresh install, enable, select, restart, log out and inActual typing works, not just registration
V18Windows: denied lock, async grant, null composition, terminated contextCorrect key disposition; no stale edit

For each application record the OS and app versions, control type, backend, automatic and manual correction, reversal, native Undo, source switching, focus behavior and failures. Start with TextEdit, Safari and Firefox text areas, then a contenteditable editor, a native text field, an Electron app and an office editor. Treat IDEs, terminals and remote sessions as exclusion and manual-availability checks first.

Browser fixture

browser-fixture.html is a standalone page with one textarea holding fixed prefix and suffix text (including a surrogate pair), with spellcheck, autocorrect and autocomplete off. Its four scenarios (EN automatic, manual, reversal, RU automatic) record ordered full-field checkpoints, composition events and the final UTF-16 caret, and give a pass or fail verdict. The report holds flags, positions and counts, never text. It can’t prove which input method produced the input. ./tools/verify browser-fixture checks the oracle itself, not a browser.

Performance targets

Targets for a release build on Apple Silicon, to measure rather than assume: pure inference p99 under 1 ms for the longest eligible word; Space to verified visible update p95 under 20 ms and p99 under 50 ms over at least 1,000 boundaries per control; idle under 0.5% of one core over five minutes with dictionary monitoring; RSS under 100 MiB; ready in under a second. None has been measured end to end yet.

Status

CI runs on each change: the default check on macOS, Windows and Linux, the sanitizers, audit, coverage, Miri, fuzzing and evaluation on macOS, and the Markdown check and the site build on Linux. The browser fixture’s self-check runs only locally (./tools/verify browser-fixture). The run page has the results and the line-level coverage report, so this page doesn’t repeat numbers that go stale.

Physical results, for the build that produced them: on the v0.1.0 source the maintainer typed by hand with the model policy in TextEdit, in a Safari text field and address bar, and in a Firefox text area. Automatic correction, Control+Option+K, Control+Option+Z and the mode switch after a correction behaved as expected in all three. Nothing since has a physical result: the default paths computed in Rust, the Learn Spelling list and the input menu’s status line. Known open questions, to check first:

  • The Learn Spelling list lives in Apple’s spell-service group container; whether the input method’s read raises an “access data from other apps” prompt is unknown.
  • VoiceOver uses Control+Option as its modifier, so Control+Option+K is also VoiceOver’s Keyboard Help; which one receives the key with VoiceOver on is untested.
  • Safari: in the browser fixture, manual conversion and reversal once left the field one UTF-16 unit short, consistent with a missing trailing Space. The hand run didn’t show it, but the fixture hasn’t been rerun.
  • ChatGPT desktop gets no automatic correction; the cause is unknown.
  • Compatibility: repeated corrections in Notes, terminal behavior, live source switching and permission retention across updates.

When reporting a problem from real use, include the application and version, the backend, the input menu’s first line, its “Last word left alone” row and dictionary state, and a synthetic reproduction (what you typed and what you got). Don’t paste private text.