Repository navigation
Respect multibyte source boundaries in literals and regexp validation - #247
Conversation
284km
left a comment
There was a problem hiding this comment.
Review of 1fa3c3b
Verdict: not ready to merge. One Major and one Minor finding are open. Most of the lexer fix works, and I saw no regression from main.
What I ran
Builds:
- PR: the author's build at 1fa3c3b. The tree is clean, and the binary is newer than every
.merefile. The last commit only renames corpus files and adds records. - main: a clean build at 66a7afd. This is an ancestor of the PR base 2137de2. The two differ in
m_parse.mere/main.mereonly by unrelated work. - Reference: clean Ruby 4.0.10.
"Evaluator" means MERE_RUBY_VM is unset. "VM" means MERE_RUBY_VM=1.
I wrote 233 source files as raw bytes in Windows-31J, Shift_JIS, EUC-JP, Big5, GBK, GB18030, EUC-KR and UTF-8. They cover "", '', %w %W %i %I %q %Q %(), quoted and bare symbols, ?x, regexp literals (with classes, %r, interpolation), plain, dash, squiggly and quoted heredocs, a line continuation after a trail character, multi-line strings, interpolation inside and around the character, identifiers, methods and constants, backticks, __ENCODING__, valid_encoding? and bytes. The characters used have a trail byte of 0x5C, 0x5B, 0x5D, 0x60, 0x7B, 0x7C or 0x7D (for example 表 ソ 能 十 ボ マ, Big5 許 功 么 叻, GBK 乗 俓 亄). I ran each file in four ways: as the main script, through require, through eval(str) and through instance_eval(str). I compared stdout and the exit status with Ruby. That makes 932 comparisons per build. I ran two smaller follow-up sets as well.
| result (932 cases) | count |
|---|---|
| same as Ruby on main and on the PR | 456 |
| fixed by the PR, evaluator and VM | 241 |
| fixed by the PR, evaluator (the VM was already right) | 123 |
wrong on main and on the PR (GB18030 and EUC-JP/EUC-KR [X-X]; see below) |
71 |
| GB18030, wrong on the evaluator on both builds | 33 |
| right on main but not on the PR | 8 (all the Prism note below) |
- UTF-8: 0 differences from Ruby on either build.
- Big5/GBK identifiers, constants, methods,
?中,:中and%w: all fixed. - The Big5
valid_encoding?/chrcases: fixed. - On the PR, the GB18030 output is byte-for-byte the same as on main.
enc_db_ranges: I listed every one- and two-byte sequence with Ruby 4.0.10.
- Big5, CP950, CP951, Big5-HKSCS and Big5-UAO all have lead A1-FE and trail 40-7E/A1-FE.
- GBK and CP936 have lead 81-FE and trail 40-7E/80-FE, and the single byte 0x80 is valid.
- The PR's ranges match these exactly. (Ruby refuses Big5 0x81-0xA0 leads, so the 161 lead is right.)
Speed: I counted instructions retired, three runs per build, alternating.
- A 600 KB UTF-8 file full of Japanese strings, comments,
%wand regexps (exitfirst, so mostly parse): main 20.44G, PR 20.53G (+0.45%). - A 213 KB ASCII file: no change beyond noise.
- The author's mapper.rb numbers look plausible. That file is ASCII, so it does not exercise the new non-ASCII branches. The Japanese file does, and the cost is small.
Merge: git merge-tree with current main (323706a) is clean. #239 adds no byte-by-byte string scanner, so I see no semantic overlap. The open #245 changes parameter parsing only, and a merge of #245 and #247 is also clean.
Findings
1. Major: a character class that contains a trail-0x5C character is still a SyntaxError. Repro, in a # coding: Windows-31J file:
p(/[表]/ =~ "表") # ruby 0; PR: premature end of char-class: /[\x95\]/ (SyntaxError)
p(/[a表]+/ =~ "b表") # ruby 1; PR: same error
p(/[表-表]/ =~ "表") # ruby 0; PR: same error
p Regexp.new("[表]") =~ "a表" # ruby 1; PR: RegexpError
p "a表b".scan(/[表]/).size # ruby 1; PR: SyntaxError- The same happens in Big5 (
/[許]/) and GBK (/[乗]/), on both the evaluator and the VM, in all four ways of loading. - The lexer now passes the literal through, but the regexp parser does not take the whole character.
rxp_skip_classandrxp_class_itemsinm_eval_leaf.meretest for\before they look at the character width. So the trail byte escapes the closing]. - The round-60 check (
rx_check_go) now selects the right encoding, but it reaches the same class parser. - Related, and the same on main: in EUC-JP and EUC-KR,
/[ソ-ソ]/is "empty range in char class". Ruby accepts it. - The handed-over hole named regexps, and classes are the common case. Corpus 991 has no class, so this was missed.
2. Minor: a backslash in front of a multibyte character. In Ruby, \ followed by a non-ASCII character gives the character itself. Repro in Windows-31J:
p "\表".bytes # ruby [149, 92]; PR: SyntaxError (unterminated string)
p "a\表b".bytes # ruby [97, 149, 92, 98]; PR evaluator: [97, 149, 8] (the trail became `\b`)
p %w[\表 x].map(&:bytes) # ruby [[92,149,92],[120]]; PR evaluator: [[92,149,32,120]]
p /\表/.source.bytes # ruby [149, 92]; PR: SyntaxError
p :"\表".to_s.bytes # ruby [149, 92]; PR: SyntaxError
p <<E.bytes
\表
E
# ruby [149, 92, 10]; PR evaluator: [149] (main: SyntaxError)- The escape branches (
lex_dq,lex_dstr_buf,pw_word, the regexp and heredoc readers) still take one byte after\. - The VM gets the main-script and require cases right.
- Main is just as wrong for most of these. The heredoc case went from a SyntaxError to silently wrong bytes, so I rate it Minor rather than a Suggestion.
- Suggested fix: when the byte after
\is 0x80 or above, takelex_src_cwbytes there.
3. Suggestion (follow-up, unchanged from main): GB18030.
- GB18030 has the same two-byte trail range as GBK, so
乗(81 5C) breaks every literal in the same way. - Example:
p "乗".bytesis "unexpected backslash" on the evaluator. On the VM it is right only throughrequire. enc_clen1has no width for GB18030, and four-byte sequences would need one too.
4. Suggestion (follow-up, runtime): Regexp.escape and Regexp.union double the trail byte.
Regexp.escape("表")in Windows-31J gives[149, 92, 92]. Ruby gives[149, 92].Regexp.union("表", "x")has the same problem.- This is not the lexer, but it is the same hole.
Note (no action): instance_eval and a 0x5B trail.
- Ruby 4.0.10 itself refuses
/ゼ/(83 5B) in a Shift_JIS source with "empty char-class". This looks like a Prism bug, and it happens in all four ways of loading. - The PR gives Ruby's error as the main script, through require and through eval, because those go through the Prism check.
instance_eval(str)does not, so there it now accepts the code. - These are the 8 "right on main, not on the PR" rows. On main they only matched because main failed earlier, with a different error.
- Please keep 0x5B-trail characters out of regexps in the corpus.
What I only read
- The diff in
m_parse.mere,m_state.mere,main.mereandm_eval_leaf.mere, and the loop record and JSON. - The author's results: corpus
--both881/881, VM corpus 881/0/0, nine gates plus record_hygiene, and six unit files before and after. - I did not rerun the corpus, the gates or the unit files.
test_regexpandtest/ruby/encwere not in the author's list, although the regexp validation path changed. Please runtest_regexpon both modes.
Bot comments and CI
- There are no earlier reviews and no inline bot comments.
- CI at 1fa3c3b at the time of review: 5 workflows passed, and 4 were still queued (CI, Rake suite, Additional gem suites, Delegation and URI gem suites).
| else if str_contains fl "n" then "ASCII-8BIT" else if str_contains fl "u" then "UTF-8" else enc9) in | ||
| let old9 = vec_get cut_e 0 in | ||
| let old_u89 = vec_get rxp_u8 0 in | ||
| let _ = cut_set enc9 in |
There was a problem hiding this comment.
Major (finding 1): this check now runs under the source encoding, but rx_validate still reaches rxp_skip_class/rxp_class_items in m_eval_leaf.mere. Those test for \ before they look at the character width. So in Windows-31J /[表]/ is still premature end of char-class: /[\x95\]/ (SyntaxError), and Regexp.new("[表]") is a RegexpError. The same happens in Big5 (/[許]/) and GBK (/[乗]/). Ruby accepts all three.
There was a problem hiding this comment.
Fixed in f73f8c9. The class/group scanners and class atoms now use the pattern encoding and whole-character widths; ranges compare encoded character values. Corpus 991 checks Windows-31J, Big5 and GBK classes, Regexp.new and scan through main scripts, require, eval and instance_eval on both engines. Full corpus is 881/881 ON/OFF and 881 VM / 0 fallback / 0 differences. The requested test_regexp comparison is included: its 4 failures / 3 errors are identical on main and candidate, with no passing case lost.
Portable evidence: https://github.com/284km/mere-ruby/blob/codex-parse-multibyte-source/unittest/records/parse-multibyte-review.json
| let c = char_at s i in | ||
| if str_eq c term then (Cons (TP "+", Cons (TStrL (strbuf_to_str b), Nil)), i + 1) | ||
| if ord c >= 128 && (if lex_src_is_utf8 () then false else true) then | ||
| (let j = i + lex_src_cw s i in (let _ = strbuf_push b (substring s i j) in lex_dstr_buf b term s j)) |
There was a problem hiding this comment.
Minor (finding 2): the multibyte branch is taken only when the character is at i. In the escape branch below, \ followed by a multibyte character still takes one byte. In Windows-31J, "a\表b" gives [97, 149, 8] on the evaluator (the trail plus b became \b). Ruby gives [97, 149, 92, 98]. "\表", /\表/ and :"\表" are SyntaxErrors, and Ruby gives the character for all three. One fix: when the byte after \ is 0x80 or above, take lex_src_cw bytes there.
There was a problem hiding this comment.
Fixed in f73f8c9. Escaped non-ASCII characters are consumed in full in quoted strings, words, symbols, regexp literals and heredoc preprocessing. The expanded corpus 991 includes all the quoted/word/regexp/heredoc forms from this finding and runs them through all four entry paths on both engines; stdout and exit status match the clean reference.
284km
left a comment
There was a problem hiding this comment.
Re-review of 7da5fa1
Verdict: not ready to merge yet. Both earlier findings are resolved. The fix adds one new Minor problem (below): a regexp program cache that does not know the encoding.
Earlier findings
| # | finding | status |
|---|---|---|
| 1 | Major: a class with a trail-0x5C character was a SyntaxError | Resolved (run) |
| 2 | Minor: a backslash before a multibyte character | Resolved (run) |
| 3 | Suggestion: GB18030 | Follow-up accepted. Not identical to main; see below |
| 4 | Suggestion: Regexp.escape / Regexp.union double the trail byte |
Follow-up accepted. Still wrong, as on main |
What I ran
Builds:
- PR: the author's build at 7da5fa1. The tree was clean, and the binary was newer than every
.merefile. (At 13:03 local time the author rebuilt the binary from an uncommitted change infcb_pct_end/fcb_regex_end/fcb_quote_end. Everything in the tables below ran before that. The GB18030 set and two small checks ran partly on the new build. Those probes have no quote or backslash inside#{}, so the change does not reach them.) - main: a clean build at 66a7afd, as in the first review.
- Reference: Ruby 4.0.10.
"Evaluator" means MERE_RUBY_VM is unset. "VM" means MERE_RUBY_VM=1.
I wrote 418 source files as raw bytes in Windows-31J, Shift_JIS, Big5, GBK, EUC-JP, EUC-KR and UTF-8. They cover the earlier repros and more:
- Classes:
[X],[aX]+,[X-X],[^X],[\X],[a\X], a class inside(?:...)and(?=...),Regexp.new("[X]"),Regexp.new("[X-X]"), interpolation,Regexp.union,scan,gsub, and/[X]/ =~ "a\\"(this must not match a lone backslash). - Escapes:
"\X","a\Xb","\X\X",%w %W %i %Q,'a\Xb',:"\X",:"a\Xb#{1}","#{1}\X",/\X/and%r[\X](.source,.inspect, matching), plain, squiggly, quoted and continued heredocs, and backticks.
The characters were 表 ソ (Windows-31J), 表 (Shift_JIS), 許 功 (Big5), 乗 (GBK), ソ 表 (EUC-JP), ソ (EUC-KR) and 表 あ (UTF-8). I ran each file in four ways: as the main script, through require, through eval(str) and through instance_eval(str). I compared stdout and the exit status with Ruby on four engines (PR and main, evaluator and VM).
| result (1,672 cases) | count |
|---|---|
| fixed by the PR (right on the PR, evaluator and VM) | 1,010 |
| same as Ruby on all four engines | 590 |
| wrong on the PR and on main | 72 |
| right on main but not on the PR | 0 |
- All 72 "wrong on both" rows are
Regexp#inspectof a non-UTF-8 regexp. Ruby prints/\x{955C}/, and mere-ruby prints/\x95\/. Main prints/\x82\xA0/for/あ/in Windows-31J as well, so this is not new. (Suggestion, follow-up.) - EUC-JP and EUC-KR
/[ソ-ソ]/now match Ruby. - I ran 15 more escape forms in five encodings:
?\X,%q,%s,<<~with interpolation,/\X#{1}/,%r{\X#{1}},%W[a\X#{1}], named groups and/X\\/. The PR matches Ruby on both engines in all of them. .sourcedrops the backslash before a non-ASCII character, as Ruby does./\あ/.sourceis"あ"and/\表/.source.bytesis[149, 92]in Windows-31J./\\表/keeps both backslashes.
Regressions I looked for:
- A UTF-8 file with 49 regexp checks: classes, ranges,
\p{}, POSIX classes,&&, escapes,/i,/nand runtime patterns. The PR matches Ruby except for one known gap and the new finding below. Lookbehind with a class,/(?<=[あ])い/, is nil on both builds. - Binary patterns now work.
Regexp.new("[\xE3\x81\x82]".b) =~ "\x81".bis 0, as in Ruby. Main gave nil./[\xff]/nis right on both builds. - Invalid patterns: a lead byte at the end, an unterminated class and a reversed range raise RegexpError as Ruby does.
test_regexp: 176 tests, 62,595 assertions, 4 failures and 3 errors, the same on PR and main in both modes. The seven failing tests have the same names on both builds.test_m17n(seed 1): 3,812 assertions with the evaluator and 3,814 with the VM, the same on PR and main. The author's record shows 3,804 → 3,796 after f73f8c9. I could not reproduce that drop of 8. Could you say where it comes from?
New finding
5. Minor: the regexp program cache does not include the encoding, and class parsing now depends on it.
- After this PR,
rxp_clencuts a class bycut_k. So the same pattern bytes give a different program in UTF-8, in binary, and in Windows-31J. rx_cut_keyadds the encoding to the key only for/iand for classes with\. A pattern like[あ]gets one key for every encoding.- Whichever encoding is compiled first wins. Repro (UTF-8 file):
p Regexp.new("[\xE3\x81\x82]".b) =~ "\x81".b # ruby 0; PR 0 p(/[あ]/ =~ "あ") # ruby 0; PR nil (main 0) p "かい".sub(/[あい]/, "!") # after Regexp.new("[\xE3\x81\x82\xE3\x81\x84]".b): ruby "か!", PR "かい" (main "か!")
- Evaluator and VM behave the same. In the other order, the UTF-8 pattern is right and the binary one is wrong, as on main.
- The same happens between Windows-31J and binary:
Regexp.new(sj.b)first, thenRegexp.new(sj)withsj = "[あ]".encode("Windows-31J"), gives nil. - Main is already order-dependent for a quantifier: after
Regexp.new("\xE3\x81\x82+".b),/あ+/.match("ああ")gives one あ. This PR adds classes, and a plain UTF-8 class literal is the common case. - I rate it Minor because it needs the same raw bytes as a binary or other-encoding pattern earlier in the process. But the answer is silently wrong, and UTF-8 was right before.
- Suggested fix: in
rx_cut_key, addcut_k(orcut_e) to the key whenever the pattern has a non-ASCII byte. Please add the two-line repro to the corpus.
Follow-ups: same as main?
- Regexp.escape / union (finding 4): the output is the same wrong bytes as main (
[149, 92, 92]forRegexp.escape("表")). One visible change:Regexp.new(Regexp.escape("表")) =~ "a表"was 1 on the main VM throughrequire, by accident. Main read the pattern as UTF-8, so the doubled\\became a literal backslash. Now the pattern is read as Windows-31J, and the lone\at the end is a RegexpError. The root cause is the same. I accept it as a follow-up, but it is now an error rather than a quiet match. Please file it soon. - GB18030 (finding 3): I ran the same 38 forms for 乗 中 表 in GB18030 (456 cases). The output is no longer identical to main. The evaluator is right in 300 cases (main 155) and the VM in 331 (main 184). Characters without a 0x5C trail (中, 表) are now mostly right. 乗 (81 5C) is still broken. One case got worse:
instance_evalof/(?:a|[乗])+z/ =~ "a乗z"was 0 on main (by accident; every other 乗 class form fails there) and is nil now. I accept GB18030 as a follow-up on that basis.
Author's results and merge criteria
- The loop note and
unittest/records/parse-multibyte-review.jsongive results for runtime f73f8c9:- corpus
--both: 881/881 - VM corpus: 881 / 0 fallback / 0 differences
- eight prefix gates and record hygiene: pass
- seven CRuby files, including
test_regexpon both modes: no lost passing case
- corpus
- So the author's local results are posted.
- Not met: finding 5 (Minor) is open.
- I did not rerun the corpus, the gates or the unit files, except
test_regexpandtest_m17nas above.
What I did not check
- Speed. The note gives mapper.rb medians of +0.22%. That file is ASCII.
- Memory.
- Shift_JIS beyond 表.
- The author's uncommitted
fcb_*change. It is not in this head.
Bot comments, merge and CI
- No inline bot comments. Our two earlier inline comments (findings 1 and 2) are resolved.
git merge-treewith current main (a63e47c) is clean.- CI at 7da5fa1: 2 workflows passed (NKF Wasm engine, Linux build dependency controls). 7 are queued: CI, Rake suite, Gem suites, Additional gem suites, Small pure Ruby gem suites, Delegation and URI gem suites, Runtime load path controls.
Merge waits for the pending manual main CI run to start.
| else if str_eq t "b" then CUProp (4, str_to_int_base arg 16, neg) | ||
| else CUProp (2, int_of_str arg, neg)), close + 1))) | ||
| and rxp_clen = fn (pat: str) -> fn (p: int) -> | ||
| if vec_get cut_k 0 != 1 then cut_clen pat p |
There was a problem hiding this comment.
Minor (finding 5): this now cuts a class by cut_k, but rx_cut_key in main.mere adds the encoding to the cache key only for /i and for classes with \. So [あ] compiled first as a binary pattern answers for the UTF-8 literal later. In a UTF-8 file, Regexp.new("[\xE3\x81\x82]".b) =~ "\x81".b followed by /[あ]/ =~ "あ" gives 0, nil. Ruby gives 0, 0, and main gives nil, 0. One fix: add cut_k to the key whenever the pattern has a non-ASCII byte.
There was a problem hiding this comment.
Fixed in runtime 8e65f01 (head 95aaeef). Every non-ASCII regexp program key now distinguishes UTF-8, binary and legacy encoding; the existing ASCII case-folding and escaped-class distinctions remain. Corpus 991 checks both compile orders, class literals, sub, quantifiers and Windows-31J/binary patterns. The exact previous 3610 binary fails those added controls on both engines; the new binary matches Ruby on both. The same batch includes the committed interpolation-boundary escape fix 3610e91.
Full validation: 881/881 corpus ON/OFF; 881 VM / 0 fallback / 0 differences; source gates, bracket gate and record_hygiene pass. All seven requested core files, including test_regexp, are COMPLETE in both modes with no passing case lost. Japanese parse-heavy input (584,005 bytes), three alternating samples: 50,820,773,873 -> 50,944,626,285 instruction median (+0.24%). Full results and before-failure probes are in unittest/records/parse-multibyte-cache-review.json. A separate explanation of the ENV-dependent m17n assertion counts follows in discussion. Post-push comments/reviews/discussion were read; ready for re-review.
|
Follow-up to the m17n assertion-count question in review 6051709723:
I ran the ordinary full 127-test file with fixed seed 1, adding only four harmless synthetic environment entries in the second run. No instrumentation or test changes:
All eight runs are COMPLETE: 127 tests, zero failures/errors, the same one skip, identical case identities. This reproduces an eight-assertion difference on the same binary and reproduces the totals in your review. The earlier per-test audit also has identical counts across exact main, f73 and 3610 within each engine. Historical ENV snapshots were not retained, so I cannot reconstruct the exact earlier entries. The committed record note reflects the investigation before this controlled experiment; this later evidence and the description now explain the ENV dependence. No environment values are published, and no additional record-only push is needed. The cache Minor itself is fixed in 8e65f01, with before-failure probes and full 881/881 ON/OFF + 881 VM / 0 fallback / 0 differences. The final head is 95aaeef; the follow-up commit only wraps a record explanation after I initially missed its 351-character line. Explicit record hygiene now passes. All post-push inline comments, review bodies and discussion were read. Ready for re-review; no merge performed. |
284km
left a comment
There was a problem hiding this comment.
Re-reviewed 95aaeef. Minor 5 from the last review (the regexp program cache key did not separate encodings) is resolved. No Critical / Major / Minor findings remain.
- 8e65f01: every non-ASCII pattern's cache key now carries its cut (binary, UTF-8, or the legacy encoding name). The ASCII-only distinctions for case folding and escaped classes are kept.
- 3610e91: the interpolation boundary scanners (
fcb_pct_end,fcb_regex_end,fcb_quote_end) now skip a whole escaped character after\, matching the lexer changes from the previous round. - Ran a cache-order probe on the author's build at this head (clean tree, binary newer than every
.merefile), on the evaluator andMERE_RUBY_VM=1, against ruby 4.0.10: compile a binary[\xE3\x81\x82]first, then UTF-8/[あ]/ =~ "あ","かい".sub(/[あい]/, "!"),/[あ]+/,Regexp.new("[あい]"), ASCII/[a-c]+/and/i,ß/ssfolding, and an escaped multibyte character inside interpolation. All identical on both engines. - The test_m17n assertion question is answered: the per-test counts are identical across main and both candidate builds, and the old record's difference is kept but not claimed.
- The loop note has the local results our merge policy asks for: corpus 881/881 ON/OFF, VM 881 / 0 fallback / 0 differences, the source gates, hygiene, the bracket gate, the seven related CRuby files on both engines, and parse-cost numbers (ASCII −0.71%, Japanese +0.24%). GB18030, Regexp.escape/union and non-UTF-8 Regexp#inspect remain recorded follow-ups.
git merge-treeagainst current main: clean. No mere-pr-review-watch inline comments.
Merging.
Respect complete source characters in CP932/Shift_JIS literals and add Big5/GBK source widths and validity ranges. Regexp classes, ranges and group scanners use the pattern encoding. Escaped non-ASCII characters remain whole in strings, words, symbols, regexps, heredocs and interpolation boundary scans. Corpus 991/992 runs encoded sources through main scripts, require, eval and instance_eval on evaluator and VM.
Review follow-up runtime 8e65f01 includes interpolation fix 3610e91 and resolves the new regexp-cache Minor: every non-ASCII compiled program is keyed separately for binary, UTF-8 and legacy encoding. Corpus 991 checks both compilation orders, class literals, substitution, quantifiers and Windows-31J/binary patterns. Earlier Major and Minor findings were independently confirmed resolved in re-review 6051709723.
Base main 2137de2; ordinary O2 compiler 9dec2ff687a08433247dbdb7729bc19c8522e538. Clean reference
tools/ref_ruby.sh, Ruby 4.0.10 revision a704b7cd95a42cc0cf5f307137bf3aac0285b915: 84 default/bundled specifications, zero extras, default Prism 1.8.2.test_regexpremains 176 tests / 62,595 assertions / 4 failures / 3 errors on both main and candidate; reference itself has 1 failure / 1 error. Full summaries and identities are retained.Additional investigation after the record was published:
test_m17n.rbtest_env (lines 1324–1326) makes two assertions per ENV entry. With no code or seed change, adding four harmless synthetic environment entries changes the full-file totals 3804 → 3812 evaluator and 3806 → 3814 VM, identically on exact f73 and 8e65 binaries, with all 127 case identities unchanged. This reproduces an eight-assertion count difference without losing coverage. The earlier per-test audit also matches main/f73/3610. Historical environment entries were not retained, so their exact identities cannot be reconstructed. The committed note records the earlier investigation state; these later controlled results are posted in discussion. No environment values are published.Portable evidence:
unittest/records/parse-multibyte-cache-review.json; the earlierparse-multibyte-review.jsonand original records remain separate. GB18030 source widths, Regexp.escape/union trail-byte handling and non-UTF-8 Regexp.inspect are accepted follow-ups, with no claim their output is unchanged. No shared framework tooling changes.