@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.
@@ -148,8 +148,8 @@ export type EngineControlMessage =
148
148
  type: "control-ack";
149
149
  identity: EngineIdentity;
150
150
  pingId: number;
151
- /** Present only when the reserved teardown acknowledgement reports that host close failed. */
152
- error?: { message: string; detail?: unknown };
151
+ /** 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). */
152
+ error?: { message: string; name?: string; detail?: unknown };
153
153
  }
154
154
  /**
155
155
  * tab → SharedWorker: an execution-limit report — a dispatch has been outstanding `elapsedMs` past the
@@ -8,7 +8,7 @@
8
8
  // never a real `Worker`/`SharedWorker` directly — which is exactly why the whole bridge is unit-testable
9
9
  // over bun's `MessageChannel` with no worker at all.
10
10
 
11
- import type { SyncRuntimeStatus } from "@pgxsinkit/contracts";
11
+ import type { SyncRuntimeStatus, SyncStorageDeclaration } from "@pgxsinkit/contracts";
12
12
 
13
13
  import type { BootReport } from "../boot-report";
14
14
  import type { ExportReport } from "../export-store";
@@ -77,6 +77,19 @@ export type BridgeMessageType =
77
77
 
78
78
  // ─── Payload shapes ───────────────────────────────────────────────────────────
79
79
 
80
+ /**
81
+ * The bridge's serialized-error wire shape. `message` always; `name` when the source error carried a
82
+ * non-default one, so a TYPED failure (e.g. a restore refused with `RestoreTargetExistsError`) stays
83
+ * type-detectable after the tab rebuilds it — a consumer must never be forced into message matching;
84
+ * `detail` for structured payloads (execution-limit mismatch, engine-relocated, …) that rebuild as their
85
+ * typed error class tab-side.
86
+ */
87
+ export interface BridgeErrorWire {
88
+ message: string;
89
+ name?: string;
90
+ detail?: unknown;
91
+ }
92
+
80
93
  /** A single auth token snapshot the tab owns and pushes to the worker (ADR-0032 decision 3). */
81
94
  export interface AuthTokenSnapshot {
82
95
  accessToken: string;
@@ -107,6 +120,13 @@ export interface ProvisionPayload {
107
120
  * lane (via the attaching helper); a browser worker never sends it.
108
121
  */
109
122
  testStoreBackend?: "memory";
123
+ /**
124
+ * The tab's WIRE storage declaration (ADR-0050) — the same declaration the pre-placement declaration
125
+ * message carried, repeated here so the ENGINE binds it (the mint's durability) wherever it runs. The
126
+ * first provision/attach binds the store's declaration; a later payload whose explicit field disagrees
127
+ * with the bound resolution is refused typed (`StorageDeclarationRefusedError`).
128
+ */
129
+ storage?: SyncStorageDeclaration;
110
130
  }
111
131
 
112
132
  /** worker → tab: the provision completed (or failed). Lets the login screen confirm the spare is warm. */
@@ -159,6 +179,13 @@ export interface AttachPayload {
159
179
  * this AFTER the engine has already booted is REFUSED (you cannot restore into a running store).
160
180
  */
161
181
  restore?: RestoreArtefactWire;
182
+ /**
183
+ * The tab's WIRE storage declaration (ADR-0050) — repeated from the pre-placement declaration message so
184
+ * the ENGINE binds it (durability included) wherever it runs, the elected dedicated engine included (whose
185
+ * scope never saw the SharedWorker's declaration message). First payload binds; a later explicit
186
+ * disagreement with the bound resolution is refused typed (`StorageDeclarationRefusedError`).
187
+ */
188
+ storage?: SyncStorageDeclaration;
162
189
  /** The tab's current auth token at attach time, or null when unauthenticated. */
163
190
  token: AuthTokenSnapshot | null;
164
191
  /**
@@ -216,15 +243,15 @@ export interface AttachAckPayload {
216
243
  * itself still RESOLVES (the engine reached `localReadReady`; only the tail failed). A live milestone
217
244
  * failure after attach rides the `milestone-error` broadcast instead.
218
245
  */
219
- writeReadyError?: { message: string; detail?: unknown };
220
- bootSettledError?: { message: string; detail?: unknown };
246
+ writeReadyError?: BridgeErrorWire;
247
+ bootSettledError?: BridgeErrorWire;
221
248
  /**
222
249
  * Present when the engine boot REJECTED for this attach: the tab rejects `attachSyncClient` with this
223
250
  * message instead of hanging forever on the ack (ADR-0032 FIX 1). A later attach retries the boot. This
224
251
  * is a LOCAL-READ-CORE failure (the engine never reached `localReadReady`); a tail failure after
225
252
  * `localReadReady` uses the stage-error fields above and does NOT reject the attach.
226
253
  */
227
- error?: { message: string; detail?: unknown };
254
+ error?: BridgeErrorWire;
228
255
  }
229
256
 
230
257
  /** worker → tab: a broadcast pull-request — any attached tab may answer, first response wins (ADR-0032 decision 3). */
@@ -336,7 +363,7 @@ export interface RpcResultPayload {
336
363
  /** The resolved value (present when `ok`). */
337
364
  value?: unknown;
338
365
  /** The rejection message + optional structured detail (present when `!ok`). */
339
- error?: { message: string; detail?: unknown };
366
+ error?: BridgeErrorWire;
340
367
  }
341
368
 
342
369
  /** tab → worker: register a live query. `id` correlates the initial snapshot; `queryId` keys subsequent diffs. */
@@ -429,7 +456,7 @@ export type BridgeEvent =
429
456
  // The mirror failure edge: the background write/sync tail REJECTED a downstream stage (ADR-0041). Rejects
430
457
  // the tab's matching `writeReady` / `bootSettled` promise so an awaiter fails loudly rather than hanging;
431
458
  // `localReadReady` (and the resolved attach) are unaffected — the engine reached local-read readiness.
432
- | { kind: "milestone-error"; stage: BootMilestone; error: { message: string; detail?: unknown } }
459
+ | { kind: "milestone-error"; stage: BootMilestone; error: BridgeErrorWire }
433
460
  | { kind: "conflict"; details: unknown }
434
461
  | { kind: "quarantine"; details: unknown }
435
462
  | { kind: "reject"; details: unknown }