@mailwoman/registry 10.0.0 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +11 -14
  2. package/lib/address-key.ts +14 -10
  3. package/lib/geocode-handler.ts +7 -5
  4. package/lib/geojson.ts +13 -7
  5. package/lib/ingest.ts +70 -92
  6. package/lib/learned-scorer.ts +38 -44
  7. package/lib/map-html.ts +26 -72
  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 -54
  12. package/lib/resolve.ts +187 -130
  13. package/lib/types.ts +35 -29
  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 +7 -5
  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 -7
  25. package/out/geojson.js.map +1 -1
  26. package/out/ingest.d.ts +49 -76
  27. package/out/ingest.d.ts.map +1 -1
  28. package/out/ingest.js +37 -62
  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 +11 -64
  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 +36 -50
  51. package/out/reconcile.d.ts.map +1 -1
  52. package/out/reconcile.js +18 -42
  53. package/out/reconcile.js.map +1 -1
  54. package/out/resolve.d.ts +152 -91
  55. package/out/resolve.d.ts.map +1 -1
  56. package/out/resolve.js +67 -68
  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 +23 -27
  63. package/out/tools/cross/dataset-correlation.d.ts.map +1 -1
  64. package/out/tools/cross/dataset-correlation.js +9 -61
  65. package/out/tools/cross/dataset-correlation.js.map +1 -1
  66. package/out/tools/cross/source-threshold-sweep.d.ts +20 -26
  67. package/out/tools/cross/source-threshold-sweep.d.ts.map +1 -1
  68. package/out/tools/cross/source-threshold-sweep.js +14 -40
  69. package/out/tools/cross/source-threshold-sweep.js.map +1 -1
  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 +25 -16
  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 +9 -8
  79. package/out/tools/geocoder/namesake-probe.d.ts.map +1 -1
  80. package/out/tools/geocoder/namesake-probe.js +6 -7
  81. package/out/tools/geocoder/namesake-probe.js.map +1 -1
  82. package/out/tools/geocoder/vs-provided-coords.d.ts +18 -15
  83. package/out/tools/geocoder/vs-provided-coords.d.ts.map +1 -1
  84. package/out/tools/geocoder/vs-provided-coords.js +30 -27
  85. package/out/tools/geocoder/vs-provided-coords.js.map +1 -1
  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 +30 -27
  91. package/out/tools/learned/scorer/clustering-eval.d.ts.map +1 -1
  92. package/out/tools/learned/scorer/clustering-eval.js +28 -38
  93. package/out/tools/learned/scorer/clustering-eval.js.map +1 -1
  94. package/out/tools/learned/scorer/crossstate-eval.d.ts +24 -18
  95. package/out/tools/learned/scorer/crossstate-eval.d.ts.map +1 -1
  96. package/out/tools/learned/scorer/crossstate-eval.js +19 -25
  97. package/out/tools/learned/scorer/crossstate-eval.js.map +1 -1
  98. package/out/tools/learned/scorer/eval.d.ts +26 -39
  99. package/out/tools/learned/scorer/eval.d.ts.map +1 -1
  100. package/out/tools/learned/scorer/eval.js +11 -71
  101. package/out/tools/learned/scorer/eval.js.map +1 -1
  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 +22 -41
  107. package/out/tools/nppes/dedup-benchmark.d.ts.map +1 -1
  108. package/out/tools/nppes/dedup-benchmark.js +21 -67
  109. package/out/tools/nppes/dedup-benchmark.js.map +1 -1
  110. package/out/tools/nppes/org-name.d.ts +5 -11
  111. package/out/tools/nppes/org-name.d.ts.map +1 -1
  112. package/out/tools/nppes/org-name.js +2 -9
  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 +6 -7
  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 +29 -18
  123. package/out/tools/nppes/sample.d.ts.map +1 -1
  124. package/out/tools/nppes/sample.js +24 -28
  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 +68 -72
  139. package/out/tools/shared.d.ts.map +1 -1
  140. package/out/tools/shared.js +50 -67
  141. package/out/tools/shared.js.map +1 -1
  142. package/out/tools/train/cross-gbt.d.ts +37 -26
  143. package/out/tools/train/cross-gbt.d.ts.map +1 -1
  144. package/out/tools/train/cross-gbt.js +14 -25
  145. package/out/tools/train/cross-gbt.js.map +1 -1
  146. package/out/tools/train/gbt.d.ts +36 -20
  147. package/out/tools/train/gbt.d.ts.map +1 -1
  148. package/out/tools/train/gbt.js +27 -31
  149. package/out/tools/train/gbt.js.map +1 -1
  150. package/out/tools/train/org-cross-gbt.d.ts +38 -24
  151. package/out/tools/train/org-cross-gbt.d.ts.map +1 -1
  152. package/out/tools/train/org-cross-gbt.js +18 -22
  153. package/out/tools/train/org-cross-gbt.js.map +1 -1
  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 +11 -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 +5 -5
  171. package/out/tools/viz/render/map.d.ts.map +1 -1
  172. package/out/tools/viz/render/map.js +6 -5
  173. package/out/tools/viz/render/map.js.map +1 -1
  174. package/out/tools/viz/{render/index.d.ts → render.d.ts} +13 -9
  175. package/out/tools/viz/render.d.ts.map +1 -0
  176. package/out/tools/viz/{render/index.js → render.js} +9 -8
  177. package/out/tools/viz/render.js.map +1 -0
  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 +35 -29
  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 +42 -185
  191. package/{lib/tools → tools}/coverage-reconciliation.ts +27 -30
  192. package/{lib/tools → tools}/cross/dataset-correlation.ts +35 -73
  193. package/{lib/tools → tools}/cross/source-threshold-sweep.ts +29 -46
  194. package/{lib/tools → tools}/dedup-ceiling.ts +34 -45
  195. package/tools/eval-geocoder.ts +77 -0
  196. package/{lib/tools → tools}/geocoder/namesake-probe.ts +9 -8
  197. package/{lib/tools → tools}/geocoder/vs-provided-coords.ts +40 -31
  198. package/{lib/tools → tools}/gold-set-sample.ts +35 -29
  199. package/{lib/tools → tools}/learned/scorer/clustering-eval.ts +49 -45
  200. package/{lib/tools → tools}/learned/scorer/crossstate-eval.ts +34 -30
  201. package/{lib/tools → tools}/learned/scorer/eval.ts +39 -78
  202. package/{lib/tools → tools}/matcher-scale.ts +21 -33
  203. package/{lib/tools → tools}/nppes/dedup-benchmark.ts +39 -83
  204. package/tools/nppes/org-name.ts +15 -0
  205. package/{lib/tools → tools}/nppes/overmerge-packet.ts +16 -12
  206. package/{lib/tools → tools}/nppes/report.ts +32 -25
  207. package/{lib/tools → tools}/nppes/sample.ts +43 -38
  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 +79 -98
  212. package/{lib/tools → tools}/train/cross-gbt.ts +39 -34
  213. package/{lib/tools → tools}/train/gbt.ts +55 -41
  214. package/{lib/tools → tools}/train/org-cross-gbt.ts +40 -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 +29 -17
  219. package/{lib/tools → tools}/viz/render/map.ts +7 -6
  220. package/{lib/tools/viz/render/index.ts → 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/lib/tools/nppes/org-name.ts +0 -23
  226. package/out/tools/index.d.ts +0 -31
  227. package/out/tools/index.d.ts.map +0 -1
  228. package/out/tools/index.js +0 -31
  229. package/out/tools/index.js.map +0 -1
  230. package/out/tools/viz/render/index.d.ts.map +0 -1
  231. package/out/tools/viz/render/index.js.map +0 -1
@@ -3,26 +3,20 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Train the CROSS-SOURCE link scorer (#655 option 2 — unblocked 2026-07-06). The dedup GBT (#603)
7
- * is trained on within-NPPES labels, so its strongest feature (`spatial-exact × name-disagree`)
8
- * REJECTS the prototypical cross-source pair ("same provider, different operational text across
9
- * registries") — the reason the cross-dataset flows pin the FS baseline. The 2026-06-16
10
- * feasibility doc blocked a cross-source retrain on "no non-circular anchor"; the anchor exists:
11
- * **CMS Open Payments joins NPPES by NPI** — the same practitioner in two INDEPENDENT registries,
12
- * each with independently human-entered name + address. Same-NPI cross-source pairs are
13
- * ground-truth positives labeled by a key the matcher's features never see.
6
+ * Train the cross-source link scorer. The dedup GBT is trained on within-NPPES labels, so its
7
+ * strongest feature (`spatial-exact × name-disagree`) rejects the prototypical cross-source pair,
8
+ * the same provider under different operational text across registries.
9
+ * CMS Open Payments joins NPPES by NPI. That join provides ground-truth positive pairs labeled by a key the matcher never sees.
14
10
  *
15
- * Pipeline: assemble NPPES + Open Payments TX records for the same NPI population (Phases A/B
16
- * here), then the SHARED `trainCrossSourceModel` runs Phases C–F — geocode through the standard
17
- * ingest → block the UNION, keep only CROSS-source candidate pairs → the SHARED
18
- * `createMatchFeaturizer` (train ≡ inference) → label by NPI → held-out-NPI calibration (the #655
19
- * threshold rule: max recall subject to a pairwise-precision bar, reported alongside F1-max) →
20
- * train the shipped model on all pairs → emit `registry/models/crosssource-gbt-en-us.ts`.
11
+ * The pipeline assembles NPPES and Open Payments TX records for the same NPI population, then the
12
+ * shared `trainCrossSourceModel` geocodes through the standard ingest and blocks the union. It keeps only
13
+ * cross-source candidate pairs. It trains the shipped model into
14
+ * `registry/models/crosssource-gbt-en-us.ts`.
21
15
  *
22
16
  * Sources (both public domain, `.notes/data-sources.md`):
23
17
  *
24
- * - `nppes_npi-registry_*.tsv` — the practice-location + primary-name records.
25
- * - `openpayments_covered-recipient-profile_*.csv` — the OP profile supplement (NPI, profile
18
+ * - `nppes_npi-registry_*.tsv`: the practice-location and primary-name records.
19
+ * - `openpayments_covered-recipient-profile_*.csv`: the OP profile supplement (NPI, profile
26
20
  * first/last, profile practice address).
27
21
  *
28
22
  * Run: `mailwoman registry train-scorer cross-gbt [--state TX] [--npis 2000]
@@ -32,6 +26,7 @@
32
26
 
33
27
  import { dataRootPath } from "@mailwoman/core/data-root"
34
28
  import { isoDate } from "@mailwoman/core/utils"
29
+ import { resolvePath, type PathBuilderLike } from "path-ts"
35
30
 
36
31
  import { addressFrequencyKey, streamRows } from "#index"
37
32
  import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
@@ -42,59 +37,74 @@ import { addr, norm, NPPES_COLUMNS as N, stateOption, trainCrossSourceModel, typ
42
37
  */
43
38
  export interface TrainCrossSourceGBTOptions {
44
39
  /**
45
- * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
40
+ * The injected geocoder factory.
41
+ *
42
+ * The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
46
43
  */
47
44
  createGeocoder: EvalGeocoderFactory
48
45
  /**
49
- * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
46
+ * Record-matcher sources directory.
47
+ *
48
+ * @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
50
49
  */
51
- sources?: string
50
+ sources?: PathBuilderLike
52
51
  /**
53
- * State filter. Default TX.
52
+ * State filter.
53
+ *
54
+ * @defaultValue TX.
54
55
  */
55
56
  state?: string
56
57
  /**
57
- * NPIs sampled. Default 2000.
58
+ * NPIs sampled.
59
+ *
60
+ * @defaultValue `2000`
58
61
  */
59
62
  npis?: number
60
63
  /**
61
- * Output TS module path. Default `registry/models/crosssource-gbt-en-us.ts`.
64
+ * Output TS module path.
65
+ *
66
+ * @defaultValue `registry/models/crosssource-gbt-en-us.ts`
62
67
  */
63
68
  out?: string
64
69
  /**
65
- * Locale recorded in the model meta. Default en-US.
70
+ * Locale recorded in the model meta.
71
+ *
72
+ * @defaultValue `"en-US"`
66
73
  */
67
74
  locale?: string
68
75
  /**
69
- * #655 threshold rule: max cross-source recall subject to this held-out pairwise precision. Default 0.95.
76
+ * Max cross-source recall subject to this held-out pairwise precision.
77
+ *
78
+ * @defaultValue `0.95`
70
79
  */
71
80
  precisionBar?: number
72
81
  /**
73
- * Training date stamped into the meta. Default today.
82
+ * The training date stored in the metadata.
83
+ *
84
+ * @defaultValue today.
74
85
  */
75
86
  date?: string
76
87
  }
77
88
 
78
89
  /**
79
- * Train + emit the cross-source link GBT — see the module doc.
90
+ * Train and emit the cross-source link GBT.
80
91
  */
81
92
  export async function trainCrossSourceGBT(
82
93
  options: TrainCrossSourceGBTOptions,
83
94
  report?: (line: string) => void
84
95
  ): Promise<{ out: string; pairs: number; recommendedThreshold: number }> {
85
- const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"))
96
+ const SOURCES = resolvePath(options.sources ?? dataRootPath("record-matcher", "sources"))
86
97
  const STATE = stateOption(options)
87
98
  const NPIS = options.npis ?? 2000
88
99
  const OUT = options.out || "packages/registry/lib/models/crosssource-gbt-en-us.ts"
89
100
  const LOCALE = options.locale || "en-US"
90
- // #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
101
+ // Max cross-source recall subject to this held-out pairwise precision.
91
102
  const PRECISION_BAR = options.precisionBar ?? 0.95
92
103
  const TRAIN_DATE = options.date || isoDate()
93
104
 
94
105
  const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
95
106
  const OP_PROFILE = `${SOURCES}/openpayments_covered-recipient-profile_20260603.csv`
96
107
 
97
- // Build Open Payments practitioner records with NPI, profile name, and profile address.
98
108
  report?.(`[A] streaming the OP profile supplement (${STATE})…`)
99
109
  const opByNPI = new Map<string, CrossSourceRow>()
100
110
 
@@ -121,8 +131,6 @@ export async function trainCrossSourceGBT(
121
131
 
122
132
  report?.(` ${opByNPI.size} OP ${STATE} practitioners`)
123
133
 
124
- // Join the same NPPES NPIs with practice address, legal name, and corpus-wide
125
- // address-frequency table (one full registry pass, identical to train-gbt). ---
126
134
  report?.("[B] full registry pass: address-frequency table + the NPI-joined NPPES rows…")
127
135
  const rows: CrossSourceRow[] = []
128
136
  const joined = new Set<string>()
@@ -157,7 +165,6 @@ export async function trainCrossSourceGBT(
157
165
  rows.push({ npi, name, org: "", address: practice, source: "nppes" })
158
166
  }
159
167
 
160
- // Keep only NPIs present in BOTH sources — every record has a cross-source counterpart.
161
168
  for (const npi of joined) {
162
169
  rows.push(opByNPI.get(npi)!)
163
170
  }
@@ -170,8 +177,6 @@ export async function trainCrossSourceGBT(
170
177
 
171
178
  report?.(` ${joined.size} NPI-joined pairs → ${rows.length} records`)
172
179
 
173
- // Run the shared cross-source trainer: geocode, form pairs, calibrate, and train.
174
- // → shipped model → committed module). ---
175
180
  return trainCrossSourceModel({
176
181
  createGeocoder: options.createGeocoder,
177
182
  rows,
@@ -3,16 +3,14 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Train the production learned-scorer model (#603). Builds the SAME NPI-keyed record set the dedup
7
- * benchmark + the clustering A/B use (the SHARED `buildNPPESSample`: real registry + name-drift +
8
- * address-variation), geocodes it, blocks → candidate pairs, featurizes each pair with the SHARED
9
- * `createMatchFeaturizer` (so train ≡ inference), labels by held-out NPI, and fits the
10
- * gradient-boosted-tree model. Writes the model as a committed TS module
11
- * (`registry/models/dedup-gbt-en-us.ts`) that ships in the package.
6
+ * Trains the production learned-scorer model. `buildNPPESSample` creates the same NPI-keyed records used by
7
+ * the dedup benchmark and clustering A/B. The sample uses the real registry and includes name drift plus address variation.
8
+ * The trainer geocodes records and groups them into candidate pairs. It featurizes each pair with
9
+ * `createMatchFeaturizer`. It labels pairs by NPI and fits a gradient-boosted tree model.
10
+ * It writes the model to the committed package module `registry/models/dedup-gbt-en-us.ts`.
12
11
  *
13
- * Unlike the eval, this trains on ALL sampled NPIs (no held-out split) — the held-out F1 is the
14
- * eval's job; this produces the shipped artifact. The eval (`learned-scorer-clustering-eval.ts`)
15
- * then re-measures generalization against the FS baseline.
12
+ * Unlike the eval, this trains on all sampled NPIs with no held-out split, since the held-out F1
13
+ * is the eval's job.
16
14
  *
17
15
  * Run: `mailwoman registry train-scorer gbt [--state TX] [--npis 3000] [--wof <admin.db>]
18
16
  * [--data-root <dir>] [--out registry/models/dedup-gbt-en-us.ts]`
@@ -20,6 +18,7 @@
20
18
 
21
19
  import { dataRootPath } from "@mailwoman/core/data-root"
22
20
  import { makeDirectories, writeLocalFile } from "@mailwoman/core/fs/writers"
21
+ import { prettyJSON, stringifyJSON } from "@mailwoman/core/json"
23
22
  import { makeLcg } from "@mailwoman/core/random"
24
23
  import { isoDate } from "@mailwoman/core/utils"
25
24
  import { block, gbtScore, trainGBT } from "@mailwoman/match"
@@ -40,7 +39,8 @@ import { scoreEntities } from "#tools/nppes/scoring"
40
39
  import { stateOption, uniqueQuantiles } from "#tools/shared"
41
40
 
42
41
  /**
43
- * Share of entities assigned to fit; the rest are held out.
42
+ * Share of entities assigned to fit.
43
+ * The rest are held out.
44
44
  */
45
45
  const FIT_SPLIT_FRACTION = 0.8
46
46
 
@@ -49,43 +49,61 @@ const FIT_SPLIT_FRACTION = 0.8
49
49
  */
50
50
  export interface TrainDedupGBTOptions {
51
51
  /**
52
- * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
52
+ * The injected geocoder factory.
53
+ *
54
+ * The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
53
55
  */
54
56
  createGeocoder: EvalGeocoderFactory
55
57
  /**
56
- * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
58
+ * Record-matcher sources directory.
59
+ *
60
+ * @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
57
61
  */
58
62
  sources?: string
59
63
  /**
60
- * State filter. Default TX.
64
+ * State filter.
65
+ *
66
+ * @defaultValue TX.
61
67
  */
62
68
  state?: string
63
69
  /**
64
- * NPIs sampled. Default 3000.
70
+ * NPIs sampled.
71
+ *
72
+ * @defaultValue `3000`
65
73
  */
66
74
  npis?: number
67
75
  /**
68
- * Output TS module path. Default `registry/models/dedup-gbt-en-us.ts`.
76
+ * Output TS module path.
77
+ *
78
+ * @defaultValue `registry/models/dedup-gbt-en-us.ts`
69
79
  */
70
80
  out?: string
71
81
  /**
72
- * Locale recorded in the model meta (the command's factory loads the matching weights). Default en-US.
82
+ * Locale recorded in the model meta (the command's factory loads the matching weights).
83
+ *
84
+ * @defaultValue `"en-US"`
73
85
  */
74
86
  locale?: string
75
87
  /**
76
- * Cost-sensitive training (#625): up-weight the NEGATIVE (distinct-pair) class by this factor so the model is more
77
- * conservative about merging — directly trades recall for precision to reduce over-merge. 1 = the symmetric
78
- * class-balanced default; >1 penalizes a false merge more than a missed one.
88
+ * Cost-sensitive training: up-weight the negative (distinct-pair) class by this factor
89
+ * so the model is more conservative about merging.
90
+ *
91
+ * It trades recall for precision to reduce over-merge.
92
+ * `1` is the symmetric class-balanced default.
93
+ *
94
+ * A value above 1 penalizes a false merge more than a missed merge.
79
95
  */
80
96
  cost?: number
81
97
  /**
82
- * Training date stamped into the meta (overridable for reproducible commits). Default today.
98
+ * The training date stored in the metadata (overridable for reproducible commits).
99
+ *
100
+ * @defaultValue today.
83
101
  */
84
102
  date?: string
85
103
  }
86
104
 
87
105
  /**
88
- * Train + emit the production dedup GBT — see the module doc.
106
+ * Train and emit the production dedup GBT.
89
107
  */
90
108
  export async function trainDedupGBT(
91
109
  options: TrainDedupGBTOptions,
@@ -97,24 +115,22 @@ export async function trainDedupGBT(
97
115
  const OUT = options.out || "packages/registry/lib/models/dedup-gbt-en-us.ts"
98
116
  const LOCALE = options.locale || "en-US"
99
117
  const COST = options.cost ?? 1
100
- const TRAIN_DATE = options.date || isoDate() // overridable for reproducible commits
118
+ const TRAIN_DATE = options.date || isoDate()
101
119
 
102
120
  const REGISTRY = `${SOURCES}/nppes_npi-registry_20260607.tsv`
103
121
  const OTHER_NAMES = `${SOURCES}/nppes_other-names_20260607.tsv`
104
122
 
105
- // Build the variation-rich sample and corpus-wide address-frequency table.
106
- // sample builder — the same records the dedup benchmark and the learned-scorer evals see). ---
107
123
  const { rows, keptNpis, addressFrequency } = await buildNPPESSample(
108
124
  { registryPath: REGISTRY, otherNamesPath: OTHER_NAMES, state: STATE, maxNpis: NPIS },
109
125
  report
110
126
  )
111
127
 
112
- // Geocode and ingest records, carrying the NPI in record.id as the label.
113
- // injected (see ./eval-geocoder.ts) — the registry package never imports the runtime. ---
128
+ // The geocoder is injected, since the registry package never imports the runtime.
114
129
  report?.("[C] geocoding…")
115
130
  const geocoder = await options.createGeocoder()
116
131
 
117
- // mapping.id = "npi" → record.id IS the NPI label (multiple records share an NPI, the ground truth).
132
+ // `record.id` supplies the NPI label.
133
+ // Multiple records can share an NPI as ground truth.
118
134
  const mapping: ColumnMapping = {
119
135
  id: "npi",
120
136
  name: "name",
@@ -131,7 +147,6 @@ export async function trainDedupGBT(
131
147
  const geocoded = records.filter((r) => r.address?.geocode).length
132
148
  report?.(` ${records.length} records, ${geocoded} geocoded`)
133
149
 
134
- // Block records, generate shared features, then assign labels.
135
150
  report?.("[D] blocking + featurizing…")
136
151
  const comparisons = buildDefaultModel({ collapseSpatial: true, addressFrequency }).comparisons
137
152
  const featurize = createMatchFeaturizer({ comparisons, addressFrequency })
@@ -139,18 +154,18 @@ export async function trainDedupGBT(
139
154
  const X = pairs.map(([a, b]) => featurize(a, b))
140
155
  const Y = pairs.map(([a, b]) => (a.id === b.id ? 1 : 0))
141
156
  const posRate = Y.reduce<number>((s, v) => s + v, 0) / Math.max(1, Y.length)
142
- const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate * COST)) // class-balanced; COST up-weights negatives
157
+ const W = Y.map((y) => (y === 1 ? 1 - posRate : posRate * COST))
143
158
  const hyperparams = { rounds: 120, depth: 3, lr: 0.3, minLeaf: 20 }
144
159
 
145
160
  if (COST !== 1) {
146
161
  report?.(` cost-sensitive: negative class weighted ×${COST} (penalize over-merge)`)
147
162
  }
148
163
 
149
- // Calibrate the default link threshold; the GBT logit is not in FS-weight units.
150
- // trained with class-balanced weights, so logit 0 (the balanced boundary) ignores the ~1% match base
151
- // rate and over-merges. Split the NPIs 80/20, fit a calibration GBT on the 80%, and sweep the
152
- // CLUSTERING threshold on the held-out 20% (the metric resolveEntities actually optimizes) for F1-max.
153
- // The shipped full-data model has near-identical logit calibration, so the threshold transfers. ---
164
+ // Calibrate the default link threshold.
165
+ // The GBT logit uses no Fellegi-Sunter weight units.
166
+ // With class-balanced weights, logit 0 ignores the roughly 1% match base rate and over-merges.
167
+ // The threshold is swept on a held-out 20% of NPIs.
168
+ // The shipped full-data model has near-identical logit calibration, so the threshold transfers.
154
169
  report?.("[E] calibrating the default link threshold on a held-out NPI split…")
155
170
  const rnd = makeLcg(20_260_615)
156
171
  const split = new Map<string, "fit" | "holdout">()
@@ -196,13 +211,12 @@ export async function trainDedupGBT(
196
211
  ` recommended link threshold ${recommendedThreshold.toFixed(3)} (held-out clustering F1 ${(100 * bestF1).toFixed(1)}%)`
197
212
  )
198
213
 
199
- // Train the shipped model on every available pair.
200
214
  report?.("[F] training the shipped model on all pairs…")
201
215
  const model = trainGBT(X, Y, W, hyperparams)
202
216
  report?.(` ${pairs.length} pairs (${(100 * posRate).toFixed(1)}% positive), ${model.trees.length} trees`)
203
217
 
204
- // Emit the model as a committed TypeScript module with a prettier-stable literal.
205
- // retrain produces a clean one-line diff, not a thousand reformatted lines. ---
218
+ // Emit the model as a committed TypeScript module with a prettier-stable literal,
219
+ // so a retrain produces a clean one-line diff.
206
220
  const meta = {
207
221
  version: "1.0.0",
208
222
  locale: LOCALE,
@@ -212,9 +226,9 @@ export async function trainDedupGBT(
212
226
  records: records.length,
213
227
  pairs: pairs.length,
214
228
  posRate: Number(posRate.toFixed(4)),
215
- costNegative: COST, // cost-sensitive negative-class up-weight (1 = symmetric class-balanced)
229
+ costNegative: COST,
216
230
  hyperparams,
217
- recommendedThreshold: Number(recommendedThreshold.toFixed(4)), // F1-max link threshold (held-out); resolveEntities' default when learnedScorer is active
231
+ recommendedThreshold: Number(recommendedThreshold.toFixed(4)),
218
232
  features: X[0]?.length ?? 0,
219
233
  addressFrequencyDistinct: addressFrequency.distinct,
220
234
  addressFrequencyTotal: addressFrequency.total,
@@ -235,9 +249,9 @@ export async function trainDedupGBT(
235
249
  ` */\n\n` +
236
250
  `import type { GBT } from "@mailwoman/match"\n\n` +
237
251
  `/** Provenance for the bundled model — what it was trained on. */\n` +
238
- `export const DEDUP_GBT_META = ${JSON.stringify(meta, null, 2)} as const\n\n` +
252
+ `export const DEDUP_GBT_META = ${prettyJSON(meta)} as const\n\n` +
239
253
  `// prettier-ignore\n` +
240
- `export const DEDUP_GBT_MODEL: GBT = ${JSON.stringify(model)}\n`
254
+ `export const DEDUP_GBT_MODEL: GBT = ${stringifyJSON(model)}\n`
241
255
 
242
256
  await makeDirectories(dirname(OUT))
243
257
  await writeLocalFile(moduleSource, OUT)
@@ -3,24 +3,21 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Train the ORG-LEVEL cross-source link scorer (#655 follow-on, 2026-07-06). The practitioner
7
- * cross-source GBT does not transfer to organization records (its person-name features go dark),
8
- * so the org-level cross-dataset flows pin the FS baseline. The org anchor: **CMS Provider of
9
- * Services joins Care Compare by CCN** — the same facility in two separately-maintained CMS
10
- * systems (certification vs quality reporting), each with independently-entered name + address.
11
- * Measured drift across the national join (n≈5.4k): 12.2% name, 4.9% address — the rename /
12
- * system-vs-facility / acquisition class the org objective exists for.
6
+ * Train the organization-level cross-source link scorer. The practitioner cross-source GBT does
7
+ * not transfer to organization records because its person-name features go dark. The organization
8
+ * cross-dataset flows therefore pin the FS baseline. CMS Provider of Services joins Care Compare
9
+ * by CCN. Each system represents the same facility and maintains its name and address separately.
13
10
  *
14
- * Pipeline: national CCN join → one record per source per facility (Phases A/B here), then the
15
- * SHARED `trainCrossSourceModel` runs Phases C–F — geocode → block the UNION, keep only
16
- * CROSS-source pairs → the SHARED featurizer → label by CCN → held-out-CCN calibration (max
17
- * recall s.t. precision ≥ bar) → train on all pairs → emit
18
- * `registry/models/org-crosssource-gbt-en-us.ts`.
11
+ * The pipeline runs a national CCN join into one record per source per facility, then the shared
12
+ * `trainCrossSourceModel` geocodes the rows and blocks the union. It keeps cross-source pairs.
13
+ * It featurizes them with the shared featurizer and labels them by CCN.
14
+ * Calibration uses held-out CCNs.
15
+ * The function emits `registry/models/org-crosssource-gbt-en-us.ts`.
19
16
  *
20
17
  * Sources (both public domain, direct CSVs):
21
18
  *
22
- * - `cms-pos_hospital-other_*.csv` — Provider of Services (PRVDR_NUM, FAC_NAME, ST_ADR…).
23
- * - `cms-carecompare_hospital-general_*.csv` — Care Compare (Facility ID, Facility Name, Address…).
19
+ * - `cms-pos_hospital-other_*.csv`: Provider of Services (PRVDR_NUM, FAC_NAME, ST_ADR…).
20
+ * - `cms-carecompare_hospital-general_*.csv`: Care Compare (Facility ID, Facility Name, Address…).
24
21
  *
25
22
  * Run: `mailwoman registry train-scorer org-cross-gbt [--cap 6000] [--precision-bar 0.95]
26
23
  * [--wof <admin.db>] [--data-root <dir>] [--out registry/models/org-crosssource-gbt-en-us.ts]`
@@ -28,6 +25,7 @@
28
25
 
29
26
  import { dataRootPath } from "@mailwoman/core/data-root"
30
27
  import { isoDate } from "@mailwoman/core/utils"
28
+ import { resolvePath, type PathBuilderLike } from "path-ts"
31
29
 
32
30
  import { addressFrequencyKey, streamRows } from "#index"
33
31
  import type { EvalGeocoderFactory } from "#tools/eval-geocoder"
@@ -38,55 +36,70 @@ import { addr, norm, trainCrossSourceModel, type CrossSourceRow } from "#tools/s
38
36
  */
39
37
  export interface TrainOrgCrossSourceGBTOptions {
40
38
  /**
41
- * The injected geocoder factory (the command wires `mailwoman/geocode-core`; see `./eval-geocoder.ts`).
39
+ * The injected geocoder factory.
40
+ *
41
+ * The command wires `mailwoman/geocode-core`, as `./eval-geocoder.ts` does.
42
42
  */
43
43
  createGeocoder: EvalGeocoderFactory
44
44
  /**
45
- * Record-matcher sources directory. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources`.
45
+ * Record-matcher sources directory.
46
+ *
47
+ * @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources`
46
48
  */
47
- sources?: string
49
+ sources?: PathBuilderLike
48
50
  /**
49
- * Care Compare facilities sampled. Default 6000.
51
+ * Care Compare facilities sampled.
52
+ *
53
+ * @defaultValue `6000`
50
54
  */
51
55
  cap?: number
52
56
  /**
53
- * Output TS module path. Default `registry/models/org-crosssource-gbt-en-us.ts`.
57
+ * Output TS module path.
58
+ *
59
+ * @defaultValue `registry/models/org-crosssource-gbt-en-us.ts`
54
60
  */
55
61
  out?: string
56
62
  /**
57
- * Locale recorded in the model meta. Default en-US.
63
+ * Locale recorded in the model meta.
64
+ *
65
+ * @defaultValue `"en-US"`
58
66
  */
59
67
  locale?: string
60
68
  /**
61
- * #655 threshold rule: max cross-source recall subject to this held-out pairwise precision. Default 0.95.
69
+ * Max cross-source recall subject to this held-out pairwise precision.
70
+ *
71
+ * @defaultValue `0.95`
62
72
  */
63
73
  precisionBar?: number
64
74
  /**
65
- * Training date stamped into the meta. Default today.
75
+ * The training date stored in the metadata.
76
+ *
77
+ * @defaultValue today.
66
78
  */
67
79
  date?: string
68
80
  }
69
81
 
70
82
  /**
71
- * Train + emit the org-level cross-source link GBT — see the module doc. The CCN is the cross-system facility key; it
72
- * rides {@link CrossSourceRow.npi} → `record.id` as the held-out label.
83
+ * Train and emit the org-level cross-source link GBT.
84
+ *
85
+ * The CCN is the cross-system facility key.
86
+ * It is stored in {@link CrossSourceRow.npi} and copied to `record.id` as the held-out label.
73
87
  */
74
88
  export async function trainOrgCrossSourceGBT(
75
89
  options: TrainOrgCrossSourceGBTOptions,
76
90
  report?: (line: string) => void
77
91
  ): Promise<{ out: string; pairs: number; recommendedThreshold: number }> {
78
- const SOURCES = options.sources || String(dataRootPath("record-matcher", "sources"))
92
+ const SOURCES = resolvePath(options.sources ?? dataRootPath("record-matcher", "sources"))
79
93
  const CAP = options.cap ?? 6000
80
94
  const OUT = options.out || "packages/registry/lib/models/org-crosssource-gbt-en-us.ts"
81
95
  const LOCALE = options.locale || "en-US"
82
- // #655 threshold rule: max cross-source recall subject to this held-out pairwise precision.
96
+ // Max cross-source recall subject to this held-out pairwise precision.
83
97
  const PRECISION_BAR = options.precisionBar ?? 0.95
84
98
  const TRAIN_DATE = options.date || isoDate()
85
99
 
86
100
  const POS = `${SOURCES}/cms-pos_hospital-other_2026q1.csv`
87
101
  const CARE_COMPARE = `${SOURCES}/cms-carecompare_hospital-general_20260706.csv`
88
102
 
89
- // Build Care Compare facility records with facility ID, name, and address.
90
103
  report?.("[A] streaming Care Compare…")
91
104
  const ccByID = new Map<string, CrossSourceRow>()
92
105
 
@@ -102,7 +115,6 @@ export async function trainOrgCrossSourceGBT(
102
115
 
103
116
  report?.(` ${ccByID.size} Care Compare facilities`)
104
117
 
105
- // Join the same CCNs from POS with the corpus-wide address-frequency table.
106
118
  report?.("[B] streaming POS + building the frequency table…")
107
119
  const rows: CrossSourceRow[] = []
108
120
  const joined = new Set<string>()
@@ -141,8 +153,6 @@ export async function trainOrgCrossSourceGBT(
141
153
 
142
154
  report?.(` ${joined.size} CCN-joined facilities → ${rows.length} records`)
143
155
 
144
- // Run the shared cross-source trainer: geocode, form pairs, calibrate, and train.
145
- // → shipped model → committed module). ---
146
156
  return trainCrossSourceModel({
147
157
  createGeocoder: options.createGeocoder,
148
158
  rows,
@@ -3,12 +3,12 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * #619: convert the TX HHSC nursing-facilities source (which ships an authoritative `Geo Location`
7
- * = `lat,lon` per facility) into the OaRow JSONL the resolver eval consumes — so our geocoder can
8
- * be graded against the provided coordinates on real facility addresses (great-circle delta, tier
9
- * breakdown via `oa-resolver-eval --address-points`).
6
+ * Convert the TX hhsc nursing-facilities source into the OaRow jsonl the resolver eval consumes.
7
+ * The source ships an authoritative `Geo Location` = `lat,lon` per facility, so the geocoder is
8
+ * graded against the provided coordinates on real facility addresses. `oa-resolver-eval
9
+ * --address-points` reports a great-circle delta and a tier breakdown.
10
10
  *
11
- * Neutral scope: this measures GEOCODER ACCURACY on real public addresses; it makes no claim about
11
+ * Neutral scope: this measures geocoder accuracy on real public addresses and makes no claim about
12
12
  * the facilities themselves.
13
13
  *
14
14
  * Run: `mailwoman registry convert tx-hhsc [--src <tsv>] [--out /tmp/txhhsc-oarow.jsonl]`
@@ -17,6 +17,8 @@
17
17
  import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root"
18
18
  import { readLocalTextFile } from "@mailwoman/core/fs/readers"
19
19
  import { writeLocalTextFile } from "@mailwoman/core/fs/writers"
20
+ import { stringifyJSON } from "@mailwoman/core/json"
21
+ import type { PathBuilderLike } from "path-ts"
20
22
  import { TSVSpliterator } from "spliterator"
21
23
 
22
24
  import { inTXBBOX } from "#tools/shared"
@@ -26,11 +28,15 @@ import { inTXBBOX } from "#tools/shared"
26
28
  */
27
29
  export interface TXHHSCConvertOptions {
28
30
  /**
29
- * The TX HHSC nursing-facilities TSV. Default `$MAILWOMAN_DATA_ROOT/record-matcher/sources/…`.
31
+ * The TX hhsc nursing-facilities TSV.
32
+ *
33
+ * @defaultValue `$MAILWOMAN_DATA_ROOT/record-matcher/sources/…`
30
34
  */
31
- src?: string
35
+ src?: PathBuilderLike
32
36
  /**
33
- * Output OaRow JSONL path. Default `/tmp/txhhsc-oarow.jsonl`.
37
+ * Output OaRow jsonl path.
38
+ *
39
+ * @defaultValue `/tmp/txhhsc-oarow.jsonl`
34
40
  */
35
41
  out?: string
36
42
  }
@@ -38,20 +44,20 @@ export interface TXHHSCConvertOptions {
38
44
  const GEO = /^\s*(-?\d+\.\d+)\s*,\s*(-?\d+\.\d+)\s*$/
39
45
 
40
46
  /**
41
- * Convert the TX HHSC nursing-facilities TSV into OaRow JSONL for `oa-resolver-eval`.
47
+ * Convert the TX hhsc nursing-facilities TSV into OaRow jsonl for `oa-resolver-eval`.
42
48
  */
43
49
  export async function convertTXHHSC(
44
50
  options: TXHHSCConvertOptions = {},
45
51
  report?: (line: string) => void
46
52
  ): Promise<{ written: number; skipped: number; out: string }> {
47
- const src = options.src || String(dataRootPath("record-matcher", "sources", "txhhsc_nursing-facilities_20260611.tsv"))
53
+ const src = options.src ?? dataRootPath("record-matcher", "sources", "txhhsc_nursing-facilities_20260611.tsv")
48
54
  const out = options.out || tempRootPath("txhhsc-oarow.jsonl")
49
55
 
50
56
  const records: string[] = []
51
57
  let skipped = 0
52
58
 
53
- // Column indices, captured from the first non-blank row. `header: false` keeps that row in the stream so the
54
- // blank-row guard below applies to it too.
59
+ // Column indices come from the first non-blank row.
60
+ // `header: false` keeps that row in the stream, so the blank-row guard below applies to it.
55
61
  let cAddr = -1
56
62
  let cCity = -1
57
63
  let cZip = -1
@@ -59,7 +65,7 @@ export async function convertTXHHSC(
59
65
  let sawHeader = false
60
66
 
61
67
  for (const f of TSVSpliterator.from(await readLocalTextFile(src), { header: false })) {
62
- if (f.every((value) => !value.trim())) continue
68
+ if (f.every((value) => !value)) continue
63
69
 
64
70
  if (!sawHeader) {
65
71
  sawHeader = true
@@ -72,9 +78,9 @@ export async function convertTXHHSC(
72
78
  continue
73
79
  }
74
80
 
75
- const addr = (f[cAddr] ?? "").trim()
76
- const city = (f[cCity] ?? "").trim()
77
- const zip = (f[cZip] ?? "").trim()
81
+ const addr = f[cAddr] ?? ""
82
+ const city = f[cCity] ?? ""
83
+ const zip = f[cZip] ?? ""
78
84
  const m = GEO.exec(f[cGeo] ?? "")
79
85
 
80
86
  if (!addr || !city || !m) {
@@ -94,7 +100,7 @@ export async function convertTXHHSC(
94
100
  }
95
101
 
96
102
  records.push(
97
- JSON.stringify({
103
+ stringifyJSON({
98
104
  input: `${addr}, ${city}, TX ${zip}`,
99
105
  lat,
100
106
  lon,
@@ -105,7 +111,7 @@ export async function convertTXHHSC(
105
111
  )
106
112
  }
107
113
 
108
- await writeLocalTextFile(records.join("\n") + "\n", out)
114
+ await writeLocalTextFile(records, out)
109
115
  report?.(`wrote ${records.length} rows (skipped ${skipped}) → ${out}`)
110
116
 
111
117
  return { written: records.length, skipped, out }
@@ -3,9 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper,
7
- * not a command). The WebGL consumers (Plotly 3D, MapLibre) get no GPU in headless Chromium, so
8
- * the browser launches on ANGLE's SwiftShader software rasterizer (`--use-gl=angle
6
+ * The shared headless-Chromium harness behind the `registry viz` renderers (an internal helper rather than a command). The WebGL consumers (Plotly 3D, MapLibre) get no GPU in headless Chromium, so
7
+ * the browser launches on angle's SwiftShader software rasterizer (`--use-gl=angle
9
8
  * --use-angle=swiftshader --enable-unsafe-swiftshader`); each caller owns its own navigation +
10
9
  * wait strategy and screenshots inside the callback.
11
10
  *
@@ -24,8 +23,10 @@ export interface ChromiumPageOptions {
24
23
  }
25
24
 
26
25
  /**
27
- * Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`, collect console + page errors,
28
- * run `fn`, and dispose the browser. The callback owns navigation, waits, and the screenshot.
26
+ * Launch headless Chromium (SwiftShader WebGL), open one page at `deviceScaleFactor: 2`,
27
+ * collect console + page errors, run `fn`, and dispose the browser.
28
+ *
29
+ * The callback owns navigation, waits and the screenshot.
29
30
  */
30
31
  export async function withChromiumPage<T>(
31
32
  options: ChromiumPageOptions,