Repository navigation
Simplify the script, post-rule, assign and assemble stages - #1434
Merged
Merged
Conversation
The 3.1 release's /simplify pass over the pipeline stages changed this cycle. No reading, report or message moves. - script_segment: rules/W6's front peel looks a title up by slicing, longest first, as the tail peel and the surname match do, rather than walking every glued title (_longest_first goes); its gate reads the cached title_prefixes rather than rebuilding a tuple per parse; the glued word's post-nominal test asks _vocab._listed_whole; one helper, _not_glued_titles, holds the test _a_name_before and _a_word_to_spare each spelled; _ends_the_name drops a parameter that was always texts[k]; the segmenter-neighbour and confidence floor comments are cut to their citations, the floor's measurement moving to decisions/W1, which held none of it; the Reads: line names the sets the module reads directly. - post_rules: _patronymic_under holds the patronymic test O9 and the O6 veto each spelled; _family_in_capitals calls its lowercase_joiner where it wrote the test out twice more; _take_trailing_initials drops its unused state; the P6 comment is cut to its citations, its history being in decisions/P6; the docstring names O8 and O9. - assemble: _INITIAL_TAGS moves above its first user. - test_layering: the recorded count of _sets reads is re-taken, 203 -> 200. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review measured frames rising with the word count on paths the first commit's folds reached: the glued word's post-nominal and title tests (T8), rules/O9's capitals walk and patronymic markers, and rules/O6's patronymic veto. Each fold called a helper once per word, which the frame budget refuses for a cost that multiplies with the input, so the inline tests come back: `_only_post_nominals`' suffix test, `_a_name_before`'s and `_a_word_to_spare`'s glued-titles test, `_family_in_capitals`' lowercase-joiner test and the patronymic test of O9's markers and O6's veto. `_sets` reads return to master's count, so test_layering is master's again. decisions/W1's floor entry now says its 112-name sample was not kept: the figures are a dated snapshot under namedivider 0.4.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
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.
Release step 0 for 3.1 (root AGENTS.md's checklist): a /simplify pass over the pipeline stages this cycle changed. It covers
_script_segment.py,_post_rules.py,_assign.py,_assemble.py,_state.py,_classify.py,_tokenize.py,_extract.pyand_group.py._comma.py,_pieces.pyand_vocab.pybelong to another pass. No reading, ambiguity report or message moves.Four read-only reviewers covered the nine files (reuse, simplification, efficiency, altitude), and two more reviewed the diff (a code review and a design-docs review). Their findings are applied below, or listed under what was declined or the behavior-changing candidates.
Simplifications, by file
_script_segment.py(1,189 → 1,145 lines)_peel_cut(rules/W6's front peel) looks a title up by slicing. It takes the word's prefixes longest first and tests each againstglued_titles, the form the tail peel and the surname match already use, instead of walking every glued title in sorted order._longest_firstgoes. It costs no new frames, since the cached_longest_entryhit is C-level, and it is about 9× faster per peeled site._vocab.title_prefixes(heads)instead of rebuildingtuple(heads)on every non-ASCII parse._ends_the_namedrops itstextparameter, which was alwaystexts[k].Ухнаагийн Хүрэлсүхgives given 'Ухнаагийн', family 'Хүрэлсүх') #1237. The history it held is in decisions/W3 and decisions/W4._SEGMENTER_CONFIDENCE_FLOORcomment is cut from 25 lines to a contract line. Its measurement moves to decisions/W1 (see the docs edit below).Reads:line names the sets the module now reads directly: conjunctions, the gated titles, the modifiers and styles, and the maiden markers._post_rules.py(1,684 → 1,642 lines)_take_trailing_initialsdrops its unusedstate.de Mesnil Jan de→ 'de de Mesnil', which stays. The old text claimed the order was tested; the code tests that the run ENDS the name, as the block below it says, and the cut comment no longer contradicts that.Consumes:line no longer lists O8 as keying onorder, which it does not read._assemble.py(942 → 942 lines)_INITIAL_TAGSmoves above its first user._assign.py,_state.py,_classify.py,_tokenize.py,_extract.py,_group.pyNo change. What was examined and declined:
_assign, two small local helpers. One would hold H10's lone-dotted-piece test in the H6 walk, the other O4's one-letter-chunks test. That block is inlined for the parse-cost band, its comment says so, and each copy is a few characters._classify, moving the H10 dotted loop under H9's gate. It is identical only while no dotted spelling is itself a gated title, so it is not a pure refactor._group, the ph-d merge comment. It explains the three head tests the code makes, which is code-local reasoning, not history.Folds reverted in review because they cost frames per word. The first push folded four hand copies into helpers:
_script_segment._only_post_nominals' suffix test into_vocab._listed_whole, which also normalizes each word a second time;_not_glued_titleshelper;_patronymic_underhelper;_family_in_capitals' two inline copies of itslowercase_joinerclosure into calls to it.Each added a call per word on its path. By root AGENTS.md's frame-budget rule, a cost that multiplies with the input stays inline, so the second commit restores all four inline tests.
The efficiency findings: none applied. They would cut the reference row from 285 to ~234, but
_CALL_BASELINE's band is two-sided. They are listed under Follow-ups.Docs and tests
uv.lockpins 0.4.2).tests/v2/test_layering.pyis untouched. The_setsread count is back at master's 203 once the folds are reverted.Measurements
uv run pytest(ja extra installed)uv run pytestwithout the ja extrauv run pytest -n0 -m serialuv run mypy,uv run ruff checkgit diff --stat origin/master -- tools/differentialtests/v2/test_snapshot.pytools/differential/cldr_agreement.pytests/v2/pipeline/test_state.pyBoth suite runs and the serial run are on the final head.
A base-versus-head grid
58 names, plus each name's NFD spelling, were each parsed under 26 configurations, in three comma shapes (as written,
, Jr.appended,Smith,prepended). The names cover:The 26 configurations are each order ×
capitals_as_family×initials_as_family×patronymic_rules, plus RU and TR_AZ. That is 8,736 parses. Readings, roles, sources and ambiguity texts are byte-identical betweenmasterand this branch.A reviewer also fuzzed
_peel_cutold against new over 300,000 words with caller-added glued titles: 0 differences. A deliberately broken variant differed on all 175 of its inputs, so the harness can see a difference.Frames
Fresh process per name, py3.11,
_frames_for/_calls_per_parsefromtests/v2/test_benchmark.py. The columns are master (90b15c84) and this branch's head._calls_per_parse)Smith, John김민준นายสมชาย ใจดีJuan dela Cruz Sta.Maria Ph.D.John Smith A.Brown PhDcapitals_as_familyMarie DUPONTcapitals_as_familyMarie de LA FONTAINE y DUPONT Jr.capitals_as_family+patronymic_rulesMarie DUPONTcapitals_as_family+patronymic_rulesMammad Ali OGLUcapitals_as_family+patronymic_rulesMarie de LA FONTAINE y DUPONT Jr.capitals_as_family+patronymic_rulesAnna Marie+ ten capitals wordstwo_given_names+patronymic_rulesIvan Petrovich SidorovThe +1 on the two non-ASCII names is
title_prefixes' first, uncached call: the benchmark's warm-up name is ASCII and never reaches that gate. After one non-ASCII warm-up parse, both trees read the same:김민준212,นายสมชาย ใจดี343,José García177.These absolute counts differ from figures taken with another warm-up (decisions/parse-cost, 2026-11-09 #1170). The comparison is between columns. No path gains a frame that grows with its word count.
_CALL_BASELINEis not edited.Stage headers
Every stage's
Reads:line was checked againstgrep -oE '\b(policy|lexicon|lex)(\._sets)?\.[a-z][a-z_]*'._post_rulesreads the suffix sets through a localsetsalias, which the grep cannot see, and the line names them._stateis not a stage.Behavior-changing candidates
Not made. Each would move a reading somewhere:
_script_segment._only_post_nominalshand-copies a one- and two-word maiden-marker lookup, where_vocab.maiden_marker_runis the shared predicate. The two agree on the shipped vocabulary. On a caller's lexicon they differ for a marker of three or more words, for overlapping markers (gebandgeb vonboth listed) and for a word that folds away._script_segment._all_titlesvs_vocab.period_joined_title. They differ on a fullwidth stop inside the word ('ดร。.รศ')._script_segment._ends_the_name's suffix test vs_listed_whole. They differ only if a cut leaves a word holding a stop, whichglued_cutsshould never do; left as is._post_rules._listed_suffixvs_listed_whole. They are identical on a capitals word, but_suggestcalls it on words that may hold a stop, so the swap could move a suggestion._extract._opens_a_listed_particlecuts at ASCII-only, where_vocab._HYPHENSis the pipeline's hyphen class. Widening it changes rules/N2's reach ('s‐Gravesandewith U+2010)._script_segment: the three spellings of "a title chunk" (_all_titles,_vocab.is_title_chunk,_a_name_before's set test) are not equivalent:Streads differently.Follow-ups
Frame savings outside the band. The efficiency reviewer measured scratch patches that cut the reference row from 285 to ~234 and
Smith, Johnfrom 136 to ~112. The biggest pieces:_ignorablecall in_tokenize(scales with every character);_is_emoji's generator over its ranges;_classifyand_group.Taking them needs a deliberate move of
_CALL_BASELINEand a decisions/parse-cost entry. The list is in the coordination notes (simplify-stages-frame-followup.md).H10's lone-dotted-piece test is spelled in
_pieces.leading_titlesand_assign. A shared helper would cost frames inleading_titles, which runs every parse. That is for the_piecesowner.🤖 Generated with Claude Code