@peerbit/native-backbone 0.2.8 → 0.2.10
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 +55 -20
- package/dist/src/index.d.ts +101 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1120 -74
- package/dist/src/index.js.map +1 -1
- package/dist/wasm/README.md +55 -20
- package/dist/wasm/native_backbone.d.ts +118 -79
- package/dist/wasm/native_backbone.js +227 -0
- package/dist/wasm/native_backbone_bg.wasm +0 -0
- package/dist/wasm/native_backbone_bg.wasm.d.ts +87 -79
- package/package.json +1 -1
- package/src/append_tx/committed_latest.rs +10 -5
- package/src/append_tx/committed_no_next.rs +6 -3
- package/src/append_tx/facts.rs +427 -1
- package/src/append_tx/mod.rs +51 -18
- package/src/append_tx/storage.rs +12 -2
- package/src/index.ts +1703 -231
package/README.md
CHANGED
|
@@ -7,26 +7,60 @@ fused. It owns the native lower-log graph, native log block store, and shared-lo
|
|
|
7
7
|
resident coordinate state in one Rust object so higher layers can move toward a
|
|
8
8
|
single `JS -> native -> compact facts` transaction boundary.
|
|
9
9
|
|
|
10
|
-
## Coordinate WAL persistence
|
|
10
|
+
## Coordinate and document-fact WAL persistence
|
|
11
11
|
|
|
12
|
-
Native shared-log coordinates
|
|
13
|
-
buffered
|
|
14
|
-
mode. Buffered
|
|
15
|
-
flush,
|
|
16
|
-
document writes.
|
|
12
|
+
Native shared-log coordinates, document values, and document signer facts can be
|
|
13
|
+
persisted through write-through or buffered WALs. Write-through flushes every
|
|
14
|
+
append and is the strictest persistence mode. Buffered WALs batch bytes and flush
|
|
15
|
+
on their pending-byte threshold, explicit flush, checkpoint, or close, which is
|
|
16
|
+
the high-throughput mode for strict native document writes.
|
|
17
17
|
|
|
18
18
|
Use `createBufferedNativeBackboneCoordinatePersistence(store)` with OPFS, memory,
|
|
19
19
|
or custom stores, and `createBufferedNativeBackboneNodeCoordinatePersistence(dir)`
|
|
20
|
-
for the Node adapter.
|
|
21
|
-
|
|
22
|
-
uses the same bounded checkpoint default.
|
|
20
|
+
for the Node adapter. Persistence flush and replay are enabled by default;
|
|
21
|
+
checkpoint compaction is not.
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
The built-in Node adapter supports explicit crash-safe checkpointing when its
|
|
24
|
+
filesystem implementation provides atomic replacement. Opt in by setting
|
|
25
|
+
`compactMaxJournalBytes` or `compactMaxJournalRecords` on
|
|
26
|
+
`NativeBackboneNodeCoordinatePersistence` or
|
|
27
|
+
`createBufferedNativeBackboneNodeCoordinatePersistence`:
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
```ts
|
|
30
|
+
const persistence = createBufferedNativeBackboneNodeCoordinatePersistence(
|
|
31
|
+
programDirectory,
|
|
32
|
+
{ compactMaxJournalBytes: 64 * 1024 * 1024 },
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Crossing either configured threshold durably publishes one versioned, checksummed
|
|
37
|
+
checkpoint for all three fact sets, switches between fixed A/B WAL generations,
|
|
38
|
+
and records an atomic replay high-water mark before covered WAL data is retired.
|
|
39
|
+
Checkpointing is serialized with flushes, so recovery chooses a fully published
|
|
40
|
+
generation instead of combining partially replaced snapshots.
|
|
41
|
+
|
|
42
|
+
Memory and OPFS persistence, along with custom stores that do not implement the
|
|
43
|
+
atomic replacement, removal, and durability capabilities, continue to reject
|
|
44
|
+
these threshold options. They retain ordinary WAL flush and replay behavior.
|
|
45
|
+
There is intentionally no automatic checkpoint threshold, including for the
|
|
46
|
+
Node helpers.
|
|
47
|
+
|
|
48
|
+
The checkpoint bounds only the coordinate, document-value, and document-signer
|
|
49
|
+
WALs. The entry-block WAL has a separate owner and remains out of scope, so this
|
|
50
|
+
feature does not by itself bound every file in a program directory.
|
|
51
|
+
|
|
52
|
+
Existing directories using the legacy snapshots and WALs open without a manual
|
|
53
|
+
migration. Their first checkpoint becomes forward-only once its staged generation
|
|
54
|
+
and downgrade sentinel are durable. If publication is interrupted after that
|
|
55
|
+
boundary, current recovery validates and promotes the staged generation; before
|
|
56
|
+
the boundary, the complete legacy WAL remains authoritative. The sentinel makes a
|
|
57
|
+
pre-checkpoint package fail closed rather than replay stale legacy files. Rolling
|
|
58
|
+
back therefore requires restoring a pre-migration copy of the directory. This is
|
|
59
|
+
an opt-in, forward-only internal persistence-format migration. It removes no
|
|
60
|
+
public API and does not alter the peer-to-peer wire format; it does add observable
|
|
61
|
+
Node checkpoint capabilities and downgrade behavior.
|
|
62
|
+
|
|
63
|
+
These fact WALs support clean stop/restart. They are not the recovery authority
|
|
30
64
|
for a crash-atomic append across blocks, graph state, heads, coordinates,
|
|
31
65
|
documents, and signer facts.
|
|
32
66
|
|
|
@@ -50,9 +84,10 @@ directory sync. Its first open creates a synced genesis only in an otherwise
|
|
|
50
84
|
empty program directory; a nonempty legacy directory fails with
|
|
51
85
|
`NativeDurabilityMigrationRequiredError` and is never adopted implicitly.
|
|
52
86
|
|
|
53
|
-
Phase one retains
|
|
54
|
-
A/B checkpoints prove staging coverage.
|
|
55
|
-
deferred until a later phase can switch
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
87
|
+
Phase one retains this separate durability-transaction journal and pins genesis
|
|
88
|
+
as its scan base while newer A/B checkpoints prove staging coverage. Compaction
|
|
89
|
+
of that journal is deliberately deferred until a later phase can switch its
|
|
90
|
+
generation and scan base together; the coordinate/document-fact checkpointing
|
|
91
|
+
described above does not alter it. Memory storage is a non-crash-safe reference
|
|
92
|
+
adapter, and OPFS remains unsupported until its lifetime lease and
|
|
93
|
+
worker-termination barriers have a dedicated conformance gate.
|
package/dist/src/index.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export * from "./durability/node-lease.js";
|
|
|
5
5
|
export * from "./durability/node-storage.js";
|
|
6
6
|
export * from "./durability/storage.js";
|
|
7
7
|
export type RangeResolution = "u32" | "u64";
|
|
8
|
+
type NativePrepareNoNextDocumentIndexCompactTrimFacts = (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number, documentKey: string, documentValuePrefixBytes: Uint8Array, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlan: NativeBackboneSimpleDocumentProjectionPlan | undefined, documentProjectionEncodedDocument: Uint8Array | undefined, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
9
|
+
type NativePrepareNoNextCachedDocumentIndexCompactTrimFacts = (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number, documentKey: string, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlanId: number, documentProjectionEncodedDocument: Uint8Array, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
10
|
+
type NativePrepareNoNextCachedPlainPutPayloadDocumentIndexCompactTrimFacts = (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number, documentKey: string, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlanId: number, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
11
|
+
type NativePrepareLatestDocumentIndexTrimFacts = (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number | undefined, documentKey: string, documentValuePrefixBytes: Uint8Array, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlan: NativeBackboneSimpleDocumentProjectionPlan | undefined, documentProjectionEncodedDocument: Uint8Array | undefined, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
12
|
+
type NativePrepareLatestCachedDocumentIndexTrimFacts = (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number | undefined, documentKey: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlanId: number, documentProjectionEncodedDocument: Uint8Array, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
8
13
|
type NativePeerbitBackboneHandle = {
|
|
9
14
|
log_len: () => number;
|
|
10
15
|
block_len: () => number;
|
|
@@ -244,18 +249,24 @@ type NativePeerbitBackboneHandle = {
|
|
|
244
249
|
]>;
|
|
245
250
|
plan_receive_coordinates_for_gids_batch: (entryHashes: string[], gids: string[], hashNumbers: string[], nextHashBatches: string[][], replicaCounts: number[], roleAgeMs: number, now: string, peerFilter: string[] | undefined, expandPeerFilter: boolean, selfHash: string, includeSelf: boolean, fullReplicaFallback: boolean, includeStrictFullReplica: boolean) => Array<[unknown[], unknown[], boolean, boolean, unknown[]]>;
|
|
246
251
|
prepare_plain_entry_commit_facts: (wallTime: bigint, logical: number, gid: string, next: string[], type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number | undefined) => unknown[];
|
|
252
|
+
prepare_plain_entry_commit_facts_trim_refs?: (wallTime: bigint, logical: number, gid: string, next: string[], type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number) => unknown[];
|
|
247
253
|
prepare_plain_entry_commit_facts_document_index: (wallTime: bigint, logical: number, gid: string, next: string[], type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number | undefined, documentKey: string, documentValuePrefixBytes: Uint8Array, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlan: NativeBackboneSimpleDocumentProjectionPlan | undefined, documentProjectionEncodedDocument: Uint8Array | undefined, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
248
254
|
prepare_plain_entry_commit_facts_document_index_cached_plan: (wallTime: bigint, logical: number, gid: string, next: string[], type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number | undefined, documentKey: string, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlanId: number, documentProjectionEncodedDocument: Uint8Array, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
249
255
|
prepare_plain_entry_commit_no_next_facts_document_index_compact: (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, documentKey: string, documentValuePrefixBytes: Uint8Array, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlan: NativeBackboneSimpleDocumentProjectionPlan | undefined, documentProjectionEncodedDocument: Uint8Array | undefined, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
250
256
|
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact: (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, documentKey: string, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlanId: number, documentProjectionEncodedDocument: Uint8Array, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
251
257
|
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_plain_put_payload?: (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, documentKey: string, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlanId: number, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
252
258
|
prepare_plain_entry_commit_no_next_facts_document_index_trim_hashes: (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number, documentKey: string, documentValuePrefixBytes: Uint8Array, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlan: NativeBackboneSimpleDocumentProjectionPlan | undefined, documentProjectionEncodedDocument: Uint8Array | undefined, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
253
|
-
prepare_plain_entry_commit_no_next_facts_document_index_compact_trim_hashes:
|
|
259
|
+
prepare_plain_entry_commit_no_next_facts_document_index_compact_trim_hashes: NativePrepareNoNextDocumentIndexCompactTrimFacts;
|
|
260
|
+
prepare_plain_entry_commit_no_next_facts_document_index_compact_trim_refs?: NativePrepareNoNextDocumentIndexCompactTrimFacts;
|
|
254
261
|
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_trim_hashes: (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number, documentKey: string, documentExistingCreated: string, documentByteElementIndexLimit: number, documentDeleteTrimmedHeads: boolean, documentProjectionPlanId: number, documentProjectionEncodedDocument: Uint8Array, documentProjectionSigner: Uint8Array | undefined) => unknown[];
|
|
255
|
-
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_hashes:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
262
|
+
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_hashes: NativePrepareNoNextCachedDocumentIndexCompactTrimFacts;
|
|
263
|
+
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_refs?: NativePrepareNoNextCachedDocumentIndexCompactTrimFacts;
|
|
264
|
+
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_hashes_plain_put_payload?: NativePrepareNoNextCachedPlainPutPayloadDocumentIndexCompactTrimFacts;
|
|
265
|
+
prepare_plain_entry_commit_no_next_facts_document_index_cached_plan_compact_trim_refs_plain_put_payload?: NativePrepareNoNextCachedPlainPutPayloadDocumentIndexCompactTrimFacts;
|
|
266
|
+
prepare_plain_entry_commit_latest_facts_document_index_trim_hashes: NativePrepareLatestDocumentIndexTrimFacts;
|
|
267
|
+
prepare_plain_entry_commit_latest_facts_document_index_trim_refs?: NativePrepareLatestDocumentIndexTrimFacts;
|
|
268
|
+
prepare_plain_entry_commit_latest_facts_document_index_cached_plan_trim_hashes: NativePrepareLatestCachedDocumentIndexTrimFacts;
|
|
269
|
+
prepare_plain_entry_commit_latest_facts_document_index_cached_plan_trim_refs?: NativePrepareLatestCachedDocumentIndexTrimFacts;
|
|
259
270
|
prepare_plain_entry_storage_facts_and_put: (wallTime: bigint, logical: number, gid: string, next: string[], type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array) => unknown[];
|
|
260
271
|
prepare_plain_entry_storage_facts_trim_and_put: (wallTime: bigint, logical: number, gid: string, next: string[], type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, trimLengthTo: number) => unknown[];
|
|
261
272
|
prepare_plain_no_next_storage_append_transaction: (wallTime: bigint, logical: number, gid: string, type: number, metaData: Uint8Array | undefined, payloadData: Uint8Array, replicas: number, roleAgeMs: number, now: string, selfHash: string, selfReplicating: boolean, resolveTrimmedEntries: boolean) => unknown[];
|
|
@@ -763,6 +774,7 @@ export type NativeBackboneAppendResult = {
|
|
|
763
774
|
assignedToRangeBoundary: boolean;
|
|
764
775
|
trimmed: NativeBackboneTrimmedEntry[];
|
|
765
776
|
trimmedHashes?: string[];
|
|
777
|
+
trimmedGids?: string[];
|
|
766
778
|
documentTrimmedHeadsProcessed?: boolean;
|
|
767
779
|
documentPreviousContext?: NativeBackboneDocumentContextFacts;
|
|
768
780
|
};
|
|
@@ -774,6 +786,7 @@ type NativeBackboneStorageAppendResult = {
|
|
|
774
786
|
assignedToRangeBoundary: boolean;
|
|
775
787
|
trimmed: NativeBackboneTrimmedEntry[];
|
|
776
788
|
trimmedHashes?: string[];
|
|
789
|
+
trimmedGids?: string[];
|
|
777
790
|
documentTrimmedHeadsProcessed?: boolean;
|
|
778
791
|
documentPreviousContext?: NativeBackboneDocumentContextFacts;
|
|
779
792
|
};
|
|
@@ -924,7 +937,21 @@ export type NativeBackboneCoordinatePersistenceOptions = NativeBackboneCoordinat
|
|
|
924
937
|
};
|
|
925
938
|
export type NativeBackboneCoordinatePersistenceStore = {
|
|
926
939
|
read(name: string): Promise<Uint8Array | undefined>;
|
|
940
|
+
/**
|
|
941
|
+
* Read a named file without materializing more than `maxBytes`.
|
|
942
|
+
*
|
|
943
|
+
* The optional method is an explicit capability: callers that require a
|
|
944
|
+
* pre-allocation bound must fail closed when it is absent and must not fall
|
|
945
|
+
* back to `read`.
|
|
946
|
+
*/
|
|
947
|
+
readLimited?(name: string, maxBytes: number): Promise<Uint8Array | undefined>;
|
|
927
948
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
949
|
+
/**
|
|
950
|
+
* Durably replace one named file without exposing a torn destination. The
|
|
951
|
+
* replacement is not visible until its bytes and containing directory have
|
|
952
|
+
* crossed their physical durability barriers.
|
|
953
|
+
*/
|
|
954
|
+
atomicReplace?(name: string, bytes: Uint8Array): Promise<void>;
|
|
928
955
|
/**
|
|
929
956
|
* Appends `bytes` to the named file. Callers hand over ownership of
|
|
930
957
|
* `bytes` and must not mutate it afterwards: buffering stores keep the
|
|
@@ -943,6 +970,13 @@ export type NativeBackboneCoordinatePersistenceStore = {
|
|
|
943
970
|
flush?: boolean;
|
|
944
971
|
}): Promise<void>;
|
|
945
972
|
};
|
|
973
|
+
export declare class NativeBackboneCoordinatePersistenceReadLimitError extends Error {
|
|
974
|
+
readonly file: string;
|
|
975
|
+
readonly maxBytes: number;
|
|
976
|
+
readonly observedBytes: bigint;
|
|
977
|
+
readonly code = "ERR_NATIVE_BACKBONE_COORDINATE_READ_LIMIT";
|
|
978
|
+
constructor(file: string, maxBytes: number, observedBytes: bigint);
|
|
979
|
+
}
|
|
946
980
|
export type NativeBackboneCoordinatePersistenceAdapter = {
|
|
947
981
|
/**
|
|
948
982
|
* Optional durable capability used by higher layers for atomic operation
|
|
@@ -1007,7 +1041,7 @@ export type NativeBackboneNodeCoordinatePersistenceOptions = NativeBackboneCoord
|
|
|
1007
1041
|
};
|
|
1008
1042
|
export declare const nativeBackboneCoordinateDropTombstoneFile = "native-backbone-drop.tombstone";
|
|
1009
1043
|
export declare const defaultNativeBackboneCoordinateFlushMaxPendingBytes: number;
|
|
1010
|
-
/**
|
|
1044
|
+
/** Recommended explicit byte threshold for crash-safe Node checkpointing. */
|
|
1011
1045
|
export declare const defaultNativeBackboneCoordinateCompactMaxJournalBytes: number;
|
|
1012
1046
|
type NativeBackboneNodeFs = {
|
|
1013
1047
|
mkdir(path: string, options?: {
|
|
@@ -1016,6 +1050,9 @@ type NativeBackboneNodeFs = {
|
|
|
1016
1050
|
readFile(path: string): Promise<Uint8Array>;
|
|
1017
1051
|
writeFile(path: string, data: Uint8Array): Promise<unknown>;
|
|
1018
1052
|
appendFile(path: string, data: Uint8Array): Promise<unknown>;
|
|
1053
|
+
rename?(from: string, to: string): Promise<unknown>;
|
|
1054
|
+
/** Explicit capability for pre-allocation-bounded positional reads. */
|
|
1055
|
+
openBoundedRead?(path: string): Promise<NativeBackboneNodeBoundedReadFileHandle>;
|
|
1019
1056
|
open?(path: string, flags: string): Promise<NativeBackboneNodeAppendFileHandle>;
|
|
1020
1057
|
rm(path: string, options?: {
|
|
1021
1058
|
force?: boolean;
|
|
@@ -1025,9 +1062,28 @@ type NativeBackboneNodeAppendFileHandle = {
|
|
|
1025
1062
|
write(data: Uint8Array): Promise<{
|
|
1026
1063
|
bytesWritten: number;
|
|
1027
1064
|
}>;
|
|
1065
|
+
read?(buffer: Uint8Array, offset: number, length: number, position: number): Promise<{
|
|
1066
|
+
bytesRead: number;
|
|
1067
|
+
}>;
|
|
1068
|
+
stat?(options: {
|
|
1069
|
+
bigint: true;
|
|
1070
|
+
}): Promise<{
|
|
1071
|
+
size: bigint;
|
|
1072
|
+
}>;
|
|
1028
1073
|
sync?(): Promise<unknown>;
|
|
1029
1074
|
close(): Promise<unknown>;
|
|
1030
1075
|
};
|
|
1076
|
+
type NativeBackboneNodeBoundedReadFileHandle = {
|
|
1077
|
+
read(buffer: Uint8Array, offset: number, length: number, position: number): Promise<{
|
|
1078
|
+
bytesRead: number;
|
|
1079
|
+
}>;
|
|
1080
|
+
stat(options: {
|
|
1081
|
+
bigint: true;
|
|
1082
|
+
}): Promise<{
|
|
1083
|
+
size: bigint;
|
|
1084
|
+
}>;
|
|
1085
|
+
close(): Promise<unknown>;
|
|
1086
|
+
};
|
|
1031
1087
|
type NativeBackboneOPFSFile = {
|
|
1032
1088
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
1033
1089
|
size: number;
|
|
@@ -1111,7 +1167,9 @@ declare class NativeBackboneLogGraph {
|
|
|
1111
1167
|
}, _blockStore: unknown): (NativeBackboneCommittedEntry & {
|
|
1112
1168
|
trimmedEntries?: NativeBackboneLogEntry[];
|
|
1113
1169
|
trimmedEntryHashes?: string[];
|
|
1170
|
+
trimmedEntryGids?: string[];
|
|
1114
1171
|
documentTrimmedHeadsProcessed?: boolean;
|
|
1172
|
+
documentPreviousContext?: NativeBackboneDocumentContextFacts;
|
|
1115
1173
|
}) | undefined;
|
|
1116
1174
|
prepareEntryV0PlainEntryAndPut(input: {
|
|
1117
1175
|
clockId: Uint8Array;
|
|
@@ -1529,6 +1587,7 @@ export declare class NativePeerbitBackbone {
|
|
|
1529
1587
|
export declare class NativeBackboneMemoryCoordinatePersistenceStore implements NativeBackboneCoordinatePersistenceStore {
|
|
1530
1588
|
readonly files: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
1531
1589
|
read(name: string): Promise<Uint8Array | undefined>;
|
|
1590
|
+
readLimited(name: string, maxBytes: number): Promise<Uint8Array | undefined>;
|
|
1532
1591
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
1533
1592
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1534
1593
|
remove(name: string): Promise<void>;
|
|
@@ -1541,7 +1600,9 @@ export declare class NativeBackboneNodeCoordinatePersistenceStore implements Nat
|
|
|
1541
1600
|
private readonly filePaths;
|
|
1542
1601
|
private directoryEnsured;
|
|
1543
1602
|
private appendFailure;
|
|
1603
|
+
readonly readLimited?: (name: string, maxBytes: number) => Promise<Uint8Array | undefined>;
|
|
1544
1604
|
readonly durableBarrier?: (name?: string) => Promise<void>;
|
|
1605
|
+
readonly atomicReplace?: (name: string, bytes: Uint8Array) => Promise<void>;
|
|
1545
1606
|
constructor(directory: string, fs?: NativeBackboneNodeFs | undefined);
|
|
1546
1607
|
private nodeFs;
|
|
1547
1608
|
private filePath;
|
|
@@ -1549,7 +1610,9 @@ export declare class NativeBackboneNodeCoordinatePersistenceStore implements Nat
|
|
|
1549
1610
|
private closeAppendHandle;
|
|
1550
1611
|
private appendHandle;
|
|
1551
1612
|
read(name: string): Promise<Uint8Array | undefined>;
|
|
1613
|
+
private readWithinLimit;
|
|
1552
1614
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
1615
|
+
private replaceAtomically;
|
|
1553
1616
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1554
1617
|
remove(name: string): Promise<void>;
|
|
1555
1618
|
flush(name?: string): Promise<void>;
|
|
@@ -1567,6 +1630,7 @@ export declare class NativeBackboneOPFSCoordinatePersistenceStore implements Nat
|
|
|
1567
1630
|
private static defaultRoot;
|
|
1568
1631
|
private static directoryParts;
|
|
1569
1632
|
read(name: string): Promise<Uint8Array | undefined>;
|
|
1633
|
+
readLimited(name: string, maxBytes: number): Promise<Uint8Array | undefined>;
|
|
1570
1634
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
1571
1635
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1572
1636
|
remove(name: string): Promise<void>;
|
|
@@ -1578,13 +1642,16 @@ export declare class NativeBackboneBufferedCoordinatePersistenceStore implements
|
|
|
1578
1642
|
private readonly options;
|
|
1579
1643
|
private readonly buffers;
|
|
1580
1644
|
private bufferedBytes;
|
|
1645
|
+
readonly readLimited?: (name: string, maxBytes: number) => Promise<Uint8Array | undefined>;
|
|
1581
1646
|
readonly supportsRemoval: boolean;
|
|
1582
1647
|
readonly durableBarrier?: (name?: string) => Promise<void>;
|
|
1648
|
+
readonly atomicReplace?: (name: string, bytes: Uint8Array) => Promise<void>;
|
|
1583
1649
|
constructor(inner: NativeBackboneCoordinatePersistenceStore, options?: {
|
|
1584
1650
|
maxBufferedBytes?: number;
|
|
1585
1651
|
});
|
|
1586
1652
|
private buffer;
|
|
1587
1653
|
read(name: string): Promise<Uint8Array | undefined>;
|
|
1654
|
+
private readWithinLimit;
|
|
1588
1655
|
write(name: string, bytes: Uint8Array): Promise<void>;
|
|
1589
1656
|
append(name: string, bytes: Uint8Array): Promise<void>;
|
|
1590
1657
|
remove(name: string): Promise<void>;
|
|
@@ -1600,7 +1667,7 @@ export declare class NativeBackboneCoordinatePersistence {
|
|
|
1600
1667
|
readonly flushIntervalMs?: number;
|
|
1601
1668
|
readonly compactMaxJournalBytes?: number;
|
|
1602
1669
|
readonly compactMaxJournalRecords?: number;
|
|
1603
|
-
readonly crashSafeCompaction
|
|
1670
|
+
readonly crashSafeCompaction: boolean;
|
|
1604
1671
|
readonly durableBarrier: boolean;
|
|
1605
1672
|
readonly supportsDrop: boolean;
|
|
1606
1673
|
readonly dropIsTerminal = true;
|
|
@@ -1610,9 +1677,22 @@ export declare class NativeBackboneCoordinatePersistence {
|
|
|
1610
1677
|
private readonly documentJournalFile;
|
|
1611
1678
|
private readonly documentSignerSnapshotFile;
|
|
1612
1679
|
private readonly documentSignerJournalFile;
|
|
1680
|
+
private readonly checkpointConfigurationChecksum;
|
|
1681
|
+
private readonly checkpointStateFile;
|
|
1682
|
+
private readonly checkpointFiles;
|
|
1683
|
+
private readonly checkpointJournalFiles;
|
|
1613
1684
|
private journalInitialized;
|
|
1685
|
+
private journalByteLength;
|
|
1686
|
+
private journalRecordCount;
|
|
1614
1687
|
private documentJournalInitialized;
|
|
1688
|
+
private documentJournalByteLength;
|
|
1689
|
+
private documentJournalRecordCount;
|
|
1615
1690
|
private documentSignerJournalInitialized;
|
|
1691
|
+
private documentSignerJournalByteLength;
|
|
1692
|
+
private documentSignerJournalRecordCount;
|
|
1693
|
+
private checkpointHighwater;
|
|
1694
|
+
private checkpointCompleted?;
|
|
1695
|
+
private checkpointPending?;
|
|
1616
1696
|
private lastFlushMs;
|
|
1617
1697
|
private persistenceQueue;
|
|
1618
1698
|
private persistenceLifecycle;
|
|
@@ -1625,13 +1705,22 @@ export declare class NativeBackboneCoordinatePersistence {
|
|
|
1625
1705
|
constructor(store: NativeBackboneCoordinatePersistenceStore, options?: NativeBackboneCoordinatePersistenceOptions);
|
|
1626
1706
|
/** Durable operation-intent capability for strict shared-log transactions. */
|
|
1627
1707
|
get intentStore(): NativeBackboneCoordinatePersistenceStore;
|
|
1708
|
+
private legacyConfiguredFiles;
|
|
1628
1709
|
private configuredFiles;
|
|
1710
|
+
private checkpointSlot;
|
|
1711
|
+
private activeJournalFiles;
|
|
1629
1712
|
private assertLifecycleActive;
|
|
1630
1713
|
private assertActive;
|
|
1714
|
+
private assertPersistenceHealthy;
|
|
1631
1715
|
private resetJournalTracking;
|
|
1716
|
+
private persistDropTombstone;
|
|
1632
1717
|
private eraseDropFiles;
|
|
1633
1718
|
drop(additionalFiles?: readonly string[]): Promise<void>;
|
|
1634
1719
|
resumeDrop(): Promise<boolean>;
|
|
1720
|
+
private barrierFile;
|
|
1721
|
+
private hasDurableLegacyMigrationSentinel;
|
|
1722
|
+
private installLegacyMigrationSentinel;
|
|
1723
|
+
private requireLegacyMigrationSentinel;
|
|
1635
1724
|
hydrate(backbone: NativePeerbitBackbone): Promise<number>;
|
|
1636
1725
|
private assertHydrating;
|
|
1637
1726
|
private resumeDropInternal;
|
|
@@ -1639,8 +1728,12 @@ export declare class NativeBackboneCoordinatePersistence {
|
|
|
1639
1728
|
flushJournalOnAppend(backbone: NativePeerbitBackbone): number | Promise<number>;
|
|
1640
1729
|
flushJournal(backbone: NativePeerbitBackbone): Promise<number>;
|
|
1641
1730
|
private enqueuePersistence;
|
|
1731
|
+
private shouldCompactJournal;
|
|
1732
|
+
private nextCheckpointGeneration;
|
|
1733
|
+
private publishCheckpoint;
|
|
1734
|
+
private cleanupRetiredCheckpointFiles;
|
|
1642
1735
|
private flushJournalInternal;
|
|
1643
|
-
compact(
|
|
1736
|
+
compact(backbone: NativePeerbitBackbone): Promise<void>;
|
|
1644
1737
|
close(): Promise<void>;
|
|
1645
1738
|
}
|
|
1646
1739
|
export declare class NativeBackboneNodeCoordinatePersistence extends NativeBackboneCoordinatePersistence {
|