@me2em/pact
    Preparing search index...

    Interface JournalStore

    Append-only journal storage with optimistic CAS-append (C2). Concurrency model: append(expectedHead, event) fails with FORK_DETECTED when the store head has moved — the caller re-reads, re-verifies and retries on the winning branch (history before the split stays valid, D27). Implementations decide persistence; the protocol only fixes the contract.

    const store = new MemoryStore();
    await store.append(ZERO32, genesis); // first event — head ZERO32
    await store.append(await store.head(), next);
    for (const e of await store.read()) console.log(e.sq, e.ty);
    interface JournalStore {
        append(expectedHead: string, event: Event): Promise<void>;
        read(): Promise<Event[]>;
        head(): Promise<string>;
    }

    Implemented by

    Index
    • CAS-append: expectedHead must equal the current JournalHead (ZERO32 for an empty store) AND the event must chain onto it — any divergence rejects with FORK_DETECTED.

      Parameters

      • expectedHead: string
      • event: Event

      Returns Promise<void>