@minnowdb/core 0.2.1 → 0.4.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 (270) hide show
  1. package/README.md +23 -32
  2. package/dist/block-format/block.d.ts +32 -13
  3. package/dist/block-format/block.js +179 -55
  4. package/dist/block-format/checksum.d.ts +2 -1
  5. package/dist/block-format/checksum.js +5 -2
  6. package/dist/block-format/codecs.d.ts +7 -2
  7. package/dist/block-format/codecs.js +53 -12
  8. package/dist/block-format/column.d.ts +3 -2
  9. package/dist/block-format/column.js +96 -30
  10. package/dist/block-format/index.d.ts +2 -2
  11. package/dist/block-format/index.js +2 -2
  12. package/dist/block-format/physical.d.ts +8 -2
  13. package/dist/block-format/physical.js +14 -6
  14. package/dist/block-format/types.d.ts +7 -3
  15. package/dist/block-format/types.js +0 -1
  16. package/dist/block-format/unicode.d.ts +11 -0
  17. package/dist/block-format/unicode.js +46 -0
  18. package/dist/date-value.d.ts +15 -0
  19. package/dist/date-value.js +64 -0
  20. package/dist/engine/artifact-cache.d.ts +2 -1
  21. package/dist/engine/artifact-cache.js +5 -1
  22. package/dist/engine/batch.d.ts +11 -3
  23. package/dist/engine/batch.js +17 -7
  24. package/dist/engine/buffered-writer.d.ts +2 -1
  25. package/dist/engine/buffered-writer.js +34 -9
  26. package/dist/engine/cache-limits.d.ts +25 -0
  27. package/dist/engine/cache-limits.js +25 -0
  28. package/dist/engine/catalog.d.ts +24 -5
  29. package/dist/engine/catalog.js +34 -7
  30. package/dist/engine/client.d.ts +29 -7
  31. package/dist/engine/client.js +216 -40
  32. package/dist/engine/database.d.ts +224 -39
  33. package/dist/engine/database.js +7475 -1539
  34. package/dist/engine/defaults.d.ts +4 -8
  35. package/dist/engine/defaults.js +46 -22
  36. package/dist/engine/errors.d.ts +19 -1
  37. package/dist/engine/errors.js +32 -2
  38. package/dist/engine/fts.d.ts +0 -6
  39. package/dist/engine/fts.js +41 -14
  40. package/dist/engine/group-index.d.ts +0 -1
  41. package/dist/engine/group-index.js +6 -11
  42. package/dist/engine/index.d.ts +16 -10
  43. package/dist/engine/index.js +12 -9
  44. package/dist/engine/join-index.d.ts +0 -1
  45. package/dist/engine/join-index.js +2 -2
  46. package/dist/engine/keyed-live.d.ts +57 -0
  47. package/dist/engine/keyed-live.js +226 -0
  48. package/dist/engine/live-api.d.ts +4 -0
  49. package/dist/engine/live-api.js +4 -0
  50. package/dist/engine/live.d.ts +43 -26
  51. package/dist/engine/live.js +504 -126
  52. package/dist/engine/memory.d.ts +2 -1
  53. package/dist/engine/memory.js +3 -2
  54. package/dist/engine/optimizer.d.ts +0 -1
  55. package/dist/engine/optimizer.js +262 -27
  56. package/dist/engine/query-api.d.ts +3 -0
  57. package/dist/engine/query-api.js +3 -0
  58. package/dist/engine/query-cache.d.ts +1 -2
  59. package/dist/engine/query-cache.js +7 -5
  60. package/dist/engine/query.d.ts +134 -29
  61. package/dist/engine/query.js +1668 -372
  62. package/dist/engine/result-wire.d.ts +0 -1
  63. package/dist/engine/result-wire.js +2 -2
  64. package/dist/engine/schema-wire.d.ts +6 -3
  65. package/dist/engine/schema-wire.js +40 -34
  66. package/dist/engine/schema.d.ts +156 -80
  67. package/dist/engine/schema.js +570 -108
  68. package/dist/engine/sort-keys.d.ts +4 -4
  69. package/dist/engine/sort-keys.js +44 -29
  70. package/dist/engine/sql-domains.d.ts +31 -0
  71. package/dist/engine/sql-domains.js +585 -0
  72. package/dist/engine/sql-driver.d.ts +19 -0
  73. package/dist/engine/sql-driver.js +1 -0
  74. package/dist/engine/sql-json.d.ts +7 -9
  75. package/dist/engine/sql-json.js +75 -15
  76. package/dist/engine/sql-semantics.d.ts +8 -3
  77. package/dist/engine/sql-semantics.js +458 -30
  78. package/dist/engine/typed-live.d.ts +67 -0
  79. package/dist/engine/typed-live.js +349 -0
  80. package/dist/engine/vector.d.ts +12 -2
  81. package/dist/engine/vector.js +635 -119
  82. package/dist/engine/worker-host.d.ts +9 -2
  83. package/dist/engine/worker-host.js +620 -152
  84. package/dist/engine/worker.d.ts +0 -1
  85. package/dist/engine/worker.js +3 -3
  86. package/dist/engine/write-block-planner.d.ts +18 -0
  87. package/dist/engine/write-block-planner.js +112 -0
  88. package/dist/index.d.ts +0 -1
  89. package/dist/index.js +0 -1
  90. package/dist/plan/index.d.ts +3 -4
  91. package/dist/plan/index.js +3 -4
  92. package/dist/storage/index.d.ts +1 -1
  93. package/dist/storage/index.js +1 -1
  94. package/dist/storage/indexeddb.d.ts +99 -51
  95. package/dist/storage/indexeddb.js +13448 -2660
  96. package/dist/storage/memory.d.ts +64 -57
  97. package/dist/storage/memory.js +1042 -128
  98. package/dist/storage/opfs/files.d.ts +18 -7
  99. package/dist/storage/opfs/files.js +115 -28
  100. package/dist/storage/opfs/index.d.ts +1 -1
  101. package/dist/storage/opfs/index.js +1 -1
  102. package/dist/storage/opfs/leader.d.ts +409 -75
  103. package/dist/storage/opfs/leader.js +4621 -650
  104. package/dist/storage/opfs/rpc.d.ts +15 -3
  105. package/dist/storage/opfs/rpc.js +224 -2
  106. package/dist/storage/opfs/snapshot-ledger.d.ts +40 -0
  107. package/dist/storage/opfs/snapshot-ledger.js +281 -0
  108. package/dist/storage/opfs/store.d.ts +33 -99
  109. package/dist/storage/opfs/store.js +453 -364
  110. package/dist/storage/persistence.d.ts +37 -0
  111. package/dist/storage/persistence.js +78 -0
  112. package/dist/storage/snapshot-stream.d.ts +24 -0
  113. package/dist/storage/snapshot-stream.js +897 -0
  114. package/dist/storage/snapshot.d.ts +9 -85
  115. package/dist/storage/snapshot.js +33 -265
  116. package/dist/storage/toolkit/extents.d.ts +41 -7
  117. package/dist/storage/toolkit/extents.js +402 -39
  118. package/dist/storage/toolkit/index.d.ts +4 -5
  119. package/dist/storage/toolkit/index.js +28 -4
  120. package/dist/storage/toolkit/record-core.d.ts +182 -55
  121. package/dist/storage/toolkit/record-core.js +6158 -1331
  122. package/dist/storage/toolkit/sync-file.d.ts +10 -1
  123. package/dist/storage/toolkit/sync-file.js +50 -2
  124. package/dist/storage/toolkit/wal.d.ts +23 -5
  125. package/dist/storage/toolkit/wal.js +89 -27
  126. package/dist/storage/toolkit/wire.d.ts +15 -2
  127. package/dist/storage/toolkit/wire.js +199 -10
  128. package/dist/storage/types.d.ts +1439 -204
  129. package/dist/storage/types.js +1745 -141
  130. package/dist/testing/block-store-conformance.d.ts +0 -1
  131. package/dist/testing/block-store-conformance.js +1009 -119
  132. package/dist/testing/index.d.ts +46 -26
  133. package/dist/testing/index.js +112 -57
  134. package/dist/testing/opfs-shim.d.ts +13 -3
  135. package/dist/testing/opfs-shim.js +40 -6
  136. package/dist/testing/simulator.d.ts +97 -0
  137. package/dist/testing/simulator.js +591 -0
  138. package/dist/testing/sqllogictest.d.ts +89 -0
  139. package/dist/testing/sqllogictest.js +434 -0
  140. package/dist/transactions/index.d.ts +92 -16
  141. package/dist/transactions/index.js +1074 -236
  142. package/dist/worker-protocol/index.d.ts +3 -2
  143. package/dist/worker-protocol/index.js +2 -5
  144. package/package.json +53 -3
  145. package/postgres-feature-profile.json +223 -0
  146. package/sql-feature-matrix.json +172 -252
  147. package/dist/block-format/block.d.ts.map +0 -1
  148. package/dist/block-format/block.js.map +0 -1
  149. package/dist/block-format/checksum.d.ts.map +0 -1
  150. package/dist/block-format/checksum.js.map +0 -1
  151. package/dist/block-format/codecs.d.ts.map +0 -1
  152. package/dist/block-format/codecs.js.map +0 -1
  153. package/dist/block-format/column.d.ts.map +0 -1
  154. package/dist/block-format/column.js.map +0 -1
  155. package/dist/block-format/index.d.ts.map +0 -1
  156. package/dist/block-format/index.js.map +0 -1
  157. package/dist/block-format/physical.d.ts.map +0 -1
  158. package/dist/block-format/physical.js.map +0 -1
  159. package/dist/block-format/types.d.ts.map +0 -1
  160. package/dist/block-format/types.js.map +0 -1
  161. package/dist/engine/artifact-cache.d.ts.map +0 -1
  162. package/dist/engine/artifact-cache.js.map +0 -1
  163. package/dist/engine/batch.d.ts.map +0 -1
  164. package/dist/engine/batch.js.map +0 -1
  165. package/dist/engine/buffered-writer.d.ts.map +0 -1
  166. package/dist/engine/buffered-writer.js.map +0 -1
  167. package/dist/engine/catalog.d.ts.map +0 -1
  168. package/dist/engine/catalog.js.map +0 -1
  169. package/dist/engine/client.d.ts.map +0 -1
  170. package/dist/engine/client.js.map +0 -1
  171. package/dist/engine/coordinator.d.ts +0 -17
  172. package/dist/engine/coordinator.d.ts.map +0 -1
  173. package/dist/engine/coordinator.js +0 -60
  174. package/dist/engine/coordinator.js.map +0 -1
  175. package/dist/engine/database.d.ts.map +0 -1
  176. package/dist/engine/database.js.map +0 -1
  177. package/dist/engine/defaults.d.ts.map +0 -1
  178. package/dist/engine/defaults.js.map +0 -1
  179. package/dist/engine/errors.d.ts.map +0 -1
  180. package/dist/engine/errors.js.map +0 -1
  181. package/dist/engine/fts.d.ts.map +0 -1
  182. package/dist/engine/fts.js.map +0 -1
  183. package/dist/engine/group-index.d.ts.map +0 -1
  184. package/dist/engine/group-index.js.map +0 -1
  185. package/dist/engine/index.d.ts.map +0 -1
  186. package/dist/engine/index.js.map +0 -1
  187. package/dist/engine/join-index.d.ts.map +0 -1
  188. package/dist/engine/join-index.js.map +0 -1
  189. package/dist/engine/live.d.ts.map +0 -1
  190. package/dist/engine/live.js.map +0 -1
  191. package/dist/engine/memory.d.ts.map +0 -1
  192. package/dist/engine/memory.js.map +0 -1
  193. package/dist/engine/optimizer.d.ts.map +0 -1
  194. package/dist/engine/optimizer.js.map +0 -1
  195. package/dist/engine/query-cache.d.ts.map +0 -1
  196. package/dist/engine/query-cache.js.map +0 -1
  197. package/dist/engine/query.d.ts.map +0 -1
  198. package/dist/engine/query.js.map +0 -1
  199. package/dist/engine/result-wire.d.ts.map +0 -1
  200. package/dist/engine/result-wire.js.map +0 -1
  201. package/dist/engine/schema-wire.d.ts.map +0 -1
  202. package/dist/engine/schema-wire.js.map +0 -1
  203. package/dist/engine/schema.d.ts.map +0 -1
  204. package/dist/engine/schema.js.map +0 -1
  205. package/dist/engine/sort-keys.d.ts.map +0 -1
  206. package/dist/engine/sort-keys.js.map +0 -1
  207. package/dist/engine/sql-json.d.ts.map +0 -1
  208. package/dist/engine/sql-json.js.map +0 -1
  209. package/dist/engine/sql-semantics.d.ts.map +0 -1
  210. package/dist/engine/sql-semantics.js.map +0 -1
  211. package/dist/engine/vector.d.ts.map +0 -1
  212. package/dist/engine/vector.js.map +0 -1
  213. package/dist/engine/worker-host.d.ts.map +0 -1
  214. package/dist/engine/worker-host.js.map +0 -1
  215. package/dist/engine/worker.d.ts.map +0 -1
  216. package/dist/engine/worker.js.map +0 -1
  217. package/dist/index.d.ts.map +0 -1
  218. package/dist/index.js.map +0 -1
  219. package/dist/plan/index.d.ts.map +0 -1
  220. package/dist/plan/index.js.map +0 -1
  221. package/dist/storage/fixture-shape.d.ts +0 -42
  222. package/dist/storage/fixture-shape.d.ts.map +0 -1
  223. package/dist/storage/fixture-shape.js +0 -146
  224. package/dist/storage/fixture-shape.js.map +0 -1
  225. package/dist/storage/index.d.ts.map +0 -1
  226. package/dist/storage/index.js.map +0 -1
  227. package/dist/storage/indexeddb.d.ts.map +0 -1
  228. package/dist/storage/indexeddb.js.map +0 -1
  229. package/dist/storage/memory.d.ts.map +0 -1
  230. package/dist/storage/memory.js.map +0 -1
  231. package/dist/storage/opfs/files.d.ts.map +0 -1
  232. package/dist/storage/opfs/files.js.map +0 -1
  233. package/dist/storage/opfs/index.d.ts.map +0 -1
  234. package/dist/storage/opfs/index.js.map +0 -1
  235. package/dist/storage/opfs/leader.d.ts.map +0 -1
  236. package/dist/storage/opfs/leader.js.map +0 -1
  237. package/dist/storage/opfs/rpc.d.ts.map +0 -1
  238. package/dist/storage/opfs/rpc.js.map +0 -1
  239. package/dist/storage/opfs/store.d.ts.map +0 -1
  240. package/dist/storage/opfs/store.js.map +0 -1
  241. package/dist/storage/snapshot.d.ts.map +0 -1
  242. package/dist/storage/snapshot.js.map +0 -1
  243. package/dist/storage/toolkit/extents.d.ts.map +0 -1
  244. package/dist/storage/toolkit/extents.js.map +0 -1
  245. package/dist/storage/toolkit/index.d.ts.map +0 -1
  246. package/dist/storage/toolkit/index.js.map +0 -1
  247. package/dist/storage/toolkit/record-core.d.ts.map +0 -1
  248. package/dist/storage/toolkit/record-core.js.map +0 -1
  249. package/dist/storage/toolkit/sync-file.d.ts.map +0 -1
  250. package/dist/storage/toolkit/sync-file.js.map +0 -1
  251. package/dist/storage/toolkit/wal.d.ts.map +0 -1
  252. package/dist/storage/toolkit/wal.js.map +0 -1
  253. package/dist/storage/toolkit/wire.d.ts.map +0 -1
  254. package/dist/storage/toolkit/wire.js.map +0 -1
  255. package/dist/storage/types.d.ts.map +0 -1
  256. package/dist/storage/types.js.map +0 -1
  257. package/dist/testing/block-store-conformance.d.ts.map +0 -1
  258. package/dist/testing/block-store-conformance.js.map +0 -1
  259. package/dist/testing/index.d.ts.map +0 -1
  260. package/dist/testing/index.js.map +0 -1
  261. package/dist/testing/opfs-shim.d.ts.map +0 -1
  262. package/dist/testing/opfs-shim.js.map +0 -1
  263. package/dist/testing/seeds.d.ts +0 -11
  264. package/dist/testing/seeds.d.ts.map +0 -1
  265. package/dist/testing/seeds.js +0 -50
  266. package/dist/testing/seeds.js.map +0 -1
  267. package/dist/transactions/index.d.ts.map +0 -1
  268. package/dist/transactions/index.js.map +0 -1
  269. package/dist/worker-protocol/index.d.ts.map +0 -1
  270. package/dist/worker-protocol/index.js.map +0 -1
@@ -1,5 +1,4 @@
1
- import { type BeginTransactionInput, type BeginTransactionResult, type CommitTransactionInput, type CompactionJobRecord, type CompactionJobRecordUpdate, type CreateGarbageCollectionJobInput, type CatalogProbe, type TriggerRecord, type FtsCandidates, type FtsColumnIndexRecord, type FtsPosting, type GarbageCollectionJobRecord, type GarbageCollectionStepResult, type LeaseRecord, type Manifest, type ManifestSummary, type PublishManifestInput, type QueryCatalogState, type RowIdRange, type RunGarbageCollectionStepInput, type SegmentRecord, type StageTransactionArtifactsInput, type StoragePage, type TableColumnRecord, type TableRecord, type TempOwnerRecord, type TempRunPage, type TransactionRecord, type TransactionRecordUpdate, type WriteTransactionInput } from "../types.js";
2
- import { type DatabaseSnapshot } from "../snapshot.js";
1
+ import { type BeginTransactionInput, type BeginTransactionResult, type AbortTransactionIfExpiredInput, type AdoptAbortedSegmentInput, type RenewTransactionInput, type CommitTransactionInput, type CompactionJobRecord, type CompactionJobRecordUpdate, type CreateGarbageCollectionJobInput, type UpdateGarbageCollectionPlanningInput, type DropTableColumnInput, type DropTableInput, type CatalogProbe, type FtsCandidates, type FtsPostingQuery, type FtsPosting, type GarbageCollectionJobRecord, type GarbageCollectionStepResult, type LeaseRecord, type MoveLeaseInput, type RenewLeaseInput, type RenewTempOwnerInput, type Manifest, type ManifestBlockRecord, type ListManifestBlockPageInput, type ListRetiredManifestBlockPageInput, type ManifestBlockPage, type ManifestSummary, type RowIdRange, type RunGarbageCollectionStepInput, type SegmentRecord, type RollbackTransactionArtifactsInput, type StageTransactionArtifactsInput, type StoragePage, type CatalogMutationOptions, type TableRecord, type TableRecordUpdate, type TempOwnerRecord, type TempRunPage, type TransactionRecord, type TransactionRecordUpdate, type UniqueKeyBuildRecord, type BeginUniqueKeyBuildInput, type RenewUniqueKeyBuildInput, type AppendUniqueKeyBuildChunkInput, type FinishUniqueKeyBuildInput, type AbortUniqueKeyBuildInput, type WriteTransactionInput, type SnapshotCatalogItem, type SnapshotMetadataItem, type SnapshotFrameStreamHeader, type SnapshotPostingItem, type SnapshotSegmentItem, type SnapshotTransactionItem, type SnapshotUniqueItem } from "../types.js";
3
2
  /**
4
3
  * How the record core sees block bytes it does not hold. The core owns every small record —
5
4
  * catalog, manifests, transactions, leases, jobs, counters, keys — but block payloads live
@@ -10,12 +9,68 @@ export interface PhysicalBlocks {
10
9
  hasBlock(id: string): boolean;
11
10
  /** `undefined` means the block does not exist. */
12
11
  blockByteLength(id: string): number | undefined;
12
+ /** Exact stored-payload CRC when the adapter persists manifest provenance. */
13
+ blockChecksum?(id: string): number | undefined;
14
+ }
15
+ type OrderedKey = string | number;
16
+ /**
17
+ * A small chunked ordered index. Random UUID insertion only shifts one bounded chunk, while a
18
+ * cursor seek binary-searches chunks and keys before walking the requested page sequentially.
19
+ */
20
+ /** @internal Exported only so the storage hardening suite can assert operation counts. */
21
+ export declare class OrderedKeyIndex<Key> {
22
+ #private;
23
+ static readonly CHUNK_SIZE = 128;
24
+ constructor(compare: (left: Key, right: Key) => number);
25
+ clear(): void;
26
+ get empty(): boolean;
27
+ add(key: Key): void;
28
+ delete(key: Key): void;
29
+ after(after: Key | null): IterableIterator<Key>;
30
+ }
31
+ /** Membership lookup plus stable lexical streaming without sorting on every bulk write. */
32
+ /** @internal Exported only so storage hardening tests can exercise lazy-index transitions. */
33
+ export declare class OrderedStringSet extends Set<string> {
34
+ #private;
35
+ constructor(values?: Iterable<string>);
36
+ add(value: string): this;
37
+ /**
38
+ * Adds a commit delta without maintaining snapshot order token-by-token. Membership remains
39
+ * eager and exact; the snapshot-only index is rebuilt once, deterministically, if ordered
40
+ * iteration is later requested. Clearing a stale index also releases its duplicate references.
41
+ */
42
+ addMany(values: Iterable<string>): this;
43
+ delete(value: string): boolean;
44
+ clear(): void;
45
+ orderedValues(): IterableIterator<string>;
46
+ }
47
+ declare class OrderedRecordMap<Key extends OrderedKey, Value> extends Map<Key, Value> {
48
+ #private;
49
+ constructor(onChange?: (previous: Value | undefined, next: Value | undefined) => void);
50
+ set(key: Key, value: Value): this;
51
+ delete(key: Key): boolean;
52
+ clear(): void;
53
+ orderedValues(after: Key | null): IterableIterator<Value>;
54
+ }
55
+ /** @internal Exported only so the storage hardening suite can exercise table-local traversal. */
56
+ export declare class SegmentRecordMap extends OrderedRecordMap<string, SegmentRecord> {
57
+ #private;
58
+ set(id: string, record: SegmentRecord): this;
59
+ delete(id: string): boolean;
60
+ clear(): void;
61
+ tableValues(tableId: string): IterableIterator<SegmentRecord>;
62
+ blockReferenceCount(blockId: string): number;
63
+ tableBlockReferenceCount(tableId: string, blockId: string): number;
64
+ segmentIdsForBlock(blockId: string): ReadonlySet<string>;
65
+ ownerReferenceCount(transactionId: string): number;
13
66
  }
14
67
  /** `RecordCore.dump()`'s shape; see there. Arrays rather than Maps so the value serializes. */
15
68
  export interface RecordCoreState {
16
69
  currentVersion: number | null;
17
70
  catalogEpoch: number;
71
+ schemaEpoch: number;
18
72
  manifests: Manifest[];
73
+ manifestBlocks: ManifestBlockRecord[];
19
74
  transactions: TransactionRecord[];
20
75
  tables: TableRecord[];
21
76
  segments: SegmentRecord[];
@@ -34,6 +89,7 @@ export interface RecordCoreState {
34
89
  totalTokens: number;
35
90
  }]>]>;
36
91
  uniqueKeys: Array<readonly [string, string[]]>;
92
+ uniqueKeyBuilds: Array<readonly [UniqueKeyBuildRecord, string[][], FinishUniqueKeyBuildInput | null]>;
37
93
  tempOwners: TempOwnerRecord[];
38
94
  }
39
95
  /**
@@ -58,9 +114,12 @@ export interface RecordCoreState {
58
114
  export declare class RecordCore {
59
115
  #private;
60
116
  constructor(physical: PhysicalBlocks);
117
+ /** Reconstructs and validates time-sensitive pinned-retired quotas after durable recovery. */
118
+ validatePinnedRetiredLimits(expiresAtCutoff: string): void;
61
119
  createTempOwner(record: TempOwnerRecord): void;
62
120
  getTempOwner(ownerId: string): TempOwnerRecord | undefined;
63
- renewTempOwner(ownerId: string, expectedRevision: number, expiresAt: string): TempOwnerRecord;
121
+ renewTempOwner(input: RenewTempOwnerInput): TempOwnerRecord;
122
+ listExpiredTempOwnerPage(expiresAtCutoff: string, afterCursor: string | null, limit: number): StoragePage<string, string>;
64
123
  /**
65
124
  * Removes the owner record when it is absent or expired, and reports whether the caller
66
125
  * should also remove the owner's physical pages. Page bytes are the enclosing store's.
@@ -73,26 +132,23 @@ export declare class RecordCore {
73
132
  * expiry sweep can reclaim them.
74
133
  */
75
134
  listTempOwnerIdsPage(afterOwnerId: string | null, limit: number, extraOwnerIds: Iterable<string>): StoragePage<string, string>;
76
- addTable(record: TableRecord): void;
135
+ addTable(record: TableRecord, options?: CatalogMutationOptions): void;
77
136
  getTable(id: string): TableRecord | undefined;
78
- updateTable(id: string, expectedRevision: number, update: {
79
- columns?: TableColumnRecord[];
80
- ftsColumns?: Record<string, FtsColumnIndexRecord> | null;
81
- triggers?: TriggerRecord[] | null;
82
- }): TableRecord;
83
- removeTable(id: string, expectedRevision: number): void;
137
+ updateTable(id: string, expectedRevision: number, update: TableRecordUpdate): TableRecord;
138
+ removeTable(id: string, expectedRevision: number, options?: CatalogMutationOptions): void;
139
+ dropTable(input: DropTableInput): ManifestSummary;
140
+ dropTableColumn(input: DropTableColumnInput): ManifestSummary;
84
141
  writeFtsBase(tableId: string, columnId: string, input: {
85
142
  coversVersion: number;
86
143
  chunks: FtsPosting[][];
87
144
  totalTokens: number;
88
145
  }): void;
89
- readFtsCandidates(tableId: string, columnId: string, terms: ReadonlyArray<{
90
- term: string;
91
- prefix: boolean;
92
- }>, upToVersion: number): FtsCandidates & {
146
+ removeFtsColumn(tableId: string, columnId: string): void;
147
+ readFtsCandidates(tableId: string, columnId: string, terms: readonly FtsPostingQuery[], upToVersion: number, maxRowIds?: number): FtsCandidates & {
93
148
  deltaChunkCount: number;
94
149
  totalTokens: number;
95
150
  coversVersion: number;
151
+ hasBase: boolean;
96
152
  };
97
153
  /**
98
154
  * The delta half of a full-text read, for stores that keep base chunks outside the core
@@ -104,6 +160,13 @@ export declare class RecordCore {
104
160
  deltaChunkCount: number;
105
161
  deltaTokens: number;
106
162
  };
163
+ readFtsPostings(tableId: string, columnId: string, upToVersion: number, maxRowIds?: number, maxRetainedBytes?: number): {
164
+ postings: FtsPosting[];
165
+ overflow: boolean;
166
+ deltaChunkCount: number;
167
+ coversVersion: number;
168
+ hasBase: boolean;
169
+ };
107
170
  /** The delta-pruning half of `writeFtsBase`, for stores that keep the base itself outside. */
108
171
  pruneFtsDeltas(tableId: string, columnId: string, coversVersion: number): void;
109
172
  /**
@@ -117,42 +180,51 @@ export declare class RecordCore {
117
180
  job: GarbageCollectionJobRecord;
118
181
  prunedManifestVersions: readonly number[];
119
182
  reclaimedSegmentIds: readonly string[];
120
- reclaimedTransactionIds?: readonly string[];
183
+ reclaimedBlockIds: readonly string[];
184
+ reclaimedTransactionIds: readonly string[];
121
185
  updatedAt: string;
122
186
  }): void;
123
187
  getTableByName(name: string): TableRecord | undefined;
124
188
  /** For stores that compose lookups over their own overridable methods. */
125
189
  getTableIdByName(name: string): string | undefined;
126
190
  listTables(): TableRecord[];
127
- addSegment(record: SegmentRecord): void;
128
191
  getSegment(id: string): SegmentRecord | undefined;
129
- listSegments(tableId?: string): SegmentRecord[];
130
- removeSegment(id: string): void;
192
+ listSegmentPage(afterId: string | null, limit: number): StoragePage<SegmentRecord, string>;
193
+ listTableSegmentPage(tableId: string, afterId: string | null, limit: number): StoragePage<SegmentRecord, string>;
194
+ removeAbortedSegment(id: string, expectedTransactionId: string): boolean;
195
+ adoptAbortedSegment(input: AdoptAbortedSegmentInput): TransactionRecord;
131
196
  reserveRowIds(tableId: string, count: number): RowIdRange;
132
197
  reserveAutoIncrement(tableId: string, columnId: string, count: number, atLeast?: bigint): RowIdRange;
133
198
  getExistingUniqueKeys(tableId: string, keyTokens: readonly string[]): string[];
199
+ /** O(1) staged UNIQUE usage for enclosing adapters' cross-accelerator admission. */
200
+ uniqueKeyBuildStagedUsage(): {
201
+ bytes: number;
202
+ entries: number;
203
+ };
204
+ beginUniqueKeyBuild(input: BeginUniqueKeyBuildInput): UniqueKeyBuildRecord;
205
+ getUniqueKeyBuild(buildId: string): UniqueKeyBuildRecord | undefined;
206
+ renewUniqueKeyBuild(input: RenewUniqueKeyBuildInput): UniqueKeyBuildRecord;
207
+ appendUniqueKeyBuildChunk(input: AppendUniqueKeyBuildChunkInput): UniqueKeyBuildRecord;
208
+ finishUniqueKeyBuild(input: FinishUniqueKeyBuildInput): TableRecord;
209
+ abortUniqueKeyBuild(input: AbortUniqueKeyBuildInput): boolean;
134
210
  getCurrentManifestVersion(): number | null;
135
211
  getCatalogProbe(): CatalogProbe;
136
- getQueryCatalogState(tableNames: readonly string[]): QueryCatalogState;
212
+ hasManifestBlocks(version: number | null, ids: readonly string[]): boolean[];
213
+ listManifestBlockPage(input: ListManifestBlockPageInput): ManifestBlockPage;
214
+ listRetiredManifestBlockPage(input: ListRetiredManifestBlockPageInput): ManifestBlockPage;
137
215
  getCurrentManifest(): Manifest | undefined;
138
216
  getManifest(version: number): Manifest | undefined;
139
- listManifests(): Manifest[];
140
217
  listManifestPage(afterVersion: number | null, limit: number): StoragePage<Manifest, number>;
141
- /**
142
- * RecordCore keeps resolved manifests. A tombstone below the first readable manifest is no
143
- * longer needed for delta resolution, but its narrowed block list remains the collector's
144
- * durable discovery record until every named payload has actually gone. Deleting it sooner
145
- * loses garbage left behind by a bounded planning pass.
146
- */
147
- removePrunedManifestRecords(): number[];
148
- publishManifest(input: PublishManifestInput): Manifest;
218
+ /** Removes only bounded summary tombstones; block discovery lives in provenance intervals. */
219
+ removePrunedManifestRecords(maxItems: number): number;
149
220
  beginTransaction(input: BeginTransactionInput): BeginTransactionResult;
150
221
  createTransaction(record: TransactionRecord): void;
151
222
  getTransaction(id: string): TransactionRecord | undefined;
152
223
  getTransactions(ids: readonly string[]): Array<TransactionRecord | undefined>;
153
- listTransactions(): TransactionRecord[];
154
224
  listTransactionPage(afterId: string | null, limit: number): StoragePage<TransactionRecord, string>;
155
225
  updateTransaction(id: string, expectedRevision: number, update: TransactionRecordUpdate): TransactionRecord;
226
+ renewTransaction(input: RenewTransactionInput): boolean;
227
+ abortTransactionIfExpired(input: AbortTransactionIfExpiredInput): TransactionRecord | undefined;
156
228
  /**
157
229
  * Validates and applies the record half of staging: the journal update and the segment
158
230
  * records. Block bytes are the enclosing store's to write — after this returns, in the same
@@ -165,7 +237,16 @@ export declare class RecordCore {
165
237
  * the check would misread them as duplicates.
166
238
  */
167
239
  blocksPrevalidated?: boolean;
240
+ /** Exact persisted byte lengths when prevalidated adapter bodies omit payload bytes. */
241
+ blockByteLengths?: ReadonlyMap<string, number>;
168
242
  }): TransactionRecord;
243
+ /**
244
+ * Runs the complete staging preflight without changing record state. Persistent adapters use
245
+ * this before allocating payload storage; the real apply repeats it under the same writer lock.
246
+ */
247
+ preflightTransactionArtifactStage(input: StageTransactionArtifactsInput): void;
248
+ /** Validates and applies the record/segment half of an atomic savepoint rewind. */
249
+ rollbackTransactionArtifacts(input: RollbackTransactionArtifactsInput): TransactionRecord;
169
250
  commitTransaction(input: CommitTransactionInput): ManifestSummary;
170
251
  /**
171
252
  * The single-shot write: begin or continue a transaction, journal the artifacts, and commit
@@ -176,24 +257,37 @@ export declare class RecordCore {
176
257
  writeTransaction(input: WriteTransactionInput, options?: {
177
258
  /** As on `stageTransactionArtifacts`: the enclosing store already checked the block ids. */
178
259
  blocksPrevalidated?: boolean;
260
+ /** Exact persisted lengths when an adapter replays placement-only block bodies. */
261
+ blockByteLengths?: ReadonlyMap<string, number>;
262
+ /** Exact persisted checksums when an adapter replays placement-only block bodies. */
263
+ blockChecksums?: ReadonlyMap<string, number>;
179
264
  }): ManifestSummary;
265
+ /** Complete, non-mutating preflight used before a persistent adapter allocates block bytes. */
266
+ preflightWriteTransaction(input: WriteTransactionInput): void;
180
267
  createLease(record: LeaseRecord): void;
181
268
  getLease(id: string): LeaseRecord | undefined;
182
269
  listLeases(): LeaseRecord[];
183
- renewLease(id: string, expectedRevision: number, expiresAt: string): LeaseRecord;
184
- moveLease(id: string, expectedRevision: number, manifestVersion: number | null, expiresAt: string): LeaseRecord;
270
+ listExpiredLeasePage(expiresAtCutoff: string, afterCursor: string | null, limit: number): StoragePage<LeaseRecord, string>;
271
+ renewLease(input: RenewLeaseInput): LeaseRecord;
272
+ moveLease(input: MoveLeaseInput): LeaseRecord;
185
273
  removeLeaseIfExpired(id: string, expectedRevision: number, expiresAtCutoff: string): boolean;
186
- removeLease(id: string): void;
274
+ removeLease(input: {
275
+ id: string;
276
+ ownerId: string;
277
+ }): boolean;
187
278
  createCompactionJob(record: CompactionJobRecord): void;
188
279
  getCompactionJob(id: string): CompactionJobRecord | undefined;
189
280
  listCompactionJobs(tableId?: string): CompactionJobRecord[];
190
281
  listCompactionJobPage(afterId: string | null, limit: number): StoragePage<CompactionJobRecord, string>;
191
282
  updateCompactionJob(id: string, expectedRevision: number, update: CompactionJobRecordUpdate): CompactionJobRecord;
192
283
  cancelCompactionJob(id: string, expectedRevision: number, cancelledAt: string): CompactionJobRecord;
193
- removeCompactionJob(id: string): void;
284
+ removeCompactionJob(id: string): boolean;
285
+ canRemoveCompactionJob(id: string): boolean;
194
286
  createGarbageCollectionJob(input: CreateGarbageCollectionJobInput): GarbageCollectionJobRecord;
287
+ updateGarbageCollectionPlanning(input: UpdateGarbageCollectionPlanningInput): GarbageCollectionJobRecord;
195
288
  getGarbageCollectionJob(id: string): GarbageCollectionJobRecord | undefined;
196
289
  listGarbageCollectionJobs(): GarbageCollectionJobRecord[];
290
+ listGarbageCollectionJobPage(afterId: string | null, limit: number): StoragePage<GarbageCollectionJobRecord, string>;
197
291
  /**
198
292
  * Advances the job and mutates every record it reclaims. Physical block bytes are the
199
293
  * caller's to delete afterwards, from the result's `reclaimedBlockIds` — in the same atomic
@@ -202,32 +296,55 @@ export declare class RecordCore {
202
296
  runGarbageCollectionStep(input: RunGarbageCollectionStepInput): GarbageCollectionStepResult;
203
297
  removeGarbageCollectionJob(id: string): void;
204
298
  /**
205
- * Copies the current version out as a portable snapshot. The caller provides the block bytes
206
- * and the atomicity run this where no commit can interleave.
299
+ * Streams the canonical metadata half of a framed snapshot while the enclosing adapter holds
300
+ * its writer queue. The iterator never builds a database-sized array: ordered indexes yield
301
+ * one record at a time and UNIQUE membership is split into bounded immutable generations.
302
+ * Posting generations are substrate-specific (OPFS keeps bases outside this core) and are
303
+ * therefore emitted by the adapter after these five record families.
207
304
  *
208
- * Only blocks the current manifest still points at are copied, which drops every superseded
209
- * block a compaction left behind, and only full-text bases that already cover this exact
210
- * version are carried; any other indexed column is exported as `invalid` so the loaded
211
- * database rebuilds it. That costs a rebuild, never a wrong answer — the index is a pruning
212
- * accelerator and the scan re-verifies every candidate.
305
+ * @internal The returned records alias immutable-at-the-call-boundary core state. Exhaust the
306
+ * iterator before releasing the enclosing writer lock.
213
307
  */
214
- exportSnapshot(readBlockBytes: (id: string) => Uint8Array | undefined): DatabaseSnapshot;
308
+ snapshotFrameMetadataItems(): IterableIterator<SnapshotCatalogItem | SnapshotSegmentItem | SnapshotTransactionItem | SnapshotUniqueItem>;
215
309
  /**
216
- * The record half of `exportSnapshot`, for stores whose block bytes need asynchronous reads:
217
- * capture the records synchronously at one version, then read the immutable (and pinned)
218
- * block files at leisure.
310
+ * Streams complete current posting generations in canonical storage-column/term order.
311
+ * The merge retains only one term's row map and one bounded output chunk; it never builds a
312
+ * second database-sized postings array. A cheap first pass derives exact descriptor totals,
313
+ * then a second pass yields the immutable chunks.
314
+ *
315
+ * @internal Memory-backed framed snapshot export. OPFS streams its extent-backed bases.
219
316
  */
220
- exportSnapshotRecords(): {
221
- records: Omit<DatabaseSnapshot, "blocks">;
222
- blockIds: string[];
317
+ snapshotFramePostingItems(): IterableIterator<SnapshotPostingItem>;
318
+ /** Exact bounded snapshot block summary; payload IDs remain in the provenance page index. */
319
+ snapshotFrameManifest(): ManifestSummary;
320
+ /** O(1) counters for diagnostics; callers never need to clone the full durable state. */
321
+ storageRecordStats(): {
322
+ manifestCount: number;
323
+ transactionCount: number;
324
+ segmentCount: number;
325
+ tableCount: number;
326
+ leaseCount: number;
327
+ compactionJobCount: number;
328
+ garbageCollectionJobCount: number;
329
+ rowCounterCount: number;
330
+ autoIncrementCounterCount: number;
331
+ ftsBaseCount: number;
332
+ ftsDeltaCount: number;
333
+ uniqueNamespaceCount: number;
334
+ uniqueKeyBuildCount: number;
335
+ tempOwnerCount: number;
336
+ liveBlockCount: number;
337
+ liveBlockBytes: number;
223
338
  };
224
- /** Refuses to load over an existing database; see `loadSnapshot` for the load itself. */
225
- importSnapshot(snapshot: DatabaseSnapshot, storeBlockBytes: (id: string, bytes: Uint8Array) => void): void;
226
- loadSnapshot(snapshot: DatabaseSnapshot, storeBlockBytes: (id: string, bytes: Uint8Array) => void): void;
227
- /** The record half of a snapshot load; block bytes are the caller's, ids theirs to name. */
228
- loadSnapshotRecords(snapshot: Omit<DatabaseSnapshot, "blocks"> & {
229
- blocks?: undefined;
230
- }, blockIds: readonly string[]): void;
339
+ /**
340
+ * Atomically promotes one already-decoded framed snapshot generation. The caller supplies a
341
+ * streaming iterable over metadata pages and the final physical block identities; this method
342
+ * builds a disposable core, validates every cross-reference, then swaps state only after the
343
+ * complete generation proves self-consistent.
344
+ *
345
+ * @internal Framed adapters call this only at the durable finish boundary.
346
+ */
347
+ loadSnapshotFrameItems(header: SnapshotFrameStreamHeader, items: Iterable<SnapshotMetadataItem>, blocks: Iterable<Pick<ManifestBlockRecord, "blockId" | "byteLength" | "checksum">>): void;
231
348
  /**
232
349
  * The complete record state as one value — the checkpoint payload of a log-structured store.
233
350
  * Everything `load` needs to reproduce this core exactly, including operational state the
@@ -244,9 +361,19 @@ export declare class RecordCore {
244
361
  load(state: RecordCoreState): void;
245
362
  }
246
363
  export declare function validateId(id: string): void;
364
+ /** Validates payload ownership at the public storage boundary without copying the hot path. */
365
+ export declare function validateBlockWriteBytes(bytes: unknown): asserts bytes is Uint8Array;
366
+ export declare function validateFtsBaseInput(input: {
367
+ coversVersion: number;
368
+ chunks: FtsPosting[][];
369
+ totalTokens: number;
370
+ }, label: string): void;
371
+ /** Validates each canonical term-sorted postings chunk without copying it. */
372
+ export declare function validateFtsPostingChunks(chunks: unknown, label: string): number;
373
+ export declare function validateSegmentRuntimeRecord(value: unknown, label: string): SegmentRecord;
247
374
  export declare function validateAutoIncrementReservation(count: number, atLeast: bigint | undefined): void;
248
375
  export declare function validateBeginTransactionInput(input: BeginTransactionInput): void;
249
376
  export declare function validateLeaseExpiration(expiresAt: string): void;
250
377
  export declare function validateTempRunPage(page: TempRunPage): void;
251
378
  export declare function validateTempRunPageIdentity(ownerId: string, runId: string, pageIndex: number): void;
252
- //# sourceMappingURL=record-core.d.ts.map
379
+ export {};