Compaction¶
engine.compact() creates a fresh Automerge document from the current state.
This bounds document growth by discarding CRDT change history and clears the
Engine's undo history/checkpoints.
Compaction is rejected while a network or sync is attached. Disconnect first, choose an agreed game-phase or epoch boundary, and compact all replicas at the same boundary. A compacted document cannot merge with pre-compaction documents, so independently compacting peers at different points can prevent the expected merge. Plan a coordinated migration or snapshot handoff before using it in a multiplayer system.
Compaction is not a backup. Save a recoverable copy before compacting and keep operational backups of the resulting document.