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

    Interface InstanceEconomies

    The lane manager's handle. laneFor hands out the scope's current-epoch lane, opening on demand; rotate settles one scope now; sweep rotates every scope past its movement or age bound; settleAll drains everything; start runs the sweep on a timer; pending and stats read across every lane. A settle that throws keeps its lane, so the next sweep retries instead of stranding the epoch. Construct through openInstanceEconomies.

    interface InstanceEconomies {
        laneFor(scope: string): InstanceEconomy;
        pending(userId: string): Promise<Amount>;
        rotate(scope: string): Promise<InstanceSettleReport | null>;
        settleAll(): Promise<InstanceSweepReport>;
        start(everyMs: number): () => void;
        stats(): { accepted: number; rejected: number; scopes: number };
        sweep(): Promise<InstanceSweepReport>;
    }
    Index
    • The user's pending-out total across every lane this manager runs (they share one registry), so a display layer shows balance - pending with one call, whatever scope the spend is in.

      Parameters

      • userId: string

      Returns Promise<Amount>

    • Settles the scope's current epoch now; the next laneFor opens the next epoch. A settle that throws keeps the lane (a settled session refuses new movements on its own, and the journal is durable), so the next rotate or sweep retries instead of stranding the epoch.

      Parameters

      • scope: string

      Returns Promise<InstanceSettleReport | null>

    • Runs sweep on a timer — the Scheduler port when the deps carry one, a built-in interval otherwise — and returns the stop function. Stopping the timer settles nothing; call settleAll to drain.

      Parameters

      • everyMs: number

      Returns () => void

    • The dashboard roll-up across every open lane.

      Returns { accepted: number; rejected: number; scopes: number }