mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
* 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. * docs(hex-words): Android parses with its own strict parser org.json is lenient and neither it nor android.util.JsonReader runs in the app's JVM unit tests, which is where the shared cases run. Verified: markdownlint-cli2 clean. * docs(hex-words): pin refusal order and out-of-range numbers; clarify writer order and phone scope The Android builder found three places where implementations could disagree: - Two problems in one file: the spec said 'the first met' but no case pinned it. It now says where each problem is met, and three cases pin it (duplicate key first, too deep first, syntax error first). - A number a 64-bit float can't hold (1e400, a 400-digit integer): serde_json refuses it, while other parsers read it as infinity. It is now notJSON wherever it appears, with two cases. - A writer checks a full list's limit first, in the reader's order. Also written down: on a phone, Word replacements apply to the app's and the keyboard's dictations (never translated ones), and on Android learned fixes are 'in use' only while Learn from my fixes is on. Verified: the reference reader (now a single sequential check pass) regenerates read.json with only the five new cases changed; merge.json and write.json are unchanged; markdownlint-cli2 is clean. * docs(hex-words): a phone's spelling-replacement that repeats an earlier one is a duplicate The iPhone builder asked what happens when two terms in one file share a spelling: on a phone both would become replacements with the same heard words. The spec only covered a spelling against the file's own replacements. Now: the earlier one wins (the file's own replacements come first), and a later one is notApplied as duplicate. One new phone merge case. Verified: the reference merger regenerates merge.json with only the new case added (25 cases); read.json and write.json unchanged; markdownlint clean.
128 lines
5.3 KiB
JSON
128 lines
5.3 KiB
JSON
{
|
||
"description": "Writing. Give the writer input (the app's own lists, in the shape shown), parse what it wrote, remove madeBy, and compare to expect.file; compare the entries it left out to expect.notExported as a set. Also check that the written file is UTF-8 without a byte order mark, passes hex-words.schema.json, has madeBy.app, and reads back with nothing skipped.",
|
||
"cases": [
|
||
{
|
||
"name": "Desktop: the vocabulary with its spellings and the Global mode's replacements, a deletion included; other modes' replacements stay home; soundsLike is left out when a term has none",
|
||
"writer": "desktop",
|
||
"input": {
|
||
"vocabulary": [{"term": "OpenCode", "soundsLike": ["open code"]}, {"term": "Rune", "soundsLike": []}],
|
||
"replacements": [{"matchedPhrase": "jet hub", "output": "GitHub"}, {"matchedPhrase": "um", "output": ""}],
|
||
"modes": [{"name": "Chat", "replacements": [{"matchedPhrase": "dash dash", "output": "--"}]}]
|
||
},
|
||
"expect": {
|
||
"file": {
|
||
"format": "hex.words",
|
||
"version": 1,
|
||
"vocabulary": [{"term": "OpenCode", "soundsLike": ["open code"]}, {"term": "Rune"}],
|
||
"replacements": [{"heard": "jet hub", "write": "GitHub"}, {"heard": "um", "write": ""}]
|
||
},
|
||
"notExported": []
|
||
}
|
||
},
|
||
{
|
||
"name": "Desktop: text is written cleaned: composed (NFC), spaces collapsed in terms, spellings and heard phrases, and CR LF in an output becomes LF",
|
||
"writer": "desktop",
|
||
"input": {
|
||
"vocabulary": [{"term": " Zoë Smith ", "soundsLike": ["zoey smith"]}],
|
||
"replacements": [{"matchedPhrase": " sign off ", "output": "Best,\r\nRyan"}],
|
||
"modes": []
|
||
},
|
||
"expect": {
|
||
"file": {
|
||
"format": "hex.words",
|
||
"version": 1,
|
||
"vocabulary": [{"term": "Zoë Smith", "soundsLike": ["zoey smith"]}],
|
||
"replacements": [{"heard": "sign off", "write": "Best,\nRyan"}]
|
||
},
|
||
"notExported": []
|
||
}
|
||
},
|
||
{
|
||
"name": "Desktop: entries a reader would skip are left out and counted, never written",
|
||
"writer": "desktop",
|
||
"input": {
|
||
"vocabulary": [
|
||
{"term": "OpenCode", "soundsLike": []},
|
||
{"term": "Hex", "soundsLike": ["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "hex", "hecks"]},
|
||
{"term": "--", "soundsLike": []}
|
||
],
|
||
"replacements": [
|
||
{"matchedPhrase": "one two three four five six seven eight nine", "output": "9"},
|
||
{"matchedPhrase": ":)", "output": "🙂"},
|
||
{"matchedPhrase": "fine", "output": "Fine"}
|
||
],
|
||
"modes": []
|
||
},
|
||
"expect": {
|
||
"file": {
|
||
"format": "hex.words",
|
||
"version": 1,
|
||
"vocabulary": [{"term": "Hex", "soundsLike": ["hecks"]}],
|
||
"replacements": [{"heard": "fine", "write": "Fine"}]
|
||
},
|
||
"notExported": [
|
||
{"path": "vocabulary[0]", "reason": "hiddenCharacters"},
|
||
{"path": "vocabulary[1].soundsLike[0]", "reason": "tooLong"},
|
||
{"path": "vocabulary[1].soundsLike[1]", "reason": "sameAsTerm"},
|
||
{"path": "vocabulary[2]", "reason": "noLetters"},
|
||
{"path": "replacements[0]", "reason": "tooManyWords"},
|
||
{"path": "replacements[1]", "reason": "noLetters"}
|
||
]
|
||
}
|
||
},
|
||
{
|
||
"name": "Desktop: empty lists still write both parts, empty",
|
||
"writer": "desktop",
|
||
"input": {"vocabulary": [], "replacements": [], "modes": []},
|
||
"expect": {
|
||
"file": {"format": "hex.words", "version": 1, "vocabulary": [], "replacements": []},
|
||
"notExported": []
|
||
}
|
||
},
|
||
{
|
||
"name": "Phone: terms and your own replacements; learned fixes stay out while the switch is off",
|
||
"writer": "phone",
|
||
"input": {
|
||
"vocabulary": ["OpenCode", "Rune"],
|
||
"replacements": [{"heard": "jet hub", "write": "GitHub"}],
|
||
"learnedFixes": [{"heard": "cloud code", "meant": "Claude Code", "active": true}],
|
||
"includeLearned": false
|
||
},
|
||
"expect": {
|
||
"file": {
|
||
"format": "hex.words",
|
||
"version": 1,
|
||
"vocabulary": [{"term": "OpenCode"}, {"term": "Rune"}],
|
||
"replacements": [{"heard": "jet hub", "write": "GitHub"}]
|
||
},
|
||
"notExported": []
|
||
}
|
||
},
|
||
{
|
||
"name": "Phone: with the switch on, learned fixes in use follow your own replacements marked learned; a learned fix for words you already replace is left out, and one switched off or not yet applied is never exported",
|
||
"writer": "phone",
|
||
"input": {
|
||
"vocabulary": ["OpenCode"],
|
||
"replacements": [{"heard": "jet hub", "write": "GitHub"}],
|
||
"learnedFixes": [
|
||
{"heard": "cloud code", "meant": "Claude Code", "active": true},
|
||
{"heard": "Jet Hub", "meant": "JetHub", "active": true},
|
||
{"heard": "pie torch", "meant": "PyTorch", "active": false}
|
||
],
|
||
"includeLearned": true
|
||
},
|
||
"expect": {
|
||
"file": {
|
||
"format": "hex.words",
|
||
"version": 1,
|
||
"vocabulary": [{"term": "OpenCode"}],
|
||
"replacements": [
|
||
{"heard": "jet hub", "write": "GitHub"},
|
||
{"heard": "cloud code", "write": "Claude Code", "learned": true}
|
||
]
|
||
},
|
||
"notExported": [{"path": "learnedFixes[1]", "reason": "duplicate"}]
|
||
}
|
||
}
|
||
]
|
||
}
|