@mailwoman/registry 9.1.0 → 9.3.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 (228) hide show
  1. package/README.md +2 -2
  2. package/{address-key.ts → lib/address-key.ts} +1 -1
  3. package/{geocode-handler.ts → lib/geocode-handler.ts} +7 -7
  4. package/{geojson.ts → lib/geojson.ts} +12 -6
  5. package/{index.ts → lib/index.ts} +10 -10
  6. package/{ingest.ts → lib/ingest.ts} +77 -69
  7. package/{learned-scorer.ts → lib/learned-scorer.ts} +1 -1
  8. package/{map-html.ts → lib/map-html.ts} +10 -16
  9. package/{reconcile.ts → lib/reconcile.ts} +9 -24
  10. package/{resolve.ts → lib/resolve.ts} +31 -13
  11. package/{tools → lib/tools}/coverage-reconciliation.ts +13 -15
  12. package/{tools → lib/tools}/cross-dataset-correlation.ts +64 -139
  13. package/{tools → lib/tools}/cross-source-threshold-sweep.ts +21 -32
  14. package/{tools → lib/tools}/dedup-ceiling.ts +33 -144
  15. package/{tools → lib/tools}/eval-geocoder.ts +10 -11
  16. package/{tools → lib/tools}/geocoder-namesake-probe.ts +5 -12
  17. package/{tools → lib/tools}/geocoder-vs-provided-coords.ts +12 -11
  18. package/lib/tools/gold-set-sample.ts +141 -0
  19. package/lib/tools/index.ts +31 -0
  20. package/{tools → lib/tools}/learned-scorer-clustering-eval.ts +71 -260
  21. package/{tools → lib/tools}/learned-scorer-crossstate-eval.ts +62 -245
  22. package/{tools → lib/tools}/learned-scorer-eval.ts +64 -263
  23. package/{tools → lib/tools}/matcher-scale.ts +5 -5
  24. package/lib/tools/nppes/org-name.ts +23 -0
  25. package/lib/tools/nppes/overmerge-packet.ts +94 -0
  26. package/lib/tools/nppes/report.ts +373 -0
  27. package/lib/tools/nppes/sample.ts +245 -0
  28. package/lib/tools/nppes/scoring.ts +114 -0
  29. package/lib/tools/nppes/settings.ts +102 -0
  30. package/lib/tools/nppes/truth-grains.ts +161 -0
  31. package/lib/tools/nppes-dedup-benchmark.ts +408 -0
  32. package/lib/tools/shared.ts +763 -0
  33. package/lib/tools/train-cross-gbt.ts +209 -0
  34. package/{tools → lib/tools}/train-gbt.ts +38 -156
  35. package/lib/tools/train-org-cross-gbt.ts +179 -0
  36. package/{tools → lib/tools}/txhhsc-to-oarow.ts +10 -28
  37. package/lib/tools/viz/browser.ts +50 -0
  38. package/{tools → lib/tools}/viz/cross-dataset-map.ts +16 -39
  39. package/{tools → lib/tools}/viz/geocode-first-surface.ts +13 -39
  40. package/{tools → lib/tools}/viz/render-map.ts +10 -23
  41. package/lib/tools/viz/render.ts +98 -0
  42. package/{tools → lib/tools}/viz/source-provenance-map.ts +20 -39
  43. package/{tools → lib/tools}/viz/yardstick-figure.ts +6 -5
  44. package/{types.ts → lib/types.ts} +10 -1
  45. package/out/address-key.d.ts +1 -1
  46. package/out/address-key.d.ts.map +1 -1
  47. package/out/address-key.js.map +1 -1
  48. package/out/geocode-handler.d.ts +6 -6
  49. package/out/geocode-handler.d.ts.map +1 -1
  50. package/out/geocode-handler.js +6 -6
  51. package/out/geocode-handler.js.map +1 -1
  52. package/out/geojson.d.ts +7 -2
  53. package/out/geojson.d.ts.map +1 -1
  54. package/out/geojson.js +8 -5
  55. package/out/geojson.js.map +1 -1
  56. package/out/index.d.ts +10 -10
  57. package/out/index.d.ts.map +1 -1
  58. package/out/index.js +10 -10
  59. package/out/index.js.map +1 -1
  60. package/out/ingest.d.ts +64 -46
  61. package/out/ingest.d.ts.map +1 -1
  62. package/out/ingest.js +33 -46
  63. package/out/ingest.js.map +1 -1
  64. package/out/learned-scorer.d.ts +1 -1
  65. package/out/learned-scorer.d.ts.map +1 -1
  66. package/out/learned-scorer.js.map +1 -1
  67. package/out/map-html.d.ts +4 -4
  68. package/out/map-html.d.ts.map +1 -1
  69. package/out/map-html.js +6 -11
  70. package/out/map-html.js.map +1 -1
  71. package/out/models/crosssource-gbt-en-us.d.ts.map +1 -1
  72. package/out/models/crosssource-gbt-en-us.js.map +1 -1
  73. package/out/models/dedup-gbt-en-us.d.ts.map +1 -1
  74. package/out/models/dedup-gbt-en-us.js.map +1 -1
  75. package/out/models/org-crosssource-gbt-en-us.d.ts.map +1 -1
  76. package/out/models/org-crosssource-gbt-en-us.js.map +1 -1
  77. package/out/reconcile.d.ts +6 -1
  78. package/out/reconcile.d.ts.map +1 -1
  79. package/out/reconcile.js +7 -21
  80. package/out/reconcile.js.map +1 -1
  81. package/out/resolve.d.ts +19 -7
  82. package/out/resolve.d.ts.map +1 -1
  83. package/out/resolve.js +20 -6
  84. package/out/resolve.js.map +1 -1
  85. package/out/tools/coverage-reconciliation.d.ts +1 -1
  86. package/out/tools/coverage-reconciliation.d.ts.map +1 -1
  87. package/out/tools/coverage-reconciliation.js +12 -12
  88. package/out/tools/coverage-reconciliation.js.map +1 -1
  89. package/out/tools/cross-dataset-correlation.d.ts +4 -4
  90. package/out/tools/cross-dataset-correlation.d.ts.map +1 -1
  91. package/out/tools/cross-dataset-correlation.js +60 -111
  92. package/out/tools/cross-dataset-correlation.js.map +1 -1
  93. package/out/tools/cross-source-threshold-sweep.d.ts +2 -2
  94. package/out/tools/cross-source-threshold-sweep.d.ts.map +1 -1
  95. package/out/tools/cross-source-threshold-sweep.js +19 -27
  96. package/out/tools/cross-source-threshold-sweep.js.map +1 -1
  97. package/out/tools/dedup-ceiling.d.ts.map +1 -1
  98. package/out/tools/dedup-ceiling.js +36 -118
  99. package/out/tools/dedup-ceiling.js.map +1 -1
  100. package/out/tools/eval-geocoder.d.ts +9 -13
  101. package/out/tools/eval-geocoder.d.ts.map +1 -1
  102. package/out/tools/eval-geocoder.js +2 -2
  103. package/out/tools/eval-geocoder.js.map +1 -1
  104. package/out/tools/geocoder-namesake-probe.d.ts +2 -2
  105. package/out/tools/geocoder-namesake-probe.d.ts.map +1 -1
  106. package/out/tools/geocoder-namesake-probe.js +4 -8
  107. package/out/tools/geocoder-namesake-probe.js.map +1 -1
  108. package/out/tools/geocoder-vs-provided-coords.d.ts +1 -1
  109. package/out/tools/geocoder-vs-provided-coords.d.ts.map +1 -1
  110. package/out/tools/geocoder-vs-provided-coords.js +11 -9
  111. package/out/tools/geocoder-vs-provided-coords.js.map +1 -1
  112. package/out/tools/gold-set-sample.d.ts +5 -5
  113. package/out/tools/gold-set-sample.d.ts.map +1 -1
  114. package/out/tools/gold-set-sample.js +37 -121
  115. package/out/tools/gold-set-sample.js.map +1 -1
  116. package/out/tools/index.d.ts +24 -29
  117. package/out/tools/index.d.ts.map +1 -1
  118. package/out/tools/index.js +24 -29
  119. package/out/tools/index.js.map +1 -1
  120. package/out/tools/learned-scorer-clustering-eval.d.ts +1 -1
  121. package/out/tools/learned-scorer-clustering-eval.d.ts.map +1 -1
  122. package/out/tools/learned-scorer-clustering-eval.js +35 -170
  123. package/out/tools/learned-scorer-clustering-eval.js.map +1 -1
  124. package/out/tools/learned-scorer-crossstate-eval.d.ts +5 -5
  125. package/out/tools/learned-scorer-crossstate-eval.d.ts.map +1 -1
  126. package/out/tools/learned-scorer-crossstate-eval.js +44 -166
  127. package/out/tools/learned-scorer-crossstate-eval.js.map +1 -1
  128. package/out/tools/learned-scorer-eval.d.ts +1 -1
  129. package/out/tools/learned-scorer-eval.d.ts.map +1 -1
  130. package/out/tools/learned-scorer-eval.js +37 -173
  131. package/out/tools/learned-scorer-eval.js.map +1 -1
  132. package/out/tools/matcher-scale.d.ts.map +1 -1
  133. package/out/tools/matcher-scale.js +5 -5
  134. package/out/tools/matcher-scale.js.map +1 -1
  135. package/out/tools/nppes/org-name.d.ts +21 -0
  136. package/out/tools/nppes/org-name.d.ts.map +1 -0
  137. package/out/tools/nppes/org-name.js +13 -0
  138. package/out/tools/nppes/org-name.js.map +1 -0
  139. package/out/tools/nppes/overmerge-packet.d.ts +39 -0
  140. package/out/tools/nppes/overmerge-packet.d.ts.map +1 -0
  141. package/out/tools/nppes/overmerge-packet.js +55 -0
  142. package/out/tools/nppes/overmerge-packet.js.map +1 -0
  143. package/out/tools/nppes/report.d.ts +93 -0
  144. package/out/tools/nppes/report.d.ts.map +1 -0
  145. package/out/tools/nppes/report.js +186 -0
  146. package/out/tools/nppes/report.js.map +1 -0
  147. package/out/tools/nppes/sample.d.ts +90 -0
  148. package/out/tools/nppes/sample.d.ts.map +1 -0
  149. package/out/tools/nppes/sample.js +131 -0
  150. package/out/tools/nppes/sample.js.map +1 -0
  151. package/out/tools/nppes/scoring.d.ts +36 -0
  152. package/out/tools/nppes/scoring.d.ts.map +1 -0
  153. package/out/tools/nppes/scoring.js +80 -0
  154. package/out/tools/nppes/scoring.js.map +1 -0
  155. package/out/tools/nppes/settings.d.ts +38 -0
  156. package/out/tools/nppes/settings.d.ts.map +1 -0
  157. package/out/tools/nppes/settings.js +79 -0
  158. package/out/tools/nppes/settings.js.map +1 -0
  159. package/out/tools/nppes/truth-grains.d.ts +50 -0
  160. package/out/tools/nppes/truth-grains.d.ts.map +1 -0
  161. package/out/tools/nppes/truth-grains.js +123 -0
  162. package/out/tools/nppes/truth-grains.js.map +1 -0
  163. package/out/tools/nppes-dedup-benchmark.d.ts +7 -3
  164. package/out/tools/nppes-dedup-benchmark.d.ts.map +1 -1
  165. package/out/tools/nppes-dedup-benchmark.js +106 -673
  166. package/out/tools/nppes-dedup-benchmark.js.map +1 -1
  167. package/out/tools/shared.d.ts +244 -7
  168. package/out/tools/shared.d.ts.map +1 -1
  169. package/out/tools/shared.js +353 -21
  170. package/out/tools/shared.js.map +1 -1
  171. package/out/tools/train-cross-gbt.d.ts +7 -7
  172. package/out/tools/train-cross-gbt.d.ts.map +1 -1
  173. package/out/tools/train-cross-gbt.js +47 -145
  174. package/out/tools/train-cross-gbt.js.map +1 -1
  175. package/out/tools/train-gbt.d.ts +7 -7
  176. package/out/tools/train-gbt.d.ts.map +1 -1
  177. package/out/tools/train-gbt.js +31 -111
  178. package/out/tools/train-gbt.js.map +1 -1
  179. package/out/tools/train-org-cross-gbt.d.ts +7 -5
  180. package/out/tools/train-org-cross-gbt.d.ts.map +1 -1
  181. package/out/tools/train-org-cross-gbt.js +45 -141
  182. package/out/tools/train-org-cross-gbt.js.map +1 -1
  183. package/out/tools/txhhsc-to-oarow.d.ts +2 -2
  184. package/out/tools/txhhsc-to-oarow.d.ts.map +1 -1
  185. package/out/tools/txhhsc-to-oarow.js +9 -23
  186. package/out/tools/txhhsc-to-oarow.js.map +1 -1
  187. package/out/tools/viz/browser.d.ts +34 -0
  188. package/out/tools/viz/browser.d.ts.map +1 -0
  189. package/out/tools/viz/browser.js +33 -0
  190. package/out/tools/viz/browser.js.map +1 -0
  191. package/out/tools/viz/cross-dataset-map.d.ts +4 -25
  192. package/out/tools/viz/cross-dataset-map.d.ts.map +1 -1
  193. package/out/tools/viz/cross-dataset-map.js +12 -33
  194. package/out/tools/viz/cross-dataset-map.js.map +1 -1
  195. package/out/tools/viz/geocode-first-surface.d.ts +6 -35
  196. package/out/tools/viz/geocode-first-surface.d.ts.map +1 -1
  197. package/out/tools/viz/geocode-first-surface.js +10 -37
  198. package/out/tools/viz/geocode-first-surface.js.map +1 -1
  199. package/out/tools/viz/render-map.d.ts +3 -6
  200. package/out/tools/viz/render-map.d.ts.map +1 -1
  201. package/out/tools/viz/render-map.js +9 -19
  202. package/out/tools/viz/render-map.js.map +1 -1
  203. package/out/tools/viz/render.d.ts +4 -9
  204. package/out/tools/viz/render.d.ts.map +1 -1
  205. package/out/tools/viz/render.js +24 -39
  206. package/out/tools/viz/render.js.map +1 -1
  207. package/out/tools/viz/source-provenance-map.d.ts +4 -24
  208. package/out/tools/viz/source-provenance-map.d.ts.map +1 -1
  209. package/out/tools/viz/source-provenance-map.js +12 -32
  210. package/out/tools/viz/source-provenance-map.js.map +1 -1
  211. package/out/tools/viz/yardstick-figure.d.ts +2 -2
  212. package/out/tools/viz/yardstick-figure.d.ts.map +1 -1
  213. package/out/tools/viz/yardstick-figure.js +5 -4
  214. package/out/tools/viz/yardstick-figure.js.map +1 -1
  215. package/out/types.d.ts +11 -1
  216. package/out/types.d.ts.map +1 -1
  217. package/out/types.js.map +1 -1
  218. package/package.json +180 -11
  219. package/tools/gold-set-sample.ts +0 -252
  220. package/tools/index.ts +0 -36
  221. package/tools/nppes-dedup-benchmark.ts +0 -1180
  222. package/tools/shared.ts +0 -160
  223. package/tools/train-cross-gbt.ts +0 -358
  224. package/tools/train-org-cross-gbt.ts +0 -329
  225. package/tools/viz/render.ts +0 -113
  226. /package/{models → lib/models}/crosssource-gbt-en-us.ts +0 -0
  227. /package/{models → lib/models}/dedup-gbt-en-us.ts +0 -0
  228. /package/{models → lib/models}/org-crosssource-gbt-en-us.ts +0 -0
@@ -3,38 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The geocode-first decision surface — the headline concept figure for the record matcher.
7
- *
8
- * What a reader should walk away with: **geography is the primary key; string similarity only
9
- * refines within a place.** The figure makes that legible as a _landscape_. Two surfaces of
10
- * P(match) over the same record-pair space (string similarity × geographic distance), scored by
11
- * the SAME Fellegi-Sunter machinery, differing only in which evidence each model is allowed to
12
- * see:
13
- *
14
- * - **String-first** sees the name agreement only → its decision boundary is _vertical_: high string
15
- * similarity ⇒ match, at any distance. It fuses `Springfield General (IL)` with `Springfield
16
- * General (MA)` (identical name, ~1500 km apart) and still misses `123 Main St` ↔ `123 Main
17
- * Street Apt 2` when the strings drift.
18
- * - **Geocode-first** also sees the distance agreement → its boundary _bends with geography_: near
19
- * the same coordinate a modest name match suffices; far apart, even an exact name is
20
- * rejected. It gets both traps right.
21
- *
22
- * Honesty notes (so the figure can't mislead):
23
- *
24
- * - The per-level weights are the REAL Bayes factors from the codebase — `NAME_LEVELS`
25
- * (`registry/resolve.ts`) and `DEFAULT_DISTANCE_LEVELS` (`match/distance.ts`). Geography
26
- * simply carries the heaviest evidence: ±9.45 bits at the same-building grain vs ±6.32 for an
27
- * exact name.
28
- * - The PRIOR is illustrative (λ shown in the caption), not production's λ=1e-4. Production is even
29
- * more conservative and leans on additional corroboration (phone, the spatial exact-key) that
30
- * this two-axis slice deliberately omits — the point here is the _shape of the boundary_, not
31
- * a reproduction of a production score. The caption says so.
32
- *
33
- * Emits a self-contained Plotly HTML (twin 3D landscapes + an annotated 2D contour). Render to PNG
34
- * with `renderPlotlyHTMLToPNG` (`./render.ts` — Playwright + swiftshader for headless WebGL).
35
- *
36
- * Run: `mailwoman registry viz geocode-first-surface [--lambda 0.02]
37
- * [--out-html /tmp/geocode-first-surface.html]`
6
+ * Plot string-only and string-plus-distance match probabilities using the record matcher's
7
+ * Fellegi-Sunter weights. The supplied prior is illustrative and the output is self-contained HTML.
38
8
  */
39
9
  /**
40
10
  * Options for {@linkcode geocodeFirstSurface}.
@@ -42,7 +12,8 @@
42
12
  export interface GeocodeFirstSurfaceOptions {
43
13
  /**
44
14
  * Illustrative prior λ. Production's record matcher uses λ=1e-4 (calibrated for the full multi-field model with phone
45
- * + spatial exact-key); here we want the boundary visible in a two-axis slice. Default 0.02.
15
+ *
16
+ * - Spatial exact-key); here we want the boundary visible in a two-axis slice. Default 0.02.
46
17
  */
47
18
  lambda?: number;
48
19
  /**
@@ -53,7 +24,7 @@ export interface GeocodeFirstSurfaceOptions {
53
24
  /**
54
25
  * Emit the geocode-first decision-surface Plotly HTML — see the module doc.
55
26
  */
56
- export declare function geocodeFirstSurface(options?: GeocodeFirstSurfaceOptions, report?: (line: string) => void): {
27
+ export declare function geocodeFirstSurface(options?: GeocodeFirstSurfaceOptions, report?: (line: string) => void): Promise<{
57
28
  outHTML: string;
58
- };
29
+ }>;
59
30
  //# sourceMappingURL=geocode-first-surface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geocode-first-surface.d.ts","sourceRoot":"","sources":["../../../tools/viz/geocode-first-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAuDD;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,GAAE,0BAA+B,EACxC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CA2MrB"}
1
+ {"version":3,"file":"geocode-first-surface.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/geocode-first-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB;AAuDD;;GAEG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,GAAE,0BAA+B,EACxC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA6M9B"}
@@ -3,40 +3,11 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The geocode-first decision surface — the headline concept figure for the record matcher.
7
- *
8
- * What a reader should walk away with: **geography is the primary key; string similarity only
9
- * refines within a place.** The figure makes that legible as a _landscape_. Two surfaces of
10
- * P(match) over the same record-pair space (string similarity × geographic distance), scored by
11
- * the SAME Fellegi-Sunter machinery, differing only in which evidence each model is allowed to
12
- * see:
13
- *
14
- * - **String-first** sees the name agreement only → its decision boundary is _vertical_: high string
15
- * similarity ⇒ match, at any distance. It fuses `Springfield General (IL)` with `Springfield
16
- * General (MA)` (identical name, ~1500 km apart) and still misses `123 Main St` ↔ `123 Main
17
- * Street Apt 2` when the strings drift.
18
- * - **Geocode-first** also sees the distance agreement → its boundary _bends with geography_: near
19
- * the same coordinate a modest name match suffices; far apart, even an exact name is
20
- * rejected. It gets both traps right.
21
- *
22
- * Honesty notes (so the figure can't mislead):
23
- *
24
- * - The per-level weights are the REAL Bayes factors from the codebase — `NAME_LEVELS`
25
- * (`registry/resolve.ts`) and `DEFAULT_DISTANCE_LEVELS` (`match/distance.ts`). Geography
26
- * simply carries the heaviest evidence: ±9.45 bits at the same-building grain vs ±6.32 for an
27
- * exact name.
28
- * - The PRIOR is illustrative (λ shown in the caption), not production's λ=1e-4. Production is even
29
- * more conservative and leans on additional corroboration (phone, the spatial exact-key) that
30
- * this two-axis slice deliberately omits — the point here is the _shape of the boundary_, not
31
- * a reproduction of a production score. The caption says so.
32
- *
33
- * Emits a self-contained Plotly HTML (twin 3D landscapes + an annotated 2D contour). Render to PNG
34
- * with `renderPlotlyHTMLToPNG` (`./render.ts` — Playwright + swiftshader for headless WebGL).
35
- *
36
- * Run: `mailwoman registry viz geocode-first-surface [--lambda 0.02]
37
- * [--out-html /tmp/geocode-first-surface.html]`
6
+ * Plot string-only and string-plus-distance match probabilities using the record matcher's
7
+ * Fellegi-Sunter weights. The supplied prior is illustrative and the output is self-contained HTML.
38
8
  */
39
- import { writeFileSync } from "node:fs";
9
+ import { tempRootPath } from "@mailwoman/core/data-root";
10
+ import { writeLocalFile } from "@mailwoman/core/fs/writers";
40
11
  /**
41
12
  * Registry/resolve.ts → NAME_LEVELS.
42
13
  */
@@ -79,9 +50,9 @@ function distanceWeight(km) {
79
50
  /**
80
51
  * Emit the geocode-first decision-surface Plotly HTML — see the module doc.
81
52
  */
82
- export function geocodeFirstSurface(options = {}, report) {
53
+ export async function geocodeFirstSurface(options = {}, report) {
83
54
  const LAMBDA = options.lambda ?? 0.02;
84
- const OUT_HTML = options.outHTML || "/tmp/geocode-first-surface.html";
55
+ const OUT_HTML = options.outHTML || tempRootPath("geocode-first-surface.html");
85
56
  const PRIOR = priorWeight(LAMBDA);
86
57
  /**
87
58
  * String-first model: name evidence only — distance is invisible to it.
@@ -141,7 +112,9 @@ export function geocodeFirstSurface(options = {}, report) {
141
112
  lambda: LAMBDA,
142
113
  prior: PRIOR,
143
114
  };
144
- const safe = JSON.stringify(data).replaceAll(/<\/script>/gi, "<\\/script>");
115
+ // EVERY `<`, not only `</script>`: `<!--` also leaves script-data state in the HTML tokenizer, after which a
116
+ // later `</script>` no longer ends the element. `\u003c` is the same string to a JSON reader.
117
+ const safe = JSON.stringify(data).replaceAll("<", "\\u003c");
145
118
  const html = `<!doctype html><html><head><meta charset="utf-8"/>
146
119
  <script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
147
120
  <style>
@@ -245,7 +218,7 @@ document.getElementByID("cap").innerHTML =
245
218
  "Trap ② string-first="+fmt(D.traps[1].stringP)+" (reject ✗) · geocode-first="+fmt(D.traps[1].geoP)+" (MATCH ✓).";
246
219
  </script>
247
220
  </body></html>`;
248
- writeFileSync(OUT_HTML, html);
221
+ await writeLocalFile(html, OUT_HTML);
249
222
  report?.(`[written] ${OUT_HTML}`);
250
223
  report?.(`λ=${LAMBDA} prior=${PRIOR.toFixed(2)} bits`);
251
224
  for (const t of trapRows) {
@@ -1 +1 @@
1
- {"version":3,"file":"geocode-first-surface.js","sourceRoot":"","sources":["../../../tools/viz/geocode-first-surface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AA4BvC;;GAEG;AACH,MAAM,WAAW,GAAY;IAC5B,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE;IACrD,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE;IACxD,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE;CAC1D,C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I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4ED,CAAA;IAEd,MAAM,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACpC,MAAM,EAAE,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAA;IACjC,MAAM,EAAE,CAAC,KAAK,MAAM,WAAW,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAEvD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC1B,MAAM,EAAE,CACP,KAAK,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CACxJ,CAAA;IACF,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAA;AAC7B,CAAC"}
@@ -9,18 +9,15 @@
9
9
  *
10
10
  * Two house-stack constraints make this fiddlier than the Plotly/SVG renderers:
11
11
  *
12
- * - MapLibre needs a real WebGL context → ANGLE's SwiftShader software rasterizer (the same flags the
13
- * 3D Plotly render uses).
14
- * - The basemap tiles come from `tiles.sister.software`, which CORS-restricts to localhost + the docs
12
+ * - MapLibre needs a real WebGL context — the shared harness (`./browser.ts`) provides one through
13
+ * SwiftShader.
14
+ * - The basemap tiles come from `tiles.mailwoman.ai`, which CORS-restricts to localhost + the docs
15
15
  * domains — so the page MUST be SERVED OVER LOCALHOST, not opened as a file (a file:// page
16
16
  * renders accurate markers on a blank basemap). Serve the output dir first, e.g. `python3 -m
17
17
  * http.server 8899 -d <dir>`, then point this at `http://localhost:8899/<page>.html`.
18
18
  *
19
19
  * The map paints asynchronously after the network settles; we wait for networkidle, then a fixed
20
20
  * beat for the basemap tiles + marker layer to finish compositing.
21
- *
22
- * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
23
- * fn (the corpus-tools lazy-import convention).
24
21
  */
25
22
  /**
26
23
  * Options for {@linkcode renderServedMapToPNG}.
@@ -1 +1 @@
1
- {"version":3,"file":"render-map.d.ts","sourceRoot":"","sources":["../../../tools/viz/render-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA2BtD"}
1
+ {"version":3,"file":"render-map.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/render-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAetD"}
@@ -9,37 +9,27 @@
9
9
  *
10
10
  * Two house-stack constraints make this fiddlier than the Plotly/SVG renderers:
11
11
  *
12
- * - MapLibre needs a real WebGL context → ANGLE's SwiftShader software rasterizer (the same flags the
13
- * 3D Plotly render uses).
14
- * - The basemap tiles come from `tiles.sister.software`, which CORS-restricts to localhost + the docs
12
+ * - MapLibre needs a real WebGL context — the shared harness (`./browser.ts`) provides one through
13
+ * SwiftShader.
14
+ * - The basemap tiles come from `tiles.mailwoman.ai`, which CORS-restricts to localhost + the docs
15
15
  * domains — so the page MUST be SERVED OVER LOCALHOST, not opened as a file (a file:// page
16
16
  * renders accurate markers on a blank basemap). Serve the output dir first, e.g. `python3 -m
17
17
  * http.server 8899 -d <dir>`, then point this at `http://localhost:8899/<page>.html`.
18
18
  *
19
19
  * The map paints asynchronously after the network settles; we wait for networkidle, then a fixed
20
20
  * beat for the basemap tiles + marker layer to finish compositing.
21
- *
22
- * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
23
- * fn (the corpus-tools lazy-import convention).
24
21
  */
22
+ import { withChromiumPage } from "#tools/viz/browser";
25
23
  /**
26
24
  * Screenshot a served MapLibre map page once the tiles + marker layer settle.
27
25
  */
28
26
  export async function renderServedMapToPNG(options, report) {
29
- // playwright + Chromium are heavy — lazy import (the pipeline convention).
30
- const { chromium } = await import("playwright");
31
- const browser = await chromium.launch({
32
- args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
27
+ const { consoleErrors: errors } = await withChromiumPage({ viewport: { width: 1100, height: 760 } }, async (page) => {
28
+ await page.goto(options.url, { waitUntil: "networkidle", timeout: 30_000 });
29
+ // MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
30
+ await page.waitForTimeout(4000);
31
+ await page.screenshot({ path: options.outPNG });
33
32
  });
34
- const page = await browser.newPage({ viewport: { width: 1100, height: 760 }, deviceScaleFactor: 2 });
35
- const errors = [];
36
- page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
37
- page.on("pageerror", (e) => errors.push(String(e)));
38
- await page.goto(options.url, { waitUntil: "networkidle", timeout: 30_000 });
39
- // MapLibre composites tiles + the marker layer async after the network settles; give it a beat.
40
- await page.waitForTimeout(4000);
41
- await page.screenshot({ path: options.outPNG });
42
- await browser.close();
43
33
  report?.(`[map-render] ${options.outPNG}; console errors=${errors.length}`);
44
34
  for (const e of errors.slice(0, 6)) {
45
35
  report?.(" " + e);
@@ -1 +1 @@
1
- {"version":3,"file":"render-map.js","sourceRoot":"","sources":["../../../tools/viz/render-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAgBH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACzC,OAAyB,EACzB,MAA+B;IAE/B,2EAA2E;IAC3E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAA;IAE/C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACrC,IAAI,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,wBAAwB,CAAC;KAC5G,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAA;IAEpG,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACxE,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEnD,MAAM,IAA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AAgG;QAChG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAC/B,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,MAAM,EAAE,CAAC,gBAAgB,OAAO,CAAC,MAAM,oBAAoB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;IAE3E,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;QACpC,MAAM,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA;IACnB,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AACzD,CAAC"}
@@ -6,15 +6,10 @@
6
6
  * Render a self-contained Plotly HTML to a PNG via headless Chromium — the shared renderer behind
7
7
  * the `registry viz` figures (an internal helper, not a command).
8
8
  *
9
- * Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context; headless Chromium has none by
10
- * default, so we force ANGLE's SwiftShader software rasterizer (`--use-gl=angle
11
- * --use-angle=swiftshader --enable-unsafe-swiftshader`). 2D traces (`contour`/`heatmap`) render
12
- * on the 2D canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div
13
- * rather than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
14
- *
15
- * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
16
- * fn (the corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never
17
- * pays for it.
9
+ * Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context, which the shared harness
10
+ * (`./browser.ts`) provides through SwiftShader; 2D traces (`contour`/`heatmap`) render on the 2D
11
+ * canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div rather
12
+ * than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
18
13
  */
19
14
  /**
20
15
  * Options for {@linkcode renderPlotlyHTMLToPNG}.
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../tools/viz/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,mBAAmB,EAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA8DtD"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,mBAAmB,EAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAkDtD"}
@@ -6,51 +6,36 @@
6
6
  * Render a self-contained Plotly HTML to a PNG via headless Chromium — the shared renderer behind
7
7
  * the `registry viz` figures (an internal helper, not a command).
8
8
  *
9
- * Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context; headless Chromium has none by
10
- * default, so we force ANGLE's SwiftShader software rasterizer (`--use-gl=angle
11
- * --use-angle=swiftshader --enable-unsafe-swiftshader`). 2D traces (`contour`/`heatmap`) render
12
- * on the 2D canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div
13
- * rather than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
14
- *
15
- * Playwright (headless Chromium) is a heavy dev-only dependency — lazy-imported inside the entry
16
- * fn (the corpus-tools lazy-import convention), so importing `@mailwoman/registry/tools` never
17
- * pays for it.
9
+ * Plotly 3D (`surface`/`scatter3d`) needs a real WebGL context, which the shared harness
10
+ * (`./browser.ts`) provides through SwiftShader; 2D traces (`contour`/`heatmap`) render on the 2D
11
+ * canvas regardless. We wait for Plotly's `plotly_afterplot` to fire on every graph div rather
12
+ * than a fixed sleep, so the screenshot can't race the (async) WebGL paint.
18
13
  */
19
- import { resolve } from "node:path";
20
- import { pathToFileURL } from "node:url";
14
+ import { pathToFileURL } from "@mailwoman/core/module/file-url";
15
+ import { resolvePath as resolve } from "path-ts";
16
+ import { withChromiumPage } from "#tools/viz/browser";
21
17
  /**
22
18
  * Screenshot a Plotly HTML page after every graph div's `plotly_afterplot` fires.
23
19
  */
24
20
  export async function renderPlotlyHTMLToPNG(options, report) {
25
- // playwright + Chromium are heavy — lazy import (the pipeline convention).
26
- const { chromium } = await import("playwright");
27
- const browser = await chromium.launch({
28
- args: ["--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--ignore-gpu-blocklist"],
29
- });
30
- const page = await browser.newPage({
31
- viewport: { width: options.width ?? 1160, height: options.height ?? 1000 },
32
- deviceScaleFactor: 2,
33
- });
34
- const errors = [];
35
- page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
36
- page.on("pageerror", (e) => errors.push(String(e)));
37
- await page.goto(pathToFileURL(resolve(options.inHTML)).href, { waitUntil: "networkidle" });
38
- // Resolve once every Plotly graph div has fired plotly_afterplot (3D paints land async, after
39
- // newPlot's promise resolves), with a per-div fallback so an already-painted div can't hang us.
40
- await page.evaluate(async () => {
41
- const doc = globalThis.document;
42
- const divs = [...doc.querySelectorAll("div")]
43
- .map((d) => d)
44
- .filter((d) => d._fullLayout && typeof d.on === "function");
45
- await Promise.all(divs.map((d) => new Promise((res) => {
46
- d.on("plotly_afterplot", () => res());
47
- setTimeout(() => res(), 2000);
48
- })));
21
+ const { consoleErrors: errors } = await withChromiumPage({ viewport: { width: options.width ?? 1160, height: options.height ?? 1000 } }, async (page) => {
22
+ await page.goto(pathToFileURL(resolve(options.inHTML)).href, { waitUntil: "networkidle" });
23
+ // Resolve once every Plotly graph div has fired plotly_afterplot (3D paints land async, after
24
+ // newPlot's promise resolves), with a per-div fallback so an already-painted div can't hang us.
25
+ await page.evaluate(async () => {
26
+ const doc = Reflect.get(globalThis, "document");
27
+ const divs = [...doc.querySelectorAll("div")]
28
+ .map((d) => d)
29
+ .filter((d) => d._fullLayout && typeof d.on === "function");
30
+ await Promise.all(divs.map((d) => new Promise((res) => {
31
+ d.on("plotly_afterplot", () => res());
32
+ setTimeout(() => res(), 2000);
33
+ })));
34
+ });
35
+ // Final settle for the software WebGL rasterizer.
36
+ await page.waitForTimeout(800);
37
+ await page.screenshot({ path: resolve(options.outPNG), fullPage: true });
49
38
  });
50
- // Final settle for the software WebGL rasterizer.
51
- await page.waitForTimeout(800);
52
- await page.screenshot({ path: resolve(options.outPNG), fullPage: true });
53
- await browser.close();
54
39
  if (errors.length) {
55
40
  report?.(`[render] ${errors.length} console error(s):`);
56
41
  for (const e of errors.slice(0, 8)) {
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../tools/viz/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,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;YAE5D,MAAM,OAAO,CAAC,GAAG,CAChB,IAAI,CAAC,GAAG,CACP,CAAC,CAAC,EAAE,EAAE,CACL,IAAI,OAAO,CAAO,CAAC,GAAG,EAAE,EAAE;gBACzB,CAAC,CAAC,EAAG,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;gBACtC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA;YAC9B,CAAC,CAAC,CACH,CACD,CAAA;QACF,CAAC,CAAC,CAAA;QAEF,kDAAkD;QAClD,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;QAE9B,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACzE,CAAC,CACD,CAAA;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,EAAE,CAAC,YAAY,MAAM,CAAC,MAAM,oBAAoB,CAAC,CAAA;QAEvD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;YACpC,MAAM,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA;QACnB,CAAC;IACF,CAAC;IAED,MAAM,EAAE,CAAC,YAAY,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAEtC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,CAAA;AACzD,CAAC"}
@@ -3,28 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The address-point provenance map — the "show your work" proof, on a map.
7
- *
8
- * Every coordinate Mailwoman resolves to comes from an open dataset, and we keep the provenance on
9
- * the point. This samples the per-state address-point DB (`address_point.source`) and renders it
10
- * on the house MapLibre + Protomaps stack via {@link toMapHTML}, each dot COLORED BY its upstream
11
- * open-data source — the National Address Database (a federal release) vs OpenAddresses (county /
12
- * municipal open-data publishers). New York is the clean example: NAD blankets the state, and New
13
- * York City arrives separately from NYC Open Data, so the source split is visible as a
14
- * geography.
15
- *
16
- * No competitor in this space will tell you which open dataset a given coordinate came from — for
17
- * them the assembled pipeline is the moat. Here the provenance is the point of the map.
18
- *
19
- * Streets without a rooftop point are covered by TIGER interpolation (`tiger:edges`), a separate
20
- * layer not plotted here; this map is the rooftop-point sources only.
21
- *
22
- * SERVE THE OUTPUT OVER LOCALHOST (the house tile server CORS-restricts to localhost + the docs
23
- * domains). e.g. `python3 -m http.server -d <dir>`, or `renderServedMapToPNG` (`./render-map.ts`)
24
- * against the served URL.
25
- *
26
- * Run: `mailwoman registry viz source-provenance-map [--state ny] [--db <address-points-us-XX.db>]
27
- * [--out-html /tmp/source-provenance.html] [--nad-mod 700] [--oa-mod 120] [--cap 7000]`
6
+ * Sample `address_point.source` rows from a state database and render them by source in MapLibre.
7
+ * The output requires an HTTP origin because the tile server does not serve `file:` origins.
28
8
  */
29
9
  /**
30
10
  * Options for {@linkcode sourceProvenanceMap}.
@@ -58,8 +38,8 @@ export interface SourceProvenanceMapOptions {
58
38
  /**
59
39
  * Render the per-state address-point provenance map — see the module doc.
60
40
  */
61
- export declare function sourceProvenanceMap(options?: SourceProvenanceMapOptions, report?: (line: string) => void): {
41
+ export declare function sourceProvenanceMap(options?: SourceProvenanceMapOptions, report?: (line: string) => void): Promise<{
62
42
  outHTML: string;
63
43
  points: number;
64
- };
44
+ }>;
65
45
  //# sourceMappingURL=source-provenance-map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-provenance-map.d.ts","sourceRoot":"","sources":["../../../tools/viz/source-provenance-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAQH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAuBD;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,GAAE,0BAA+B,EACxC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAiErC"}
1
+ {"version":3,"file":"source-provenance-map.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/source-provenance-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ;AAuBD;;GAEG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,GAAE,0BAA+B,EACxC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA+D9C"}
@@ -3,33 +3,14 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * The address-point provenance map — the "show your work" proof, on a map.
7
- *
8
- * Every coordinate Mailwoman resolves to comes from an open dataset, and we keep the provenance on
9
- * the point. This samples the per-state address-point DB (`address_point.source`) and renders it
10
- * on the house MapLibre + Protomaps stack via {@link toMapHTML}, each dot COLORED BY its upstream
11
- * open-data source — the National Address Database (a federal release) vs OpenAddresses (county /
12
- * municipal open-data publishers). New York is the clean example: NAD blankets the state, and New
13
- * York City arrives separately from NYC Open Data, so the source split is visible as a
14
- * geography.
15
- *
16
- * No competitor in this space will tell you which open dataset a given coordinate came from — for
17
- * them the assembled pipeline is the moat. Here the provenance is the point of the map.
18
- *
19
- * Streets without a rooftop point are covered by TIGER interpolation (`tiger:edges`), a separate
20
- * layer not plotted here; this map is the rooftop-point sources only.
21
- *
22
- * SERVE THE OUTPUT OVER LOCALHOST (the house tile server CORS-restricts to localhost + the docs
23
- * domains). e.g. `python3 -m http.server -d <dir>`, or `renderServedMapToPNG` (`./render-map.ts`)
24
- * against the served URL.
25
- *
26
- * Run: `mailwoman registry viz source-provenance-map [--state ny] [--db <address-points-us-XX.db>]
27
- * [--out-html /tmp/source-provenance.html] [--nad-mod 700] [--oa-mod 120] [--cap 7000]`
6
+ * Sample `address_point.source` rows from a state database and render them by source in MapLibre.
7
+ * The output requires an HTTP origin because the tile server does not serve `file:` origins.
28
8
  */
29
- import { writeFileSync } from "node:fs";
30
- import { DatabaseSync } from "node:sqlite";
31
- import { dataRootPath } from "@mailwoman/core/utils";
32
- import { toMapHTML } from "@mailwoman/registry";
9
+ import { dataRootPath, tempRootPath } from "@mailwoman/core/data-root";
10
+ import { writeLocalFile } from "@mailwoman/core/fs/writers";
11
+ import { isPresent } from "@mailwoman/core/objects";
12
+ import { DatabaseClient } from "@mailwoman/sqlite/client";
13
+ import { toMapHTML } from "#index";
33
14
  // Collapse the raw `source` string into a human, mappable category. The address-point DB stores e.g.
34
15
  // "overture:NAD" or "overture:OpenAddresses/NY/NYC Open Data" — the suffix is the real upstream
35
16
  // publisher, which is what we want to color by (the "overture:" prefix is just the theme it arrived in).
@@ -45,14 +26,14 @@ function categorize(source) {
45
26
  /**
46
27
  * Render the per-state address-point provenance map — see the module doc.
47
28
  */
48
- export function sourceProvenanceMap(options = {}, report) {
29
+ export async function sourceProvenanceMap(options = {}, report) {
49
30
  const STATE = (options.state || "ny").toLowerCase();
50
31
  const DB = options.db || String(dataRootPath("address-points", `address-points-us-${STATE}.db`));
51
- const OUT = options.outHTML || "/tmp/source-provenance.html";
32
+ const OUT = options.outHTML || tempRootPath("source-provenance.html");
52
33
  const NAD_MOD = options.nadMod ?? 700; // keep ~1/700 of NAD points
53
34
  const OA_MOD = options.oaMod ?? 120; // keep ~1/120 of OpenAddresses points
54
35
  const CAP = options.cap ?? 7000; // per-source marker cap
55
- const db = new DatabaseSync(DB, { readOnly: true });
36
+ using db = new DatabaseClient(DB, { readOnly: true });
56
37
  // Two stratified samples so the smaller source (OpenAddresses, ~1/6 of NY) stays visible next to NAD.
57
38
  // abs(random()) % mod == 0 keeps a spatially-uniform ~1/mod fraction; LIMIT caps the marker count.
58
39
  const sample = (where, mod) => db
@@ -64,12 +45,11 @@ export function sourceProvenanceMap(options = {}, report) {
64
45
  ...sample("source = 'overture:NAD'", NAD_MOD),
65
46
  ...sample("source LIKE 'overture:OpenAddresses%'", OA_MOD),
66
47
  ];
67
- db.close();
68
48
  const counts = new Map();
69
49
  const features = rows.map((r) => {
70
50
  const { bucket, publisher } = categorize(r.source);
71
51
  counts.set(bucket, (counts.get(bucket) ?? 0) + 1);
72
- const addr = [r.number, r.street_raw].filter(Boolean).join(" ").trim();
52
+ const addr = [r.number, r.street_raw].filter(isPresent).join(" ").trim();
73
53
  return {
74
54
  type: "Feature",
75
55
  geometry: { type: "Point", coordinates: [r.lon, r.lat] },
@@ -89,7 +69,7 @@ export function sourceProvenanceMap(options = {}, report) {
89
69
  flavor: "light",
90
70
  colorBy: "bucket",
91
71
  });
92
- writeFileSync(OUT, html);
72
+ await writeLocalFile(html, OUT);
93
73
  report?.(`[written] ${OUT} (${features.length} points)`);
94
74
  for (const [bucket, n] of [...counts.entries()].toSorted((a, b) => b[1] - a[1])) {
95
75
  report?.(` ${n.toString().padStart(5)} ${bucket}`);
@@ -1 +1 @@
1
- {"version":3,"file":"source-provenance-map.js","sourceRoot":"","sources":["../../../tools/viz/source-provenance-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAgC/C,qGAAqG;AACrG,gGAAgG;AAChG,yGAAyG;AACzG,SAAS,UAAU,CAAC,MAAc;IACjC,IAAI,MAAM,KAAK,cAAc;QAAE,OAAO,EAAE,MAAM,EAAE,2BAA2B,EAAE,SAAS,EAAE,eAAe,EAAE,CAAA;IAEzG,IAAI,MAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;QACjD,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAA;QAE7D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,mBAAmB,SAAS,EAAE,EAAE,CAAA;IAC9E,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AAC7C,CAAC;AAQD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAClC,UAAsC,EAAE,EACxC,MAA+B;IAE/B,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;IACnD,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,MAAM,CAAC,YAA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E,QAAQ,CAAC,MAAM,EAAE,CAAA;AACjD,CAAC"}
@@ -35,7 +35,7 @@ export interface YardstickFigureOptions {
35
35
  /**
36
36
  * Emit the dedup-yardstick slope chart as a self-contained SVG — see the module doc.
37
37
  */
38
- export declare function yardstickFigure(options?: YardstickFigureOptions, report?: (line: string) => void): {
38
+ export declare function yardstickFigure(options?: YardstickFigureOptions, report?: (line: string) => void): Promise<{
39
39
  outSVG: string;
40
- };
40
+ }>;
41
41
  //# sourceMappingURL=yardstick-figure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"yardstick-figure.d.ts","sourceRoot":"","sources":["../../../tools/viz/yardstick-figure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AA6DD;;GAEG;AACH,wBAAgB,eAAe,CAC9B,OAAO,GAAE,sBAA2B,EACpC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAiIpB"}
1
+ {"version":3,"file":"yardstick-figure.d.ts","sourceRoot":"","sources":["../../../lib/tools/viz/yardstick-figure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AA6DD;;GAEG;AACH,wBAAsB,eAAe,CACpC,OAAO,GAAE,sBAA2B,EACpC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC7B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAiI7B"}
@@ -23,7 +23,8 @@
23
23
  * Run: `mailwoman registry viz yardstick-figure
24
24
  * [--out-svg docs/records/evals/charts/dedup-yardstick.svg]`
25
25
  */
26
- import { writeFileSync } from "node:fs";
26
+ import { writeLocalTextFile } from "@mailwoman/core/fs/writers";
27
+ import { escapeHTML } from "@mailwoman/core/strings/escape";
27
28
  const GRAINS = [
28
29
  { key: "NPI", label: "NPI", classes: 1000, note: "one entity per registration\n(over-segments orgs)" },
29
30
  { key: "site", label: "site", classes: 1456, note: "subpart-collapse +\naddress-split (conservative)" },
@@ -65,11 +66,11 @@ const MODELS = [
65
66
  { key: "GBT", label: "GBT (shipped default)", color: "#3578e5", width: 3, dash: "" },
66
67
  { key: "FS", label: "FS full stack", color: "#9ca3af", width: 2, dash: "5 4" },
67
68
  ];
68
- const esc = (s) => s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
69
+ const esc = escapeHTML;
69
70
  /**
70
71
  * Emit the dedup-yardstick slope chart as a self-contained SVG — see the module doc.
71
72
  */
72
- export function yardstickFigure(options = {}, report) {
73
+ export async function yardstickFigure(options = {}, report) {
73
74
  const OUT = options.outSVG || "docs/records/evals/charts/dedup-yardstick.svg";
74
75
  const parts = [];
75
76
  const push = (s) => parts.push(s);
@@ -132,7 +133,7 @@ export function yardstickFigure(options = {}, report) {
132
133
  // Footer caveat — the gold-set anchor.
133
134
  push(`<text x="${plotL}" y="${H - 10}" font-size="9.5" fill="#9ca3af">Gold set (2026-06-16-dedup-gold-set-tx120): 120/120 hard co-located pairs = same org, 0 genuine over-merges. The coordinate (geocode-first building key) is the tightest honest ruler; NPI charges correct same-org merges as errors.</text>`);
134
135
  push(`</svg>`);
135
- writeFileSync(OUT, parts.join(""));
136
+ await writeLocalTextFile(parts.join(""), OUT);
136
137
  report?.(`[written] ${OUT}`);
137
138
  report?.(` GBT F1: NPI ${F1.GBT[0]} → site ${F1.GBT[1]} → org-name ${F1.GBT[2]} → coord ${F1.GBT[3]} (+${(F1.GBT[3] - F1.GBT[0]).toFixed(1)}pp)`);
138
139
  report?.(` over-merge: ${OVERMERGE.GBT.join(" → ")}`);