import { type RuntimeRecord } from "../domain/records.js"; import type { Engine, RoleId } from "../domain/role-policy.js"; import type { EvidenceReference, EvidenceStore } from "../evidence/store.js"; import type { RuntimeEventBus } from "../events/bus.js"; import type { GoalAuthority } from "../goals/authority.js"; import { type OutboxStore } from "../outbox/store.js"; import { createTicketLifecycleService, type TicketMaterializer } from "../tickets/store.js"; import { type TicketWorktreeRecord } from "../worktrees/manager.js"; import { type WorkerRegistry } from "../workers/registry.js"; import { type CapturedDispatchIntent, type DispatchBudgetSnapshot, type DispatchIntent } from "./intent.js"; export type { CapturedDispatchIntent, DispatchBudgetSnapshot, DispatchIntent, } from "./intent.js"; export type DispatchState = "preparing" | "accepted" | "acknowledged" | "result-received" | "resolved"; export type DispatchResolution = "done" | "blocked"; export interface DispatchProposal extends DispatchIntent { readonly advisor_evidence: EvidenceReference; } export interface DispatchAcknowledgement { readonly dispatch_id: string; readonly worker_record_id: string; readonly session_id: string; readonly operation_nonce: string; readonly acknowledged_at: string; } export interface DispatchResultReceipt { readonly dispatch_id: string; readonly goal_id: string; readonly goal_version: number; readonly worker_record_id: string; readonly session_id: string; readonly ticket_id: string; readonly attempt: number; readonly lease_token: string; readonly worktree_id: string; readonly worktree_path: string; readonly worktree_commit: string; readonly status: DispatchResolution; readonly summary: string; readonly operation_nonce: string; readonly reported_at: string; } export type DispatchPayload = Record & { dispatch_id: string; goal_id: string; goal_version: number; ticket_id: string; ticket_version: number; lease_token: string; attempt: number; worker_record_id: string; worker_id: string; session_id: string; role_id: Extract; model_id: string; engine: Engine; provider_mode: "claude_interactive" | "codex_goal"; worktree_id: string; worktree_path: string; worktree_branch: string; worktree_base_commit: string; worktree_start_commit?: string; prior_failure_evidence: EvidenceReference | null; prior_reflection_evidence: EvidenceReference | null; capabilities: string[]; budget_snapshot: DispatchBudgetSnapshot; acceptance_criteria: string[]; evidence_requirements: string[]; task_body: string; operation_nonce: string; dispatch_intent_sha256?: string; advisor_evidence?: EvidenceReference; policy_version: 2; policy_digest: string; created_at: string; updated_at: string; delivery_event_id: string | null; accepted_at: string | null; acknowledgement: DispatchAcknowledgement | null; result: DispatchResultReceipt | null; executor_evidence: EvidenceReference | null; resolution: DispatchResolution | null; resolved_at: string | null; }; export type DispatchRecord = RuntimeRecord; export interface DispatchAuthority { captureIntent(input: DispatchIntent): CapturedDispatchIntent; propose(input: DispatchProposal): Readonly<{ status: "created" | "replayed"; record: DispatchRecord; }>; acknowledge(input: DispatchAcknowledgement): Readonly<{ status: "applied" | "replayed"; record: DispatchRecord; }>; recordResult(input: DispatchResultReceipt): Readonly<{ status: "applied" | "replayed"; record: DispatchRecord; }>; reconcile(dispatchId: string): DispatchRecord; read(dispatchId: string): DispatchRecord; readIfExists(dispatchId: string): DispatchRecord | undefined; list(): readonly DispatchRecord[]; } export declare function deriveWorktreeId(record: TicketWorktreeRecord): string; export declare function createDispatchAuthority(options: { readonly recordsRoot: string; readonly locksRoot: string; readonly worktreeRecordsRoot: string; readonly packageRoot: string; readonly configRoot: string; readonly workspaceRoot: string; readonly actorId: string; readonly systemActorId: string; readonly goals: GoalAuthority; readonly tickets: ReturnType; readonly ticketMaterializer: TicketMaterializer; readonly workers: WorkerRegistry; readonly evidenceStore: EvidenceStore; readonly events: RuntimeEventBus; readonly outbox: OutboxStore; readonly clock?: () => string; }): DispatchAuthority; export declare function captureStoredDispatchIntent(payload: DispatchPayload): CapturedDispatchIntent; export declare function dispatchWorktreeStartCommit(payload: DispatchPayload): string; export declare function assertDispatchAuthority(value: unknown): asserts value is DispatchAuthority;