CompactionConfig
Defined in: packages/core/src/compaction-config.ts:7
Configuration for history compaction behavior.
Compaction creates snapshot nodes in the Merkle-DAG that summarize the full CRDT state, allowing peers to skip replaying the full change history.
Properties
Section titled “Properties”enabled
Section titled “enabled”enabled:
boolean
Defined in: packages/core/src/compaction-config.ts:15
Enable periodic automatic compaction. When false, snapshots are manual
(document.snapshot()) except for the depth bound: a writer whose
retained sync tree reaches 256 levels always snapshots and prunes,
because each change nests that tree one level deeper and serialization
rejects trees deeper than 512 levels.
gcAfterPrune
Section titled “gcAfterPrune”gcAfterPrune:
boolean
Defined in: packages/core/src/compaction-config.ts:51
After pruning the in-memory sync tree, delete the orphaned blocks from the Helia blockstore. Opt-in because deletion is destructive: once a block is gone, peers that lazy-load it via PeerborneDocument.loadChangeBlock or that re-broadcast the change will not be able to fetch the data locally.
Only blocks that this document stored for its own changes while this
option was on are deleted, never blocks fetched from peers or stored by
another document or the application, even when a change tree names them.
Deletion preserves current tree references, snapshot boundaries, recent
tips and existing Helia pins. A changed retention lease pauses the pass;
collectGarbage() can retry retained candidates. One block deletion holds
the mutation queue until its I/O settles, then yields to pending work.
The record of stored blocks, and so the candidate metadata, is bounded to
32,768 identifiers of at most 512 code units each; once it is full, the
oldest stored block is forgotten and kept. This is not a total blockstore
quota or browser heap bound.
CIDs remain in _hashes for incoming-message deduplication.
Has no effect when pruneAfterSnapshot is false.
keepRecentNodes
Section titled “keepRecentNodes”keepRecentNodes:
number
Defined in: packages/core/src/compaction-config.ts:58
Keep at least N recent change nodes after pruning so slightly-behind peers can catch up. A depth-bound prune always keeps the 128 most recent inline changes instead.
minChangesBeforeSnapshot
Section titled “minChangesBeforeSnapshot”minChangesBeforeSnapshot:
number
Defined in: packages/core/src/compaction-config.ts:21
Minimum document changes before the first snapshot, to avoid premature snapshots.
pruneAfterSnapshot
Section titled “pruneAfterSnapshot”pruneAfterSnapshot:
boolean
Defined in: packages/core/src/compaction-config.ts:28
Prune old nodes from the in-memory sync tree after a snapshot. ACL nodes are always preserved. A depth-bound snapshot prunes even when this is false.
snapshotInterval
Section titled “snapshotInterval”snapshotInterval:
number
Defined in: packages/core/src/compaction-config.ts:18
Create a snapshot every N document changes (ACL changes do not count).