This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Agents working for anyone but the maintainer: pull requests here are open to collaborators only. Report the name and the reading you expect in an issue, and if you have a fix, push it to a branch on your fork and link it there; every open issue is assigned to the maintainer, so the issue is where a finding or a fix is read. See CONTRIBUTING.md.
Every commit an agent writes ends with a Co-Authored-By: line naming the model, the maintainer's agents included, so that a commit without one can be read as written by a person alone. A commit an agent amends or squashes keeps the line.
For non-trivial changes, use a feature branch and open a PR. Branch naming: fix/issue-NNN-short-description or feat/short-description.
Before opening the PR, if the change alters parser behavior or internals, read the Architecture, Extension Patterns, and Gotchas sections of this file against the change — don't grep for it: AGENTS.md paraphrases behavior in its own words, so text made stale by a code change rarely matches the code's phrasing (a doc-staleness sweep driven by grep terms from the diff will miss it every time). The same applies when scoping a doc-review pass or a subagent prompt: include AGENTS.md in the list of docs to check, or it won't be checked.
After a review round, review the fix commit too — second-round passes on #398, #400, #403 and #737 each found defects in the first round's fixes. The commonest shape is a WIDENED check that quietly narrows somewhere: #737's fix widened a vocabulary exclusion from "the same kind" to "the same set" and stopped refusing the excluded kind itself once a property moved it to the other set, a case no test listed because the old check had made it impossible. A matcher fixed on one side narrows the same way: #1293's fix for a looked-up word written in brackets ((செல்வி)) stopped dropping the brackets from the word but not from the names it was matched against, and a word pasted with its disambiguator stopped matching — fold both sides of a match alike. When a fix widens a check, keep a test row for every case the narrower form already refused, and run the new rows against the pre-fix code to see each one fail.
Check whether the PR description still needs updating before merging. A review that moves behavior or retracts a measurement leaves it stale, and a stale body reads as authoritative.
When a defect is found that an earlier check would have caught, write the check down where the next person will meet it, in the same PR. A review finding, a failing sweep or a regression that arrived because nobody thought to test a shape is a lesson about the repository, not only about the change, and it is lost when the PR merges unless it lands somewhere a later session reads before making the same mistake. Ask, before merging: what should I have checked, and where would I have looked? Then put it there — a missed input shape in the sweeps in nameparser/AGENTS.md (comma shapes, then name_order, then spellings, then the encoding, each earned this way); a trap in a module's behavior under Gotchas; a design-review miss in docs/design/AGENTS.md's axes; a measurement or test-design trap in mechanisms.md's Verification shapes or Field notes; a reusable design move in mechanisms.md proper. Name the PR or issue that earned it and the input that showed it, so the rule can be checked against its case. #610 is the shape: its sweep test found that the maiden take missed a shape-only numeral, and the spelling sweep in nameparser/AGENTS.md records the class (VI beside V and III). This is how the file accumulates expertise rather than history — prefer amending an existing paragraph to adding a new one, and delete a lesson the code has since made impossible.
A scripted multi-edit that asserts as it goes discards everything when a late pattern misses. Assert every pattern before applying any, then verify the edit landed — three times in one session a docs batch failed its last assertion, wrote nothing, and reported success, invisible because prose edits fail no test. And replace by an anchored match, never across a whole file: a history line quotes the wrong spelling on purpose, and #909's sed turning segment_scripts=() into frozenset() also rewrote #337's record of what shipped wrong, until the design-docs review found it.
Three committed contributor docs carry the parser's normative rules and their reasons, enforced by the doc tests in tests/v2/ (design_docs.py, rules_doc.py and the test_doc_/test_rules_/test_design_docs modules). Before proposing a design or a fix that touches parser behavior, read docs/design/mechanisms.md and the relevant docs/design/rules/ sections — the catalog is keyed by problem shape, and the pattern you are about to invent is often already there.
- rules/ — NORMATIVE rules (intended behavior, domain-topic sections, executable examples;
deviates:markers track known parser gaps), one file per rule and per section Background. Every rule is written in the skeleton format (#761), which replaced an indented block format: a plain-language When / Then / Because head, Except bullets each carrying its own fenced example, Precedence and Accepted bullets, and a footer for the signal and pointers, described in docs/design/rules/README.md. Cite asrules/P1; code comments quote a verbatim excerpt in double quotes, checked by tests/v2/test_doc_citations.py. - decisions/ — the ADR-style record, one file per key: dated entries, Declined: (rejected WITH evidence), Excluded: (what must stay out of a wordlist and why), Open: (issue links, never restated; also keyed to a vocabulary set for contested memberships — the right-rule-wrong-set class), 3-0-reevaluations (append whenever a design cites 1.4 parity as load-bearing).
- mechanisms.md — problem-shape catalog with citable contract statements; stage-attribution claims in comments must cite an entry verbatim, never restate it in fresh words. In a
.pyfile cite it asmechanisms.md#SLUG ("a quote")on one line, the form tests/v2/test_doc_citations.py reads, checking the slug and the quote; inside docs/design/'s rules, decisions and mechanisms.md the same test checks the slug alone. Nothing reads a citation in AGENTS.md or a tools README, so grep for the slug there when an entry is renamed. #801's first draft wrotemechanisms.md's NAME-DATA-JOBS, a form the check reads nowhere, and its fix put the quote on the next line, where a docstring citation's quote is not read either.
Each rule and decisions entry is its own named file (rules/S6-case-signal-at-the-suffix-slot.md, decisions/vocabulary-collisions.md), and each folder's README.md indexes them; a new rule or a new decisions key is a new file plus its index line (a new decisions file opens with ## Standing and ## Log, decisions/README.md; older files of Declined, Excluded, Open, removal or mapping lines are indexed under its Reference lists and need no block), and tests/v2/test_design_docs.py holds each index line to the file's heading and name, and tests/v2/design_docs.py is the one module that knows the layout (#713). Citations carry the ID only, never the name, so a file can be renamed freely. When you cite a rule or decision in chat, a commit or a PR, give its name with its ID — "S6 (the case signal at the suffix slot)" — since the ID alone tells the reader nothing about which rule it is.
Same-PR amendment rule. Any PR that changes or clarifies parser behavior — or the boundaries around a documented rule, since a neighboring change can invalidate a rule's stated limits without touching its code — amends the rules in the same diff (the doc diff is part of the reviewable change, like tests). A change that resolves or reverses a design question adds a decisions entry; a new reusable pattern adds a mechanisms.md entry; a fixed deviation removes its deviates: marker in the same PR (the examples test forces this). Issues proposing behavior changes should be drafted in rule shape — When, Then and Because, the exceptions with their examples and boundaries, accepted consequences, open questions, exclusions — so landing an accepted proposal is a copy, not a rewrite.
Counting claims. A bare count in prose is either an assertion or a liability, keyed by who observes its staleness: asserted counts (a test holds the number) fail CI at change time — the useful kind; dated snapshots ("51 sites at spec time") cannot go stale; standing present-tense prose counts are the forbidden class — promote to an assertion, add a date, or state the invariant and let a test count. After changing how many times something runs, sweep for counts, not for the thing's name.
Release-log claims. Quantified or universal behavior claims in release bullets must come from the snapshot's diff since the last release, be verified against rules examples, or -- for a view the snapshot cannot see -- carry a recompute recipe stored with the design entry the bullet cites; never write one from memory. uv run python tools/differential/snapshot.py --since v<last release> prints every corpus name the release moved, grouped by changed field; v2.4.1 is the first tag carrying a snapshot, and for an older release compare.py --baseline <version> prints the same report against the PyPI wheel, closing with the entries compared and how many moved names are Latin-only. Both say how many moved names only corpus_cldr.jsonl holds. The snapshot records the seven role fields, ambiguity kinds, each report's alternative reading (since #752's phase 2m), initials(), the two case-repair views (capitalized() and capitalized(force=True), each only where it changes the text, #826) and, since 3.0, the suffix's generation and credentials views (where the suffix holds a generation, rules/R8), its honorifics view (where it is not empty, rules/R8, #326) and the patronymic and surname2 views (each where it is not empty, rules/R9 and R10; the snapshot parses the default policy, so no name fills surname2, which two_family_names reads and, under locales.ZH, a Han surname pair, rules/W5) for every name, so an initials, case, generation or patronymic count is read off it directly -- with two limits. A case view holds the whole repaired name, so in a name repair changes, a role move that changes the rendering moves the view too, with or without a word recased: read a view move that comes with a role move by its words' case, not by whether it moved (#808's John Smith, otr/l moved both, 'John Smith OTR/L' -> 'Otr/L John Smith'). And --since a tag whose snapshot predates #826 (v2.5.0 and earlier) does not compare the views at all, so 2.6.0's case claims come from compare.py --baseline 2.5.0. corpus_cldr.jsonl's fictional renderings are in it: count them out of a release figure (both tools print how many moved names only that file holds), or say the figure includes them. A render view the snapshot does not record -- str() under a custom format, initials() under a custom spec -- stays invisible to it, and for those the first two sources cannot reach a claim: the snapshot is byte-identical across the change, and an example line witnesses an output without counting anything. The DEFAULT str() is mostly invisible too, the snapshot seeing it only through a case view where repair changes the text: #754's render defaults moved str() for 1,034 corpus entries and the case views for 159, so a change to the default rendering is measured by rendering every entry in both trees (decisions/R6's 2026-10-29 entry holds the recipe). A recipe names the corpus files, the policy sweep, and -- the part that is easy to omit and fatal -- THE COMPARATOR, which must be something the shipped tree is not: #408's first recipe said to compare initials() against a folded-first partition, which is what initials() now IS, so it reproduced 0 where the bullet claimed 660 and was the only stated provenance for the number. Run the recipe as written before shipping the bullet. Cross-version numbers (a released wheel, the pre-change tree) are dated snapshots under Counting claims, since nothing in the repository re-runs them. The same standard binds decisions entries and PR bodies: a claim that a change restores the released reading is measured over the whole moved population against the wheel, never spot-checked (#625 claimed its 774 moves landed on the 1.4.0 and 2.3.0 readings from three names; measured, the tree matched 2.3.0 on 0 of 258 moved texts, master on 152), and a population size is re-counted from its recipe, never copied from another entry (the same entry carried #624's 137,810 for a grid of 395,148). Code comments citing rule IDs follow the excerpt discipline, checked by tests/v2/test_doc_citations.py: a rule's quotable text is its fields' prose (When, Tolerated, Then and its bullets, Because, and the Except, Precedence and Accepted bullets), and its fences and the footer below ---, where the Signal: line stands, are not; rules/H names the H section, whose Background is quotable; a decisions citation may paraphrase, but what it quotes must be verbatim; and a reference with no quote must still name something that exists. The check's reach is a quote within four words of the ID or chained to one that is: a quote further off reads exactly like a name written in double quotes, so it is NOT checked, and the second review of #632 found 14 such quotes stale by hand. Keep a quote beside its ID. Quotes of AGENTS.md itself are not checked at all. A citation comment holds three things: the quote, a line saying which clause this code implements, and decisions/X (#N) pointers to the entries that hold the history. A code-local reason a reader of that line needs may stay beside them (why an index is safe to keep, why a test runs last), but issue history, measurements and restated examples belong in decisions/, where they are dated and kept current; in a comment they are a second copy that goes stale where nobody looks. #760 trimmed five blocks of 59 to 100 lines that had grown that way (_post_rules._mark_suffix_entries, group's P3 both-sides test, its S2/P2/P4 chain head and S4 chain emitter, and the honorific peel's scope in _script_segment), moving into dated decisions bullets what those entries lacked. Two of the moved claims no longer held: a policy example that had stopped reaching its case, and a credential said to land as a title that lands as a suffix.
Writing the user docs (docs/*.rst) has its own AGENTS.md too. docs/AGENTS.md carries the style the docs are written in — tables as indexes, subheadings per task, measured claims, recipe doctests — distilled from PR #588. It also holds the length scan (tools/docs_scan.py) and the reader critique every new or rewritten page gets before a release. It loads the same way as the docs/design/ one below; if your tool does not do nested discovery, read it before editing a .rst file under docs/.
A nested AGENTS.md is a file in its folder, and a tool that reads the folder whole reads it too. Root AGENTS.md is loaded by every session, so guidance that applies to one folder belongs in that folder's AGENTS.md, which loads when a session reads a file there: nameparser/AGENTS.md (the sweeps), nameparser/_pipeline/AGENTS.md (ambiguity reports), nameparser/vocab/AGENTS.md (adding a word), nameparser/locales/AGENTS.md (the contract a shipped pack is built to), docs/AGENTS.md and docs/design/AGENTS.md. Before adding one, check what reads its folder: tools/vocab/build.py refuses every non-TOML file in nameparser/vocab/ but the names in its SKIPPED, so that a misnamed language file fails loudly, and #911's vocab file failed eleven tests until it joined that set.
Working on docs/design/ has its own AGENTS.md. docs/design/AGENTS.md carries the landing-a-design distillation checklist, the primary-source review rule, the dated-count convention, and the review axes. Claude Code loads it automatically when a session reads or edits anything under docs/design/; if your tool does not do nested discovery, read it yourself before touching those files or reviewing a change to them.
Triaging a design backlog: shape before value. When a pile of open questions has to be ordered, relatedness will not partition it — in a parser nearly everything touches particles or suffixes. The line that does is whether a decision changes WHAT THE MODEL CAN EXPRESS or fills in a value in a shape already fixed. Settle the shape questions first, as a batch: they are few, they are usually independent of each other (so their own ordering does not matter), and each one collapses or re-frames a run of the value questions below it. The rest are leaves needing one measurement and one answer apiece, in any order. Worked example, 2026-08-16 (#386): 30 open issues and ~13 open design questions reduced to three shape decisions, which decided or re-framed fourteen of them — and two of the three turned out smaller than their issues claimed, because the issues had gone stale. Check the age of an issue's premises before believing its cost estimate.
Markdown line width: don't hard-wrap prose. Measured 2026-08-16 — wrapped and unwrapped render identically, docs/design/ is not in the Sphinx build, and unwrapping is byte-identical (newline→space is 1:1), so the width buys nothing and costs diff churn (74% of #386's decisions.md deletions were reflow, not change). AGENTS.md and docs/design/ were unwrapped in one whitespace-only commit on 2026-08-16; keep new prose unwrapped rather than reformatting again. The blame cost was 43 lines of 1717, measured, not the wholesale reset predicted before doing it — git's diff maps most joined lines back to whichever commit wrote their opening text. .git-blame-ignore-revs lists the commit and is worth enabling (git config blame.ignoreRevsFile .git-blame-ignore-revs) for future format-only commits, but it recovered none of those 43: --ignore-revs-file cannot pass blame through a commit that MERGES lines, because the joined line has no counterpart in the parent to re-attribute to. One exception, enforced: a rule's example, Signal: and pointer lines are parsed per line, so a wrapped one is a hard error naming its rule. A rule's prose is unwrapped like any other, its examples standing in fences (#761).
Guard tests SHOULD carry a recorded negative control — the answer with the guard off, stored as data (the _UNGUARDED_EFFECT shape in tests/v2/pipeline/test_state.py; see mechanisms.md's Verification shapes). Re-take it after the last commit that adds tests, before merge: a review round that adds rows moves the count, and three recorded controls in a row went stale that way (#625 27 → 30, #636 4 → 9, #637 5 → 7 → 11), each caught only by the next review.
Invariant tests over a generated grid share ONE parsed grid, and a grid pairs a text only with configurations that can read it differently. Both rules are in tests/v2/test_properties.py (_connective_findings, _off_switch_findings, _rows) and both were bought at a price: four tests each walking the same 170,100-row grid, and a grid that was a full cross product of texts × lexicons × policies, together took that module from 11s to 115s and CI's build jobs from ~5 minutes to 17–25 (under coverage every parse costs several times more, and every later PR pays it). A new invariant over an existing grid joins that grid's walk instead of opening its own; a new grid states its measured runtime where it is built. Trim a grid by SHAPE — a variant lexicon reaches only the texts holding the word it adds — never by sampling, and prove the dropped rows were duplicates by signature before dropping them. Mutation counts in the tests' docstrings are counts over the grid, so re-measure them whenever the grid moves -- and so do the DESIGN DOCS that quote them. A recorded control reaches docs/design/decisions/ and docs/design/mechanisms.md as well as the docstring, nothing checks those copies, and a grid change silently makes them wrong about a number they present as measured: the #397 second review moved four such figures at once (2026-09-20). Move them in the same commit, and where the older number is worth keeping, label it with the population it was measured over rather than deleting it.
# Preferred: use uv run (works without activating the venv)
# Alternative: .venv/bin/<tool> if the venv is already active
# Run all tests (includes --doctest-modules, so doctests in nameparser/ are also run).
# Parallel by default (pytest-xdist, `-n auto --dist worksteal` in pyproject's addopts),
# which DESELECTS the clock-timed `serial` tests (the scaling ratios and the
# thousand-names backstop in tests/v2/test_benchmark.py) -- run them in the second
# command. The module's frame, call and shift counts run in the first.
# `-n0` runs everything serially in one process.
uv run pytest
uv run pytest -n0 -m serial
# Run a single test file / class / method
uv run pytest tests/test_python_api.py
uv run pytest tests/test_python_api.py::PythonApiTests::test_utf8
# Type check (covers nameparser/ and tests/, per pyproject.toml's [tool.mypy] packages)
uv run mypy
# Lint (the whole repo, tests and tools included -- what CI's "Run linter" step runs)
uv run ruff check
# Debug how a specific name string is parsed: 2.0 core parse() --
# prints the ParsedName repr raw and capitalized, then initials;
# --json emits the component dict; --locale/--strict/--order,
# --lone-name-word and the Policy switch flags parse under a
# configuration (--help lists them)
uv run python -m nameparser "Dr. Juan Q. Xavier de la Vega III"
# Rebuild the compiled vocabulary after editing nameparser/vocab/*.toml
# (--check exits 1 if nameparser/config/_compiled.py, the reading
# index nameparser/config/_index.py or the compiled [rules] tables
# nameparser/config/_rules.py is stale), and look
# words up by text, kind, issue or exclusion
uv run python tools/vocab/build.py
uv run python tools/vocab/query.py --word 殿
# Build docs
uv run sphinx-build -b html docs dist/docs
# Maintain docs/release_log.rst as changes land:
# - Keep an "Unreleased" entry at the top: `* X.Y.Z - Unreleased`
# - Add one bullet per notable change; prefix with Add/Fix/Remove/Change
# - A bullet is an index, not the record: a bold lead (plain text only --
# RST markup does not nest, so no ``literal`` or role inside ** **), ONE
# before/after example naming the releases it differs from, a limit
# sentence only where a caller would trip on it, then the issue link(s):
# :issue:`123` or :issue:`123`, :issue:`124` (sphinx.ext.extlinks; a PR
# number works too). The mechanism, boundary cases and measurements live
# in the issue and docs/design/decisions/, never in the bullet --
# 2.4.0's entry was cut from 10,765 words to 1,491 on 2026-10-11
# - Merge bullets a user would see as one change, with several links,
# and carry every merged bullet's limits over: 2.7's merge of eight
# phase-2j bullets read 'a bare one reverses after a comma' over Vice
# and Grand, which stay titles there, until review ran them
# - Version is decided at release time (patch/minor/major per semver)
# - Format matches existing entries — see the 2.4.0 block for a current example
# Release checklist (PyPI publish is triggered automatically by GitHub Actions on release creation)
# 0. First, a /simplify pass over every module the cycle changed that has not
# had one since it changed (`git diff --stat v<last release>` lists them):
# file-disjoint passes, one PR each, merged one at a time, each holding
# snapshot.jsonl byte-identical and the frame band (_CALL_BASELINE), each
# reviewed, then its fix commit reviewed too. A simpler form that moves a
# reading is out of bounds there: list it in the PR body under
# "Behavior-changing candidates" with what it moves, and file the ones
# worth weighing as issues. 3.0 ran only a Lexicon pass until three passes
# late in the cycle (#1083, #1084, #1085) found 6 frames and three
# follow-ups (#1087, #1088, #1089). Run the passes BEFORE the sweep below,
# since they rewrite comments and docstrings the sweep reads.
# Then sweep for stale prose. Grepping for the changed SYMBOL finds almost none of
# it: prose describes behavior in words, not identifiers. Walk these sites
# explicitly — every one of them has gone stale at least once.
# - docs/*.rst: getting-started.rst, usage.rst and shapes.rst examples and API surface, plus any file listing
# config constants or Policy fields
# - a reader critique of every docs/*.rst page that is new or
# substantially rewritten this cycle, run as docs/AGENTS.md's "A reader
# critique before release" says, with `uv run python tools/docs_scan.py`
# for the lengths. 3.1's matching and suggester pages reached review
# with long sections under no subheading and with buried guidance,
# found by hand (#1406, #1408)
# - migrate.rst's "Changed in ..." list: the shapes whose 1.4 reading
# moved, each with a doctest. Every release log bullet saying "1.4.0
# through" the last release adds one. 2.5.0 nearly shipped with none
# of its nine
# - README.rst's announcement at the top: it is the PyPI project page
# (pyproject's `readme`), so it should lead with the release being
# shipped, drawn from the release log's summary. 2.4.0 nearly shipped
# still announcing 2.0 and 2.1. Check it with `python -m doctest
# README.rst` and `uv run --with readme_renderer python -m
# readme_renderer README.rst -o /tmp/readme.html` (PyPI's renderer)
# - docstrings that autodoc renders (nameparser/_policy.py, _types.py, ...).
# These ARE the API reference in modules.html, so a docs/*.rst-only sweep
# structurally misses half the rendered page — that is how the guide and
# the reference ended up teaching different Policy spellings in 2.1
# - user-facing MESSAGES: warnings and raise text often hand the reader code
# to paste, and it has to be code that still works (and type-checks)
# - pipeline stage header blocks: each _pipeline/*.py docstring declares
# "Reads:". That is checkable, so check it rather than reading it:
# compare it against grep -oE '\b(policy|lexicon|lex)(\._sets)?\.[a-z][a-z_]*'
# on the module (a vocabulary set is read as `lexicon._sets.titles`
# since 4i-a, and a Reads: line names it `Lexicon.titles`). The grep
# sees only reads spelled in the module itself: not a read through a
# `sets = lexicon._sets` alias (`sets.titles`; 20 such bindings in
# _pipeline/ on 2026-11-16) and not a read a stage makes through a
# helper in _vocab or _pieces (assign reads the suffix sets that way,
# through is_suffix_lenient). `uv run python tools/stage_reads.py`
# sees both: it runs every tests/v2/cases.py row through the stages
# with the Lexicon and Policy wrapped to record each read, and lists
# per stage what was read and a text that read it (`--stage classify`
# for one); it cannot see a read no row reaches. A Reads: line may
# name a set of fields at once, as _classify's does by naming the
# fields it leaves out, so check what it leaves out against the trace
# - tests/v2/cases.py notes, which explain why a row lands where it does
# - docs/design/rules/, decisions/ and mechanisms.md -- READ, don't
# grep: the excerpt and example tests catch citation and example drift,
# but statement and Background prose can still be wrong about behavior
# that changed
# - EVERY AGENTS.md, not just the root: nameparser/AGENTS.md,
# nameparser/_pipeline/AGENTS.md, nameparser/vocab/AGENTS.md,
# nameparser/locales/AGENTS.md, docs/AGENTS.md and
# docs/design/AGENTS.md (`git ls-files '*AGENTS.md'` lists them),
# for stale commands, architecture notes, sweeps or gotchas.
# READ them after the cycle's last behavior PR merges: 3.0's
# sweep (#1079) read four of the six, and a later check found the root's
# initials gotcha still naming v1's initials_separator/initials_format
# - the pickle-break bullet: pickle every public type (Lexicon, Policy,
# Parser, ParsedName, Ambiguity, a locale pack) under the
# last release's wheel and load each in the tree; don't derive it
# from a dataclass diff. 2.7's bullet named Lexicon and Parser and
# missed the locale packs, which carry a Lexicon
# Then run `uv run python tools/differential/parity_check.py` and
# relabel every case row it lists: `parity` is cases.py's default, and
# no test checks it against 1.4.0 (Gotchas). 3.1's sweep found 72
# such rows, 32 of them written that cycle.
# And check for open Dependabot PRs on uv.lock (namedivider-python) and merge them
# first — pyproject floats >=0.4 so fresh installs get the newest namedivider, but
# CI's ja-extra job installs from uv.lock and only tests what the lock pins
# 1. Read what the release moved: `uv run python tools/differential/snapshot.py
# --since v<last release>`. It prints every corpus name that reads
# differently, grouped by changed field. That report is the source for the release notes'
# behavior claims (see Release-log claims above); a move nobody can
# account for is a finding to settle before the log is drafted.
# 2. Clear PRE_RELEASE in nameparser/_version.py — it carries 'dev' through the
# cycle (see step 9), so releasing is setting it to ''. VERSION should already
# be the version you are shipping; bump it here only if step 9 was skipped.
# For an RC, set PRE_RELEASE = 'rc1' (etc.) instead — __version__ joins it
# without a dot ('2.0.0rc1').
# Also set the `version:` field in CITATION.cff to this release. It is the ONE
# version string that does NOT track the tree: it names the last citable
# released artifact, so it lags on purpose for the whole cycle and catches up
# here. Nothing checks this — no test, no CI — so it is on you.
# 3. Stamp "Unreleased" → "X.Y.Z - Month DD, YYYY" in docs/release_log.rst
# 4. git commit + git tag -a vX.Y.Z -m "Release X.Y.Z"
# 5. git push origin master && git push origin vX.Y.Z ← tag must be pushed separately before gh release create
# 6. gh release create vX.Y.Z --title "vX.Y.Z" --notes "..."
# 7. Close the milestone of the minor just shipped and open one named for
# the next minor. Milestones are titled by minor, "X.Y" (3.2, 3.3), never
# "Next Release" (decided 2026-11-22), so the PRs of a cycle carry its
# number from the start. For 3.2.0:
# MILESTONE=$(gh api repos/derek73/python-nameparser/milestones --jq '.[] | select(.title=="3.2") | .number')
# gh api -X PATCH repos/derek73/python-nameparser/milestones/$MILESTONE -f state=closed
# gh api -X POST repos/derek73/python-nameparser/milestones -f title="3.3"
# 8. Set DEFAULT_BASELINE in tools/differential/compare.py to the version
# just released, so a bare compare.py measures against it. This runs
# on the branch released from, so a release cut from a maintenance
# branch (3.0.1 from 3.0.x) needs it applied on master too: master's
# stayed on 3.0.0 until the 3.1 sweep.
# 9. Open the next cycle's VERSION: bump VERSION in nameparser/_version.py to
# the minor now being worked, and set PRE_RELEASE = 'dev'. The tree then says
# what it is building rather than what it last shipped -- docs/conf.py reads
# __version__ directly, so Read the Docs' "latest" is otherwise stuck on the
# previous release for the whole cycle.
# It also restores compare.py's version tell: with the tree and
# the baseline wheel both reporting the same release, only the __file__ path
# distinguishes them, which is the weak state test_tell_rejects_a_module_
# loaded_from_the_checkout documents. A dev tree differs on both halves.
# 'dev' normalizes to X.Y.0.dev0 -- above the last release, below the one it
# precedes -- so an install from master can never masquerade as the release.
# Leave CITATION.cff alone: it names the last RELEASED version and is meant
# to lag until step 2 of the next release.The library has two layers: data — the per-word TOML in nameparser/vocab/, compiled into the nameparser/config/ modules — and logic, the pipeline in the underscore-private nameparser/_*.py modules (see 2.0 API modules below). The v1 parser was deleted at 2.0's M11 swap (readable as git show 2d5d8c2:nameparser/parser.py), and the v1-compatible HumanName/Constants facade that replaced it in 2.x was deleted in 3.0 (#357); the facade is readable as git show v2.8.0:nameparser/_facade.py and _config_shim.py.
Design philosophy — positional and language-agnostic. The parser assigns parts by position plus small sets of words that join to neighbors; it never detects language. A name's language can't be reliably inferred from Latin-script transliteration ("Ali" is Arabic or Italian; "Van"/"Della"/"Bin" are first names in some cultures, particles in others), so language-specific rules belong in opt-in config (a Lexicon, a Policy, a locale pack), never global defaults. Many "wrong for language X" reports (#133, #150, #130, #85, #103, #146, #83) are irreducible ambiguities — e.g. de Mesnil (want last name) vs Van Johnson (want first name) are the same [prefix][word] shape. Before adding a rule, confirm it doesn't break the opposite case (run the full suite — Portuguese and "Van Johnson" tests are the usual canaries). The one scoped exception (2.1, #271/#272): script-conditional behavior is permitted exactly where the SCRIPT ITSELF — not statistics about it — determines the convention. The never-detect-language rule is about Latin transliteration, where the signal is destroyed; native script is a different question, answered per behavior rather than per script. What it licenses today, each stated in its rule, with the history in the decisions file named beside it or, where none is, the one of the same ID:
- Wholly-Han, wholly-Hangul and kana-licensed names read family-first (
Policy.script_orders): zh and ja both write family-first in native script, so order cannot be misread though the language is unknowable. Hiragana licenses Japanese (#272), while pure katakana, full-width or halfwidth, keeps the positional default: it may be a transcribed foreign name already in its source order or a Japanese reading written family-first, so its script settles nothing and a caller who knows opts in throughscript_orders(#594) — rules/W4. - Unspaced hangul splits into surname + given name on the Korean census surnames shipped as default vocabulary: nothing but Korean is written in hangul, and the surnames are a closed set — rules/W1.
- The 间隔号 U+00B7, and the fullwidth full stop U+FF0E typed in its place (#1312), between classified characters marks a transcription, so the name keeps its declared order (rules/W4) and never segments (rules/W1's interpunct Except); it divides only when flanked, being also the Catalan punt volat (
Gal·la) — rules/T3 (#298). - The nakaguro (U+30FB and halfwidth U+FF65) separates words unconditionally, in tokenize, so neither policy opt-out (
script_orders={},segment_scripts=frozenset()) reaches it: its codepoints are CJK-only — rules/T2, history in decisions/T2 and T3. The Ethiopic wordspace U+1361 divides the same way, being Ethiopic-only (#1202, decisions/T2). - U+202F, the narrow no-break space, joins two Mongolian letters into one word, being the script's suffix connector there, and divides like any whitespace beside anything else (
Jean : Dupont) — rules/T6 (#1236). - A listed CJK honorific glued to the end of a name splits off, but only an entry that can never end a name (#308): the same not-a-guess standard applied to WORDS rather than a script, the vocabulary carrying the license itself, so neither opt-out reaches it either. Its reach across a family comma is tolerated rather than contract — rules/W2, rules/W3, decisions/W2. Its mirror, a listed title glued to the START of the name's first word (Thai
นายสมชาย), splits off on the same license, only an entry vetted as opening no name (attached = { side = "before" }, #317) — rules/W6, decisions/W6. - Han segmentation stays OPT-IN (
locales.ZH;locales.JAwith aParser(segmenter=...)): a Chinese surname list corrupts Japanese kanji names (高 is a common Chinese surname, so 高橋一郎 would split 高+橋一郎 where the correct reading is 高橋+一郎), and no surname list divides a kanji name at all — rules/W1.
A pack's script order is a different license, and not on this list: Cyrillic settles no order (Russian writes given-first, Mongolian the father's name first), so no default keys on Script.CYRILLIC and DEFAULT_SCRIPT_ORDERS holds no entry for it; locales.MN carries one (FAMILY_FIRST_GIVEN_LAST), licensed by the caller's choice of Mongolian, as a caller's own katakana entry is by the caller (#594), and it reads every wholly-Cyrillic name that way, Russian ones included — rules/W4's pack Except, decisions/W4 (#1237). Never read it as "Cyrillic means family-first".
The group suggester (Parser.suggest) is outside this rule, as decided in decisions/group-suggestion's 2026-11-10 SCOPE entry (accepted 2026-11-15): the parser never detects language; the group suggester may, over a group the caller declares, says what it saw, and its answer is configuration the caller applies. No parse changes, and a single name is still read positionally.
Latin-script input is never touched by any of this: "Kim Min-jun" is genuinely order-ambiguous and stays governed by name_order and opt-in packs. Before adding a script-conditional rule, work out which of the three it is — certain, certain for this one behavior only, or a statistical guess wearing a script's clothes.
A constant's membership is a question you may reopen. Proposing that a word be ADDED, REMOVED or MOVED between vocabulary sets is ordinary design work — a shipped entry is not evidence that anyone judged it. SUFFIX_ACRONYMS arrived in af5bdab as a bulk Wikipedia import never reviewed against surname collisions: 572 of its 577 alphabetic entries leave family empty in "John <word>" against five ambiguous-gated exceptions (recomputed 2026-09-07; the fifth is ba; 568 of 575 against seven, measured 2026-09-25 after #540), and sa, se and om are borne as surnames (measured 2026-08-23; all three since decided, sa removed from the vocabulary on 2026-10-25, #857), as were rai, cha, ba and mc before decisions/suffix-acronym-collisions decided all four — rai and cha removed, ba marked ambiguous, mc left alone as no borne name at all. The same entry marked meng and lac ambiguous on 2026-09-25 (#540). When a fix starts to look like new machinery, check the vocabulary first. Criterion: decisions/vocabulary-collisions, with #360's positional qualifier.
Sweep the forms a change can reach: comma shapes, then name_order. No comma, a FULL name before the comma, a ONE-WORD name before the comma and NOTHING before the comma are four paths, and the last two are the misses. For orders, tests/v2/test_cases.py runs every row under all three but asserts only R2's family partition there, so it checks nothing a new change moves: parse your change's names in each comma shape AND each order yourself. The grid each needs (an empty head and a nickname-only head, a particle, connective and suffixed surname before the comma, two title-particles at the head, a dual second in a title run, a trailing title after an empty head), how to read a grid's moves, and the predicate and exclusion-list traps are in nameparser/AGENTS.md, beside the spelling sweep.
Then sweep the spellings: a class reached by vocabulary is also reached by SHAPE. A test that uses only the listed spelling of a word class walks only the vocabulary path, and the shape path is a separate branch that can be missing while every test passes, so when a change touches a word class, test one spelling from each path. The classes where a path was missed (roman numerals, credentials and titles, a separator's spacing, a full stop inside a word, capitals between name words, adjacent pairs), each with the PR that found it, are in nameparser/AGENTS.md, which loads when a session reads anything under nameparser/, the vocabulary TOML included.
And the encoding: a letter class written [^\W\d_] or tested with isalpha() is blind to a combining mark. Python's \w and isalpha() do not match Mn, so a letter written as base plus accent (NFD) ends a word early; the vocabulary path is immune because _normalize NFC-folds, the shape path is not. Which predicates were blind (#652, #665), how each was fixed, what is deliberately left uncovered and the guards to add a row to are in nameparser/AGENTS.md, beside the other sweeps.
The default vocabulary is written per word, in TOML, and compiled. nameparser/vocab/<tag>.toml holds one file per BCP 47 language tag, each [[word]] entry a text and its readings keyed by kind. What a file means, how an entry is built, the kinds and properties with the set each compiles into, exclusions, bearer counts and the steps for adding a word are in nameparser/vocab/README.md, the reference for anyone editing the TOML; tests/v2/test_vocab.py holds its kind, property, derived-marker and reserved-name tables to the names build.py accepts and the sets it compiles, so read it rather than restating it here. The parser never reads the TOML: tools/vocab/build.py runs the build checks that replaced the modules' import-time asserts (its docstring numbers them), turns every reading into an index row with its file's tag, and writes the rows, and every file's tag (FILES, a file holding only exclusions included, for a strict choice to name), as the committed reading index nameparser/config/_index.py (#753, phase 3a) and, compiled, as the committed nameparser/config/_compiled.py, frozenset literals one entry per line; the build never reads _index.py back. A file a shipped pack reads may also hold a [rules] table, each key a Policy field (patronymic_rules, name_order, two_family_names, two_given_names, initials_as_family), which the build checks against its RULE_KEYS and PACK_RULES and writes as nameparser/config/_rules.py; _locale.rules_patch(tag) turns a file's table into the PolicyPatch a pack carries, RU's and TR_AZ's from ru.toml and tr.toml, and the two_family_names of ES, CS and SK from es.toml, cs.toml and sk.toml, and HR's and SL's from hr.toml and sl.toml (decisions/O6, 2026-11-21, #1190), and ES_AR's from es.toml, a country pack reading its language's table (#754, 4f; decisions/vocabulary-model's 2026-10-29 4f entry), and VI's name_order from vi.toml (#1108), and NE's initials_as_family from ne.toml (#1254), and the two_family_names of PT_BR and PT_PT from pt-BR.toml and pt-PT.toml, country files writing a table pt.toml does not, pt-PT.toml also holding Portugal's own default = false readings (decisions/O6, 2026-11-19, #1453; decisions/P10, 2026-11-19, #1189). The compiler is nameparser/_reading_index.py's compile_readings, with the kind and property tables it reads (CATEGORY, BEHAVIORAL, GATED_WORDS), so the build and a choice of languages compile alike: Locale.languages (3.0, phase 3b) is a choice of BCP 47 tags, which parser_for unions across its packs and base's recorded choice and records on the Lexicon (Lexicon.languages, 3.0's 4i-c), the lexicon compiling its base's readings through choose and its own edits after them, choose selecting the readings (a chosen file's default = false ones on; on a word a chosen file holds a vocabulary reading of, other files' vocabulary readings off, save mul.toml's and und.toml's; a chosen conjunction's may_be_initial dropped; under parser_for(..., strict=True), 3j, only the chosen files, mul.toml (#1005) and native-script words' readings as a plain choice of the same languages keeps them, name readings included, compiled, through strict_pool), changed_words deriving a choice's deviation surface which tests/v2/test_locales.py's gate reads, and strict_ungated the words a strict choice ungates against the plain one, which tests/v2/test_reading_index.py holds to a reviewed table (decisions/vocabulary-model, 2026-10-29 3b; 2026-10-31 #753, phase 3j); the build keeps the checks and loads that module by path, as it loads _lexicon.py, and tests/v2/test_reading_index.py holds that the index compiled with no choice is _compiled.py exactly. readings_of(text) there is the run-time reader of the index, every reading of a word with its file's tag, loaded on first call; languages_of(text, categories) is the reader a default parse calls for Reading.languages (3.0), through the lexicon's private _files (_lexicon._ReadingFiles, one per base, log and choice, hashed by identity so assemble's memo keyed by it costs no frame), which under a choice or a caller's log names the files whose reading is on in that lexicon instead (3.0's 4i-d), so the first parse that reads a word from its Lexicon's vocabulary loads the index. Through 2.x each config/ module re-exported its constants from _compiled.py (TITLES = _compiled.TITLES) under an autodoc docstring; 3.0 removed those modules (#1007, 2.8.1 warning of them), so the compiled sets are private, Lexicon reads them, and a caller lists a kind's words with Lexicon.words(kind=...), docs/migrate.rst giving the call for each 2.x constant (a test runs every one). tests/v2/test_vocab.py fails when _compiled.py is stale, and tests/v2/test_reading_index.py when the index is, each naming the refresh command, and test_vocab.py gives every build check a mutation. The model, the phasing and what was declined: decisions/vocabulary-model.
The compiled SETS are frozen since 2.2 (#293): there is no .add()/.remove() on any of them, so a default word list is changed at runtime by configuring a Lexicon, never by editing a constant, and the shipped default is changed by editing the TOML and rebuilding. The five dicts are not frozen. _compiled.CAPITALIZATION_EXCEPTIONS is vocabulary-shaped, private since 3.0, and read once by the cached Lexicon.default(), so an edit after the first parse misses it — configure the object (dataclasses.replace(lexicon, capitalization_exceptions=...)). _compiled.SAME_AS (the name match's listed spellings, a dict of dicts, below), _compiled.SAME_AS_NAMED beside it, _compiled.FAMILIAR (the familiar forms) and _compiled.ALTERNATE_SPELLINGS (the alternate spellings) are the same hazard: each Lexicon reads them once into its own _same_as, _same_as_named, _familiar and _alternate at construction, the default's cached, so an edit to the module misses every lexicon already built — configure the object (lexicon.add(word, kind=..., same_as=...)). REGEXES, the other mutable mapping through 2.x, went with config/regexes.py in 3.0 (#1008). tests/v2/test_contracts.py::test_every_vocabulary_constant_is_frozen sweeps every module in nameparser/config/ (_compiled and _ko_surnames hold its constants) and names those five dicts as explicit exemptions rather than letting its isinstance filter drop them.
The compiled sets, read by Lexicon (mostly as the _sets field of the same name lower-cased; GLUED_HONORIFICS is honorific_tails, NON_GIVEN_NAME_PARTICLES derives particles_ambiguous, and CAPITALIZATION_EXCEPTIONS is the capitalization_exceptions field); a caller lists one with Lexicon.words(kind=...), or a comprehension over it where the set is derived, docs/migrate.rst giving each:
-
titles —
TITLES(every title reading; prenominals),GIVEN_NAME_TITLES(the readings withaddresses = "given", e.g. "Sir", which treat the following name as given, not family — a subset of the title readings by construction, though not ofTITLES: a word that may also be a given name, such askingorsheikh, compiles toTITLES_AMBIGUOUSinstead) andAFTER_GIVEN_TITLES(the salutation readings withafter_given = true, read as the title where one ends the given part after a family comma, rules/H8, #835 — a subset by construction);TITLE_ABBREVIATIONS(the title readings withabbreviation = true,maj, which rules/H5's trailing chain takes with its period where the word is inTITLES_AMBIGUOUS, and on a style rules/H9 gives the article before it as a partner, #999; private, like the kind sets 3.0 added);DOTTED_TITLES(the title readings withdotted = true,us,uk,pd, the titles abbreviating several words that a run of single letters joined by full stops spells, which rules/H10 reads as the title at the head of a name where a title the run keeps follows it, #490; private);GLUED_TITLES(the title readings withattached = { side = "before" }, Thaiนาย,นางสาว,อาจารย์, which rules/W6's front peel splits off the start of the name's first word they are glued to, #317; private);TITLES_AMBIGUOUS(a title reading beside agivenone, derived, compiled INSTEAD of intoTITLES: a title only inside a title phrase, rules/H9, #752 phase 2i),TITLE_MODIFIERSandTITLE_STYLES(by kind) andTITLE_PHRASES(the two-word phrasesattachesmakes) -
suffixes —
SUFFIX_ACRONYMS(suffix readings withacronym = true, matched with every period removed, e.g. "M.D.") andSUFFIX_WORDS(the rest, e.g. "Jr."), disjoint because a word has one suffix kind;SUFFIX_ACRONYMS_AMBIGUOUS(an acronym reading on a word with agivenorfamilyreading, derived since 2026-10-25: the build refuses the phase 1 flagmay_be_name; agivenreading carryingsame_as, a name written short, marks no clash with a suffix reading since #1383 (ReadingProperties.marks_a_clash), somd, Muhammad written short, stays an unambiguous credential);SUFFIX_WORDS_AMBIGUOUS(its word twin, a generation or agnomen reading, or a credential written as a word, on a word with a name reading,fils,junior,júnior, the agnomens andkc,pcanddl, gated by the count, rules/S11, since 2026-10-25, the credentials since 2026-10-30, #965, Junior since #1039) withAGNOMENSinside it (theagnomenkind) andTITLE_CASE_NAME_WORDSbeside it (the readings writtentitle_case_is_name,fils,père,kc,pc,dl, whose writing leans, Title case to the name; any other gated word's writing never leans, #1039); andGLUED_HONORIFICS(#308,attached), the subset ofSUFFIX_WORDSthe peel may split off the END of a name token — a separate, harsher bar, since the glued position has no writer-drawn boundary to lean on, and each word refused it carriesexcluded = { attached = … } -
particles —
PARTICLES(family-name particles, e.g. "de", "van") andNON_GIVEN_NAME_PARTICLES, the curated subset that is never a standalone given name (the particles whose word has nogivenreading, each statingmay_be_given = false; agivenreading on the word is what makes a particle possibly given, the phase 1 flagmay_be_given = truerefused since 2026-10-25). What the subset licenses is rules/P1's fold inpost_rules(the "rule 1b" of older issue comments — decisions/legacy-rule-numbers maps the old numbers), and the fold has ONE site: the piece that OPENS the name. A lone never-given particle there, with at least one more name word behind it, starts the family. Titles do not move the opening position (rules/P4), soSir de Mesnilreads familyde Mesnilunder everyname_order, asde Mesnildoes. How far the fold reaches depends on the order the name was read under: by default it takes the rest of the name (de Mesnil Jean→ familyde Mesnil Jean); under either family-first order it takes the particle run plus ONE name unit and lays the rest out by the order (de Mesnil Jean→ familyde Mesnil, givenJean); after a family comma it takes the rest of that part whatever the order (Smith, de Mesnil Jean→ familySmith de Mesnil Jean). The leading particle stays a lone piece for the fold to find —groupdoes not chain it forward, and the fold walks the particles after it itself — sode la Vegareads familyde la Vegaunder all three orders. Behind a title-particle (St,Freiherr, P4's Except) it does chain, and under a family-first order the fold cuts that chain as it cuts a run (St de Mesnil Jean→ familyde Mesnil, givenJean, #828). The GIVEN position is not a site. It was a second one until #467, which removed it because under a family-first order that slot holds what the caller DECLARED to be the given name:Mesnil deunderFAMILY_FIRSTorFAMILY_FIRST_GIVEN_LASTreads givende, familyMesnil. Nor is a particle inside the name:Juan de la Vegaunder a family-first order reads familyJuan, givende la Vega, with no ambiguity recorded — what the vocabulary forbids is the bare particle as a given name, not a name part that begins with one. A baredehas nothing to fold into and is placed like any one-word name, byPolicy.lone_name_word(rules/O5, #1111): givendeby default under every order, familydewhere the caller sets the switch to family. A leading particle OUTSIDE the set is left to position —Van Goghis givenVan, familyGoghby default and familyVan, givenGoghunder both family-first orders — and records aPARTICLE_OR_GIVENambiguity under all three, save one written in lower case in a mixed-case name under a family-first order, which the fold takes and which records none (van Gogh→ familyvan Gogh, rules/P11, #670); a never-given particle opening the name records none (de Mesnil), and neither does an ambiguous one inside it (Vincent van Gogh). The internalLexicon._sets.particles_ambiguous, the particles holding agivenreading, is its complement withinPARTICLES, so the two mark OPPOSITE sets — see the flip warning indocs/migrate.rstbefore translating either -
bound given names —
BOUND_GIVEN_NAMES(bound_givenreadings, e.g. "abdul", "abu"; one that is also a particle needs agivenreading, a build check); a group-stage rule joins the first non-title piece to its following piece before roles are assigned, reserving a family word unless a family comma has already fixed it or a given-name title stands ahead (#369, rules/P5) (ported from v1's_join_bound_first_name), andBOUND_PHRASES(#694, rules/P12, the two-word given names a bound word'scompleted_bylists, Arabicعبدbefore the names of God), each pair joined past the first name word, where P5's join does not reach, andBOUND_COMPLETES_ANY(#1464, thecompletes_anyreadings, the Latinabdul,abd,abdel,abdal,abou) withBOUND_LONG_NAMES_ONLYinside it (long_names_only,abdul), the bound words P12 joins with any plain name word after them, the second only in a name of four name words or more, both private; andBOUND_SECONDS(#1072, thebound_secondkind, Arabic-scriptالدينandاللهwith their Persian and Urdu spellings, andالغنى,الفقار), the words a pair writes second, which P12 joins with the plain word before them at the first name word too, withBOUND_SECOND_PHRASESbeside it (the pairs a reading'scompleteslists,ذو الغنى) andBOUND_SECONDS_LISTED(the words every reading of which listscompletes,الغنى,الفقار, which join behind the listed words alone, where any other second word joins behind any plain word), private -
given names written short —
GIVEN_NAME_ABBREVIATIONS(#789, agivenreading carryingsame_as, the full name: "chas", "wm", Filipino "ma",md), the given names written short that rules/H2's shape yields to, and that rules/C13's given-name Except reads where one is also a credential opening the part after a family comma (#1393, classify'svocab:given-abbreviationtag), and that rules/S8's run declines for in a name written wholly in one case with a name word behind it (#1394,SITI NORA MD YUSRI); nothing else reads it -
names a given name's second half reads —
PARTICLE_GIVEN_NAMES(#704, agivenreading writtenafter_particle: "carmen", "ángeles", "lurdes", "graças", the Spanish and Portuguese words a compound given name writes behind a particle, which rules/P10 reads as a middle name inMaría del Carmen García, by default, and "piedade" only under a Portuguese choice, #1118, #1122),SAINT_PARTICLES(thesaintkind,san,santa,st,ste,sta,sto, whose run P10 refuses,Santa Maríabeing a surname) andSHARED_NAMES(#704, a name reading writtenshared: Sikh "kaur", "singh", which rules/O6 and O7 neither take nor complete and P10 does not complete,Kaur del Carmen García), private; each is read through classify's tags or the lexicon in_post_rules -
conjunctions —
CONJUNCTIONS(e.g. "and", "of") used to chain multi-word titles and to join name parts (rules/P3), plusCONJUNCTIONS_AMBIGUOUS(#383/#479, rules/P8,may_be_initial, refused by the build on anything but a cased single letter), the subset of single cased letters that read as an INITIAL in a name written wholly in one case — a marker set -
maiden markers —
MAIDEN_MARKERS(birth_markerreadings, e.g. "née", "geb.") routing the following name tomaiden; with anaddresses = "given"title, the one kind a phrase may be (z domu) -
alias markers —
ALIAS_MARKERS(alias_markerreadings,@andurf;aliasandakawrittendefault = false), private, routing the following words tonicknameup to a patronymic particle, another marker, a comma or the trailing post-nominal run (rules/N4, #1164); classify tags the wordvocab:alias-marker, and group's alias take shares_clause_takewith the maiden take -
config/_ko_surnames.py, private since 3.0 (config/surnames.pythrough 2.x, 2.8.2 warning of the move) and read asLexicon.default().surnames—KOREAN_SURNAMES, the census list the 2.0 API splits unspaced hangul on (#271), still written in Python with an import-timeassert_normalized: a segmentation list, outside the per-word model, like the locale packs' lists. -
the views' kinds —
GENERATION_WORDS,CREDENTIAL_WORDS(a credential written as a word),HONORIFIC_WORDSandPATRONYMIC_PARTICLES(3.0's 4b and 4c), private: the kinds the other sets do not record, which classify reads to tag a word for thegeneration,credentials,honorificsandpatronymicviews (rules/R8, rules/R9) -
case masks —
CAPITALIZATION_EXCEPTIONSmapping of case MASKS (e.g.{'phd': 'PhD'}), compiled from thecasedproperty, at most one per word: each value is its key's own letters and digits recased, laid over the word as written, soph.d.repairs toPh.D.and repair never writes the value's own punctuation into the word (#459);LexiconraisesValueErroron a value that spells anything else; andCAPITALIZED_PARTICLES(thesaintandrankkinds, private), the particles case repair writes with a capital rather than in lowercase, keyed on the kind so a word needs no mask of its own (rules/R4, #1069), andCAPITAL_OPENING_PARTICLES(the particle readings writtencapital_opening,terandder, private), the particles case repair writes with a capital where the word before it in the family name is no particle, nor, where it opens the family name, the word written right before it in any role (Levon Ter Petrosyan, butJan van der BergandVan der Walt), keyed on a property becauseder's kind,article, isde's andla's too (rules/R12) -
listed spellings —
SAME_AS, private, read byLexiconas_same_asand nowhere in a parse: everysame_askeyed by the group of its reading's kind (_reading_index.SAME_AS_GROUPS:givenfor a given name or a bound given name,familyfor a surname or a particle,title,suffix), each word with every full form it carries there (sramong titles is bothseñorandsenhor). The name match (_match.py) reads each role in its group throughLexicon._headwords, every word reachable through the group's links, so a given name's spelling never matches a surname (Ma, Jack/María, Jackconflict) and a loop is simply all its words (decisions/name-matching, 2026-11-08); andSAME_AS_NAMED, per group, the words of it whose name reading'ssame_asstands beside a name reading of the same kind with none, a name of its own too (jo), whose links_headwordsfollows only where_match._spellingsread the word with its trailing period (the 2026-11-08 #1006 follow-up) -
familiar forms —
FAMILIAR, private, read byLexiconas_familiar(throughLexicon._familiar_forms) and nowhere in a parse: eachfamiliarreading'sshort_for, the longer given names a short one stands for (max->maximilian,maxwell), every file's together, whichLexiconreads both ways (a pair matches whichever way its source wrote it, never chained) and the name match reads as the opt-infamiliar-form.familiaris a category of its own, never agivenreading, which would move parses where the word is also a title, particle or suffix; a choice neither prefers nor drops by it (_reading_index.UNPREFERRED), andtools/vocab/familiar.pywrites the shipped ones, and the shipped spellings, fromtools/vocab/familiar_reviewed.tsvalone, the pairstools/vocab/familiar_candidates.pyfinds in ORCID, a few familiar forms the FEC's filings and Congress's legislators evidence, counted by recipes in decisions/name-matching rather than a committed tool, and the Central and Eastern European and Balkan pairstools/vocab/familiar_wikidata.pyfinds in Wikidata's people (a birth name beside the label, or a nickname or the label beside the given name, per language; 2026-11-20 #1387), and the Brazilian Portuguese pairstools/vocab/familiar_tse.pyfinds in Brazil's election candidates, a ballot name beside the civil given name it stands for (2026-11-20 #1495), as two readers reviewed them (decisions/name-matching, 2026-11-08 FAMILIAR FORMS, 2026-11-12 ALTERNATE SPELLINGS ARE OPT-IN and 2026-11-13 THE FAMILIAR FORMS FROM DATA ALONE); andALTERNATE_SPELLINGSbeside it, eachspellingreading'sspelling_of, the given names a name is another spelling of by the person's or a romanization's choice (olhaofolga), read byLexiconas_alternate(throughLexicon._alternate_spellings) both ways and never chained, and by the name match as the opt-inalternate-spelling: a kind of its own, never agivenreading'ssame_as, which would make the word a name written short and move parses (GIVEN_NAME_ABBREVIATIONS) -
the group suggester's tables —
config/_order_names.py, private, written bytools/vocab/order_names.py(--write; its hand-kept spelling lists sit above the generated blocks) and read by_suggestonly, never by a parse or aLexicon:ROMANIZED_SURNAMES(zh, ko and vi surnames folded by_suggest.fold),COMMON_GIVEN_NAMES, andCOMMON_SURNAMES(#1364, the given names' mirror: family-box words ORCID's holders rarely type as a given name, mostly Spanish), the two surname tables read together asSURNAMES. They are notLexiconkinds, so a language choice,strict=Trueand a caller's edit do not reach them and no snapshot moves with them (decisions/group-suggestion, 2026-11-10 TABLES)
config/__init__.py holds a docstring only: the package is the home of the data modules, and since 3.0 nothing else (#357), all of them private (#1007; regexes went with #1008; surnames became _ko_surnames in #1077, named for vocab/ko.toml's tag, and stays in config/ because the default lexicon reads it and _lexicon may not import locales/, a layer above it).
The 2.0 rewrite landed as underscore-private modules beside the v1 code, which 2.0 and then 3.0 deleted. These conventions apply to all of it. The design record (rationale, settled-decision logs, dated amendments) is docs/design/: nameparser-2.0-rfc.md, the rules, the decisions entries and mechanisms.md; this section is the enforceable subset. A commit that establishes or amends one of these conventions must update this section in the same commit — grep-driven staleness sweeps miss paraphrased prose (see Workflow above), so write-time maintenance is the mechanism, audits are the backstop.
- Module layout: every module is underscore-private (
_types.py,_lexicon.py,_policy.py,_locale.py,_render.py,_reading_index.py,_pipeline/,_parser.py, and_match.py, which holds name matching:Matching, the settings objectParser.matching()builds, and its result types, and_suggest.py, the group suggester:Parser.suggesttallies one vote per name from per-name signals and returns aSuggestion, decided under the thresholds in the decisions file group-suggestion). The public import surface is exactlynameparserandnameparser.locales(the vocabulary's compiled sets are private since 3.0, #1007, the Korean surname list since #1077 (2.8.2 warning of it, #1076), andregexeswent with #1008;tests/v2/test_layering.pyrefuses a public module innameparser/config/);nameparser/__init__.pyholds re-exports and__all__only — no logic. - Layering is enforced by
tests/v2/test_layering.py(exact-module matching;if TYPE_CHECKING:imports don't count):_typesimports nothing internal at module level — its rendering delegates import_render, andParsedName.matches_parser, at call time;_lexiconand_policysit above_typesindependently (_lexiconmay importnameparser.config.*DATA modules, e.g.config/_ko_surnames.pyandconfig/_compiled.py, and_reading_indexat call time only, to compile a configured lexicon's readings, sincetools/vocab/build.pyloads it by path, 3.0's 4i-b);_reading_indeximports nothing internal at module level and the index,config/_index.py, at call time, sincetools/vocab/build.pyloads it by path;_localesits on_lexicon+_policy(plus_typesfor the shared pickle mixin, andconfig/_rules.pyat call time, inrules_patch);_renderimports_types,_lexicon(forLexicon.default()and_normalize) and_policy(for the scripts that write no initials);_matchimports_types,_policy(forPolicy(), which its repr compares a parser's policy with),_lexicon(for_normalize, which tells a hyphen half that is a listed particle bylexicon._sets.particles, andLexicon.default(), which the repr compares a parser's lexicon with) and_pipeline/_vocab(for_HYPHEN_CHARS, rules/O6's hyphens, each of which the match reads as the hyphen-minus,_HYPHENS, the pattern it cuts a word at them by, #1264, andin_initialless_script, the scripts that write no initials),_parserat call time only, inMatching's constructor, which requires aParser, and its repr, which tells aParserfrom a subclass, andParserunderTYPE_CHECKINGfor its annotations;_suggestimports_types,_policy,_lexicon(the particles, the titles and_normalize), the pipeline's predicates (_pipeline/_vocab's patronymic, title, suffix, numeral and capitals-word tests,_pipeline/_state's commas,_pipeline/_post_rules's_listed_suffix, rules/O9's credential and numeral test) andconfig/_order_names.py, imports_parserat call time, inSuggestion.__post_init__, to check that the base is aParser, and namesParserunderTYPE_CHECKINGfor its annotations;_pipeline/*imports_types+_lexicon+_policyplus in-package_pipelinehelpers,_assemblealso_reading_index, for the kindsReading.languagesmatches (CATEGORY; the files themselves it reads throughLexicon._files, 4i-d;_vocabimported it in 3.0's 4b and 4c for a listed suffix word's kind and a patronymic particle's, which since 4i-b the lexicon compiles into_sets);_parsersits on everything except_render,_matchat call time only, inParser.matching(),_suggestat call time only, inParser.suggest(), and_reading_indexat call time only, to validate a choice's tags and move the case masks it moves (the choice itself compiles in_lexicon._built);__main__imports only the public package; every locale pack module (locales/*.py) imports_locale/_lexicon/_policy/_typesand its own private data modules, or its language pack's, inlocales/only (es.pyimports_es_given_names.py,es_ar.py_es_ar_given_names.py, andpt_br.pyandpt_pt.pyshare_pt_given_names.py, #1453;_typesjoined the list in #272 —locales/ja.py's segmenter factory constructs aSegmentation), a data module (a leading underscore) imports nothing internal, and thelocales/__init__additionally lazy-imports its packs (PEP 562). No pack is keyed by hand: the test's_locale_rules()holds every file inlocales/to that rule, a relative import read by the absolute name it resolves to, so a new pack is checked from its first commit. Extend the test'sALLOWEDtable when adding any other module; its completeness checks fail on a_pipeline/module it does not key and on alocales/module no rule reaches. - Canonical field order — the seven roles in
Roleenum declaration order, defined once and derived everywhere (properties,as_dict, reprs,comparison_key). Never restate the order literally.Roleis aStrEnum: members compare as their field-name strings, andtokens_for()coerces strings via_coerce_enum. - Method organization, fixed section order in every class: fields +
__post_init__validation → alternative constructors → dunders (construction/equality → protocol → operators) → properties → public methods by concern (access → editing → comparison → rendering delegates) → private helpers last, except a helper serving exactly one section may sit at that section's head. - Validation is eager and fail-loud: every
raisestates the offending value, the expected form, and the fix. Exception taxonomy: wrong type — including wrong element type inside a collection, barestrwhere an iterable of strings is expected, or aMappingwhere a plain iterable is expected — raisesTypeError; well-typed but unacceptable values raiseValueError; failed enum lookups stayValueErrorfor any input (stdlibEnumTypeprecedent). When the message hands the reader code to paste, that code has to survive a type checker, and then RUN — nameparser shipspy.typed, and a placeholder can type-check and still raise: the 2.4 release sweep's first fix to thecapitalization_exceptionshint offered('key', 'Value'), which passes mypy and fails #459's mask check, sotest_add_capitalization_exceptions_raises_pointing_at_replacenow executes the offered code. #337's segmenterless warning offeredPolicy(segment_scripts=()), anarg-typeerror, because these fields are annotated with what they STORE rather than everything the constructor accepts. Prefer thefrozenset()/()spellings in messages and docstrings, and pin the offered spelling in a test — the warning tests matched onja_segmenterand never checked the actionable half of the message. A warning emitted inParser.__post_init__needsparser_forto re-emit it from its own frame (thecatch_warnings(record=True)block at its return):__post_init__'sstacklevelis sized for directParser(...)construction, and throughparser_for's extra frame the default one-line rendering attributes the warning to the library's ownreturn Parser(...)— the exact call the message tells the user to change becomes invisible. No single stacklevel serves both entry points; a new construction warning gets the re-emission for free, but a new CONSTRUCTION SITE forParserinside this package needs its own re-emission or its callers get library-attributed warnings (#337 review). - Guard, hint, and emit for the WHOLE family, and parametrize the test over it: a check added to one member of a set belongs on all of it, and the test must sweep the family, not one example. This session shipped
_reject_str_and_mappingonPolicybut notPolicyPatch, the bytes decode hint on three of five config entry points, and a regex-sync roster missing four of its copies — each a separate follow-up bug that a{class} × {field} × {bad-value}parametrization would have caught and a per-example test hid. When you find you're guarding member N, grep for the other members first. - Ambiguities are emitted at the DECISION site: an
Ambiguityrecords a fork the parse had to call, not a token that sits in an ambiguous vocabulary, so emit where the branch is taken, in every stage that takes one, and name the reading not taken. The reading TAKEN (Token.reading, 3.0) is the one read later, at assemble, where roles are final, from the role and the tags the deciding stages left, its suffix and name sources by the predicates that name the reading not taken. The contract is mechanisms.md#AMBIGUITY-AT-THE-DECISION-SITE; the working rules (branches that change nothing, the field a report names, the stages that decidePARTICLE_OR_GIVEN,alternative, the reading taken, and how to test an emitter) are innameparser/_pipeline/AGENTS.md, which loads when a session reads a pipeline stage. - A kind is worth adding only if a reader would hesitate too: the test is not "does the code take a branch" but whether a person reading that input would genuinely be unsure. "Smith, John V." reads as a middle initial to anyone -- the period settles it -- so reporting it would be noise that teaches callers to ignore the field, which costs more than the missing report. Reachability of the second branch is necessary, not sufficient. The example was "Smith, John V" until #877 measured FEC writing that bare letter as a middle initial about as often as letter frequency predicts, where the parser reads the generation: a fork that feels settled is a claim to measure against the data before it decides a report. Prefer leaving a fork silent and documenting the omission over emitting on input nobody finds ambiguous.
- Parser owns config-dependent conveniences:
Parser.matches/Parser.capitalized/Parser.reviseexist because theParsedNameequivalents fall back to DEFAULT config for str/omitted arguments (documented loudly in both docstrings).reviseharvests tokens from a full sub-parse of each replacement value (tags kept minusFOLDED_TAG, roles forced, the R1 entry passsuffix_entriesre-run over the forced state so a suffix value's entries follow its own commas, ambiguities discarded); the merge tail is shared withreplace()viaParsedName._with_field_tokens.Parser.capitalizeddelegates throughname.capitalized(self.lexicon)specifically so_parsernever imports_render— keep it that way. - A reading is of one word, save a birth marker and a title addressing the given name (the build's check 8, which
_lexicon._make_editruns on everyaddand RAISES on, since a reading is now a caller's statement the compile can refuse as the build does: 3.0's 4i-b). The two lists,surnamesandgiven_names, andcapitalization_exceptionskeys still WARN on a multi-word entry (_normset/_normpairsvia_warn_at_caller, UserWarning, never a raise — an inert entry produces nothing). The default vocabulary and every locale pack must stay warning-free (test_default_lexicon_builds_warning_free,test_pack_vocabulary_entries_are_single_words). - Invariants guard harm, not no-ops: add a constructor check when violating it produces a wrong parse, not when it produces nothing. A false positive costs a working configuration; a true positive on an inert condition costs the user nothing, so that trade is never worth taking. Since 3.0's 4i-b a
Lexiconcompiles from readings, which hold the 2.x marker-over-base relations by construction; the checks a caller's edit reaches are the build's checks 3 (a kind and its properties,may_be_initialon a single cased letter alone), 4 (one suffix kind per word), 8 (a phrase), 9 (a bound given name that is a particle has agivenreading) and 11's agnomen clause (an agnomen has a name reading), in_lexicon._make_editand_check_pool, which_lexicon._builtruns again under a choice of languages, refusing a caller's reading that clashes with one the choice turns on and naming the edit, each raising with the call that fixes it, because each is a wrong parse. A given-addressing title run the parse can never build is not checked, because an unreachable entry is simply never consulted (see Gotchas). Before adding one, construct the config it forbids and check what actually breaks. Between raise and silence sits the construction-timeUserWarning, for a gap that is statically decidable, harmless to SOME deliberate caller, and indistinguishable-from-working for everyone else: the segmenterless activation (#337 —parser_for(locales.JA)without a segmenter behaved exactly like a working parser minus the feature) warns rather than raises because the segmentation-inert JA registration is itself a pinned property, and a warning is filterable by the caller who wants exactly that. The message must carry every applicable remedy and no inapplicable one (theja_segmenterhint fires only when a Japanese script is among the dead ones). Test fuzzers that legitimately construct such configs suppress the warning by MESSAGE, never by category — a blanketUserWarningignore would mask the next construction diagnostic (_quiet_parserintests/v2/test_properties.pyis the pattern). - Reprs are bounded: render which fields deviate from a named baseline and by how much, never contents (
Lexicon(default + title: +2)).PolicyPatch's repr shows only set (non-UNSET) fields;_order_reprmust never raise even on an unvalidated patch's garbagename_order(PolicyPatch defers validation to apply time); the sweep test intests/v2/test_reprs.pypins that no config repr leaks the UNSET sentinel. - Every pipeline stage is one module holding one public function of the same name (
_tokenize.py/tokenize), with the exceptions named where they stand —_group.py'smarker_run_length, a shared predicate (mechanisms.md#ONE-PREDICATE-PER-QUESTION), and since #511_post_rules.py'ssuffix_entries, the R1 entry pass as a function, becauseParser.reviseruns that one pass over a forced-role sub-parse and a stage's tail cannot be called on its own — and its module docstring declares the contract in three labelled lines:Consumes:what it takes fromParseState,Produces:what it hands back,Reads:whichPolicy/Lexiconfields it consults.Reads:is the load-bearing one — it makes "which stage do I touch for this feature?" a grep rather than a read-through. AReads:line names a vocabulary set asLexicon.<field>, and every library module but_lexiconreads it aslexicon._sets.<field>(_lexicon._LexiconSets, #754's 4i-a), never off the public field,surnamesandgiven_namesincluded though they stay public, which let 4i-b make the other twenty internal without touching a reader;tests/v2/test_layering.pyrefuses a direct read, field by field, in the library and in every tool. The authority for the stage set is_pipeline/__init__.py'sSTAGES(eight, and not public API) with the field-ownership map inParseState's docstring, pinned bytests/v2/pipeline/test_state.py; NOT the rules, which are implementation-free by their own preamble and whoseimplemented:names modules honoring a rule rather than stages. A_pipeline/module that is not a stage says what it is in its first line instead (_assemble.pyand_comma.py: "Not a stage: …";_vocab.py,_pieces.pyand_state.pyname themselves shared predicates or the pipeline's state),_assemble.pywith aReads:line all the same, since it readsPolicyandLexiconfields too (itsReads:line lists them), so absence of the three lines is a claim about the module rather than an oversight. Provenance: §5 of the 2026-07-11 conventions spec, recorded here 2026-08-16. - Frames are a budget for hot and scaling paths; everywhere else, prefer the shared predicate. The parser's cost is counted in Python frames (
sys.setprofile"call" events — deterministic and load-immune, which is why #475 chose them over wall-clock timing), but one frame is small: measured 2026-09-28 on py3.11, a trivial call costs about 13 ns against 40–80 µs for a whole parse, so one frame per parse is roughly 0.03% of it. What the budget exists to catch is how a cost SCALES and how it ACCUMULATES, so weigh an extra frame by four questions, in order. (1) Does it multiply with the input — per token, per member, per pair? Then it matters, and a hand-inlined fast path can earn its place (the inline tag tests ahead of_pieces.starts_a_credential_runin its loops, each a necessary half of the predicate so nothing can drift;_vocab.run_word_foldwas the measured example until #613 deleted the run test it served). Folding a copy into a shared helper is where such a pre-check gets lost: #617 replaced_comma._title_chains, whose loop tested the conjunction tag inline, with a call into group's loop, which asksis_conj_pieceper piece, and every family-comma parse paid two frames per word of the part (Smith, John+2) while the reference row fell -- review caught it; the fix gates the call on the tag walk the caller already makes, andtest_a_comma_part_with_no_free_connective_skips_the_joinholds it. Count a comma name, not only the reference row, when a fold touches the comma path. (2) How many names pay it — every parse, where plain names likeSmith, Johnmust keep their cost, or only a rare shape? (3) Does it move an enforced guard — the ±2% reference band intest_benchmark.py(_CALL_BASELINE, decisions/parse-cost) or a scaling ratio? (4) What does the inline alternative cost to maintain? A hand copy of a predicate that can drift is the defect class mechanisms.md#ONE-PREDICATE-PER-QUESTION names, and it compounds; a NARROWER question stated exactly is not a copy and may stay inline on that ground alone. A constant frame on a rare shape that no guard sees loses to readability: #544's cleanup declinedis_title_piecefor one frame on comma credential runs (24 ns a parse, no guard moved), a stricter call than this rule asks for; by this rule the inline test is still right, but because it asks the narrower question (a lone word in both vocabularies), not because of the frame. The converse holds too: the frame counter cannot see C-level work (x in some_list, slices, string concatenation), so "no new frames" is not "no new cost" — #553's quadratic was a list membership test inside a loop, invisible to every frame guard, and #1036's a slice assignment shifting the piece list once per merge, which a dev machine's clock read as linear and only CI's runners did not (_ShiftCountingListintests/v2/test_benchmark.pycounts those shifts now). - A claim about WHICH STAGE or WHICH LAYER does something is checkable — check it before writing it. The pipeline is eight stages with a written ownership map (
ParseState's docstring, pinned bytests/v2/pipeline/test_state.py), andparse(s).tokensprints every token's role and tags, so "extract assigns this", "classify never sees that", "group consumes it" each have a one-command answer. #329's prose claimed delimited maiden content is "claimed whole before classify has tagged anything inside it"; measured,classifytags the marker fine and only the CONSUMING is missing, because_group's rule walkspiecesand a token that already carries a role is not inpieces. Two different mechanisms, one plausible sentence covering both. That single claim then shipped SIX times across three correction rounds, which is the part worth internalizing: when a mechanism claim turns out wrong, sweep for where else you wrote it, and sweep again at the END of the change over the words the change itself just added. Prose density here means one idea lives in a docstring, a case note, a release-log entry and this file at once; the implementer working against a wrong mechanism is the person most likely to restate it; and rewriting a mechanism claim is writing one, so the correction earns the same one-command check as the original — two of the six instances were fresh errors introduced by the sentence fixing the previous one. Adjacency is the trap. The claim that feels already-known is the one about the neighbouring stage or the neighbouring layer: one comment block in the 2.xtests/v2/test_facade_cases.pygot the exception type, the raising layer, the skip mechanism, the count of skipped rows, and which row was blocked all wrong at once — every one a claim about_config_shimversus real 1.4.0, written from reasoning, in the file whose whole job is translating between them. What finally held was not better prose but moving the claim into a test (_CORE_ONLY_IDS, deleted with the facade in 3.0), which cannot be wrong the way a sentence can. - Typing/docs:
from __future__ import annotations;frozen=True, slots=Trueon every public dataclass; strict-profile mypy flags via per-module overrides in pyproject (strict = trueitself is not valid per-module). Docstrings state contracts in prose with no doctest blocks —--doctest-modulesmakes every example a test; behavior examples go to unit tests per the lean-docs rule. Document the positive direction of a partial property: "a non-emptyambiguitiesis a signal to act on" is checkable, while "an empty one means no fork occurred" is a universal negative needing exhaustive verification -- that claim was written twice and falsified twice, at sites the author had not audited. - The segmenter contract: the optional
Parser(segmenter=...)hook is parse-totality's ONE exception (locales spec section 4). Everything inside that exception is a bug in USER CODE, never a fact about the name, so it is surfaced rather than absorbed: the segmenter's own exceptions propagate, and the two protocol violations the stage can detect for itself — an answer of the wrong type, and one cutting at or past the end of the token it was handed — raiseTypeError/ValueErrorfrom_script_segmentfor the same reason. The line to hold when adding a check there: a protocol violation by the segmenter's AUTHOR raises, while an adapter's defense against its own third-party library (locales/ja.py's repertoire, length, kanji, reconstruction and score guards) declines withNone, because what those catch is a fact about the content. - Pickling: v2 types must round-trip (
Parseris picklable by construction, and it holds aLexicon; the one qualifier is that aParserpickles iff its segmenter does — see the segmenter bullet above). Every frozen type assigns_guarded_getstate/_guarded_setstate(_types.py) in its class body (@dataclass(slots=True)would override inherited pickle methods) — unpickling fails at the LOAD site on field-layout skew, with one widening: a field added after its type shipped carriesmetadata={_types.ADDED_IN: "<release>"}and a default, and an older pickle missing it loads with the default (Ambiguity.alternative, 2.7;Token.reading,Reading.languages,Reading.second_surname,Reading.first_surname,ParsedName.order,Policy.two_given_names,PolicyPatch.two_given_names,Policy.lone_name_word,PolicyPatch.lone_name_wordandLocale.languages, 3.0.0;Policy.initials_as_family,PolicyPatch.initials_as_family,Policy.capitals_as_family,PolicyPatch.capitals_as_familyandNameEvidence.family_in_capitals, 3.1.0) -- a missing field without the marker, default or not, an unknown field and a renamed one are still refused, each a row intests/v2/test_types.py::_REFUSED_SKEWS, so a new field on a pickled type takes the marker or breaks every older pickle; the shared guard deliberately does NOT re-validate values (pickle is not a security boundary; canonical state comes from a validated instance).LexiconandLexiconReadingkeep their own copy of the guard (layering); a new unpicklable slot type needs the same treatment plus a round-trip test. Since 3.0's 4i-b aLexiconpickles its lists, its masks, its edit log, its choice of languages (_languagesand_strict, 4i-c, markedADDED_INso a 4i-b pickle loads choosing nothing) and its base as a SNAPSHOT of the reading index's rows, so a pickle parses as it did where it was written, a snapshot equal to the running release's index loading as the by-reference default again (decisions/vocabulary-model, 2026-11-02 #754, item 5); its private_sets,_cap_map,_same_as,_same_as_named,_familiar,_chosenand_filesfields are built at construction and never pickled.Lexicon's copy of the guard admits theADDED_INmarker, read under_lexicon._ADDED_IN, the same string, since layering keeps_lexiconfrom importing_types(test_lexicon_marks_an_added_field_with_the_shared_keyholds the two equal), so a newLexiconfield takes the marker and a default or breaks older pickles. A 2.x state holds the compiled sets instead, and is refused since 3.1 with aValueError(_lexicon._refused_2x) that tells the layout 3.0 loaded, 2.7's and 2.8's, to re-pickle under 3.0, and any older one to rebuild — that layout a frozen record (_LAYOUT_3_0_LOADED), never_VOCAB_FIELDS, which a new field joins and every 2.8 pickle would then lack, the translation 3.0 loaded it by being deleted (decisions/vocabulary-model, 2026-11-08 #1003); the 2.8Lexicon,Parserand locale-pack pickles intests/v2/data/lexicon_v28.pickleare the refusal test's input. And unlike the shared guard it DOES re-validate: a load goes through the constructor, which checks the base, refuses an edit not in canonical form, and refuses a list or mask entry that is not already normalized, because a foreign blob would otherwise load a different lexicon in silence (a snapshot base of a kind this release does not know, an editaddwould not have written, a list entry the fold changes). - One sanctioned global: the cached default
Parser(_parser._default_parser, whichparse()andParsedName.matchesuse). Lazily cached FROZEN singletons (Lexicon.default()'sfunctools.cache, the default parser's) are constants, not state; any second piece of module-level MUTABLE state requires amending the conventions doc, on purpose, in review. - Tests: all v2 tests live in the
tests/v2/package, one test module per source module plus the cross-cutting ones (test_reprs.py,test_layering.py,test_contracts.py,test_properties.py,test_benchmark.py, thecases.py/test_cases.pytable,test_regex_sync.py, which pins render's hand-copied patterns to the pipeline's,test_script_properties.py, which checks each row of the script-property table through the readers of each column that take a word, andtest_snapshot.py, which holds every corpus name's reading totools/differential/snapshot.jsonl— sharing_differential_fixtures.pywithtest_differential.pyandtest_corpora.pyfor the handles ontools/differential/), names stating behavior; the 1.x suite's parsing tests stand ported toparse()intests/*.py. Never assertLexicon.default()contents; the narrow sourcing spot-checks intest_default_sources_v1_vocabularythat pin the v1→v2 migration contract (e.g. the flippedparticles_ambiguousmodel) are the sanctioned exception.
Adding a word to the vocabulary — the steps are in nameparser/vocab/README.md, and the traps they have run into (other readings that clash, reading the real-name counts, the predicates that test a member's spelling, user-doc examples that use the word, recording the vetting on the word) are in nameparser/vocab/AGENTS.md, which loads when a session reads a vocabulary TOML file. First check the word's OTHER readings (uv run python tools/vocab/query.py --word <word>), then its bearers (uv run python tools/name_usage.py <word>, with --boxes adding rows for the fielded local corpora that count the word by box and country, and --country CC the country a pack is for). For a title that is also a name (rules/H9's batches, #913), uv run python tools/vocab/word_report.py <word>... --base <checkout> prints the H9 shape grid, the word's incidence in every fetched local corpus and its usage rows in one run, and --rank orders candidates before a batch is cut; uv run python tools/differential/measure.py --base <checkout> then runs every corpus check of the change, one after another, the local ones against the base.
Before adding a short/common word to PARTICLES globally, test it mid-string against realistic 3-token names, not just check for English-word collisions: Korean/Vietnamese given names put a short syllable in the middle slot (Park In Hwan, Nguyen To Nga), and Western names put a bare initial there (John V. Smith). A word that looks safe ("nobody is named 'to'") can still swallow a real middle name/initial into the last name once it's a global prefix — confirmed regressions for to/in/an/ten/then and bare v this way (PR #191).
Adding a curated sub-set of an existing vocabulary set (a marker over a base set, as AFTER_GIVEN_TITLES is over TITLES) — it is a behavioral PROPERTY of a reading, not a second word list: a row in nameparser/_reading_index.py's BEHAVIORAL table, a branch in its compile_readings adding the words whose reading carries it and a key in its Compiled TypedDict, a constant of the same name in tools/vocab/build.py's CONSTANTS roster (an import-time assert there holds the two to one list), and, for Lexicon to read it, _lexicon._COMPILED_FIELDS and _LexiconSets (no module re-exports a compiled set since 3.0, #1007). A property the compiler reads is kept in the reading index by indexed(), which reads BEHAVIORAL, so a new one reaches a choice of languages too. The subset relation then holds by construction, since the property cannot exist without its reading, so it needs no check. A marker that records a clash with a NAME is the other shape: derived from the word's name reading beside the clashing one (SUFFIX_ACRONYMS_AMBIGUOUS, SUFFIX_WORDS_AMBIGUOUS, and the complement NON_GIVEN_NAME_PARTICLES works from), not written as a property, so it too holds by construction (decisions/vocabulary-model, 2026-10-25). The two suffix markers, and check 11's agnomen clause, read a name reading through ReadingProperties.marks_a_clash, which leaves out a given name written short (#1383: md stays an unambiguous credential); the title and particle markers read every given reading, a short form standing at the head of a name where a title or particle does. A relation construction does not give (∩ == ∅ with a set the sub-set cannot logically overlap; a sub-set member that is also a title is silently inert, title handling consuming it first) goes in check_pool, with a mutation in tests/v2/test_vocab.py's table. Do not forbid titles ∩ particles — that overlap is intentional (freiherr, st). A caller states a property on a reading (add(w, kind="salutation", after_given=True)), so a caller's word reaches the base and the sub-set together, as a file's does (3.0's 4i-b). Two traps a gating set met (#752 phase 2i). Where a caller listing a word in the BASE set has always meant "read it as this everywhere" (the 1.4 recipe c.titles.add("dean"), spelled remove("dean", kind="given") since 3.0's 4i-b), the gated words compile OUT of the base rather than into both, or the gate overrides the caller's listing: TITLES_AMBIGUOUS is not a subset of TITLES for that reason, and a word in both reads as a title. And _VOCAB_FIELDS is read by three rosters: two in _pipeline/_vocab.py, the capitals shape's "unlisted" (in_any_wordlist, over _LISTED_FIELDS, the roster less four fields) and the comma contrast's "claimed as non-name" (_NON_NAME_FIELDS, those less surnames and bound_given_names), and _assemble._listed_whole, which reads it whole to tell a word the parse's own lexicon lists for Reading.languages. A new field joins all three by default; a field whose words may be names leaves the two in _vocab, which the grid found as John Smith, DEAN reversed where C6 had read a credential; #789's given_name_abbreviations met it again (John Smith, JAS and Jas SMITH, XYZ reversed), found by review because its grid held only the dotted spellings the set was for -- a new field's grid holds the spellings it must NOT move too.
Shipping data from a new source: name its licence in the package metadata. Data the project derives by measuring (counts, its own cutoffs and filters) is its own; a curated list copied whole keeps its licence, and goes in an extra package rather than the core if that licence is a burden (decisions/shipped-data-licences, FACTS WE MEASURE). A list copied whole from a third-party dataset that lands in nameparser/ adds that dataset's SPDX identifier to pyproject.toml's license expression and a line to README.rst's License section, and, where its licence asks its text or notice to travel with copies, a LICENSE-<source> file at the root, listed in license-files and in tests/v2/test_licensing.py's _THIRD_PARTY. A list the project measured on a dataset (a census table's counts, a ranking cut at a measured cutoff) adds nothing to the expression: it is credited in its module's docstring and in README.rst's License section, and listed in test_licensing.py's _CREDITED. The INE (CC BY 4.0, 3.0.0), Taiwan (OGDL, 2.5.0) and Unihan (Unicode License v3, 2.5.0, in locales/zh.py through tools/zh_surnames.py, which zh.py's docstring did not name) data shipped behind an expression naming the LGPL alone, and nam_dict's GFDL data reached the tree with no copy of the GFDL, until decisions/shipped-data-licences (2026-11-12, #1370); the Unihan data has since been replaced by Wikidata's, CC0, and its licence left the expression (that file's 2026-11-12 UNIHAN REPLACED), and nam_dict's data has since left the tree, its familiar pairs dropped (#1372) and the suggester's given names ranked from ORCID (that file's 2026-11-12 GIVEN NAMES FROM ORCID); the INE and Taiwan lists, being the project's measurements, left the expression again and are credited only (that file's 2026-11-13 #1382 MEASURED DATA LEAVES THE EXPRESSION); and the nicknames list's familiar forms, the last list copied whole, left with LICENSE-nicknames, so the expression is LGPL-2.1-or-later alone (that file's 2026-11-13 THE NICKNAMES LIST LEAVES). A replacement for a list is generated from data the project may use and reviewed, never by checking the list against that data, which would leave the result derived from it; the list may stand as a yardstick of what the replacement misses, nothing drawn from it (decisions/name-matching's 2026-11-12 and 2026-11-13 entries measured nam_dict's and the nicknames list's pairs that way).
Comparing configurations: use tools/differential/config_diff.py, not a throwaway script. Parsing the corpora under two or more configurations in one tree (the default against a choice, plain against strict, a lexicon with a word removed via expr:) is config_diff.py diff, parallel, with corpus, country, regex and sample filters, the moves grouped by field and the words whose role changed ranked; config_diff.py gaps is the per-language strict-gap report on top of it, and --readings writes every name's readings so two trees' runs compare line by line. #1000, #1005, #1017 and #1019 each wrote a single-process script for this (tools/differential/README.md, "Measuring a change").
Measuring a change to name matching: use tools/differential/match_diff.py --base <checkout>. A change to nameparser/_match.py, or to the vocabulary only the name match reads (same_as, familiar), moves no parse, so the snapshot and every corpus check below report nothing; match_diff.py lists every name pair whose check result or keys moved, under twenty-two settings, and every consistent pair sharing no key (#1278). A clean run vouches only for the shapes its draw holds: it draws its pairs from tests/v2/test_match.py and the corpora, so a change to a shape no drawn pair holds reports 0 moves (#1390 moved 0 of 687,500 rows until its own test rows existed). Add the change's rows to the test file first, then read the run. A setting naming an outcome the base does not know subtracts nothing there, so -joined against a base older than #1261 compares a caller who drops joined with the old default, which is the claim that caller keeps what they accepted. The base is the branch's merge base, re-pointed for each branch: a scratch base kept from the previous PR measures that PR's moves too, and #1261's first figures came from #1262's base, found by review. #1221, #1267 and #1260 each wrote a throwaway oracle for this first (tools/differential/README.md, "Measuring a change"). It parses under Parser() and locales.ES alone, so a change to how a caller's Lexicon edit is applied moves nothing in it by construction (#1404's remove of a familiar pair: 0 moves, which vouches only that the default did not move), and is tested through a matcher built on the edited lexicon. And an edit that names a word the match reads must compare it as the match does: the familiar index files each name under its folded forms (_lexicon._forms), so #1404's first build, cutting a pair by its stored spelling, left Alex / Alejandro consistent through the pair mul.toml stores on álex, found only because a test asked the matcher and not the lexicon's readings; give such an edit a row whose stored word differs from the written one by an accent and by a transcription (ü / ue).
Measuring a change to the group suggester: use tools/differential/suggest_measure.py. Run it after any change to nameparser/_suggest.py, to nameparser/config/_order_names.py (or tools/vocab/order_names.py, which writes it) or to a predicate a signal reads (the capitals, particle and patronymic tests, and the title, suffix and numeral tests a name is read past), or to rules/O9 or rules/O6, whose readings the capitals_as_family and two_family_names votes ask of the parse itself: suggest moves no parse, so the snapshot and every corpus check report nothing. It draws groups of known order, 2, 3, 4, 5, 10, 20, 50 and 200 names by default (a change to a threshold adds --sizes 2,3,4,5,10,20,50,100,200,500,1000,2000: a share counted among the names that vote holds at 200 names and fails past it, which no default size shows, and #1442's two stray votes decided lists of 500 and more for that reason), from the local corpora and reports the share of groups read right by size, the same-order rows being the anti-goal (at least 95% at every size, save pv-listed-given's two same-order rows, a list of nothing but given names that are surnames the ORCID surname table lists (Cooper, Burke, Clarke), which that table reads the wrong way round, a cost left open (decisions/group-suggestion, 2026-11-19 #1364), save orcid-givcaps' two same-order rows, a list writing its given names in capitals (ANNA Smith), which the capitals signal reads the wrong way round by design (decisions/group-suggestion, 2026-11-12 CAPITALS), and orcid-byline-joined's given-first row at 50 and 100 names, and at 200 until #1357, a list of nothing but AM Hoy bylines that the few names the name tables vote on decide (decisions/group-suggestion, 2026-11-14 #1355, which took orcid-byline's own row off this list, as #1397 took orcid-famcaps-short's); groups of 2 to 4 are where #1308's final review found a patronymic rule forcing given-first on a family-first base); --set NAME=VALUE overrides a threshold, and --set _MIN_VOTES=1000000 --set _MIN_PATRONYMIC_VOTES=1000000 --set _MIN_RUN_NAMES=1000000 --set _MIN_TWO_FAMILY_VOTES=1000000 decides nothing and is the harness proof (the order count alone leaves the patronymic rule free to decide its own given-first order, the two vote counts leave the letters setting free to decide, and the last holds two_family_names; _MIN_VOTES also holds capitals_as_family, whose table --set _MIN_CAPITALS_LETTERS=1000000 empties alone). A change to the two_family_names vote reads the orcid-span-CC populations (ORCID holders of a country, the boxes saying which words are the family) by country: the groups deciding the switch, which the countries the switch costs (Bangladesh, Ghana, Kenya, Pakistan, Vietnam, Angola, Mozambique, Turkey) must not reach, and whole names right under the suggestion against the base (decisions/group-suggestion, 2026-11-19 #1452). A table change also moves the print(suggestion) evidence docs/getting-started.rst and docs/suggest.rst show as doctests, which uv run pytest does not run: run uv run sphinx-build -b doctest docs <tmpdir> too (#1374's ORCID table made Wang Xiaoming a given-name vote and failed every build job). Its figures are quoted in Parser.suggest's docstring, docs/suggest.rst and docs/design/decisions/group-suggestion.md; re-take all three when they move (decisions/group-suggestion's THRESHOLDS entry names the command, and its latest dated entries carrying re-taken sizes, 2026-11-19 #1364's, #1447's and #1452's, hold the figures the other two round; the 2026-11-12 CAPITALS entry holds the capitals_as_family table, which the docstring's and docs/suggest.rst's capitals sentences round). A signal that reads one of the pipeline's predicates must read it exactly where the pipeline's rule does, no wider and no narrower, and its tests need a row at each edge: #1310's patronymic signal first voted an -ovich ending on any word (wider: two-word Abramovich Roman decided East Slavic and forced given-first), then its fix refused one on the first word, which rules/O1 never asks about (narrower: Abramovich Roman Arkadyevich, which the rule reads right, cast nothing). Only the second review caught the narrowing. A signal that votes where exactly ONE end of a name is listed votes by the other end alone once one end is no longer read: #1355's first sketch stopped looking up a short capitals word opening a name, and WU Zhi then cast a given-first surname vote by Zhi, so the shipped rule silences the signal on the whole name; when a rule stops reading a word, put a name whose other word is listed too in its grid. And a rule keyed to a word's shape needs a population of nothing but that shape: the default populations mix short capitals surnames with long ones, so the ending word's twin of that defect (Zhi LI) went unseen from #1308 until #1355 cut orcid-famcaps-short, and #1397 fixed it (decisions/group-suggestion, 2026-11-14 #1355 and #1397). A setting has more than one effect, and a suggestion that leaves something out leaves it out on every base: #1356 was first decided on "the East Slavic rule stands down under a family-first order", true of its reordering and false of its patronymic view, and PR #1399 as first pushed then kept every family-first base's order. Five names written Zzyvan Petrovich Qqsidorov under FAMILY_FIRST were read family Zzyvan where master moved the base and read them right; and SIDOROV Ivan Petrovich five times under FAMILY_FIRST_GIVEN_LAST lost the rule, though capitals_as_family, suggested in the same patch, makes the rule name the patronymic there. Review found both; the tool's table was identical with and without them, its populations then holding neither shape and no FAMILY_FIRST_GIVEN_LAST base anywhere in it (it has read the parliament lists under one since, which catches the second kind on a real list; its draws still run under two bases). Before deciding what a suggestion leaves out, sweep every base order × every switch the same patch can turn on × both written positions of the word the rule reads, and compare whole names read right (given and family), not the family alone: FAMILY_FIRST_GIVEN_LAST reads the family of Sidorov Ivan Petrovich right and its given name wrong, which a family count scored as nothing to fix. One signal is wider on purpose, and says so where it is decided: the letters signal (#1254) counts a run joined with full stops (B.K.), which rules/O8 never moves, beside the spaced runs it does, since three quarters of Nepal's runs are written joined (decisions/group-suggestion, 2026-11-11 LETTER RUNS); a test holds every other run to the rule exactly.
Validating a new parsing rule — before implementing, simulate it in a throwaway script against TEST_NAMES (plus a few target-language examples) to catch regressions/false-positives early. E.g. this surfaced the last_base do/st/mc empties and the patronymic "David Michael Abramovich" false-reorder. After the change, tests/v2/test_snapshot.py lists every corpus name it moved, grouped by changed field -- read them, and re-record with uv run python tools/differential/snapshot.py --record once every move is intended, so the PR diff of snapshot.jsonl shows the reviewer the same list. uv run python tools/differential/cldr_agreement.py reports how the tree's agreement with CLDR's stated name fields moved; tests/v2/test_cldr_agreement.py fails on any move, and tools/differential/cldr_agreement.json doubles as a measured list of names the parser and CLDR read differently. The same command and test score the GND corpus's real names (gnd_fields.jsonl, record gnd_agreement.json) by the same rules, and --record rewrites every record, printing per source what it accepts. A locale-pack change reads the second view the same command prints, per pack (cldr_agreement_locales.json, #672, and wikidata_native_agreement_locales.json for real Han and kana names); its JA rows run only with the ja extra installed. A change to Han, Hangul or kana order or to Korean segmentation reads wikidata_native_agreement.json too: the only real names in those scripts the corpora hold. It holds no honorific, so a change to the honorific peel moves nothing there. A change to comma or credential handling also reads the local corpus of hand-typed names (snapshot.py --local ctgov-officials --base <base checkout>, which reads the base from a baseline kept for its package's files and never the shared snapshot beside the corpus (a base read once from the same fetch is copied rather than parsed again; --sample N reads a fixed sample while iterating; the shared snapshot beside the corpus is one file per source for every worktree, and #752's phase 2f found ctgov reporting a sibling branch's 1,334 joined-credential readings as its own moves against it); tools/differential/README.md's "Local corpora"): the one population of names nobody chose for a test or a catalog, so it shows how often each shape is typed, and the one no CI run sees. A change to title handling reads ukec-individuals the same way: UK donors' names in spoken order and mixed case, in 8,219 of whose 15,214 parse() read a title on 2026-10-22. A change to English titles, honorifics or post-nominals also reads snapshot.py --local govuk-people the same way: GOV.UK's display names of ministers, officials and officers, the title run and the post-nominals as an office writes them (The Rt Hon, Sir, Baroness, ranks; KC, CBE, KCB), in 2,093 of whose 6,021 parse() read one or both on 2026-10-30. A change to Spanish titles, to the es pack, or to how a title marks where a name starts after an office reads snapshot.py --local dof-signatures the same way: the names in the signature blocks of Mexico's Diario Oficial for 2025, cut from the clause that names the signatory's office, 65.4% of its 33,565 signatures opening with a title (Lic., Dr., Mtro., C., Licenciada, C.P.), whose first word parse() read as a title in 82.1% and parser_for(locales.ES) in 86.8% on 2026-10-31. A change to particles or generational words reads snapshot.py --local tse-donors the same way, Brazilian names in spoken order dense with both. A change to initials, to a title word outside English, or to how a script's combining marks are read reads snapshot.py --local nepal-candidates the same way: Nepal's local election candidates, each a romanized name (surnames written as initials, B.K., K.C.; honorific titles such as Guru in front, Shekh, a title there until #752's phase 2j made it one only inside a title phrase, and Md., a title by its period's shape until #1383 made it Muhammad written short, the given name) beside the same name in Devanagari, written with vowel signs and the virama, combining marks the letter-shape tests do not count as letters (decisions/nfd-shapes), and with the joiners ZWJ and ZWNJ. It is the only large population of South Asian names the corpora hold, and its corpus reads both scripts. A change to non-Latin scripts or to Arabic-script names reads snapshot.py --local jrc-names the same way, and local_corpora.py groups jrc-names: the spellings of one person across scripts and transliterations, harvested from news text, with 17,074 Arabic-script spellings where the committed corpora hold 315 distinct names with an Arabic letter, 96 of them CLDR's fictional renderings (2026-10-24), and under a licence that keeps even a reading of one of its names in the cache. A change to patronymics, to Turkic or East Slavic names, to Indic titles and initials, or to Slavic or Portuguese double surnames reads snapshot.py --local opensanctions-parliaments --base <base checkout> the same way, and local_corpora.py groups opensanctions-parliaments: the members of twenty-eight national chambers as each parliament writes them (Azerbaijan, the Central Asian chambers, Turkey, Croatia, Slovenia, Slovakia, Portugal, India, Ukraine, Belarus, Russia, Indonesia, Ethiopia, South Korea, Israel, Mongolia, and since 2026-11-19 Malaysia, Pakistan's two chambers, Egypt and Somalia, #1465) and Indonesia's 2018 regional heads, read through OpenSanctions, 26,515 spellings of 20,856 members on 2026-11-19 (24,302 of 19,283 on 2026-11-12, before the five chambers and some other lists' newer exports; 24,084 of 19,216 on 2026-11-08, before the Khural and other lists' newer exports), some members' aliases in another script (Kazakh beside Russian Cyrillic, Uzbek Cyrillic beside Latin, Devanagari beside Latin, Hangul and Hanja or Hebrew beside Latin) or with a title (Shri, Smt.), the population issues #1186 to #1192 were read from, and the one that measures Indonesia's H. and Imam (#1205, #1206) Ethiopia's father's name (#1203), Korea's Hangul and Hanja (#1213, #1215, #1216) Israel's Hebrew (#1209 to #1211) and Mongolia's Cyrillic, the father's name first (#1237, mn_parliament, 126 members, added 2026-11-12), and Egypt's Arabic-script names, each written short and with the full chain of names (#1072, #1464); config_diff.py --group <dataset> keeps one parliament. A change to Malay, Indian-Malaysian or Chinese-Malaysian names (bin, binti, B., bt, a/l, a/p, anak, the @ alias, MD, honorifics such as Ustaz and Cikgu opening a name, a Chinese name written family first) or to names written wholly in capitals reads snapshot.py --local my-candidates --base <base checkout> the same way: Malaysia's election candidates of 2008 to 2023 as their ballots name them, in capitals, 3,077 distinct names on 2026-11-19, grouped by the ethnicity each file states (config_diff.py --group chinese), the population issues #1467, #1468, #1164, #1183 and #1179 were read from. A change that cuts one written word across two fields, or joins two written words, first reads how local_agreement.py compares a box (agrees, tools/differential/README.md): 3.1's #1296 cut B.A.S.D. into given B., middle A.S.D., and 1,140 orcid-researchers records scored a miss though read right until #1470 (measured 2026-11-19). A change to title vocabulary reads local_agreement.py --base's titled in and titled out lines beside its regressions: a listed title the filer typed into the given-names box and the parse reads as the title is counted apart from the agreement figure since #1501, 9,145 orcid-researchers records on 2026-11-20, so a word newly read as a title moves records that agreed into titled in (a given name wrongly peeled, as Hon is in Hong Kong), not into the regressions; read the titles listed there. A change to which field a word lands in also reads local_agreement.py psc-individuals --base <base checkout> the same way: real names with the four boxes their filers typed them into (UK companies' people with significant control), scored field by field and by nationality; and local_agreement.py orcid-researchers --base <base checkout>, ORCID holders' own two boxes (given names, family name) from every country, scored by the country they work or live in -- a population each person split for themselves, academic but worldwide, the one to read for a change a language pack makes. Its name is COMPOSED from those boxes, given first, so it cannot show which word a writer put first: a count of where a word falls in it is fixed by construction, and #1163's 538 records with the trailing letters in the family box against 0 with the word before them (Lakshmi R S, never R S Lakshmi) reproduced from that field. Order is measured on the free-text credit name (125,960 of the 2026-10-27 fetch's 1,831,533 records, which lean towards bibliographic bylines), against the boxes (decisions/O8); and local_agreement.py patentsview-inventors --base <base checkout>, US patents' inventors in the two boxes their filings give, split by a professional filer, with how many people filed under each name in each country, the one to read for how common a name's word is among a country's US-patent inventors. A change to titles or post-nominals, or to the cs pack, reads local_agreement.py cz-candidates --base <base checkout>, and with --locale cs too: Czech election candidates' four boxes (the title before the name, given names, surname, the title after it), scored by election, the only population whose titles are stated apart from the name, 36% of its 170,181 records titled (2026-10-30), nearly all academic degrees; its names are composed from the boxes (Ing. Jan Novák, Ph.D.), so it says nothing about how a writer spaces or punctuates them. A change to family-first order, to Vietnamese names or to their titles reads local_agreement.py uit-vinames --base <base checkout> and local_agreement.py vn-assembly --base <base checkout>, and with --locale vi, locales.VI being that pack (#1108): 21,090 distinct names and 499 National Assembly deputies written family name first with their diacritics, whose parts no one filed but the convention derives (first word the family, last the given, the words between the middle name), so they score middle names, which ORCID's two boxes cannot, and vn-assembly the GS./PGS./TS./ThS. titles composed from the education each deputy states. These are the only real fielded populations outside the committed fields files, and no CI run sees them either.
The suite runs in parallel, so a test that passes only after another one has warmed a cache fails at random — --dist worksteal hands each worker a different slice of the tests on every run, splitting modules too. Three tests/v2/test_vocab.py tests repointed tools/vocab/build.py's ROOT at a fixture tree while its lazily loaded _lexicon.py was still read from ROOT, and passed for as long as the suite ran serially, because an earlier test always loaded it first; each failed when run alone. Run a new test on its own (uv run pytest -n0 path::test) before trusting it, and bind a path at import, as build.py's VOCAB, OUTPUT and _LEXICON_PATH are, when tests repoint the root it is derived from. A functools.cache is per process too, so tests sharing a grid walk (below) take the walk once per worker that runs one of them.
Code branching on an optional extra takes the untested branch only in CI — namedivider sits in the local .venv from earlier work but is absent from every build job, so if _JA_AVAILABLE else None runs the PRESENT path locally and the ABSENT path in CI. That broke #337 after a locally-green suite. Before pushing anything that touches the ja extra, run the suite without it: uv pip uninstall namedivider-python && uv run pytest -q, then reinstall. The editable install of nameparser itself is the same trap one step out: a distribution packager runs the suite from the sdist with nothing installed, and #949's test of word_report.py's child reached check_source only because an import with no tree on the path fell through to the install; with none, it died on ModuleNotFoundError first. A test that needs a package outside the tree plants one, as that test now does, and a test that reads git skips outside a checkout. CI's source-tree job runs the suite from a git archive export with nothing installed, so both now fail at PR time. The packager's other layout is the converse, and it broke a whole release: Debian's autopkgtest installs its built package and copies tests/, tools/ and docs/design/ beside it with no nameparser/ source package, and there 3.0's suite aborted at collection (tools/vocab/build.py exits where it loads nameparser/_reading_index.py by path), with 36 failures and errors behind it under Debian's own skip list (measured 2026-11-08), each a test reading a package file by its checkout path (parents[2] / "nameparser" / ..., a tool's ZH_MODULE) or docs/*.rst (#1184). A test reads the package through the module it imports (Path(module.__file__)); one whose subject is the source tree (the vocabulary build, a test running the differential harness, the citation comments) skips through tests/checkout.py's require_checkout() or @needs_checkout, and one reading docs/*.rst through @needs_docs, a separate flag because the packager's build-time run has the built package beside the tests and still no user docs. Mark the test, not the module, so the rest still runs there (a harness test left unmarked fails there with a note naming the mark, tests/conftest.py); CI's installed-package job runs that layout.
A local run on 3.11 cannot see a deprecation newer interpreters raise — .python-version pins 3.11, pytest's filterwarnings = ["error"] turns every warning into a failure, and CI runs 3.11 through 3.15, so a stdlib call deprecated in a later release passes here and fails the newer jobs. #795 passed maxsplit to re.split positionally (deprecated in 3.13) and failed four jobs while 3.11 and 3.12 passed. A stdlib MESSAGE a test reads is the harder case, since the newest interpreter need not show it either: argparse lists an invalid choice's options bare on 3.12 (3.12.13) and quotes them on 3.11, 3.13, 3.14.7 and 3.15, so #1114's test matching 'off' passed here and on 3.15 and failed only 3.12. Match such a message in a form every interpreter writes. Before pushing new code, run it on the newest interpreter CI uses too, in an environment of its own: UV_PROJECT_ENVIRONMENT=<a scratch folder> uv run --python 3.15 pytest -q (uv fetches the interpreter). A bare uv run --python 3.15 rebuilds the worktree's shared .venv on 3.15, and the next plain uv run rebuilds it back on 3.11. A reviewer or a background run using that .venv meanwhile loses packages mid-run: on 2026-11-05 the #1087 session's run left the venv without namedivider, and #1088's lost hypothesis under its reviewers. With its own environment, the 3.15 run leaves .venv untouched (its pyvenv.cfg unchanged, measured that day), so it can run beside the reviewers. If a bare run already happened, uv sync --all-extras restores the extras. Pass maxsplit, count and flags to re.split/re.sub by keyword.
Parsing must never write into its config — Lexicon and Policy are frozen, so a parse cannot write to them; v1 did, registering dotted abbreviations like Lt.Gov. into the shared config through 1.2.x, which made parse results order-dependent and thread-unsafe. Keep any new cache keyed and immutable for the same reason (tests/test_constants.py's JoinedPieceTests hold the readings of that bug's inputs).
The nameparser/config vocabulary constants are frozen (2.2, #293; private since 3.0, #1007) — _compiled.TITLES.add("dean") raises AttributeError at the line that writes it, so a runtime addition goes on a config OBJECT instead: Parser(lexicon=Lexicon.default().remove("dean", kind="given")). What the freeze buys: Lexicon.default() is functools.cached and reads the constants once, so pre-freeze an edit after the first parse was invisible to parse() while one before it was not, which depended on nothing the reader could see (through 2.x the v1 Constants copied the constants at every construction too, a third moment).
Titles permanently shadow first names — be conservative — any word in TITLES is always consumed as a title and can never be parsed as a first name. "Dean" is the canonical example: it's a common academic title and a common given name, so it is not in TITLES but in TITLES_AMBIGUOUS, a title only inside a title phrase (Dean of Students, Associate Dean; rules/H9, #752 phase 2i), and users who need it everywhere add it to a Lexicon of their own. A title that is also a given name now has that machinery: a given reading on the word moves it there, decided word by word in measured batches (decisions/vocabulary-model's 2026-10-24 order). A rule that reads a title by its neighbours in the title run meets more phrase shapes than the qualifier-then-head it was designed on: the object of a connective (President of the United States, the Queen's Bench, whose united, states and bench are modifiers with no head after them), a head before of (Member of Parliament), and a qualifier written after its head (Chargé d'Affaires, Princess Royal). Phase 2i's first build, "a modifier needs a head title after it", broke President of the United States, Chargé d'Affaires and the committed Queen's Bench row, found by the case table and the committed corpora, and then read a modifier ENDING the name out of H5's trailing run (Jane Smith Vice.), found by the design-docs review; put each shape, and the trailing position, in the grid of any such rule. Before adding a word to TITLES, ask: "Could this plausibly be someone's given name in any culture?" If yes, don't add it globally; it belongs in a caller-supplied Lexicon instead. This same caution applies to international honorifics — Frau is a first name in some contexts, and Prince and Sheikh were titles until 2.7 gave them a given reading, which moved them to TITLES_AMBIGUOUS (rules/H9). It also applies to any prefix sub-set gated on "never a first name": obscure-looking foreign particles are surprisingly often real given names — Von (Von Miller), Vander (Brazilian, also the Arcane character). When unsure, exclude — a missing member just means that name isn't auto-handled, whereas a wrong member misparses a real person. The decided exception is a word borne as a name only RARELY in the leading position — mostly a surname written last (graf, greve, knight), a few with small given-name or surname-first counts (herra, hrabia): the title claim acts only in front, so it ships, and a name that begins with it (Greve Anna, Herra Wijaya → title) is the accepted cost. That is a judgment by incidence, made per word, with the counts taken recorded on the word's entry in nameparser/vocab/ (herra's, hrabia's; graf, which predates #606, and greve and knight, which #606 proposed, carry none) and the class in decisions/salutation-titles (rules/H1's Accepted clause states the cost), not a rule a sweep can apply: a word that commonly leads a real name (Vietnamese Ông, the given names thiru, puan) is still out of TITLES, a pack that settles the reading taking it in (locales.MS reads Puan as a title, decisions/salutation-titles, 2026-11-19 #1179); marshal reads as a title only in a phrase (Field Marshal). tools/name_usage.py produces the counts this judgment starts from (role counts, plus Wikidata citizenship to tell where a family name is written first); its Wikidata column is a lower bound (Shehu Shagari has no given-name statement), so a small count there proves little and a zero proves nothing, and its nam_dict row gives a band per country rather than a count, with a missing name proving nothing either.
The period-abbreviation title inference runs at the head of the GIVEN-NAME part, not the head of the name — an unrecognized multi-letter word ending in a single trailing period (_pieces._PERIOD_ABBREV, v1's period_abbreviation regex, imported from _vocab, {2,} letters — it was assign's until #424 and group's until #439) is treated as a title in the leading title run, e.g. "Insp. Jane Morse" → title='Insp.'. "Leading" is per SEGMENT: _peel_leading_titles is called for NO_COMMA segment 0, SUFFIX_COMMA segment 0, and FAMILY_COMMA segment 1, so "Morse, Det. Insp. Jane" → title='Det. Insp.' and a lone "Smith, Xyz." → title='Xyz.' — long-standing, verified against 1.4.0, and the mechanism behind #296 ("Smith, Jr." read title in 1.4.0; the comma's credential read takes it as suffix Jr. now). The docs said "leading word" until 2026-08-01 and were wrong for every comma path. FAMILY_COMMA segment 0 peels too since #701, but by VOCABULARY only (rules/H6, in assign's family-comma branch rather than _peel_leading_titles): Dr. Smith, John → title='Dr.', while Xyz. Smith, John keeps family Xyz. Smith, and a title-particle (St, Freiherr) stops the run, as does a title with nothing but post-nominals behind it (Dr. Jr., John keeps family Dr.); a title/suffix dual with a name word behind it still peels (Rev. Sr. Smith, Mary). It adds nothing to the Lexicon, so the periodless form ("Insp") is unaffected elsewhere. The {2,} length requirement — not a separate initials check — is what excludes single-letter initials like "J.", and since #1136 a closed list of transliteration digraphs (_vocab._DIGRAPH_INITIALS, e.g. Yu., Zh., Kh.; not Ts., Ch. or Sh., which are also titles written short) is declined by spelling in both is_leading_title and is_title_shaped (rules/H2's transliteration-digraph Except), reading as a name word rather than as T5's initial; the same word after the given name is left as a middle name. The inference OUTRANKS vocabulary where it runs: "Esq. Smith" → title='Esq.' even though esq is suffix-only vocabulary, because the shape rule fires before anything consults the suffix sets. The one vocabulary it yields to, since #789 (phase 2k of #752), is a given name written short (a given reading with same_as, in the TOML or a caller's add(w, kind="given", same_as=...), compiled into the internal Lexicon._sets.given_name_abbreviations): "Chas. Smith" → given='Chas.', read off classify's vocab:given-abbreviation tag in is_leading_title and off the lexicon in _vocab.is_title_shaped, the two spellings of one test that test_is_title_shaped_and_is_leading_title_agree holds together. The second spelling is what rules/C4's comma count and the title phrase's head run ask, so a change to the shape moves comma names nobody wrote it for: #789's first grid held no comma and missed Chas. Smith, Ed (given 'Ed', family 'Chas. Smith' before, suffix 'Ed' after), which only mutating is_title_shaped's half alone showed. Put a word of the ambiguous class after a comma behind the shaped word (X. Smith, Ed), and a modifier in front of it (Vice X. Smith, Ed), in the grid of any change to the shape, and mutate each spelling separately. The INFERENCE still runs in one direction only, and that is what the two slots share and where they part (rewritten 2026-09-08, #316): a period-marked word is claimed by SHAPE at the front and by VOCABULARY at the back, so an unlisted abbreviation opening a name is a title while an unlisted abbreviation ending one is a NAME word ("John Smith Xyz." → family='Xyz.'). A trailing period-marked word the vocabulary knows as a title now IS one ("John Smith Prof." → title='Prof.', rules/H5) — the comma path read a lone Smith, Prof. that way already, and the given part's Smith, John Prof. since 2.3.0 (1.4.0 through 2.2.0 read Doe, Jane Mrs. middle 'Mrs.'), so the two agree now — and a trailing period-marked word the UNAMBIGUOUS SUFFIX vocabulary knows is still a suffix, the suffix run being peeled first ("John Smith Esq." → suffix='Esq.'). A BARE trailing title word stays a name word ("John Smith Sir", "Mary Jane Pope"), which is the doctrine line below, save a listed salutation ending the given part after a family comma (rules/H8, "Doe, Jane Mrs" → title='Mrs'). Meanwhile period_joined_vocab resolves INTERIOR-period tokens (Lt.Gov., Msc.Ed.) to title-or-suffix by vocabulary, and _extract._period_escape treats any period-final delimited content that rules/S1 does not set apart as not-a-nickname. The trailing chain's SHAPE is wider than the front's since #1116: a word ending in a period may hold periods or hyphens inside it (_vocab._TRAILING_TITLE_SHAPE), so a listed title written that way and a period_joined_vocab title ending a name chain ("Hans Meier Priv.-Doz.", "John Smith Lt.Gov." → title), while H2's front shape stays letters only; a title listed whole with a period inside it needs no final period there ("Maria Rossi Dott.ssa", classify's JOINED_TITLE_TAG, #1104). Four sites, and the trailing one now resolves by two vocabularies in order rather than one; a fifth, rules/H10 (#490), reads a run of single letters joined by full stops at the head by vocabulary looked up without its stops, as the title it spells where the vocabulary marks that title dotted and a title the run keeps follows it (U.S. District Judge, but U.S. Grant given 'U.', middle 'S.', its given names 'U.S.'); unifying the rest is open design work, not settled. (#109; see docs/shapes.rst "Titles you didn't configure")
Cyrillic suffix regexes need re.I even when the pattern is suffix-only — a Latin title-cased word (Ivanovich) keeps its suffix lowercase, so re.I seemed skippable; but an irregular Cyrillic suffix can be nearly the whole word (ильич), so title-casing capitalizes into the suffix itself (Ильич). east_slavic_patronymic_cyrillic (v1's name for what is _vocab._EAST_SLAVIC_CYR since 3.0 removed config/regexes.py, #1008) shipped without re.I on the Latin reasoning and silently failed on capitalized irregular forms — don't assume Latin's title-case safety transfers to Cyrillic. (#185)
Suffix words vs the initial veto — single-letter roman numeral suffixes (i, v) are suffix words but also initial-shaped, so _vocab.is_suffix_strict (v1's is_suffix) vetoes them through _vocab.is_initial. _vocab.is_suffix_lenient accepts suffix words without the veto and is only safe in unambiguous positions, after a comma (#136, #144). The veto runs only in a script that writes initials since #320: is_initial ANDs the bare shape test (is_initial_shaped) with "not in a script that writes no initials", the rows of _policy._SCRIPT_PROPERTIES whose writes_initials is false (Han, Hangul, Hiragana, Katakana, since #1256 the Myanmar and Thai scripts, since #1149 the Arabic script, whose د. and م. are titles, and since #1380 the Lao script; decisions/script-properties), so the single-character CJK suffix words (씨, 様, 氏, 군, 양, 님, 殿) written with a period read as suffixes: "김민준 씨." gives suffix 씨.. V./I. still lose to the veto and still need the lenient test.
Comparing against v1 needs PYTHONSAFEPATH=1 AND a directory outside the worktree — uv run --isolated --no-project --with 'nameparser==1.4.0' still puts the checkout's nameparser/ ahead of the pinned wheel on sys.path, so the "v1" side silently imports the branch and every comparison reports parity. Run it as cd <scratch dir> && PYTHONSAFEPATH=1 uv run --isolated --no-project --with 'nameparser==1.4.0' python -c "...". This produces false confidence rather than an error, so it invalidates results without ever looking wrong. A tests/v2/cases.py row's parity means 1.4.0, and no test checks it -- the table runs every row against the tree, so a row labelled parity that only matches master passes for good, and parity is the dataclass default, so a row written with no classification claims it. #614 added eight such rows, compared against master; #620 found them by running the wheel this way and relabelled each with the change its reading came from, found by git bisect run in a scratch worktree (git worktree add --detach, never this one). 3.1's prose sweep found 72 more, 27 of them #1395's md_* rows, and the check is a kept tool since: uv run python tools/differential/parity_check.py reads every default-config parity row with the 1.4.0 wheel, hardened as compare.py is, and lists each row 1.4.0 reads otherwise with its fields (--check exits 1 on one). It needs the network or uv's cache, so no CI job runs it, and it skips the rows carrying a policy or a locale, whose parity stays unchecked. Run it after adding a row on the default, and relabel what it lists the way #620 did. When bisecting, run Python with -B and git clean -fdx the scratch tree at each step: two checkouts within one second leave a stale .pyc whose source has the same mtime and size, and in 3.1's relabel one answered for two rows, naming a commit whose parent already read them.
A group-side reading of a family comma's given part that asks tail_reading disagrees with the given part's own walk, and the disagreement is accepted. tail_reading reads the part as the comma-less name reads it, plus the bare salutations rules/H8 adds after a family comma, which a predictor of this part asks for with salutations=True (#835); assign's walk over the given part after a family comma reads by its own predicates -- V before a third comma part is read strictly (#144), staying a name word (Smith, John van der Berg V, Jr. reads middle 'van der Berg V'), and P6 attaches a period-marked title-particle (St.) the comma-less reading takes as a title. So a bound or a decline group computes with tail_reading acts where the walk then reads no title: #623's chain bound (Smith, John Mc Prof. V, Jr. → suffix 'Mc, Jr.', middle 'Prof. V') and #637's join decline (Smith, abdul Prof. V, Jr. → middle 'Prof. V', Smith, abdul St. → family 'St. Smith'); a numeral VI to X was a third such shape until #784 read it as a suffix on both sides. Both were recorded rather than narrowed (decided as garbage input; decisions/H5 and #P5, rules/P5's Accepted clause). Before writing another group-side predictor of the given part, sweep those two shapes and decide, rather than rediscovering the gap in review. And a change to the trailing peel ITSELF reaches the given part through those predictors without touching them: #718's words-to-spare count for a one-letter numeral, asked through trailing_run_start, made the chain take the V in Smith, Freiherr von Berg V (given 'von Berg V', unreported) while assign's walk, which never counts there (S4: "read without it"), read it as the suffix -- found by review on a grid of family-comma and empty-head shapes behind a title-particle; the predictor now passes count_numeral=False. When a change moves what the peel takes, put a family comma with a title-particle head in its grid.
A comparison that runs both sides in one tree reports 0 differences, which is what success looks like. tools/differential/compare.py has been hardened against this — it generates its baseline worker into a temp dir, strips PYTHONPATH from the child, and aborts unless both the version AND the resolved path check out on each side; its README's three invocation traps are the analysis behind that design, worth reading before changing the harness. The exposure is ad-hoc comparisons you write yourself, where the same collapse has a cause the harness cannot disarm for you: the shell's working directory persists between tool calls, so a two-tree comparison written as two cds silently runs both halves in whichever tree it landed in. Pin absolute paths, and assert nameparser.__file__ on both sides the way compare.py does. The general rule outlives any particular trap: before believing a null result, prove the harness can report a difference — a clean run and a broken harness are the same output. The proof has to come from the input class the null result is about: #683 moved tools/name_usage.py to a POST and checked it with shehu, which is ASCII and so cannot show that the server decodes a Cyrillic body. A misdecoded query still runs and matches nothing, so the Cyrillic zeros it was meant to vouch for proved nothing until Иван (17,119 given) went through the same path. The converse trap is a mutation that moves nothing: it shows the code is unexercised by your grids, not that it is dead. #638 was filed calling group's chain re-ask dead on a grid with no title-particle head before a particle run and a dotted acronym; the next review found 400 moves (Smith, Freiherr van Berg X.Y.Z.) and the issue closed the same day. Before calling code dead, look for the input that reaches it. A CACHE of readings is the same trap one step removed: a wrong key copies one tree's readings in as another's, and the check then reports nothing. #859 first keyed snapshot.py --local's kept baselines by git rev-parse HEAD:nameparser, which answers for the enclosing checkout, so a gitignored copy inside one (build/lib) took the checkout's key; two reviewers found it. Key a cached reading by what the import reads -- the files on disk, hashed again after the read -- never by what version control says should be there. And a switch that changes no file defeats any file key: #752's spike set its options by environment variable, so after the first run every option copied that run's cached local readings until the variables joined the key (2026-10-24). A SHARED file of readings is the same trap with no key at all: a local corpus's snapshot.jsonl and psc-individuals' agreement.jsonl are one file per corpus for every worktree, decided by whoever recorded last, and on 2026-10-25 parallel sessions of #752's phase 2 read a sibling's re-record as their own moves -- the silent case being a sibling's record from a branch holding the same change, which reads as "no moves". Use --base <checkout> whenever another session may be measuring: it reads the base from a baseline keyed by its package's files and never touches the shared file. A kept reading is published under its key only once it is whole and its tree unchanged: --base's first draft had the agreement child write straight to the kept path, through a temporary name every session shared, so two sessions scoring one base could keep a record cut on a line boundary, which every later session would reuse. Write into a folder of the run's own, read it back against a count, take the digest again, then rename it into place. And the cache itself is shared: a test's corpus reaches a temporary cache only where a fixture has set NAMEPARSER_TOOLS_CACHE (each local-corpus test module's autouse wrapper of _differential_fixtures.own_cache), so a probe that plants one from anywhere else -- a scratch file, a test written outside those modules -- writes the real corpus. On 2026-11-04, during a review that probed config_diff.py score that way, psc-individuals was replaced by a one-record fixture, and every session's PSC score read one record until it was restored. Brief a reviewer to set NAMEPARSER_TOOLS_CACHE to a folder of its own before planting anything; local_corpora.fetch(source) called directly rebuilds psc-individuals from its cached parts (the CLI's fetch skips a corpus already present), and the rebuilt raw file's sha256 matching the kept agreement records' raw_sha256 shows it whole.
SUFFIX_ACRONYMS and SUFFIX_WORDS are DISJOINT by construction (since 2026-10-18; an import-time assert from 2026-09-08) — a word has one suffix kind, and its reading is an acronym or a word (acronym), so the vocabulary build refuses a word classified twice; the fix is to choose, not to relax the check — the two branches normalize differently (the word test strips only edge periods, the acronym test strips all of them), so a word in both is matched by two rules and which one fired is unreadable from outside. esq was the single overlap and left SUFFIX_ACRONYMS, which is what made the assert possible; the whole algebra that had made the overlap safe, and the criterion that decided which set a word belongs to, are in the suffix-acronym-collisions entry of docs/design/decisions/ if anyone wants them.
A given-name title run is deliberately not checked for whether the parse can build it — do not add a check — since 3.0's 4i-b it is a title reading with addresses="given", so the word is a title by construction, and a run of several words (add("lt col", kind="title", addresses="given")) is a phrase the build's check 8 admits; the lookup key is the space-joined run of Role.TITLE tokens, built by the parse — matched whole OR by that key's LAST word since #489, a run addressing the way its final title does — and a conjunction inside a run is itself tagged Role.TITLE, so "sir and dame" is a matchable key whose middle word lives in conjunctions. A whole-entry check rejected multi-word entries; a per-word check rejected that one. No static relation over the vocabulary sets decides reachability. An unreachable entry is inert — nothing consults it and nothing misparses — so the condition being "guarded" costs the user nothing while each guard cost a working configuration. If a diagnostic is wanted, it must be non-blocking — the multi-word UserWarning _normset gives a list entry is the shipped example; a raise remains wrong.
_normalize must reach a fixed point — storage and match-time share the one fold, and Lexicon.__setstate__ re-validates, so a value that changes on re-normalization changes under its owner. strip().strip(".") alone is not idempotent ('. a .' → ' a ' → 'a'). The loop is the fix; keep any new stripping inside it. Anything built on _normalize must converge too — _fold_words runs _normalize per word and DROPS the words that fold away (_title_key is that list space-joined, and _run_addresses_by_given reads the list itself, so its last-word arm is the last word of the FOLDED key by construction); keeping the empty slot stored 'lt .' as 'lt ', a key match-time can never rebuild (so the entry is silently inert) and __setstate__ rejects on the next round-trip as "not written by this version".
Perf regressions are caught by the scaling tests, not the absolute-time ones — the thousand-names test (test_a_thousand_names_still_parse_in_reasonable_time) uses constant-size, delimiter-free input and is structurally blind to a complexity regression. A new inner loop, a policy-gated stage or a shape that needs a prefix gets a row in tests/v2/test_benchmark.py: its module docstring says which table, and the comment beside each table carries the measurements behind its rule. The timed rows read the thread's CPU time (_CLOCK), not the wall clock, so they hold on a laptop other sessions are loading: measured 2026-11-11 beside 24 busy-loop processes on 12 cores, the wall clock read 27 of 33 ratio rows at or over their 6.0 bound and the CPU clock none. CPU time is not load-immune -- a thread moved to an efficiency core or onto a cold cache is charged the slower run, and a clean ~4.0x row read up to 5.6x (+40%) under that load -- and a ratio can read LOW too, a slow stretch landing on the small input -- so _ratio interleaves the two inputs and, where its first seven rounds read within 20% of the bound or over it, takes all 35 and judges the last minimums. Those rounds are not a retry: each only lowers an input's minimum toward its true cost, so the ratio converges on the true one, though not monotonically, which is why it is judged once, at the end, never at the first reading that passes. Never "fix" a flaky timed row by raising its bound or re-running the test until it passes, which lets a real quadratic through. Count instead of timing wherever the question allows (frames, _ShiftCountingList), since a count needs no serial pass and no extra rounds. And an ABSOLUTE frame count depends on what the process parsed before it (decisions/parse-cost, 2026-11-09 #1170). The counted guards that run in the parallel suite are ratios, a ±2% band averaged over 50 parses or wide enough for that drift, and exact counts of one function's calls (only=/caller=, == 0 up to == 6); each passed alone in a fresh process, after the 21,065 tests of test_cases.py and test_match.py in one, and in three full parallel runs (2026-11-11, #1352). A new exact pin needs the same check, and a new timed test takes the serial mark. Coverage is collected on ONE interpreter, 3.14's (COVERAGE_ON in .github/workflows/python-package.yml, whose comment says why).
A JSONL file written with json.dumps(..., ensure_ascii=False) is cut by str.splitlines() — json.dumps leaves U+2028, U+2029 and U+0085 unescaped, and splitlines() splits at all three, so one name pasted from a document holding a line separator turns its line into two halves of invalid JSON, and the file into one no reader can load. #801's review found it in the local corpora (a single official among 536,981 would have made the cache unloadable for good), and the review of that fix found it again one file over, in snapshot.py's dump/load, which the fix had not touched. So it is fixed at the shared source now: corpus_build.jsonl_line escapes the three and corpus_build.jsonl_lines cuts at "\n" only, and corpus_build's corpus and fields writers, snapshot.py, cldr_agreement.py, local_corpora.py, local_psc.py's extracts and local_agreement.py go through them. A new JSONL writer or reader in tools/ goes through the same two. Still outside them: the builders that write their own lines (build_cjk_corpus.py, _conventions, _shapes, _rules, _issues), compare.py's worker stream, the tests' corpus reads (_differential_fixtures.py, test_corpora.py), and the extracts of local_orcid and local_patentsview, streamed through gzip.open(..., newline="\n") rather than read whole for their 25M and 5.3M lines, which cuts at "\n" only as jsonl_lines does; none of the 16 committed JSONL files held one on 2026-10-21.
A row count does not prove a CSV whole: Python's csv returns a body cut inside a row as a short last row, without raising -- even inside an open quote ('a,b\r\n"x,y' gives [['a', 'b'], ['x,y']]). So a fetch that checks its row count against the source's stated total, and tolerates a few malformed rows, passes a cut body one name short. #842's review found it in ukec-individuals (two reviewers independently); the fix requires the body to end with a line break and its last row not to be short (a cut only shortens a row; a long last row is left to the malformed share), with a test for each arm, since a quoted field holding a line break lets a cut end at one. A new CSV source (a tools/differential/local_<source>.py module) takes the same check (local_ukec._ukec_rows's last-row test), and its skip shares are tested at their shipped values, not only patched open for a small fixture.
Expected-failure tests use @pytest.mark.xfail — the test classes are plain pytest classes, not unittest.TestCase, so @unittest.expectedFailure is not honored.
_normalize strips only a word's edges — whitespace, full stops and, in a non-ASCII word, an edge ZWNJ or ZWJ (#1335), the tatweel being deleted wherever it stands (#1151); interior periods survive, so 'M.D.' → 'm.d', not 'md'. Shipped keys in capitalization_exceptions are dot-free, so lookups must also try .replace('.', ''); whatever key matches, its value is a case mask applied to the word as written, never substituted for it (#459).
Doctests — docstring examples in nameparser/*.py run under uv run pytest (--doctest-modules; testpaths is tests + nameparser only). The .rst doctests in docs/ (every .rst file there) and README.rst are also run in CI: the python-package.yml workflow runs sphinx-build -b doctest docs dist/doctest (covers every .rst under docs/) and python -m doctest README.rst as separate steps after the existing -b html build. Both should pass with zero failures — expect a clean run, not baked-in noise. An example needing an optional extra cannot be a doctest. namedivider-python is not in the dev group, so it reaches only the ja-extra job; a .. doctest:: requiring a segmenter passes locally, where it is incidentally installed, and fails sphinx-build -b doctest in all five build jobs. Use .. code-block:: python for those. That is why the Japanese examples in east-asian.rst are code-blocks while the Korean and Chinese honorific ones are live doctests — the latter go through VOCABULARY, which ships. Same rule for README.rst.
Every .. doctest:: block in one .rst file shares a single namespace — the per-document default group — so both local variables and global state carry forward, in document order. Two consequences, and the first is the one that bites. A variable bound in one block clobbers that name in every later block, so inserting a section that binds something common breaks examples further down the file that were passing and that you never touched: writing the #271 usage.rst section with name = parse("김민준") in it made name.initials() six blocks later return '민. 김.' instead of 'J. Q. X. V.'. Pick a distinctive variable name (minjun), or reuse whatever the surrounding blocks already bind. Second, any global state an example changes leaks into every later example in the same build, so reset it in the same block; the 2.0 API has none to change, which is why examples build a Parser of their own. A repr shown in an example must not depend on set iteration order, which varies with per-process string hash randomization.
Don't use the bare python3 -m doctest <file>.rst CLI (no optionflags) to check files under docs/ — it ignores each block's :options: directive (e.g. +NORMALIZE_WHITESPACE, +ELLIPSIS) and reports false-positive whitespace failures that look like real regressions. uv run sphinx-build -b doctest docs <tmpdir> is the faithful check for those. README.rst has no :options: directives (plain :: blocks, not .. doctest::), so the bare python -m doctest README.rst CLI is fine there — that's what CI actually runs.
uv run mypy covers tests/ too (pyproject.toml's [tool.mypy] packages = ["nameparser", "tests"], PR #250) — a test that deliberately passes an off-contract value to assert a TypeError/ValueError (e.g. parse(None) in tests/v2/test_parser.py), needs a # type: ignore[code] comment on that line rather than a signature change. Before reaching for an ignore, check whether the "error" is really a source annotation that hasn't caught up with already-supported runtime behavior — widen the annotation instead in that case.
initials()'s separator is intra-group only — it controls the joiner between consecutive initials within a name group (e.g. two middle names). Spaces between groups come from spec. To fully concatenate initials you need both: parse("John Quincy Xavier Adams").initials(spec="{given}{middle}{family}", separator="") gives 'J.Q.X.A.', where separator="" alone gives 'J. Q.X. A.' (v1 spelled these initials_separator and initials_format).
pr/NNN local branches track upstream PRs — don't commit to them by accident. Check git branch --show-current before starting work.
Title vs suffix is positional for BARE words, and the leading period-abbreviation rule overrides even that — a word matching TITLES at the front of a name becomes title; the same word matching SUFFIX_ACRONYMS/SUFFIX_WORDS at the end becomes suffix (never both, regardless of the word's real-world meaning). The TITLES/suffix overlap was audited in #296 (2026-08-23): the pure postnominals (jr, junior, phd, do, se) left TITLES, the v1-residue dr/sra left the suffix sets, and the ten words in both on 2026-11-21 (ms, sr, lt, vc, the ranks cpl, cpo, cpt, csm, sgm, and since #1128 the Cyrillic д-р; md, sa and ra were duals too until #853 took md's title reading out, a leading Md being the given name Muhammad, #857 took sa out of the vocabulary, and #1483 gave ra a Korean name reading, which makes its title one only inside a title phrase, rules/H9) are deliberate duals that position decides (recount with L = Parser().lexicon._sets; sorted(L.titles & (L.suffix_acronyms | L.suffix_words))). External test sources (old issue gists, etc.) sometimes assert suffix for a leading professional abbreviation like PD/Dipl.-Ing. — that's the source data being wrong, not a parser bug. Verify position before "fixing" it. Two qualifications the older "purely positional" wording papered over, the first measured 2026-08-01 and the second answered 2026-09-08 (#316): a PERIOD-marked leading word is claimed by the shape rule before any vocabulary is read ("Esq. Smith" → title, though esq is suffix-only), save a listed title and, since #789, a given name written short ("Chas. Smith" → given), while a run of single letters, which the shape rule never takes, is a title at the head only by rules/H10's vocabulary ("U.S. Senator John Smith" → title='U.S. Senator'), and a PERIOD-marked trailing word is claimed by VOCABULARY — first the suffix sets, which the peel reads before anything else ("John Smith Esq." → suffix), then the titles ("John Smith Prof." → title='Prof.', rules/H5) — while an unlisted abbreviation there stays a name part ("John Smith Xyz." → family='Xyz.') unless it is written as two or more period-separated chunks, which since 2.4 IS a trailing shape rule (Policy.unlisted_dotted_suffixes, default on: "John Smith X.Y.Z." → suffix='X.Y.Z.', read by the same words-to-spare count a bare ambiguous acronym takes, rules/S3), except paired initials in a script with capitals, which stay a name word ("Ram Bahadur B.K." → family='B.K.', #864). The SINGLE trailing period is still not one, deliberately — it is the abbreviation shape any word can wear. The bare word is where "positional" still holds whole -- outside a part past the second comma, which holds no name word, so C2 reads a bare title word there as a title since #603 (Eric H. Holder, Jr., Attorney General), and outside a listed salutation ending the given part after a family comma, which rules/H8 reads as the title since #835 (Doe, Jane Mrs), the comma having marked the surname's place -- and the reason it must: TITLES holds words that are in no suffix set — 787 of them on 2026-10-11 (746 before #606's salutations), measured with L = Parser().lexicon._sets; len(L.titles - L.suffix_acronyms - L.suffix_words), a figure that grows with the vocabulary and never shrinks the argument — and many are ordinary surnames (pope, bishop, judge, baron, master, ...), so a vocabulary-first rule over BARE trailing words would read "Mary Jane Pope" as title='Pope', family='Jane'. The period is what separates the safe case from that one, and it separates it by being a WRITING convention rather than by making the collision go away: "Mary Jane Pope" keeps family='Pope' while "Mary Jane Pope." reads title='Pope.', family='Jane', a cost accepted under the input-is-a-name premise rather than one the rule prevents (the trailing-position bullet in decisions/vocabulary-exclusions, measured 2026-09-09). Since #316 that sentence describes the shipped rule rather than an aspiration.
Prefer behavior tests over constant-content tests — don't assert on the literal contents/structure of config constants (e.g. SUFFIX_ACRONYMS == SET_A | SET_B, 'x' in SOME_SET). Test observable parsing behavior instead (parse(...) output). Constant-content assertions just create a second place to update whenever the lists change.
A parse-behavior test can still be a disguised constant-content test if it only exercises one or two hardcoded entries from a large list (e.g. guarding a specific missing-comma typo in SUFFIX_ACRONYMS) — it documents that one instance without catching the same bug class elsewhere in the list. Prefer a test on the structural property itself, or skip a dedicated test for narrow, unrepeatable typo fixes.
A guard that decides its own scope can stop guarding without failing. Two shapes hit in #329, both in live code. _POLICY_SHAPES in test_benchmark.py had one entry, and pytest turns an empty parametrize into a skip, not a failure, so deleting it would have dissolved the quadratic guard into the skip count. And the 2.x test_facade_cases.py::_constants_for decided which case rows it could express: its gate had been structurally unsatisfiable since the maiden-wins canonicalization landed, silently skipping seven rows, while an unenumerated Policy field would instead let a row run MISTRANSLATED. Neither could fail, because a skip is indistinguishable from "correctly declined". Assert the table is non-empty, give each shape a reachability probe, and tie any hand-written field enumeration to dataclasses.fields(...) the way test_policy.py's test_policy_patch_mirrors_policy_field_names does. A component that filters its own input needs a test on the filter, not only on what survives it. A filter whose only witnesses are shipped files loses them when the data changes: _reading_index.tags() leaves out a file of familiar readings alone, and #1370's follow-up deleted mt.toml and sq.toml and emptied hu.toml's familiar readings, the last such files, leaving the filter untested until review planted one (test_a_file_holding_only_familiar_readings_is_chosen_only_strictly; #1379 has since given hu.toml a familiar reading again, zsuzsa, so a shipped file is a witness today, which the planted one does not depend on); when a change removes data, ask which guard used it as its example. The same holds for a record split by scope: a check that reads each scope's share of a record never sees an entry that falls in no scope, so test that every entry has one — #672's per-pack CLDR ratchet missed record entries for a file dropped from LOCALE_FILES, and its re-record carried them over as if their pack were merely unmeasured.
Deleting a test module: sort its tests by the code they exercise, not by their names. A module named for a retired tool also holds tests of code that survives it. #664 deleted test_ledger_guards.py and rewrote test_differential.py, triaging both by test name, and review found five tests guarding live code in the discard pile: four of build_issues_corpus.py's harvester, and the check that compare.py reports the entries it skips. For each test, grep its module-level handles (load_tool("..."), imports) and ask whether that code is also being deleted. The converse holds for rewriting tests: a tool that reads test SOURCE by its syntax breaks when the tests change form though no assertion moved. #357 ported the 1.x suite from HumanName(...) to parse(...) and helpers wrapping it, and tools/differential/build_corpus.py, which collected the first argument of HumanName calls, returned 183 of the 566 names it reads now, with no warning, until review ran it; grep tools/ for the call names a port rewrites.
When adding a new aggregate property (like given_names or surnames), always include a test for the empty path — a name that produces no value for that property, which must render ''. Example: parse("Williams") for a given-names property (a family-only string has no given or middle).
python_classes = ["*Tests", "*TestCase"] in pyproject.toml — suffix style (FooTests), NOT prefix (TestFoo); wrong style silently skips discovery.
Tests run under pytest (via uv run pytest) and are split one file per concern (tests/test_titles.py, tests/test_suffixes.py, etc.): the 1.x suite, which asserted through HumanName until 3.0 and now asserts the same readings through parse(). tests/base.py holds ParsedNameTestBase — a plain (non-unittest) base whose m() helper is a custom assert that prints the original name string on failure (plus thin assert* shims kept from the suite's unittest days). TEST_NAMES (in tests/test_variations.py) is a list of name strings permuted into comma-separated variants as a regression check. Tests that should fail use @pytest.mark.xfail. When adding a parsing case, prefer a row in tests/v2/cases.py; a tests/test_*.py test is fine where the case table cannot express it, and consider adding the base form to TEST_NAMES.
Test classes that parse with a dedicated flagged Policy (e.g. middle_as_family=True) subclass FlaggedPolicyTestBase (tests/base.py) and set policy_kwargs = {...} — don't hand-write per-class setup_method/hn() fixture pairs.