@pgxsinkit/client 0.1.53 → 0.2.1
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/README.md +22 -0
- package/dist/adoption.d.ts +118 -0
- package/dist/adoption.d.ts.map +1 -0
- package/dist/boot-report.d.ts +54 -15
- package/dist/boot-report.d.ts.map +1 -1
- package/dist/convergence.d.ts +2 -1
- package/dist/convergence.d.ts.map +1 -1
- package/dist/export-store.d.ts +1 -1
- package/dist/export-store.d.ts.map +1 -1
- package/dist/index.d.ts +286 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4795 -1519
- package/dist/index.js.map +34 -24
- package/dist/live-rows-sql.d.ts +1 -1
- package/dist/local-store.d.ts +16 -31
- package/dist/local-store.d.ts.map +1 -1
- package/dist/local-tables.d.ts +4 -4
- package/dist/mutation.d.ts +18 -15
- package/dist/mutation.d.ts.map +1 -1
- package/dist/opfs-effects.d.ts +51 -0
- package/dist/opfs-effects.d.ts.map +1 -0
- package/dist/placement-probe.d.ts +75 -0
- package/dist/placement-probe.d.ts.map +1 -0
- package/dist/schema.d.ts +11 -16
- package/dist/schema.d.ts.map +1 -1
- package/dist/store-boot.d.ts +77 -0
- package/dist/store-boot.d.ts.map +1 -0
- package/dist/store-lifecycle.d.ts +153 -0
- package/dist/store-lifecycle.d.ts.map +1 -0
- package/dist/store-meta.d.ts +190 -0
- package/dist/store-meta.d.ts.map +1 -0
- package/dist/store-path.d.ts +77 -7
- package/dist/store-path.d.ts.map +1 -1
- package/dist/sync/apply.d.ts.map +1 -1
- package/dist/sync/shape-inbox.d.ts +1 -1
- package/dist/sync/types.d.ts +3 -3
- package/dist/testing.js.map +3 -3
- package/dist/worker/attach-sync-client.d.ts +300 -16
- package/dist/worker/attach-sync-client.d.ts.map +1 -1
- package/dist/worker/define-sync-worker.d.ts +164 -23
- package/dist/worker/define-sync-worker.d.ts.map +1 -1
- package/dist/worker/election-coordinator.d.ts +95 -0
- package/dist/worker/election-coordinator.d.ts.map +1 -0
- package/dist/worker/engine-control.d.ts +266 -0
- package/dist/worker/engine-control.d.ts.map +1 -0
- package/dist/worker/engine-router.d.ts +75 -0
- package/dist/worker/engine-router.d.ts.map +1 -0
- package/dist/worker/live-query-manager.d.ts.map +1 -1
- package/dist/worker/protocol.d.ts +47 -31
- package/dist/worker/protocol.d.ts.map +1 -1
- package/dist/worker/sw-placement.d.ts +37 -0
- package/dist/worker/sw-placement.d.ts.map +1 -0
- package/package.json +4 -3
- package/skills/core/SKILL.md +15 -12
- package/skills/operating/SKILL.md +142 -46
- package/src/adoption.ts +275 -0
- package/src/boot-report.ts +70 -17
- package/src/convergence.ts +2 -1
- package/src/export-store.ts +1 -1
- package/src/index.ts +1157 -115
- package/src/live-rows-sql.ts +1 -1
- package/src/local-store.ts +18 -40
- package/src/local-tables.ts +2 -2
- package/src/mutation.ts +115 -53
- package/src/mutations-api.ts +3 -3
- package/src/opfs-effects.ts +160 -0
- package/src/placement-probe.ts +168 -0
- package/src/schema.ts +17 -22
- package/src/store-boot.ts +343 -0
- package/src/store-lifecycle.ts +227 -0
- package/src/store-meta.ts +459 -0
- package/src/store-path.ts +197 -22
- package/src/sync/apply.ts +63 -63
- package/src/sync/index.ts +2 -2
- package/src/sync/shape-inbox.ts +1 -1
- package/src/sync/types.ts +3 -3
- package/src/testing.ts +2 -2
- package/src/worker/attach-sync-client.ts +1753 -102
- package/src/worker/define-sync-worker.ts +1034 -71
- package/src/worker/election-coordinator.ts +462 -0
- package/src/worker/engine-control.ts +379 -0
- package/src/worker/engine-router.ts +355 -0
- package/src/worker/live-query-manager.ts +4 -1
- package/src/worker/protocol.ts +46 -16
- package/src/worker/sw-placement.ts +64 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type EngineIdentity, type ExecutionLimitConfig } from "./engine-control";
|
|
2
|
+
/**
|
|
3
|
+
* The namespaced key under which every ADR-0049 control message rides the tab↔SharedWorker transport, so the
|
|
4
|
+
* control plane coexists with the data-path bridge envelope (`protocol.ts`) without any change to it. The tab
|
|
5
|
+
* side (step 7) sends/reads the identical envelope.
|
|
6
|
+
*/
|
|
7
|
+
export { ENGINE_CONTROL_ENVELOPE_KEY } from "./engine-control";
|
|
8
|
+
/**
|
|
9
|
+
* The minimal MessagePort-shaped transport the router needs — the intersection of a real `MessagePort`, a
|
|
10
|
+
* `SharedWorker` connection port, and the pipe ends it mints. Modeled on `protocol.ts`'s `BridgePort` (kept
|
|
11
|
+
* local, not imported, because the router's transfer list is plain `unknown[]` and it never `close()`s a tab
|
|
12
|
+
* port). Injected everywhere so the router is exercised with plain recording ports (no worker) in tests.
|
|
13
|
+
*/
|
|
14
|
+
export interface RouterPort {
|
|
15
|
+
postMessage: (message: unknown, transfer?: unknown[]) => void;
|
|
16
|
+
addEventListener: (type: "message", listener: (event: {
|
|
17
|
+
data: unknown;
|
|
18
|
+
}) => void) => void;
|
|
19
|
+
removeEventListener: (type: "message", listener: (event: {
|
|
20
|
+
data: unknown;
|
|
21
|
+
}) => void) => void;
|
|
22
|
+
start?: () => void;
|
|
23
|
+
}
|
|
24
|
+
/** The setTimeout/clearTimeout pair the probe loop schedules on — injectable for deterministic tests. */
|
|
25
|
+
export interface RouterTimers {
|
|
26
|
+
setTimeout(fn: () => void, ms: number): unknown;
|
|
27
|
+
clearTimeout(handle: unknown): void;
|
|
28
|
+
}
|
|
29
|
+
export interface EngineRouterOptions {
|
|
30
|
+
/** The opaque id of THIS SharedWorker instance — scopes every minted {@link EngineIdentity}'s generation. */
|
|
31
|
+
swInstanceId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Engine-construction execution limit (`undefined`/absent `maxDispatchMs` = DISABLED, ADR D5). The router
|
|
34
|
+
* only FORWARDS tab-reported overdue dispatches into control-channel probes when enabled; the verdict
|
|
35
|
+
* threshold is {@link probeMissThreshold}. Disabled → overdue reports are ignored entirely.
|
|
36
|
+
*/
|
|
37
|
+
executionLimit?: ExecutionLimitConfig;
|
|
38
|
+
/** Consecutive unanswered probe pings before an engine-loss verdict (default 3). */
|
|
39
|
+
probeMissThreshold?: number;
|
|
40
|
+
/** Injectable pipe factory (default `() => new MessageChannel()`) so tests can observe both minted ends. */
|
|
41
|
+
createPipe?: () => {
|
|
42
|
+
port1: RouterPort;
|
|
43
|
+
port2: RouterPort;
|
|
44
|
+
};
|
|
45
|
+
/** Injectable timers for probe scheduling (default `globalThis`) for deterministic tests. */
|
|
46
|
+
timers?: RouterTimers;
|
|
47
|
+
/** Milliseconds between probe pings once a dispatch is reported overdue (default 2000). */
|
|
48
|
+
probeIntervalMs?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface EngineRouter {
|
|
51
|
+
/**
|
|
52
|
+
* Register a tab's bridge port. Returns an unregister fn. If an engine is CURRENT and already ready, this
|
|
53
|
+
* late joiner is piped IMMEDIATELY; otherwise it is piped when the current engine's `engine-ready` fans out.
|
|
54
|
+
*/
|
|
55
|
+
attachTab(tabPort: RouterPort): () => void;
|
|
56
|
+
/**
|
|
57
|
+
* tab→SW: the leader coordinator announces a fresh engine control channel. Stamps the next
|
|
58
|
+
* {@link EngineIdentity} ({@link mintEngineIdentity}), stores the control channel, and returns the identity.
|
|
59
|
+
* On the engine's `engine-ready` for THIS identity it pipes every attached tab. Any prior engine's control
|
|
60
|
+
* listener/probe is cleared first (this does not itself fan a notice).
|
|
61
|
+
*/
|
|
62
|
+
announceEngine(controlPort: RouterPort): EngineIdentity;
|
|
63
|
+
/**
|
|
64
|
+
* Fan a relocation notice to every tab: `leader-granted` (untagged) or `engine-retiring` (tagged with the
|
|
65
|
+
* retired identity). BOTH clear the current identity + control channel. Engine-loss verdicts fan
|
|
66
|
+
* `engine-retiring` internally the same way.
|
|
67
|
+
*/
|
|
68
|
+
openHandoff(reason: "leader-granted" | "engine-retiring"): void;
|
|
69
|
+
/** The current identity, or `undefined` before the first announce / while relocating. */
|
|
70
|
+
currentIdentity(): EngineIdentity | undefined;
|
|
71
|
+
/** Total attached-tab count (used later for destroy peer-refusal). */
|
|
72
|
+
tabCount(): number;
|
|
73
|
+
}
|
|
74
|
+
export declare function createEngineRouter(options: EngineRouterOptions): EngineRouter;
|
|
75
|
+
//# sourceMappingURL=engine-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-router.d.ts","sourceRoot":"","sources":["../../src/worker/engine-router.ts"],"names":[],"mappings":"AAqBA,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAE1B,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IAC9D,gBAAgB,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,KAAK,IAAI,CAAC;IAC1F,mBAAmB,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,KAAK,IAAI,CAAC;IAC7F,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,yGAAyG;AACzG,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAChD,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IAClC,6GAA6G;IAC7G,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,oFAAoF;IACpF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4GAA4G;IAC5G,UAAU,CAAC,EAAE,MAAM;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,CAAC;IAC5D,6FAA6F;IAC7F,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,2FAA2F;IAC3F,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,IAAI,CAAC;IAC3C;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,UAAU,GAAG,cAAc,CAAC;IACxD;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,IAAI,CAAC;IAChE,yFAAyF;IACzF,eAAe,IAAI,cAAc,GAAG,SAAS,CAAC;IAC9C,sEAAsE;IACtE,QAAQ,IAAI,MAAM,CAAC;CACpB;AAgBD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA+O7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-query-manager.d.ts","sourceRoot":"","sources":["../../src/worker/live-query-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"live-query-manager.d.ts","sourceRoot":"","sources":["../../src/worker/live-query-manager.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,2BAA2B,CAAC;AAM5F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,8GAA8G;AAC9G,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;AAE5D,sGAAsG;AACtG,MAAM,WAAW,cAAc;IAC7B,8GAA8G;IAC9G,cAAc,CAAC,IAAI,EAAE,SAA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,CAmXnF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SyncRuntimeStatus } from "@pgxsinkit/contracts";
|
|
1
|
+
import type { SyncRuntimeStatus, SyncStorageDeclaration } from "@pgxsinkit/contracts";
|
|
2
2
|
import type { BootReport } from "../boot-report";
|
|
3
3
|
import type { ExportReport } from "../export-store";
|
|
4
4
|
export declare const BRIDGE_CHANNEL: "pgxsinkit-bridge";
|
|
@@ -6,7 +6,8 @@ export declare const BRIDGE_PROTOCOL_VERSION: 1;
|
|
|
6
6
|
/**
|
|
7
7
|
* A structured-clone transferable (an `ArrayBuffer`, a `MessagePort`, …). The library carries no DOM lib
|
|
8
8
|
* dependency (like the convergence triggers), so this is the toolkit's own name for the type a future
|
|
9
|
-
* columnar codec would hand to `postMessage`'s transfer list.
|
|
9
|
+
* columnar codec would hand to `postMessage`'s transfer list. The wire-format-1 identity codec
|
|
10
|
+
* ({@link BRIDGE_PROTOCOL_VERSION}) never produces one.
|
|
10
11
|
*/
|
|
11
12
|
export type BridgeTransferable = unknown;
|
|
12
13
|
/**
|
|
@@ -41,6 +42,18 @@ export interface BridgeEnvelope {
|
|
|
41
42
|
payload: unknown;
|
|
42
43
|
}
|
|
43
44
|
export type BridgeMessageType = "provision" | "attach" | "detach" | "token-push" | "token-response" | "rpc" | "subscribe" | "unsubscribe" | "wake" | "set-online" | "provision-ack" | "attach-ack" | "token-request" | "rpc-result" | "live-initial" | "live-diff" | "live-hydrated" | "event";
|
|
45
|
+
/**
|
|
46
|
+
* The bridge's serialized-error wire shape. `message` always; `name` when the source error carried a
|
|
47
|
+
* non-default one, so a TYPED failure (e.g. a restore refused with `RestoreTargetExistsError`) stays
|
|
48
|
+
* type-detectable after the tab rebuilds it — a consumer must never be forced into message matching;
|
|
49
|
+
* `detail` for structured payloads (execution-limit mismatch, engine-relocated, …) that rebuild as their
|
|
50
|
+
* typed error class tab-side.
|
|
51
|
+
*/
|
|
52
|
+
export interface BridgeErrorWire {
|
|
53
|
+
message: string;
|
|
54
|
+
name?: string;
|
|
55
|
+
detail?: unknown;
|
|
56
|
+
}
|
|
44
57
|
/** A single auth token snapshot the tab owns and pushes to the worker (ADR-0032 decision 3). */
|
|
45
58
|
export interface AuthTokenSnapshot {
|
|
46
59
|
accessToken: string;
|
|
@@ -70,6 +83,13 @@ export interface ProvisionPayload {
|
|
|
70
83
|
* lane (via the attaching helper); a browser worker never sends it.
|
|
71
84
|
*/
|
|
72
85
|
testStoreBackend?: "memory";
|
|
86
|
+
/**
|
|
87
|
+
* The tab's WIRE storage declaration (ADR-0050) — the same declaration the pre-placement declaration
|
|
88
|
+
* message carried, repeated here so the ENGINE binds it (the mint's durability) wherever it runs. The
|
|
89
|
+
* first provision/attach binds the store's declaration; a later payload whose explicit field disagrees
|
|
90
|
+
* with the bound resolution is refused typed (`StorageDeclarationRefusedError`).
|
|
91
|
+
*/
|
|
92
|
+
storage?: SyncStorageDeclaration;
|
|
73
93
|
}
|
|
74
94
|
/** worker → tab: the provision completed (or failed). Lets the login screen confirm the spare is warm. */
|
|
75
95
|
export interface ProvisionAckPayload {
|
|
@@ -110,6 +130,10 @@ export interface AttachPayload {
|
|
|
110
130
|
* memory-store selection travels as this explicit field. Set only by the test lane; never by a browser tab.
|
|
111
131
|
*/
|
|
112
132
|
testStoreBackend?: "memory";
|
|
133
|
+
/** ADR-0049 D5: the tab's engine-construction limit, checked by the host before it acknowledges attach. */
|
|
134
|
+
executionLimit?: {
|
|
135
|
+
maxDispatchMs?: number;
|
|
136
|
+
};
|
|
113
137
|
/**
|
|
114
138
|
* Restore the store from a backup on THIS attach (ADR-0035 decision 6) — the worker-mode carrier of
|
|
115
139
|
* `createSyncClient`'s `restoreFrom`. Restore rides the FIRST attach (the boot attach): a `File`/`Blob`
|
|
@@ -119,6 +143,13 @@ export interface AttachPayload {
|
|
|
119
143
|
* this AFTER the engine has already booted is REFUSED (you cannot restore into a running store).
|
|
120
144
|
*/
|
|
121
145
|
restore?: RestoreArtefactWire;
|
|
146
|
+
/**
|
|
147
|
+
* The tab's WIRE storage declaration (ADR-0050) — repeated from the pre-placement declaration message so
|
|
148
|
+
* the ENGINE binds it (durability included) wherever it runs, the elected dedicated engine included (whose
|
|
149
|
+
* scope never saw the SharedWorker's declaration message). First payload binds; a later explicit
|
|
150
|
+
* disagreement with the bound resolution is refused typed (`StorageDeclarationRefusedError`).
|
|
151
|
+
*/
|
|
152
|
+
storage?: SyncStorageDeclaration;
|
|
122
153
|
/** The tab's current auth token at attach time, or null when unauthenticated. */
|
|
123
154
|
token: AuthTokenSnapshot | null;
|
|
124
155
|
/**
|
|
@@ -177,24 +208,15 @@ export interface AttachAckPayload {
|
|
|
177
208
|
* itself still RESOLVES (the engine reached `localReadReady`; only the tail failed). A live milestone
|
|
178
209
|
* failure after attach rides the `milestone-error` broadcast instead.
|
|
179
210
|
*/
|
|
180
|
-
writeReadyError?:
|
|
181
|
-
|
|
182
|
-
detail?: unknown;
|
|
183
|
-
};
|
|
184
|
-
bootSettledError?: {
|
|
185
|
-
message: string;
|
|
186
|
-
detail?: unknown;
|
|
187
|
-
};
|
|
211
|
+
writeReadyError?: BridgeErrorWire;
|
|
212
|
+
bootSettledError?: BridgeErrorWire;
|
|
188
213
|
/**
|
|
189
214
|
* Present when the engine boot REJECTED for this attach: the tab rejects `attachSyncClient` with this
|
|
190
215
|
* message instead of hanging forever on the ack (ADR-0032 FIX 1). A later attach retries the boot. This
|
|
191
216
|
* is a LOCAL-READ-CORE failure (the engine never reached `localReadReady`); a tail failure after
|
|
192
217
|
* `localReadReady` uses the stage-error fields above and does NOT reject the attach.
|
|
193
218
|
*/
|
|
194
|
-
error?:
|
|
195
|
-
message: string;
|
|
196
|
-
detail?: unknown;
|
|
197
|
-
};
|
|
219
|
+
error?: BridgeErrorWire;
|
|
198
220
|
}
|
|
199
221
|
/** worker → tab: a broadcast pull-request — any attached tab may answer, first response wins (ADR-0032 decision 3). */
|
|
200
222
|
export interface TokenRequestPayload {
|
|
@@ -256,10 +278,7 @@ export interface RpcResultPayload {
|
|
|
256
278
|
/** The resolved value (present when `ok`). */
|
|
257
279
|
value?: unknown;
|
|
258
280
|
/** The rejection message + optional structured detail (present when `!ok`). */
|
|
259
|
-
error?:
|
|
260
|
-
message: string;
|
|
261
|
-
detail?: unknown;
|
|
262
|
-
};
|
|
281
|
+
error?: BridgeErrorWire;
|
|
263
282
|
}
|
|
264
283
|
/** tab → worker: register a live query. `id` correlates the initial snapshot; `queryId` keys subsequent diffs. */
|
|
265
284
|
export interface SubscribePayload {
|
|
@@ -268,9 +287,9 @@ export interface SubscribePayload {
|
|
|
268
287
|
params: unknown[];
|
|
269
288
|
/**
|
|
270
289
|
* The unique output aliases the worker wraps the query's columns under so it is safe to MATERIALISE
|
|
271
|
-
* (one per output column, in the compiled SQL's column order).
|
|
272
|
-
*
|
|
273
|
-
*
|
|
290
|
+
* (one per output column, in the compiled SQL's column order). When omitted, the worker leaves the SQL
|
|
291
|
+
* untouched and returns name-keyed rows; supply it for a JOIN with same-named columns, which
|
|
292
|
+
* `live.query`/`live.incrementalQuery` otherwise
|
|
274
293
|
* refuse to materialise (`column "title" specified more than once`). When present, result columns are
|
|
275
294
|
* the aliases, so {@link pkColumns} must name a PK by its alias.
|
|
276
295
|
*/
|
|
@@ -286,9 +305,8 @@ export interface SubscribePayload {
|
|
|
286
305
|
/**
|
|
287
306
|
* Per-subscription keep-alive hint (ms) for the worker's live-query manager (ADR-0040 decision 4): how long
|
|
288
307
|
* the shared registration should be retained after this subscription's last consumer leaves, so a matching
|
|
289
|
-
* resubscribe reuses it verbatim.
|
|
290
|
-
*
|
|
291
|
-
* means "no hint".
|
|
308
|
+
* resubscribe reuses it verbatim. When omitted, the worker falls back to
|
|
309
|
+
* `liveQueries.defaultKeepAliveMs`; absent means "no hint".
|
|
292
310
|
*/
|
|
293
311
|
keepAliveMs?: number;
|
|
294
312
|
}
|
|
@@ -355,10 +373,7 @@ export type BridgeEvent = {
|
|
|
355
373
|
} | {
|
|
356
374
|
kind: "milestone-error";
|
|
357
375
|
stage: BootMilestone;
|
|
358
|
-
error:
|
|
359
|
-
message: string;
|
|
360
|
-
detail?: unknown;
|
|
361
|
-
};
|
|
376
|
+
error: BridgeErrorWire;
|
|
362
377
|
} | {
|
|
363
378
|
kind: "conflict";
|
|
364
379
|
details: unknown;
|
|
@@ -410,9 +425,10 @@ export interface BridgeCodec {
|
|
|
410
425
|
decode: (payload: unknown) => unknown;
|
|
411
426
|
}
|
|
412
427
|
/**
|
|
413
|
-
* The
|
|
414
|
-
*
|
|
415
|
-
* only this object, never the message types or
|
|
428
|
+
* The identity codec, wire-format version 1 ({@link BRIDGE_PROTOCOL_VERSION}): the body IS the payload,
|
|
429
|
+
* and the transport's structured clone does the real copying. No transferables. The sole codec at this
|
|
430
|
+
* wire version — swapping in a columnar codec later touches only this object, never the message types or
|
|
431
|
+
* the router.
|
|
416
432
|
*/
|
|
417
433
|
export declare const identityCodec: BridgeCodec;
|
|
418
434
|
/** Build a wire envelope, running the payload through the codec. Returns the envelope + any transferables. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/worker/protocol.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/worker/protocol.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,cAAc,EAAG,kBAA2B,CAAC;AAC1D,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAElD;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEz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AAc,CAOtE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,kBAAkB,EAAE,GAC9B,IAAI,CAQN"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type PlacementProbeResult } from "../placement-probe";
|
|
2
|
+
/**
|
|
3
|
+
* The SharedWorker's engine-home decision (ADR-0049 D1). `shared-worker` = the engine boots in this
|
|
4
|
+
* SharedWorker scope (granted OPFS sync access, SW-direct, election never engages); `elected-worker` = the
|
|
5
|
+
* SharedWorker is router-only and each tab elects a dedicated engine worker. `probeError` carries the probe's
|
|
6
|
+
* verbatim denial attribution when NOT granted (diagnostics only, never parsed). `swInstanceId` scopes every
|
|
7
|
+
* minted engine identity's generation (`engine-router.ts`).
|
|
8
|
+
*/
|
|
9
|
+
export interface SwPlacementResult {
|
|
10
|
+
engineHome: "shared-worker" | "elected-worker";
|
|
11
|
+
probeError?: string;
|
|
12
|
+
swInstanceId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Present ONLY on a `shared-worker` home that is a CAPABILITY-ABSENCE fallback (ADR-0049 D1), not an OPFS
|
|
15
|
+
* grant: the platform cannot hold sync-access handles in any home, so the engine boots in-SharedWorker on the
|
|
16
|
+
* IDBFS backend with the registry-declared durability. Carries the verbatim probe attribution the fallback
|
|
17
|
+
* boot stamps into `storageFallbackReason` (decision 12). Absent on a granted `shared-worker` (SW-direct OPFS)
|
|
18
|
+
* and on `elected-worker` — an OPFS-capable elected home is not a fallback.
|
|
19
|
+
*/
|
|
20
|
+
storageFallbackReason?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Injectable seams so the decision is deterministic in a Bun unit test (no real OPFS, no real crypto needed). */
|
|
23
|
+
export interface DecideSwPlacementDeps {
|
|
24
|
+
/** The placement probe; defaults to {@link probeOpfsSyncAccess}. Injected in tests to drive both verdicts. */
|
|
25
|
+
probe?: () => Promise<PlacementProbeResult>;
|
|
26
|
+
/** Mint the opaque SharedWorker instance id; defaults to `crypto.randomUUID()`. Injected for deterministic tests. */
|
|
27
|
+
mintInstanceId?: () => string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Decide the SharedWorker's engine home ONCE at startup (ADR-0049 D1, invariant 8 — probe per boot, never
|
|
31
|
+
* cached). Runs the placement probe; a granted verdict places the engine in-scope (`shared-worker`), a denied
|
|
32
|
+
* one puts the SharedWorker in router-only mode (`elected-worker`) and carries the probe's verbatim error for
|
|
33
|
+
* diagnostics. This is a PURE decision — no engine boots and no router is created here; the bootstrap
|
|
34
|
+
* (`define-sync-worker.ts`) acts on the result.
|
|
35
|
+
*/
|
|
36
|
+
export declare function decideSwPlacement(deps?: DecideSwPlacementDeps): Promise<SwPlacementResult>;
|
|
37
|
+
//# sourceMappingURL=sw-placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sw-placement.d.ts","sourceRoot":"","sources":["../../src/worker/sw-placement.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,oBAAoB,EAAuB,MAAM,oBAAoB,CAAC;AAEpF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,eAAe,GAAG,gBAAgB,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,kHAAkH;AAClH,MAAM,WAAW,qBAAqB;IACpC,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC5C,qHAAqH;IACrH,cAAc,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAahG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgxsinkit/client",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"tanstack-intent"
|
|
6
6
|
],
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
"@electric-sql/client": "^1.5.24",
|
|
37
37
|
"@electric-sql/experimental": "^6.0.24",
|
|
38
38
|
"@electric-sql/pglite-tools": "0.4.4",
|
|
39
|
-
"@pgxsinkit/contracts": "0.1
|
|
39
|
+
"@pgxsinkit/contracts": "0.2.1",
|
|
40
|
+
"@pgxsinkit/pglite-opfs-repacked": "0.2.1"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
|
-
"@electric-sql/pglite": "0.5.4",
|
|
43
|
+
"@electric-sql/pglite": ">=0.5.4-pgx.0 <0.5.5",
|
|
43
44
|
"drizzle-orm": "1.0.0-rc.4",
|
|
44
45
|
"zod": "^4.4.3"
|
|
45
46
|
},
|
package/skills/core/SKILL.md
CHANGED
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: core
|
|
15
15
|
library: "@pgxsinkit/client"
|
|
16
|
-
library_version: "0.
|
|
16
|
+
library_version: "0.2.2"
|
|
17
17
|
source: https://pgxsinkit.github.io/llms-full.txt
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -213,17 +213,20 @@ constraint that holds server-side also holds in PGlite.
|
|
|
213
213
|
## Naming the local store
|
|
214
214
|
|
|
215
215
|
`createSyncClient`/`createClientPGlite` take a **plain `storePath`** (e.g. `"my-app-store"`), never a
|
|
216
|
-
storage URL — the backend is derived
|
|
217
|
-
|
|
218
|
-
the
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
`
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
default
|
|
225
|
-
|
|
226
|
-
|
|
216
|
+
storage URL — the backend is derived, not named: a capability-proven browser engine home uses the
|
|
217
|
+
constant-handle OPFS-repacked backend, fixed worker mode and browser fallbacks use IndexedDB, and bun/Node
|
|
218
|
+
uses the filesystem; anything containing `://` throws `InvalidStorePathError`. Memory-backed stores are
|
|
219
|
+
deliberately not expressible in the production API (pgxsinkit's retention + journal durability assume a
|
|
220
|
+
persisted store): in TESTS, spread `memoryStoreForTests("name")` from `@pgxsinkit/client/testing` into the
|
|
221
|
+
options; a caller-owned `pgliteInstance` that is provably non-persistent (a bare `new PGlite()`, or
|
|
222
|
+
`memory://`) is refused with `NonPersistentStoreError` unless a testing acknowledgment is spread alongside.
|
|
223
|
+
Separately from persistence, the store's flush **timing** is `durability`, declared once on the registry
|
|
224
|
+
(`storage.durability`, default `"relaxed"`) — never a per-open, per-tab, or minting-surface option. Its
|
|
225
|
+
physical behavior is backend-specific: idb detaches its whole-snapshot flush, while OPFS-repacked keeps the
|
|
226
|
+
host awaited but omits routine physical flushes. `"strict"` restores each backend's strict boundary. The
|
|
227
|
+
SharedWorker factory, capability-driven Safari/Chromium/Firefox engine placement, relocation outcomes,
|
|
228
|
+
adoption, destruction, write-latency rationale, and recovery windows live in the `operating` skill.
|
|
229
|
+
Backups, the SQL exports, and `restoreFrom` are there too.
|
|
227
230
|
|
|
228
231
|
## Where to look
|
|
229
232
|
|