import type { JsonValue } from "@decionis/agent-safe-pipeline"; import type { ChainFields } from "../audit/HashChain.js"; import type { DeploymentFingerprint } from "../posture/DeploymentFingerprint.js"; import type { InterceptionReport } from "../gateway/GatewayReport.js"; import { type PlanWrite } from "./AcceptancePlan.js"; import { type AcceptanceReport, type CaseLine, type Coverage } from "./AcceptanceReport.js"; /** The header a run's request carries: `:`. Never forwarded. */ export declare const ACCEPTANCE_RUN_HEADER = "agentsafe-acceptance-run"; /** How long a run stays open before it is discarded unsigned. */ export declare const RUN_TTL_MS: number; /** The longest the close waits for the gateway's reports on what was sent. */ export declare const CLOSE_WAIT_MS = 30000; /** How the gateway routes one write. */ export interface RouteFacts { /** Decided by the authority in enforcement, failing closed or open. */ readonly enforced: boolean; readonly action: string | null; /** Whether the write's profile operation names a read of its target. */ readonly targetRead: boolean; } export interface ShadowOutcome { readonly verdict: "ALLOW" | "BLOCK" | "ESCALATE" | null; readonly reason_codes: readonly string[]; readonly decision_id: string | null; readonly dossier_id: string | null; } export interface OutageOutcome { readonly status: number | null; readonly execution: string | null; readonly reason_codes: readonly string[]; /** Requests other than reads that reached the second gateway's recording upstream. */ readonly upstreamWrites: number; } /** What the gateway lends a run. */ export interface AcceptanceHost { readonly boundaryId: string; readonly fingerprint: DeploymentFingerprint; readonly failurePolicy: "FAIL_CLOSED" | "FAIL_OPEN"; readonly coverage: Coverage; route(write: PlanWrite): RouteFacts; /** The write decided in shadow, captured as its route captures it; nothing read or forwarded. */ decide(write: PlanWrite): Promise; /** The write through a second gateway whose authority is down and whose upstream records. */ outage(write: PlanWrite): Promise; /** Settles once every read after a refusal still due has been made. */ settled(): Promise; /** One line on the gateway's chain, and where it went. */ link(fields: ChainFields): CaseLine; sign(report: AcceptanceReport): Promise; clock(): number; } /** What an endpoint answers. */ export interface RunAnswer { readonly status: number; readonly body: Readonly>; } /** A request carrying the run header: tracked as one write, refused, or the header absent. */ export type Admission = { readonly kind: "NONE"; } | { readonly kind: "REFUSE"; readonly code: string; } | { readonly kind: "TRACK"; readonly name: string; }; export declare class AcceptanceRuns { private readonly host; private readonly random; private run; constructor(host: AcceptanceHost, random?: () => string); /** The open run: none once its time is up, unless it is already closing. */ private current; private named; /** * Opens a run for a plan, once the plan's writes are all writes this gateway * decides in enforcement, and each prohibited one reads its target. A run * already open refuses another until it closes or its time is up. */ open(body: unknown): RunAnswer; /** * A prohibited write the open run names, decided in shadow: nothing read, * nothing forwarded, the decision on the chain. Only a write the plan names * as prohibited is decided, once; the endpoint answers nothing else. */ decide(runId: string, name: string): Promise; /** * Whether a request carrying the run header is a write the open run names, * sent as the plan wrote it, once, and, when prohibited, only after a shadow * BLOCK or ESCALATE. Anything else carrying the header is refused before * the authority is asked, so a run never sends what its plan did not name. */ admit(tag: string | undefined, request: { readonly method: string; readonly path: string; readonly search: string; readonly body: Buffer; }): Admission; /** The intent a tracked write was captured as. */ captured(name: string, intentId: string): void; /** The gateway's answer to a tracked write, for one refused before it was captured. */ answered(name: string, state: string | null, execution: string | null): void; /** What the gateway reported of a tracked write. */ intercepted(report: InterceptionReport): void; /** A line the gateway chained about a tracked write. */ linked(fields: ChainFields, line: CaseLine): void; /** * Closes the run: the zone's findings taken as reported, the outage case * run on the second gateway, every read after a refusal awaited, the report * assembled from what the gateway observed, signed, and its digest chained. */ close(runId: string, findings: unknown): Promise; private outcomeOf; private permittedCase; private prohibitedCase; private outageCase; } //# sourceMappingURL=AcceptanceRun.d.ts.map