/** * What shadow mode found, kept by the gateway itself: for every consequential * request it forwarded unchanged, what the authority said it would have * decided, counted by verdict and by action name, with the first and last * time. It is the report an operator reads before turning enforcement on, * and it is counts only: the action names are the route table's, the * verdicts are the authority's, and no path, body, parameter or identifier * is kept. The authority keeps its own record of the same observations, with * the dossiers; this is the gateway's, available where the gateway runs. */ import type { GatewayConfig } from "./GatewayConfig.js"; export type ShadowVerdict = "ALLOW" | "ESCALATE" | "BLOCK" | "NONE"; export interface ShadowCounts { readonly ALLOW: number; readonly ESCALATE: number; readonly BLOCK: number; /** The authority could not be asked, or did not answer in time: no verdict to count. */ readonly NONE: number; } /** * Of the would-be holds and refusals, how many the upstream accepted as sent * (a 2xx): each is a request that passed every credential and permission * check on its way and would not have passed the authority, which is the * Compromised Principal Test observed rather than stated. */ export interface AcceptedCounts { readonly ESCALATE: number; readonly BLOCK: number; } /** Of the would-be ALLOWs of payments, what the exposure ledger would have said, by status. */ export type ExposureCounts = Readonly>; export interface ShadowSummary { /** * Present once a route that releases money was observed: of its would-be * ALLOWs, what the exposure ledger would have said (`WITHIN_LIMIT`, * `EXCEEDED`, `UNAVAILABLE`, ...). Nothing was counted against a limit. */ readonly exposure?: ExposureCounts; /** When the first and the last observation settled; null before any did. */ readonly since: string | null; readonly until: string | null; readonly observed: number; readonly would: ShadowCounts; readonly accepted: AcceptedCounts; readonly by_action: Readonly>; } /** What `agentsafe` prints on a terminal for a shadow summary, and the switch it ends with. */ export interface ShadowReport { readonly event: "SHADOW_REPORT"; readonly at: string; readonly shadow: ShadowSummary; /** How enforcement is turned on for this configuration, in the operator's own terms. */ readonly enforce: string; } export declare class ShadowLedger { private since; private until; private count; private would; private accepted; private readonly byAction; private exposure; /** How many observations have settled so far. */ get observed(): number; /** * One settled observation: the action, what the authority would have * decided (null when it could not be asked), when, and the status the * upstream answered the forwarded request with (null when it did not). */ record(action: string, verdict: ShadowVerdict | null, at: string, upstreamStatus?: number | null): void; /** What the exposure ledger would have said about one would-be ALLOW of a payment. */ recordExposure(status: string): void; summary(): ShadowSummary; } /** * The one control the report ends with, in the terms this gateway was * configured in: a provisional workspace cannot enforce at all, a file * changes its own line, and the flag or the variable serves the rest. */ export declare function enforcementSwitch(config: GatewayConfig): string; /** The report for a terminal: the counts, the actions, what enforcement would have changed, and the switch. */ export declare function renderShadowReport(report: ShadowReport, options: { readonly color: boolean; }): string; //# sourceMappingURL=ShadowLedger.d.ts.map