/** * Per-attempt receipts. * * Every attempt gets an immutable receipt: run_id, attempt_id, * lease_generation, launch token (clientToken + startedBy), task id, * timestamps, image + bundle digests, the frozen policy, and — once the * attempt reaches a terminal outcome — exit code and artifact/log pointers. * Receipts are written through the storage adapter; the terminal receipt * finalizes the run row. */ import type { RunExecutionStore } from "./storage.js"; import type { AttemptReceipt, AttemptRecord, FrozenAdmission, TerminalRunStatus } from "./types.js"; export type { AttemptReceipt }; export interface CreateAttemptReceiptInput { admission: FrozenAdmission; attempt: AttemptRecord; /** ECS task arn, when the launch is confirmed. */ taskId: string | null; launchedAt: string; artifactPointers?: string[]; logPointers?: string[]; } export interface FinalizeAttemptReceiptInput { runId: string; attemptId: string; status: TerminalRunStatus; exitCode: number | null; completedAt: string; artifactPointers?: string[]; logPointers?: string[]; costCents?: number | null; } export interface ReceiptService { /** Persist the launch-time receipt before (or right after) the launch call. */ recordLaunch(input: CreateAttemptReceiptInput): Promise; /** Finalize the attempt's receipt; also finalizes the run row. */ finalize(input: FinalizeAttemptReceiptInput): Promise<{ receipt: AttemptReceipt | null; runId: string; status: TerminalRunStatus; }>; get(runId: string, attemptId: string): Promise; } export declare function createReceiptService(store: RunExecutionStore): ReceiptService;