hex/tests/fixtures/hex-words/README.md
Ryan Vogel ff9c7fc1a2 docs: define the Hex words file (.hexwords), version 1, with shared cases
Ryan approved sharing vocabulary and word replacements between the desktop,
iPhone and Android apps through a file the person moves themselves. Three
builders start from this in parallel, so the format is written down and frozen
first, with cases all three apps must pass.

- docs/specs/hex-words.md: every field and limit, how text is cleaned and
  compared, the reading order with its refusal and skip reasons, versions,
  what each app writes, the merge rules (desktop and phone) and Undo, the
  file's name and type on each platform, and what a reader must never do.
- tests/fixtures/hex-words: read.json (54 cases over files/, from small to
  hostile: not UTF-8, 10,000 levels deep, duplicate keys, lone surrogates,
  8 MiB + 1 byte generated), merge.json (24 desktop and phone cases),
  write.json (6 cases) and hex-words.schema.json (JSON Schema 2020-12 for
  writer output). files/ is byte-exact (-text -whitespace).
- docs/README.md links the spec.

No app code changes. The typing config (.mhexconfig) stays separate: its
parts need evidence and Full Access, and it describes one phone's keyboard.

Verified: the expected results were produced by a throwaway Python reference
reader, merger and writer (not committed) and read through by hand; every
write.json output and the valid read results re-written validate against the
schema with jsonschema 4.26, and five malformed writer outputs are rejected;
a file with every list at its limits in 4-byte characters is 6.5 MiB, under
the 8 MiB cap; markdownlint-cli2 is clean on the new docs.
2026-11-24 17:45:25 -05:00

23 lines
1.4 KiB
Markdown

# Hex words file: shared cases
The cases every Hex reads, merges and writes `.hexwords` files against: the desktop app
(Rust), Hex for iPhone and Hex for Android. The format is defined in
[`docs/specs/hex-words.md`](../../../docs/specs/hex-words.md). This folder only proves it.
- **`read.json`**: one case per file in `files/`. Read its bytes (or, for `generate`, the
base file followed by spaces up to `padWithSpacesTo` bytes) and compare the whole result to
`expect`. Compare `skipped` as a set of `{path, reason}`. Where a case has `skippedCounts`
instead, compare the number of skips per reason.
- **`merge.json`**: `merge(receiver, before, incoming, limits, parts, choices)` against
`expect`. `receiver` is `desktop` or `phone`, and `limits` overrides the receiver's own
for that case. Undo after each case must give back `before`.
- **`write.json`**: give the writer `input`, parse what it wrote, drop `madeBy`, and compare
to `expect.file`. Compare `expect.notExported` as a set. The written bytes must also be
UTF-8 without a byte order mark, pass `hex-words.schema.json`, and read back with nothing
skipped.
- **`hex-words.schema.json`**: JSON Schema 2020-12 for what a writer writes.
Some files here are broken on purpose: not UTF-8, UTF-16, 10,000 levels deep. Keep them byte for
byte. Don't reformat them, and don't let an editor fix their encoding.
A change to the definition that changes an outcome changes these cases in the same pull request.