Skip to content

Commit fe08159

Browse files
derek73claude
andcommitted
Correct the #1435 log's move counts and the C16 run's comment
Re-take the grid's mutation counts (34,848 and 4,536 of 215,280 rows), name the one-case arm of the run's letter test, and say that C16's count is taken only where the head may be one word. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d0ca52a commit fe08159

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎docs/design/decisions/parse-cost.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ Open: none in this file.
4848
- 2026-11-07 #1157 — NO ROW MOVES; release checklist step 0's pass over post_rules and assign. O3's fold and R2's marks now share one `_positions` walk, which the fold updates, so a `middle_as_family` parse walks once fewer; P10's and W5's tag gates are one plain walk; a lone name word's field is decided where it is placed, so placing one piece makes no `_name_positions` call; S1's settling credential is asked only of a clause holding an unsettled member; N3's early nickname scan sits behind `state.extracted`. Measured 2026-11-07, py3.11, one warm parse counted with a `sys.setprofile` hook, before and after (dbc2fc22 and the change, and again on b43ad933, #1154's merge, and on c489c9a7, #1162's merge, after #1158's, each against the change rebased onto it, every count the same): the reference name 287 either way; `Smith` 128 → 125, `John (Ret.) Smith` 216 → 213, `John Smith (PhD, MA)` 253 → 250, `王李小明` 155 → 152; `John Smith` 130 and `Smith, John` 140 unchanged; no name rose under the default, `FAMILY_FIRST`, `middle_as_family`, `lone_name_word=FAMILY` or `two_family_names` policies. BEHAVIOR IDENTICAL: `snapshot.jsonl` byte-identical, and, for the switches the snapshot's default policy cannot see, dbc2fc22 and the change (2aeb6b95, before the rebase) read alike under a policy sweep, each tree loaded by path with `PYTHONSAFEPATH=1` and its `__file__` checked: every distinct text of the committed `tools/differential/corpus*.jsonl` files (the `name` key, or the line's string) plus 14 shapes these paths reach (`Juan Smith`, `Smith`, `de`, `María del Carmen García`, `王李小明`, `Smith, John`, `John (Ret.) Smith`, `John Smith (PhD, MA)`, `John Smith (MA)`, `John Smith (MA, Jr.)`, `(Bob)`, `Smith (Bob)`, `Ivan Petrovich Sidorov`, `García López, Juan`), 6,906 texts, each parsed by `Parser(policy=Policy(name_order=..., middle_as_family=..., lone_name_word=..., two_family_names=...))` under the three orders, each switch off and on and the lone field given or family (24 policies, every other field at its default), the comparator a line per parse holding the `repr` of the text, the policy's four values, `tokens` and `ambiguities`, the two files compared with `cmp`: 0 of 165,744 lines differ. The negative control, dbc2fc22 with `_assign._name_positions`' one-piece branch returning `[first]` where it returned `[lone]`, reads 3,157 (measured 2026-11-07 in #1157's review). `test_post_rules_walks_the_roles_once_per_reader` pins the `middle_as_family` row at 2 walks, against 3 before.
4949
- 2026-11-09 #1170 — EVERY ROW MOVES DOWN, by 4 on 3.11 and 3 on 3.12 to 3.15: `parse` 289 → 285 and 280 → 277, the rows re-taken where the tree measures rather than by the change alone, master having drifted to 291.80 and 282.80 inside the band since #1089. Three `post_rules` helpers that every parse calls stop making calls they need not make, the three cleanups #1157's pass declined only because the code was unchanged since its last pass: `_leading_name_piece` tests a piece's tokens in a plain inner loop where an `any()` generator cost a frame per resume; `post_rules` asks `_rotations_apply` only where `patronymic_rules` is set, the rotations' only readers testing a rule's membership; and `_mark_suffix_entries` collects the suffix positions in a plain loop and returns before `delimiter_cores` on a name holding fewer than two, where `zip` over them never ran. Measured 2026-11-09 on 9f6264e4 (#1295's merge) and on the change, each interpreter on its own (`uv run python tools/perf/call_count.py`, and with `UV_PROJECT_ENVIRONMENT=<a scratch folder> uv run --python 3.1x` for 3.12 to 3.15): 291.80 → 284.80 on 3.11 and 282.80 → 276.80 on each of 3.12 to 3.15. Per name, one warm parse counted with `_frames_for` in `tests/v2/test_benchmark.py`, py3.11, each name in a process of its own: `John Smith` 131 → 126, `Smith, John` 141 → 136, `John Smith Jr., PhD` 264 → 260, `Dr. John Smith Jr.` 241 → 234. A name's absolute count depends on what the process parsed before it, `_frames_for`'s one warm-up parse leaving some first-use work to the name, so the same tree read `Dr. John Smith Jr.` 224, 214 and 234 by the order its names ran in (two reviews of #1170); compare counts taken the same way, and read the difference, which held at 7 for that name in every order. BEHAVIOR IDENTICAL by construction, each change returning where the old code's result was already decided (a rotation needs its rule in `patronymic_rules`; `zip` over fewer than two suffixes is empty; the inner loop is the `any()` it replaces), and `snapshot.jsonl` byte-identical. `test_post_rules_helpers_return_before_their_frames` holds the two calls the band cannot see put back, with its recorded control (9f6264e4: 2 generator frames on `John Smith`, 1 `delimiter_cores` call), and `test_post_rules_walks_the_roles_once_per_reader`'s pin on the calls `post_rules` makes directly moves 7 → 6. By the four frame questions: every parse pays them (question 2) and they move the band (question 3); none is a copy of a predicate (question 4). Declined again, as #1157 declined them: a `stale` flag on the position lists and dropping the recompute after P6, each bringing back the stale-list shape #359 fixed. SUPERSEDES: the 2026-11-05 #1089 entry's rows.
5050
- 2026-11-11 #1352 — THE TIMED ROWS READ CPU TIME, AND THE COUNTS RUN IN PARALLEL; NO ROW, BOUND OR BASELINE MOVES. On a laptop running several agent sessions the wall-clock rows failed at random and passed alone. Measured on py3.11, 12 cores (6 performance, 6 efficiency), five `uv run pytest -n0 -m serial tests/v2/test_benchmark.py` runs beside 24 shell busy loops (load average 37-48): 20, 23, 21, 19 and 23 of the module's 62 tests failed on 970b54e5, at up to 10.0x against `_MAX_RATIO` 6.0; on the change, 0 of 34 in each of five runs at 24 busy loops (load 50-62) and at none, and in five at 12, which barely loaded the machine (the before tree failed none there either). Per row, three runs at 24 busy loops (load 18-75): `time.perf_counter()` read 27 of the 33 ratio rows at 6.0 or over at least once, up to 14.0x; `time.thread_time()`, measured back to back, none over 5.76x (as high as 5.76x with no busy loops too). CPU time is not load-immune -- interleaved best-of-7 read a clean row up to 5.6x, the thread charged for a slower core or a colder cache, and a user-interactive QoS hint did not help -- and noise can DEFLATE a ratio as well as inflate it: with more rounds taken only at or over the bound, a planted quadratic reading 6.7x quiet (`given_part_titles`) read 5.93x once at 24 busy loops and passed, and a loop stopping at its first reading under the bound could stop on a dip (both found by #1352's review). So `_ratio` interleaves the two inputs and, where its first 7 rounds read at or over 80% of the bound (`_NEAR`; `bound * _NEAR` is 4.800000000000001 in floating point), takes all 35 and judges the last minimums, each round only moving the two minimums toward the true costs; `test_ratio_takes_more_rounds_only_near_the_bound` holds that on a scripted clock, and fails against both earlier loops. Loaded, the serial pass takes 78-115s against 47s, the escalation's price; quiet it takes 18s, as before. The defects it guards are seen as before. Quiet, the old wall-clock `_best` and `_ratio` fail the same rows in every run under a planted C-level quadratic in the word count, every row within 0.35x. The recorded controls read on `_ratio`, quiet then at 24 busy loops: `link_run` 13.9-14.1 and 14.9-16.4 on b9ed1429; `given_part_run` 8.0 and 10.0-10.3 and `given_part_titles` 10.1 and 11.1-12.5 on 003b4962; `title_chain` 12.0 and 13.5-14.8, `pair_run` 10.0 and 10.2-12.8, `caps_pairs` 10.1-10.2 and 12.2-12.8 and `delimiter_cores` 10.4 and 11.8-13.1 on 9dd271b2; `connective_between_particles` 8.5 and 8.9-10.2 on 5752df69 (#939 before its review); and `slash_chain` 8.8-8.9 and 8.9-9.2 with #1103's per-step copy planted. That is against 3.97-4.19 quiet and up to 5.06 at 24 busy loops on 970b54e5. The weakest planted quadratic, 6.3-7.0x quiet on eleven rows, read 7.18x or more on every row in five runs at 24 busy loops. A planted backtracking regex reads 7.31 s of CPU over the thousand names, against 7.36 s wall. The 5s bound is CPU seconds now and no looser for work on the parse's own thread, CPU time being at most the wall time of a single-threaded parse; it no longer sees time spent blocked or on another thread, which a parse never spends. 962301f7's memory move reads 4.07-4.43 on the CPU clock and 4.07-4.50 on the wall clock, quiet, as the 2026-11-03 #1036 entry found for the wall clock; `_ShiftCountingList` holds it. The 28 untimed tests (the frame, call and shift counts and the table checks) lose the `serial` mark. Each passes alone in a fresh process, after the 21,065 tests of `test_cases.py` and `test_match.py` in one, in three full parallel runs, and under `--cov` on 3.11 and 3.14. The order dependence of an absolute count (the 2026-11-09 #1170 entry) stays inside a ratio, a band, or an exact count of one named function's calls (`only=`/`caller=`, `== 0` up to `== 6`), none of which counts an `lru_cache`'d function.
51-
- 2026-11-18 #1435 — NO ROW MOVES; A RUN OF INITIALS BEHIND A FULL NAME ASKS NO COUNT. #1238's C16 block in `_comma.decide` put a dotted run spelling a listed credential, every letter a capital, into `maybe`, so `John Smith, M.D.` paid C4's `name_word_count` and the C11 books, which only a one-word head reads the run by. Where the run is the part's only entry in `maybe` (no word of the class and no caps-shape candidate beside it), `decide` now asks `_lone_word` first (once, its answer kept for the reading), and behind a head that is not one word skips the count and the books: the run stays in `maybe`, so the part is still read as the count's part and never takes the listing form's early return, and with nothing else in `maybe` the count licenses nothing and `head_named` meets no member. Frames, `test_benchmark._frames_for` for one parse in a fresh process, master (b78d5af2) then branch: `John Smith, M.D.` 221 → 199 on 3.11 and 203 → 185 on 3.15; `John Smith, MD` 190 and 178 and `Smith, John` 136 and 125 unchanged; `Smith, J.P.`, which still counts, 233 and 218 unchanged. The issue's table (209 for `John Smith, M.D.` on master) was taken in a process that had parsed other names first, which moves the absolute count and not the difference (the 2026-11-09 #1170 entry). The issue's proposed gate (append the run only beside another class word or behind a one-word head) was not taken: it sends such a part down the no-`maybe` path, equal only where the listing early return and C1's fallback agree, which nothing holds by construction. Checked against master: a grid of 215,280 parses (65 heads, from empty, nickname, title, particle and title-particle heads alone and in pairs to full and one-case names, × 46 tails of dotted runs, listed and ambiguous credentials, paired initials and their company × three comma spellings and a later part × the three orders × six policies) byte-identical, the issue's gate also identical there, and the harness shown to see a move (a `_lone_word` always true moves 30,502 of an earlier 175,536-row grid of 53 heads; skipping the count behind a one-word head too moves 4,542 rows, `Smith van, M.D.` reading given 'M.', middle 'D.', family 'Smith van' where master reads given 'Smith', family 'van', suffix 'M.D.', `_lone_word` reading that head as one word while the count finds two); `snapshot.jsonl` byte-identical; and `snapshot.py --local ctgov-officials` and `ctgov-contacts` against master, no move. `test_a_run_of_initials_behind_a_full_name_takes_no_count` holds the saving, its control recorded in its docstring, and `test_the_count_c16_skips_decides_no_reading` (tests/v2/pipeline/test_comma.py) the readings a wrong gate moves. Under each of three mutants (the gate removed; the count skipped behind a one-word head too; `run_alone` forced true, so a run beside another entry of `maybe` such as `John Smith, M.D. M.A` skips the count as well) the frame test fails, and under the last two the reading test does too. A run beside `MA` (`John Smith, M.D. MA`) never joins `maybe`, `MA` being the run's company (C16), so it reaches none of this.
51+
- 2026-11-18 #1435 — NO ROW MOVES; A RUN OF INITIALS BEHIND A FULL NAME ASKS NO COUNT. #1238's C16 block in `_comma.decide` put a dotted run spelling a listed credential, every letter a capital or the name in one case, into `maybe`, so `John Smith, M.D.` paid C4's `name_word_count` and the C11 books, which only a one-word head reads the run by. Where the run is the part's only entry in `maybe` (no word of the class and no caps-shape candidate beside it), `decide` now asks `_lone_word` first (once, its answer kept for the reading), and behind a head that is not one word skips the count and the books: the run stays in `maybe`, so the part is still read as the count's part and never takes the listing form's early return, and with nothing else in `maybe` the count licenses nothing and `head_named` meets no member. Frames, `test_benchmark._frames_for` for one parse in a fresh process, master (b78d5af2) then branch: `John Smith, M.D.` 221 → 199 on 3.11 and 203 → 185 on 3.15; `John Smith, MD` 190 and 178 and `Smith, John` 136 and 125 unchanged; `Smith, J.P.`, which still counts, 233 and 218 unchanged. The issue's table (209 for `John Smith, M.D.` on master) was taken in a process that had parsed other names first, which moves the absolute count and not the difference (the 2026-11-09 #1170 entry). The issue's proposed gate (append the run only beside another class word or behind a one-word head) was not taken: it sends such a part down the no-`maybe` path, equal only where the listing early return and C1's fallback agree, which nothing holds by construction. Checked against master: a grid of 215,280 parses (65 heads, from empty, nickname, title, particle and title-particle heads alone and in pairs to full and one-case names, × 46 tails of dotted runs, listed and ambiguous credentials, paired initials and their company × three comma spellings and a later part × the three orders × six policies) byte-identical, the issue's gate also identical there, and the harness shown to see a move (on the same grid, a `_lone_word` always true moves 34,848 rows, and skipping the count behind a one-word head too moves 4,536, `Smith van, M.D.` reading given 'M.', middle 'D.', family 'Smith van' where master reads given 'Smith', family 'van', suffix 'M.D.', `_lone_word` reading that head as one word while the count finds two); `snapshot.jsonl` byte-identical; and `snapshot.py --local ctgov-officials` and `ctgov-contacts` against master, no move. `test_a_run_of_initials_behind_a_full_name_takes_no_count` holds the saving, its control recorded in its docstring, and `test_the_count_c16_skips_decides_no_reading` (tests/v2/pipeline/test_comma.py) the readings a wrong gate moves. Under each of three mutants (the gate removed; the count skipped behind a one-word head too; `run_alone` forced true, so a run beside another entry of `maybe` such as `John Smith, M.D. M.A` skips the count as well) the frame test fails, and under the last two the reading test does too. A run beside `MA` (`John Smith, M.D. MA`) never joins `maybe`, `MA` being the run's company (C16), so it reaches none of this.

‎nameparser/_pipeline/_comma.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ def decide(state: ParseState, splits: bool | None = True) -> ParseState:
762762
# rules/C16: "behind one word, initials run together are the given
763763
# name whatever they spell" -- the runs that spell a listed
764764
# credential ('J.P.', 'M.A.'), joined to the class so C4's count is
765-
# taken (decisions/C16 (#1238)). Gathered only
765+
# taken where the head may be one word (decisions/C16 (#1238),
766+
# #1435). Gathered only
766767
# where the part holds a full stop, so 'Smith, John' pays no frame;
767768
# a part whose other words are all credentials is C8's run
768769
# ('Smith, M.D. Ph.D.').

0 commit comments

Comments
 (0)