@mailwoman/resolver 9.2.0 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/README.md +5 -5
  2. package/{admin-coherence-passes.ts → lib/admin/coherence-passes.ts} +8 -8
  3. package/{admin-containment.ts → lib/admin/containment.ts} +5 -14
  4. package/lib/admin/index.ts +10 -0
  5. package/lib/admin/jp-municipality.ts +97 -0
  6. package/{admin-winner.ts → lib/admin/winner.ts} +13 -2
  7. package/{backend-capabilities.ts → lib/backend-capabilities.ts} +3 -3
  8. package/{bare-toponym-race.ts → lib/bare-toponym-race.ts} +1 -1
  9. package/{decorate-node.ts → lib/decorate-node.ts} +2 -2
  10. package/{fold-name.ts → lib/fold-name.ts} +2 -2
  11. package/{index.ts → lib/index.ts} +16 -21
  12. package/{plausibility.ts → lib/plausibility.ts} +5 -4
  13. package/{postcode-country-coherence.ts → lib/postcode/country-coherence.ts} +27 -32
  14. package/lib/postcode/index.ts +9 -0
  15. package/{postcode-prefix.ts → lib/postcode/prefix.ts} +4 -4
  16. package/{postcode-shape-coherence.ts → lib/postcode/shape-coherence.ts} +10 -24
  17. package/{remote-resolver.ts → lib/remote-resolver.ts} +13 -4
  18. package/{rerank.ts → lib/rerank.ts} +2 -2
  19. package/{resolve.ts → lib/resolve/index.ts} +120 -602
  20. package/lib/resolve/passes.ts +544 -0
  21. package/{span-rescore.ts → lib/span-rescore.ts} +63 -97
  22. package/{street-evidence.ts → lib/street/evidence.ts} +39 -6
  23. package/lib/street/index.ts +8 -0
  24. package/{street-tier.ts → lib/street/tier.ts} +125 -110
  25. package/{toponym-prior.ts → lib/toponym-prior.ts} +8 -8
  26. package/out/{admin-coherence-passes.d.ts → admin/coherence-passes.d.ts} +6 -6
  27. package/out/admin/coherence-passes.d.ts.map +1 -0
  28. package/out/{admin-coherence-passes.js → admin/coherence-passes.js} +9 -9
  29. package/out/admin/coherence-passes.js.map +1 -0
  30. package/out/{admin-containment.d.ts → admin/containment.d.ts} +5 -5
  31. package/out/admin/containment.d.ts.map +1 -0
  32. package/out/{admin-containment.js → admin/containment.js} +6 -12
  33. package/out/admin/containment.js.map +1 -0
  34. package/out/admin/index.d.ts +10 -0
  35. package/out/admin/index.d.ts.map +1 -0
  36. package/out/admin/index.js +10 -0
  37. package/out/admin/index.js.map +1 -0
  38. package/out/admin/jp-municipality.d.ts +50 -0
  39. package/out/admin/jp-municipality.d.ts.map +1 -0
  40. package/out/admin/jp-municipality.js +54 -0
  41. package/out/admin/jp-municipality.js.map +1 -0
  42. package/out/{admin-winner.d.ts → admin/winner.d.ts} +8 -3
  43. package/out/admin/winner.d.ts.map +1 -0
  44. package/out/{admin-winner.js → admin/winner.js} +14 -3
  45. package/out/admin/winner.js.map +1 -0
  46. package/out/backend-capabilities.d.ts.map +1 -1
  47. package/out/backend-capabilities.js +3 -3
  48. package/out/backend-capabilities.js.map +1 -1
  49. package/out/bare-toponym-race.d.ts.map +1 -1
  50. package/out/bare-toponym-race.js +1 -1
  51. package/out/bare-toponym-race.js.map +1 -1
  52. package/out/decorate-node.d.ts +1 -1
  53. package/out/decorate-node.d.ts.map +1 -1
  54. package/out/decorate-node.js +1 -1
  55. package/out/decorate-node.js.map +1 -1
  56. package/out/fold-name.d.ts +2 -2
  57. package/out/fold-name.d.ts.map +1 -1
  58. package/out/fold-name.js +2 -2
  59. package/out/fold-name.js.map +1 -1
  60. package/out/index.d.ts +15 -15
  61. package/out/index.d.ts.map +1 -1
  62. package/out/index.js +9 -9
  63. package/out/index.js.map +1 -1
  64. package/out/plausibility.d.ts +5 -4
  65. package/out/plausibility.d.ts.map +1 -1
  66. package/out/plausibility.js +5 -4
  67. package/out/plausibility.js.map +1 -1
  68. package/out/{postcode-country-coherence.d.ts → postcode/country-coherence.d.ts} +16 -16
  69. package/out/postcode/country-coherence.d.ts.map +1 -0
  70. package/out/{postcode-country-coherence.js → postcode/country-coherence.js} +24 -25
  71. package/out/postcode/country-coherence.js.map +1 -0
  72. package/out/postcode/index.d.ts +9 -0
  73. package/out/postcode/index.d.ts.map +1 -0
  74. package/out/postcode/index.js +9 -0
  75. package/out/postcode/index.js.map +1 -0
  76. package/out/{postcode-prefix.d.ts → postcode/prefix.d.ts} +4 -4
  77. package/out/postcode/prefix.d.ts.map +1 -0
  78. package/out/{postcode-prefix.js → postcode/prefix.js} +4 -4
  79. package/out/postcode/prefix.js.map +1 -0
  80. package/out/{postcode-shape-coherence.d.ts → postcode/shape-coherence.d.ts} +3 -3
  81. package/out/postcode/shape-coherence.d.ts.map +1 -0
  82. package/out/{postcode-shape-coherence.js → postcode/shape-coherence.js} +11 -20
  83. package/out/postcode/shape-coherence.js.map +1 -0
  84. package/out/remote-resolver.d.ts +18 -3
  85. package/out/remote-resolver.d.ts.map +1 -1
  86. package/out/remote-resolver.js +2 -2
  87. package/out/remote-resolver.js.map +1 -1
  88. package/out/rerank.d.ts +1 -1
  89. package/out/rerank.d.ts.map +1 -1
  90. package/out/rerank.js +2 -2
  91. package/out/rerank.js.map +1 -1
  92. package/out/{resolve.d.ts → resolve/index.d.ts} +1 -1
  93. package/out/resolve/index.d.ts.map +1 -0
  94. package/out/{resolve.js → resolve/index.js} +88 -387
  95. package/out/resolve/index.js.map +1 -0
  96. package/out/resolve/passes.d.ts +218 -0
  97. package/out/resolve/passes.d.ts.map +1 -0
  98. package/out/resolve/passes.js +333 -0
  99. package/out/resolve/passes.js.map +1 -0
  100. package/out/span-rescore.d.ts +16 -16
  101. package/out/span-rescore.d.ts.map +1 -1
  102. package/out/span-rescore.js +43 -69
  103. package/out/span-rescore.js.map +1 -1
  104. package/out/{street-evidence.d.ts → street/evidence.d.ts} +18 -3
  105. package/out/street/evidence.d.ts.map +1 -0
  106. package/out/{street-evidence.js → street/evidence.js} +22 -6
  107. package/out/street/evidence.js.map +1 -0
  108. package/out/street/index.d.ts +8 -0
  109. package/out/street/index.d.ts.map +1 -0
  110. package/out/street/index.js +8 -0
  111. package/out/street/index.js.map +1 -0
  112. package/out/{street-tier.d.ts → street/tier.d.ts} +14 -3
  113. package/out/street/tier.d.ts.map +1 -0
  114. package/out/{street-tier.js → street/tier.js} +115 -99
  115. package/out/street/tier.js.map +1 -0
  116. package/out/toponym-prior.d.ts +8 -8
  117. package/out/toponym-prior.d.ts.map +1 -1
  118. package/out/toponym-prior.js +8 -8
  119. package/out/toponym-prior.js.map +1 -1
  120. package/package.json +116 -59
  121. package/vitest.config.ts +5 -6
  122. package/out/admin-coherence-passes.d.ts.map +0 -1
  123. package/out/admin-coherence-passes.js.map +0 -1
  124. package/out/admin-containment.d.ts.map +0 -1
  125. package/out/admin-containment.js.map +0 -1
  126. package/out/admin-winner.d.ts.map +0 -1
  127. package/out/admin-winner.js.map +0 -1
  128. package/out/postcode-country-coherence.d.ts.map +0 -1
  129. package/out/postcode-country-coherence.js.map +0 -1
  130. package/out/postcode-prefix.d.ts.map +0 -1
  131. package/out/postcode-prefix.js.map +0 -1
  132. package/out/postcode-shape-coherence.d.ts.map +0 -1
  133. package/out/postcode-shape-coherence.js.map +0 -1
  134. package/out/resolve.d.ts.map +0 -1
  135. package/out/resolve.js.map +0 -1
  136. package/out/street-evidence.d.ts.map +0 -1
  137. package/out/street-evidence.js.map +0 -1
  138. package/out/street-tier.d.ts.map +0 -1
  139. package/out/street-tier.js.map +0 -1
  140. package/out/vitest.config.d.ts +0 -16
  141. package/out/vitest.config.d.ts.map +0 -1
  142. package/out/vitest.config.js +0 -36
  143. package/out/vitest.config.js.map +0 -1
@@ -13,10 +13,10 @@
13
13
  */
14
14
 
15
15
  import { isStreetDirectionalToken } from "@mailwoman/codex/us"
16
- import type { AddressNode } from "@mailwoman/core/decoder"
16
+ import { collectNodes, walkNodes, type AddressNode } from "@mailwoman/core/decoder"
17
17
  import type { AddressPointLookup, InterpolationLookup, StreetCentroidLookup } from "@mailwoman/core/resolver"
18
18
 
19
- import { foldName } from "./fold-name.ts"
19
+ import { foldName } from "#fold-name"
20
20
 
21
21
  /**
22
22
  * Street-name component tags that, with the street node itself, reconstruct the full street string.
@@ -26,27 +26,16 @@ const STREET_NAME_TAGS = new Set(["street", "street_prefix", "street_prefix_part
26
26
  /**
27
27
  * Reassemble the full street string from the street node's subtree (#483 coverage fix). The parser nests the
28
28
  * directional/suffix as `street_prefix`/`street_suffix` CHILDREN of `street` (containment.ts), so `street.value` alone
29
- * is the bare base name ("Sheldon" for "East Sheldon Rd") — which misses the coordinate shards keyed on the FULL
29
+ * is the bare base name ("Sheldon" for "East Sheldon Rd") — which misses the coordinate extracts keyed on the FULL
30
30
  * normalized name. Collect street + its prefix/particle/suffix descendants (NOT house_number/unit, which also nest
31
31
  * under street), order by span offset, and join.
32
32
  */
33
33
  function assembleStreetValue(streetNode: AddressNode, directionalUnit?: AddressNode): string {
34
- const parts: AddressNode[] = []
35
- const stack = [streetNode]
36
-
37
- while (stack.length) {
38
- const n = stack.pop()!
39
-
40
- if (STREET_NAME_TAGS.has(n.tag) && n.value.trim()) {
41
- parts.push(n)
42
- }
43
-
44
- stack.push(...n.children)
45
- }
34
+ const parts = collectNodes([streetNode], (n) => STREET_NAME_TAGS.has(n.tag) && n.value.trim().length > 0)
46
35
 
47
36
  // #718 admin-tail: a directional quadrant the model mis-tagged `unit` ("1532 Taylor Street NE" →
48
37
  // [unit] "NE") folds back into the street key by span order, so the situs/interp lookup matches the
49
- // shard's "taylor street northeast" (the lookup normalizer expands the abbreviation). Lookup-key
38
+ // extract's "taylor street northeast" (the lookup normalizer expands the abbreviation). Lookup-key
50
39
  // only — the parse output and admin resolution are untouched. Byte-stable when absent (undefined).
51
40
  if (directionalUnit && directionalUnit.value.trim()) {
52
41
  parts.push(directionalUnit)
@@ -61,7 +50,7 @@ function assembleStreetValue(streetNode: AddressNode, directionalUnit?: AddressN
61
50
  * Directional quadrant values the model sometimes emits as a `unit` node instead of inside the street subtree (#718
62
51
  * admin-tail diagnostic: ~19% of the admin-fallback tail, 83% of DC). Folded into the street lookup key by
63
52
  * {@link assembleStreetValue}; the situs/interp lookup normalizer expands the abbreviation ("ne" → "northeast") so the
64
- * shard's full street name matches.
53
+ * extract's full street name matches.
65
54
  */
66
55
  // The 8 USPS cardinals/intercardinals (abbrev or name) — @codex/us owns the canonical table (#215).
67
56
  const isDirectionalUnit = (value: string): boolean => isStreetDirectionalToken(value.replaceAll(".", ""))
@@ -79,47 +68,69 @@ const isDirectionalUnit = (value: string): boolean => isStreetDirectionalToken(v
79
68
  */
80
69
  const LOCALITY_BBOX_RADIUS_DEG = 0.25
81
70
 
82
- export function applyAddressPoint(roots: AddressNode[], lookup: AddressPointLookup, bboxFallback?: boolean): void {
83
- let street: AddressNode | undefined
84
- let houseNumber: AddressNode | undefined
85
- let directionalUnit: AddressNode | undefined
86
- let localityNode: AddressNode | undefined
87
- let locality: string | undefined
88
- let postcode: string | undefined
89
- const stack = [...roots]
90
-
91
- while (stack.length) {
92
- const n = stack.pop()!
93
-
94
- if (n.tag === "street" && !street) {
95
- street = n
71
+ /**
72
+ * Every `(street, house_number)` pair the tree offers, nearest pair first: the house number whose span sits closest to
73
+ * the street's, a number BEFORE the street winning a tie. A venue-led string parses more than one of each — `Bar 1802,
74
+ * 22 Rue Pascal, 75005 Paris, France` carries two house numbers and one street, and `22` is the one written beside `Rue
75
+ * Pascal`. The tiers probe the pairs in this order and stop at the first register hit, and the pair that hit is what
76
+ * the result names; a walk that took "the first node of each tag" paired whatever the traversal met first.
77
+ */
78
+ export function streetNumberPairs(
79
+ roots: readonly AddressNode[]
80
+ ): Array<{ street: AddressNode; houseNumber: AddressNode }> {
81
+ const streets: AddressNode[] = []
82
+ const numbers: AddressNode[] = []
83
+
84
+ for (const node of walkNodes(roots)) {
85
+ if (node.tag === "street") {
86
+ streets.push(node)
96
87
  }
97
88
 
98
- if (n.tag === "house_number" && !houseNumber) {
99
- houseNumber = n
89
+ if (node.tag === "house_number") {
90
+ numbers.push(node)
100
91
  }
92
+ }
101
93
 
102
- if (n.tag === "unit" && !directionalUnit && isDirectionalUnit(n.value)) {
103
- directionalUnit = n
104
- }
94
+ const pairs = streets.flatMap((street) => numbers.map((houseNumber) => ({ street, houseNumber })))
105
95
 
106
- if (n.tag === "locality" && !localityNode && n.value.trim()) {
107
- localityNode = n
108
- locality = n.value.trim()
109
- }
96
+ return pairs.toSorted((a, b) => pairGap(a) - pairGap(b))
97
+ }
110
98
 
111
- if (n.tag === "postcode" && !postcode && n.value.trim()) {
112
- postcode = n.value.trim()
113
- }
99
+ /**
100
+ * Characters between a house number and its street; a number after the street costs one extra so the tie goes to the
101
+ * number written before it, the order every Latin-script address system this resolver serves writes.
102
+ */
103
+ function pairGap(pair: { street: AddressNode; houseNumber: AddressNode }): number {
104
+ const { street, houseNumber } = pair
114
105
 
115
- stack.push(...n.children)
106
+ if (houseNumber.end <= street.start) return street.start - houseNumber.end
107
+
108
+ return houseNumber.start - street.end + 1
109
+ }
110
+
111
+ /**
112
+ * The first node of `tag` in document order whose value is non-blank, when the tree carries one.
113
+ */
114
+ function firstOfTag(roots: readonly AddressNode[], tag: AddressNode["tag"]): AddressNode | undefined {
115
+ for (const node of walkNodes(roots)) {
116
+ if (node.tag === tag && node.value.trim()) return node
116
117
  }
117
118
 
118
- if (!street || !houseNumber) return
119
+ return undefined
120
+ }
119
121
 
120
- if (street.metadata?.["resolution_tier"] === "address_point") return
122
+ export function applyAddressPoint(roots: AddressNode[], lookup: AddressPointLookup, bboxFallback?: boolean): void {
123
+ const pairs = streetNumberPairs(roots)
124
+ const directionalUnit = [...walkNodes(roots)].find((n) => n.tag === "unit" && isDirectionalUnit(n.value))
125
+ const localityNode = firstOfTag(roots, "locality")
126
+ const locality = localityNode?.value.trim()
127
+ const postcode = firstOfTag(roots, "postcode")?.value.trim()
121
128
 
122
- // #247 OSM bbox fall-through: when enabled (an OSM shard is wired) and the locality resolved to a
129
+ if (!pairs.length) return
130
+
131
+ if (pairs.some((pair) => pair.street.metadata?.["resolution_tier"] === "address_point")) return
132
+
133
+ // #247 OSM bbox fall-through: when enabled (an OSM extract is wired) and the locality resolved to a
123
134
  // coordinate, scope a final `(street, number)` probe by the locality's box — recovering OSM points that
124
135
  // carry no postcode/locality tag of their own. US situs never enables it, so its probes are byte-identical.
125
136
  let bbox: { minLat: number; maxLat: number; minLon: number; maxLon: number } | undefined
@@ -133,15 +144,31 @@ export function applyAddressPoint(roots: AddressNode[], lookup: AddressPointLook
133
144
  }
134
145
  }
135
146
 
136
- const hit = lookup.find({
137
- street: assembleStreetValue(street, directionalUnit),
138
- number: houseNumber.value,
139
- postcode,
140
- locality,
141
- bbox,
142
- })
147
+ let street: AddressNode | undefined
148
+ let houseNumber: AddressNode | undefined
149
+ let hit: ReturnType<AddressPointLookup["find"]> | undefined
150
+
151
+ for (const pair of pairs) {
152
+ hit = lookup.find({
153
+ street: assembleStreetValue(pair.street, directionalUnit),
154
+ number: pair.houseNumber.value,
155
+ postcode,
156
+ locality,
157
+ bbox,
158
+ })
159
+
160
+ if (hit) {
161
+ street = pair.street
162
+ houseNumber = pair.houseNumber
163
+
164
+ break
165
+ }
166
+ }
167
+
168
+ if (!hit || !street || !houseNumber) return
143
169
 
144
- if (!hit) return
170
+ // The number the register answered for is the one the result names (tree-shape.ts `slotNodes` reads the stamp).
171
+ houseNumber.metadata = { ...houseNumber.metadata, resolution_tier: "address_point" }
145
172
 
146
173
  street.metadata = {
147
174
  ...street.metadata,
@@ -161,7 +188,7 @@ export function applyAddressPoint(roots: AddressNode[], lookup: AddressPointLook
161
188
 
162
189
  /**
163
190
  * House-number interpolation tier (#483): the third rung, consulted ONLY when the exact address-point tier
164
- * ({@link applyAddressPoint}) did NOT already stamp the street node (`resolution_tier === "address_point"`). That gate
191
+ * ({@link applyAddressPoint}) did NOT already stamp the street node (`resolution_tier === "address_point"`). That check
165
192
  * IS the "after the exact-point fall-through" — an estimate never overwrites a real situs point. Postcode-scoped (no
166
193
  * locality — the interpolators abstain statewide without a postcode). Stamps a DISTINCT metadata key
167
194
  * (`interpolated_point`, never `address_point`). Additive only — admin resolution is untouched.
@@ -171,61 +198,50 @@ export function applyInterpolation(
171
198
  lookup: InterpolationLookup,
172
199
  radiusCalibration?: number
173
200
  ): void {
174
- let street: AddressNode | undefined
175
- let houseNumber: AddressNode | undefined
176
- let directionalUnit: AddressNode | undefined
177
- let postcode: string | undefined
178
- let localityCoord: { lat: number; lon: number } | undefined
179
- const stack = [...roots]
201
+ const pairs = streetNumberPairs(roots)
202
+ const directionalUnit = [...walkNodes(roots)].find((n) => n.tag === "unit" && isDirectionalUnit(n.value))
203
+ const postcode = firstOfTag(roots, "postcode")?.value.trim()
204
+ // The resolved locality's coordinate — the `near` tie-breaker the interpolator may consult when the query carries
205
+ // no postcode and the covering ranges span several ZIPs (the borough-namesake class). Only a RESOLVED locality
206
+ // qualifies; an unresolved one contributes nothing.
207
+ const resolvedLocality = [...walkNodes(roots)].find((n) => n.tag === "locality" && n.lat != null && n.lon != null)
180
208
 
181
- while (stack.length) {
182
- const n = stack.pop()!
209
+ const localityCoord = resolvedLocality ? { lat: resolvedLocality.lat!, lon: resolvedLocality.lon! } : undefined
183
210
 
184
- if (n.tag === "street" && !street) {
185
- street = n
186
- }
211
+ if (!pairs.length) return
187
212
 
188
- if (n.tag === "house_number" && !houseNumber) {
189
- houseNumber = n
190
- }
191
-
192
- if (n.tag === "unit" && !directionalUnit && isDirectionalUnit(n.value)) {
193
- directionalUnit = n
194
- }
213
+ // The fall-through check: an exact situs point already won — never override it with an estimate.
214
+ if (pairs.some((pair) => pair.street.metadata?.["resolution_tier"] === "address_point")) return
195
215
 
196
- if (n.tag === "postcode" && !postcode && n.value.trim()) {
197
- postcode = n.value.trim()
198
- }
199
-
200
- // The resolved locality's coordinate — the `near` tie-breaker the interpolator may consult when
201
- // the query carries no postcode and the covering ranges span several ZIPs (the borough-namesake
202
- // class). Only a RESOLVED locality qualifies; an unresolved one contributes nothing.
203
- if (n.tag === "locality" && !localityCoord && n.lat != null && n.lon != null) {
204
- localityCoord = { lat: n.lat, lon: n.lon }
205
- }
216
+ const near = postcode ? undefined : localityCoord
206
217
 
207
- stack.push(...n.children)
208
- }
218
+ let street: AddressNode | undefined
219
+ let houseNumber: AddressNode | undefined
220
+ let hit: ReturnType<InterpolationLookup["find"]> | undefined
209
221
 
210
- if (!street || !houseNumber) return
222
+ for (const pair of pairs) {
223
+ hit = lookup.find({
224
+ street: assembleStreetValue(pair.street, directionalUnit),
225
+ number: pair.houseNumber.value,
226
+ postcode,
227
+ ...(near ? { near } : {}),
228
+ })
211
229
 
212
- // The fall-through gate: an exact situs point already won — never override it with an estimate.
213
- if (street.metadata?.["resolution_tier"] === "address_point") return
230
+ if (hit) {
231
+ street = pair.street
232
+ houseNumber = pair.houseNumber
214
233
 
215
- const near = postcode ? undefined : localityCoord
234
+ break
235
+ }
236
+ }
216
237
 
217
- const hit = lookup.find({
218
- street: assembleStreetValue(street, directionalUnit),
219
- number: houseNumber.value,
220
- postcode,
221
- ...(near ? { near } : {}),
222
- })
238
+ if (!hit || !street || !houseNumber) return
223
239
 
224
- if (!hit) return
240
+ houseNumber.metadata = { ...houseNumber.metadata, resolution_tier: "interpolated" }
225
241
  // Conformal-calibrated radius (#374): the raw half-segment heuristic underestimates the true spread
226
- // (~72% coverage on Travis); ×1.70 → a 90% bound. The ARTIFACT's own multiplier (read from the shard's
242
+ // (~72% coverage on Travis); ×1.70 → a 90% bound. The ARTIFACT's own multiplier (read from the extract's
227
243
  // `interp_calibration` metadata table at open time — `lookup.radiusCalibration`) is the default; an
228
- // explicit caller factor is the @internal instrument override. Neither present (shards predating the
244
+ // explicit caller factor is the @internal instrument override. Neither present (extracts predating the
229
245
  // metadata table, no caller factor) keeps the raw value, byte-stable. Preserve the raw radius for
230
246
  // transparency.
231
247
  const factor = radiusCalibration ?? lookup.radiusCalibration
@@ -248,7 +264,7 @@ export function applyInterpolation(
248
264
  * a place name ("Place Bellecour", "Cours de l'Intendance", "Quai des Bateliers"). Used by the #1042 street-centroid
249
265
  * tier to recognize a thoroughfare that the model mis-parsed as a `locality` (the FR no-street class, #901).
250
266
  * Deliberately generous — a false positive simply misses the exact street-centroid lookup and no-ops; the lookup is the
251
- * real gate.
267
+ * real check.
252
268
  */
253
269
  const FR_VOIE_TYPES: ReadonlySet<string> = new Set([
254
270
  "rue",
@@ -302,7 +318,9 @@ const FR_VOIE_TYPES: ReadonlySet<string> = new Set([
302
318
  ])
303
319
 
304
320
  /**
305
- * Fold to lower-case, diacritic-stripped, punctuation-free tokens — mirrors `street-normalize.ts`'s `fold`.
321
+ * Fold to lower-case, diacritic-stripped, punctuation-free tokens — a deliberate local copy of
322
+ * `@mailwoman/resolver-wof-sqlite/street-normalize`'s `fold`: `@mailwoman/resolver` does not depend on that package, so
323
+ * the two are kept in step by hand.
306
324
  */
307
325
  function foldVoieTokens(s: string): string[] {
308
326
  return s
@@ -357,13 +375,12 @@ export function applyStreetCentroid(
357
375
  let streetNode: AddressNode | undefined
358
376
  let houseNumber = false
359
377
  let postcode: string | undefined
360
- const adminValues: string[] = [] // region / locality values, in tree order (thoroughfare and commune both hide here)
361
- const resolvedCountries: string[] = [] // countries the tree actually resolved to — a post-resolution country hint
362
- const stack = [...roots]
363
-
364
- while (stack.length) {
365
- const n = stack.pop()!
378
+ // Region / locality values in document order (thoroughfare and commune both hide here), and the countries the tree
379
+ // resolved to — a post-resolution country hint.
380
+ const adminValues: string[] = []
381
+ const resolvedCountries: string[] = []
366
382
 
383
+ for (const n of walkNodes(roots)) {
367
384
  if (n.tag === "house_number") {
368
385
  houseNumber = true
369
386
  }
@@ -390,13 +407,11 @@ export function applyStreetCentroid(
390
407
  if (rc && !resolvedCountries.includes(rc)) {
391
408
  resolvedCountries.push(rc)
392
409
  }
393
-
394
- stack.push(...n.children)
395
410
  }
396
411
 
397
412
  if (houseNumber) return // street-only tier — a numbered address is the rooftop tiers' job
398
413
 
399
- // Candidate countries: pre-resolution hints (defaultCountry + ungated placer) then the resolved countries. BAN is
414
+ // Candidate countries: pre-resolution hints (defaultCountry + unrestricted placer) then the resolved countries. BAN is
400
415
  // FR-only, so a non-FR candidate simply yields no lookup; the exact (street, base-commune) match is the real filter.
401
416
  const countries: string[] = []
402
417
 
@@ -32,7 +32,7 @@
32
32
  * {@link rankByCountryPrior} covers the other half of the class — the query where a country IS
33
33
  * known, but only because a locale said so. See `span-rescore.ts` for where that one applies.
34
34
  *
35
- * Both obey the same three house rules, and neither is a gate:
35
+ * Both obey the same three house rules, and neither is a check:
36
36
  *
37
37
  * 1. **Tier-safe.** `exactMatch` stays the primary key. A soft prior re-orders WITHIN a tier; it never
38
38
  * promotes a partial match over an exact one.
@@ -44,7 +44,7 @@
44
44
  * 3. **Stable.** Equal keys keep their incoming order, so the backend's own ranking survives underneath. That order
45
45
  * carries decisions only the backend can make — the candidate backend's seat tiebreak
46
46
  * (`resolver-wof-sqlite/primary-preference.ts`) reaches an end-to-end answer solely through this stability
47
- * (#1729), so equal-key stability here is load-bearing, not cosmetic.
47
+ * (#1729), so equal-key stability here is required, not cosmetic.
48
48
  */
49
49
 
50
50
  import type { ResolvedPlace } from "@mailwoman/core/resolver"
@@ -313,12 +313,12 @@ export const NATIONAL_CAPITAL_MARGIN_LOG10 = 2
313
313
  *
314
314
  * The rule: within the exact tier, take the first NATIONAL-capital row and walk it upward past each row it is within
315
315
  * {@link NATIONAL_CAPITAL_MARGIN_LOG10} of, stopping at the first row over the margin or at another national capital.
316
- * Same three house rules as the other keys — tier-safe (never crosses the exact/partial boundary; the cost is real and
317
- * accepted: a capital that only PARTIALLY matched the query — Saint George's, Grenada for the abbreviated "St.
318
- * George's" — stays behind every exact match, because crossing that line is how iteration 1 answered bare "Djibouti"
319
- * with the capital city instead of the country), positive evidence only (no capital in the list → identity, and the
320
- * margin reads the same `prominence ?? score` size every other key does), and stable (non-promoted rows keep their
321
- * order).
316
+ * Same three house rules as the other keys — tier-safe (never crosses the exact/partial boundary.
317
+ *
318
+ * A capital that only PARTIALLY matched the query — Saint George's, Grenada for the abbreviated "St. George's" — stays
319
+ * behind every exact match, because crossing that line is how iteration 1 answered bare "Djibouti" with the capital
320
+ * city instead of the country), positive evidence only (no capital in the list → identity, and the margin reads the
321
+ * same `prominence ?? score` size every other key does), and stable (non-promoted rows keep their order).
322
322
  *
323
323
  * The margin deliberately re-uses log10-population units rather than the importance scale: the ratified importance flip
324
324
  * decisions (Whitby/Windsor/Springfield) sit on gaps of 0.004–0.02, while the capital contests this key exists for sit
@@ -59,12 +59,12 @@ export declare function applyExplicitCountryCoherence(roots: readonly AddressNod
59
59
  * same-named locality under it? Only when BOTH hold does it swap the region and locality to the in-country pair.
60
60
  * Geography confirms; the subdivision table is a soft name→country prior, not a routing decision.
61
61
  *
62
- * Evidence-gated to stay byte-stable on the domestic path. It fires ONLY when (a) a default country is in force, (b)
63
- * the region node is UNRESOLVED (the default-country filter came up empty — a US region resolves fine under `US`, so a
64
- * well-formed US query never trips this), (c) the token is a subdivision of a DIFFERENT country than the default, and
65
- * (d) both the foreign region and a same-named foreign locality resolve. "Springfield, IL" / "Portland, ME": the region
66
- * resolves under `US`, so gate (b) fails and the tree is untouched. Costs one region + one locality lookup per
62
+ * Evidence-conditional to stay byte-stable on the domestic path. It fires ONLY when (a) a default country is in force,
63
+ * (b) the region node is UNRESOLVED (the default-country filter came up empty — a US region resolves fine under `US`,
64
+ * so a well-formed US query never trips this), (c) the token is a subdivision of a DIFFERENT country than the default,
65
+ * and (d) both the foreign region and a same-named foreign locality resolve. "Springfield, IL" / "Portland, ME": the
66
+ * region resolves under `US`, so check (b) fails and the tree is untouched. Costs one region + one locality lookup per
67
67
  * triggering pair. See `ResolveOpts.adminCoherence`.
68
68
  */
69
69
  export declare function applyRegionCountryCoherence(roots: readonly AddressNode[], backend: ResolverBackend, defaultCountry: string | undefined): Promise<void>;
70
- //# sourceMappingURL=admin-coherence-passes.d.ts.map
70
+ //# sourceMappingURL=coherence-passes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coherence-passes.d.ts","sourceRoot":"","sources":["../../lib/admin/coherence-passes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAI9E;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBhH;AAoKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,6BAA6B,CAClD,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CA2Bf;AA2CD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,2BAA2B,CAChD,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,eAAe,EACxB,cAAc,EAAE,MAAM,GAAG,SAAS,GAChC,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
@@ -9,7 +9,7 @@
9
9
  * byte-stability guarantees are documented on the pass itself; `resolveTree` sequences them.
10
10
  */
11
11
  import { matchCountry, matchSubdivision } from "@mailwoman/codex/country";
12
- import { decorateNode, isResolvedWithCoord } from "./decorate-node.js";
12
+ import { decorateNode, isResolvedWithCoord } from "#decorate-node";
13
13
  /**
14
14
  * Admin descendant-consistency (#263) — the joint-consistency resolve, scoped to the admin assignment. The greedy walk
15
15
  * resolves a region on its own (name + population), so "ME" picks Messina (IT) over Maine, then scopes "Portland" to
@@ -243,11 +243,11 @@ async function reconcileExplicitCountry(countryNode, localityNode, backend) {
243
243
  * same-named locality under it? Only when BOTH hold does it swap the region and locality to the in-country pair.
244
244
  * Geography confirms; the subdivision table is a soft name→country prior, not a routing decision.
245
245
  *
246
- * Evidence-gated to stay byte-stable on the domestic path. It fires ONLY when (a) a default country is in force, (b)
247
- * the region node is UNRESOLVED (the default-country filter came up empty — a US region resolves fine under `US`, so a
248
- * well-formed US query never trips this), (c) the token is a subdivision of a DIFFERENT country than the default, and
249
- * (d) both the foreign region and a same-named foreign locality resolve. "Springfield, IL" / "Portland, ME": the region
250
- * resolves under `US`, so gate (b) fails and the tree is untouched. Costs one region + one locality lookup per
246
+ * Evidence-conditional to stay byte-stable on the domestic path. It fires ONLY when (a) a default country is in force,
247
+ * (b) the region node is UNRESOLVED (the default-country filter came up empty — a US region resolves fine under `US`,
248
+ * so a well-formed US query never trips this), (c) the token is a subdivision of a DIFFERENT country than the default,
249
+ * and (d) both the foreign region and a same-named foreign locality resolve. "Springfield, IL" / "Portland, ME": the
250
+ * region resolves under `US`, so check (b) fails and the tree is untouched. Costs one region + one locality lookup per
251
251
  * triggering pair. See `ResolveOpts.adminCoherence`.
252
252
  */
253
253
  export async function applyRegionCountryCoherence(roots, backend, defaultCountry) {
@@ -261,7 +261,7 @@ export async function applyRegionCountryCoherence(roots, backend, defaultCountry
261
261
  // Fire for an UNRESOLVED region (the default-country filter came up empty) whose companion locality node
262
262
  // exists — regardless of the locality's resolution state, so it covers both the resolved-but-foreign namesake
263
263
  // (Montreal → the greedy US pick, Montreal WI) and the unresolved locality the span-rescore tier would
264
- // otherwise back-fill with a US namesake. The in-country lookups below are the evidence gate.
264
+ // otherwise back-fill with a US namesake. The in-country lookups below are the evidence check.
265
265
  if (regionHere &&
266
266
  !isResolvedWithCoord(regionHere) &&
267
267
  (node.tag === "locality" || node.tag === "dependent_locality") &&
@@ -281,7 +281,7 @@ export async function applyRegionCountryCoherence(roots, backend, defaultCountry
281
281
  * default-country filter hid. `matchSubdivision` turns the region token into `{ name, country }` (null for anything
282
282
  * that isn't a US state or CA province → no-op); the region's full name then resolves it under that country (expanding
283
283
  * the abbreviation the gazetteer FTS index lacks), and the locality is re-scoped to the same country. Leaves both nodes
284
- * untouched unless every gate holds — the subdivision names a different country than the default, the region resolves
284
+ * untouched unless every check holds — the subdivision names a different country than the default, the region resolves
285
285
  * under it, and a same-named locality exists there — so the domestic path stays byte-identical.
286
286
  */
287
287
  async function reconcileRegionCountry(regionNode, localityNode, backend, defaultCountry) {
@@ -324,4 +324,4 @@ async function reconcileRegionCountry(regionNode, localityNode, backend, default
324
324
  decorateNode(localityNode, lc, scoped.filter((l) => l !== lc));
325
325
  localityNode.metadata = { ...localityNode.metadata, region_country_repicked: true };
326
326
  }
327
- //# sourceMappingURL=admin-coherence-passes.js.map
327
+ //# sourceMappingURL=coherence-passes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coherence-passes.js","sourceRoot":"","sources":["../../lib/admin/coherence-passes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAIzE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAElE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,KAA6B,EAAE,OAAwB;IAChG,MAAM,KAAK,GAAG,KAAK,EAAE,IAAiB,EAAE,cAAkC,EAAiB,EAAE;QAC5F,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAA;QAE7F,IACC,UAAU;YACV,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,IAAI,IAAI,CAAC,GAAG,KAAK,oBAAoB,CAAC;YAC9D,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,EACvB,CAAC;YACF,MAAM,kBAAkB,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,MAAM,KAAK,CAAC,KAAK,EAAE,UAAU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AAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAElF,IAAI,CAAC,EAAE;QAAE,OAAM;IAEf,kHAAkH;IAClH,+FAA+F;IAC/F,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC;QACtC,IAAI,EAAE,YAAY,CAAC,KAAK;QACxB,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,KAAK,EAAE,CAAC;KACR,CAAC,CAAA;IAEF,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IAE5E,IAAI,CAAC,EAAE;QAAE,OAAM;IAEf,oHAAoH;IACpH,YAAY,CACX,UAAU,EACV,EAAE,EACF,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CACpC,CAAA;IAED,UAAU,CAAC,QAAQ,GAAG,EAAE,GAAG,UAAU,CAAC,QAAQ,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAA;IAE/E,YAAY,CACX,YAAY,EACZ,EAAE,EACF,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAC9B,CAAA;IAED,YAAY,CAAC,QAAQ,GAAG,EAAE,GAAG,YAAY,CAAC,QAAQ,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAA;AACpF,CAAC"}
@@ -9,13 +9,13 @@
9
9
  * before the limit window (so a contained candidate can reach the walk at all), and the resolver
10
10
  * walk partitions AGAIN after its fame/anchor re-ranks (so `rankByImportance` cannot hand the top
11
11
  * slot back to a more-famous uncontained namesake — Richmond VA outscores Richmond, North
12
- * Yorkshire on importance, and without the second partition the lever loses exactly where fame
12
+ * Yorkshire on importance, and without the second partition the change loses exactly where fame
13
13
  * disagrees with the qualifier). Two call sites, one function, one ordering.
14
14
  */
15
- import type { AddressNode } from "@mailwoman/core/decoder";
15
+ import { type AddressNode } from "@mailwoman/core/decoder";
16
16
  /**
17
17
  * Find the first non-empty region-tagged span anywhere in a tree — the qualifier the walk threads onto locality
18
- * lookups. Deliberately the same node the admin-coherence VERDICTS read (the first `region` node), so the lever's
18
+ * lookups. Deliberately the same node the admin-coherence VERDICTS read (the first `region` node), so the change's
19
19
  * firing population and the flag's `contradicted` population are the same rows. A `region` slot can hold a country name
20
20
  * the parser mislabeled ("Moscow, Russia" parses region="Russia") — the backend's qualifier probe answers that too,
21
21
  * because containment is containment whatever tier the container sits at.
@@ -36,7 +36,7 @@ export declare function firstRegionQualifier(roots: readonly AddressNode[]): str
36
36
  */
37
37
  export declare function partitionByContainment<T>(rows: readonly T[], isContained: (row: T) => boolean, isExact: (row: T) => boolean): T[];
38
38
  /**
39
- * The trace verdict for one locality pick under the lever — stamped as `metadata.admin_containment` so an inert
39
+ * The trace verdict for one locality pick under the change — stamped as `metadata.admin_containment` so an inert
40
40
  * mechanism is visible in the result rather than silently dead (#1719's rule). Derived from the candidates'
41
41
  * `containedByQualifier` stamps: any `true` → `"contained"`; stamps present but none true → `"no_contained_candidate"`;
42
42
  * no stamps at all → `"unavailable"` (the backend or artifact cannot answer — a pre-sidecar candidate.db, the FTS or
@@ -45,4 +45,4 @@ export declare function partitionByContainment<T>(rows: readonly T[], isContaine
45
45
  export declare function adminContainmentVerdict(candidates: ReadonlyArray<{
46
46
  containedByQualifier?: boolean | undefined;
47
47
  }>): "contained" | "no_contained_candidate" | "unavailable";
48
- //# sourceMappingURL=admin-containment.d.ts.map
48
+ //# sourceMappingURL=containment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../lib/admin/containment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1E;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,GAAG,SAAS,CAEtF;AAED;;;;;;;;;;;;GAYG;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;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,aAAa,CAAC;IAAE,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,CAAC,GACvE,WAAW,GAAG,wBAAwB,GAAG,aAAa,CAYxD"}
@@ -9,25 +9,19 @@
9
9
  * before the limit window (so a contained candidate can reach the walk at all), and the resolver
10
10
  * walk partitions AGAIN after its fame/anchor re-ranks (so `rankByImportance` cannot hand the top
11
11
  * slot back to a more-famous uncontained namesake — Richmond VA outscores Richmond, North
12
- * Yorkshire on importance, and without the second partition the lever loses exactly where fame
12
+ * Yorkshire on importance, and without the second partition the change loses exactly where fame
13
13
  * disagrees with the qualifier). Two call sites, one function, one ordering.
14
14
  */
15
+ import { firstNodeWhere } from "@mailwoman/core/decoder";
15
16
  /**
16
17
  * Find the first non-empty region-tagged span anywhere in a tree — the qualifier the walk threads onto locality
17
- * lookups. Deliberately the same node the admin-coherence VERDICTS read (the first `region` node), so the lever's
18
+ * lookups. Deliberately the same node the admin-coherence VERDICTS read (the first `region` node), so the change's
18
19
  * firing population and the flag's `contradicted` population are the same rows. A `region` slot can hold a country name
19
20
  * the parser mislabeled ("Moscow, Russia" parses region="Russia") — the backend's qualifier probe answers that too,
20
21
  * because containment is containment whatever tier the container sits at.
21
22
  */
22
23
  export function firstRegionQualifier(roots) {
23
- const stack = [...roots];
24
- while (stack.length) {
25
- const n = stack.pop();
26
- if (n.tag === "region" && n.value.trim().length)
27
- return n.value.trim();
28
- stack.push(...n.children);
29
- }
30
- return undefined;
24
+ return firstNodeWhere(roots, (n) => n.tag === "region" && n.value.trim().length > 0)?.value.trim();
31
25
  }
32
26
  /**
33
27
  * Stable, TIER-SAFE partition: within each match tier, candidates the containment source vouched for (`isContained`)
@@ -62,7 +56,7 @@ export function partitionByContainment(rows, isContained, isExact) {
62
56
  return out;
63
57
  }
64
58
  /**
65
- * The trace verdict for one locality pick under the lever — stamped as `metadata.admin_containment` so an inert
59
+ * The trace verdict for one locality pick under the change — stamped as `metadata.admin_containment` so an inert
66
60
  * mechanism is visible in the result rather than silently dead (#1719's rule). Derived from the candidates'
67
61
  * `containedByQualifier` stamps: any `true` → `"contained"`; stamps present but none true → `"no_contained_candidate"`;
68
62
  * no stamps at all → `"unavailable"` (the backend or artifact cannot answer — a pre-sidecar candidate.db, the FTS or
@@ -79,4 +73,4 @@ export function adminContainmentVerdict(candidates) {
79
73
  }
80
74
  return evaluated ? "no_contained_candidate" : "unavailable";
81
75
  }
82
- //# sourceMappingURL=admin-containment.js.map
76
+ //# sourceMappingURL=containment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containment.js","sourceRoot":"","sources":["../../lib/admin/containment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAoB,MAAM,yBAAyB,CAAA;AAE1E;;;;;;GAMG;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,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,EAAE,CAAA;AACnG,CAAC;A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CAAC;QACpC,IAAI,SAAS,CAAC,oBAAoB,KAAK,IAAI;YAAE,OAAO,WAAW,CAAA;QAE/D,IAAI,SAAS,CAAC,oBAAoB,KAAK,SAAS,EAAE,CAAC;YAClD,SAAS,GAAG,IAAI,CAAA;QACjB,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,aAAa,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#admin/coherence-passes";
7
+ export * from "#admin/containment";
8
+ export * from "#admin/jp-municipality";
9
+ export * from "#admin/winner";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/admin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export * from "#admin/coherence-passes";
7
+ export * from "#admin/containment";
8
+ export * from "#admin/jp-municipality";
9
+ export * from "#admin/winner";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/admin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA"}