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.
- package/dist/server/activity/store.d.ts +1 -1
- package/dist/server/analytics/injectedScripts.d.ts +1 -1
- package/dist/server/analytics/injectedScripts.js +1 -1
- package/dist/server/analytics/webAnalytics.d.ts +1 -1
- package/dist/server/analytics/webAnalytics.js +1 -1
- package/dist/server/auth/loginThrottleDurable.d.ts +3 -3
- package/dist/server/auth/loginThrottleDurable.js +3 -3
- package/dist/server/auth/passwordCost.js +1 -1
- package/dist/server/ctgrChunkDurable.d.ts +1 -1
- package/dist/server/ctgrChunkDurable.js +1 -1
- package/dist/server/d1/backup.d.ts +1 -1
- package/dist/server/d1/backup.js +1 -1
- package/dist/server/d1/http.d.ts +2 -2
- package/dist/server/d1/http.js +2 -2
- package/dist/server/d1/invocation.js +1 -1
- package/dist/server/d1/limits.d.ts +1 -1
- package/dist/server/d1/limits.js +1 -1
- package/dist/server/d1/pullD1.d.ts +4 -1
- package/dist/server/d1/pullD1.js +5 -2
- package/dist/server/d1/scheduling.d.ts +1 -1
- package/dist/server/d1/scheduling.js +1 -1
- package/dist/server/d1/types.d.ts +1 -1
- package/dist/server/d1/types.js +1 -1
- package/dist/server/d1/values.d.ts +1 -1
- package/dist/server/d1/values.js +1 -1
- package/dist/server/dropzone/index.d.ts +1 -0
- package/dist/server/dropzone/index.js +1 -0
- package/dist/server/dropzone/report.d.ts +188 -0
- package/dist/server/dropzone/report.js +430 -0
- package/dist/server/dropzone/scan.d.ts +22 -3
- package/dist/server/dropzone/scan.js +46 -1
- package/dist/server/engagement/index.d.ts +1 -1
- package/dist/server/engagement/index.js +1 -1
- package/dist/server/guard/argon2Binding.js +1 -1
- package/dist/server/guard/kdfWorkerEntry.js +2 -2
- package/dist/server/incidents/index.d.ts +1 -1
- package/dist/server/incidents/index.js +1 -1
- package/dist/server/incidents/store.d.ts +1 -1
- package/dist/server/incidents/store.js +1 -1
- package/dist/server/jobs/timeout.d.ts +1 -1
- package/dist/server/jobs/timeout.js +1 -1
- package/dist/server/master-lock/accountsPage.d.ts +1 -1
- package/dist/server/master-lock/accountsPage.js +2 -2
- package/dist/server/master-lock/guard.js +1 -1
- package/dist/server/master-lock/lockPage.d.ts +1 -1
- package/dist/server/master-lock/lockPage.js +2 -2
- package/dist/server/master-lock/masterLock.d.ts +2 -2
- package/dist/server/master-lock/masterLock.js +2 -2
- package/dist/server/metrics/normalizeRoute.js +1 -1
- package/dist/server/metrics/telemetrySink.d.ts +2 -2
- package/dist/server/metrics/telemetrySink.js +1 -1
- package/dist/server/middleware/zValidator.js +2 -2
- package/dist/server/notifications/hub.js +1 -1
- package/dist/server/requestLog/requestMetrics.d.ts +2 -2
- package/dist/server/requestLog/requestMetrics.js +2 -2
- package/dist/server/retention/archive.d.ts +1 -1
- package/dist/server/retention/archive.js +2 -2
- package/dist/server/satellite/config.js +2 -2
- package/dist/server/satellite/door.d.ts +1 -1
- package/dist/server/sharing/contract.d.ts +1 -1
- package/dist/server/storage/binaryStore.d.ts +1 -1
- package/dist/server/storage/binaryStore.js +3 -3
- package/dist/server/storage/derivatives.d.ts +2 -2
- package/dist/server/storage/derivatives.js +2 -2
- package/dist/server/storage/files/adapter.d.ts +2 -2
- package/dist/server/storage/files/adapter.js +10 -10
- package/dist/server/storage/files/catalogue.d.ts +1 -1
- package/dist/server/storage/files/catalogue.js +4 -4
- package/dist/server/storage/files/chunkedUpload.d.ts +2 -2
- package/dist/server/storage/files/chunkedUpload.js +1 -1
- package/dist/server/storage/files/fileRoutes.d.ts +1 -1
- package/dist/server/storage/files/fileRoutes.js +4 -4
- package/dist/server/storage/files/mimeByExt.js +1 -1
- package/dist/server/storage/files/stack.d.ts +2 -2
- package/dist/server/storage/files/types.d.ts +4 -4
- package/dist/server/storage/files/types.js +1 -1
- package/dist/server/storage/index.js +1 -1
- package/dist/server/storage/objectStoreMediaStore.js +1 -1
- package/dist/server/storage/transcodeJobs.js +5 -5
- package/dist/server/storage/types.d.ts +1 -1
- package/dist/server/storage/types.js +1 -1
- package/dist/server/storage/videoDerivativeKeys.d.ts +1 -1
- package/dist/server/storage/videoDerivativeKeys.js +1 -1
- package/dist/server/storage/videoProcessor.js +1 -1
- package/dist/server/sync/status.d.ts +1 -1
- package/dist/server/zipStream.d.ts +1 -1
- package/dist/server/zipStream.js +1 -1
- package/docs/activity.md +2 -2
- package/docs/retention.md +2 -2
- package/package.json +1 -1
- package/src/leafSubpathsImportNothing.spec.ts +1 -1
- package/src/namedSubpathsResolve.spec.ts +1 -1
- package/src/noTimerDialsAPeer.spec.ts +1 -1
- package/src/nodeBuiltinsAreProbedByCalling.spec.ts +1 -1
- package/src/publishShape.spec.ts +1 -1
- package/src/server/activity/store.ts +1 -1
- package/src/server/analytics/injectedScripts.spec.ts +1 -1
- package/src/server/analytics/injectedScripts.ts +1 -1
- package/src/server/analytics/webAnalytics.ts +1 -1
- package/src/server/auth/loginThrottleDurable.ts +3 -3
- package/src/server/auth/passwordCost.ts +1 -1
- package/src/server/bench/cpuBudget.spec.ts +1 -1
- package/src/server/bench/tail.spec.ts +1 -1
- package/src/server/ctgrChunkDurable.ts +1 -1
- package/src/server/d1/backup.spec.ts +1 -1
- package/src/server/d1/backup.ts +1 -1
- package/src/server/d1/http.ts +2 -2
- package/src/server/d1/invocation.spec.ts +1 -1
- package/src/server/d1/invocation.ts +1 -1
- package/src/server/d1/limits.ts +1 -1
- package/src/server/d1/pullD1.spec.ts +9 -1
- package/src/server/d1/pullD1.ts +5 -2
- package/src/server/d1/scheduling.ts +1 -1
- package/src/server/d1/types.ts +1 -1
- package/src/server/d1/values.ts +1 -1
- package/src/server/dropzone/index.ts +8 -0
- package/src/server/dropzone/report.spec.ts +275 -0
- package/src/server/dropzone/report.ts +568 -0
- package/src/server/dropzone/scan.spec.ts +2 -2
- package/src/server/dropzone/scan.ts +68 -5
- package/src/server/engagement/engagement.spec.ts +1 -1
- package/src/server/engagement/index.ts +1 -1
- package/src/server/google-oauth/googleOAuth.spec.ts +1 -1
- package/src/server/guard/argon2Binding.ts +1 -1
- package/src/server/guard/kdfWorkerEntry.ts +2 -2
- package/src/server/incidents/index.ts +1 -1
- package/src/server/incidents/store.ts +1 -1
- package/src/server/jobs/timeout.ts +1 -1
- package/src/server/master-lock/accountsPage.spec.ts +2 -2
- package/src/server/master-lock/accountsPage.ts +2 -2
- package/src/server/master-lock/beaconNeverReachesTheWall.spec.ts +2 -2
- package/src/server/master-lock/guard.spec.ts +2 -2
- package/src/server/master-lock/guard.ts +1 -1
- package/src/server/master-lock/lockPage.spec.ts +1 -1
- package/src/server/master-lock/lockPage.ts +2 -2
- package/src/server/master-lock/masterLock.spec.ts +1 -1
- package/src/server/master-lock/masterLock.ts +2 -2
- package/src/server/master-lock/sessions.spec.ts +1 -1
- package/src/server/metrics/normalizeRoute.ts +1 -1
- package/src/server/metrics/telemetrySink.ts +3 -3
- package/src/server/middleware/bodyLimit.spec.ts +1 -1
- package/src/server/middleware/zValidator.spec.ts +3 -3
- package/src/server/middleware/zValidator.ts +3 -3
- package/src/server/notifications/hub.ts +1 -1
- package/src/server/requestLog/requestMetrics.spec.ts +2 -2
- package/src/server/requestLog/requestMetrics.ts +3 -3
- package/src/server/retention/archive.spec.ts +2 -2
- package/src/server/retention/archive.ts +2 -2
- package/src/server/satellite/config.ts +2 -2
- package/src/server/satellite/door.ts +1 -1
- package/src/server/satellite/satellite.spec.ts +1 -1
- package/src/server/sharing/contract.ts +1 -1
- package/src/server/storage/binaryServerProcessing.spec.ts +1 -1
- package/src/server/storage/binaryServerProcessing.ts +4 -4
- package/src/server/storage/binaryStore.spec.ts +6 -6
- package/src/server/storage/binaryStore.ts +4 -4
- package/src/server/storage/chunked.integration.spec.ts +2 -2
- package/src/server/storage/derivatives.ts +2 -2
- package/src/server/storage/fileUploadClient.integration.spec.ts +1 -1
- package/src/server/storage/files/adapter.photo.spec.ts +2 -2
- package/src/server/storage/files/adapter.spec.ts +3 -3
- package/src/server/storage/files/adapter.ts +10 -10
- package/src/server/storage/files/catalogue.spec.ts +1 -1
- package/src/server/storage/files/catalogue.ts +4 -4
- package/src/server/storage/files/chunkedUpload.spec.ts +5 -5
- package/src/server/storage/files/chunkedUpload.ts +3 -3
- package/src/server/storage/files/fileRoutes.spec.ts +3 -3
- package/src/server/storage/files/fileRoutes.ts +5 -5
- package/src/server/storage/files/mimeByExt.ts +1 -1
- package/src/server/storage/files/stack.ts +3 -3
- package/src/server/storage/files/types.ts +6 -6
- package/src/server/storage/index.ts +1 -1
- package/src/server/storage/objectStoreMediaStore.ts +1 -1
- package/src/server/storage/sources.ts +1 -1
- package/src/server/storage/transcodeJobs.ts +5 -5
- package/src/server/storage/types.ts +2 -2
- package/src/server/storage/uploadSession.spec.ts +1 -1
- package/src/server/storage/videoDerivativeKeys.spec.ts +3 -3
- package/src/server/storage/videoDerivativeKeys.ts +1 -1
- package/src/server/storage/videoProcessor.ts +1 -1
- package/src/server/sync/status.ts +1 -1
- package/src/server/sync/timer.spec.ts +1 -1
- package/src/server/worker-argon2/index.spec.ts +1 -1
- package/src/server/zipStream.spec.ts +2 -2
- package/src/server/zipStream.ts +1 -1
- package/src/shippedFilesAreTracked.spec.ts +2 -2
|
@@ -51,7 +51,7 @@ export type FilePage = {
|
|
|
51
51
|
items: FileRecord[];
|
|
52
52
|
nextCursor?: string;
|
|
53
53
|
};
|
|
54
|
-
/** Every listing order the
|
|
54
|
+
/** Every listing order the catalog understands — the single source of truth the route layer
|
|
55
55
|
* validates against and the `FileSort` union derives from. `recent` = newest first (default);
|
|
56
56
|
* `oldest` = oldest first; `name` = A→Z; `size` = largest first; `random` = a seeded shuffle
|
|
57
57
|
* (the seed is minted per session and folded into the cursor, so a visit reshuffles but its own
|
|
@@ -85,7 +85,7 @@ export type ListFilesOptions = {
|
|
|
85
85
|
/** Server-authoritative smart-view classification, computed ONCE at write time and stored.
|
|
86
86
|
* `isText` (a non-binary inline file) ⇒ code; else by mime. */
|
|
87
87
|
export declare function classifyFileType(mime: string, isText?: boolean): FileType;
|
|
88
|
-
/** The
|
|
88
|
+
/** The catalog contract. A SQLite implementation is the production default; the interface lets
|
|
89
89
|
* an app swap it. All calls are owner-scoped via {@link MediaCtx} (one tenant never sees another). */
|
|
90
90
|
/** Cheap owner-scoped aggregates (COUNT/SUM over the files table) — the admin
|
|
91
91
|
* surface's "site stats" source. */
|
|
@@ -111,7 +111,7 @@ export interface FileCatalogue {
|
|
|
111
111
|
tags?: string[];
|
|
112
112
|
}): Promise<FileRecord>;
|
|
113
113
|
/** Register bytes uploaded OUT OF BAND (a chunked upload sent direct to the backend) — insert the
|
|
114
|
-
* row + kick processing WITHOUT re-storing bytes (they already sit at the
|
|
114
|
+
* row + kick processing WITHOUT re-storing bytes (they already sit at the catalog's key for this
|
|
115
115
|
* id: fsSourceKey for video, fileBinaryKey otherwise). */
|
|
116
116
|
registerUploaded(ctx: MediaCtx, upload: {
|
|
117
117
|
id: string;
|
|
@@ -148,7 +148,7 @@ export interface FileCatalogue {
|
|
|
148
148
|
restore(ctx: MediaCtx, id: string): Promise<void>;
|
|
149
149
|
/** Ingest file(s) from a LOCAL path already on this host's disk (a directory imports every
|
|
150
150
|
* regular file inside it, recursively; a file imports just itself). Each imported file is
|
|
151
|
-
* tagged with its immediate containing folder name (the
|
|
151
|
+
* tagged with its immediate containing folder name (the catalog is flat — folder structure
|
|
152
152
|
* survives as a tag, not a tree) plus any `tags` passed. Unreadable/unsupported entries are
|
|
153
153
|
* skipped, not thrown — the return value reports both. */
|
|
154
154
|
importFromPath(ctx: MediaCtx, absPath: string, opts?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Every listing order the
|
|
1
|
+
/** Every listing order the catalog understands — the single source of truth the route layer
|
|
2
2
|
* validates against and the `FileSort` union derives from. `recent` = newest first (default);
|
|
3
3
|
* `oldest` = oldest first; `name` = A→Z; `size` = largest first; `random` = a seeded shuffle
|
|
4
4
|
* (the seed is minted per session and folded into the cursor, so a visit reshuffles but its own
|
|
@@ -9,7 +9,7 @@ export { DERIVATIVE_SUFFIXES, hlsMasterKeyFor, hlsPrefixFor, isDerivativeKey, po
|
|
|
9
9
|
export { createBinaryServerStore } from './binaryServerStore.js';
|
|
10
10
|
export { createBinaryServerProcessing, } from './binaryServerProcessing.js';
|
|
11
11
|
// The transcode API as a plain job client, for apps whose binaries do NOT live in the file
|
|
12
|
-
//
|
|
12
|
+
// catalog (apps/notes keys attachments by sha256). One derivative pipeline, two doors.
|
|
13
13
|
export { createTranscodeJobClient, } from './transcodeJobs.js';
|
|
14
14
|
export { createDiskStore } from './diskStore.js';
|
|
15
15
|
// The FileCatalogue: a SQLite-backed tagged flat file system over this storage layer — one
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// fork the whole transcode orchestrator onto a second store type, the asset
|
|
8
8
|
// `transcode` handler wraps its `ObjectStore` in this adapter and reuses the
|
|
9
9
|
// pipeline unchanged. There is deliberately NO `localPath`, so `processVideo`
|
|
10
|
-
//
|
|
10
|
+
// materializes the source by download — correct for a stream store where the
|
|
11
11
|
// bytes may live off-box (S3/R2).
|
|
12
12
|
const streamToBytes = async (stream) => new Uint8Array(await new Response(stream).arrayBuffer());
|
|
13
13
|
const bytesToStream = (bytes) => new ReadableStream({
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
// It was already here, inlined inside `createBinaryServerProcessing`, but only reachable
|
|
5
5
|
// through that module's two seams (`VideoProcessor` / `ImageDerivatives`), which are shaped
|
|
6
|
-
// for the cursedbelt file
|
|
7
|
-
//
|
|
8
|
-
// sha256 through satellite-kit's binary-store and has no
|
|
9
|
-
// the pipeline without either adopting the
|
|
6
|
+
// for the cursedbelt file CATALOG: they take a `MediaStore`, a `workDir`, an owner and a
|
|
7
|
+
// catalog id. An app that stores binaries some other way — apps/notes keys attachments by
|
|
8
|
+
// sha256 through satellite-kit's binary-store and has no catalog at all — could not reach
|
|
9
|
+
// the pipeline without either adopting the catalog or writing a second HTTP client.
|
|
10
10
|
//
|
|
11
|
-
// So the transport lives here and the
|
|
11
|
+
// So the transport lives here and the catalog seams are built on top of it. There is ONE
|
|
12
12
|
// derivative pipeline in the fleet, and this is its entry point.
|
|
13
13
|
//
|
|
14
14
|
// ── Why binary-server rather than deriving locally ──────────────────────────────────────
|
|
@@ -173,7 +173,7 @@ export interface PhotoSource {
|
|
|
173
173
|
recordView?(ctx: MediaCtx, photoId: string): Promise<void>;
|
|
174
174
|
}
|
|
175
175
|
/** A source of MIXED media (photos + videos) for a combined gallery — the union of
|
|
176
|
-
* {@link MediaSource} and {@link PhotoSource} over ONE
|
|
176
|
+
* {@link MediaSource} and {@link PhotoSource} over ONE catalog. `list`/`resolve`
|
|
177
177
|
* yield `GalleryMedia` (a `mediaKind`-tagged photo|video), and a `kind` filter narrows
|
|
178
178
|
* to just photos or just videos. Same cursor/tag/sort listing contract as its siblings. */
|
|
179
179
|
export interface MediaGallerySource {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// no packages resolvable at all and fails if it throws, so an `import` here that survives
|
|
12
12
|
// transpilation (anything that is not `import type`) turns that spec red rather than turning
|
|
13
13
|
// up in a consumer's install. The subpath exists because `./server/storage`'s own index is a
|
|
14
|
-
// barrel: it reaches `streamToken` → `auth/jwt` → jose, the whole SQLite file
|
|
14
|
+
// barrel: it reaches `streamToken` → `auth/jwt` → jose, the whole SQLite file catalog under
|
|
15
15
|
// `files/`, and a lazily-imported `sharp` — while an app that wants only the SHAPE of a file
|
|
16
16
|
// token (apps/collections wanted exactly `FileTokenClaims`, a type TypeScript erases) was made
|
|
17
17
|
// to install a one-time-password library to get it. Add types here freely; add a value import
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* FileCatalogue: a caller that holds an owner and an item id, whose derivatives live in their
|
|
27
27
|
* own top-level namespaces. This module addresses a caller that holds a binary-server KEY and
|
|
28
28
|
* derives sibling names from it, which is what makes "ask /meta for a name you computed" work
|
|
29
|
-
* with no
|
|
29
|
+
* with no catalog at all.
|
|
30
30
|
*
|
|
31
31
|
* Two consumers, two shapes, both correct:
|
|
32
32
|
* · `fs*` — cursedbelt's own FileCatalogue / the `library` transcode strategy.
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* FileCatalogue: a caller that holds an owner and an item id, whose derivatives live in their
|
|
27
27
|
* own top-level namespaces. This module addresses a caller that holds a binary-server KEY and
|
|
28
28
|
* derives sibling names from it, which is what makes "ask /meta for a name you computed" work
|
|
29
|
-
* with no
|
|
29
|
+
* with no catalog at all.
|
|
30
30
|
*
|
|
31
31
|
* Two consumers, two shapes, both correct:
|
|
32
32
|
* · `fs*` — cursedbelt's own FileCatalogue / the `library` transcode strategy.
|
|
@@ -64,7 +64,7 @@ export async function processVideo(opts) {
|
|
|
64
64
|
await mkdir(jobDir, { recursive: true });
|
|
65
65
|
try {
|
|
66
66
|
report('processing', 1);
|
|
67
|
-
// 1.
|
|
67
|
+
// 1. Materialize the source locally for ffmpeg (use the backend's own path if local).
|
|
68
68
|
let srcPath = (await store.localPath?.(sourceKey)) ?? null;
|
|
69
69
|
if (!srcPath) {
|
|
70
70
|
const bytes = await store.get(sourceKey);
|
|
@@ -43,7 +43,7 @@ export interface SyncStatusReporter {
|
|
|
43
43
|
* a claim about failures that did not happen. But "a peer authenticated here" is
|
|
44
44
|
* something that happened to the database, and forgetting it produced the owner's
|
|
45
45
|
* 2026-08-16 report — prod saying *"Awaiting first sync"* over a vault he had used
|
|
46
|
-
* for weeks. The badge's own words are "your Mac has not
|
|
46
|
+
* for weeks. The badge's own words are "your Mac has not dialed since this server
|
|
47
47
|
* last restarted", which is true and which nobody reads as anything but "this has
|
|
48
48
|
* never synced". A receiver restarts on every deploy, and the dialer runs every 5
|
|
49
49
|
* minutes only while the Mac is awake — so the window in which a perfectly converged
|
|
@@ -87,7 +87,7 @@ export declare function dosDateTime(when: Date | string | null | undefined): {
|
|
|
87
87
|
* want `Notes/Summary.md` produce `Summary.md` and `Summary (2).md`, because a zip with two
|
|
88
88
|
* identical names extracts as one file, silently losing the other. A duplicate FOLDER is written
|
|
89
89
|
* once: its files already land in it. Names are compared the way the person's disk will compare
|
|
90
|
-
* them — case-folded and Unicode-
|
|
90
|
+
* them — case-folded and Unicode-normalized, since macOS and Windows both treat `Todo.md` and
|
|
91
91
|
* `todo.md` as ONE file — so the later one is numbered rather than overwriting the first on unzip.
|
|
92
92
|
*
|
|
93
93
|
* A member that cannot be read (its `open()` returns `null` or throws, or the caller yielded it
|
package/dist/server/zipStream.js
CHANGED
|
@@ -181,7 +181,7 @@ function asStream(body) {
|
|
|
181
181
|
* want `Notes/Summary.md` produce `Summary.md` and `Summary (2).md`, because a zip with two
|
|
182
182
|
* identical names extracts as one file, silently losing the other. A duplicate FOLDER is written
|
|
183
183
|
* once: its files already land in it. Names are compared the way the person's disk will compare
|
|
184
|
-
* them — case-folded and Unicode-
|
|
184
|
+
* them — case-folded and Unicode-normalized, since macOS and Windows both treat `Todo.md` and
|
|
185
185
|
* `todo.md` as ONE file — so the later one is numbered rather than overwriting the first on unzip.
|
|
186
186
|
*
|
|
187
187
|
* A member that cannot be read (its `open()` returns `null` or throws, or the caller yielded it
|
package/docs/activity.md
CHANGED
|
@@ -24,7 +24,7 @@ value of the column:
|
|
|
24
24
|
| `error` | the app **failed** to do what it meant to do | whoever maintains the app |
|
|
25
25
|
|
|
26
26
|
A refusal recorded as `error` makes the app look broken exactly when it worked, and buries its
|
|
27
|
-
real failures under correct
|
|
27
|
+
real failures under correct behavior; a failure recorded as `denied` hides a bug as a policy.
|
|
28
28
|
`roms` records BOTH halves of an upload for this reason: an accepted one puts a file on the
|
|
29
29
|
owner's storage under his name, and a refused one — `denied` — is the row that answers "I tried
|
|
30
30
|
to add that game weeks ago".
|
|
@@ -33,7 +33,7 @@ to add that game weeks ago".
|
|
|
33
33
|
|
|
34
34
|
Identical to `cursedbelt-core/sharing`'s `ShareResource`, so a resource passes from one
|
|
35
35
|
primitive to the other with no translation (`activityFromShareEvent`). `app` is on every row so
|
|
36
|
-
a merge across apps stays
|
|
36
|
+
a merge across apps stays labeled.
|
|
37
37
|
|
|
38
38
|
## 4. Describing an event is the library's job
|
|
39
39
|
|
package/docs/retention.md
CHANGED
|
@@ -17,7 +17,7 @@ Why by category rather than by table:
|
|
|
17
17
|
|
|
18
18
|
- **Long-term data is protected by ABSENCE.** There is no category that can describe a note, a
|
|
19
19
|
setting, a password, a save state, a playlist or a vault entry. "Should this table have a
|
|
20
|
-
policy?" is answered by whether an honest category exists, not by somebody's
|
|
20
|
+
policy?" is answered by whether an honest category exists, not by somebody's judgment on
|
|
21
21
|
the day — and a new table is safe by default, because it is not swept until it is declared.
|
|
22
22
|
- **The number is the category's, not the app's.** Every deleting category defaults to the
|
|
23
23
|
owner's two-week standard or shorter. A deleting category that wanted a longer default would
|
|
@@ -53,7 +53,7 @@ it is that the thing should not be accumulating.
|
|
|
53
53
|
|
|
54
54
|
## 6. A threshold is tuned against the CORPUS, never against the story
|
|
55
55
|
|
|
56
|
-
`apps/music/scripts/backup.ts:172-190` records the failure: a refusal keyed on "a
|
|
56
|
+
`apps/music/scripts/backup.ts:172-190` records the failure: a refusal keyed on "a catalog
|
|
57
57
|
with tracks and no organizing work must be a stage database" was written from the story, and
|
|
58
58
|
the live corpus at cutover (5,391 tracks, 0 playlists, 0 tags) would have tripped it nightly on
|
|
59
59
|
a healthy library. Before a retention or refusal number ships, measure it against what the app
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedbelt-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.49.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The app-facing Bun/Hono server tier of the cursedbelt split — storage, sharing, activity, guard, sync. React-free; cursedbelt-core below it.",
|
|
@@ -141,7 +141,7 @@ const LEAVES = [
|
|
|
141
141
|
* in 4.1.0 from five app-side copies, and it is the module that decides whether a ROM
|
|
142
142
|
* byte, a photograph, a song and a scanned document are readable — so every app takes
|
|
143
143
|
* it, and none of them may pay `sharp`/`otplib`/`kysely` for the privilege. It sits
|
|
144
|
-
* in `src/server/storage/` beside the file-
|
|
144
|
+
* in `src/server/storage/` beside the file-catalog and transcode graph, which is
|
|
145
145
|
* exactly the barrel this must never be reached through: `./storage`'s index is heavy
|
|
146
146
|
* and this module's whole point is that it costs `node:crypto` and nothing else.
|
|
147
147
|
* Its batched `/internal/ops/meta` client (4.47.0) is a sibling that imports nothing.
|
|
@@ -103,7 +103,7 @@ describe('subpaths named in this repo resolve', () => {
|
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
it('knows what the manifest exports', () => {
|
|
106
|
-
// If `exports` is ever read wrong, every
|
|
106
|
+
// If `exports` is ever read wrong, every offense below silently becomes one.
|
|
107
107
|
expect(exported.has('')).toBe(true); // the "." root entry
|
|
108
108
|
expect(exported.has('/master-lock')).toBe(true);
|
|
109
109
|
expect(exported.has('/react')).toBe(false); // the react tier stayed in `cursedbelt` at the 2026-09-15 split
|
|
@@ -46,7 +46,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
46
46
|
* dependency: `sync/timer.ts`'s callback calls `deps.sync(peer)`, which dials, and
|
|
47
47
|
* that is legitimate (it is the push). A reintroduced `deps.checkRequest(peer)`
|
|
48
48
|
* would be structurally identical and this check would miss it. Nothing static can
|
|
49
|
-
* separate those two — so the strict measurement is **
|
|
49
|
+
* separate those two — so the strict measurement is **behavioral** and lives in
|
|
50
50
|
* `sync/timer.spec.ts` ("a healthy peer with no local news is dialed ONCE at boot,
|
|
51
51
|
* then never", 24 simulated hours) and `sync/signal.spec.ts` ("a connected client
|
|
52
52
|
* issues exactly ONE outbound request, forever"). Those two bound the sync engine
|
|
@@ -46,7 +46,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
46
46
|
* ## The excuse, and why there is one
|
|
47
47
|
*
|
|
48
48
|
* A line carrying `probe-by-calling:ignore` (on it, or on the line above) is allowed — for
|
|
49
|
-
* the one honest use left:
|
|
49
|
+
* the one honest use left: labeling. `cpuClock.ts` decides by calling and then uses a
|
|
50
50
|
* presence check only to say `(absent)` or `(throws)` in the clock's source string. Excuse
|
|
51
51
|
* the LINE, never delete the rule.
|
|
52
52
|
*
|
package/src/publishShape.spec.ts
CHANGED
|
@@ -65,7 +65,7 @@ describe('publish shape', () => {
|
|
|
65
65
|
// npm rejects a "./"-prefixed bin value, calls the NAME invalid, and drops
|
|
66
66
|
// the entry — with a warning, not an error. The package publishes fine and
|
|
67
67
|
// installs with no CLI at all. Invisible under a file: link, where the bin
|
|
68
|
-
// is linked from the source manifest before npm ever
|
|
68
|
+
// is linked from the source manifest before npm ever normalizes it.
|
|
69
69
|
const bin = (pkg as { bin?: Record<string, string> }).bin ?? {};
|
|
70
70
|
const prefixed = Object.entries(bin).filter(([, v]) => v.startsWith('./'));
|
|
71
71
|
expect(
|
|
@@ -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`.
|
|
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
|
|
@@ -9,7 +9,7 @@ const PAGE = "https://collections.cursedalchemy.com/";
|
|
|
9
9
|
* The tag Cloudflare's Automatic Setup appended, byte-for-byte as the zone emitted it on
|
|
10
10
|
* 2026-09-18 — pinned path, integrity hash, `crossorigin` and all. It is kept in its
|
|
11
11
|
* AUTOMATIC spelling on purpose: this is the shape that was arriving unasked-for, and a
|
|
12
|
-
* checker that only
|
|
12
|
+
* checker that only recognized the manual snippet would go quiet the moment somebody turned
|
|
13
13
|
* auto-install back on.
|
|
14
14
|
*/
|
|
15
15
|
const BEACON =
|
|
@@ -41,7 +41,7 @@ export interface InjectedScript {
|
|
|
41
41
|
* Every `<script src=…>` in `html` whose origin is NOT `pageUrl`'s.
|
|
42
42
|
*
|
|
43
43
|
* Inline scripts are ignored: they are the page's own (most shells here ship one, a pre-paint
|
|
44
|
-
*
|
|
44
|
+
* color-scheme script) and a CSP that refuses them is a different finding from this one.
|
|
45
45
|
* `data:` and `blob:` are ignored for the same reason — neither is a host anything could have
|
|
46
46
|
* injected.
|
|
47
47
|
*/
|
|
@@ -139,7 +139,7 @@ export const WEB_ANALYTICS_PUBLIC_HOST = "cursedalchemy.com";
|
|
|
139
139
|
*
|
|
140
140
|
* A device in GET-only mode (`cursedbelt-core/ctgr-client`) sits behind something that drops
|
|
141
141
|
* every non-GET, and the beacon reports with a POST to the page's `/cdn-cgi/rum`. It cannot be
|
|
142
|
-
*
|
|
142
|
+
* tunneled the way our own API is — the script is Cloudflare's — so there it only ever failed,
|
|
143
143
|
* a red line per page view, and recorded nothing. Not loading it loses no data (2026-10-08).
|
|
144
144
|
*
|
|
145
145
|
* 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
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
*
|
|
@@ -328,7 +328,7 @@ describe('the bench runner', () => {
|
|
|
328
328
|
*
|
|
329
329
|
* Filed 2026-09-19 by the `collections` port — the first app to mount this harness — which
|
|
330
330
|
* had to leave `POST /api/duplicates/rescan` and `POST /api/recycle/purge`, the only two
|
|
331
|
-
* routes in it whose cost is O(
|
|
331
|
+
* routes in it whose cost is O(catalog), declared but unbenched for exactly this reason.
|
|
332
332
|
*/
|
|
333
333
|
describe('a destructive case — the fixture rebuild between iterations', () => {
|
|
334
334
|
/** ~4 CPU-ms per item held, ~0 CPU-ms when the library is empty. */
|
|
@@ -55,7 +55,7 @@ describe('recordTailTraces', () => {
|
|
|
55
55
|
expect(report.routes.map((r) => r.key)).toEqual(['GET /api/items/:id']);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it('🔴 refuses a PROXY recorder — real numbers may not be
|
|
58
|
+
it('🔴 refuses a PROXY recorder — real numbers may not be labeled a proxy, nor the reverse', () => {
|
|
59
59
|
const recorder = createCpuRecorder({ clock: processCpuClock(), config: BUDGETS });
|
|
60
60
|
expect(() => recordTailTraces(recorder, [])).toThrow(/is a PROXY/);
|
|
61
61
|
});
|
|
@@ -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
|
|
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.
|
|
@@ -98,7 +98,7 @@ describe('the D1 half records a coordinate instead of copying bytes', () => {
|
|
|
98
98
|
|
|
99
99
|
test('🔴 it reports needsPeriodicCapture: false — Time Travel is automatic', () => {
|
|
100
100
|
// A nightly no-op job logging "backup complete" is worse than no job, because it
|
|
101
|
-
// reads as evidence. A scheduler must
|
|
101
|
+
// reads as evidence. A scheduler must honor this flag.
|
|
102
102
|
expect(createTimeTravelBackup({ databaseName: 'patterns' }).needsPeriodicCapture).toBe(false);
|
|
103
103
|
});
|
|
104
104
|
|
package/src/server/d1/backup.ts
CHANGED
|
@@ -67,7 +67,7 @@ export interface TimeTravelOpts {
|
|
|
67
67
|
/**
|
|
68
68
|
* The D1 implementation: record the coordinate, because retention is automatic.
|
|
69
69
|
*
|
|
70
|
-
* 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must
|
|
70
|
+
* 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must honor that rather
|
|
71
71
|
* than calling `capture()` on a timer — a nightly no-op job that logs "backup complete"
|
|
72
72
|
* is worse than no job, because it reads as evidence.
|
|
73
73
|
*/
|
package/src/server/d1/http.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
@@ -129,7 +129,7 @@ describe('the per-invocation query budget', () => {
|
|
|
129
129
|
expect(db.used).toBe(0);
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
test('a budget above D1\'s real cap is refused rather than
|
|
132
|
+
test('a budget above D1\'s real cap is refused rather than honored', () => {
|
|
133
133
|
expect(() => perInvocation(base, { max: LIMITS.queriesPerInvocation + 1 })).toThrow(D1LimitError);
|
|
134
134
|
expect(() => perInvocation(base, { max: 0 })).toThrow(RangeError);
|
|
135
135
|
expect(() => perInvocation(base, { max: 1.5 })).toThrow(RangeError);
|
|
@@ -170,7 +170,7 @@ export function perInvocation(db: D1LikeDatabase, opts: { max?: number } = {}):
|
|
|
170
170
|
'queries per Worker invocation',
|
|
171
171
|
max,
|
|
172
172
|
LIMITS.queriesPerInvocation,
|
|
173
|
-
'A budget above D1\'s own cap cannot be
|
|
173
|
+
'A budget above D1\'s own cap cannot be honored — the service refuses first. Lower it, or split the work across invocations.',
|
|
174
174
|
);
|
|
175
175
|
}
|
|
176
176
|
const budget = new Budget(max);
|
package/src/server/d1/limits.ts
CHANGED
|
@@ -226,7 +226,7 @@ export function chunkForBind<T>(items: readonly T[], paramsPerItem: number): T[]
|
|
|
226
226
|
* `WHERE … ORDER BY … LIMIT ? OFFSET ?` page and the `COUNT(*)` beside it), and on a write
|
|
227
227
|
* it trades one atomic statement for a batch that is atomic only per chunk. `json_each`
|
|
228
228
|
* over a JSON array is one parameter however long the list is, keeps the statement whole,
|
|
229
|
-
* and SQLite still drives the column's index through the
|
|
229
|
+
* and SQLite still drives the column's index through the materialized set.
|
|
230
230
|
*
|
|
231
231
|
* The array travels as one TEXT value, so the ceiling moves from 100 ids to
|
|
232
232
|
* `LIMITS.valueBytes` (2 MB) of JSON — about 70,000 of this fleet's 25-character ids — and
|
|
@@ -324,7 +324,7 @@ describe('pulling D1 down — paged SELECTs, table by table, never an export', (
|
|
|
324
324
|
|
|
325
325
|
test('a page that blips is asked again at the SAME size — a wire failure is not a page too large', async () => {
|
|
326
326
|
const source = live("INSERT INTO items VALUES ('i1', 'a');");
|
|
327
|
-
// wrangler's
|
|
327
|
+
// wrangler's colored form, as patterns' log has it.
|
|
328
328
|
const { run, seen } = blipping(source, (sql) => sql.includes('FROM "items"'), 1, '✘ \u001b[1mfetch failed\u001b[0m');
|
|
329
329
|
const slept: number[] = [];
|
|
330
330
|
await pullWaiting(scratch(), run, slept);
|
|
@@ -336,6 +336,14 @@ describe('pulling D1 down — paged SELECTs, table by table, never an export', (
|
|
|
336
336
|
expect(slept).toEqual([WAITS[0] as number]);
|
|
337
337
|
});
|
|
338
338
|
|
|
339
|
+
test("🔴 wrangler crashing on `setTypeOfService EINVAL` is a dropped connection, waited out (vault, 2026-10-23)", async () => {
|
|
340
|
+
const source = live("INSERT INTO items VALUES ('i1', 'a');");
|
|
341
|
+
const said = 'error: could not list D1\'s tables: …\nerror: setTypeOfService EINVAL\n errno: -22,\n syscall: "setTypeOfService",\n code: "EINVAL"';
|
|
342
|
+
const slept: number[] = [];
|
|
343
|
+
await pullWaiting(scratch(), blipping(source, (sql) => sql.includes('sqlite_master'), 1, said).run, slept);
|
|
344
|
+
expect(slept).toEqual([WAITS[0] as number]);
|
|
345
|
+
});
|
|
346
|
+
|
|
339
347
|
test('a wire that stays down still REFUSES, with its own words, after every wait', async () => {
|
|
340
348
|
const source = live("INSERT INTO items VALUES ('i1', 'a');");
|
|
341
349
|
const slept: number[] = [];
|
package/src/server/d1/pullD1.ts
CHANGED
|
@@ -244,12 +244,15 @@ export const TRANSIENT_WAITS_MS: readonly number[] = [5_000, 20_000, 60_000];
|
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
246
|
* A failure of the WIRE between this Mac and Cloudflare, not an answer from D1 — which asking
|
|
247
|
-
* again a little later fixes.
|
|
247
|
+
* again a little later fixes. `setTypeOfService EINVAL` is one in disguise: undici sets the socket's
|
|
248
|
+
* TOS before every request, and macOS answers `setsockopt` on a connection the peer already reset
|
|
249
|
+
* with EINVAL — so under Bun a dropped connection crashes wrangler with it instead of ECONNRESET
|
|
250
|
+
* (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
|
|
248
251
|
* large, bad SQL, auth) is never retried here, so a page refused for its size still halves at
|
|
249
252
|
* once instead of sleeping ~1.5 minutes per halving.
|
|
250
253
|
*/
|
|
251
254
|
export const isTransient = (message: string): boolean =>
|
|
252
|
-
/fetch failed|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|socket hang up|network connection was lost/i.test(
|
|
255
|
+
/fetch failed|ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|socket hang up|network connection was lost|setTypeOfService EINVAL/i.test(
|
|
253
256
|
message,
|
|
254
257
|
);
|
|
255
258
|
|
|
@@ -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
|
|
34
|
+
* a minute, which would change behavior in production and nowhere else.
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
import type { D1LikeDatabase } from './types.js';
|
package/src/server/d1/types.ts
CHANGED
|
@@ -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
|
|
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.
|
package/src/server/d1/values.ts
CHANGED
|
@@ -97,7 +97,7 @@ const LEADING_NOISE = /^(?:\s|--[^\n]*\n?|\/\*[\s\S]*?\*\/)+/;
|
|
|
97
97
|
* Only a leading `SELECT` is claimed, because that is the one keyword that is
|
|
98
98
|
* unambiguous: `WITH … INSERT … RETURNING` and `INSERT … RETURNING` both return rows AND
|
|
99
99
|
* write. Anything this returns `false` for is measured exactly instead (see
|
|
100
|
-
* `local.ts`), so a statement shape this does not
|
|
100
|
+
* `local.ts`), so a statement shape this does not recognize costs two extra queries —
|
|
101
101
|
* never a wrong number.
|
|
102
102
|
*/
|
|
103
103
|
export const isPureReadSql = (sql: string): boolean => /^select\b/i.test(sql.replace(LEADING_NOISE, ''));
|
|
@@ -28,3 +28,11 @@ export {
|
|
|
28
28
|
type DuplicateVerdict,
|
|
29
29
|
type DuplicateQuestion,
|
|
30
30
|
} from "./duplicates.js";
|
|
31
|
+
export {
|
|
32
|
+
createIngestReporter,
|
|
33
|
+
FILES_JOURNAL,
|
|
34
|
+
type FileOutcome,
|
|
35
|
+
type IngestReporter,
|
|
36
|
+
type ReportFile,
|
|
37
|
+
type SourceDrive,
|
|
38
|
+
} from "./report.js";
|