@mailwoman/core 9.1.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/README.md +1 -1
  2. package/api/responses.ts +12 -0
  3. package/coarse-placer/featurize.ts +0 -2
  4. package/coarse-placer/tools/build-dataset.ts +1 -1
  5. package/coarse-placer/tools/build-outlier-exposure.ts +1 -1
  6. package/coarse-placer/tools/build-outlier-latin.ts +13 -7
  7. package/coarse-placer/tools/build-outlier-oa.ts +11 -5
  8. package/coarse-placer/tools/eval-latin-offmap.ts +3 -2
  9. package/coarse-placer/tools/eval-openset.ts +3 -2
  10. package/coarse-placer/tools/eval-quant-compare.ts +3 -2
  11. package/coarse-placer/tools/eval.ts +3 -2
  12. package/coarse-placer/tools/fnv-hash.ts +1 -6
  13. package/coarse-placer/tools/index.ts +1 -1
  14. package/coarse-placer/tools/probe-frontier.ts +3 -2
  15. package/coarse-placer/tools/quantize.ts +2 -2
  16. package/coarse-placer/tools/train.ts +2 -1
  17. package/crypto/node.ts +3 -1
  18. package/data/internal/dictionaries/languages.csv +184 -184
  19. package/data/libpostal/README.md +8 -2
  20. package/db/schema.ts +12 -3
  21. package/decoder/containment.ts +5 -1
  22. package/decoder/index.ts +1 -0
  23. package/decoder/parse-diff.ts +347 -0
  24. package/decoder/proposals-to-tree.ts +1 -1
  25. package/decoder/serialize-json.ts +51 -7
  26. package/decoder/serialize-tuples.ts +7 -1
  27. package/decoder/serialize-xml.ts +1 -1
  28. package/decoder/tree-shape.ts +144 -0
  29. package/decoder/types.ts +8 -0
  30. package/decoder/validate-tree.ts +15 -3
  31. package/env/index.ts +3 -1
  32. package/env/paths.ts +21 -33
  33. package/env/schema.ts +26 -3
  34. package/fs/utils/formatters.ts +107 -0
  35. package/fs/utils/index.ts +7 -0
  36. package/fs/zip.ts +1 -1
  37. package/layers/manifest.ts +56 -15
  38. package/layers/schema.ts +54 -2
  39. package/locale/locale.ts +1 -1
  40. package/locale/registry.ts +1 -1
  41. package/objects.ts +20 -8
  42. package/out/api/responses.d.ts +9 -0
  43. package/out/api/responses.d.ts.map +1 -1
  44. package/out/api/responses.js +11 -0
  45. package/out/api/responses.js.map +1 -1
  46. package/out/coarse-placer/featurize.d.ts +0 -1
  47. package/out/coarse-placer/featurize.d.ts.map +1 -1
  48. package/out/coarse-placer/featurize.js.map +1 -1
  49. package/out/coarse-placer/tools/build-dataset.js +1 -1
  50. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  51. package/out/coarse-placer/tools/build-outlier-exposure.js +1 -1
  52. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  53. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  54. package/out/coarse-placer/tools/build-outlier-latin.js +12 -7
  55. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  56. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  57. package/out/coarse-placer/tools/build-outlier-oa.js +10 -5
  58. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  59. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  60. package/out/coarse-placer/tools/eval-latin-offmap.js +2 -2
  61. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  62. package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
  63. package/out/coarse-placer/tools/eval-openset.js +2 -2
  64. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  65. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
  66. package/out/coarse-placer/tools/eval-quant-compare.js +2 -2
  67. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  68. package/out/coarse-placer/tools/eval.d.ts.map +1 -1
  69. package/out/coarse-placer/tools/eval.js +2 -2
  70. package/out/coarse-placer/tools/eval.js.map +1 -1
  71. package/out/coarse-placer/tools/fnv-hash.d.ts +1 -6
  72. package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
  73. package/out/coarse-placer/tools/fnv-hash.js +1 -6
  74. package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
  75. package/out/coarse-placer/tools/index.d.ts +1 -1
  76. package/out/coarse-placer/tools/index.js +1 -1
  77. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  78. package/out/coarse-placer/tools/probe-frontier.js +2 -2
  79. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  80. package/out/coarse-placer/tools/quantize.js +2 -2
  81. package/out/coarse-placer/tools/quantize.js.map +1 -1
  82. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  83. package/out/coarse-placer/tools/train.js +1 -1
  84. package/out/coarse-placer/tools/train.js.map +1 -1
  85. package/out/crypto/node.d.ts.map +1 -1
  86. package/out/crypto/node.js +2 -1
  87. package/out/crypto/node.js.map +1 -1
  88. package/out/db/schema.d.ts +12 -3
  89. package/out/db/schema.d.ts.map +1 -1
  90. package/out/db/schema.js +6 -0
  91. package/out/db/schema.js.map +1 -1
  92. package/out/decoder/containment.d.ts.map +1 -1
  93. package/out/decoder/containment.js +5 -1
  94. package/out/decoder/containment.js.map +1 -1
  95. package/out/decoder/index.d.ts +1 -0
  96. package/out/decoder/index.d.ts.map +1 -1
  97. package/out/decoder/index.js +1 -0
  98. package/out/decoder/index.js.map +1 -1
  99. package/out/decoder/parse-diff.d.ts +125 -0
  100. package/out/decoder/parse-diff.d.ts.map +1 -0
  101. package/out/decoder/parse-diff.js +219 -0
  102. package/out/decoder/parse-diff.js.map +1 -0
  103. package/out/decoder/proposals-to-tree.js.map +1 -1
  104. package/out/decoder/serialize-json.d.ts +29 -0
  105. package/out/decoder/serialize-json.d.ts.map +1 -1
  106. package/out/decoder/serialize-json.js +20 -4
  107. package/out/decoder/serialize-json.js.map +1 -1
  108. package/out/decoder/serialize-tuples.d.ts +8 -1
  109. package/out/decoder/serialize-tuples.d.ts.map +1 -1
  110. package/out/decoder/serialize-tuples.js +7 -1
  111. package/out/decoder/serialize-tuples.js.map +1 -1
  112. package/out/decoder/serialize-xml.js +1 -1
  113. package/out/decoder/serialize-xml.js.map +1 -1
  114. package/out/decoder/tree-shape.d.ts +84 -0
  115. package/out/decoder/tree-shape.d.ts.map +1 -0
  116. package/out/decoder/tree-shape.js +98 -0
  117. package/out/decoder/tree-shape.js.map +1 -0
  118. package/out/decoder/types.d.ts +11 -0
  119. package/out/decoder/types.d.ts.map +1 -1
  120. package/out/decoder/validate-tree.d.ts +8 -0
  121. package/out/decoder/validate-tree.d.ts.map +1 -1
  122. package/out/decoder/validate-tree.js +4 -3
  123. package/out/decoder/validate-tree.js.map +1 -1
  124. package/out/env/index.d.ts +10 -1
  125. package/out/env/index.d.ts.map +1 -1
  126. package/out/env/index.js +2 -1
  127. package/out/env/index.js.map +1 -1
  128. package/out/env/paths.d.ts +15 -8
  129. package/out/env/paths.d.ts.map +1 -1
  130. package/out/env/paths.js +19 -29
  131. package/out/env/paths.js.map +1 -1
  132. package/out/env/schema.d.ts +9 -1
  133. package/out/env/schema.d.ts.map +1 -1
  134. package/out/env/schema.js +25 -3
  135. package/out/env/schema.js.map +1 -1
  136. package/out/fs/utils/formatters.d.ts +57 -0
  137. package/out/fs/utils/formatters.d.ts.map +1 -0
  138. package/out/fs/utils/formatters.js +79 -0
  139. package/out/fs/utils/formatters.js.map +1 -0
  140. package/out/fs/utils/index.d.ts +7 -0
  141. package/out/fs/utils/index.d.ts.map +1 -0
  142. package/out/fs/utils/index.js +7 -0
  143. package/out/fs/utils/index.js.map +1 -0
  144. package/out/fs/zip.js +1 -1
  145. package/out/fs/zip.js.map +1 -1
  146. package/out/layers/manifest.d.ts +32 -7
  147. package/out/layers/manifest.d.ts.map +1 -1
  148. package/out/layers/manifest.js +31 -6
  149. package/out/layers/manifest.js.map +1 -1
  150. package/out/layers/schema.d.ts +48 -2
  151. package/out/layers/schema.d.ts.map +1 -1
  152. package/out/layers/schema.js +32 -0
  153. package/out/layers/schema.js.map +1 -1
  154. package/out/locale/locale.d.ts +1 -1
  155. package/out/locale/locale.d.ts.map +1 -1
  156. package/out/locale/registry.js +1 -1
  157. package/out/locale/registry.js.map +1 -1
  158. package/out/objects.d.ts +12 -6
  159. package/out/objects.d.ts.map +1 -1
  160. package/out/objects.js +4 -1
  161. package/out/objects.js.map +1 -1
  162. package/out/pipeline/index.d.ts +2 -6
  163. package/out/pipeline/index.d.ts.map +1 -1
  164. package/out/pipeline/index.js +1 -3
  165. package/out/pipeline/index.js.map +1 -1
  166. package/out/pipeline/runtime-pipeline.d.ts +51 -9
  167. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  168. package/out/pipeline/runtime-pipeline.js +29 -132
  169. package/out/pipeline/runtime-pipeline.js.map +1 -1
  170. package/out/pipeline/span-proposer.js +1 -1
  171. package/out/pipeline/span-proposer.js.map +1 -1
  172. package/out/pipeline/types.d.ts +22 -14
  173. package/out/pipeline/types.d.ts.map +1 -1
  174. package/out/pipeline/types.js.map +1 -1
  175. package/out/policy/defaults.d.ts +1 -1
  176. package/out/policy/defaults.d.ts.map +1 -1
  177. package/out/policy/defaults.js +1 -1
  178. package/out/policy/defaults.js.map +1 -1
  179. package/out/policy/policy.d.ts +1 -1
  180. package/out/policy/policy.d.ts.map +1 -1
  181. package/out/policy/registry.d.ts +1 -1
  182. package/out/policy/registry.d.ts.map +1 -1
  183. package/out/resolver/coverage-facts.d.ts +89 -0
  184. package/out/resolver/coverage-facts.d.ts.map +1 -0
  185. package/out/resolver/coverage-facts.js +22 -0
  186. package/out/resolver/coverage-facts.js.map +1 -0
  187. package/out/resolver/index.d.ts +2 -1
  188. package/out/resolver/index.d.ts.map +1 -1
  189. package/out/resolver/index.js +1 -0
  190. package/out/resolver/index.js.map +1 -1
  191. package/out/resolver/lookup-types.d.ts +178 -0
  192. package/out/resolver/lookup-types.d.ts.map +1 -0
  193. package/out/resolver/lookup-types.js +11 -0
  194. package/out/resolver/lookup-types.js.map +1 -0
  195. package/out/resolver/placetype-map.d.ts +71 -0
  196. package/out/resolver/placetype-map.d.ts.map +1 -0
  197. package/out/resolver/placetype-map.js +98 -0
  198. package/out/resolver/placetype-map.js.map +1 -0
  199. package/out/resolver/postcode-format.d.ts +38 -0
  200. package/out/resolver/postcode-format.d.ts.map +1 -0
  201. package/out/resolver/postcode-format.js +83 -0
  202. package/out/resolver/postcode-format.js.map +1 -0
  203. package/out/resolver/types.d.ts +271 -297
  204. package/out/resolver/types.d.ts.map +1 -1
  205. package/out/resolver/types.js +4 -97
  206. package/out/resolver/types.js.map +1 -1
  207. package/out/resources/git.d.ts +8 -1
  208. package/out/resources/git.d.ts.map +1 -1
  209. package/out/resources/git.js +4 -3
  210. package/out/resources/git.js.map +1 -1
  211. package/out/resources/languages/types.gen.d.ts +1 -1
  212. package/out/resources/languages/types.gen.d.ts.map +1 -1
  213. package/out/resources/languages/types.gen.js +40 -0
  214. package/out/resources/languages/types.gen.js.map +1 -1
  215. package/out/resources/libpostal.d.ts +2 -2
  216. package/out/resources/libpostal.d.ts.map +1 -1
  217. package/out/resources/libpostal.js +2 -2
  218. package/out/resources/libpostal.js.map +1 -1
  219. package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
  220. package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
  221. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
  222. package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
  223. package/out/resources/whosonfirst/PlacetypeDataSource.js +28 -3
  224. package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
  225. package/out/resources/whosonfirst/loader.d.ts +2 -2
  226. package/out/resources/whosonfirst/loader.d.ts.map +1 -1
  227. package/out/resources/whosonfirst/loader.js.map +1 -1
  228. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  229. package/out/resources/whosonfirst/placetypes/Placetype.js +2 -2
  230. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  231. package/out/resources/whosonfirst/placetypes/admin.d.ts +9 -1
  232. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  233. package/out/resources/whosonfirst/placetypes/admin.js +1 -1
  234. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  235. package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
  236. package/out/resources/whosonfirst/placetypes/definition.js +1 -1
  237. package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
  238. package/out/resources/whosonfirst/placetypes/index.d.ts +1 -0
  239. package/out/resources/whosonfirst/placetypes/index.d.ts.map +1 -1
  240. package/out/resources/whosonfirst/placetypes/index.js +1 -0
  241. package/out/resources/whosonfirst/placetypes/index.js.map +1 -1
  242. package/out/resources/whosonfirst/placetypes/specificity.d.ts +65 -0
  243. package/out/resources/whosonfirst/placetypes/specificity.d.ts.map +1 -0
  244. package/out/resources/whosonfirst/placetypes/specificity.js +101 -0
  245. package/out/resources/whosonfirst/placetypes/specificity.js.map +1 -0
  246. package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
  247. package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -1
  248. package/out/resources/whosonfirst/sharded-repo.js +46 -2
  249. package/out/resources/whosonfirst/sharded-repo.js.map +1 -1
  250. package/out/scripting/arguments.d.ts +27 -0
  251. package/out/scripting/arguments.d.ts.map +1 -0
  252. package/out/scripting/arguments.js +32 -0
  253. package/out/scripting/arguments.js.map +1 -0
  254. package/out/scripting/command.d.ts +28 -0
  255. package/out/scripting/command.d.ts.map +1 -0
  256. package/out/scripting/command.js +47 -0
  257. package/out/scripting/command.js.map +1 -0
  258. package/out/scripting/index.js +3 -3
  259. package/out/scripting/index.js.map +1 -1
  260. package/out/scripting/utils/index.d.ts +1 -12
  261. package/out/scripting/utils/index.d.ts.map +1 -1
  262. package/out/scripting/utils/index.js +4 -21
  263. package/out/scripting/utils/index.js.map +1 -1
  264. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  265. package/out/tools/download-libpostal-resources.js +4 -7
  266. package/out/tools/download-libpostal-resources.js.map +1 -1
  267. package/out/tools/download-ssl-address.d.ts +3 -3
  268. package/out/tools/download-ssl-address.d.ts.map +1 -1
  269. package/out/tools/download-ssl-address.js +26 -13
  270. package/out/tools/download-ssl-address.js.map +1 -1
  271. package/out/tools/generate-language-types.d.ts +16 -1
  272. package/out/tools/generate-language-types.d.ts.map +1 -1
  273. package/out/tools/generate-language-types.js +38 -5
  274. package/out/tools/generate-language-types.js.map +1 -1
  275. package/out/tools/index.d.ts +1 -2
  276. package/out/tools/index.d.ts.map +1 -1
  277. package/out/tools/index.js +1 -2
  278. package/out/tools/index.js.map +1 -1
  279. package/out/utils/data-root.d.ts +27 -7
  280. package/out/utils/data-root.d.ts.map +1 -1
  281. package/out/utils/data-root.js +36 -13
  282. package/out/utils/data-root.js.map +1 -1
  283. package/out/utils/hash.d.ts +2 -3
  284. package/out/utils/hash.d.ts.map +1 -1
  285. package/out/utils/hash.js +3 -3
  286. package/out/utils/hash.js.map +1 -1
  287. package/out/utils/index.d.ts +1 -0
  288. package/out/utils/index.d.ts.map +1 -1
  289. package/out/utils/index.js +1 -0
  290. package/out/utils/index.js.map +1 -1
  291. package/out/utils/jsonl.js +1 -1
  292. package/out/utils/jsonl.js.map +1 -1
  293. package/out/utils/repo.d.ts +8 -0
  294. package/out/utils/repo.d.ts.map +1 -1
  295. package/out/utils/repo.js +10 -1
  296. package/out/utils/repo.js.map +1 -1
  297. package/out/utils/sealed-db.d.ts +11 -0
  298. package/out/utils/sealed-db.d.ts.map +1 -1
  299. package/out/utils/sealed-db.js +28 -1
  300. package/out/utils/sealed-db.js.map +1 -1
  301. package/out/utils/sqlite-rows.d.ts +34 -0
  302. package/out/utils/sqlite-rows.d.ts.map +1 -0
  303. package/out/utils/sqlite-rows.js +37 -0
  304. package/out/utils/sqlite-rows.js.map +1 -0
  305. package/out/utils/stats.d.ts +1 -6
  306. package/out/utils/stats.d.ts.map +1 -1
  307. package/out/utils/stats.js +1 -6
  308. package/out/utils/stats.js.map +1 -1
  309. package/package.json +476 -7
  310. package/pipeline/index.ts +12 -14
  311. package/pipeline/runtime-pipeline.ts +29 -183
  312. package/pipeline/span-proposer.ts +1 -1
  313. package/pipeline/types.ts +26 -15
  314. package/policy/defaults.ts +1 -1
  315. package/policy/policy.ts +1 -1
  316. package/policy/registry.ts +1 -1
  317. package/resolver/coverage-facts.ts +102 -0
  318. package/resolver/index.ts +5 -0
  319. package/resolver/lookup-types.ts +174 -0
  320. package/resolver/placetype-map.ts +122 -0
  321. package/resolver/postcode-format.ts +89 -0
  322. package/resolver/types.ts +293 -351
  323. package/resources/git.ts +18 -4
  324. package/resources/languages/types.gen.ts +60 -0
  325. package/resources/libpostal.ts +4 -3
  326. package/resources/whosonfirst/DataSourceCache.ts +2 -1
  327. package/resources/whosonfirst/PlacetypeDataSource.ts +36 -11
  328. package/resources/whosonfirst/loader.ts +3 -2
  329. package/resources/whosonfirst/placetypes/Placetype.ts +3 -2
  330. package/resources/whosonfirst/placetypes/admin.ts +11 -2
  331. package/resources/whosonfirst/placetypes/definition.ts +4 -3
  332. package/resources/whosonfirst/placetypes/index.ts +1 -0
  333. package/resources/whosonfirst/placetypes/specificity.ts +114 -0
  334. package/resources/whosonfirst/sharded-repo.ts +55 -2
  335. package/scripting/arguments.ts +38 -0
  336. package/scripting/command.ts +55 -0
  337. package/scripting/index.ts +3 -3
  338. package/scripting/utils/index.ts +6 -23
  339. package/tools/download-libpostal-resources.ts +4 -7
  340. package/tools/download-ssl-address.ts +28 -12
  341. package/tools/generate-language-types.ts +39 -5
  342. package/tools/index.ts +1 -2
  343. package/utils/data-root.ts +40 -14
  344. package/utils/hash.ts +5 -4
  345. package/utils/index.ts +1 -0
  346. package/utils/jsonl.ts +1 -1
  347. package/utils/repo.ts +12 -1
  348. package/utils/sealed-db.ts +30 -1
  349. package/utils/sqlite-rows.ts +40 -0
  350. package/utils/stats.ts +1 -6
  351. package/data/libpostal/dictionaries/all/chains.txt +0 -504
  352. package/kysley/adapter.ts +0 -29
  353. package/out/kysley/adapter.d.ts +0 -13
  354. package/out/kysley/adapter.d.ts.map +0 -1
  355. package/out/kysley/adapter.js +0 -25
  356. package/out/kysley/adapter.js.map +0 -1
  357. package/out/pipeline/reconcile-lookups.d.ts +0 -39
  358. package/out/pipeline/reconcile-lookups.d.ts.map +0 -1
  359. package/out/pipeline/reconcile-lookups.js +0 -88
  360. package/out/pipeline/reconcile-lookups.js.map +0 -1
  361. package/out/pipeline/reconcile.d.ts +0 -153
  362. package/out/pipeline/reconcile.d.ts.map +0 -1
  363. package/out/pipeline/reconcile.js +0 -388
  364. package/out/pipeline/reconcile.js.map +0 -1
  365. package/out/pipeline/span-logit-aggregation.d.ts +0 -58
  366. package/out/pipeline/span-logit-aggregation.d.ts.map +0 -1
  367. package/out/pipeline/span-logit-aggregation.js +0 -117
  368. package/out/pipeline/span-logit-aggregation.js.map +0 -1
  369. package/pipeline/reconcile-lookups.ts +0 -111
  370. package/pipeline/reconcile.ts +0 -583
  371. package/pipeline/span-logit-aggregation.ts +0 -156
@@ -1,88 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * Pre-fetch adapters that wire a `ResolverBackend` into the reconciler's concordance axes (#478
7
- * step 2, re-scoped): `reconcileSpans` already implements resolver-candidate and parent-chain
8
- * scoring but the runtime pipeline never passed the lookups — the axes were dormant, exercised
9
- * only by Map-backed test fixtures.
10
- *
11
- * The reconciler's beam search is SYNCHRONOUS; the backend is async. So this module does one
12
- * bounded async pre-fetch pass — `findPlace` per (phrase-span × top-k tag) pair, `ancestors` per
13
- * fetched place — and returns Map-backed lookups with the contract the reconciler expects. Query
14
- * count is capped (`maxLookups`, default 12) the same way `resolveTree` caps its walk; pairs are
15
- * visited in classifier-score order so the budget goes to the likeliest spans.
16
- */
17
- const RESOLVABLE_TAGS = new Set(["country", "region", "locality", "dependent_locality", "county", "subregion"]);
18
- /**
19
- * Build the reconciler's concordance lookups from one bounded pre-fetch pass over the backend.
20
- *
21
- * @param backend The gazetteer backend (Stage 6's `WOFSqlitePlaceLookup.asResolverBackend()` in production; any
22
- * structural match in tests).
23
- * @param raw The normalized input text — span bounds index into this.
24
- * @param classifierTopK The aggregated per-span tag candidates (score-descending preferred; the budget follows this
25
- * order).
26
- * @param opts.maxLookups Hard cap on `findPlace` calls (default 12).
27
- * @param opts.candidatesPerPair Max places retained per (span, tag) pair (default 3).
28
- */
29
- export async function prefetchReconcileLookups(backend, raw, classifierTopK, opts) {
30
- const maxLookups = opts?.maxLookups ?? 12;
31
- const perPair = opts?.candidatesPerPair ?? 3;
32
- const candidateTable = new Map();
33
- const chainTable = new Map();
34
- const pairKey = (span, tag) => `${span.start}:${span.end}:${tag}`;
35
- let budget = maxLookups;
36
- for (const candidate of classifierTopK) {
37
- if (budget <= 0)
38
- break;
39
- if (!RESOLVABLE_TAGS.has(candidate.tag))
40
- continue;
41
- const key = pairKey(candidate.span, candidate.tag);
42
- if (candidateTable.has(key))
43
- continue;
44
- const text = raw.slice(candidate.span.start, candidate.span.end).trim();
45
- if (!text)
46
- continue;
47
- budget--;
48
- let places = [];
49
- try {
50
- places = await backend.findPlace({
51
- text,
52
- placetype: candidate.tag,
53
- ...(opts?.defaultCountry ? { country: opts.defaultCountry } : {}),
54
- limit: perPair,
55
- });
56
- }
57
- catch {
58
- // A backend failure degrades to "no concordance evidence for this pair" — the
59
- // reconciler scores without it, identical to today's behavior.
60
- }
61
- candidateTable.set(key, places.slice(0, perPair));
62
- // Ancestors are synchronous + memoized backend-side; chain them now so parentsOf is a
63
- // pure Map read during the beam search.
64
- if (backend.ancestors) {
65
- for (const place of places) {
66
- if (chainTable.has(place.id))
67
- continue;
68
- const chain = backend.ancestors(place.id) ?? [];
69
- // The reconciler's concordance check is MEMBERSHIP-ONLY (by id) — Ancestor carries no
70
- // coordinates, and none are needed; zeroes satisfy the ResolvedPlace shape.
71
- chainTable.set(place.id, chain.map((a) => ({ id: a.id, name: a.name, placetype: a.placetype, lat: 0, lon: 0 })));
72
- }
73
- }
74
- }
75
- return {
76
- resolverCandidates: {
77
- candidatesFor(span, tag) {
78
- return candidateTable.get(pairKey(span, tag)) ?? [];
79
- },
80
- },
81
- parentChain: {
82
- parentsOf(place) {
83
- return chainTable.get(place.id) ?? [];
84
- },
85
- },
86
- };
87
- }
88
- //# sourceMappingURL=reconcile-lookups.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconcile-lookups.js","sourceRoot":"","sources":["../../pipeline/reconcile-lookups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAA;AAO/G;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC7C,OAAwB,EACxB,GAAW,EACX,cAAkD,EAClD,IAAmF;IAEnF,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,EAAE,CAAA;IACzC,MAAM,OAAO,GAAG,IAAI,EAAE,iBAAiB,IAAI,CAAC,CAAA;IAE5C,MAAM,cAAc,GAAG,IAAI,GAAG,EAA2B,CAAA;IACzD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAoC,CAAA;IAC9D,MAAM,OAAO,GAAG,CAAC,IAAoC,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE,CAAA;IAEzG,IAAI,MAAM,GAAG,UAAU,CAAA;IAEvB,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;QACxC,IAAI,MAAM,IAAI,CAAC;YAAE,MAAK;QAEtB,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC;YAAE,SAAQ;QACjD,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,SA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,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAkB,CAAC,CACvG,CAAA;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO;QACN,kBAAkB,EAAE;YACnB,aAAa,CAAC,IAAI,EAAE,GAAG;gBACtB,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;YACpD,CAAC;SACD;QACD,WAAW,EAAE;YACZ,SAAS,CAAC,KAAK;gBACd,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAA;YACtC,CAAC;SACD;KACD,CAAA;AACF,CAAC"}
@@ -1,153 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * `reconcileSpans` — Stage 5 joint-decoding path.
7
- *
8
- * Today's runtime Stage 5 (in `runtime-pipeline.ts`) just keeps the classifier-emitted spans in
9
- * start order. That fallback covers callers who don't yet have top-k inputs from Stages 2.7 / 3 /
10
- * 6. This file is the **opt-in** joint-decoding path that turns Stage 5 from a sort into a
11
- * reconciler: pick the parse tree that maximizes
12
- *
13
- * ```
14
- * ∏ phrase_grouper_confidence
15
- * × classifier_confidence
16
- * × resolver_score
17
- * × concordance_bonus(parent_id chain)
18
- * ```
19
- *
20
- * Closes the kryptonite catalogue (`NY-NY Steakhouse, Houston, TX`, `Paris, Texas`, `Saint
21
- * Petersburg, FL`, `Buffalo Buffalo`) where today's argmax-per-stage produces internally-
22
- * inconsistent parses that the layer above can't repair.
23
- *
24
- * The implementation is a beam search over candidate slots — each slot is one `(phrase_span,
25
- * classifier_tag, resolver_place)` triple. Three knobs prune the cross product: `kSpan` (de-duped
26
- * phrase span proposals), `kTag` (classifier tag interpretations per span), and `kResolver`
27
- * (resolver candidates per `(span, tag)`). Concordance scoring is incremental — when a slot is
28
- * added, we check the new place's `parent_id` chain against the running admin assignment and
29
- * adjust the running score before pruning.
30
- *
31
- * The Thread C-s classifier top-k contract is mocked locally for v0.5.0 (see `ClassifierCandidate`
32
- * below). The real classifier output adapter ships with `@mailwoman/neural` once Thread C-s
33
- * lands; the existing `ResolvedPlace` shape from `@mailwoman/core/resolver` is what backs the
34
- * resolver-candidates axis (parent_id chains live there).
35
- *
36
- * See `docs/articles/plan/phases/PHASE_8_v0_5_0_fresh_slate.md` § D for the v0.5.0 context and
37
- * `docs/articles/concepts/the-knowledge-ladder.md` § Reconcile for the design rationale.
38
- */
39
- import type { AddressTree, ComponentTag } from "../decoder/types.ts";
40
- import type { ResolvedPlace } from "../resolver/types.ts";
41
- import type { PhraseProposal } from "./types.ts";
42
- /**
43
- * One classifier interpretation for one input span. Pins the Thread C-s contract for the reconciler — the real
44
- * classifier emits this directly once that thread lands. Until then, tests hand-build a list of these to simulate top-k
45
- * output.
46
- *
47
- * The classifier may emit multiple candidates for the same span (different tag hypotheses); the reconciler treats those
48
- * as the top-k tag axis. Candidates whose `span` does not exactly match a phrase proposal's span are ignored — the
49
- * phrase grouper is the boundary-discovery authority.
50
- */
51
- export interface ClassifierCandidate {
52
- span: {
53
- start: number;
54
- end: number;
55
- };
56
- tag: ComponentTag;
57
- /**
58
- * Calibrated confidence in [0, 1].
59
- */
60
- score: number;
61
- }
62
- /**
63
- * Resolver lookup for the (span, tag) axis. In production wraps a `ResolverBackend` (Stage 6); in tests an in-memory
64
- * table built per fixture. Returned candidates must already be sorted descending by score — the reconciler takes the
65
- * top `kResolver` as-is.
66
- */
67
- export interface ResolverCandidatesLookup {
68
- candidatesFor(span: {
69
- start: number;
70
- end: number;
71
- }, tag: ComponentTag): ReadonlyArray<ResolvedPlace>;
72
- }
73
- /**
74
- * Parent-chain lookup for concordance scoring. WOF SQLite is the source of truth in production (Stage 6); tests pass a
75
- * `Map`-backed mock. Returns the place's ancestors (order unimportant — the reconciler only checks membership).
76
- */
77
- export interface ParentChainLookup {
78
- parentsOf(place: ResolvedPlace): ReadonlyArray<ResolvedPlace>;
79
- }
80
- export interface ReconcileInputs {
81
- /**
82
- * Raw input text — used to materialize `value` strings on the resulting tree.
83
- */
84
- raw: string;
85
- phraseProposals: ReadonlyArray<PhraseProposal>;
86
- /**
87
- * Sorted descending by score. May be empty (returns an empty tree).
88
- */
89
- classifierTopK: ReadonlyArray<ClassifierCandidate>;
90
- resolverCandidates?: ResolverCandidatesLookup;
91
- parentChain?: ParentChainLookup;
92
- opts?: ReconcileOpts;
93
- }
94
- export interface ReconcileOpts {
95
- /**
96
- * Top-k phrase span proposals retained per (start, end) — default 3.
97
- */
98
- kSpan?: number;
99
- /**
100
- * Top-k classifier tag interpretations retained per span — default 3.
101
- */
102
- kTag?: number;
103
- /**
104
- * Top-k resolver candidates retained per (span, tag) — default 5.
105
- */
106
- kResolver?: number;
107
- /**
108
- * Concordance bonus multiplier. 1.0 weights chain-consistency equal to one classifier-score factor; lower values
109
- * trust the classifier more, higher values trust the gazetteer more. Default 1.0.
110
- */
111
- concordanceWeight?: number;
112
- /**
113
- * Beam width during search — default 16.
114
- */
115
- beamWidth?: number;
116
- /**
117
- * Runner-up parses returned alongside the winner — default 3.
118
- */
119
- runnersUp?: number;
120
- }
121
- export interface ScoreBreakdown {
122
- phrase: number;
123
- classifier: number;
124
- resolver: number;
125
- concordance: number;
126
- /**
127
- * Composite multiplicative score in real space, [0, ∞).
128
- */
129
- total: number;
130
- }
131
- export interface ParseTree {
132
- tree: AddressTree;
133
- /**
134
- * Softmaxed confidence in [0, 1] over the finalized beam.
135
- */
136
- confidence: number;
137
- runnersUp: AddressTree[];
138
- scoreBreakdown: ScoreBreakdown;
139
- }
140
- /**
141
- * Joint-decode the best parse tree from Stage 2.7 phrase proposals, Stage 3 classifier top-k, and Stage 6 resolver
142
- * candidates. See file header for the scoring formula.
143
- *
144
- * The result tree's roots are the winning `(span, tag, place)` triples in source order. Each node's `placeID`, `lat`,
145
- * `lon` come from the chosen resolver candidate; `confidence` reflects the per- factor score for that slot. `runnersUp`
146
- * are the next-best parses for caller inspection.
147
- *
148
- * Empty `classifierTopK` short-circuits to an empty tree at confidence 0 — no joint decode is possible without tag
149
- * interpretations. Callers without top-k should use the runtime-pipeline fallback (which keeps classifier-emitted spans
150
- * sorted by start).
151
- */
152
- export declare function reconcileSpans(inputs: ReconcileInputs): ParseTree;
153
- //# sourceMappingURL=reconcile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../pipeline/reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC,GAAG,EAAE,YAAY,CAAA;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACxC,aAAa,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,YAAY,GAAG,aAAa,CAAC,aAAa,CAAC,CAAA;CACpG;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAAC,aAAa,CAAC,CAAA;CAC7D;AAED,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX,eAAe,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC9C;;OAEG;IACH,cAAc,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;IAClD,kBAAkB,CAAC,EAAE,wBAAwB,CAAA;IAC7C,WAAW,CAAC,EAAE,iBAAiB,CAAA;IAC/B,IAAI,CAAC,EAAE,aAAa,CAAA;CACpB;AAED,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,WAAW,CAAA;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,cAAc,EAAE,cAAc,CAAA;CAC9B;AAwED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAgEjE"}
@@ -1,388 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- *
6
- * `reconcileSpans` — Stage 5 joint-decoding path.
7
- *
8
- * Today's runtime Stage 5 (in `runtime-pipeline.ts`) just keeps the classifier-emitted spans in
9
- * start order. That fallback covers callers who don't yet have top-k inputs from Stages 2.7 / 3 /
10
- * 6. This file is the **opt-in** joint-decoding path that turns Stage 5 from a sort into a
11
- * reconciler: pick the parse tree that maximizes
12
- *
13
- * ```
14
- * ∏ phrase_grouper_confidence
15
- * × classifier_confidence
16
- * × resolver_score
17
- * × concordance_bonus(parent_id chain)
18
- * ```
19
- *
20
- * Closes the kryptonite catalogue (`NY-NY Steakhouse, Houston, TX`, `Paris, Texas`, `Saint
21
- * Petersburg, FL`, `Buffalo Buffalo`) where today's argmax-per-stage produces internally-
22
- * inconsistent parses that the layer above can't repair.
23
- *
24
- * The implementation is a beam search over candidate slots — each slot is one `(phrase_span,
25
- * classifier_tag, resolver_place)` triple. Three knobs prune the cross product: `kSpan` (de-duped
26
- * phrase span proposals), `kTag` (classifier tag interpretations per span), and `kResolver`
27
- * (resolver candidates per `(span, tag)`). Concordance scoring is incremental — when a slot is
28
- * added, we check the new place's `parent_id` chain against the running admin assignment and
29
- * adjust the running score before pruning.
30
- *
31
- * The Thread C-s classifier top-k contract is mocked locally for v0.5.0 (see `ClassifierCandidate`
32
- * below). The real classifier output adapter ships with `@mailwoman/neural` once Thread C-s
33
- * lands; the existing `ResolvedPlace` shape from `@mailwoman/core/resolver` is what backs the
34
- * resolver-candidates axis (parent_id chains live there).
35
- *
36
- * See `docs/articles/plan/phases/PHASE_8_v0_5_0_fresh_slate.md` § D for the v0.5.0 context and
37
- * `docs/articles/concepts/the-knowledge-ladder.md` § Reconcile for the design rationale.
38
- */
39
- const DEFAULTS = {
40
- kSpan: 3,
41
- kTag: 3,
42
- kResolver: 5,
43
- concordanceWeight: 1,
44
- beamWidth: 16,
45
- runnersUp: 3,
46
- };
47
- /**
48
- * Log-space bonus per **word covered** by an accepted slot. Counterweight for the multiplicative penalty inherent in
49
- * "score = ∏ confidences": each factor in [0, 1] strictly lowers the running score, which would otherwise make the
50
- * empty parse always win. With per-word scaling, a slot is worth including when the per-word geometric mean of its
51
- * factors exceeds 1/2.5 = 0.4; below that, the search prefers to skip.
52
- *
53
- * Why per-word and not per-slot: a constant per-slot bonus carries two structural biases, both measured on `"New York
54
- * City"` (2026-06-11):
55
- *
56
- * 1. **Fragments beat coverage.** The per-token logit aggregation gives interior fragments inflated confidence (`City`
57
- * aggregates I-locality mass → locality 0.92 vs 0.60 for the full span), and a per-slot bonus charges nothing for
58
- * leaving the rest of the input unexplained — so the beam picked the bare `locality="City"` (+0.475) over
59
- * `locality="New York City"` (+0.199) and the grouper-audit then promoted the orphaned `York` to a spurious
60
- * `region`.
61
- * 2. **More spans collect more bonuses.** For two interpretations covering the same words, the one split into more slots
62
- * banked one bonus per slot — a fragmentation subsidy.
63
- *
64
- * Scaling the bonus by the slot's word count makes coverage the thing being rewarded: equal-coverage interpretations
65
- * collect equal bonus (the classifier/phrase/resolver factors alone decide), and an interpretation that explains more
66
- * of the input out-scores one that silently drops words unless the extra evidence is weak (per-word factor mean <
67
- * 0.4).
68
- *
69
- * The choice of 2.5 is a tuning constant, not a free parameter we expose — exposing it would invite callers to disable
70
- * inclusion entirely (defeating the purpose of the reconciler) and the sensible range is narrow. Lives here rather than
71
- * `ReconcileOpts` for that reason. Words are whitespace-delimited; scripts without spaces (CJK) count as one word,
72
- * which degrades to the old per-slot behavior rather than misbehaving.
73
- */
74
- const INCLUSION_LOG_BONUS = Math.log(2.5);
75
- /**
76
- * Admin levels from coarse to fine. Concordance scoring walks pairs (parent_level, child_level) and checks the child's
77
- * parent_id chain for the parent's place id.
78
- */
79
- const ADMIN_LEVELS = ["country", "region", "locality", "dependent_locality"];
80
- const ADMIN_LEVEL_SET = new Set(ADMIN_LEVELS);
81
- /**
82
- * Joint-decode the best parse tree from Stage 2.7 phrase proposals, Stage 3 classifier top-k, and Stage 6 resolver
83
- * candidates. See file header for the scoring formula.
84
- *
85
- * The result tree's roots are the winning `(span, tag, place)` triples in source order. Each node's `placeID`, `lat`,
86
- * `lon` come from the chosen resolver candidate; `confidence` reflects the per- factor score for that slot. `runnersUp`
87
- * are the next-best parses for caller inspection.
88
- *
89
- * Empty `classifierTopK` short-circuits to an empty tree at confidence 0 — no joint decode is possible without tag
90
- * interpretations. Callers without top-k should use the runtime-pipeline fallback (which keeps classifier-emitted spans
91
- * sorted by start).
92
- */
93
- export function reconcileSpans(inputs) {
94
- const opts = { ...DEFAULTS, ...inputs.opts };
95
- const slots = buildSlots(inputs, opts);
96
- if (!slots.length) {
97
- return emptyParseTree(inputs.raw);
98
- }
99
- // Beam search over left-to-right slot inclusion. Each slot is either accepted (if non-
100
- // overlapping with the beam's claimed range) or skipped. Beam pruning keeps the top
101
- // `beamWidth` by running log-score.
102
- // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
103
- const slotsByStart = slots.slice().sort((a, b) => a.span.start - b.span.start);
104
- let beams = [{ assignments: [], logScore: 0, lastEnd: -1 }];
105
- for (const slot of slotsByStart) {
106
- const next = [];
107
- for (const beam of beams) {
108
- next.push(beam);
109
- if (slot.span.start >= beam.lastEnd) {
110
- const concordanceDelta = concordanceDeltaFor(beam.assignments, slot, inputs, opts);
111
- if (concordanceDelta === Number.NEGATIVE_INFINITY)
112
- continue;
113
- const slotLog = logSafe(slot.phraseConf) +
114
- logSafe(slot.classifierScore) +
115
- logSafe(slot.resolverScore) +
116
- concordanceDelta +
117
- INCLUSION_LOG_BONUS * slot.wordCount;
118
- next.push({
119
- assignments: [...beam.assignments, slot],
120
- logScore: beam.logScore + slotLog,
121
- lastEnd: slot.span.end,
122
- });
123
- }
124
- }
125
- next.sort((a, b) => b.logScore - a.logScore);
126
- beams = next.slice(0, opts.beamWidth);
127
- }
128
- beams.sort((a, b) => b.logScore - a.logScore);
129
- // Drop the empty beam if there's at least one non-empty competitor (the empty beam scores 0,
130
- // which would otherwise dominate when all real candidates have very low log-scores).
131
- const populated = beams.filter((b) => b.assignments.length > 0);
132
- const ordered = populated.length ? populated : beams;
133
- const top = ordered[0];
134
- const runners = ordered.slice(1, 1 + opts.runnersUp);
135
- const trees = ordered.map((b) => buildTree(b, inputs.raw));
136
- const confidences = softmax(ordered.map((b) => b.logScore));
137
- return {
138
- tree: trees[0],
139
- confidence: confidences[0],
140
- runnersUp: runners.map((_, i) => trees[i + 1]),
141
- scoreBreakdown: breakdownFor(top, inputs, opts),
142
- };
143
- }
144
- /**
145
- * Build the candidate slot set: dedupe phrase proposals by (start, end), join with classifier top-k tag candidates,
146
- * join with resolver places per (span, tag).
147
- *
148
- * Spans with no classifier candidate are dropped — the reconciler cannot tag them. Spans with no resolver candidate
149
- * still survive; the resolver score defaults to 1 (neutral) and the slot's place is null (won't contribute to
150
- * concordance).
151
- */
152
- function buildSlots(inputs, opts) {
153
- const bySpanKey = new Map();
154
- for (const p of inputs.phraseProposals) {
155
- const k = spanKey(p.span.start, p.span.end);
156
- const cur = bySpanKey.get(k);
157
- if (!cur || p.confidence > cur.confidence) {
158
- bySpanKey.set(k, p);
159
- }
160
- }
161
- // `kSpan` limits the number of overlapping proposals anchored at each start position — NOT a
162
- // global cap on phrase proposals. Two phrases at different starts (e.g. `Houston` at 18 +
163
- // `TX` at 27) are independent candidates and both must survive `kSpan = 3`. Without this per-
164
- // start grouping, a low-confidence-but-correct proposal (e.g. `Houston` @ 0.65) is dropped
165
- // just because the input has many higher-confidence proposals elsewhere.
166
- const byStart = new Map();
167
- for (const p of bySpanKey.values()) {
168
- const arr = byStart.get(p.span.start) ?? [];
169
- arr.push(p);
170
- byStart.set(p.span.start, arr);
171
- }
172
- const spans = [];
173
- for (const arr of byStart.values()) {
174
- spans.push(...topN(arr, opts.kSpan, (p) => p.confidence));
175
- }
176
- const tagsBySpan = new Map();
177
- for (const c of inputs.classifierTopK) {
178
- const k = spanKey(c.span.start, c.span.end);
179
- const arr = tagsBySpan.get(k) ?? [];
180
- arr.push(c);
181
- tagsBySpan.set(k, arr);
182
- }
183
- const slots = [];
184
- for (const phrase of spans) {
185
- const key = spanKey(phrase.span.start, phrase.span.end);
186
- const tagCandidates = topN(tagsBySpan.get(key) ?? [], opts.kTag, (c) => c.score);
187
- const words = wordCountOf(inputs.raw, phrase.span);
188
- for (const tagC of tagCandidates) {
189
- const places = inputs.resolverCandidates
190
- ? inputs.resolverCandidates.candidatesFor(tagC.span, tagC.tag).slice(0, opts.kResolver)
191
- : [];
192
- if (!places.length) {
193
- slots.push({
194
- span: phrase.span,
195
- phraseConf: phrase.confidence,
196
- tag: tagC.tag,
197
- classifierScore: tagC.score,
198
- place: null,
199
- resolverScore: 1,
200
- wordCount: words,
201
- });
202
- continue;
203
- }
204
- for (const place of places) {
205
- slots.push({
206
- span: phrase.span,
207
- phraseConf: phrase.confidence,
208
- tag: tagC.tag,
209
- classifierScore: tagC.score,
210
- place,
211
- resolverScore: normalizeResolverScore(place.score),
212
- wordCount: words,
213
- });
214
- }
215
- }
216
- }
217
- return slots;
218
- }
219
- /**
220
- * Whitespace-delimited word count of a span's surface text, floor 1. Scales the per-slot inclusion bonus so coverage —
221
- * not slot count — is what the search rewards (see `INCLUSION_LOG_BONUS`).
222
- */
223
- function wordCountOf(raw, span) {
224
- const text = raw.slice(span.start, span.end).trim();
225
- if (!text.length)
226
- return 1;
227
- return text.split(/\s+/).length;
228
- }
229
- /**
230
- * Concordance delta for adding `slot` to an existing beam. Returns the log-space contribution to add to the beam's
231
- * running score, or `-Infinity` if the slot introduces a hard contradiction (would be admissible into the beam's admin
232
- * chain but explicitly disagrees).
233
- *
234
- * Behavior at the boundaries:
235
- *
236
- * - Slot has no place or is non-admin → 0 (no chain contribution).
237
- * - No admin neighbors yet → 0 (nothing to agree with).
238
- * - Admin chain agrees → `+ concordanceWeight × log(1 + match_ratio)`.
239
- * - Some admin pairs cannot be verified (missing parents) → 0 contribution per neutral pair.
240
- * - Admin chain has any explicit contradiction → `-Infinity` (hard veto).
241
- */
242
- function concordanceDeltaFor(existing, candidate, inputs, opts) {
243
- if (!candidate.place || !ADMIN_LEVEL_SET.has(candidate.tag))
244
- return 0;
245
- const chainOf = inputs.parentChain;
246
- if (!chainOf)
247
- return 0;
248
- const candIdx = ADMIN_LEVELS.indexOf(candidate.tag);
249
- let matches = 0;
250
- let neutrals = 0;
251
- let pairs = 0;
252
- for (const prior of existing) {
253
- if (!prior.place || !ADMIN_LEVEL_SET.has(prior.tag))
254
- continue;
255
- const priorIdx = ADMIN_LEVELS.indexOf(prior.tag);
256
- const child = priorIdx > candIdx ? prior : candidate;
257
- const parent = priorIdx > candIdx ? candidate : prior;
258
- if (child === parent)
259
- continue;
260
- const chain = chainOf.parentsOf(child.place);
261
- pairs++;
262
- if (!chain.length) {
263
- neutrals++;
264
- continue;
265
- }
266
- const hit = chain.some((p) => idsEqual(p.id, parent.place.id));
267
- if (hit) {
268
- matches++;
269
- }
270
- else {
271
- return Number.NEGATIVE_INFINITY;
272
- }
273
- }
274
- if (pairs === 0)
275
- return 0;
276
- const matchRatio = matches / pairs;
277
- // Linear in matchRatio so a fully-consistent chain contributes exactly `+concordanceWeight`
278
- // log-space — the briefing's "+1 for fully consistent" reading. Matches contribute
279
- // proportionally; neutrals (no chain data) don't penalize.
280
- return opts.concordanceWeight * matchRatio;
281
- }
282
- function idsEqual(a, b) {
283
- return String(a) === String(b);
284
- }
285
- /**
286
- * Compute the per-factor breakdown for the winning beam. Independently of the search's `logScore` (which carries the
287
- * inclusion-bonus prior), the breakdown surfaces the bare `phrase × classifier × resolver × concordance` product so
288
- * callers can introspect why a tree won.
289
- */
290
- function breakdownFor(beam, inputs, opts) {
291
- let phrase = 1;
292
- let classifier = 1;
293
- let resolver = 1;
294
- for (const a of beam.assignments) {
295
- phrase *= Math.max(a.phraseConf, 0);
296
- classifier *= Math.max(a.classifierScore, 0);
297
- resolver *= Math.max(a.resolverScore, 0);
298
- }
299
- const concordanceLog = totalConcordanceLog(beam.assignments, inputs, opts);
300
- const concordance = Math.exp(concordanceLog);
301
- const total = phrase * classifier * resolver * concordance;
302
- return { phrase, classifier, resolver, concordance, total };
303
- }
304
- /**
305
- * Recompute the joint concordance contribution for the entire assignment list (vs the incremental `concordanceDeltaFor`
306
- * used during search). Used by the breakdown.
307
- */
308
- function totalConcordanceLog(assignments, inputs, opts) {
309
- if (!inputs.parentChain)
310
- return 0;
311
- let acc = 0;
312
- for (let i = 0; i < assignments.length; i++) {
313
- const delta = concordanceDeltaFor(assignments.slice(0, i), assignments[i], inputs, opts);
314
- if (delta === Number.NEGATIVE_INFINITY)
315
- return Number.NEGATIVE_INFINITY;
316
- acc += delta;
317
- }
318
- return acc;
319
- }
320
- function buildTree(beam, raw) {
321
- const roots = beam.assignments
322
- .slice()
323
- // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
324
- .sort((a, b) => a.span.start - b.span.start)
325
- .map((slot) => ({
326
- tag: slot.tag,
327
- value: raw.slice(slot.span.start, slot.span.end),
328
- start: slot.span.start,
329
- end: slot.span.end,
330
- confidence: slot.classifierScore * slot.phraseConf,
331
- children: [],
332
- source: "reconcile",
333
- sourceID: "reconcile:stage-5-joint",
334
- ...(slot.place
335
- ? {
336
- lat: slot.place.lat,
337
- lon: slot.place.lon,
338
- placeID: `${placeIDPrefix(slot.place)}:${slot.place.id}`,
339
- }
340
- : {}),
341
- }));
342
- return { raw, roots };
343
- }
344
- function emptyParseTree(raw) {
345
- return {
346
- tree: { raw, roots: [] },
347
- confidence: 0,
348
- runnersUp: [],
349
- scoreBreakdown: { phrase: 0, classifier: 0, resolver: 0, concordance: 1, total: 0 },
350
- };
351
- }
352
- function placeIDPrefix(place) {
353
- // Mirror the convention used by @mailwoman/core/resolver-wof-sqlite (`wof:<id>`). Resolver
354
- // backends that don't carry an implicit vendor in `id` get a neutral `place:` prefix.
355
- return typeof place.id === "number" ? "wof" : "place";
356
- }
357
- function spanKey(start, end) {
358
- return `${start}:${end}`;
359
- }
360
- function topN(items, n, key) {
361
- return (items
362
- .slice()
363
- // oxlint-disable-next-line unicorn/no-array-sort -- sorts a freshly-built array; toSorted would double-allocate on a hot path
364
- .sort((a, b) => key(b) - key(a))
365
- .slice(0, n));
366
- }
367
- function logSafe(x) {
368
- return x > 0 ? Math.log(x) : -50;
369
- }
370
- function normalizeResolverScore(score) {
371
- // Resolver score scale is implementation-defined; clamp to (0, 1] for the multiplicative
372
- // combiner. A backend that returns 0 still counts as a candidate (e.g. a partial match) but
373
- // contributes a tiny log-factor.
374
- if (!Number.isFinite(score) || score <= 0)
375
- return 0.01;
376
- if (score > 1)
377
- return 1;
378
- return score;
379
- }
380
- function softmax(scores) {
381
- if (!scores.length)
382
- return [];
383
- const max = Math.max(...scores);
384
- const exps = scores.map((s) => Math.exp(s - max));
385
- const sum = exps.reduce((a, b) => a + b, 0);
386
- return exps.map((e) => e / sum);
387
- }
388
- //# sourceMappingURL=reconcile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reconcile.js","sourceRoot":"","sources":["../../pipeline/reconcile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAyGH,MAAM,QAAQ,GAAG;IAChB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,CAAC;IACZ,iBAAiB,EAAE,CAAC;IACpB,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,CAAC;CACZ,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEzC;;;GAGG;AACH,MAAM,YAAY,GAAgC,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAA;AACzG,MAAM,eAAe,GAAG,IAAI,GAAG,CAAe,YAAY,CAAC,CAAA;AA2B3D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,MAAuB;IACrD,MAAM,IAAI,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;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