@mailwoman/core 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.
Files changed (380) hide show
  1. package/README.md +1 -1
  2. package/api/responses.ts +12 -0
  3. package/coarse-placer/featurize.ts +0 -2
  4. package/coarse-placer/tools/build-dataset.ts +2 -2
  5. package/coarse-placer/tools/build-outlier-exposure.ts +2 -2
  6. package/coarse-placer/tools/build-outlier-latin.ts +14 -8
  7. package/coarse-placer/tools/build-outlier-oa.ts +12 -6
  8. package/coarse-placer/tools/eval-latin-offmap.ts +3 -4
  9. package/coarse-placer/tools/eval-openset.ts +3 -3
  10. package/coarse-placer/tools/eval-quant-compare.ts +3 -3
  11. package/coarse-placer/tools/eval.ts +3 -3
  12. package/coarse-placer/tools/fnv-hash.ts +1 -6
  13. package/coarse-placer/tools/index.ts +1 -1
  14. package/coarse-placer/tools/probe-frontier.ts +3 -4
  15. package/coarse-placer/tools/quantize.ts +3 -2
  16. package/coarse-placer/tools/train.ts +2 -2
  17. package/crypto/node.ts +3 -1
  18. package/data/internal/dictionaries/languages.csv +184 -184
  19. package/data/libpostal/README.md +8 -2
  20. package/db/schema.ts +12 -3
  21. package/decoder/build-tree.ts +19 -0
  22. package/decoder/containment.ts +5 -1
  23. package/decoder/index.ts +1 -0
  24. package/decoder/parse-diff.ts +347 -0
  25. package/decoder/proposals-to-tree.ts +1 -1
  26. package/decoder/serialize-json.ts +51 -7
  27. package/decoder/serialize-tuples.ts +7 -1
  28. package/decoder/serialize-xml.ts +1 -1
  29. package/decoder/tree-shape.ts +144 -0
  30. package/decoder/types.ts +8 -0
  31. package/decoder/validate-tree.ts +15 -3
  32. package/env/index.ts +3 -1
  33. package/env/paths.ts +21 -33
  34. package/env/schema.ts +35 -3
  35. package/fs/utils/formatters.ts +107 -0
  36. package/fs/utils/index.ts +7 -0
  37. package/fs/zip.ts +297 -0
  38. package/layers/manifest.ts +56 -15
  39. package/layers/schema.ts +54 -2
  40. package/locale/locale.ts +1 -1
  41. package/locale/registry.ts +1 -1
  42. package/objects.ts +20 -8
  43. package/out/api/responses.d.ts +9 -0
  44. package/out/api/responses.d.ts.map +1 -1
  45. package/out/api/responses.js +11 -0
  46. package/out/api/responses.js.map +1 -1
  47. package/out/coarse-placer/featurize.d.ts +0 -1
  48. package/out/coarse-placer/featurize.d.ts.map +1 -1
  49. package/out/coarse-placer/featurize.js.map +1 -1
  50. package/out/coarse-placer/tools/build-dataset.js +1 -2
  51. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  52. package/out/coarse-placer/tools/build-outlier-exposure.js +1 -2
  53. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  54. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  55. package/out/coarse-placer/tools/build-outlier-latin.js +12 -8
  56. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  57. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  58. package/out/coarse-placer/tools/build-outlier-oa.js +10 -6
  59. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  60. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  61. package/out/coarse-placer/tools/eval-latin-offmap.js +2 -4
  62. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  63. package/out/coarse-placer/tools/eval-openset.js +2 -3
  64. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  65. package/out/coarse-placer/tools/eval-quant-compare.js +2 -3
  66. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  67. package/out/coarse-placer/tools/eval.js +2 -3
  68. package/out/coarse-placer/tools/eval.js.map +1 -1
  69. package/out/coarse-placer/tools/fnv-hash.d.ts +1 -6
  70. package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
  71. package/out/coarse-placer/tools/fnv-hash.js +1 -6
  72. package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
  73. package/out/coarse-placer/tools/index.d.ts +1 -1
  74. package/out/coarse-placer/tools/index.js +1 -1
  75. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  76. package/out/coarse-placer/tools/probe-frontier.js +2 -4
  77. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  78. package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
  79. package/out/coarse-placer/tools/quantize.js +2 -2
  80. package/out/coarse-placer/tools/quantize.js.map +1 -1
  81. package/out/coarse-placer/tools/train.js +1 -2
  82. package/out/coarse-placer/tools/train.js.map +1 -1
  83. package/out/crypto/node.d.ts.map +1 -1
  84. package/out/crypto/node.js +2 -1
  85. package/out/crypto/node.js.map +1 -1
  86. package/out/db/schema.d.ts +12 -3
  87. package/out/db/schema.d.ts.map +1 -1
  88. package/out/db/schema.js +6 -0
  89. package/out/db/schema.js.map +1 -1
  90. package/out/decoder/build-tree.d.ts.map +1 -1
  91. package/out/decoder/build-tree.js +17 -0
  92. package/out/decoder/build-tree.js.map +1 -1
  93. package/out/decoder/containment.d.ts.map +1 -1
  94. package/out/decoder/containment.js +5 -1
  95. package/out/decoder/containment.js.map +1 -1
  96. package/out/decoder/index.d.ts +1 -0
  97. package/out/decoder/index.d.ts.map +1 -1
  98. package/out/decoder/index.js +1 -0
  99. package/out/decoder/index.js.map +1 -1
  100. package/out/decoder/parse-diff.d.ts +125 -0
  101. package/out/decoder/parse-diff.d.ts.map +1 -0
  102. package/out/decoder/parse-diff.js +219 -0
  103. package/out/decoder/parse-diff.js.map +1 -0
  104. package/out/decoder/proposals-to-tree.js.map +1 -1
  105. package/out/decoder/serialize-json.d.ts +29 -0
  106. package/out/decoder/serialize-json.d.ts.map +1 -1
  107. package/out/decoder/serialize-json.js +20 -4
  108. package/out/decoder/serialize-json.js.map +1 -1
  109. package/out/decoder/serialize-tuples.d.ts +8 -1
  110. package/out/decoder/serialize-tuples.d.ts.map +1 -1
  111. package/out/decoder/serialize-tuples.js +7 -1
  112. package/out/decoder/serialize-tuples.js.map +1 -1
  113. package/out/decoder/serialize-xml.js +1 -1
  114. package/out/decoder/serialize-xml.js.map +1 -1
  115. package/out/decoder/tree-shape.d.ts +84 -0
  116. package/out/decoder/tree-shape.d.ts.map +1 -0
  117. package/out/decoder/tree-shape.js +98 -0
  118. package/out/decoder/tree-shape.js.map +1 -0
  119. package/out/decoder/types.d.ts +11 -0
  120. package/out/decoder/types.d.ts.map +1 -1
  121. package/out/decoder/validate-tree.d.ts +8 -0
  122. package/out/decoder/validate-tree.d.ts.map +1 -1
  123. package/out/decoder/validate-tree.js +4 -3
  124. package/out/decoder/validate-tree.js.map +1 -1
  125. package/out/env/index.d.ts +13 -1
  126. package/out/env/index.d.ts.map +1 -1
  127. package/out/env/index.js +2 -1
  128. package/out/env/index.js.map +1 -1
  129. package/out/env/paths.d.ts +15 -8
  130. package/out/env/paths.d.ts.map +1 -1
  131. package/out/env/paths.js +19 -29
  132. package/out/env/paths.js.map +1 -1
  133. package/out/env/schema.d.ts +12 -1
  134. package/out/env/schema.d.ts.map +1 -1
  135. package/out/env/schema.js +33 -3
  136. package/out/env/schema.js.map +1 -1
  137. package/out/fs/utils/formatters.d.ts +57 -0
  138. package/out/fs/utils/formatters.d.ts.map +1 -0
  139. package/out/fs/utils/formatters.js +79 -0
  140. package/out/fs/utils/formatters.js.map +1 -0
  141. package/out/fs/utils/index.d.ts +7 -0
  142. package/out/fs/utils/index.d.ts.map +1 -0
  143. package/out/fs/utils/index.js +7 -0
  144. package/out/fs/utils/index.js.map +1 -0
  145. package/out/fs/zip.d.ts +116 -0
  146. package/out/fs/zip.d.ts.map +1 -0
  147. package/out/fs/zip.js +216 -0
  148. package/out/fs/zip.js.map +1 -0
  149. package/out/layers/manifest.d.ts +32 -7
  150. package/out/layers/manifest.d.ts.map +1 -1
  151. package/out/layers/manifest.js +31 -6
  152. package/out/layers/manifest.js.map +1 -1
  153. package/out/layers/schema.d.ts +48 -2
  154. package/out/layers/schema.d.ts.map +1 -1
  155. package/out/layers/schema.js +32 -0
  156. package/out/layers/schema.js.map +1 -1
  157. package/out/locale/locale.d.ts +1 -1
  158. package/out/locale/locale.d.ts.map +1 -1
  159. package/out/locale/registry.js +1 -1
  160. package/out/locale/registry.js.map +1 -1
  161. package/out/objects.d.ts +12 -6
  162. package/out/objects.d.ts.map +1 -1
  163. package/out/objects.js +4 -1
  164. package/out/objects.js.map +1 -1
  165. package/out/pipeline/index.d.ts +3 -7
  166. package/out/pipeline/index.d.ts.map +1 -1
  167. package/out/pipeline/index.js +2 -4
  168. package/out/pipeline/index.js.map +1 -1
  169. package/out/pipeline/runtime-pipeline.d.ts +51 -9
  170. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  171. package/out/pipeline/runtime-pipeline.js +46 -133
  172. package/out/pipeline/runtime-pipeline.js.map +1 -1
  173. package/out/pipeline/span-proposer.js +1 -1
  174. package/out/pipeline/span-proposer.js.map +1 -1
  175. package/out/pipeline/types.d.ts +137 -16
  176. package/out/pipeline/types.d.ts.map +1 -1
  177. package/out/pipeline/types.js +30 -0
  178. package/out/pipeline/types.js.map +1 -1
  179. package/out/policy/defaults.d.ts +1 -1
  180. package/out/policy/defaults.d.ts.map +1 -1
  181. package/out/policy/defaults.js +1 -1
  182. package/out/policy/defaults.js.map +1 -1
  183. package/out/policy/policy.d.ts +1 -1
  184. package/out/policy/policy.d.ts.map +1 -1
  185. package/out/policy/registry.d.ts +1 -1
  186. package/out/policy/registry.d.ts.map +1 -1
  187. package/out/resolver/coverage-facts.d.ts +89 -0
  188. package/out/resolver/coverage-facts.d.ts.map +1 -0
  189. package/out/resolver/coverage-facts.js +22 -0
  190. package/out/resolver/coverage-facts.js.map +1 -0
  191. package/out/resolver/index.d.ts +4 -1
  192. package/out/resolver/index.d.ts.map +1 -1
  193. package/out/resolver/index.js +2 -0
  194. package/out/resolver/index.js.map +1 -1
  195. package/out/resolver/lookup-types.d.ts +178 -0
  196. package/out/resolver/lookup-types.d.ts.map +1 -0
  197. package/out/resolver/lookup-types.js +11 -0
  198. package/out/resolver/lookup-types.js.map +1 -0
  199. package/out/resolver/placetype-map.d.ts +71 -0
  200. package/out/resolver/placetype-map.d.ts.map +1 -0
  201. package/out/resolver/placetype-map.js +98 -0
  202. package/out/resolver/placetype-map.js.map +1 -0
  203. package/out/resolver/postcode-format.d.ts +38 -0
  204. package/out/resolver/postcode-format.d.ts.map +1 -0
  205. package/out/resolver/postcode-format.js +83 -0
  206. package/out/resolver/postcode-format.js.map +1 -0
  207. package/out/resolver/referential.d.ts +73 -0
  208. package/out/resolver/referential.d.ts.map +1 -0
  209. package/out/resolver/referential.js +71 -0
  210. package/out/resolver/referential.js.map +1 -0
  211. package/out/resolver/types.d.ts +401 -264
  212. package/out/resolver/types.d.ts.map +1 -1
  213. package/out/resolver/types.js +4 -97
  214. package/out/resolver/types.js.map +1 -1
  215. package/out/resources/git.d.ts +8 -1
  216. package/out/resources/git.d.ts.map +1 -1
  217. package/out/resources/git.js +4 -3
  218. package/out/resources/git.js.map +1 -1
  219. package/out/resources/languages/types.gen.d.ts +1 -1
  220. package/out/resources/languages/types.gen.d.ts.map +1 -1
  221. package/out/resources/languages/types.gen.js +40 -0
  222. package/out/resources/languages/types.gen.js.map +1 -1
  223. package/out/resources/libpostal.d.ts +2 -2
  224. package/out/resources/libpostal.d.ts.map +1 -1
  225. package/out/resources/libpostal.js +2 -2
  226. package/out/resources/libpostal.js.map +1 -1
  227. package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
  228. package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
  229. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
  230. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  231. package/out/resources/whosonfirst/PlacetypeDataSource.js +28 -3
  232. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  233. package/out/resources/whosonfirst/loader.d.ts +2 -2
  234. package/out/resources/whosonfirst/loader.d.ts.map +1 -1
  235. package/out/resources/whosonfirst/loader.js.map +1 -1
  236. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  237. package/out/resources/whosonfirst/placetypes/Placetype.js +1 -1
  238. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  239. package/out/resources/whosonfirst/placetypes/admin.d.ts +9 -1
  240. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  241. package/out/resources/whosonfirst/placetypes/admin.js +1 -1
  242. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  243. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  244. package/out/resources/whosonfirst/placetypes/definition.js +1 -1
  245. package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
  246. package/out/resources/whosonfirst/placetypes/index.d.ts +1 -0
  247. package/out/resources/whosonfirst/placetypes/index.d.ts.map +1 -1
  248. package/out/resources/whosonfirst/placetypes/index.js +1 -0
  249. package/out/resources/whosonfirst/placetypes/index.js.map +1 -1
  250. package/out/resources/whosonfirst/placetypes/specificity.d.ts +65 -0
  251. package/out/resources/whosonfirst/placetypes/specificity.d.ts.map +1 -0
  252. package/out/resources/whosonfirst/placetypes/specificity.js +101 -0
  253. package/out/resources/whosonfirst/placetypes/specificity.js.map +1 -0
  254. package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
  255. package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -1
  256. package/out/resources/whosonfirst/sharded-repo.js +46 -2
  257. package/out/resources/whosonfirst/sharded-repo.js.map +1 -1
  258. package/out/scripting/arguments.d.ts +27 -0
  259. package/out/scripting/arguments.d.ts.map +1 -0
  260. package/out/scripting/arguments.js +32 -0
  261. package/out/scripting/arguments.js.map +1 -0
  262. package/out/scripting/command.d.ts +28 -0
  263. package/out/scripting/command.d.ts.map +1 -0
  264. package/out/scripting/command.js +47 -0
  265. package/out/scripting/command.js.map +1 -0
  266. package/out/scripting/index.js +3 -3
  267. package/out/scripting/index.js.map +1 -1
  268. package/out/scripting/utils/index.d.ts +1 -12
  269. package/out/scripting/utils/index.d.ts.map +1 -1
  270. package/out/scripting/utils/index.js +4 -21
  271. package/out/scripting/utils/index.js.map +1 -1
  272. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  273. package/out/tools/download-libpostal-resources.js +4 -7
  274. package/out/tools/download-libpostal-resources.js.map +1 -1
  275. package/out/tools/download-ssl-address.d.ts +3 -3
  276. package/out/tools/download-ssl-address.d.ts.map +1 -1
  277. package/out/tools/download-ssl-address.js +26 -13
  278. package/out/tools/download-ssl-address.js.map +1 -1
  279. package/out/tools/generate-language-types.d.ts +16 -1
  280. package/out/tools/generate-language-types.d.ts.map +1 -1
  281. package/out/tools/generate-language-types.js +38 -5
  282. package/out/tools/generate-language-types.js.map +1 -1
  283. package/out/tools/index.d.ts +1 -2
  284. package/out/tools/index.d.ts.map +1 -1
  285. package/out/tools/index.js +1 -2
  286. package/out/tools/index.js.map +1 -1
  287. package/out/utils/data-root.d.ts +27 -7
  288. package/out/utils/data-root.d.ts.map +1 -1
  289. package/out/utils/data-root.js +36 -13
  290. package/out/utils/data-root.js.map +1 -1
  291. package/out/utils/hash.d.ts +2 -3
  292. package/out/utils/hash.d.ts.map +1 -1
  293. package/out/utils/hash.js +3 -3
  294. package/out/utils/hash.js.map +1 -1
  295. package/out/utils/index.d.ts +1 -0
  296. package/out/utils/index.d.ts.map +1 -1
  297. package/out/utils/index.js +1 -0
  298. package/out/utils/index.js.map +1 -1
  299. package/out/utils/jsonl.js +1 -1
  300. package/out/utils/jsonl.js.map +1 -1
  301. package/out/utils/repo.d.ts +8 -0
  302. package/out/utils/repo.d.ts.map +1 -1
  303. package/out/utils/repo.js +10 -1
  304. package/out/utils/repo.js.map +1 -1
  305. package/out/utils/sealed-db.d.ts +11 -0
  306. package/out/utils/sealed-db.d.ts.map +1 -1
  307. package/out/utils/sealed-db.js +28 -1
  308. package/out/utils/sealed-db.js.map +1 -1
  309. package/out/utils/sqlite-rows.d.ts +34 -0
  310. package/out/utils/sqlite-rows.d.ts.map +1 -0
  311. package/out/utils/sqlite-rows.js +37 -0
  312. package/out/utils/sqlite-rows.js.map +1 -0
  313. package/out/utils/stats.d.ts +1 -6
  314. package/out/utils/stats.d.ts.map +1 -1
  315. package/out/utils/stats.js +1 -6
  316. package/out/utils/stats.js.map +1 -1
  317. package/package.json +488 -8
  318. package/pipeline/index.ts +14 -15
  319. package/pipeline/runtime-pipeline.ts +48 -184
  320. package/pipeline/span-proposer.ts +1 -1
  321. package/pipeline/types.ts +143 -16
  322. package/policy/defaults.ts +1 -1
  323. package/policy/policy.ts +1 -1
  324. package/policy/registry.ts +1 -1
  325. package/resolver/coverage-facts.ts +102 -0
  326. package/resolver/index.ts +18 -0
  327. package/resolver/lookup-types.ts +174 -0
  328. package/resolver/placetype-map.ts +122 -0
  329. package/resolver/postcode-format.ts +89 -0
  330. package/resolver/referential.ts +84 -0
  331. package/resolver/types.ts +423 -315
  332. package/resources/git.ts +18 -4
  333. package/resources/languages/types.gen.ts +60 -0
  334. package/resources/libpostal.ts +4 -3
  335. package/resources/whosonfirst/DataSourceCache.ts +2 -1
  336. package/resources/whosonfirst/PlacetypeDataSource.ts +36 -11
  337. package/resources/whosonfirst/loader.ts +3 -2
  338. package/resources/whosonfirst/placetypes/Placetype.ts +2 -1
  339. package/resources/whosonfirst/placetypes/admin.ts +11 -2
  340. package/resources/whosonfirst/placetypes/definition.ts +4 -3
  341. package/resources/whosonfirst/placetypes/index.ts +1 -0
  342. package/resources/whosonfirst/placetypes/specificity.ts +114 -0
  343. package/resources/whosonfirst/sharded-repo.ts +55 -2
  344. package/scripting/arguments.ts +38 -0
  345. package/scripting/command.ts +55 -0
  346. package/scripting/index.ts +3 -3
  347. package/scripting/utils/index.ts +5 -23
  348. package/tools/download-libpostal-resources.ts +4 -7
  349. package/tools/download-ssl-address.ts +28 -12
  350. package/tools/generate-language-types.ts +39 -5
  351. package/tools/index.ts +1 -2
  352. package/utils/data-root.ts +40 -14
  353. package/utils/hash.ts +5 -4
  354. package/utils/index.ts +1 -0
  355. package/utils/jsonl.ts +1 -1
  356. package/utils/repo.ts +12 -1
  357. package/utils/sealed-db.ts +30 -1
  358. package/utils/sqlite-rows.ts +40 -0
  359. package/utils/stats.ts +1 -6
  360. package/data/libpostal/dictionaries/all/chains.txt +0 -504
  361. package/kysley/adapter.ts +0 -29
  362. package/out/kysley/adapter.d.ts +0 -13
  363. package/out/kysley/adapter.d.ts.map +0 -1
  364. package/out/kysley/adapter.js +0 -25
  365. package/out/kysley/adapter.js.map +0 -1
  366. package/out/pipeline/reconcile-lookups.d.ts +0 -39
  367. package/out/pipeline/reconcile-lookups.d.ts.map +0 -1
  368. package/out/pipeline/reconcile-lookups.js +0 -88
  369. package/out/pipeline/reconcile-lookups.js.map +0 -1
  370. package/out/pipeline/reconcile.d.ts +0 -153
  371. package/out/pipeline/reconcile.d.ts.map +0 -1
  372. package/out/pipeline/reconcile.js +0 -388
  373. package/out/pipeline/reconcile.js.map +0 -1
  374. package/out/pipeline/span-logit-aggregation.d.ts +0 -58
  375. package/out/pipeline/span-logit-aggregation.d.ts.map +0 -1
  376. package/out/pipeline/span-logit-aggregation.js +0 -117
  377. package/out/pipeline/span-logit-aggregation.js.map +0 -1
  378. package/pipeline/reconcile-lookups.ts +0 -111
  379. package/pipeline/reconcile.ts +0 -583
  380. package/pipeline/span-logit-aggregation.ts +0 -156
@@ -0,0 +1,178 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The SYNCHRONOUS street-tier lookup contracts the resolution ladder is built on — address point,
7
+ * interpolation, street centroid, postcode prefix. Synchronous by design: `@mailwoman/neural` calls into this
8
+ * ladder, so turning one member async forces every implementer and both package boundaries async with it.
9
+ */
10
+ /**
11
+ * One exact address-point hit (#476): a real situs coordinate for `(street, number)` within a postcode/locality scope —
12
+ * the street-level tier in front of admin-centroid resolution.
13
+ */
14
+ export interface AddressPointHit {
15
+ lat: number;
16
+ lon: number;
17
+ /**
18
+ * Provenance, e.g. `"overture:NAD"`.
19
+ */
20
+ source: string;
21
+ /**
22
+ * Pinned data release the point came from, e.g. `"2026-05-20.0"`.
23
+ */
24
+ release: string;
25
+ /**
26
+ * The point's OWN scope tags, when the shard row carries them — the register's locality (normalized key form) and
27
+ * postcode. A rooftop answer can then be DECORATED with the commune/postcode the register attests, which a query that
28
+ * never named them cannot supply. Optional: not every source carries both, and existing readers/consumers predate the
29
+ * fields.
30
+ */
31
+ localityNorm?: string;
32
+ postcode?: string;
33
+ }
34
+ /**
35
+ * Street-level exact-point lookup (#476). Implementations own their normalization — both the shard build and this
36
+ * lookup must apply the SAME normalizer (see `resolver-wof-sqlite/street-normalize.ts`). Core depends only on this
37
+ * contract.
38
+ */
39
+ export interface AddressPointLookup {
40
+ find(query: {
41
+ street: string;
42
+ number: string;
43
+ postcode?: string;
44
+ locality?: string;
45
+ /**
46
+ * Optional bbox scope (`minLat`/`maxLat`/`minLon`/`maxLon`), tried AFTER postcode/locality. For shards whose points
47
+ * carry no postcode/locality of their own (OSM addr nodes often don't) but DO carry a coordinate — the resolved
48
+ * locality's bounding box scopes the `(street, number)` probe instead. US situs never passes it (byte-stable).
49
+ */
50
+ bbox?: {
51
+ minLat: number;
52
+ maxLat: number;
53
+ minLon: number;
54
+ maxLon: number;
55
+ };
56
+ }): AddressPointHit | null;
57
+ }
58
+ /**
59
+ * One interpolated coordinate estimate (#483) — NEVER an exact situs point (`uncertaintyM` prices the estimate
60
+ * honestly). Structural mirror of `InterpolatedHit` in `resolver-wof-sqlite/interpolation.ts`; keep this a SUBSET of
61
+ * that shape so the concrete `StreetInterpolator`/`AddressPointInterpolator` satisfy {@link InterpolationLookup} with no
62
+ * adapter (the {@link AddressPointHit} precedent).
63
+ */
64
+ export interface InterpolatedPointHit {
65
+ lat: number;
66
+ lon: number;
67
+ interpolated: true;
68
+ /**
69
+ * `address_point` = bracketed between real neighbor points; `tiger_range` = linear within a segment range.
70
+ */
71
+ method: "address_point" | "tiger_range";
72
+ /**
73
+ * False when only the opposite side's range contained the number (right block, wrong side).
74
+ */
75
+ parityMatched?: boolean;
76
+ /**
77
+ * `both` = neighbors bracketed it; `single` = one-sided extrapolation (larger uncertainty).
78
+ */
79
+ bracket?: "both" | "single";
80
+ /**
81
+ * Honest uncertainty radius in METERS (half the matched segment length).
82
+ */
83
+ uncertaintyM: number;
84
+ source: string;
85
+ release: string;
86
+ }
87
+ /**
88
+ * House-number interpolation lookup (#483). Like {@link AddressPointLookup}, implementations own their normalization
89
+ * (the shared `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Postcode-scoped; without
90
+ * a postcode the tier answers only when the covering ranges agree on ONE postcode — `near` (the resolved locality's
91
+ * coordinate) lets an implementation break a multi-postcode tie by segment proximity instead of abstaining (the
92
+ * Brooklyn-vs-Great-Neck namesake class). Optional and advisory: implementations may ignore it.
93
+ */
94
+ export interface InterpolationLookup {
95
+ find(query: {
96
+ street: string;
97
+ number: string;
98
+ postcode?: string;
99
+ near?: {
100
+ lat: number;
101
+ lon: number;
102
+ };
103
+ }): InterpolatedPointHit | null;
104
+ /**
105
+ * The ARTIFACT's own conformal radius multiplier for `uncertaintyM` (#374), read from the shard's
106
+ * `interp_calibration` metadata table at open time (the pair-index δ/transitionBeta header precedent): the multiplier
107
+ * is a property of the calibration set the artifact was built against, so it ships in the artifact, not in caller
108
+ * code. The resolver applies it as the DEFAULT whenever `ResolveOpts.interpolationRadiusCalibration` is absent.
109
+ * `undefined` (or an implementation without the property) = the artifact carries none — shards built before the
110
+ * metadata table existed; behavior is then exactly the pre-artifact ladder (caller-supplied factor or raw).
111
+ * Implementations must read this at OPEN time (constructor/factory), never per-lookup — `find()` is synchronous by
112
+ * design.
113
+ */
114
+ readonly radiusCalibration?: number;
115
+ }
116
+ /**
117
+ * One street-CENTROID hit (#1042) — the street-level tier BELOW the exact address-point tier and ABOVE admin-centroid
118
+ * resolution. A street's centroid + an honest extent-derived radius, for a street-only query (no house number) that an
119
+ * address-point tier cannot serve by definition. Derived from a national register's rooftop points
120
+ * (`street-centroids-<cc>.db`, a `GROUP BY street` roll-up). `uncertaintyM` prices the coarseness (half the street's
121
+ * bbox diagonal) so a consumer never mistakes it for a rooftop.
122
+ */
123
+ export interface StreetCentroidHit {
124
+ lat: number;
125
+ lon: number;
126
+ /**
127
+ * Honest coarse radius in METERS — half the street's bounding-box diagonal.
128
+ */
129
+ uncertaintyM: number;
130
+ source: string;
131
+ release: string;
132
+ }
133
+ /**
134
+ * Street-centroid lookup (#1042). Like {@link AddressPointLookup}, implementations own their normalization (the shared
135
+ * `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Scoped by `postcode` (preferred) or
136
+ * `locality` (the base commune) — NO house number: this is the street-only tier.
137
+ */
138
+ export interface StreetCentroidLookup {
139
+ find(query: {
140
+ street: string;
141
+ postcode?: string;
142
+ locality?: string;
143
+ }): StreetCentroidHit | null;
144
+ }
145
+ /**
146
+ * One admin-ancestry entry a PFX1 node asserts (coarsest-first: country → constituent country → district).
147
+ */
148
+ export interface PostcodePrefixAncestor {
149
+ placetype: string;
150
+ wofID: number;
151
+ name: string;
152
+ }
153
+ /**
154
+ * A PFX1 postcode-prefix node — the partial-code prior's payload ({@link ResolveOpts.postcodePrefixPrior}, #31
155
+ * Mechanism 3). The coordinate is OPTIONAL and its absence is meaningful: an ancestry-only tier (NI's 80 BT districts)
156
+ * carries `ancestors` and no `lat`/`lon` — representable as absence, never as `0,0` (the meaning-of-zero rule).
157
+ * `radiusP95Km` is mandatory whenever a coordinate is present (M-3's receipt: a 1-digit US band and a GB outward code
158
+ * are both "a prefix with a centroid" and differ by 200×).
159
+ */
160
+ export interface PostcodePrefixNode {
161
+ prefix: string;
162
+ ancestors: readonly PostcodePrefixAncestor[];
163
+ lat?: number;
164
+ lon?: number;
165
+ radiusP95Km?: number;
166
+ unitCount: number;
167
+ }
168
+ /**
169
+ * The PFX1 index the resolver probes — minimal, structural (`probe` + optional `country`), so `@mailwoman/resolver`
170
+ * consumes an index built in `@mailwoman/neural` without depending on it (B3-5: the partial-code prior touches zero
171
+ * model inputs). `country` is the ISO-3166 alpha-2 the index was built for (upper-case); the resolver only probes an
172
+ * index whose country matches the query's country scope.
173
+ */
174
+ export interface PostcodePrefixIndexLike {
175
+ probe(prefix: string): PostcodePrefixNode | null;
176
+ readonly country?: string;
177
+ }
178
+ //# sourceMappingURL=lookup-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup-types.d.ts","sourceRoot":"","sources":["../../resolver/lookup-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,IAAI,CAAC,KAAK,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB;;;;WAIG;QACH,IAAI,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KACzE,GAAG,eAAe,GAAG,IAAI,CAAA;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,IAAI,CAAA;IAClB;;OAEG;IACH,MAAM,EAAE,eAAe,GAAG,aAAa,CAAA;IACvC;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IACnC,IAAI,CAAC,KAAK,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KACnC,GAAG,oBAAoB,GAAG,IAAI,CAAA;IAC/B;;;;;;;;;OASG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,iBAAiB,GAAG,IAAI,CAAA;CAC/F;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACZ;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,sBAAsB,EAAE,CAAA;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAAA;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CACzB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The SYNCHRONOUS street-tier lookup contracts the resolution ladder is built on — address point,
7
+ * interpolation, street centroid, postcode prefix. Synchronous by design: `@mailwoman/neural` calls into this
8
+ * ladder, so turning one member async forces every implementer and both package boundaries async with it.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=lookup-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup-types.js","sourceRoot":"","sources":["../../resolver/lookup-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Component-tag → resolver-placetype mapping, the equivalence groups a query expands into, and the test
7
+ * that tells a widened match from an exact one.
8
+ */
9
+ import type { ComponentTag } from "../decoder/types.ts";
10
+ /**
11
+ * Mapping from mailwoman's address-component tags to the resolver's placetype taxonomy.
12
+ *
13
+ * PARTIAL on purpose: a tag absent from the map is NOT queried, and the resolver pass leaves its classifier attribution
14
+ * untouched. Omission is therefore a routing decision, not an oversight.
15
+ */
16
+ export type PlacetypeMap = Partial<Record<ComponentTag, string>>;
17
+ /**
18
+ * The map used when a backend does not supply its own.
19
+ *
20
+ * `street` and `house_number` are absent because WOF admin has no rows for them — they resolve through the situs shards
21
+ * instead, which are keyed by street, not by placetype. Locale-specific tiers (JP-style prefecture subdivisions) are
22
+ * absent for the same reason: a different shard entirely.
23
+ */
24
+ export declare const DEFAULT_PLACETYPE_MAP: PlacetypeMap;
25
+ /**
26
+ * Placetype-equivalence groups for lookup FILTERING. WOF splits a single addressing tier across several placetypes, but
27
+ * an address's span can name ANY of them. A backend that filters to the one "obvious" placetype makes the equivalents
28
+ * unreachable, so a fuzzy same-name place in the wrong tier wins instead.
29
+ *
30
+ * Three tiers are affected (the value of each entry is the set the SQL filter should accept; the FIRST entry is the
31
+ * canonical/requested type, which shard routing keys off):
32
+ *
33
+ * - **`locality`** — `locality` (most cities), `borough` (Brooklyn, the Paris arrondissements, the London boroughs), and
34
+ * `localadmin` (FR communes, US towns/townships in New England). Without the group, Brooklyn-the-borough (pop 2.5M)
35
+ * was unreachable and the fuzzy "Brooklyn Park, MN" won.
36
+ * - **`region`** — `region` + `macroregion` (#718). WOF does NOT model every country's top-level civil division as
37
+ * `region`: Italian regions (Lombardia, Veneto, Toscana…) are `macroregion` (their PROVINCES are `region`), and the
38
+ * post-2016 French régions (Île-de-France) are `macroregion` too. An address's `region` span names exactly those, so
39
+ * a `region`-only filter resolved them to NOTHING (confirmed against the IT/FR eval rows). US states / DE
40
+ * Bundesländer / ES provincias are genuine `region`, so the EXACT-type match is preferred in ranking (see the
41
+ * resolve.ts fallback-quality annotation) — the macro is the recall safety net, not a demotion.
42
+ * - **`county`** — `county` + `macrocounty` (#718). The `subregion` ComponentTag maps to `county` via
43
+ * {@link DEFAULT_PLACETYPE_MAP}; WOF carries `macrocounty` for FR départements-grouping / DE / GB tiers above the
44
+ * county. Proactive (no eval row exercises `subregion` today) but symmetric with `region` — biasing to inclusion,
45
+ * since a missed resolution costs more than a too-broad candidate (which is QA-visible). Same exact-type preference
46
+ * applies.
47
+ *
48
+ * This table is the single source of truth for that expansion, shared by every lookup backend
49
+ * (`@mailwoman/core/resolver-wof-sqlite`, `@mailwoman/core/resolver-wof-wasm`, and the demo's httpvfs lookup) so the
50
+ * Node and browser resolvers can't drift. Keyed by the REQUESTED placetype. Placetypes without an entry pass through
51
+ * unchanged — an explicit `placetype: "borough"` query stays narrow.
52
+ */
53
+ export declare const PLACETYPE_FILTER_GROUPS: Readonly<Record<string, readonly string[]>>;
54
+ /**
55
+ * Expand a placetype filter through {@link PLACETYPE_FILTER_GROUPS}, deduplicated and order-preserving (the first entry
56
+ * stays first — shard routing keys off it). `null`/`undefined` (no filter) passes through untouched.
57
+ */
58
+ export declare function expandPlacetypeFilter(placetypes: null): null;
59
+ export declare function expandPlacetypeFilter(placetypes: readonly string[]): string[];
60
+ export declare function expandPlacetypeFilter(placetypes: readonly string[] | null): string[] | null;
61
+ /**
62
+ * Did `candidatePlacetype` resolve `requestedPlacetype` only via a BROADER admin tier (a macro-type fallback within the
63
+ * {@link PLACETYPE_FILTER_GROUPS} expansion), rather than the exact type (#718)?
64
+ *
65
+ * `region` → `region` is exact (false); `region` → `macroregion` is a fallback (true). Scoped to the `macro*` tiers
66
+ * (see {@link MACRO_FALLBACK_PLACETYPES}) so the `locality` group's borough/localadmin peers stay exact. The resolver
67
+ * uses this to (a) prefer an exact-type candidate in ranking and (b) annotate `resolutionQuality: "fallback"` when only
68
+ * a macro-type matched. A placetype outside the requested group, or any non-macro member, is treated as exact (false).
69
+ */
70
+ export declare function isPlacetypeFallback(requestedPlacetype: string, candidatePlacetype: string): boolean;
71
+ //# sourceMappingURL=placetype-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placetype-map.d.ts","sourceRoot":"","sources":["../../resolver/placetype-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAUnC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAI/E,CAAA;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAA;AAC7D,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;AAC9E,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,IAAI,CAAA;AA0B5F;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAQnG"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Component-tag → resolver-placetype mapping, the equivalence groups a query expands into, and the test
7
+ * that tells a widened match from an exact one.
8
+ */
9
+ /**
10
+ * The map used when a backend does not supply its own.
11
+ *
12
+ * `street` and `house_number` are absent because WOF admin has no rows for them — they resolve through the situs shards
13
+ * instead, which are keyed by street, not by placetype. Locale-specific tiers (JP-style prefecture subdivisions) are
14
+ * absent for the same reason: a different shard entirely.
15
+ */
16
+ export const DEFAULT_PLACETYPE_MAP = {
17
+ country: "country",
18
+ region: "region",
19
+ locality: "locality",
20
+ dependent_locality: "locality",
21
+ subregion: "county",
22
+ // `postcode` (mailwoman tag) maps to WOF's `postalcode` placetype. Resolves only when the
23
+ // backend has the postcode shard available — `WOFSQLitePlaceLookup` auto-routes `postalcode`
24
+ // queries to a `postalcode_us` (or similarly-named) shard, falling back to main if absent.
25
+ postcode: "postalcode",
26
+ };
27
+ /**
28
+ * Placetype-equivalence groups for lookup FILTERING. WOF splits a single addressing tier across several placetypes, but
29
+ * an address's span can name ANY of them. A backend that filters to the one "obvious" placetype makes the equivalents
30
+ * unreachable, so a fuzzy same-name place in the wrong tier wins instead.
31
+ *
32
+ * Three tiers are affected (the value of each entry is the set the SQL filter should accept; the FIRST entry is the
33
+ * canonical/requested type, which shard routing keys off):
34
+ *
35
+ * - **`locality`** — `locality` (most cities), `borough` (Brooklyn, the Paris arrondissements, the London boroughs), and
36
+ * `localadmin` (FR communes, US towns/townships in New England). Without the group, Brooklyn-the-borough (pop 2.5M)
37
+ * was unreachable and the fuzzy "Brooklyn Park, MN" won.
38
+ * - **`region`** — `region` + `macroregion` (#718). WOF does NOT model every country's top-level civil division as
39
+ * `region`: Italian regions (Lombardia, Veneto, Toscana…) are `macroregion` (their PROVINCES are `region`), and the
40
+ * post-2016 French régions (Île-de-France) are `macroregion` too. An address's `region` span names exactly those, so
41
+ * a `region`-only filter resolved them to NOTHING (confirmed against the IT/FR eval rows). US states / DE
42
+ * Bundesländer / ES provincias are genuine `region`, so the EXACT-type match is preferred in ranking (see the
43
+ * resolve.ts fallback-quality annotation) — the macro is the recall safety net, not a demotion.
44
+ * - **`county`** — `county` + `macrocounty` (#718). The `subregion` ComponentTag maps to `county` via
45
+ * {@link DEFAULT_PLACETYPE_MAP}; WOF carries `macrocounty` for FR départements-grouping / DE / GB tiers above the
46
+ * county. Proactive (no eval row exercises `subregion` today) but symmetric with `region` — biasing to inclusion,
47
+ * since a missed resolution costs more than a too-broad candidate (which is QA-visible). Same exact-type preference
48
+ * applies.
49
+ *
50
+ * This table is the single source of truth for that expansion, shared by every lookup backend
51
+ * (`@mailwoman/core/resolver-wof-sqlite`, `@mailwoman/core/resolver-wof-wasm`, and the demo's httpvfs lookup) so the
52
+ * Node and browser resolvers can't drift. Keyed by the REQUESTED placetype. Placetypes without an entry pass through
53
+ * unchanged — an explicit `placetype: "borough"` query stays narrow.
54
+ */
55
+ export const PLACETYPE_FILTER_GROUPS = {
56
+ locality: ["locality", "borough", "localadmin"],
57
+ region: ["region", "macroregion"],
58
+ county: ["county", "macrocounty"],
59
+ };
60
+ export function expandPlacetypeFilter(placetypes) {
61
+ if (!placetypes)
62
+ return null;
63
+ const out = [];
64
+ for (const placetype of placetypes) {
65
+ for (const expanded of PLACETYPE_FILTER_GROUPS[placetype] ?? [placetype]) {
66
+ if (!out.includes(expanded)) {
67
+ out.push(expanded);
68
+ }
69
+ }
70
+ }
71
+ return out;
72
+ }
73
+ /**
74
+ * Macro/broader-tier members of {@link PLACETYPE_FILTER_GROUPS} — the recall safety net a query may fall through to
75
+ * when no candidate of the EXACT requested placetype exists (#718). DELIBERATELY scoped to the `macro*` tiers only: the
76
+ * `locality` group's `borough`/`localadmin` are genuine peers (Brooklyn-the-borough is a first-class locality answer,
77
+ * #404-class), NOT fallbacks — so they must NOT be deprioritized or annotated. Only `macroregion`/`macrocounty` are a
78
+ * broader admin tier standing in for a true `region`/`county`.
79
+ */
80
+ const MACRO_FALLBACK_PLACETYPES = new Set(["macroregion", "macrocounty"]);
81
+ /**
82
+ * Did `candidatePlacetype` resolve `requestedPlacetype` only via a BROADER admin tier (a macro-type fallback within the
83
+ * {@link PLACETYPE_FILTER_GROUPS} expansion), rather than the exact type (#718)?
84
+ *
85
+ * `region` → `region` is exact (false); `region` → `macroregion` is a fallback (true). Scoped to the `macro*` tiers
86
+ * (see {@link MACRO_FALLBACK_PLACETYPES}) so the `locality` group's borough/localadmin peers stay exact. The resolver
87
+ * uses this to (a) prefer an exact-type candidate in ranking and (b) annotate `resolutionQuality: "fallback"` when only
88
+ * a macro-type matched. A placetype outside the requested group, or any non-macro member, is treated as exact (false).
89
+ */
90
+ export function isPlacetypeFallback(requestedPlacetype, candidatePlacetype) {
91
+ const group = PLACETYPE_FILTER_GROUPS[requestedPlacetype];
92
+ if (!group)
93
+ return false;
94
+ if (candidatePlacetype === requestedPlacetype)
95
+ return false;
96
+ return MACRO_FALLBACK_PLACETYPES.has(candidatePlacetype) && group.includes(candidatePlacetype);
97
+ }
98
+ //# sourceMappingURL=placetype-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placetype-map.js","sourceRoot":"","sources":["../../resolver/placetype-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IAClD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,kBAAkB,EAAE,UAAU;IAC9B,SAAS,EAAE,QAAQ;IACnB,0FAA0F;IAC1F,6FAA6F;IAC7F,2FAA2F;IAC3F,QAAQ,EAAE,YAAY;CACtB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAgD;IACnF,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,YAAY,CAAC;IAC/C,MAAM,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,MAAM,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;CACjC,CAAA;AAUD,MAAM,UAAU,qBAAqB,CAAC,UAAoC;IACzE,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAA;IAC5B,MAAM,GAAG,GAAa,EAAE,CAAA;IAExB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,KAAK,MAAM,QAAQ,IAAI,uBAAuB,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1E,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC7B,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnB,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAA;AAE9F;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,kBAA0B,EAAE,kBAA0B;IACzF,MAAM,KAAK,GAAG,uBAAuB,CAAC,kBAAkB,CAAC,CAAA;IAEzD,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IAExB,IAAI,kBAAkB,KAAK,kBAAkB;QAAE,OAAO,KAAK,CAAA;IAE3D,OAAO,yBAAyB,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAA;AAC/F,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Postcode FORMAT → country evidence, pure and platform-free — the #928 unforgeable singles and the
7
+ * #1589 bare-context implied set. Lifted out of `mailwoman/geocode-core` so `@mailwoman/resolver`
8
+ * (which runs in the browser via the demo cascade) can derive the implied set itself instead of
9
+ * depending on a CLI-side caller to thread it — the 2026-08-11 staged-repoint e2e caught exactly
10
+ * that gap (`100 00` resolved in Node and not in the browser, same artifact). `geocode-core`
11
+ * re-exports everything here, so its consumers and tests are unmoved.
12
+ */
13
+ /**
14
+ * #928: distinctive postcode FORMATS that unambiguously indicate a country — a stronger country signal than the
15
+ * language-based coarse placer, which conflates GB/US (both carry English street patterns) and mis-routes GB addresses
16
+ * to US namesakes (`London E4 9AZ` → London, Ohio) at 0.94–0.96 confidence. The format is unforgeable across these
17
+ * countries: the GB pattern (letters-first) never matches a US ZIP or an NL `\d{4} [A-Z]{2}` code. Extend ONLY with
18
+ * formats validated as non-overlapping. Feeds the `postcodeCountryPrior` lever (gated, default-off pending its gate).
19
+ */
20
+ export declare const POSTCODE_FORMAT_COUNTRY: ReadonlyArray<{
21
+ readonly re: RegExp;
22
+ readonly country: string;
23
+ }>;
24
+ /**
25
+ * The country a parsed postcode's FORMAT implies, or null. See {@link POSTCODE_FORMAT_COUNTRY}.
26
+ */
27
+ export declare function countryFromPostcodeFormat(postcode: string | undefined): string | null;
28
+ /**
29
+ * EVERY country a parsed postcode's FORMAT is consistent with — the singles table, the NL PC6 shape, and the shared
30
+ * `NNN NN` family. Empty when the shape implies nothing (a bare 5-digit reads US/FR/DE and more; that family stays with
31
+ * the locale prior on purpose — the `75008` contract).
32
+ *
33
+ * Unlike {@link countryFromPostcodeFormat}, this is NOT an unforgeable-in-any-context claim: consumers (the resolver's
34
+ * implied-set probe, the CLI's withheld-scope guard) apply it only to a tree that is a bare postcode, where the
35
+ * street-fragment collision the singles table must exclude cannot arise.
36
+ */
37
+ export declare function countriesFromPostcodeFormat(postcode: string | undefined): readonly string[];
38
+ //# sourceMappingURL=postcode-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcode-format.d.ts","sourceRoot":"","sources":["../../resolver/postcode-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAepG,CAAA;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAQrF;AAiBD;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAc3F"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * Postcode FORMAT → country evidence, pure and platform-free — the #928 unforgeable singles and the
7
+ * #1589 bare-context implied set. Lifted out of `mailwoman/geocode-core` so `@mailwoman/resolver`
8
+ * (which runs in the browser via the demo cascade) can derive the implied set itself instead of
9
+ * depending on a CLI-side caller to thread it — the 2026-08-11 staged-repoint e2e caught exactly
10
+ * that gap (`100 00` resolved in Node and not in the browser, same artifact). `geocode-core`
11
+ * re-exports everything here, so its consumers and tests are unmoved.
12
+ */
13
+ /**
14
+ * #928: distinctive postcode FORMATS that unambiguously indicate a country — a stronger country signal than the
15
+ * language-based coarse placer, which conflates GB/US (both carry English street patterns) and mis-routes GB addresses
16
+ * to US namesakes (`London E4 9AZ` → London, Ohio) at 0.94–0.96 confidence. The format is unforgeable across these
17
+ * countries: the GB pattern (letters-first) never matches a US ZIP or an NL `\d{4} [A-Z]{2}` code. Extend ONLY with
18
+ * formats validated as non-overlapping. Feeds the `postcodeCountryPrior` lever (gated, default-off pending its gate).
19
+ */
20
+ export const POSTCODE_FORMAT_COUNTRY = [
21
+ // GB `E4 9AZ` — letters-first, ends `\d[A-Z]{2}`. Never matches a US ZIP / NL / FR / CA code.
22
+ { re: /^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$/i, country: "GB" },
23
+ // CA `K2P 1L4` — `A#A #A#`, ends `\d[A-Z]\d` (distinct from GB's `\d[A-Z]{2}`). The placer conflates CA
24
+ // with US (English) / FR (Québec) at 0.9–1.0 confidence, same failure as GB; the format is unambiguous.
25
+ { re: /^[A-Z]\d[A-Z]\s?\d[A-Z]\d$/i, country: "CA" },
26
+ // IE Eircode `D02 AF30` — routing key (letter + 2 digits, or the D6W special) + a 4-alnum unique part.
27
+ // The 4-char unique part is what separates it from GB's 3-char `\d[A-Z]{2}` inward (no real-code
28
+ // overlap; Belfast `BT1 5GS` stays GB — Northern Ireland uses GB postcodes). The placer mis-routes IE
29
+ // 5/5 (Cork→US 0.99, Drogheda→US 1.00) — the same conflation class as GB/CA.
30
+ { re: /^(?:[A-Z]\d{2}|D6W)\s?[A-Z\d]{4}$/i, country: "IE" },
31
+ // NL PC6 is DELIBERATELY ABSENT: `\d{4} [A-Z]{2}` is forgeable in parse context — a US
32
+ // house-number + directional fragment (`1234 NE`, `8990 SW`) matches it exactly, and this table
33
+ // feeds recognizeBarePostcode, which must never touch a street name. NL lives in
34
+ // countriesFromPostcodeFormat instead, whose consumers gate on a bare-postcode TREE.
35
+ ];
36
+ /**
37
+ * The country a parsed postcode's FORMAT implies, or null. See {@link POSTCODE_FORMAT_COUNTRY}.
38
+ */
39
+ export function countryFromPostcodeFormat(postcode) {
40
+ const p = postcode?.trim();
41
+ if (!p)
42
+ return null;
43
+ for (const { re, country } of POSTCODE_FORMAT_COUNTRY)
44
+ if (re.test(p))
45
+ return country;
46
+ return null;
47
+ }
48
+ /**
49
+ * Spaced `NNN NN` — the CZ/SK/SE/GR shared postcode space (#1589's `100 00`). Unlike the
50
+ * {@link POSTCODE_FORMAT_COUNTRY} singles, this shape implies a SET: no single country owns it, so it can gate a
51
+ * locale-inferred scope but never name one country outright.
52
+ */
53
+ const SHARED_NNN_NN = /^\d{3} \d{2}$/;
54
+ /**
55
+ * NL PC6 (`1012 LG`) — digits-first then exactly two letters. NL-unique as a POSTCODE shape (GB/CA/IE are
56
+ * letters-first; the digit-only families carry no letters), but too forgeable for {@link POSTCODE_FORMAT_COUNTRY}: a US
57
+ * house-number + directional fragment (`1234 NE`) matches it, so it must never feed recognizeBarePostcode. It belongs
58
+ * only here, where every consumer gates on a tree that IS a bare postcode.
59
+ */
60
+ const NL_PC6 = /^\d{4}\s?[A-Z]{2}$/i;
61
+ /**
62
+ * EVERY country a parsed postcode's FORMAT is consistent with — the singles table, the NL PC6 shape, and the shared
63
+ * `NNN NN` family. Empty when the shape implies nothing (a bare 5-digit reads US/FR/DE and more; that family stays with
64
+ * the locale prior on purpose — the `75008` contract).
65
+ *
66
+ * Unlike {@link countryFromPostcodeFormat}, this is NOT an unforgeable-in-any-context claim: consumers (the resolver's
67
+ * implied-set probe, the CLI's withheld-scope guard) apply it only to a tree that is a bare postcode, where the
68
+ * street-fragment collision the singles table must exclude cannot arise.
69
+ */
70
+ export function countriesFromPostcodeFormat(postcode) {
71
+ const p = postcode?.trim();
72
+ if (!p)
73
+ return [];
74
+ const single = countryFromPostcodeFormat(p);
75
+ if (single)
76
+ return [single];
77
+ if (NL_PC6.test(p))
78
+ return ["NL"];
79
+ if (SHARED_NNN_NN.test(p))
80
+ return ["CZ", "SK", "SE", "GR"];
81
+ return [];
82
+ }
83
+ //# sourceMappingURL=postcode-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postcode-format.js","sourceRoot":"","sources":["../../resolver/postcode-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqE;IACxG,8FAA8F;IAC9F,EAAE,EAAE,EAAE,sCAAsC,EAAE,OAAO,EAAE,IAAI,EAAE;IAC7D,wGAAwG;IACxG,wGAAwG;IACxG,EAAE,EAAE,EAAE,6BAA6B,EAAE,OAAO,EAAE,IAAI,EAAE;IACpD,uGAAuG;IACvG,iGAAiG;IACjG,sGAAsG;IACtG,6EAA6E;IAC7E,EAAE,EAAE,EAAE,oCAAoC,EAAE,OAAO,EAAE,IAAI,EAAE;IAC3D,uFAAuF;IACvF,gGAAgG;IAChG,iFAAiF;IACjF,qFAAqF;CACrF,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAA4B;IACrE,MAAM,CAAC,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAA;IAE1B,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAA;IAEnB,KAAK,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,uBAAuB;QAAE,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAAE,OAAO,OAAO,CAAA;IAErF,OAAO,IAAI,CAAA;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,aAAa,GAAG,eAAe,CAAA;AAErC;;;;;GAKG;AACH,MAAM,MAAM,GAAG,qBAAqB,CAAA;AAEpC;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAA4B;IACvE,MAAM,CAAC,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAA;IAE1B,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAA;IAEjB,MAAM,MAAM,GAAG,yBAAyB,CAAC,CAAC,CAAC,CAAA;IAE3C,IAAI,MAAM;QAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAE3B,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjC,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IAE1D,OAAO,EAAE,CAAA;AACV,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The REFERENTIAL score and its comparator — the ranking half of the two-score split (ROAD_TO_V9 §2
7
+ * R1, ratified 2026-08-06).
8
+ *
9
+ * THE POLICY. "The importance of a knowledge-base article is not the probability that this is the
10
+ * place the user means." A geocoder ranks by REFERENTIAL likelihood; encyclopedic importance is
11
+ * carried as data and is never a ranking key. Saint-Denis is the canonical case: the
12
+ * Seine-Saint-Denis suburb (pop 96,128) carries encyclopedic 0.1173 and the Aude hamlet (pop 418)
13
+ * carries 0.5683, so encyclopedic ranking inverts the answer every user means, by 4.8x.
14
+ *
15
+ * WHY THIS LIVES IN `@mailwoman/core`. Three packages need the same number and must not drift:
16
+ * `@mailwoman/resolver` (backend-agnostic — it cannot import a backend),
17
+ * `@mailwoman/resolver-wof-sqlite` (the gazetteer schema + both lookups), and the FST builder that
18
+ * stamps referential scores into the decode-bias artifact. `core/resolver/types.ts` already owns the
19
+ * `ResolvedPlace` contract these three share, so the score that contract carries belongs beside it.
20
+ */
21
+ /**
22
+ * Population divisor in {@link referentialFromPopulation}. A 1,000-person place scores `log2(2)/14` — the curve starts
23
+ * counting at the scale where WOF actually records population.
24
+ */
25
+ export declare const REFERENTIAL_POPULATION_DIVISOR = 1000;
26
+ /**
27
+ * Log2 denominator in {@link referentialFromPopulation}. 14 puts the ceiling at `2^14 · 1000` people.
28
+ */
29
+ export declare const REFERENTIAL_LOG2_SCALE = 14;
30
+ /**
31
+ * The population at which {@link referentialFromPopulation} saturates at exactly 1.0: `(2^14 − 1) · 1000` = 16,383,000.
32
+ *
33
+ * Load-bearing, not trivia. Above this the score CLAMPS, so two megacities that population would order (Tokyo ~37 M vs
34
+ * Delhi ~33 M) tie at 1.0. Any ranking keyed on referential alone must break that tie on raw population to stay
35
+ * ordering-identical to the population-first path — which is exactly what {@link compareReferential} does, and why it
36
+ * exists rather than a bare subtraction at each call site.
37
+ */
38
+ export declare const REFERENTIAL_SATURATION_POPULATION: number;
39
+ /**
40
+ * Population → referential likelihood in [0, 1].
41
+ *
42
+ * `min(1, log2(1 + pop/1000) / 14)` — the formula the FST builder has used for its population fallback since the FST
43
+ * shipped, and the one `gazetteer importance` used for its fallback rows. It is defined ONCE here so the decode-bias
44
+ * artifact's values, the gazetteer's `referential` column, and the resolver's ranking key are the same number by
45
+ * construction rather than by three matching copies.
46
+ *
47
+ * MEANING OF ZERO: an absent population row and a recorded population of 0 both return 0, and 0 means "no population
48
+ * evidence" — the ranking treats it as no boost, never a penalty. WOF carries population for roughly 15% of localities,
49
+ * so absence is the common case and must stay cheap.
50
+ */
51
+ export declare function referentialFromPopulation(population: number | null | undefined): number;
52
+ /**
53
+ * A thing that can be ranked referentially. Both fields optional — a candidate with neither sorts last, which is the
54
+ * same place a candidate with no population has always sorted.
55
+ */
56
+ export interface ReferentiallyRankable {
57
+ referential?: number;
58
+ population?: number;
59
+ }
60
+ /**
61
+ * The ranking comparator: referential DESC, raw population DESC as the tiebreak. Negative when `a` outranks `b`, so it
62
+ * drops straight into `Array#sort`.
63
+ *
64
+ * The population tiebreak is not a hedge — it is what makes "rank by referential" and "rank by population" the SAME
65
+ * ORDER on every input, because {@link referentialFromPopulation} is strictly increasing below
66
+ * {@link REFERENTIAL_SATURATION_POPULATION} and constant above it. Without the tiebreak this comparator would silently
67
+ * re-order the world's largest cities: a real behavior change, and the one the D-rule would catch.
68
+ *
69
+ * Encyclopedic importance is deliberately not a parameter. Ranking by it is the thing §2 forbids, and a comparator that
70
+ * cannot express it is a stronger guarantee than a comment asking nobody to.
71
+ */
72
+ export declare function compareReferential(a: ReferentiallyRankable, b: ReferentiallyRankable): number;
73
+ //# sourceMappingURL=referential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"referential.d.ts","sourceRoot":"","sources":["../../resolver/referential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,QAAqE,CAAA;AAEnH;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAIvF;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAE7F"}