Skip to content

fix(isc): decode \U escapes; duplicate ruleset is a load error (G7) - #51

Merged
ronaldtse merged 2 commits into
mainfrom
fix/cross-runtime-convergence-u-escape-g7
Nov 23, 2026
Merged

ronaldtse merged 2 commits into
mainfrom
fix/cross-runtime-convergence-u-escape-g7

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Summary

Closes the two remaining cross-runtime divergences (uppercase-Ў golden replay exclusion from #49, and the parity-G7 duplicate-ruleset semantics) by converging py on the trio's behavior. Every target behavior is the MAJORITY behavior on fresh origin/main clones of ruby/ts/rs — no new semantics invented.

1. Capital-\U escape now decodes (Finding 1: the 3 excluded golden rows)

_quoted_string rendered \U as a literal "U" with the digits as raw text, so the three Belarusian maps' uppercase-Ў rules (sub "\U040E" "Ŭ" / "W") never fired and the rows passed Ў through:

map golden py before py after
gki-bel-Cyrl-Latn-2000 Ŭ Ў Ŭ
mvd-bel-Cyrl-Latn-2008 W Ў W
odni-bel-Cyrl-Latn-2015 W Ў W

The old behavior cited a "ts carries the same deviation" parity note from the 0.1.x hand parser — stale since the WO19 G6 fix (ts decodes both spellings; ruby/rs always did; grammar esc_uni = "U" (4*8hexd) as unicode, esc_u_lone only the non-hex fallback). Implemented as the grammar's ordered alternatives: 4..8 hex digits decode greedily (9th digit stays raw), fewer than 4 → literal U with digits raw. Edge shapes verified ruby-identical 4/4 (\U00000041→A, \U000000410→A0, \U00e9→é, \Uab→Uab); \u short forms still reject 4/4.

Convergence: the golden corpus replay (tests/golden/isc-wf0.jsonl, rs origin/main capture, 16,322 rows) now runs with NO exclusions and is byte-identical 16,322/16,322 — exactly the 3 rows above converge (all rows of the 3 previously-excluded maps now replay; their other rows already matched), zero other rows change (the only corpus uses of the single-backslash capital escape are these 3 maps; the doubled-backslash \\U040E literal forms in bgnpcgn-bel-1979 / alalc-bel-1997 / mvd-rus-2008 are untouched and still pass). The replay test's exclusion set and its rationale are removed.

Pins: tests/test_isc.py::test_capital_escape_decodes_and_falls_back (replaces test_capital_escape_stays_literal_u, ruby-measured edges).

2. Duplicate ruleset declaration is a named load error (Finding 2: parity-G7)

The 0.2.x parser rewrite lost the 0.1.0 check the WO18 G7 round cites as canon ("py canon"): doc_rulesets' dict comprehension silently let the last ruleset a win — measured xz → x3 on maps probe tst-rsdupdef.isc where ruby/ts/rs all reject on current mains (ruby MapLogicError ruby#854, ts IscLoadError ts#138, rs MapLogicError rs#19, pins: wf1_semantics_spec.rb / wf1.test.ts / tests/wf1.rs::duplicate_ruleset_is_a_load_error).

py now raises its named-load-error family class (UnsupportedConstruct, same class as its cycle/unknown-ruleset rejections) with the ts-shaped message ruleset "a" declared more than once in <systemCode> — at the ruleset-table build for the loading document, and in _owner_rulesets for dependency documents (the trio validate every document they build). Contract recorded upstream on interscript/maps#293.

Pins: tests/test_wf1.py::test_duplicate_ruleset_declaration_is_a_named_load_error (block-use and stage-level-use forms, message shape asserted).

Proof

  • Full pytest tests/ green with both fixes (the 16,322-row replay included, no exclusions).
  • Pre-fix baseline: same suite green before the changes (58 tests of the two touched files; the replay passed only because the 3 maps were excluded).
  • G7 probes: both tst-rsdupdef / tst-rsdup2 now reject; four-runtime matrix re-probed on fresh clones (ruby/ts/rs reject, py rejects).

…lback)

The parser rendered \U as a literal "U" with the digits as raw text — a
stale 0.1.x ts hand-parser parity note (ts decodes both spellings since
the WO19 G6 fix; ruby/rs always did; grammar/isc.parg esc_uni =
"U" (4*8hexd) as unicode, esc_u_lone only the non-hex fallback).

Consequence: the three Belarusian maps' uppercase-Ў rules
(sub "\U040E" "Ŭ" / "W") never fired, and the golden corpus replay
carried a standing exclusion for all rows of gki-bel-Cyrl-Latn-2000,
mvd-bel-Cyrl-Latn-2008 and odni-bel-Cyrl-Latn-2015 (py#49's tracked
divergence). All 68 rows of those maps now replay byte-identically
(16,322/16,322 with no exclusions); exactly the 3 uppercase-Ў rows
converge — every other corpus row is unchanged (the only corpus uses
of the single-backslash capital escape are these 3 maps; the
doubled-backslash \\U040E literal forms elsewhere are untouched).

Edge shapes are ruby-measured 4/4: \U00000041 -> A; \U000000410 -> A0
(first 8 hex consumed, a 9th stays raw); \U00e9 -> é; \Uab -> Uab
(fewer than 4 hex digits = esc_u_lone literal "U", digits raw).
Lowercase \u short forms still reject, as before.
The 0.2.x parser rewrite lost the 0.1.0 check that the WO18 G7 round
cites as canon ("py canon"): the ruleset-table dict comprehension let
the last `ruleset a` silently win, so py accepted maps the trio reject
— measured "xz" -> "x3" on maps docs/parity probe tst-rsdupdef.isc
(ruby MapLogicError #854, ts IscLoadError #138, rs MapLogicError #19,
all current mains). Keep-first/last-wins hides map bugs and makes the
executed body declaration-order dependent; spec section 6 item 4
already makes the adjacent cycle case a load error.

py now raises its named-load-error family class (UnsupportedConstruct,
the same class as its cycle / unknown-ruleset rejections) with the
trio's message shape — ruleset "a" declared more than once in
<systemCode> — at the ruleset-table build, and for dependency
documents in _owner_rulesets (the trio validate every document they
build). Pins both use forms: block-position `use` and stage-level
`use`.
@ronaldtse
ronaldtse merged commit d68faaa into main Nov 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant