@mailwoman/core 9.1.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 (371) 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 +1 -1
  5. package/coarse-placer/tools/build-outlier-exposure.ts +1 -1
  6. package/coarse-placer/tools/build-outlier-latin.ts +13 -7
  7. package/coarse-placer/tools/build-outlier-oa.ts +11 -5
  8. package/coarse-placer/tools/eval-latin-offmap.ts +3 -2
  9. package/coarse-placer/tools/eval-openset.ts +3 -2
  10. package/coarse-placer/tools/eval-quant-compare.ts +3 -2
  11. package/coarse-placer/tools/eval.ts +3 -2
  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 -2
  15. package/coarse-placer/tools/quantize.ts +2 -2
  16. package/coarse-placer/tools/train.ts +2 -1
  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/containment.ts +5 -1
  22. package/decoder/index.ts +1 -0
  23. package/decoder/parse-diff.ts +347 -0
  24. package/decoder/proposals-to-tree.ts +1 -1
  25. package/decoder/serialize-json.ts +51 -7
  26. package/decoder/serialize-tuples.ts +7 -1
  27. package/decoder/serialize-xml.ts +1 -1
  28. package/decoder/tree-shape.ts +144 -0
  29. package/decoder/types.ts +8 -0
  30. package/decoder/validate-tree.ts +15 -3
  31. package/env/index.ts +3 -1
  32. package/env/paths.ts +21 -33
  33. package/env/schema.ts +26 -3
  34. package/fs/utils/formatters.ts +107 -0
  35. package/fs/utils/index.ts +7 -0
  36. package/fs/zip.ts +1 -1
  37. package/layers/manifest.ts +56 -15
  38. package/layers/schema.ts +54 -2
  39. package/locale/locale.ts +1 -1
  40. package/locale/registry.ts +1 -1
  41. package/objects.ts +20 -8
  42. package/out/api/responses.d.ts +9 -0
  43. package/out/api/responses.d.ts.map +1 -1
  44. package/out/api/responses.js +11 -0
  45. package/out/api/responses.js.map +1 -1
  46. package/out/coarse-placer/featurize.d.ts +0 -1
  47. package/out/coarse-placer/featurize.d.ts.map +1 -1
  48. package/out/coarse-placer/featurize.js.map +1 -1
  49. package/out/coarse-placer/tools/build-dataset.js +1 -1
  50. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  51. package/out/coarse-placer/tools/build-outlier-exposure.js +1 -1
  52. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  53. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  54. package/out/coarse-placer/tools/build-outlier-latin.js +12 -7
  55. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  56. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  57. package/out/coarse-placer/tools/build-outlier-oa.js +10 -5
  58. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  59. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  60. package/out/coarse-placer/tools/eval-latin-offmap.js +2 -2
  61. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  62. package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
  63. package/out/coarse-placer/tools/eval-openset.js +2 -2
  64. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  65. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
  66. package/out/coarse-placer/tools/eval-quant-compare.js +2 -2
  67. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  68. package/out/coarse-placer/tools/eval.d.ts.map +1 -1
  69. package/out/coarse-placer/tools/eval.js +2 -2
  70. package/out/coarse-placer/tools/eval.js.map +1 -1
  71. package/out/coarse-placer/tools/fnv-hash.d.ts +1 -6
  72. package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
  73. package/out/coarse-placer/tools/fnv-hash.js +1 -6
  74. package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
  75. package/out/coarse-placer/tools/index.d.ts +1 -1
  76. package/out/coarse-placer/tools/index.js +1 -1
  77. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  78. package/out/coarse-placer/tools/probe-frontier.js +2 -2
  79. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  80. package/out/coarse-placer/tools/quantize.js +2 -2
  81. package/out/coarse-placer/tools/quantize.js.map +1 -1
  82. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  83. package/out/coarse-placer/tools/train.js +1 -1
  84. package/out/coarse-placer/tools/train.js.map +1 -1
  85. package/out/crypto/node.d.ts.map +1 -1
  86. package/out/crypto/node.js +2 -1
  87. package/out/crypto/node.js.map +1 -1
  88. package/out/db/schema.d.ts +12 -3
  89. package/out/db/schema.d.ts.map +1 -1
  90. package/out/db/schema.js +6 -0
  91. package/out/db/schema.js.map +1 -1
  92. package/out/decoder/containment.d.ts.map +1 -1
  93. package/out/decoder/containment.js +5 -1
  94. package/out/decoder/containment.js.map +1 -1
  95. package/out/decoder/index.d.ts +1 -0
  96. package/out/decoder/index.d.ts.map +1 -1
  97. package/out/decoder/index.js +1 -0
  98. package/out/decoder/index.js.map +1 -1
  99. package/out/decoder/parse-diff.d.ts +125 -0
  100. package/out/decoder/parse-diff.d.ts.map +1 -0
  101. package/out/decoder/parse-diff.js +219 -0
  102. package/out/decoder/parse-diff.js.map +1 -0
  103. package/out/decoder/proposals-to-tree.js.map +1 -1
  104. package/out/decoder/serialize-json.d.ts +29 -0
  105. package/out/decoder/serialize-json.d.ts.map +1 -1
  106. package/out/decoder/serialize-json.js +20 -4
  107. package/out/decoder/serialize-json.js.map +1 -1
  108. package/out/decoder/serialize-tuples.d.ts +8 -1
  109. package/out/decoder/serialize-tuples.d.ts.map +1 -1
  110. package/out/decoder/serialize-tuples.js +7 -1
  111. package/out/decoder/serialize-tuples.js.map +1 -1
  112. package/out/decoder/serialize-xml.js +1 -1
  113. package/out/decoder/serialize-xml.js.map +1 -1
  114. package/out/decoder/tree-shape.d.ts +84 -0
  115. package/out/decoder/tree-shape.d.ts.map +1 -0
  116. package/out/decoder/tree-shape.js +98 -0
  117. package/out/decoder/tree-shape.js.map +1 -0
  118. package/out/decoder/types.d.ts +11 -0
  119. package/out/decoder/types.d.ts.map +1 -1
  120. package/out/decoder/validate-tree.d.ts +8 -0
  121. package/out/decoder/validate-tree.d.ts.map +1 -1
  122. package/out/decoder/validate-tree.js +4 -3
  123. package/out/decoder/validate-tree.js.map +1 -1
  124. package/out/env/index.d.ts +10 -1
  125. package/out/env/index.d.ts.map +1 -1
  126. package/out/env/index.js +2 -1
  127. package/out/env/index.js.map +1 -1
  128. package/out/env/paths.d.ts +15 -8
  129. package/out/env/paths.d.ts.map +1 -1
  130. package/out/env/paths.js +19 -29
  131. package/out/env/paths.js.map +1 -1
  132. package/out/env/schema.d.ts +9 -1
  133. package/out/env/schema.d.ts.map +1 -1
  134. package/out/env/schema.js +25 -3
  135. package/out/env/schema.js.map +1 -1
  136. package/out/fs/utils/formatters.d.ts +57 -0
  137. package/out/fs/utils/formatters.d.ts.map +1 -0
  138. package/out/fs/utils/formatters.js +79 -0
  139. package/out/fs/utils/formatters.js.map +1 -0
  140. package/out/fs/utils/index.d.ts +7 -0
  141. package/out/fs/utils/index.d.ts.map +1 -0
  142. package/out/fs/utils/index.js +7 -0
  143. package/out/fs/utils/index.js.map +1 -0
  144. package/out/fs/zip.js +1 -1
  145. package/out/fs/zip.js.map +1 -1
  146. package/out/layers/manifest.d.ts +32 -7
  147. package/out/layers/manifest.d.ts.map +1 -1
  148. package/out/layers/manifest.js +31 -6
  149. package/out/layers/manifest.js.map +1 -1
  150. package/out/layers/schema.d.ts +48 -2
  151. package/out/layers/schema.d.ts.map +1 -1
  152. package/out/layers/schema.js +32 -0
  153. package/out/layers/schema.js.map +1 -1
  154. package/out/locale/locale.d.ts +1 -1
  155. package/out/locale/locale.d.ts.map +1 -1
  156. package/out/locale/registry.js +1 -1
  157. package/out/locale/registry.js.map +1 -1
  158. package/out/objects.d.ts +12 -6
  159. package/out/objects.d.ts.map +1 -1
  160. package/out/objects.js +4 -1
  161. package/out/objects.js.map +1 -1
  162. package/out/pipeline/index.d.ts +2 -6
  163. package/out/pipeline/index.d.ts.map +1 -1
  164. package/out/pipeline/index.js +1 -3
  165. package/out/pipeline/index.js.map +1 -1
  166. package/out/pipeline/runtime-pipeline.d.ts +51 -9
  167. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  168. package/out/pipeline/runtime-pipeline.js +29 -132
  169. package/out/pipeline/runtime-pipeline.js.map +1 -1
  170. package/out/pipeline/span-proposer.js +1 -1
  171. package/out/pipeline/span-proposer.js.map +1 -1
  172. package/out/pipeline/types.d.ts +22 -14
  173. package/out/pipeline/types.d.ts.map +1 -1
  174. package/out/pipeline/types.js.map +1 -1
  175. package/out/policy/defaults.d.ts +1 -1
  176. package/out/policy/defaults.d.ts.map +1 -1
  177. package/out/policy/defaults.js +1 -1
  178. package/out/policy/defaults.js.map +1 -1
  179. package/out/policy/policy.d.ts +1 -1
  180. package/out/policy/policy.d.ts.map +1 -1
  181. package/out/policy/registry.d.ts +1 -1
  182. package/out/policy/registry.d.ts.map +1 -1
  183. package/out/resolver/coverage-facts.d.ts +89 -0
  184. package/out/resolver/coverage-facts.d.ts.map +1 -0
  185. package/out/resolver/coverage-facts.js +22 -0
  186. package/out/resolver/coverage-facts.js.map +1 -0
  187. package/out/resolver/index.d.ts +2 -1
  188. package/out/resolver/index.d.ts.map +1 -1
  189. package/out/resolver/index.js +1 -0
  190. package/out/resolver/index.js.map +1 -1
  191. package/out/resolver/lookup-types.d.ts +178 -0
  192. package/out/resolver/lookup-types.d.ts.map +1 -0
  193. package/out/resolver/lookup-types.js +11 -0
  194. package/out/resolver/lookup-types.js.map +1 -0
  195. package/out/resolver/placetype-map.d.ts +71 -0
  196. package/out/resolver/placetype-map.d.ts.map +1 -0
  197. package/out/resolver/placetype-map.js +98 -0
  198. package/out/resolver/placetype-map.js.map +1 -0
  199. package/out/resolver/postcode-format.d.ts +38 -0
  200. package/out/resolver/postcode-format.d.ts.map +1 -0
  201. package/out/resolver/postcode-format.js +83 -0
  202. package/out/resolver/postcode-format.js.map +1 -0
  203. package/out/resolver/types.d.ts +271 -297
  204. package/out/resolver/types.d.ts.map +1 -1
  205. package/out/resolver/types.js +4 -97
  206. package/out/resolver/types.js.map +1 -1
  207. package/out/resources/git.d.ts +8 -1
  208. package/out/resources/git.d.ts.map +1 -1
  209. package/out/resources/git.js +4 -3
  210. package/out/resources/git.js.map +1 -1
  211. package/out/resources/languages/types.gen.d.ts +1 -1
  212. package/out/resources/languages/types.gen.d.ts.map +1 -1
  213. package/out/resources/languages/types.gen.js +40 -0
  214. package/out/resources/languages/types.gen.js.map +1 -1
  215. package/out/resources/libpostal.d.ts +2 -2
  216. package/out/resources/libpostal.d.ts.map +1 -1
  217. package/out/resources/libpostal.js +2 -2
  218. package/out/resources/libpostal.js.map +1 -1
  219. package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
  220. package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
  221. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
  222. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  223. package/out/resources/whosonfirst/PlacetypeDataSource.js +28 -3
  224. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  225. package/out/resources/whosonfirst/loader.d.ts +2 -2
  226. package/out/resources/whosonfirst/loader.d.ts.map +1 -1
  227. package/out/resources/whosonfirst/loader.js.map +1 -1
  228. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  229. package/out/resources/whosonfirst/placetypes/Placetype.js +2 -2
  230. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  231. package/out/resources/whosonfirst/placetypes/admin.d.ts +9 -1
  232. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  233. package/out/resources/whosonfirst/placetypes/admin.js +1 -1
  234. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  235. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  236. package/out/resources/whosonfirst/placetypes/definition.js +1 -1
  237. package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
  238. package/out/resources/whosonfirst/placetypes/index.d.ts +1 -0
  239. package/out/resources/whosonfirst/placetypes/index.d.ts.map +1 -1
  240. package/out/resources/whosonfirst/placetypes/index.js +1 -0
  241. package/out/resources/whosonfirst/placetypes/index.js.map +1 -1
  242. package/out/resources/whosonfirst/placetypes/specificity.d.ts +65 -0
  243. package/out/resources/whosonfirst/placetypes/specificity.d.ts.map +1 -0
  244. package/out/resources/whosonfirst/placetypes/specificity.js +101 -0
  245. package/out/resources/whosonfirst/placetypes/specificity.js.map +1 -0
  246. package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
  247. package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -1
  248. package/out/resources/whosonfirst/sharded-repo.js +46 -2
  249. package/out/resources/whosonfirst/sharded-repo.js.map +1 -1
  250. package/out/scripting/arguments.d.ts +27 -0
  251. package/out/scripting/arguments.d.ts.map +1 -0
  252. package/out/scripting/arguments.js +32 -0
  253. package/out/scripting/arguments.js.map +1 -0
  254. package/out/scripting/command.d.ts +28 -0
  255. package/out/scripting/command.d.ts.map +1 -0
  256. package/out/scripting/command.js +47 -0
  257. package/out/scripting/command.js.map +1 -0
  258. package/out/scripting/index.js +3 -3
  259. package/out/scripting/index.js.map +1 -1
  260. package/out/scripting/utils/index.d.ts +1 -12
  261. package/out/scripting/utils/index.d.ts.map +1 -1
  262. package/out/scripting/utils/index.js +4 -21
  263. package/out/scripting/utils/index.js.map +1 -1
  264. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  265. package/out/tools/download-libpostal-resources.js +4 -7
  266. package/out/tools/download-libpostal-resources.js.map +1 -1
  267. package/out/tools/download-ssl-address.d.ts +3 -3
  268. package/out/tools/download-ssl-address.d.ts.map +1 -1
  269. package/out/tools/download-ssl-address.js +26 -13
  270. package/out/tools/download-ssl-address.js.map +1 -1
  271. package/out/tools/generate-language-types.d.ts +16 -1
  272. package/out/tools/generate-language-types.d.ts.map +1 -1
  273. package/out/tools/generate-language-types.js +38 -5
  274. package/out/tools/generate-language-types.js.map +1 -1
  275. package/out/tools/index.d.ts +1 -2
  276. package/out/tools/index.d.ts.map +1 -1
  277. package/out/tools/index.js +1 -2
  278. package/out/tools/index.js.map +1 -1
  279. package/out/utils/data-root.d.ts +27 -7
  280. package/out/utils/data-root.d.ts.map +1 -1
  281. package/out/utils/data-root.js +36 -13
  282. package/out/utils/data-root.js.map +1 -1
  283. package/out/utils/hash.d.ts +2 -3
  284. package/out/utils/hash.d.ts.map +1 -1
  285. package/out/utils/hash.js +3 -3
  286. package/out/utils/hash.js.map +1 -1
  287. package/out/utils/index.d.ts +1 -0
  288. package/out/utils/index.d.ts.map +1 -1
  289. package/out/utils/index.js +1 -0
  290. package/out/utils/index.js.map +1 -1
  291. package/out/utils/jsonl.js +1 -1
  292. package/out/utils/jsonl.js.map +1 -1
  293. package/out/utils/repo.d.ts +8 -0
  294. package/out/utils/repo.d.ts.map +1 -1
  295. package/out/utils/repo.js +10 -1
  296. package/out/utils/repo.js.map +1 -1
  297. package/out/utils/sealed-db.d.ts +11 -0
  298. package/out/utils/sealed-db.d.ts.map +1 -1
  299. package/out/utils/sealed-db.js +28 -1
  300. package/out/utils/sealed-db.js.map +1 -1
  301. package/out/utils/sqlite-rows.d.ts +34 -0
  302. package/out/utils/sqlite-rows.d.ts.map +1 -0
  303. package/out/utils/sqlite-rows.js +37 -0
  304. package/out/utils/sqlite-rows.js.map +1 -0
  305. package/out/utils/stats.d.ts +1 -6
  306. package/out/utils/stats.d.ts.map +1 -1
  307. package/out/utils/stats.js +1 -6
  308. package/out/utils/stats.js.map +1 -1
  309. package/package.json +476 -7
  310. package/pipeline/index.ts +12 -14
  311. package/pipeline/runtime-pipeline.ts +29 -183
  312. package/pipeline/span-proposer.ts +1 -1
  313. package/pipeline/types.ts +26 -15
  314. package/policy/defaults.ts +1 -1
  315. package/policy/policy.ts +1 -1
  316. package/policy/registry.ts +1 -1
  317. package/resolver/coverage-facts.ts +102 -0
  318. package/resolver/index.ts +5 -0
  319. package/resolver/lookup-types.ts +174 -0
  320. package/resolver/placetype-map.ts +122 -0
  321. package/resolver/postcode-format.ts +89 -0
  322. package/resolver/types.ts +293 -351
  323. package/resources/git.ts +18 -4
  324. package/resources/languages/types.gen.ts +60 -0
  325. package/resources/libpostal.ts +4 -3
  326. package/resources/whosonfirst/DataSourceCache.ts +2 -1
  327. package/resources/whosonfirst/PlacetypeDataSource.ts +36 -11
  328. package/resources/whosonfirst/loader.ts +3 -2
  329. package/resources/whosonfirst/placetypes/Placetype.ts +3 -2
  330. package/resources/whosonfirst/placetypes/admin.ts +11 -2
  331. package/resources/whosonfirst/placetypes/definition.ts +4 -3
  332. package/resources/whosonfirst/placetypes/index.ts +1 -0
  333. package/resources/whosonfirst/placetypes/specificity.ts +114 -0
  334. package/resources/whosonfirst/sharded-repo.ts +55 -2
  335. package/scripting/arguments.ts +38 -0
  336. package/scripting/command.ts +55 -0
  337. package/scripting/index.ts +3 -3
  338. package/scripting/utils/index.ts +6 -23
  339. package/tools/download-libpostal-resources.ts +4 -7
  340. package/tools/download-ssl-address.ts +28 -12
  341. package/tools/generate-language-types.ts +39 -5
  342. package/tools/index.ts +1 -2
  343. package/utils/data-root.ts +40 -14
  344. package/utils/hash.ts +5 -4
  345. package/utils/index.ts +1 -0
  346. package/utils/jsonl.ts +1 -1
  347. package/utils/repo.ts +12 -1
  348. package/utils/sealed-db.ts +30 -1
  349. package/utils/sqlite-rows.ts +40 -0
  350. package/utils/stats.ts +1 -6
  351. package/data/libpostal/dictionaries/all/chains.txt +0 -504
  352. package/kysley/adapter.ts +0 -29
  353. package/out/kysley/adapter.d.ts +0 -13
  354. package/out/kysley/adapter.d.ts.map +0 -1
  355. package/out/kysley/adapter.js +0 -25
  356. package/out/kysley/adapter.js.map +0 -1
  357. package/out/pipeline/reconcile-lookups.d.ts +0 -39
  358. package/out/pipeline/reconcile-lookups.d.ts.map +0 -1
  359. package/out/pipeline/reconcile-lookups.js +0 -88
  360. package/out/pipeline/reconcile-lookups.js.map +0 -1
  361. package/out/pipeline/reconcile.d.ts +0 -153
  362. package/out/pipeline/reconcile.d.ts.map +0 -1
  363. package/out/pipeline/reconcile.js +0 -388
  364. package/out/pipeline/reconcile.js.map +0 -1
  365. package/out/pipeline/span-logit-aggregation.d.ts +0 -58
  366. package/out/pipeline/span-logit-aggregation.d.ts.map +0 -1
  367. package/out/pipeline/span-logit-aggregation.js +0 -117
  368. package/out/pipeline/span-logit-aggregation.js.map +0 -1
  369. package/pipeline/reconcile-lookups.ts +0 -111
  370. package/pipeline/reconcile.ts +0 -583
  371. package/pipeline/span-logit-aggregation.ts +0 -156
@@ -11,8 +11,18 @@
11
11
  * `RemoteResolver` adapter (Phase 4.4 — Pelias / BAN / Nominatim) without a public-API break.
12
12
  *
13
13
  * See `docs/plan/phases/PHASE_4_3_resolver_integration.md` for the design intent.
14
+ *
15
+ * This module is a published subpath (`@mailwoman/core/resolver/types`) with a wide consumer set, so the
16
+ * groups that moved to siblings are re-exported here rather than requiring every importer to move with them.
14
17
  */
15
- import type { AddressTree, ComponentTag } from "../decoder/types.ts";
18
+ import type { AddressTree } from "../decoder/types.ts";
19
+ import type { GazetteerArtifactCoverage } from "./coverage-facts.ts";
20
+ import type { AddressPointLookup, InterpolationLookup, PostcodePrefixIndexLike, StreetCentroidLookup } from "./lookup-types.ts";
21
+ import type { PlacetypeMap } from "./placetype-map.ts";
22
+ export type { CountryBBoxFact, CountryCoverageFact, GazetteerArtifactCoverage } from "./coverage-facts.ts";
23
+ export { hardCountrySafelistFromCoverage } from "./coverage-facts.ts";
24
+ export type { AddressPointHit, AddressPointLookup, InterpolatedPointHit, InterpolationLookup, PostcodePrefixAncestor, PostcodePrefixIndexLike, PostcodePrefixNode, StreetCentroidHit, StreetCentroidLookup, } from "./lookup-types.ts";
25
+ export { DEFAULT_PLACETYPE_MAP, expandPlacetypeFilter, isPlacetypeFallback, PLACETYPE_FILTER_GROUPS, type PlacetypeMap, } from "./placetype-map.ts";
16
26
  /**
17
27
  * One candidate place returned by a resolver. Mirrors the shape used by `@mailwoman/core/resolver-wof-sqlite`'s
18
28
  * `PlaceCandidate` — kept structurally compatible so a callsite holding a `PlaceCandidate` can be passed where a
@@ -63,6 +73,12 @@ export interface ResolvedPlace {
63
73
  * to score-based ordering.
64
74
  */
65
75
  prominence?: number;
76
+ /**
77
+ * Raw population from the backend's record, when carried (`PlaceCandidate.population` mirrors it). Absent means
78
+ * UNKNOWN, never zero — the meaning-of-zero rule. The bare-toponym race's region-dominance rule reads this because
79
+ * {@link ResolvedPlace.prominence} saturates at the backend's population cap and erases the margins it needs.
80
+ */
81
+ population?: number;
66
82
  /**
67
83
  * REFERENTIAL likelihood in [0, 1] — population-anchored, the named form of the key namesake ranking has always used
68
84
  * (ROAD_TO_V9 §2, ratified 2026-08-06: "the importance of a knowledge-base article is not the probability that this
@@ -121,6 +137,23 @@ export interface ResolvedPlace {
121
137
  * Absent when the exact placetype matched (the normal case).
122
138
  */
123
139
  resolutionQuality?: "fallback";
140
+ /**
141
+ * The admin-containment verdict for this candidate (#1717 stage 2) — TRI-STATE, and the absence is load-bearing
142
+ * (meaning-of-zero): `true` = the backend's ancestors sidecar vouches that this candidate sits UNDER the query's
143
+ * parsed region qualifier; `false` = the backend evaluated containment and could not vouch for it; `undefined` = the
144
+ * question was never asked — the lever is off, the query carried no qualifier, or the backend/artifact cannot answer
145
+ * (no sidecar). Set only by backends implementing `FindPlaceQuery.regionQualifier`; consumed by the resolver walk's
146
+ * `adminContainmentRerank` partition, which must never read `undefined` as "not contained".
147
+ */
148
+ containedByQualifier?: boolean;
149
+ /**
150
+ * #1731: `true` when a `parentID` region scope was applied, MISSED across the whole probe cascade, and the backend's
151
+ * unscoped fallback produced this row — the re-admission path where a wrong-instance namesake enters (the Astoria
152
+ * class: no locality-group row exists under the parent, so the fallback answers population-first from anywhere).
153
+ * Absent when the question never arose (no parent scope, or the scoped probe answered). Backend-optional; the
154
+ * resolver-interior trace (#1721) surfaces it as a gate.
155
+ */
156
+ regionScopeMiss?: boolean;
124
157
  }
125
158
  /**
126
159
  * Pull-based contract for a single resolver query. The resolver knows nothing about `AddressTree` — it just answers
@@ -129,90 +162,17 @@ export interface ResolvedPlace {
129
162
  * Structurally compatible with `PlaceLookup` from `@mailwoman/core/resolver-wof-sqlite` so the latter satisfies this
130
163
  * interface without an adapter shim.
131
164
  */
132
- /**
133
- * One country's measured hard-filter coverage fact, as recorded at a promote gate. Facts about the gazetteer artifact
134
- * live IN the artifact (the `country_coverage` table the gazetteer build emits) — code constants are only the fallback
135
- * for artifacts that predate the manifest.
136
- *
137
- * Meaning-of-zero discipline: a country ABSENT from the coverage map was never measured — never "measured and failed".
138
- * A measured-and-failed country is PRESENT with `hardFilterSafe: false` (e.g. FI at 69.5% hard-resolve), so the
139
- * negative result is a first-class record, distinguishable from ignorance.
140
- */
141
- export interface CountryCoverageFact {
142
- /**
143
- * ISO 3166-1 alpha-2, uppercase.
144
- */
145
- country: string;
146
- /**
147
- * The promote-gate VERDICT: hard-filtering this country is a pure win (a hard-filter miss is almost always a genuine
148
- * non-match, not a coverage gap). Stored as a verdict — not re-derived from `hardResolveRate` at read time — because
149
- * the gate is a judgment over a panel, not a pure rate function (CA cleared at the #928 promote on the
150
- * postcode-format-prior rationale despite a sub-95% panel resolve rate).
151
- */
152
- hardFilterSafe: boolean;
153
- /**
154
- * Measured hard-resolve rate (0..1) on the panel named in `source`, when the receipt recorded one.
155
- */
156
- hardResolveRate?: number;
157
- /**
158
- * Panel size behind `hardResolveRate`, when recorded.
159
- */
160
- sampleSize?: number;
161
- /**
162
- * ISO-8601 date of the measurement / promote gate.
163
- */
164
- measuredAt: string;
165
- /**
166
- * The receipt: which panel/gate produced this row (issue + date, human-readable).
167
- */
168
- source: string;
169
- }
170
- /**
171
- * One country's coarse guard-B bounding box, as carried by the gazetteer artifact's `country_bbox` table.
172
- */
173
- export interface CountryBBoxFact {
174
- /**
175
- * ISO 3166-1 alpha-2, uppercase.
176
- */
177
- country: string;
178
- latMin: number;
179
- latMax: number;
180
- lonMin: number;
181
- lonMax: number;
182
- /**
183
- * Provenance of the box (harness + date).
184
- */
185
- source: string;
186
- }
187
- /**
188
- * Facts a loaded gazetteer artifact declares about itself — read from the artifact's own manifest tables at open time,
189
- * carried on the {@link ResolverBackend}/{@link Resolver} handle so consumers read the facts from the artifact they are
190
- * actually resolving against. `undefined` on the handle = the artifact predates the manifest → consumers fall back to
191
- * the code constants (byte-identical legacy behavior).
192
- */
193
- export interface GazetteerArtifactCoverage {
194
- /**
195
- * Country → measured coverage fact. ABSENCE = never measured (meaning-of-zero), never "failed".
196
- */
197
- countryCoverage: ReadonlyMap<string, CountryCoverageFact>;
198
- /**
199
- * Country → guard-B bbox. ABSENCE = no box → the plausibility guard fails open for that country.
200
- */
201
- countryBBoxes: ReadonlyMap<string, CountryBBoxFact>;
202
- /**
203
- * Derived at load: the countries whose fact says `hardFilterSafe` — the artifact's hard-country safelist.
204
- */
205
- hardCountrySafelist: ReadonlySet<string>;
206
- }
207
- /**
208
- * Derive the hard-country safelist from coverage facts — the ONE derivation both the reader and the build share.
209
- */
210
- export declare function hardCountrySafelistFromCoverage(facts: Iterable<CountryCoverageFact>): ReadonlySet<string>;
211
165
  export interface ResolverBackend {
212
166
  findPlace(query: {
213
167
  text: string;
214
168
  placetype?: string | string[];
215
169
  country?: string;
170
+ /**
171
+ * ISO-3166 alpha-2 scoping the TYPO-FUZZY tier only (#1585): exact and qualifier-strip probes stay worldwide, the
172
+ * corrected-key probes honor it, and a scoped-empty fuzzy ABSTAINS instead of falling through to a world-fuzzy
173
+ * candidate. Backends without a fuzzy tier ignore it. Ignored when `country` is set (already narrower).
174
+ */
175
+ fuzzyCountry?: string;
216
176
  parentID?: number | string;
217
177
  /**
218
178
  * Sibling postcode string, when the address carries one. A coordinate-first backend uses it to inject
@@ -235,6 +195,32 @@ export interface ResolverBackend {
235
195
  lon: number;
236
196
  weight?: number;
237
197
  }>;
198
+ /**
199
+ * Restrict name matching to PRIMARY-keyed rows — set by probes whose query surface is a RE-READING (a token cut out
200
+ * of a longer classified span) rather than a naming. The #1626 rationale, generalized: `Savile Row`'s token `Row`
201
+ * never named Rhu's historical alias, so the alias tier must not answer it; a whole-input bare toponym DID name
202
+ * whatever it matches (Москва's exonym rows included) and keeps the alias tier. Backends without a primary flag
203
+ * ignore it.
204
+ */
205
+ primaryOnly?: boolean;
206
+ /**
207
+ * Alias-row NAME ROLES the probe refuses to answer through (#1730) — set by the bare-toponym side races with
208
+ * `abbr`/`gloss`. A lone bare token matching only an abbreviation row ("Tó" folded onto Toledo's "TO") or a
209
+ * translation-gloss row is a weak re-reading, not a naming; role-NULL alias rows (the exonym tier, the country
210
+ * display names) stay fully open, which is what `primaryOnly` could never express. Backends without a role column
211
+ * ignore it — an older artifact degrades to today's behavior.
212
+ */
213
+ excludeNameRoles?: readonly string[];
214
+ /**
215
+ * The tree's parsed REGION qualifier, verbatim (#1717 stage 2) — set by the resolver on locality lookups when
216
+ * `ResolveOpts.adminContainmentRerank` is on. A capable backend resolves the qualifier to its own region-class rows
217
+ * and (a) stamps every returned candidate's `containedByQualifier`, (b) ranks contained candidates ahead of
218
+ * uncontained ones, and (c) may ADD contained same-name candidates its other filters (a locale-inferred country
219
+ * scope) would have hidden — additive only, never a filter, so a qualifier that matches nothing changes nothing.
220
+ * Backends without a containment source ignore it (candidates then carry no stamp, which the walk reports as
221
+ * `unavailable`).
222
+ */
223
+ regionQualifier?: string;
238
224
  limit?: number;
239
225
  }): Promise<ResolvedPlace[]>;
240
226
  /**
@@ -257,6 +243,35 @@ export interface ResolverBackend {
257
243
  */
258
244
  artifactCoverage?: GazetteerArtifactCoverage;
259
245
  }
246
+ /**
247
+ * An optional {@link ResolverBackend} method the loaded backend does not implement, and what that costs.
248
+ *
249
+ * Optional methods let a backend be valid while omitting a capability — but the options they serve can still default to
250
+ * ON, in which case the feature reports success and does nothing. This type carries the absence as data so a caller can
251
+ * read it instead of inferring it from a result that looks complete.
252
+ */
253
+ export interface BackendCapabilityGap {
254
+ /**
255
+ * The absent method, named as it appears on {@link ResolverBackend}.
256
+ */
257
+ capability: "ancestors" | "coincidentLocalitiesFor";
258
+ /**
259
+ * The {@link ResolveOpts} field whose behavior the absence removes.
260
+ */
261
+ gates: keyof ResolveOpts;
262
+ /**
263
+ * Whether `gates` is on unless a caller turns it off — the difference between a silent loss and a chosen one.
264
+ */
265
+ defaultOn: boolean;
266
+ /**
267
+ * What stops working, in terms of the answer rather than the call.
268
+ */
269
+ degrades: string;
270
+ /**
271
+ * The backend's class name, so a log line identifies which artifact is loaded.
272
+ */
273
+ backend: string;
274
+ }
260
275
  /**
261
276
  * One link in a resolved place's containment lineage ({@link ResolverBackend.ancestors}, #404).
262
277
  */
@@ -286,160 +301,6 @@ export interface CoincidentLocality extends ResolvedPlace {
286
301
  /**
287
302
  * Options for `resolveTree`. All optional with sensible defaults.
288
303
  */
289
- /**
290
- * One exact address-point hit (#476): a real situs coordinate for `(street, number)` within a postcode/locality scope —
291
- * the street-level tier in front of admin-centroid resolution.
292
- */
293
- export interface AddressPointHit {
294
- lat: number;
295
- lon: number;
296
- /**
297
- * Provenance, e.g. `"overture:NAD"`.
298
- */
299
- source: string;
300
- /**
301
- * Pinned data release the point came from, e.g. `"2026-05-20.0"`.
302
- */
303
- release: string;
304
- }
305
- /**
306
- * Street-level exact-point lookup (#476). Implementations own their normalization — both the shard build and this
307
- * lookup must apply the SAME normalizer (see `resolver-wof-sqlite/street-normalize.ts`). Core depends only on this
308
- * contract.
309
- */
310
- export interface AddressPointLookup {
311
- find(query: {
312
- street: string;
313
- number: string;
314
- postcode?: string;
315
- locality?: string;
316
- /**
317
- * Optional bbox scope (`minLat`/`maxLat`/`minLon`/`maxLon`), tried AFTER postcode/locality. For shards whose points
318
- * carry no postcode/locality of their own (OSM addr nodes often don't) but DO carry a coordinate — the resolved
319
- * locality's bounding box scopes the `(street, number)` probe instead. US situs never passes it (byte-stable).
320
- */
321
- bbox?: {
322
- minLat: number;
323
- maxLat: number;
324
- minLon: number;
325
- maxLon: number;
326
- };
327
- }): AddressPointHit | null;
328
- }
329
- /**
330
- * One interpolated coordinate estimate (#483) — NEVER an exact situs point (`uncertaintyM` prices the estimate
331
- * honestly). Structural mirror of `InterpolatedHit` in `resolver-wof-sqlite/interpolation.ts`; keep this a SUBSET of
332
- * that shape so the concrete `StreetInterpolator`/`AddressPointInterpolator` satisfy {@link InterpolationLookup} with no
333
- * adapter (the {@link AddressPointHit} precedent).
334
- */
335
- export interface InterpolatedPointHit {
336
- lat: number;
337
- lon: number;
338
- interpolated: true;
339
- /**
340
- * `address_point` = bracketed between real neighbor points; `tiger_range` = linear within a segment range.
341
- */
342
- method: "address_point" | "tiger_range";
343
- /**
344
- * False when only the opposite side's range contained the number (right block, wrong side).
345
- */
346
- parityMatched?: boolean;
347
- /**
348
- * `both` = neighbors bracketed it; `single` = one-sided extrapolation (larger uncertainty).
349
- */
350
- bracket?: "both" | "single";
351
- /**
352
- * Honest uncertainty radius in METERS (half the matched segment length).
353
- */
354
- uncertaintyM: number;
355
- source: string;
356
- release: string;
357
- }
358
- /**
359
- * House-number interpolation lookup (#483). Like {@link AddressPointLookup}, implementations own their normalization
360
- * (the shared `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Postcode-scoped (no
361
- * locality field) — the tier abstains statewide without a postcode.
362
- */
363
- export interface InterpolationLookup {
364
- find(query: {
365
- street: string;
366
- number: string;
367
- postcode?: string;
368
- }): InterpolatedPointHit | null;
369
- /**
370
- * The ARTIFACT's own conformal radius multiplier for `uncertaintyM` (#374), read from the shard's
371
- * `interp_calibration` metadata table at open time (the pair-index δ/transitionBeta header precedent): the multiplier
372
- * is a property of the calibration set the artifact was built against, so it ships in the artifact, not in caller
373
- * code. The resolver applies it as the DEFAULT whenever `ResolveOpts.interpolationRadiusCalibration` is absent.
374
- * `undefined` (or an implementation without the property) = the artifact carries none — shards built before the
375
- * metadata table existed; behavior is then exactly the pre-artifact ladder (caller-supplied factor or raw).
376
- * Implementations must read this at OPEN time (constructor/factory), never per-lookup — `find()` is synchronous by
377
- * design.
378
- */
379
- readonly radiusCalibration?: number;
380
- }
381
- /**
382
- * One street-CENTROID hit (#1042) — the street-level tier BELOW the exact address-point tier and ABOVE admin-centroid
383
- * resolution. A street's centroid + an honest extent-derived radius, for a street-only query (no house number) that an
384
- * address-point tier cannot serve by definition. Derived from a national register's rooftop points
385
- * (`street-centroids-<cc>.db`, a `GROUP BY street` roll-up). `uncertaintyM` prices the coarseness (half the street's
386
- * bbox diagonal) so a consumer never mistakes it for a rooftop.
387
- */
388
- export interface StreetCentroidHit {
389
- lat: number;
390
- lon: number;
391
- /**
392
- * Honest coarse radius in METERS — half the street's bounding-box diagonal.
393
- */
394
- uncertaintyM: number;
395
- source: string;
396
- release: string;
397
- }
398
- /**
399
- * Street-centroid lookup (#1042). Like {@link AddressPointLookup}, implementations own their normalization (the shared
400
- * `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Scoped by `postcode` (preferred) or
401
- * `locality` (the base commune) — NO house number: this is the street-only tier.
402
- */
403
- export interface StreetCentroidLookup {
404
- find(query: {
405
- street: string;
406
- postcode?: string;
407
- locality?: string;
408
- }): StreetCentroidHit | null;
409
- }
410
- /**
411
- * One admin-ancestry entry a PFX1 node asserts (coarsest-first: country → constituent country → district).
412
- */
413
- export interface PostcodePrefixAncestor {
414
- placetype: string;
415
- wofID: number;
416
- name: string;
417
- }
418
- /**
419
- * A PFX1 postcode-prefix node — the partial-code prior's payload ({@link ResolveOpts.postcodePrefixPrior}, #31
420
- * Mechanism 3). The coordinate is OPTIONAL and its absence is meaningful: an ancestry-only tier (NI's 80 BT districts)
421
- * carries `ancestors` and no `lat`/`lon` — representable as absence, never as `0,0` (the meaning-of-zero rule).
422
- * `radiusP95Km` is mandatory whenever a coordinate is present (M-3's receipt: a 1-digit US band and a GB outward code
423
- * are both "a prefix with a centroid" and differ by 200×).
424
- */
425
- export interface PostcodePrefixNode {
426
- prefix: string;
427
- ancestors: readonly PostcodePrefixAncestor[];
428
- lat?: number;
429
- lon?: number;
430
- radiusP95Km?: number;
431
- unitCount: number;
432
- }
433
- /**
434
- * The PFX1 index the resolver probes — minimal, structural (`probe` + optional `country`), so `@mailwoman/resolver`
435
- * consumes an index built in `@mailwoman/neural` without depending on it (B3-5: the partial-code prior touches zero
436
- * model inputs). `country` is the ISO-3166 alpha-2 the index was built for (upper-case); the resolver only probes an
437
- * index whose country matches the query's country scope.
438
- */
439
- export interface PostcodePrefixIndexLike {
440
- probe(prefix: string): PostcodePrefixNode | null;
441
- readonly country?: string;
442
- }
443
304
  export interface ResolveOpts {
444
305
  /**
445
306
  * Hard cap on how many backend lookups one tree may issue. Default 10. Prevents a tree with dozens of candidate nodes
@@ -464,6 +325,23 @@ export interface ResolveOpts {
464
325
  * overrides it deeper in the tree.
465
326
  */
466
327
  defaultCountry?: string;
328
+ /**
329
+ * True when {@link defaultCountry} was INFERRED from the locale rather than user-declared. A `country`-placetype
330
+ * lookup under an inferred scope is a self-contradiction — the query names a country outright, and the filter can
331
+ * only admit the scope country itself (bare `Germany` under the default en-US locale filtered out the DE row and fell
332
+ * through to a US locality whose historical alias is "Germany, Ohio"). The resolver therefore withholds an inferred
333
+ * {@link defaultCountry} from `country`-placetype lookups only; an EXPLICIT scope stays supreme (the #912 posture), as
334
+ * do parent evidence and the confident placer.
335
+ */
336
+ defaultCountryIsInferred?: boolean;
337
+ /**
338
+ * #1585 — the locale hint's country, scoping the backend's TYPO-FUZZY tier only. Unlike {@link defaultCountry} this
339
+ * is threaded even where the bare-toponym guard withholds the hard scope: an exact foreign match still resolves
340
+ * (`Paris` under en-US), but a typo CORRECTION stays inside the hinted country, and a scoped-empty correction
341
+ * abstains rather than falling through to a world-fuzzy candidate (`Stanmore Bay` under en-NZ must not answer Banmore
342
+ * IN). Never a country filter on exact matches — the fuzzy tier is the only consumer.
343
+ */
344
+ fuzzyCountryScope?: string;
467
345
  /**
468
346
  * Ordered proximity-bias points (viewport center first, then user location, …), each optionally weighted (default
469
347
  * 1.0). SOFT ranking signal only — candidates near a bias point win prominence ties (the ambiguous-postcode case:
@@ -543,6 +421,18 @@ export interface ResolveOpts {
543
421
  * consulted when `localeCountryPrior` is set.
544
422
  */
545
423
  localeCountryPriorWeight?: number;
424
+ /**
425
+ * #1880 — capital status of a candidate (2 national capital, 1 admin-1 seat, 0 neither), answered by the caller's
426
+ * reference against the candidate's own name + country + coordinates. Consumed by the resolver's bounded capital
427
+ * promotion (`resolver/toponym-prior.ts` — the bare-toponym class only, after the fame key). Structural rather than a
428
+ * named import because this package must not depend on the reference's home. Undefined → no promotion, byte-stable.
429
+ */
430
+ capitalLevel?: (place: {
431
+ name: string;
432
+ country?: string;
433
+ lat: number;
434
+ lon: number;
435
+ }) => number;
546
436
  /**
547
437
  * #743/#194 — a CONFIDENT coarse-placer country applied as a HARD candidate filter (`query.country`), not the soft
548
438
  * {@link anchorPosterior} boost. This collapses the off-continent tail for LOW-population places the soft prior can't
@@ -777,6 +667,14 @@ export interface ResolveOpts {
777
667
  * structural type (`PostcodePrefixIndexLike`), injected, never imported from `@mailwoman/neural`.
778
668
  */
779
669
  postcodePrefixPrior?: boolean;
670
+ /**
671
+ * #1589 — countries the parsed postcode's FORMAT implies (the #928 unforgeable singles plus the shared `NNN NN`
672
+ * CZ/SK/SE/GR family). Applied by the `postalcode` lookup ONLY when no country constraint survives (an explicit
673
+ * `defaultCountry` outranks format evidence, which outranks a locale hint): the lookup probes exactly the implied
674
+ * countries, keeps the most populous hit, and abstains when all miss rather than falling through to a fold-colliding
675
+ * unconstrained probe.
676
+ */
677
+ postcodeFormatCountries?: readonly string[];
780
678
  /**
781
679
  * The PFX1 postcode-prefix index to probe when {@link postcodePrefixPrior} is on — injected by the pipeline (loaded
782
680
  * from `$MAILWOMAN_DATA_ROOT/postcode-prefix/postcode-prefix-<cc>.bin`), never constructed here. Structural
@@ -797,11 +695,28 @@ export interface ResolveOpts {
797
695
  * or the backend lacks `ancestors`. Pass `false` to opt out.
798
696
  */
799
697
  adminCoherence?: boolean;
800
- hierarchyCompletion?: boolean;
801
698
  /**
802
- * @deprecated Renamed to {@link hierarchyCompletion} (#405 generalized #387). Still honored.
699
+ * Dual-role completion (#387, generalized by #405). Some places are two things at once — Singapore is a country AND a
700
+ * city, Washington DC a region AND a locality — but the address writes one span, so the tree resolves a region and
701
+ * carries no locality node even though the place genuinely is one.
702
+ *
703
+ * When a region resolved and no locality span is present, this asks the gazetteer's `coincident_roles` relation
704
+ * (#403, via {@link ResolverBackend.coincidentLocalitiesFor}) whether that region also functions as a locality, and
705
+ * ATTACHES a second reading to the same node. The region answer is untouched; the locality reading rides alongside it
706
+ * in `interpretations`, stamped `resolver_completed` so a consumer can tell it was inferred rather than parsed.
707
+ *
708
+ * **Default-ON, and on the shipped default backend it currently does nothing.** `WOFCandidateTableLookup` implements
709
+ * neither `coincidentLocalitiesFor` nor `ancestors` — `candidate.db` carries no such table — so the guard returns and
710
+ * no interpretation is attached. `Resolver.capabilityGaps` reports that at construction rather than leaving it
711
+ * silent.
712
+ *
713
+ * Measured 2026-08-15 on the FTS backend, which DOES implement both: toggling this flag changed **0 of 837** board
714
+ * inputs. The capability is real and its measured value on everything we currently test is zero, which is why
715
+ * `candidate.db` was not grown to support it (#1667, closed not-planned). Reopen on a consumer that needs it.
716
+ *
717
+ * `false` opts out; byte-stable either way on any backend lacking the relation.
803
718
  */
804
- cityStateFallback?: boolean;
719
+ hierarchyCompletion?: boolean;
805
720
  /**
806
721
  * Attach each resolved node's ancestor lineage (#404) — the containment chain (county → region → country) the
807
722
  * backend's {@link ResolverBackend.ancestors} returns — onto `metadata.ancestors`. The Pelias/Nominatim
@@ -810,71 +725,117 @@ export interface ResolveOpts {
810
725
  * resolver actually resolved.
811
726
  */
812
727
  includeAncestors?: boolean;
728
+ /**
729
+ * Admin-containment re-rank (#1717 stage 2) — make a parsed REGION qualifier participate in locality-candidate
730
+ * selection. `Weimar, Thüringen` under the en-US locale resolves to Weimar, Texas: the locale-inferred
731
+ * `defaultCountry` becomes a hard `country` filter on the locality lookup, so the candidate pool is all-US before any
732
+ * comparator runs — the qualifier the parse got RIGHT never reaches the deciding site (the #1729 lesson, measured
733
+ * again here: the DE row is simply not in the list). The coherence passes cannot reach this class either:
734
+ * `applyAdminCoherence` needs the locality to have FAILED, `applyRegionCountryCoherence` expands only the codex US+CA
735
+ * subdivision table, and there is no postcode for #42 to re-scope by.
736
+ *
737
+ * When on, the walk threads the tree's first region-tagged span onto every locality lookup
738
+ * (`FindPlaceQuery.regionQualifier`); a capable backend answers containment from its ancestors sidecar — stamping
739
+ * `ResolvedPlace.containedByQualifier` and ADDING contained same-name candidates a locale-inferred country scope hid
740
+ * — and the walk finishes with a TIER-SAFE stable partition: contained candidates ahead of uncontained ones, within
741
+ * the exact-match tier, preserving each group's relative order. The partition runs AFTER the fame/anchor re-ranks
742
+ * because the qualifier is the address's OWN text — evidence, which outranks a prior (the same precedence
743
+ * `anchorPosterior` holds over `rankByImportance`).
744
+ *
745
+ * Soft by construction: candidates are only ever added or reordered, never dropped, so a qualifier that matches
746
+ * nothing (or contains no same-name candidate) leaves the answer byte-identical. Stands down under an EXPLICIT caller
747
+ * `defaultCountry` (the #912 posture: only a locale-INFERRED scope is bypassable by the address's own evidence). Each
748
+ * locality pick records `metadata.admin_containment`: `"contained"` (the sidecar vouched for at least one candidate),
749
+ * `"no_contained_candidate"` (evaluated, none contained), or `"unavailable"` (the backend or artifact cannot answer —
750
+ * a pre-sidecar candidate.db, the FTS/browser backends) — so an inert lever is visible in the trace rather than
751
+ * silently dead (#1719's rule; the parse-side census cannot see resolver levers, so the stamp is the census surface
752
+ * here).
753
+ *
754
+ * **Default OFF** (D-rule): opt in and measure; the promotion battery is the full board + gauntlet + parity ON/OFF
755
+ * with one declared variable.
756
+ */
757
+ adminContainmentRerank?: boolean;
758
+ /**
759
+ * Resolver-interior trace sink (#1721): when set, the walk emits one {@link ResolveNodeTrace} per candidate lookup —
760
+ * the query as sent, the candidate table with per-stage ranks, every gate that fired, and the pick's provenance — so
761
+ * "the right row was present at rank 3 and lost to the fame term" is a recorded fact instead of a spelunking result.
762
+ * Absent (the default) the walk does ZERO trace bookkeeping and stays byte-identical; the sink is a hot-path opt-in
763
+ * for debug surfaces, never a production default.
764
+ */
765
+ traceSink?: (record: ResolveNodeTrace) => void;
766
+ /**
767
+ * When a lookup resolves NOTHING, re-probe the same value across the other admin bands and record which ones hold it
768
+ * ({@link ResolveNodeTrace.reachableIn}) — a DIAGNOSTIC that never changes the answer.
769
+ *
770
+ * The distinction it buys is the one a `null` cannot carry: a key we hold under a different placetype is a
771
+ * REACHABILITY failure — the model's tag chose the band, and a wrong tag makes a row we own unreachable — while a key
772
+ * that exists nowhere is a coverage fact. Those call for opposite work and today reach a caller identically.
773
+ *
774
+ * Costs one extra backend call per band per miss, so it is off by default and belongs to debug surfaces. Requires
775
+ * `traceSink`: with no sink there is nowhere to record the answer, and the probes would be pure cost.
776
+ */
777
+ diagnoseUnreachable?: boolean;
813
778
  }
814
779
  /**
815
- * Mapping from mailwoman's address-component tags to the resolver's placetype taxonomy. Components not present in the
816
- * map are NOT queried — the resolver pass leaves their classifier attribution untouched.
817
- *
818
- * Phase 4.3 default ships the obvious admin-level mappings; other tags (postcode, street, venue, dependent_locality,
819
- * prefecture, etc.) are explicitly omitted because:
820
- *
821
- * - `postcode` lives in a separate WOF shard (Phase 4.3.x follow-up via the postalcode loader).
822
- * - `street` / `house_number` aren't in WOF admin — would need OSM / OpenAddresses gazetteers and license diligence
823
- * (Phase 4.4 candidate).
824
- * - Non-US JP-specific tags wait on a different shard entirely.
825
- */
826
- export type PlacetypeMap = Partial<Record<ComponentTag, string>>;
827
- /**
828
- * Placetype equivalences applied when a backend does not supply its own. A `locality` query must also reach `borough`
829
- * and `localadmin` rows — Brooklyn is a borough, and a strict filter made it unreachable.
830
- */
831
- export declare const DEFAULT_PLACETYPE_MAP: PlacetypeMap;
832
- /**
833
- * Placetype-equivalence groups for lookup FILTERING. WOF splits a single addressing tier across several placetypes, but
834
- * an address's span can name ANY of them. A backend that filters to the one "obvious" placetype makes the equivalents
835
- * unreachable, so a fuzzy same-name place in the wrong tier wins instead.
836
- *
837
- * Three tiers are affected (the value of each entry is the set the SQL filter should accept; the FIRST entry is the
838
- * canonical/requested type, which shard routing keys off):
839
- *
840
- * - **`locality`** — `locality` (most cities), `borough` (Brooklyn, the Paris arrondissements, the London boroughs), and
841
- * `localadmin` (FR communes, US towns/townships in New England). Without the group, Brooklyn-the-borough (pop 2.5M)
842
- * was unreachable and the fuzzy "Brooklyn Park, MN" won.
843
- * - **`region`** — `region` + `macroregion` (#718). WOF does NOT model every country's top-level civil division as
844
- * `region`: Italian regions (Lombardia, Veneto, Toscana…) are `macroregion` (their PROVINCES are `region`), and the
845
- * post-2016 French régions (Île-de-France) are `macroregion` too. An address's `region` span names exactly those, so
846
- * a `region`-only filter resolved them to NOTHING (confirmed against the IT/FR eval rows). US states / DE
847
- * Bundesländer / ES provincias are genuine `region`, so the EXACT-type match is preferred in ranking (see the
848
- * resolve.ts fallback-quality annotation) — the macro is the recall safety net, not a demotion.
849
- * - **`county`** — `county` + `macrocounty` (#718). The `subregion` ComponentTag maps to `county` via
850
- * {@link DEFAULT_PLACETYPE_MAP}; WOF carries `macrocounty` for FR départements-grouping / DE / GB tiers above the
851
- * county. Proactive (no eval row exercises `subregion` today) but symmetric with `region` — biasing to inclusion,
852
- * since a missed resolution costs more than a too-broad candidate (which is QA-visible). Same exact-type preference
853
- * applies.
854
- *
855
- * This table is the single source of truth for that expansion, shared by every lookup backend
856
- * (`@mailwoman/core/resolver-wof-sqlite`, `@mailwoman/core/resolver-wof-wasm`, and the demo's httpvfs lookup) so the
857
- * Node and browser resolvers can't drift. Keyed by the REQUESTED placetype. Placetypes without an entry pass through
858
- * unchanged — an explicit `placetype: "borough"` query stays narrow.
859
- */
860
- export declare const PLACETYPE_FILTER_GROUPS: Readonly<Record<string, readonly string[]>>;
861
- /**
862
- * Expand a placetype filter through {@link PLACETYPE_FILTER_GROUPS}, deduplicated and order-preserving (the first entry
863
- * stays first — shard routing keys off it). `null`/`undefined` (no filter) passes through untouched.
780
+ * One candidate as the resolver's deciding site saw it — the fields the ranking stages actually read, plus a per-stage
781
+ * rank vector. `ranks` carries one entry per stage that RAN, in execution order (`initial` = the backend's own order;
782
+ * then whichever of `anchor`, `locale_prior`, `importance`, `containment`, `exact_type` were active); a stage a
783
+ * candidate set never went through is absent, never defaulted. The vector is what makes loss attributable: the stage
784
+ * whose entry moved a row down is the term it lost to.
864
785
  */
865
- export declare function expandPlacetypeFilter(placetypes: null): null;
866
- export declare function expandPlacetypeFilter(placetypes: readonly string[]): string[];
867
- export declare function expandPlacetypeFilter(placetypes: readonly string[] | null): string[] | null;
786
+ export interface ResolveCandidateTrace {
787
+ id: string | number;
788
+ name: string;
789
+ country: string;
790
+ placetype: string;
791
+ score: number;
792
+ prominence?: number;
793
+ importance?: number;
794
+ population?: number;
795
+ exactMatch?: boolean;
796
+ containedByQualifier?: boolean;
797
+ ranks: Record<string, number>;
798
+ }
868
799
  /**
869
- * Did `candidatePlacetype` resolve `requestedPlacetype` only via a BROADER admin tier (a macro-type fallback within the
870
- * {@link PLACETYPE_FILTER_GROUPS} expansion), rather than the exact type (#718)?
871
- *
872
- * `region` → `region` is exact (false); `region` → `macroregion` is a fallback (true). Scoped to the `macro*` tiers
873
- * (see {@link MACRO_FALLBACK_PLACETYPES}) so the `locality` group's borough/localadmin peers stay exact. The resolver
874
- * uses this to (a) prefer an exact-type candidate in ranking and (b) annotate `resolutionQuality: "fallback"` when only
875
- * a macro-type matched. A placetype outside the requested group, or any non-macro member, is treated as exact (false).
800
+ * One `ResolveNodeTrace` per backend lookup the walk performed (#1721) — and one per POST-WALK recovery that answers
801
+ * off the walk (`span_rescore`, `postal_compound_recovery`), so no resolved coordinate is off the record. `gates`
802
+ * records mechanism events in execution order, in the resolver's own vocabulary (`parent_fallback_retry`,
803
+ * `region_scope_miss`, `backend_error`, `postcode_format_probe`, `postcode_prefix_prior`, `bare_race`,
804
+ * `empty_admin_pick`, `min_score_reject`, `bare_country_repick`, `bare_region_repick`, `placetype_fallback`). `picked:
805
+ * null` states the lookup resolved nothing — a claim, not an omission. The candidate table is capped
806
+ * ({@link ResolveNodeTrace.candidatesTruncated} counts the tail) so a trace stays a record, not a dump.
876
807
  */
877
- export declare function isPlacetypeFallback(requestedPlacetype: string, candidatePlacetype: string): boolean;
808
+ export interface ResolveNodeTrace {
809
+ tag: string;
810
+ value: string;
811
+ placetype: string;
812
+ query: {
813
+ country?: string;
814
+ parentID?: string | number;
815
+ postcode?: string;
816
+ regionQualifier?: string;
817
+ limit: number;
818
+ };
819
+ gates: string[];
820
+ /**
821
+ * Which OTHER admin bands hold this value, probed only when the lookup resolved nothing and
822
+ * {@link ResolveOpts.diagnoseUnreachable} is on.
823
+ *
824
+ * `[]` is a measured absence — every band was asked and none held it, so the miss is coverage. `undefined` means
825
+ * nobody asked, which is a different fact and must not be read as an empty answer.
826
+ */
827
+ reachableIn?: Array<{
828
+ placetype: string;
829
+ n: number;
830
+ }>;
831
+ candidates: ResolveCandidateTrace[];
832
+ candidatesTruncated: number;
833
+ picked: {
834
+ id: string | number;
835
+ name: string;
836
+ source: "ranked" | "bare_country" | "bare_region" | "postcode_prefix" | "postcode_format_probe" | "empty_admin" | "span_rescore" | "postal_compound_recovery";
837
+ } | null;
838
+ }
878
839
  /**
879
840
  * The interface implemented by `createWOFResolver` and any future resolver factories.
880
841
  *
@@ -884,11 +845,24 @@ export declare function isPlacetypeFallback(requestedPlacetype: string, candidat
884
845
  */
885
846
  export interface Resolver {
886
847
  resolveTree(tree: AddressTree, opts?: ResolveOpts): Promise<AddressTree>;
848
+ /**
849
+ * Direct gazetteer probe, passed through from the {@link ResolverBackend} — for pipeline-level consumers that need one
850
+ * lookup outside a tree walk (the #1738 dominant-bearer guard on the coarse placer's hard-country promotion is the
851
+ * first). Optional like the members below: a resolver without it degrades its consumers to their without-the-probe
852
+ * behavior, never to a crash.
853
+ */
854
+ findPlace?: ResolverBackend["findPlace"];
887
855
  /**
888
856
  * Facts the loaded gazetteer artifact declares about itself, passed through from the {@link ResolverBackend} so
889
857
  * pipeline-level consumers (the hard-country coverage gate, guard-B plausibility) read them from the handle they
890
858
  * already hold. Absent = artifact predates the manifest → code-constant fallback.
891
859
  */
892
860
  artifactCoverage?: GazetteerArtifactCoverage;
861
+ /**
862
+ * Optional backend methods this resolver's backend does not implement, each naming the default-ON option it silently
863
+ * disables. Empty means every default-ON option has the support it needs; absent means the resolver predates the
864
+ * check. See {@link BackendCapabilityGap}.
865
+ */
866
+ capabilityGaps?: readonly BackendCapabilityGap[];
893
867
  }
894
868
  //# sourceMappingURL=types.d.ts.map