@mailwoman/core 8.1.0 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) hide show
  1. package/api/APIClient.ts +3 -4
  2. package/api/responses.ts +6 -3
  3. package/coarse-placer/coarse-placer.ts +26 -11
  4. package/coarse-placer/featurize.ts +25 -16
  5. package/coarse-placer/tools/build-dataset.ts +42 -18
  6. package/coarse-placer/tools/build-outlier-exposure.ts +51 -18
  7. package/coarse-placer/tools/build-outlier-latin.ts +48 -22
  8. package/coarse-placer/tools/build-outlier-oa.ts +52 -20
  9. package/coarse-placer/tools/eval-latin-offmap.ts +37 -12
  10. package/coarse-placer/tools/eval-openset.ts +104 -37
  11. package/coarse-placer/tools/eval-quant-compare.ts +41 -11
  12. package/coarse-placer/tools/eval.ts +51 -13
  13. package/coarse-placer/tools/fnv-hash.ts +5 -3
  14. package/coarse-placer/tools/probe-frontier.ts +63 -32
  15. package/coarse-placer/tools/quantize.ts +30 -8
  16. package/coarse-placer/tools/train.ts +63 -17
  17. package/collections.ts +2 -2
  18. package/decoder/build-tree.ts +16 -3
  19. package/decoder/calibration.ts +23 -7
  20. package/decoder/containment.ts +3 -1
  21. package/decoder/proposals-to-tree.ts +2 -0
  22. package/decoder/resolve-proposal-overlaps.ts +5 -1
  23. package/decoder/serialize-json.ts +8 -2
  24. package/decoder/serialize-tuples.ts +7 -2
  25. package/decoder/serialize-xml.ts +29 -11
  26. package/decoder/types.ts +34 -12
  27. package/decoder/unknown-spans.ts +14 -5
  28. package/decoder/validate-tree.ts +6 -1
  29. package/env/index.ts +1 -1
  30. package/env/load.ts +1 -1
  31. package/env/paths.ts +1 -1
  32. package/env/schema.ts +12 -4
  33. package/errors/schema.ts +1 -1
  34. package/fs/node.ts +9 -10
  35. package/identifiers.ts +3 -3
  36. package/kysley/adapter.ts +1 -1
  37. package/layers/manifest.ts +22 -8
  38. package/layers/schema.ts +59 -19
  39. package/locale/locale.ts +6 -2
  40. package/locale/profiles/en-us.ts +3 -0
  41. package/locale/profiles/fr-fr.ts +3 -0
  42. package/locale/profiles/ja-jp.ts +6 -0
  43. package/locale/registry.ts +3 -1
  44. package/logging/shared.ts +1 -0
  45. package/logging/utils.ts +1 -1
  46. package/objects.ts +7 -2
  47. package/out/api/APIClient.d.ts +1 -1
  48. package/out/api/APIClient.d.ts.map +1 -1
  49. package/out/api/APIClient.js +3 -2
  50. package/out/api/APIClient.js.map +1 -1
  51. package/out/api/responses.d.ts.map +1 -1
  52. package/out/api/responses.js +3 -3
  53. package/out/api/responses.js.map +1 -1
  54. package/out/coarse-placer/coarse-placer.d.ts +19 -9
  55. package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
  56. package/out/coarse-placer/coarse-placer.js +6 -4
  57. package/out/coarse-placer/coarse-placer.js.map +1 -1
  58. package/out/coarse-placer/featurize.d.ts.map +1 -1
  59. package/out/coarse-placer/featurize.js +20 -16
  60. package/out/coarse-placer/featurize.js.map +1 -1
  61. package/out/coarse-placer/tools/build-dataset.d.ts +15 -5
  62. package/out/coarse-placer/tools/build-dataset.d.ts.map +1 -1
  63. package/out/coarse-placer/tools/build-dataset.js +19 -14
  64. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  65. package/out/coarse-placer/tools/build-outlier-exposure.d.ts +21 -7
  66. package/out/coarse-placer/tools/build-outlier-exposure.d.ts.map +1 -1
  67. package/out/coarse-placer/tools/build-outlier-exposure.js +24 -12
  68. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  69. package/out/coarse-placer/tools/build-outlier-latin.d.ts +18 -6
  70. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  71. package/out/coarse-placer/tools/build-outlier-latin.js +27 -17
  72. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  73. package/out/coarse-placer/tools/build-outlier-oa.d.ts +18 -6
  74. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  75. package/out/coarse-placer/tools/build-outlier-oa.js +29 -15
  76. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  77. package/out/coarse-placer/tools/eval-latin-offmap.d.ts +18 -6
  78. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  79. package/out/coarse-placer/tools/eval-latin-offmap.js +13 -7
  80. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  81. package/out/coarse-placer/tools/eval-openset.d.ts +24 -8
  82. package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
  83. package/out/coarse-placer/tools/eval-openset.js +52 -31
  84. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  85. package/out/coarse-placer/tools/eval-quant-compare.d.ts +30 -10
  86. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
  87. package/out/coarse-placer/tools/eval-quant-compare.js +4 -2
  88. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  89. package/out/coarse-placer/tools/eval.d.ts +24 -8
  90. package/out/coarse-placer/tools/eval.d.ts.map +1 -1
  91. package/out/coarse-placer/tools/eval.js +16 -6
  92. package/out/coarse-placer/tools/eval.js.map +1 -1
  93. package/out/coarse-placer/tools/fnv-hash.d.ts +3 -1
  94. package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
  95. package/out/coarse-placer/tools/fnv-hash.js +5 -3
  96. package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
  97. package/out/coarse-placer/tools/probe-frontier.d.ts +18 -6
  98. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  99. package/out/coarse-placer/tools/probe-frontier.js +39 -23
  100. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  101. package/out/coarse-placer/tools/quantize.d.ts +15 -5
  102. package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
  103. package/out/coarse-placer/tools/quantize.js +11 -4
  104. package/out/coarse-placer/tools/quantize.js.map +1 -1
  105. package/out/coarse-placer/tools/train.d.ts +24 -8
  106. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  107. package/out/coarse-placer/tools/train.js +24 -10
  108. package/out/coarse-placer/tools/train.js.map +1 -1
  109. package/out/collections.js +2 -2
  110. package/out/collections.js.map +1 -1
  111. package/out/decoder/build-tree.d.ts.map +1 -1
  112. package/out/decoder/build-tree.js +9 -3
  113. package/out/decoder/build-tree.js.map +1 -1
  114. package/out/decoder/calibration.d.ts +17 -3
  115. package/out/decoder/calibration.d.ts.map +1 -1
  116. package/out/decoder/calibration.js +12 -4
  117. package/out/decoder/calibration.js.map +1 -1
  118. package/out/decoder/containment.d.ts +3 -1
  119. package/out/decoder/containment.d.ts.map +1 -1
  120. package/out/decoder/containment.js +3 -1
  121. package/out/decoder/containment.js.map +1 -1
  122. package/out/decoder/proposals-to-tree.d.ts.map +1 -1
  123. package/out/decoder/proposals-to-tree.js.map +1 -1
  124. package/out/decoder/resolve-proposal-overlaps.d.ts.map +1 -1
  125. package/out/decoder/resolve-proposal-overlaps.js +5 -1
  126. package/out/decoder/resolve-proposal-overlaps.js.map +1 -1
  127. package/out/decoder/serialize-json.d.ts +6 -2
  128. package/out/decoder/serialize-json.d.ts.map +1 -1
  129. package/out/decoder/serialize-json.js.map +1 -1
  130. package/out/decoder/serialize-tuples.d.ts +6 -2
  131. package/out/decoder/serialize-tuples.d.ts.map +1 -1
  132. package/out/decoder/serialize-tuples.js.map +1 -1
  133. package/out/decoder/serialize-xml.d.ts +21 -7
  134. package/out/decoder/serialize-xml.d.ts.map +1 -1
  135. package/out/decoder/serialize-xml.js +7 -5
  136. package/out/decoder/serialize-xml.js.map +1 -1
  137. package/out/decoder/types.d.ts +34 -12
  138. package/out/decoder/types.d.ts.map +1 -1
  139. package/out/decoder/types.js +1 -1
  140. package/out/decoder/types.js.map +1 -1
  141. package/out/decoder/unknown-spans.d.ts +9 -3
  142. package/out/decoder/unknown-spans.d.ts.map +1 -1
  143. package/out/decoder/unknown-spans.js +4 -2
  144. package/out/decoder/unknown-spans.js.map +1 -1
  145. package/out/decoder/validate-tree.d.ts +3 -1
  146. package/out/decoder/validate-tree.d.ts.map +1 -1
  147. package/out/decoder/validate-tree.js +3 -1
  148. package/out/decoder/validate-tree.js.map +1 -1
  149. package/out/env/index.js +0 -1
  150. package/out/env/index.js.map +1 -1
  151. package/out/env/load.js +1 -1
  152. package/out/env/load.js.map +1 -1
  153. package/out/env/paths.js +1 -1
  154. package/out/env/paths.js.map +1 -1
  155. package/out/env/schema.d.ts.map +1 -1
  156. package/out/env/schema.js +12 -4
  157. package/out/env/schema.js.map +1 -1
  158. package/out/errors/schema.js +1 -1
  159. package/out/errors/schema.js.map +1 -1
  160. package/out/fs/node.d.ts +1 -2
  161. package/out/fs/node.d.ts.map +1 -1
  162. package/out/fs/node.js +7 -8
  163. package/out/fs/node.js.map +1 -1
  164. package/out/identifiers.js +3 -3
  165. package/out/identifiers.js.map +1 -1
  166. package/out/kysley/adapter.d.ts +1 -1
  167. package/out/kysley/adapter.d.ts.map +1 -1
  168. package/out/kysley/adapter.js +1 -1
  169. package/out/kysley/adapter.js.map +1 -1
  170. package/out/layers/manifest.d.ts +18 -6
  171. package/out/layers/manifest.d.ts.map +1 -1
  172. package/out/layers/manifest.js +8 -4
  173. package/out/layers/manifest.js.map +1 -1
  174. package/out/layers/schema.d.ts +57 -19
  175. package/out/layers/schema.d.ts.map +1 -1
  176. package/out/layers/schema.js +24 -8
  177. package/out/layers/schema.js.map +1 -1
  178. package/out/locale/locale.d.ts +6 -2
  179. package/out/locale/locale.d.ts.map +1 -1
  180. package/out/locale/profiles/en-us.d.ts +3 -0
  181. package/out/locale/profiles/en-us.d.ts.map +1 -1
  182. package/out/locale/profiles/en-us.js +3 -0
  183. package/out/locale/profiles/en-us.js.map +1 -1
  184. package/out/locale/profiles/fr-fr.d.ts +3 -0
  185. package/out/locale/profiles/fr-fr.d.ts.map +1 -1
  186. package/out/locale/profiles/fr-fr.js +3 -0
  187. package/out/locale/profiles/fr-fr.js.map +1 -1
  188. package/out/locale/profiles/ja-jp.d.ts +3 -0
  189. package/out/locale/profiles/ja-jp.d.ts.map +1 -1
  190. package/out/locale/profiles/ja-jp.js +6 -0
  191. package/out/locale/profiles/ja-jp.js.map +1 -1
  192. package/out/locale/registry.d.ts +3 -1
  193. package/out/locale/registry.d.ts.map +1 -1
  194. package/out/locale/registry.js +3 -1
  195. package/out/locale/registry.js.map +1 -1
  196. package/out/logging/shared.d.ts.map +1 -1
  197. package/out/logging/shared.js +1 -0
  198. package/out/logging/shared.js.map +1 -1
  199. package/out/logging/utils.js +1 -1
  200. package/out/logging/utils.js.map +1 -1
  201. package/out/objects.d.ts.map +1 -1
  202. package/out/objects.js +2 -2
  203. package/out/objects.js.map +1 -1
  204. package/out/pipeline/index.d.ts +2 -2
  205. package/out/pipeline/index.d.ts.map +1 -1
  206. package/out/pipeline/index.js +1 -1
  207. package/out/pipeline/index.js.map +1 -1
  208. package/out/pipeline/reconcile-lookups.d.ts.map +1 -1
  209. package/out/pipeline/reconcile-lookups.js.map +1 -1
  210. package/out/pipeline/reconcile.d.ts +30 -10
  211. package/out/pipeline/reconcile.d.ts.map +1 -1
  212. package/out/pipeline/reconcile.js +12 -9
  213. package/out/pipeline/reconcile.js.map +1 -1
  214. package/out/pipeline/runtime-pipeline.d.ts +18 -0
  215. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  216. package/out/pipeline/runtime-pipeline.js +73 -46
  217. package/out/pipeline/runtime-pipeline.js.map +1 -1
  218. package/out/pipeline/span-logit-aggregation.d.ts.map +1 -1
  219. package/out/pipeline/span-logit-aggregation.js +5 -2
  220. package/out/pipeline/span-logit-aggregation.js.map +1 -1
  221. package/out/pipeline/span-proposer.d.ts +19 -9
  222. package/out/pipeline/span-proposer.d.ts.map +1 -1
  223. package/out/pipeline/span-proposer.js +42 -22
  224. package/out/pipeline/span-proposer.js.map +1 -1
  225. package/out/pipeline/types.d.ts +77 -19
  226. package/out/pipeline/types.d.ts.map +1 -1
  227. package/out/pipeline/types.js +16 -0
  228. package/out/pipeline/types.js.map +1 -1
  229. package/out/policy/proposal-collection.d.ts +1 -1
  230. package/out/policy/proposal-collection.d.ts.map +1 -1
  231. package/out/policy/proposal-collection.js +2 -3
  232. package/out/policy/proposal-collection.js.map +1 -1
  233. package/out/policy/registry.d.ts +9 -3
  234. package/out/policy/registry.d.ts.map +1 -1
  235. package/out/policy/registry.js +9 -3
  236. package/out/policy/registry.js.map +1 -1
  237. package/out/resolver/index.d.ts.map +1 -1
  238. package/out/resolver/types.d.ts +94 -30
  239. package/out/resolver/types.d.ts.map +1 -1
  240. package/out/resolver/types.js +7 -1
  241. package/out/resolver/types.js.map +1 -1
  242. package/out/resources/LocaleIndex.d.ts +1 -1
  243. package/out/resources/LocaleIndex.d.ts.map +1 -1
  244. package/out/resources/LocaleIndex.js +1 -2
  245. package/out/resources/LocaleIndex.js.map +1 -1
  246. package/out/resources/ResourceMapCache.d.ts.map +1 -1
  247. package/out/resources/ResourceMapCache.js +1 -1
  248. package/out/resources/ResourceMapCache.js.map +1 -1
  249. package/out/resources/collections.d.ts.map +1 -1
  250. package/out/resources/collections.js +3 -1
  251. package/out/resources/collections.js.map +1 -1
  252. package/out/resources/languages/index.d.ts +1 -1
  253. package/out/resources/languages/index.d.ts.map +1 -1
  254. package/out/resources/languages/index.js +1 -1
  255. package/out/resources/languages/index.js.map +1 -1
  256. package/out/resources/libpostal.d.ts +1 -1
  257. package/out/resources/libpostal.d.ts.map +1 -1
  258. package/out/resources/libpostal.js +7 -5
  259. package/out/resources/libpostal.js.map +1 -1
  260. package/out/resources/set.js +6 -6
  261. package/out/resources/set.js.map +1 -1
  262. package/out/resources/whosonfirst/DataSourceCache.d.ts +1 -4
  263. package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
  264. package/out/resources/whosonfirst/DataSourceCache.js +1 -20
  265. package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
  266. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +1 -1
  267. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  268. package/out/resources/whosonfirst/PlacetypeDataSource.js +2 -2
  269. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  270. package/out/resources/whosonfirst/backoff.d.ts +19 -0
  271. package/out/resources/whosonfirst/backoff.d.ts.map +1 -0
  272. package/out/resources/whosonfirst/backoff.js +35 -0
  273. package/out/resources/whosonfirst/backoff.js.map +1 -0
  274. package/out/resources/whosonfirst/loader.d.ts +1 -1
  275. package/out/resources/whosonfirst/loader.d.ts.map +1 -1
  276. package/out/resources/whosonfirst/loader.js +0 -1
  277. package/out/resources/whosonfirst/loader.js.map +1 -1
  278. package/out/resources/whosonfirst/placetypes/Placetype.d.ts +4 -1
  279. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  280. package/out/resources/whosonfirst/placetypes/Placetype.js +8 -6
  281. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  282. package/out/resources/whosonfirst/placetypes/admin.d.ts +6 -4
  283. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  284. package/out/resources/whosonfirst/placetypes/admin.js +8 -4
  285. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  286. package/out/resources/whosonfirst/placetypes/definition.d.ts +5 -6
  287. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  288. package/out/resources/whosonfirst/placetypes/definition.js +3 -0
  289. package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
  290. package/out/resources/whosonfirst/placetypes/graph.d.ts +4 -2
  291. package/out/resources/whosonfirst/placetypes/graph.d.ts.map +1 -1
  292. package/out/resources/whosonfirst/placetypes/graph.js +0 -0
  293. package/out/resources/whosonfirst/placetypes/graph.js.map +1 -1
  294. package/out/resources/whosonfirst/placetypes/mermaid.d.ts +4 -2
  295. package/out/resources/whosonfirst/placetypes/mermaid.d.ts.map +1 -1
  296. package/out/resources/whosonfirst/placetypes/mermaid.js +0 -1
  297. package/out/resources/whosonfirst/placetypes/mermaid.js.map +1 -1
  298. package/out/resources/whosonfirst/placetypes/tree.d.ts +1 -1
  299. package/out/resources/whosonfirst/placetypes/tree.d.ts.map +1 -1
  300. package/out/resources/whosonfirst/placetypes/tree.js +0 -1
  301. package/out/resources/whosonfirst/placetypes/tree.js.map +1 -1
  302. package/out/routing/index.d.ts.map +1 -1
  303. package/out/routing/index.js +1 -1
  304. package/out/routing/index.js.map +1 -1
  305. package/out/scripting/utils/index.d.ts +3 -1
  306. package/out/scripting/utils/index.d.ts.map +1 -1
  307. package/out/scripting/utils/index.js +3 -1
  308. package/out/scripting/utils/index.js.map +1 -1
  309. package/out/tokenization/Span.js.map +1 -1
  310. package/out/tokenization/normalizer.js +11 -11
  311. package/out/tokenization/normalizer.js.map +1 -1
  312. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  313. package/out/tools/download-libpostal-resources.js.map +1 -1
  314. package/out/tools/download-ssl-address.d.ts +9 -3
  315. package/out/tools/download-ssl-address.d.ts.map +1 -1
  316. package/out/tools/download-ssl-address.js +8 -4
  317. package/out/tools/download-ssl-address.js.map +1 -1
  318. package/out/tools/generate-language-types.d.ts +12 -4
  319. package/out/tools/generate-language-types.d.ts.map +1 -1
  320. package/out/tools/generate-language-types.js +3 -1
  321. package/out/tools/generate-language-types.js.map +1 -1
  322. package/out/types/Classification.d.ts.map +1 -1
  323. package/out/types/Classification.js.map +1 -1
  324. package/out/types/classifier.d.ts +27 -9
  325. package/out/types/classifier.d.ts.map +1 -1
  326. package/out/types/component.d.ts +8 -4
  327. package/out/types/component.d.ts.map +1 -1
  328. package/out/types/component.js +3 -3
  329. package/out/types/component.js.map +1 -1
  330. package/out/utils/data-root.d.ts +3 -1
  331. package/out/utils/data-root.d.ts.map +1 -1
  332. package/out/utils/data-root.js +3 -1
  333. package/out/utils/data-root.js.map +1 -1
  334. package/out/utils/hash.d.ts +6 -2
  335. package/out/utils/hash.d.ts.map +1 -1
  336. package/out/utils/hash.js +6 -2
  337. package/out/utils/hash.js.map +1 -1
  338. package/out/utils/jsonl.d.ts +9 -3
  339. package/out/utils/jsonl.d.ts.map +1 -1
  340. package/out/utils/jsonl.js +9 -3
  341. package/out/utils/jsonl.js.map +1 -1
  342. package/out/utils/python-json.d.ts +6 -2
  343. package/out/utils/python-json.d.ts.map +1 -1
  344. package/out/utils/python-json.js +9 -3
  345. package/out/utils/python-json.js.map +1 -1
  346. package/out/utils/python-random.d.ts +15 -5
  347. package/out/utils/python-random.d.ts.map +1 -1
  348. package/out/utils/python-random.js +17 -7
  349. package/out/utils/python-random.js.map +1 -1
  350. package/out/utils/repo.d.ts +4 -0
  351. package/out/utils/repo.d.ts.map +1 -1
  352. package/out/utils/repo.js +4 -0
  353. package/out/utils/repo.js.map +1 -1
  354. package/out/utils/sealed-db.d.ts +6 -2
  355. package/out/utils/sealed-db.d.ts.map +1 -1
  356. package/out/utils/sealed-db.js +6 -2
  357. package/out/utils/sealed-db.js.map +1 -1
  358. package/out/utils/stats.d.ts +9 -3
  359. package/out/utils/stats.d.ts.map +1 -1
  360. package/out/utils/stats.js +11 -5
  361. package/out/utils/stats.js.map +1 -1
  362. package/package.json +2 -2
  363. package/pipeline/index.ts +5 -1
  364. package/pipeline/reconcile-lookups.ts +3 -0
  365. package/pipeline/reconcile.ts +65 -24
  366. package/pipeline/runtime-pipeline.ts +95 -46
  367. package/pipeline/span-logit-aggregation.ts +7 -2
  368. package/pipeline/span-proposer.ts +95 -34
  369. package/pipeline/types.ts +88 -19
  370. package/policy/proposal-collection.ts +4 -3
  371. package/policy/registry.ts +13 -3
  372. package/resolver/index.ts +1 -0
  373. package/resolver/types.ts +95 -30
  374. package/resources/LocaleIndex.ts +2 -2
  375. package/resources/ResourceMapCache.ts +3 -2
  376. package/resources/collections.ts +4 -1
  377. package/resources/languages/index.ts +2 -1
  378. package/resources/libpostal.ts +6 -3
  379. package/resources/set.ts +6 -6
  380. package/resources/whosonfirst/DataSourceCache.ts +2 -24
  381. package/resources/whosonfirst/PlacetypeDataSource.ts +2 -2
  382. package/resources/whosonfirst/backoff.ts +39 -0
  383. package/resources/whosonfirst/loader.ts +2 -1
  384. package/resources/whosonfirst/placetypes/Placetype.ts +9 -6
  385. package/resources/whosonfirst/placetypes/admin.ts +12 -7
  386. package/resources/whosonfirst/placetypes/definition.ts +6 -6
  387. package/resources/whosonfirst/placetypes/graph.ts +0 -0
  388. package/resources/whosonfirst/placetypes/mermaid.ts +5 -2
  389. package/resources/whosonfirst/placetypes/tree.ts +1 -1
  390. package/routing/index.ts +5 -1
  391. package/scripting/utils/index.ts +3 -1
  392. package/tokenization/Span.ts +1 -1
  393. package/tokenization/normalizer.ts +11 -11
  394. package/tools/download-libpostal-resources.ts +1 -0
  395. package/tools/download-ssl-address.ts +19 -7
  396. package/tools/generate-language-types.ts +12 -4
  397. package/types/Classification.ts +5 -0
  398. package/types/classifier.ts +27 -9
  399. package/types/component.ts +9 -5
  400. package/utils/data-root.ts +3 -1
  401. package/utils/hash.ts +6 -2
  402. package/utils/jsonl.ts +11 -3
  403. package/utils/python-json.ts +13 -4
  404. package/utils/python-random.ts +17 -7
  405. package/utils/repo.ts +8 -0
  406. package/utils/sealed-db.ts +10 -2
  407. package/utils/stats.ts +11 -5
@@ -85,7 +85,7 @@ export function aggregateSpanLogits(
85
85
  overlapping.push(t)
86
86
  }
87
87
 
88
- if (overlapping.length === 0) continue
88
+ if (!overlapping.length) continue
89
89
 
90
90
  // Aggregate softmax probabilities per component tag (strip BIO prefix).
91
91
  const tagScores = new Map<string, number>()
@@ -107,8 +107,10 @@ export function aggregateSpanLogits(
107
107
 
108
108
  // Normalize by number of overlapping tokens so longer spans don't auto-win.
109
109
  const norm = overlapping.length
110
+
110
111
  const sorted = [...tagScores.entries()]
111
112
  .map(([tag, score]) => ({ tag, score: score / norm }))
113
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
112
114
  .sort((a, b) => b.score - a.score)
113
115
  .slice(0, topK)
114
116
 
@@ -136,7 +138,9 @@ function stripBIOPrefix(label: string): string {
136
138
  return label.slice(dash + 1)
137
139
  }
138
140
 
139
- /** Numerically stable softmax over a row of logits. */
141
+ /**
142
+ * Numerically stable softmax over a row of logits.
143
+ */
140
144
  function softmax(row: readonly number[]): number[] {
141
145
  let max = row[0]!
142
146
 
@@ -144,6 +148,7 @@ function softmax(row: readonly number[]): number[] {
144
148
  if (row[i]! > max) {
145
149
  max = row[i]!
146
150
  }
151
+
147
152
  const exps = row.map((v) => Math.exp(v - max))
148
153
  const sum = exps.reduce((a, b) => a + b, 0)
149
154
 
@@ -34,13 +34,34 @@
34
34
  * (see `neural/span-proposer-lexicon.ts`).
35
35
  */
36
36
 
37
- /** Typed kinds a span proposal may carry. See the module doc for the three cue families. */
37
+ /**
38
+ * Token count below which an input is too short for its tail position to carry much signal.
39
+ */
40
+ const SHORT_INPUT_MAX_TOKENS = 3
41
+
42
+ /**
43
+ * Confidence for a tail span in an input too short to clear {@link SHORT_INPUT_MAX_TOKENS}.
44
+ */
45
+ const SHORT_TAIL_CONFIDENCE = 0.45
46
+
47
+ /**
48
+ * Digits in the first half of a ZIP+4. A hyphen compound with this shape is a postcode, not a house number.
49
+ */
50
+ const ZIP5_LENGTH = 5
51
+
52
+ /**
53
+ * Confidence at which an ANNOTATION_SPAN is trusted enough to swallow the inner proposals it covers. Below it both
54
+ * readings survive and the reconciler decides.
55
+ */
56
+ const CONFIDENT_ANNOTATION_MIN = 0.6
57
+
58
+ /**
59
+ * Typed kinds a span proposal may carry. See the module doc for the three cue families.
60
+ */
38
61
  export type ProposedSpanKind =
39
62
  /** A balanced `()`/`[]` group whose content reads as an aside about the address. */
40
63
  | "ANNOTATION_SPAN"
41
- /**
42
- * A balanced quote group — the content is likely a NAME (venue/unit); typing is the classifier's job.
43
- */
64
+ /** A balanced quote group — the content is likely a NAME (venue/unit); typing is the classifier's job. */
44
65
  | "QUOTED_SPAN"
45
66
  /** Delivery-service designator + identifier ("PO Box 19", "GPO Box 2890", "Private Bag 7"). */
46
67
  | "PO_BOX_PHRASE"
@@ -55,12 +76,16 @@ export type ProposedSpanKind =
55
76
  /** Dual-path SPLIT reading, right side: the house number ("14" of "Flat 2/14"). */
56
77
  | "SPLIT_HOUSE_NUMBER"
57
78
 
58
- /** One typed span proposal. Char offsets into the raw input; `end` exclusive. */
79
+ /**
80
+ * One typed span proposal. Char offsets into the raw input; `end` exclusive.
81
+ */
59
82
  export interface ProposedSpan {
60
83
  start: number
61
84
  end: number
62
85
  kind: ProposedSpanKind
63
- /** 0..1. Confidence is shape-derived; consumers weight or floor it (it is never a verdict). */
86
+ /**
87
+ * 0..1. Confidence is shape-derived; consumers weight or floor it (it is never a verdict).
88
+ */
64
89
  confidence: number
65
90
  /**
66
91
  * Alternative readings of ONE surface share a group id (M3 dual-path: the fused and split readings of `2/14` carry
@@ -83,9 +108,13 @@ export interface SpanProposerLexicon {
83
108
  * Codex system codes the lexicon was built from ("us", "au", "nz", …) — drives M3 locale conditioning.
84
109
  */
85
110
  systems: ReadonlySet<string>
86
- /** Leading secondary-unit designator tokens (USPS Pub-28 C2 variants: "apt", "ste", "unit", …). */
111
+ /**
112
+ * Leading secondary-unit designator tokens (USPS Pub-28 C2 variants: "apt", "ste", "unit", …).
113
+ */
87
114
  unitDesignators: ReadonlySet<string>
88
- /** Level-class designator tokens ("floor", "fl", "bsmt", "ph", …) — typed LEVEL_PHRASE. */
115
+ /**
116
+ * Level-class designator tokens ("floor", "fl", "bsmt", "ph", …) — typed LEVEL_PHRASE.
117
+ */
89
118
  levelDesignators: ReadonlySet<string>
90
119
  /**
91
120
  * Descriptive designators ("building", "rear", "side", …) that, inside a bracketed group, read as annotation content
@@ -99,7 +128,9 @@ export interface SpanProposerLexicon {
99
128
  deliveryService?: RegExp
100
129
  }
101
130
 
102
- /** Empty lexicon — paired-delimiter proposals only. */
131
+ /**
132
+ * Empty lexicon — paired-delimiter proposals only.
133
+ */
103
134
  export const EMPTY_SPAN_PROPOSER_LEXICON: SpanProposerLexicon = {
104
135
  systems: new Set(),
105
136
  unitDesignators: new Set(),
@@ -107,16 +138,18 @@ export const EMPTY_SPAN_PROPOSER_LEXICON: SpanProposerLexicon = {
107
138
  weakDesignators: new Set(),
108
139
  }
109
140
 
110
- // ---------------------------------------------------------------------------
111
- // Tokenization (offset-preserving, punctuation-stripped match bodies)
112
- // ---------------------------------------------------------------------------
141
+ //#region Tokenization
113
142
 
114
143
  interface RawToken {
115
- /** Whitespace-delimited body as written. */
144
+ /**
145
+ * Whitespace-delimited body as written.
146
+ */
116
147
  body: string
117
148
  start: number
118
149
  end: number
119
- /** Body with leading/trailing punctuation stripped (for matching); offsets of the stripped core. */
150
+ /**
151
+ * Body with leading/trailing punctuation stripped (for matching); offsets of the stripped core.
152
+ */
120
153
  stripped: string
121
154
  strippedStart: number
122
155
  strippedEnd: number
@@ -139,6 +172,7 @@ function tokenize(text: string): RawToken[] {
139
172
  while (i < text.length && !/\s/.test(text[i]!)) {
140
173
  i++
141
174
  }
175
+
142
176
  const body = text.slice(start, i)
143
177
  let s = 0
144
178
  let e = body.length
@@ -150,6 +184,7 @@ function tokenize(text: string): RawToken[] {
150
184
  while (e > s && EDGE_PUNCT.test(body[e - 1]!)) {
151
185
  e--
152
186
  }
187
+
153
188
  out.push({
154
189
  body,
155
190
  start,
@@ -163,9 +198,9 @@ function tokenize(text: string): RawToken[] {
163
198
  return out
164
199
  }
165
200
 
166
- // ---------------------------------------------------------------------------
167
- // Cue family 1 — paired delimiters (M2)
168
- // ---------------------------------------------------------------------------
201
+ //#endregion
202
+
203
+ //#region Cue family 1 — paired delimiters (M2)
169
204
 
170
205
  /**
171
206
  * Find balanced pairs for one open/close class. Returns null when ANY delimiter of the class is unbalanced (stray
@@ -188,10 +223,12 @@ function findBalancedPairs(text: string, open: string, close: string): Array<{ o
188
223
  }
189
224
  }
190
225
 
191
- return stack.length > 0 ? null : out
226
+ return stack.length ? null : out
192
227
  }
193
228
 
194
- /** Same-character quote pairing ("…"): consecutive occurrences pair up; an odd count is unbalanced. */
229
+ /**
230
+ * Same-character quote pairing ("…"): consecutive occurrences pair up; an odd count is unbalanced.
231
+ */
195
232
  function findSameCharPairs(text: string, ch: string): Array<{ open: number; close: number }> | null {
196
233
  const positions: number[] = []
197
234
 
@@ -224,10 +261,11 @@ function findSameCharPairs(text: string, ch: string): Array<{ open: number; clos
224
261
  function annotationConfidence(content: string, atEndOfInput: boolean, lexicon: SpanProposerLexicon): number {
225
262
  const tokens = content.split(/\s+/).filter(Boolean)
226
263
 
227
- if (tokens.length === 0) return 0
264
+ if (!tokens.length) return 0
228
265
 
229
266
  if (tokens.length === 2) {
230
267
  const lead = tokens[0]!.toLowerCase().replace(/\.$/, "")
268
+
231
269
  const strong =
232
270
  (lexicon.unitDesignators.has(lead) || lexicon.levelDesignators.has(lead)) && !lexicon.weakDesignators.has(lead)
233
271
 
@@ -236,7 +274,7 @@ function annotationConfidence(content: string, atEndOfInput: boolean, lexicon: S
236
274
 
237
275
  if (/^[\p{Ll}0-9]/u.test(content)) return 0.9
238
276
 
239
- if (atEndOfInput && tokens.length <= 3) return 0.45
277
+ if (atEndOfInput && tokens.length <= SHORT_INPUT_MAX_TOKENS) return SHORT_TAIL_CONFIDENCE
240
278
 
241
279
  return 0.75
242
280
  }
@@ -261,6 +299,7 @@ function proposePairedDelimiters(text: string, lexicon: SpanProposerLexicon): Pr
261
299
 
262
300
  if (!content) continue
263
301
  const atEnd = p.close >= lastNonSpace - 1
302
+
264
303
  out.push({
265
304
  start: p.open,
266
305
  end: p.close + 1,
@@ -278,6 +317,7 @@ function proposePairedDelimiters(text: string, lexicon: SpanProposerLexicon): Pr
278
317
  // „…“ (low-9 opener, German/Czech): closes with “ — only scanned when a „ is present, so the
279
318
  // “ ” class above (which would see a stray “) is skipped for such inputs.
280
319
  ]
320
+
281
321
  const hasLow9 = text.includes("„")
282
322
 
283
323
  for (const [idx, find] of quotePairFinders.entries()) {
@@ -310,11 +350,13 @@ function proposePairedDelimiters(text: string, lexicon: SpanProposerLexicon): Pr
310
350
  return out
311
351
  }
312
352
 
313
- // ---------------------------------------------------------------------------
314
- // Cue family 2 — designator + identifier (the sub-premise grammar)
315
- // ---------------------------------------------------------------------------
353
+ //#endregion
316
354
 
317
- /** Short identifier shapes per the designator grammar: "4B", "500", "#104", "B", "B99". */
355
+ //#region Cue family 2 — designator + identifier
356
+
357
+ /**
358
+ * Short identifier shapes per the designator grammar: "4B", "500", "#104", "B", "B99".
359
+ */
318
360
  function isShortIdentifier(body: string): boolean {
319
361
  return /^#?\d{1,6}[A-Za-z]{0,2}$/.test(body) || /^[A-Za-z]$/.test(body) || /^[A-Za-z]\d{1,4}$/.test(body)
320
362
  }
@@ -339,6 +381,7 @@ function proposeDesignatorPhrases(
339
381
  // cue family 3 owns punctuated ids
340
382
  if (!isShortIdentifier(next.stripped)) continue
341
383
  const weak = lexicon.weakDesignators.has(lead)
384
+
342
385
  out.push({
343
386
  start: tokens[i]!.strippedStart,
344
387
  end: next.strippedEnd,
@@ -366,9 +409,9 @@ function proposeDesignatorPhrases(
366
409
  return out
367
410
  }
368
411
 
369
- // ---------------------------------------------------------------------------
370
- // Cue family 3 — dual-path numeric punctuation (M3)
371
- // ---------------------------------------------------------------------------
412
+ //#endregion
413
+
414
+ //#region Cue family 3 — dual-path numeric punctuation (M3)
372
415
 
373
416
  const SLASH_COMPOUND = /^(\d{1,4}[A-Za-z]?)\/(\d{1,5}[A-Za-z]?)$/
374
417
  const HYPHEN_COMPOUND = /^(\d{1,4})-(\d{1,5})$/
@@ -412,6 +455,7 @@ function proposeNumericReadings(
412
455
  confidence: 0.85,
413
456
  source: "fraction:usps-half-address",
414
457
  })
458
+
415
459
  continue
416
460
  }
417
461
 
@@ -420,6 +464,7 @@ function proposeNumericReadings(
420
464
  if (slash) {
421
465
  const leftEnd = t.strippedStart + slash[1]!.length
422
466
  const rightStart = leftEnd + 1
467
+
423
468
  // Reading A context: a unit/level designator leads ("Unit 4/22", "Flat 2/14" via the
424
469
  // leading-shape fallback below). Reading B context: the compound itself leads the address
425
470
  // ("3/45 Wattle St" — the AU/NZ bare sub-premise shape, only proposed when those codex
@@ -435,6 +480,7 @@ function proposeNumericReadings(
435
480
  if (prevIsDesignator || leadingShape) {
436
481
  const group = nextGroup()
437
482
  const conf = prevIsDesignator ? (hasAuNz ? 0.85 : 0.6) : 0.7
483
+
438
484
  out.push({
439
485
  start: prev!.strippedStart,
440
486
  end: leftEnd,
@@ -443,6 +489,7 @@ function proposeNumericReadings(
443
489
  alternativeGroup: group,
444
490
  source: prevIsDesignator ? "slash:designator-split" : "slash:leading-designator-shape",
445
491
  })
492
+
446
493
  out.push({
447
494
  start: rightStart,
448
495
  end: t.strippedEnd,
@@ -451,6 +498,7 @@ function proposeNumericReadings(
451
498
  alternativeGroup: group,
452
499
  source: "slash:designator-split",
453
500
  })
501
+
454
502
  out.push({
455
503
  start: t.strippedStart,
456
504
  end: t.strippedEnd,
@@ -461,6 +509,7 @@ function proposeNumericReadings(
461
509
  })
462
510
  } else if (i === 0 && hasAuNz && tokens.length > 1) {
463
511
  const group = nextGroup()
512
+
464
513
  out.push({
465
514
  start: t.strippedStart,
466
515
  end: leftEnd,
@@ -469,6 +518,7 @@ function proposeNumericReadings(
469
518
  alternativeGroup: group,
470
519
  source: "slash:bare-leading-split",
471
520
  })
521
+
472
522
  out.push({
473
523
  start: rightStart,
474
524
  end: t.strippedEnd,
@@ -477,6 +527,7 @@ function proposeNumericReadings(
477
527
  alternativeGroup: group,
478
528
  source: "slash:bare-leading-split",
479
529
  })
530
+
480
531
  out.push({
481
532
  start: t.strippedStart,
482
533
  end: t.strippedEnd,
@@ -496,6 +547,7 @@ function proposeNumericReadings(
496
547
  source: "slash:trailing-fused",
497
548
  })
498
549
  }
550
+
499
551
  continue
500
552
  }
501
553
 
@@ -503,12 +555,13 @@ function proposeNumericReadings(
503
555
 
504
556
  if (hyphen) {
505
557
  // ZIP+4 shape is a postcode, not a house number — never propose a reading for it.
506
- if (hyphen[1]!.length === 5) continue
558
+ if (hyphen[1]!.length === ZIP5_LENGTH) continue
507
559
  const next = i + 1 < tokens.length ? tokens[i + 1] : undefined
508
560
  const leftEnd = t.strippedStart + hyphen[1]!.length
509
561
 
510
562
  if (prevIsDesignator) {
511
563
  const group = nextGroup()
564
+
512
565
  out.push({
513
566
  start: prev!.strippedStart,
514
567
  end: leftEnd,
@@ -517,6 +570,7 @@ function proposeNumericReadings(
517
570
  alternativeGroup: group,
518
571
  source: "hyphen:designator-split",
519
572
  })
573
+
520
574
  out.push({
521
575
  start: leftEnd + 1,
522
576
  end: t.strippedEnd,
@@ -525,6 +579,7 @@ function proposeNumericReadings(
525
579
  alternativeGroup: group,
526
580
  source: "hyphen:designator-split",
527
581
  })
582
+
528
583
  out.push({
529
584
  start: t.strippedStart,
530
585
  end: t.strippedEnd,
@@ -552,9 +607,9 @@ function proposeNumericReadings(
552
607
  return out
553
608
  }
554
609
 
555
- // ---------------------------------------------------------------------------
556
- // Entry point
557
- // ---------------------------------------------------------------------------
610
+ //#endregion
611
+
612
+ //#region Entry point
558
613
 
559
614
  /**
560
615
  * Propose typed spans over `text`. Pure and synchronous; safe to run on every parse. Proposals may overlap freely
@@ -566,18 +621,22 @@ function proposeNumericReadings(
566
621
  * QUOTED_SPANs is NOT suppressed (quotes wrap names, not asides).
567
622
  */
568
623
  export function proposeSpans(text: string, lexicon: SpanProposerLexicon = EMPTY_SPAN_PROPOSER_LEXICON): ProposedSpan[] {
569
- if (text.length === 0) return []
624
+ if (!text.length) return []
570
625
  let groupCounter = 0
571
626
  const nextGroup = (): number => groupCounter++
572
627
 
573
628
  const paired = proposePairedDelimiters(text, lexicon)
574
629
  const tokens = tokenize(text)
630
+
575
631
  const inner = [
576
632
  ...proposeDesignatorPhrases(text, tokens, lexicon),
577
633
  ...proposeNumericReadings(tokens, lexicon, nextGroup),
578
634
  ]
579
635
 
580
- const confidentAnnotations = paired.filter((p) => p.kind === "ANNOTATION_SPAN" && p.confidence >= 0.6)
636
+ const confidentAnnotations = paired.filter(
637
+ (p) => p.kind === "ANNOTATION_SPAN" && p.confidence >= CONFIDENT_ANNOTATION_MIN
638
+ )
639
+
581
640
  const survivors = inner.filter((p) => !confidentAnnotations.some((a) => p.start >= a.start && p.end <= a.end))
582
641
 
583
642
  const out = [...paired, ...survivors]
@@ -585,3 +644,5 @@ export function proposeSpans(text: string, lexicon: SpanProposerLexicon = EMPTY_
585
644
 
586
645
  return out
587
646
  }
647
+
648
+ //#endregion
package/pipeline/types.ts CHANGED
@@ -19,7 +19,9 @@ import type { Section } from "../types/classifier.ts"
19
19
 
20
20
  export type LocaleTag = string
21
21
 
22
- /** Optional user-location signal for Stage 6 resolver scoring. */
22
+ /**
23
+ * Optional user-location signal for Stage 6 resolver scoring.
24
+ */
23
25
  export type UserLocation = { lat: number; lon: number } | { country: string } | { region: string; country: string }
24
26
 
25
27
  /**
@@ -31,10 +33,18 @@ export type UserLocation = { lat: number; lon: number } | { country: string } |
31
33
  */
32
34
  export type PlacetypePairPassthrough = object | false
33
35
 
34
- /** Common opts threaded through every stage. */
36
+ /**
37
+ * Common opts threaded through every stage.
38
+ */
35
39
  export interface PipelineOpts {
36
40
  locale?: LocaleTag
37
41
  userLocation?: UserLocation
42
+ /**
43
+ * Explicit input register (operator Decision A / GTM B10 — see {@link InputMode}). When unset the pipeline derives it
44
+ * from the kind classifier's verdict via {@link deriveInputMode}. Endpoint wrappers set their register default here
45
+ * (validation/batch → `"formatted"`, autocomplete/demo search → `"fragmented"`).
46
+ */
47
+ inputMode?: InputMode
38
48
  /**
39
49
  * Disable fast-path shortcuts; always run the full pipeline. Does NOT bypass the poi_query branch — that's a routing
40
50
  * decision (the kind classifier + `stages.poiIntent`), not a fast-path shortcut, so a `poi_query`-classified input
@@ -54,7 +64,9 @@ export interface PipelineOpts {
54
64
  * docs/articles/evals/experiments/2026-06-14-reconcile-retirement.md.
55
65
  */
56
66
  jointReconcile?: boolean
57
- /** Hard cap on lookups the resolver may issue; passed through. */
67
+ /**
68
+ * Hard cap on lookups the resolver may issue; passed through.
69
+ */
58
70
  resolveOpts?: ResolveOpts
59
71
  /**
60
72
  * #690: title-case detected all-caps ASCII input before the Stage 3 classifier (helps on all-caps registry/compliance
@@ -94,14 +106,18 @@ export interface PipelineOpts {
94
106
  signal?: AbortSignal
95
107
  }
96
108
 
97
- /** Minimal structural shape `NormalizedInput` must satisfy. Compatible with @mailwoman/normalize. */
109
+ /**
110
+ * Minimal structural shape `NormalizedInput` must satisfy. Compatible with @mailwoman/normalize.
111
+ */
98
112
  export interface NormalizedInputLite {
99
113
  raw: string
100
114
  normalized: string
101
115
  appliedLocale?: string
102
116
  }
103
117
 
104
- /** Minimal structural shape `QueryShape` must satisfy. Compatible with @mailwoman/query-shape. */
118
+ /**
119
+ * Minimal structural shape `QueryShape` must satisfy. Compatible with @mailwoman/query-shape.
120
+ */
105
121
  export interface QueryShapeLite {
106
122
  knownFormats: ReadonlyArray<{
107
123
  format: string
@@ -113,7 +129,9 @@ export interface QueryShapeLite {
113
129
  totalLength?: number
114
130
  }
115
131
 
116
- /** Detected (or asserted) locale + alternatives. */
132
+ /**
133
+ * Detected (or asserted) locale + alternatives.
134
+ */
117
135
  export interface LocaleHint {
118
136
  locale: LocaleTag
119
137
  confidence: number
@@ -121,7 +139,9 @@ export interface LocaleHint {
121
139
  source: "caller" | "detected" | "ensemble"
122
140
  }
123
141
 
124
- /** Kind classifier output. */
142
+ /**
143
+ * Kind classifier output.
144
+ */
125
145
  export type QueryKind =
126
146
  | "postcode_only"
127
147
  | "locality_only"
@@ -138,6 +158,34 @@ export interface QueryKindResult {
138
158
  alternatives: ReadonlyArray<{ kind: QueryKind; confidence: number }>
139
159
  }
140
160
 
161
+ /**
162
+ * The input register (operator Decision A, 2026-07-28 — the Option-A evidence-bundle verdict): `fragmented` is the
163
+ * map-search register (a human typing "belleville" or "12 rue de la paix"); `formatted` is the validation/record
164
+ * register (a checkout form or CRM row submitting a full postal address). The evidence-bundle channels feed ONLY in
165
+ * fragmented mode — three training runs showed they lift the fragment register (admin-street homonym +0.765 lower+heal)
166
+ * while degrading full-address parses (the flip census, `.superpowers/sdd/progress.md` 2026-07-28). Explicitly settable
167
+ * on every surface (CLI/API); when unset, {@link deriveInputMode} maps the kind-classifier's verdict. Endpoint defaults
168
+ * (GTM B10): validation/batch/CSV → formatted; autocomplete/demo search → fragmented; plain parse → derived.
169
+ */
170
+ export type InputMode = "fragmented" | "formatted"
171
+
172
+ /**
173
+ * Map a {@link QueryKind} to its {@link InputMode} register. Multi-component postal specifications
174
+ * (`structured_address`/`po_box`/`intersection`) are the formatted register; single-thing lookups (postcode, locality,
175
+ * landmark, POI, vague) are fragments. NEVER keyed on case — lowercase is the primary user register (operator
176
+ * doctrine).
177
+ */
178
+ export function deriveInputMode(kind: QueryKind): InputMode {
179
+ switch (kind) {
180
+ case "structured_address":
181
+ case "po_box":
182
+ case "intersection":
183
+ return "formatted"
184
+ default:
185
+ return "fragmented"
186
+ }
187
+ }
188
+
141
189
  /**
142
190
  * The structured POI intent — the pluggable boundary between detection (kind classifier), the executors (Plan 3's
143
191
  * poi.db SQL compiler), and the export formats (OverpassQL emitter). Category ids are `@mailwoman/poi-taxonomy` ids
@@ -149,18 +197,24 @@ export interface POIIntent {
149
197
  | { kind: "category"; categoryID: string; matched: string }
150
198
  | { kind: "brand"; name: string; wikidata?: string; matched: string }
151
199
  | { kind: "name"; text: string }
152
- /** Spatial anchor: the split-off remainder text and its parse, when the query carried one. */
200
+ /**
201
+ * Spatial anchor: the split-off remainder text and its parse, when the query carried one.
202
+ */
153
203
  anchor?: {
154
204
  text?: string
155
205
  tree?: AddressTree
156
- /** Caller-supplied bias point ("near me"); executors treat it as the anchor when no tree resolved. */
206
+ /**
207
+ * Caller-supplied bias point ("near me"); executors treat it as the anchor when no tree resolved.
208
+ */
157
209
  biasPoint?: { latitude: number; longitude: number }
158
210
  radiusM?: number
159
211
  }
160
212
  limit?: number
161
213
  }
162
214
 
163
- /** One executed POI search result (spec §3.4; produced by the executor, absent pre-execution). */
215
+ /**
216
+ * One executed POI search result (spec §3.4; produced by the executor, absent pre-execution).
217
+ */
164
218
  export interface POIResult {
165
219
  name: string | null
166
220
  categoryID: string | null
@@ -169,7 +223,9 @@ export interface POIResult {
169
223
  longitude: number
170
224
  country: string
171
225
  confidence: number
172
- /** Overture GERS id — nullable METADATA ONLY, never a key (the #470 rule). */
226
+ /**
227
+ * Overture GERS id — nullable METADATA ONLY, never a key (the #470 rule).
228
+ */
173
229
  gersID: string | null
174
230
  /**
175
231
  * Read-time WOF ancestry, deepest-first — the paid-down half of the poiQueryKind register row's debt. Attached by the
@@ -257,6 +313,11 @@ export interface FSTMatcherLike {
257
313
 
258
314
  export interface ClassifierOpts {
259
315
  queryShape?: QueryShapeLite
316
+ /**
317
+ * The input register (see {@link InputMode}). `formatted` runs the evidence-bundle channels deliberately OFF; the
318
+ * pipeline passes an explicit mode on every parse (caller override or {@link deriveInputMode} of the kind verdict).
319
+ */
320
+ inputMode?: InputMode
260
321
  fst?: FSTMatcherLike
261
322
  fstBiasScale?: number
262
323
  /**
@@ -266,9 +327,13 @@ export interface ClassifierOpts {
266
327
  * `classifier.parse` for measured, opt-in use.
267
328
  */
268
329
  fstStreetMorphology?: FSTMatcherLike
269
- /** Magnitude overrides for the morphology emission prior — the pipeline always passes the zeroed pair. */
330
+ /**
331
+ * Magnitude overrides for the morphology emission prior — the pipeline always passes the zeroed pair.
332
+ */
270
333
  fstStreetMorphologyOpts?: { biasScale?: number; dependentLocalityPenalty?: number }
271
- /** Run the deterministic postcode regex repair pass (v0.7 #35) on the decoded labels. */
334
+ /**
335
+ * Run the deterministic postcode regex repair pass (v0.7 #35) on the decoded labels.
336
+ */
272
337
  postcodeRepair?: boolean
273
338
  /**
274
339
  * #690: title-case a detected all-caps ASCII input before the model (all-caps registry/compliance data is partly
@@ -369,11 +434,11 @@ export interface RuntimePipelineStages {
369
434
  resolverBackend?: ResolverBackend
370
435
  }
371
436
 
372
- export interface PipelineTiming {
373
- [stage: string]: number // ms
374
- }
437
+ export type PipelineTiming = Record<string, number>
375
438
 
376
- /** Result of one `runPipeline` call. */
439
+ /**
440
+ * Result of one `runPipeline` call.
441
+ */
377
442
  export interface PipelineResult {
378
443
  input: string
379
444
  normalized: NormalizedInputLite
@@ -387,9 +452,13 @@ export interface PipelineResult {
387
452
  */
388
453
  phraseProposals: PhraseProposal[]
389
454
  tree: AddressTree
390
- /** Present only when the poi-intent stage produced an outcome (path === "poi"). */
455
+ /**
456
+ * Present only when the poi-intent stage produced an outcome (path === "poi").
457
+ */
391
458
  poiIntent?: POIIntentOutcome
392
459
  timing: PipelineTiming
393
- /** Which path the coordinator took. `"fast-path"` skipped stages 3-5; `"poi"` took the intent branch. */
460
+ /**
461
+ * Which path the coordinator took. `"fast-path"` skipped stages 3-5; `"poi"` took the intent branch.
462
+ */
394
463
  path: "fast-path" | "full" | "poi"
395
464
  }
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  import type { Section } from "../types/classifier.ts"
20
- import { type ClassificationProposal, type ClassifierContext, type ProposalClassifier } from "../types/index.ts"
20
+ import type { ClassificationProposal, ClassifierContext, ProposalClassifier } from "../types/index.ts"
21
21
  import type { PolicyRegistry } from "./policy.ts"
22
22
 
23
23
  /**
@@ -37,14 +37,15 @@ export async function collectProposals(
37
37
  for (const classifier of classifiers) {
38
38
  for (const section of sections) {
39
39
  tasks.push(
40
- classifier.classify(section, context).catch((err) => {
41
- console.warn(`[proposal-collection] ${classifier.id} threw on section "${section.body}":`, err)
40
+ classifier.classify(section, context).catch((error) => {
41
+ console.warn(`[proposal-collection] ${classifier.id} threw on section "${section.body}":`, error)
42
42
 
43
43
  return []
44
44
  })
45
45
  )
46
46
  }
47
47
  }
48
+
48
49
  const results = await Promise.all(tasks)
49
50
 
50
51
  return results.flat()