@mailwoman/resolver 8.1.0 → 8.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.
@@ -0,0 +1,415 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The street-level coordinate tiers, in cascade order: exact address point (#476), house-number
7
+ * interpolation (#483), then the street-centroid fallback. Each answers WHERE, never WHICH PLACE —
8
+ * they stamp a coordinate onto the STREET node's metadata and never touch admin resolution.
9
+ *
10
+ * Split out of `resolve.ts` so the resolver file holds the walk and the admin-coherence passes, and
11
+ * this one holds the tiers. The FR voie-type folding lives here because only the street-centroid
12
+ * tier consults it.
13
+ */
14
+ import { isStreetDirectionalToken } from "@mailwoman/codex/us";
15
+ import { haversineKm } from "@mailwoman/spatial";
16
+ import { foldName } from "./fold-name.js";
17
+ /**
18
+ * Street-name component tags that, with the street node itself, reconstruct the full street string.
19
+ */
20
+ const STREET_NAME_TAGS = new Set(["street", "street_prefix", "street_prefix_particle", "street_suffix"]);
21
+ /**
22
+ * Reassemble the full street string from the street node's subtree (#483 coverage fix). The parser nests the
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
25
+ * normalized name. Collect street + its prefix/particle/suffix descendants (NOT house_number/unit, which also nest
26
+ * under street), order by span offset, and join.
27
+ */
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
+ }
38
+ // #718 admin-tail: a directional quadrant the model mis-tagged `unit` ("1532 Taylor Street NE" →
39
+ // [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
41
+ // only — the parse output and admin resolution are untouched. Byte-stable when absent (undefined).
42
+ if (directionalUnit && directionalUnit.value.trim()) {
43
+ parts.push(directionalUnit);
44
+ }
45
+ parts.sort((a, b) => a.start - b.start);
46
+ return parts.map((n) => n.value.trim()).join(" ");
47
+ }
48
+ /**
49
+ * Directional quadrant values the model sometimes emits as a `unit` node instead of inside the street subtree (#718
50
+ * admin-tail diagnostic: ~19% of the admin-fallback tail, 83% of DC). Folded into the street lookup key by
51
+ * {@link assembleStreetValue}; the situs/interp lookup normalizer expands the abbreviation ("ne" → "northeast") so the
52
+ * shard's full street name matches.
53
+ */
54
+ // The 8 USPS cardinals/intercardinals (abbrev or name) — @codex/us owns the canonical table (#215).
55
+ const isDirectionalUnit = (value) => isStreetDirectionalToken(value.replaceAll(".", ""));
56
+ /**
57
+ * Address-point tier (#476): find `street` + `house_number` in the tree (first occurrence, depth-first), scope by the
58
+ * tree's postcode/locality values, and on an exact hit stamp the point onto the STREET node's metadata. Additive only —
59
+ * admin resolution is never altered.
60
+ */
61
+ /**
62
+ * Half-width (degrees) of the bbox derived from a resolved locality centroid for the #247 OSM bbox fall-through. ~0.25°
63
+ * ≈ 28 km N–S — generous enough for a large metro whose centroid sits off the queried point, while the EXACT `(street,
64
+ * number)` match keeps a cross-commune collision rare. The proper fix is per-point scope backfill (the OSM association
65
+ * / point-in-polygon pass, #250); this is the coverage stopgap until then.
66
+ */
67
+ 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();
90
+ }
91
+ if (n.tag === "postcode" && !postcode && n.value.trim()) {
92
+ postcode = n.value.trim();
93
+ }
94
+ stack.push(...n.children);
95
+ }
96
+ if (!street || !houseNumber)
97
+ return;
98
+ // #247 OSM bbox fall-through: when enabled (an OSM shard is wired) and the locality resolved to a
99
+ // coordinate, scope a final `(street, number)` probe by the locality's box — recovering OSM points that
100
+ // carry no postcode/locality tag of their own. US situs never enables it, so its probes are byte-identical.
101
+ let bbox;
102
+ if (bboxFallback && localityNode?.lat != null && localityNode.lon != null) {
103
+ bbox = {
104
+ minLat: localityNode.lat - LOCALITY_BBOX_RADIUS_DEG,
105
+ maxLat: localityNode.lat + LOCALITY_BBOX_RADIUS_DEG,
106
+ minLon: localityNode.lon - LOCALITY_BBOX_RADIUS_DEG,
107
+ maxLon: localityNode.lon + LOCALITY_BBOX_RADIUS_DEG,
108
+ };
109
+ }
110
+ const hit = lookup.find({
111
+ street: assembleStreetValue(street, directionalUnit),
112
+ number: houseNumber.value,
113
+ postcode,
114
+ locality,
115
+ bbox,
116
+ });
117
+ if (!hit)
118
+ return;
119
+ street.metadata = {
120
+ ...street.metadata,
121
+ address_point: { lat: hit.lat, lon: hit.lon, source: hit.source, release: hit.release },
122
+ resolution_tier: "address_point",
123
+ };
124
+ }
125
+ /**
126
+ * House-number interpolation tier (#483): the third rung, consulted ONLY when the exact address-point tier
127
+ * ({@link applyAddressPoint}) did NOT already stamp the street node (`resolution_tier === "address_point"`). That gate
128
+ * IS the "after the exact-point fall-through" — an estimate never overwrites a real situs point. Postcode-scoped (no
129
+ * locality — the interpolators abstain statewide without a postcode). Stamps a DISTINCT metadata key
130
+ * (`interpolated_point`, never `address_point`). Additive only — admin resolution is untouched.
131
+ */
132
+ export function applyInterpolation(roots, lookup, radiusCalibration) {
133
+ let street;
134
+ let houseNumber;
135
+ let directionalUnit;
136
+ let postcode;
137
+ const stack = [...roots];
138
+ while (stack.length) {
139
+ const n = stack.pop();
140
+ if (n.tag === "street" && !street) {
141
+ street = n;
142
+ }
143
+ if (n.tag === "house_number" && !houseNumber) {
144
+ houseNumber = n;
145
+ }
146
+ if (n.tag === "unit" && !directionalUnit && isDirectionalUnit(n.value)) {
147
+ directionalUnit = n;
148
+ }
149
+ if (n.tag === "postcode" && !postcode && n.value.trim()) {
150
+ postcode = n.value.trim();
151
+ }
152
+ stack.push(...n.children);
153
+ }
154
+ if (!street || !houseNumber)
155
+ return;
156
+ // The fall-through gate: an exact situs point already won — never override it with an estimate.
157
+ if (street.metadata?.["resolution_tier"] === "address_point")
158
+ return;
159
+ const hit = lookup.find({ street: assembleStreetValue(street, directionalUnit), number: houseNumber.value, postcode });
160
+ if (!hit)
161
+ return;
162
+ // Conformal-calibrated radius (#374): the raw half-segment heuristic underestimates the true spread
163
+ // (~72% coverage on Travis); ×1.70 → a 90% bound. The ARTIFACT's own multiplier (read from the shard's
164
+ // `interp_calibration` metadata table at open time — `lookup.radiusCalibration`) is the default; an
165
+ // explicit caller factor is the @internal instrument override. Neither present (shards predating the
166
+ // metadata table, no caller factor) keeps the raw value, byte-stable. Preserve the raw radius for
167
+ // transparency.
168
+ const factor = radiusCalibration ?? lookup.radiusCalibration;
169
+ const calibrated = factor ? Math.round(hit.uncertaintyM * factor) : hit.uncertaintyM;
170
+ street.metadata = {
171
+ ...street.metadata,
172
+ interpolated_point: { lat: hit.lat, lon: hit.lon, source: hit.source, release: hit.release },
173
+ resolution_tier: "interpolated",
174
+ uncertainty_m: calibrated,
175
+ ...(factor ? { uncertainty_raw_m: hit.uncertaintyM, uncertainty_calibration: factor } : {}),
176
+ interpolation_method: hit.method,
177
+ ...(hit.parityMatched !== undefined ? { parity_matched: hit.parityMatched } : {}),
178
+ ...(hit.bracket !== undefined ? { interpolation_bracket: hit.bracket } : {}),
179
+ };
180
+ }
181
+ /**
182
+ * French thoroughfare (voie) type tokens — the leading word that marks a street-only span as a THOROUGHFARE rather than
183
+ * a place name ("Place Bellecour", "Cours de l'Intendance", "Quai des Bateliers"). Used by the #1042 street-centroid
184
+ * tier to recognize a thoroughfare that the model mis-parsed as a `locality` (the FR no-street class, #901).
185
+ * Deliberately generous — a false positive simply misses the exact street-centroid lookup and no-ops; the lookup is the
186
+ * real gate.
187
+ */
188
+ const FR_VOIE_TYPES = new Set([
189
+ "rue",
190
+ "ruelle",
191
+ "venelle",
192
+ "avenue",
193
+ "av",
194
+ "ave",
195
+ "boulevard",
196
+ "bd",
197
+ "bld",
198
+ "bvd",
199
+ "boul",
200
+ "place",
201
+ "pl",
202
+ "cours",
203
+ "quai",
204
+ "impasse",
205
+ "imp",
206
+ "allee",
207
+ "all",
208
+ "chemin",
209
+ "ch",
210
+ "che",
211
+ "passage",
212
+ "pas",
213
+ "square",
214
+ "sq",
215
+ "faubourg",
216
+ "fg",
217
+ "fbg",
218
+ "route",
219
+ "rte",
220
+ "esplanade",
221
+ "promenade",
222
+ "sentier",
223
+ "sente",
224
+ "villa",
225
+ "cite",
226
+ "hameau",
227
+ "montee",
228
+ "chaussee",
229
+ "traverse",
230
+ "mail",
231
+ "clos",
232
+ "voie",
233
+ "quartier",
234
+ "lotissement",
235
+ "residence",
236
+ "rond",
237
+ ]);
238
+ /**
239
+ * Fold to lower-case, diacritic-stripped, punctuation-free tokens — mirrors `street-normalize.ts`'s `fold`.
240
+ */
241
+ function foldVoieTokens(s) {
242
+ return s
243
+ .normalize("NFKD")
244
+ .replaceAll(/[̀-ͯ]/g, "")
245
+ .toLowerCase()
246
+ .replaceAll(/[.,'’]/g, "")
247
+ .replaceAll("-", " ")
248
+ .split(/\s+/)
249
+ .filter(Boolean);
250
+ }
251
+ /**
252
+ * Does a string START with a French thoroughfare type token ("Rue …", "Place …")?
253
+ */
254
+ function isVoieShaped(s) {
255
+ const first = foldVoieTokens(s)[0];
256
+ return first !== undefined && FR_VOIE_TYPES.has(first);
257
+ }
258
+ /**
259
+ * Push `v` (trimmed, non-empty, deduped, capped) onto `list`.
260
+ */
261
+ function pushCandidate(list, v, cap) {
262
+ const t = v?.trim();
263
+ if (t && list.length < cap && !list.includes(t)) {
264
+ list.push(t);
265
+ }
266
+ }
267
+ /**
268
+ * Street-centroid tier (#1042): the street-level rung BELOW the exact/interpolation tiers and ABOVE admin-centroid
269
+ * resolution. For a STREET-ONLY query (a thoroughfare with NO house number), stamp the street's centroid onto a
270
+ * `street` node so a consumer gets a street-level coordinate instead of the commune centroid (or a wrong namesake).
271
+ *
272
+ * The FR no-street class mis-parses the thoroughfare — "Place Bellecour, Lyon" parses `region=Lyon`, `locality="Place
273
+ * Bellecour"`; "Avenue des Champs-Élysées" truncates — so this recovers the thoroughfare + commune RAW-TEXT-first (the
274
+ * same substrate as span-rescore), preferring parsed nodes and falling back to the comma-split raw query. A
275
+ * thoroughfare is recognized by its leading voie type ({@link isVoieShaped}); the commune is any non-voie span. Every
276
+ * (thoroughfare, commune) pair is probed against the exact street-centroid lookup, first hit wins — a false candidate
277
+ * simply misses. Additive only: fires ONLY when no house number is present (rooftop tiers untouched) and no
278
+ * street-level coordinate already resolved, and never alters admin resolution.
279
+ */
280
+ export function applyStreetCentroid(roots, raw, provider, hints) {
281
+ let streetNode;
282
+ let houseNumber = false;
283
+ let postcode;
284
+ const adminValues = []; // region / locality values, in tree order (thoroughfare and commune both hide here)
285
+ const resolvedCountries = []; // countries the tree actually resolved to — a post-resolution country hint
286
+ const stack = [...roots];
287
+ while (stack.length) {
288
+ const n = stack.pop();
289
+ if (n.tag === "house_number") {
290
+ houseNumber = true;
291
+ }
292
+ if (n.tag === "street" && !streetNode) {
293
+ streetNode = n;
294
+ }
295
+ // Never shadow a real street-level coordinate the exact/interp tiers already stamped.
296
+ if (n.metadata?.["resolution_tier"] === "address_point" || n.metadata?.["resolution_tier"] === "interpolated") {
297
+ return;
298
+ }
299
+ if (!postcode && n.tag === "postcode" && n.value.trim()) {
300
+ postcode = n.value.trim();
301
+ }
302
+ if ((n.tag === "region" || n.tag === "locality" || n.tag === "dependent_locality") && n.value.trim()) {
303
+ adminValues.push(n.value.trim());
304
+ }
305
+ const rc = n.metadata?.["resolver_country"]?.trim().toLowerCase();
306
+ if (rc && !resolvedCountries.includes(rc)) {
307
+ resolvedCountries.push(rc);
308
+ }
309
+ stack.push(...n.children);
310
+ }
311
+ if (houseNumber)
312
+ return; // street-only tier — a numbered address is the rooftop tiers' job
313
+ // Candidate countries: pre-resolution hints (defaultCountry + ungated placer) then the resolved countries. BAN is
314
+ // FR-only, so a non-FR candidate simply yields no lookup; the exact (street, base-commune) match is the real filter.
315
+ const countries = [];
316
+ for (const c of [...hints, ...resolvedCountries]) {
317
+ const cc = c?.trim().toLowerCase();
318
+ if (cc && !countries.includes(cc)) {
319
+ countries.push(cc);
320
+ }
321
+ }
322
+ const lookups = countries.map((c) => provider(c)).filter((l) => l != null);
323
+ if (!lookups.length)
324
+ return;
325
+ const rawSegments = raw
326
+ .split(",")
327
+ .map((s) => s.trim())
328
+ .filter(Boolean);
329
+ const CAP = 5;
330
+ // Thoroughfare candidates (parsed-first, then raw): the assembled street node, any voie-shaped parsed value, any
331
+ // voie-shaped raw comma-segment. The parse often truncates these (Champs-Élysées → "Avenue des Champs"), so the raw
332
+ // segment is the recovery — a candidate that misses just advances to the next.
333
+ const thoroughfares = [];
334
+ if (streetNode) {
335
+ pushCandidate(thoroughfares, assembleStreetValue(streetNode), CAP);
336
+ }
337
+ for (const v of adminValues) {
338
+ if (isVoieShaped(v)) {
339
+ pushCandidate(thoroughfares, v, CAP);
340
+ }
341
+ }
342
+ for (const s of rawSegments) {
343
+ if (isVoieShaped(s)) {
344
+ pushCandidate(thoroughfares, s, CAP);
345
+ }
346
+ }
347
+ if (!thoroughfares.length)
348
+ return;
349
+ // Commune candidates: non-voie parsed admin values, then non-voie raw segments (a truncated/garbled parse loses the
350
+ // commune — "Rue de la République, Marseille" parses `locality="e"` — so the raw "Marseille" is the recovery).
351
+ const communes = [];
352
+ for (const v of adminValues) {
353
+ if (!isVoieShaped(v)) {
354
+ pushCandidate(communes, v, CAP);
355
+ }
356
+ }
357
+ for (const s of rawSegments) {
358
+ if (!isVoieShaped(s) && !thoroughfares.includes(s)) {
359
+ pushCandidate(communes, s, CAP);
360
+ }
361
+ }
362
+ for (const lookup of lookups) {
363
+ for (const street of thoroughfares) {
364
+ let hit = postcode ? lookup.find({ street, postcode }) : null;
365
+ let matchedCommune;
366
+ for (let i = 0; !hit && i < communes.length; i++) {
367
+ hit = lookup.find({ street, locality: communes[i] });
368
+ if (hit) {
369
+ matchedCommune = communes[i];
370
+ }
371
+ }
372
+ if (!hit)
373
+ continue;
374
+ const target = streetNode ??
375
+ (() => {
376
+ const injected = {
377
+ tag: "street",
378
+ value: street,
379
+ start: 0,
380
+ end: 0,
381
+ confidence: 0.5,
382
+ children: [],
383
+ };
384
+ roots.push(injected);
385
+ return injected;
386
+ })();
387
+ target.metadata = {
388
+ ...target.metadata,
389
+ street_centroid: { lat: hit.lat, lon: hit.lon, source: hit.source, release: hit.release },
390
+ resolution_tier: "street",
391
+ uncertainty_m: hit.uncertaintyM,
392
+ };
393
+ // #1058: a commune-scoped hit is REGISTER evidence of the street's locality — record it for
394
+ // the geocode layer's locality/city decoration, and drop any span-rescored locality that
395
+ // contradicts it. Span-rescore injects SPECULATIVELY (a low-confidence street prefix like
396
+ // "Rue" exact-matches the commune Rue in Somme); the register's exact (street, commune)
397
+ // match is strictly stronger, so the injected token-of-the-street must not survive as the
398
+ // result's city.
399
+ if (matchedCommune) {
400
+ target.metadata = { ...target.metadata, street_locality: matchedCommune };
401
+ for (let i = roots.length - 1; i >= 0; i--) {
402
+ const n = roots[i];
403
+ if (n.tag !== "locality" || n.metadata?.["span_rescore"] !== true)
404
+ continue;
405
+ const names = [n.value, n.metadata?.["resolver_name"] ?? ""];
406
+ if (!names.some((name) => foldName(name) === foldName(matchedCommune))) {
407
+ roots.splice(i, 1);
408
+ }
409
+ }
410
+ }
411
+ return;
412
+ }
413
+ }
414
+ }
415
+ //# sourceMappingURL=street-tier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"street-tier.js","sourceRoot":"","sources":["../street-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC;;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,GAAkB,EAAE,CAAA;IAC/B,MAAM,KAAK,GAAG,CAAC,UAAU,CAAC,CAAA;IAE1B,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,EAAG,CAAA;QAEtB,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACnD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACd,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC1B,CAAC;IAED,iGAAiG;IACjG,oGAAoG;IACpG,iGAAiG;IACjG,mGAAmG;IACnG,IAAI,eAAe,IAAI,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QACrD,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC5B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE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,CAAC;gBACF,CAAC;YACF,CAAC;YAED,OAAM;QACP,CAAC;IACF,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailwoman/resolver",
3
- "version": "8.1.0",
3
+ "version": "8.3.0",
4
4
  "description": "The address resolver: walk an AddressTree, decorate nodes with gazetteer-supplied coordinates + attribution. Backend-agnostic (any ResolverBackend), with the span-rescore + postcode-consistency levers. Lifted out of @mailwoman/core so it can depend on @mailwoman/spatial (haversine) + @mailwoman/codex (USPS directionals) instead of reinventing them; the type contract stays in core so the pipeline composes it without a cycle.",
5
5
  "license": "AGPL-3.0-only OR LicenseRef-Commercial",
6
6
  "repository": {
@@ -57,8 +57,8 @@
57
57
  }
58
58
  },
59
59
  "dependencies": {
60
- "@mailwoman/codex": "8.1.0",
61
- "@mailwoman/core": "8.1.0",
62
- "@mailwoman/spatial": "8.1.0"
60
+ "@mailwoman/codex": "8.3.0",
61
+ "@mailwoman/core": "8.3.0",
62
+ "@mailwoman/spatial": "8.3.0"
63
63
  }
64
64
  }
package/plausibility.ts CHANGED
@@ -47,12 +47,16 @@ const RESOLUTION_TIER: Partial<Record<ComponentTag, number>> = {
47
47
  house_number: 5,
48
48
  }
49
49
 
50
- /** A resolved place lifted off the tree — the coordinate a caller would serve, plus its granularity tag. */
50
+ /**
51
+ * A resolved place lifted off the tree — the coordinate a caller would serve, plus its granularity tag.
52
+ */
51
53
  export interface ResolvedCoordinate {
52
54
  tag: ComponentTag
53
55
  lat: number
54
56
  lon: number
55
- /** Canonical place URI (`wof:…`) when the resolver supplied one. */
57
+ /**
58
+ * Canonical place URI (`wof:…`) when the resolver supplied one.
59
+ */
56
60
  placeID?: string
57
61
  }
58
62
 
@@ -142,6 +146,7 @@ export function outsideExpectedCountry(
142
146
 
143
147
  return lat < fact.latMin || lat > fact.latMax || lon < fact.lonMin || lon > fact.lonMax
144
148
  }
149
+
145
150
  const b = COUNTRY_BBOX[cc]
146
151
 
147
152
  if (!b) return false
@@ -149,7 +154,9 @@ export function outsideExpectedCountry(
149
154
  return lat < b[0] || lat > b[1] || lon < b[2] || lon > b[3]
150
155
  }
151
156
 
152
- /** Result of {@link isImplausibleResolution} — the boolean plus the reason, for telemetry + fallback logs. */
157
+ /**
158
+ * Result of {@link isImplausibleResolution} — the boolean plus the reason, for telemetry + fallback logs.
159
+ */
153
160
  export interface PlausibilityVerdict {
154
161
  implausible: boolean
155
162
  /**
@@ -157,7 +164,9 @@ export interface PlausibilityVerdict {
157
164
  * `outside-expected-country` = the served coordinate lies outside the expected country's bbox (guard B).
158
165
  */
159
166
  reason?: "country-centroid" | "outside-expected-country"
160
- /** The coordinate the verdict was drawn from, when anything resolved. */
167
+ /**
168
+ * The coordinate the verdict was drawn from, when anything resolved.
169
+ */
161
170
  coordinate?: ResolvedCoordinate
162
171
  }
163
172
 
@@ -24,10 +24,14 @@
24
24
  import type { AddressTree } from "@mailwoman/core/decoder"
25
25
  import type { ResolveOpts, Resolver } from "@mailwoman/core/resolver"
26
26
 
27
- /** `ResolveOpts` minus the non-serializable live lookup handles. What actually crosses the wire. */
27
+ /**
28
+ * `ResolveOpts` minus the non-serializable live lookup handles. What actually crosses the wire.
29
+ */
28
30
  export type SerializableResolveOpts = Omit<ResolveOpts, "addressPoints" | "interpolation">
29
31
 
30
- /** Strip the live lookup handles from `ResolveOpts` so the rest can be JSON-serialized over HTTP. */
32
+ /**
33
+ * Strip the live lookup handles from `ResolveOpts` so the rest can be JSON-serialized over HTTP.
34
+ */
31
35
  export function serializableResolveOpts(opts?: ResolveOpts): SerializableResolveOpts | undefined {
32
36
  if (!opts) return undefined
33
37
  const { addressPoints: _ap, interpolation: _ip, ...rest } = opts
@@ -40,21 +44,31 @@ export interface RemoteResolverOpts {
40
44
  * Full URL of the resolver service's resolve-tree endpoint, e.g. `http://resolver:7081/v1/resolve`.
41
45
  */
42
46
  endpoint: string
43
- /** Injectable fetch (tests / custom agents). Defaults to the global `fetch`. */
47
+ /**
48
+ * Injectable fetch (tests / custom agents). Defaults to the global `fetch`.
49
+ */
44
50
  fetch?: typeof fetch
45
- /** Per-request timeout in ms. Default 10000. */
51
+ /**
52
+ * Per-request timeout in ms. Default 10000.
53
+ */
46
54
  timeoutMs?: number
47
- /** Extra headers (auth, tracing). `Content-Type: application/json` is always set. */
55
+ /**
56
+ * Extra headers (auth, tracing). `Content-Type: application/json` is always set.
57
+ */
48
58
  headers?: Record<string, string>
49
59
  }
50
60
 
51
- /** The wire request body `POST <endpoint>` expects (and the matching server handler parses). */
61
+ /**
62
+ * The wire request body `POST <endpoint>` expects (and the matching server handler parses).
63
+ */
52
64
  export interface ResolveTreeRequest {
53
65
  tree: AddressTree
54
66
  opts?: SerializableResolveOpts
55
67
  }
56
68
 
57
- /** The wire response body the server returns. */
69
+ /**
70
+ * The wire response body the server returns.
71
+ */
58
72
  export interface ResolveTreeResponse {
59
73
  tree: AddressTree
60
74
  }
@@ -79,6 +93,7 @@ export class RemoteResolver implements Resolver {
79
93
 
80
94
  try {
81
95
  const body: ResolveTreeRequest = { tree, opts: serializableResolveOpts(opts) }
96
+
82
97
  const res = await this.#fetch(this.#endpoint, {
83
98
  method: "POST",
84
99
  headers: { "Content-Type": "application/json", ...this.#headers },
@@ -89,6 +104,7 @@ export class RemoteResolver implements Resolver {
89
104
  if (!res.ok) {
90
105
  throw new Error(`RemoteResolver: ${this.#endpoint} → HTTP ${res.status} ${res.statusText}`)
91
106
  }
107
+
92
108
  const json = (await res.json()) as Partial<ResolveTreeResponse>
93
109
 
94
110
  if (!json || !json.tree || !Array.isArray(json.tree.roots)) {