import { type PlacedDecision, type PlacedFault } from './placements.js'; import type { RateBucket, RateBucketRequest, RateBudgetDeclaration, RateValues } from './rateBudget.js'; /** What a consumption reads and writes: the twin's own bookkeeping rows, at the request's World time. `recording` is * false for a read-only request, which consumes nothing; `reads` is true for a request whose operation writes nothing, * whose consumption stays off the log. */ export type ScenarioLedger = { vendor: string; service: string; root?: string; at: string; recording: boolean; reads?: boolean; rows(type: '_decision' | '_fault'): Array>; record(type: '_decision' | '_fault', fields: Record, id?: string): Promise; }; /** The vendor's judgement at `point` for `subject`: the one already taken for them, else the first decision * placed for it, else `byDefault`. Taken in a write, it is recorded in the log; in a request that writes nothing, its * use is counted in the scenario ledger and noted in the request's journal (ADR 0036 ยง4). */ export declare function decide(ledger: ScenarioLedger, point: string, subject: string, byDefault: T): Promise; /** The model turns placed for this vendor and not yet used up, in order: what the kernel matches a turn * against with the pack's matchers. */ export declare function turnDecisions(ledger: ScenarioLedger): PlacedDecision[]; /** Record a turn's decision: the placed one that answered it, or the labelled default. */ export declare function recordTurn(ledger: ScenarioLedger, chosen: PlacedDecision | undefined, outcome: unknown): Promise; /** The request faults placed on this vendor that are not used up, in order. */ export declare function requestFaults(ledger: ScenarioLedger): PlacedFault[]; /** Record a fault that landed: in the log where it is part of a write's history, else as `noteFault`. */ export declare function recordFault(ledger: ScenarioLedger, fault: PlacedFault, where: Record): Promise; /** A fault that landed on a request that writes nothing (a read; a request refused before the vendor acts): its landing * counted in the scenario ledger, so its `times` is used up, and noted in the request's journal line. */ export declare function noteFault(ledger: ScenarioLedger, fault: PlacedFault, where: Record): Promise; /** A fault placed at a point of the pack's own (one item of a batch), for `subject`; recorded when it lands. */ export declare function faultAt(ledger: ScenarioLedger, point: string, subject: string): Promise; /** A ledger over a twin's store alone, for the kernel's own paths that open no context (an event's delivery, the * idempotency layer a failure lands in). */ export declare function serviceLedger(input: { vendor: string; service: string; root?: string; at: string; recording: boolean; reads?: boolean; }): ScenarioLedger; /** The first webhook fault of `kinds` placed on this vendor for an event type, not used up: an event's write asks for a * delay or a duplicate, each attempt for a drop, so one kind never hides another. */ export declare function webhookFault(ledger: ScenarioLedger, type: string, kinds: readonly string[]): PlacedFault | undefined; /** The `lag` placed on this vendor's eventually consistent operations (an `operation` names one), if any. */ export declare function listLag(ledger: Pick, operation: string): PlacedFault | undefined; /** One bucket a request was counted in, or refused by, and the values its templates read. */ export type RateCount = { bucket: RateBucket; values: RateValues; }; /** What the vendor's switched-on buckets made of a request: the bucket that refused it, or every bucket it was counted * in; `release` ends its time in flight (a bucket's `concurrency`) once it is answered. */ export type RateOutcome = { refused?: RateCount; counted: RateCount[]; release(): void; }; /** The vendor's buckets as the `rate-limit`s placed switch them on: every bucket the pack declares, or the one * a fault names, its `limit` per `per` tightened where the fault gives one (never loosened). The request is weighed and * keyed in each bucket it belongs to and, under the scenario ledger's lock, refused by the first it would exhaust * (counted in none) or counted in all. Undefined when no rate-limit is placed: nothing is counted. A read-only request is * not counted. Windows and refills run on the request's World time. */ export declare function rateLimited(ledger: ScenarioLedger, request: RateBucketRequest, declared: RateBudgetDeclaration | undefined): Promise;