@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tier.d.ts","sourceRoot":"","sources":["../../lib/street/tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAsD7G;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,SAAS,WAAW,EAAE,GAC3B,KAAK,CAAC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,WAAW,CAAA;CAAE,CAAC,CAiB1D;AAyBD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAiEhH;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,WAAW,EAAE,EACpB,MAAM,EAAE,mBAAmB,EAC3B,iBAAiB,CAAC,EAAE,MAAM,GACxB,IAAI,CA4DN;AAgGD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,WAAW,EAAE,EACpB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,oBAAoB,GAAG,SAAS,EAC/D,KAAK,EAAE,SAAS,MAAM,EAAE,GACtB,IAAI,CAqKN"}
@@ -12,8 +12,8 @@
12
12
  * tier consults it.
13
13
  */
14
14
  import { isStreetDirectionalToken } from "@mailwoman/codex/us";
15
- import { haversineKm } from "@mailwoman/spatial";
16
- import { foldName } from "./fold-name.js";
15
+ import { collectNodes, walkNodes } from "@mailwoman/core/decoder";
16
+ import { foldName } from "#fold-name";
17
17
  /**
18
18
  * Street-name component tags that, with the street node itself, reconstruct the full street string.
19
19
  */
@@ -21,23 +21,15 @@ const STREET_NAME_TAGS = new Set(["street", "street_prefix", "street_prefix_part
21
21
  /**
22
22
  * Reassemble the full street string from the street node's subtree (#483 coverage fix). The parser nests the
23
23
  * directional/suffix as `street_prefix`/`street_suffix` CHILDREN of `street` (containment.ts), so `street.value` alone
24
- * is the bare base name ("Sheldon" for "East Sheldon Rd") — which misses the coordinate shards keyed on the FULL
24
+ * is the bare base name ("Sheldon" for "East Sheldon Rd") — which misses the coordinate extracts keyed on the FULL
25
25
  * normalized name. Collect street + its prefix/particle/suffix descendants (NOT house_number/unit, which also nest
26
26
  * under street), order by span offset, and join.
27
27
  */
28
28
  function assembleStreetValue(streetNode, directionalUnit) {
29
- const parts = [];
30
- const stack = [streetNode];
31
- while (stack.length) {
32
- const n = stack.pop();
33
- if (STREET_NAME_TAGS.has(n.tag) && n.value.trim()) {
34
- parts.push(n);
35
- }
36
- stack.push(...n.children);
37
- }
29
+ const parts = collectNodes([streetNode], (n) => STREET_NAME_TAGS.has(n.tag) && n.value.trim().length > 0);
38
30
  // #718 admin-tail: a directional quadrant the model mis-tagged `unit` ("1532 Taylor Street NE" →
39
31
  // [unit] "NE") folds back into the street key by span order, so the situs/interp lookup matches the
40
- // shard's "taylor street northeast" (the lookup normalizer expands the abbreviation). Lookup-key
32
+ // extract's "taylor street northeast" (the lookup normalizer expands the abbreviation). Lookup-key
41
33
  // only — the parse output and admin resolution are untouched. Byte-stable when absent (undefined).
42
34
  if (directionalUnit && directionalUnit.value.trim()) {
43
35
  parts.push(directionalUnit);
@@ -49,7 +41,7 @@ function assembleStreetValue(streetNode, directionalUnit) {
49
41
  * Directional quadrant values the model sometimes emits as a `unit` node instead of inside the street subtree (#718
50
42
  * admin-tail diagnostic: ~19% of the admin-fallback tail, 83% of DC). Folded into the street lookup key by
51
43
  * {@link assembleStreetValue}; the situs/interp lookup normalizer expands the abbreviation ("ne" → "northeast") so the
52
- * shard's full street name matches.
44
+ * extract's full street name matches.
53
45
  */
54
46
  // The 8 USPS cardinals/intercardinals (abbrev or name) — @codex/us owns the canonical table (#215).
55
47
  const isDirectionalUnit = (value) => isStreetDirectionalToken(value.replaceAll(".", ""));
@@ -65,39 +57,58 @@ const isDirectionalUnit = (value) => isStreetDirectionalToken(value.replaceAll("
65
57
  * / point-in-polygon pass, #250); this is the coverage stopgap until then.
66
58
  */
67
59
  const LOCALITY_BBOX_RADIUS_DEG = 0.25;
68
- export function applyAddressPoint(roots, lookup, bboxFallback) {
69
- let street;
70
- let houseNumber;
71
- let directionalUnit;
72
- let localityNode;
73
- let locality;
74
- let postcode;
75
- const stack = [...roots];
76
- while (stack.length) {
77
- const n = stack.pop();
78
- if (n.tag === "street" && !street) {
79
- street = n;
80
- }
81
- if (n.tag === "house_number" && !houseNumber) {
82
- houseNumber = n;
83
- }
84
- if (n.tag === "unit" && !directionalUnit && isDirectionalUnit(n.value)) {
85
- directionalUnit = n;
86
- }
87
- if (n.tag === "locality" && !localityNode && n.value.trim()) {
88
- localityNode = n;
89
- locality = n.value.trim();
60
+ /**
61
+ * Every `(street, house_number)` pair the tree offers, nearest pair first: the house number whose span sits closest to
62
+ * the street's, a number BEFORE the street winning a tie. A venue-led string parses more than one of each — `Bar 1802,
63
+ * 22 Rue Pascal, 75005 Paris, France` carries two house numbers and one street, and `22` is the one written beside `Rue
64
+ * Pascal`. The tiers probe the pairs in this order and stop at the first register hit, and the pair that hit is what
65
+ * the result names; a walk that took "the first node of each tag" paired whatever the traversal met first.
66
+ */
67
+ export function streetNumberPairs(roots) {
68
+ const streets = [];
69
+ const numbers = [];
70
+ for (const node of walkNodes(roots)) {
71
+ if (node.tag === "street") {
72
+ streets.push(node);
90
73
  }
91
- if (n.tag === "postcode" && !postcode && n.value.trim()) {
92
- postcode = n.value.trim();
74
+ if (node.tag === "house_number") {
75
+ numbers.push(node);
93
76
  }
94
- stack.push(...n.children);
95
77
  }
96
- if (!street || !houseNumber)
78
+ const pairs = streets.flatMap((street) => numbers.map((houseNumber) => ({ street, houseNumber })));
79
+ return pairs.toSorted((a, b) => pairGap(a) - pairGap(b));
80
+ }
81
+ /**
82
+ * Characters between a house number and its street; a number after the street costs one extra so the tie goes to the
83
+ * number written before it, the order every Latin-script address system this resolver serves writes.
84
+ */
85
+ function pairGap(pair) {
86
+ const { street, houseNumber } = pair;
87
+ if (houseNumber.end <= street.start)
88
+ return street.start - houseNumber.end;
89
+ return houseNumber.start - street.end + 1;
90
+ }
91
+ /**
92
+ * The first node of `tag` in document order whose value is non-blank, when the tree carries one.
93
+ */
94
+ function firstOfTag(roots, tag) {
95
+ for (const node of walkNodes(roots)) {
96
+ if (node.tag === tag && node.value.trim())
97
+ return node;
98
+ }
99
+ return undefined;
100
+ }
101
+ export function applyAddressPoint(roots, lookup, bboxFallback) {
102
+ const pairs = streetNumberPairs(roots);
103
+ const directionalUnit = [...walkNodes(roots)].find((n) => n.tag === "unit" && isDirectionalUnit(n.value));
104
+ const localityNode = firstOfTag(roots, "locality");
105
+ const locality = localityNode?.value.trim();
106
+ const postcode = firstOfTag(roots, "postcode")?.value.trim();
107
+ if (!pairs.length)
97
108
  return;
98
- if (street.metadata?.["resolution_tier"] === "address_point")
109
+ if (pairs.some((pair) => pair.street.metadata?.["resolution_tier"] === "address_point"))
99
110
  return;
100
- // #247 OSM bbox fall-through: when enabled (an OSM shard is wired) and the locality resolved to a
111
+ // #247 OSM bbox fall-through: when enabled (an OSM extract is wired) and the locality resolved to a
101
112
  // coordinate, scope a final `(street, number)` probe by the locality's box — recovering OSM points that
102
113
  // carry no postcode/locality tag of their own. US situs never enables it, so its probes are byte-identical.
103
114
  let bbox;
@@ -109,62 +120,87 @@ export function applyAddressPoint(roots, lookup, bboxFallback) {
109
120
  maxLon: localityNode.lon + LOCALITY_BBOX_RADIUS_DEG,
110
121
  };
111
122
  }
112
- const hit = lookup.find({
113
- street: assembleStreetValue(street, directionalUnit),
114
- number: houseNumber.value,
115
- postcode,
116
- locality,
117
- bbox,
118
- });
119
- if (!hit)
123
+ let street;
124
+ let houseNumber;
125
+ let hit;
126
+ for (const pair of pairs) {
127
+ hit = lookup.find({
128
+ street: assembleStreetValue(pair.street, directionalUnit),
129
+ number: pair.houseNumber.value,
130
+ postcode,
131
+ locality,
132
+ bbox,
133
+ });
134
+ if (hit) {
135
+ street = pair.street;
136
+ houseNumber = pair.houseNumber;
137
+ break;
138
+ }
139
+ }
140
+ if (!hit || !street || !houseNumber)
120
141
  return;
142
+ // The number the register answered for is the one the result names (tree-shape.ts `slotNodes` reads the stamp).
143
+ houseNumber.metadata = { ...houseNumber.metadata, resolution_tier: "address_point" };
121
144
  street.metadata = {
122
145
  ...street.metadata,
123
- address_point: { lat: hit.lat, lon: hit.lon, source: hit.source, release: hit.release },
146
+ address_point: {
147
+ lat: hit.lat,
148
+ lon: hit.lon,
149
+ source: hit.source,
150
+ release: hit.release,
151
+ // The register row's OWN scope tags, when carried — a rooftop consumer can decorate the
152
+ // commune/postcode the register attests even when the query never named them.
153
+ ...(hit.localityNorm ? { locality_norm: hit.localityNorm } : {}),
154
+ ...(hit.postcode ? { postcode: hit.postcode } : {}),
155
+ },
124
156
  resolution_tier: "address_point",
125
157
  };
126
158
  }
127
159
  /**
128
160
  * House-number interpolation tier (#483): the third rung, consulted ONLY when the exact address-point tier
129
- * ({@link applyAddressPoint}) did NOT already stamp the street node (`resolution_tier === "address_point"`). That gate
161
+ * ({@link applyAddressPoint}) did NOT already stamp the street node (`resolution_tier === "address_point"`). That check
130
162
  * IS the "after the exact-point fall-through" — an estimate never overwrites a real situs point. Postcode-scoped (no
131
163
  * locality — the interpolators abstain statewide without a postcode). Stamps a DISTINCT metadata key
132
164
  * (`interpolated_point`, never `address_point`). Additive only — admin resolution is untouched.
133
165
  */
134
166
  export function applyInterpolation(roots, lookup, radiusCalibration) {
167
+ const pairs = streetNumberPairs(roots);
168
+ const directionalUnit = [...walkNodes(roots)].find((n) => n.tag === "unit" && isDirectionalUnit(n.value));
169
+ const postcode = firstOfTag(roots, "postcode")?.value.trim();
170
+ // The resolved locality's coordinate — the `near` tie-breaker the interpolator may consult when the query carries
171
+ // no postcode and the covering ranges span several ZIPs (the borough-namesake class). Only a RESOLVED locality
172
+ // qualifies; an unresolved one contributes nothing.
173
+ const resolvedLocality = [...walkNodes(roots)].find((n) => n.tag === "locality" && n.lat != null && n.lon != null);
174
+ const localityCoord = resolvedLocality ? { lat: resolvedLocality.lat, lon: resolvedLocality.lon } : undefined;
175
+ if (!pairs.length)
176
+ return;
177
+ // The fall-through check: an exact situs point already won — never override it with an estimate.
178
+ if (pairs.some((pair) => pair.street.metadata?.["resolution_tier"] === "address_point"))
179
+ return;
180
+ const near = postcode ? undefined : localityCoord;
135
181
  let street;
136
182
  let houseNumber;
137
- let directionalUnit;
138
- let postcode;
139
- const stack = [...roots];
140
- while (stack.length) {
141
- const n = stack.pop();
142
- if (n.tag === "street" && !street) {
143
- street = n;
144
- }
145
- if (n.tag === "house_number" && !houseNumber) {
146
- houseNumber = n;
147
- }
148
- if (n.tag === "unit" && !directionalUnit && isDirectionalUnit(n.value)) {
149
- directionalUnit = n;
183
+ let hit;
184
+ for (const pair of pairs) {
185
+ hit = lookup.find({
186
+ street: assembleStreetValue(pair.street, directionalUnit),
187
+ number: pair.houseNumber.value,
188
+ postcode,
189
+ ...(near ? { near } : {}),
190
+ });
191
+ if (hit) {
192
+ street = pair.street;
193
+ houseNumber = pair.houseNumber;
194
+ break;
150
195
  }
151
- if (n.tag === "postcode" && !postcode && n.value.trim()) {
152
- postcode = n.value.trim();
153
- }
154
- stack.push(...n.children);
155
196
  }
156
- if (!street || !houseNumber)
157
- return;
158
- // The fall-through gate: an exact situs point already won — never override it with an estimate.
159
- if (street.metadata?.["resolution_tier"] === "address_point")
160
- return;
161
- const hit = lookup.find({ street: assembleStreetValue(street, directionalUnit), number: houseNumber.value, postcode });
162
- if (!hit)
197
+ if (!hit || !street || !houseNumber)
163
198
  return;
199
+ houseNumber.metadata = { ...houseNumber.metadata, resolution_tier: "interpolated" };
164
200
  // Conformal-calibrated radius (#374): the raw half-segment heuristic underestimates the true spread
165
- // (~72% coverage on Travis); ×1.70 → a 90% bound. The ARTIFACT's own multiplier (read from the shard's
201
+ // (~72% coverage on Travis); ×1.70 → a 90% bound. The ARTIFACT's own multiplier (read from the extract's
166
202
  // `interp_calibration` metadata table at open time — `lookup.radiusCalibration`) is the default; an
167
- // explicit caller factor is the @internal instrument override. Neither present (shards predating the
203
+ // explicit caller factor is the @internal instrument override. Neither present (extracts predating the
168
204
  // metadata table, no caller factor) keeps the raw value, byte-stable. Preserve the raw radius for
169
205
  // transparency.
170
206
  const factor = radiusCalibration ?? lookup.radiusCalibration;
@@ -185,7 +221,7 @@ export function applyInterpolation(roots, lookup, radiusCalibration) {
185
221
  * a place name ("Place Bellecour", "Cours de l'Intendance", "Quai des Bateliers"). Used by the #1042 street-centroid
186
222
  * tier to recognize a thoroughfare that the model mis-parsed as a `locality` (the FR no-street class, #901).
187
223
  * Deliberately generous — a false positive simply misses the exact street-centroid lookup and no-ops; the lookup is the
188
- * real gate.
224
+ * real check.
189
225
  */
190
226
  const FR_VOIE_TYPES = new Set([
191
227
  "rue",
@@ -238,7 +274,9 @@ const FR_VOIE_TYPES = new Set([
238
274
  "rond",
239
275
  ]);
240
276
  /**
241
- * Fold to lower-case, diacritic-stripped, punctuation-free tokens — mirrors `street-normalize.ts`'s `fold`.
277
+ * Fold to lower-case, diacritic-stripped, punctuation-free tokens — a deliberate local copy of
278
+ * `@mailwoman/resolver-wof-sqlite/street-normalize`'s `fold`: `@mailwoman/resolver` does not depend on that package, so
279
+ * the two are kept in step by hand.
242
280
  */
243
281
  function foldVoieTokens(s) {
244
282
  return s
@@ -248,7 +286,7 @@ function foldVoieTokens(s) {
248
286
  .replaceAll(/[.,'’]/g, "")
249
287
  .replaceAll("-", " ")
250
288
  .split(/\s+/)
251
- .filter(Boolean);
289
+ .filter((token) => token.length > 0);
252
290
  }
253
291
  /**
254
292
  * Does a string START with a French thoroughfare type token ("Rue …", "Place …")?
@@ -283,11 +321,11 @@ export function applyStreetCentroid(roots, raw, provider, hints) {
283
321
  let streetNode;
284
322
  let houseNumber = false;
285
323
  let postcode;
286
- const adminValues = []; // region / locality values, in tree order (thoroughfare and commune both hide here)
287
- const resolvedCountries = []; // countries the tree actually resolved to — a post-resolution country hint
288
- const stack = [...roots];
289
- while (stack.length) {
290
- const n = stack.pop();
324
+ // Region / locality values in document order (thoroughfare and commune both hide here), and the countries the tree
325
+ // resolved to — a post-resolution country hint.
326
+ const adminValues = [];
327
+ const resolvedCountries = [];
328
+ for (const n of walkNodes(roots)) {
291
329
  if (n.tag === "house_number") {
292
330
  houseNumber = true;
293
331
  }
@@ -308,11 +346,10 @@ export function applyStreetCentroid(roots, raw, provider, hints) {
308
346
  if (rc && !resolvedCountries.includes(rc)) {
309
347
  resolvedCountries.push(rc);
310
348
  }
311
- stack.push(...n.children);
312
349
  }
313
350
  if (houseNumber)
314
351
  return; // street-only tier — a numbered address is the rooftop tiers' job
315
- // Candidate countries: pre-resolution hints (defaultCountry + ungated placer) then the resolved countries. BAN is
352
+ // Candidate countries: pre-resolution hints (defaultCountry + unrestricted placer) then the resolved countries. BAN is
316
353
  // FR-only, so a non-FR candidate simply yields no lookup; the exact (street, base-commune) match is the real filter.
317
354
  const countries = [];
318
355
  for (const c of [...hints, ...resolvedCountries]) {
@@ -327,7 +364,7 @@ export function applyStreetCentroid(roots, raw, provider, hints) {
327
364
  const rawSegments = raw
328
365
  .split(",")
329
366
  .map((s) => s.trim())
330
- .filter(Boolean);
367
+ .filter((segment) => segment.length > 0);
331
368
  const CAP = 5;
332
369
  // Thoroughfare candidates (parsed-first, then raw): the assembled street node, any voie-shaped parsed value, any
333
370
  // voie-shaped raw comma-segment. The parse often truncates these (Champs-Élysées → "Avenue des Champs"), so the raw
@@ -414,4 +451,4 @@ export function applyStreetCentroid(roots, raw, provider, hints) {
414
451
  }
415
452
  }
416
453
  }
417
- //# sourceMappingURL=street-tier.js.map
454
+ //# sourceMappingURL=tier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tier.js","sourceRoot":"","sources":["../../lib/street/tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAoB,MAAM,yBAAyB,CAAA;AAGnF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,eAAe,EAAE,wBAAwB,EAAE,eAAe,CAAC,CAAC,CAAA;AAExG;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,UAAuB,EAAE,eAA6B;IAClF,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CA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ACP,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -32,7 +32,7 @@
32
32
  * {@link rankByCountryPrior} covers the other half of the class — the query where a country IS
33
33
  * known, but only because a locale said so. See `span-rescore.ts` for where that one applies.
34
34
  *
35
- * Both obey the same three house rules, and neither is a gate:
35
+ * Both obey the same three house rules, and neither is a check:
36
36
  *
37
37
  * 1. **Tier-safe.** `exactMatch` stays the primary key. A soft prior re-orders WITHIN a tier; it never
38
38
  * promotes a partial match over an exact one.
@@ -41,7 +41,10 @@
41
41
  * rank population gave it while the scored rows reorder among themselves. On a candidate.db built
42
42
  * before the #28 `importance` column, nothing is scored, so {@link rankByImportance} is
43
43
  * byte-stable by construction.
44
- * 3. **Stable.** Equal keys keep their incoming order, so the backend's own ranking survives underneath.
44
+ * 3. **Stable.** Equal keys keep their incoming order, so the backend's own ranking survives underneath. That order
45
+ * carries decisions only the backend can make — the candidate backend's seat tiebreak
46
+ * (`resolver-wof-sqlite/primary-preference.ts`) reaches an end-to-end answer solely through this stability
47
+ * (#1729), so equal-key stability here is required, not cosmetic.
45
48
  */
46
49
  import type { ResolvedPlace } from "@mailwoman/core/resolver";
47
50
  /**
@@ -61,19 +64,6 @@ import type { ResolvedPlace } from "@mailwoman/core/resolver";
61
64
  * - `Fulda` en-US — Fulda MN 3.13 + 2 = 5.13 beats Fulda DE 4.84. **Held.**
62
65
  */
63
66
  export declare const DEFAULT_COUNTRY_PRIOR_WEIGHT = 2;
64
- /**
65
- * Importance margin below which two SAME-COUNTRY bearers are a tie, and the tie falls back to referential (size) order.
66
- * Ratified 2026-08-11 (the five bare-query flip decisions): bare `Springfield` must stay on the referential answer —
67
- * the live chain is IL 0.612605 → MA 0.611142 → MO 0.596195 (adjacent gaps 0.0015 and 0.0149, full span 0.0164), so the
68
- * band must cover at least the 0.0149 adjacent gap for the trio to chain into one cluster.
69
- *
70
- * The band never compares across countries, and that scope is forced by decided rows, not preference: Windsor's
71
- * accepted flip (GB 0.564842 over CA 0.560687) sits at a 0.0042 gap — inside ANY band that covers Springfield. The two
72
- * decisions are only co-satisfiable if the band binds same-country pairs alone. That is also what the §2 referential
73
- * policy (ROAD_TO_V9) says: within a country the geocoder ranks referentially; the blended prior's job is the
74
- * cross-country question — which country's bearer a bare query meant.
75
- */
76
- export declare const SAME_COUNTRY_IMPORTANCE_TIE_BAND = 0.02;
77
67
  /**
78
68
  * The fields a ranking key reads. Structural rather than `ResolvedPlace` so the backend's own `PlaceCandidate` (a
79
69
  * structural twin) can be ranked without a cast.
@@ -88,10 +78,10 @@ type Rankable = Pick<ResolvedPlace, "score"> & Partial<Pick<ResolvedPlace, "coun
88
78
  * fewer than two candidates are scored.
89
79
  *
90
80
  * The producer is the candidate build's `importance` column (#28) — the BLENDED prior (the concordance's
91
- * encyclopedia-derived channel where a concordance matched, a population-derived proxy elsewhere; see
92
- * `candidate-schema.ts` → `CandidateTable.importance` for why the strict channel is deliberately NOT what lands there).
93
- * On an artifact predating the column, `importance` is `undefined` on every candidate the backend produces and the
94
- * abstention below keeps the ranking byte-stable.
81
+ * encyclopedia-derived channel clamped around a population-derived base — `place-importance-schema.ts`'s
82
+ * `blendImportance`; see `candidate-schema.ts` → `CandidateTable.importance` for why the strict channel is deliberately
83
+ * NOT what lands there). On an artifact predating the column, `importance` is `undefined` on every candidate the
84
+ * backend produces and the abstention below keeps the ranking byte-stable.
95
85
  *
96
86
  * Flip decisions, ratified 2026-08-11: bare `Moscow`→Москва, `Manchester`→GB, `Fulda`→DE, `Cambridge`→GB are ACCEPTED
97
87
  * behavior — all cross-country contests, where this prior answers the question population cannot. Bare `Springfield`
@@ -111,5 +101,39 @@ export declare function rankByImportance<T extends Rankable>(candidates: readonl
111
101
  * effectively hard, `0` to disable.
112
102
  */
113
103
  export declare function rankByCountryPrior<T extends Rankable>(candidates: readonly T[], country: string | undefined, weight?: number): T[];
104
+ /**
105
+ * Capital status of a resolved candidate, answered by the caller's reference (#1880 —
106
+ * `@mailwoman/resolver-wof-sqlite/capitals` is the shipped implementation): 2 for a national capital, 1 for an admin-1
107
+ * seat, 0 for neither. The resolver stays backend-agnostic — it never loads the reference, it only consumes the
108
+ * verdict.
109
+ */
110
+ export type CapitalLevelFn = (place: Pick<ResolvedPlace, "name" | "country" | "lat" | "lon">) => number;
111
+ /**
112
+ * Margin a national capital may give away, in log10-population units: a namesake must be more than 10^2 = 100x more
113
+ * populous to hold the lead. Bare "San José" reaches the Costa Rican capital (342,188) over San Jose, California
114
+ * (969,655 — 2.8x); bare "Hamilton" stays on Hamilton, Ontario (519,949) over Bermuda's 902-person capital (576x).
115
+ */
116
+ export declare const NATIONAL_CAPITAL_MARGIN_LOG10 = 2;
117
+ /**
118
+ * Bounded capital promotion (#1880) — the third soft key for the bare-toponym class, applied AFTER
119
+ * {@link rankByImportance} because the fame prior is what decides this class and a capital signal parked below the
120
+ * deciding stage measurably never reaches an answer (the iteration-1 board run: the candidate-order bonus reordered
121
+ * `findPlace` on every target row and moved 0 of the 12).
122
+ *
123
+ * The rule: within the exact tier, take the first NATIONAL-capital row and walk it upward past each row it is within
124
+ * {@link NATIONAL_CAPITAL_MARGIN_LOG10} of, stopping at the first row over the margin or at another national capital.
125
+ * Same three house rules as the other keys — tier-safe (never crosses the exact/partial boundary.
126
+ *
127
+ * A capital that only PARTIALLY matched the query — Saint George's, Grenada for the abbreviated "St. George's" — stays
128
+ * behind every exact match, because crossing that line is how iteration 1 answered bare "Djibouti" with the capital
129
+ * city instead of the country), positive evidence only (no capital in the list → identity, and the margin reads the
130
+ * same `prominence ?? score` size every other key does), and stable (non-promoted rows keep their order).
131
+ *
132
+ * The margin deliberately re-uses log10-population units rather than the importance scale: the ratified importance flip
133
+ * decisions (Whitby/Windsor/Springfield) sit on gaps of 0.004–0.02, while the capital contests this key exists for sit
134
+ * on gaps of 0.21–0.24 — an importance-scale bonus big enough to win them would dwarf every ratified decision on the
135
+ * same scale.
136
+ */
137
+ export declare function promoteCapitals<T extends Rankable & Pick<ResolvedPlace, "name" | "country" | "lat" | "lon">>(candidates: readonly T[], level: CapitalLevelFn | undefined): T[];
114
138
  export {};
115
139
  //# sourceMappingURL=toponym-prior.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toponym-prior.d.ts","sourceRoot":"","sources":["../toponym-prior.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gCAAgC,OAAO,CAAA;AAEpD;;;GAGG;AACH,KAAK,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GAC3C,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC,CAAC,CAAA;AAmIrF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAkBlF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,QAAQ,EACpD,UAAU,EAAE,SAAS,CAAC,EAAE,EACxB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,GAAE,MAAqC,GAC3C,CAAC,EAAE,CAOL"}
1
+ {"version":3,"file":"toponym-prior.d.ts","sourceRoot":"","sources":["../lib/toponym-prior.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAA;AAgB7C;;;GAGG;AACH,KAAK,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GAC3C,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,CAAC,CAAC,CAAA;AAmIrF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAkBlF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,QAAQ,EACpD,UAAU,EAAE,SAAS,CAAC,EAAE,EACxB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,GAAE,MAAqC,GAC3C,CAAC,EAAE,CAOL;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,MAAM,CAAA;AAYvG;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC,EAC3G,UAAU,EAAE,SAAS,CAAC,EAAE,EACxB,KAAK,EAAE,cAAc,GAAG,SAAS,GAC/B,CAAC,EAAE,CAoCL"}
@@ -32,7 +32,7 @@
32
32
  * {@link rankByCountryPrior} covers the other half of the class — the query where a country IS
33
33
  * known, but only because a locale said so. See `span-rescore.ts` for where that one applies.
34
34
  *
35
- * Both obey the same three house rules, and neither is a gate:
35
+ * Both obey the same three house rules, and neither is a check:
36
36
  *
37
37
  * 1. **Tier-safe.** `exactMatch` stays the primary key. A soft prior re-orders WITHIN a tier; it never
38
38
  * promotes a partial match over an exact one.
@@ -41,7 +41,10 @@
41
41
  * rank population gave it while the scored rows reorder among themselves. On a candidate.db built
42
42
  * before the #28 `importance` column, nothing is scored, so {@link rankByImportance} is
43
43
  * byte-stable by construction.
44
- * 3. **Stable.** Equal keys keep their incoming order, so the backend's own ranking survives underneath.
44
+ * 3. **Stable.** Equal keys keep their incoming order, so the backend's own ranking survives underneath. That order
45
+ * carries decisions only the backend can make — the candidate backend's seat tiebreak
46
+ * (`resolver-wof-sqlite/primary-preference.ts`) reaches an end-to-end answer solely through this stability
47
+ * (#1729), so equal-key stability here is required, not cosmetic.
45
48
  */
46
49
  /**
47
50
  * Weight of the locale-country bonus, in the same log10-population units the candidate backend's `prominence` uses
@@ -72,7 +75,7 @@ export const DEFAULT_COUNTRY_PRIOR_WEIGHT = 2;
72
75
  * policy (ROAD_TO_V9) says: within a country the geocoder ranks referentially; the blended prior's job is the
73
76
  * cross-country question — which country's bearer a bare query meant.
74
77
  */
75
- export const SAME_COUNTRY_IMPORTANCE_TIE_BAND = 0.02;
78
+ const SAME_COUNTRY_IMPORTANCE_TIE_BAND = 0.02;
76
79
  /**
77
80
  * Partition into (exact, rest), sort each half with `key` DESC, and re-join. The partition is what keeps a soft prior
78
81
  * soft: it can only ever re-order candidates the backend already considers equally good matches. Backends that don't
@@ -84,7 +87,7 @@ function rankWithinTier(candidates, compare) {
84
87
  const rest = [];
85
88
  for (const c of candidates) {
86
89
  // `exactMatch` is TRI-STATE: true / false / undefined (a backend path that stamps no flag —
87
- // e.g. WOFSqlitePlaceLookup's postcode-area neighbours from #fetchLocalitiesByID). Only a
90
+ // e.g. WOFSQLitePlaceLookup's postcode-area neighbours from #fetchLocalitiesByID). Only a
88
91
  // stated TRUE earns the exact tier; undefined must not outrank a real fuzzy name match
89
92
  // (the 2026-08-10 de.native_locality incident: 75 Saxon towns lost to nameless neighbours).
90
93
  ;
@@ -191,10 +194,10 @@ function orderMeasuredByImportance(rows) {
191
194
  * fewer than two candidates are scored.
192
195
  *
193
196
  * The producer is the candidate build's `importance` column (#28) — the BLENDED prior (the concordance's
194
- * encyclopedia-derived channel where a concordance matched, a population-derived proxy elsewhere; see
195
- * `candidate-schema.ts` → `CandidateTable.importance` for why the strict channel is deliberately NOT what lands there).
196
- * On an artifact predating the column, `importance` is `undefined` on every candidate the backend produces and the
197
- * abstention below keeps the ranking byte-stable.
197
+ * encyclopedia-derived channel clamped around a population-derived base — `place-importance-schema.ts`'s
198
+ * `blendImportance`; see `candidate-schema.ts` → `CandidateTable.importance` for why the strict channel is deliberately
199
+ * NOT what lands there). On an artifact predating the column, `importance` is `undefined` on every candidate the
200
+ * backend produces and the abstention below keeps the ranking byte-stable.
198
201
  *
199
202
  * Flip decisions, ratified 2026-08-11: bare `Moscow`→Москва, `Manchester`→GB, `Fulda`→DE, `Cambridge`→GB are ACCEPTED
200
203
  * behavior — all cross-country contests, where this prior answers the question population cannot. Bare `Springfield`
@@ -237,4 +240,69 @@ export function rankByCountryPrior(candidates, country, weight = DEFAULT_COUNTRY
237
240
  const key = (c) => size(c) + (c.country?.toUpperCase() === target ? weight : 0);
238
241
  return rankWithinTier(candidates, (a, b) => key(b) - key(a));
239
242
  }
243
+ /**
244
+ * The level a candidate must hold to be PROMOTED: national capitals only. Admin-1 seats stay un-promoted, and that
245
+ * scope is forced by decided rows, not caution — a seat margin of even 1 log10 unit flips bare `Springfield` to
246
+ * Springfield, Illinois against the ratified 2026-08-11 referential decision
247
+ * ({@link SAME_COUNTRY_IMPORTANCE_TIE_BAND}), and sends bare `Hamilton` to the Waikato seat (Hamilton NZ, 2.8x smaller
248
+ * than Hamilton, Ontario), both measured on the shipped `candidate.db`. The reference still records seats; no consumer
249
+ * promotes on them.
250
+ */
251
+ const PROMOTABLE_CAPITAL_LEVEL = 2;
252
+ /**
253
+ * Margin a national capital may give away, in log10-population units: a namesake must be more than 10^2 = 100x more
254
+ * populous to hold the lead. Bare "San José" reaches the Costa Rican capital (342,188) over San Jose, California
255
+ * (969,655 — 2.8x); bare "Hamilton" stays on Hamilton, Ontario (519,949) over Bermuda's 902-person capital (576x).
256
+ */
257
+ export const NATIONAL_CAPITAL_MARGIN_LOG10 = 2;
258
+ /**
259
+ * Bounded capital promotion (#1880) — the third soft key for the bare-toponym class, applied AFTER
260
+ * {@link rankByImportance} because the fame prior is what decides this class and a capital signal parked below the
261
+ * deciding stage measurably never reaches an answer (the iteration-1 board run: the candidate-order bonus reordered
262
+ * `findPlace` on every target row and moved 0 of the 12).
263
+ *
264
+ * The rule: within the exact tier, take the first NATIONAL-capital row and walk it upward past each row it is within
265
+ * {@link NATIONAL_CAPITAL_MARGIN_LOG10} of, stopping at the first row over the margin or at another national capital.
266
+ * Same three house rules as the other keys — tier-safe (never crosses the exact/partial boundary.
267
+ *
268
+ * A capital that only PARTIALLY matched the query — Saint George's, Grenada for the abbreviated "St. George's" — stays
269
+ * behind every exact match, because crossing that line is how iteration 1 answered bare "Djibouti" with the capital
270
+ * city instead of the country), positive evidence only (no capital in the list → identity, and the margin reads the
271
+ * same `prominence ?? score` size every other key does), and stable (non-promoted rows keep their order).
272
+ *
273
+ * The margin deliberately re-uses log10-population units rather than the importance scale: the ratified importance flip
274
+ * decisions (Whitby/Windsor/Springfield) sit on gaps of 0.004–0.02, while the capital contests this key exists for sit
275
+ * on gaps of 0.21–0.24 — an importance-scale bonus big enough to win them would dwarf every ratified decision on the
276
+ * same scale.
277
+ */
278
+ export function promoteCapitals(candidates, level) {
279
+ if (!level || candidates.length < 2)
280
+ return [...candidates];
281
+ const exact = [];
282
+ const rest = [];
283
+ for (const c of candidates) {
284
+ // Tri-state exactMatch, same reading as rankWithinTier: only a stated TRUE earns the tier.
285
+ ;
286
+ (c.exactMatch === true ? exact : rest).push(c);
287
+ }
288
+ const tier = exact.length ? exact : rest;
289
+ const best = tier.findIndex((c) => level(c) >= PROMOTABLE_CAPITAL_LEVEL);
290
+ if (best <= 0)
291
+ return [...candidates];
292
+ let target = best;
293
+ while (target > 0) {
294
+ const above = tier[target - 1];
295
+ if (level(above) >= PROMOTABLE_CAPITAL_LEVEL)
296
+ break;
297
+ if (size(tier[best]) + NATIONAL_CAPITAL_MARGIN_LOG10 < size(above))
298
+ break;
299
+ target--;
300
+ }
301
+ if (target === best)
302
+ return [...candidates];
303
+ const reordered = [...tier];
304
+ const [capital] = reordered.splice(best, 1);
305
+ reordered.splice(target, 0, capital);
306
+ return exact.length ? [...reordered, ...rest] : reordered;
307
+ }
240
308
  //# sourceMappingURL=toponym-prior.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toponym-prior.js","sourceRoot":"","sources":["../toponym-prior.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAIH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAA;AASpD;;;;;GAKG;AACH,SAAS,cAAc,CAAqB,UAAwB,EAAE,OAA+B;IACpG,MAAM,KAAK,GAAQ,EAAE,CAAA;IACrB,MAAM,IAAI,GAAQ,EAAE,CAAA;IAEpB,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC5B,4FAA4F;QAC5F,0FAA0F;QAC1F,uFAAuF;QACvF,4FAA4F;QAC5F,CAAC;QAAA,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC;IAED,yEAAyE;IACzE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,IAAI,GAAG,CAAC,CAAW,EAAU,EAAE,CAAC,CAAC,CAA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