export declare const WORK_INTENT_SCHEMA_VERSION: 2; export declare const WORK_EVENT_SCHEMA_VERSION: 1; export type WorkState = "waiting" | "ready" | "running" | "awaiting_approval" | "in_review" | "blocked" | "succeeded" | "cancelled"; export type WorkNextAction = "wait_for_dependencies" | "run" | "wait_for_run" | "resolve_approval" | "resume" | "retry" | "review" | "none"; export type WorkAttemptTrigger = "initial" | "retry"; export interface WorkIntent { schema_version: typeof WORK_INTENT_SCHEMA_VERSION; id: string; title: string; objective: string; acceptance: string[]; dependencies: string[]; workflow: { path: string; sha256: string; }; max_attempts: number; /** Ceiling on consecutive uncharged attempts (ADR 0046), separate from * max_attempts. An upstream outage produces uncharged attempt after uncharged * attempt; without a bound it would retry forever. At the bound the item stops * and reports it is blocked on an outside service. */ max_uncharged_attempts: number; source?: { kind: "human" | "workflow" | "external"; ref?: string; }; created_at: string; } export type WorkEventType = "work.created" | "work.reconciled" | "attempt.started" | "attempt.resumed" | "work.accepted" | "work.cancelled" | "work.reopened"; export interface WorkEvent { schema_version: typeof WORK_EVENT_SCHEMA_VERSION; work_id: string; seq: number; ts: string; event: WorkEventType; actor: string; reason?: string; run_id?: string; attempt?: number; trigger?: WorkAttemptTrigger; workspace_binding_id?: string; proof_sha256?: string; terminal_attestation_sha256?: string; accepted_unknowns?: string[]; /** Operator corrections raised with a reopen. Authored by a human against a * prior attempt, carried into the next attempt, and open until disposed. */ findings?: WorkOperatorFinding[]; /** How an operator disposed of each open finding at acceptance. */ dispositions?: WorkFindingDisposition[]; state?: WorkState; next_action?: WorkNextAction; } export interface WorkOperatorFinding { id: string; statement: string; } export interface WorkFindingDisposition { id: string; outcome: "fixed" | "deferred"; reason?: string; } export interface WorkAttempt { number: number; run_id: string; started_at: string; trigger?: WorkAttemptTrigger; status: "running" | "parked" | "succeeded" | "failed" | "lost" | "transcript_unreadable"; approval_id?: string; proof_path?: string; transcript_error?: string; /** Why this failed attempt was uninformative about the work (ADR 0046), read * from the proof's run.class. Absent ⇒ the attempt is charged, exactly as * before ADR 0046 (which is also how a proof without a class reads). */ uncharged?: "environment" | "upstream" | "decision"; /** Docket id this attempt stopped on, when uncharged is "decision" and the * script named one. Lets the projection point at the question itself. */ blocked_on?: string; } export interface WorkProjection { id: string; title: string; state: WorkState; reason: string; next_action: WorkNextAction; unresolved_dependencies: string[]; attempts: WorkAttempt[]; /** Every attempt started, charged or not. Drives the next attempt number and * history ordering, so it counts uncharged attempts too. */ attempts_used: number; /** Attempts that were informative about the work (ADR 0046). This — not * attempts_used — is what max_attempts budgets, so an uncharged environment or * upstream attempt does not consume the retry budget. */ charged_attempts: number; attempts_remaining: number; latest_run_id?: string; approval_id?: string; proof_path?: string; /** Set when this item stopped because a human must rule. The value is the * docket id when the script named one, else the empty string — present either * way, so a reader can distinguish "waiting on a person" from every other * terminal block without parsing the reason prose. */ blocked_on_decision?: string; updated_at: string; } export interface WorkRecord { intent: WorkIntent; events: WorkEvent[]; projection: WorkProjection; } export interface WorkListWarning { work_id: string; reason: string; } export interface WorkListResult { records: WorkRecord[]; warnings: WorkListWarning[]; } export interface CreateWorkItemInput { coordRoot: string; title: string; objective: string; workflowPath: string; acceptance?: string[]; dependencies?: string[]; maxAttempts?: number; maxUnchargedAttempts?: number; source?: WorkIntent["source"]; id?: string; actor?: string; } export declare function createWorkItem(input: CreateWorkItemInput): WorkRecord; export declare function readWorkItem(coordRoot: string, workId: string): WorkRecord; export declare function listWorkItems(coordRoot: string): WorkRecord[]; export declare function listWorkItemsWithWarnings(coordRoot: string): WorkListResult; export declare function reconcileWorkItem(coordRoot: string, workId: string, actor?: string): WorkRecord; export declare function reconcileAllWorkItems(coordRoot: string, actor?: string): WorkRecord[]; export declare function acceptWorkItem(coordRoot: string, workId: string, input?: { actor?: string; reason?: string; acceptedUnknowns?: readonly string[]; dispositions?: readonly WorkFindingDisposition[]; }): WorkRecord; export declare function cancelWorkItem(coordRoot: string, workId: string, input?: { actor?: string; reason?: string; }): WorkRecord; export declare function reopenWorkItem(coordRoot: string, workId: string, input?: { actor?: string; reason?: string; findings?: readonly string[]; }): WorkRecord; /** Findings raised by the most recent reopen that no later acceptance disposed * of. Empty when the work was never reopened with findings. */ export declare function openOperatorFindings(coordRoot: string, workId: string): { actor: string; findings: WorkOperatorFinding[]; }; export declare function assertWorkId(workId: string): void; export declare function newWorkId(): string; export declare function newWorkflowRunId(): string; /** @internal Runner seam; not a separate persistence contract. */ export declare function appendReconcileIfChanged(coordRoot: string, record: WorkRecord, actor: string): void; /** @internal Runner seam; not a separate persistence contract. */ export declare function appendWorkEvent(coordRoot: string, workId: string, input: Omit): WorkEvent; /** @internal Runner seam; not a separate persistence contract. */ export declare function readWorkItemIgnoringLease(coordRoot: string, workId: string): WorkRecord; /** @internal Runner seam; not a separate persistence contract. */ export declare function assertWorkflowUnchanged(intent: WorkIntent): void; /** @internal Runner seam; not a separate persistence contract. */ export declare function acquireWorkLease(coordRoot: string, workId: string): () => void; /** @internal Work transcript mutation seam. */ export declare function acquireWorkEventLease(coordRoot: string, workId: string): () => void; /** @internal Runner seam; not a separate persistence contract. */ export declare function boundedActor(value?: string, fallback?: string): string; //# sourceMappingURL=state.d.ts.map