From ba5b4e224e3a393d27a1387ff2ea8aab4f9db47f Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 11 Nov 2026 22:07:18 +0800 Subject: [PATCH] fix: Item::Alias#max_length counts 1 for map-local aliases - rs parity The deterministic parallel sort (megaregexp path) raised NotImplementedError for any non-stdlib alias, erroring whole passes: 33 golden rows across un-ara-Arab-Latn-1971/1972 and the odni-rus Arabic variants carried a standing cross-runtime exemption. The rs runtime - the golden source, at zero deltas - counts every alias as max_length 1 (rs Item::max_length: Prim/Alias => 1, 0 for none), and alias resolution would need document context the sort site does not carry. The ruby runtime now mirrors that. Specs watched failing first: the pinned-to-rs integration row through the megaregexp path, and the unit counts (any alias 1, none 0). Verified: ruby golden gate parity 12,337 rows -> delta 0 (was 33); full suite 409 examples 0 failures; the WO80 capture-in-parallel NoMethodError pin is unaffected (different class, capture stays unsupported in parallel). --- lib/interscript/node/item/alias.rb | 7 ++++-- spec/isc/semantics_spec.rb | 37 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/interscript/node/item/alias.rb b/lib/interscript/node/item/alias.rb index 79f3914f..66a6923c 100644 --- a/lib/interscript/node/item/alias.rb +++ b/lib/interscript/node/item/alias.rb @@ -14,12 +14,15 @@ def boundary_like? Interscript::Stdlib.boundary_like_alias?(name) end + # rs parity (WO17): the deterministic parallel sort counts every + # alias as 1 (0 for none) — rs Item::max_length treats Prim/Alias + # uniformly, and resolving the expansion here would need document + # context the sort site does not carry. def max_length if stdlib? [:none].include?(name) ? 0 : 1 else - return 1 if name == :unicode_hangul - raise NotImplementedError, "can't get a max length of this alias" + 1 end end diff --git a/spec/isc/semantics_spec.rb b/spec/isc/semantics_spec.rb index 65c30790..6bb8a1e7 100644 --- a/spec/isc/semantics_spec.rb +++ b/spec/isc/semantics_spec.rb @@ -138,6 +138,43 @@ def context_map(id, rule) .to raise_error(NoMethodError, /max_length/) end end + + # WO17 — rs parity: the deterministic parallel sort counts every + # alias as max_length 1 (rs Item::max_length: Prim/Alias => 1). The + # reference runtime raised NotImplementedError for map-local aliases, + # erroring the whole megaregexp pass — 33 golden rows across the + # Arabic maps. Pinned to the rs outputs for the same document. + it "rules: a map-local alias in a megaregexp pass sorts like the rs runtime (WO17)" do + body = <<~ISC + system "TST:xx-Arab:Latn:31" { + metadata { + authority_id tst + id 31 + language iso-639-2:xx + source_script Arab + destination_script Latn + } + aliases { + arab_letter = any("ابتثجحخدذرزسشصضطظعغفقكلمنهوي") + } + stage main { + parallel { + sub { from "ب" + arab_letter to "X" not_before "ن" } + } + } + } + ISC + with_map("tst-aliasmax-1.isc", body) do + expect(Interscript.transliterate("tst-aliasmax-1", "بتة")).to eq("Xة") + expect(Interscript.transliterate("tst-aliasmax-1", "بتن")).to eq("Xن") + end + end + + it "rules: Item::Alias#max_length counts 1 for any alias (rs parity, WO17)" do + expect(Interscript::Node::Item::Alias.new(:some_document_alias).max_length).to eq(1) + expect(Interscript::Node::Item::Alias.new(:none).max_length).to eq(0) + expect(Interscript::Node::Item::Alias.new(:arab_alphabet).max_length).to eq(1) + end end RSpec.describe "ISC semantics — run and to-directives" do