import type { AcquiredRunResources, ResourceDisposition, ResourceId, RunResourcePayloads, RunSiteKind, SettlementCause } from "./run-contracts.js"; /** The save-versus-discard decision the settlement makes before any close. */ export type ReuseDecision = { readonly kind: "save"; readonly savedId: ResourceId; } | { readonly kind: "discard"; readonly reason: string; }; /** * The inputs the reuse decision reads. The site derives the candidate from the * settled slots. A null candidate means the run holds nothing to save. */ export interface ReuseCandidateInput { /** The site kind. "host" saves the runtime; "sandbox" saves the staged files. */ readonly kind: RunSiteKind; /** True when the settlement cause permits a save (a clean persistent turn). */ readonly causePermitsSave: boolean; /** * Amendment B: the run-scoped credentials the candidate would still carry into * the store. A save is eligible only when this list is empty — no run-scoped * credential issued to the runtime remains valid. */ readonly liveRunScopedCredentials: readonly string[]; } /** One resource's final disposition, as the settlement records it. */ export interface ResourceDispositionRecord { readonly id: ResourceId; readonly disposition: ResourceDisposition; } /** The per-resource disposition report the settlement produces at the end. */ export interface SettlementDispositionReport { readonly records: readonly ResourceDispositionRecord[]; } /** The settled slots view a step reads. `get` returns undefined for an empty slot. */ export interface SettlementSlots { get(id: Id): RunResourcePayloads[Id] | undefined; has(id: ResourceId): boolean; } /** * The effectful steps the sequence runs. The engine implements each step over * its own run state. Each step no-ops on an empty slot. A step must not throw * for the sequence to record its error and continue; a throw is caught and * recorded under the Phase 3 error policy. */ export interface SettlementSteps { /** * Derive the reuse candidate from the settled slots and the cause, or null * when the run holds nothing to save. */ reuseCandidate(slots: SettlementSlots, cause: SettlementCause | null): ReuseCandidateInput | null; /** Close every runtime the decision did not transfer; drop the warm entry on close. */ endSession(slots: SettlementSlots, decision: ReuseDecision): Promise | void; /** Perform the decision: a save transfers to the site store; everything else discards. */ settleReuse(slots: SettlementSlots, decision: ReuseDecision): Promise | void; /** Stop both bridges in one `allSettled`. */ stopTransport(slots: SettlementSlots): Promise | void; /** The site sync-back. */ syncBack(slots: SettlementSlots): Promise | void; /** Release the staging lease. Runs in a `finally`. */ releaseStagingLease(slots: SettlementSlots): void; /** Record a per-step error under the Phase 3 error policy. */ recordError(step: string, error: unknown): Promise | void; } /** * The pure reuse decision. A save is eligible only when a candidate exists, the * cause permits a save, and Amendment B holds: no run-scoped credential issued * to the candidate remains valid. Everything else discards, with a reason. */ export declare function decideReuse(candidate: ReuseCandidateInput | null): ReuseDecision; /** * Settle the run's resources. Claims the ledger once, makes the reuse decision, * runs the ordered steps under the Phase 3 error policy, releases the staging * lease in a `finally`, and returns the final per-resource disposition report. */ export declare function settleAcpRun(ledger: AcquiredRunResources, cause: SettlementCause | null, steps: SettlementSteps): Promise; //# sourceMappingURL=settlement-sequence.d.ts.map