cursedbelt-server 4.48.0 → 4.49.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 (186) hide show
  1. package/dist/server/activity/store.d.ts +1 -1
  2. package/dist/server/analytics/injectedScripts.d.ts +1 -1
  3. package/dist/server/analytics/injectedScripts.js +1 -1
  4. package/dist/server/analytics/webAnalytics.d.ts +1 -1
  5. package/dist/server/analytics/webAnalytics.js +1 -1
  6. package/dist/server/auth/loginThrottleDurable.d.ts +3 -3
  7. package/dist/server/auth/loginThrottleDurable.js +3 -3
  8. package/dist/server/auth/passwordCost.js +1 -1
  9. package/dist/server/ctgrChunkDurable.d.ts +1 -1
  10. package/dist/server/ctgrChunkDurable.js +1 -1
  11. package/dist/server/d1/backup.d.ts +1 -1
  12. package/dist/server/d1/backup.js +1 -1
  13. package/dist/server/d1/http.d.ts +2 -2
  14. package/dist/server/d1/http.js +2 -2
  15. package/dist/server/d1/invocation.js +1 -1
  16. package/dist/server/d1/limits.d.ts +1 -1
  17. package/dist/server/d1/limits.js +1 -1
  18. package/dist/server/d1/pullD1.d.ts +4 -1
  19. package/dist/server/d1/pullD1.js +5 -2
  20. package/dist/server/d1/scheduling.d.ts +1 -1
  21. package/dist/server/d1/scheduling.js +1 -1
  22. package/dist/server/d1/types.d.ts +1 -1
  23. package/dist/server/d1/types.js +1 -1
  24. package/dist/server/d1/values.d.ts +1 -1
  25. package/dist/server/d1/values.js +1 -1
  26. package/dist/server/dropzone/index.d.ts +1 -0
  27. package/dist/server/dropzone/index.js +1 -0
  28. package/dist/server/dropzone/report.d.ts +188 -0
  29. package/dist/server/dropzone/report.js +430 -0
  30. package/dist/server/dropzone/scan.d.ts +22 -3
  31. package/dist/server/dropzone/scan.js +46 -1
  32. package/dist/server/engagement/index.d.ts +1 -1
  33. package/dist/server/engagement/index.js +1 -1
  34. package/dist/server/guard/argon2Binding.js +1 -1
  35. package/dist/server/guard/kdfWorkerEntry.js +2 -2
  36. package/dist/server/incidents/index.d.ts +1 -1
  37. package/dist/server/incidents/index.js +1 -1
  38. package/dist/server/incidents/store.d.ts +1 -1
  39. package/dist/server/incidents/store.js +1 -1
  40. package/dist/server/jobs/timeout.d.ts +1 -1
  41. package/dist/server/jobs/timeout.js +1 -1
  42. package/dist/server/master-lock/accountsPage.d.ts +1 -1
  43. package/dist/server/master-lock/accountsPage.js +2 -2
  44. package/dist/server/master-lock/guard.js +1 -1
  45. package/dist/server/master-lock/lockPage.d.ts +1 -1
  46. package/dist/server/master-lock/lockPage.js +2 -2
  47. package/dist/server/master-lock/masterLock.d.ts +2 -2
  48. package/dist/server/master-lock/masterLock.js +2 -2
  49. package/dist/server/metrics/normalizeRoute.js +1 -1
  50. package/dist/server/metrics/telemetrySink.d.ts +2 -2
  51. package/dist/server/metrics/telemetrySink.js +1 -1
  52. package/dist/server/middleware/zValidator.js +2 -2
  53. package/dist/server/notifications/hub.js +1 -1
  54. package/dist/server/requestLog/requestMetrics.d.ts +2 -2
  55. package/dist/server/requestLog/requestMetrics.js +2 -2
  56. package/dist/server/retention/archive.d.ts +1 -1
  57. package/dist/server/retention/archive.js +2 -2
  58. package/dist/server/satellite/config.js +2 -2
  59. package/dist/server/satellite/door.d.ts +1 -1
  60. package/dist/server/sharing/contract.d.ts +1 -1
  61. package/dist/server/storage/binaryStore.d.ts +1 -1
  62. package/dist/server/storage/binaryStore.js +3 -3
  63. package/dist/server/storage/derivatives.d.ts +2 -2
  64. package/dist/server/storage/derivatives.js +2 -2
  65. package/dist/server/storage/files/adapter.d.ts +2 -2
  66. package/dist/server/storage/files/adapter.js +10 -10
  67. package/dist/server/storage/files/catalogue.d.ts +1 -1
  68. package/dist/server/storage/files/catalogue.js +4 -4
  69. package/dist/server/storage/files/chunkedUpload.d.ts +2 -2
  70. package/dist/server/storage/files/chunkedUpload.js +1 -1
  71. package/dist/server/storage/files/fileRoutes.d.ts +1 -1
  72. package/dist/server/storage/files/fileRoutes.js +4 -4
  73. package/dist/server/storage/files/mimeByExt.js +1 -1
  74. package/dist/server/storage/files/stack.d.ts +2 -2
  75. package/dist/server/storage/files/types.d.ts +4 -4
  76. package/dist/server/storage/files/types.js +1 -1
  77. package/dist/server/storage/index.js +1 -1
  78. package/dist/server/storage/objectStoreMediaStore.js +1 -1
  79. package/dist/server/storage/transcodeJobs.js +5 -5
  80. package/dist/server/storage/types.d.ts +1 -1
  81. package/dist/server/storage/types.js +1 -1
  82. package/dist/server/storage/videoDerivativeKeys.d.ts +1 -1
  83. package/dist/server/storage/videoDerivativeKeys.js +1 -1
  84. package/dist/server/storage/videoProcessor.js +1 -1
  85. package/dist/server/sync/status.d.ts +1 -1
  86. package/dist/server/zipStream.d.ts +1 -1
  87. package/dist/server/zipStream.js +1 -1
  88. package/docs/activity.md +2 -2
  89. package/docs/retention.md +2 -2
  90. package/package.json +1 -1
  91. package/src/leafSubpathsImportNothing.spec.ts +1 -1
  92. package/src/namedSubpathsResolve.spec.ts +1 -1
  93. package/src/noTimerDialsAPeer.spec.ts +1 -1
  94. package/src/nodeBuiltinsAreProbedByCalling.spec.ts +1 -1
  95. package/src/publishShape.spec.ts +1 -1
  96. package/src/server/activity/store.ts +1 -1
  97. package/src/server/analytics/injectedScripts.spec.ts +1 -1
  98. package/src/server/analytics/injectedScripts.ts +1 -1
  99. package/src/server/analytics/webAnalytics.ts +1 -1
  100. package/src/server/auth/loginThrottleDurable.ts +3 -3
  101. package/src/server/auth/passwordCost.ts +1 -1
  102. package/src/server/bench/cpuBudget.spec.ts +1 -1
  103. package/src/server/bench/tail.spec.ts +1 -1
  104. package/src/server/ctgrChunkDurable.ts +1 -1
  105. package/src/server/d1/backup.spec.ts +1 -1
  106. package/src/server/d1/backup.ts +1 -1
  107. package/src/server/d1/http.ts +2 -2
  108. package/src/server/d1/invocation.spec.ts +1 -1
  109. package/src/server/d1/invocation.ts +1 -1
  110. package/src/server/d1/limits.ts +1 -1
  111. package/src/server/d1/pullD1.spec.ts +9 -1
  112. package/src/server/d1/pullD1.ts +5 -2
  113. package/src/server/d1/scheduling.ts +1 -1
  114. package/src/server/d1/types.ts +1 -1
  115. package/src/server/d1/values.ts +1 -1
  116. package/src/server/dropzone/index.ts +8 -0
  117. package/src/server/dropzone/report.spec.ts +275 -0
  118. package/src/server/dropzone/report.ts +568 -0
  119. package/src/server/dropzone/scan.spec.ts +2 -2
  120. package/src/server/dropzone/scan.ts +68 -5
  121. package/src/server/engagement/engagement.spec.ts +1 -1
  122. package/src/server/engagement/index.ts +1 -1
  123. package/src/server/google-oauth/googleOAuth.spec.ts +1 -1
  124. package/src/server/guard/argon2Binding.ts +1 -1
  125. package/src/server/guard/kdfWorkerEntry.ts +2 -2
  126. package/src/server/incidents/index.ts +1 -1
  127. package/src/server/incidents/store.ts +1 -1
  128. package/src/server/jobs/timeout.ts +1 -1
  129. package/src/server/master-lock/accountsPage.spec.ts +2 -2
  130. package/src/server/master-lock/accountsPage.ts +2 -2
  131. package/src/server/master-lock/beaconNeverReachesTheWall.spec.ts +2 -2
  132. package/src/server/master-lock/guard.spec.ts +2 -2
  133. package/src/server/master-lock/guard.ts +1 -1
  134. package/src/server/master-lock/lockPage.spec.ts +1 -1
  135. package/src/server/master-lock/lockPage.ts +2 -2
  136. package/src/server/master-lock/masterLock.spec.ts +1 -1
  137. package/src/server/master-lock/masterLock.ts +2 -2
  138. package/src/server/master-lock/sessions.spec.ts +1 -1
  139. package/src/server/metrics/normalizeRoute.ts +1 -1
  140. package/src/server/metrics/telemetrySink.ts +3 -3
  141. package/src/server/middleware/bodyLimit.spec.ts +1 -1
  142. package/src/server/middleware/zValidator.spec.ts +3 -3
  143. package/src/server/middleware/zValidator.ts +3 -3
  144. package/src/server/notifications/hub.ts +1 -1
  145. package/src/server/requestLog/requestMetrics.spec.ts +2 -2
  146. package/src/server/requestLog/requestMetrics.ts +3 -3
  147. package/src/server/retention/archive.spec.ts +2 -2
  148. package/src/server/retention/archive.ts +2 -2
  149. package/src/server/satellite/config.ts +2 -2
  150. package/src/server/satellite/door.ts +1 -1
  151. package/src/server/satellite/satellite.spec.ts +1 -1
  152. package/src/server/sharing/contract.ts +1 -1
  153. package/src/server/storage/binaryServerProcessing.spec.ts +1 -1
  154. package/src/server/storage/binaryServerProcessing.ts +4 -4
  155. package/src/server/storage/binaryStore.spec.ts +6 -6
  156. package/src/server/storage/binaryStore.ts +4 -4
  157. package/src/server/storage/chunked.integration.spec.ts +2 -2
  158. package/src/server/storage/derivatives.ts +2 -2
  159. package/src/server/storage/fileUploadClient.integration.spec.ts +1 -1
  160. package/src/server/storage/files/adapter.photo.spec.ts +2 -2
  161. package/src/server/storage/files/adapter.spec.ts +3 -3
  162. package/src/server/storage/files/adapter.ts +10 -10
  163. package/src/server/storage/files/catalogue.spec.ts +1 -1
  164. package/src/server/storage/files/catalogue.ts +4 -4
  165. package/src/server/storage/files/chunkedUpload.spec.ts +5 -5
  166. package/src/server/storage/files/chunkedUpload.ts +3 -3
  167. package/src/server/storage/files/fileRoutes.spec.ts +3 -3
  168. package/src/server/storage/files/fileRoutes.ts +5 -5
  169. package/src/server/storage/files/mimeByExt.ts +1 -1
  170. package/src/server/storage/files/stack.ts +3 -3
  171. package/src/server/storage/files/types.ts +6 -6
  172. package/src/server/storage/index.ts +1 -1
  173. package/src/server/storage/objectStoreMediaStore.ts +1 -1
  174. package/src/server/storage/sources.ts +1 -1
  175. package/src/server/storage/transcodeJobs.ts +5 -5
  176. package/src/server/storage/types.ts +2 -2
  177. package/src/server/storage/uploadSession.spec.ts +1 -1
  178. package/src/server/storage/videoDerivativeKeys.spec.ts +3 -3
  179. package/src/server/storage/videoDerivativeKeys.ts +1 -1
  180. package/src/server/storage/videoProcessor.ts +1 -1
  181. package/src/server/sync/status.ts +1 -1
  182. package/src/server/sync/timer.spec.ts +1 -1
  183. package/src/server/worker-argon2/index.spec.ts +1 -1
  184. package/src/server/zipStream.spec.ts +2 -2
  185. package/src/server/zipStream.ts +1 -1
  186. package/src/shippedFilesAreTracked.spec.ts +2 -2
@@ -19,7 +19,7 @@
19
19
  * ```
20
20
  *
21
21
  * ── 🔴 Four properties this file exists to guarantee ────────────────────────
22
- * 1. **Append only.** No update verb, no delete verb, no `TRUNCATE`. Ageing
22
+ * 1. **Append only.** No update verb, no delete verb, no `TRUNCATE`. Aging
23
23
  * rows out is the fleet retention standard's job, through a declaration the
24
24
  * owner can see (`satellite-kit/retention`) — never a silent cutoff here.
25
25
  * 2. **A source is READ, never copied.** `share_events` stays the canonical
@@ -39,7 +39,7 @@ export interface InjectedScript {
39
39
  * Every `<script src=…>` in `html` whose origin is NOT `pageUrl`'s.
40
40
  *
41
41
  * Inline scripts are ignored: they are the page's own (most shells here ship one, a pre-paint
42
- * colour-scheme script) and a CSP that refuses them is a different finding from this one.
42
+ * color-scheme script) and a CSP that refuses them is a different finding from this one.
43
43
  * `data:` and `blob:` are ignored for the same reason — neither is a host anything could have
44
44
  * injected.
45
45
  */
@@ -32,7 +32,7 @@
32
32
  * Every `<script src=…>` in `html` whose origin is NOT `pageUrl`'s.
33
33
  *
34
34
  * Inline scripts are ignored: they are the page's own (most shells here ship one, a pre-paint
35
- * colour-scheme script) and a CSP that refuses them is a different finding from this one.
35
+ * color-scheme script) and a CSP that refuses them is a different finding from this one.
36
36
  * `data:` and `blob:` are ignored for the same reason — neither is a host anything could have
37
37
  * injected.
38
38
  */
@@ -120,7 +120,7 @@ export declare const WEB_ANALYTICS_PUBLIC_HOST = "cursedalchemy.com";
120
120
  *
121
121
  * A device in GET-only mode (`cursedbelt-core/ctgr-client`) sits behind something that drops
122
122
  * every non-GET, and the beacon reports with a POST to the page's `/cdn-cgi/rum`. It cannot be
123
- * tunnelled the way our own API is — the script is Cloudflare's — so there it only ever failed,
123
+ * tunneled the way our own API is — the script is Cloudflare's — so there it only ever failed,
124
124
  * a red line per page view, and recorded nothing. Not loading it loses no data (2026-10-08).
125
125
  *
126
126
  * The guard reads the URL as well as `localStorage.ctgr`: this script runs before the app's
@@ -127,7 +127,7 @@ export const WEB_ANALYTICS_PUBLIC_HOST = "cursedalchemy.com";
127
127
  *
128
128
  * A device in GET-only mode (`cursedbelt-core/ctgr-client`) sits behind something that drops
129
129
  * every non-GET, and the beacon reports with a POST to the page's `/cdn-cgi/rum`. It cannot be
130
- * tunnelled the way our own API is — the script is Cloudflare's — so there it only ever failed,
130
+ * tunneled the way our own API is — the script is Cloudflare's — so there it only ever failed,
131
131
  * a red line per page view, and recorded nothing. Not loading it loses no data (2026-10-08).
132
132
  *
133
133
  * The guard reads the URL as well as `localStorage.ctgr`: this script runs before the app's
@@ -11,7 +11,7 @@
11
11
  * spread across N isolates gets N × the global allowance the header calls "the actual defense".
12
12
  *
13
13
  * A Durable Object is the exact shape of the fix: one instance addressed by name, requests to it
14
- * serialised, so every isolate in every colo meets the same counts. It runs the SAME
14
+ * serialized, so every isolate in every colo meets the same counts. It runs the SAME
15
15
  * `createLoginThrottle` algorithm — nothing here re-decides a threshold or a delay — and persists
16
16
  * the ledger to the object's storage after every change, so the object's own eviction (minutes
17
17
  * idle, measured on patterns' live object) forgets nothing either.
@@ -20,10 +20,10 @@
20
20
  * The throttle is checked BEFORE argon2, on every attempt, and the point of checking first is
21
21
  * that a refused attempt is cheap. A D1 read-modify-write per attempt is a query against the
22
22
  * invocation's 1,000-query budget and, worse, not atomic across concurrent invocations: two
23
- * guesses that snapshot the same count both write count+1. The object serialises for free.
23
+ * guesses that snapshot the same count both write count+1. The object serializes for free.
24
24
  *
25
25
  * ── `attempt` is one operation, not two ─────────────────────────────────────
26
- * `/throttle/attempt` checks and charges in one serialised step, so a burst of concurrent guesses
26
+ * `/throttle/attempt` checks and charges in one serialized step, so a burst of concurrent guesses
27
27
  * is admitted only up to the threshold rather than all at once against one stale count. See
28
28
  * `loginThrottle.ts`'s `attempt` section.
29
29
  *
@@ -11,7 +11,7 @@
11
11
  * spread across N isolates gets N × the global allowance the header calls "the actual defense".
12
12
  *
13
13
  * A Durable Object is the exact shape of the fix: one instance addressed by name, requests to it
14
- * serialised, so every isolate in every colo meets the same counts. It runs the SAME
14
+ * serialized, so every isolate in every colo meets the same counts. It runs the SAME
15
15
  * `createLoginThrottle` algorithm — nothing here re-decides a threshold or a delay — and persists
16
16
  * the ledger to the object's storage after every change, so the object's own eviction (minutes
17
17
  * idle, measured on patterns' live object) forgets nothing either.
@@ -20,10 +20,10 @@
20
20
  * The throttle is checked BEFORE argon2, on every attempt, and the point of checking first is
21
21
  * that a refused attempt is cheap. A D1 read-modify-write per attempt is a query against the
22
22
  * invocation's 1,000-query budget and, worse, not atomic across concurrent invocations: two
23
- * guesses that snapshot the same count both write count+1. The object serialises for free.
23
+ * guesses that snapshot the same count both write count+1. The object serializes for free.
24
24
  *
25
25
  * ── `attempt` is one operation, not two ─────────────────────────────────────
26
- * `/throttle/attempt` checks and charges in one serialised step, so a burst of concurrent guesses
26
+ * `/throttle/attempt` checks and charges in one serialized step, so a burst of concurrent guesses
27
27
  * is admitted only up to the threshold rather than all at once against one stale count. See
28
28
  * `loginThrottle.ts`'s `attempt` section.
29
29
  *
@@ -14,7 +14,7 @@
14
14
  * production cost 52.85 s
15
15
  * test cost 7.32 s
16
16
  *
17
- * Eighty-six per cent of what was, that morning, the largest single workspace in
17
+ * Eighty-six percent of what was, that morning, the largest single workspace in
18
18
  * `verify:scoped` — paid by every agent on every branch touching auth or any shared
19
19
  * package, and again on every union gate.
20
20
  *
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * ── One object per payload ───────────────────────────────────────────────────
20
20
  * Addressed by `ctgr:<_cid>` (a `crypto.randomUUID()` the client mints per request), so the
21
- * chunks of one request are serialised through one object and different requests never
21
+ * chunks of one request are serialized through one object and different requests never
22
22
  * contend. The partial lives in the object's memory: chunks arrive milliseconds apart, the idle
23
23
  * TTL is 30 s, and an object is only evicted after minutes idle — a partial it loses is one a
24
24
  * deploy would have lost too. An object holding nothing costs nothing.
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * ── One object per payload ───────────────────────────────────────────────────
20
20
  * Addressed by `ctgr:<_cid>` (a `crypto.randomUUID()` the client mints per request), so the
21
- * chunks of one request are serialised through one object and different requests never
21
+ * chunks of one request are serialized through one object and different requests never
22
22
  * contend. The partial lives in the object's memory: chunks arrive milliseconds apart, the idle
23
23
  * TTL is 30 s, and an object is only evicted after minutes idle — a partial it loses is one a
24
24
  * deploy would have lost too. An object holding nothing costs nothing.
@@ -63,7 +63,7 @@ export interface TimeTravelOpts {
63
63
  /**
64
64
  * The D1 implementation: record the coordinate, because retention is automatic.
65
65
  *
66
- * 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must honour that rather
66
+ * 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must honor that rather
67
67
  * than calling `capture()` on a timer — a nightly no-op job that logs "backup complete"
68
68
  * is worse than no job, because it reads as evidence.
69
69
  */
@@ -36,7 +36,7 @@
36
36
  /**
37
37
  * The D1 implementation: record the coordinate, because retention is automatic.
38
38
  *
39
- * 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must honour that rather
39
+ * 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must honor that rather
40
40
  * than calling `capture()` on a timer — a nightly no-op job that logs "backup complete"
41
41
  * is worse than no job, because it reads as evidence.
42
42
  */
@@ -10,12 +10,12 @@
10
10
  * the only other door into D1 was a per-app bearer route on the Worker for each one.
11
11
  *
12
12
  * So the Mac gets the same {@link D1LikeDatabase} a Worker holds, pointed at the same
13
- * database, and the app's own catalogue code runs unchanged against production — ONE writer
13
+ * database, and the app's own catalog code runs unchanged against production — ONE writer
14
14
  * of the rows, one schema, one set of statements.
15
15
  *
16
16
  * ── How ──────────────────────────────────────────────────────────────────────────────────
17
17
  * It is a {@link D1BindingLike} over `POST /accounts/:account/d1/database/:db/query` (and
18
- * `/raw`), handed to {@link createRemoteD1} — so every value normalisation, limit check and
18
+ * `/raw`), handed to {@link createRemoteD1} — so every value normalization, limit check and
19
19
  * `success: false` guard is the binding driver's own, not a second copy that could drift.
20
20
  * `batch()` sends `{ batch: [...] }`, which D1 runs as one unit exactly as a binding's batch
21
21
  * does: measured 2026-09-23 on a throwaway database, a batch whose second statement violated
@@ -10,12 +10,12 @@
10
10
  * the only other door into D1 was a per-app bearer route on the Worker for each one.
11
11
  *
12
12
  * So the Mac gets the same {@link D1LikeDatabase} a Worker holds, pointed at the same
13
- * database, and the app's own catalogue code runs unchanged against production — ONE writer
13
+ * database, and the app's own catalog code runs unchanged against production — ONE writer
14
14
  * of the rows, one schema, one set of statements.
15
15
  *
16
16
  * ── How ──────────────────────────────────────────────────────────────────────────────────
17
17
  * It is a {@link D1BindingLike} over `POST /accounts/:account/d1/database/:db/query` (and
18
- * `/raw`), handed to {@link createRemoteD1} — so every value normalisation, limit check and
18
+ * `/raw`), handed to {@link createRemoteD1} — so every value normalization, limit check and
19
19
  * `success: false` guard is the binding driver's own, not a second copy that could drift.
20
20
  * `batch()` sends `{ batch: [...] }`, which D1 runs as one unit exactly as a binding's batch
21
21
  * does: measured 2026-09-23 on a throwaway database, a batch whose second statement violated
@@ -135,7 +135,7 @@ export function perInvocation(db, opts = {}) {
135
135
  throw new RangeError(`max must be a positive integer, got ${max}`);
136
136
  }
137
137
  if (max > LIMITS.queriesPerInvocation) {
138
- throw new D1LimitError('queries per Worker invocation', max, LIMITS.queriesPerInvocation, 'A budget above D1\'s own cap cannot be honoured — the service refuses first. Lower it, or split the work across invocations.');
138
+ throw new D1LimitError('queries per Worker invocation', max, LIMITS.queriesPerInvocation, 'A budget above D1\'s own cap cannot be honored — the service refuses first. Lower it, or split the work across invocations.');
139
139
  }
140
140
  const budget = new Budget(max);
141
141
  return {
@@ -93,7 +93,7 @@ export declare function chunkForBind<T>(items: readonly T[], paramsPerItem: numb
93
93
  * `WHERE … ORDER BY … LIMIT ? OFFSET ?` page and the `COUNT(*)` beside it), and on a write
94
94
  * it trades one atomic statement for a batch that is atomic only per chunk. `json_each`
95
95
  * over a JSON array is one parameter however long the list is, keeps the statement whole,
96
- * and SQLite still drives the column's index through the materialised set.
96
+ * and SQLite still drives the column's index through the materialized set.
97
97
  *
98
98
  * The array travels as one TEXT value, so the ceiling moves from 100 ids to
99
99
  * `LIMITS.valueBytes` (2 MB) of JSON — about 70,000 of this fleet's 25-character ids — and
@@ -203,7 +203,7 @@ export function chunkForBind(items, paramsPerItem) {
203
203
  * `WHERE … ORDER BY … LIMIT ? OFFSET ?` page and the `COUNT(*)` beside it), and on a write
204
204
  * it trades one atomic statement for a batch that is atomic only per chunk. `json_each`
205
205
  * over a JSON array is one parameter however long the list is, keeps the statement whole,
206
- * and SQLite still drives the column's index through the materialised set.
206
+ * and SQLite still drives the column's index through the materialized set.
207
207
  *
208
208
  * The array travels as one TEXT value, so the ceiling moves from 100 ids to
209
209
  * `LIMITS.valueBytes` (2 MB) of JSON — about 70,000 of this fleet's 25-character ids — and
@@ -168,7 +168,10 @@ export interface PullD1Options {
168
168
  export declare const TRANSIENT_WAITS_MS: readonly number[];
169
169
  /**
170
170
  * A failure of the WIRE between this Mac and Cloudflare, not an answer from D1 — which asking
171
- * again a little later fixes. Only these are waited out — a refusal D1 actually made (a page too
171
+ * again a little later fixes. `setTypeOfService EINVAL` is one in disguise: undici sets the socket's
172
+ * TOS before every request, and macOS answers `setsockopt` on a connection the peer already reset
173
+ * with EINVAL — so under Bun a dropped connection crashes wrangler with it instead of ECONNRESET
174
+ * (vault's and auth's nightly pulls, 2026-10-23, both under the background clamp's starved handshakes). Only these are waited out — a refusal D1 actually made (a page too
172
175
  * large, bad SQL, auth) is never retried here, so a page refused for its size still halves at
173
176
  * once instead of sleeping ~1.5 minutes per halving.
174
177
  */
@@ -196,11 +196,14 @@ export function backupTables(rows) {
196
196
  export const TRANSIENT_WAITS_MS = [5_000, 20_000, 60_000];
197
197
  /**
198
198
  * A failure of the WIRE between this Mac and Cloudflare, not an answer from D1 — which asking
199
- * again a little later fixes. Only these are waited out — a refusal D1 actually made (a page too
199
+ * again a little later fixes. `setTypeOfService EINVAL` is one in disguise: undici sets the socket's
200
+ * TOS before every request, and macOS answers `setsockopt` on a connection the peer already reset
201
+ * with EINVAL — so under Bun a dropped connection crashes wrangler with it instead of ECONNRESET
202
+ * (vault's and auth's nightly pulls, 2026-10-23, both under the background clamp's starved handshakes). Only these are waited out — a refusal D1 actually made (a page too
200
203
  * large, bad SQL, auth) is never retried here, so a page refused for its size still halves at
201
204
  * once instead of sleeping ~1.5 minutes per halving.
202
205
  */
203
- export const isTransient = (message) => /fetch failed|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|socket hang up|network connection was lost/i.test(message);
206
+ export const isTransient = (message) => /fetch failed|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|socket hang up|network connection was lost|setTypeOfService EINVAL/i.test(message);
204
207
  const sqlIdent = (name) => `"${name.replaceAll('"', '""')}"`;
205
208
  const sqlText = (text) => `'${text.replaceAll("'", "''")}'`;
206
209
  /**
@@ -31,7 +31,7 @@
31
31
  * a 6-field expression with a leading seconds column, and this repo already contains three
32
32
  * jobs declared `'* * * * * *'` — once per second. Those cannot become Cron Triggers at
33
33
  * all, and {@link classifySchedule} says so by name instead of silently rounding them up to
34
- * a minute, which would change behaviour in production and nowhere else.
34
+ * a minute, which would change behavior in production and nowhere else.
35
35
  */
36
36
  import type { D1LikeDatabase } from './types.js';
37
37
  /** The Workers primitive a piece of scheduled work maps onto. */
@@ -31,7 +31,7 @@
31
31
  * a 6-field expression with a leading seconds column, and this repo already contains three
32
32
  * jobs declared `'* * * * * *'` — once per second. Those cannot become Cron Triggers at
33
33
  * all, and {@link classifySchedule} says so by name instead of silently rounding them up to
34
- * a minute, which would change behaviour in production and nowhere else.
34
+ * a minute, which would change behavior in production and nowhere else.
35
35
  */
36
36
  /** Cloudflare Queues: $0.40 per million operations, first million free each month. */
37
37
  const QUEUE_USD_PER_MILLION = 0.4;
@@ -40,7 +40,7 @@
40
40
  *
41
41
  * D1 has no interactive transaction — there is no `BEGIN`/`COMMIT` over HTTP, only
42
42
  * {@link D1LikeDatabase.batch}, which is atomic and runs as one round trip. A local
43
- * driver that happily honoured `BEGIN` would be the sync-vs-async trap a third time, so
43
+ * driver that happily honored `BEGIN` would be the sync-vs-async trap a third time, so
44
44
  * {@link D1UnsupportedError} is thrown by both. Wrap the statements in `batch()` instead;
45
45
  * it is atomic on D1 and wrapped in a real `bun:sqlite` transaction locally, so the
46
46
  * guarantee is the same.
@@ -40,7 +40,7 @@
40
40
  *
41
41
  * D1 has no interactive transaction — there is no `BEGIN`/`COMMIT` over HTTP, only
42
42
  * {@link D1LikeDatabase.batch}, which is atomic and runs as one round trip. A local
43
- * driver that happily honoured `BEGIN` would be the sync-vs-async trap a third time, so
43
+ * driver that happily honored `BEGIN` would be the sync-vs-async trap a third time, so
44
44
  * {@link D1UnsupportedError} is thrown by both. Wrap the statements in `batch()` instead;
45
45
  * it is atomic on D1 and wrapped in a real `bun:sqlite` transaction locally, so the
46
46
  * guarantee is the same.
@@ -36,7 +36,7 @@ export declare const normalizeBinds: (values: readonly unknown[]) => D1LikeBinda
36
36
  * Only a leading `SELECT` is claimed, because that is the one keyword that is
37
37
  * unambiguous: `WITH … INSERT … RETURNING` and `INSERT … RETURNING` both return rows AND
38
38
  * write. Anything this returns `false` for is measured exactly instead (see
39
- * `local.ts`), so a statement shape this does not recognise costs two extra queries —
39
+ * `local.ts`), so a statement shape this does not recognize costs two extra queries —
40
40
  * never a wrong number.
41
41
  */
42
42
  export declare const isPureReadSql: (sql: string) => boolean;
@@ -84,7 +84,7 @@ const LEADING_NOISE = /^(?:\s|--[^\n]*\n?|\/\*[\s\S]*?\*\/)+/;
84
84
  * Only a leading `SELECT` is claimed, because that is the one keyword that is
85
85
  * unambiguous: `WITH … INSERT … RETURNING` and `INSERT … RETURNING` both return rows AND
86
86
  * write. Anything this returns `false` for is measured exactly instead (see
87
- * `local.ts`), so a statement shape this does not recognise costs two extra queries —
87
+ * `local.ts`), so a statement shape this does not recognize costs two extra queries —
88
88
  * never a wrong number.
89
89
  */
90
90
  export const isPureReadSql = (sql) => /^select\b/i.test(sql.replace(LEADING_NOISE, ''));
@@ -11,3 +11,4 @@
11
11
  */
12
12
  export { describeSweep, isJunkName, isStable, pruneEmptyDirs, scanDropzone, sweepDropzone, type DropHandler, type DropOutcome, type DroppedFile, type ScanOptions, type SweepReport, } from "./scan.js";
13
13
  export { askBinaryServerAboutDuplicate, hashFile, type DuplicateVerdict, type DuplicateQuestion, } from "./duplicates.js";
14
+ export { createIngestReporter, FILES_JOURNAL, type FileOutcome, type IngestReporter, type ReportFile, type SourceDrive, } from "./report.js";
@@ -11,3 +11,4 @@
11
11
  */
12
12
  export { describeSweep, isJunkName, isStable, pruneEmptyDirs, scanDropzone, sweepDropzone, } from "./scan.js";
13
13
  export { askBinaryServerAboutDuplicate, hashFile, } from "./duplicates.js";
14
+ export { createIngestReporter, FILES_JOURNAL, } from "./report.js";
@@ -0,0 +1,188 @@
1
+ export declare const PROGRESS_VERSION = 1;
2
+ export declare const PROGRESS_FILE = "progress.json";
3
+ export declare const FILES_JOURNAL = "files.jsonl";
4
+ export declare const QUEUE_FILE = "queue.jsonl";
5
+ /** The page polls every few seconds; the file need not be fresher than that. */
6
+ export declare const WRITE_EVERY_MS = 2000;
7
+ export declare const JOURNAL_ROTATE_BYTES: number;
8
+ /** A finished source stays listed this long, so "what finished today" is on the page. */
9
+ export declare const FINISHED_KEPT_MS: number;
10
+ /** The name of the source that holds an account's loose files. */
11
+ export declare const LOOSE_FILES = "Loose files";
12
+ /** Where a file is on its way through the sweep. Outcomes leave the queue. */
13
+ /** `copying`: still being written into the dropzone — it goes in on a later sweep. `skipped`: left alone. */
14
+ export type FileState = "queued" | "copying" | "uploading" | "waiting-room" | "waiting-drive" | "skipped" | "failed";
15
+ export type FileOutcome = "added" | "duplicate" | "parked" | "blocked" | "failed";
16
+ export interface Tally {
17
+ files: number;
18
+ bytes: number;
19
+ }
20
+ export interface SourceDrive {
21
+ volume: string;
22
+ /** `ok` mounted · `unmounted` the volume is not there (unplugged) · `deleted` mounted, folder gone. */
23
+ state: "ok" | "unmounted" | "deleted";
24
+ /** The volume is a disk image: where its file lives, and whether THAT drive is plugged in. */
25
+ image?: {
26
+ file: string;
27
+ hostVolume: string | null;
28
+ hostMounted: boolean;
29
+ reattachTried: boolean;
30
+ };
31
+ }
32
+ /** What the reporter needs of a file: whose it is, where it is, and how big. */
33
+ export interface ReportFile {
34
+ accountId: string;
35
+ /** Absolute path — with the account, what tells two files apart. */
36
+ path: string;
37
+ /** Relative to the account folder: its first segment names the source. */
38
+ relativePath: string;
39
+ size: number;
40
+ }
41
+ /** A file's outcome, as the journal records it. */
42
+ export type ReportResult = {
43
+ outcome: FileOutcome;
44
+ detail?: string;
45
+ itemId?: string;
46
+ };
47
+ /** What an earlier run already settled for a file — `found`'s `settled` answers it. */
48
+ export interface SettledFile {
49
+ outcome?: Exclude<FileOutcome, "failed"> | null;
50
+ at: string;
51
+ itemId?: string | null;
52
+ }
53
+ export interface ProgressSource {
54
+ id: string;
55
+ account: {
56
+ id: string;
57
+ label: string;
58
+ };
59
+ /** The folder or link's own name, or {@link LOOSE_FILES}. */
60
+ label: string;
61
+ kind: "linked" | "folder" | "loose";
62
+ /** Where it is in the dropzone. */
63
+ path: string;
64
+ /** A link's real target. */
65
+ target?: string;
66
+ drive?: SourceDrive;
67
+ startedAt: string;
68
+ /** When nothing was left to do — cleared if more arrives. */
69
+ finishedAt: string | null;
70
+ /** When the last file reached an outcome. */
71
+ lastOutcomeAt: string | null;
72
+ /** Everything it holds: what is left, plus (for a folder that empties as it goes) what was filed. */
73
+ total: Tally;
74
+ done: Tally;
75
+ added: number;
76
+ duplicate: number;
77
+ blocked: number;
78
+ parked: number;
79
+ queued: Tally;
80
+ waitingForRoom: Tally;
81
+ waitingForDrive: Tally;
82
+ skipped: Tally;
83
+ failed: Tally;
84
+ current: {
85
+ path: string;
86
+ bytes: number;
87
+ key: string;
88
+ startedAt: string;
89
+ } | null;
90
+ }
91
+ export interface IngestProgress {
92
+ v: typeof PROGRESS_VERSION;
93
+ app: string;
94
+ /** The launchd job that runs the sweep — station reads its health and can start it. */
95
+ job: string;
96
+ everySeconds: number;
97
+ dropzone: string;
98
+ updatedAt: string;
99
+ sweep: {
100
+ pid: number;
101
+ startedAt: string;
102
+ finishedAt: string | null;
103
+ state: "running" | "finished" | "failed";
104
+ phase: "starting" | "walking" | "filing" | "done";
105
+ error?: string;
106
+ };
107
+ /** The app's accounts — what the `uid` on its web uploads names (`/api/upload/session`). */
108
+ accounts: {
109
+ id: string;
110
+ label: string;
111
+ }[];
112
+ /**
113
+ * The store's free space against the floor the sweep keeps, and what recently filed files'
114
+ * derivatives still hold back of it, until when — collections' linked pacing; `null` for a sweep
115
+ * that does not wait for room.
116
+ */
117
+ room: ReportRoom | null;
118
+ sources: ProgressSource[];
119
+ }
120
+ export interface ReportRoom {
121
+ freeBytes: number | null;
122
+ floorBytes: number;
123
+ spaceFactor: number;
124
+ owedBytes?: number;
125
+ owedUntil?: string | null;
126
+ }
127
+ export interface FileLine {
128
+ at: string;
129
+ source: string;
130
+ account: string;
131
+ /** Relative to the account folder. */
132
+ path: string;
133
+ bytes: number;
134
+ outcome: FileOutcome;
135
+ detail?: string;
136
+ itemId?: string;
137
+ /** From `found`'s `settled`, the first time the journal was started — not seen happening. */
138
+ backfilled?: true;
139
+ }
140
+ export interface QueueLine {
141
+ source: string;
142
+ path: string;
143
+ bytes: number;
144
+ state: FileState;
145
+ }
146
+ /** The source a file belongs to: its account plus the first segment of its path, or the loose files. */
147
+ export declare function sourceIdOf(accountId: string, relativePath: string): {
148
+ id: string;
149
+ label: string;
150
+ top: string | null;
151
+ };
152
+ export interface ReporterOptions {
153
+ /** `$FORGE_STATE/state/<app>-ingest` — station finds the report by that name. */
154
+ stateDir: string;
155
+ app: string;
156
+ /** The launchd job that runs the sweep. */
157
+ job: string;
158
+ everySeconds: number;
159
+ dropzone: string;
160
+ /** Each account folder. A one-owner dropzone is one account whose `dir` is the dropzone itself. */
161
+ accounts: readonly {
162
+ id: string;
163
+ label: string;
164
+ dir: string;
165
+ }[];
166
+ /** A linked source's drive: its volume, whether it is plugged in, and for a disk image the drive its file is on. */
167
+ driveOf?: (target: string) => SourceDrive | undefined;
168
+ room?: () => ReportRoom | null;
169
+ now?: () => number;
170
+ warn?: (line: string) => void;
171
+ pid?: number;
172
+ }
173
+ /**
174
+ * One sweep's reporter. `ingest.ts` makes it before the walk and hands its hooks to `sweepFiles`.
175
+ */
176
+ export declare function createIngestReporter<F extends ReportFile = ReportFile>(o: ReporterOptions): {
177
+ walking: () => void;
178
+ unreachable: (accountId: string, relativePath: string, target: string) => void;
179
+ found: (files: readonly F[], settled?: ((file: F) => SettledFile | undefined) | undefined) => void;
180
+ progress: {
181
+ waiting: (file: F, why: "done" | "room" | "copying" | "skipped" | "drive") => void;
182
+ uploading: (file: F, key: string) => void;
183
+ };
184
+ result: (file: F, result: ReportResult) => void;
185
+ finish: (error?: string | undefined) => void;
186
+ };
187
+ export type IngestReporter<F extends ReportFile = ReportFile> = ReturnType<typeof createIngestReporter<F>>;
188
+ export declare function readProgress(path: string): IngestProgress | null;