@catalyst-cloud/sdk 0.7.0 → 0.8.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 (74) hide show
  1. package/README.md +92 -0
  2. package/dist/browser.d.ts +9 -0
  3. package/dist/browser.d.ts.map +1 -0
  4. package/dist/browser.js +24 -0
  5. package/dist/browser.js.map +1 -0
  6. package/dist/live-sync-client.d.ts +128 -9
  7. package/dist/live-sync-client.d.ts.map +1 -1
  8. package/dist/live-sync-client.js +369 -51
  9. package/dist/live-sync-client.js.map +1 -1
  10. package/dist/replica/browser/apply.d.ts +29 -0
  11. package/dist/replica/browser/apply.d.ts.map +1 -0
  12. package/dist/replica/browser/apply.js +59 -0
  13. package/dist/replica/browser/apply.js.map +1 -0
  14. package/dist/replica/browser/browser-lock.d.ts +25 -0
  15. package/dist/replica/browser/browser-lock.d.ts.map +1 -0
  16. package/dist/replica/browser/browser-lock.js +91 -0
  17. package/dist/replica/browser/browser-lock.js.map +1 -0
  18. package/dist/replica/browser/browser-replica.d.ts +237 -0
  19. package/dist/replica/browser/browser-replica.d.ts.map +1 -0
  20. package/dist/replica/browser/browser-replica.js +952 -0
  21. package/dist/replica/browser/browser-replica.js.map +1 -0
  22. package/dist/replica/browser/db.worker.d.ts +2 -0
  23. package/dist/replica/browser/db.worker.d.ts.map +1 -0
  24. package/dist/replica/browser/db.worker.js +40 -0
  25. package/dist/replica/browser/db.worker.js.map +1 -0
  26. package/dist/replica/browser/delta-queue.d.ts +187 -0
  27. package/dist/replica/browser/delta-queue.d.ts.map +1 -0
  28. package/dist/replica/browser/delta-queue.js +328 -0
  29. package/dist/replica/browser/delta-queue.js.map +1 -0
  30. package/dist/replica/browser/ports.d.ts +39 -0
  31. package/dist/replica/browser/ports.d.ts.map +1 -0
  32. package/dist/replica/browser/ports.js +144 -0
  33. package/dist/replica/browser/ports.js.map +1 -0
  34. package/dist/replica/browser/protocol.d.ts +129 -0
  35. package/dist/replica/browser/protocol.d.ts.map +1 -0
  36. package/dist/replica/browser/protocol.js +12 -0
  37. package/dist/replica/browser/protocol.js.map +1 -0
  38. package/dist/replica/browser/seed-read-gate.d.ts +13 -0
  39. package/dist/replica/browser/seed-read-gate.d.ts.map +1 -0
  40. package/dist/replica/browser/seed-read-gate.js +36 -0
  41. package/dist/replica/browser/seed-read-gate.js.map +1 -0
  42. package/dist/replica/browser/seed-session.d.ts +23 -0
  43. package/dist/replica/browser/seed-session.d.ts.map +1 -0
  44. package/dist/replica/browser/seed-session.js +57 -0
  45. package/dist/replica/browser/seed-session.js.map +1 -0
  46. package/dist/replica/browser/snapshot-stream.d.ts +24 -0
  47. package/dist/replica/browser/snapshot-stream.d.ts.map +1 -0
  48. package/dist/replica/browser/snapshot-stream.js +113 -0
  49. package/dist/replica/browser/snapshot-stream.js.map +1 -0
  50. package/dist/replica/browser/sqlite-db.d.ts +9 -0
  51. package/dist/replica/browser/sqlite-db.d.ts.map +1 -0
  52. package/dist/replica/browser/sqlite-db.js +28 -0
  53. package/dist/replica/browser/sqlite-db.js.map +1 -0
  54. package/dist/replica/browser/support.d.ts +2 -0
  55. package/dist/replica/browser/support.d.ts.map +1 -0
  56. package/dist/replica/browser/support.js +30 -0
  57. package/dist/replica/browser/support.js.map +1 -0
  58. package/dist/replica/browser/validate.d.ts +17 -0
  59. package/dist/replica/browser/validate.d.ts.map +1 -0
  60. package/dist/replica/browser/validate.js +47 -0
  61. package/dist/replica/browser/validate.js.map +1 -0
  62. package/dist/replica/browser/worker-core.d.ts +10 -0
  63. package/dist/replica/browser/worker-core.d.ts.map +1 -0
  64. package/dist/replica/browser/worker-core.js +181 -0
  65. package/dist/replica/browser/worker-core.js.map +1 -0
  66. package/dist/replica/catalyst-replica.d.ts +6 -9
  67. package/dist/replica/catalyst-replica.d.ts.map +1 -1
  68. package/dist/replica/catalyst-replica.js +6 -15
  69. package/dist/replica/catalyst-replica.js.map +1 -1
  70. package/dist/replica/migration-shape.d.ts +11 -0
  71. package/dist/replica/migration-shape.d.ts.map +1 -0
  72. package/dist/replica/migration-shape.js +25 -0
  73. package/dist/replica/migration-shape.js.map +1 -0
  74. package/package.json +16 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-replica.js","sourceRoot":"","sources":["../../../src/replica/browser/browser-replica.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,qGAAqG;AACrG,aAAa;AACb,EAAE;AACF,qGAAqG;AACrG,qGAAqG;AACrG,mEAAmE;AACnE,uGAAuG;AACvG,oGAAoG;AACpG,uGAAuG;AACvG,0CAA0C;AAC1C,oGAAoG;AACpG,uGAAuG;AACvG,0BAA0B;AAC1B,EAAE;AACF,mGAAmG;AACnG,oGAAoG;AACpG,+FAA+F;AAC/F,EAAE;AACF,4FAA4F;AAC5F,sGAAsG;AACtG,sGAAsG;AACtG,4DAA4D;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAY3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAA0B,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD;qEACqE;AACrE,MAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C;uGACuG;AACvG,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,gCAAgC,GAAG,MAAM,CAAC;AAEhD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,6BAA6B,GAAG,OAAO,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IAC1D,aAAa;IACb,kBAAkB;IAClB,YAAY;CACb,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,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AAC;QACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,EAAE,OAAO,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,mGAAmG;QACnG,iGAAiG;QACjG,mEAAmE;QACnE,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,MAAM,GAAG,GAAS,EAAE;YACxB,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,SAAS,EAAE,CAAC;YACnB,IAAI,EAAE,OAAO,EAAE,CAAC;QAClB,CAAC,CAAC;QACF,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAgC,EAAE,EAAE;gBACtE,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE;oBAAE,MAAM,EAAE,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,MAAM,QAAQ,GAAa,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;YAC9D,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QACD,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=db.worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.worker.d.ts","sourceRoot":"","sources":["../../../src/replica/browser/db.worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ // replica/browser/db.worker.ts — the OPFS replica's Worker entry point (CTC-51 → CTC-114, ADR-0002
2
+ // browser twin of the node CatalystReplica). SAHPool's OPFS SyncAccessHandles are Worker-only, so the
3
+ // WHOLE replica DB lives here and the main thread (browser-replica.ts) drives it over postMessage
4
+ // using the protocol.ts contract. buildIssuesView / buildIssueDetail / buildPullsView run UNCHANGED
5
+ // over the wasm SqlExecutor — the load-bearing ADR-0002 "same query, four runtimes" proof, in the
6
+ // browser.
7
+ //
8
+ // All dispatch logic lives in worker-core.ts (injected opener, so it is unit-tested over a `:memory:`
9
+ // DB); this entry only binds it to the real OPFS opener and the postMessage envelope.
10
+ //
11
+ // PACKAGING (CTC-114): consumers reach this via `new Worker(new URL("./db.worker.js",
12
+ // import.meta.url), { type: "module" })` in browser-replica.ts — the portable idiom Vite, webpack 5
13
+ // and Rollup all statically detect and emit as a separate worker chunk. The `@sqlite.org/sqlite-wasm`
14
+ // import below (a peer dependency) is resolved by the CONSUMER's bundler inside that chunk, and its
15
+ // .wasm asset rides the consumer's asset pipeline.
16
+ /// <reference lib="webworker" />
17
+ import { openReplica } from "./sqlite-db.js";
18
+ import { createWorkerCore } from "./worker-core.js";
19
+ const core = createWorkerCore((request) => openReplica(request.dbPath, request.directory));
20
+ /** The single message handler — settle every request into an ok/err envelope keyed by its id. */
21
+ self.addEventListener("message", (event) => {
22
+ const { id, request } = event.data;
23
+ core
24
+ .handle(request)
25
+ .then((result) => {
26
+ const ok = { id, ok: true, result };
27
+ self.postMessage(ok);
28
+ })
29
+ .catch((err) => {
30
+ // Serialize the REAL cause — the client rethrows this message, and a bare "error" with no
31
+ // diagnosable reason was a CTC-51 pain point.
32
+ const fail = {
33
+ id,
34
+ ok: false,
35
+ error: err instanceof Error ? err.message : String(err),
36
+ };
37
+ self.postMessage(fail);
38
+ });
39
+ });
40
+ //# sourceMappingURL=db.worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.worker.js","sourceRoot":"","sources":["../../../src/replica/browser/db.worker.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,sGAAsG;AACtG,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A live delta as it rides into the worker: the wire record plus its change_log seq. */
3
+ export type SeqChange = WireChange & {
4
+ seq: number;
5
+ };
6
+ /**
7
+ * Largest number of deltas handed to the worker in ONE applyChanges RPC.
8
+ *
9
+ * The cap is about the CLONE, not the transaction — the worker already wraps a whole `changes` array
10
+ * in a single transaction. `changes` is structured-cloned across the worker boundary and `issues` /
11
+ * `issue_history` rows carry the provider's full `raw` JSON (measured avg ~9 KB, max ~94 KB), so an
12
+ * uncapped batch would let a 200k-row replay serialize itself into one message. 500 keeps a batch in
13
+ * the low single-digit MB while still amortizing the OPFS commit ~500×.
14
+ */
15
+ export declare const MAX_APPLY_BATCH_ROWS = 500;
16
+ /**
17
+ * Depth at which we stop buffering and ask for a fresh snapshot instead.
18
+ *
19
+ * Batching alone does NOT bound retention — it collapses the three retained copies per frame into one
20
+ * and drains far faster, but the buffer itself is still O(frames received). At ~19.5 KB of parsed V8
21
+ * objects per issues frame (measured), a 200k-frame replay would be ~3.9 GB of inbox on the main
22
+ * thread. Past this depth a snapshot is simply cheaper than the replay — /snapshot is one streamed
23
+ * body, not N individually-cloned frames — so the queue escalates instead of growing.
24
+ *
25
+ * 20,000 × ~19.5 KB ≈ 390 MB worst case, which is a bad-but-survivable ceiling rather than an
26
+ * unbounded one. The real remedy is to stop the server creating the condition (pace/cap `replaySince`
27
+ * in apps/mirror/src/do/ws.ts) — this is the client-side backstop for when it does.
28
+ */
29
+ export declare const MAX_INBOX_DEPTH = 20000;
30
+ /**
31
+ * Consecutive apply rejections tolerated before the queue stops retrying and asks for a re-seed.
32
+ *
33
+ * Bounded deliberately. A transient OPFS/SQLite error deserves a retry, but `applyChanges` can also
34
+ * reject DETERMINISTICALLY (schema drift, a row the current schema cannot accept) — and an unbounded
35
+ * retry on that is a hot loop that never converges. After this many failures the batch is no longer
36
+ * replayable in place, so escalating to a snapshot is both the correct answer and the terminating one.
37
+ */
38
+ export declare const MAX_APPLY_RETRIES = 3;
39
+ /** Base delay between apply retries; grows linearly with the failure count. */
40
+ export declare const APPLY_RETRY_DELAY_MS = 250;
41
+ /** Why the owner is being asked to re-seed. */
42
+ export type OverflowReason = "depth" | "apply-failed";
43
+ /** What the queue needs from its owner. `apply` resolves with the worker's post-apply cursor. */
44
+ export interface DeltaQueueOptions {
45
+ apply: (changes: SeqChange[]) => Promise<{
46
+ cursor: number;
47
+ }>;
48
+ /** Called ONCE per completed drain (not per batch, and never per frame) with the highest cursor. */
49
+ onDrained: (cursor: number) => void;
50
+ /** Called when an apply rejects. The failed batch is REQUEUED, so this is a warning, not a loss. */
51
+ onError: (err: unknown) => void;
52
+ /**
53
+ * Called ONCE when the owner must drop the socket and re-seed from /snapshot, with the depth at the
54
+ * moment of escalation and the reason:
55
+ *
56
+ * • `"depth"` — the buffer passed {@link MAX_INBOX_DEPTH}. The backlog is deeper than it is
57
+ * worth replaying, so the queue drops what it holds: those frames are about to be superseded by
58
+ * the snapshot, and keeping them is exactly the retention this bound exists to prevent.
59
+ * • `"apply-failed"` — {@link MAX_APPLY_RETRIES} consecutive applies rejected. The buffered rows
60
+ * cannot be written, so the cursor cannot advance past them safely; only a re-seed recovers.
61
+ *
62
+ * `reason` is a SECOND parameter rather than a changed first one so existing one-arg handlers keep
63
+ * working unchanged.
64
+ *
65
+ * REQUIRED (CTC-114 review round 6). It was optional, and omitting it was silently terminal: an
66
+ * overflow latches `overflowed` permanently, empties the inbox, and makes every later `push()` a
67
+ * no-op — while `depth` reads 0 and no error is raised. This callback is the ONLY signal that the
68
+ * owner must re-seed and call `resume()`, so without it a `DeltaQueue` stops syncing forever with
69
+ * nothing to observe. `DeltaQueue` is publicly exported (`@catalyst-cloud/sdk/browser`), so that
70
+ * was a reachable third-party configuration, not a theoretical one. Made required rather than
71
+ * non-latching because the latch is load-bearing — dropping it would let a stale batch land on top
72
+ * of a fresh snapshot. Free to tighten now: `./browser` is new and unpublished in 0.8.0, so there
73
+ * is no install base to break.
74
+ */
75
+ onOverflow: (depth: number, reason: OverflowReason) => void;
76
+ /**
77
+ * Called whenever the queue THROWS ACCEPTED FRAMES AWAY, for any reason, before they were applied.
78
+ *
79
+ * The owner's obligation is to roll its transport high-water back to its durable cursor: those seqs
80
+ * were accepted off the socket and are now in neither the store nor this buffer, so a reconnect
81
+ * resuming above them seals a hole that nothing ever re-requests and the next applied batch carries
82
+ * the durable cursor past.
83
+ *
84
+ * PAIRED WITH THE DISCARD, not with a reason (CTC-114 review round 12, P1). That rollback used to
85
+ * live in the owner's `onOverflow` handler, which covered exactly ONE of this queue's discard sites
86
+ * — so round 9's `pause()` introduced a second discard with no rollback, and a gap- or server-driven
87
+ * reseed that began with frames still buffered and then FAILED lost them permanently. Routing every
88
+ * discard through one notification makes the pairing structural: a future discard site cannot forget
89
+ * the compensation, because emptying the inbox IS the notification.
90
+ */
91
+ onDiscard: () => void;
92
+ maxBatch?: number;
93
+ maxDepth?: number;
94
+ maxApplyRetries?: number;
95
+ retryDelayMs?: number;
96
+ }
97
+ export declare class DeltaQueue {
98
+ private readonly inbox;
99
+ private draining;
100
+ private stopped;
101
+ private overflowed;
102
+ private readonly opts;
103
+ private readonly maxBatch;
104
+ private readonly maxDepth;
105
+ private readonly maxApplyRetries;
106
+ private readonly retryDelayMs;
107
+ /** Consecutive apply rejections. Reset by any successful batch and by resume(). */
108
+ private applyFailures;
109
+ private retryTimer;
110
+ constructor(opts: DeltaQueueOptions);
111
+ /** How many deltas are buffered but not yet applied (observability + tests). */
112
+ get depth(): number;
113
+ /**
114
+ * THE ONE WAY buffered frames are thrown away (CTC-114 review round 12).
115
+ *
116
+ * There are five sites that empty the inbox — depth overflow, apply-failed overflow, `pause()`,
117
+ * `resume()` and `stop()` — and the owner's compensating high-water rollback was wired to exactly
118
+ * one of them. Routing every discard through here pairs the compensation with the act by
119
+ * construction, so a future site cannot forget it. Fires only when something was really dropped, so
120
+ * it is safe to call unconditionally.
121
+ */
122
+ private discardInbox;
123
+ /**
124
+ * Buffer one delta and make sure a drain is running.
125
+ *
126
+ * Returns whether the frame was KEPT (CTC-114 review round 11). A latched queue — paused for a
127
+ * re-seed, or overflowed — REFUSES frames, and the owner must not count a refused frame as
128
+ * delivered: its transport high-water would then describe a seq that is in neither the store nor
129
+ * this buffer, so a reconnect resuming above it seals a hole nothing ever re-requests.
130
+ *
131
+ * The owner used to advance that high-water unconditionally, one line ABOVE the call that decides.
132
+ * That was safe only while the sole latch (overflow) rolled the high-water back in the same
133
+ * synchronous block; round 9's `pause()` added a second latch with no such compensation, after
134
+ * which the safety rested on `closeSocket()` happening before `pause()` on every path. Returning
135
+ * the decision makes the owner's bookkeeping follow the queue's, instead of racing it.
136
+ */
137
+ push(change: SeqChange): boolean;
138
+ /**
139
+ * Latch the queue for an owner-driven re-seed, WITHOUT escalating back to the owner (CTC-114 review
140
+ * round 9).
141
+ *
142
+ * The same latch `onOverflow` sets, minus the callback — the owner is the one re-seeding, so telling
143
+ * it to re-seed would be circular. Without this, a reseed that began while buffered work remained
144
+ * (a gap escalating mid-replay, say) left the queue live across `seedBegin`: its retry timer then
145
+ * posted an `applyChanges` INTO the seed's open transaction, whose nested `BEGIN` rejects, and the
146
+ * repeated failures walked the queue into its apply-failed overflow during an otherwise healthy
147
+ * re-seed. The overflow's `requestResync()` then returned immediately — the transport is already
148
+ * resyncing — so the escalation bought no recovery at all and simply discarded live frames.
149
+ *
150
+ * Dropping the inbox is correct for the same reason `resume()` drops it: everything buffered is
151
+ * pre-snapshot by definition, and the snapshot supersedes it. `resume()` clears this.
152
+ */
153
+ pause(): void;
154
+ /** Clear the overflow latch so the queue accepts deltas again (after the owner's re-seed lands). */
155
+ resume(): void;
156
+ /**
157
+ * Invoke a CONSUMER callback without letting it break the queue's state machine.
158
+ *
159
+ * These handlers are arbitrary app code — the replica forwards them straight to `onStatus` /
160
+ * `onChanged`, so a React setState that throws lands here. Uncaught, the exception propagates out of
161
+ * the failure path BEFORE `scheduleRetry()` or the overflow escalation runs: the batch is already
162
+ * requeued and the transport's high-water has already advanced past it, so on a quiet feed nothing
163
+ * ever re-drains it and a reconnect resumes ABOVE data that was never applied. The transport applies
164
+ * the same discipline to its own user handlers.
165
+ */
166
+ private notify;
167
+ /** Cancel a pending self-retry. */
168
+ private clearRetry;
169
+ /**
170
+ * Re-enter the drain on a timer after a failed apply.
171
+ *
172
+ * Self-driven on purpose: `push()` is the only other thing that starts a drain, so on a quiet feed a
173
+ * requeued batch would otherwise sit in the inbox indefinitely — while `acceptedSeq` on the socket
174
+ * has already advanced past it, meaning a reconnect would never replay it either.
175
+ */
176
+ private scheduleRetry;
177
+ /**
178
+ * Drain the inbox into `apply` in bounded batches. SINGLE-FLIGHT — a re-entrant call is a no-op, so
179
+ * at most one apply is outstanding at a time and everything arriving meanwhile is coalesced into the
180
+ * next batch.
181
+ */
182
+ drain(): Promise<void>;
183
+ /** Drop everything buffered and refuse further work (teardown). Each queued delta retains a fully
184
+ * parsed row, so leaving them behind would pin that memory until the queue itself is collected. */
185
+ stop(): void;
186
+ }
187
+ //# sourceMappingURL=delta-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delta-queue.d.ts","sourceRoot":"","sources":["../../../src/replica/browser/delta-queue.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAMhD,yFAAyF;AACzF,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,cAAc,CAAC;AAEtD,iGAAiG;AACjG,MAAM,WAAW,iBAAiB;IAChC,KAAK,E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G,OAAO;IAkBhC;;;;;;;;;;;;;;OAcG;IACH,KAAK,IAAI,IAAI;IAOb,oGAAoG;IACpG,MAAM,IAAI,IAAI;IAad;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM;IAQd,mCAAmC;IACnC,OAAO,CAAC,UAAU;IAOlB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IASrB;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsE5B;wGACoG;IACpG,IAAI,IAAI,IAAI;CAKb"}
@@ -0,0 +1,328 @@
1
+ // replica/delta-queue.ts — the coalescing buffer between the live socket and the OPFS worker (CTC-318).
2
+ //
3
+ // The SDK delivers ONE onChange per change_log row, and a stale-cursor reconnect replays up to
4
+ // CHANGE_LOG_MAX_ROWS = 200,000 of them back-to-back (apps/mirror/src/do/ws.ts replaySince sends one
5
+ // frame per row in a tight loop). The replica client used to answer each frame on its own:
6
+ //
7
+ // onChange: (frame) => { void this.applyDelta(frame) } → call({ applyChanges, changes: [wire] })
8
+ //
9
+ // which is fire-and-forget with no backpressure anywhere. Every frame became its own structured clone,
10
+ // its own worker RPC, its own OPFS transaction and its own FULL view rebuild — while the gap between
11
+ // arrival rate (network) and drain rate (one fsync per row) accumulated without bound, holding a fully
12
+ // parsed row (issues carry the provider's `raw` JSON) per undrained frame.
13
+ //
14
+ // This module buffers frames and drains them in bounded batches under a SINGLE-FLIGHT loop. The
15
+ // coalescing needs no timer, which is the important trick: each WebSocket message arrives in its OWN
16
+ // task, so a microtask/queueMicrotask flush would batch nothing. Instead, while one apply is awaited
17
+ // every frame that arrives piles into the inbox and the next iteration takes the lot — so the batch
18
+ // size self-tunes to the lag. An idle tab applies one row at a time with no added latency; a replay
19
+ // applies them `maxBatch` at a time.
20
+ //
21
+ // Pure over an injected `apply` (the seam streamSeedIntoWorker established in CTC-132), so the
22
+ // batching is unit-testable without the wasm/OPFS worker.
23
+ import { requireNonNegativeFinite, requirePositiveInt, } from "./validate.js";
24
+ /**
25
+ * Largest number of deltas handed to the worker in ONE applyChanges RPC.
26
+ *
27
+ * The cap is about the CLONE, not the transaction — the worker already wraps a whole `changes` array
28
+ * in a single transaction. `changes` is structured-cloned across the worker boundary and `issues` /
29
+ * `issue_history` rows carry the provider's full `raw` JSON (measured avg ~9 KB, max ~94 KB), so an
30
+ * uncapped batch would let a 200k-row replay serialize itself into one message. 500 keeps a batch in
31
+ * the low single-digit MB while still amortizing the OPFS commit ~500×.
32
+ */
33
+ export const MAX_APPLY_BATCH_ROWS = 500;
34
+ /**
35
+ * Depth at which we stop buffering and ask for a fresh snapshot instead.
36
+ *
37
+ * Batching alone does NOT bound retention — it collapses the three retained copies per frame into one
38
+ * and drains far faster, but the buffer itself is still O(frames received). At ~19.5 KB of parsed V8
39
+ * objects per issues frame (measured), a 200k-frame replay would be ~3.9 GB of inbox on the main
40
+ * thread. Past this depth a snapshot is simply cheaper than the replay — /snapshot is one streamed
41
+ * body, not N individually-cloned frames — so the queue escalates instead of growing.
42
+ *
43
+ * 20,000 × ~19.5 KB ≈ 390 MB worst case, which is a bad-but-survivable ceiling rather than an
44
+ * unbounded one. The real remedy is to stop the server creating the condition (pace/cap `replaySince`
45
+ * in apps/mirror/src/do/ws.ts) — this is the client-side backstop for when it does.
46
+ */
47
+ export const MAX_INBOX_DEPTH = 20_000;
48
+ /**
49
+ * Consecutive apply rejections tolerated before the queue stops retrying and asks for a re-seed.
50
+ *
51
+ * Bounded deliberately. A transient OPFS/SQLite error deserves a retry, but `applyChanges` can also
52
+ * reject DETERMINISTICALLY (schema drift, a row the current schema cannot accept) — and an unbounded
53
+ * retry on that is a hot loop that never converges. After this many failures the batch is no longer
54
+ * replayable in place, so escalating to a snapshot is both the correct answer and the terminating one.
55
+ */
56
+ export const MAX_APPLY_RETRIES = 3;
57
+ /** Base delay between apply retries; grows linearly with the failure count. */
58
+ export const APPLY_RETRY_DELAY_MS = 250;
59
+ export class DeltaQueue {
60
+ inbox = [];
61
+ draining = false;
62
+ stopped = false;
63
+ overflowed = false;
64
+ opts;
65
+ maxBatch;
66
+ maxDepth;
67
+ maxApplyRetries;
68
+ retryDelayMs;
69
+ /** Consecutive apply rejections. Reset by any successful batch and by resume(). */
70
+ applyFailures = 0;
71
+ retryTimer = null;
72
+ constructor(opts) {
73
+ this.opts = opts;
74
+ this.maxBatch = opts.maxBatch ?? MAX_APPLY_BATCH_ROWS;
75
+ this.maxDepth = opts.maxDepth ?? MAX_INBOX_DEPTH;
76
+ this.maxApplyRetries = opts.maxApplyRetries ?? MAX_APPLY_RETRIES;
77
+ this.retryDelayMs = opts.retryDelayMs ?? APPLY_RETRY_DELAY_MS;
78
+ // `DeltaQueue` and `DeltaQueueOptions` are both public exports of `./browser`, so every one of
79
+ // these is consumer-supplied and may arrive from unchecked runtime config. Validate them ALL —
80
+ // not just the one that happened to be reported (CTC-114 review round 10). `maxBatch` was guarded
81
+ // in round 5 and `maxDepth` was not, though it is the same kind of value from the same object,
82
+ // and its failure modes are worse. Fixing the class rather than the instance is the point.
83
+ //
84
+ // • maxBatch — `splice(0, 0)` removes NOTHING, so the drain loop's `while (length > 0)`
85
+ // never advances: it awaits `apply([])` and iterates again forever, an unbounded stream of
86
+ // empty worker transactions that never applies the queued change.
87
+ // • maxDepth — 0/negative/fractional makes the FIRST frame overflow and force a
88
+ // snapshot; `NaN` makes `inbox.length > maxDepth` permanently FALSE, so the inbox grows
89
+ // without bound and the OOM backstop this whole module exists for is silently gone.
90
+ // • maxApplyRetries — below 1, the first transient apply error escalates straight to a full
91
+ // re-seed instead of retrying at all.
92
+ //
93
+ // Fail at construction rather than degrade silently at the first delta.
94
+ requirePositiveInt("DeltaQueue", "maxBatch", this.maxBatch);
95
+ requirePositiveInt("DeltaQueue", "maxDepth", this.maxDepth);
96
+ requirePositiveInt("DeltaQueue", "maxApplyRetries", this.maxApplyRetries);
97
+ // Delay may legitimately be 0 (retry on the next tick) but must be finite and non-negative — NaN
98
+ // makes setTimeout fire immediately, turning the bounded backoff into a hot loop.
99
+ requireNonNegativeFinite("DeltaQueue", "retryDelayMs", this.retryDelayMs);
100
+ // Same reasoning, at RUNTIME, for the same reason (CTC-114 review round 6): the type now requires
101
+ // `onOverflow`, but an untyped-JS consumer of the public export gets no help from that — which is
102
+ // exactly the case the maxBatch guard above exists for. Omitting it is silently TERMINAL: the
103
+ // first overflow latches the queue, empties the inbox, and turns every later push() into a no-op,
104
+ // while `depth` reads 0 and nothing is raised. This callback is the only signal that the owner
105
+ // must re-seed and call resume(), so failing at construction beats syncing forever-nothing.
106
+ if (typeof opts.onOverflow !== "function") {
107
+ throw new Error("DeltaQueue: onOverflow is required — it is the ONLY signal that the queue has latched and " +
108
+ "the owner must re-seed and call resume(); without it an overflow stops syncing silently.");
109
+ }
110
+ }
111
+ /** How many deltas are buffered but not yet applied (observability + tests). */
112
+ get depth() {
113
+ return this.inbox.length;
114
+ }
115
+ /**
116
+ * THE ONE WAY buffered frames are thrown away (CTC-114 review round 12).
117
+ *
118
+ * There are five sites that empty the inbox — depth overflow, apply-failed overflow, `pause()`,
119
+ * `resume()` and `stop()` — and the owner's compensating high-water rollback was wired to exactly
120
+ * one of them. Routing every discard through here pairs the compensation with the act by
121
+ * construction, so a future site cannot forget it. Fires only when something was really dropped, so
122
+ * it is safe to call unconditionally.
123
+ */
124
+ discardInbox() {
125
+ if (this.inbox.length === 0)
126
+ return;
127
+ this.inbox.length = 0;
128
+ this.notify("onDiscard", () => this.opts.onDiscard());
129
+ }
130
+ /**
131
+ * Buffer one delta and make sure a drain is running.
132
+ *
133
+ * Returns whether the frame was KEPT (CTC-114 review round 11). A latched queue — paused for a
134
+ * re-seed, or overflowed — REFUSES frames, and the owner must not count a refused frame as
135
+ * delivered: its transport high-water would then describe a seq that is in neither the store nor
136
+ * this buffer, so a reconnect resuming above it seals a hole nothing ever re-requests.
137
+ *
138
+ * The owner used to advance that high-water unconditionally, one line ABOVE the call that decides.
139
+ * That was safe only while the sole latch (overflow) rolled the high-water back in the same
140
+ * synchronous block; round 9's `pause()` added a second latch with no such compensation, after
141
+ * which the safety rested on `closeSocket()` happening before `pause()` on every path. Returning
142
+ * the decision makes the owner's bookkeeping follow the queue's, instead of racing it.
143
+ */
144
+ push(change) {
145
+ if (this.stopped || this.overflowed)
146
+ return false;
147
+ this.inbox.push(change);
148
+ if (this.inbox.length > this.maxDepth) {
149
+ // Deeper than it is worth replaying — drop the backlog and let the owner re-seed. Latched, so
150
+ // a burst raises exactly one escalation rather than one per subsequent frame.
151
+ this.overflowed = true;
152
+ const depth = this.inbox.length;
153
+ this.discardInbox();
154
+ this.clearRetry();
155
+ this.notify("onOverflow", () => this.opts.onOverflow(depth, "depth"));
156
+ // This frame went into the discarded backlog, so it was NOT kept either.
157
+ return false;
158
+ }
159
+ void this.drain();
160
+ return true;
161
+ }
162
+ /**
163
+ * Latch the queue for an owner-driven re-seed, WITHOUT escalating back to the owner (CTC-114 review
164
+ * round 9).
165
+ *
166
+ * The same latch `onOverflow` sets, minus the callback — the owner is the one re-seeding, so telling
167
+ * it to re-seed would be circular. Without this, a reseed that began while buffered work remained
168
+ * (a gap escalating mid-replay, say) left the queue live across `seedBegin`: its retry timer then
169
+ * posted an `applyChanges` INTO the seed's open transaction, whose nested `BEGIN` rejects, and the
170
+ * repeated failures walked the queue into its apply-failed overflow during an otherwise healthy
171
+ * re-seed. The overflow's `requestResync()` then returned immediately — the transport is already
172
+ * resyncing — so the escalation bought no recovery at all and simply discarded live frames.
173
+ *
174
+ * Dropping the inbox is correct for the same reason `resume()` drops it: everything buffered is
175
+ * pre-snapshot by definition, and the snapshot supersedes it. `resume()` clears this.
176
+ */
177
+ pause() {
178
+ if (this.stopped)
179
+ return;
180
+ this.overflowed = true;
181
+ this.discardInbox();
182
+ this.clearRetry();
183
+ }
184
+ /** Clear the overflow latch so the queue accepts deltas again (after the owner's re-seed lands). */
185
+ resume() {
186
+ if (this.stopped)
187
+ return;
188
+ // Anything still buffered here is PRE-RESEED work by definition — while `overflowed` is latched
189
+ // push() refuses every frame, so nothing new can have arrived — and the snapshot supersedes it.
190
+ // Dropping it is the same reasoning the overflow paths already apply to the backlog they discard;
191
+ // resuming without it would let a stale batch be applied on top of the fresh DB by the next live
192
+ // push, where an old delete removes a row the snapshot legitimately has.
193
+ this.discardInbox();
194
+ this.overflowed = false;
195
+ // The re-seed supersedes whatever could not be applied, so the failure streak starts over.
196
+ this.applyFailures = 0;
197
+ }
198
+ /**
199
+ * Invoke a CONSUMER callback without letting it break the queue's state machine.
200
+ *
201
+ * These handlers are arbitrary app code — the replica forwards them straight to `onStatus` /
202
+ * `onChanged`, so a React setState that throws lands here. Uncaught, the exception propagates out of
203
+ * the failure path BEFORE `scheduleRetry()` or the overflow escalation runs: the batch is already
204
+ * requeued and the transport's high-water has already advanced past it, so on a quiet feed nothing
205
+ * ever re-drains it and a reconnect resumes ABOVE data that was never applied. The transport applies
206
+ * the same discipline to its own user handlers.
207
+ */
208
+ notify(label, fn) {
209
+ try {
210
+ fn();
211
+ }
212
+ catch (err) {
213
+ console.error(`[delta-queue] ${label} handler threw`, err);
214
+ }
215
+ }
216
+ /** Cancel a pending self-retry. */
217
+ clearRetry() {
218
+ if (this.retryTimer !== null) {
219
+ clearTimeout(this.retryTimer);
220
+ this.retryTimer = null;
221
+ }
222
+ }
223
+ /**
224
+ * Re-enter the drain on a timer after a failed apply.
225
+ *
226
+ * Self-driven on purpose: `push()` is the only other thing that starts a drain, so on a quiet feed a
227
+ * requeued batch would otherwise sit in the inbox indefinitely — while `acceptedSeq` on the socket
228
+ * has already advanced past it, meaning a reconnect would never replay it either.
229
+ */
230
+ scheduleRetry() {
231
+ if (this.stopped || this.overflowed || this.retryTimer !== null)
232
+ return;
233
+ const delay = this.retryDelayMs * this.applyFailures;
234
+ this.retryTimer = setTimeout(() => {
235
+ this.retryTimer = null;
236
+ void this.drain();
237
+ }, delay);
238
+ }
239
+ /**
240
+ * Drain the inbox into `apply` in bounded batches. SINGLE-FLIGHT — a re-entrant call is a no-op, so
241
+ * at most one apply is outstanding at a time and everything arriving meanwhile is coalesced into the
242
+ * next batch.
243
+ */
244
+ async drain() {
245
+ // A PENDING RETRY owns the next attempt (CTC-114 review round 5). `push()` calls drain() on every
246
+ // incoming frame and only `draining` was checked — but the failure path clears `draining` before
247
+ // arming the backoff, so the very next live frame re-entered immediately and the 250/500 ms delay
248
+ // never elapsed. On a busy feed three frames could burn the whole `maxApplyRetries` budget in
249
+ // milliseconds and escalate to a full /snapshot re-seed for a transient OPFS error that the
250
+ // documented delay would have ridden out. Frames arriving meanwhile are NOT lost — they buffer in
251
+ // the inbox, and the retry drains the whole of it. scheduleRetry()'s own timer nulls this field
252
+ // before calling drain(), so the retry itself is never blocked by this guard.
253
+ if (this.draining || this.stopped || this.retryTimer !== null)
254
+ return;
255
+ this.draining = true;
256
+ let applied = false;
257
+ let highest = 0;
258
+ while (this.inbox.length > 0 && !this.stopped) {
259
+ // `splice` REMOVES the batch before the await, so the failure path below must put it back. It
260
+ // previously did not, and the loss was silent and permanent: worker-core.applyChanges advances
261
+ // the durable OPFS cursor to the highest seq it has SEEN, so the next successful batch sealed
262
+ // the hole below the cursor. A reload does not heal that, and the socket's high-water mark
263
+ // stops a reconnect from replaying it — up to maxBatch rows simply ceased to exist locally.
264
+ const batch = this.inbox.splice(0, this.maxBatch);
265
+ try {
266
+ const { cursor } = await this.opts.apply(batch);
267
+ if (cursor > highest)
268
+ highest = cursor;
269
+ for (const c of batch)
270
+ if (c.seq > highest)
271
+ highest = c.seq;
272
+ applied = true;
273
+ this.applyFailures = 0;
274
+ }
275
+ catch (err) {
276
+ this.draining = false;
277
+ if (this.stopped)
278
+ return;
279
+ // A DEPTH overflow can latch WHILE this apply is in flight: push() cleared the inbox and the
280
+ // owner is already re-seeding. Requeueing here would resurrect work the incoming snapshot
281
+ // supersedes — and since scheduleRetry() is inert while overflowed, the batch would simply sit
282
+ // in the inbox until the next live push drained it ON TOP of the fresh DB, where an old delete
283
+ // removes a row the snapshot legitimately has. Drop it, and do not escalate again: the owner
284
+ // has already been told to re-seed.
285
+ if (this.overflowed) {
286
+ // The SIXTH discard site, and the one `discardInbox()` cannot see: this batch was spliced
287
+ // OUT of the inbox before the await, so dropping it here loses frames that are no longer in
288
+ // the buffer to discard. Same obligation on the owner, so the same notification.
289
+ this.notify("onDiscard", () => this.opts.onDiscard());
290
+ this.notify("onError", () => this.opts.onError(err));
291
+ return;
292
+ }
293
+ // Back at the FRONT: these seqs are strictly older than anything still queued behind them,
294
+ // and the worker applies in order.
295
+ this.inbox.unshift(...batch);
296
+ this.applyFailures += 1;
297
+ this.notify("onError", () => this.opts.onError(err));
298
+ if (this.applyFailures >= this.maxApplyRetries) {
299
+ // Not replayable in place. Drop the backlog and let the owner re-seed — same contract as a
300
+ // depth overflow, so the owner needs no new branch.
301
+ this.overflowed = true;
302
+ const depth = this.inbox.length;
303
+ this.discardInbox();
304
+ this.clearRetry();
305
+ this.notify("onOverflow", () => this.opts.onOverflow(depth, "apply-failed"));
306
+ }
307
+ else {
308
+ this.scheduleRetry();
309
+ }
310
+ return;
311
+ }
312
+ }
313
+ this.draining = false;
314
+ // ONE notification per drain rather than one per frame. The caller's reaction is a full view
315
+ // rebuild + a structured clone of a whole page back across the boundary, and a burst of deltas has
316
+ // exactly one visible outcome — so firing it per frame was pure waste.
317
+ if (applied && !this.stopped)
318
+ this.notify("onDrained", () => this.opts.onDrained(highest));
319
+ }
320
+ /** Drop everything buffered and refuse further work (teardown). Each queued delta retains a fully
321
+ * parsed row, so leaving them behind would pin that memory until the queue itself is collected. */
322
+ stop() {
323
+ this.stopped = true;
324
+ this.clearRetry();
325
+ this.discardInbox();
326
+ }
327
+ }
328
+ //# sourceMappingURL=delta-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delta-queue.js","sourceRoot":"","sources":["../../../src/replica/browser/delta-queue.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,EAAE;AACF,+FAA+F;AAC/F,qGAAqG;AACrG,2FAA2F;AAC3F,EAAE;AACF,yG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