@mailwoman/registry 9.4.0 → 10.1.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 (263) hide show
  1. package/README.md +10 -10
  2. package/lib/address-key.ts +14 -10
  3. package/lib/geocode-handler.ts +6 -4
  4. package/lib/geojson.ts +13 -17
  5. package/lib/ingest.ts +57 -83
  6. package/lib/learned-scorer.ts +38 -44
  7. package/lib/map-html.ts +24 -70
  8. package/lib/models/crosssource-gbt-en-us.ts +9 -7
  9. package/lib/models/dedup-gbt-en-us.ts +9 -8
  10. package/lib/models/org-crosssource-gbt-en-us.ts +10 -8
  11. package/lib/reconcile.ts +45 -55
  12. package/lib/resolve.ts +180 -124
  13. package/lib/types.ts +18 -12
  14. package/out/address-key.d.ts +14 -10
  15. package/out/address-key.d.ts.map +1 -1
  16. package/out/address-key.js +14 -10
  17. package/out/address-key.js.map +1 -1
  18. package/out/geocode-handler.d.ts +6 -4
  19. package/out/geocode-handler.d.ts.map +1 -1
  20. package/out/geocode-handler.js +6 -4
  21. package/out/geocode-handler.js.map +1 -1
  22. package/out/geojson.d.ts +9 -5
  23. package/out/geojson.d.ts.map +1 -1
  24. package/out/geojson.js +13 -15
  25. package/out/geojson.js.map +1 -1
  26. package/out/ingest.d.ts +46 -75
  27. package/out/ingest.d.ts.map +1 -1
  28. package/out/ingest.js +27 -54
  29. package/out/ingest.js.map +1 -1
  30. package/out/learned-scorer.d.ts +29 -26
  31. package/out/learned-scorer.d.ts.map +1 -1
  32. package/out/learned-scorer.js +31 -39
  33. package/out/learned-scorer.js.map +1 -1
  34. package/out/map-html.d.ts +13 -32
  35. package/out/map-html.d.ts.map +1 -1
  36. package/out/map-html.js +9 -62
  37. package/out/map-html.js.map +1 -1
  38. package/out/models/crosssource-gbt-en-us.d.ts +9 -7
  39. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  40. package/out/models/crosssource-gbt-en-us.js +9 -7
  41. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  42. package/out/models/dedup-gbt-en-us.d.ts +9 -8
  43. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  44. package/out/models/dedup-gbt-en-us.js +9 -8
  45. package/out/models/dedup-gbt-en-us.js.map +1 -1
  46. package/out/models/org-crosssource-gbt-en-us.d.ts +10 -8
  47. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  48. package/out/models/org-crosssource-gbt-en-us.js +10 -8
  49. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  50. package/out/reconcile.d.ts +35 -50
  51. package/out/reconcile.d.ts.map +1 -1
  52. package/out/reconcile.js +19 -43
  53. package/out/reconcile.js.map +1 -1
  54. package/out/resolve.d.ts +150 -90
  55. package/out/resolve.d.ts.map +1 -1
  56. package/out/resolve.js +62 -63
  57. package/out/resolve.js.map +1 -1
  58. package/out/tools/coverage-reconciliation.d.ts +23 -23
  59. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  60. package/out/tools/coverage-reconciliation.js +15 -26
  61. package/out/tools/coverage-reconciliation.js.map +1 -1
  62. package/out/tools/cross/dataset-correlation.d.ts +58 -0
  63. package/out/tools/cross/dataset-correlation.d.ts.map +1 -0
  64. package/out/tools/{cross-dataset-correlation.js → cross/dataset-correlation.js} +10 -62
  65. package/out/tools/cross/dataset-correlation.js.map +1 -0
  66. package/out/tools/cross/source-threshold-sweep.d.ts +60 -0
  67. package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -0
  68. package/out/tools/{cross-source-threshold-sweep.js → cross/source-threshold-sweep.js} +15 -41
  69. package/out/tools/cross/source-threshold-sweep.js.map +1 -0
  70. package/out/tools/dedup-ceiling.d.ts +23 -26
  71. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  72. package/out/tools/dedup-ceiling.js +22 -41
  73. package/out/tools/dedup-ceiling.js.map +1 -1
  74. package/out/tools/eval-geocoder.d.ts +22 -15
  75. package/out/tools/eval-geocoder.d.ts.map +1 -1
  76. package/out/tools/eval-geocoder.js +5 -6
  77. package/out/tools/eval-geocoder.js.map +1 -1
  78. package/out/tools/geocoder/namesake-probe.d.ts +33 -0
  79. package/out/tools/geocoder/namesake-probe.d.ts.map +1 -0
  80. package/out/tools/{geocoder-namesake-probe.js → geocoder/namesake-probe.js} +7 -8
  81. package/out/tools/geocoder/namesake-probe.js.map +1 -0
  82. package/out/tools/geocoder/vs-provided-coords.d.ts +53 -0
  83. package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -0
  84. package/out/tools/{geocoder-vs-provided-coords.js → geocoder/vs-provided-coords.js} +31 -28
  85. package/out/tools/geocoder/vs-provided-coords.js.map +1 -0
  86. package/out/tools/gold-set-sample.d.ts +27 -18
  87. package/out/tools/gold-set-sample.d.ts.map +1 -1
  88. package/out/tools/gold-set-sample.js +18 -22
  89. package/out/tools/gold-set-sample.js.map +1 -1
  90. package/out/tools/learned/scorer/clustering-eval.d.ts +77 -0
  91. package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -0
  92. package/out/tools/{learned-scorer-clustering-eval.js → learned/scorer/clustering-eval.js} +29 -39
  93. package/out/tools/learned/scorer/clustering-eval.js.map +1 -0
  94. package/out/tools/learned/scorer/crossstate-eval.d.ts +65 -0
  95. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -0
  96. package/out/tools/{learned-scorer-crossstate-eval.js → learned/scorer/crossstate-eval.js} +20 -26
  97. package/out/tools/learned/scorer/crossstate-eval.js.map +1 -0
  98. package/out/tools/learned/scorer/eval.d.ts +60 -0
  99. package/out/tools/learned/scorer/eval.d.ts.map +1 -0
  100. package/out/tools/{learned-scorer-eval.js → learned/scorer/eval.js} +12 -72
  101. package/out/tools/learned/scorer/eval.js.map +1 -0
  102. package/out/tools/matcher-scale.d.ts +12 -17
  103. package/out/tools/matcher-scale.d.ts.map +1 -1
  104. package/out/tools/matcher-scale.js +11 -29
  105. package/out/tools/matcher-scale.js.map +1 -1
  106. package/out/tools/nppes/dedup-benchmark.d.ts +81 -0
  107. package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -0
  108. package/out/tools/{nppes-dedup-benchmark.js → nppes/dedup-benchmark.js} +21 -67
  109. package/out/tools/nppes/dedup-benchmark.js.map +1 -0
  110. package/out/tools/nppes/org-name.d.ts +5 -4
  111. package/out/tools/nppes/org-name.d.ts.map +1 -1
  112. package/out/tools/nppes/org-name.js +2 -2
  113. package/out/tools/nppes/org-name.js.map +1 -1
  114. package/out/tools/nppes/overmerge-packet.d.ts +15 -11
  115. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -1
  116. package/out/tools/nppes/overmerge-packet.js +7 -8
  117. package/out/tools/nppes/overmerge-packet.js.map +1 -1
  118. package/out/tools/nppes/report.d.ts +17 -13
  119. package/out/tools/nppes/report.d.ts.map +1 -1
  120. package/out/tools/nppes/report.js +6 -14
  121. package/out/tools/nppes/report.js.map +1 -1
  122. package/out/tools/nppes/sample.d.ts +28 -17
  123. package/out/tools/nppes/sample.d.ts.map +1 -1
  124. package/out/tools/nppes/sample.js +23 -26
  125. package/out/tools/nppes/sample.js.map +1 -1
  126. package/out/tools/nppes/scoring.d.ts +7 -6
  127. package/out/tools/nppes/scoring.d.ts.map +1 -1
  128. package/out/tools/nppes/scoring.js +6 -5
  129. package/out/tools/nppes/scoring.js.map +1 -1
  130. package/out/tools/nppes/settings.d.ts +10 -7
  131. package/out/tools/nppes/settings.d.ts.map +1 -1
  132. package/out/tools/nppes/settings.js +16 -16
  133. package/out/tools/nppes/settings.js.map +1 -1
  134. package/out/tools/nppes/truth-grains.d.ts +36 -23
  135. package/out/tools/nppes/truth-grains.d.ts.map +1 -1
  136. package/out/tools/nppes/truth-grains.js +36 -20
  137. package/out/tools/nppes/truth-grains.js.map +1 -1
  138. package/out/tools/shared.d.ts +63 -59
  139. package/out/tools/shared.d.ts.map +1 -1
  140. package/out/tools/shared.js +49 -66
  141. package/out/tools/shared.js.map +1 -1
  142. package/out/tools/train/cross-gbt.d.ts +88 -0
  143. package/out/tools/train/cross-gbt.d.ts.map +1 -0
  144. package/out/tools/{train-cross-gbt.js → train/cross-gbt.js} +15 -26
  145. package/out/tools/train/cross-gbt.js.map +1 -0
  146. package/out/tools/train/gbt.d.ts +85 -0
  147. package/out/tools/train/gbt.d.ts.map +1 -0
  148. package/out/tools/{train-gbt.js → train/gbt.js} +28 -32
  149. package/out/tools/train/gbt.js.map +1 -0
  150. package/out/tools/train/org-cross-gbt.d.ts +84 -0
  151. package/out/tools/train/org-cross-gbt.d.ts.map +1 -0
  152. package/out/tools/{train-org-cross-gbt.js → train/org-cross-gbt.js} +19 -23
  153. package/out/tools/train/org-cross-gbt.js.map +1 -0
  154. package/out/tools/txhhsc-to-oarow.d.ts +14 -9
  155. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  156. package/out/tools/txhhsc-to-oarow.js +16 -15
  157. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  158. package/out/tools/viz/browser.d.ts +6 -5
  159. package/out/tools/viz/browser.d.ts.map +1 -1
  160. package/out/tools/viz/browser.js +6 -5
  161. package/out/tools/viz/browser.js.map +1 -1
  162. package/out/tools/viz/cross-dataset-map.d.ts +7 -4
  163. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  164. package/out/tools/viz/cross-dataset-map.js +9 -6
  165. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  166. package/out/tools/viz/geocode-first-surface.d.ts +10 -5
  167. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  168. package/out/tools/viz/geocode-first-surface.js +16 -11
  169. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  170. package/out/tools/viz/{render-map.d.ts → render/map.d.ts} +6 -6
  171. package/out/tools/viz/render/map.d.ts.map +1 -0
  172. package/out/tools/viz/{render-map.js → render/map.js} +7 -6
  173. package/out/tools/viz/render/map.js.map +1 -0
  174. package/out/tools/viz/render.d.ts +12 -8
  175. package/out/tools/viz/render.d.ts.map +1 -1
  176. package/out/tools/viz/render.js +8 -7
  177. package/out/tools/viz/render.js.map +1 -1
  178. package/out/tools/viz/source-provenance-map.d.ts +19 -7
  179. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  180. package/out/tools/viz/source-provenance-map.js +11 -8
  181. package/out/tools/viz/source-provenance-map.js.map +1 -1
  182. package/out/tools/viz/yardstick-figure.d.ts +2 -21
  183. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  184. package/out/tools/viz/yardstick-figure.js +3 -39
  185. package/out/tools/viz/yardstick-figure.js.map +1 -1
  186. package/out/types.d.ts +17 -11
  187. package/out/types.d.ts.map +1 -1
  188. package/out/types.js +2 -2
  189. package/out/types.js.map +1 -1
  190. package/package.json +41 -184
  191. package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
  192. package/{lib/tools/cross-dataset-correlation.ts → tools/cross/dataset-correlation.ts} +31 -72
  193. package/{lib/tools/cross-source-threshold-sweep.ts → tools/cross/source-threshold-sweep.ts} +29 -46
  194. package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
  195. package/tools/eval-geocoder.ts +74 -0
  196. package/{lib/tools/geocoder-namesake-probe.ts → tools/geocoder/namesake-probe.ts} +9 -8
  197. package/{lib/tools/geocoder-vs-provided-coords.ts → tools/geocoder/vs-provided-coords.ts} +39 -30
  198. package/{lib/tools → tools}/gold-set-sample.ts +35 -29
  199. package/{lib/tools/learned-scorer-clustering-eval.ts → tools/learned/scorer/clustering-eval.ts} +49 -45
  200. package/{lib/tools/learned-scorer-crossstate-eval.ts → tools/learned/scorer/crossstate-eval.ts} +34 -30
  201. package/{lib/tools/learned-scorer-eval.ts → tools/learned/scorer/eval.ts} +35 -78
  202. package/{lib/tools → tools}/matcher-scale.ts +21 -33
  203. package/{lib/tools/nppes-dedup-benchmark.ts → tools/nppes/dedup-benchmark.ts} +37 -82
  204. package/{lib/tools → tools}/nppes/org-name.ts +5 -4
  205. package/{lib/tools → tools}/nppes/overmerge-packet.ts +17 -13
  206. package/{lib/tools → tools}/nppes/report.ts +32 -25
  207. package/{lib/tools → tools}/nppes/sample.ts +41 -36
  208. package/{lib/tools → tools}/nppes/scoring.ts +7 -6
  209. package/{lib/tools → tools}/nppes/settings.ts +16 -16
  210. package/{lib/tools → tools}/nppes/truth-grains.ts +46 -26
  211. package/{lib/tools → tools}/shared.ts +73 -83
  212. package/{lib/tools/train-cross-gbt.ts → tools/train/cross-gbt.ts} +38 -34
  213. package/{lib/tools/train-gbt.ts → tools/train/gbt.ts} +55 -41
  214. package/{lib/tools/train-org-cross-gbt.ts → tools/train/org-cross-gbt.ts} +39 -30
  215. package/{lib/tools → tools}/txhhsc-to-oarow.ts +24 -18
  216. package/{lib/tools → tools}/viz/browser.ts +6 -5
  217. package/{lib/tools → tools}/viz/cross-dataset-map.ts +15 -9
  218. package/{lib/tools → tools}/viz/geocode-first-surface.ts +28 -17
  219. package/{lib/tools/viz/render-map.ts → tools/viz/render/map.ts} +7 -6
  220. package/{lib/tools → tools}/viz/render.ts +16 -11
  221. package/{lib/tools → tools}/viz/source-provenance-map.ts +30 -15
  222. package/{lib/tools → tools}/viz/yardstick-figure.ts +6 -43
  223. package/lib/tools/eval-geocoder.ts +0 -67
  224. package/lib/tools/index.ts +0 -31
  225. package/out/tools/cross-dataset-correlation.d.ts +0 -65
  226. package/out/tools/cross-dataset-correlation.d.ts.map +0 -1
  227. package/out/tools/cross-dataset-correlation.js.map +0 -1
  228. package/out/tools/cross-source-threshold-sweep.d.ts +0 -66
  229. package/out/tools/cross-source-threshold-sweep.d.ts.map +0 -1
  230. package/out/tools/cross-source-threshold-sweep.js.map +0 -1
  231. package/out/tools/geocoder-namesake-probe.d.ts +0 -32
  232. package/out/tools/geocoder-namesake-probe.d.ts.map +0 -1
  233. package/out/tools/geocoder-namesake-probe.js.map +0 -1
  234. package/out/tools/geocoder-vs-provided-coords.d.ts +0 -50
  235. package/out/tools/geocoder-vs-provided-coords.d.ts.map +0 -1
  236. package/out/tools/geocoder-vs-provided-coords.js.map +0 -1
  237. package/out/tools/index.d.ts +0 -31
  238. package/out/tools/index.d.ts.map +0 -1
  239. package/out/tools/index.js +0 -31
  240. package/out/tools/index.js.map +0 -1
  241. package/out/tools/learned-scorer-clustering-eval.d.ts +0 -74
  242. package/out/tools/learned-scorer-clustering-eval.d.ts.map +0 -1
  243. package/out/tools/learned-scorer-clustering-eval.js.map +0 -1
  244. package/out/tools/learned-scorer-crossstate-eval.d.ts +0 -59
  245. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +0 -1
  246. package/out/tools/learned-scorer-crossstate-eval.js.map +0 -1
  247. package/out/tools/learned-scorer-eval.d.ts +0 -77
  248. package/out/tools/learned-scorer-eval.d.ts.map +0 -1
  249. package/out/tools/learned-scorer-eval.js.map +0 -1
  250. package/out/tools/nppes-dedup-benchmark.d.ts +0 -101
  251. package/out/tools/nppes-dedup-benchmark.d.ts.map +0 -1
  252. package/out/tools/nppes-dedup-benchmark.js.map +0 -1
  253. package/out/tools/train-cross-gbt.d.ts +0 -78
  254. package/out/tools/train-cross-gbt.d.ts.map +0 -1
  255. package/out/tools/train-cross-gbt.js.map +0 -1
  256. package/out/tools/train-gbt.d.ts +0 -69
  257. package/out/tools/train-gbt.d.ts.map +0 -1
  258. package/out/tools/train-gbt.js.map +0 -1
  259. package/out/tools/train-org-cross-gbt.d.ts +0 -71
  260. package/out/tools/train-org-cross-gbt.d.ts.map +0 -1
  261. package/out/tools/train-org-cross-gbt.js.map +0 -1
  262. package/out/tools/viz/render-map.d.ts.map +0 -1
  263. package/out/tools/viz/render-map.js.map +0 -1
@@ -2,21 +2,6 @@
2
2
  * @copyright Sister Software
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
- *
6
- * Cross-dataset correlation (#618) — the marquee proof: resolve ONE record set across datasets that
7
- * share NO key. NPPES (the national provider registry), FCC Rural Health Care filings, and TX
8
- * HHSC facility registries each describe overlapping physical entities under different names,
9
- * formats, and schemas. Geo-first blocking is what makes resolving them tractable.
10
- *
11
- * We ingest each source under its own {@link ColumnMapping} + a `source` provenance label into ONE
12
- * combined record set, geocode every address through mailwoman's real parser + resolver, resolve
13
- * to canonical entities, and report the entities whose members span ≥2 sources — those are the
14
- * cross-dataset links. We surface the correlation; interpretation is the consumer's.
15
- *
16
- * Tractable slice: TX-scoped, capped per source. Streams the 4.8 GB NPPES registry via `streamRows`.
17
- *
18
- * Run: `mailwoman registry scorer-eval cross-dataset [--cap 300] [--wof <admin.db>]
19
- * [--data-root <dir>] [--out-md docs/articles/evals/matcher-dedup/<date>-...md]`
20
5
  */
21
6
 
22
7
  import { dataRootPath } from "@mailwoman/core/data-root"
@@ -36,9 +21,6 @@ import {
36
21
  import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
37
22
  import { buildSpecs, norm, pct, stateOption, type SourceSpec } from "#tools/shared"
38
23
 
39
- /**
40
- * Distinct sources an entity needs to count toward the triple-corroborated tally.
41
- */
42
24
  const MIN_TRIPLE_SOURCES = 3
43
25
 
44
26
  /**
@@ -46,44 +28,49 @@ const MIN_TRIPLE_SOURCES = 3
46
28
  */
47
29
  export interface CrossDatasetCorrelationOptions {
48
30
  /**
49
- * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
31
+ * Creates the geocoder that resolves the sampled rows.
50
32
  */
51
33
  createGeocoder: EvalGeocoderFactory
34
+
52
35
  /**
53
- * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
36
+ * The record-matcher sources directory.
37
+ *
38
+ * It defaults to `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
54
39
  */
55
40
  sources?: string
41
+
56
42
  /**
57
- * Rows kept per source for geocoding (state-scoped). Default 300.
43
+ * The number of in-state rows sampled per source for geocoding.
44
+ * It defaults to 300.
58
45
  */
59
46
  cap?: number
47
+
60
48
  /**
61
- * State filter. Default TX.
49
+ * The state filter.
50
+ * It defaults to `TX`.
62
51
  */
63
52
  state?: string
53
+
64
54
  /**
65
- * The inverse-address-frequency change is a CORPUS statistic — it can't be synthesized from the geocoded sample. By
66
- * default we scan the FULL files (cheap, parse-free) for an in-state corpus-wide frequency table and feed it to the
67
- * matcher, so the proven #617 change actually bites on a sub-sampled run. The scan adds a full pass over the 4.8 GB
68
- * NPPES file (~5 min); `--no-corpus-frequency` skips it and falls back to resolveEntities' zero-config input-scoped
69
- * default (#86). Default true.
55
+ * Whether to scan every in-state row to build a corpus-wide address-frequency table.
56
+ * It defaults to true.
57
+ *
58
+ * The scan reads the full source files, including the multi-gigabyte NPPES file.
59
+ * When it is false, `resolveEntities` computes frequencies from the sample only.
70
60
  */
71
61
  corpusFrequency?: boolean
62
+
72
63
  /**
73
- * Also write the markdown report here.
64
+ * An optional path for the Markdown report.
74
65
  */
75
66
  outMd?: string
67
+
76
68
  /**
77
- * Also write the entity FeatureCollection here (the reconciliation artifact, QGIS-ready).
69
+ * An optional path for the entity GeoJSON FeatureCollection.
78
70
  */
79
71
  outGeojson?: string
80
72
  }
81
73
 
82
- /**
83
- * Compose a row's address for the corpus-wide frequency table. {@link ingestRows} joins the mapped address columns with
84
- * `", "` (the #694 flip) while this join uses a space — the two agree once `addressFrequencyKey` folds punctuation to
85
- * spaces, so a frequency key built here matches the geocoded record's `address.raw`.
86
- */
87
74
  function composeAddress(row: Record<string, string>, columns: string | string[] | undefined): string {
88
75
  if (!columns) return ""
89
76
  const list = Array.isArray(columns) ? columns : [columns]
@@ -95,11 +82,6 @@ function composeAddress(row: Record<string, string>, columns: string | string[]
95
82
  .trim()
96
83
  }
97
84
 
98
- /**
99
- * FCC RHC funding commitments — TWO addressable entities per row (a Filing HCP and a Participating HCP), each exploded
100
- * into its own record (the #618 B1 two-entity-per-row case). Composed after the shared {@link buildSpecs} trio, which
101
- * this probe correlates against.
102
- */
103
85
  const commitmentsSpec = (S: string, STATE: string): SourceSpec => ({
104
86
  source: "fcc-rhc-commitments",
105
87
  path: `${S}/fcc-rhc_commitments-disbursements_form462-466-466a_20260615.tsv`,
@@ -138,25 +120,24 @@ const commitmentsSpec = (S: string, STATE: string): SourceSpec => ({
138
120
  })
139
121
 
140
122
  /**
141
- * Cross-dataset correlation (#618) — see the module doc. Emits the markdown report to stdout.
123
+ * Geocodes a sample of each source dataset in one state, resolves the records into entities across sources.
124
+ * It returns a Markdown report of the cross-source links.
125
+ *
126
+ * Progress lines go to `report`.
127
+ * The function also writes the report and GeoJSON when `outMd` or `outGeojson` is set.
142
128
  */
143
129
  export async function crossDatasetCorrelation(
144
130
  options: CrossDatasetCorrelationOptions,
145
131
  report?: (line: string) => void
146
132
  ): Promise<{ markdown: string }> {
147
133
  const SOURCES = options.sources || dataRootPath("record-matcher", "sources")
148
- const CAP = options.cap ?? 300 // rows kept per source for geocoding (state-scoped)
134
+ const CAP = options.cap ?? 300
149
135
  const STATE = stateOption(options)
150
136
  const OUT_MD = options.outMd || ""
151
- const OUT_GEOJSON = options.outGeojson || "" // the reconciliation artifact (FeatureCollection, QGIS-ready)
137
+ const OUT_GEOJSON = options.outGeojson || ""
152
138
  const CORPUS_FREQ = options.corpusFrequency ?? true
153
139
  const SPECS = [...buildSpecs(`${SOURCES}`, STATE), commitmentsSpec(`${SOURCES}`, STATE)]
154
140
 
155
- // --- Phase A: stream each source, TX-filter, explode → keep the first CAP rows for geocoding AND
156
- // (when --corpus-frequency, the default) count EVERY in-state address into a corpus-wide table. The
157
- // sample is the matched set; the frequency table reflects the full TX population, so the proven
158
- // inverse-frequency change down-weights a genuinely-crowded shared campus even when it appears once in
159
- // the geocoded sample. ---
160
141
  const rawBySource = new Map<string, Record<string, string>[]>()
161
142
  const addrCounts = new Map<string, number>()
162
143
  let addrTotal = 0
@@ -186,7 +167,6 @@ export async function crossDatasetCorrelation(
186
167
  }
187
168
  }
188
169
 
189
- // Stop early only when we DON'T need the full frequency pass (otherwise scan to EOF).
190
170
  if (!CORPUS_FREQ && kept.length >= CAP) break
191
171
  }
192
172
 
@@ -194,7 +174,6 @@ export async function crossDatasetCorrelation(
194
174
  report?.(` ${spec.source}: ${kept.length} sampled`)
195
175
  }
196
176
 
197
- // The in-state corpus-wide address-frequency table (the #617 change, fed to the matcher below).
198
177
  const addressFrequency = CORPUS_FREQ
199
178
  ? {
200
179
  total: addrTotal,
@@ -207,14 +186,12 @@ export async function crossDatasetCorrelation(
207
186
  report?.(` address-frequency table: ${addrCounts.size} distinct over ${addrTotal} ${STATE} addresses`)
208
187
  }
209
188
 
210
- // --- Phase B: geocoder (injected — see ./eval-geocoder.ts). ---
211
189
  report?.("[B] building the geocoder…")
212
190
  const geocoder = await options.createGeocoder()
213
191
 
214
192
  let geo = 0
215
193
  let total = 0
216
194
 
217
- // Count placements at the boundary (parity with the retired in-script counter).
218
195
  const geocodeForIngest: GeocodeAddress = async (raw) => {
219
196
  const g = await geocoder.geocodeAddress(raw)
220
197
 
@@ -227,14 +204,12 @@ export async function crossDatasetCorrelation(
227
204
  return g
228
205
  }
229
206
 
230
- // --- Phase C: ingest each source (its own mapping + source label) into one combined record set. ---
231
207
  report?.("[C] geocoding + ingesting all sources…")
232
208
  const records: SourceRecord[] = []
233
209
 
234
210
  for (const spec of SPECS) {
235
211
  const rows = rawBySource.get(spec.source)!
236
- // Per-source geocode-rate snapshot (#694 diagnostic): the boundary counters are global, so delta
237
- // them across each source to see WHERE nulls concentrate in the aggregate run.
212
+
238
213
  const g0 = geo
239
214
  const t0 = total
240
215
  const recs = await ingestRows(rows, spec.mapping, { geocodeAddress: geocodeForIngest })
@@ -242,7 +217,6 @@ export async function crossDatasetCorrelation(
242
217
  const dt = total - t0
243
218
  report?.(` ${spec.source}: geocoded ${dg}/${dt} (${dt ? ((100 * dg) / dt).toFixed(1) : "0"}%)`)
244
219
 
245
- // Namespace ids by source so cross-source ids never collide.
246
220
  for (const r of recs) {
247
221
  r.id = `${spec.source}:${r.id}`
248
222
  }
@@ -253,24 +227,14 @@ export async function crossDatasetCorrelation(
253
227
  geocoder[Symbol.dispose]()
254
228
  report?.(` ${records.length} records; geocoded ${geo}/${total} (${((100 * geo) / total).toFixed(1)}%)`)
255
229
 
256
- // --- Phase D: resolve to canonical entities. The proven changes are default-on (#86): collapsed
257
- // spatial (A1) + inverse-address-frequency. We feed the corpus-wide table when we built one; otherwise
258
- // resolveEntities auto-computes the input-scoped default. ---
259
230
  report?.("[D] resolving across sources…")
260
231
 
261
- // learnedScorer:false — the GBT default is calibrated for same-dataset DEDUP, where "same address +
262
- // different name" means distinct co-located providers (reject). CROSS-dataset linkage is the opposite
263
- // objective: "same address + different name" is the prototypical signal of the SAME facility under a
264
- // different operational name across sources. The dedup GBT rejects exactly those true cross-source
265
- // links (measured: cross-source 219→166, triple-source 10→1), so this flow uses the recall-appropriate
266
- // FS baseline. (A cross-objective GBT threshold is the documented follow-up — #655.)
267
232
  const { entities, candidatePairs } = resolveEntities(records, {
268
233
  trainEM: true,
269
234
  learnedScorer: false,
270
235
  ...(addressFrequency ? { addressFrequency } : {}),
271
236
  })
272
237
 
273
- // --- Phase E: find the cross-source entities — members spanning ≥2 distinct sources. ---
274
238
  const sourceOf = (r: SourceRecord) => r.source ?? "?"
275
239
 
276
240
  const crossSource = entities
@@ -278,7 +242,6 @@ export async function crossDatasetCorrelation(
278
242
  .filter((x) => x.sources.size >= 2)
279
243
  .toSorted((a, b) => b.sources.size - a.sources.size || b.e.records.length - a.e.records.length)
280
244
 
281
- // Source-pair co-occurrence matrix.
282
245
  const pairCounts = new Map<string, number>()
283
246
 
284
247
  for (const { sources } of crossSource) {
@@ -292,7 +255,6 @@ export async function crossDatasetCorrelation(
292
255
  }
293
256
  }
294
257
 
295
- // --- Report. ---
296
258
  const lines: string[] = [
297
259
  `# Cross-dataset correlation (#618 / #87 real-data run)`,
298
260
  "",
@@ -389,8 +351,8 @@ export async function crossDatasetCorrelation(
389
351
  `${SPECS.length} datasets with no shared key — a provider registry, a federal funding program (two of its forms, ` +
390
352
  `the commitments form exploded into its Filing + Participating HCP per row), and a state facility registry — ` +
391
353
  `resolve into a single entity model where ${crossSource.length} entities are corroborated by ≥2 independent ` +
392
- `sources (${triple} by all three kinds), purely on geocoded location + name/org agreement, in pure Node (no ` +
393
- `Elasticsearch, no server). Each cross-source entity is a candidate "same place, multiple records" surfaced for ` +
354
+ `sources (${triple} by all three kinds), purely on geocoded location + name/org agreement, in pure Node without ` +
355
+ `Elasticsearch or a server. Each cross-source entity is a candidate "same place, multiple records" surfaced for ` +
394
356
  `review; whether a correlation means anything is the data consumer's call, not ours.`
395
357
  )
396
358
 
@@ -405,9 +367,6 @@ export async function crossDatasetCorrelation(
405
367
  report?.(`\n[written] ${OUT_MD}`)
406
368
  }
407
369
 
408
- // --- The reconciliation artifact: a GeoJSON FeatureCollection of every resolved entity. Each feature
409
- // carries `sources` + `sourceIDs` (so an analyst filters the cross-dataset links by `sources` length ≥ 2)
410
- // and the geocode tier. QGIS-ready; this is the operator-verifiable output of the matcher. ---
411
370
  if (OUT_GEOJSON) {
412
371
  const fc = toGeoJSON(entities)
413
372
  await writeLocalJSONFile(fc, OUT_GEOJSON)
@@ -3,25 +3,9 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * #655 measurement — can a RE-THRESHOLDED dedup GBT beat the FS baseline on the cross-SOURCE link
7
- * discovery objective? The dedup GBT (#603) is pinned OFF for cross-dataset flows because its
8
- * over-merge features (`spatial-exact × name/org-disagree`) push true "same facility, different
9
- * operational name across sources" pairs NEGATIVE — and the GBT logit REPLACES the FS weight, so
10
- * a threshold can't trivially separate them. This quantifies that.
11
- *
12
- * Geocode the three sources ONCE (NPPES + FCC-RHC + TX HHSC, TX-scoped), then resolve repeatedly:
13
- * the FS baseline (the recall-correct baseline) and the bundled GBT at a fine threshold sweep.
14
- * For each arm, report cross-source links (entities spanning ≥2 sources), triple-source entities,
15
- * total entities (an over-merge proxy — fewer = more collapsing), and a LABEL-FREE precision
16
- * proxy: PHONE corroboration — the fraction of cross-source entities in which two records from
17
- * DIFFERENT sources carry the same phone number (strong same-facility evidence the scorer didn't
18
- * directly use as the join key).
19
- *
20
- * Verdict logic: if some GBT threshold matches FS's cross-source link count at ≥ FS phone-corrob,
21
- * the threshold fix (option 1) works → ship a cross-source threshold. If matching FS link count
22
- * only comes with collapsing total entities and a LOWER phone-corrob (junk over-merges), the
23
- * threshold is insufficient by construction → FS stays pinned / a cross-objective retrain (#655
24
- * option 2) is the only change.
6
+ * Cross-source threshold sweep. Resolve the sources once, then compare the Fellegi-Sunter
7
+ * baseline against the bundled GBT over a fine threshold sweep, scoring each arm on cross-source
8
+ * links, triple-source entities, total entities and phone corroboration.
25
9
  *
26
10
  * Run: `mailwoman registry scorer-eval threshold-sweep [--cap 2000] [--state TX]
27
11
  * [--wof <admin.db>] [--data-root <dir>] [--out-md <md>]`
@@ -60,24 +44,33 @@ const MIN_CROSS_SOURCE_AGREEMENT = 3
60
44
  */
61
45
  export interface CrossSourceThresholdSweepOptions {
62
46
  /**
63
- * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
47
+ * The injected geocoder factory.
48
+ *
49
+ * The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
64
50
  */
65
51
  createGeocoder: EvalGeocoderFactory
66
52
  /**
67
- * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
53
+ * Record-matcher sources directory.
54
+ *
55
+ * Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
68
56
  */
69
57
  sources?: string
70
58
  /**
71
- * Rows kept per source. Default 2000.
59
+ * Rows kept per source.
60
+ *
61
+ * Default 2000.
72
62
  */
73
63
  cap?: number
74
64
  /**
75
- * State filter. Default TX.
65
+ * State filter.
66
+ *
67
+ * Default TX.
76
68
  */
77
69
  state?: string
78
70
  /**
79
- * #655 option 2: a trained CROSS-SOURCE GBT module (exports CROSS_SOURCE_GBT_MODEL + _META) to grade as a third arm
80
- * at its recommended threshold — the model `registry train-scorer cross-gbt` emits.
71
+ * A trained cross-source GBT module (exports CROSS_SOURCE_GBT_MODEL + _META) to
72
+ * grade as a third arm at its recommended threshold.
73
+ * This is the model `registry train-scorer cross-gbt` emits.
81
74
  */
82
75
  candidate?: string
83
76
  /**
@@ -86,17 +79,16 @@ export interface CrossSourceThresholdSweepOptions {
86
79
  outMd?: string
87
80
  }
88
81
 
89
- /**
90
- * Distinct provenance labels an entity's records span.
91
- */
92
82
  const entitySources = (e: ResolvedEntity): Set<string> =>
93
83
  new Set(e.records.map((r) => r.source).filter((s): s is string => !!s))
94
84
 
95
85
  /**
96
- * Label-free precision proxy: does this cross-source entity carry the SAME phone in records from two DIFFERENT sources?
97
- * (Phone isn't the join key, so a match is independent corroboration of same-facility.) Entities where no two
98
- * cross-source records both have a phone are "unknown" — we only count corroborated / contradicted among those that CAN
99
- * be checked.
86
+ * Label-free precision proxy: does this cross-source entity have the same phone
87
+ * in records from two different sources?
88
+ *
89
+ * Phone is not the join key, so a match is independent corroboration of one facility.
90
+ * Entities without phone numbers on two cross-source records are unknown.
91
+ * Only checkable entities count.
100
92
  */
101
93
  function phoneEvidence(e: ResolvedEntity): "corroborated" | "contradicted" | "unknown" {
102
94
  const bySource = new Map<string, Set<string>>()
@@ -185,7 +177,8 @@ async function measure(label: string, threshold: number | null, entities: Resolv
185
177
  }
186
178
 
187
179
  /**
188
- * #655 cross-source threshold sweep — see the module doc. Emits the markdown report to stdout.
180
+ * Compare the FS baseline against bundled GBT over a threshold sweep.
181
+ * Emit the markdown report to stdout.
189
182
  */
190
183
  export async function crossSourceThresholdSweep(
191
184
  options: CrossSourceThresholdSweepOptions,
@@ -198,7 +191,6 @@ export async function crossSourceThresholdSweep(
198
191
  const CANDIDATE = options.candidate || ""
199
192
  const SPECS = buildSpecs(`${SOURCES}`, STATE)
200
193
 
201
- // --- Ingest + geocode each source ONCE. ---
202
194
  const rawBySource = new Map<string, Record<string, string>[]>()
203
195
 
204
196
  for (const spec of SPECS) {
@@ -237,7 +229,6 @@ export async function crossSourceThresholdSweep(
237
229
  const geocoded = records.filter((r) => r.address?.geocode).length
238
230
  report?.(` ${records.length} records; geocoded ${geocoded}`)
239
231
 
240
- // --- The bundled GBT scorer over the input-scoped address-frequency basis (eval convention). ---
241
232
  const addrCounts = new Map<string, number>()
242
233
  let addrTotal = 0
243
234
 
@@ -257,7 +248,6 @@ export async function crossSourceThresholdSweep(
257
248
  const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons
258
249
  const gbtScorer = createGBTScorer({ model: DEDUP_GBT_MODEL, comparisons, addressFrequency })
259
250
 
260
- // --- Arm 1: the FS baseline (the recall-correct baseline cross-source flows currently pin). ---
261
251
  report?.("[D] resolving — FS baseline baseline…")
262
252
 
263
253
  const fs = await measure(
@@ -266,8 +256,6 @@ export async function crossSourceThresholdSweep(
266
256
  resolveEntities(records, { trainEM: true, collapseSpatial: true, addressFrequency, learnedScorer: false }).entities
267
257
  )
268
258
 
269
- // --- Arm 2: the bundled GBT at a fine threshold sweep (down well below the dedup 2.71, since
270
- // cross-source pairs sit at strongly NEGATIVE logits). ---
271
259
  const SWEEP = [-8, -6, -5, -4, -3, -2, -1, 0, 1, 2, DEDUP_GBT_META.recommendedThreshold]
272
260
  const gbtArms: ArmMetrics[] = []
273
261
 
@@ -284,12 +272,9 @@ export async function crossSourceThresholdSweep(
284
272
  gbtArms.push(await measure(`GBT @ ${t.toFixed(2)}`, t, entities))
285
273
  }
286
274
 
287
- // --- Verdict. The threshold fix WORKS only if some GBT arm dominates FS — more (or equal)
288
- // cross-source links at ≥ FS phone-corroboration WITHOUT over-merging (entity count must not
289
- // collapse below ~90% of FS, else the "links" are giant-blob artifacts). Otherwise FS is on the
290
- // frontier and threshold alone is insufficient. ---
275
+ // A GBT arm dominates only when it matches FS cross-source links at no lower phone corroboration and
276
+ // keeps at least 90% of FS entities, since a collapse means giant-blob artifacts rather than links.
291
277
  const pct = (n: number, d: number) => formatPercent(n, d, 0)
292
- // --- Arm 3 (#655 option 2): the cross-source-trained GBT at its own recommended threshold. ---
293
278
  const candidateArms: ArmMetrics[] = []
294
279
 
295
280
  if (CANDIDATE) {
@@ -334,13 +319,11 @@ export async function crossSourceThresholdSweep(
334
319
  (a) => a.crossSource >= fs.crossSource && rate(a) >= fsCorrobRate && a.entities >= minEntities
335
320
  )
336
321
 
337
- // The candidate (#655 option-2 models) gets its own verdict scan — the hardcoded option-1 verdict
338
- // below is about the DEDUP GBT and must not silently absorb (or ignore) a candidate arm.
322
+ // The candidate gets its own verdict scan, separate from the option-1 verdict for the dedup GBT.
339
323
  const candidateDominating = candidateArms.find(
340
324
  (a) => a.crossSource >= fs.crossSource && rate(a) >= fsCorrobRate && a.entities >= minEntities
341
325
  )
342
326
 
343
- // Best cross-source rate among arms that still retain enough entities to be meaningful.
344
327
  let candidateBest: ArmMetrics | null = null
345
328
 
346
329
  for (const arm of candidateArms) {
@@ -3,28 +3,16 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * #625 ceiling measurement — "how good is good enough" for dedup, derived from the data instead of
7
- * asserted as a round number (DeepSeek consult, issue #625). The residual dedup error is
8
- * OVER-MERGE: distinct co-located providers (different NPIs at one clinic/billing address) fused
9
- * because a shared address outvotes a disagreeing name. The irreducible part of that — the
10
- * **Bayes error** — is the set of co-located distinct-NPI pairs whose NAMES are also ~identical:
11
- * no name/org feature can separate them, so any address-aware matcher over-merges them. That
12
- * floor caps PRECISION.
6
+ * Dedup ceiling measurement, answering how good is good enough for dedup from the data rather
7
+ * than from a round number. The residual dedup error is over-merge: distinct co-located providers
8
+ * (different NPIs at one address) fused because a shared address outvotes a disagreeing name. The
9
+ * irreducible part is the set of co-located distinct-NPI pairs whose name text is also near
10
+ * identical, so no name or organization feature can separate them.
13
11
  *
14
- * This measures it directly and label-free, using NPI as the distinctness truth (different NPI =
15
- * different provider). Geocode-free on purpose: the question is the DATA's separability, not the
16
- * geocoder — so we can run at large N (tens of thousands of TX providers) in seconds. We key
17
- * "same address" with the matcher's own `addressFrequencyKey`, and "same name" with a normalized
18
- * token Jaccard over the legal business name.
19
- *
20
- * Reports, over co-located distinct-NPI pairs (the over-merge population):
21
- *
22
- * - Co-location prevalence (addresses hosting ≥2 distinct NPIs; providers at shared addresses)
23
- * - The org-name-similarity distribution of those pairs
24
- * - The COLLISION rate: fraction with org-sim ≥ τ (irreducible over-merge) — the precision floor
25
- * - Whether a shared phone would help (it doesn't: institutional switchboards) — among collisions,
26
- * how often the two distinct NPIs ALSO share a phone (so phone over-links, can't separate)
27
- * …and derives a precision/F1 CEILING under stated assumptions, with the caveats called out.
12
+ * This measures that floor directly and without labels, using NPI as the distinctness truth. It
13
+ * is geocode-free on purpose, so it can run at large N in seconds. "Same address" uses the
14
+ * matcher's own `addressFrequencyKey`, and "same name" uses a normalized token Jaccard over the
15
+ * legal business name.
28
16
  *
29
17
  * Run: `mailwoman registry dedup-ceiling [--cap 50000] [--state TX] [--sources <dir>] [--tau 0.7]
30
18
  * [--out-md <md>]`
@@ -47,19 +35,27 @@ const WEAK_SIMILARITY_MIN = 0.3
47
35
  */
48
36
  export interface DedupCeilingOptions {
49
37
  /**
50
- * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
38
+ * Record-matcher sources directory.
39
+ *
40
+ * Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
51
41
  */
52
42
  sources?: string
53
43
  /**
54
- * Providers sampled from the registry. Default 50000.
44
+ * Providers sampled from the registry.
45
+ *
46
+ * Default 50000.
55
47
  */
56
48
  cap?: number
57
49
  /**
58
- * State filter. Default TX.
50
+ * State filter.
51
+ *
52
+ * Default TX.
59
53
  */
60
54
  state?: string
61
55
  /**
62
- * Org-name Jaccard collision threshold. Default 0.7.
56
+ * Org-name Jaccard collision threshold.
57
+ *
58
+ * Default 0.7.
63
59
  */
64
60
  tau?: number
65
61
  /**
@@ -69,7 +65,8 @@ export interface DedupCeilingOptions {
69
65
  }
70
66
 
71
67
  /**
72
- * #625 ceiling measurement — see the module doc. Emits the markdown report to stdout.
68
+ * Measure the irreducible over-merge of co-located providers.
69
+ * Emit the markdown report to stdout.
73
70
  */
74
71
  export async function dedupCeiling(
75
72
  options: DedupCeilingOptions = {},
@@ -82,23 +79,19 @@ export async function dedupCeiling(
82
79
  const OUT_MD = options.outMd || ""
83
80
  const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
84
81
 
85
- // --- Stream TX type-2 (org) providers; one primary record per NPI at its practice address. ---
86
82
  report?.(`[A] streaming ${STATE} org providers (cap ${CAP})…`)
87
83
  const { byAddr, kept, scanned } = await scanColocatedProviders({ registryPath: REGISTRY, state: STATE, cap: CAP })
88
84
  report?.(` scanned ${scanned} rows → ${kept} ${STATE} org providers at ${byAddr.size} distinct addresses`)
89
85
 
90
- // --- Over co-located distinct-NPI pairs: the org-similarity distribution + collision rate. ---
91
86
  let sharedAddresses = 0
92
87
  let providersAtSharedAddr = 0
93
88
  let pairs = 0
94
- let collide = 0 // org-sim ≥ τ — name-indistinguishable co-located distinct NPIs
95
- let mid = 0 // τ > sim ≥ 0.3 — partially separable
96
- let separable = 0 // sim < 0.3 — clearly different names
97
- let collideSharePhone = 0 // of collisions, also share a phone (phone can't separate either)
98
- // Of the collisions, split NPI-over-segmentation (one org, many NPIs — merge is CORRECT) from
99
- // genuinely-distinct co-located providers (the TRUE irreducible over-merge):
100
- let collideSameAuth = 0 // share an authorized official ⇒ one org, multiple NPIs ⇒ correct to merge
101
- let collideDistinct = 0 // different official AND different specialty ⇒ genuinely different providers
89
+ let collide = 0
90
+ let mid = 0
91
+ let separable = 0
92
+ let collideSharePhone = 0
93
+ let collideSameAuth = 0
94
+ let collideDistinct = 0
102
95
  const PAIR_BUDGET = 5_000_000
103
96
 
104
97
  // guard against a pathological mega-address (PO-box farms)
@@ -140,14 +133,10 @@ export async function dedupCeiling(
140
133
  }
141
134
  }
142
135
 
143
- // --- Derive the precision ceiling. An address-aware matcher must, on co-located distinct-NPI
144
- // pairs, either merge (wrong) or hold them apart using name/org. It CAN separate the `separable`
145
- // (and most `mid`) pairs but NOT the `collide` ones. So the irreducible false-merge rate among
146
- // co-located distinct pairs is collide/pairs; an oracle's precision on the co-located decision is
147
- // bounded by how many merges it makes that are correct. We report the collision rate directly and
148
- // a precision-ceiling BAND (optimistic: only `collide` over-merge; conservative: `collide` + half
149
- // of `mid`). Recall is NOT the binding constraint here (NPPES same-NPI records almost always share
150
- // either address or org), so the F1 ceiling tracks the precision ceiling. ---
136
+ // The irreducible false-merge rate among co-located distinct pairs is collide/pairs.
137
+ // Report the collision rate directly with a precision-ceiling band: optimistic counts
138
+ // only `collide`, and conservative counts `collide` plus half of `mid`.
139
+ // Recall is not binding here, so the F1 ceiling tracks the precision ceiling.
151
140
  const pct = formatPercent
152
141
 
153
142
  const lines: string[] = [
@@ -208,7 +197,7 @@ export async function dedupCeiling(
208
197
  `Recommendation: drop 0.85. Set the bar against a subpart-aware / adjudicated entity truth, report NPI-level AND ` +
209
198
  `entity-level side by side, and target "separate the ~${pct(collideDistinct, pairs)} genuinely-distinct co-located ` +
210
199
  `pairs the GBT can still reach" rather than a round F1. The GBT's corroboration-feature work (#625 revised) ` +
211
- `attacks exactly that separable slice.`,
200
+ `attacks exactly that separable subset.`,
212
201
  "",
213
202
  `## Caveats`,
214
203
  "",
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
6
+ * The injected-geocoder interface for the record-matcher tools. The registry package never imports
7
+ * the heavy runtime (neural parser, WOF resolver, per-state extracts), since `mailwoman` depends on
8
+ * `@mailwoman/registry` and the reverse import would cycle the workspace graph. Each tool instead
9
+ * takes an {@linkcode EvalGeocoderFactory} the CLI command constructs from
10
+ * `mailwoman/geocode-core` (see `mailwoman/commands/registry/run.tsx`).
11
+ */
12
+
13
+ import type { ColumnMapping, GeocodeAddress, SourceRecord } from "#index"
14
+
15
+ /**
16
+ * The raw single-address geocode surface used by the probe tools, mirroring
17
+ * `mailwoman/geocode-core`'s wire shape.
18
+ */
19
+ export interface EvalGeocodeResult {
20
+ lat: number | null
21
+ lon: number | null
22
+ /**
23
+ * Wire key that mirrors `GeocodeResult.resolution_tier`.
24
+ */
25
+ resolution_tier?: string | null
26
+ }
27
+
28
+ /**
29
+ * A constructed geocoder: the matcher's ingest interface, the raw geocode and the handle release.
30
+ */
31
+ export interface EvalGeocoder extends Disposable {
32
+ /**
33
+ * The matcher's ingest interface (parse and geocode to `PostalAddress`),
34
+ * built through `geocodeAddressVia`.
35
+ */
36
+ geocodeAddress: GeocodeAddress
37
+ /**
38
+ * Raw single-address geocode returning lat, lon and resolution tier.
39
+ */
40
+ geocode: (address: string) => Promise<EvalGeocodeResult>
41
+ /**
42
+ * Release the DB handles (extracts + WOF lookup).
43
+ */
44
+ }
45
+
46
+ /**
47
+ * Per-construction toggles a tool may need to control (the command owns model/WOF/data-root wiring).
48
+ */
49
+ export interface EvalGeocoderInit {
50
+ /**
51
+ * All-caps case normalization.
52
+ *
53
+ * Default on.
54
+ * `nppes-benchmark --legacy-join` turns it off for the A/B.
55
+ */
56
+ normalizeCase?: boolean
57
+ }
58
+
59
+ /**
60
+ * Build a geocoder on demand.
61
+ *
62
+ * Tools construct it late and dispose it as soon as geocoding is done.
63
+ */
64
+ export type EvalGeocoderFactory = (init?: EvalGeocoderInit) => Promise<EvalGeocoder>
65
+
66
+ /**
67
+ * The threaded geocode surface (`mailwoman/geocode-stream` behind the interface)
68
+ * for `nppes-dedup-benchmark --parallel-geocode`.
69
+ * It yields enriched records in completion order.
70
+ */
71
+ export type EvalGeocodeStream = (
72
+ records: SourceRecord[],
73
+ opts: { mapping: ColumnMapping; concurrency: number }
74
+ ) => AsyncIterable<SourceRecord>