@mailwoman/resolver 9.0.0 → 9.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 +89 -0
- package/admin-coherence-passes.ts +435 -0
- package/admin-containment.ts +101 -0
- package/admin-winner.ts +178 -0
- package/backend-capabilities.ts +88 -0
- package/bare-toponym-race.ts +129 -0
- package/decorate-node.ts +127 -0
- package/fold-name.ts +19 -3
- package/index.ts +14 -0
- package/out/admin-coherence-passes.d.ts +70 -0
- package/out/admin-coherence-passes.d.ts.map +1 -0
- package/out/admin-coherence-passes.js +327 -0
- package/out/admin-coherence-passes.js.map +1 -0
- package/out/admin-containment.d.ts +48 -0
- package/out/admin-containment.d.ts.map +1 -0
- package/out/admin-containment.js +82 -0
- package/out/admin-containment.js.map +1 -0
- package/out/admin-winner.d.ts +109 -0
- package/out/admin-winner.d.ts.map +1 -0
- package/out/admin-winner.js +119 -0
- package/out/admin-winner.js.map +1 -0
- package/out/backend-capabilities.d.ts +37 -0
- package/out/backend-capabilities.d.ts.map +1 -0
- package/out/backend-capabilities.js +75 -0
- package/out/backend-capabilities.js.map +1 -0
- package/out/bare-toponym-race.d.ts +55 -0
- package/out/bare-toponym-race.d.ts.map +1 -0
- package/out/bare-toponym-race.js +110 -0
- package/out/bare-toponym-race.js.map +1 -0
- package/out/decorate-node.d.ts +24 -0
- package/out/decorate-node.d.ts.map +1 -0
- package/out/decorate-node.js +103 -0
- package/out/decorate-node.js.map +1 -0
- package/out/fold-name.d.ts +18 -3
- package/out/fold-name.d.ts.map +1 -1
- package/out/fold-name.js +19 -3
- package/out/fold-name.js.map +1 -1
- package/out/index.d.ts +4 -1
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/postcode-country-coherence.d.ts +91 -14
- package/out/postcode-country-coherence.d.ts.map +1 -1
- package/out/postcode-country-coherence.js +279 -42
- package/out/postcode-country-coherence.js.map +1 -1
- package/out/postcode-prefix.d.ts +101 -0
- package/out/postcode-prefix.d.ts.map +1 -0
- package/out/postcode-prefix.js +125 -0
- package/out/postcode-prefix.js.map +1 -0
- package/out/postcode-shape-coherence.d.ts +113 -0
- package/out/postcode-shape-coherence.d.ts.map +1 -0
- package/out/postcode-shape-coherence.js +193 -0
- package/out/postcode-shape-coherence.js.map +1 -0
- package/out/resolve.d.ts +1 -1
- package/out/resolve.d.ts.map +1 -1
- package/out/resolve.js +592 -410
- package/out/resolve.js.map +1 -1
- package/out/span-rescore.d.ts +28 -0
- package/out/span-rescore.d.ts.map +1 -1
- package/out/span-rescore.js +151 -17
- package/out/span-rescore.js.map +1 -1
- package/out/street-evidence.js +1 -1
- package/out/street-evidence.js.map +1 -1
- package/out/street-tier.d.ts.map +1 -1
- package/out/street-tier.js +28 -5
- package/out/street-tier.js.map +1 -1
- package/out/toponym-prior.d.ts +139 -0
- package/out/toponym-prior.d.ts.map +1 -0
- package/out/toponym-prior.js +308 -0
- package/out/toponym-prior.js.map +1 -0
- package/package.json +98 -7
- package/postcode-country-coherence.ts +355 -50
- package/postcode-prefix.ts +166 -0
- package/postcode-shape-coherence.ts +248 -0
- package/resolve.ts +809 -527
- package/span-rescore.ts +206 -19
- package/street-evidence.ts +1 -1
- package/street-tier.ts +31 -5
- package/toponym-prior.ts +367 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcode-country-coherence.js","sourceRoot":"","sources":["../postcode-country-coherence.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"postcode-country-coherence.js","sourceRoot":"","sources":["../postcode-country-coherence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuGG;AAEH,+FAA+F;AAC/F,iDAAiD;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;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CAAC,QAAQ,GAAG;YACZ,GAAG,CAAC,CAAC,QAAQ;YACb,sBAAsB,EAAE,KAAK,CAAC,OAAO;YACrC,oGAAoG;YACpG,6EAA6E;YAC7E,+BAA+B,EAAE,KAAK,CAAC,QAAQ;YAC/C,mGAAmG;YACnG,2BAA2B;YAC3B,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,yBAAyB,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1F,CAAA;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Postcode-prefix prior (#31, Mechanism 3) — the partial-code prior for postcodes the full-code
|
|
7
|
+
* gazetteer does not carry. #1480's abstention is the defect: a BT unit with no permissive source
|
|
8
|
+
* behind it (the NI half of Code-Point Open) misses the gazetteer, and the tree contributes
|
|
9
|
+
* NOTHING for it — no country scope, no district, no coordinate. This module derives the code's
|
|
10
|
+
* PREFIX and probes the PFX1 index (`postcode-prefix-<cc>.bin`), so the resolve "abstains on the
|
|
11
|
+
* UNIT and still contributes its DISTRICT": the node resolves from the prefix's centroid and/or
|
|
12
|
+
* ancestry, whichever the artifact carries.
|
|
13
|
+
*
|
|
14
|
+
* The index is a structural type (`PostcodePrefixIndexLike`, declared in `core/resolver/types.ts`),
|
|
15
|
+
* injected by the pipeline and never imported from `@mailwoman/neural` — B3-5: the probe touches
|
|
16
|
+
* zero model inputs. The loader lives in `@mailwoman/neural/postcode-prefix-index.ts` (PFX1 format:
|
|
17
|
+
* magic, header, dictionary, quantized i16 coordinates, `radiusP95Km`, ancestry); the resolver
|
|
18
|
+
* side only defines the derivation law and the probe.
|
|
19
|
+
*
|
|
20
|
+
* ## The derivation law (per artifact country)
|
|
21
|
+
*
|
|
22
|
+
* - **GB** — the OUTWARD code: the compact (whitespace-stripped) form minus its trailing 3 unit
|
|
23
|
+
* characters ("SW1A 2AA" → "SW1A", "BT9 5GS" → "BT9"). Never a greedy regex — the unit is
|
|
24
|
+
* exactly 3 chars in the compact form, and `outwardOf` in `mailwoman/gazetteer-pipeline/
|
|
25
|
+
* postcode-prefix.ts` is the build-side twin of this law.
|
|
26
|
+
* - **US** — the 3-digit section ("94043" → "940"). M-3 measured 3 digits as the first length
|
|
27
|
+
* where the ZIP prefix stops being free (145 km p95 median); a 5-digit artifact would be the
|
|
28
|
+
* full code the gazetteer already carries. No US artifact ships yet (B3-4 needs a ZCTA
|
|
29
|
+
* acquisition) — the branch exists so the law is tested before the data.
|
|
30
|
+
* - **Anything else** — abstain (null).
|
|
31
|
+
*
|
|
32
|
+
* ## The probe's country gate
|
|
33
|
+
*
|
|
34
|
+
* The index is country-specific EVIDENCE: it is only probed when its `country` matches the
|
|
35
|
+
* query's country scope (or the scope is absent). A GB index must not speak under a US scope —
|
|
36
|
+
* the pipeline passes the locale's index, and the walk's country filter is the caller's declared
|
|
37
|
+
* universe.
|
|
38
|
+
*
|
|
39
|
+
* ## Metadata contract (what the node carries afterward)
|
|
40
|
+
*
|
|
41
|
+
* - `postcode_prefix` — the prefix string that resolved it.
|
|
42
|
+
* - `postcode_prefix_ancestors` — the ancestry the prefix asserts (coarsest-first; GB outward
|
|
43
|
+
* nodes carry country → constituent-country → district).
|
|
44
|
+
* - `postcode_prefix_radius_p95_km` — the artifact's measured p95 radius, when the node carries a
|
|
45
|
+
* coordinate (M-3's receipt: a 1-digit US band and a GB outward code differ by 200×; never read
|
|
46
|
+
* a coordinate without its radius).
|
|
47
|
+
* - `coordinate_source: "postcode_prefix"` — ONLY when the node actually carries a coordinate.
|
|
48
|
+
* The ancestry-only tier (NI's 80 BT districts) stays coordinate-free — the meaning-of-zero
|
|
49
|
+
* rule, and the half that decides B3-3: inventing a BT centroid would reproduce the `BT3 9QQ` →
|
|
50
|
+
* Sheffield defect #1480 just fixed.
|
|
51
|
+
*
|
|
52
|
+
* **D-rule: opt-in behind `ResolveOpts.postcodePrefixPrior`, default-OFF** (the PCN1 posture:
|
|
53
|
+
* data + loader + offline probe, no decode wiring; the header ships without `delta` until a
|
|
54
|
+
* calibration measures one). Bars: B3-2 (≥60% of held-out units within 10 km, zero worse than the
|
|
55
|
+
* abstention arm), B3-3 (NI ≥95% country scope GB + NIR ancestry + correct district named, 0%
|
|
56
|
+
* coordinate), B3-5 (structural — no model inputs touched).
|
|
57
|
+
*/
|
|
58
|
+
import type { PostcodePrefixIndexLike, PostcodePrefixNode, ResolvedPlace } from "@mailwoman/core/resolver";
|
|
59
|
+
/**
|
|
60
|
+
* A resolved place that may carry NO coordinate. `ResolvedPlace` requires `lat`/`lon` (every gazetteer row has a value,
|
|
61
|
+
* even the 0,0 unlocated sentinel), and the prefix prior's ancestry-only tier must express absence as `undefined`
|
|
62
|
+
* instead — B3-3: inventing a centroid would reproduce the `BT3 9QQ` → Sheffield defect #1480. `decorateNode` copies
|
|
63
|
+
* `lat`/`lon` onto the node verbatim, so an undefined coordinate stays absent on the node — the meaning-of-zero rule.
|
|
64
|
+
* Widened ONLY at this seam: gazetteer places (always coordinate-bearing) remain plain `ResolvedPlace`.
|
|
65
|
+
*/
|
|
66
|
+
export type CoordinateOptionalPlace = Omit<ResolvedPlace, "lat" | "lon"> & {
|
|
67
|
+
lat?: number;
|
|
68
|
+
lon?: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Derive the prefix the index is keyed by, per the artifact's own country law. Returns null (abstain) for a country
|
|
72
|
+
* with no derivation law, or a code too short to carry a prefix.
|
|
73
|
+
*/
|
|
74
|
+
export declare function derivePostcodePrefix(code: string, country?: string): string | null;
|
|
75
|
+
/**
|
|
76
|
+
* The outcome of a successful prefix probe.
|
|
77
|
+
*/
|
|
78
|
+
export interface PostcodePrefixProbeResult {
|
|
79
|
+
/**
|
|
80
|
+
* The prefix string that hit.
|
|
81
|
+
*/
|
|
82
|
+
prefix: string;
|
|
83
|
+
/**
|
|
84
|
+
* The index node — its `ancestors` and optional coordinate/radius are the prior's payload.
|
|
85
|
+
*/
|
|
86
|
+
node: PostcodePrefixNode;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Probe the index for `code`'s prefix. Two abstention gates, in order: the index's country must match the query's
|
|
90
|
+
* country scope (or the scope is absent), and the derivation law must yield a prefix the index carries. Returns null to
|
|
91
|
+
* abstain — never throws, never guesses.
|
|
92
|
+
*/
|
|
93
|
+
export declare function probePostcodePrefix(code: string, index: PostcodePrefixIndexLike, queryCountry?: string): PostcodePrefixProbeResult | null;
|
|
94
|
+
/**
|
|
95
|
+
* Build the synthetic `ResolvedPlace` a prefix hit resolves a `postalcode` node to. `id: 0` — it is NOT a gazetteer row
|
|
96
|
+
* (the same sentinel `applyPostcodeConsistency` uses for its displaced place, resolve.ts) — and the coordinate is
|
|
97
|
+
* present ONLY when the node carries one, so an ancestry-only hit stays coordinate-free by construction (B3-3's 0%
|
|
98
|
+
* half).
|
|
99
|
+
*/
|
|
100
|
+
export declare function postcodePrefixResolvedPlace(prefix: string, node: PostcodePrefixNode, index: PostcodePrefixIndexLike): CoordinateOptionalPlace;
|
|
101
|
+
//# sourceMappingURL=postcode-prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode-prefix.d.ts","sourceRoot":"","sources":["../postcode-prefix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE1G;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,KAAK,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAazG;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkBlF;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,kBAAkB,CAAA;CACxB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,uBAAuB,EAC9B,YAAY,CAAC,EAAE,MAAM,GACnB,yBAAyB,GAAG,IAAI,CAclC;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAC1C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,uBAAuB,GAC5B,uBAAuB,CAYzB"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Postcode-prefix prior (#31, Mechanism 3) — the partial-code prior for postcodes the full-code
|
|
7
|
+
* gazetteer does not carry. #1480's abstention is the defect: a BT unit with no permissive source
|
|
8
|
+
* behind it (the NI half of Code-Point Open) misses the gazetteer, and the tree contributes
|
|
9
|
+
* NOTHING for it — no country scope, no district, no coordinate. This module derives the code's
|
|
10
|
+
* PREFIX and probes the PFX1 index (`postcode-prefix-<cc>.bin`), so the resolve "abstains on the
|
|
11
|
+
* UNIT and still contributes its DISTRICT": the node resolves from the prefix's centroid and/or
|
|
12
|
+
* ancestry, whichever the artifact carries.
|
|
13
|
+
*
|
|
14
|
+
* The index is a structural type (`PostcodePrefixIndexLike`, declared in `core/resolver/types.ts`),
|
|
15
|
+
* injected by the pipeline and never imported from `@mailwoman/neural` — B3-5: the probe touches
|
|
16
|
+
* zero model inputs. The loader lives in `@mailwoman/neural/postcode-prefix-index.ts` (PFX1 format:
|
|
17
|
+
* magic, header, dictionary, quantized i16 coordinates, `radiusP95Km`, ancestry); the resolver
|
|
18
|
+
* side only defines the derivation law and the probe.
|
|
19
|
+
*
|
|
20
|
+
* ## The derivation law (per artifact country)
|
|
21
|
+
*
|
|
22
|
+
* - **GB** — the OUTWARD code: the compact (whitespace-stripped) form minus its trailing 3 unit
|
|
23
|
+
* characters ("SW1A 2AA" → "SW1A", "BT9 5GS" → "BT9"). Never a greedy regex — the unit is
|
|
24
|
+
* exactly 3 chars in the compact form, and `outwardOf` in `mailwoman/gazetteer-pipeline/
|
|
25
|
+
* postcode-prefix.ts` is the build-side twin of this law.
|
|
26
|
+
* - **US** — the 3-digit section ("94043" → "940"). M-3 measured 3 digits as the first length
|
|
27
|
+
* where the ZIP prefix stops being free (145 km p95 median); a 5-digit artifact would be the
|
|
28
|
+
* full code the gazetteer already carries. No US artifact ships yet (B3-4 needs a ZCTA
|
|
29
|
+
* acquisition) — the branch exists so the law is tested before the data.
|
|
30
|
+
* - **Anything else** — abstain (null).
|
|
31
|
+
*
|
|
32
|
+
* ## The probe's country gate
|
|
33
|
+
*
|
|
34
|
+
* The index is country-specific EVIDENCE: it is only probed when its `country` matches the
|
|
35
|
+
* query's country scope (or the scope is absent). A GB index must not speak under a US scope —
|
|
36
|
+
* the pipeline passes the locale's index, and the walk's country filter is the caller's declared
|
|
37
|
+
* universe.
|
|
38
|
+
*
|
|
39
|
+
* ## Metadata contract (what the node carries afterward)
|
|
40
|
+
*
|
|
41
|
+
* - `postcode_prefix` — the prefix string that resolved it.
|
|
42
|
+
* - `postcode_prefix_ancestors` — the ancestry the prefix asserts (coarsest-first; GB outward
|
|
43
|
+
* nodes carry country → constituent-country → district).
|
|
44
|
+
* - `postcode_prefix_radius_p95_km` — the artifact's measured p95 radius, when the node carries a
|
|
45
|
+
* coordinate (M-3's receipt: a 1-digit US band and a GB outward code differ by 200×; never read
|
|
46
|
+
* a coordinate without its radius).
|
|
47
|
+
* - `coordinate_source: "postcode_prefix"` — ONLY when the node actually carries a coordinate.
|
|
48
|
+
* The ancestry-only tier (NI's 80 BT districts) stays coordinate-free — the meaning-of-zero
|
|
49
|
+
* rule, and the half that decides B3-3: inventing a BT centroid would reproduce the `BT3 9QQ` →
|
|
50
|
+
* Sheffield defect #1480 just fixed.
|
|
51
|
+
*
|
|
52
|
+
* **D-rule: opt-in behind `ResolveOpts.postcodePrefixPrior`, default-OFF** (the PCN1 posture:
|
|
53
|
+
* data + loader + offline probe, no decode wiring; the header ships without `delta` until a
|
|
54
|
+
* calibration measures one). Bars: B3-2 (≥60% of held-out units within 10 km, zero worse than the
|
|
55
|
+
* abstention arm), B3-3 (NI ≥95% country scope GB + NIR ancestry + correct district named, 0%
|
|
56
|
+
* coordinate), B3-5 (structural — no model inputs touched).
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* The MINIMUM compact code length for a GB outward derivation — a shorter code has no 3-character unit to strip ("B3"
|
|
60
|
+
* is a GB area, not a unit-bearing code).
|
|
61
|
+
*/
|
|
62
|
+
const MIN_GB_OUTWARD_CODE_LENGTH = 5;
|
|
63
|
+
/**
|
|
64
|
+
* The MINIMUM code length for a US section derivation.
|
|
65
|
+
*/
|
|
66
|
+
const MIN_US_SECTION_CODE_LENGTH = 3;
|
|
67
|
+
/**
|
|
68
|
+
* Derive the prefix the index is keyed by, per the artifact's own country law. Returns null (abstain) for a country
|
|
69
|
+
* with no derivation law, or a code too short to carry a prefix.
|
|
70
|
+
*/
|
|
71
|
+
export function derivePostcodePrefix(code, country) {
|
|
72
|
+
if (!code || !country)
|
|
73
|
+
return null;
|
|
74
|
+
const compact = code.replaceAll(/\s+/g, "");
|
|
75
|
+
switch (country.toUpperCase()) {
|
|
76
|
+
// The outward-code law: compact minus the trailing 3 unit characters ("SW1A2AA" → "SW1A",
|
|
77
|
+
// "BT93GS" → "BT9"). Exactly 3 — never a greedy regex, the build-side twin is `outwardOf`.
|
|
78
|
+
case "GB":
|
|
79
|
+
return compact.length >= MIN_GB_OUTWARD_CODE_LENGTH ? compact.slice(0, -3) : null;
|
|
80
|
+
// The 3-digit sectional centre ("94043" → "940"). Deliberately looser than the build side, which
|
|
81
|
+
// requires a real ZIP shape: a probe for something that is not a code simply misses, and a reader
|
|
82
|
+
// that re-derived the writer's validation would be a second copy of it.
|
|
83
|
+
case "US":
|
|
84
|
+
return compact.length >= MIN_US_SECTION_CODE_LENGTH ? compact.slice(0, 3) : null;
|
|
85
|
+
default:
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Probe the index for `code`'s prefix. Two abstention gates, in order: the index's country must match the query's
|
|
91
|
+
* country scope (or the scope is absent), and the derivation law must yield a prefix the index carries. Returns null to
|
|
92
|
+
* abstain — never throws, never guesses.
|
|
93
|
+
*/
|
|
94
|
+
export function probePostcodePrefix(code, index, queryCountry) {
|
|
95
|
+
const indexCountry = index.country?.toUpperCase();
|
|
96
|
+
// Country gate: the index is evidence FOR its own country only. A GB index under a US scope stays
|
|
97
|
+
// silent — the walk's country filter is the caller's declared universe.
|
|
98
|
+
if (queryCountry && indexCountry && queryCountry.toUpperCase() !== indexCountry)
|
|
99
|
+
return null;
|
|
100
|
+
const prefix = derivePostcodePrefix(code, indexCountry);
|
|
101
|
+
if (!prefix)
|
|
102
|
+
return null;
|
|
103
|
+
const node = index.probe(prefix);
|
|
104
|
+
return node ? { prefix, node } : null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build the synthetic `ResolvedPlace` a prefix hit resolves a `postalcode` node to. `id: 0` — it is NOT a gazetteer row
|
|
108
|
+
* (the same sentinel `applyPostcodeConsistency` uses for its displaced place, resolve.ts) — and the coordinate is
|
|
109
|
+
* present ONLY when the node carries one, so an ancestry-only hit stays coordinate-free by construction (B3-3's 0%
|
|
110
|
+
* half).
|
|
111
|
+
*/
|
|
112
|
+
export function postcodePrefixResolvedPlace(prefix, node, index) {
|
|
113
|
+
return {
|
|
114
|
+
id: 0,
|
|
115
|
+
name: prefix,
|
|
116
|
+
placetype: "postalcode",
|
|
117
|
+
// `""` = country unknown — the same empty-string convention the candidate backend uses for a row
|
|
118
|
+
// whose country_id resolves to nothing.
|
|
119
|
+
country: index.country?.toUpperCase() ?? "",
|
|
120
|
+
...(node.lat !== undefined && node.lon !== undefined ? { lat: node.lat, lon: node.lon } : {}),
|
|
121
|
+
score: 0,
|
|
122
|
+
exactMatch: false,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=postcode-prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode-prefix.js","sourceRoot":"","sources":["../postcode-prefix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAaH;;;GAGG;AACH,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAEpC;;GAEG;AACH,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAEpC;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY,EAAE,OAAgB;IAClE,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAA;IAElC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAE3C,QAAQ,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QAC/B,0FAA0F;QAC1F,2FAA2F;QAC3F,KAAK,IAAI;YACR,OAAO,OAAO,CAAC,MAAM,IAAI,0BAA0B,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAClF,iGAAiG;QACjG,kGAAkG;QAClG,wEAAwE;QACxE,KAAK,IAA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AC7F,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,KAAK;KACjB,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Postcode-shape coherence (#31, Mechanism 1) — shape as CONFIDENCE and EXCLUSION, downstream of the
|
|
7
|
+
* siblings. The fifth member of the joint-consistency coherence family (after `applyAdminCoherence`
|
|
8
|
+
* #263, `applyExplicitCountryCoherence` #822, `applyRegionCountryCoherence`, and
|
|
9
|
+
* `findPostcodeCountryScope` #42/#1477), and the only one that is pure-sync and backend-free:
|
|
10
|
+
* everything it needs is `candidateSystemsForPostcode` plus the tree.
|
|
11
|
+
*
|
|
12
|
+
* The defect (M-1, `docs/superpowers/plans/2026-08-05-postcode-structure-arc.md`): the decoder
|
|
13
|
+
* sometimes tags a HOUSE NUMBER as `postcode` when its digits form a foreign postcode shape —
|
|
14
|
+
* "1200" in "Twin Peaks Golf Course, 1200 Cornell Dr, Longmont, CO 80503" is accepted only by the
|
|
15
|
+
* AU/NZ 4-digit shape, while every sibling placetype says US. The shape alone cannot say a code is
|
|
16
|
+
* foreign (49/100 Gauntlet codes are accepted by more than one system, 10 by none), so this pass
|
|
17
|
+
* never reads the shape as country evidence by itself — it INTERSECTS each span's candidate systems
|
|
18
|
+
* with the systems the SIBLINGS already assert, and only a confident sibling set can demote.
|
|
19
|
+
*
|
|
20
|
+
* ## The rule (three outcomes, per span)
|
|
21
|
+
*
|
|
22
|
+
* 1. **Intersection non-empty → CONFIRMED.** Stamp `postcode_shape_systems` (the narrowed
|
|
23
|
+
* intersection, upper-case). Additive metadata only — resolution is byte-identical (B1-1). The
|
|
24
|
+
* same intersection narrows `findPostcodeCountryScope`'s candidate list when the caller threads
|
|
25
|
+
* it (a pure subset of codex's shape candidates — safe by construction).
|
|
26
|
+
* 2. **Intersection empty + confident siblings → EXCLUDED.** A digit-only span is demoted to
|
|
27
|
+
* `house_number` (the correct sibling tag — B1-2's "correct sibling tag surviving"); a
|
|
28
|
+
* letter-bearing span keeps its tag and gets `postcode_shape_excluded: true` instead (the
|
|
29
|
+
* compound-split corner — "15 07691" — is #942 postal-compound-recovery territory, out of
|
|
30
|
+
* scope). Either way the span's contribution to the resolve is stripped: `firstPostcodeValue`,
|
|
31
|
+
* the walk's postcode lookup, and the post-walk postcode passes all skip excluded spans.
|
|
32
|
+
* 3. **No confident siblings → ABSTAIN** (the `postcode-country-coherence.ts:269` posture
|
|
33
|
+
* verbatim). A shape no codex system recognizes (the 10/110 slice-less codes) also abstains —
|
|
34
|
+
* an empty candidate set is no evidence either way.
|
|
35
|
+
*
|
|
36
|
+
* ## What counts as a sibling signal
|
|
37
|
+
*
|
|
38
|
+
* - The **country node**, via `matchCountry`, territory-mapped: PR/VI/GU/MP/AS are USPS
|
|
39
|
+
* abbreviations (`codex/us/state.ts`), so a "Puerto Rico" token speaks for `us` — the mapping
|
|
40
|
+
* that protects the true postcode in "Ponce, 00716, Puerto Rico".
|
|
41
|
+
* - The **region node**, via `matchSubdivision` (US states + CA provinces; the US-first tiebreak
|
|
42
|
+
* that makes "CA" mean California is `matchSubdivision`'s own), plus the region's
|
|
43
|
+
* `country_hint` metadata stamp (`mailwoman/region-recognition.ts` writes it on 2-letter US
|
|
44
|
+
* state abbreviations).
|
|
45
|
+
* - Signals are filtered to the codex SystemCode universe BEFORE the intersection test. A country
|
|
46
|
+
* with no codex slice (ES, MX, IE, …) can never appear in any candidate set, so an unfiltered
|
|
47
|
+
* signal would make every intersection empty and every span "foreign" — the slice-less filter
|
|
48
|
+
* is the whole reason the JP-shaped "15 07691" span in the ES Portopetro row ABSTAINS rather
|
|
49
|
+
* than false-excludes.
|
|
50
|
+
*
|
|
51
|
+
* Deliberately NOT a signal: a second postcode span. The census's "cross-span" idea fails on the
|
|
52
|
+
* symmetric case — "2000 Sydney NSW, SW1A 2AA London" would exclude BOTH true codes (their systems
|
|
53
|
+
* are disjoint), a regression worse than the defect. Cross-country multi-postcode strings are
|
|
54
|
+
* pathological, and every M-1 span carries a country/region/`country_hint` signal instead.
|
|
55
|
+
*
|
|
56
|
+
* `defaultCountry` is never a signal: it is a LOCALE DEFAULT, not knowledge. B1-3's confound —
|
|
57
|
+
* "Sydney NSW 2000, Australia" reached with a US default must not have its 2000 excluded, and "10
|
|
58
|
+
* Downing Street, London SW1A 2AA" under a US default must not either. Those rows are exactly what
|
|
59
|
+
* `findPostcodeCountryScope` exists to rescue, and an exclusion pass that trusted the default
|
|
60
|
+
* would delete the evidence the country pass needs.
|
|
61
|
+
*
|
|
62
|
+
* ## Evidence posture
|
|
63
|
+
*
|
|
64
|
+
* M-1's six Gauntlet exclusion spans grade 4 exclusions (US "1600"/"3080"/"1200" via their region,
|
|
65
|
+
* PR "3499" via the territory-mapped country) + 2 documented abstentions (MX "2000" — no country
|
|
66
|
+
* token, "Tabasco" is not a `matchSubdivision` key; ES "15 07691" — no ES slice). Within-country,
|
|
67
|
+
* the exclusion problem is close to empty on the curated board, and a 5-digit house number in a
|
|
68
|
+
* DE/FR address is shape-native — the shape cannot exclude it (M-1 finding #1), so the mechanism
|
|
69
|
+
* CONFIRMS it instead.
|
|
70
|
+
*
|
|
71
|
+
* **D-rule: opt-in behind `ResolveOpts.postcodeShapeCoherence`, default-OFF.** Demotion is the
|
|
72
|
+
* failure mode with teeth, so a default-on promotion needs the full pre-registered gate (B1-1
|
|
73
|
+
* byte-stability, B1-2 exclusion ≥90% with the correct sibling tag surviving, B1-3 confound ≤2%
|
|
74
|
+
* false exclusions; kill on any B1-3 δ).
|
|
75
|
+
*/
|
|
76
|
+
import type { AddressNode } from "@mailwoman/core/decoder";
|
|
77
|
+
/**
|
|
78
|
+
* The pass's per-tree verdict — the caller (and the B1 board tests) can see exactly which spans were confirmed,
|
|
79
|
+
* excluded, or abstained, and which confirmed span's narrowed systems should bound the country-scope pass.
|
|
80
|
+
*/
|
|
81
|
+
export interface PostcodeShapeVerdict {
|
|
82
|
+
/**
|
|
83
|
+
* The narrowed candidate systems (upper-case) of the FIRST confirmed postcode node — the one `firstPostcodeValue`
|
|
84
|
+
* will pick — to thread into `findPostcodeCountryScope` as its candidate list. Undefined when no postcode node was
|
|
85
|
+
* confirmed.
|
|
86
|
+
*/
|
|
87
|
+
narrowing?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* The postcode strings the mechanism confirmed (shape ∩ confident siblings ≠ ∅).
|
|
90
|
+
*/
|
|
91
|
+
confirmed: string[];
|
|
92
|
+
/**
|
|
93
|
+
* The postcode strings the mechanism excluded (shape ∩ confident siblings = ∅).
|
|
94
|
+
*/
|
|
95
|
+
excluded: string[];
|
|
96
|
+
/**
|
|
97
|
+
* The postcode strings the mechanism abstained on (no confident siblings, or no codex shape).
|
|
98
|
+
*/
|
|
99
|
+
abstained: string[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Run the shape-coherence verdict over every `postcode` span in the tree, mutating the EXCLUDED spans in place (the
|
|
103
|
+
* retag / exclusion stamp) and stamping CONFIRMED spans' narrowed systems. Pure-sync: no backend, no queries. See the
|
|
104
|
+
* header for the full rule.
|
|
105
|
+
*/
|
|
106
|
+
export declare function applyPostcodeShapeCoherence(roots: readonly AddressNode[]): PostcodeShapeVerdict;
|
|
107
|
+
/**
|
|
108
|
+
* True when a node is a postcode span this pass excluded but could not retag (the letter-bearing compound corner). The
|
|
109
|
+
* resolve's postcode consumers (`firstPostcodeValue`, the walk's postcode lookup, the post-walk postcode passes) all
|
|
110
|
+
* skip these, which is what "strip the postcode tag's contribution" means for a span that keeps its tag.
|
|
111
|
+
*/
|
|
112
|
+
export declare function isShapeExcludedPostcode(node: AddressNode): boolean;
|
|
113
|
+
//# sourceMappingURL=postcode-shape-coherence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode-shape-coherence.d.ts","sourceRoot":"","sources":["../postcode-shape-coherence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAU1D;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAA;CACnB;AAmDD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,oBAAoB,CAsE/F;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAElE"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Postcode-shape coherence (#31, Mechanism 1) — shape as CONFIDENCE and EXCLUSION, downstream of the
|
|
7
|
+
* siblings. The fifth member of the joint-consistency coherence family (after `applyAdminCoherence`
|
|
8
|
+
* #263, `applyExplicitCountryCoherence` #822, `applyRegionCountryCoherence`, and
|
|
9
|
+
* `findPostcodeCountryScope` #42/#1477), and the only one that is pure-sync and backend-free:
|
|
10
|
+
* everything it needs is `candidateSystemsForPostcode` plus the tree.
|
|
11
|
+
*
|
|
12
|
+
* The defect (M-1, `docs/superpowers/plans/2026-08-05-postcode-structure-arc.md`): the decoder
|
|
13
|
+
* sometimes tags a HOUSE NUMBER as `postcode` when its digits form a foreign postcode shape —
|
|
14
|
+
* "1200" in "Twin Peaks Golf Course, 1200 Cornell Dr, Longmont, CO 80503" is accepted only by the
|
|
15
|
+
* AU/NZ 4-digit shape, while every sibling placetype says US. The shape alone cannot say a code is
|
|
16
|
+
* foreign (49/100 Gauntlet codes are accepted by more than one system, 10 by none), so this pass
|
|
17
|
+
* never reads the shape as country evidence by itself — it INTERSECTS each span's candidate systems
|
|
18
|
+
* with the systems the SIBLINGS already assert, and only a confident sibling set can demote.
|
|
19
|
+
*
|
|
20
|
+
* ## The rule (three outcomes, per span)
|
|
21
|
+
*
|
|
22
|
+
* 1. **Intersection non-empty → CONFIRMED.** Stamp `postcode_shape_systems` (the narrowed
|
|
23
|
+
* intersection, upper-case). Additive metadata only — resolution is byte-identical (B1-1). The
|
|
24
|
+
* same intersection narrows `findPostcodeCountryScope`'s candidate list when the caller threads
|
|
25
|
+
* it (a pure subset of codex's shape candidates — safe by construction).
|
|
26
|
+
* 2. **Intersection empty + confident siblings → EXCLUDED.** A digit-only span is demoted to
|
|
27
|
+
* `house_number` (the correct sibling tag — B1-2's "correct sibling tag surviving"); a
|
|
28
|
+
* letter-bearing span keeps its tag and gets `postcode_shape_excluded: true` instead (the
|
|
29
|
+
* compound-split corner — "15 07691" — is #942 postal-compound-recovery territory, out of
|
|
30
|
+
* scope). Either way the span's contribution to the resolve is stripped: `firstPostcodeValue`,
|
|
31
|
+
* the walk's postcode lookup, and the post-walk postcode passes all skip excluded spans.
|
|
32
|
+
* 3. **No confident siblings → ABSTAIN** (the `postcode-country-coherence.ts:269` posture
|
|
33
|
+
* verbatim). A shape no codex system recognizes (the 10/110 slice-less codes) also abstains —
|
|
34
|
+
* an empty candidate set is no evidence either way.
|
|
35
|
+
*
|
|
36
|
+
* ## What counts as a sibling signal
|
|
37
|
+
*
|
|
38
|
+
* - The **country node**, via `matchCountry`, territory-mapped: PR/VI/GU/MP/AS are USPS
|
|
39
|
+
* abbreviations (`codex/us/state.ts`), so a "Puerto Rico" token speaks for `us` — the mapping
|
|
40
|
+
* that protects the true postcode in "Ponce, 00716, Puerto Rico".
|
|
41
|
+
* - The **region node**, via `matchSubdivision` (US states + CA provinces; the US-first tiebreak
|
|
42
|
+
* that makes "CA" mean California is `matchSubdivision`'s own), plus the region's
|
|
43
|
+
* `country_hint` metadata stamp (`mailwoman/region-recognition.ts` writes it on 2-letter US
|
|
44
|
+
* state abbreviations).
|
|
45
|
+
* - Signals are filtered to the codex SystemCode universe BEFORE the intersection test. A country
|
|
46
|
+
* with no codex slice (ES, MX, IE, …) can never appear in any candidate set, so an unfiltered
|
|
47
|
+
* signal would make every intersection empty and every span "foreign" — the slice-less filter
|
|
48
|
+
* is the whole reason the JP-shaped "15 07691" span in the ES Portopetro row ABSTAINS rather
|
|
49
|
+
* than false-excludes.
|
|
50
|
+
*
|
|
51
|
+
* Deliberately NOT a signal: a second postcode span. The census's "cross-span" idea fails on the
|
|
52
|
+
* symmetric case — "2000 Sydney NSW, SW1A 2AA London" would exclude BOTH true codes (their systems
|
|
53
|
+
* are disjoint), a regression worse than the defect. Cross-country multi-postcode strings are
|
|
54
|
+
* pathological, and every M-1 span carries a country/region/`country_hint` signal instead.
|
|
55
|
+
*
|
|
56
|
+
* `defaultCountry` is never a signal: it is a LOCALE DEFAULT, not knowledge. B1-3's confound —
|
|
57
|
+
* "Sydney NSW 2000, Australia" reached with a US default must not have its 2000 excluded, and "10
|
|
58
|
+
* Downing Street, London SW1A 2AA" under a US default must not either. Those rows are exactly what
|
|
59
|
+
* `findPostcodeCountryScope` exists to rescue, and an exclusion pass that trusted the default
|
|
60
|
+
* would delete the evidence the country pass needs.
|
|
61
|
+
*
|
|
62
|
+
* ## Evidence posture
|
|
63
|
+
*
|
|
64
|
+
* M-1's six Gauntlet exclusion spans grade 4 exclusions (US "1600"/"3080"/"1200" via their region,
|
|
65
|
+
* PR "3499" via the territory-mapped country) + 2 documented abstentions (MX "2000" — no country
|
|
66
|
+
* token, "Tabasco" is not a `matchSubdivision` key; ES "15 07691" — no ES slice). Within-country,
|
|
67
|
+
* the exclusion problem is close to empty on the curated board, and a 5-digit house number in a
|
|
68
|
+
* DE/FR address is shape-native — the shape cannot exclude it (M-1 finding #1), so the mechanism
|
|
69
|
+
* CONFIRMS it instead.
|
|
70
|
+
*
|
|
71
|
+
* **D-rule: opt-in behind `ResolveOpts.postcodeShapeCoherence`, default-OFF.** Demotion is the
|
|
72
|
+
* failure mode with teeth, so a default-on promotion needs the full pre-registered gate (B1-1
|
|
73
|
+
* byte-stability, B1-2 exclusion ≥90% with the correct sibling tag surviving, B1-3 confound ≤2%
|
|
74
|
+
* false exclusions; kill on any B1-3 δ).
|
|
75
|
+
*/
|
|
76
|
+
import { candidateSystemsForPostcode } from "@mailwoman/codex";
|
|
77
|
+
import { matchCountry, matchSubdivision } from "@mailwoman/codex/country";
|
|
78
|
+
import { isUSStateAbbreviation } from "@mailwoman/codex/us";
|
|
79
|
+
/**
|
|
80
|
+
* The codex address systems a sibling signal can speak for — the universe `candidateSystemsForPostcode` can return, in
|
|
81
|
+
* the upper-case ISO form this module's signals are emitted in (`SystemCode` itself is lower-case). Signals from
|
|
82
|
+
* countries with no codex slice are filtered out BEFORE the intersection test, so a slice-less country can never
|
|
83
|
+
* manufacture an empty intersection (the false-exclusion trap; see the header).
|
|
84
|
+
*/
|
|
85
|
+
const SYSTEM_UNIVERSE = new Set(["US", "DE", "FR", "CA", "GB", "JP", "AU", "NZ"]);
|
|
86
|
+
/**
|
|
87
|
+
* Collect the sibling country signals: the country node (territory-mapped), the region node (`matchSubdivision` +
|
|
88
|
+
* `country_hint`), each filtered to the codex SystemCode universe. The tree is walked once for ALL postcode spans —
|
|
89
|
+
* sibling evidence is tree-level, not per-span.
|
|
90
|
+
*/
|
|
91
|
+
function collectSiblingSystems(roots) {
|
|
92
|
+
const out = new Set();
|
|
93
|
+
const stack = [...roots];
|
|
94
|
+
while (stack.length) {
|
|
95
|
+
const n = stack.pop();
|
|
96
|
+
stack.push(...n.children);
|
|
97
|
+
if (n.tag === "country") {
|
|
98
|
+
const matched = matchCountry(n.value);
|
|
99
|
+
if (!matched)
|
|
100
|
+
continue;
|
|
101
|
+
// Territory map: PR/VI/GU/MP/AS are USPS state-or-territory abbreviations (codex/us/state.ts),
|
|
102
|
+
// so a US-territory country token ("Puerto Rico", "Guam") is a US-system signal.
|
|
103
|
+
const system = isUSStateAbbreviation(matched.iso2) ? "US" : matched.iso2.toUpperCase();
|
|
104
|
+
if (SYSTEM_UNIVERSE.has(system)) {
|
|
105
|
+
out.add(system);
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (n.tag === "region") {
|
|
110
|
+
// (a) The region's value as a subdivision ("CA" → US, "ON" → CA — the US-wins tiebreak for
|
|
111
|
+
// "CA" is matchSubdivision's own). (b) The `country_hint` stamp annotateUSRegions writes on
|
|
112
|
+
// 2-letter US state abbreviations — the same evidence via the pipeline's other seam.
|
|
113
|
+
const sub = matchSubdivision(n.value);
|
|
114
|
+
if (sub && SYSTEM_UNIVERSE.has(sub.country.toUpperCase())) {
|
|
115
|
+
out.add(sub.country.toUpperCase());
|
|
116
|
+
}
|
|
117
|
+
const hint = n.metadata?.["country_hint"];
|
|
118
|
+
if (typeof hint === "string" && SYSTEM_UNIVERSE.has(hint.toUpperCase())) {
|
|
119
|
+
out.add(hint.toUpperCase());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Run the shape-coherence verdict over every `postcode` span in the tree, mutating the EXCLUDED spans in place (the
|
|
127
|
+
* retag / exclusion stamp) and stamping CONFIRMED spans' narrowed systems. Pure-sync: no backend, no queries. See the
|
|
128
|
+
* header for the full rule.
|
|
129
|
+
*/
|
|
130
|
+
export function applyPostcodeShapeCoherence(roots) {
|
|
131
|
+
const verdict = { confirmed: [], excluded: [], abstained: [] };
|
|
132
|
+
// The postcode spans in tree order — the same DFS `firstPostcodeValue` uses, so the verdict's
|
|
133
|
+
// "first confirmed" is the node `state.postcode` will read.
|
|
134
|
+
const postcodes = [];
|
|
135
|
+
const stack = [...roots];
|
|
136
|
+
while (stack.length) {
|
|
137
|
+
const n = stack.pop();
|
|
138
|
+
if (n.tag === "postcode" && n.value.trim().length) {
|
|
139
|
+
postcodes.push(n);
|
|
140
|
+
}
|
|
141
|
+
stack.push(...n.children);
|
|
142
|
+
}
|
|
143
|
+
if (!postcodes.length)
|
|
144
|
+
return verdict;
|
|
145
|
+
const siblingSystems = collectSiblingSystems(roots);
|
|
146
|
+
for (const node of postcodes) {
|
|
147
|
+
const code = node.value.trim();
|
|
148
|
+
const systems = candidateSystemsForPostcode(code);
|
|
149
|
+
// A shape no codex system recognizes is no evidence either way — abstain (the 10/110
|
|
150
|
+
// slice-less Gauntlet codes: IE Eircode, SI, IM, …).
|
|
151
|
+
if (!systems.length) {
|
|
152
|
+
verdict.abstained.push(code);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const intersection = systems.map((system) => system.toUpperCase()).filter((system) => siblingSystems.has(system));
|
|
156
|
+
if (intersection.length) {
|
|
157
|
+
verdict.confirmed.push(code);
|
|
158
|
+
// Additive only — resolution stays byte-identical (B1-1). The narrowed intersection is the
|
|
159
|
+
// candidate set the country-scope pass should bound itself to.
|
|
160
|
+
node.metadata = { ...node.metadata, postcode_shape_systems: intersection };
|
|
161
|
+
if (verdict.narrowing === undefined) {
|
|
162
|
+
verdict.narrowing = intersection;
|
|
163
|
+
}
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (siblingSystems.size) {
|
|
167
|
+
// Confident siblings, empty intersection → EXCLUDED. A digit-only span is demoted to its
|
|
168
|
+
// correct sibling tag (B1-2); a letter-bearing span (the "15 07691" compound corner) keeps
|
|
169
|
+
// its tag and is stamped instead — either way every resolve consumer skips it.
|
|
170
|
+
verdict.excluded.push(code);
|
|
171
|
+
if (/^\d+$/.test(code)) {
|
|
172
|
+
node.tag = "house_number";
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
node.metadata = { ...node.metadata, postcode_shape_excluded: true };
|
|
176
|
+
}
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
// No confident siblings — the same abstention posture postcode-country-coherence.ts:269 takes
|
|
180
|
+
// on zero-or-two coherent countries. Never guess with the shape alone.
|
|
181
|
+
verdict.abstained.push(code);
|
|
182
|
+
}
|
|
183
|
+
return verdict;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* True when a node is a postcode span this pass excluded but could not retag (the letter-bearing compound corner). The
|
|
187
|
+
* resolve's postcode consumers (`firstPostcodeValue`, the walk's postcode lookup, the post-walk postcode passes) all
|
|
188
|
+
* skip these, which is what "strip the postcode tag's contribution" means for a span that keeps its tag.
|
|
189
|
+
*/
|
|
190
|
+
export function isShapeExcludedPostcode(node) {
|
|
191
|
+
return node.tag === "postcode" && node.metadata?.["postcode_shape_excluded"] === true;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=postcode-shape-coherence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcode-shape-coherence.js","sourceRoot":"","sources":["../postcode-shape-coherence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAG3D;;;;;GAKG;AACH,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AA2B9G;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,KAA6B;IAC3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;IACxD,OAAO,IAAI,CAAC,GAAG,KAAK,UAAU,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,yBAAyB,CAAC,KAAK,IAAI,CAAA;AACtF,CAAC"}
|
package/out/resolve.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { type Resolver, type ResolverBackend } from "@mailwoman/core/resolver";
|
|
15
15
|
/**
|
|
16
16
|
* Build a `Resolver` backed by a `ResolverBackend`. The backend can be any concrete impl structurally compatible with
|
|
17
|
-
* `PlaceLookup` — e.g. `new
|
|
17
|
+
* `PlaceLookup` — e.g. `new WOFSQLitePlaceLookup({ databasePath }).asResolverBackend()` or a fake for tests.
|
|
18
18
|
*/
|
|
19
19
|
export declare function createWOFResolver(backend: ResolverBackend): Resolver;
|
|
20
20
|
//# sourceMappingURL=resolve.d.ts.map
|
package/out/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAaN,KAAK,QAAQ,EACb,KAAK,eAAe,EAEpB,MAAM,0BAA0B,CAAA;AA+BjC;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAEpE"}
|