@minnowdb/core 0.3.0 → 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 (276) hide show
  1. package/README.md +4 -2
  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 +0 -1
  21. package/dist/engine/artifact-cache.js +0 -1
  22. package/dist/engine/batch.d.ts +5 -2
  23. package/dist/engine/batch.js +0 -1
  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 +5 -6
  29. package/dist/engine/catalog.js +5 -5
  30. package/dist/engine/client.d.ts +27 -7
  31. package/dist/engine/client.js +197 -31
  32. package/dist/engine/database.d.ts +161 -38
  33. package/dist/engine/database.js +4320 -1523
  34. package/dist/engine/defaults.d.ts +0 -1
  35. package/dist/engine/defaults.js +2 -4
  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 +39 -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 -11
  43. package/dist/engine/index.js +12 -10
  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 +499 -129
  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 +4 -4
  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 +0 -1
  59. package/dist/engine/query-cache.js +4 -4
  60. package/dist/engine/query.d.ts +4 -7
  61. package/dist/engine/query.js +348 -155
  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 +1 -2
  65. package/dist/engine/schema-wire.js +0 -1
  66. package/dist/engine/schema.d.ts +3 -8
  67. package/dist/engine/schema.js +41 -24
  68. package/dist/engine/sort-keys.d.ts +0 -1
  69. package/dist/engine/sort-keys.js +2 -2
  70. package/dist/engine/sql-domains.d.ts +6 -1
  71. package/dist/engine/sql-domains.js +209 -45
  72. package/dist/engine/sql-driver.d.ts +2 -2
  73. package/dist/engine/sql-driver.js +0 -1
  74. package/dist/engine/sql-json.d.ts +0 -1
  75. package/dist/engine/sql-json.js +53 -7
  76. package/dist/engine/sql-semantics.d.ts +8 -5
  77. package/dist/engine/sql-semantics.js +427 -65
  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 +7 -1
  81. package/dist/engine/vector.js +202 -58
  82. package/dist/engine/worker-host.d.ts +8 -2
  83. package/dist/engine/worker-host.js +616 -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 +0 -1
  91. package/dist/plan/index.js +0 -1
  92. package/dist/storage/index.d.ts +1 -1
  93. package/dist/storage/index.js +1 -1
  94. package/dist/storage/indexeddb.d.ts +74 -65
  95. package/dist/storage/indexeddb.js +12301 -2076
  96. package/dist/storage/memory.d.ts +56 -66
  97. package/dist/storage/memory.js +1004 -139
  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 +403 -91
  103. package/dist/storage/opfs/leader.js +4306 -602
  104. package/dist/storage/opfs/rpc.d.ts +15 -3
  105. package/dist/storage/opfs/rpc.js +223 -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 +26 -121
  109. package/dist/storage/opfs/store.js +436 -388
  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 -99
  115. package/dist/storage/snapshot.js +33 -309
  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 +3 -4
  119. package/dist/storage/toolkit/index.js +27 -3
  120. package/dist/storage/toolkit/record-core.d.ts +174 -61
  121. package/dist/storage/toolkit/record-core.js +5401 -849
  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 +4 -6
  127. package/dist/storage/toolkit/wire.js +80 -25
  128. package/dist/storage/types.d.ts +1271 -218
  129. package/dist/storage/types.js +1471 -138
  130. package/dist/testing/block-store-conformance.d.ts +0 -1
  131. package/dist/testing/block-store-conformance.js +877 -138
  132. package/dist/testing/index.d.ts +42 -31
  133. package/dist/testing/index.js +100 -68
  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 +0 -1
  137. package/dist/testing/simulator.js +43 -12
  138. package/dist/testing/sqllogictest.d.ts +0 -1
  139. package/dist/testing/sqllogictest.js +0 -1
  140. package/dist/transactions/index.d.ts +81 -20
  141. package/dist/transactions/index.js +1050 -268
  142. package/dist/worker-protocol/index.d.ts +3 -2
  143. package/dist/worker-protocol/index.js +2 -5
  144. package/package.json +49 -1
  145. package/dist/block-format/block.d.ts.map +0 -1
  146. package/dist/block-format/block.js.map +0 -1
  147. package/dist/block-format/checksum.d.ts.map +0 -1
  148. package/dist/block-format/checksum.js.map +0 -1
  149. package/dist/block-format/codecs.d.ts.map +0 -1
  150. package/dist/block-format/codecs.js.map +0 -1
  151. package/dist/block-format/column.d.ts.map +0 -1
  152. package/dist/block-format/column.js.map +0 -1
  153. package/dist/block-format/index.d.ts.map +0 -1
  154. package/dist/block-format/index.js.map +0 -1
  155. package/dist/block-format/physical.d.ts.map +0 -1
  156. package/dist/block-format/physical.js.map +0 -1
  157. package/dist/block-format/types.d.ts.map +0 -1
  158. package/dist/block-format/types.js.map +0 -1
  159. package/dist/engine/artifact-cache.d.ts.map +0 -1
  160. package/dist/engine/artifact-cache.js.map +0 -1
  161. package/dist/engine/batch.d.ts.map +0 -1
  162. package/dist/engine/batch.js.map +0 -1
  163. package/dist/engine/buffered-writer.d.ts.map +0 -1
  164. package/dist/engine/buffered-writer.js.map +0 -1
  165. package/dist/engine/catalog.d.ts.map +0 -1
  166. package/dist/engine/catalog.js.map +0 -1
  167. package/dist/engine/client.d.ts.map +0 -1
  168. package/dist/engine/client.js.map +0 -1
  169. package/dist/engine/coordinator.d.ts +0 -17
  170. package/dist/engine/coordinator.d.ts.map +0 -1
  171. package/dist/engine/coordinator.js +0 -60
  172. package/dist/engine/coordinator.js.map +0 -1
  173. package/dist/engine/database.d.ts.map +0 -1
  174. package/dist/engine/database.js.map +0 -1
  175. package/dist/engine/defaults.d.ts.map +0 -1
  176. package/dist/engine/defaults.js.map +0 -1
  177. package/dist/engine/errors.d.ts.map +0 -1
  178. package/dist/engine/errors.js.map +0 -1
  179. package/dist/engine/fts.d.ts.map +0 -1
  180. package/dist/engine/fts.js.map +0 -1
  181. package/dist/engine/group-index.d.ts.map +0 -1
  182. package/dist/engine/group-index.js.map +0 -1
  183. package/dist/engine/index.d.ts.map +0 -1
  184. package/dist/engine/index.js.map +0 -1
  185. package/dist/engine/join-index.d.ts.map +0 -1
  186. package/dist/engine/join-index.js.map +0 -1
  187. package/dist/engine/live.d.ts.map +0 -1
  188. package/dist/engine/live.js.map +0 -1
  189. package/dist/engine/memory.d.ts.map +0 -1
  190. package/dist/engine/memory.js.map +0 -1
  191. package/dist/engine/optimizer.d.ts.map +0 -1
  192. package/dist/engine/optimizer.js.map +0 -1
  193. package/dist/engine/query-cache.d.ts.map +0 -1
  194. package/dist/engine/query-cache.js.map +0 -1
  195. package/dist/engine/query.d.ts.map +0 -1
  196. package/dist/engine/query.js.map +0 -1
  197. package/dist/engine/result-wire.d.ts.map +0 -1
  198. package/dist/engine/result-wire.js.map +0 -1
  199. package/dist/engine/schema-wire.d.ts.map +0 -1
  200. package/dist/engine/schema-wire.js.map +0 -1
  201. package/dist/engine/schema.d.ts.map +0 -1
  202. package/dist/engine/schema.js.map +0 -1
  203. package/dist/engine/sort-keys.d.ts.map +0 -1
  204. package/dist/engine/sort-keys.js.map +0 -1
  205. package/dist/engine/sql-domains.d.ts.map +0 -1
  206. package/dist/engine/sql-domains.js.map +0 -1
  207. package/dist/engine/sql-driver.d.ts.map +0 -1
  208. package/dist/engine/sql-driver.js.map +0 -1
  209. package/dist/engine/sql-json.d.ts.map +0 -1
  210. package/dist/engine/sql-json.js.map +0 -1
  211. package/dist/engine/sql-semantics.d.ts.map +0 -1
  212. package/dist/engine/sql-semantics.js.map +0 -1
  213. package/dist/engine/vector.d.ts.map +0 -1
  214. package/dist/engine/vector.js.map +0 -1
  215. package/dist/engine/worker-host.d.ts.map +0 -1
  216. package/dist/engine/worker-host.js.map +0 -1
  217. package/dist/engine/worker.d.ts.map +0 -1
  218. package/dist/engine/worker.js.map +0 -1
  219. package/dist/index.d.ts.map +0 -1
  220. package/dist/index.js.map +0 -1
  221. package/dist/plan/index.d.ts.map +0 -1
  222. package/dist/plan/index.js.map +0 -1
  223. package/dist/storage/fixture-shape.d.ts +0 -42
  224. package/dist/storage/fixture-shape.d.ts.map +0 -1
  225. package/dist/storage/fixture-shape.js +0 -146
  226. package/dist/storage/fixture-shape.js.map +0 -1
  227. package/dist/storage/index.d.ts.map +0 -1
  228. package/dist/storage/index.js.map +0 -1
  229. package/dist/storage/indexeddb.d.ts.map +0 -1
  230. package/dist/storage/indexeddb.js.map +0 -1
  231. package/dist/storage/memory.d.ts.map +0 -1
  232. package/dist/storage/memory.js.map +0 -1
  233. package/dist/storage/opfs/files.d.ts.map +0 -1
  234. package/dist/storage/opfs/files.js.map +0 -1
  235. package/dist/storage/opfs/index.d.ts.map +0 -1
  236. package/dist/storage/opfs/index.js.map +0 -1
  237. package/dist/storage/opfs/leader.d.ts.map +0 -1
  238. package/dist/storage/opfs/leader.js.map +0 -1
  239. package/dist/storage/opfs/rpc.d.ts.map +0 -1
  240. package/dist/storage/opfs/rpc.js.map +0 -1
  241. package/dist/storage/opfs/store.d.ts.map +0 -1
  242. package/dist/storage/opfs/store.js.map +0 -1
  243. package/dist/storage/snapshot.d.ts.map +0 -1
  244. package/dist/storage/snapshot.js.map +0 -1
  245. package/dist/storage/toolkit/extents.d.ts.map +0 -1
  246. package/dist/storage/toolkit/extents.js.map +0 -1
  247. package/dist/storage/toolkit/index.d.ts.map +0 -1
  248. package/dist/storage/toolkit/index.js.map +0 -1
  249. package/dist/storage/toolkit/record-core.d.ts.map +0 -1
  250. package/dist/storage/toolkit/record-core.js.map +0 -1
  251. package/dist/storage/toolkit/sync-file.d.ts.map +0 -1
  252. package/dist/storage/toolkit/sync-file.js.map +0 -1
  253. package/dist/storage/toolkit/wal.d.ts.map +0 -1
  254. package/dist/storage/toolkit/wal.js.map +0 -1
  255. package/dist/storage/toolkit/wire.d.ts.map +0 -1
  256. package/dist/storage/toolkit/wire.js.map +0 -1
  257. package/dist/storage/types.d.ts.map +0 -1
  258. package/dist/storage/types.js.map +0 -1
  259. package/dist/testing/block-store-conformance.d.ts.map +0 -1
  260. package/dist/testing/block-store-conformance.js.map +0 -1
  261. package/dist/testing/index.d.ts.map +0 -1
  262. package/dist/testing/index.js.map +0 -1
  263. package/dist/testing/opfs-shim.d.ts.map +0 -1
  264. package/dist/testing/opfs-shim.js.map +0 -1
  265. package/dist/testing/seeds.d.ts +0 -11
  266. package/dist/testing/seeds.d.ts.map +0 -1
  267. package/dist/testing/seeds.js +0 -50
  268. package/dist/testing/seeds.js.map +0 -1
  269. package/dist/testing/simulator.d.ts.map +0 -1
  270. package/dist/testing/simulator.js.map +0 -1
  271. package/dist/testing/sqllogictest.d.ts.map +0 -1
  272. package/dist/testing/sqllogictest.js.map +0 -1
  273. package/dist/transactions/index.d.ts.map +0 -1
  274. package/dist/transactions/index.js.map +0 -1
  275. package/dist/worker-protocol/index.d.ts.map +0 -1
  276. 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 FtsPostingQuery, 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 SecondaryIndexRecord, 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,29 +132,19 @@ 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
- secondaryIndexes?: Record<string, SecondaryIndexRecord> | null;
82
- expectedManifestVersion?: {
83
- value: number | null;
84
- };
85
- uniqueKeySeed?: {
86
- namespaceId: string;
87
- keyTokens: readonly string[];
88
- };
89
- triggers?: TriggerRecord[] | null;
90
- }): TableRecord;
91
- 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;
92
141
  writeFtsBase(tableId: string, columnId: string, input: {
93
142
  coversVersion: number;
94
143
  chunks: FtsPosting[][];
95
144
  totalTokens: number;
96
145
  }): void;
97
146
  removeFtsColumn(tableId: string, columnId: string): void;
98
- readFtsCandidates(tableId: string, columnId: string, terms: readonly FtsPostingQuery[], upToVersion: number): FtsCandidates & {
147
+ readFtsCandidates(tableId: string, columnId: string, terms: readonly FtsPostingQuery[], upToVersion: number, maxRowIds?: number): FtsCandidates & {
99
148
  deltaChunkCount: number;
100
149
  totalTokens: number;
101
150
  coversVersion: number;
@@ -111,8 +160,9 @@ export declare class RecordCore {
111
160
  deltaChunkCount: number;
112
161
  deltaTokens: number;
113
162
  };
114
- readFtsPostings(tableId: string, columnId: string, upToVersion: number): {
163
+ readFtsPostings(tableId: string, columnId: string, upToVersion: number, maxRowIds?: number, maxRetainedBytes?: number): {
115
164
  postings: FtsPosting[];
165
+ overflow: boolean;
116
166
  deltaChunkCount: number;
117
167
  coversVersion: number;
118
168
  hasBase: boolean;
@@ -130,43 +180,51 @@ export declare class RecordCore {
130
180
  job: GarbageCollectionJobRecord;
131
181
  prunedManifestVersions: readonly number[];
132
182
  reclaimedSegmentIds: readonly string[];
133
- reclaimedTransactionIds?: readonly string[];
183
+ reclaimedBlockIds: readonly string[];
184
+ reclaimedTransactionIds: readonly string[];
134
185
  updatedAt: string;
135
186
  }): void;
136
187
  getTableByName(name: string): TableRecord | undefined;
137
188
  /** For stores that compose lookups over their own overridable methods. */
138
189
  getTableIdByName(name: string): string | undefined;
139
190
  listTables(): TableRecord[];
140
- addSegment(record: SegmentRecord): void;
141
191
  getSegment(id: string): SegmentRecord | undefined;
142
- listSegments(tableId?: string): SegmentRecord[];
143
192
  listSegmentPage(afterId: string | null, limit: number): StoragePage<SegmentRecord, string>;
144
- removeSegment(id: string): void;
193
+ listTableSegmentPage(tableId: string, afterId: string | null, limit: number): StoragePage<SegmentRecord, string>;
194
+ removeAbortedSegment(id: string, expectedTransactionId: string): boolean;
195
+ adoptAbortedSegment(input: AdoptAbortedSegmentInput): TransactionRecord;
145
196
  reserveRowIds(tableId: string, count: number): RowIdRange;
146
197
  reserveAutoIncrement(tableId: string, columnId: string, count: number, atLeast?: bigint): RowIdRange;
147
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;
148
210
  getCurrentManifestVersion(): number | null;
149
211
  getCatalogProbe(): CatalogProbe;
150
- getQueryCatalogState(tableNames: readonly string[]): QueryCatalogState;
212
+ hasManifestBlocks(version: number | null, ids: readonly string[]): boolean[];
213
+ listManifestBlockPage(input: ListManifestBlockPageInput): ManifestBlockPage;
214
+ listRetiredManifestBlockPage(input: ListRetiredManifestBlockPageInput): ManifestBlockPage;
151
215
  getCurrentManifest(): Manifest | undefined;
152
216
  getManifest(version: number): Manifest | undefined;
153
- listManifests(): Manifest[];
154
217
  listManifestPage(afterVersion: number | null, limit: number): StoragePage<Manifest, number>;
155
- /**
156
- * RecordCore keeps resolved manifests. A tombstone below the first readable manifest is no
157
- * longer needed for delta resolution, but its narrowed block list remains the collector's
158
- * durable discovery record until every named payload has actually gone. Deleting it sooner
159
- * loses garbage left behind by a bounded planning pass.
160
- */
161
- removePrunedManifestRecords(): number[];
162
- publishManifest(input: PublishManifestInput): Manifest;
218
+ /** Removes only bounded summary tombstones; block discovery lives in provenance intervals. */
219
+ removePrunedManifestRecords(maxItems: number): number;
163
220
  beginTransaction(input: BeginTransactionInput): BeginTransactionResult;
164
221
  createTransaction(record: TransactionRecord): void;
165
222
  getTransaction(id: string): TransactionRecord | undefined;
166
223
  getTransactions(ids: readonly string[]): Array<TransactionRecord | undefined>;
167
- listTransactions(): TransactionRecord[];
168
224
  listTransactionPage(afterId: string | null, limit: number): StoragePage<TransactionRecord, string>;
169
225
  updateTransaction(id: string, expectedRevision: number, update: TransactionRecordUpdate): TransactionRecord;
226
+ renewTransaction(input: RenewTransactionInput): boolean;
227
+ abortTransactionIfExpired(input: AbortTransactionIfExpiredInput): TransactionRecord | undefined;
170
228
  /**
171
229
  * Validates and applies the record half of staging: the journal update and the segment
172
230
  * records. Block bytes are the enclosing store's to write — after this returns, in the same
@@ -179,7 +237,16 @@ export declare class RecordCore {
179
237
  * the check would misread them as duplicates.
180
238
  */
181
239
  blocksPrevalidated?: boolean;
240
+ /** Exact persisted byte lengths when prevalidated adapter bodies omit payload bytes. */
241
+ blockByteLengths?: ReadonlyMap<string, number>;
182
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;
183
250
  commitTransaction(input: CommitTransactionInput): ManifestSummary;
184
251
  /**
185
252
  * The single-shot write: begin or continue a transaction, journal the artifacts, and commit
@@ -190,24 +257,37 @@ export declare class RecordCore {
190
257
  writeTransaction(input: WriteTransactionInput, options?: {
191
258
  /** As on `stageTransactionArtifacts`: the enclosing store already checked the block ids. */
192
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>;
193
264
  }): ManifestSummary;
265
+ /** Complete, non-mutating preflight used before a persistent adapter allocates block bytes. */
266
+ preflightWriteTransaction(input: WriteTransactionInput): void;
194
267
  createLease(record: LeaseRecord): void;
195
268
  getLease(id: string): LeaseRecord | undefined;
196
269
  listLeases(): LeaseRecord[];
197
- renewLease(id: string, expectedRevision: number, expiresAt: string): LeaseRecord;
198
- 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;
199
273
  removeLeaseIfExpired(id: string, expectedRevision: number, expiresAtCutoff: string): boolean;
200
- removeLease(id: string): void;
274
+ removeLease(input: {
275
+ id: string;
276
+ ownerId: string;
277
+ }): boolean;
201
278
  createCompactionJob(record: CompactionJobRecord): void;
202
279
  getCompactionJob(id: string): CompactionJobRecord | undefined;
203
280
  listCompactionJobs(tableId?: string): CompactionJobRecord[];
204
281
  listCompactionJobPage(afterId: string | null, limit: number): StoragePage<CompactionJobRecord, string>;
205
282
  updateCompactionJob(id: string, expectedRevision: number, update: CompactionJobRecordUpdate): CompactionJobRecord;
206
283
  cancelCompactionJob(id: string, expectedRevision: number, cancelledAt: string): CompactionJobRecord;
207
- removeCompactionJob(id: string): void;
284
+ removeCompactionJob(id: string): boolean;
285
+ canRemoveCompactionJob(id: string): boolean;
208
286
  createGarbageCollectionJob(input: CreateGarbageCollectionJobInput): GarbageCollectionJobRecord;
287
+ updateGarbageCollectionPlanning(input: UpdateGarbageCollectionPlanningInput): GarbageCollectionJobRecord;
209
288
  getGarbageCollectionJob(id: string): GarbageCollectionJobRecord | undefined;
210
289
  listGarbageCollectionJobs(): GarbageCollectionJobRecord[];
290
+ listGarbageCollectionJobPage(afterId: string | null, limit: number): StoragePage<GarbageCollectionJobRecord, string>;
211
291
  /**
212
292
  * Advances the job and mutates every record it reclaims. Physical block bytes are the
213
293
  * caller's to delete afterwards, from the result's `reclaimedBlockIds` — in the same atomic
@@ -216,32 +296,55 @@ export declare class RecordCore {
216
296
  runGarbageCollectionStep(input: RunGarbageCollectionStepInput): GarbageCollectionStepResult;
217
297
  removeGarbageCollectionJob(id: string): void;
218
298
  /**
219
- * Copies the current version out as a portable snapshot. The caller provides the block bytes
220
- * 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.
221
304
  *
222
- * Only blocks the current manifest still points at are copied, which drops every superseded
223
- * block a compaction left behind, and only full-text bases that already cover this exact
224
- * version are carried; any other indexed column is exported as `invalid` so the loaded
225
- * database rebuilds it. That costs a rebuild, never a wrong answer — the index is a pruning
226
- * 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.
227
307
  */
228
- exportSnapshot(readBlockBytes: (id: string) => Uint8Array | undefined): DatabaseSnapshot;
308
+ snapshotFrameMetadataItems(): IterableIterator<SnapshotCatalogItem | SnapshotSegmentItem | SnapshotTransactionItem | SnapshotUniqueItem>;
229
309
  /**
230
- * The record half of `exportSnapshot`, for stores whose block bytes need asynchronous reads:
231
- * capture the records synchronously at one version, then read the immutable (and pinned)
232
- * 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.
233
316
  */
234
- exportSnapshotRecords(): {
235
- records: Omit<DatabaseSnapshot, "blocks">;
236
- 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;
237
338
  };
238
- /** Refuses to load over an existing database; see `loadSnapshot` for the load itself. */
239
- importSnapshot(snapshot: DatabaseSnapshot, storeBlockBytes: (id: string, bytes: Uint8Array) => void): void;
240
- loadSnapshot(snapshot: DatabaseSnapshot, storeBlockBytes: (id: string, bytes: Uint8Array) => void): void;
241
- /** The record half of a snapshot load; block bytes are the caller's, ids theirs to name. */
242
- loadSnapshotRecords(snapshot: Omit<DatabaseSnapshot, "blocks"> & {
243
- blocks?: undefined;
244
- }, 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;
245
348
  /**
246
349
  * The complete record state as one value — the checkpoint payload of a log-structured store.
247
350
  * Everything `load` needs to reproduce this core exactly, including operational state the
@@ -258,9 +361,19 @@ export declare class RecordCore {
258
361
  load(state: RecordCoreState): void;
259
362
  }
260
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;
261
374
  export declare function validateAutoIncrementReservation(count: number, atLeast: bigint | undefined): void;
262
375
  export declare function validateBeginTransactionInput(input: BeginTransactionInput): void;
263
376
  export declare function validateLeaseExpiration(expiresAt: string): void;
264
377
  export declare function validateTempRunPage(page: TempRunPage): void;
265
378
  export declare function validateTempRunPageIdentity(ownerId: string, runId: string, pageIndex: number): void;
266
- //# sourceMappingURL=record-core.d.ts.map
379
+ export {};