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

    Interface ClusterNode

    One node's handle. ownerOf/owns/assertOwns answer the shared rendezvous assignment; openSession opens ownership-gated epochs; recover finishes a crashed node's session; laneOptions spreads into the lane manager; sweepOrphans runs the shared-journal sweep. Construct through openClusterNode.

    interface ClusterNode {
        nodeId: string;
        reservations: Reservations;
        assertOwns(scope: string): void;
        laneOptions(): { epochMaxAgeMs: number; reservations: Reservations };
        openSession(
            scope: string,
            options?: Omit<SessionOptions, "reservations">,
        ): InstanceSession;
        ownerOf(scope: string): string;
        owns(scope: string): boolean;
        recover(sessionId: string): Promise<InstanceSession>;
        sweepOrphans(
            input?: { limit?: number; now?: number },
        ): Promise<OrphanSweepSummary>;
    }
    Index
    nodeId: string
    reservations: Reservations

    The store-backed registry every session on this node screens against. Pass it wherever a registry is asked for (the worker's orphans job, a lane manager not built from laneOptions); never build a second one per node.

    • Throws SESSION_MISROUTED unless this node owns the scope — the gate for a request edge.

      Parameters

      • scope: string

      Returns void

    • Spread into openInstanceEconomies so the manager's lanes share this node's registry and rotate under the same bound the sweep law was validated against.

      Returns { epochMaxAgeMs: number; reservations: Reservations }

    • Opens the scope's next raw netting epoch: ownership-gated, screened by the shared registry, session id minted as sess:<scope>:<nonce>-<n>. The caller owes the epoch discipline — settle within epochMaxAgeMs, then open the next epoch (the lane manager does both on cadence; see laneOptions).

      Parameters

      Returns InstanceSession

    • The scope's owning node per the rendezvous assignment — the same answer on every node.

      Parameters

      • scope: string

      Returns string

    • Whether the assignment routes the scope here; the boolean form of ClusterNode.ownerOf.

      Parameters

      • scope: string

      Returns boolean

    • Rebuilds a journaled session with the shared registry wired in — the failover path for a session id the sweep reported. The shared counter already holds the crashed node's reservations, and wiring the registry here is what tells recovery not to re-apply them.

      Parameters

      • sessionId: string

      Returns Promise<InstanceSession>

    • One orphan-sweep pass over the shared journal: reports crashed epochs, settles the ones older than the validated bound when the sweep opt-in is set, and releases their reservations. Schedule it like any worker sweep; more than one node running it is safe (settling is idempotent against stored evidence).

      Parameters

      • Optionalinput: { limit?: number; now?: number }

      Returns Promise<OrphanSweepSummary>