/** * One governed attempt whose outcome nobody knows: the upstream answered 5xx * or nothing after the request was sent. Kept by the client's * `Idempotency-Key`, so a retry with that key can be linked to it, and a * different request under that key refused. */ export interface IndeterminateAttempt { /** `retryDigest` of the request: what the key promised. */ readonly requestDigest: string; readonly intentId: string; readonly decisionId: string | null; readonly dossierId: string | null; /** * The exposure reservation key the attempt drew under, when its route * releases money: a retry reserves under it, so what the attempt kept is * ended with the retry's outcome rather than drawn a second time. */ readonly reservationKey?: string; readonly recordedAt: string; readonly expiresAt: number; } /** * Where a gateway remembers its INDETERMINATE attempts, by the client's * idempotency key, within one tenant. Nothing else is kept: no body, no * header, and the key itself only as the name it is found by. */ export interface AttemptStore { /** False when the store is full or cannot write: the attempt is not remembered. */ record(idempotencyKey: string, attempt: IndeterminateAttempt): boolean; /** The live record under a key; an expired or unreadable one is removed and is absent. */ find(idempotencyKey: string): IndeterminateAttempt | undefined; /** Forgets the record under a key, only if it is for this request. */ forget(idempotencyKey: string, requestDigest: string): void; close(): void; } /** How long an INDETERMINATE attempt is remembered: a day, well inside the hold store's seven-day ceiling. */ export declare const ATTEMPT_TTL_MS: number; /** The most INDETERMINATE attempts one gateway remembers. */ export declare const MAX_ATTEMPTS = 1000; /** In this process's memory: lost on restart, and seen only by this replica. */ export declare class MemoryAttemptStore implements AttemptStore { private readonly clock; private readonly attempts; constructor(clock: () => number); record(idempotencyKey: string, attempt: IndeterminateAttempt): boolean; find(idempotencyKey: string): IndeterminateAttempt | undefined; forget(idempotencyKey: string, requestDigest: string): void; close(): void; private sweep; } /** The subdirectory of the hold directory the records live in. */ export declare const ATTEMPT_DIRECTORY = "attempts"; /** * INDETERMINATE attempts as files beside the durable holds, in the same * custody: the directory every replica mounts and the hold key. Each file is * sealed with AES-256-GCM under the hold key, its associated data the tenant * and the idempotency key, so a file copied to another tenant, or renamed to * another key, does not open. A file is named by an HMAC of the tenant and * the key under a name key derived from the hold key, so the directory says * nothing about the keys clients sent. A record is replaced by a rename, so a * reader on any replica sees a whole record or none. */ export declare class FileAttemptStore implements AttemptStore { private readonly scope; private readonly clock; private readonly key; private readonly nameKey; private readonly dir; constructor(holdDir: string, keyFile: string, scope: string, clock: () => number); record(idempotencyKey: string, attempt: IndeterminateAttempt): boolean; find(idempotencyKey: string): IndeterminateAttempt | undefined; forget(idempotencyKey: string, requestDigest: string): void; close(): void; /** Removes expired records and orphaned temporary files; returns how many are live. */ sweep(): number; private unseal; private aad; private path; private static exists; private static expiresAt; private static olderThan; } //# sourceMappingURL=AttemptStore.d.ts.map