@pgxsinkit/client 0.1.51 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +22 -0
  2. package/dist/adoption.d.ts +118 -0
  3. package/dist/adoption.d.ts.map +1 -0
  4. package/dist/boot-report.d.ts +54 -15
  5. package/dist/boot-report.d.ts.map +1 -1
  6. package/dist/convergence.d.ts +2 -1
  7. package/dist/convergence.d.ts.map +1 -1
  8. package/dist/error-chain.d.ts +9 -0
  9. package/dist/error-chain.d.ts.map +1 -0
  10. package/dist/export-dump.d.ts.map +1 -1
  11. package/dist/export-store.d.ts +1 -1
  12. package/dist/export-store.d.ts.map +1 -1
  13. package/dist/index.d.ts +309 -38
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +4628 -1489
  16. package/dist/index.js.map +36 -24
  17. package/dist/live-rows-sql.d.ts +1 -1
  18. package/dist/local-store.d.ts +16 -31
  19. package/dist/local-store.d.ts.map +1 -1
  20. package/dist/local-tables.d.ts +10 -4
  21. package/dist/local-tables.d.ts.map +1 -1
  22. package/dist/mutation.d.ts +12 -15
  23. package/dist/mutation.d.ts.map +1 -1
  24. package/dist/opfs-effects.d.ts +51 -0
  25. package/dist/opfs-effects.d.ts.map +1 -0
  26. package/dist/placement-probe.d.ts +75 -0
  27. package/dist/placement-probe.d.ts.map +1 -0
  28. package/dist/schema.d.ts +11 -16
  29. package/dist/schema.d.ts.map +1 -1
  30. package/dist/store-boot.d.ts +77 -0
  31. package/dist/store-boot.d.ts.map +1 -0
  32. package/dist/store-lifecycle.d.ts +153 -0
  33. package/dist/store-lifecycle.d.ts.map +1 -0
  34. package/dist/store-meta.d.ts +190 -0
  35. package/dist/store-meta.d.ts.map +1 -0
  36. package/dist/store-path.d.ts +77 -7
  37. package/dist/store-path.d.ts.map +1 -1
  38. package/dist/sync/apply.d.ts +12 -1
  39. package/dist/sync/apply.d.ts.map +1 -1
  40. package/dist/sync/index.d.ts.map +1 -1
  41. package/dist/sync/shape-inbox.d.ts +1 -1
  42. package/dist/sync/types.d.ts +3 -3
  43. package/dist/testing.js.map +3 -3
  44. package/dist/worker/attach-sync-client.d.ts +239 -13
  45. package/dist/worker/attach-sync-client.d.ts.map +1 -1
  46. package/dist/worker/define-sync-worker.d.ts +162 -5
  47. package/dist/worker/define-sync-worker.d.ts.map +1 -1
  48. package/dist/worker/election-coordinator.d.ts +95 -0
  49. package/dist/worker/election-coordinator.d.ts.map +1 -0
  50. package/dist/worker/engine-control.d.ts +265 -0
  51. package/dist/worker/engine-control.d.ts.map +1 -0
  52. package/dist/worker/engine-router.d.ts +75 -0
  53. package/dist/worker/engine-router.d.ts.map +1 -0
  54. package/dist/worker/live-query-manager.d.ts.map +1 -1
  55. package/dist/worker/live-query-params-guard.d.ts +14 -0
  56. package/dist/worker/live-query-params-guard.d.ts.map +1 -0
  57. package/dist/worker/protocol.d.ts +32 -11
  58. package/dist/worker/protocol.d.ts.map +1 -1
  59. package/dist/worker/sw-placement.d.ts +37 -0
  60. package/dist/worker/sw-placement.d.ts.map +1 -0
  61. package/package.json +4 -3
  62. package/skills/core/SKILL.md +15 -8
  63. package/skills/operating/SKILL.md +114 -34
  64. package/src/adoption.ts +275 -0
  65. package/src/boot-report.ts +70 -17
  66. package/src/convergence.ts +2 -1
  67. package/src/error-chain.ts +26 -0
  68. package/src/export-dump.ts +5 -1
  69. package/src/export-store.ts +1 -1
  70. package/src/index.ts +1246 -118
  71. package/src/live-rows-sql.ts +1 -1
  72. package/src/local-store.ts +18 -40
  73. package/src/local-tables.ts +9 -2
  74. package/src/mutation.ts +67 -49
  75. package/src/mutations-api.ts +3 -3
  76. package/src/opfs-effects.ts +160 -0
  77. package/src/placement-probe.ts +168 -0
  78. package/src/schema.ts +17 -22
  79. package/src/store-boot.ts +343 -0
  80. package/src/store-lifecycle.ts +227 -0
  81. package/src/store-meta.ts +459 -0
  82. package/src/store-path.ts +197 -22
  83. package/src/sync/apply.ts +227 -89
  84. package/src/sync/index.ts +33 -9
  85. package/src/sync/shape-inbox.ts +1 -1
  86. package/src/sync/types.ts +3 -3
  87. package/src/testing.ts +2 -2
  88. package/src/worker/attach-sync-client.ts +1675 -117
  89. package/src/worker/define-sync-worker.ts +810 -50
  90. package/src/worker/election-coordinator.ts +462 -0
  91. package/src/worker/engine-control.ts +379 -0
  92. package/src/worker/engine-router.ts +355 -0
  93. package/src/worker/live-query-manager.ts +10 -1
  94. package/src/worker/live-query-params-guard.ts +57 -0
  95. package/src/worker/protocol.ts +41 -10
  96. package/src/worker/sw-placement.ts +64 -0
@@ -13,7 +13,7 @@
13
13
  * keep DISTINCT values). `SELECT *` from the aliased derived table is safe precisely because the alias
14
14
  * list has already made the names unique.
15
15
  *
16
- * Returns the SQL UNCHANGED when `fields` is absent or empty — the backward-compatible path for existing
16
+ * Returns the SQL UNCHANGED when `fields` is absent or empty — the default path for
17
17
  * callers (raw SQL strings, or non-colliding queries that pass no `fields`): they keep name-keyed rows
18
18
  * exactly as before. Only a caller that supplies `fields` opts into alias-keyed rows.
19
19
  */
@@ -1,11 +1,5 @@
1
1
  import { type MutationDiagnostics, type SyncTableRegistry } from "@pgxsinkit/contracts";
2
2
  import type { MutationDb } from "./mutation";
3
- /**
4
- * The fingerprint-keyed local store (ADR-0006). The registry fingerprint the local PGlite
5
- * database was provisioned under is recorded in the local-meta table; comparing it to the
6
- * current fingerprint on boot is how a registry change is *detected* (rather than a
7
- * hand-bumped `idb://…-vN` suffix), which drives the drain-then-drop read-cache rebuild.
8
- */
9
3
  /** A boot-time registry-version reconciliation outcome (ADR-0006 drain-then-drop). */
10
4
  export interface LocalStoreVersionEvent {
11
5
  status: "rebuilt" | "deferred";
@@ -14,12 +8,12 @@ export interface LocalStoreVersionEvent {
14
8
  /** Mutations still owed to the server (pending + sending + failed + quarantined). */
15
9
  owedMutations: number;
16
10
  }
17
- /** The minimal mutation-runtime surface the version reconciliation needs. */
11
+ /** The mutation-runtime surface required by registry reconciliation. */
18
12
  interface VersionReconcileRuntime {
19
13
  registryVersion: string;
20
14
  readMutationStats: () => Promise<MutationDiagnostics>;
21
15
  }
22
- /** The registry fingerprint the local store was last provisioned under, or null if unstamped. */
16
+ /** The registry fingerprint under which the local store was provisioned, or null if unstamped. */
23
17
  export declare function readStoredRegistryFingerprint(db: MutationDb, registry: SyncTableRegistry): Promise<string | null>;
24
18
  /**
25
19
  * The consistency-group keys of `lazy + persistent` groups that were activated on a previous boot
@@ -32,25 +26,24 @@ export declare function readActivatedLazyGroups(db: MutationDb, registry: SyncTa
32
26
  export declare function writeLazyGroupActivation(db: MutationDb, registry: SyncTableRegistry, groupKey: string): Promise<void>;
33
27
  /** Clear a persisted lazy activation — an explicit `desync` reverts the group to dormant next boot (ADR-0021 §2). */
34
28
  export declare function clearLazyGroupActivation(db: MutationDb, registry: SyncTableRegistry, groupKey: string): Promise<void>;
35
- /** Stamp the local store with the fingerprint it is now provisioned under. */
29
+ /** Stamp the local store with the registry fingerprint it is provisioned under. */
36
30
  export declare function writeStoredRegistryFingerprint(db: MutationDb, registry: SyncTableRegistry, fingerprint: string): Promise<void>;
37
31
  /**
38
- * The durable-schema fingerprint the local store was last provisioned under (slice 3 / proposal §3), or null
39
- * when unstamped (a legacy store, or a store whose durable schema was never executed under this feature).
40
- * Follows the raw-seam read shape of {@link readStoredRegistryFingerprint}.
32
+ * The durable-schema fingerprint the local store was last provisioned under, or null
33
+ * when initial provisioning has not completed.
41
34
  */
42
35
  export declare function readStoredLocalSchemaFingerprint(db: MutationDb, registry: SyncTableRegistry): Promise<string | null>;
43
36
  /**
44
37
  * Stamp the durable-schema fingerprint the store is now provisioned under (slice 3). Called ONLY after a
45
- * successful durable-schema exec — every full durable exec (boot fast-path miss, reconcile rebuild,
38
+ * successful durable-schema exec — every full durable exec (initial provisioning,
46
39
  * `dropReadCache`) and its stamp travel together, so the fingerprint never claims a schema that was not run.
47
40
  */
48
41
  export declare function writeStoredLocalSchemaFingerprint(db: MutationDb, registry: SyncTableRegistry, fingerprint: string): Promise<void>;
49
42
  /**
50
- * The durable recovery-required marker (warm-persisted-store-startup slice 2 / proposal §1). Its
43
+ * The durable recovery-required marker. Its
51
44
  * `pgxsinkit_local_meta` value is `"true"` while a `sending` journal row MAY have been committed since the
52
- * last clean settle, and `"false"` once pgxsinkit has PROVEN no `sending` row remains. Absent = a
53
- * pre-feature (legacy) store: run one conservative legacy recovery pass, then initialize the marker.
45
+ * last clean settle, and `"false"` once pgxsinkit has PROVEN no `sending` row remains. Absent means the
46
+ * store has not initialized the marker yet: run one conservative recovery pass, then initialize it.
54
47
  *
55
48
  * The invariant the whole slice protects: **the marker is never `"false"` while a committed `sending`
56
49
  * journal row exists.** It is upheld by marker-first ordering — {@link writeMutationRecoveryRequired}(true)
@@ -61,8 +54,7 @@ export declare function writeStoredLocalSchemaFingerprint(db: MutationDb, regist
61
54
  export declare const MUTATION_RECOVERY_REQUIRED_KEY = "mutation_recovery_required";
62
55
  /**
63
56
  * Read the durable recovery-required marker: `true`/`false` for the stored value, or `null` when the key is
64
- * absent (a legacy/pre-feature store). Follows the raw-seam read shape of
65
- * {@link readStoredRegistryFingerprint}.
57
+ * absent (the marker has not been initialized).
66
58
  *
67
59
  * FIX 4 (fail closed): the marker is a SAFETY marker — `false` is the ONLY value that skips recovery, so any
68
60
  * present value that is not exactly `"true"` or `"false"` (corruption, a future encoding, stray whitespace, a
@@ -73,11 +65,11 @@ export declare function readMutationRecoveryRequired(db: MutationDb, registry: S
73
65
  /**
74
66
  * Upsert the durable recovery-required marker to `"true"`/`"false"` unconditionally. The `true` write is the
75
67
  * marker-first SET (awaited before the first `sending` transition of a dirty epoch); the `false` write
76
- * initializes an absent (legacy) marker AFTER a legacy recovery pass has guaranteed no `sending` row remains.
68
+ * initializes an absent marker AFTER a conservative recovery pass has guaranteed no `sending` row remains.
77
69
  */
78
70
  export declare function writeMutationRecoveryRequired(db: MutationDb, registry: SyncTableRegistry, required: boolean): Promise<void>;
79
71
  /**
80
- * Self-verifying clear (proposal §1 rule 2): set the marker to `"false"` in ONE guarded, Drizzle-composed
72
+ * Self-verifying clear: set the marker to `"false"` in ONE guarded, Drizzle-composed
81
73
  * statement — but only where NOT EXISTS any `sending` row in ANY writable journal (the EXISTS-union is built
82
74
  * from the registry's journal Drizzle objects via {@link getJournalTable}). Correct regardless of JS
83
75
  * bookkeeping: a concurrent enqueue that committed a `sending` row makes the guard fail, so the marker stays
@@ -86,23 +78,16 @@ export declare function writeMutationRecoveryRequired(db: MutationDb, registry:
86
78
  * row blocked it OR no marker row exists yet. Off the boot path AND at the end of a boot recovery pass.
87
79
  *
88
80
  * The marker row must already exist for this UPDATE to take effect; the absent-store INIT is a distinct
89
- * unconditional {@link writeMutationRecoveryRequired}(false) after the legacy pass (a pure guarded UPDATE
81
+ * unconditional {@link writeMutationRecoveryRequired}(false) after the initialization pass (a pure guarded UPDATE
90
82
  * cannot create the row, and drizzle-rc.4 cannot render a from-less guarded insert-select).
91
83
  */
92
84
  export declare function clearMutationRecoveryMarkerIfSettled(db: MutationDb, registry: SyncTableRegistry): Promise<{
93
85
  cleared: boolean;
94
86
  }>;
95
87
  /**
96
- * Reconcile the local store against the current registry fingerprint (ADR-0006). A fresh
97
- * (unstamped) store is stamped; an unchanged fingerprint is a no-op. On a change, the read
98
- * cache is dropped and rebuilt at the new shape **only when nothing is owed locally** —
99
- * otherwise the rebuild is deferred (and retried on a later boot) so un-flushed/quarantined
100
- * writes are never silently dropped. The drain happens across sessions: pending writes flush
101
- * and reconcile during normal use, and the rebuild completes once the journal is clear.
102
- *
103
- * An unstamped store is always treated as brand-new. There is no pre-fingerprint-store path:
104
- * the fingerprint mechanism shipped before launch, so every store in existence was
105
- * provisioned with it (and a stamped store's journal therefore always has `registry_version`).
88
+ * Reconcile a store created by a supported release against the current registry fingerprint. An unstamped
89
+ * store is stamped; an unchanged fingerprint is a no-op. On a change, the read cache is rebuilt only when
90
+ * no mutations are owed. Otherwise the rebuild is deferred until a later boot, preserving local writes.
106
91
  */
107
92
  export declare function reconcileLocalStoreVersion<TRegistry extends SyncTableRegistry>(args: {
108
93
  db: MutationDb;
@@ -1 +1 @@
1
- {"version":3,"file":"local-store.d.ts","sourceRoot":"","sources":["../src/local-store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAe7C;;;;;GAKG;AAEH,sFAAsF;AACtF,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;IAC/B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,qFAAqF;IACrF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,6EAA6E;AAC7E,UAAU,uBAAuB;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACvD;AAED,iGAAiG;AACjG,wBAAsB,6BAA6B,CACjD,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxB;AAKD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAS/G;AAaD,6GAA6G;AAC7G,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,qHAAqH;AACrH,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAO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CAAC,CAezC"}
@@ -79,13 +79,13 @@ declare const journalShape: PgTableWithColumns<{
79
79
  identity: undefined;
80
80
  generated: undefined;
81
81
  }>;
82
- registryVersion: import("drizzle-orm/pg-core").PgBuildColumn<"_pgxsinkit_journal_shape", import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, {
82
+ registryVersion: import("drizzle-orm/pg-core").PgBuildColumn<"_pgxsinkit_journal_shape", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
83
83
  name: string;
84
84
  tableName: "_pgxsinkit_journal_shape";
85
85
  dataType: "string";
86
86
  data: string;
87
87
  driverParam: string;
88
- notNull: false;
88
+ notNull: true;
89
89
  hasDefault: false;
90
90
  isPrimaryKey: false;
91
91
  isAutoincrement: false;
@@ -683,6 +683,12 @@ export interface ApplyTarget {
683
683
  propertyKeyByName: Record<string, string>;
684
684
  /** Primary-key column NAMES, in order (from the entry, local-projection override honoured). */
685
685
  primaryKey: string[];
686
+ /**
687
+ * CDC insert-apply policy (ADR-0045), from the entry. `"insert"` (default) applies a CDC insert as a
688
+ * plain INSERT so a genuine PK collision surfaces; `"upsert"` applies it idempotently (ON CONFLICT DO
689
+ * UPDATE) because this table legitimately receives locally-derived provisional rows.
690
+ */
691
+ applyMode: "insert" | "upsert";
686
692
  /** Model-derived column types (`deriveSyncColumnTypes`), keyed by DB column name via `.name`. */
687
693
  columnTypes: SyncColumnType[];
688
694
  /**
@@ -792,13 +798,13 @@ declare const allMutationsShape: PgViewWithSelection<"pgxsinkit_all_mutations",
792
798
  identity: undefined;
793
799
  generated: undefined;
794
800
  }>;
795
- registryVersion: import("drizzle-orm/pg-core").PgBuildColumn<"pgxsinkit_all_mutations", import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, {
801
+ registryVersion: import("drizzle-orm/pg-core").PgBuildColumn<"pgxsinkit_all_mutations", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
796
802
  name: string;
797
803
  tableName: "pgxsinkit_all_mutations";
798
804
  dataType: "string";
799
805
  data: string;
800
806
  driverParam: string;
801
- notNull: false;
807
+ notNull: true;
802
808
  hasDefault: false;
803
809
  isPrimaryKey: false;
804
810
  isAutoincrement: false;
@@ -1 +1 @@
1
- {"version":3,"file":"local-tables.d.ts","sourceRoot":"","sources":["../src/local-tables.ts"],"names":[],"mappings":"AAEA,OAAO,EAYL,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAgH9B,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAkE,CAAC;AACrF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAkE,CAAC;AACrF,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiF,CAAC;AACtG,QAAA,MAAM,cAAc;;;;;;;;;;;;;;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AS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,iGAAiG;IACjG,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B;;;;OAIG;IACH,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;CACxE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,SAAS,iBAAiB,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,SAAS,EAC3G,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,IAAI,GACb,WAAW,CAmBb;AAkCD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAwE,CAAC;AAEhG;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,iBAAiB,CAAC;AAExD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,GAAG,gBAAgB,CAElF;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,cAAc,CAY7E"}
@@ -50,8 +50,8 @@ export interface MutationDetail {
50
50
  nextRetryAtUs: string | null;
51
51
  serverUpdatedAtUs: string | null;
52
52
  updatedAtUs: string;
53
- /** Registry fingerprint (ADR-0004) the mutation was authored under, or null if unstamped. */
54
- registryVersion: string | null;
53
+ /** Registry fingerprint under which the mutation was authored. */
54
+ registryVersion: string;
55
55
  }
56
56
  export interface MutationDb {
57
57
  exec: (sql: string) => Promise<unknown>;
@@ -62,20 +62,17 @@ export interface MutationDb {
62
62
  export interface CreateMutationRuntimeOptions<TRegistry extends SyncTableRegistry> {
63
63
  db: MutationDb;
64
64
  registry: TRegistry;
65
- writeUrl: string;
65
+ batchWriteUrl: string;
66
66
  getAuthToken?: () => Promise<string | undefined>;
67
67
  /** Static headers added to every write request (e.g. a Supabase Cloud `apikey`); see {@link CreateSyncClientOptions.requestHeaders}. */
68
68
  requestHeaders?: Record<string, string>;
69
- /**
70
- * Registry fingerprint (ADR-0004) stamped onto each enqueued mutation as its
71
- * `registry_version`, so a version-boundary crossing is known before sending (ADR-0006).
72
- */
69
+ /** Registry fingerprint stamped onto each enqueued mutation; normally derived from {@link registry}. */
73
70
  registryVersion?: string;
74
71
  /**
75
72
  * Whether pgxsinkit owns the local schema (and therefore the `pgxsinkit_local_meta` table the durable
76
73
  * recovery-required marker lives in). Defaults to `true`. A caller-owned `pgliteInstance` boot sets this
77
- * `false`: the meta table may not exist, so the marker is never read/written and boot recovery falls back
78
- * to the legacy always-recover pass (proposal §1 caller-owned-PGlite constraint).
74
+ * `false`: the meta table may not exist, so the marker is never read/written and boot recovery runs
75
+ * unconditionally.
79
76
  */
80
77
  ownsMetaTable?: boolean;
81
78
  /**
@@ -126,7 +123,7 @@ export interface CreateMutationRuntimeOptions<TRegistry extends SyncTableRegistr
126
123
  * The result of {@link MutationRuntime.runBootRecovery}, shaped to feed the `warmBoot` BootReport fields
127
124
  * directly (ADR-0034): whether the per-table recovery loop was skipped, whether recovery was required this
128
125
  * boot, how many writable journals were visited, and how many rows were lifted `sending → pending` (`null`
129
- * when the pass was legacy/uncounted, a real count on the marker-`true` path).
126
+ * when the selected pass is uncounted, a real count on the marker-`true` path).
130
127
  */
131
128
  export interface BootRecoveryOutcome {
132
129
  skipped: boolean;
@@ -135,7 +132,7 @@ export interface BootRecoveryOutcome {
135
132
  rowsRecovered: number | null;
136
133
  }
137
134
  export interface MutationRuntime<TRegistry extends SyncTableRegistry> {
138
- /** The registry fingerprint (ADR-0004) this runtime stamps onto enqueued mutations. */
135
+ /** Registry fingerprint stamped onto mutations authored by this runtime. */
139
136
  registryVersion: string;
140
137
  create: <TKey extends SyncTableName<TRegistry>>(table: TKey, input: SyncTableCreateInput<TRegistry, TKey>) => Promise<void>;
141
138
  update: <TKey extends SyncTableName<TRegistry>>(table: TKey, entityKey: Record<string, string>, patch: SyncTableUpdateInput<TRegistry, TKey>) => Promise<void>;
@@ -176,16 +173,16 @@ export interface MutationRuntime<TRegistry extends SyncTableRegistry> {
176
173
  retryFailed: (table?: SyncTableName<TRegistry>) => Promise<void>;
177
174
  recoverSending: (table?: SyncTableName<TRegistry>) => Promise<void>;
178
175
  /**
179
- * Boot-time journal recovery driven by the durable recovery-required marker (proposal §1 / slice 2). The
176
+ * Boot-time journal recovery driven by the durable recovery-required marker. The
180
177
  * internal boot entry point that decides — from the marker and the boot mode — whether the per-table
181
178
  * `sending → pending` recovery loop runs at all, and clears/initializes the marker afterwards. It NEVER
182
179
  * runs from a consumer call ({@link recoverSending} keeps today's exact per-table semantics and never
183
180
  * touches the marker); {@link BootRecoveryOutcome} feeds the `warmBoot` BootReport fields verbatim.
184
181
  *
185
- * - `ownsMetaTable: false` (caller-owned PGlite) → legacy always-recover, marker untouched.
186
- * - `restore: true` → legacy recovery + {@link quarantineRecovered} + self-verifying clear (marker ignored).
182
+ * - `ownsMetaTable: false` (caller-owned PGlite) → unconditional recovery, marker untouched.
183
+ * - `restore: true` → unconditional recovery + {@link quarantineRecovered} + self-verifying clear (marker ignored).
187
184
  * - marker `false` → skip the loop entirely.
188
- * - marker absent (legacy store) → one legacy recovery pass, then initialize the marker.
185
+ * - marker absent (not initialized) → one conservative recovery pass, then initialize the marker.
189
186
  * - marker `true` → the N per-table updates PLUS the self-verifying clear, wrapped in one transaction.
190
187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AAK,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,CA2iC5B"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The minimal structural shape of an OPFS `FileSystemDirectoryHandle` this module traverses: the
3
+ * create-or-not `getDirectoryHandle`/`getFileHandle` hops and the recursive `removeEntry`. Declared locally
4
+ * so the module carries no DOM lib dependency (the pattern the rest of the toolkit uses for OPFS handles).
5
+ */
6
+ export interface DirLike {
7
+ getDirectoryHandle(name: string, options?: {
8
+ create?: boolean;
9
+ }): Promise<DirLike>;
10
+ getFileHandle(name: string, options?: {
11
+ create?: boolean;
12
+ }): Promise<unknown>;
13
+ removeEntry(name: string, options?: {
14
+ recursive?: boolean;
15
+ }): Promise<void>;
16
+ }
17
+ /** The injectable seam so Bun unit tests fake the OPFS root (there is no real OPFS there). */
18
+ export interface OpfsEffectsDeps {
19
+ /**
20
+ * The OPFS root getter. Omit in production: the default reads `navigator.storage.getDirectory` off
21
+ * `globalThis` (structural, no DOM lib). Absent API → the delete effects are no-ops, `observe` is
22
+ * `"unobservable"`, and the create effects throw (they are only reached in the opfs engine home).
23
+ */
24
+ getRoot?: () => Promise<DirLike>;
25
+ }
26
+ /** The effects surface the store-boot wiring drives (create-if-absent / delete-if-present / never-creating observe). */
27
+ export interface OpfsEffects {
28
+ /** Create-if-absent the commitment sentinel file at `pgxsinkit/commitments/<identity>`. */
29
+ publishSentinel(): Promise<void>;
30
+ /** Delete-if-present the commitment sentinel (`NotFoundError` swallowed). */
31
+ deleteSentinel(): Promise<void>;
32
+ /** Recursively delete-if-present the store directory `pgxsinkit/stores/<identity>` (`NotFoundError` swallowed). */
33
+ deleteStoreDirectory(): Promise<void>;
34
+ /**
35
+ * Never-creating walk of the commitment namespace. A root/API failure (or the API being absent) reads as
36
+ * `"unobservable"` — this method NEVER throws.
37
+ */
38
+ observeCommitmentNamespace(): Promise<{
39
+ sentinelPresent: boolean;
40
+ storeDirectoryPresent: boolean;
41
+ } | "unobservable">;
42
+ /** Create-if-absent chain to the store directory, returning its handle for the opfs-repacked factory. */
43
+ getStoreDirectoryHandle(): Promise<unknown>;
44
+ }
45
+ /**
46
+ * Construct the real OPFS effects for a store, all under `store-path.ts`'s disjoint namespaces. The returned
47
+ * object's methods satisfy the idempotency contracts the `store-lifecycle.ts` machines require, so a boot that
48
+ * resumes an interrupted destruction/candidate/adoption re-runs them safely.
49
+ */
50
+ export declare function createOpfsEffects(storePath: string, deps?: OpfsEffectsDeps): OpfsEffects;
51
+ //# sourceMappingURL=opfs-effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opfs-effects.d.ts","sourceRoot":"","sources":["../src/opfs-effects.ts"],"names":[],"mappings":"AAiBA;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnF,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9E,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E;AAED,8FAA8F;AAC9F,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC;AAED,wHAAwH;AACxH,MAAM,WAAW,WAAW;IAC1B,2FAA2F;IAC3F,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,6EAA6E;IAC7E,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,mHAAmH;IACnH,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC;;;OAGG;IACH,0BAA0B,IAAI,OAAO,CAAC;QAAE,eAAe,EAAE,OAAO,CAAC;QAAC,qBAAqB,EAAE,OAAO,CAAA;KAAE,GAAG,cAAc,CAAC,CAAC;IACrH,yGAAyG;IACzG,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7C;AAgBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,WAAW,CAqFxF"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * The minimal structural shape of the OPFS sync-access handle the probe opens and immediately closes. The
3
+ * open is the whole verdict; `close()` releases it so the scratch file can be removed. Typed locally so this
4
+ * module carries no DOM lib dependency (the pattern `store-path.ts` uses for OPFS handles).
5
+ */
6
+ export interface OpfsSyncAccessHandle {
7
+ close(): void;
8
+ }
9
+ /**
10
+ * The minimal structural shape of an OPFS `FileSystemFileHandle` the probe opens a sync-access handle on.
11
+ * `createSyncAccessHandle` is typed as POSSIBLY ABSENT on purpose: the probe never pre-checks it — it calls
12
+ * it, and absence at CALL time surfaces as the thrown `TypeError` we report verbatim, which is itself an
13
+ * honest "no sync access here" verdict rather than a presence sniff.
14
+ */
15
+ export interface OpfsProbeFileHandle {
16
+ createSyncAccessHandle?: () => Promise<OpfsSyncAccessHandle>;
17
+ }
18
+ /**
19
+ * The minimal structural shape of the OPFS `FileSystemDirectoryHandle` the probe walks and creates under.
20
+ * All three hops use `{ create: true }`: the probe MAKES its namespace (unlike `store-path.ts`'s
21
+ * never-creating existence walk). Declared locally so this module carries no DOM lib dependency.
22
+ */
23
+ export interface OpfsProbeDirectoryHandle {
24
+ getDirectoryHandle(name: string, options: {
25
+ create: true;
26
+ }): Promise<OpfsProbeDirectoryHandle>;
27
+ getFileHandle(name: string, options: {
28
+ create: true;
29
+ }): Promise<OpfsProbeFileHandle>;
30
+ removeEntry(name: string): Promise<void>;
31
+ }
32
+ /** The outcome of one placement probe. The probe ANSWERS; it never rejects. */
33
+ export interface PlacementProbeResult {
34
+ /** True only when a REAL `createSyncAccessHandle` open succeeded in this scope. */
35
+ granted: boolean;
36
+ /** Verbatim `Name: message` of the denial/failure when not granted (diagnostics; never parsed). */
37
+ error?: string;
38
+ /** Wall-clock ms the probe took (injectable clock). */
39
+ ms: number;
40
+ }
41
+ /** Injectable seams so the probe is deterministic in a Bun unit test (no real OPFS there). */
42
+ export interface PlacementProbeDeps {
43
+ /**
44
+ * The OPFS root getter. Omit in production: the default reads `navigator.storage.getDirectory` off
45
+ * `globalThis` (structural, no DOM lib). Absent API → the API-absent verdict below.
46
+ */
47
+ getRoot?: () => Promise<OpfsProbeDirectoryHandle>;
48
+ /**
49
+ * The scratch file name to open under `pgxsinkit/probe/`. Defaults to `probe-<random>` — UNIQUE per call
50
+ * so concurrent SharedWorkers (different stores, same origin) can probe simultaneously without contending
51
+ * on one file. Injected for deterministic tests.
52
+ */
53
+ scratchName?: string;
54
+ /** Wall clock. Defaults to `performance.now()`-or-`Date.now()` (the `boot-report.ts` `nowMs` pattern). */
55
+ now?: () => number;
56
+ }
57
+ /**
58
+ * Probe whether a REAL `createSyncAccessHandle` open succeeds in the executing scope — the ADR-0049 D1
59
+ * verdict that decides the engine home. Granted → the engine boots in this scope (SharedWorker-direct) and
60
+ * election never engages; denied → router-only mode (attach acks carry `electionRequired: true`).
61
+ *
62
+ * Sequence, all under the `pgxsinkit/probe/` namespace ({@link opfsProbeDirectoryPath}):
63
+ * 1. Resolve the OPFS root (`navigator.storage.getDirectory()`); API absent → {@link OPFS_API_ABSENT_ERROR}.
64
+ * 2. Walk/create `pgxsinkit` → `probe` (`{ create: true }`).
65
+ * 3. Create the scratch file (`{ create: true }`).
66
+ * 4. Call `createSyncAccessHandle()` — the verdict. Absence at call time throws a `TypeError` we report.
67
+ * 5. On success: `close()` the handle → granted.
68
+ * 6. ALWAYS (finally): `removeEntry` the scratch file, best-effort.
69
+ *
70
+ * Any throw in steps 1–4 (bar the API-absent early return) → `{ granted: false, error: "Name: message" }`.
71
+ * The probe NEVER rethrows: it answers, it never fails. And it is NEVER cached — every call probes afresh
72
+ * (invariant 8).
73
+ */
74
+ export declare function probeOpfsSyncAccess(deps?: PlacementProbeDeps): Promise<PlacementProbeResult>;
75
+ //# sourceMappingURL=placement-probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement-probe.d.ts","sourceRoot":"","sources":["../src/placement-probe.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC9D;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC/F,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrF,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,OAAO,EAAE,OAAO,CAAC;IACjB,mGAAmG;IACnG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,8FAA8F;AAC9F,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAClD;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0GAA0G;IAC1G,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AA+BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,GAAE,kBAAuB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAyCtG"}
package/dist/schema.d.ts CHANGED
@@ -1,23 +1,19 @@
1
1
  import { type AnyPgTable } from "drizzle-orm/pg-core";
2
2
  import { type SyncTableRegistry } from "@pgxsinkit/contracts";
3
- /**
4
- * Local key/value metadata table. Holds the registry fingerprint the local store was
5
- * provisioned under (ADR-0006), so a registry change is detected on boot and the read
6
- * cache is rebuilt — rather than relying on a hand-bumped `idb://…-vN` suffix.
7
- */
3
+ /** Local key/value metadata table for current-store safety, boot state, and registry identity. */
8
4
  export declare const LOCAL_META_TABLE = "pgxsinkit_local_meta";
9
5
  export declare const REGISTRY_FINGERPRINT_KEY = "registry_fingerprint";
10
6
  /**
11
7
  * 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
8
+ * provisioned under for the warm-store schema fast path. Its value is
13
9
  * `lsf1:<hash(durable SQL)>` (see {@link computeLocalSchemaFingerprint}); a boot compares it against the
14
10
  * freshly-generated durable SQL's hash to SKIP the durable replay when they match.
15
11
  */
16
12
  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). */
13
+ /** The fixed namespace for the exact supported local-schema fingerprint. */
18
14
  export declare const LOCAL_SCHEMA_FINGERPRINT_PREFIX = "lsf1:";
19
15
  /**
20
- * The registry-wide cross-journal mutation view (warm-persisted-store-startup slice 4 / proposal §5,
16
+ * The registry-wide cross-journal mutation view used by the mutation-status API,
21
17
  * option 1). A `TEMP` view UNION-ALL-ing every writable table's journal down to the shared fixed columns
22
18
  * (plus a `table_key` literal per branch), so a consumer can render one global mutation summary/detail
23
19
  * subscription instead of one live query per writable journal. It MUST be `TEMP`: an ephemeral entry's
@@ -53,17 +49,16 @@ export declare function generateEphemeralLocalSchemaSql<TRegistry extends SyncTa
53
49
  /**
54
50
  * The complete local schema — durable statements then ephemeral statements — the single script the
55
51
  * 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).
52
+ * is the registry-ordered stream, followed by the always-applied ephemeral portion — which for any registry
53
+ * with a writable table carries the `pgxsinkit_all_mutations` TEMP VIEW as its trailing statement. For a
54
+ * MIXED registry the script is idempotent-equivalent to (not a character-for-character match of) a
55
+ * single-pass interleave: the persistent clusters precede the ephemeral ones and the ephemeral portion
56
+ * re-emits idempotent enum guards — a reordering of independent `IF NOT EXISTS` DDL that executes to the
57
+ * same schema. Equals `durable + ephemeral` by construction (test-covered).
63
58
  */
64
59
  export declare function generateLocalSchemaSql<TRegistry extends SyncTableRegistry>(registry: TRegistry): string;
65
60
  /**
66
- * The durable-schema fingerprint value (slice 3 / proposal §3): `lsf1:<FNV-1a hash of the durable SQL>`. The
61
+ * The durable-schema fingerprint value: `lsf1:<FNV-1a hash of the durable SQL>`. The
67
62
  * hash is over the generated durable DDL body itself (no composed inputs, no hand-maintained format-version
68
63
  * constant), so it auto-invalidates on ANY generator change, registry change, or projection rename — the
69
64
  * ADR-0018 apply-function-fingerprint precedent applied to the local schema. Stamped into
@@ -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,EAWL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAyB9B;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAC/D;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AACvE,+GAA+G;AAC/G,eAAO,MAAM,+BAA+B,UAAU,CAAC;AAEvD;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,4BAA4B,CAAC;AAE5D;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,YACxC,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,E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0 +1,77 @@
1
+ import { type OpfsEffectsDeps } from "./opfs-effects";
2
+ import { type StoreBootVerdict, type StoreMetaDeps } from "./store-meta";
3
+ /**
4
+ * The resolved storage backend a boot lands on. `opfs-repacked` (the elected/SW-direct opfs engine home),
5
+ * `idbfs` (browser, no sync-access handles), `filesystem` (Bun/Node), or `memory` (the sanctioned
6
+ * test/ephemeral lane). Surfaced on the BootReport as an additive field under the ADR-0034 reportVersion
7
+ * rule (additive fields keep `reportVersion: 1`); ADR-0049 named the backends.
8
+ */
9
+ export type ResolvedStorageBackend = "opfs-repacked" | "idbfs" | "filesystem" | "memory";
10
+ /** The outcome of {@link resolveStoreBoot}: the URL to open the store at, its backend, and the boot verdict. */
11
+ export interface StoreBootResolution {
12
+ /** The PGlite dataDir URL, always assembled by {@link resolveStoreDataDir} (the one URL assembler). */
13
+ dataDir: string;
14
+ /** The resolved backend, for diagnostics. */
15
+ storageBackend: ResolvedStorageBackend;
16
+ /**
17
+ * The executed boot verdict. Absent on the passthrough backends (`memory` / `filesystem`), which have NO
18
+ * meta machinery. Present on every browser classification — in particular it is the signal that an opfs
19
+ * CANDIDATE was stood up UNCOMMITTED (`virgin-create` / `delete-candidate-and-rebuild`): the mint seam must
20
+ * run the commitment barrier before exposing that store to writes (plan step 10b/11).
21
+ */
22
+ verdict?: StoreBootVerdict;
23
+ }
24
+ /** Options for {@link resolveStoreBoot}. */
25
+ export interface ResolveStoreBootOptions {
26
+ /** The placement probe's result, injected by the caller (invariant 8 — probe per boot, never cached here). */
27
+ hasOpfsSyncAccess: boolean;
28
+ /** The internal test-only memory backend override (ADR-0036), carried through from the mint seam. */
29
+ backendOverride?: "memory";
30
+ /** Injectable IO seams so Bun unit tests fake the whole browser surface. */
31
+ deps?: {
32
+ /** The store-meta IndexedDB seam (defaults to `globalThis.indexedDB` inside store-meta). */
33
+ meta?: StoreMetaDeps;
34
+ /** The OPFS root seam (defaults to `navigator.storage.getDirectory` inside opfs-effects). */
35
+ opfs?: OpfsEffectsDeps;
36
+ /** The recordless idb existence check (defaults to store-meta's non-creating {@link idbStoreExists}). */
37
+ idbExists?: (storePath: string) => Promise<boolean>;
38
+ };
39
+ }
40
+ /**
41
+ * A probe-denied browser still has to honour an existing `deleting` phase before it may create a replacement
42
+ * IDB store. The old cache is already explicitly destructible; the only authority handoff required is to
43
+ * remove the OPFS commitment sentinel, then publish `idb-authoritative` before the replacement is exposed.
44
+ * Any sentinel-less directory is disposable residue and is removed before a later OPFS candidate is minted.
45
+ */
46
+ export declare function recoverDeniedBootDeletion(storePath: string, deps?: ResolveStoreBootOptions["deps"]): Promise<boolean>;
47
+ /**
48
+ * Resolve where a store boots and finish any destructive/candidate/adoption work the verdict demands, then
49
+ * return the `dataDir` + `storageBackend` the mint seam opens at. The full plan boot classification 1–7,
50
+ * EXECUTED:
51
+ *
52
+ * - **memory override** → `memory://` passthrough, no classification (the sanctioned test/ephemeral lane has
53
+ * no meta machinery).
54
+ * - **non-browser** (no idb, no opfs handles) → `file://` passthrough, no classification (the filesystem
55
+ * backend has no meta machinery either).
56
+ * - **browser** → read the meta record ({@link readStoreMetaRecord}; {@link StoreMetaUnreadableError}
57
+ * propagates = fail closed, invariant 12), map {@link META_STORE_UNAVAILABLE} to a provable absence
58
+ * (no idb ⇒ no record and no existing idb store), observe the commitment namespace and the recordless idb fact,
59
+ * classify, and execute:
60
+ * - `resume-deletion` → complete the destructive lifecycle, then RE-CLASSIFY from the now-clean state
61
+ * (bounded by {@link MAX_DELETION_RECLASSIFY}).
62
+ * - `delete-candidate-and-rebuild` → delete the stale sentinel AND the candidate directory (a barrier-gap
63
+ * crash's sentinel must never survive), then rebuild per placement (the virgin path).
64
+ * - `repair-record-then-open-committed` → write `opfs-committed`, then open committed.
65
+ * - `open-committed` → open the committed opfs store (open failures are HARD at mint time; the bounded
66
+ * retries for transient UnknownError-class failures live in the mint seam's factory-call wrapper).
67
+ * - `boot-idb-authoritative` → write `idb-authoritative` FIRST when there is no record yet (recordless idb), then
68
+ * `idb://`.
69
+ * - `adoption-recovery` → {@link classifyAdoptionRecovery}: `complete-adoption` finishes the barrier
70
+ * (`opfs-committed` + delete the idb predecessor) → `opfs://`; `teardown-and-restart` tears the candidate
71
+ * down, sets `idb-authoritative`, and boots `idb://` (adoption re-runs later, plan step 11).
72
+ * - `virgin-create` → with opfs access, {@link beginFreshCandidate} (record `opfs-candidate` BEFORE the
73
+ * directory) → `opfs://` UNCOMMITTED (barrier is step 10b/11); without opfs access, `idb-authoritative` →
74
+ * `idb://`.
75
+ */
76
+ export declare function resolveStoreBoot(storePath: string, opts: ResolveStoreBootOptions): Promise<StoreBootResolution>;
77
+ //# sourceMappingURL=store-boot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-boot.d.ts","sourceRoot":"","sources":["../src/store-boot.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAGnB,MAAM,cAAc,CAAC;AAGtB;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,eAAe,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEzF,gHAAgH;AAChH,MAAM,WAAW,mBAAmB;IAClC,uGAAuG;IACvG,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,cAAc,EAAE,sBAAsB,CAAC;IACvC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC,8GAA8G;IAC9G,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qGAAqG;IACrG,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,EAAE;QACL,4FAA4F;QAC5F,IAAI,CAAC,EAAE,aAAa,CAAC;QACrB,6FAA6F;QAC7F,IAAI,CAAC,EAAE,eAAe,CAAC;QACvB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