@me2em/pact
    Preparing search index...

    Class JournalVerifier

    Incremental journal verifier (RC3-D4): the streaming face of the same replay verifyJournal runs — there is no second, "fast" verification path; the only skip is the re-check of an already committed prefix (RC3-D2). Each apply runs the full PACTS §7.7 order on its event (chain → envelope/skew/signatures → semantics/quorum); the committed prefix is protected by a hash-commitment (RC3-D1) that applySuffix re-derives from the caller's actual array on every call — a diverged journal rejects with FORK_DETECTED (RC3-D3, fail-closed, no silent recompute; run verifyJournal for a from-scratch diagnosis of the exact cause).

    The state is opaque and in-memory only (RC3-D6): it is not a wire format and never crosses JournalStore/Channel; suffix verification against a foreign head is verifyPrefix's contract. Failed apply* calls leave the state unchanged — this is the atomicity invariant of the verifier, and it is normative, not incidental: every check precedes every mutation, both in apply itself (chain → envelope → skew → signatures; even the pid latch commits with the event) and inside applyEvent (each event type validates its semantics — quorum, grammar, membership — before its first state.* write; PACTS §7.7 order). The review tests (test/verify.spec.ts, "atomicity") pin this by simulating a failure inside applyEvent and a failed first apply, asserting the whole committed state via _debugState() — a future event type that mutates before it validates will fail them.

    Skew (RC3-D5): the Clock is read per applied event; pin the clock (or set skewCheck: 'none') for era-consistent streaming replays.

    const verifier = createJournalVerifier({ now: () => 1700000000 });
    for (const event of incoming) verifier.apply(event);
    const { roster, journalHead } = verifier.snapshot();
    Index
    • Full verification + application of one event (PACTS §7.7 order: chain → envelope/skew → signatures → semantics/quorum).

      Parameters

      • event: Event

        The event to verify and apply; sq must equal the current height and ph — the current head.

      Returns void

      PactError on the first violation: FORK_DETECTED (chain), MALFORMED / UNKNOWN_EVENT_TYPE / PAYLOAD_TOO_LARGE (envelope/payload), SKEW, SIGNATURE_INVALID, INVALID_QUORUM (semantics). The state is left unchanged on failure.

    • RC3-D2: the cheap integrity pass over the caller's array [0..height) — pid/sq/ph chain plus the hash-commitment re-derived from the actual content (JCS + SHA-256, no signatures, no state machine) — then the full check of [height..len). A no-op suffix applies nothing and still re-checks the prefix.

      Parameters

      • events: Event[]

        The journal array to verify: the committed prefix [0..height) plus the suffix [height..len) to apply in order.

      Returns void

      PactError FORK_DETECTED when the array is shorter than the committed prefix or the prefix diverges from the hash-commitment; otherwise whatever apply throws on the first bad suffix event.