Marmot-TS
    Preparing search index...

    Interface GroupHistoryTree

    The retained group history tree (Marmot v2 full-fork history). Holds every group state ever observed — the canonical branch and every fork — as a tree of ClientState snapshots linked by commit edges. No pruning is performed: the tree retains everything.

    The light index (per-node epoch/parent/edge metadata) is always resident. Heavy material (serialized snapshots + commit bytes) is kept in a bounded in-memory LRU and otherwise fetched from a backing key-value store on demand, so memory stays bounded even as the tree grows without limit. Newly recorded nodes are pinned in memory until flush persists them.

    Snapshots are stored as bytes, never as live ClientState objects: ts-mls zeroes a parent state's consumed secrets in place when a commit is processed from it, so a retained live object could be corrupted out from under a sibling-branch replay. Re-deriving a state (stateAt) decodes a fresh, independent object every call.

    interface GroupHistoryTree {
        get isDirty(): boolean;
        get rootTag(): string | undefined;
        get size(): number;
        ancestors(tag: string): string[];
        bindStore(store: HistoryTreeStore): void;
        childrenOf(tag: string): string[];
        commitBytesOf(
            childTag: string,
        ): Promise<Uint8Array<ArrayBufferLike> | undefined>;
        commitMessageOf(childTag: string): Promise<MlsMessage | undefined>;
        epochOf(tag: string): number | undefined;
        flush(): Promise<void>;
        hasNode(tag: string): boolean;
        isTip(tag: string): boolean;
        lowestCommonAncestor(a: string, b: string): string | undefined;
        node(tag: string): HistoryNode | undefined;
        nodesAtEpoch(epoch: number): string[];
        parentOf(tag: string): string | undefined;
        path(tag: string): string[] | undefined;
        recordCommit(
            parentTag: string,
            commitMessage: MlsMessage,
            childState: ClientState,
            senderLeafIndex?: number,
        ): string;
        recordEdge(edge: EdgeSnapshot): boolean;
        setRoot(state: ClientState): string;
        snapshotOf(tag: string): Promise<Uint8Array<ArrayBufferLike> | undefined>;
        stateAt(tag: string): Promise<ClientState | undefined>;
        tags(): string[];
        tips(): string[];
        updateSnapshot(tag: string, state: ClientState): void;
    }
    Index

    Engine

    • Binds a backing store to a fresh, in-memory tree so its nodes can be flushed and its heavy material later evicted/reloaded. Marks every current node dirty so the first flush persists the whole tree. A no-op if the same store is already bound (e.g. on a tree loaded via load).

      Parameters

      • store: HistoryTreeStore

      Returns void

    • Persists all unflushed nodes incrementally: each dirty node's light edge record, snapshot, and commit bytes are written under its own keys, plus the meta (root) record. Append-only — already-persisted nodes are untouched, so a save costs O(new nodes), not O(tree). Requires a bound store.

      Returns Promise<void>

    • Records a commit applied from a retained parent node to its resulting child state, adding (or linking) the child node. Idempotent on the child tag: a duplicate commit re-links without overwriting. Throws if the parent is not already in the tree.

      Parameters

      Returns string

      the child node tag.

    • Records an edge from a snapshot captured at branch-build time. Unlike recordCommit, the child snapshot is supplied pre-serialized — fork recovery serializes each branch state the instant it is produced, before ts-mls can zero that state's secrets when exploring its children. Idempotent on the child tag. Returns false (without recording) when the parent is not yet in the tree, so a batch can skip a dangling edge instead of throwing.

      Parameters

      • edge: EdgeSnapshot

      Returns boolean

    • The serialized ClientState snapshot bytes for a node, or undefined if absent. Served from the in-memory cache, else fetched from the store.

      Parameters

      • tag: string

      Returns Promise<Uint8Array<ArrayBufferLike> | undefined>

    • Replaces a node's retained snapshot — used after staging a proposal onto a node, which updates its unappliedProposals without advancing the epoch. The new state's confirmation tag MUST equal the node tag (staging a proposal does not change it). Throws if the node is absent or the tag would change.

      Parameters

      Returns void