@mailwoman/core 8.6.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +2 -2
  2. package/api/clock.ts +1 -1
  3. package/api/disk-storage.ts +7 -4
  4. package/api/test-clocks.ts +57 -9
  5. package/api/test-transport.ts +182 -0
  6. package/coarse-placer/coarse-placer.ts +2 -1
  7. package/coarse-placer/tools/build-dataset.ts +2 -2
  8. package/coarse-placer/tools/build-outlier-exposure.ts +2 -2
  9. package/coarse-placer/tools/build-outlier-latin.ts +3 -2
  10. package/coarse-placer/tools/build-outlier-oa.ts +3 -2
  11. package/coarse-placer/tools/eval-latin-offmap.ts +8 -8
  12. package/coarse-placer/tools/eval-openset.ts +20 -12
  13. package/coarse-placer/tools/eval-quant-compare.ts +8 -9
  14. package/coarse-placer/tools/eval.ts +30 -23
  15. package/coarse-placer/tools/probe-frontier.ts +9 -7
  16. package/coarse-placer/tools/quantize.ts +4 -2
  17. package/coarse-placer/tools/train.ts +10 -10
  18. package/collections.ts +2 -128
  19. package/crypto/node.ts +68 -0
  20. package/decoder/build-tree.ts +19 -0
  21. package/env/schema.ts +58 -2
  22. package/fs/zip.ts +297 -0
  23. package/identifiers.ts +48 -0
  24. package/layers/manifest.ts +2 -1
  25. package/locale/profiles/en-us.ts +2 -3
  26. package/locale/profiles/fr-fr.ts +1 -1
  27. package/locale/profiles/ja-jp.ts +7 -7
  28. package/objects.ts +40 -8
  29. package/out/api/clock.d.ts +1 -1
  30. package/out/api/clock.js +1 -1
  31. package/out/api/disk-storage.d.ts +1 -1
  32. package/out/api/disk-storage.d.ts.map +1 -1
  33. package/out/api/disk-storage.js +5 -5
  34. package/out/api/disk-storage.js.map +1 -1
  35. package/out/api/test-clocks.d.ts +2 -2
  36. package/out/api/test-clocks.d.ts.map +1 -1
  37. package/out/api/test-clocks.js +51 -9
  38. package/out/api/test-clocks.js.map +1 -1
  39. package/out/api/test-transport.d.ts +112 -0
  40. package/out/api/test-transport.d.ts.map +1 -0
  41. package/out/api/test-transport.js +84 -0
  42. package/out/api/test-transport.js.map +1 -0
  43. package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
  44. package/out/coarse-placer/coarse-placer.js +2 -1
  45. package/out/coarse-placer/coarse-placer.js.map +1 -1
  46. package/out/coarse-placer/tools/build-dataset.js +1 -2
  47. package/out/coarse-placer/tools/build-dataset.js.map +1 -1
  48. package/out/coarse-placer/tools/build-outlier-exposure.js +1 -2
  49. package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
  50. package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
  51. package/out/coarse-placer/tools/build-outlier-latin.js +2 -2
  52. package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
  53. package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
  54. package/out/coarse-placer/tools/build-outlier-oa.js +2 -2
  55. package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
  56. package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
  57. package/out/coarse-placer/tools/eval-latin-offmap.js +5 -8
  58. package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
  59. package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
  60. package/out/coarse-placer/tools/eval-openset.js +12 -11
  61. package/out/coarse-placer/tools/eval-openset.js.map +1 -1
  62. package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
  63. package/out/coarse-placer/tools/eval-quant-compare.js +7 -9
  64. package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
  65. package/out/coarse-placer/tools/eval.d.ts.map +1 -1
  66. package/out/coarse-placer/tools/eval.js +20 -21
  67. package/out/coarse-placer/tools/eval.js.map +1 -1
  68. package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
  69. package/out/coarse-placer/tools/probe-frontier.js +8 -8
  70. package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
  71. package/out/coarse-placer/tools/quantize.d.ts.map +1 -1
  72. package/out/coarse-placer/tools/quantize.js +3 -2
  73. package/out/coarse-placer/tools/quantize.js.map +1 -1
  74. package/out/coarse-placer/tools/train.d.ts.map +1 -1
  75. package/out/coarse-placer/tools/train.js +7 -10
  76. package/out/coarse-placer/tools/train.js.map +1 -1
  77. package/out/collections.d.ts +1 -59
  78. package/out/collections.d.ts.map +1 -1
  79. package/out/collections.js +2 -90
  80. package/out/collections.js.map +1 -1
  81. package/out/crypto/node.d.ts +43 -0
  82. package/out/crypto/node.d.ts.map +1 -0
  83. package/out/crypto/node.js +43 -0
  84. package/out/crypto/node.js.map +1 -0
  85. package/out/decoder/build-tree.d.ts.map +1 -1
  86. package/out/decoder/build-tree.js +17 -0
  87. package/out/decoder/build-tree.js.map +1 -1
  88. package/out/env/index.d.ts +8 -0
  89. package/out/env/index.d.ts.map +1 -1
  90. package/out/env/schema.d.ts +9 -1
  91. package/out/env/schema.d.ts.map +1 -1
  92. package/out/env/schema.js +54 -2
  93. package/out/env/schema.js.map +1 -1
  94. package/out/fs/zip.d.ts +116 -0
  95. package/out/fs/zip.d.ts.map +1 -0
  96. package/out/fs/zip.js +216 -0
  97. package/out/fs/zip.js.map +1 -0
  98. package/out/identifiers.d.ts +23 -0
  99. package/out/identifiers.d.ts.map +1 -1
  100. package/out/identifiers.js +39 -0
  101. package/out/identifiers.js.map +1 -1
  102. package/out/layers/manifest.d.ts.map +1 -1
  103. package/out/layers/manifest.js +2 -1
  104. package/out/layers/manifest.js.map +1 -1
  105. package/out/locale/profiles/en-us.d.ts +2 -3
  106. package/out/locale/profiles/en-us.d.ts.map +1 -1
  107. package/out/locale/profiles/en-us.js +2 -3
  108. package/out/locale/profiles/en-us.js.map +1 -1
  109. package/out/locale/profiles/fr-fr.d.ts +1 -1
  110. package/out/locale/profiles/fr-fr.js +1 -1
  111. package/out/locale/profiles/ja-jp.d.ts +7 -7
  112. package/out/locale/profiles/ja-jp.js +7 -7
  113. package/out/objects.d.ts +18 -2
  114. package/out/objects.d.ts.map +1 -1
  115. package/out/objects.js +29 -3
  116. package/out/objects.js.map +1 -1
  117. package/out/pipeline/index.d.ts +2 -2
  118. package/out/pipeline/index.d.ts.map +1 -1
  119. package/out/pipeline/index.js +1 -1
  120. package/out/pipeline/index.js.map +1 -1
  121. package/out/pipeline/runtime-pipeline.d.ts +1 -1
  122. package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
  123. package/out/pipeline/runtime-pipeline.js +74 -18
  124. package/out/pipeline/runtime-pipeline.js.map +1 -1
  125. package/out/pipeline/span-proposer.d.ts +24 -0
  126. package/out/pipeline/span-proposer.d.ts.map +1 -1
  127. package/out/pipeline/span-proposer.js +36 -1
  128. package/out/pipeline/span-proposer.js.map +1 -1
  129. package/out/pipeline/types.d.ts +155 -3
  130. package/out/pipeline/types.d.ts.map +1 -1
  131. package/out/pipeline/types.js +41 -1
  132. package/out/pipeline/types.js.map +1 -1
  133. package/out/resolver/index.d.ts +3 -1
  134. package/out/resolver/index.d.ts.map +1 -1
  135. package/out/resolver/index.js +1 -0
  136. package/out/resolver/index.js.map +1 -1
  137. package/out/resolver/referential.d.ts +73 -0
  138. package/out/resolver/referential.d.ts.map +1 -0
  139. package/out/resolver/referential.js +71 -0
  140. package/out/resolver/referential.js.map +1 -0
  141. package/out/resolver/types.d.ts +204 -0
  142. package/out/resolver/types.d.ts.map +1 -1
  143. package/out/resolver/types.js.map +1 -1
  144. package/out/resources/index.d.ts +0 -1
  145. package/out/resources/index.d.ts.map +1 -1
  146. package/out/resources/index.js +0 -1
  147. package/out/resources/index.js.map +1 -1
  148. package/out/resources/libpostal.d.ts.map +1 -1
  149. package/out/resources/libpostal.js +3 -4
  150. package/out/resources/libpostal.js.map +1 -1
  151. package/out/resources/whosonfirst/index.d.ts +1 -0
  152. package/out/resources/whosonfirst/index.d.ts.map +1 -1
  153. package/out/resources/whosonfirst/index.js +1 -0
  154. package/out/resources/whosonfirst/index.js.map +1 -1
  155. package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
  156. package/out/resources/whosonfirst/placetypes/Placetype.js +6 -5
  157. package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
  158. package/out/resources/whosonfirst/placetypes/admin.d.ts +12 -3
  159. package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
  160. package/out/resources/whosonfirst/placetypes/admin.js +1 -1
  161. package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
  162. package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
  163. package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -0
  164. package/out/resources/whosonfirst/sharded-repo.js +58 -0
  165. package/out/resources/whosonfirst/sharded-repo.js.map +1 -0
  166. package/out/scripting/utils/index.d.ts.map +1 -1
  167. package/out/scripting/utils/index.js +2 -2
  168. package/out/scripting/utils/index.js.map +1 -1
  169. package/out/tools/download-libpostal-resources.d.ts.map +1 -1
  170. package/out/tools/download-libpostal-resources.js +1 -0
  171. package/out/tools/download-libpostal-resources.js.map +1 -1
  172. package/out/tools/generate-language-types.d.ts.map +1 -1
  173. package/out/tools/generate-language-types.js +5 -11
  174. package/out/tools/generate-language-types.js.map +1 -1
  175. package/out/utils/data-root.d.ts +20 -6
  176. package/out/utils/data-root.d.ts.map +1 -1
  177. package/out/utils/data-root.js +24 -5
  178. package/out/utils/data-root.js.map +1 -1
  179. package/out/utils/hash.d.ts +6 -0
  180. package/out/utils/hash.d.ts.map +1 -1
  181. package/out/utils/hash.js +8 -0
  182. package/out/utils/hash.js.map +1 -1
  183. package/out/utils/index.d.ts +1 -0
  184. package/out/utils/index.d.ts.map +1 -1
  185. package/out/utils/index.js +1 -0
  186. package/out/utils/index.js.map +1 -1
  187. package/out/utils/jsonl.d.ts +17 -3
  188. package/out/utils/jsonl.d.ts.map +1 -1
  189. package/out/utils/jsonl.js +23 -6
  190. package/out/utils/jsonl.js.map +1 -1
  191. package/out/utils/python-json.d.ts +3 -3
  192. package/out/utils/python-json.js +9 -9
  193. package/out/utils/python-numeric.d.ts +33 -0
  194. package/out/utils/python-numeric.d.ts.map +1 -0
  195. package/out/utils/python-numeric.js +149 -0
  196. package/out/utils/python-numeric.js.map +1 -0
  197. package/out/utils/python-random.d.ts +26 -1
  198. package/out/utils/python-random.d.ts.map +1 -1
  199. package/out/utils/python-random.js +43 -7
  200. package/out/utils/python-random.js.map +1 -1
  201. package/out/utils/repo.d.ts.map +1 -1
  202. package/out/utils/repo.js +18 -0
  203. package/out/utils/repo.js.map +1 -1
  204. package/out/utils/sealed-db.d.ts +12 -0
  205. package/out/utils/sealed-db.d.ts.map +1 -1
  206. package/out/utils/sealed-db.js +32 -1
  207. package/out/utils/sealed-db.js.map +1 -1
  208. package/package.json +34 -7
  209. package/pipeline/index.ts +3 -1
  210. package/pipeline/runtime-pipeline.ts +88 -27
  211. package/pipeline/span-proposer.ts +64 -1
  212. package/pipeline/types.ts +160 -2
  213. package/resolver/index.ts +13 -0
  214. package/resolver/referential.ts +84 -0
  215. package/resolver/types.ts +207 -0
  216. package/resources/index.ts +0 -1
  217. package/resources/libpostal.ts +8 -7
  218. package/resources/whosonfirst/index.ts +1 -0
  219. package/resources/whosonfirst/placetypes/Placetype.ts +13 -8
  220. package/resources/whosonfirst/placetypes/admin.ts +12 -2
  221. package/resources/whosonfirst/sharded-repo.ts +69 -0
  222. package/scripting/utils/index.ts +2 -3
  223. package/tools/download-libpostal-resources.ts +1 -0
  224. package/tools/generate-language-types.ts +5 -14
  225. package/utils/data-root.ts +27 -6
  226. package/utils/hash.ts +9 -0
  227. package/utils/index.ts +1 -0
  228. package/utils/jsonl.ts +26 -7
  229. package/utils/python-json.ts +10 -10
  230. package/utils/python-numeric.ts +168 -0
  231. package/utils/python-random.ts +49 -8
  232. package/utils/repo.ts +18 -0
  233. package/utils/sealed-db.ts +38 -1
  234. package/out/resources/collections.d.ts +0 -22
  235. package/out/resources/collections.d.ts.map +0 -1
  236. package/out/resources/collections.js +0 -69
  237. package/out/resources/collections.js.map +0 -1
  238. package/resources/collections.ts +0 -96
package/fs/zip.ts ADDED
@@ -0,0 +1,297 @@
1
+ /**
2
+ * @copyright Sister Software.
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ * @file Zip readers, in two flavours — buffer-in for archives already in memory, path-in for archives on disk.
6
+ *
7
+ * {@link extractZip} and {@link extractSingleFileZip} take the whole archive as a `Buffer`, which is the right shape
8
+ * when a client has just downloaded one (`bdc/sdk/download.ts`) and the wrong shape for anything sizable: adm-zip
9
+ * holds the archive AND the decompressed member resident at once. The national address dumps under
10
+ * `$MAILWOMAN_DATA_ROOT` are 0.5–2.9 GB compressed and up to 9 GB unpacked, so the path-in readers below stream —
11
+ * yauzl seeks the central directory over a file handle and inflates one member on demand, at constant memory
12
+ * regardless of archive size.
13
+ *
14
+ * The path-in readers also handle ZIP64, which the dumps need: a member above 4 GB parks `0xFFFFFFFF` in the 32-bit
15
+ * size and offset slots and carries the real values in the entry's extra field.
16
+ */
17
+
18
+ import { createWriteStream } from "node:fs"
19
+ import { mkdir } from "node:fs/promises"
20
+ import { basename, dirname, join } from "node:path"
21
+ import { pipeline } from "node:stream/promises"
22
+ import { crc32 } from "node:zlib"
23
+
24
+ import ADMZip from "adm-zip"
25
+ import type { PathBuilderLike } from "path-ts"
26
+ import { open as openArchive } from "yauzl-promise"
27
+
28
+ export type ZipEntryContentPair = [entry: ADMZip.IZipEntry, content: Buffer]
29
+
30
+ /**
31
+ * Extract the contents of a zip file.
32
+ *
33
+ * @category Files
34
+ * @internal
35
+ */
36
+ export function extractZip(data: ArrayBuffer | Buffer): Map<ADMZip.IZipEntry, Buffer> {
37
+ const normalizedData = data instanceof ArrayBuffer ? Buffer.from(data) : data
38
+ const zip = new ADMZip(normalizedData)
39
+
40
+ const pairs = zip
41
+ .getEntries()
42
+ .map((entry) => [entry, zip.readFile(entry)])
43
+ .filter((pair): pair is ZipEntryContentPair => pair[1] !== null)
44
+
45
+ if (!pairs.length) {
46
+ throw new Error("No entry pairs found in zip file.")
47
+ }
48
+
49
+ return new Map<ADMZip.IZipEntry, Buffer>(pairs)
50
+ }
51
+
52
+ /**
53
+ * Extract the contents of a zip file and return the first entry.
54
+ */
55
+ export function extractSingleFileZip(data: ArrayBuffer | Buffer): Promise<Buffer> {
56
+ const normalizedData = data instanceof ArrayBuffer ? Buffer.from(data) : data
57
+ const zip = new ADMZip(normalizedData)
58
+
59
+ const [entry] = zip.getEntries()
60
+
61
+ // We use the async version of getData to avoid blocking the event loop.
62
+ return new Promise<Buffer>((resolve, reject) =>
63
+ // oxlint-disable-next-line no-promise-executor-return
64
+ entry!.getDataAsync((extractedData, error) => {
65
+ if (error) {
66
+ reject(error)
67
+ } else {
68
+ resolve(extractedData)
69
+ }
70
+ })
71
+ )
72
+ }
73
+
74
+ /**
75
+ * Names a member of an archive, either exactly or by pattern.
76
+ *
77
+ * A pattern matches the FIRST entry whose full archive-internal path tests true, in central-directory order.
78
+ */
79
+ export type ZipEntrySelector = string | RegExp
80
+
81
+ /**
82
+ * One archive member, as reported by the central directory.
83
+ *
84
+ * @category Files
85
+ */
86
+ export interface ZipEntryInfo {
87
+ /**
88
+ * The archive-internal path, e.g. `it/countrywide.csv`. Directory entries keep their trailing slash.
89
+ */
90
+ name: string
91
+ compressedSize: number
92
+ uncompressedSize: number
93
+ }
94
+
95
+ function selectorMatches(selector: ZipEntrySelector, name: string): boolean {
96
+ return typeof selector === "string" ? name === selector : selector.test(name)
97
+ }
98
+
99
+ /**
100
+ * List an archive's members without decompressing any of them.
101
+ *
102
+ * @category Files
103
+ */
104
+ export async function listZipEntries(archivePath: PathBuilderLike): Promise<ZipEntryInfo[]> {
105
+ const archive = await openArchive(String(archivePath))
106
+ const entries: ZipEntryInfo[] = []
107
+
108
+ try {
109
+ for await (const entry of archive) {
110
+ entries.push({
111
+ name: entry.filename,
112
+ compressedSize: entry.compressedSize,
113
+ uncompressedSize: entry.uncompressedSize,
114
+ })
115
+ }
116
+ } finally {
117
+ await archive.close()
118
+ }
119
+
120
+ return entries
121
+ }
122
+
123
+ /**
124
+ * Stream one member's decompressed bytes out of an archive on disk.
125
+ *
126
+ * Nothing beyond the central directory and the inflate window is held in memory, so this is bounded by the consumer
127
+ * rather than by the member's size. A consumer that stops early — a `take`, a `break` — destroys the member stream and
128
+ * closes the archive on the way out.
129
+ *
130
+ * @category Files
131
+ * @throws If no member matches `selector`.
132
+ */
133
+ export async function* readZipEntry(
134
+ archivePath: PathBuilderLike,
135
+ selector: ZipEntrySelector
136
+ ): AsyncGenerator<Uint8Array> {
137
+ const archive = await openArchive(String(archivePath))
138
+
139
+ try {
140
+ for await (const entry of archive) {
141
+ if (!selectorMatches(selector, entry.filename)) continue
142
+
143
+ const contents = await entry.openReadStream()
144
+
145
+ try {
146
+ yield* contents
147
+ } finally {
148
+ contents.destroy()
149
+ }
150
+
151
+ return
152
+ }
153
+
154
+ throw new Error(`No entry matching ${selector} in ${archivePath}`)
155
+ } finally {
156
+ await archive.close()
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Write one member's decompressed bytes to `destinationPath`.
162
+ *
163
+ * @category Files
164
+ *
165
+ * @returns The number of bytes written, as the central directory reports them.
166
+ * @throws If no member matches `selector`.
167
+ */
168
+ export async function extractZipEntry(
169
+ archivePath: PathBuilderLike,
170
+ selector: ZipEntrySelector,
171
+ destinationPath: PathBuilderLike
172
+ ): Promise<number> {
173
+ const archive = await openArchive(String(archivePath))
174
+
175
+ try {
176
+ for await (const entry of archive) {
177
+ if (!selectorMatches(selector, entry.filename)) continue
178
+
179
+ await pipeline(await entry.openReadStream(), createWriteStream(String(destinationPath)))
180
+
181
+ return entry.uncompressedSize
182
+ }
183
+ } finally {
184
+ await archive.close()
185
+ }
186
+
187
+ throw new Error(`No entry matching ${selector} in ${archivePath}`)
188
+ }
189
+
190
+ export interface ExtractZipEntriesOptions {
191
+ /**
192
+ * Which members to write. Omit for every member.
193
+ */
194
+ selector?: ZipEntrySelector
195
+ /**
196
+ * Write each member under its basename rather than its archive-internal path, flattening the tree — `unzip -j`.
197
+ *
198
+ * The shapefile archives this exists for carry their siblings in one directory, and the readers downstream expect
199
+ * them flat.
200
+ */
201
+ flatten?: boolean
202
+ }
203
+
204
+ /**
205
+ * Extract members of an archive into `destinationDirectory`.
206
+ *
207
+ * Directory entries are skipped; a nested path is created as needed unless `flatten` is set. Members stream one at a
208
+ * time, so this is bounded by the largest member rather than by the archive.
209
+ *
210
+ * @category Files
211
+ *
212
+ * @returns The archive-internal names of everything written, in central-directory order.
213
+ */
214
+ export async function extractZipEntries(
215
+ archivePath: PathBuilderLike,
216
+ destinationDirectory: PathBuilderLike,
217
+ { selector, flatten = false }: ExtractZipEntriesOptions = {}
218
+ ): Promise<string[]> {
219
+ const archive = await openArchive(String(archivePath))
220
+ const written: string[] = []
221
+
222
+ try {
223
+ for await (const entry of archive) {
224
+ if (entry.filename.endsWith("/")) continue
225
+
226
+ if (selector && !selectorMatches(selector, entry.filename)) continue
227
+
228
+ const relative = flatten ? basename(entry.filename) : entry.filename
229
+ const destination = join(String(destinationDirectory), relative)
230
+
231
+ if (!flatten) {
232
+ await mkdir(dirname(destination), { recursive: true })
233
+ }
234
+
235
+ await pipeline(await entry.openReadStream(), createWriteStream(destination))
236
+
237
+ written.push(entry.filename)
238
+ }
239
+ } finally {
240
+ await archive.close()
241
+ }
242
+
243
+ return written
244
+ }
245
+
246
+ /**
247
+ * Verify every member's CRC-32 against the value its central-directory header claims — what `unzip -t` is for.
248
+ *
249
+ * This is a corruption check on a download, so it decompresses everything and keeps nothing; the archive is read one
250
+ * member at a time and the checksum is folded chunk by chunk, so memory is bounded by the inflate window.
251
+ *
252
+ * The CRC is computed here rather than delegated to yauzl's `validateCrc32`, which asserts `Cannot validate CRC32 for
253
+ * uncompressed data` on a STORED member — and a corrupt stored member is precisely what this is meant to catch. Folding
254
+ * it locally covers both storage methods with one path.
255
+ *
256
+ * @category Files
257
+ *
258
+ * @returns The number of members checked. @throws If the archive is unreadable, or any member's checksum or length
259
+ * disagrees with its header.
260
+ */
261
+ export async function verifyZipIntegrity(archivePath: PathBuilderLike): Promise<number> {
262
+ const archive = await openArchive(String(archivePath))
263
+ let checked = 0
264
+
265
+ try {
266
+ for await (const entry of archive) {
267
+ if (entry.filename.endsWith("/")) continue
268
+
269
+ const contents = await entry.openReadStream({ validateCrc32: false })
270
+ let checksum = 0
271
+ let length = 0
272
+
273
+ for await (const chunk of contents) {
274
+ checksum = crc32(chunk as Uint8Array, checksum)
275
+ length += (chunk as Uint8Array).length
276
+ }
277
+
278
+ if (checksum !== entry.crc32) {
279
+ throw new Error(
280
+ `CRC mismatch in ${archivePath}: ${entry.filename} is 0x${checksum.toString(16)}, header claims 0x${entry.crc32.toString(16)}`
281
+ )
282
+ }
283
+
284
+ if (length !== entry.uncompressedSize) {
285
+ throw new Error(
286
+ `Length mismatch in ${archivePath}: ${entry.filename} is ${length} bytes, header claims ${entry.uncompressedSize}`
287
+ )
288
+ }
289
+
290
+ checked++
291
+ }
292
+ } finally {
293
+ await archive.close()
294
+ }
295
+
296
+ return checked
297
+ }
package/identifiers.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
+
6
7
  import { camelCase, capitalCase, snakeCase } from "change-case"
7
8
  import type { CamelCase, SnakeCase } from "type-fest"
8
9
 
@@ -56,3 +57,50 @@ export function smartCapitalCase(input: string): string {
56
57
 
57
58
  return capitalCase(input)
58
59
  }
60
+
61
+ /**
62
+ * Python `str.isupper()`: at least one cased character, and every cased character uppercase.
63
+ *
64
+ * Distinct from {@link isUniformlyCased}, which reports `true` for a string with no cased characters at all — `"123"` is
65
+ * uniformly cased and is NOT `isupper()`. Ports that gate a titlecase on the Python predicate need this one.
66
+ */
67
+ export function pyIsUpper(input: string): boolean {
68
+ let hasCased = false
69
+
70
+ for (const ch of input) {
71
+ if (ch.toLowerCase() === ch.toUpperCase()) continue
72
+
73
+ hasCased = true
74
+
75
+ if (ch !== ch.toUpperCase()) return false
76
+ }
77
+
78
+ return hasCased
79
+ }
80
+
81
+ /**
82
+ * Python `str.title()`: titlecase the first cased character of each run, lowercase the rest.
83
+ *
84
+ * Not `capitalCase` from change-case, which splits on word boundaries and drops punctuation — Python titlecases
85
+ * `"o'brien"` to `"O'Brien"` because the apostrophe ends a cased run.
86
+ */
87
+ export function pyTitle(input: string): string {
88
+ let out = ""
89
+ let prevCased = false
90
+
91
+ for (const ch of input) {
92
+ const cased = ch.toLowerCase() !== ch.toUpperCase()
93
+
94
+ out += prevCased ? ch.toLowerCase() : ch.toUpperCase()
95
+ prevCased = cased
96
+ }
97
+
98
+ return out
99
+ }
100
+
101
+ /**
102
+ * Titlecase a SHOUTED string, leave anything else alone — the shape source dumps use when a field arrives ALL CAPS.
103
+ */
104
+ export function titlecaseIfUpper(input: string): string {
105
+ return pyIsUpper(input) ? pyTitle(input) : input
106
+ }
@@ -10,6 +10,7 @@
10
10
 
11
11
  import type { Kysely } from "kysely"
12
12
 
13
+ import { parseJSONStrict } from "../objects.ts"
13
14
  import { LayerFreshnessPolicy, LayerTier, type LayerContractDatabase } from "./schema.ts"
14
15
 
15
16
  /**
@@ -119,7 +120,7 @@ export async function readLayerManifest(db: Kysely<LayerContractDatabase>): Prom
119
120
  buildCmd: row.build_cmd,
120
121
  buildSHA: row.build_sha,
121
122
  freshnessPolicy: row.freshness_policy as LayerFreshnessPolicy,
122
- spineKeys: JSON.parse(row.spine_keys) as SpineKeys,
123
+ spineKeys: parseJSONStrict<SpineKeys>(row.spine_keys),
123
124
  createdAt: row.created_at,
124
125
  }
125
126
 
@@ -3,9 +3,8 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * En-US locale profile (per Phase 0 task 5). Lists the rule classifier IDs the legacy registry will
7
- * assign and the `ComponentTag`s the US locale actually uses. No `weightsPackage` is set in Phase
8
- * 0 — neural weights ship in Phase 3.
6
+ * En-US locale profile. Lists the rule classifier IDs active in this locale and the
7
+ * `ComponentTag`s the US locale actually uses.
9
8
  */
10
9
 
11
10
  import type { LocaleProfile } from "../locale.ts"
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Fr-FR locale profile (per Phase 0 task 5). Uses the same rule classifier set as en-US for
6
+ * Fr-FR locale profile. Uses the same rule classifier set as en-US for
7
7
  * locale-agnostic primitives, with the French-specific component set: cedex (postal routing),
8
8
  * street_prefix_particle (de la / du / des), and dependent_locality (arrondissement). The
9
9
  * `central_european_street_name` classifier lives in the registry for FR / DE / etc. and is
@@ -3,14 +3,14 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  *
6
- * Ja-JP locale profile, used in Phase 0 §8 for the forward-compat sanity check (#8 task 8): does
7
- * the core abstraction accept a locale that omits `street` and `house_number` entirely without
8
- * throwing or tripping a type assertion? If this profile registers cleanly today, Phase 6 (Japan)
9
- * does not need a core refactor.
6
+ * Ja-JP locale profile, and the core abstraction's forward-compat sanity check (#8): does the
7
+ * registry accept a locale that omits `street` entirely, and whose hierarchy runs
8
+ * largest-to-smallest, without throwing or tripping a type assertion? While this profile registers
9
+ * cleanly, Japan support needs no core refactor.
10
10
  *
11
- * Note: no rule classifiers are listed because the JP profile is neural-only in Phase 6. The rule
12
- * pipeline does not produce Japanese-specific tags; declaring an empty list here verifies the
13
- * system does not assume there are rule classifiers for every locale.
11
+ * No rule classifiers are listed because the JP profile is neural-only — the rule pipeline produces
12
+ * no Japanese-specific tags. The empty list is itself the assertion that nothing in the system
13
+ * assumes every locale has rule classifiers.
14
14
  */
15
15
 
16
16
  import type { LocaleProfile } from "../locale.ts"
package/objects.ts CHANGED
@@ -6,10 +6,10 @@
6
6
  * Utility functions for working with objects.
7
7
  */
8
8
 
9
+ import type { PathBuilderLike } from "path-ts"
10
+ import { isIterable } from "spliterator"
9
11
  import type { JsonObject } from "type-fest"
10
12
 
11
- import { isIterable } from "./collections.ts"
12
-
13
13
  type SetLike<T> = { has(value: T): boolean } | Iterable<T>
14
14
 
15
15
  /**
@@ -172,17 +172,49 @@ export function omitNullable<T extends object>(input: T): NonNullableObject<T> {
172
172
 
173
173
  /**
174
174
  * Given serialized JSON, attempt to parse it.
175
+ *
176
+ * Non-throwing: invalid JSON — and any non-string input, `Buffer` included — returns the fallback (`null` unless one is
177
+ * given). Callers that need a throw on corrupt input, or `JSON.parse`'s reviver parameter, use `JSON.parse` directly
178
+ * behind a scoped lint disable.
175
179
  */
176
- export function tryParsingJSON<T = unknown>(input: unknown, fallback?: undefined): T | undefined
177
- export function tryParsingJSON<T = unknown>(input: unknown, fallback: null): T | null
180
+ export function tryParsingJSON<T = unknown>(input: unknown): T | null
181
+ export function tryParsingJSON<T = unknown, F = T>(input: unknown, fallback: F): T | F
178
182
 
179
- export function tryParsingJSON<T = unknown, F = null>(input: unknown, fallback?: F): T | F {
180
- if (typeof input !== "string") return (fallback ?? null) as F
183
+ export function tryParsingJSON<T = unknown, F = T>(input: unknown, fallback?: F): T | F | null {
184
+ if (typeof input !== "string") return fallback ?? null
181
185
 
182
186
  try {
183
- return JSON.parse(input)
187
+ // oxlint-disable-next-line no-restricted-properties -- The wrapper the rule recommends.
188
+ return JSON.parse(input) as T
184
189
  } catch {
185
- return (fallback ?? null) as F
190
+ return fallback ?? null
191
+ }
192
+ }
193
+
194
+ export class JSONParseError extends Error {
195
+ constructor(message: string, options?: ErrorOptions) {
196
+ super(message, options)
197
+ this.name = "JSONParseError"
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Parses JSON input or throws a `JSONParseError` if parsing fails.
203
+ *
204
+ * @param input - The JSON input to parse.
205
+ *
206
+ * @returns The parsed object.
207
+ */
208
+ export function parseJSONStrict<T = unknown>(input: PathBuilderLike): T {
209
+ if (!input) {
210
+ throw new JSONParseError(`Expected JSON input, got ${input}`)
211
+ }
212
+
213
+ try {
214
+ // oxlint-disable-next-line no-restricted-properties -- The wrapper the rule recommends.
215
+ return JSON.parse(String(input)) as T
216
+ } catch (error: unknown) {
217
+ throw new JSONParseError(`Failed to parse JSON`, { cause: error })
186
218
  }
187
219
  }
188
220
 
@@ -4,7 +4,7 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  * @file The injectable time source every timing-sensitive part of {@linkcode APIClient} reads through.
6
6
  *
7
- * Lifted from `filer/sdk/sec-client.ts` (3b task 5) when the SEC client's bespoke pacing/retry
7
+ * Lifted from `filer/sdk/sec-client.ts` when the SEC client's bespoke pacing/retry
8
8
  * machinery moved down into `@mailwoman/core/api`. Keeping the seam is the whole reason the pacing
9
9
  * and backoff suites are deterministic and finish in milliseconds instead of sleeping on the wall
10
10
  * clock — a rate-limit test that actually waits 100ms per grant costs 4s for a 40-call fan-out and
package/out/api/clock.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @author Teffen Ellis, et al.
5
5
  * @file The injectable time source every timing-sensitive part of {@linkcode APIClient} reads through.
6
6
  *
7
- * Lifted from `filer/sdk/sec-client.ts` (3b task 5) when the SEC client's bespoke pacing/retry
7
+ * Lifted from `filer/sdk/sec-client.ts` when the SEC client's bespoke pacing/retry
8
8
  * machinery moved down into `@mailwoman/core/api`. Keeping the seam is the whole reason the pacing
9
9
  * and backoff suites are deterministic and finish in milliseconds instead of sleeping on the wall
10
10
  * clock — a rate-limit test that actually waits 100ms per grant costs 4s for a 40-call fan-out and
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  * @file An on-disk `axios-cache-interceptor` storage adapter, so a client gets a durable HTTP cache by
6
- * CONFIGURATION rather than by hand-rolling one (3b task 5).
6
+ * CONFIGURATION rather than by hand-rolling one.
7
7
  *
8
8
  * NODE ONLY, and deliberately NOT re-exported from `./index.ts`: `core/api` reaches a browser bundle
9
9
  * (`docs`'s `DashboardMap` → `@mailwoman/cartographer` → `tiles/api.ts` → `@mailwoman/core/api`),
@@ -1 +1 @@
1
- {"version":3,"file":"disk-storage.d.ts","sourceRoot":"","sources":["../../api/disk-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,EAAE,KAAK,YAAY,EAAgB,KAAK,oBAAoB,EAAqB,MAAM,yBAAyB,CAAA;AAEvH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGxE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAA;IACnD;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;CACvB;AA0BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,YAAY,CA+I1E"}
1
+ {"version":3,"file":"disk-storage.d.ts","sourceRoot":"","sources":["../../api/disk-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,EAAE,KAAK,YAAY,EAAgB,KAAK,oBAAoB,EAAqB,MAAM,yBAAyB,CAAA;AAEvH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAIxE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAA;IACnD;;OAEG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;CACvB;AA0BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,YAAY,CAiJ1E"}
@@ -3,7 +3,7 @@
3
3
  * @license AGPL-3.0
4
4
  * @author Teffen Ellis, et al.
5
5
  * @file An on-disk `axios-cache-interceptor` storage adapter, so a client gets a durable HTTP cache by
6
- * CONFIGURATION rather than by hand-rolling one (3b task 5).
6
+ * CONFIGURATION rather than by hand-rolling one.
7
7
  *
8
8
  * NODE ONLY, and deliberately NOT re-exported from `./index.ts`: `core/api` reaches a browser bundle
9
9
  * (`docs`'s `DashboardMap` → `@mailwoman/cartographer` → `tiles/api.ts` → `@mailwoman/core/api`),
@@ -27,6 +27,7 @@ import { mkdir, readFile, rename, rm, unlink, writeFile } from "node:fs/promises
27
27
  import { join } from "node:path";
28
28
  import { buildStorage } from "axios-cache-interceptor";
29
29
  import { ConsoleLogger } from "../logging/index.js";
30
+ import { tryParsingJSON } from "../objects.js";
30
31
  import { sha256Hex } from "../utils/hash.js";
31
32
  /**
32
33
  * Whether a storage value is one worth persisting. `loading` is an in-flight marker with no reusable body — it belongs
@@ -117,15 +118,14 @@ export function buildDiskStorage(options) {
117
118
  catch {
118
119
  return undefined;
119
120
  }
120
- try {
121
- return JSON.parse(raw);
122
- }
123
- catch {
121
+ const parsed = tryParsingJSON(raw);
122
+ if (parsed === null) {
124
123
  // A truncated or hand-edited entry is a miss, not a crash — re-fetching is always safe.
125
124
  logger.warn(`Discarding an unreadable cache entry for ${key}.`);
126
125
  await removeEntry(key);
127
126
  return undefined;
128
127
  }
128
+ return parsed;
129
129
  },
130
130
  set: async (key, value) => {
131
131
  if (!isPersistableState(value)) {
@@ -1 +1 @@
1
- {"version":3,"file":"disk-storage.js","sourceRoot":"","sources":["../../api/disk-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAqB,YAAY,EAAgD,MAAM,yBAAyB,CAAA;AAEvH,OA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CAAC,CAAC,MAAM,CAAC,KAAK,CACtD,EAAE,CACF,CAAA;gBAED,kFAAkF;gBAClF,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;YAClD,CAAC;oBAAS,CAAC;gBACV,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACpB,CAAC;QACF,CAAC;QAED,MAAM,EAAE,WAAW;QAEnB,KAAK,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,CAAC,KAAK,EAAE,CAAA;YAEf,6FAA6F;YAC7F,6FAA6F;YAC7F,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;YACrD,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAC5C,CAAC;KACD,CAAC,CAAA;AACH,CAAC"}
@@ -74,8 +74,8 @@ export declare class VirtualClock implements ClockLike {
74
74
  * the clock past the deadlines that are registered a moment later, and the test hangs. This polls instead: drain, and
75
75
  * if any sleep is pending, advance to the earliest deadline; if none is, yield and look again.
76
76
  *
77
- * Throws rather than hanging when the work neither settles nor schedules anything for {@linkcode MAX_IDLE_TURNS}
78
- * consecutive turns — a diagnosable failure beats a test-timeout stack trace pointing at the `it()`.
77
+ * Throws rather than hanging when the work neither settles nor schedules anything for {@linkcode IDLE_BUDGET_MS} of
78
+ * REAL time — a diagnosable failure beats a test-timeout stack trace pointing at the `it()`.
79
79
  */
80
80
  runUntilSettled<T>(work: Promise<T>): Promise<T>;
81
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"test-clocks.d.ts","sourceRoot":"","sources":["../../api/test-clocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAS3C;;;GAGG;AACH,wBAAgB,eAAe,IA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