agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
52 lines (51 loc) • 2.53 kB
TypeScript
/**
* hosting/signin/memorySignIns — the bounded in-memory {@link SignInStore}.
*
* Bounded (rule 19), and fair — one person can never sign everybody else out
* (review idI34 S-1):
*
* - **A per-account cap** (default 10 live sign-ins per `userId`). A person's
* eleventh sign-in ends THAT person's oldest; nobody else's.
* - **Dead rows are swept** before anything is counted — past their lifetime,
* or idle longer than `idleMinutes` when given (the door's own idle limit;
* review idI57 N-12) — so dead sign-ins never crowd out live ones.
* - **A full store REFUSES** a new sign-in ({@link SignInStoreFullError}, the
* door answers 503) rather than evicting another account's live sign-in.
* - **Every end is announced** through `onDelete`, which `signInSource` turns
* into its `onEnd` — so a socket carrying an ended sign-in closes at once.
*
* Per process, and stated: a restart signs everybody out, and a second replica
* does not know the first one's sign-ins. Run one replica, pin each browser to
* one (sticky sessions), or put a shared store behind the same verbs.
*/
import type { SignInStore } from './types.js';
export { MemorySignInsConfigError } from './errors.js';
export interface MemorySignInsOptions {
/** The most live sign-ins kept at once. Default 10 000. */
readonly max?: number;
/** The most live sign-ins one account may hold. Default 10. */
readonly perAccount?: number;
/**
* Minutes without use after which a row is dead — pass the door's
* `idleMinutes` so an idle sign-in stops holding a place against `max`.
* Absent: only the lifetime (`expiresAt`) is swept.
*/
readonly idleMinutes?: number;
/** The clock, epoch ms, for sweeping expired rows. Default `Date.now`. */
readonly now?: () => number;
/** Told once when the store passes 90 % of `max`. Default: `console.warn`. */
readonly warn?: (message: string) => void;
}
/** The in-memory store, plus what a banner or a test needs to read. */
export interface MemorySignIns extends SignInStore {
/** How many sign-ins are kept right now. */
readonly size: number;
/** The cap. */
readonly max: number;
/** The per-account cap. */
readonly perAccount: number;
onDelete(listener: (key: string) => void): () => void;
}
export declare const DEFAULT_SIGN_IN_MAX = 10000;
export declare const DEFAULT_SIGN_INS_PER_ACCOUNT = 10;
export declare function memorySignIns(options?: MemorySignInsOptions): MemorySignIns;