@pwngh/economy-lab
    Preparing search index...

    Class InstanceSession

    A durable journal session: record accepts movements (idempotent per key, screened against the reservation registry), flush commits the pending batch, settle re-derives the net from the journal, re-verifies the hash chain, and posts it in clearing chunks — once per session id, epochs rotate after that. Construct through openInstanceSession, or recoverSession after a crash. A session is a single-writer object: interleaved concurrent record calls can fork the chain on one seq, so a concurrent edge serializes on top (as InstanceEconomy does).

    Index
    • Commits the pending batch to the journal — one insert, one fsync for the whole batch.

      Returns Promise<void>

    • Accepts or rejects one movement. Acceptance means: affordable against (first-touch balance + everything pending across sessions sharing the registry) and queued for the next journal batch. Unbalanced or non-CREDIT legs throw. A repeat of a seen key replays its recorded outcome.

      Parameters

      Returns Promise<MovementOutcome>

    • Settles the whole session: flush, re-derive the net from the JOURNAL (never from memory), re-verify the session chain, then post the net in clearing chunks. On a refused chunk, compensate what posted and replay movement-by-movement, so every accepted movement ends in exactly one ledger-final outcome either way.

      Returns Promise<SettleReport>

    • Whether this session's settle already ran — on a recovered session, what the stored settlement evidence proved. The orphan sweep (src/worker/orphans.ts) reads this to tell a finished epoch from one that still needs settling.

      Returns boolean