Repository navigation
Unicode Gauntlet vs tree-sitter: the international text foundation, side by side - #3953
Merged
Merged
Conversation
tests/tools/unicode_gauntlet_vs_treesitter.py runs the gauntlet's metamorphic oracle on the function-name channel for three readings of every cell: GitGalaxy (the gauntlet's own scans), tree-sitter on the raw file bytes, and tree-sitter after decoding with the cell's true encoding. Cells count only where tree-sitter has a grammar + node map and both engines pass a control against keyword-rosetta's hand-verified answer key; Dart's non-ASCII renames are excluded as illegal programs. Writes results.json, summary.json (chart-ready) and report.md. unicode_gauntlet.run() gains an optional cells_out hook so the comparison reuses the same estates and scans instead of re-planning them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5
Comment on lines
+428
to
+431
| "- The oracle is the gauntlet's own metamorphic design, `facts(T(seed)) == T(facts(seed))`, applied to one " | ||
| "channel: the multiset of function names (case-folded, as the gauntlet compares) in the files tree-sitter " | ||
| "reads. Each engine is compared with ITSELF on the cell's reference, so a construct an extractor misses on " | ||
| "both sides cancels out; only what the script or the encoding changes counts.", |
Comment on lines
+432
to
+434
| "- The gauntlet (and so the rename list) was designed around GitGalaxy: the renamed units are the functions " | ||
| "GitGalaxy found in the seed. Controls guard the other side: a language counts only where tree-sitter finds " | ||
| "every function keyword-rosetta's hand-verified answer key lists on the UTF-8 seed.", |
Comment on lines
+435
to
+437
| "- tree-sitter's side is its raw reading through tree_sitter_accuracy_audit's NODE_MAPS / `_get_node_name` -- " | ||
| "not the audit's reconciled ground truth. A language absent from NODE_MAPS is `ts-no-grammar` even when the " | ||
| "pack has a grammar (objective-c, cobol, ...), because writing node maps here would be a new extractor.", |
Comment on lines
+438
to
+440
| "- `ts-raw` hands tree-sitter the file's bytes, as tree-sitter-based tools do. It has no notion of a BOM, " | ||
| "UTF-16 or a legacy code page; `ts-decode` shows what a careful integrator gets by decoding first. A name " | ||
| "whose bytes are not UTF-8 is recorded as broken, never decoded with a lossy handler.", |
Comment on lines
+441
to
+443
| "- GitGalaxy decodes Shift-JIS, GB18030 and EBCDIC cells because the scan DECLARES the page " | ||
| "(`--source-encoding`, as the gauntlet runs them); cp1252 is undeclared (its fallback is what those cells " | ||
| "test). `ts-decode` gets the same knowledge of the true encoding; `ts-raw` gets none.", |
Comment on lines
+444
to
+448
| "- Legality: the renames follow the gauntlet's legality.json. Dart is excluded (`not-legal`): its spec allows " | ||
| "ASCII letters only, so a grammar refusing `probeBranch名前` is correct. Other languages' rules for combining " | ||
| "marks (Mn / Mc: Devanagari, Tamil, NFD) were NOT checked against each spec here -- Kotlin's grammar names " | ||
| "only L* letters and Nd digits, so some of tree-sitter-kotlin's Devanagari / Tamil / NFD failures may be " | ||
| "the grammar rejecting code its compiler would too. Han / Hangul (Lo letters) are legal where Unicode is.", |
Comment on lines
+450
to
+451
| "- Parameter counts, classes and the other channels are not compared; `gauntlet_all_channels_pass` in " | ||
| "results.json carries GitGalaxy's full gauntlet verdict for reference.", |
Comment on lines
+452
to
+453
| "- The default plan samples two encodings per script (the gauntlet's CI plan); `--full` runs every " | ||
| "(script, encoding) pair, including cp1252.", |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of epic #3811 (Tours the Globe): how GitGalaxy's international text foundation compares with tree-sitter on the same cells, under the same oracle.
What it measures
tests/tools/unicode_gauntlet_vs_treesitter.pyreuses every Unicode Gauntlet cell (language × script × encoding, including line endings) and GitGalaxy's scans of them. It then applies the gauntlet's metamorphic oracle,facts(T(seed)) == T(facts(seed)), to the one channel both engines produce: the multiset of function names in the files tree-sitter can read. Each engine is compared with its own reading of the cell's reference, so to pass a cell it must find the same number of functions with every name whole. Three readings:function_data).tree_sitter_accuracy_audit'sNODE_MAPS/_get_node_name. A name that isn't valid UTF-8 is recorded as broken, with its bytes. It is never decoded with a lossy handler.Methodology and caveats
expected_function_nodes. Controls: GitGalaxy 29/29 languages, tree-sitter 27/29 (fortran misses 3 functions and objective-c's.hfiles read as C find 0, so both are excluded ascontrol-fail).not-legal). The Dart spec allows only ASCII letters in identifiers, but the gauntlet'slegality.jsonlists Dart as a Unicode-identifier language, so its non-ASCII cells aren't valid programs. tree-sitter-dart correctly refuses them. GitGalaxy "passing" them only shows it is more permissive than the compiler. This is a flaw in the gauntlet's legality table, not an engine bug. I did not fix it here.--source-encoding). cp1252 is undeclared.ts-decodegets the same knowledge of the true encoding;ts-rawgets none.gauntlet_all_channels_passin results.json carries GitGalaxy's full verdict, which was 2725/2725.ts-no-grammar(no NODE_MAPS entry): the whole mainframe seed (COBOL, PL/I, JCL, HLASM, CSD, so every EBCDIC cell), groovy, scheme, sqlite, ada, yaml and others. I didn't write new node maps.Headline:
--fullrun, 2725 cells, 1881 attemptable, 398 s wall with--jobs 8tree-sitter beat GitGalaxy on no cell.
By encoding (GitGalaxy / ts-raw / ts-decode): utf-8 100 / 95.0 / 95.0 · utf-8-sig 100 / 95.0 / 95.0 · crlf 100 / 95.0 / 95.0 · utf-16 100 / 0 / 95.0 · utf-16-be 100 / 0 / 95.0 · cp1252 100 / 0 / 100 · shift_jis 100 / 0 / 97.2 · gb18030 100 / 0 / 94.4.
What still fails after decoding is the grammar: Devanagari and Tamil 83%, Han, Hangul and NFD 89%. Examples: tree-sitter-haskell and tree-sitter-scala cut
probebranchनामtoprobebranchन, tree-sitter-kotlin returns justम, and tree-sitter-haskell and tree-sitter-kotlin drop名前. Raw failures: cp1252éèçcomes through as invalid UTF-8 bytes; UTF-16 files give 0 functions or phantom 1-letter names; GB18030 and Shift-JIS produce cut or missing names.Run it
It writes
DIR/results.json(per cell: each reading's verdict and first difference),DIR/summary.json(chart-ready engine × script / encoding / language pass rates) andDIR/report.md. The default is the gauntlet's sampled plan;--fullruns every (script, encoding) pair.tests/tools/test_unicode_gauntlet_vs_treesitter.pyskips cleanly withouttree_sitter_language_pack. It covers the pure parts and runs a small real run (python, java and lua × French × UTF-8, UTF-16 and cp1252), asserting thatpython|french|cp1252fails tree-sitter raw and passes both GitGalaxy and ts-decode.The only change to
unicode_gauntlet.pyis an optionalcells_outhook onrun(). No engine code changed.pr_gates.py --fastpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5