@mailwoman/resolver 10.0.0 → 10.2.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.
- package/README.md +9 -7
- package/lib/admin/coherence-passes.ts +31 -172
- package/lib/admin/containment.ts +15 -33
- package/lib/admin/jp-municipality.ts +21 -14
- package/lib/admin/winner.ts +37 -69
- package/lib/backend-capabilities.ts +28 -27
- package/lib/bare-toponym-race.ts +69 -37
- package/lib/decorate-node.ts +25 -49
- package/lib/fold-name.ts +5 -18
- package/lib/index.ts +5 -9
- package/lib/plausibility.ts +41 -68
- package/lib/postcode/country-coherence.ts +92 -296
- package/lib/postcode/prefix.ts +24 -86
- package/lib/postcode/shape-coherence.ts +26 -116
- package/lib/remote-resolver.ts +38 -33
- package/lib/rerank.ts +41 -54
- package/lib/resolve/passes.ts +188 -177
- package/lib/resolve.ts +744 -0
- package/lib/span-rescore.ts +219 -175
- package/lib/street/evidence.ts +65 -73
- package/lib/street/tier.ts +51 -194
- package/lib/toponym-prior.ts +54 -180
- package/out/admin/coherence-passes.d.ts +18 -69
- package/out/admin/coherence-passes.d.ts.map +1 -1
- package/out/admin/coherence-passes.js +24 -166
- package/out/admin/coherence-passes.js.map +1 -1
- package/out/admin/containment.d.ts +13 -31
- package/out/admin/containment.d.ts.map +1 -1
- package/out/admin/containment.js +13 -31
- package/out/admin/containment.js.map +1 -1
- package/out/admin/jp-municipality.d.ts +21 -14
- package/out/admin/jp-municipality.d.ts.map +1 -1
- package/out/admin/jp-municipality.js +18 -12
- package/out/admin/jp-municipality.js.map +1 -1
- package/out/admin/winner.d.ts +32 -64
- package/out/admin/winner.d.ts.map +1 -1
- package/out/admin/winner.js +23 -56
- package/out/admin/winner.js.map +1 -1
- package/out/{admin/index.d.ts → admin.d.ts} +1 -1
- package/out/admin.d.ts.map +1 -0
- package/out/{admin/index.js → admin.js} +1 -1
- package/out/admin.js.map +1 -0
- package/out/backend-capabilities.d.ts +19 -20
- package/out/backend-capabilities.d.ts.map +1 -1
- package/out/backend-capabilities.js +28 -26
- package/out/backend-capabilities.js.map +1 -1
- package/out/bare-toponym-race.d.ts +54 -27
- package/out/bare-toponym-race.d.ts.map +1 -1
- package/out/bare-toponym-race.js +69 -37
- package/out/bare-toponym-race.js.map +1 -1
- package/out/decorate-node.d.ts +6 -8
- package/out/decorate-node.d.ts.map +1 -1
- package/out/decorate-node.js +25 -49
- package/out/decorate-node.js.map +1 -1
- package/out/fold-name.d.ts +5 -18
- package/out/fold-name.d.ts.map +1 -1
- package/out/fold-name.js +5 -18
- package/out/fold-name.js.map +1 -1
- package/out/index.d.ts +5 -6
- package/out/index.d.ts.map +1 -1
- package/out/index.js +5 -8
- package/out/index.js.map +1 -1
- package/out/plausibility.d.ts +30 -60
- package/out/plausibility.d.ts.map +1 -1
- package/out/plausibility.js +19 -52
- package/out/plausibility.js.map +1 -1
- package/out/postcode/country-coherence.d.ts +53 -167
- package/out/postcode/country-coherence.d.ts.map +1 -1
- package/out/postcode/country-coherence.js +42 -259
- package/out/postcode/country-coherence.js.map +1 -1
- package/out/postcode/prefix.d.ts +18 -69
- package/out/postcode/prefix.d.ts.map +1 -1
- package/out/postcode/prefix.js +11 -78
- package/out/postcode/prefix.js.map +1 -1
- package/out/postcode/shape-coherence.d.ts +18 -85
- package/out/postcode/shape-coherence.d.ts.map +1 -1
- package/out/postcode/shape-coherence.js +11 -107
- package/out/postcode/shape-coherence.js.map +1 -1
- package/out/{postcode/index.d.ts → postcode.d.ts} +1 -1
- package/out/postcode.d.ts.map +1 -0
- package/out/{postcode/index.js → postcode.js} +1 -1
- package/out/postcode.js.map +1 -0
- package/out/remote-resolver.d.ts +32 -31
- package/out/remote-resolver.d.ts.map +1 -1
- package/out/remote-resolver.js +12 -20
- package/out/remote-resolver.js.map +1 -1
- package/out/rerank.d.ts +32 -46
- package/out/rerank.d.ts.map +1 -1
- package/out/rerank.js +16 -41
- package/out/rerank.js.map +1 -1
- package/out/resolve/passes.d.ts +108 -95
- package/out/resolve/passes.d.ts.map +1 -1
- package/out/resolve/passes.js +67 -126
- package/out/resolve/passes.js.map +1 -1
- package/out/resolve.d.ts +15 -0
- package/out/resolve.d.ts.map +1 -0
- package/out/resolve.js +557 -0
- package/out/resolve.js.map +1 -0
- package/out/span-rescore.d.ts +56 -65
- package/out/span-rescore.d.ts.map +1 -1
- package/out/span-rescore.js +134 -132
- package/out/span-rescore.js.map +1 -1
- package/out/street/evidence.d.ts +56 -61
- package/out/street/evidence.d.ts.map +1 -1
- package/out/street/evidence.js +22 -46
- package/out/street/evidence.js.map +1 -1
- package/out/street/tier.d.ts +18 -30
- package/out/street/tier.d.ts.map +1 -1
- package/out/street/tier.js +43 -191
- package/out/street/tier.js.map +1 -1
- package/out/{street/index.d.ts → street.d.ts} +1 -1
- package/out/street.d.ts.map +1 -0
- package/out/{street/index.js → street.js} +1 -1
- package/out/street.js.map +1 -0
- package/out/toponym-prior.d.ts +22 -110
- package/out/toponym-prior.d.ts.map +1 -1
- package/out/toponym-prior.js +41 -170
- package/out/toponym-prior.js.map +1 -1
- package/package.json +44 -147
- package/lib/resolve/index.ts +0 -989
- package/out/admin/index.d.ts.map +0 -1
- package/out/admin/index.js.map +0 -1
- package/out/postcode/index.d.ts.map +0 -1
- package/out/postcode/index.js.map +0 -1
- package/out/resolve/index.d.ts +0 -20
- package/out/resolve/index.d.ts.map +0 -1
- package/out/resolve/index.js +0 -808
- package/out/resolve/index.js.map +0 -1
- package/out/street/index.d.ts.map +0 -1
- package/out/street/index.js.map +0 -1
- package/vitest.config.ts +0 -38
- /package/lib/{admin/index.ts → admin.ts} +0 -0
- /package/lib/{postcode/index.ts → postcode.ts} +0 -0
- /package/lib/{street/index.ts → street.ts} +0 -0
|
@@ -2,57 +2,30 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
-
*
|
|
6
|
-
* The three post-walk admin coherence passes (#263 / #822 / the region-country pass) — split from
|
|
7
|
-
* `resolve.ts` on the `bare-toponym-race.ts` precedent: the walk file holds the walk, this one
|
|
8
|
-
* holds the joint-consistency re-picks that run after it. Each pass's contract, triggers, and
|
|
9
|
-
* byte-stability guarantees are documented on the pass itself; `resolveTree` sequences them.
|
|
10
5
|
*/
|
|
11
6
|
import { matchCountry, matchSubdivision } from "@mailwoman/codex/country";
|
|
12
7
|
import { PLACETYPE_FILTER_GROUPS } from "@mailwoman/codex/placetype-map";
|
|
13
8
|
import { decorateNode, isResolvedWithCoord } from "#decorate-node";
|
|
14
|
-
/**
|
|
15
|
-
* The region-band placetypes a lineage names a region by — `region` and its macro widening, the same set the lookup
|
|
16
|
-
* filter admits for a `region` request.
|
|
17
|
-
*/
|
|
18
9
|
const REGION_LINEAGE_PLACETYPES = new Set(PLACETYPE_FILTER_GROUPS["region"] ?? ["region"]);
|
|
19
|
-
/**
|
|
20
|
-
* The numeric or string id behind a node's `placeID` (`wof:85679553` → `85679553`), or undefined when the node resolved
|
|
21
|
-
* to no place.
|
|
22
|
-
*/
|
|
23
10
|
function placeIDValue(node) {
|
|
24
11
|
const match = /^[a-z]+:(.+)$/u.exec(node.placeID ?? "");
|
|
25
|
-
return match?.[1];
|
|
12
|
+
return match?.[1] ?? null;
|
|
26
13
|
}
|
|
27
14
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* The walk scopes a child lookup to its resolved parent. When that scoped probe misses, two widenings exist so an
|
|
32
|
-
* incomplete hierarchy (a real place whose ancestor chain lacks its region) still resolves: the resolver's retry
|
|
33
|
-
* without the parent, and the candidate backend's interior region-scope fallback (#1731), which re-admits rows from
|
|
34
|
-
* outside the region and stamps them `regionScopeMiss`. Both also admit a namesake under another region: `臺南市北區`
|
|
35
|
-
* resolved 臺南市 (Tainan City), found no 北區 under it — the candidate table carries no Han key for Tainan's — and the
|
|
36
|
-
* widening answered Hsinchu's 北區, 214 km away, which the coherence report then marked `region: contradicted` while the
|
|
37
|
-
* point stood. Of the 289 held-out Taiwanese 鄉鎮市區, 21 resolved this way at 15.6–238 km when the register was read as
|
|
38
|
-
* bare `縣市鄉鎮市區` lines.
|
|
15
|
+
* Un-resolves a parent-fallback pick whose stamped ancestors name a region other than
|
|
16
|
+
* the resolved region above it, marking it `parent_fallback_refused`.
|
|
39
17
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* different place and is un-resolved here, so the admin ladder answers the parent's own point rather than a namesake
|
|
43
|
-
* elsewhere. Only widened picks are examined (`metadata.parent_fallback`, stamped by the walk for either mechanism),
|
|
44
|
-
* and only when the parent region resolved to a place identity; no-op without the ancestor sidecar, since a chain that
|
|
45
|
-
* cannot be read is not a contradiction. The classifier attribution stays on the node; `parent_fallback_refused`
|
|
46
|
-
* records what happened.
|
|
18
|
+
* A pick whose ancestor chain names no region is kept, because the fallback
|
|
19
|
+
* exists for places with incomplete hierarchies.
|
|
47
20
|
*/
|
|
48
21
|
export function applyParentFallbackContradiction(roots) {
|
|
49
22
|
const visit = (node, regionAncestor) => {
|
|
50
|
-
const regionHere = node.tag === "region" && placeIDValue(node)
|
|
23
|
+
const regionHere = node.tag === "region" && placeIDValue(node) ? node : regionAncestor;
|
|
51
24
|
if (regionHere && node !== regionHere && node.metadata?.["parent_fallback"] === true) {
|
|
52
25
|
const regionID = placeIDValue(regionHere);
|
|
53
26
|
const ancestors = node.metadata?.["ancestors"];
|
|
54
27
|
const regions = (ancestors ?? []).filter((a) => REGION_LINEAGE_PLACETYPES.has(a.placetype));
|
|
55
|
-
if (regionID
|
|
28
|
+
if (regionID && regions.length && !regions.some((a) => String(a.id) === regionID)) {
|
|
56
29
|
delete node.lat;
|
|
57
30
|
delete node.lon;
|
|
58
31
|
delete node.placeID;
|
|
@@ -75,16 +48,12 @@ export function applyParentFallbackContradiction(roots) {
|
|
|
75
48
|
}
|
|
76
49
|
}
|
|
77
50
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* Messina's descendants, finds nothing, and the result falls back to the region centroid (Sicily). The region's
|
|
81
|
-
* same-named runner-ups (Maine, Missouri, …) were already captured as `alternatives`; this pass asks the question the
|
|
82
|
-
* greedy order skipped — _which "ME" has a "Portland" under it?_ — and re-picks the (region, locality) pair where a
|
|
83
|
-
* same-named locality descends from a same-named region candidate. Geography decides; no country prior, no list.
|
|
51
|
+
* Re-picks a resolved region and its unresolved child locality as a pair, choosing the
|
|
52
|
+
* region candidate that actually contains a locality with the same name.
|
|
84
53
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
54
|
+
* This recovers cases such as "Portland, ME" where the region was picked in isolation
|
|
55
|
+
* before the locality was known.
|
|
56
|
+
* It leaves trees with a resolved locality untouched.
|
|
88
57
|
*/
|
|
89
58
|
export async function applyAdminCoherence(roots, backend) {
|
|
90
59
|
const visit = async (node, regionAncestor) => {
|
|
@@ -92,7 +61,7 @@ export async function applyAdminCoherence(roots, backend) {
|
|
|
92
61
|
if (regionHere &&
|
|
93
62
|
(node.tag === "locality" || node.tag === "dependent_locality") &&
|
|
94
63
|
!isResolvedWithCoord(node) &&
|
|
95
|
-
node.value.trim()
|
|
64
|
+
node.value.trim()) {
|
|
96
65
|
await reconcileAdminPair(regionHere, node, backend);
|
|
97
66
|
}
|
|
98
67
|
for (const child of node.children) {
|
|
@@ -103,24 +72,8 @@ export async function applyAdminCoherence(roots, backend) {
|
|
|
103
72
|
await visit(root, null);
|
|
104
73
|
}
|
|
105
74
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Re-pick a (region, locality) pair so the locality descends from the region. `alternatives` on the node are the
|
|
108
|
-
* `ResolvedPlace` runner-ups `decorateNode` attached (typed `unknown[]` in the decoder, which can't import resolver
|
|
109
|
-
* types — the cast is sound). Picks the FIRST same-named locality (already score-ordered) that descends from a
|
|
110
|
-
* same-named region candidate, then swaps both nodes. Leaves both untouched when no consistent pair exists (a genuinely
|
|
111
|
-
* un-gazetteered locality — "Portland, VT" with no Portland in Vermont — stays as the region centroid, not a foreign
|
|
112
|
-
* namesake).
|
|
113
|
-
*/
|
|
114
75
|
async function reconcileAdminPair(regionNode, localityNode, backend) {
|
|
115
|
-
// EXACT region matches only: the alternatives for a 2-letter token are loose ("ME" also surfaces
|
|
116
|
-
// Missouri/Michigan/Mississippi as fuzzy M-state runner-ups). Restricting to exact name/alias matches
|
|
117
|
-
// (Maine/Messina/Medway for "ME") keeps the join honest. `exactMatch` is stamped by exactMatchTiering.
|
|
118
76
|
const regionCands = (regionNode.alternatives ?? []).filter((r) => r.exactMatch);
|
|
119
|
-
// For each exact region candidate, ask the gazetteer directly: is there a same-named locality UNDER it?
|
|
120
|
-
// The `parentID` scope is the descendant test (over the #832-repaired ancestors table), and it finds the
|
|
121
|
-
// instance regardless of its global population rank — "Springfield, ME" reaches the small Springfield in
|
|
122
|
-
// Maine that an unscoped top-N window would drop. First region with an exact-named descendant wins; the
|
|
123
|
-
// region candidates are score-ordered, so a tie breaks toward the more prominent place.
|
|
124
77
|
for (const region of regionCands) {
|
|
125
78
|
const scoped = await backend.findPlace({
|
|
126
79
|
text: localityNode.value,
|
|
@@ -137,11 +90,6 @@ async function reconcileAdminPair(regionNode, localityNode, backend) {
|
|
|
137
90
|
return;
|
|
138
91
|
}
|
|
139
92
|
}
|
|
140
|
-
// #267 follow-up: the token may name a COUNTRY whose namesake is a more-populous foreign region — "Tbilisi,
|
|
141
|
-
// Georgia" parses region("Georgia") → the US state, but Tbilisi descends from Georgia the COUNTRY. When no
|
|
142
|
-
// region candidate holds the locality, try same-named country candidates: a foreign capital under its
|
|
143
|
-
// country out-votes the state namesake. Needs the country + the locality's ancestry in the gazetteer (the
|
|
144
|
-
// #267 admin fold). The re-picked region node then carries the country place; the locality coordinate wins.
|
|
145
93
|
const countryCands = (await backend.findPlace({ text: regionNode.value, placetype: "country", limit: 3 })).filter((c) => c.exactMatch);
|
|
146
94
|
for (const country of countryCands) {
|
|
147
95
|
const scoped = await backend.findPlace({
|
|
@@ -159,15 +107,6 @@ async function reconcileAdminPair(regionNode, localityNode, backend) {
|
|
|
159
107
|
return;
|
|
160
108
|
}
|
|
161
109
|
}
|
|
162
|
-
// #1023: the admin gazetteer may carry NO `country`-placetype node for the token AND the same-named
|
|
163
|
-
// foreign locality may be ORPHANED (parent_id = -1) — the 2026-07-07 rebuild flattened Georgia's admin
|
|
164
|
-
// hierarchy to localities-only, so the country-node lookup above finds nothing and the `parentID`
|
|
165
|
-
// descendant test can never reach Tbilisi. Fall back to matchCountry: normalize the token to an
|
|
166
|
-
// ISO-3166 alpha-2 and scope the locality by the gazetteer's `country` COLUMN (set even on an orphaned
|
|
167
|
-
// row). Same primitive reconcileExplicitCountry (#822) uses, so the region-parsed namesake path
|
|
168
|
-
// ("Tbilisi, Georgia") converges with the country-parsed one ("Vienna, Austria"). matchCountry returns
|
|
169
|
-
// null for a US state name/abbrev ("Illinois" / "ME" / "IL"), so a real US (region, locality) pair
|
|
170
|
-
// never reaches here — this stays inert on the domestic path.
|
|
171
110
|
const mc = matchCountry(regionNode.value);
|
|
172
111
|
if (mc) {
|
|
173
112
|
const scoped = await backend.findPlace({
|
|
@@ -180,21 +119,10 @@ async function reconcileAdminPair(regionNode, localityNode, backend) {
|
|
|
180
119
|
if (lc) {
|
|
181
120
|
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
182
121
|
localityNode.metadata = { ...localityNode.metadata, admin_coherence_repicked: true };
|
|
183
|
-
// The token named a foreign country the admin gazetteer has no node for, but the greedy walk had
|
|
184
|
-
// already decorated the region node with the US-state namesake. Revert that stale decoration so the
|
|
185
|
-
// node stops asserting the wrong-country coordinate + `resolver_country` (which would otherwise leak
|
|
186
|
-
// into the result's `countryCode`); the re-picked locality carries the winning coordinate, and the
|
|
187
|
-
// region node falls back to the parsed "Georgia" token, unresolved (the admin DB has nothing truer).
|
|
188
122
|
revertResolverDecoration(regionNode);
|
|
189
123
|
}
|
|
190
124
|
}
|
|
191
125
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Undo a resolver decoration on a node: restore the classifier attribution {@link decorateNode} displaced into
|
|
194
|
-
* `metadata.classifier_source(_id)` and drop the resolver-supplied coordinate/identity/alternatives. Used by the #1023
|
|
195
|
-
* country fall-through when the region token turns out to name a foreign country the admin gazetteer holds no node for
|
|
196
|
-
* — the greedy walk had bound it to the US-state namesake, and that stale claim must not survive the locality re-pick.
|
|
197
|
-
*/
|
|
198
126
|
function revertResolverDecoration(node) {
|
|
199
127
|
const meta = { ...node.metadata };
|
|
200
128
|
const priorSource = meta["classifier_source"];
|
|
@@ -211,7 +139,7 @@ function revertResolverDecoration(node) {
|
|
|
211
139
|
"resolution_quality",
|
|
212
140
|
"postcode_city_mismatch",
|
|
213
141
|
]) {
|
|
214
|
-
// oxlint-disable-next-line typescript/no-dynamic-delete -- removing one key from a plain record
|
|
142
|
+
// oxlint-disable-next-line typescript/no-dynamic-delete -- removing one key from a plain record. the object is not on a hot path
|
|
215
143
|
delete meta[key];
|
|
216
144
|
}
|
|
217
145
|
node.metadata = meta;
|
|
@@ -221,36 +149,16 @@ function revertResolverDecoration(node) {
|
|
|
221
149
|
node.alternatives = undefined;
|
|
222
150
|
}
|
|
223
151
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
* (Vienna WV) and IGNORES the "Austria" the address named. This pass asks the question the greedy order skipped —
|
|
227
|
-
* _which "Vienna" is in the country the address names?_ — and re-picks the locality to the same-named place under that
|
|
228
|
-
* country. The country code comes from the parser's OWN `country` emission via codex's ISO-3166 table (a name→code
|
|
229
|
-
* normalization of a token the model already classified, NOT a routing prior or safelist); the gazetteer's `country`
|
|
230
|
-
* column does the geographic confirmation. No pin, no list; generalizes to every country.
|
|
152
|
+
* Re-picks a locality to the place with the same name inside the country specified in
|
|
153
|
+
* the address, when that country is the locality's nearest admin context.
|
|
231
154
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* and then regardless of the locality's resolution state — so it covers both the resolved-but-foreign locality (Sydney
|
|
235
|
-
* → the greedy AU pick was wrong) and the unresolved locality the span-rescore tier would otherwise back-fill with the
|
|
236
|
-
* US namesake (Vienna → Vienna WV). Byte-stable when the locality already resolved in-country (the id guard) or the
|
|
237
|
-
* named country holds no same-named locality (the fail-safe — what also protects "Turkey, TX": no country token ⇒ no
|
|
238
|
-
* trigger; and an in-country lookup that finds nothing keeps the greedy result). Costs one country-scoped locality
|
|
239
|
-
* lookup per triggering pair. See `ResolveOpts.adminCoherence`.
|
|
155
|
+
* It leaves the locality unchanged when it already resolved to that place or
|
|
156
|
+
* when that country has no locality with the same name.
|
|
240
157
|
*/
|
|
241
158
|
export async function applyExplicitCountryCoherence(roots, backend) {
|
|
242
159
|
const visit = async (node, countryToken, regionAbove) => {
|
|
243
|
-
const countryHere = node.tag === "country" && node.value.trim()
|
|
244
|
-
// A region suppresses the country re-pick only when it RESOLVED: the suppression's rationale is
|
|
245
|
-
// that applyAdminCoherence + the region's `parentID` scope already disambiguate the locality
|
|
246
|
-
// ("Springfield, IL" must not re-pick to the most populous US Springfield), and an UNRESOLVED
|
|
247
|
-
// region disambiguates nothing — 'NIC-38' (an ISO-3166-2 code the gazetteer holds no node for)
|
|
248
|
-
// silently swallowed the explicit 'Nicaragua', and El Sauce resolved a US namesake. This pass
|
|
249
|
-
// runs post-walk, so resolution state is known.
|
|
160
|
+
const countryHere = node.tag === "country" && node.value.trim() ? node : countryToken;
|
|
250
161
|
const regionHere = regionAbove || ((node.tag === "region" || node.tag === "subregion") && isResolvedWithCoord(node));
|
|
251
|
-
// Fire only when the explicit country is the locality's NEAREST RESOLVED admin context.
|
|
252
|
-
// Fires regardless of the locality's resolution state, so it PRE-EMPTS the span-rescore tier
|
|
253
|
-
// (which would otherwise back-fill the unresolved locality with the US namesake).
|
|
254
162
|
if (countryHere && !regionHere && (node.tag === "locality" || node.tag === "dependent_locality")) {
|
|
255
163
|
await reconcileExplicitCountry(countryHere, node, backend);
|
|
256
164
|
}
|
|
@@ -262,15 +170,6 @@ export async function applyExplicitCountryCoherence(roots, backend) {
|
|
|
262
170
|
await visit(root, null, false);
|
|
263
171
|
}
|
|
264
172
|
}
|
|
265
|
-
/**
|
|
266
|
-
* Re-pick a resolved locality to its same-named place UNDER the explicitly-named country. `matchCountry` turns the
|
|
267
|
-
* country token into an ISO-3166 alpha-2 (returns null for an unrecognized token → no-op); the backend then surfaces
|
|
268
|
-
* the in-country namesake the population-first unscoped window buried. Leaves the node untouched when the country is
|
|
269
|
-
* unrecognized, the named country has no exact same-named locality (the fail-safe), or the locality already resolved to
|
|
270
|
-
* that place (the id guard → byte-stable). The country node itself stays as the parser emitted it — the named
|
|
271
|
-
* well-covered countries carry no `country`-placetype row in the admin gazetteer, so there is nothing to decorate it
|
|
272
|
-
* with; the locality coordinate is what the re-pick fixes.
|
|
273
|
-
*/
|
|
274
173
|
async function reconcileExplicitCountry(countryNode, localityNode, backend) {
|
|
275
174
|
const mc = matchCountry(countryNode.value);
|
|
276
175
|
if (!mc)
|
|
@@ -284,52 +183,27 @@ async function reconcileExplicitCountry(countryNode, localityNode, backend) {
|
|
|
284
183
|
const lc = scoped.find((l) => l.exactMatch && !(l.lat === 0 && l.lon === 0));
|
|
285
184
|
if (!lc)
|
|
286
185
|
return;
|
|
287
|
-
// Already the in-country place? (placeID encodes the WOF id.) Then the greedy walk was right — byte-stable.
|
|
288
186
|
if (localityNode.placeID === `wof:${lc.id}`)
|
|
289
187
|
return;
|
|
290
188
|
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
291
189
|
localityNode.metadata = { ...localityNode.metadata, explicit_country_repicked: true };
|
|
292
190
|
}
|
|
293
191
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* and disjoint from {@link applyAdminCoherence} (which needs a region that DID resolve): this pass owns the mirror case,
|
|
297
|
-
* where the region qualifier is a foreign subdivision the default-country hard filter (`spr.country = ?`) discarded.
|
|
192
|
+
* Re-picks the region and locality into a foreign country when the region token is that
|
|
193
|
+
* country's subdivision and the default-country filter left it unresolved.
|
|
298
194
|
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
* redirect the country to CA — and the locality "Montreal" is force-matched to the populous US namesake (Montreal, WI).
|
|
302
|
-
* The greedy order threw away the evidence that could correct it.
|
|
303
|
-
*
|
|
304
|
-
* The fix expands the region token to its country via codex's ISO-3166-2 subdivision table (`matchSubdivision`: "QC" →
|
|
305
|
-
* `{ name: "Quebec", country: "CA" }`, handling the FTS index's missing "QC" alt-name code-side), then asks the two
|
|
306
|
-
* questions the greedy walk skipped: does that subdivision genuinely resolve UNDER its own country, and is there a
|
|
307
|
-
* same-named locality under it? Only when BOTH hold does it swap the region and locality to the in-country pair.
|
|
308
|
-
* Geography confirms; the subdivision table is a soft name→country prior, not a routing decision.
|
|
309
|
-
*
|
|
310
|
-
* Evidence-conditional to stay byte-stable on the domestic path. It fires ONLY when (a) a default country is in force,
|
|
311
|
-
* (b) the region node is UNRESOLVED (the default-country filter came up empty — a US region resolves fine under `US`,
|
|
312
|
-
* so a well-formed US query never trips this), (c) the token is a subdivision of a DIFFERENT country than the default,
|
|
313
|
-
* and (d) both the foreign region and a same-named foreign locality resolve. "Springfield, IL" / "Portland, ME": the
|
|
314
|
-
* region resolves under `US`, so check (b) fails and the tree is untouched. Costs one region + one locality lookup per
|
|
315
|
-
* triggering pair. See `ResolveOpts.adminCoherence`.
|
|
195
|
+
* Both the foreign region and a locality with the same name under that country must resolve,
|
|
196
|
+
* so domestic queries whose region resolves are never changed.
|
|
316
197
|
*/
|
|
317
198
|
export async function applyRegionCountryCoherence(roots, backend, defaultCountry) {
|
|
318
|
-
// No default country → no hard country filter was applied, so no region qualifier was discarded by one. The bug
|
|
319
|
-
// this pass corrects is specific to the locale-inferred default country; without it, there is nothing to rescue.
|
|
320
199
|
if (!defaultCountry)
|
|
321
200
|
return;
|
|
322
201
|
const visit = async (node, regionAncestor) => {
|
|
323
|
-
// Track the nearest region ancestor regardless of its resolution state (the trigger is an UNRESOLVED region).
|
|
324
202
|
const regionHere = node.tag === "region" || node.tag === "subregion" ? node : regionAncestor;
|
|
325
|
-
// Fire for an UNRESOLVED region (the default-country filter came up empty) whose companion locality node
|
|
326
|
-
// exists — regardless of the locality's resolution state, so it covers both the resolved-but-foreign namesake
|
|
327
|
-
// (Montreal → the greedy US pick, Montreal WI) and the unresolved locality the span-rescore tier would
|
|
328
|
-
// otherwise back-fill with a US namesake. The in-country lookups below are the evidence check.
|
|
329
203
|
if (regionHere &&
|
|
330
204
|
!isResolvedWithCoord(regionHere) &&
|
|
331
205
|
(node.tag === "locality" || node.tag === "dependent_locality") &&
|
|
332
|
-
node.value.trim()
|
|
206
|
+
node.value.trim()) {
|
|
333
207
|
await reconcileRegionCountry(regionHere, node, backend, defaultCountry);
|
|
334
208
|
}
|
|
335
209
|
for (const child of node.children) {
|
|
@@ -340,28 +214,15 @@ export async function applyRegionCountryCoherence(roots, backend, defaultCountry
|
|
|
340
214
|
await visit(root, null);
|
|
341
215
|
}
|
|
342
216
|
}
|
|
343
|
-
/**
|
|
344
|
-
* Re-pick an (unresolved region, resolved-but-foreign-namesake locality) pair to the in-country instance the
|
|
345
|
-
* default-country filter hid. `matchSubdivision` turns the region token into `{ name, country }` (null for anything
|
|
346
|
-
* that isn't a US state or CA province → no-op); the region's full name then resolves it under that country (expanding
|
|
347
|
-
* the abbreviation the gazetteer FTS index lacks), and the locality is re-scoped to the same country. Leaves both nodes
|
|
348
|
-
* untouched unless every check holds — the subdivision names a different country than the default, the region resolves
|
|
349
|
-
* under it, and a same-named locality exists there — so the domestic path stays byte-identical.
|
|
350
|
-
*/
|
|
351
217
|
async function reconcileRegionCountry(regionNode, localityNode, backend, defaultCountry) {
|
|
352
218
|
const sub = matchSubdivision(regionNode.value);
|
|
353
219
|
if (!sub)
|
|
354
220
|
return;
|
|
355
|
-
// The subdivision must belong to a DIFFERENT country than the locale default. A US-state token under a US default
|
|
356
|
-
// (sub.country === defaultCountry) never reaches the swap — the pass is inert on the domestic path.
|
|
357
221
|
if (sub.country.toUpperCase() === defaultCountry.toUpperCase())
|
|
358
222
|
return;
|
|
359
|
-
// The locality already resolved in the subdivision's country? Then the greedy walk was already right — byte-stable.
|
|
360
223
|
const localityCountry = localityNode.metadata?.["resolver_country"]?.toUpperCase();
|
|
361
224
|
if (localityCountry === sub.country.toUpperCase())
|
|
362
225
|
return;
|
|
363
|
-
// Confirm the subdivision genuinely resolves under its own country, by its full name (expands "QC" → "Quebec", the
|
|
364
|
-
// form the FTS index carries). No resolvable region → no evidence the token is a real foreign subdivision; abstain.
|
|
365
226
|
const regionScoped = await backend.findPlace({
|
|
366
227
|
text: sub.name,
|
|
367
228
|
placetype: "region",
|
|
@@ -371,8 +232,6 @@ async function reconcileRegionCountry(regionNode, localityNode, backend, default
|
|
|
371
232
|
const rc = regionScoped.find((r) => r.exactMatch && !(r.lat === 0 && r.lon === 0));
|
|
372
233
|
if (!rc)
|
|
373
234
|
return;
|
|
374
|
-
// Is there a same-named locality under that country? (the descendant test, by country column — the same primitive
|
|
375
|
-
// reconcileExplicitCountry uses.) No in-country namesake → keep the greedy result (fail-safe).
|
|
376
235
|
const scoped = await backend.findPlace({
|
|
377
236
|
text: localityNode.value,
|
|
378
237
|
placetype: "locality",
|
|
@@ -382,7 +241,6 @@ async function reconcileRegionCountry(regionNode, localityNode, backend, default
|
|
|
382
241
|
const lc = scoped.find((l) => l.exactMatch && !(l.lat === 0 && l.lon === 0));
|
|
383
242
|
if (!lc)
|
|
384
243
|
return;
|
|
385
|
-
// Adopt the in-country pair: the region gets the foreign subdivision, the locality its same-named foreign instance.
|
|
386
244
|
decorateNode(regionNode, rc, regionScoped.filter((r) => r !== rc));
|
|
387
245
|
regionNode.metadata = { ...regionNode.metadata, region_country_repicked: true };
|
|
388
246
|
decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coherence-passes.js","sourceRoot":"","sources":["../../lib/admin/co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). The candidate backend partitions its row set
|
|
9
|
-
* before the limit window (so a contained candidate can reach the walk at all), and the resolver
|
|
10
|
-
* walk partitions AGAIN after its fame/anchor re-ranks (so `rankByImportance` cannot hand the top
|
|
11
|
-
* slot back to a more-famous uncontained namesake — Richmond VA outscores Richmond, North
|
|
12
|
-
* Yorkshire on importance, and without the second partition the change loses exactly where fame
|
|
13
|
-
* disagrees with the qualifier). Two call sites, one function, one ordering.
|
|
6
|
+
* Both decision sites call this ordering function.
|
|
7
|
+
* The candidate backend partitions rows before the limit window. The resolver walk partitions again after fame and anchor re-ranking.
|
|
14
8
|
*/
|
|
15
9
|
import { type AddressNode } from "@mailwoman/core/decoder";
|
|
16
10
|
/**
|
|
17
|
-
* Find the first non-empty region-tagged span anywhere in a tree — the qualifier the
|
|
18
|
-
* lookups
|
|
19
|
-
*
|
|
20
|
-
* the parser mislabeled ("Moscow, Russia" parses region="Russia") — the backend's qualifier probe answers that too,
|
|
21
|
-
* because containment is containment whatever tier the container sits at.
|
|
11
|
+
* Find the first non-empty region-tagged span anywhere in a tree — the qualifier the
|
|
12
|
+
* walk threads onto locality lookups, deliberately the same node the admin-coherence
|
|
13
|
+
* verdicts read so the two populations coincide.
|
|
22
14
|
*/
|
|
23
|
-
export declare function firstRegionQualifier(roots: readonly AddressNode[]): string |
|
|
15
|
+
export declare function firstRegionQualifier(roots: readonly AddressNode[]): string | null;
|
|
24
16
|
/**
|
|
25
|
-
* Stable,
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* splits the population exactly as `rankWithinTier`'s tri-state rule does, only a stated exact tier earns the front),
|
|
29
|
-
* positive-evidence-only (only a stated `true` moves a row; `false` and "never evaluated" both hold their incoming
|
|
30
|
-
* rank, so an incapable backend is a no-op by construction), and stable (the backend's own ordering survives within
|
|
31
|
-
* each (tier, containment) cell).
|
|
32
|
-
*
|
|
33
|
-
* Implemented with the slot idiom (`reorderMeasured`'s mechanics): each tier's members permute only among the positions
|
|
34
|
-
* that tier already occupies, so a tier-interleaved list — the walk's no-importance path never regrouped tiers — cannot
|
|
35
|
-
* have a rest-tier row promoted across an exact-tier boundary by this partition.
|
|
17
|
+
* Stable, tier-safe, positive-evidence-only partition: within each match tier,
|
|
18
|
+
* candidates vouched for by the containment source (`isContained`) move ahead of the others.
|
|
19
|
+
* Both groups keep their incoming relative order.
|
|
36
20
|
*/
|
|
37
21
|
export declare function partitionByContainment<T>(rows: readonly T[], isContained: (row: T) => boolean, isExact: (row: T) => boolean): T[];
|
|
38
22
|
/**
|
|
39
|
-
* The trace verdict for one locality pick
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* no stamps at all → `"unavailable"` (the backend or artifact cannot answer — a pre-sidecar candidate.db, the FTS or
|
|
43
|
-
* browser backend, or a qualifier the probe never ran for).
|
|
23
|
+
* The trace verdict for one locality pick, stamped as `metadata.admin_containment`:
|
|
24
|
+
* any `true` → `"contained"`; stamps present but none true → `"no_contained_candidate"`;
|
|
25
|
+
* no stamps at all → `"unavailable"`.
|
|
44
26
|
*/
|
|
45
27
|
export declare function adminContainmentVerdict(candidates: ReadonlyArray<{
|
|
46
|
-
containedByQualifier?: boolean |
|
|
28
|
+
containedByQualifier?: boolean | null;
|
|
47
29
|
}>): "contained" | "no_contained_candidate" | "unavailable";
|
|
48
30
|
//# sourceMappingURL=containment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../lib/admin/containment.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../lib/admin/containment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1E;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,CAEjF;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,EAChC,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAC1B,CAAC,EAAE,CAuBL;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,aAAa,CAAC;IAAE,oBAAoB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAC,GAClE,WAAW,GAAG,wBAAwB,GAAG,aAAa,CAYxD"}
|
package/out/admin/containment.js
CHANGED
|
@@ -3,38 +3,22 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* exactly the points a constant cannot express). The candidate backend partitions its row set
|
|
9
|
-
* before the limit window (so a contained candidate can reach the walk at all), and the resolver
|
|
10
|
-
* walk partitions AGAIN after its fame/anchor re-ranks (so `rankByImportance` cannot hand the top
|
|
11
|
-
* slot back to a more-famous uncontained namesake — Richmond VA outscores Richmond, North
|
|
12
|
-
* Yorkshire on importance, and without the second partition the change loses exactly where fame
|
|
13
|
-
* disagrees with the qualifier). Two call sites, one function, one ordering.
|
|
6
|
+
* Both decision sites call this ordering function.
|
|
7
|
+
* The candidate backend partitions rows before the limit window. The resolver walk partitions again after fame and anchor re-ranking.
|
|
14
8
|
*/
|
|
15
9
|
import { firstNodeWhere } from "@mailwoman/core/decoder";
|
|
16
10
|
/**
|
|
17
|
-
* Find the first non-empty region-tagged span anywhere in a tree — the qualifier the
|
|
18
|
-
* lookups
|
|
19
|
-
*
|
|
20
|
-
* the parser mislabeled ("Moscow, Russia" parses region="Russia") — the backend's qualifier probe answers that too,
|
|
21
|
-
* because containment is containment whatever tier the container sits at.
|
|
11
|
+
* Find the first non-empty region-tagged span anywhere in a tree — the qualifier the
|
|
12
|
+
* walk threads onto locality lookups, deliberately the same node the admin-coherence
|
|
13
|
+
* verdicts read so the two populations coincide.
|
|
22
14
|
*/
|
|
23
15
|
export function firstRegionQualifier(roots) {
|
|
24
|
-
return firstNodeWhere(roots, (n) => n.tag === "region" && n.value.trim()
|
|
16
|
+
return firstNodeWhere(roots, (n) => n.tag === "region" && n.value.trim())?.value.trim() ?? null;
|
|
25
17
|
}
|
|
26
18
|
/**
|
|
27
|
-
* Stable,
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* splits the population exactly as `rankWithinTier`'s tri-state rule does, only a stated exact tier earns the front),
|
|
31
|
-
* positive-evidence-only (only a stated `true` moves a row; `false` and "never evaluated" both hold their incoming
|
|
32
|
-
* rank, so an incapable backend is a no-op by construction), and stable (the backend's own ordering survives within
|
|
33
|
-
* each (tier, containment) cell).
|
|
34
|
-
*
|
|
35
|
-
* Implemented with the slot idiom (`reorderMeasured`'s mechanics): each tier's members permute only among the positions
|
|
36
|
-
* that tier already occupies, so a tier-interleaved list — the walk's no-importance path never regrouped tiers — cannot
|
|
37
|
-
* have a rest-tier row promoted across an exact-tier boundary by this partition.
|
|
19
|
+
* Stable, tier-safe, positive-evidence-only partition: within each match tier,
|
|
20
|
+
* candidates vouched for by the containment source (`isContained`) move ahead of the others.
|
|
21
|
+
* Both groups keep their incoming relative order.
|
|
38
22
|
*/
|
|
39
23
|
export function partitionByContainment(rows, isContained, isExact) {
|
|
40
24
|
const out = [...rows];
|
|
@@ -56,18 +40,16 @@ export function partitionByContainment(rows, isContained, isExact) {
|
|
|
56
40
|
return out;
|
|
57
41
|
}
|
|
58
42
|
/**
|
|
59
|
-
* The trace verdict for one locality pick
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* no stamps at all → `"unavailable"` (the backend or artifact cannot answer — a pre-sidecar candidate.db, the FTS or
|
|
63
|
-
* browser backend, or a qualifier the probe never ran for).
|
|
43
|
+
* The trace verdict for one locality pick, stamped as `metadata.admin_containment`:
|
|
44
|
+
* any `true` → `"contained"`; stamps present but none true → `"no_contained_candidate"`;
|
|
45
|
+
* no stamps at all → `"unavailable"`.
|
|
64
46
|
*/
|
|
65
47
|
export function adminContainmentVerdict(candidates) {
|
|
66
48
|
let evaluated = false;
|
|
67
49
|
for (const candidate of candidates) {
|
|
68
50
|
if (candidate.containedByQualifier === true)
|
|
69
51
|
return "contained";
|
|
70
|
-
if (candidate.containedByQualifier
|
|
52
|
+
if (candidate.containedByQualifier != null) {
|
|
71
53
|
evaluated = true;
|
|
72
54
|
}
|
|
73
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containment.js","sourceRoot":"","sources":["../../lib/admin/containment.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"containment.js","sourceRoot":"","sources":["../../lib/admin/containment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAoB,MAAM,yBAAyB,CAAA;AAE1E;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA6B;IACjE,OAAO,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,IAAI,CAAA;AAChG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACrC,IAAkB,EAClB,WAAgC,EAChC,OAA4B;IAE5B,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IAErB,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAa,EAAE,CAAA;QAE1B,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,S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
|
*
|
|
7
|
-
* The JP model tags `神戸市西区` (city
|
|
8
|
-
* the postal form
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* The JP model tags `神戸市西区` (city plus ward) and `猿島郡五霞町` (county plus town) as one
|
|
8
|
+
* `municipality` span. This matches the postal form. WOF keys the city, ward and town separately.
|
|
9
|
+
* A whole-span probe misses, so the coordinate falls to the prefecture centroid. The JP board records
|
|
10
|
+
* errors of 25–52 km. An unscoped probe of the trailing unit performs worse. A bare `西区` resolves to a
|
|
11
|
+
* namesake ward in another city. In the test, Kobe's query resolves to Fukuoka, 407 km away.
|
|
12
|
+
* The split scores 251 of 300 rows, compared with 271 for the whole-span probe. The resolver uses the
|
|
13
|
+
* head and tail as a scoped pair. It resolves the head first, then probes the tail as its child.
|
|
14
|
+
* Candidate matching stays within the head scope.
|
|
13
15
|
*/
|
|
14
16
|
export interface CompoundMunicipality {
|
|
15
17
|
/**
|
|
@@ -27,22 +29,27 @@ export interface CompoundMunicipality {
|
|
|
27
29
|
*/
|
|
28
30
|
export declare function compoundMunicipality(value: string): CompoundMunicipality | null;
|
|
29
31
|
/**
|
|
30
|
-
* One probe of the gazetteer as the walk makes it: `value` under `scope`,
|
|
32
|
+
* One probe of the gazetteer as the walk makes it: `value` under `scope`,
|
|
33
|
+
* with the parent fallback allowed or withheld.
|
|
31
34
|
*/
|
|
32
35
|
export type CompoundMunicipalityProbe<Place, Pick extends {
|
|
33
36
|
top: Place;
|
|
34
37
|
metadata?: Record<string, unknown>;
|
|
35
38
|
}> = (value: string, scope: Place | null, parentFallback: boolean) => Promise<Pick | null>;
|
|
36
39
|
/**
|
|
37
|
-
* A compound municipality probed as a
|
|
38
|
-
* with the walk's ordinary fallback, then the tail as the head's child with
|
|
39
|
-
* ward or town outside the head is never admissible
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* A compound municipality probed as a scoped pair after the whole span missed: the head under the
|
|
41
|
+
* node's own parent with the walk's ordinary fallback, then the tail as the head's child with
|
|
42
|
+
* the parent fallback withheld, so a namesake ward or town outside the head is never admissible,
|
|
43
|
+
* including one the backend re-admits through its own region-scope fallback (`regionScopeMiss`).
|
|
44
|
+
*
|
|
45
|
+
* A county head usually has no key.
|
|
46
|
+
* The tail then probes under the parent the walk already holds.
|
|
47
|
+
* Answers the tail when it hits, else the head, else null.
|
|
48
|
+
*
|
|
49
|
+
* Two probes at most, each drawn from the caller's budget (`hasBudget`).
|
|
43
50
|
*/
|
|
44
51
|
export declare function resolveCompoundMunicipality<Place extends {
|
|
45
|
-
regionScopeMiss?: boolean;
|
|
52
|
+
regionScopeMiss?: boolean | null;
|
|
46
53
|
}, Pick extends {
|
|
47
54
|
top: Place;
|
|
48
55
|
metadata?: Record<string, unknown>;
|