import { type WorkflowAtomicFaultInjector } from "./atomic-storage.js"; import type { AmbiguityId, AttemptId, AcceptanceCheck, ContractRevisionId, ModelSpec, ObjectiveContract, PeerMessageId, PeerMessageProjection, RunProjectionV2, RunSource, ReportSchemaV1, ReportSchemaPolicy, WorkerAttemptProjection, WorkerBudget, WorkerContract, WorkerContinuationProvenance, WorkerId, WorkerProjection, WorkerRequest, WorkerLaunchContractV2 } from "./workflow-types.js"; import { WorkflowLeaseManager, type ProcessIdentity } from "./workflow-lease.js"; export interface StartRunInput { readonly requestKey: string; readonly source: RunSource; readonly objective: ObjectiveContract; } export type StartRunResult = { readonly kind: "created"; readonly projection: RunProjectionV2; } | { readonly kind: "existing"; readonly projection: RunProjectionV2; }; export interface WorkflowRunStoreOptions { readonly namespaceDirectory: string; readonly leaseManager: WorkflowLeaseManager; readonly supervisorGeneration: string; readonly randomUUID?: () => string; readonly now?: () => Date; readonly atomicFault?: WorkflowAtomicFaultInjector; } export type RunRecordDiagnostic = { readonly kind: "healthy"; readonly directory: string; readonly projection: RunProjectionV2; } | { readonly kind: "corrupt"; readonly directory: string; readonly diagnostic: string; }; export declare class RunConflictError extends Error { constructor(message: string); } export declare class LedgerIntegrityError extends Error { constructor(message: string); } export declare class BudgetExceededError extends Error { constructor(message: string); } export interface PrepareWorkerIntentResult { readonly kind: "created" | "existing"; readonly projection: RunProjectionV2; readonly worker: WorkerProjection; } export interface PrepareAttemptResult { readonly projection: RunProjectionV2; readonly worker: WorkerProjection; readonly attempt: WorkerAttemptProjection; } export declare class WorkflowRunStore { #private; constructor(options: WorkflowRunStoreOptions); startRun(input: StartRunInput): Promise; subscribe(listener: (projection: RunProjectionV2) => void): () => void; readRun(requestKey: string): Promise; listRuns(): Promise; diagnoseRunRecords(): Promise; recordWorkerIntent(inputRequestKey: string, input: { readonly createdByDriverSessionId: string; readonly sessionPath: string; readonly request: WorkerRequest; }): Promise; prepareWorkerIntent(inputRequestKey: string, input: { readonly createdByDriverSessionId: string; readonly sessionPath: string; readonly request: WorkerRequest; readonly parentWorkerId: WorkerId | null; readonly depth: number; readonly continuation?: WorkerContinuationProvenance; }): Promise; prepareReplacementAttempt(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly model?: ModelSpec; readonly fallbackReason?: string; }): Promise; recordAttemptStarted(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly attemptId: AttemptId; readonly workerAttemptGeneration: string; readonly leaseGeneration: string; readonly processIdentity: ProcessIdentity; /** Write side is schema 2 only; schema 1 stays readable history and never launches a child. */ readonly launchContract: WorkerLaunchContractV2; }): Promise; recordWorkerReady(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly attemptId: AttemptId; readonly workerAttemptGeneration: string; readonly sessionFile: string; }): Promise; recordAttemptUsage(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly attemptId: AttemptId; readonly workerAttemptGeneration: string; readonly tokens: number; readonly costUsd: number; readonly outputBytes: number; }): Promise; requestWorkerCancellation(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly reason: string; }): Promise; recordCancellationSignalSent(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly attemptId: AttemptId; readonly workerAttemptGeneration: string; readonly signal: string; }): Promise; recordAttemptExit(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly attemptId: AttemptId; readonly workerAttemptGeneration: string; readonly exitStatus: { readonly code: number | null; readonly signal: string | null; }; readonly candidateOutcome: { readonly valueOrRef: string | null; readonly hash: string | null; }; readonly uncertainSideEffects: boolean; readonly reason: string; }): Promise; recordWorkerNeedsAttention(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly attemptId: AttemptId; readonly workerAttemptGeneration: string; readonly reason: string; readonly ambiguous: boolean; }): Promise; requestContractRevision(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly correlation?: string; readonly goal?: string; readonly acceptance?: readonly string[]; readonly constraints?: readonly string[]; readonly report_schema?: ReportSchemaV1 | null; readonly report_schema_policy?: ReportSchemaPolicy; readonly requires_human_approval?: boolean; readonly acceptance_check?: AcceptanceCheck | null; }): Promise; recordContractRevisionDelivered(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly revisionId: ContractRevisionId; readonly boundary: "next-inference"; }): Promise; recordCollectObservation(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly structuredPayload: unknown; readonly consecutiveRounds: number; }): Promise; recordSilentStall(inputRequestKey: string, input: { readonly workerId: WorkerId; }): Promise; recordGateEvaluation(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly reportMatches: boolean | null; readonly acceptanceCheckExitCode: number | null; readonly humanApproved: boolean | null; readonly evidenceExists?: boolean; }): Promise; recordSteerDelivered(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly messageHash: string; readonly correlation?: string; }): Promise; recordWorkerWaitDeclared(inputRequestKey: string, input: { readonly workerId: WorkerId; readonly attemptId: AttemptId; readonly workerAttemptGeneration: string; readonly reason: string; readonly correlation: string; }): Promise; recordPeerMessageRequested(inputRequestKey: string, input: { readonly senderWorkerId: WorkerId; readonly recipientWorkerId: WorkerId; readonly grant: string; readonly correlation: string; readonly messageHash: string; }): Promise<{ readonly projection: RunProjectionV2; readonly message: PeerMessageProjection; }>; recordPeerMessageDelivery(inputRequestKey: string, input: { readonly messageId: PeerMessageId; readonly recipientWorkerId: WorkerId; readonly recipientAttemptId: AttemptId; readonly recipientWorkerAttemptGeneration: string; readonly status: "delivered" | "indeterminate"; readonly diagnostic?: string; }): Promise; markAmbiguous(inputRequestKey: string, input: { readonly ambiguityId?: AmbiguityId; readonly reason: string; readonly relatedIds: readonly string[]; }): Promise; recordReconciliation(inputRequestKey: string, input: { readonly ambiguityId: AmbiguityId; readonly decision: string; readonly evidenceRefs: readonly string[]; readonly workerState?: Exclude; }): Promise; } export declare function runDirectoryForRequest(namespaceDirectory: string, requestKey: string): string; export declare function effectiveWorkerContract(worker: WorkerProjection): WorkerContract; export declare function latestWorkerContract(worker: WorkerProjection): WorkerContract; export declare function expectedWorkerCadenceMs(budget: WorkerBudget): number; /** Worker output bytes are measured on Pi's own event stream, not on the answer text. */ export declare const OUTPUT_BYTE_UNIT_NOTE: string; //# sourceMappingURL=run-store.d.ts.map