@mailwoman/resolver 9.1.0 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +89 -0
  2. package/lib/admin/coherence-passes.ts +435 -0
  3. package/lib/admin/containment.ts +92 -0
  4. package/lib/admin/index.ts +10 -0
  5. package/lib/admin/jp-municipality.ts +97 -0
  6. package/lib/admin/winner.ts +189 -0
  7. package/lib/backend-capabilities.ts +88 -0
  8. package/lib/bare-toponym-race.ts +129 -0
  9. package/lib/decorate-node.ts +127 -0
  10. package/lib/fold-name.ts +36 -0
  11. package/{index.ts → lib/index.ts} +27 -18
  12. package/{plausibility.ts → lib/plausibility.ts} +5 -4
  13. package/{postcode-country-coherence.ts → lib/postcode/country-coherence.ts} +173 -86
  14. package/lib/postcode/index.ts +9 -0
  15. package/{postcode-prefix.ts → lib/postcode/prefix.ts} +7 -6
  16. package/{postcode-shape-coherence.ts → lib/postcode/shape-coherence.ts} +10 -24
  17. package/{remote-resolver.ts → lib/remote-resolver.ts} +13 -4
  18. package/{rerank.ts → lib/rerank.ts} +2 -2
  19. package/lib/resolve/index.ts +982 -0
  20. package/lib/resolve/passes.ts +544 -0
  21. package/{span-rescore.ts → lib/span-rescore.ts} +114 -99
  22. package/{street-evidence.ts → lib/street/evidence.ts} +40 -7
  23. package/lib/street/index.ts +8 -0
  24. package/{street-tier.ts → lib/street/tier.ts} +138 -99
  25. package/{toponym-prior.ts → lib/toponym-prior.ts} +97 -8
  26. package/out/admin/coherence-passes.d.ts +70 -0
  27. package/out/admin/coherence-passes.d.ts.map +1 -0
  28. package/out/admin/coherence-passes.js +327 -0
  29. package/out/admin/coherence-passes.js.map +1 -0
  30. package/out/admin/containment.d.ts +48 -0
  31. package/out/admin/containment.d.ts.map +1 -0
  32. package/out/admin/containment.js +76 -0
  33. package/out/admin/containment.js.map +1 -0
  34. package/out/admin/index.d.ts +10 -0
  35. package/out/admin/index.d.ts.map +1 -0
  36. package/out/admin/index.js +10 -0
  37. package/out/admin/index.js.map +1 -0
  38. package/out/admin/jp-municipality.d.ts +50 -0
  39. package/out/admin/jp-municipality.d.ts.map +1 -0
  40. package/out/admin/jp-municipality.js +54 -0
  41. package/out/admin/jp-municipality.js.map +1 -0
  42. package/out/admin/winner.d.ts +114 -0
  43. package/out/admin/winner.d.ts.map +1 -0
  44. package/out/admin/winner.js +130 -0
  45. package/out/admin/winner.js.map +1 -0
  46. package/out/backend-capabilities.d.ts +37 -0
  47. package/out/backend-capabilities.d.ts.map +1 -0
  48. package/out/backend-capabilities.js +75 -0
  49. package/out/backend-capabilities.js.map +1 -0
  50. package/out/bare-toponym-race.d.ts +55 -0
  51. package/out/bare-toponym-race.d.ts.map +1 -0
  52. package/out/bare-toponym-race.js +110 -0
  53. package/out/bare-toponym-race.js.map +1 -0
  54. package/out/decorate-node.d.ts +24 -0
  55. package/out/decorate-node.d.ts.map +1 -0
  56. package/out/decorate-node.js +103 -0
  57. package/out/decorate-node.js.map +1 -0
  58. package/out/fold-name.d.ts +18 -3
  59. package/out/fold-name.d.ts.map +1 -1
  60. package/out/fold-name.js +19 -3
  61. package/out/fold-name.js.map +1 -1
  62. package/out/index.d.ts +15 -12
  63. package/out/index.d.ts.map +1 -1
  64. package/out/index.js +9 -7
  65. package/out/index.js.map +1 -1
  66. package/out/plausibility.d.ts +5 -4
  67. package/out/plausibility.d.ts.map +1 -1
  68. package/out/plausibility.js +5 -4
  69. package/out/plausibility.js.map +1 -1
  70. package/out/{postcode-country-coherence.d.ts → postcode/country-coherence.d.ts} +46 -25
  71. package/out/postcode/country-coherence.d.ts.map +1 -0
  72. package/out/{postcode-country-coherence.js → postcode/country-coherence.js} +157 -77
  73. package/out/postcode/country-coherence.js.map +1 -0
  74. package/out/postcode/index.d.ts +9 -0
  75. package/out/postcode/index.d.ts.map +1 -0
  76. package/out/postcode/index.js +9 -0
  77. package/out/postcode/index.js.map +1 -0
  78. package/out/{postcode-prefix.d.ts → postcode/prefix.d.ts} +4 -4
  79. package/out/postcode/prefix.d.ts.map +1 -0
  80. package/out/{postcode-prefix.js → postcode/prefix.js} +7 -6
  81. package/out/postcode/prefix.js.map +1 -0
  82. package/out/{postcode-shape-coherence.d.ts → postcode/shape-coherence.d.ts} +3 -3
  83. package/out/postcode/shape-coherence.d.ts.map +1 -0
  84. package/out/{postcode-shape-coherence.js → postcode/shape-coherence.js} +11 -20
  85. package/out/postcode/shape-coherence.js.map +1 -0
  86. package/out/remote-resolver.d.ts +18 -3
  87. package/out/remote-resolver.d.ts.map +1 -1
  88. package/out/remote-resolver.js +2 -2
  89. package/out/remote-resolver.js.map +1 -1
  90. package/out/rerank.d.ts +1 -1
  91. package/out/rerank.d.ts.map +1 -1
  92. package/out/rerank.js +2 -2
  93. package/out/rerank.js.map +1 -1
  94. package/out/{resolve.d.ts → resolve/index.d.ts} +2 -2
  95. package/out/resolve/index.d.ts.map +1 -0
  96. package/out/resolve/index.js +795 -0
  97. package/out/resolve/index.js.map +1 -0
  98. package/out/resolve/passes.d.ts +218 -0
  99. package/out/resolve/passes.d.ts.map +1 -0
  100. package/out/resolve/passes.js +333 -0
  101. package/out/resolve/passes.js.map +1 -0
  102. package/out/span-rescore.d.ts +16 -16
  103. package/out/span-rescore.d.ts.map +1 -1
  104. package/out/span-rescore.js +87 -71
  105. package/out/span-rescore.js.map +1 -1
  106. package/out/{street-evidence.d.ts → street/evidence.d.ts} +18 -3
  107. package/out/street/evidence.d.ts.map +1 -0
  108. package/out/{street-evidence.js → street/evidence.js} +23 -7
  109. package/out/street/evidence.js.map +1 -0
  110. package/out/street/index.d.ts +8 -0
  111. package/out/street/index.d.ts.map +1 -0
  112. package/out/street/index.js +8 -0
  113. package/out/street/index.js.map +1 -0
  114. package/out/{street-tier.d.ts → street/tier.d.ts} +14 -3
  115. package/out/street/tier.d.ts.map +1 -0
  116. package/out/{street-tier.js → street/tier.js} +127 -90
  117. package/out/street/tier.js.map +1 -0
  118. package/out/toponym-prior.d.ts +43 -19
  119. package/out/toponym-prior.d.ts.map +1 -1
  120. package/out/toponym-prior.js +76 -8
  121. package/out/toponym-prior.js.map +1 -1
  122. package/package.json +167 -19
  123. package/vitest.config.ts +5 -6
  124. package/fold-name.ts +0 -20
  125. package/out/postcode-country-coherence.d.ts.map +0 -1
  126. package/out/postcode-country-coherence.js.map +0 -1
  127. package/out/postcode-prefix.d.ts.map +0 -1
  128. package/out/postcode-prefix.js.map +0 -1
  129. package/out/postcode-shape-coherence.d.ts.map +0 -1
  130. package/out/postcode-shape-coherence.js.map +0 -1
  131. package/out/resolve.d.ts.map +0 -1
  132. package/out/resolve.js +0 -1049
  133. package/out/resolve.js.map +0 -1
  134. package/out/street-evidence.d.ts.map +0 -1
  135. package/out/street-evidence.js.map +0 -1
  136. package/out/street-tier.d.ts.map +0 -1
  137. package/out/street-tier.js.map +0 -1
  138. package/out/vitest.config.d.ts +0 -16
  139. package/out/vitest.config.d.ts.map +0 -1
  140. package/out/vitest.config.js +0 -36
  141. package/out/vitest.config.js.map +0 -1
  142. package/resolve.ts +0 -1369
@@ -20,11 +20,11 @@
20
20
  * (`scripts/eval/span-rescore-validate.ts`, eval
21
21
  * `docs/articles/evals/experiments/2026-06-23-370-span-rescore.mdx`): longest-exact-match-wins (the gold
22
22
  * locality is usually the LONGER, more-specific name — shortest- wins grabs the ambiguous prefix
23
- * "Tomaszów" of "Tomaszów Mazowiecki", 135 km off), and a postcode- consistency gate that rejects
23
+ * "Tomaszów" of "Tomaszów Mazowiecki", 135 km off), and a postcode- consistency check that rejects
24
24
  * a match far from where the postcode resolves (kills coverage-gap false-positives where the
25
25
  * backend has postcode coverage).
26
26
  */
27
- import type { AddressNode } from "@mailwoman/core/decoder";
27
+ import { type AddressNode } from "@mailwoman/core/decoder";
28
28
  import type { ResolvedPlace, ResolverBackend } from "@mailwoman/core/resolver";
29
29
  export interface SpanRescoreOptions {
30
30
  /**
@@ -32,15 +32,15 @@ export interface SpanRescoreOptions {
32
32
  */
33
33
  country?: string;
34
34
  /**
35
- * Sibling postcode — used both as the backend disambiguation hint AND the consistency-gate anchor.
35
+ * Sibling postcode — used both as the backend disambiguation hint AND the consistency-check anchor.
36
36
  */
37
37
  postcode?: string;
38
38
  /**
39
- * Reject a candidate whose coordinate is farther than this (km) from the postcode anchor. The gate only fires when
39
+ * Reject a candidate whose coordinate is farther than this (km) from the postcode anchor. The check only fires when
40
40
  * the postcode resolves to a point in the backend; otherwise it can't and the match is accepted (so it never
41
41
  * penalizes a backend without postcode coverage). 0 disables. Default 50.
42
42
  */
43
- gateKm?: number;
43
+ thresholdKm?: number;
44
44
  /**
45
45
  * Max contiguous raw tokens to treat as one locality span. Default 4.
46
46
  */
@@ -87,18 +87,18 @@ export interface RescoreCandidate {
87
87
  */
88
88
  place: ResolvedPlace;
89
89
  /**
90
- * Whether the postcode-consistency gate FIRED for this recovery — i.e. the postcode resolved to a point and the match
91
- * was validated within `gateKm` of it. `true` = high-precision (postcode- consistent); `false` = ungated (no
92
- * postcode→point coverage for this country, so the match wasn't geo-validated — the ~83%-precision case). The caller
93
- * surfaces this as `metadata.rescore_gated` so a consumer can threshold on it WITHOUT a hidden per-country coverage
94
- * map. Deliberately NOT folded into the calibrated `confidence` — that would break the isotonic guarantee (a true
95
- * calibrated 0.83 must not be confused with a rescore plug-in estimate).
90
+ * Whether the postcode-consistency check FIRED for this recovery — i.e. the postcode resolved to a point and the
91
+ * match was validated within `thresholdKm` of it. `true` = high-precision (postcode- consistent); `false` =
92
+ * unrestricted (no postcode→point coverage for this country, so the match wasn't geo-validated — the ~83%-precision
93
+ * case). The caller surfaces this as `metadata.rescore_postcode_verified` so a consumer can threshold on it WITHOUT a
94
+ * hidden per-country coverage map. Deliberately NOT folded into the calibrated `confidence` — that would break the
95
+ * isotonic guarantee (a true calibrated 0.83 must not be confused with a rescore plug-in estimate).
96
96
  */
97
- gated: boolean;
97
+ postcodeVerified: boolean;
98
98
  /**
99
99
  * The SAME-SPAN namesake runner-ups — the other exact-name matches this recovery's own lookup already returned, in
100
- * the backend's rank order, minus the winner and minus anything the postcode gate rejected. Empty when the span named
101
- * exactly one place.
100
+ * the backend's rank order, minus the winner and minus anything the postcode check rejected. Empty when the span
101
+ * named exactly one place.
102
102
  *
103
103
  * #1537: these were being discarded. A name the model reads as a `street` ("Springfield", "Berlin", "Manchester",
104
104
  * "Moscow", "Fulda") never reaches the admin walk, so the whole tree comes back unresolved and THIS tier is what
@@ -108,7 +108,7 @@ export interface RescoreCandidate {
108
108
  * backend, 2026-08-07: those five queries returned 1 candidate each while `Cambridge`/`Athens`/`Paris` — the same
109
109
  * class, but parsed as `locality` — returned 4-5.
110
110
  *
111
- * The winner is unchanged by their presence: the pick is still the first gate-passing exact match, and these are the
111
+ * The winner is unchanged by their presence: the pick is still the first check-passing exact match, and these are the
112
112
  * ones that came after it. This costs no extra query — they were in the same `findPlace` response.
113
113
  */
114
114
  alternatives: ResolvedPlace[];
@@ -125,7 +125,7 @@ export declare function postcodeCodeSubset(postcode: string): string;
125
125
  export declare function hasResolvedPlace(roots: readonly AddressNode[]): boolean;
126
126
  /**
127
127
  * Find the best locality the raw text exact-matches in the gazetteer. Returns null when nothing matches (or the
128
- * postcode gate rejects every match). Callers gate on `hasResolvedPlace` first.
128
+ * postcode check rejects every match). Callers test `hasResolvedPlace` first.
129
129
  */
130
130
  export declare function findRescoreCandidate(raw: string, roots: readonly AddressNode[], backend: ResolverBackend, opts?: SpanRescoreOptions): Promise<RescoreCandidate | null>;
131
131
  //# sourceMappingURL=span-rescore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"span-rescore.d.ts","sourceRoot":"","sources":["../span-rescore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAK9E,MAAM,WAAW,kB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AI,CAAC,CAwNlC"}
@@ -20,21 +20,14 @@
20
20
  * (`scripts/eval/span-rescore-validate.ts`, eval
21
21
  * `docs/articles/evals/experiments/2026-06-23-370-span-rescore.mdx`): longest-exact-match-wins (the gold
22
22
  * locality is usually the LONGER, more-specific name — shortest- wins grabs the ambiguous prefix
23
- * "Tomaszów" of "Tomaszów Mazowiecki", 135 km off), and a postcode- consistency gate that rejects
23
+ * "Tomaszów" of "Tomaszów Mazowiecki", 135 km off), and a postcode- consistency check that rejects
24
24
  * a match far from where the postcode resolves (kills coverage-gap false-positives where the
25
25
  * backend has postcode coverage).
26
26
  */
27
+ import { firstNodeWhere, walkNodes } from "@mailwoman/core/decoder";
27
28
  import { haversineKm } from "@mailwoman/spatial";
28
- import { DEFAULT_COUNTRY_PRIOR_WEIGHT, rankByCountryPrior, rankByImportance } from "./toponym-prior.js";
29
- /**
30
- * Normalize for exact comparison: lowercase, strip diacritics + punctuation, collapse whitespace.
31
- */
32
- const norm = (s) => s
33
- .toLowerCase()
34
- .normalize("NFD")
35
- .replaceAll(/[^a-z0-9 ]/g, " ")
36
- .replaceAll(/\s+/g, " ")
37
- .trim();
29
+ import { foldName } from "#fold-name";
30
+ import { DEFAULT_COUNTRY_PRIOR_WEIGHT, rankByCountryPrior, rankByImportance } from "#toponym-prior";
38
31
  /**
39
32
  * Whitespace/punctuation tokenization of the raw input, char offsets preserved, diacritics intact.
40
33
  */
@@ -72,37 +65,18 @@ const BARE_TOPONYM_FETCH = 20;
72
65
  * the hard filter keeps its say: this is what holds 'Berlin, Wisconsin' on Berlin, Wisconsin.
73
66
  */
74
67
  function hasAdminQualifier(roots) {
75
- const stack = [...roots];
76
- while (stack.length) {
77
- const n = stack.pop();
78
- if ((n.tag === "region" ||
79
- n.tag === "subregion" ||
80
- n.tag === "country" ||
81
- n.tag === "postcode" ||
82
- n.tag === "house_number") &&
83
- n.value.trim().length) {
84
- return true;
85
- }
86
- if (n.children?.length) {
87
- stack.push(...n.children);
88
- }
89
- }
90
- return false;
68
+ return (firstNodeWhere(roots, (n) => (n.tag === "region" ||
69
+ n.tag === "subregion" ||
70
+ n.tag === "country" ||
71
+ n.tag === "postcode" ||
72
+ n.tag === "house_number") &&
73
+ n.value.trim().length > 0) !== undefined);
91
74
  }
92
75
  /**
93
76
  * True if any node in the tree already carries a resolved place id — the #685 brake.
94
77
  */
95
78
  export function hasResolvedPlace(roots) {
96
- const stack = [...roots];
97
- while (stack.length) {
98
- const n = stack.pop();
99
- if (n.placeID)
100
- return true;
101
- if (n.children?.length) {
102
- stack.push(...n.children);
103
- }
104
- }
105
- return false;
79
+ return firstNodeWhere(roots, (n) => Boolean(n.placeID)) !== undefined;
106
80
  }
107
81
  /**
108
82
  * Char ranges of confident street / house_number / postcode constituents, including the street affixes (`street_prefix`
@@ -110,11 +84,34 @@ export function hasResolvedPlace(roots) {
110
84
  * NY" is a street suffix, not a locality, and without this guard the recovery exact-matches it against a same-named
111
85
  * place ("Ave", France) and injects a bogus locality.
112
86
  */
87
+ /**
88
+ * Ranges of MULTI-TOKEN `country` / `region` spans, used to block their INTERIOR tokens from being re-read as
89
+ * standalone places. The whole span itself stays probeable — only proper sub-spans are refused.
90
+ *
91
+ * The parse grouping is the claim: when the model binds `Papua`, `New` and `Guinea` into one country span, `New` is a
92
+ * modifier inside a name, not a name. Probing it anyway matches a real US place (`New`, wof:1276997945) and pins the
93
+ * address to Kentucky — an answer strictly worse than none, because it is confident and wrong.
94
+ *
95
+ * Deliberately NOT confidence-conditioned, unlike {@link confidentRanges}. The country node in that case carries 0.68,
96
+ * under the 0.7 bar, and a low-confidence GROUPING is still a grouping: the tokens were read as one name either way,
97
+ * and the interior of a name the parse doubts is not thereby a better standalone candidate. Single-token spans are
98
+ * excluded — there is no interior to protect.
99
+ */
100
+ function multiTokenNameInteriors(roots, raw) {
101
+ const out = [];
102
+ for (const n of walkNodes(roots)) {
103
+ if ((n.tag === "country" || n.tag === "region") &&
104
+ Number.isFinite(n.start) &&
105
+ Number.isFinite(n.end) &&
106
+ tokenizeRaw(raw.slice(n.start, n.end)).length > 1) {
107
+ out.push([n.start, n.end]);
108
+ }
109
+ }
110
+ return out;
111
+ }
113
112
  function confidentRanges(roots, threshold, raw, postalCompoundRecovery) {
114
113
  const out = [];
115
- const stack = [...roots];
116
- while (stack.length) {
117
- const n = stack.pop();
114
+ for (const n of walkNodes(roots)) {
118
115
  if ((n.tag === "postcode" ||
119
116
  n.tag === "house_number" ||
120
117
  n.tag === "street" ||
@@ -137,37 +134,34 @@ function confidentRanges(roots, threshold, raw, postalCompoundRecovery) {
137
134
  out.push([n.start, n.end]);
138
135
  }
139
136
  }
140
- if (n.children?.length) {
141
- stack.push(...n.children);
142
- }
143
137
  }
144
138
  return out;
145
139
  }
146
140
  /**
147
141
  * Find the best locality the raw text exact-matches in the gazetteer. Returns null when nothing matches (or the
148
- * postcode gate rejects every match). Callers gate on `hasResolvedPlace` first.
142
+ * postcode check rejects every match). Callers test `hasResolvedPlace` first.
149
143
  */
150
144
  export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
151
- const gateKm = opts.gateKm ?? 50;
145
+ const thresholdKm = opts.thresholdKm ?? 50;
152
146
  const maxSpan = opts.maxSpanTokens ?? 4;
153
147
  const threshold = opts.confidentThreshold ?? 0.7;
154
148
  const country = opts.country;
155
149
  const postcode = opts.postcode?.trim() || undefined;
156
150
  // Postcode-consistency anchor: where does the postcode itself resolve? (No-op when the backend has
157
- // no postcode coverage — findPlace returns nothing → no anchor → gate can't fire → match accepted.)
151
+ // no postcode coverage — findPlace returns nothing → no anchor → check can't fire → match accepted.)
158
152
  let anchor = null;
159
- if (postcode && gateKm > 0) {
153
+ if (postcode && thresholdKm > 0) {
160
154
  // #961: both anchor probes are postalcode-TYPED. Untyped, a truncated code fragment (v5.3.0
161
155
  // emits "250 Zabiče" → subset "250") name-matches arbitrary places ("Chak No 250", PK) and the
162
- // false anchor then GATES OUT the true village. A typed miss leaves anchor=null → the match is
163
- // accepted ungated, which is the correct degradation for an unverifiable code.
156
+ // false anchor then EXCLUDES the true village. A typed miss leaves anchor=null → the match is
157
+ // accepted unrestricted, which is the correct degradation for an unverifiable code.
164
158
  const pcHits = await backend.findPlace({ text: postcode, country, placetype: "postalcode", limit: 2 });
165
159
  const a = pcHits.find((h) => h.lat !== 0 || h.lon !== 0);
166
160
  if (a) {
167
161
  anchor = { lat: a.lat, lon: a.lon };
168
162
  }
169
163
  // #942: the globbed compound ("1382 Kožljek") matches no bare-code row — retry the anchor with
170
- // the code-shaped token subset so the consistency gate can validate the recovered city.
164
+ // the code-shaped token subset so the consistency check can validate the recovered city.
171
165
  if (!anchor && opts.postalCompoundRecovery) {
172
166
  const code = postcodeCodeSubset(postcode);
173
167
  if (code && code !== postcode) {
@@ -182,6 +176,9 @@ export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
182
176
  const toks = tokenizeRaw(raw);
183
177
  const avoid = confidentRanges(roots, threshold, raw, opts.postalCompoundRecovery ?? false);
184
178
  const overlapsAvoid = (s, e) => avoid.some(([as, ae]) => s < ae && as < e);
179
+ // Proper sub-spans of a multi-token country/region name are refused; the whole span is not.
180
+ const nameInteriors = multiTokenNameInteriors(roots, raw);
181
+ const isNameInterior = (s, e) => nameInteriors.some(([ns, ne]) => s >= ns && e <= ne && !(s === ns && e === ne));
185
182
  const spans = [];
186
183
  for (let len = Math.min(maxSpan, toks.length); len >= 1; len--) {
187
184
  for (let i = 0; i + len <= toks.length; i++) {
@@ -189,6 +186,8 @@ export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
189
186
  const end = toks[i + len - 1].end;
190
187
  if (overlapsAvoid(start, end))
191
188
  continue;
189
+ if (isNameInterior(start, end))
190
+ continue;
192
191
  spans.push({ text: raw.slice(start, end), start, end, len });
193
192
  }
194
193
  }
@@ -201,12 +200,12 @@ export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
201
200
  //
202
201
  // So for this ONE query shape the filter is demoted to an additive prior: probe the gazetteer
203
202
  // unscoped, then rank with `rankByCountryPrior` so an in-country place may be up to 100x smaller and
204
- // still win. This is the #912 lever ("Paris under en-US must not be hard-scoped to Paris, Texas")
203
+ // still win. This is the #912 change ("Paris under en-US must not be hard-scoped to Paris, Texas")
205
204
  // applied at the tier that actually decides the class — #912 lives upstream in the CLI and keys on a
206
205
  // `locality`-tagged tree, but the model reads a bare famous name as a `street`, so the shape that
207
206
  // needs it most is exactly the shape that guard cannot see.
208
207
  //
209
- // The shape gate is deliberately narrow. `qualified` below is the D-rule guard: a postcode, a region,
208
+ // The shape check is deliberately narrow. `qualified` below is the D-rule guard: a postcode, a region,
210
209
  // a country or a house number in the tree means the address named its own context and a locale guess
211
210
  // is no longer the only evidence — 'Berlin, Wisconsin' keeps resolving to Berlin, Wisconsin. And the
212
211
  // span must cover the WHOLE input: a sub-span of a longer query is not a bare toponym, so
@@ -218,20 +217,37 @@ export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
218
217
  // Everything the prior needs EXCEPT the span itself — hoisted so the per-span test is one comparison.
219
218
  const softCountryEligible = softCountry && !!country && !qualified && !!wholeInput;
220
219
  for (const sp of spans) {
221
- const key = norm(sp.text);
220
+ const key = foldName(sp.text);
222
221
  if (key.length < 2 || /^\d+$/.test(key))
223
222
  continue; // skip bare numbers / empties
224
- const bare = softCountryEligible && sp.start === wholeInput.start && sp.end === wholeInput.end;
223
+ // Whole-input coverage and the soft-country prior are SEPARATE checks. `bare` (the prior) also
224
+ // needs an unqualified tree + a caller country; `wholeSpan` alone decides the alias tier below —
225
+ // a scope-less bare "Riyadh"/"Frankfurt" is still a NAMING (their Latin surfaces live in alias
226
+ // rows: الرياض / Frankfurt am Main), and conflating the two checks cost exactly those rows on the
227
+ // 2026-08-15 board before this line split them.
228
+ const wholeSpan = !!wholeInput && sp.start === wholeInput.start && sp.end === wholeInput.end;
229
+ const bare = softCountryEligible && wholeSpan;
225
230
  const hits = bare
226
231
  ? rankByCountryPrior(await backend.findPlace({ text: sp.text, postcode, placetype: "locality", limit: BARE_TOPONYM_FETCH }), country, countryWeight)
227
- : await backend.findPlace({ text: sp.text, country, postcode, placetype: "locality", limit: 5 });
232
+ : // A SUB-span probe is a RE-READING of a token the parse classified into a longer span — it
233
+ // never NAMED an alias, so alias-keyed rows are off for it (`primaryOnly`, the #1632
234
+ // Savile→Rhu door). A whole-input span keeps the alias tier regardless of scope (the
235
+ // Москва/Riyadh-class exonym recall, #1546).
236
+ await backend.findPlace({
237
+ text: sp.text,
238
+ country,
239
+ postcode,
240
+ placetype: "locality",
241
+ limit: 5,
242
+ ...(wholeSpan ? {} : { primaryOnly: true }),
243
+ });
228
244
  // #1546: NO primary-name re-check here — the backend's `exactMatch` IS the name-OR-alias surface
229
245
  // equality (the names table / alt_names bag), so a query matches a place when ANY stored name
230
246
  // equals it. Re-comparing only the PRIMARY name folded to [a-z0-9 ] excluded exactly the
231
247
  // non-Latin-primary class: Москва folds to "" and could never equal "moscow", so Moscow RU never
232
248
  // entered the list and Moscow, Idaho won by default among the Latin-named bearers — population-
233
249
  // first ranking starved, not violated. The alias surface is the recall; ranking then does its job.
234
- // The postcode gate below still applies to every admitted candidate, Moscow RU included.
250
+ // The postcode check below still applies to every admitted candidate, Moscow RU included.
235
251
  //
236
252
  // #17: importance-first WITHIN the admitted set. The key is the #28 blended fame prior
237
253
  // (`PlaceCandidate.importance`, produced by the candidate build) — the only key that separates
@@ -240,23 +256,23 @@ export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
240
256
  // signal when it has been measured, and leaves an unscored candidate exactly where population
241
257
  // put it.
242
258
  const exact = rankByImportance(hits.filter((h) => h.exactMatch && (h.lat !== 0 || h.lon !== 0)));
243
- const withinGate = (p) => !anchor || gateKm <= 0 || haversineKm(anchor.lat, anchor.lon, p.lat, p.lon) <= gateKm;
259
+ const withinThreshold = (p) => !anchor || thresholdKm <= 0 || haversineKm(anchor.lat, anchor.lon, p.lat, p.lon) <= thresholdKm;
244
260
  for (const h of exact) {
245
- if (!withinGate(h))
261
+ if (!withinThreshold(h))
246
262
  continue;
247
- // gated = the postcode anchor existed AND validated this match (within gateKm). When no anchor
248
- // (no postcode→point coverage), the match is ungated — returned, but flagged lower-precision.
263
+ // conditional = the postcode anchor existed AND validated this match (within thresholdKm). When no anchor
264
+ // (no postcode→point coverage), the match is unrestricted — returned, but flagged lower-precision.
249
265
  //
250
- // #1537: carry the rest of the SAME lookup's exact matches as the namesake runner-ups. Gate-filtered on the
251
- // same rule as the winner — a candidate the postcode gate rejected is not a namesake worth offering, it is a
266
+ // #1537: carry the rest of the SAME lookup's exact matches as the namesake runner-ups. Check-filtered on the
267
+ // same rule as the winner — a candidate the postcode check rejected is not a namesake worth offering, it is a
252
268
  // place the evidence already excluded. Rank order is the backend's, preserved by `filter`.
253
269
  return {
254
270
  text: sp.text,
255
271
  start: sp.start,
256
272
  end: sp.end,
257
273
  place: h,
258
- gated: anchor !== null,
259
- alternatives: exact.filter((a) => a !== h && withinGate(a)),
274
+ postcodeVerified: anchor !== null,
275
+ alternatives: exact.filter((a) => a !== h && withinThreshold(a)),
260
276
  };
261
277
  }
262
278
  }
@@ -264,15 +280,15 @@ export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
264
280
  // CLI's en-US default scoped both the anchor and the village probe to US, so the SI floor never
265
281
  // fired through geocode-core while the same rows resolved 25/25 on the resolver harness. When the
266
282
  // scoped pass finds nothing and a postcode is present, re-probe the spans UNSCOPED (the admin
267
- // gazetteer is one shard, all countries), then verify each exact candidate against the postcode's
268
- // code subset resolved in the CANDIDATE's own country (postcode shards route by country). A
269
- // cross-country promotion is accepted ONLY postcode-verified within the gate — never ungated —
283
+ // gazetteer is one extract, all countries), then verify each exact candidate against the postcode's
284
+ // code subset resolved in the CANDIDATE's own country (postcode extracts route by country). A
285
+ // cross-country promotion is accepted ONLY postcode-verified within the radius — never unverified —
270
286
  // so a US-shaped query can't wander abroad on a name coincidence (the 48026 guard: resolved
271
287
  // trees never reach this code, and unresolved ones must pass the joint postcode check).
272
- if (opts.postalCompoundRecovery && postcode && gateKm > 0) {
288
+ if (opts.postalCompoundRecovery && postcode && thresholdKm > 0) {
273
289
  const code = postcodeCodeSubset(postcode) || postcode.trim();
274
290
  for (const sp of spans) {
275
- const key = norm(sp.text);
291
+ const key = foldName(sp.text);
276
292
  if (key.length < 2 || /^\d+$/.test(key))
277
293
  continue;
278
294
  const hits = await backend.findPlace({ text: sp.text, placetype: "locality", limit: 5 });
@@ -291,13 +307,13 @@ export async function findRescoreCandidate(raw, roots, backend, opts = {}) {
291
307
  limit: 2,
292
308
  });
293
309
  const verified = pcHits.find((p) => p.lat !== 0 || p.lon !== 0);
294
- if (verified && haversineKm(verified.lat, verified.lon, h.lat, h.lon) <= gateKm) {
310
+ if (verified && haversineKm(verified.lat, verified.lon, h.lat, h.lon) <= thresholdKm) {
295
311
  // No alternatives from this pass, deliberately. Admission here is per-candidate postcode
296
312
  // verification — one `findPlace` per runner-up — and the class it serves is the opposite of the
297
313
  // namesake one: a postcode is present and has already picked the country, so there is nothing
298
314
  // ambiguous left to declare. The bare-toponym queries #1537 is about never reach this branch (it
299
315
  // requires a postcode).
300
- return { text: sp.text, start: sp.start, end: sp.end, place: h, gated: true, alternatives: [] };
316
+ return { text: sp.text, start: sp.start, end: sp.end, place: h, postcodeVerified: true, alternatives: [] };
301
317
  }
302
318
  }
303
319
  }
@@ -1 +1 @@
1
- {"version":3,"file":"span-rescore.js","sourceRoot":"","sources":["../span-rescore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AA2FvG;;GAEG;AACH,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE,CAClC,CAAC;KACC,WAAW,EAAE;KACb,SAAS,CAAC,KAAK,CAAC;KAChB,UAAU,CAAC,aAAa,EAAE,GAAG,CAA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CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YAE9E,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO;oBAAE,SAAQ;gBAEjD,4CAA4C;gBAC5C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC;oBACtC,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,CAAC,CAAC,OAAO;oBAClB,SAAS,EAAE,YAAY;oBACvB,KAAK,EAAE,CAAC;iBACR,CAAC,CAAA;gBAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAA;gBAE/D,IAAI,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC;oBACtF,yFAAyF;oBACzF,gGAAgG;oBAChG,8FAA8F;oBAC9F,iGAAiG;oBACjG,wBAAwB;oBACxB,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAA;gBAC3G,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC"}
@@ -26,6 +26,7 @@
26
26
  * backend lives in `@mailwoman/resolver-wof-sqlite` (`SQLiteStreetNameLookup`); callers inject it,
27
27
  * mirroring the `PlaceLookup` pattern.
28
28
  */
29
+ import type { Exclusion } from "@mailwoman/evidence";
29
30
  /**
30
31
  * A street-name existence probe. Backend-agnostic; the FR instance is BAN street-centroids, a future US instance is
31
32
  * TIGER, etc. (per the registry-backed-structured-prediction doctrine tiers).
@@ -85,10 +86,18 @@ export interface PickByStreetEvidenceOpts {
85
86
  * G2 — the margin cap. A candidate whose score is more than this far below rank-1 is never promoted by evidence
86
87
  * (without it, evidence reaches deep down the list and moves off correct rank-1 parses). Default 2.5 — the value the
87
88
  * v2 board measured (148 fixes / 3 breaks). UNCALIBRATED across models: re-fit when the span head retrains, since raw
88
- * score margins are not comparable across models. (Plan #1134 pre-registers an isotonic ambiguity gate to replace
89
+ * score margins are not comparable across models. (Plan #1134 pre-registers an isotonic ambiguity check to replace
89
90
  * it.)
90
91
  */
91
92
  marginCap?: number;
93
+ /**
94
+ * One entry per candidate, positionally aligned. A non-null entry DEMOTES that candidate by one bit — it is
95
+ * considered only after every un-excluded sibling. It is never removed: with every candidate excluded the pick is
96
+ * still rank-1, because the worst case this policy accepts is the model's own ranking.
97
+ *
98
+ * Omitted or all-null reproduces the measured v2 policy exactly.
99
+ */
100
+ exclusions?: ReadonlyArray<Exclusion | null>;
92
101
  }
93
102
  export interface StreetEvidencePick<T = unknown> {
94
103
  /**
@@ -103,15 +112,21 @@ export interface StreetEvidencePick<T = unknown> {
103
112
  * True when evidence MOVED the pick off rank-1 (a rank-2-beats-rank-1 correction — loggable training signal).
104
113
  */
105
114
  moved: boolean;
115
+ /**
116
+ * Indices an exclusion demoted, in input order. Empty when no exclusion applied — a loggable record of what the
117
+ * coverage check licensed, distinct from what evidence found.
118
+ */
119
+ demoted: number[];
106
120
  }
107
121
  /**
108
122
  * The measured v2 rerank policy. Given candidates in PARSE-SCORE order (rank-1 first) and an evidence probe, return the
109
123
  * first candidate whose street surface passes ALL of: (1) exists in the index, (2) G1 — not pure type vocabulary, (3)
110
124
  * G2 — within `marginCap` of rank-1. If none passes, return rank-1 (fail-open). Positive evidence only; the model's
111
125
  * order is preserved among equal-evidence candidates. This is the `resolver/rerank.ts` anti-Pelias discipline applied
112
- * to the name signal: one bit, no blending.
126
+ * to the name signal: one bit, no blending. `opts.exclusions` adds one more bit in the same fold: a coverage-licensed
127
+ * absence demotes its candidate behind every un-excluded sibling and never removes it.
113
128
  *
114
129
  * @param candidates Parse candidates, rank-1 FIRST (the caller sorts by score descending).
115
130
  */
116
131
  export declare function pickByStreetEvidence<T>(candidates: ReadonlyArray<StreetCandidate<T>>, evidence: StreetLocalityEvidence, opts?: PickByStreetEvidenceOpts): StreetEvidencePick<T>;
117
- //# sourceMappingURL=street-evidence.d.ts.map
132
+ //# sourceMappingURL=evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../../lib/street/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;;;;OAOG;IACH,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAA;IAC1E;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQzD;AA4CD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAMnE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC3C;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,CAAA;CACX;AAED,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;CAC5C;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,OAAO;IAC9C;;OAEG;IACH,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACrC,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAC7C,QAAQ,EAAE,sBAAsB,EAChC,IAAI,GAAE,wBAA6B,GACjC,kBAAkB,CAAC,CAAC,CAAC,CA4CvB"}
@@ -85,7 +85,7 @@ const FR_STREET_TYPE_WORDS = new Set([
85
85
  * True when the folded surface contains no token outside {@link FR_STREET_TYPE_WORDS} — i.e. it is pure type/particle.
86
86
  */
87
87
  export function isPureTypeVocabulary(foldedSurface) {
88
- const tokens = foldedSurface.split(" ").filter(Boolean);
88
+ const tokens = foldedSurface.split(" ").filter((value) => value.length > 0);
89
89
  if (!tokens.length)
90
90
  return true;
91
91
  return tokens.every((t) => FR_STREET_TYPE_WORDS.has(t));
@@ -95,7 +95,8 @@ export function isPureTypeVocabulary(foldedSurface) {
95
95
  * first candidate whose street surface passes ALL of: (1) exists in the index, (2) G1 — not pure type vocabulary, (3)
96
96
  * G2 — within `marginCap` of rank-1. If none passes, return rank-1 (fail-open). Positive evidence only; the model's
97
97
  * order is preserved among equal-evidence candidates. This is the `resolver/rerank.ts` anti-Pelias discipline applied
98
- * to the name signal: one bit, no blending.
98
+ * to the name signal: one bit, no blending. `opts.exclusions` adds one more bit in the same fold: a coverage-licensed
99
+ * absence demotes its candidate behind every un-excluded sibling and never removes it.
99
100
  *
100
101
  * @param candidates Parse candidates, rank-1 FIRST (the caller sorts by score descending).
101
102
  */
@@ -106,20 +107,35 @@ export function pickByStreetEvidence(candidates, evidence, opts = {}) {
106
107
  }
107
108
  const rank1 = candidates[0];
108
109
  const topScore = rank1.score;
110
+ const demoted = [];
111
+ const considered = [];
109
112
  for (let i = 0; i < candidates.length; i++) {
113
+ if (opts.exclusions?.[i]) {
114
+ demoted.push(i);
115
+ }
116
+ else {
117
+ considered.push(i);
118
+ }
119
+ }
120
+ // An excluded candidate is considered only after every un-excluded sibling; it is never dropped.
121
+ const order = demoted.length ? [...considered, ...demoted] : considered;
122
+ for (const i of order) {
110
123
  const c = candidates[i];
111
124
  if (!c.streetSurface)
112
125
  continue;
113
- // G2: candidates are score-ordered, so once one falls past the cap nothing deeper qualifies either.
126
+ // G2: the margin is measured from rank-1's score, whatever position the candidate is considered at.
114
127
  if (topScore - c.score > marginCap)
115
- break;
128
+ continue;
116
129
  // G1: a pure street-type/particle surface (bare `rue`) carries no name — no evidence credit.
117
130
  if (isPureTypeVocabulary(foldStreetSurface(c.streetSurface)))
118
131
  continue;
119
132
  if (evidence.hasStreetName(c.streetSurface, opts.scope)) {
120
- return { candidate: c, index: i, moved: i > 0 };
133
+ return { candidate: c, index: i, moved: i > 0, demoted };
121
134
  }
122
135
  }
123
- return { candidate: rank1, index: 0, moved: false };
136
+ // Fail-open: the first un-excluded candidate, which is rank-1 unless an exclusion demoted it, and rank-1 again when
137
+ // every candidate is excluded.
138
+ const fallback = order[0] ?? 0;
139
+ return { candidate: candidates[fallback], index: fallback, moved: fallback > 0, demoted };
124
140
  }
125
- //# sourceMappingURL=street-evidence.js.map
141
+ //# sourceMappingURL=evidence.js.map
@@ -0,0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CAAC,CAAC;YAAE,SAAQ;QAEtE,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,CAAA;QACzD,CAAC;IACF,CAAC;IAED,oHAAoH;IACpH,+BAA+B;IAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAE9B,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,CAAA;AAC3F,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#street/evidence";
7
+ export * from "#street/tier";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/street/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#street/evidence";
7
+ export * from "#street/tier";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/street/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA"}
@@ -11,12 +11,23 @@
11
11
  * this one holds the tiers. The FR voie-type folding lives here because only the street-centroid
12
12
  * tier consults it.
13
13
  */
14
- import type { AddressNode } from "@mailwoman/core/decoder";
14
+ import { type AddressNode } from "@mailwoman/core/decoder";
15
15
  import type { AddressPointLookup, InterpolationLookup, StreetCentroidLookup } from "@mailwoman/core/resolver";
16
+ /**
17
+ * Every `(street, house_number)` pair the tree offers, nearest pair first: the house number whose span sits closest to
18
+ * the street's, a number BEFORE the street winning a tie. A venue-led string parses more than one of each — `Bar 1802,
19
+ * 22 Rue Pascal, 75005 Paris, France` carries two house numbers and one street, and `22` is the one written beside `Rue
20
+ * Pascal`. The tiers probe the pairs in this order and stop at the first register hit, and the pair that hit is what
21
+ * the result names; a walk that took "the first node of each tag" paired whatever the traversal met first.
22
+ */
23
+ export declare function streetNumberPairs(roots: readonly AddressNode[]): Array<{
24
+ street: AddressNode;
25
+ houseNumber: AddressNode;
26
+ }>;
16
27
  export declare function applyAddressPoint(roots: AddressNode[], lookup: AddressPointLookup, bboxFallback?: boolean): void;
17
28
  /**
18
29
  * House-number interpolation tier (#483): the third rung, consulted ONLY when the exact address-point tier
19
- * ({@link applyAddressPoint}) did NOT already stamp the street node (`resolution_tier === "address_point"`). That gate
30
+ * ({@link applyAddressPoint}) did NOT already stamp the street node (`resolution_tier === "address_point"`). That check
20
31
  * IS the "after the exact-point fall-through" — an estimate never overwrites a real situs point. Postcode-scoped (no
21
32
  * locality — the interpolators abstain statewide without a postcode). Stamps a DISTINCT metadata key
22
33
  * (`interpolated_point`, never `address_point`). Additive only — admin resolution is untouched.
@@ -36,4 +47,4 @@ export declare function applyInterpolation(roots: AddressNode[], lookup: Interpo
36
47
  * street-level coordinate already resolved, and never alters admin resolution.
37
48
  */
38
49
  export declare function applyStreetCentroid(roots: AddressNode[], raw: string, provider: (country: string) => StreetCentroidLookup | undefined, hints: readonly string[]): void;
39
- //# sourceMappingURL=street-tier.d.ts.map
50
+ //# sourceMappingURL=tier.d.ts.map