@pgxsinkit/client 0.1.49 → 0.1.50
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/boot-report.d.ts +76 -0
- package/dist/boot-report.d.ts.map +1 -1
- package/dist/index.d.ts +56 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1036 -286
- package/dist/index.js.map +13 -12
- package/dist/local-store.d.ts +58 -0
- package/dist/local-store.d.ts.map +1 -1
- package/dist/local-tables.d.ts +340 -0
- package/dist/local-tables.d.ts.map +1 -1
- package/dist/mutation.d.ts +36 -0
- package/dist/mutation.d.ts.map +1 -1
- package/dist/mutations-api.d.ts +82 -0
- package/dist/mutations-api.d.ts.map +1 -0
- package/dist/schema.d.ts +62 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/worker/attach-sync-client.d.ts.map +1 -1
- package/dist/worker/define-sync-worker.d.ts.map +1 -1
- package/dist/worker/protocol.d.ts +44 -1
- package/dist/worker/protocol.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/core/SKILL.md +1 -1
- package/skills/operating/SKILL.md +1 -1
- package/src/boot-report.ts +108 -0
- package/src/index.ts +555 -136
- package/src/local-store.ts +150 -3
- package/src/local-tables.ts +49 -1
- package/src/mutation.ts +256 -15
- package/src/mutations-api.ts +310 -0
- package/src/schema.ts +406 -193
- package/src/worker/attach-sync-client.ts +114 -5
- package/src/worker/define-sync-worker.ts +65 -4
- package/src/worker/protocol.ts +38 -1
package/dist/schema.d.ts
CHANGED
|
@@ -7,7 +7,69 @@ import { type SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const LOCAL_META_TABLE = "pgxsinkit_local_meta";
|
|
9
9
|
export declare const REGISTRY_FINGERPRINT_KEY = "registry_fingerprint";
|
|
10
|
+
/**
|
|
11
|
+
* The `pgxsinkit_local_meta` key holding the DURABLE-schema fingerprint the local store was last
|
|
12
|
+
* provisioned under (warm-persisted-store-startup slice 3 / proposal §3). Its value is
|
|
13
|
+
* `lsf1:<hash(durable SQL)>` (see {@link computeLocalSchemaFingerprint}); a boot compares it against the
|
|
14
|
+
* freshly-generated durable SQL's hash to SKIP the durable replay when they match.
|
|
15
|
+
*/
|
|
16
|
+
export declare const LOCAL_SCHEMA_FINGERPRINT_KEY = "local_schema_fingerprint";
|
|
17
|
+
/** The versioned value prefix for {@link LOCAL_SCHEMA_FINGERPRINT_KEY} (bump only if the encoding changes). */
|
|
18
|
+
export declare const LOCAL_SCHEMA_FINGERPRINT_PREFIX = "lsf1:";
|
|
19
|
+
/**
|
|
20
|
+
* The registry-wide cross-journal mutation view (warm-persisted-store-startup slice 4 / proposal §5,
|
|
21
|
+
* option 1). A `TEMP` view UNION-ALL-ing every writable table's journal down to the shared fixed columns
|
|
22
|
+
* (plus a `table_key` literal per branch), so a consumer can render one global mutation summary/detail
|
|
23
|
+
* subscription instead of one live query per writable journal. It MUST be `TEMP`: an ephemeral entry's
|
|
24
|
+
* journal is a `pg_temp` relation (ADR-0021 §3), which a durable view cannot reference — and it is
|
|
25
|
+
* recreated on every engine boot (a TEMP view dies with the old engine), so it lives in the always-applied
|
|
26
|
+
* ephemeral schema portion, NOT the durable (fingerprint-gated) portion. See {@link getAllMutationsView}
|
|
27
|
+
* for the query-authoring Drizzle object over it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ALL_MUTATIONS_VIEW = "pgxsinkit_all_mutations";
|
|
30
|
+
/**
|
|
31
|
+
* The shared fixed journal columns the {@link ALL_MUTATIONS_VIEW} branches project (in journal-DDL order),
|
|
32
|
+
* mirroring `buildJournalFixedColumns` (local-tables.ts) MINUS `payload_json` (detail rows stay
|
|
33
|
+
* payload-free by default — entity identity comes from `entity_key_json`) and the per-table PRIMARY KEY
|
|
34
|
+
* columns (they differ per branch, so they cannot appear in a UNION ALL). `mutation_seq` is retained: it is
|
|
35
|
+
* a shared fixed column and {@link import("./mutation").MutationDetail} carries it — but it is per-journal,
|
|
36
|
+
* NOT globally ordered, so the detail API orders by `enqueued_at_us`, never this.
|
|
37
|
+
*/
|
|
38
|
+
export declare const ALL_MUTATIONS_JOURNAL_COLUMNS: readonly ["mutation_id", "entity_key_json", "mutation_seq", "mutation_kind", "status", "registry_version", "base_server_version", "write_unit", "write_mode", "attempt_count", "last_error", "last_http_status", "conflict_reason", "server_updated_at_us", "enqueued_at_us", "next_retry_at_us", "sent_at_us", "acked_at_us", "updated_at_us"];
|
|
39
|
+
/**
|
|
40
|
+
* The minimal durable bootstrap (schema + meta table) as an executable script (slice 3). Run as the first,
|
|
41
|
+
* tiny crossing on every client-owned boot so the `local_schema_fingerprint` read/write has its table before
|
|
42
|
+
* the fingerprint fast path decides whether to replay the rest of the durable schema. Depends on the
|
|
43
|
+
* registry only for its local schema name, so it is a function rather than a bare constant.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildLocalMetaBootstrapSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
46
|
+
/** The DURABLE local schema as an executable script (slice 3) — the fingerprint's basis. See {@link durableSchemaStatements}. */
|
|
47
|
+
export declare function generateDurableLocalSchemaSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
48
|
+
/**
|
|
49
|
+
* The EPHEMERAL (always-applied) local schema as an executable script (slice 3), or `""` when the registry
|
|
50
|
+
* has no ephemeral entry (so the boot skips the crossing). See {@link ephemeralSchemaStatements}.
|
|
51
|
+
*/
|
|
52
|
+
export declare function generateEphemeralLocalSchemaSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
53
|
+
/**
|
|
54
|
+
* The complete local schema — durable statements then ephemeral statements — the single script the
|
|
55
|
+
* wipe/rebuild paths and every external caller keep using. For an all-persistent registry the durable stream
|
|
56
|
+
* IS the historical stream in registry order, now followed by the always-applied ephemeral portion — which
|
|
57
|
+
* for any registry with a writable table carries the `pgxsinkit_all_mutations` TEMP VIEW (slice 4), so the
|
|
58
|
+
* full script is no longer byte-identical to the pre-slice-4 output (it gains the trailing view). For a MIXED
|
|
59
|
+
* registry it is also idempotent-equivalent, NOT byte-identical to a single-pass interleave: the persistent
|
|
60
|
+
* clusters precede the ephemeral ones and the ephemeral portion re-emits idempotent enum guards — a
|
|
61
|
+
* reordering of independent `IF NOT EXISTS` DDL that executes to the same schema. Equals `durable + ephemeral`
|
|
62
|
+
* by construction (test-covered).
|
|
63
|
+
*/
|
|
10
64
|
export declare function generateLocalSchemaSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
65
|
+
/**
|
|
66
|
+
* The durable-schema fingerprint value (slice 3 / proposal §3): `lsf1:<FNV-1a hash of the durable SQL>`. The
|
|
67
|
+
* hash is over the generated durable DDL body itself (no composed inputs, no hand-maintained format-version
|
|
68
|
+
* constant), so it auto-invalidates on ANY generator change, registry change, or projection rename — the
|
|
69
|
+
* ADR-0018 apply-function-fingerprint precedent applied to the local schema. Stamped into
|
|
70
|
+
* {@link LOCAL_SCHEMA_FINGERPRINT_KEY} only after a successful durable exec.
|
|
71
|
+
*/
|
|
72
|
+
export declare function computeLocalSchemaFingerprint<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
|
|
11
73
|
/**
|
|
12
74
|
* Render `CREATE TABLE IF NOT EXISTS` (plus a `CREATE INDEX IF NOT EXISTS` per declared index) for a
|
|
13
75
|
* Drizzle `pgTable` / `pgSchema.table`, through the SAME column/PK/type machinery
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAErF,OAAO,EAWL,KAAK,iBAAiB,EACvB,MA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chE;AAmLD;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,EAAE,CAapH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAgB/G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAyB7G;AAgHD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAkBtG;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,SAAS,iBAAiB,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CA8BvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,SAAS,iBAAiB,EACrE,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,MAAM,GACf,MAAM,CAkCR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attach-sync-client.d.ts","sourceRoot":"","sources":["../../src/worker/attach-sync-client.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,iBAAiB,EAEjB,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,OAAO,
|
|
1
|
+
{"version":3,"file":"attach-sync-client.d.ts","sourceRoot":"","sources":["../../src/worker/attach-sync-client.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAEV,iBAAiB,EAEjB,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD,OAAO,EAOL,KAAK,cAAc,EAE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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-sync-worker.d.ts","sourceRoot":"","sources":["../../src/worker/define-sync-worker.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAoC,iBAAiB,EAAa,MAAM,sBAAsB,CAAC;AAI3G,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,uBAAuB,EAO5B,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAUlB,OAAO,
|
|
1
|
+
{"version":3,"file":"define-sync-worker.d.ts","sourceRoot":"","sources":["../../src/worker/define-sync-worker.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAoC,iBAAiB,EAAa,MAAM,sBAAsB,CAAC;AAI3G,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,uBAAuB,EAO5B,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAUlB,OAAO,EAGL,KAAK,WAAW,EAGhB,KAAK,UAAU,EAWhB,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,uBAAuB,CAAC,SAAS,SAAS,iBAAiB;IAC1E;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,SAAS,GAAG,SAAS,CAAC;IACtE;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACxF,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,+GAA+G;IAC/G,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,wGAAwG;IACxG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CA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
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* The two background boot stages the worker announces over the bridge as one-shot milestones (ADR-0041
|
|
149
|
+
* stage 2). `localReadReady` is NOT in this set: under the Option B contract the `attach-ack` fires AT the
|
|
150
|
+
* engine's `localReadReady`, so a tab resolves that stage from the ack itself (early OR late attach) — it
|
|
151
|
+
* needs no separate milestone. `writeReady` and `bootSettled` cross in the background write/sync tail, after
|
|
152
|
+
* the ack, so they DO ride milestone messages (and the late-attach ack fold).
|
|
153
|
+
*/
|
|
154
|
+
export type BootMilestone = "writeReady" | "bootSettled";
|
|
147
155
|
/** worker → tab: attach acknowledged. `alreadyBooted` is false for the attach that booted the engine. */
|
|
148
156
|
export interface AttachAckPayload {
|
|
149
157
|
alreadyBooted: boolean;
|
|
@@ -154,9 +162,34 @@ export interface AttachAckPayload {
|
|
|
154
162
|
* the ack, rather than wait for a phase-"ready" status that may never come again.
|
|
155
163
|
*/
|
|
156
164
|
engineReady?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Late-attach milestone fold (ADR-0041 stage 2): true when the engine had ALREADY crossed `writeReady` /
|
|
167
|
+
* `bootSettled` by the time this attach was acked, so a tab attaching after the stage fired resolves it
|
|
168
|
+
* straight from the ack rather than waiting for a `milestone` broadcast it missed. The ack fires AT
|
|
169
|
+
* `localReadReady`, so that stage is always implied by a non-error ack and carries no boolean.
|
|
170
|
+
*/
|
|
171
|
+
writeReady?: boolean;
|
|
172
|
+
bootSettled?: boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Late-attach failure fold (ADR-0041 stage 2): present when the engine's background write/sync tail had
|
|
175
|
+
* already REJECTED a downstream stage before this attach was acked. The tab rejects the matching stage
|
|
176
|
+
* promise (so a gated write / `bootSettled` awaiter fails loudly rather than hangs) — but the attach
|
|
177
|
+
* itself still RESOLVES (the engine reached `localReadReady`; only the tail failed). A live milestone
|
|
178
|
+
* failure after attach rides the `milestone-error` broadcast instead.
|
|
179
|
+
*/
|
|
180
|
+
writeReadyError?: {
|
|
181
|
+
message: string;
|
|
182
|
+
detail?: unknown;
|
|
183
|
+
};
|
|
184
|
+
bootSettledError?: {
|
|
185
|
+
message: string;
|
|
186
|
+
detail?: unknown;
|
|
187
|
+
};
|
|
157
188
|
/**
|
|
158
189
|
* Present when the engine boot REJECTED for this attach: the tab rejects `attachSyncClient` with this
|
|
159
|
-
* message instead of hanging forever on the ack (ADR-0032 FIX 1). A later attach retries the boot.
|
|
190
|
+
* message instead of hanging forever on the ack (ADR-0032 FIX 1). A later attach retries the boot. This
|
|
191
|
+
* is a LOCAL-READ-CORE failure (the engine never reached `localReadReady`); a tail failure after
|
|
192
|
+
* `localReadReady` uses the stage-error fields above and does NOT reject the attach.
|
|
160
193
|
*/
|
|
161
194
|
error?: {
|
|
162
195
|
message: string;
|
|
@@ -300,6 +333,16 @@ export type BridgeEvent = {
|
|
|
300
333
|
} | {
|
|
301
334
|
kind: "groupReady";
|
|
302
335
|
groupKey: string;
|
|
336
|
+
} | {
|
|
337
|
+
kind: "milestone";
|
|
338
|
+
stage: BootMilestone;
|
|
339
|
+
} | {
|
|
340
|
+
kind: "milestone-error";
|
|
341
|
+
stage: BootMilestone;
|
|
342
|
+
error: {
|
|
343
|
+
message: string;
|
|
344
|
+
detail?: unknown;
|
|
345
|
+
};
|
|
303
346
|
} | {
|
|
304
347
|
kind: "conflict";
|
|
305
348
|
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;AAE9D,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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CAAC;IAAC,QAAQ,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAU/D;AAED,mHAAmH;AACnH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,cAAc,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgxsinkit/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"tanstack-intent"
|
|
6
6
|
],
|
|
@@ -36,7 +36,7 @@
|
|
|
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.1.50"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@electric-sql/pglite": "0.5.4",
|
package/skills/core/SKILL.md
CHANGED
package/src/boot-report.ts
CHANGED
|
@@ -24,6 +24,14 @@ export interface BootReport {
|
|
|
24
24
|
mode: "in-process" | "worker";
|
|
25
25
|
/** Whether the caller proved the store a schemaless spare (the ADR-0032 S4 fresh-store hint). */
|
|
26
26
|
freshStore: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* How this store presented at boot: `"restored"` when the boot seeded a brand-new store from a backup
|
|
29
|
+
* (ADR-0035 `restoreFrom`); `"fresh"` when the caller proved it a schemaless spare (the SAME signal as
|
|
30
|
+
* {@link BootReport.freshStore}); `"warm"` otherwise (an existing persisted store — the common case).
|
|
31
|
+
* Distinct from `freshStore`, which stays a bare boolean: `storeKind` additionally names the restore case,
|
|
32
|
+
* which a boolean cannot express.
|
|
33
|
+
*/
|
|
34
|
+
storeKind: "fresh" | "warm" | "restored";
|
|
27
35
|
/** Whether the ADR-0032 S4 fetch/schema overlap was active for this boot. */
|
|
28
36
|
overlapPrefetch: boolean;
|
|
29
37
|
/** The registry fingerprint the store is provisioned under — the same value store-version reconcile stamps. */
|
|
@@ -32,6 +40,18 @@ export interface BootReport {
|
|
|
32
40
|
startedAt: number;
|
|
33
41
|
/** Boot start → `onInitialSync` (all eager groups caught up). */
|
|
34
42
|
totalMs: number;
|
|
43
|
+
/**
|
|
44
|
+
* Boot start → `localReadReady` resolved (ADR-0041): PGlite open, durable schema compatible, store-version
|
|
45
|
+
* reconcile complete, and the drizzle read facade built — cached reads are safe with ZERO network. `null`
|
|
46
|
+
* when the boot rejected before the stage. Additive field; `reportVersion` stays `1`.
|
|
47
|
+
*/
|
|
48
|
+
localReadReadyMs: number | null;
|
|
49
|
+
/**
|
|
50
|
+
* Boot start → `writeReady` resolved (ADR-0041): the mutation runtime is constructed and boot recovery
|
|
51
|
+
* (plus restore quarantine on a restore boot) has completed — enqueue is safe. `null` when the boot
|
|
52
|
+
* rejected before the stage. Additive field; `reportVersion` stays `1`.
|
|
53
|
+
*/
|
|
54
|
+
writeReadyMs: number | null;
|
|
35
55
|
/**
|
|
36
56
|
* Present only when the store was pre-provisioned (a spare's initdb ran off-thread before this boot
|
|
37
57
|
* adopted it); `null` otherwise. When present, `phases.pgliteCreateMs` is `null` — the create cost is
|
|
@@ -64,6 +84,31 @@ export interface BootReport {
|
|
|
64
84
|
*/
|
|
65
85
|
prepareMs?: number;
|
|
66
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Warm-persisted-store-startup observability (the schema-replay + journal-recovery fast-path lane). Every
|
|
89
|
+
* field carries the honest CURRENT truth so the report never lies mid-lane: the durable-schema-fingerprint
|
|
90
|
+
* slice sets the `schema*` flags and the recovery-marker slice the `journal*` flags as those optimizations
|
|
91
|
+
* land. Grouped like {@link BootReport.phases} so the flags structured-clone across the worker bridge as one
|
|
92
|
+
* unit.
|
|
93
|
+
*/
|
|
94
|
+
warmBoot: {
|
|
95
|
+
/** Whether durable-schema replay was skipped this boot (a fingerprint match). `false` today — replay is unconditional. */
|
|
96
|
+
schemaSkipped: boolean;
|
|
97
|
+
/** Whether the stored durable-schema fingerprint matched the generated schema. `false` today — not yet computed. */
|
|
98
|
+
schemaFingerprintMatch: boolean;
|
|
99
|
+
/** Whether the boot-time `recoverSending` journal pass was skipped this boot. `false` today — the pass is unconditional. */
|
|
100
|
+
journalRecoverySkipped: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Whether journal recovery was required this boot. `true` today under pre-marker legacy semantics: with no
|
|
103
|
+
* durable recovery marker, recovery is ALWAYS treated as required. The recovery-marker slice will set this
|
|
104
|
+
* from the durable marker instead (a clean shutdown clears the marker → `false`, skipping recovery).
|
|
105
|
+
*/
|
|
106
|
+
journalRecoveryRequired: boolean;
|
|
107
|
+
/** How many writable table journals the boot-time `recoverSending` pass visited (the registry's writable-entry count). */
|
|
108
|
+
journalTablesVisited: number;
|
|
109
|
+
/** Rows lifted `sending → pending` by recovery. `null` = not yet instrumented; populated by the recovery-marker slice. */
|
|
110
|
+
journalRowsRecovered: number | null;
|
|
111
|
+
};
|
|
67
112
|
/**
|
|
68
113
|
* Per consistency GROUP, for the eager + promoted boot groups only (a lazily-activated-later group never
|
|
69
114
|
* appears — nor mutates a finalized report). Groups run concurrently, so `fetchMs`/`applyMs` are per-group
|
|
@@ -190,6 +235,33 @@ export interface BootReportBuilder extends BootStampCollector {
|
|
|
190
235
|
) => Promise<T>;
|
|
191
236
|
setPgliteCreateMs: (ms: number | null) => void;
|
|
192
237
|
setProvision: (provision: BootReport["provision"]) => void;
|
|
238
|
+
/**
|
|
239
|
+
* Record the durable-schema fast-path outcome (the durable-schema-fingerprint slice): whether replay was
|
|
240
|
+
* skipped and whether the stored fingerprint matched. Both default to the current truth (`false`), so this
|
|
241
|
+
* need not be called until that slice lands.
|
|
242
|
+
*/
|
|
243
|
+
setSchemaFastPath: (info: { skipped: boolean; fingerprintMatch: boolean }) => void;
|
|
244
|
+
/**
|
|
245
|
+
* Record the boot-time journal-recovery outcome (the recovery-marker slice): whether the pass was skipped,
|
|
246
|
+
* whether it was required, how many writable journals it visited, and how many rows it lifted (`null` until
|
|
247
|
+
* instrumented). `tablesVisited` is wired from boot today; the rest default to current-truth values.
|
|
248
|
+
*/
|
|
249
|
+
setJournalRecovery: (info: {
|
|
250
|
+
skipped: boolean;
|
|
251
|
+
required: boolean;
|
|
252
|
+
tablesVisited: number;
|
|
253
|
+
rowsRecovered: number | null;
|
|
254
|
+
}) => void;
|
|
255
|
+
/**
|
|
256
|
+
* Stamp `localReadReadyMs` at the moment the staged local-read core resolves `localReadReady` (ADR-0041).
|
|
257
|
+
* Idempotent — the first stamp wins.
|
|
258
|
+
*/
|
|
259
|
+
setLocalReadReadyMs: (ms: number) => void;
|
|
260
|
+
/**
|
|
261
|
+
* Stamp `writeReadyMs` at the moment the write/recovery tail resolves `writeReady` (ADR-0041). Idempotent —
|
|
262
|
+
* the first stamp wins.
|
|
263
|
+
*/
|
|
264
|
+
setWriteReadyMs: (ms: number) => void;
|
|
193
265
|
/**
|
|
194
266
|
* Record `phases.syncStartMs` directly — for the ADR-0032 S4 overlap path, where sync construction is
|
|
195
267
|
* kicked off before schema exec (not wrapped in {@link BootReportBuilder.phase}) and has no rail line.
|
|
@@ -207,6 +279,7 @@ export interface BootReportBuilder extends BootStampCollector {
|
|
|
207
279
|
export interface BootReportInit {
|
|
208
280
|
mode: BootReport["mode"];
|
|
209
281
|
freshStore: boolean;
|
|
282
|
+
storeKind: BootReport["storeKind"];
|
|
210
283
|
overlapPrefetch: boolean;
|
|
211
284
|
registryFingerprint: string;
|
|
212
285
|
}
|
|
@@ -218,7 +291,20 @@ export function createBootReportBuilder(init: BootReportInit): BootReportBuilder
|
|
|
218
291
|
let prepareMs: number | null = null;
|
|
219
292
|
let pgliteCreateMs: number | null = null;
|
|
220
293
|
let provision: BootReport["provision"] = null;
|
|
294
|
+
// Current-truth defaults (this slice's honest baseline): durable schema replay + journal recovery are both
|
|
295
|
+
// unconditional today, and recovery is always treated as required pre-marker. Later slices flip these via
|
|
296
|
+
// the setters below.
|
|
297
|
+
let warmBoot: BootReport["warmBoot"] = {
|
|
298
|
+
schemaSkipped: false,
|
|
299
|
+
schemaFingerprintMatch: false,
|
|
300
|
+
journalRecoverySkipped: false,
|
|
301
|
+
journalRecoveryRequired: true,
|
|
302
|
+
journalTablesVisited: 0,
|
|
303
|
+
journalRowsRecovered: null,
|
|
304
|
+
};
|
|
221
305
|
let syncStartDoneOffset: number | null = null;
|
|
306
|
+
let localReadReadyMs: number | null = null;
|
|
307
|
+
let writeReadyMs: number | null = null;
|
|
222
308
|
const groups: GroupAccumulator[] = [];
|
|
223
309
|
let built: BootReport | null = null;
|
|
224
310
|
|
|
@@ -245,6 +331,24 @@ export function createBootReportBuilder(init: BootReportInit): BootReportBuilder
|
|
|
245
331
|
setProvision: (value) => {
|
|
246
332
|
provision = value;
|
|
247
333
|
},
|
|
334
|
+
setSchemaFastPath: (info) => {
|
|
335
|
+
warmBoot = { ...warmBoot, schemaSkipped: info.skipped, schemaFingerprintMatch: info.fingerprintMatch };
|
|
336
|
+
},
|
|
337
|
+
setJournalRecovery: (info) => {
|
|
338
|
+
warmBoot = {
|
|
339
|
+
...warmBoot,
|
|
340
|
+
journalRecoverySkipped: info.skipped,
|
|
341
|
+
journalRecoveryRequired: info.required,
|
|
342
|
+
journalTablesVisited: info.tablesVisited,
|
|
343
|
+
journalRowsRecovered: info.rowsRecovered,
|
|
344
|
+
};
|
|
345
|
+
},
|
|
346
|
+
setLocalReadReadyMs: (ms) => {
|
|
347
|
+
if (localReadReadyMs == null) localReadReadyMs = ms;
|
|
348
|
+
},
|
|
349
|
+
setWriteReadyMs: (ms) => {
|
|
350
|
+
if (writeReadyMs == null) writeReadyMs = ms;
|
|
351
|
+
},
|
|
248
352
|
setSyncStartMs: (ms) => {
|
|
249
353
|
durations.set("syncStart", ms);
|
|
250
354
|
},
|
|
@@ -264,11 +368,15 @@ export function createBootReportBuilder(init: BootReportInit): BootReportBuilder
|
|
|
264
368
|
reportVersion: 1,
|
|
265
369
|
mode: init.mode,
|
|
266
370
|
freshStore: init.freshStore,
|
|
371
|
+
storeKind: init.storeKind,
|
|
267
372
|
overlapPrefetch: init.overlapPrefetch,
|
|
268
373
|
registryFingerprint: init.registryFingerprint,
|
|
269
374
|
startedAt,
|
|
270
375
|
totalMs,
|
|
376
|
+
localReadReadyMs,
|
|
377
|
+
writeReadyMs,
|
|
271
378
|
provision,
|
|
379
|
+
warmBoot,
|
|
272
380
|
phases: {
|
|
273
381
|
pgliteCreateMs,
|
|
274
382
|
schemaExecMs: duration("schemaExec"),
|