@me2em/pact
    Preparing search index...

    Function finalize

    • Fail-closed assembly (B-7): the extended journal must verify. Any verification failure (chain, signatures, quorum, semantics) throws the underlying PactError — the caller receives a usable event only when the whole journal replays clean. Skew of the historical prefix is intentionally out of scope (ТЗ §3.4: assembly does not defend against skew — verify does, C3): the assembly clock may legitimately be far from the prefix's era (a fresh event appended to history).

      Cost (rc.3): a cache hit verifies only the new event in full — the prefix costs a cheap hash-integrity pass (RC3-D2) instead of the rc.2 full replay; a miss replays from scratch (rc.2 behavior).

      Parameters

      • events: Event[]

        The verified journal prefix to extend.

      • event: Event

        The fully built event (envelope + payload + signatures).

      • clock: Clock

        The assembly clock (also keys the verifier cache).

      Returns Event

      The same event — now proven to continue a clean replay.

      PactError on any verification failure (B-7 — fail-closed): chain, envelope, signatures, semantics.

      const signed = { ...raw, sig: signaturesFor(raw, keys) };
      const event = finalize(events, signed, clock);