@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,36 +2,13 @@
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
  import { dataRootPath } from "@mailwoman/core/data-root";
22
7
  import { writeLocalFile, writeLocalJSONFile } from "@mailwoman/core/fs/writers";
23
8
  import { isPresent } from "@mailwoman/core/objects";
24
9
  import { addressFrequencyKey, ingestRows, repName, resolveEntities, streamRows, toGeoJSON, } from "#index";
25
10
  import { buildSpecs, norm, pct, stateOption } from "#tools/shared";
26
- /**
27
- * Distinct sources an entity needs to count toward the triple-corroborated tally.
28
- */
29
11
  const MIN_TRIPLE_SOURCES = 3;
30
- /**
31
- * Compose a row's address for the corpus-wide frequency table. {@link ingestRows} joins the mapped address columns with
32
- * `", "` (the #694 flip) while this join uses a space — the two agree once `addressFrequencyKey` folds punctuation to
33
- * spaces, so a frequency key built here matches the geocoded record's `address.raw`.
34
- */
35
12
  function composeAddress(row, columns) {
36
13
  if (!columns)
37
14
  return "";
@@ -42,11 +19,6 @@ function composeAddress(row, columns) {
42
19
  .join(" ")
43
20
  .trim();
44
21
  }
45
- /**
46
- * FCC RHC funding commitments — TWO addressable entities per row (a Filing HCP and a Participating HCP), each exploded
47
- * into its own record (the #618 B1 two-entity-per-row case). Composed after the shared {@link buildSpecs} trio, which
48
- * this probe correlates against.
49
- */
50
22
  const commitmentsSpec = (S, STATE) => ({
51
23
  source: "fcc-rhc-commitments",
52
24
  path: `${S}/fcc-rhc_commitments-disbursements_form462-466-466a_20260615.tsv`,
@@ -79,21 +51,20 @@ const commitmentsSpec = (S, STATE) => ({
79
51
  },
80
52
  });
81
53
  /**
82
- * Cross-dataset correlation (#618) — see the module doc. Emits the markdown report to stdout.
54
+ * Geocodes a sample of each source dataset in one state, resolves the records into entities across sources.
55
+ * It returns a Markdown report of the cross-source links.
56
+ *
57
+ * Progress lines go to `report`.
58
+ * The function also writes the report and GeoJSON when `outMd` or `outGeojson` is set.
83
59
  */
84
60
  export async function crossDatasetCorrelation(options, report) {
85
61
  const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
86
- const CAP = options.cap ?? 300; // rows kept per source for geocoding (state-scoped)
62
+ const CAP = options.cap ?? 300;
87
63
  const STATE = stateOption(options);
88
64
  const OUT_MD = options.outMd || "";
89
- const OUT_GEOJSON = options.outGeojson || ""; // the reconciliation artifact (FeatureCollection, QGIS-ready)
65
+ const OUT_GEOJSON = options.outGeojson || "";
90
66
  const CORPUS_FREQ = options.corpusFrequency ?? true;
91
67
  const SPECS = [...buildSpecs(`${SOURCES}`, STATE), commitmentsSpec(`${SOURCES}`, STATE)];
92
- // --- Phase A: stream each source, TX-filter, explode → keep the first CAP rows for geocoding AND
93
- // (when --corpus-frequency, the default) count EVERY in-state address into a corpus-wide table. The
94
- // sample is the matched set; the frequency table reflects the full TX population, so the proven
95
- // inverse-frequency change down-weights a genuinely-crowded shared campus even when it appears once in
96
- // the geocoded sample. ---
97
68
  const rawBySource = new Map();
98
69
  const addrCounts = new Map();
99
70
  let addrTotal = 0;
@@ -117,14 +88,12 @@ export async function crossDatasetCorrelation(options, report) {
117
88
  kept.push(e);
118
89
  }
119
90
  }
120
- // Stop early only when we DON'T need the full frequency pass (otherwise scan to EOF).
121
91
  if (!CORPUS_FREQ && kept.length >= CAP)
122
92
  break;
123
93
  }
124
94
  rawBySource.set(spec.source, kept);
125
95
  report?.(` ${spec.source}: ${kept.length} sampled`);
126
96
  }
127
- // The in-state corpus-wide address-frequency table (the #617 change, fed to the matcher below).
128
97
  const addressFrequency = CORPUS_FREQ
129
98
  ? {
130
99
  total: addrTotal,
@@ -135,12 +104,10 @@ export async function crossDatasetCorrelation(options, report) {
135
104
  if (CORPUS_FREQ) {
136
105
  report?.(` address-frequency table: ${addrCounts.size} distinct over ${addrTotal} ${STATE} addresses`);
137
106
  }
138
- // --- Phase B: geocoder (injected — see ./eval-geocoder.ts). ---
139
107
  report?.("[B] building the geocoder…");
140
108
  const geocoder = await options.createGeocoder();
141
109
  let geo = 0;
142
110
  let total = 0;
143
- // Count placements at the boundary (parity with the retired in-script counter).
144
111
  const geocodeForIngest = async (raw) => {
145
112
  const g = await geocoder.geocodeAddress(raw);
146
113
  total++;
@@ -149,20 +116,16 @@ export async function crossDatasetCorrelation(options, report) {
149
116
  }
150
117
  return g;
151
118
  };
152
- // --- Phase C: ingest each source (its own mapping + source label) into one combined record set. ---
153
119
  report?.("[C] geocoding + ingesting all sources…");
154
120
  const records = [];
155
121
  for (const spec of SPECS) {
156
122
  const rows = rawBySource.get(spec.source);
157
- // Per-source geocode-rate snapshot (#694 diagnostic): the boundary counters are global, so delta
158
- // them across each source to see WHERE nulls concentrate in the aggregate run.
159
123
  const g0 = geo;
160
124
  const t0 = total;
161
125
  const recs = await ingestRows(rows, spec.mapping, { geocodeAddress: geocodeForIngest });
162
126
  const dg = geo - g0;
163
127
  const dt = total - t0;
164
128
  report?.(` ${spec.source}: geocoded ${dg}/${dt} (${dt ? ((100 * dg) / dt).toFixed(1) : "0"}%)`);
165
- // Namespace ids by source so cross-source ids never collide.
166
129
  for (const r of recs) {
167
130
  r.id = `${spec.source}:${r.id}`;
168
131
  }
@@ -170,28 +133,17 @@ export async function crossDatasetCorrelation(options, report) {
170
133
  }
171
134
  geocoder[Symbol.dispose]();
172
135
  report?.(` ${records.length} records; geocoded ${geo}/${total} (${((100 * geo) / total).toFixed(1)}%)`);
173
- // --- Phase D: resolve to canonical entities. The proven changes are default-on (#86): collapsed
174
- // spatial (A1) + inverse-address-frequency. We feed the corpus-wide table when we built one; otherwise
175
- // resolveEntities auto-computes the input-scoped default. ---
176
136
  report?.("[D] resolving across sources…");
177
- // learnedScorer:false — the GBT default is calibrated for same-dataset DEDUP, where "same address +
178
- // different name" means distinct co-located providers (reject). CROSS-dataset linkage is the opposite
179
- // objective: "same address + different name" is the prototypical signal of the SAME facility under a
180
- // different operational name across sources. The dedup GBT rejects exactly those true cross-source
181
- // links (measured: cross-source 219→166, triple-source 10→1), so this flow uses the recall-appropriate
182
- // FS baseline. (A cross-objective GBT threshold is the documented follow-up — #655.)
183
137
  const { entities, candidatePairs } = resolveEntities(records, {
184
138
  trainEM: true,
185
139
  learnedScorer: false,
186
140
  ...(addressFrequency ? { addressFrequency } : {}),
187
141
  });
188
- // --- Phase E: find the cross-source entities — members spanning ≥2 distinct sources. ---
189
142
  const sourceOf = (r) => r.source ?? "?";
190
143
  const crossSource = entities
191
144
  .map((e) => ({ e, sources: new Set(e.records.map(sourceOf)) }))
192
145
  .filter((x) => x.sources.size >= 2)
193
146
  .toSorted((a, b) => b.sources.size - a.sources.size || b.e.records.length - a.e.records.length);
194
- // Source-pair co-occurrence matrix.
195
147
  const pairCounts = new Map();
196
148
  for (const { sources } of crossSource) {
197
149
  const list = [...sources].toSorted();
@@ -202,7 +154,6 @@ export async function crossDatasetCorrelation(options, report) {
202
154
  }
203
155
  }
204
156
  }
205
- // --- Report. ---
206
157
  const lines = [
207
158
  `# Cross-dataset correlation (#618 / #87 real-data run)`,
208
159
  "",
@@ -273,8 +224,8 @@ export async function crossDatasetCorrelation(options, report) {
273
224
  lines.push(`${SPECS.length} datasets with no shared key — a provider registry, a federal funding program (two of its forms, ` +
274
225
  `the commitments form exploded into its Filing + Participating HCP per row), and a state facility registry — ` +
275
226
  `resolve into a single entity model where ${crossSource.length} entities are corroborated by ≥2 independent ` +
276
- `sources (${triple} by all three kinds), purely on geocoded location + name/org agreement, in pure Node (no ` +
277
- `Elasticsearch, no server). Each cross-source entity is a candidate "same place, multiple records" surfaced for ` +
227
+ `sources (${triple} by all three kinds), purely on geocoded location + name/org agreement, in pure Node without ` +
228
+ `Elasticsearch or a server. Each cross-source entity is a candidate "same place, multiple records" surfaced for ` +
278
229
  `review; whether a correlation means anything is the data consumer's call, not ours.`);
279
230
  lines.push("");
280
231
  const md = lines.join("\n");
@@ -283,9 +234,6 @@ export async function crossDatasetCorrelation(options, report) {
283
234
  await writeLocalFile(md, OUT_MD);
284
235
  report?.(`\n[written] ${OUT_MD}`);
285
236
  }
286
- // --- The reconciliation artifact: a GeoJSON FeatureCollection of every resolved entity. Each feature
287
- // carries `sources` + `sourceIDs` (so an analyst filters the cross-dataset links by `sources` length ≥ 2)
288
- // and the geocode tier. QGIS-ready; this is the operator-verifiable output of the matcher. ---
289
237
  if (OUT_GEOJSON) {
290
238
  const fc = toGeoJSON(entities);
291
239
  await writeLocalJSONFile(fc, OUT_GEOJSON);
@@ -293,4 +241,4 @@ export async function crossDatasetCorrelation(options, report) {
293
241
  }
294
242
  return { markdown: md };
295
243
  }
296
- //# sourceMappingURL=cross-dataset-correlation.js.map
244
+ //# sourceMappingURL=dataset-correlation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataset-correlation.js","sourceRoot":"","sources":["../../../tools/cross/dataset-correlation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEnD,OAAO,EACN,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,eAAe,EACf,UAAU,EACV,SAAS,GAGT,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAA;AAEnF,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAkD5B,SAAS,cAAc,CAAC,GAA2B,EAAE,OAAsC;IAC1F,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAA;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,CAAC,MAAM,+CAA+C;QAC7G,YAAY,MAAM,+FAA+F;QACjH,iHAAiH;QACjH,qFAAqF,CACtF,CAAA;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAE3B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEf,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;QAChC,MAAM,EAAE,CAAC,eAAe,MAAM,EAAE,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QACjB,MAAM,EAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;QAC9B,MAAM,kBAAkB,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;QACzC,MAAM,EAAE,CAAC,aAAa,WAAW,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,qBAAqB,WAAW,CAAC,MAAM,gBAAgB,CAAC,CAAA;IAClH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AACxB,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ *
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.
9
+ *
10
+ * Run: `mailwoman registry scorer-eval threshold-sweep [--cap 2000] [--state TX]
11
+ * [--wof <admin.db>] [--data-root <dir>] [--out-md <md>]`
12
+ */
13
+ import type { EvalGeocoderFactory } from "#tools/eval-geocoder";
14
+ /**
15
+ * Options for {@linkcode crossSourceThresholdSweep}.
16
+ */
17
+ export interface CrossSourceThresholdSweepOptions {
18
+ /**
19
+ * The injected geocoder factory.
20
+ *
21
+ * The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
22
+ */
23
+ createGeocoder: EvalGeocoderFactory;
24
+ /**
25
+ * Record-matcher sources directory.
26
+ *
27
+ * Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
28
+ */
29
+ sources?: string;
30
+ /**
31
+ * Rows kept per source.
32
+ *
33
+ * Default 2000.
34
+ */
35
+ cap?: number;
36
+ /**
37
+ * State filter.
38
+ *
39
+ * Default TX.
40
+ */
41
+ state?: string;
42
+ /**
43
+ * A trained cross-source GBT module (exports CROSS_SOURCE_GBT_MODEL + _META) to
44
+ * grade as a third arm at its recommended threshold.
45
+ * This is the model `registry train-scorer cross-gbt` emits.
46
+ */
47
+ candidate?: string;
48
+ /**
49
+ * Also write the markdown report here.
50
+ */
51
+ outMd?: string;
52
+ }
53
+ /**
54
+ * Compare the FS baseline against bundled GBT over a threshold sweep.
55
+ * Emit the markdown report to stdout.
56
+ */
57
+ export declare function crossSourceThresholdSweep(options: CrossSourceThresholdSweepOptions, report?: (line: string) => void): Promise<{
58
+ markdown: string;
59
+ }>;
60
+ //# sourceMappingURL=source-threshold-sweep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-threshold-sweep.d.ts","sourceRoot":"","sources":["../../../tools/cross/source-threshold-sweep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsBH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAQ/D;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;;;OAIG;IACH,cAAc,EAAE,mBAAmB,CAAA;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAmGD;;;GAGG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,gCAAgC,EACzC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAsO/B"}
@@ -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>]`
@@ -45,15 +29,14 @@ import { buildSpecs, stateOption } from "#tools/shared";
45
29
  * Independent sources that must agree before a cluster counts as cross-source corroborated.
46
30
  */
47
31
  const MIN_CROSS_SOURCE_AGREEMENT = 3;
48
- /**
49
- * Distinct provenance labels an entity's records span.
50
- */
51
32
  const entitySources = (e) => new Set(e.records.map((r) => r.source).filter((s) => !!s));
52
33
  /**
53
- * Label-free precision proxy: does this cross-source entity carry the SAME phone in records from two DIFFERENT sources?
54
- * (Phone isn't the join key, so a match is independent corroboration of same-facility.) Entities where no two
55
- * cross-source records both have a phone are "unknown" — we only count corroborated / contradicted among those that CAN
56
- * be checked.
34
+ * Label-free precision proxy: does this cross-source entity have the same phone
35
+ * in records from two different sources?
36
+ *
37
+ * Phone is not the join key, so a match is independent corroboration of one facility.
38
+ * Entities without phone numbers on two cross-source records are unknown.
39
+ * Only checkable entities count.
57
40
  */
58
41
  function phoneEvidence(e) {
59
42
  const bySource = new Map();
@@ -117,7 +100,8 @@ async function measure(label, threshold, entities) {
117
100
  };
118
101
  }
119
102
  /**
120
- * #655 cross-source threshold sweep — see the module doc. Emits the markdown report to stdout.
103
+ * Compare the FS baseline against bundled GBT over a threshold sweep.
104
+ * Emit the markdown report to stdout.
121
105
  */
122
106
  export async function crossSourceThresholdSweep(options, report) {
123
107
  const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
@@ -126,7 +110,6 @@ export async function crossSourceThresholdSweep(options, report) {
126
110
  const OUT_MD = options.outMd || "";
127
111
  const CANDIDATE = options.candidate || "";
128
112
  const SPECS = buildSpecs(`${SOURCES}`, STATE);
129
- // --- Ingest + geocode each source ONCE. ---
130
113
  const rawBySource = new Map();
131
114
  for (const spec of SPECS) {
132
115
  report?.(`[A] ${spec.source}: streaming + ${STATE} filter (cap ${CAP})…`);
@@ -156,7 +139,6 @@ export async function crossSourceThresholdSweep(options, report) {
156
139
  geocoder[Symbol.dispose]();
157
140
  const geocoded = records.filter((r) => r.address?.geocode).length;
158
141
  report?.(` ${records.length} records; geocoded ${geocoded}`);
159
- // --- The bundled GBT scorer over the input-scoped address-frequency basis (eval convention). ---
160
142
  const addrCounts = new Map();
161
143
  let addrTotal = 0;
162
144
  for (const r of records) {
@@ -172,11 +154,8 @@ export async function crossSourceThresholdSweep(options, report) {
172
154
  };
173
155
  const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons;
174
156
  const gbtScorer = createGBTScorer({ model: DEDUP_GBT_MODEL, comparisons, addressFrequency });
175
- // --- Arm 1: the FS baseline (the recall-correct baseline cross-source flows currently pin). ---
176
157
  report?.("[D] resolving — FS baseline baseline…");
177
158
  const fs = await measure("FS baseline", 0, resolveEntities(records, { trainEM: true, collapseSpatial: true, addressFrequency, learnedScorer: false }).entities);
178
- // --- Arm 2: the bundled GBT at a fine threshold sweep (down well below the dedup 2.71, since
179
- // cross-source pairs sit at strongly NEGATIVE logits). ---
180
159
  const SWEEP = [-8, -6, -5, -4, -3, -2, -1, 0, 1, 2, DEDUP_GBT_META.recommendedThreshold];
181
160
  const gbtArms = [];
182
161
  for (const t of SWEEP) {
@@ -189,12 +168,9 @@ export async function crossSourceThresholdSweep(options, report) {
189
168
  });
190
169
  gbtArms.push(await measure(`GBT @ ${t.toFixed(2)}`, t, entities));
191
170
  }
192
- // --- Verdict. The threshold fix WORKS only if some GBT arm dominates FS — more (or equal)
193
- // cross-source links at ≥ FS phone-corroboration WITHOUT over-merging (entity count must not
194
- // collapse below ~90% of FS, else the "links" are giant-blob artifacts). Otherwise FS is on the
195
- // frontier and threshold alone is insufficient. ---
171
+ // A GBT arm dominates only when it matches FS cross-source links at no lower phone corroboration and
172
+ // keeps at least 90% of FS entities, since a collapse means giant-blob artifacts rather than links.
196
173
  const pct = (n, d) => formatPercent(n, d, 0);
197
- // --- Arm 3 (#655 option 2): the cross-source-trained GBT at its own recommended threshold. ---
198
174
  const candidateArms = [];
199
175
  if (CANDIDATE) {
200
176
  const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(resolvePath(CANDIDATE)).href)));
@@ -218,10 +194,8 @@ export async function crossSourceThresholdSweep(options, report) {
218
194
  const fsCorrobRate = rate(fs);
219
195
  const minEntities = Math.floor(fs.entities * 0.9);
220
196
  const dominating = gbtArms.find((a) => a.crossSource >= fs.crossSource && rate(a) >= fsCorrobRate && a.entities >= minEntities);
221
- // The candidate (#655 option-2 models) gets its own verdict scan — the hardcoded option-1 verdict
222
- // below is about the DEDUP GBT and must not silently absorb (or ignore) a candidate arm.
197
+ // The candidate gets its own verdict scan, separate from the option-1 verdict for the dedup GBT.
223
198
  const candidateDominating = candidateArms.find((a) => a.crossSource >= fs.crossSource && rate(a) >= fsCorrobRate && a.entities >= minEntities);
224
- // Best cross-source rate among arms that still retain enough entities to be meaningful.
225
199
  let candidateBest = null;
226
200
  for (const arm of candidateArms) {
227
201
  if (arm.entities >= minEntities && arm.crossSource > (candidateBest?.crossSource ?? -1)) {
@@ -287,4 +261,4 @@ export async function crossSourceThresholdSweep(options, report) {
287
261
  }
288
262
  return { markdown: md };
289
263
  }
290
- //# sourceMappingURL=cross-source-threshold-sweep.js.map
264
+ //# sourceMappingURL=source-threshold-sweep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-threshold-sweep.js","sourceRoot":"","sources":["../../../tools/cross/source-threshold-sweep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;;;;;;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,OAAO,EACN,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,e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W,EAAE,EAAE,CAAC,cAAc,CAAC,oEAAoE;YAC7G,GAAG,WAAW,yFAAyF;YACvG,mGAAmG;YACnG,iGAAiG;YACjG,sGAAsG;YACtG,uFAAuF,CACxF,CAAA;IACF,CAAC;SAAM,CAAC;QACP,KAAK,CAAC,IAAI,CACT,WAAW,UAAU,CAAC,SAAS,oBAAoB,UAAU,CAAC,WAAW,cAAc,EAAE,CAAC,WAAW,OAAO;YAC3G,GAAG,GAAG,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,cAAc,CAAC,qBAAqB,GAAG,CAAC,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK;YACzH,GAAG,UAAU,CAAC,QAAQ,iBAAiB,EAAE,CAAC,QAAQ,6DAA6D;YAC/G,eAAe,UAAU,CAAC,SAAS,GAAG,CACvC,CAAA;IACF,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAE3B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEf,IAAI,MAAM,EAAE,CAAC;QACZ,MAAM,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;QAChC,MAAM,EAAE,CAAC,aAAa,MAAM,EAAE,CAAC,CAAA;IAChC,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AACxB,CAAC"}
@@ -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>]`
@@ -34,19 +22,27 @@
34
22
  */
35
23
  export interface DedupCeilingOptions {
36
24
  /**
37
- * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
25
+ * Record-matcher sources directory.
26
+ *
27
+ * Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
38
28
  */
39
29
  sources?: string;
40
30
  /**
41
- * Providers sampled from the registry. Default 50000.
31
+ * Providers sampled from the registry.
32
+ *
33
+ * Default 50000.
42
34
  */
43
35
  cap?: number;
44
36
  /**
45
- * State filter. Default TX.
37
+ * State filter.
38
+ *
39
+ * Default TX.
46
40
  */
47
41
  state?: string;
48
42
  /**
49
- * Org-name Jaccard collision threshold. Default 0.7.
43
+ * Org-name Jaccard collision threshold.
44
+ *
45
+ * Default 0.7.
50
46
  */
51
47
  tau?: number;
52
48
  /**
@@ -55,7 +51,8 @@ export interface DedupCeilingOptions {
55
51
  outMd?: string;
56
52
  }
57
53
  /**
58
- * #625 ceiling measurement — see the module doc. Emits the markdown report to stdout.
54
+ * Measure the irreducible over-merge of co-located providers.
55
+ * Emit the markdown report to stdout.
59
56
  */
60
57
  export declare function dedupCeiling(options?: DedupCeilingOptions, report?: (line: string) => void): Promise<{
61
58
  markdown: string;
@@ -1 +1 @@
1
- {"version":3,"file":"dedup-ceiling.d.ts","sourceRoot":"","sources":["../../lib/tools/dedup-ceiling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAcH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAsB,YAAY,CACjC,OAAO,GAAE,mBAAwB,EACjC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA+J/D"}
1
+ {"version":3,"file":"dedup-ceiling.d.ts","sourceRoot":"","sources":["../../tools/dedup-ceiling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAcH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,wBAAsB,YAAY,CACjC,OAAO,GAAE,mBAAwB,EACjC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAuJ/D"}
@@ -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>]`
@@ -39,7 +27,8 @@ import { colocatedDistinctPairs, scanColocatedProviders, stateOption } from "#to
39
27
  */
40
28
  const WEAK_SIMILARITY_MIN = 0.3;
41
29
  /**
42
- * #625 ceiling measurement — see the module doc. Emits the markdown report to stdout.
30
+ * Measure the irreducible over-merge of co-located providers.
31
+ * Emit the markdown report to stdout.
43
32
  */
44
33
  export async function dedupCeiling(options = {}, report) {
45
34
  const SOURCES = options.sources || dataRootPath("record-matcher", "sources");
@@ -48,22 +37,18 @@ export async function dedupCeiling(options = {}, report) {
48
37
  const TAU = options.tau ?? 0.7;
49
38
  const OUT_MD = options.outMd || "";
50
39
  const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`;
51
- // --- Stream TX type-2 (org) providers; one primary record per NPI at its practice address. ---
52
40
  report?.(`[A] streaming ${STATE} org providers (cap ${CAP})…`);
53
41
  const { byAddr, kept, scanned } = await scanColocatedProviders({ registryPath: REGISTRY, state: STATE, cap: CAP });
54
42
  report?.(` scanned ${scanned} rows → ${kept} ${STATE} org providers at ${byAddr.size} distinct addresses`);
55
- // --- Over co-located distinct-NPI pairs: the org-similarity distribution + collision rate. ---
56
43
  let sharedAddresses = 0;
57
44
  let providersAtSharedAddr = 0;
58
45
  let pairs = 0;
59
- let collide = 0; // org-sim ≥ τ — name-indistinguishable co-located distinct NPIs
60
- let mid = 0; // τ > sim ≥ 0.3 — partially separable
61
- let separable = 0; // sim < 0.3 — clearly different names
62
- let collideSharePhone = 0; // of collisions, also share a phone (phone can't separate either)
63
- // Of the collisions, split NPI-over-segmentation (one org, many NPIs — merge is CORRECT) from
64
- // genuinely-distinct co-located providers (the TRUE irreducible over-merge):
65
- let collideSameAuth = 0; // share an authorized official ⇒ one org, multiple NPIs ⇒ correct to merge
66
- let collideDistinct = 0; // different official AND different specialty ⇒ genuinely different providers
46
+ let collide = 0;
47
+ let mid = 0;
48
+ let separable = 0;
49
+ let collideSharePhone = 0;
50
+ let collideSameAuth = 0;
51
+ let collideDistinct = 0;
67
52
  const PAIR_BUDGET = 5_000_000;
68
53
  // guard against a pathological mega-address (PO-box farms)
69
54
  let lastGroup = null;
@@ -98,14 +83,10 @@ export async function dedupCeiling(options = {}, report) {
98
83
  separable++;
99
84
  }
100
85
  }
101
- // --- Derive the precision ceiling. An address-aware matcher must, on co-located distinct-NPI
102
- // pairs, either merge (wrong) or hold them apart using name/org. It CAN separate the `separable`
103
- // (and most `mid`) pairs but NOT the `collide` ones. So the irreducible false-merge rate among
104
- // co-located distinct pairs is collide/pairs; an oracle's precision on the co-located decision is
105
- // bounded by how many merges it makes that are correct. We report the collision rate directly and
106
- // a precision-ceiling BAND (optimistic: only `collide` over-merge; conservative: `collide` + half
107
- // of `mid`). Recall is NOT the binding constraint here (NPPES same-NPI records almost always share
108
- // either address or org), so the F1 ceiling tracks the precision ceiling. ---
86
+ // The irreducible false-merge rate among co-located distinct pairs is collide/pairs.
87
+ // Report the collision rate directly with a precision-ceiling band: optimistic counts
88
+ // only `collide`, and conservative counts `collide` plus half of `mid`.
89
+ // Recall is not binding here, so the F1 ceiling tracks the precision ceiling.
109
90
  const pct = formatPercent;
110
91
  const lines = [
111
92
  `# #625 — dedup ceiling: the irreducible over-merge of co-located providers`,
@@ -165,7 +146,7 @@ export async function dedupCeiling(options = {}, report) {
165
146
  `Recommendation: drop 0.85. Set the bar against a subpart-aware / adjudicated entity truth, report NPI-level AND ` +
166
147
  `entity-level side by side, and target "separate the ~${pct(collideDistinct, pairs)} genuinely-distinct co-located ` +
167
148
  `pairs the GBT can still reach" rather than a round F1. The GBT's corroboration-feature work (#625 revised) ` +
168
- `attacks exactly that separable slice.`,
149
+ `attacks exactly that separable subset.`,
169
150
  "",
170
151
  `## Caveats`,
171
152
  "",