# AGENTS.md Mailwoman is a postal-address parser. The unscoped `mailwoman` package provides the CLI and library. The `packages/` directory also contains 88 scoped `@mailwoman/*` packages. The root `workspaces` field expands to 90 workspaces, including `docs`; `readWorkspaceDirectories` in `@mailwoman/core/repo/workspaces` is the authoritative reader. The root package, `@mailwoman/universe`, is private. Sixty-nine workspaces publish to npm. `.release-it.json` defines that set, and the twenty-one others are private. `packages/osm` publishes as code only: its `mailwoman.codeOnly` declaration makes the release audit refuse a tarball that ships a data file. Run the workspace check described in `lib/release-kit/AGENTS.md` after adding or moving a workspace. Every `packages/*` workspace keeps its library under `lib/`, with each test beside the module it covers. A workspace may add up to three more source roots, `sdk/`, `tools/` and `cli/`, described under workspace conventions. `test/` holds fixtures, shared test helpers and Playwright suites. `docs/` keeps Docusaurus source under `src/`. The complete workspace catalog is `docs/engineering/reference/workspaces.mdx`. The non-workspace directories `packages/trainer/` and `packages/hrt/` (cargo crates), `hf-publish/`, `data/`, `evals/`, and `docker/` have their purposes documented in that catalog and their local READMEs. ## Instruction routing Before editing a workspace, read the nearest `AGENTS.md` on that path. Codex loads nested instruction files automatically only when the session starts in their directory, so a session started at the repository root must read the applicable file explicitly. - `packages/core/AGENTS.md` covers HTTP clients, filesystem access, paths, module resolution, shared helpers, and core's Vite import cycle. - `packages/mailwoman/AGENTS.md` covers CLI helpers, parser test helpers, ANSI output assertions, and interactive Ink tests. - `packages/corpus/AGENTS.md` covers OpenAddresses acquisition, source timestamps, CSV structure, and corpus recipe outputs. Each `packages/corpus/lib//AGENTS.md` states that country's legal position on electing address data. - `packages/mailwoman/tools/training/AGENTS.md` covers Modal training launches and the host audits a launch requires. - `lib/release-kit/AGENTS.md` covers publish artifacts, workspace registration, CI releases, and partial-release recovery. - `packages/sqlite/AGENTS.md` covers database construction and the SQL that deliberately remains raw. - `docs/engineering/reference/training-row-encoder.mdx` covers the training loader's Rust encoder in `packages/mtf/crates/mtf-channels`, its sampler in `crates/mtf-sampler`, and the parity records a change to either must verify. Use repository skills for procedures rather than copying their steps into this file: - `training-arc` before launching or grading a training run. - `eval-model` before deciding whether a model may ship. - `mailwoman-release` for every npm publish or model promotion. - `wof-build` for rebuilding WOF SQLite and FST artifacts. - `task-intake` for implementation or training work expected to produce a PR or handoff. - `five-whys` when a failure's cause isn't directly established. ## Read before changing behavior - `docs/records/site-2026-08/concepts/what-mailwoman-is.mdx` explains the calibrated, retrieval-augmented sequence labeler and the grammar/atlas division of labor. - `packages/codex/lib/support/promises.json` declares the support promises: each country and input language and script Mailwoman guarantees, and to what depth. The `support-promises` repository check refuses a promise without a passing gauntlet case. `docs/superpowers/specs/2026-11-14-locale-support-promises-design.md` records the design. - `docs/engineering/SCOPE.mdx` keeps the per-country locale evidence, workstreams, runtime flags, and the live roadmap. `docs/records/plan/` holds the v1 plan, its phase documents and its reference pages as historical records. - `docs/engineering/reference/jurisdiction-coverage.mdx` answers what this repository has for each of 255 jurisdictions, one row each, with corpus rows, admission, gazetteer places and board rows in separate columns. It is generated by `packages/mailwoman/tools/dev-tools/corpus/jurisdiction-coverage.run.ts`; regenerate it rather than answering the question again. - The evaluation coverage register, `docs/engineering/reference/evaluation-coverage.mdx`, records each country's release-requirement status, sampled addresses, independent groups, sources and provenance classes for one versioned held-out dataset. It is generated by `packages/mailwoman/tools/eval-harness/heldout/dataset/coverage/register.run.ts` from a dataset manifest (`freeze.run.ts`) and an overlap audit (`overlap.run.ts`) in the same directory. It currently covers `heldout-confirm-v0.8.22`. - `yarn mwops effects ` answers what a workspace's or a module's code reads, writes, fetches, launches and runs at import. Without an argument it lists the workspaces and prints each state machine's transition table. It reads the tree as it is, and the repository keeps no copy of its output. A pull request's `scope` job writes the effects the change adds and removes to its job summary. - `docs/engineering/CONTRIBUTING_MODEL_WORK.mdx` defines model evaluation requirements and the release-quality procedure: a default-on model or decoder change ships only on a `pass` verdict against the registered release requirements. Those requirements replaced the D-rule on 2026-10-20. The current specification, v13, which `release/current-spec.ts` names, registers model 10.8.0 as the published identity and the v8.9.0 seed 42 artifact as the candidate. Its confirmation read on 2026-11-19 returned `pass` on all 16 checks, the first `pass` verdict. `docs/records/evals/2026-11-19-release-requirements-v13.md` records that read, and `docs/records/evals/2026-11-20-release-requirements-v14.md` the unregistered v14 draft. - `docs/engineering/HOLDOUT_AND_EVALUATION.mdx` is the held-out data and evaluation specification: how rows are split, the checks that admit a corpus manifest, the comparator, the three-run rule for a corpus or recipe change, and the checks a training run passes before launch. Read it before changing the split policy, a holdout table, an evaluation draw, or a training launch. - `docs/engineering/reference/product-license-tokens.mdx` specifies the platform license key, the commercial training grant, the trust register and the model provenance manifest that `@mailwoman/license/product` and the `product-license` crate both implement. Read it before changing a credential, the trainer's license check, or an export's provenance. - `docs/engineering/reference/decoder-grammar.mdx` defines the decoder objective and constraint taxonomy. Read it before changing the decoder, a prior, or phrase cohesion. - `docs/engineering/reference/layer-interface.mdx` defines spatial-layer manifests, coverage, data tiers, and the meaning of zero coverage. - `docs/engineering/reference/poi-layer-runbook.mdx` covers the POI database build and publish path. - `docs/engineering/reference/coverage-overlay.mdx` covers the demo coverage overlay. - `RELEASING.md` and the `mailwoman-release` skill govern releases. - `docs/records/evals/` contains evaluation reports. `evals/scores-by-version.json` is the score ledger. The latest `parity-scorecard-*.md` is the human-readable per-tag table. - `.claude/output-styles/mailwoman-development.md` is the shared communication standard for agents. `config/vale/.vale-chat.ini` enforces its mechanical subset for Codex and Claude Code responses. `docs/engineering/reference/SCHEMA.mdx` is the canonical definition of `ComponentTag`. ## Workspace conventions Node runs TypeScript source directly through type stripping. Relative imports include `.ts`, and each compiling workspace uses `rewriteRelativeImportExtensions: true` and `erasableSyntaxOnly: true`. Use a constant object plus a derived union instead of `enum`. Avoid constructor parameter properties and runtime namespaces. A package owns the declarations it exports. Do not re-export a declaration from another `@mailwoman/*` package or from `mailwoman`. Import the declaration from its owning package. The `mailwoman/no-cross-package-reexport` lint rule enforces this boundary. A test sits in the same directory as the module it covers: `packages/core/lib/decoder/build-tree.ts` is tested by `packages/core/lib/decoder/build-tree.test.ts`. The suffix selects the suite: `.test.ts` runs in the fast suite, `.integration.test.ts` in the slow suite, and `.full.test.ts` in the full-data suite. A test may import its module by relative path, by the package's `#` imports, or by the public export. The `test-layout` repository check reports a test in a directory that holds no module. Knip counts a test's import as a use, so the `test-only-exports` check reports an export that only tests import, and the `debt` counter keeps that count from growing. Mark an export meant for outside users `@public`. A directory's role decides its source root, whether or not shipped code imports it. `lib/` holds only the library. `sdk/` holds data acquisition: fetching, downloading and extracting source data. `tools/` holds build, evaluation and maintenance code. `cli/` holds a command-line program, entered at `cli/main.ts`. Library code never imports the other three roots. The `no-library-to-role-directory` dependency rule enforces this, and the `no-serve-package-to-build-tooling` rule keeps request-path packages away from every workspace's `sdk/` and `tools/`. The tooling workspaces listed in `TOOLING_PACKAGES` in `dependency-cruiser.config.mjs` keep their tooling under `lib/`. Each compiling workspace sets `rootDir` to `./lib`; TypeScript therefore emits `lib/x.ts` as `out/x.js`. Each extra root is its own project reference with a `tsconfig.json` that emits `/x.ts` as `out//x.js` and references `..`. Project references are acyclic, so the compiler also refuses a library import of an extra root. Every build `tsconfig.json` excludes `**/*.test.ts`, and every published `files` list negates it, so a colocated test reaches neither `out/` nor a tarball. Test configurations widen `rootDir` because shared helpers under `test/` sit outside `lib/`. The ten `neural-weights-*` data packages and `sentencepiece-wasm` compile no TypeScript. Every workspace except `@mailwoman/core` exports `.`, `./package.json`, `./env` when it has one, and one `./*` pattern per source root: `./*` maps to `{types: ./out/*.d.ts, node: ./lib/*.ts, default: ./out/*.js}`, and `./sdk/*`, `./tools/*` and `./cli/*` map the same way under their root. The `imports` map mirrors it with `#*` and `#/*`. A directory module is a sibling file, `.ts`, rather than `/index.ts`; the one index file is a package's root entry. The `workspace-exports`, `workspace-files` and `nested-index` repository checks enforce these shapes, and each has a fix. Move modules with `mwops health move`, which proves every rewritten specifier by TypeScript resolution before writing. A package's `lib/` root holds its entry file `index.ts`, its `env.ts` and `paths.ts` where the workspace convention requires those subpaths, and the sibling file of each directory. Every other module lives in a directory whose title states its role: the artifact it reads, as `candidate/` does, or the step it performs, as `ranking/` does. A new module goes into the directory of its role, and a role with no directory yet gets one. A directory holds one role. When its description would need "and", it is two directories. A hyphen inside a known name stays in the directory's title: a component tag such as `house-number/` or `street-prefix/`, and a name such as `sub-venue/`. The `prefix-directories` check holds those names in one set and reads each as one segment, so it never asks for `sub/venue/`, and `house-number-forms.ts` still belongs under `house-number/`. Use the established shared implementation before adding a local helper. `mailwoman/prefer-home` and the `private-name-shadows-export` repository check report repeated implementation shapes and private names that collide with exports. Before moving code into a shared package, count the runtime dependencies and shipped bytes the move adds to each importing package; `nuts-lookup`, `timezone-lookup`, and the GBT test retain documented local implementations to avoid large dependency graphs. That count covers runtime imports. A declaration several packages need has one home and is imported with `import type`, which adds no runtime dependency. The `duplicate-exported-shape` repository check reports an exported interface or type alias whose body another workspace also exports. When two platforms must agree on behavior, share the function rather than copying its constants. Search for the concept rather than a name already chosen: `mwdev_symbol` with `describes` matches a sentence against every exported declaration's docstring, and with `query` returns the declaration site, signature and export status in one call. Fall back to LSP `workspaceSymbol` anchored on the file being edited and on the package where such a helper would live, then to a repository-wide grep for the type or artifact rather than the verb. A `@see {@linkcode name}` tag that doesn't resolve means route reads to the existing helper. At the end of a sprint whose lanes ran as separate subagents, triage the sprint's commits for re-typed helpers below jscpd's 80-token floor. A rule about one country lives in per-country data or under a per-country directory, never as a hard-coded branch in a shared module. The codex holds per-country tables, and an adapter or recipe for one country sits under `packages//lib//`. A shared module that must branch on a country writes `// country-branch: ` on the line above, stating why the rule is one country's and which planetary source would replace it. The `country-branches` repository check reports every other comparison against a country literal. Before writing a branch for US, GB or another well-covered locale, look for the source that covers every country: Who's On First admin names and abbreviations, the Overture places file, the codex country tables. A finding about a few countries is a hypothesis about a global distribution. Before adding a row to a per-country table such as `COUNTRY_PLACETYPE_OVERRIDES` in `packages/codex/lib/labels/placetype-map.ts`, compute the same statistic for every country and print the distribution. When the countries that looked anomalous sit inside a populated mode, the rule is wrong rather than the countries. A census drawn from where the data is densest encodes that region's structure as the norm. A collection of countries is a `CountrySet` from `@mailwoman/codex/country/sets`, built by a constructor that reads one source table: `worldCountries()`, `countriesOfScript()`, `countriesOfAddressSystem()`, `countriesOfWeightsFamily()`, `dependentTerritories()`, or `countriesDeclaredBy()` for a list a config declares. A signature states the set it needs. The `country-literal-sets` repository check reports a hand-typed list of codes held by a binding such as `CJK_COUNTRIES`, and a cast to `CountrySet`. A list that records a per-country fact keeps a `country-branch:` reason. `docs/engineering/reference/country-sets.mdx` describes the module. The acronym convention capitalizes each acronym as a complete camel-case component: `createWOFResolver`, `parseJSON`, `readID`, and `modelURL`. Preserve external names, snake-case wire fields, and documented CLI adapter keys. `sister-software/no-title-case-acronym` enforces the convention. A `*.run.ts` tool or a `tools/` script parses its flags with `parseArgs` from `node:util`, declaring each switch as a `{ type: "boolean" }` option. A tri-state pin takes `--x` and `--no-x`. A `cli/` command declares its options in the `CommandSpec` its module exports (`packages/mailwoman/cli/native/spec.ts`). The `restrictProcessGlobals` lint rule refuses a scan of `process.argv`. Test for the presence of what the code needs, such as `typeof id === "number"` or `x != null`, rather than `!== undefined`, which encodes how a value happens to be absent and fails silently when `null` enters the channel. Apply the rule to the code being touched rather than as a sweep over existing sites. Run `yarn lint` for lint, formatting, prose, dependency, and repository-health checks. Run `yarn typecheck` for build and test type checking. Run the narrow package tests during iteration and the affected workspace's complete tests before handoff. Do not claim a command passed unless it ran. When reporting lint results, state the command's exit status and distinguish errors from warnings. A zero exit status doesn't mean the run had zero warnings. Read the per-file findings for changed files before saying they're clear. If output was truncated, inspect the saved log for those paths. Run `yarn compile` before `yarn lint`: two `#` imports in `packages/mailwoman` map the `node` condition to `out/`, so knip and the bundle-graph check fail on an uncompiled tree. Run `mwops release copy-weights` after `yarn compile`, or the FST, postcode and pair-index files are left out. A pipeline's exit status is its last command's, so `audit | grep … && launch` launches on a failed audit and `tsc | tail` reports green on nine errors. Run only a command whose exit code decides the next step. Run a repository check with `mwops check `: it exits with the check's status, writes the output to a log outside the checkout, and prints the counts, failing tests and log path, or with `--json` the whole result. A heavy check waits for the host lock and for CI within `--max-wait-minutes`. `mwops host status` names what holds the host, and `mwops check preflight` runs the direct-push set below. `yarn health` runs the whole check registry through `health:checks`, which calls `mwops health all`, beside the dependency, manifest and duplication checks. A check runs once `lib/repo-health/registry.ts` registers it. `mwops health all --except ` leaves a check out while a decision recorded in its issue is open, and `health:checks` passes zero ids today. The tests under `lib/repo-health`, which `mwops check health-tree` runs, cover each check's own logic. ## Functions, classes and construction Most of this repository is exported functions over typed data. The rules below say when another form applies and how a long-lived object comes into being. 1. Write a plain exported function over typed data unless rule 2 or rule 3 applies. 2. Write a class when its instances own a resource handle or mutable state with a lifetime. The class keeps state in `#` fields and declares `Symbol.dispose` or `Symbol.asyncDispose`. An error type is a class. 3. When an interface has several stateless implementations, each is a `create*` function that returns an object typed as the interface. A class may sit behind such a function when callers need only the interface. 4. A class that opens something asynchronously has a private constructor and one `static async create`. A public constructor never returns an instance that needs a second call before use. 5. A class extends `Error`, a platform class, or a base that owns a resource, such as `SQLiteLookup` or `APIClient`. Reuse code by composing objects, and keep inheritance for those three cases. 6. A library module keeps zero handle in mutable module-level state. A handle belongs to a registry service or to an object the caller owns. A module-level cache of a pure computation states its reason on the line above. 7. A resource that more than one consumer of an engine reads is defined on the service registry with its `needs`. A value computed asynchronously from another service and read by several services is defined the same way, so it is computed once per scope. A plain setting is an option and takes zero token. A request-scoped object is built by a function. A definition omits `release` when its instance is itself disposable, because `async-init` disposes such an instance. 8. A role has one interface, declared in the package that owns the role. A `*Like` type is for a foreign shape the package can't import. 9. A long-running function reports progress through an `onX` callback option. When several listeners need the same notification, the object exposes `subscribe(listener)` and returns a disposable. A class name's suffix states its role. A `*Client` extends `APIClient`, a `*Provider` implements an interface whose name ends in `Provider`, and a `*Resolver` implements `Resolver`. A class that reads one database or binary artifact by key is a `*Lookup`. The `role-suffixes` repository check reads each exported class's `extends` and `implements` clauses and reports a suffix whose role they don't declare. Four practices from larger class-based codebases stay out: decorator injection, a shared `Disposable` base class, an `I` prefix on interfaces, and the `private` keyword in place of `#`. `erasableSyntaxOnly` rejects a decorator. ## Role words Each word below has one sense in a new name, a directory title and prose. A census on 2026-11-23 found 19 of these words in several senses each across exported declarations. An existing name in another sense keeps its spelling until a change renames it, and a wire identifier or an external name keeps it for good. - **service**: an object the service registry builds once per scope from a definition with `needs`. A remote endpoint is "a web service" or its own title, such as the Census geocoder. - **registry**: the service registry. A keyed in-memory table is "a table", and a government's list of records is "a register". - **provider**: an interchangeable implementation of an interface whose title ends in `Provider`. A broadband company is a provider in the BDC data's own vocabulary, and those field names stay as published. - **resolver**: an implementation of `Resolver`, which maps a parsed tree to places. A reader of one database or binary artifact by key is a **lookup**. - **client**: a class that extends `APIClient`, `DatabaseClient` or `GitClient`. The browser side of an application is "the page". - **adapter**: a corpus adapter. It reads one publication into rows. - **stage**: an object `{ id, run }` that `runStage` in `@mailwoman/core/pipeline` runs. The **request context** is what every stage of one request reads: the abort signal, the trace sink, the timing and the faults. - **pipeline**: the stages of one request, in order. A build that produces database files is "a build". - **session**: a `GeocodeSession`, built by `createGeocodeSession`. - **engine**: what a caller runs to parse or geocode, built by the modules under `packages/mailwoman/lib/engine/`. - **layer**: a spatial data layer with a manifest. A map's drawing layer is "a tile layer". - **source**: the publication a row or a file came from. A map's tile endpoint is "a tile source". - **scope**: a geographic restriction on a geocode, such as the country scope. A child of the service registry is "a child registry", and the files a pull request changes are "the change". - **recipe**: a corpus recipe. **overlay** is always written with its kind: "the corpus overlay" or "the weights overlay". - **artifact**: a built file with an identity. A **manifest** records an artifact's identity and inputs. - **label**: a `ComponentTag`. A module whose subject is one label sits under `labels/