/**
 * Host-level `session_status` subscriptions.
 *
 * A subscription is connection-scoped and activity-neutral: it never attaches to a session, never counts
 * toward `attachments` and never refreshes a session's idle window. Its records ride the subscribing
 * connection's own FIFO actor, and every publish is called by the writer AFTER it enqueued the record that
 * caused the change, so on a connection that is also attached the status always lands after its cause.
 * `seq` is per subscription: the snapshot carries `seq: 0` and every delta is strictly +1. Reconnecting is
 * a new subscription with a fresh snapshot; nothing is replayed.
 *
 * A new subscription answers through its connection's writer actor BEFORE it goes live: the router calls
 * `subscribe()`, enqueues the response carrying the snapshot, then `activate()` with the resolved
 * subscription id. Deltas published in between are held against the id `subscribe()` already minted and
 * flushed onto the actor the moment `activate()` runs, so no `seq > 0` record can overtake the response
 * that carries the `seq 0` snapshot.
 */
import type { EffectStatus } from "./effect-record.ts";
import { MirrorPending } from "./compact-mirror-pending.ts";
import { type SessionStatusActor, type SessionStatusCause, type SessionStatusLastEffect, type SessionStatusRecord, type SessionStatusTerminal } from "./session-status.ts";
import { type SessionStatusSource, type SessionStatusDelivery, type SubscriptionOptions } from "./session-status-subscriptions.ts";
export type { SessionStatusSource, SessionStatusDelivery } from "./session-status-subscriptions.ts";
/** Optional hook a later effect ledger installs to fill `session_status.lastEffect`. */
export type SessionLastEffectProvider = (sessionId: string) => SessionStatusLastEffect | undefined;
/** One connection may hold at most this many subscriptions; the cap mirrors the selector's own id budget. */
export declare const MAX_SUBSCRIPTIONS_PER_CONNECTION = 64;
export declare class SessionStatusStream {
    onSubscriptionEnd?: (connectionId: string, subscriptionId: string) => void;
    private readonly subscriptions;
    private readonly pendings;
    private readonly terminals;
    private readonly lastViews;
    private readonly lastChanges;
    private source;
    private lastEffect;
    private nextSubscription;
    private readonly delivery;
    constructor(delivery: SessionStatusDelivery);
    setSource(source: SessionStatusSource): void;
    setLastEffectProvider(provider: SessionLastEffectProvider | undefined): void;
    get size(): number;
    connectionSize(connectionId: string): number;
    subscribe(connectionId: string, options: SubscriptionOptions, snapshotSink?: (rows: () => Iterable<SessionStatusRecord>, subscriptionId: string) => void): {
        readonly subscriptionId: string;
        readonly snapshot: readonly SessionStatusRecord[];
        readonly seq: number;
    };
    private snapshotRows;
    /** Flips the subscription live once its answer is on the connection's actor, flushing held deltas. */
    activate(subscriptionId: string): void;
    unsubscribe(connectionId: string, subscriptionId: string): boolean;
    dropConnection(connectionId: string): void;
    pendingBuffer(subscriptionId: string): MirrorPending | undefined;
    private queue;
    /**
     * Publish one change. `contextOnly` changes (a `set_session_context` patch) reach only subscribers that
     * asked for context, because nothing else in the record moved.
     */
    publish(sessionId: string, cause: SessionStatusCause, by: SessionStatusActor, contextOnly?: boolean): void;
    /** Publish one effect transition to every matched `effects: true` subscriber, sharing the seq. */
    publishEffect(sessionId: string, status: EffectStatus): void;
    seal(sessionId: string, terminal: SessionStatusTerminal, cause: SessionStatusCause, by: SessionStatusActor): void;
    forget(sessionId: string): void;
    dialogTargets(sessionId: string): readonly string[];
    mirrorTargets(sessionId: string, recordType: string, dialogs?: boolean): readonly string[];
    mirrorAdmissions(peer: string, sessionId: string, recordType: string): readonly string[];
    private mirrorSubscriptions;
    matchingConnections(sessionId: string): ReadonlyMap<string, boolean>;
    requiredAdmissions(peer: string, sessionId: string): readonly string[];
    requiredSessions(peer: string): readonly string[];
    /** The live view, falling back to the last one seen once the registry has dropped a sealed entry. */
    private currentView;
    private derive;
    private lastChangeOf;
    private recordFor;
}
//# sourceMappingURL=session-status-stream.d.ts.map