@peerbit/native-backbone 0.1.4 → 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.
- package/README.md +31 -0
- package/dist/src/durability/codec.d.ts +86 -0
- package/dist/src/durability/codec.d.ts.map +1 -0
- package/dist/src/durability/codec.js +365 -0
- package/dist/src/durability/codec.js.map +1 -0
- package/dist/src/durability/lease.d.ts +59 -0
- package/dist/src/durability/lease.d.ts.map +1 -0
- package/dist/src/durability/lease.js +48 -0
- package/dist/src/durability/lease.js.map +1 -0
- package/dist/src/durability/memory-storage.d.ts +37 -0
- package/dist/src/durability/memory-storage.d.ts.map +1 -0
- package/dist/src/durability/memory-storage.js +436 -0
- package/dist/src/durability/memory-storage.js.map +1 -0
- package/dist/src/durability/node-lease.d.ts +14 -0
- package/dist/src/durability/node-lease.d.ts.map +1 -0
- package/dist/src/durability/node-lease.js +214 -0
- package/dist/src/durability/node-lease.js.map +1 -0
- package/dist/src/durability/node-storage.d.ts +76 -0
- package/dist/src/durability/node-storage.d.ts.map +1 -0
- package/dist/src/durability/node-storage.js +1813 -0
- package/dist/src/durability/node-storage.js.map +1 -0
- package/dist/src/durability/storage.d.ts +224 -0
- package/dist/src/durability/storage.d.ts.map +1 -0
- package/dist/src/durability/storage.js +343 -0
- package/dist/src/durability/storage.js.map +1 -0
- package/dist/src/index.d.ts +93 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +717 -199
- package/dist/src/index.js.map +1 -1
- package/dist/wasm/README.md +31 -0
- package/dist/wasm/native_backbone.d.ts +131 -115
- package/dist/wasm/native_backbone.js +96 -0
- package/dist/wasm/native_backbone_bg.wasm +0 -0
- package/dist/wasm/native_backbone_bg.wasm.d.ts +119 -115
- package/package.json +4 -3
- package/src/durability/codec.ts +683 -0
- package/src/durability/lease.ts +87 -0
- package/src/durability/memory-storage.ts +593 -0
- package/src/durability/node-lease.ts +293 -0
- package/src/durability/node-storage.ts +2798 -0
- package/src/durability/storage.ts +682 -0
- package/src/durability.rs +1872 -0
- package/src/index.ts +1392 -735
- package/src/lib.rs +1 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { NATIVE_DURABILITY_MAX_U64, NATIVE_DURABILITY_MAX_WRITER_ID_BYTES, } from "./lease.js";
|
|
2
|
+
export const NATIVE_DURABILITY_STORAGE_VERSION = 1;
|
|
3
|
+
export const NATIVE_DURABILITY_MAX_TRANSACTION_ID_BYTES = 1024;
|
|
4
|
+
export class NativeDurabilityStorageUnsupportedError extends Error {
|
|
5
|
+
code = "ERR_NATIVE_DURABILITY_STORAGE_UNSUPPORTED";
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "NativeDurabilityStorageUnsupportedError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class NativeDurabilityMigrationRequiredError extends Error {
|
|
12
|
+
directory;
|
|
13
|
+
code = "ERR_NATIVE_DURABILITY_MIGRATION_REQUIRED";
|
|
14
|
+
constructor(directory) {
|
|
15
|
+
super(`Native crash-safe durability requires an explicit migration for nonempty program directory: ${directory}`);
|
|
16
|
+
this.directory = directory;
|
|
17
|
+
this.name = "NativeDurabilityMigrationRequiredError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class NativeDurabilityStorageClosedError extends Error {
|
|
21
|
+
code = "ERR_NATIVE_DURABILITY_STORAGE_CLOSED";
|
|
22
|
+
constructor() {
|
|
23
|
+
super("Native durability storage is closed");
|
|
24
|
+
this.name = "NativeDurabilityStorageClosedError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class NativeDurabilityStorageCorruptionError extends Error {
|
|
28
|
+
cause;
|
|
29
|
+
code = "ERR_NATIVE_DURABILITY_STORAGE_CORRUPTION";
|
|
30
|
+
constructor(message, cause) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.cause = cause;
|
|
33
|
+
this.name = "NativeDurabilityStorageCorruptionError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class NativeDurabilityDigestMismatchError extends Error {
|
|
37
|
+
subject;
|
|
38
|
+
code = "ERR_NATIVE_DURABILITY_DIGEST_MISMATCH";
|
|
39
|
+
constructor(subject) {
|
|
40
|
+
super(`Native durability digest mismatch for ${subject}`);
|
|
41
|
+
this.subject = subject;
|
|
42
|
+
this.name = "NativeDurabilityDigestMismatchError";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class NativeDurabilityJournalOffsetConflictError extends Error {
|
|
46
|
+
expectedOffset;
|
|
47
|
+
actualOffset;
|
|
48
|
+
code = "ERR_NATIVE_DURABILITY_JOURNAL_OFFSET_CONFLICT";
|
|
49
|
+
constructor(expectedOffset, actualOffset) {
|
|
50
|
+
super(`Native durability journal offset conflict: expected ${expectedOffset}, found ${actualOffset}`);
|
|
51
|
+
this.expectedOffset = expectedOffset;
|
|
52
|
+
this.actualOffset = actualOffset;
|
|
53
|
+
this.name = "NativeDurabilityJournalOffsetConflictError";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class NativeDurabilityOutcomeUnknownError extends Error {
|
|
57
|
+
operation;
|
|
58
|
+
transactionId;
|
|
59
|
+
txSequence;
|
|
60
|
+
cause;
|
|
61
|
+
code = "ERR_NATIVE_DURABILITY_OUTCOME_UNKNOWN";
|
|
62
|
+
outcome = "unknown";
|
|
63
|
+
constructor(operation, transactionId, txSequence, cause) {
|
|
64
|
+
super(`Native durability ${operation} outcome is unknown for transaction ${transactionId}`);
|
|
65
|
+
this.operation = operation;
|
|
66
|
+
this.transactionId = transactionId;
|
|
67
|
+
this.txSequence = txSequence;
|
|
68
|
+
this.cause = cause;
|
|
69
|
+
this.name = "NativeDurabilityOutcomeUnknownError";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class NativeDurabilityIncompleteTailMismatchError extends Error {
|
|
73
|
+
code = "ERR_NATIVE_DURABILITY_INCOMPLETE_TAIL_MISMATCH";
|
|
74
|
+
constructor(message) {
|
|
75
|
+
super(message);
|
|
76
|
+
this.name = "NativeDurabilityIncompleteTailMismatchError";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export const copyNativeDurabilityBytes = (bytes) => new Uint8Array(bytes);
|
|
80
|
+
export const nativeDurabilityBytesEqual = (left, right) => {
|
|
81
|
+
if (left.byteLength !== right.byteLength)
|
|
82
|
+
return false;
|
|
83
|
+
for (let i = 0; i < left.byteLength; i++) {
|
|
84
|
+
if (left[i] !== right[i])
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
};
|
|
89
|
+
export const nativeDurabilityDigestHex = (digest) => Array.from(digest, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
90
|
+
export const nativeDurabilityDigestFromHex = (value) => {
|
|
91
|
+
if (!/^[0-9a-f]{64}$/.test(value)) {
|
|
92
|
+
throw new NativeDurabilityStorageCorruptionError("Native durability digest must be 32 lowercase hexadecimal bytes");
|
|
93
|
+
}
|
|
94
|
+
const bytes = new Uint8Array(32);
|
|
95
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
96
|
+
bytes[i] = Number.parseInt(value.slice(i * 2, i * 2 + 2), 16);
|
|
97
|
+
}
|
|
98
|
+
return bytes;
|
|
99
|
+
};
|
|
100
|
+
const canonicalValue = (value) => {
|
|
101
|
+
if (typeof value === "bigint")
|
|
102
|
+
return { bigint: value.toString() };
|
|
103
|
+
if (value instanceof Uint8Array) {
|
|
104
|
+
return { bytes: nativeDurabilityDigestHex(value) };
|
|
105
|
+
}
|
|
106
|
+
if (Array.isArray(value))
|
|
107
|
+
return value.map(canonicalValue);
|
|
108
|
+
if (value && typeof value === "object") {
|
|
109
|
+
return Object.fromEntries(Object.entries(value)
|
|
110
|
+
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
|
|
111
|
+
.map(([key, entry]) => [key, canonicalValue(entry)]));
|
|
112
|
+
}
|
|
113
|
+
return value;
|
|
114
|
+
};
|
|
115
|
+
export const encodeNativeDurabilityCanonical = (value) => new TextEncoder().encode(JSON.stringify(canonicalValue(value)));
|
|
116
|
+
export const sha256NativeDurability = async (bytes) => {
|
|
117
|
+
if (!globalThis.crypto?.subtle) {
|
|
118
|
+
throw new NativeDurabilityStorageUnsupportedError("SHA-256 requires Web Crypto in the memory durability adapter");
|
|
119
|
+
}
|
|
120
|
+
const input = new Uint8Array(bytes.byteLength);
|
|
121
|
+
input.set(bytes);
|
|
122
|
+
return new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", input.buffer));
|
|
123
|
+
};
|
|
124
|
+
export const assertNativeDurabilityDigest = async (subject, bytes, expected) => {
|
|
125
|
+
if (expected.byteLength !== 32) {
|
|
126
|
+
throw new NativeDurabilityDigestMismatchError(subject);
|
|
127
|
+
}
|
|
128
|
+
const actual = await sha256NativeDurability(bytes);
|
|
129
|
+
if (!nativeDurabilityBytesEqual(actual, expected)) {
|
|
130
|
+
throw new NativeDurabilityDigestMismatchError(subject);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
export const nativeDurabilityScopeDigest = async (value) => sha256NativeDurability(encodeNativeDurabilityCanonical(value));
|
|
134
|
+
const assertU64 = (name, value) => {
|
|
135
|
+
if (typeof value !== "bigint" ||
|
|
136
|
+
value < 0n ||
|
|
137
|
+
value > NATIVE_DURABILITY_MAX_U64) {
|
|
138
|
+
throw new TypeError(`${name} must be an unsigned 64-bit bigint`);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
export const assertNativeDurabilityOperationScope = (scope) => {
|
|
142
|
+
if (!scope ||
|
|
143
|
+
typeof scope.transactionId !== "string" ||
|
|
144
|
+
!scope.transactionId) {
|
|
145
|
+
throw new TypeError("transactionId must be a non-empty string");
|
|
146
|
+
}
|
|
147
|
+
if (new TextEncoder().encode(scope.transactionId).byteLength >
|
|
148
|
+
NATIVE_DURABILITY_MAX_TRANSACTION_ID_BYTES) {
|
|
149
|
+
throw new TypeError("transactionId exceeds the journal format limit");
|
|
150
|
+
}
|
|
151
|
+
assertU64("txSequence", scope.txSequence);
|
|
152
|
+
assertU64("recordLsn", scope.recordLsn);
|
|
153
|
+
};
|
|
154
|
+
export const assertNativeDurabilityFence = (fence) => {
|
|
155
|
+
if (!fence ||
|
|
156
|
+
typeof fence.ownerId !== "string" ||
|
|
157
|
+
!fence.ownerId ||
|
|
158
|
+
typeof fence.domainId !== "string" ||
|
|
159
|
+
!fence.domainId) {
|
|
160
|
+
throw new TypeError("Durability fence ownerId/domainId must be non-empty");
|
|
161
|
+
}
|
|
162
|
+
if (new TextEncoder().encode(fence.ownerId).byteLength >
|
|
163
|
+
NATIVE_DURABILITY_MAX_WRITER_ID_BYTES ||
|
|
164
|
+
new TextEncoder().encode(fence.domainId).byteLength >
|
|
165
|
+
NATIVE_DURABILITY_MAX_WRITER_ID_BYTES) {
|
|
166
|
+
throw new TypeError("Durability fence ownerId/domainId exceeds format limit");
|
|
167
|
+
}
|
|
168
|
+
assertU64("fence.epoch", fence.epoch);
|
|
169
|
+
if (fence.epoch === 0n) {
|
|
170
|
+
throw new TypeError("Durability fence epoch must be non-zero");
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
export const assertNativeDurabilityStageRequest = (request) => {
|
|
174
|
+
assertNativeDurabilityOperationScope(request?.scope);
|
|
175
|
+
if (request.scope.txSequence === 0n || request.scope.recordLsn === 0n) {
|
|
176
|
+
throw new RangeError("Staging txSequence and recordLsn must be non-zero");
|
|
177
|
+
}
|
|
178
|
+
if (!Array.isArray(request.blocks)) {
|
|
179
|
+
throw new TypeError("Staging blocks must be an array");
|
|
180
|
+
}
|
|
181
|
+
const sorted = [...request.blocks].sort((left, right) => left.ordinal - right.ordinal);
|
|
182
|
+
for (let index = 0; index < sorted.length; index++) {
|
|
183
|
+
const block = sorted[index];
|
|
184
|
+
if (block.ordinal !== index) {
|
|
185
|
+
throw new RangeError("Staging ordinals must be contiguous from zero");
|
|
186
|
+
}
|
|
187
|
+
if (typeof block.cid !== "string" || !block.cid) {
|
|
188
|
+
throw new TypeError(`Staging block ${index} has an invalid CID`);
|
|
189
|
+
}
|
|
190
|
+
if (!(block.bytes instanceof Uint8Array)) {
|
|
191
|
+
throw new TypeError(`Staging block ${index} bytes must be Uint8Array`);
|
|
192
|
+
}
|
|
193
|
+
if (!(block.digest instanceof Uint8Array) ||
|
|
194
|
+
block.digest.byteLength !== 32) {
|
|
195
|
+
throw new TypeError(`Staging block ${index} digest must be 32 bytes`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
export const assertNativeDurabilityJournalAppendRequest = (request) => {
|
|
200
|
+
if (!request ||
|
|
201
|
+
typeof request.transactionId !== "string" ||
|
|
202
|
+
!request.transactionId) {
|
|
203
|
+
throw new TypeError("transactionId must be a non-empty string");
|
|
204
|
+
}
|
|
205
|
+
if (new TextEncoder().encode(request.transactionId).byteLength >
|
|
206
|
+
NATIVE_DURABILITY_MAX_TRANSACTION_ID_BYTES) {
|
|
207
|
+
throw new TypeError("transactionId exceeds the journal format limit");
|
|
208
|
+
}
|
|
209
|
+
assertU64("txSequence", request.txSequence);
|
|
210
|
+
assertU64("firstRecordLsn", request.firstRecordLsn);
|
|
211
|
+
assertU64("lastRecordLsn", request.lastRecordLsn);
|
|
212
|
+
if (request.txSequence === 0n ||
|
|
213
|
+
request.firstRecordLsn === 0n ||
|
|
214
|
+
request.lastRecordLsn === 0n) {
|
|
215
|
+
throw new RangeError("Journal sequence and LSN values must be non-zero");
|
|
216
|
+
}
|
|
217
|
+
if (request.lastRecordLsn < request.firstRecordLsn) {
|
|
218
|
+
throw new RangeError("lastRecordLsn must not precede firstRecordLsn");
|
|
219
|
+
}
|
|
220
|
+
if (!Number.isSafeInteger(request.expectedOffset) ||
|
|
221
|
+
request.expectedOffset < 0) {
|
|
222
|
+
throw new RangeError("expectedOffset must be a non-negative safe integer");
|
|
223
|
+
}
|
|
224
|
+
if (!(request.frames instanceof Uint8Array) ||
|
|
225
|
+
request.frames.byteLength === 0) {
|
|
226
|
+
throw new TypeError("Journal frames must be a non-empty Uint8Array");
|
|
227
|
+
}
|
|
228
|
+
if (!(request.framesDigest instanceof Uint8Array) ||
|
|
229
|
+
request.framesDigest.byteLength !== 32) {
|
|
230
|
+
throw new TypeError("framesDigest must be 32 bytes");
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
export const assertNativeDurabilityCheckpointRequest = (request) => {
|
|
234
|
+
assertNativeDurabilityOperationScope(request?.scope);
|
|
235
|
+
assertU64("checkpointLsn", request.checkpointLsn);
|
|
236
|
+
assertU64("txSequenceHighwater", request.txSequenceHighwater);
|
|
237
|
+
if (request.scope.txSequence === 0n ||
|
|
238
|
+
request.scope.recordLsn === 0n ||
|
|
239
|
+
request.scope.recordLsn > request.checkpointLsn ||
|
|
240
|
+
request.scope.txSequence > request.txSequenceHighwater) {
|
|
241
|
+
throw new RangeError("Checkpoint scope cannot exceed its LSN or transaction highwater");
|
|
242
|
+
}
|
|
243
|
+
if (!(request.bytes instanceof Uint8Array)) {
|
|
244
|
+
throw new TypeError("Checkpoint bytes must be Uint8Array");
|
|
245
|
+
}
|
|
246
|
+
if (!(request.digest instanceof Uint8Array) ||
|
|
247
|
+
request.digest.byteLength !== 32) {
|
|
248
|
+
throw new TypeError("Checkpoint digest must be 32 bytes");
|
|
249
|
+
}
|
|
250
|
+
if (!Array.isArray(request.stagingCoverage)) {
|
|
251
|
+
throw new TypeError("Checkpoint stagingCoverage must be an array");
|
|
252
|
+
}
|
|
253
|
+
const transactionIds = new Set();
|
|
254
|
+
for (const coverage of request.stagingCoverage) {
|
|
255
|
+
if (typeof coverage.transactionId !== "string" ||
|
|
256
|
+
!coverage.transactionId ||
|
|
257
|
+
transactionIds.has(coverage.transactionId)) {
|
|
258
|
+
throw new TypeError("Checkpoint staging coverage transaction IDs must be unique");
|
|
259
|
+
}
|
|
260
|
+
transactionIds.add(coverage.transactionId);
|
|
261
|
+
assertU64("coverage.txSequence", coverage.txSequence);
|
|
262
|
+
assertU64("coverage.coveredThroughLsn", coverage.coveredThroughLsn);
|
|
263
|
+
if (coverage.coveredThroughLsn > request.checkpointLsn) {
|
|
264
|
+
throw new RangeError("Staging coverage cannot extend beyond checkpointLsn");
|
|
265
|
+
}
|
|
266
|
+
if (new TextEncoder().encode(coverage.transactionId).byteLength >
|
|
267
|
+
NATIVE_DURABILITY_MAX_TRANSACTION_ID_BYTES ||
|
|
268
|
+
!(coverage.stagingManifestDigest instanceof Uint8Array) ||
|
|
269
|
+
coverage.stagingManifestDigest.byteLength !== 32) {
|
|
270
|
+
throw new TypeError("Checkpoint staging coverage fields exceed their format limits");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (!Array.isArray(request.retainedTransactions)) {
|
|
274
|
+
throw new TypeError("Checkpoint retainedTransactions must be an array");
|
|
275
|
+
}
|
|
276
|
+
const retainedIds = new Set();
|
|
277
|
+
const retainedSequences = new Set();
|
|
278
|
+
for (const retained of request.retainedTransactions) {
|
|
279
|
+
assertU64("retained transaction sequence", retained.txSequence);
|
|
280
|
+
if (retained.txSequence === 0n ||
|
|
281
|
+
retained.txSequence > request.txSequenceHighwater ||
|
|
282
|
+
typeof retained.transactionId !== "string" ||
|
|
283
|
+
!retained.transactionId ||
|
|
284
|
+
new TextEncoder().encode(retained.transactionId).byteLength >
|
|
285
|
+
NATIVE_DURABILITY_MAX_TRANSACTION_ID_BYTES ||
|
|
286
|
+
retainedIds.has(retained.transactionId) ||
|
|
287
|
+
retainedSequences.has(retained.txSequence) ||
|
|
288
|
+
!Number.isInteger(retained.phase) ||
|
|
289
|
+
retained.phase < 1 ||
|
|
290
|
+
retained.phase > 6 ||
|
|
291
|
+
!Number.isInteger(retained.operationKind) ||
|
|
292
|
+
retained.operationKind < 1 ||
|
|
293
|
+
retained.operationKind > 5 ||
|
|
294
|
+
!(retained.planDigest instanceof Uint8Array) ||
|
|
295
|
+
retained.planDigest.byteLength !== 32) {
|
|
296
|
+
throw new TypeError("Checkpoint retained transaction is invalid");
|
|
297
|
+
}
|
|
298
|
+
retainedIds.add(retained.transactionId);
|
|
299
|
+
retainedSequences.add(retained.txSequence);
|
|
300
|
+
}
|
|
301
|
+
for (const coverage of request.stagingCoverage) {
|
|
302
|
+
const retained = request.retainedTransactions.find((candidate) => candidate.transactionId === coverage.transactionId);
|
|
303
|
+
if (!retained ||
|
|
304
|
+
retained.txSequence !== coverage.txSequence ||
|
|
305
|
+
retained.phase !== 6) {
|
|
306
|
+
throw new TypeError("Checkpoint staging coverage requires the exact retained CLEAN transaction");
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
export const assertNativeDurabilityDeleteRequest = (request) => {
|
|
311
|
+
assertNativeDurabilityOperationScope(request?.scope);
|
|
312
|
+
if (!Array.isArray(request.targets) || request.targets.length === 0) {
|
|
313
|
+
throw new TypeError("Delete targets must be a non-empty array");
|
|
314
|
+
}
|
|
315
|
+
if (request.scope.txSequence === 0n || request.scope.recordLsn === 0n) {
|
|
316
|
+
throw new RangeError("Delete scope sequence and LSN must be non-zero");
|
|
317
|
+
}
|
|
318
|
+
const targetKeys = new Set();
|
|
319
|
+
for (const target of request.targets) {
|
|
320
|
+
if (target.kind === "staging") {
|
|
321
|
+
if (typeof target.transactionId !== "string" ||
|
|
322
|
+
!target.transactionId ||
|
|
323
|
+
new TextEncoder().encode(target.transactionId).byteLength >
|
|
324
|
+
NATIVE_DURABILITY_MAX_TRANSACTION_ID_BYTES) {
|
|
325
|
+
throw new TypeError("Staging delete transactionId must be non-empty");
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else if (target.kind === "checkpoint") {
|
|
329
|
+
assertU64("checkpoint generation", target.generation);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
throw new TypeError("Unknown native durability delete target");
|
|
333
|
+
}
|
|
334
|
+
const key = target.kind === "staging"
|
|
335
|
+
? `staging:${target.transactionId}`
|
|
336
|
+
: `checkpoint:${target.generation}`;
|
|
337
|
+
if (targetKeys.has(key)) {
|
|
338
|
+
throw new TypeError("Delete targets must be unique");
|
|
339
|
+
}
|
|
340
|
+
targetKeys.add(key);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/durability/storage.ts"],"names":[],"mappings":"AACA,OAAO,EACN,yBAAyB,EACzB,qCAAqC,GAErC,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAU,CAAC;AAC5D,MAAM,CAAC,MAAM,0CAA0C,GAAG,IAAI,CAAC;AAwN/D,MAAM,OAAO,uCAAwC,SAAQ,KAAK;IACxD,IAAI,GAAG,2CAA2C,CAAC;IAE5D,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yCAAyC,CAAC;IACvD,CAAC;CACD;AAED,MAAM,OAAO,sCAAuC,SAAQ,KAAK;IAG3C;IAFZ,IAAI,GAAG,0CAA0C,CAAC;IAE3D,YAAqB,SAAiB;QACrC,KAAK,CACJ,+FAA+F,SAAS,EAAE,CAC1G,CAAC;QAHkB,cAAS,GAAT,SAAS,CAAQ;QAIrC,IAAI,CAAC,IAAI,GAAG,wCAAwC,CAAC;IACtD,CAAC;CACD;AAED,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IACnD,IAAI,GAAG,sCAAsC,CAAC;IAEvD;QACC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,oCAAoC,CAAC;IAClD,CAAC;CACD;AAED,MAAM,OAAO,sCAAuC,SAAQ,KAAK;IAKtD;IAJD,IAAI,GAAG,0CAA0C,CAAC;IAE3D,YACC,OAAe,EACN,KAAe;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,UAAK,GAAL,KAAK,CAAU;QA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aAAa;gBACrB,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,UAAU;oBACxD,0CAA0C,EAC1C,CAAC;gBACF,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;YACvE,CAAC;QACF,CAAC;aAAM,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACzC,SAAS,CAAC,uBAAuB,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;QAChE,CAAC;QACD,MAAM,GAAG,GACR,MAAM,CAAC,IAAI,KAAK,SAAS;YACxB,CAAC,CAAC,WAAW,MAAM,CAAC,aAAa,EAAE;YACnC,CAAC,CAAC,cAAc,MAAM,CAAC,UAAU,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAC;QACtD,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;AACF,CAAC,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export * from "./durability/codec.js";
|
|
2
|
+
export * from "./durability/lease.js";
|
|
3
|
+
export * from "./durability/memory-storage.js";
|
|
4
|
+
export * from "./durability/node-lease.js";
|
|
5
|
+
export * from "./durability/node-storage.js";
|
|
6
|
+
export * from "./durability/storage.js";
|
|
1
7
|
export type RangeResolution = "u32" | "u64";
|
|
2
8
|
type NativePeerbitBackboneHandle = {
|
|
3
9
|
log_len: () => number;
|
|
@@ -920,23 +926,64 @@ export type NativeBackboneCoordinatePersistenceStore = {
|
|
|
920
926
|
/**
|
|
921
927
|
* Appends `bytes` to the named file. Callers hand over ownership of
|
|
922
928
|
* `bytes` and must not mutate it afterwards: buffering stores keep the
|
|
923
|
-
* array until their next flush instead of copying it.
|
|
929
|
+
* array until their next flush instead of copying it. A rejected append
|
|
930
|
+
* must either leave the file unchanged or make later appends fail closed.
|
|
924
931
|
*/
|
|
925
932
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
926
933
|
remove?(name: string): Promise<void>;
|
|
927
|
-
|
|
928
|
-
|
|
934
|
+
/** Explicit physical durability barrier; its presence is a capability. */
|
|
935
|
+
durableBarrier?(name?: string): Promise<void>;
|
|
936
|
+
/** Override removal inference for wrappers whose remove method is conditional. */
|
|
937
|
+
supportsRemoval?: boolean;
|
|
938
|
+
/** Flush one named file when supported, otherwise the complete store. */
|
|
939
|
+
flush?(name?: string): Promise<void>;
|
|
940
|
+
close?(options?: {
|
|
941
|
+
flush?: boolean;
|
|
942
|
+
}): Promise<void>;
|
|
929
943
|
};
|
|
930
944
|
export type NativeBackboneCoordinatePersistenceAdapter = {
|
|
945
|
+
/**
|
|
946
|
+
* Optional durable capability used by higher layers for atomic operation
|
|
947
|
+
* intents that must share this persistence lifecycle.
|
|
948
|
+
*/
|
|
949
|
+
intentStore?: NativeBackboneCoordinatePersistenceStore;
|
|
931
950
|
flushOnAppend?: boolean;
|
|
932
951
|
flushMaxPendingBytes?: number;
|
|
933
952
|
flushIntervalMs?: number;
|
|
934
953
|
compactMaxJournalBytes?: number;
|
|
935
954
|
compactMaxJournalRecords?: number;
|
|
955
|
+
/** Explicit opt-in for a generation-based, crash-atomic compaction protocol. */
|
|
956
|
+
crashSafeCompaction?: boolean;
|
|
957
|
+
/** Every acknowledged WAL/intent write crosses a physical durability barrier. */
|
|
958
|
+
durableBarrier?: boolean;
|
|
959
|
+
/** Drop is implemented by the underlying namespace, not only by a wrapper. */
|
|
960
|
+
supportsDrop?: boolean;
|
|
961
|
+
/** A successful drop owns handle cleanup and must not need ordinary close(). */
|
|
962
|
+
dropIsTerminal?: boolean;
|
|
936
963
|
hydrate(backbone: NativePeerbitBackbone): Promise<number>;
|
|
937
964
|
flushJournal(backbone: NativePeerbitBackbone): Promise<number>;
|
|
938
965
|
flushJournalOnAppend?(backbone: NativePeerbitBackbone): number | Promise<number>;
|
|
939
966
|
compact?(backbone: NativePeerbitBackbone): Promise<void>;
|
|
967
|
+
/**
|
|
968
|
+
* Durably erase this adapter's configured files and any additional files
|
|
969
|
+
* sharing the same namespace. A tombstone makes interrupted erases resumable.
|
|
970
|
+
*/
|
|
971
|
+
drop?(additionalFiles?: readonly string[]): Promise<void>;
|
|
972
|
+
/**
|
|
973
|
+
* Complete an interrupted drop before hydration or on the same adapter
|
|
974
|
+
* generation after `drop()` rejected. Returning `true` means the tombstoned
|
|
975
|
+
* erase completed: this generation remains terminal only if it initiated that
|
|
976
|
+
* drop, while recovery of a prior generation's marker returns to active.
|
|
977
|
+
* Returning `false` means no durable marker exists and an explicit `drop()`
|
|
978
|
+
* may start again; a generation that already initiated drop remains fenced
|
|
979
|
+
* from ordinary hydrate/flush work until that destructive retry completes.
|
|
980
|
+
* A corrupt/invalid marker rejection must likewise restore the adapter to an
|
|
981
|
+
* explicit-drop-admitting state so drop can overwrite it; transient I/O
|
|
982
|
+
* failures may keep the generation in its resumable dropping state. Once
|
|
983
|
+
* close is admitted, no new resume may queue behind terminal store teardown.
|
|
984
|
+
*/
|
|
985
|
+
resumeDrop?(): Promise<boolean>;
|
|
986
|
+
/** A rejected close may be retried to resume its first incomplete store stage. */
|
|
940
987
|
close?(): Promise<void>;
|
|
941
988
|
};
|
|
942
989
|
export type NativeBackboneCoordinatePersistenceConfig = NativeBackboneCoordinatePersistenceAdapter | (NativeBackboneCoordinatePersistenceOptions & {
|
|
@@ -956,7 +1003,9 @@ export type NativeBackboneNodeCoordinatePersistenceOptions = NativeBackboneCoord
|
|
|
956
1003
|
fs?: NativeBackboneNodeFs;
|
|
957
1004
|
writeBufferMaxBytes?: number;
|
|
958
1005
|
};
|
|
1006
|
+
export declare const nativeBackboneCoordinateDropTombstoneFile = "native-backbone-drop.tombstone";
|
|
959
1007
|
export declare const defaultNativeBackboneCoordinateFlushMaxPendingBytes: number;
|
|
1008
|
+
/** @deprecated Built-in coordinate persistence compaction is currently disabled. */
|
|
960
1009
|
export declare const defaultNativeBackboneCoordinateCompactMaxJournalBytes: number;
|
|
961
1010
|
type NativeBackboneNodeFs = {
|
|
962
1011
|
mkdir(path: string, options?: {
|
|
@@ -971,7 +1020,10 @@ type NativeBackboneNodeFs = {
|
|
|
971
1020
|
}): Promise<unknown>;
|
|
972
1021
|
};
|
|
973
1022
|
type NativeBackboneNodeAppendFileHandle = {
|
|
974
|
-
write(data: Uint8Array): Promise<
|
|
1023
|
+
write(data: Uint8Array): Promise<{
|
|
1024
|
+
bytesWritten: number;
|
|
1025
|
+
}>;
|
|
1026
|
+
sync?(): Promise<unknown>;
|
|
975
1027
|
close(): Promise<unknown>;
|
|
976
1028
|
};
|
|
977
1029
|
type NativeBackboneOPFSFile = {
|
|
@@ -983,6 +1035,7 @@ type NativeBackboneOPFSSyncAccessHandle = {
|
|
|
983
1035
|
write(buffer: Uint8Array, options?: {
|
|
984
1036
|
at?: number;
|
|
985
1037
|
}): number;
|
|
1038
|
+
truncate?(size: number): void;
|
|
986
1039
|
flush?(): void;
|
|
987
1040
|
close(): void;
|
|
988
1041
|
};
|
|
@@ -1463,6 +1516,7 @@ export declare class NativeBackboneMemoryCoordinatePersistenceStore implements N
|
|
|
1463
1516
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
1464
1517
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1465
1518
|
remove(name: string): Promise<void>;
|
|
1519
|
+
flush(_name?: string): Promise<void>;
|
|
1466
1520
|
}
|
|
1467
1521
|
export declare class NativeBackboneNodeCoordinatePersistenceStore implements NativeBackboneCoordinatePersistenceStore {
|
|
1468
1522
|
private readonly directory;
|
|
@@ -1470,6 +1524,8 @@ export declare class NativeBackboneNodeCoordinatePersistenceStore implements Nat
|
|
|
1470
1524
|
private readonly appendHandles;
|
|
1471
1525
|
private readonly filePaths;
|
|
1472
1526
|
private directoryEnsured;
|
|
1527
|
+
private appendFailure;
|
|
1528
|
+
readonly durableBarrier?: (name?: string) => Promise<void>;
|
|
1473
1529
|
constructor(directory: string, fs?: NativeBackboneNodeFs | undefined);
|
|
1474
1530
|
private nodeFs;
|
|
1475
1531
|
private filePath;
|
|
@@ -1480,10 +1536,13 @@ export declare class NativeBackboneNodeCoordinatePersistenceStore implements Nat
|
|
|
1480
1536
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
1481
1537
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1482
1538
|
remove(name: string): Promise<void>;
|
|
1539
|
+
flush(name?: string): Promise<void>;
|
|
1540
|
+
private syncDurably;
|
|
1483
1541
|
close(): Promise<void>;
|
|
1484
1542
|
}
|
|
1485
1543
|
export declare class NativeBackboneOPFSCoordinatePersistenceStore implements NativeBackboneCoordinatePersistenceStore {
|
|
1486
1544
|
private readonly directory;
|
|
1545
|
+
private appendFailure;
|
|
1487
1546
|
constructor(directory: NativeBackboneOPFSDirectoryHandle);
|
|
1488
1547
|
static create(options?: {
|
|
1489
1548
|
root?: NativeBackboneOPFSDirectoryHandle;
|
|
@@ -1495,12 +1554,16 @@ export declare class NativeBackboneOPFSCoordinatePersistenceStore implements Nat
|
|
|
1495
1554
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
1496
1555
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1497
1556
|
remove(name: string): Promise<void>;
|
|
1557
|
+
flush(_name?: string): Promise<void>;
|
|
1558
|
+
durableBarrier(name?: string): Promise<void>;
|
|
1498
1559
|
}
|
|
1499
1560
|
export declare class NativeBackboneBufferedCoordinatePersistenceStore implements NativeBackboneCoordinatePersistenceStore {
|
|
1500
1561
|
private readonly inner;
|
|
1501
1562
|
private readonly options;
|
|
1502
1563
|
private readonly buffers;
|
|
1503
1564
|
private bufferedBytes;
|
|
1565
|
+
readonly supportsRemoval: boolean;
|
|
1566
|
+
readonly durableBarrier?: (name?: string) => Promise<void>;
|
|
1504
1567
|
constructor(inner: NativeBackboneCoordinatePersistenceStore, options?: {
|
|
1505
1568
|
maxBufferedBytes?: number;
|
|
1506
1569
|
});
|
|
@@ -1510,7 +1573,9 @@ export declare class NativeBackboneBufferedCoordinatePersistenceStore implements
|
|
|
1510
1573
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1511
1574
|
remove(name: string): Promise<void>;
|
|
1512
1575
|
flush(name?: string): Promise<void>;
|
|
1513
|
-
close(
|
|
1576
|
+
close(options?: {
|
|
1577
|
+
flush?: boolean;
|
|
1578
|
+
}): Promise<void>;
|
|
1514
1579
|
}
|
|
1515
1580
|
export declare class NativeBackboneCoordinatePersistence {
|
|
1516
1581
|
private readonly store;
|
|
@@ -1519,6 +1584,10 @@ export declare class NativeBackboneCoordinatePersistence {
|
|
|
1519
1584
|
readonly flushIntervalMs?: number;
|
|
1520
1585
|
readonly compactMaxJournalBytes?: number;
|
|
1521
1586
|
readonly compactMaxJournalRecords?: number;
|
|
1587
|
+
readonly crashSafeCompaction = false;
|
|
1588
|
+
readonly durableBarrier: boolean;
|
|
1589
|
+
readonly supportsDrop: boolean;
|
|
1590
|
+
readonly dropIsTerminal = true;
|
|
1522
1591
|
private readonly snapshotFile;
|
|
1523
1592
|
private readonly journalFile;
|
|
1524
1593
|
private readonly documentSnapshotFile;
|
|
@@ -1526,26 +1595,36 @@ export declare class NativeBackboneCoordinatePersistence {
|
|
|
1526
1595
|
private readonly documentSignerSnapshotFile;
|
|
1527
1596
|
private readonly documentSignerJournalFile;
|
|
1528
1597
|
private journalInitialized;
|
|
1529
|
-
private journalByteLength;
|
|
1530
|
-
private journalRecordCount;
|
|
1531
1598
|
private documentJournalInitialized;
|
|
1532
|
-
private documentJournalByteLength;
|
|
1533
|
-
private documentJournalRecordCount;
|
|
1534
1599
|
private documentSignerJournalInitialized;
|
|
1535
|
-
private documentSignerJournalByteLength;
|
|
1536
|
-
private documentSignerJournalRecordCount;
|
|
1537
1600
|
private lastFlushMs;
|
|
1538
1601
|
private persistenceQueue;
|
|
1602
|
+
private persistenceLifecycle;
|
|
1603
|
+
private dropInitiatedOnGeneration;
|
|
1604
|
+
private persistenceFailure;
|
|
1605
|
+
private closeMode;
|
|
1606
|
+
private closeFlushCompleted;
|
|
1607
|
+
private closeStoreCompleted;
|
|
1608
|
+
private closePromise;
|
|
1539
1609
|
constructor(store: NativeBackboneCoordinatePersistenceStore, options?: NativeBackboneCoordinatePersistenceOptions);
|
|
1610
|
+
/** Durable operation-intent capability for strict shared-log transactions. */
|
|
1611
|
+
get intentStore(): NativeBackboneCoordinatePersistenceStore;
|
|
1612
|
+
private configuredFiles;
|
|
1613
|
+
private assertLifecycleActive;
|
|
1614
|
+
private assertActive;
|
|
1615
|
+
private resetJournalTracking;
|
|
1616
|
+
private eraseDropFiles;
|
|
1617
|
+
drop(additionalFiles?: readonly string[]): Promise<void>;
|
|
1618
|
+
resumeDrop(): Promise<boolean>;
|
|
1540
1619
|
hydrate(backbone: NativePeerbitBackbone): Promise<number>;
|
|
1620
|
+
private assertHydrating;
|
|
1621
|
+
private resumeDropInternal;
|
|
1541
1622
|
shouldFlushJournalOnAppend(backbone: NativePeerbitBackbone, now?: number): boolean;
|
|
1542
1623
|
flushJournalOnAppend(backbone: NativePeerbitBackbone): number | Promise<number>;
|
|
1543
1624
|
flushJournal(backbone: NativePeerbitBackbone): Promise<number>;
|
|
1544
1625
|
private enqueuePersistence;
|
|
1545
1626
|
private flushJournalInternal;
|
|
1546
|
-
|
|
1547
|
-
compact(backbone: NativePeerbitBackbone): Promise<void>;
|
|
1548
|
-
private compactInternal;
|
|
1627
|
+
compact(_backbone: NativePeerbitBackbone): Promise<void>;
|
|
1549
1628
|
close(): Promise<void>;
|
|
1550
1629
|
}
|
|
1551
1630
|
export declare class NativeBackboneNodeCoordinatePersistence extends NativeBackboneCoordinatePersistence {
|
|
@@ -1557,5 +1636,4 @@ export declare const createNativeBackboneCoordinatePersistence: (config: NativeB
|
|
|
1557
1636
|
export declare const createBufferedNativeBackboneCoordinatePersistence: (store: NativeBackboneCoordinatePersistenceStore, options?: NativeBackboneBufferedCoordinatePersistenceOptions) => NativeBackboneCoordinatePersistenceAdapter;
|
|
1558
1637
|
export declare const createBufferedNativeBackboneNodeCoordinatePersistence: (directory: string, options?: NativeBackboneNodeCoordinatePersistenceOptions) => NativeBackboneCoordinatePersistenceAdapter;
|
|
1559
1638
|
export declare const createNativePeerbitBackbone: typeof NativePeerbitBackbone.create;
|
|
1560
|
-
export {};
|
|
1561
1639
|
//# sourceMappingURL=index.d.ts.map
|