export type MultiFrontierPhase = "proposing" | "cross_review" | "converging" | "awaiting_go" | "implementing" | "checkpoint_review" | "paused" | "completed" | "failed" | "canceled"; export type MultiFrontierParticipantRole = "driver" | "watchdog"; export type MultiFrontierParticipantPermission = "read_only" | "workspace_write"; export type MultiFrontierParticipantStatus = "idle" | "running" | "waiting" | "failed" | "completed"; export type MultiFrontierApprovalState = "not_required" | "pending" | "approved" | "rejected"; export type MultiFrontierRecoveryReason = "main_process_restarted" | "driver_crashed" | "watchdog_crashed" | "app_quit" | "canceled"; export interface MultiFrontierParticipantState { participantId: string; provider: string; runtime: string; model?: string; capabilities?: string[]; sessionRef?: string; role: MultiFrontierParticipantRole; permission: MultiFrontierParticipantPermission; status: MultiFrontierParticipantStatus; } export interface MultiFrontierDriverLease { participantId: string; generation: number; leaseState: "inactive" | "active" | "revoked"; } export interface MultiFrontierApproval { state: MultiFrontierApprovalState; proposalId?: string; reviewPacketId?: string; } export interface MultiFrontierRecovery { reason: MultiFrontierRecoveryReason; recoveredAt: string; resumablePhase: MultiFrontierPhase; checkpointId?: string; } /** * The durable state contract shared by the main process and every participant. * Only the main-process coordinator writes it through this module. */ export interface MultiFrontierRunState { schemaVersion: 1; collaborationId: string; /** Opaque local workspace handle; never a filesystem path. */ workspaceId?: string; phase: MultiFrontierPhase; participants: MultiFrontierParticipantState[]; driver: MultiFrontierDriverLease | null; approval: MultiFrontierApproval; checkpointIds: string[]; round: number; proposalIds: string[]; reviewIds: string[]; /** Opt-in policy; explicit GO remains the durable default. */ autoContinueAfterAgreement: boolean; recovery?: MultiFrontierRecovery; } export interface CreateMultiFrontierRunInput { collaborationId: string; workspaceId?: string; phase?: MultiFrontierPhase; participants: MultiFrontierParticipantState[]; approval?: MultiFrontierApproval; checkpointIds?: string[]; autoContinueAfterAgreement?: boolean; } export interface RecoverMultiFrontierRunInput { now: string; reason: MultiFrontierRecoveryReason; } export interface MultiFrontierParticipantEvent { participantId: string; generation?: number; permission: MultiFrontierParticipantPermission; } export interface PersistedMultiFrontierParticipantEvent extends MultiFrontierParticipantEvent { schemaVersion: 1; id: string; collaborationId: string; createdAt: string; status?: MultiFrontierParticipantStatus; } export type MultiFrontierArtifactKind = "proposal" | "review" | "checkpoint"; export interface MultiFrontierArtifactTestSummary { name: string; status: "passed" | "failed" | "skipped"; summary?: string; } /** A bounded, redacted projection used only for Desktop orchestrator recovery. */ export interface MultiFrontierOrchestrationArtifact { id: string; kind: "proposal" | "cross_review" | "revision" | "synthesis" | "checkpoint" | "watchdog_review" | "finding_disposition" | "completion"; round: number; participantId?: string; text: string; attribution: { participantIds: string[]; sourceArtifactIds: string[]; }; supersedesArtifactId?: string; metadata?: Record; } /** * A deliberately narrow coordination record. Full diffs, transcripts, and * provider payloads stay in their owning runtime rather than this durable * cross-provider index. */ export interface PersistedMultiFrontierArtifact { schemaVersion: 1; id: string; collaborationId: string; kind: MultiFrontierArtifactKind; createdAt: string; participantId?: string; title: string; summary: string; supersedesArtifactId?: string; contentHash?: string; fileRefs?: string[]; testSummary?: MultiFrontierArtifactTestSummary[]; orchestration?: MultiFrontierOrchestrationArtifact; } export interface AppendMultiFrontierArtifactInput { id: string; collaborationId: string; kind: MultiFrontierArtifactKind; createdAt?: string; participantId?: string; title: string; summary: string; supersedesArtifactId?: string; contentHash?: string; fileRefs?: string[]; testSummary?: MultiFrontierArtifactTestSummary[]; orchestration?: MultiFrontierOrchestrationArtifact; } export interface MultiFrontierParticipantEventRetention { schemaVersion: 1; retainedEventCount: number; retainedByteCount: number; droppedEventCount: number; droppedByteCount: number; truncated: boolean; replay: { requiresSnapshot: boolean; firstRetainedEventId?: string; }; } export interface MultiFrontierParticipantEventRetentionLimits { maxEventCount: number; maxBytes: number; } export interface AppendMultiFrontierParticipantEventInput extends MultiFrontierParticipantEvent { id: string; collaborationId: string; createdAt?: string; status?: MultiFrontierParticipantStatus; } export interface MultiFrontierStoredRun extends MultiFrontierRunState { createdAt: string; updatedAt: string; } /** * The desktop main-process coordinator is the sole caller of this transition * boundary. Its callback receives a detached snapshot, never renderer input. */ export type MultiFrontierCoordinatorTransition = (current: MultiFrontierStoredRun) => MultiFrontierRunState | MultiFrontierStoredRun | null; export type AppendMultiFrontierParticipantEventResult = { accepted: true; deduplicated: boolean; event: PersistedMultiFrontierParticipantEvent; run: MultiFrontierStoredRun; } | { accepted: false; reason: "missing-run" | "stale-driver" | "missing-participant" | "event-conflict" | "terminal-participant"; run: MultiFrontierStoredRun | null; }; export type AppendMultiFrontierArtifactResult = { accepted: true; deduplicated: boolean; artifact: PersistedMultiFrontierArtifact; run: MultiFrontierStoredRun; } | { accepted: false; reason: "missing-run" | "artifact-conflict" | "missing-participant" | "missing-superseded-artifact" | "artifact-limit-reached"; run: MultiFrontierStoredRun | null; }; export declare const MAX_MULTI_FRONTIER_ARTIFACTS_PER_RUN = 200; export declare const DEFAULT_MULTI_FRONTIER_PARTICIPANT_EVENT_RETENTION: MultiFrontierParticipantEventRetentionLimits; /** All multi-frontier state stays alongside the existing local Code store. */ export declare function multiFrontierRunsStoreRoot(): string; export declare function multiFrontierRunsDir(): string; export declare function multiFrontierParticipantEventsDir(): string; export declare function multiFrontierArtifactsDir(): string; export declare function createMultiFrontierRun(input: CreateMultiFrontierRunInput): MultiFrontierStoredRun; export declare function getMultiFrontierRun(collaborationId: string): MultiFrontierStoredRun | null; export declare function listMultiFrontierRuns(): MultiFrontierStoredRun[]; /** * Recovery never resumes a native participant automatically. Any in-flight * driver lease is revoked and requires an explicit, newly fenced activation. */ export declare function recoverMultiFrontierRun(state: MultiFrontierRunState, input: RecoverMultiFrontierRunInput): MultiFrontierRunState; /** Persist the recovery decision made by the main-process coordinator. */ export declare function recoverStoredMultiFrontierRun(collaborationId: string, input: RecoverMultiFrontierRunInput): MultiFrontierStoredRun | null; /** * Applies one durable coordinator-owned state transition under the run lock. * A state-shaped result retains proposal and review references by default; * returning a full stored record is the explicit escape hatch for a * coordinator operation that intentionally changes those references. */ export declare function transitionStoredMultiFrontierRun(collaborationId: string, updatedAt: string, transition: MultiFrontierCoordinatorTransition): MultiFrontierStoredRun | null; /** * Coordinators must call this before applying a participant event. Write * events are accepted only from the active driver generation. */ export declare function canApplyMultiFrontierParticipantEvent(state: MultiFrontierRunState, event: MultiFrontierParticipantEvent): boolean; /** * Explicitly restores a write lease after recovery. The generation increments * so an event from the interrupted process can never regain write authority. */ export declare function reactivateMultiFrontierDriver(state: MultiFrontierRunState, participantId: string): MultiFrontierRunState | null; /** Assign the first explicit write lease for an implementing run. */ export declare function activateMultiFrontierDriver(state: MultiFrontierRunState, participantId: string): MultiFrontierRunState | null; /** Persist the first explicit driver activation from the main-process coordinator. */ export declare function activateStoredMultiFrontierDriver(collaborationId: string, participantId: string, now?: string): MultiFrontierStoredRun | null; /** Persist an explicit driver reactivation after the human-approved resume. */ export declare function reactivateStoredMultiFrontierDriver(collaborationId: string, participantId: string, now?: string): MultiFrontierStoredRun | null; /** * Appends an idempotent participant event after the coordinator has fenced it. * The event journal is diagnostic; state is mutated only through this guarded * coordinator entry point. */ export declare function appendMultiFrontierParticipantEvent(input: AppendMultiFrontierParticipantEventInput): AppendMultiFrontierParticipantEventResult; /** * Appends a bounded proposal, review, or checkpoint index record. The * coordinator owns both the artifact and its run-state reference under one * run lock, so a reader never observes a durable reference without its record. */ export declare function appendMultiFrontierArtifact(input: AppendMultiFrontierArtifactInput): AppendMultiFrontierArtifactResult; export declare function getMultiFrontierArtifact(collaborationId: string, artifactId: string): PersistedMultiFrontierArtifact | null; export declare function listMultiFrontierArtifacts(collaborationId: string): PersistedMultiFrontierArtifact[]; export declare function listMultiFrontierParticipantEvents(collaborationId: string): PersistedMultiFrontierParticipantEvent[]; export declare function getMultiFrontierParticipantEventRetention(collaborationId: string): MultiFrontierParticipantEventRetention | null; /** * Coordinator maintenance for a bounded event journal. It deliberately keeps * the newest contiguous tail and a replay marker instead of deleting run state. */ export declare function compactMultiFrontierParticipantEvents(collaborationId: string, limits?: MultiFrontierParticipantEventRetentionLimits): MultiFrontierParticipantEventRetention | null; //# sourceMappingURL=multi-frontier-runs.d.ts.map