@pgxsinkit/client 0.2.0 → 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/dist/index.d.ts +20 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +460 -165
- package/dist/index.js.map +8 -8
- package/dist/mutation.d.ts +6 -0
- package/dist/mutation.d.ts.map +1 -1
- package/dist/worker/attach-sync-client.d.ts +81 -20
- package/dist/worker/attach-sync-client.d.ts.map +1 -1
- package/dist/worker/define-sync-worker.d.ts +33 -8
- package/dist/worker/define-sync-worker.d.ts.map +1 -1
- package/dist/worker/engine-control.d.ts +2 -1
- package/dist/worker/engine-control.d.ts.map +1 -1
- package/dist/worker/protocol.d.ts +32 -21
- package/dist/worker/protocol.d.ts.map +1 -1
- package/package.json +3 -3
- package/skills/core/SKILL.md +1 -1
- package/skills/operating/SKILL.md +47 -8
- package/src/index.ts +55 -7
- package/src/mutation.ts +48 -4
- package/src/worker/attach-sync-client.ts +322 -130
- package/src/worker/define-sync-worker.ts +445 -132
- package/src/worker/engine-control.ts +2 -2
- package/src/worker/protocol.ts +33 -6
package/dist/mutation.d.ts
CHANGED
|
@@ -170,6 +170,12 @@ export interface MutationRuntime<TRegistry extends SyncTableRegistry> {
|
|
|
170
170
|
acks: MutationAck[];
|
|
171
171
|
}>;
|
|
172
172
|
reconcile: (table?: SyncTableName<TRegistry>) => Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Fire the runtime's dispose signal: abort every in-flight write-path fetch AND unblock any await parked on
|
|
175
|
+
* a stalled getAuthToken(). Called FIRST by the client's stop()/destroy() so teardown halts all write-network
|
|
176
|
+
* activity before it awaits the convergence pass. Idempotent; a disposed runtime performs no further network.
|
|
177
|
+
*/
|
|
178
|
+
abortInFlight: () => void;
|
|
173
179
|
retryFailed: (table?: SyncTableName<TRegistry>) => Promise<void>;
|
|
174
180
|
recoverSending: (table?: SyncTableName<TRegistry>) => Promise<void>;
|
|
175
181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I,MAAM,CAExC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAelF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAYzG;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,UAGzD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,MAAoB,UAG3F;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,MAAoB,UAE3G;AAED,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,iBAAiB,EACvE,OAAO,EAAE,4BAA4B,CAAC,SAAS,CAAC,GAC/C,eAAe,CAAC,SAAS,CAAC,CAkkC5B"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { SyncRuntimeStatus, SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
1
|
+
import type { SyncRuntimeStatus, SyncStorageDeclaration, SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
2
2
|
import type { BootReport } from "../boot-report";
|
|
3
3
|
import { type MutationDetail, type SyncClient } from "../index";
|
|
4
4
|
import type { LocalStoreVersionEvent } from "../local-store";
|
|
5
5
|
import { type OpfsEffectsDeps } from "../opfs-effects";
|
|
6
6
|
import { type DestructionEffects } from "../store-lifecycle";
|
|
7
7
|
import { type StoreMetaDeps } from "../store-meta";
|
|
8
|
+
import { type PlacementQueryResult } from "./define-sync-worker";
|
|
8
9
|
import { type CoordinatorDeps } from "./election-coordinator";
|
|
9
10
|
import { type ExecutionLimitConfig } from "./engine-control";
|
|
10
11
|
import { type AuthTokenSnapshot, type BridgeCodec, type BridgePort, type BridgeTransferable } from "./protocol";
|
|
@@ -85,6 +86,65 @@ export declare function createStoreDestructionEffects(storePath: string, deps?:
|
|
|
85
86
|
opfs?: OpfsEffectsDeps;
|
|
86
87
|
meta?: StoreMetaDeps;
|
|
87
88
|
}): DestructionEffects;
|
|
89
|
+
/**
|
|
90
|
+
* Destroy every local artifact of a store BY PATH (ADR-0050 stage 2; the public face of the ADR-0049 D8
|
|
91
|
+
* destruction machinery): the OPFS store directory, the commitment sentinel, the meta record, AND the idb
|
|
92
|
+
* database — backend-agnostic (delete-if-present on both backends), with the bounded VFS-ownership-lag retry.
|
|
93
|
+
*
|
|
94
|
+
* **Precondition: the store is NOT running.** This is the companion to {@link SyncClient.destroy} (the
|
|
95
|
+
* supervised destroy of an ATTACHED store — peer-checked, teardown-acknowledged): reach for
|
|
96
|
+
* `destroyStoreArtifacts` for a store nobody is attached to — an obsolete path a preference change left
|
|
97
|
+
* behind, a wipe of known store paths. Called on a path a live engine still holds, the backend delete throws
|
|
98
|
+
* an ownership error after the bounded retry — loud, and safely RE-RUNNABLE: the destruction sequence is
|
|
99
|
+
* idempotent and phase-recorded (a store whose meta record says `deleting` is refused for boot), so a re-run
|
|
100
|
+
* completes it. No liveness probe is attempted here — it could not be race-free, and the ownership error
|
|
101
|
+
* already fails hard; callers keep failed paths on their own retry list (e.g. the board's Obsolete stores).
|
|
102
|
+
*/
|
|
103
|
+
export declare function destroyStoreArtifacts(storePath: string, opts?: StoreDestructionRetryOptions): Promise<void>;
|
|
104
|
+
/** Options for {@link quiesceStoreWorker} (ADR-0050). */
|
|
105
|
+
export interface StoreWorkerQuiesceOptions {
|
|
106
|
+
/** The ADR-0050 storage declaration to post on the port. Omit (or `{}`) to state NO opinion — always
|
|
107
|
+
* compatible with whatever declaration the live worker already bound, so it can never be refused. Passing a
|
|
108
|
+
* concrete declaration risks a `StorageDeclarationRefusedError` if it disagrees with the bound one. */
|
|
109
|
+
storage?: SyncStorageDeclaration;
|
|
110
|
+
/** Bound on the whole handshake (declaration → placement reply → teardown ack). Default 6000ms. On timeout
|
|
111
|
+
* the returned promise REJECTS — the caller keeps the path on its retry list; it is NOT proof of teardown. */
|
|
112
|
+
timeoutMs?: number;
|
|
113
|
+
/** Injectable timers (tests); defaults to real `setTimeout`/`clearTimeout`. */
|
|
114
|
+
timers?: AttachClientTimers;
|
|
115
|
+
}
|
|
116
|
+
/** The outcome of {@link quiesceStoreWorker}. */
|
|
117
|
+
export interface StoreWorkerQuiesceOutcome {
|
|
118
|
+
/** The store's engine home as reported by its placement reply. */
|
|
119
|
+
engineHome: PlacementQueryResult["engineHome"];
|
|
120
|
+
/** True iff an SW-direct engine was torn down here (its host closed, releasing the backend connection).
|
|
121
|
+
* `false` for an `elected-worker` home — there is no in-SharedWorker engine to close from this router-only
|
|
122
|
+
* connection; the elected dedicated engine dies with its owning tab (the browser terminates it on document
|
|
123
|
+
* teardown), releasing its store, so no active teardown is needed before a path-addressed destroy. */
|
|
124
|
+
toreDown: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Quiesce the SharedWorker HOSTING a store, by path, so its backend connection is released BEFORE a
|
|
128
|
+
* {@link destroyStoreArtifacts} on the same path (ADR-0050). The gap it closes: the board's workers are
|
|
129
|
+
* `extendedLifetime`, so a store's SharedWorker OUTLIVES the document that spawned it — and the idbfs backend
|
|
130
|
+
* holds its IndexedDB connection open for the engine's whole life. So after a reload, an idbfs store's worker
|
|
131
|
+
* is still alive and still holding the connection; `deleteDatabase` blocks and `destroyStoreArtifacts` fails,
|
|
132
|
+
* boot after boot, until the browser eventually reaps the worker. OPFS releases its handles when idle, so it
|
|
133
|
+
* never had this problem — this is the idbfs (SW-direct) fix.
|
|
134
|
+
*
|
|
135
|
+
* `worker` is a factory (or instance), exactly like {@link attachSyncClient}'s `worker` — the caller constructs
|
|
136
|
+
* `new SharedWorker(url, { name: storePath })`, so the library stays DOM-free. Connecting by that name reaches
|
|
137
|
+
* the LIVE worker (if any) or spawns a fresh one; either way the sequence is: post the declaration, query
|
|
138
|
+
* placement, and — for a `shared-worker` home — send `engine-teardown` and await its reserved ack, which the
|
|
139
|
+
* host posts only after `closeHost()` has stopped the engine and released the backend connection (it then
|
|
140
|
+
* closes its own scope). An `elected-worker` home resolves immediately with `toreDown: false` (see the field).
|
|
141
|
+
*
|
|
142
|
+
* Idempotent and safe on an already-dead store: a fresh spawn boots no engine, and its teardown closes an empty
|
|
143
|
+
* host. Compose it as `await quiesceStoreWorker(f).catch(() => {}); await destroyStoreArtifacts(path)` — a
|
|
144
|
+
* quiesce failure (timeout) must NOT abort the destroy, whose own ownership-lag handling reports honestly and
|
|
145
|
+
* leaves the path re-runnable.
|
|
146
|
+
*/
|
|
147
|
+
export declare function quiesceStoreWorker(worker: (() => WorkerLike) | WorkerLike, opts?: StoreWorkerQuiesceOptions): Promise<StoreWorkerQuiesceOutcome>;
|
|
88
148
|
/** The bounded ownership-retry options for {@link runStoreDestruction} (the VFS-lock-lag guard, D8/fault row). */
|
|
89
149
|
export interface StoreDestructionRetryOptions {
|
|
90
150
|
/** Max retries of `deleteBackendStore` on an ownership-lock-lag error before giving up (default 5). */
|
|
@@ -157,11 +217,27 @@ export interface AttachSyncClientOptions<TRegistry extends SyncTableRegistry> {
|
|
|
157
217
|
* Restore the worker's store from a backup on attach (ADR-0035 decision 6) — the worker-mode `restoreFrom`.
|
|
158
218
|
* A `File`/`Blob` as produced by {@link SyncClient.exportStore}; the facade decomposes it into a transferred
|
|
159
219
|
* `ArrayBuffer` + name/mime ({@link RestoreArtefactWire}) and the worker recomposes it for `createSyncClient`.
|
|
160
|
-
* Restore rides the
|
|
161
|
-
*
|
|
162
|
-
*
|
|
220
|
+
* Restore rides the one handshake that reaches the ENGINE HOME: a restore-bearing attach awaits the
|
|
221
|
+
* placement reply, then carries the artifact on the SW-port handshake when the in-scope host is the engine
|
|
222
|
+
* (SW-direct / declared-idbfs) or on the first per-tab PIPE handshake when the engine is elected — the
|
|
223
|
+
* router-only SharedWorker is payload-blind, so a restore posted there would be dropped and destroyed.
|
|
224
|
+
* Passing it when the engine has ALREADY booted rejects the attach with a typed error
|
|
225
|
+
* (`RestoreIntoRunningStoreError` by name — you cannot restore into a running store). The restored engine
|
|
226
|
+
* boots offline and its recovered journal is quarantined, exactly as in-process — see `restoreFrom` on
|
|
227
|
+
* `createSyncClient`.
|
|
163
228
|
*/
|
|
164
229
|
restoreFrom?: File | Blob;
|
|
230
|
+
/**
|
|
231
|
+
* The tab's WIRE storage declaration for this store (ADR-0050) — posted as the declaration message on the
|
|
232
|
+
* worker port BEFORE the placement query (so `backend: "idbfs"` can skip the probe), and carried on the
|
|
233
|
+
* provision/attach payloads so the engine binds it (durability included). Omit (or `{}`) for "no opinion":
|
|
234
|
+
* a registry-attached static declaration, else the capability defaults, decide. A registry-attached
|
|
235
|
+
* declaration is AUTHORITATIVE — an explicit field here that disagrees with it (or with the declaration
|
|
236
|
+
* another tab already bound) is a typed refusal (`StorageDeclarationRefusedError`), never silently
|
|
237
|
+
* overridden: a store's declaration is immutable, and a preference change mints a fresh store under a
|
|
238
|
+
* fresh path instead.
|
|
239
|
+
*/
|
|
240
|
+
storage?: SyncStorageDeclaration;
|
|
165
241
|
codec?: BridgeCodec;
|
|
166
242
|
onStatusChange?: (status: SyncRuntimeStatus) => void;
|
|
167
243
|
onConflict?: (details: MutationDetail[]) => void;
|
|
@@ -278,7 +354,7 @@ export type AttachedSyncClient<TRegistry extends SyncTableRegistry> = SyncClient
|
|
|
278
354
|
};
|
|
279
355
|
export declare function attachSyncClient<const TRegistry extends SyncTableRegistry>(options: AttachSyncClientOptions<TRegistry>): Promise<AttachedSyncClient<TRegistry>>;
|
|
280
356
|
/** {@link provisionSyncWorker} options — attach's transport/store/factory seams, plus the provision expiry. */
|
|
281
|
-
export type ProvisionSyncWorkerOptions<TRegistry extends SyncTableRegistry> = Pick<AttachSyncClientOptions<TRegistry>, "worker" | "port" | "storeId" | "storePath" | "codec" | "createEngineWorker" | "electionIo" | "awaitOwnershipRelease" | "timers"> & {
|
|
357
|
+
export type ProvisionSyncWorkerOptions<TRegistry extends SyncTableRegistry> = Pick<AttachSyncClientOptions<TRegistry>, "worker" | "port" | "storeId" | "storePath" | "storage" | "codec" | "createEngineWorker" | "electionIo" | "awaitOwnershipRelease" | "timers"> & {
|
|
282
358
|
/**
|
|
283
359
|
* How long (ms) the elected-mode provision claim (and its shared-coordinator ref) is held before an abandoned
|
|
284
360
|
* warmed provision auto-retires (ADR-0049 step 8, "abandoned warmed provision → claim expiry"). Default 60000.
|
|
@@ -287,21 +363,6 @@ export type ProvisionSyncWorkerOptions<TRegistry extends SyncTableRegistry> = Pi
|
|
|
287
363
|
*/
|
|
288
364
|
provisionExpiryMs?: number;
|
|
289
365
|
};
|
|
290
|
-
/** Options for deliberately retiring a SW-direct host before changing its construction identity. */
|
|
291
|
-
export type RetireSyncWorkerHostOptions = Pick<AttachSyncClientOptions<SyncTableRegistry>, "worker" | "port" | "timers"> & {
|
|
292
|
-
/** Bound for the placement + teardown handshake. Default 5000 ms. */
|
|
293
|
-
timeoutMs?: number;
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Quiesce and retire a SW-direct sync host without deleting its store.
|
|
297
|
-
*
|
|
298
|
-
* This is the construction-lifecycle companion to {@link provisionSyncWorker}: a caller that must replace a
|
|
299
|
-
* SharedWorker under a different construction identity (for example, a different durability preference) first
|
|
300
|
-
* awaits this barrier so the old extended-lifetime worker releases its database handle. Elected placement owns
|
|
301
|
-
* retirement through its coordinator and is therefore rejected here. Retirement is refused while peer tabs are
|
|
302
|
-
* attached: changing one tab's construction preference must not terminate a host other tabs are actively using.
|
|
303
|
-
*/
|
|
304
|
-
export declare function retireSyncWorkerHost(options: RetireSyncWorkerHostOptions): Promise<void>;
|
|
305
366
|
/**
|
|
306
367
|
* Pre-spawn a worker's store WITHOUT attaching (ADR-0032 decision 5). Sent at the board's login screen against a
|
|
307
368
|
* freshly-named spare `SharedWorker`: the worker runs PGlite `create`/initdb only and holds the raw store idle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attach-sync-client.d.ts","sourceRoot":"","sources":["../../src/worker/attach-sync-client.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"attach-sync-client.d.ts","sourceRoot":"","sources":["../../src/worker/attach-sync-client.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEV,iBAAiB,EACjB,sBAAsB,EAEtB,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,OAAO,EAQL,KAAK,cAAc,EAEnB,KAAK,UAAU,EAGhB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAyB,KAAK,aAAa,EAAwB,MAAM,eAAe,CAAC;AAGhG,OAAO,EAQL,KAAK,oBAAoB,EAE1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAOL,KAAK,oBAAoB,EAI1B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEhB,KAAK,UAAU,EACf,KAAK,kBAAkB,EAexB,MAAM,YAAY,CAAC;AAEpB,mHAAmH;AACnH,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IAC1E,gBAAgB,CAAC,EAAE,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AAuB,CAAC,SAAS,CAAC,GAC1C,OAAO,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAo7CxC;AAED,+GAA+G;AAC/G,MAAM,MAAM,0BAA0B,CAAC,SAAS,SAAS,iBAAiB,IAAI,IAAI,CAChF,uBAAuB,CAAC,SAAS,CAAC,EAChC,QAAQ,GACR,MAAM,GACN,SAAS,GACT,WAAW,GACX,SAAS,GACT,OAAO,GACP,oBAAoB,GACpB,YAAY,GACZ,uBAAuB,GACvB,QAAQ,CACX,GAAG;IACF;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,SAAS,SAAS,iBAAiB,EAC3E,OAAO,EAAE,0BAA0B,CAAC,SAAS,CAAC,GAC7C,OAAO,CAAC,IAAI,CAAC,CAuJf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
1
|
+
import type { SyncStorageDeclaration, SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
2
2
|
import { type AdoptionDeclaration, type ClientPGlite, type CreateSyncClientOptions, type SyncClient } from "../index";
|
|
3
3
|
import { type PlacementProbeResult } from "../placement-probe";
|
|
4
4
|
import { type ExecutionLimitConfig } from "./engine-control";
|
|
@@ -176,6 +176,28 @@ export declare const PLACEMENT_RESULT_KEY: "pgx0049PlacementResult";
|
|
|
176
176
|
export declare const DESTROY_QUERY_KEY: "pgx0049DestroyQuery";
|
|
177
177
|
/** The reply to a {@link DESTROY_QUERY_KEY} query — the attached-tab count (querying tab included). */
|
|
178
178
|
export declare const DESTROY_VERDICT_KEY: "pgx0049DestroyVerdict";
|
|
179
|
+
/**
|
|
180
|
+
* The DECLARATION-MESSAGE envelope key (ADR-0050): the tab posts `{ [DECLARATION_KEY]: SyncStorageDeclaration }`
|
|
181
|
+
* on EVERY worker port BEFORE its placement query — always, even when the app declared nothing (an empty `{}`
|
|
182
|
+
* meaning "no opinion: capability defaults"). The bootstrap defers its placement decision until the first one
|
|
183
|
+
* arrives (a registry-attached static declaration decides at startup instead), binds the first arrival for the
|
|
184
|
+
* worker/store lifetime, and refuses explicit conflicts. The worker NAME carries the store path only — never
|
|
185
|
+
* configuration; that was the fault this key replaces.
|
|
186
|
+
*/
|
|
187
|
+
export declare const DECLARATION_KEY: "pgx0050Declaration";
|
|
188
|
+
/**
|
|
189
|
+
* The reply when a declaration (or an engine-bound message on an undeclared port) is REFUSED (ADR-0050):
|
|
190
|
+
* `{ [DECLARATION_REFUSED_KEY]: { message, name } }`. `name` is the stable typed-error name
|
|
191
|
+
* (`StorageDeclarationRefusedError`) so the tab rebuilds the refusal typed and fails its boot loudly —
|
|
192
|
+
* never a silent old value, never a hang.
|
|
193
|
+
*/
|
|
194
|
+
export declare const DECLARATION_REFUSED_KEY: "pgx0050DeclarationRefused";
|
|
195
|
+
/** The {@link DECLARATION_REFUSED_KEY} reply payload. */
|
|
196
|
+
export interface DeclarationRefusedWire {
|
|
197
|
+
message: string;
|
|
198
|
+
/** The stable typed-error name (`StorageDeclarationRefusedError`) for the tab-side rebuild. */
|
|
199
|
+
name: string;
|
|
200
|
+
}
|
|
179
201
|
/** The placement a tab learns from the SharedWorker (the reply payload under {@link PLACEMENT_RESULT_KEY}). */
|
|
180
202
|
export interface PlacementQueryResult {
|
|
181
203
|
engineHome: SwPlacementResult["engineHome"];
|
|
@@ -194,7 +216,9 @@ export interface PlacementQueryResult {
|
|
|
194
216
|
/** The SharedWorker placement bootstrap's dependencies (all injected so it is unit-testable off-worker). */
|
|
195
217
|
export interface SharedWorkerBootstrapDeps {
|
|
196
218
|
/** The engine host `connect` — used in SW-direct (`shared-worker`) placement to pipe a port to the in-scope engine. */
|
|
197
|
-
connect: (port: BridgePort
|
|
219
|
+
connect: (port: BridgePort, connection?: {
|
|
220
|
+
placementQueriesHandled?: boolean;
|
|
221
|
+
}) => void;
|
|
198
222
|
/** Quiesce and close the in-scope host before SW-direct destruction acknowledges handle release. */
|
|
199
223
|
closeHost?: () => Promise<void>;
|
|
200
224
|
/** Current attached-tab count for the DESTROY verdict in SW-direct mode (the host's own port set). */
|
|
@@ -202,13 +226,14 @@ export interface SharedWorkerBootstrapDeps {
|
|
|
202
226
|
/** The opt-in execution limit, threaded into the router in `elected-worker` (router-only) placement. */
|
|
203
227
|
executionLimit?: ExecutionLimitConfig;
|
|
204
228
|
/**
|
|
205
|
-
* The registry
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* and
|
|
229
|
+
* The registry-attached STATIC storage declaration (ADR-0050) — authoritative when present: it binds the
|
|
230
|
+
* store's declaration and decides placement AT SCOPE STARTUP (no wait for a declaration message).
|
|
231
|
+
* `backend: "idbfs"` skips the probe entirely and binds the in-SharedWorker engine host on idbfs (ADR-0049
|
|
232
|
+
* D1's declared opt-out — the declared mode, not a fallback); any other resolution runs the UNCONDITIONAL
|
|
233
|
+
* placement probe. Absent: the scope is registry-silent and DEFERS its placement decision until the first
|
|
234
|
+
* port's declaration message arrives (whose explicit fields then bind).
|
|
210
235
|
*/
|
|
211
|
-
|
|
236
|
+
staticStorage?: SyncStorageDeclaration;
|
|
212
237
|
/** Test seam: inject the placement decision (a fake probe result) instead of the real {@link decideSwPlacement}. */
|
|
213
238
|
decidePlacement?: () => Promise<SwPlacementResult>;
|
|
214
239
|
/** Defaults to `globalThis`; tests inject a fake SharedWorker scope. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-sync-worker.d.ts","sourceRoot":"","sources":["../../src/worker/define-sync-worker.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"define-sync-worker.d.ts","sourceRoot":"","sources":["../../src/worker/define-sync-worker.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAGV,sBAAsB,EAEtB,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;A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MAAM,MAAM,CAAC;IACxB,wGAAwG;IACxG,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,oHAAoH;IACpH,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnD,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,IAAI,CAAC;IAC3D;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC7C;AAED,oHAAoH;AACpH,MAAM,WAAW,yBAAyB;IACxC,0GAA0G;IAC1G,UAAU,EAAE,iBAAiB,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IACxD,oHAAoH;IACpH,WAAW,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAqCD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CA8C1E"}
|
|
@@ -132,9 +132,10 @@ export type EngineControlMessage =
|
|
|
132
132
|
type: "control-ack";
|
|
133
133
|
identity: EngineIdentity;
|
|
134
134
|
pingId: number;
|
|
135
|
-
/** Present only when the reserved teardown acknowledgement reports that host close failed. */
|
|
135
|
+
/** Present only when the reserved teardown acknowledgement reports that host close failed. Mirrors `protocol.ts`'s `BridgeErrorWire` (this module deliberately imports nothing from the bridge). */
|
|
136
136
|
error?: {
|
|
137
137
|
message: string;
|
|
138
|
+
name?: string;
|
|
138
139
|
detail?: unknown;
|
|
139
140
|
};
|
|
140
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-control.d.ts","sourceRoot":"","sources":["../../src/worker/engine-control.ts"],"names":[],"mappings":"AAYA,+EAA+E;AAC/E,eAAO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GAAG,SAAS,CAAC;AAElE,gHAAgH;AAChH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,qBAAqB,CAAC;IACnC,OAAO,EAAE,sBAAsB,CAAC;CACjC;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,sBAAyB;IACtC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAEzC,YAAY,OAAO,EAAE,sBAAsB,EAI1C;CACF;AAiBD,6GAA6G;AAC7G,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,mBAAmB,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAMzF"}
|
|
@@ -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";
|
|
@@ -42,6 +42,18 @@ export interface BridgeEnvelope {
|
|
|
42
42
|
payload: unknown;
|
|
43
43
|
}
|
|
44
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
|
+
}
|
|
45
57
|
/** A single auth token snapshot the tab owns and pushes to the worker (ADR-0032 decision 3). */
|
|
46
58
|
export interface AuthTokenSnapshot {
|
|
47
59
|
accessToken: string;
|
|
@@ -71,6 +83,13 @@ export interface ProvisionPayload {
|
|
|
71
83
|
* lane (via the attaching helper); a browser worker never sends it.
|
|
72
84
|
*/
|
|
73
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;
|
|
74
93
|
}
|
|
75
94
|
/** worker → tab: the provision completed (or failed). Lets the login screen confirm the spare is warm. */
|
|
76
95
|
export interface ProvisionAckPayload {
|
|
@@ -124,6 +143,13 @@ export interface AttachPayload {
|
|
|
124
143
|
* this AFTER the engine has already booted is REFUSED (you cannot restore into a running store).
|
|
125
144
|
*/
|
|
126
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;
|
|
127
153
|
/** The tab's current auth token at attach time, or null when unauthenticated. */
|
|
128
154
|
token: AuthTokenSnapshot | null;
|
|
129
155
|
/**
|
|
@@ -182,24 +208,15 @@ export interface AttachAckPayload {
|
|
|
182
208
|
* itself still RESOLVES (the engine reached `localReadReady`; only the tail failed). A live milestone
|
|
183
209
|
* failure after attach rides the `milestone-error` broadcast instead.
|
|
184
210
|
*/
|
|
185
|
-
writeReadyError?:
|
|
186
|
-
|
|
187
|
-
detail?: unknown;
|
|
188
|
-
};
|
|
189
|
-
bootSettledError?: {
|
|
190
|
-
message: string;
|
|
191
|
-
detail?: unknown;
|
|
192
|
-
};
|
|
211
|
+
writeReadyError?: BridgeErrorWire;
|
|
212
|
+
bootSettledError?: BridgeErrorWire;
|
|
193
213
|
/**
|
|
194
214
|
* Present when the engine boot REJECTED for this attach: the tab rejects `attachSyncClient` with this
|
|
195
215
|
* message instead of hanging forever on the ack (ADR-0032 FIX 1). A later attach retries the boot. This
|
|
196
216
|
* is a LOCAL-READ-CORE failure (the engine never reached `localReadReady`); a tail failure after
|
|
197
217
|
* `localReadReady` uses the stage-error fields above and does NOT reject the attach.
|
|
198
218
|
*/
|
|
199
|
-
error?:
|
|
200
|
-
message: string;
|
|
201
|
-
detail?: unknown;
|
|
202
|
-
};
|
|
219
|
+
error?: BridgeErrorWire;
|
|
203
220
|
}
|
|
204
221
|
/** worker → tab: a broadcast pull-request — any attached tab may answer, first response wins (ADR-0032 decision 3). */
|
|
205
222
|
export interface TokenRequestPayload {
|
|
@@ -261,10 +278,7 @@ export interface RpcResultPayload {
|
|
|
261
278
|
/** The resolved value (present when `ok`). */
|
|
262
279
|
value?: unknown;
|
|
263
280
|
/** The rejection message + optional structured detail (present when `!ok`). */
|
|
264
|
-
error?:
|
|
265
|
-
message: string;
|
|
266
|
-
detail?: unknown;
|
|
267
|
-
};
|
|
281
|
+
error?: BridgeErrorWire;
|
|
268
282
|
}
|
|
269
283
|
/** tab → worker: register a live query. `id` correlates the initial snapshot; `queryId` keys subsequent diffs. */
|
|
270
284
|
export interface SubscribePayload {
|
|
@@ -359,10 +373,7 @@ export type BridgeEvent = {
|
|
|
359
373
|
} | {
|
|
360
374
|
kind: "milestone-error";
|
|
361
375
|
stage: BootMilestone;
|
|
362
|
-
error:
|
|
363
|
-
message: string;
|
|
364
|
-
detail?: unknown;
|
|
365
|
-
};
|
|
376
|
+
error: BridgeErrorWire;
|
|
366
377
|
} | {
|
|
367
378
|
kind: "conflict";
|
|
368
379
|
details: unknown;
|
|
@@ -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;AAEzC;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IACzE,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,EAA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/client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"tanstack-intent"
|
|
6
6
|
],
|
|
@@ -36,8 +36,8 @@
|
|
|
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.2.
|
|
40
|
-
"@pgxsinkit/pglite-opfs-repacked": "0.2.
|
|
39
|
+
"@pgxsinkit/contracts": "0.2.1",
|
|
40
|
+
"@pgxsinkit/pglite-opfs-repacked": "0.2.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@electric-sql/pglite": ">=0.5.4-pgx.0 <0.5.5",
|
package/skills/core/SKILL.md
CHANGED
|
@@ -14,7 +14,7 @@ description: >-
|
|
|
14
14
|
metadata:
|
|
15
15
|
type: task
|
|
16
16
|
library: "@pgxsinkit/client"
|
|
17
|
-
library_version: "0.2.
|
|
17
|
+
library_version: "0.2.2"
|
|
18
18
|
source: https://pgxsinkit.github.io/start/operating-in-production/
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -294,13 +294,52 @@ offline for inspection; a clean-journal restore may honor the normal online opti
|
|
|
294
294
|
persisted store normally. Consumer docs:
|
|
295
295
|
<https://pgxsinkit.github.io/concepts/export-and-restore/>.
|
|
296
296
|
|
|
297
|
-
**Adoption
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
creation-path equivalent and refuses a live store with `StoreInUseError`.
|
|
302
|
-
|
|
303
|
-
|
|
297
|
+
**Adoption.** An existing idb store is authoritative and is never silently replaced by a newly capable
|
|
298
|
+
OPFS home. Automatic adoption is default-off and requires the worker-entry declaration
|
|
299
|
+
`adoption: "server-reconstructible"`; only a drained journal, authorized online reconstruction, and a
|
|
300
|
+
returned strict barrier permit the idb predecessor to be deleted. `adoptStore()` is the manual
|
|
301
|
+
creation-path equivalent and refuses a live store with `StoreInUseError`.
|
|
302
|
+
|
|
303
|
+
**Resetting and deleting stores (ADR-0050).** Three non-interchangeable levers — pick by what you keep
|
|
304
|
+
and whether the store is running:
|
|
305
|
+
|
|
306
|
+
- `client.dropReadCache()` — keep the store, drop synced rows, resync in place (overlay + journal survive).
|
|
307
|
+
- `client.destroy()` — delete a RUNNING store from an attached client: peer-count checked
|
|
308
|
+
(`StoreDestroyRefusedError` while peers hold it), owed-journal checked (refused unless `force`),
|
|
309
|
+
teardown-acknowledged before deletion.
|
|
310
|
+
- `destroyStoreArtifacts(storePath)` — delete a NOT-running store by path: OPFS directory + commitment
|
|
311
|
+
sentinel + meta record + idb database, backend-agnostic, bounded ownership-lag retry. Documented
|
|
312
|
+
precondition, no liveness probe: on a still-held path it throws the ownership error — loud and safely
|
|
313
|
+
re-runnable (idempotent, phase-recorded; a `deleting`-marked store is refused for boot). Keep failed
|
|
314
|
+
paths on a retry list for the next boot. An idb-only sweep is NOT a substitute — it leaks the OPFS arena.
|
|
315
|
+
- `quiesceStoreWorker(worker, opts?)` (ADR-0050) — the by-path TEARDOWN companion that MAKES a store
|
|
316
|
+
not-running before `destroyStoreArtifacts`. Give it a worker factory of the same shape `attachSyncClient`
|
|
317
|
+
takes (`() => new SharedWorker(url, { name: storePath })`) — but the factory MUST construct the worker with
|
|
318
|
+
**byte-identical options to the LIVE store worker**, `extendedLifetime: true` included. A named SharedWorker
|
|
319
|
+
dedups onto one instance, and Chromium (148+) FAILS a second `new SharedWorker(name, …)` whose options
|
|
320
|
+
disagree with the live one (an `error` event, no `onconnect`) — the teardown port then exchanges zero
|
|
321
|
+
messages and only times out. Omitting `extendedLifetime` on the teardown worker does not shorten its life
|
|
322
|
+
(`closeHost` + `scope.close()` end it); it only breaks the dedup and defeats the primitive. It reaches the
|
|
323
|
+
worker by name, posts the
|
|
324
|
+
declaration, queries placement, and for an SW-direct home (idbfs, real-Safari opfs) sends `engine-teardown`
|
|
325
|
+
and AWAITS the reserved ack (engine stopped, backend connection released → `{ toreDown: true }`); an elected
|
|
326
|
+
home is a no-op (`{ toreDown: false }` — the elected engine dies with its tab). Compose best-effort:
|
|
327
|
+
`await quiesceStoreWorker(f).catch(() => {}); await destroyStoreArtifacts(path)`. A timeout REJECTS (not
|
|
328
|
+
proof of teardown, default 6s) and must not abort the destroy; omit `storage` (no opinion) so a worker on
|
|
329
|
+
an older declaration is never refused; idempotent + safe on an already-dead store.
|
|
330
|
+
|
|
331
|
+
**Storage-preference changes.** A store's storage declaration (backend/durability) is IMMUTABLE — bound at
|
|
332
|
+
first contact, conflicts refused typed (`StorageDeclarationRefusedError`). Never re-home or
|
|
333
|
+
delete-and-recreate a live path (an `extendedLifetime` predecessor may still hold it). The pattern:
|
|
334
|
+
atomically drop bindings + record the old exact paths on an obsolete list FIRST, then write the new
|
|
335
|
+
preference and reload; fresh stores mint under fresh paths, and each boot walks the obsolete list in
|
|
336
|
+
the background (never awaited on sign-in), per path QUIESCING the worker (`quiesceStoreWorker`) BEFORE
|
|
337
|
+
`destroyStoreArtifacts`. The quiesce is what makes idbfs converge: an `extendedLifetime` idbfs
|
|
338
|
+
predecessor holds its IndexedDB connection across the reload, so a bare destroy would block forever
|
|
339
|
+
(opfs releases on idle; idbfs does not) — tearing the host down releases the connection so the first
|
|
340
|
+
retry wins. Dynamic declarations travel as the wire `storage` option on
|
|
341
|
+
`attachSyncClient`/`provisionSyncWorker`; a registry-attached static declaration stays authoritative. Consumer docs:
|
|
342
|
+
<https://pgxsinkit.github.io/concepts/local-store-lifecycle/>.
|
|
304
343
|
|
|
305
344
|
## Proxying Electric: force `cache-control: no-store`
|
|
306
345
|
|