@mailwoman/core 8.1.0 → 8.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 (406) 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 +3 -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 +3 -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 +6 -2
  327. package/out/types/component.d.ts.map +1 -1
  328. package/out/types/component.js.map +1 -1
  329. package/out/utils/data-root.d.ts +3 -1
  330. package/out/utils/data-root.d.ts.map +1 -1
  331. package/out/utils/data-root.js +3 -1
  332. package/out/utils/data-root.js.map +1 -1
  333. package/out/utils/hash.d.ts +6 -2
  334. package/out/utils/hash.d.ts.map +1 -1
  335. package/out/utils/hash.js +6 -2
  336. package/out/utils/hash.js.map +1 -1
  337. package/out/utils/jsonl.d.ts +9 -3
  338. package/out/utils/jsonl.d.ts.map +1 -1
  339. package/out/utils/jsonl.js +9 -3
  340. package/out/utils/jsonl.js.map +1 -1
  341. package/out/utils/python-json.d.ts +6 -2
  342. package/out/utils/python-json.d.ts.map +1 -1
  343. package/out/utils/python-json.js +9 -3
  344. package/out/utils/python-json.js.map +1 -1
  345. package/out/utils/python-random.d.ts +15 -5
  346. package/out/utils/python-random.d.ts.map +1 -1
  347. package/out/utils/python-random.js +17 -7
  348. package/out/utils/python-random.js.map +1 -1
  349. package/out/utils/repo.d.ts +4 -0
  350. package/out/utils/repo.d.ts.map +1 -1
  351. package/out/utils/repo.js +4 -0
  352. package/out/utils/repo.js.map +1 -1
  353. package/out/utils/sealed-db.d.ts +6 -2
  354. package/out/utils/sealed-db.d.ts.map +1 -1
  355. package/out/utils/sealed-db.js +6 -2
  356. package/out/utils/sealed-db.js.map +1 -1
  357. package/out/utils/stats.d.ts +9 -3
  358. package/out/utils/stats.d.ts.map +1 -1
  359. package/out/utils/stats.js +11 -5
  360. package/out/utils/stats.js.map +1 -1
  361. package/package.json +2 -2
  362. package/pipeline/index.ts +5 -1
  363. package/pipeline/reconcile-lookups.ts +3 -0
  364. package/pipeline/reconcile.ts +65 -24
  365. package/pipeline/runtime-pipeline.ts +95 -46
  366. package/pipeline/span-logit-aggregation.ts +7 -2
  367. package/pipeline/span-proposer.ts +95 -34
  368. package/pipeline/types.ts +88 -19
  369. package/policy/proposal-collection.ts +4 -3
  370. package/policy/registry.ts +13 -3
  371. package/resolver/index.ts +1 -0
  372. package/resolver/types.ts +95 -30
  373. package/resources/LocaleIndex.ts +2 -2
  374. package/resources/ResourceMapCache.ts +3 -2
  375. package/resources/collections.ts +4 -1
  376. package/resources/languages/index.ts +2 -1
  377. package/resources/libpostal.ts +6 -3
  378. package/resources/set.ts +6 -6
  379. package/resources/whosonfirst/DataSourceCache.ts +2 -24
  380. package/resources/whosonfirst/PlacetypeDataSource.ts +2 -2
  381. package/resources/whosonfirst/backoff.ts +39 -0
  382. package/resources/whosonfirst/loader.ts +2 -1
  383. package/resources/whosonfirst/placetypes/Placetype.ts +9 -6
  384. package/resources/whosonfirst/placetypes/admin.ts +12 -7
  385. package/resources/whosonfirst/placetypes/definition.ts +6 -6
  386. package/resources/whosonfirst/placetypes/graph.ts +0 -0
  387. package/resources/whosonfirst/placetypes/mermaid.ts +5 -2
  388. package/resources/whosonfirst/placetypes/tree.ts +1 -1
  389. package/routing/index.ts +5 -1
  390. package/scripting/utils/index.ts +3 -1
  391. package/tokenization/Span.ts +1 -1
  392. package/tokenization/normalizer.ts +11 -11
  393. package/tools/download-libpostal-resources.ts +1 -0
  394. package/tools/download-ssl-address.ts +19 -7
  395. package/tools/generate-language-types.ts +12 -4
  396. package/types/Classification.ts +5 -0
  397. package/types/classifier.ts +27 -9
  398. package/types/component.ts +6 -2
  399. package/utils/data-root.ts +3 -1
  400. package/utils/hash.ts +6 -2
  401. package/utils/jsonl.ts +11 -3
  402. package/utils/python-json.ts +13 -4
  403. package/utils/python-random.ts +17 -7
  404. package/utils/repo.ts +8 -0
  405. package/utils/sealed-db.ts +10 -2
  406. package/utils/stats.ts +11 -5
@@ -53,7 +53,9 @@ import type { PhraseProposal } from "./types.ts"
53
53
  export interface ClassifierCandidate {
54
54
  span: { start: number; end: number }
55
55
  tag: ComponentTag
56
- /** Calibrated confidence in [0, 1]. */
56
+ /**
57
+ * Calibrated confidence in [0, 1].
58
+ */
57
59
  score: number
58
60
  }
59
61
 
@@ -75,10 +77,14 @@ export interface ParentChainLookup {
75
77
  }
76
78
 
77
79
  export interface ReconcileInputs {
78
- /** Raw input text — used to materialize `value` strings on the resulting tree. */
80
+ /**
81
+ * Raw input text — used to materialize `value` strings on the resulting tree.
82
+ */
79
83
  raw: string
80
84
  phraseProposals: ReadonlyArray<PhraseProposal>
81
- /** Sorted descending by score. May be empty (returns an empty tree). */
85
+ /**
86
+ * Sorted descending by score. May be empty (returns an empty tree).
87
+ */
82
88
  classifierTopK: ReadonlyArray<ClassifierCandidate>
83
89
  resolverCandidates?: ResolverCandidatesLookup
84
90
  parentChain?: ParentChainLookup
@@ -86,20 +92,30 @@ export interface ReconcileInputs {
86
92
  }
87
93
 
88
94
  export interface ReconcileOpts {
89
- /** Top-k phrase span proposals retained per (start, end) — default 3. */
95
+ /**
96
+ * Top-k phrase span proposals retained per (start, end) — default 3.
97
+ */
90
98
  kSpan?: number
91
- /** Top-k classifier tag interpretations retained per span — default 3. */
99
+ /**
100
+ * Top-k classifier tag interpretations retained per span — default 3.
101
+ */
92
102
  kTag?: number
93
- /** Top-k resolver candidates retained per (span, tag) — default 5. */
103
+ /**
104
+ * Top-k resolver candidates retained per (span, tag) — default 5.
105
+ */
94
106
  kResolver?: number
95
107
  /**
96
108
  * Concordance bonus multiplier. 1.0 weights chain-consistency equal to one classifier-score factor; lower values
97
109
  * trust the classifier more, higher values trust the gazetteer more. Default 1.0.
98
110
  */
99
111
  concordanceWeight?: number
100
- /** Beam width during search — default 16. */
112
+ /**
113
+ * Beam width during search — default 16.
114
+ */
101
115
  beamWidth?: number
102
- /** Runner-up parses returned alongside the winner — default 3. */
116
+ /**
117
+ * Runner-up parses returned alongside the winner — default 3.
118
+ */
103
119
  runnersUp?: number
104
120
  }
105
121
 
@@ -108,13 +124,17 @@ export interface ScoreBreakdown {
108
124
  classifier: number
109
125
  resolver: number
110
126
  concordance: number
111
- /** Composite multiplicative score in real space, [0, ∞). */
127
+ /**
128
+ * Composite multiplicative score in real space, [0, ∞).
129
+ */
112
130
  total: number
113
131
  }
114
132
 
115
133
  export interface ParseTree {
116
134
  tree: AddressTree
117
- /** Softmaxed confidence in [0, 1] over the finalized beam. */
135
+ /**
136
+ * Softmaxed confidence in [0, 1] over the finalized beam.
137
+ */
118
138
  confidence: number
119
139
  runnersUp: AddressTree[]
120
140
  scoreBreakdown: ScoreBreakdown
@@ -124,7 +144,7 @@ const DEFAULTS = {
124
144
  kSpan: 3,
125
145
  kTag: 3,
126
146
  kResolver: 5,
127
- concordanceWeight: 1.0,
147
+ concordanceWeight: 1,
128
148
  beamWidth: 16,
129
149
  runnersUp: 3,
130
150
  }
@@ -172,15 +192,21 @@ interface SlotChoice {
172
192
  classifierScore: number
173
193
  place: ResolvedPlace | null
174
194
  resolverScore: number
175
- /** Whitespace-delimited word count of the span's surface text — scales the inclusion bonus. */
195
+ /**
196
+ * Whitespace-delimited word count of the span's surface text — scales the inclusion bonus.
197
+ */
176
198
  wordCount: number
177
199
  }
178
200
 
179
201
  interface Beam {
180
202
  assignments: SlotChoice[]
181
- /** Log-space score combining phrase × classifier × resolver × concordance (running). */
203
+ /**
204
+ * Log-space score combining phrase × classifier × resolver × concordance (running).
205
+ */
182
206
  logScore: number
183
- /** Cached last-end so we can extend left-to-right without re-scanning assignments. */
207
+ /**
208
+ * Cached last-end so we can extend left-to-right without re-scanning assignments.
209
+ */
184
210
  lastEnd: number
185
211
  }
186
212
 
@@ -201,13 +227,14 @@ export function reconcileSpans(inputs: ReconcileInputs): ParseTree {
201
227
 
202
228
  const slots = buildSlots(inputs, opts)
203
229
 
204
- if (slots.length === 0) {
230
+ if (!slots.length) {
205
231
  return emptyParseTree(inputs.raw)
206
232
  }
207
233
 
208
234
  // Beam search over left-to-right slot inclusion. Each slot is either accepted (if non-
209
235
  // overlapping with the beam's claimed range) or skipped. Beam pruning keeps the top
210
236
  // `beamWidth` by running log-score.
237
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
211
238
  const slotsByStart = slots.slice().sort((a, b) => a.span.start - b.span.start)
212
239
  let beams: Beam[] = [{ assignments: [], logScore: 0, lastEnd: -1 }]
213
240
 
@@ -221,12 +248,14 @@ export function reconcileSpans(inputs: ReconcileInputs): ParseTree {
221
248
  const concordanceDelta = concordanceDeltaFor(beam.assignments, slot, inputs, opts)
222
249
 
223
250
  if (concordanceDelta === Number.NEGATIVE_INFINITY) continue
251
+
224
252
  const slotLog =
225
253
  logSafe(slot.phraseConf) +
226
254
  logSafe(slot.classifierScore) +
227
255
  logSafe(slot.resolverScore) +
228
256
  concordanceDelta +
229
257
  INCLUSION_LOG_BONUS * slot.wordCount
258
+
230
259
  next.push({
231
260
  assignments: [...beam.assignments, slot],
232
261
  logScore: beam.logScore + slotLog,
@@ -234,6 +263,7 @@ export function reconcileSpans(inputs: ReconcileInputs): ParseTree {
234
263
  })
235
264
  }
236
265
  }
266
+
237
267
  next.sort((a, b) => b.logScore - a.logScore)
238
268
  beams = next.slice(0, opts.beamWidth)
239
269
  }
@@ -242,7 +272,7 @@ export function reconcileSpans(inputs: ReconcileInputs): ParseTree {
242
272
  // Drop the empty beam if there's at least one non-empty competitor (the empty beam scores 0,
243
273
  // which would otherwise dominate when all real candidates have very low log-scores).
244
274
  const populated = beams.filter((b) => b.assignments.length > 0)
245
- const ordered = populated.length > 0 ? populated : beams
275
+ const ordered = populated.length ? populated : beams
246
276
 
247
277
  const top = ordered[0]!
248
278
  const runners = ordered.slice(1, 1 + opts.runnersUp)
@@ -277,6 +307,7 @@ function buildSlots(inputs: ReconcileInputs, opts: Required<ReconcileOpts>): Slo
277
307
  bySpanKey.set(k, p)
278
308
  }
279
309
  }
310
+
280
311
  // `kSpan` limits the number of overlapping proposals anchored at each start position — NOT a
281
312
  // global cap on phrase proposals. Two phrases at different starts (e.g. `Houston` at 18 +
282
313
  // `TX` at 27) are independent candidates and both must survive `kSpan = 3`. Without this per-
@@ -289,6 +320,7 @@ function buildSlots(inputs: ReconcileInputs, opts: Required<ReconcileOpts>): Slo
289
320
  arr.push(p)
290
321
  byStart.set(p.span.start, arr)
291
322
  }
323
+
292
324
  const spans: PhraseProposal[] = []
293
325
 
294
326
  for (const arr of byStart.values()) {
@@ -316,7 +348,7 @@ function buildSlots(inputs: ReconcileInputs, opts: Required<ReconcileOpts>): Slo
316
348
  ? inputs.resolverCandidates.candidatesFor(tagC.span, tagC.tag).slice(0, opts.kResolver)
317
349
  : []
318
350
 
319
- if (places.length === 0) {
351
+ if (!places.length) {
320
352
  slots.push({
321
353
  span: phrase.span,
322
354
  phraseConf: phrase.confidence,
@@ -326,6 +358,7 @@ function buildSlots(inputs: ReconcileInputs, opts: Required<ReconcileOpts>): Slo
326
358
  resolverScore: 1,
327
359
  wordCount: words,
328
360
  })
361
+
329
362
  continue
330
363
  }
331
364
 
@@ -353,7 +386,7 @@ function buildSlots(inputs: ReconcileInputs, opts: Required<ReconcileOpts>): Slo
353
386
  function wordCountOf(raw: string, span: { start: number; end: number }): number {
354
387
  const text = raw.slice(span.start, span.end).trim()
355
388
 
356
- if (text.length === 0) return 1
389
+ if (!text.length) return 1
357
390
 
358
391
  return text.split(/\s+/).length
359
392
  }
@@ -394,12 +427,15 @@ function concordanceDeltaFor(
394
427
 
395
428
  if (child === parent) continue
396
429
  const chain = chainOf.parentsOf(child.place!)
430
+
397
431
  pairs++
398
432
 
399
- if (chain.length === 0) {
433
+ if (!chain.length) {
400
434
  neutrals++
435
+
401
436
  continue
402
437
  }
438
+
403
439
  const hit = chain.some((p) => idsEqual(p.id, parent.place!.id))
404
440
 
405
441
  if (hit) {
@@ -437,6 +473,7 @@ function breakdownFor(beam: Beam, inputs: ReconcileInputs, opts: Required<Reconc
437
473
  classifier *= Math.max(a.classifierScore, 0)
438
474
  resolver *= Math.max(a.resolverScore, 0)
439
475
  }
476
+
440
477
  const concordanceLog = totalConcordanceLog(beam.assignments, inputs, opts)
441
478
  const concordance = Math.exp(concordanceLog)
442
479
  const total = phrase * classifier * resolver * concordance
@@ -469,6 +506,7 @@ function totalConcordanceLog(
469
506
  function buildTree(beam: Beam, raw: string): AddressTree {
470
507
  const roots: AddressNode[] = beam.assignments
471
508
  .slice()
509
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
472
510
  .sort((a, b) => a.span.start - b.span.start)
473
511
  .map((slot) => ({
474
512
  tag: slot.tag,
@@ -511,10 +549,13 @@ function spanKey(start: number, end: number): string {
511
549
  }
512
550
 
513
551
  function topN<T>(items: ReadonlyArray<T>, n: number, key: (t: T) => number): T[] {
514
- return items
515
- .slice()
516
- .sort((a, b) => key(b) - key(a))
517
- .slice(0, n)
552
+ return (
553
+ items
554
+ .slice()
555
+ // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
556
+ .sort((a, b) => key(b) - key(a))
557
+ .slice(0, n)
558
+ )
518
559
  }
519
560
 
520
561
  function logSafe(x: number): number {
@@ -533,7 +574,7 @@ function normalizeResolverScore(score: number): number {
533
574
  }
534
575
 
535
576
  function softmax(scores: number[]): number[] {
536
- if (scores.length === 0) return []
577
+ if (!scores.length) return []
537
578
  const max = Math.max(...scores)
538
579
  const exps = scores.map((s) => Math.exp(s - max))
539
580
  const sum = exps.reduce((a, b) => a + b, 0)
@@ -18,11 +18,12 @@ import { prefetchReconcileLookups } from "./reconcile-lookups.ts"
18
18
  import type { ClassifierCandidate } from "./reconcile.ts"
19
19
  import { reconcileSpans } from "./reconcile.ts"
20
20
  import { aggregateSpanLogits } from "./span-logit-aggregation.ts"
21
- import { WORD_CONSISTENCY_SHIP_DEFAULT } from "./types.ts"
21
+ import { WORD_CONSISTENCY_SHIP_DEFAULT, deriveInputMode } from "./types.ts"
22
22
  import type {
23
23
  AddressClassifier,
24
24
  ClassifierOpts,
25
25
  FSTMatcherLike,
26
+ InputMode,
26
27
  LocaleHint,
27
28
  LocaleTag,
28
29
  NormalizedInputLite,
@@ -35,6 +36,19 @@ import type {
35
36
  RuntimePipelineStages,
36
37
  } from "./types.ts"
37
38
 
39
+ /**
40
+ * Kind confidence required to skip the full pipeline. Set high deliberately: a short-circuit that fires on a wrong kind
41
+ * cannot be recovered downstream, so the cost of being wrong is a whole mis-parse, while the cost of being cautious is
42
+ * one extra pass.
43
+ */
44
+ const SHORT_CIRCUIT_MIN_CONFIDENCE = 0.95
45
+
46
+ /**
47
+ * Longest `locality_only` input allowed to short-circuit. Past it the query is likely carrying more than a locality
48
+ * name, and the full pipeline should look for what else is in there.
49
+ */
50
+ const SHORT_CIRCUIT_MAX_LOCALITY_LENGTH = 30
51
+
38
52
  /**
39
53
  * Known QueryShape format strings that indicate "this token is a postcode". Mirrors the set in
40
54
  * `@mailwoman/kind-classifier` — kept duplicated so core/pipeline has no dep on kind-classifier.
@@ -58,34 +72,35 @@ function isPostcodeFormat(format: string): boolean {
58
72
  * whole-string country guess is a broader, softer signal than a postcode that pins the country, so it blends more
59
73
  * gently with the candidate score.
60
74
  */
61
- const COARSE_PLACER_ANCHOR_WEIGHT = 1.0
75
+ const COARSE_PLACER_ANCHOR_WEIGHT = 1
62
76
 
63
- // #194: minimum placer confidence to promote the soft country prior to a HARD filter (empty→unresolved).
64
- // The placer already abstains below 0.9 in-map MASS (open-set rule), but the per-country argmax prob
65
- // can still be split across neighbours (DK↔NO, EE↔LT↔LV); requiring a high argmax confidence keeps the
66
- // hard filter to the cases the model is sure of (FI/PL routinely score ~1.0) and leaves the ambiguous
67
- // ones on the soft path. Deliberately strict — a wrong hard country is the #244 M2 misroute failure.
77
+ /**
78
+ * #194: minimum placer confidence to promote the soft country prior to a HARD filter (empty→unresolved). The placer
79
+ * already abstains below 0.9 in-map MASS (open-set rule), but the per-country argmax prob can still be split across
80
+ * neighbours (DK↔NO, EE↔LT↔LV); requiring a high argmax confidence keeps the hard filter to the cases the model is sure
81
+ * of (FI/PL routinely score ~1.0) and leaves the ambiguous ones on the soft path. Deliberately strict — a wrong hard
82
+ * country is the #244 M2 misroute failure.
83
+ */
68
84
  const HARD_PLACE_COUNTRY_MIN_CONF = 0.9
69
85
 
70
- // #743/#194 coverage guard: countries whose candidate gazetteer is complete enough that hard-filtering
71
- // is a PURE WIN — measured hard-resolve-rate ≥ 95% on held-out OpenAddresses points, so a hard-filter
72
- // "miss → unresolved" is rare and almost always a genuine non-match, not a coverage gap. A confident
73
- // placement OUTSIDE this set stays on the SOFT prior, so the low-coverage tail (FI/PL/…) keeps its
74
- // recall until its gazetteer is filled (#193) — the win for covered countries, no recall regression
75
- // for the rest (DeepSeek-advised, 2026-06-22).
76
- //
77
- // FALLBACK ROLE (survey candidate #2, 2026-07-26): this set is now the FALLBACK for gazetteer
78
- // artifacts that predate the coverage manifest. Facts about the artifact live IN the artifact — the
79
- // candidate gazetteer's `country_coverage` table carries the per-country promote-gate verdicts + the
80
- // measured rates (the numbers that used to be trivia in this comment), and a loaded artifact's
81
- // derived safelist (`resolver.artifactCoverage.hardCountrySafelist`) takes precedence over this
82
- // constant. The measured record lives in `mailwoman/gazetteer-pipeline/coverage-manifest.ts`
83
- // (MEASURED_COUNTRY_COVERAGE — grow THAT at promotes; it updates the artifact at rebuild). Precedence:
84
- // per-call `PipelineOpts.hardCountrySafelist` (the eval's instrument, measures ungated to grow the
85
- // list) → the loaded artifact's manifest → this constant.
86
- // Historical receipts now recorded structurally in MEASURED_COUNTRY_COVERAGE: US/FR/DE 100, ES 99.8,
87
- // NL 97.3, IT 96.8 (in); FI 69.5, PL 77.8 (measured, out); GB + CA at the #928 promote (2026-07-06,
88
- // OSM panels, night 34); AU with the #244 placer class (2026-07-06).
86
+ /**
87
+ * #743/#194 coverage guard: countries whose candidate gazetteer is complete enough that hard-filtering is a PURE WIN —
88
+ * measured hard-resolve-rate ≥ 95% on held-out OpenAddresses points, so a hard-filter "miss → unresolved" is rare and
89
+ * almost always a genuine non-match, not a coverage gap. A confident placement OUTSIDE this set stays on the SOFT
90
+ * prior, so the low-coverage tail (FI/PL/…) keeps its recall until its gazetteer is filled (#193) — the win for covered
91
+ * countries, no recall regression for the rest (DeepSeek-advised, 2026-06-22).
92
+ *
93
+ * FALLBACK ROLE (survey candidate #2, 2026-07-26): this set is now the FALLBACK for gazetteer artifacts that predate
94
+ * the coverage manifest. Facts about the artifact live IN the artifact — the candidate gazetteer's `country_coverage`
95
+ * table carries the per-country promote-gate verdicts + the measured rates (the numbers that used to be trivia in this
96
+ * comment), and a loaded artifact's derived safelist (`resolver.artifactCoverage.hardCountrySafelist`) takes precedence
97
+ * over this constant. The measured record lives in `mailwoman/gazetteer-pipeline/coverage-manifest.ts`
98
+ * (MEASURED_COUNTRY_COVERAGE — grow THAT at promotes; it updates the artifact at rebuild). Precedence: per-call
99
+ * `PipelineOpts.hardCountrySafelist` (the eval's instrument, measures ungated to grow the list) → the loaded artifact's
100
+ * manifest → this constant. Historical receipts now recorded structurally in MEASURED_COUNTRY_COVERAGE: US/FR/DE 100,
101
+ * ES 99.8, NL 97.3, IT 96.8 (in); FI 69.5, PL 77.8 (measured, out); GB + CA at the #928 promote (2026-07-06, OSM
102
+ * panels, night 34); AU with the #244 placer class (2026-07-06).
103
+ */
89
104
  export const HARD_PLACE_COUNTRY_SAFELIST: ReadonlySet<string> = new Set([
90
105
  "US",
91
106
  "ES",
@@ -113,12 +128,13 @@ export function isBareLocalityTree(tree: AddressTree): boolean {
113
128
  let sawLocality = false
114
129
  const stack = [...tree.roots]
115
130
 
116
- while (stack.length > 0) {
131
+ while (stack.length) {
117
132
  const node = stack.pop()!
118
133
 
119
134
  if (node.tag === "locality") {
120
135
  sawLocality = true
121
136
  } else if (node.value.trim() !== "") return false
137
+
122
138
  stack.push(...node.children)
123
139
  }
124
140
 
@@ -158,17 +174,23 @@ function isPostcodeFormatHit(hit: { format: string }): boolean {
158
174
  return isPostcodeFormat(hit.format)
159
175
  }
160
176
 
161
- /** Pass-through normalize used when no `normalize` stage is wired. */
177
+ /**
178
+ * Pass-through normalize used when no `normalize` stage is wired.
179
+ */
162
180
  function identityNormalize(raw: string, opts?: { locale?: string }): NormalizedInputLite {
163
181
  return { raw, normalized: raw, appliedLocale: opts?.locale }
164
182
  }
165
183
 
166
- /** No-op query-shape used when no `computeQueryShape` stage is wired. */
184
+ /**
185
+ * No-op query-shape used when no `computeQueryShape` stage is wired.
186
+ */
167
187
  function emptyQueryShape(): QueryShapeLite {
168
188
  return { knownFormats: [] }
169
189
  }
170
190
 
171
- /** Default locale detector: trusts the caller's hint, or falls back to `und`. */
191
+ /**
192
+ * Default locale detector: trusts the caller's hint, or falls back to `und`.
193
+ */
172
194
  async function defaultDetectLocale(
173
195
  _input: NormalizedInputLite,
174
196
  _shape: QueryShapeLite,
@@ -178,13 +200,15 @@ async function defaultDetectLocale(
178
200
 
179
201
  return {
180
202
  locale,
181
- confidence: opts?.hint ? 1.0 : 0.0,
203
+ confidence: opts?.hint ? 1 : 0,
182
204
  alternatives: [],
183
205
  source: opts?.hint ? "caller" : "detected",
184
206
  }
185
207
  }
186
208
 
187
- /** Default kind classifier: always returns `structured_address` with low confidence (no fast-path). */
209
+ /**
210
+ * Default kind classifier: always returns `structured_address` with low confidence (no fast-path).
211
+ */
188
212
  async function defaultClassifyKind(
189
213
  _input: NormalizedInputLite,
190
214
  _shape: QueryShapeLite,
@@ -192,7 +216,7 @@ async function defaultClassifyKind(
192
216
  ): Promise<QueryKindResult> {
193
217
  return {
194
218
  kind: "structured_address",
195
- confidence: 0.0,
219
+ confidence: 0,
196
220
  alternatives: [],
197
221
  }
198
222
  }
@@ -204,14 +228,14 @@ async function defaultClassifyKind(
204
228
  function canShortCircuit(kind: QueryKindResult, shape: QueryShapeLite, opts?: PipelineOpts): boolean {
205
229
  if (opts?.forceFullPipeline) return false
206
230
 
207
- if (kind.confidence < 0.95) return false
231
+ if (kind.confidence < SHORT_CIRCUIT_MIN_CONFIDENCE) return false
208
232
 
209
233
  if (kind.kind === "postcode_only") {
210
234
  return shape.knownFormats.some(isPostcodeFormatHit)
211
235
  }
212
236
 
213
237
  if (kind.kind === "locality_only") {
214
- return (shape.totalLength ?? Infinity) <= 30 && shape.characterClass === "alpha"
238
+ return (shape.totalLength ?? Infinity) <= SHORT_CIRCUIT_MAX_LOCALITY_LENGTH && shape.characterClass === "alpha"
215
239
  }
216
240
 
217
241
  return false
@@ -326,7 +350,9 @@ export async function runPipeline(
326
350
  opts?.hardPlaceCountry,
327
351
  opts?.hardCountrySafelist ?? stages.resolver?.artifactCoverage?.hardCountrySafelist
328
352
  )
353
+
329
354
  placerAnchorApplied = true
355
+
330
356
  effectiveOpts = {
331
357
  ...opts,
332
358
  resolveOpts: {
@@ -445,6 +471,7 @@ export async function runPipeline(
445
471
  // to opt back into reconcile (the A/B harnesses do). Report:
446
472
  // docs/articles/evals/experiments/2026-06-14-reconcile-retirement.md.
447
473
  const jointEnabled = opts?.jointReconcile ?? false
474
+
448
475
  const useJointReconcile =
449
476
  jointEnabled && phraseProposals.length > 0 && stages.classifier && "parseWithLogits" in stages.classifier
450
477
 
@@ -458,6 +485,7 @@ export async function runPipeline(
458
485
 
459
486
  throwIfAborted(opts)
460
487
  const tClassify = performance.now()
488
+
461
489
  const {
462
490
  tree: argmaxTree,
463
491
  logits,
@@ -467,6 +495,7 @@ export async function runPipeline(
467
495
  fst: stages.fst,
468
496
  ...streetContextGateFor(stages),
469
497
  })
498
+
470
499
  timing["token-classify"] = performance.now() - tClassify
471
500
 
472
501
  throwIfAborted(opts)
@@ -484,13 +513,14 @@ export async function runPipeline(
484
513
  { labels, text: normalized.normalized }
485
514
  )
486
515
 
487
- if (classifierTopK.length > 0) {
516
+ if (classifierTopK.length) {
488
517
  // Concordance axes (#478): when the caller wires a backend, one bounded pre-fetch
489
518
  // activates the resolver-candidate + parent-chain scoring the reconciler already
490
519
  // implements. Absent backend = classifier-only reconcile (byte-stable).
491
520
  // Country constraint from the locale gate's BCP-47 tag ("en-US" -> "US"); absent or
492
521
  // und-like tags pass no constraint (ranking alone decides — matches resolveTree's default).
493
522
  const localeCountry = locale.locale.split("-")[1]?.toUpperCase()
523
+
494
524
  const lookups = stages.resolverBackend
495
525
  ? await prefetchReconcileLookups(
496
526
  stages.resolverBackend,
@@ -499,12 +529,14 @@ export async function runPipeline(
499
529
  localeCountry && localeCountry.length === 2 ? { defaultCountry: localeCountry } : {}
500
530
  )
501
531
  : undefined
532
+
502
533
  const result = reconcileSpans({
503
534
  raw: normalized.normalized,
504
535
  phraseProposals,
505
536
  classifierTopK,
506
537
  ...(lookups ? { resolverCandidates: lookups.resolverCandidates, parentChain: lookups.parentChain } : {}),
507
538
  })
539
+
508
540
  tree = result.tree
509
541
  // The reconciler can leave a span uncovered (e.g. it picked the single-token street
510
542
  // `Trento` over `Via Trento`, orphaning `Via`). The grouper-audit below would then promote
@@ -515,10 +547,12 @@ export async function runPipeline(
515
547
  } else {
516
548
  tree = argmaxTree
517
549
  }
550
+
518
551
  timing["reconcile"] = performance.now() - tReconcile
519
552
  } else if (stages.classifier) {
520
553
  throwIfAborted(opts)
521
554
  const tClassify = performance.now()
555
+
522
556
  tree = await safeClassify(
523
557
  stages.classifier,
524
558
  normalized.normalized,
@@ -526,12 +560,15 @@ export async function runPipeline(
526
560
  stages.fst,
527
561
  opts?.normalizeCase,
528
562
  opts?.placetypePair,
529
- stages.streetMorphology
563
+ stages.streetMorphology,
564
+ // Decision A: explicit caller register wins; otherwise the kind verdict decides. NEVER case-keyed.
565
+ opts?.inputMode ?? deriveInputMode(kind.kind)
530
566
  )
567
+
531
568
  timing["token-classify"] = performance.now() - tClassify
532
569
  }
533
570
 
534
- if (phraseProposals.length > 0 && tree.roots.length >= 0) {
571
+ if (phraseProposals.length && tree.roots.length >= 0) {
535
572
  const tAudit = performance.now()
536
573
  tree = grouperAudit(tree, phraseProposals, normalized.normalized, auditClassifierTopK)
537
574
  timing["grouper-audit"] = performance.now() - tAudit
@@ -546,6 +583,7 @@ export async function runPipeline(
546
583
  if (placerAnchorApplied && isBareLocalityTree(tree)) {
547
584
  effectiveOpts = opts
548
585
  }
586
+
549
587
  tree = await safeResolve(stages.resolver, tree, effectiveOpts)
550
588
  timing["resolve"] = performance.now() - tResolve
551
589
  }
@@ -576,7 +614,9 @@ function throwIfAborted(opts?: PipelineOpts): void {
576
614
  }
577
615
  }
578
616
 
579
- /** Defensive wrapper: if the classifier throws, return an empty tree rather than abort the pipeline. */
617
+ /**
618
+ * Defensive wrapper: if the classifier throws, return an empty tree rather than abort the pipeline.
619
+ */
580
620
  async function safeClassify(
581
621
  classifier: AddressClassifier,
582
622
  text: string,
@@ -584,7 +624,8 @@ async function safeClassify(
584
624
  fst?: FSTMatcherLike,
585
625
  normalizeCase?: boolean,
586
626
  placetypePair?: PlacetypePairPassthrough,
587
- streetMorphology?: FSTMatcherLike
627
+ streetMorphology?: FSTMatcherLike,
628
+ inputMode?: InputMode
588
629
  ): Promise<AddressTree> {
589
630
  try {
590
631
  // Postcode regex repair on by default (v0.7 #35, operator-signed). #690 normalizeCase forwards as-is —
@@ -596,6 +637,7 @@ async function safeClassify(
596
637
  // no-prior decode), so the classifier's `opts?.placetypePair ?? cfg.placetypePair` resolution is unchanged when absent.
597
638
  return await classifier.parse(text, {
598
639
  queryShape,
640
+ inputMode,
599
641
  fst,
600
642
  postcodeRepair: true,
601
643
  normalizeCase,
@@ -639,7 +681,9 @@ function streetContextGateFor(stages: { fst?: FSTMatcherLike; streetMorphology?:
639
681
  : {}
640
682
  }
641
683
 
642
- /** Defensive wrapper: a grouper failure returns an empty proposal list rather than abort. */
684
+ /**
685
+ * Defensive wrapper: a grouper failure returns an empty proposal list rather than abort.
686
+ */
643
687
  async function safeGroupPhrases(
644
688
  groupPhrases: NonNullable<RuntimePipelineStages["groupPhrases"]>,
645
689
  normalized: NormalizedInputLite,
@@ -653,9 +697,7 @@ async function safeGroupPhrases(
653
697
  }
654
698
  }
655
699
 
656
- // ---------------------------------------------------------------------------
657
- // Grouper-audit pass
658
- // ---------------------------------------------------------------------------
700
+ // MARK: Grouper-audit pass
659
701
 
660
702
  const GROUPER_TYPING_PENALTY = 0.55
661
703
 
@@ -686,11 +728,12 @@ export function grouperAudit(
686
728
  text: string,
687
729
  classifierTopK?: ClassifierCandidate[]
688
730
  ): AddressTree {
689
- if (proposals.length === 0) return tree
731
+ if (!proposals.length) return tree
690
732
 
691
733
  const roots = [...tree.roots]
692
734
 
693
735
  const allNodes: Array<{ start: number; end: number }> = []
736
+
694
737
  const collectNodes = (nodes: typeof roots): void => {
695
738
  for (const n of nodes) {
696
739
  allNodes.push({ start: n.start, end: n.end })
@@ -700,6 +743,7 @@ export function grouperAudit(
700
743
  }
701
744
  }
702
745
  }
746
+
703
747
  collectNodes(roots)
704
748
 
705
749
  // Index the classifier's single best tag per exact span (start:end) so the audit can defer to it.
@@ -722,6 +766,7 @@ export function grouperAudit(
722
766
  // from being shadowed by an earlier-positioned spurious node in `decodeAsJSON` (#425 residual tail).
723
767
  const SINGLETON_TAGS: ReadonlySet<ComponentTag> = new Set<ComponentTag>(["locality", "region", "postcode", "country"])
724
768
  const presentSingletons = new Set<ComponentTag>()
769
+
725
770
  const collectSingletons = (nodes: typeof roots): void => {
726
771
  for (const n of nodes) {
727
772
  if (SINGLETON_TAGS.has(n.tag)) {
@@ -733,6 +778,7 @@ export function grouperAudit(
733
778
  }
734
779
  }
735
780
  }
781
+
736
782
  collectSingletons(roots)
737
783
  const dedupeSingletons = classifierTopK !== undefined
738
784
 
@@ -752,6 +798,7 @@ export function grouperAudit(
752
798
 
753
799
  // Defer to the classifier when it confidently typed this exact span as something else.
754
800
  const classifierVerdict = bestTagBySpan.get(`${proposal.span.start}:${proposal.span.end}`)
801
+
755
802
  const tag =
756
803
  classifierVerdict && classifierVerdict.score >= CLASSIFIER_OVERRIDE_MIN ? classifierVerdict.tag : phraseTag
757
804
 
@@ -781,7 +828,9 @@ export function grouperAudit(
781
828
  return { raw: tree.raw, roots }
782
829
  }
783
830
 
784
- /** Defensive wrapper: a resolver failure leaves the classifier tree intact. */
831
+ /**
832
+ * Defensive wrapper: a resolver failure leaves the classifier tree intact.
833
+ */
785
834
  async function safeResolve(
786
835
  resolver: NonNullable<RuntimePipelineStages["resolver"]>,
787
836
  tree: AddressTree,