import { type LunaFabricSolReason } from "./luna-fabric-contract.js"; import { type LunaFabricSchedulerState } from "./luna-fabric-scheduler.js"; import type { ParallelDispatchArchive, ParallelDispatchDescriptor, ParallelDispatchOutcome, ParallelDispatchSnapshot, WorktreeParallelContract, WorktreeCommitArtifact } from "./types.js"; import { type ExecutionPlan } from "./execution-plan.js"; import { RunFlightLedger } from "./run-flight-ledger.js"; import { type ValidationBudgetRequest, type ValidationOutcome } from "./validation-budget.js"; import type { ChildTerminalEvidence } from "./child-terminal-reconciliation.js"; import { type ChildTerminalIdentity } from "./child-terminal-reconciliation.js"; import { CancellableChildLifecycle } from "./child-lifecycle-runtime.js"; import { type CriticalPathInput, type CriticalPathResult, type CriticalPathTakeoverTrigger } from "./critical-path.js"; import { type FabricWaveBoundaryIdentity, type WaveBoundaryRecoveryBudget, type WaveBoundaryReplayReason } from "./wave-boundary-replay.js"; export declare function decideFabricValidationAdmission(request: ValidationBudgetRequest, consumed: number, events: readonly unknown[]): { decision: "DENY"; reason: string; redundant_time_ms: number; reused_fingerprint: null; scope: import("./validation-budget.js").ValidationScope | null; evidence_key: string | null; consumed: number; } | { reused_fingerprint: string | null; decision: "ALLOW" | "SKIP" | "DENY"; reason: "invalid-contract" | "duplicate-evidence" | "budget-exhausted" | "retry-justification-required" | "marginal-value-required" | "owner-mismatch" | "allowed"; scope: import("./validation-budget.js").ValidationScope | null; evidence_key: string | null; consumed: number; redundant_time_ms: number; }; export interface FabricValidationSettlement { readonly outcome: ValidationOutcome; readonly exitCode: number | null; readonly duration_ms?: number; } export declare function finalizeFabricValidationSettlement(settlement: FabricValidationSettlement, postconditionsPassed: boolean): FabricValidationSettlement; export type ParallelDispatchErrorCode = "invalid-contract" | "stale-base" | "dirty-tree" | "active-run" | "descriptor-mismatch" | "descriptor-replay" | "outcome-conflict" | "artifact-invalid" | "wave-not-ready" | "candidate-invalid" | "wave-integration-failed" | "corrupt-state" | "state-locked" | "lifecycle-failed"; export declare class ParallelDispatchError extends Error { readonly code: ParallelDispatchErrorCode; constructor(code: ParallelDispatchErrorCode, message: string); } export type ParallelDispatchPrepareResult = { readonly status: "prepared"; readonly snapshot: ParallelDispatchSnapshot; } | { readonly status: "serial-fallback"; readonly reason: "scope-overlap" | "dependency-ambiguous"; }; /** Runtime capacity and mapping limits that the pure admission policy cannot observe. */ export type FabricDispatchSolReason = LunaFabricSolReason | "unit-count-exceeds-capacity" | "concurrent-scope-overlap" | "contract-unmappable" | "target-checked-out"; export type ParallelDispatchFabricPrepareResult = { readonly status: "prepared"; readonly snapshot: ParallelDispatchSnapshot; readonly fabric_fingerprint: string; readonly plan_id: string | null; readonly plan_binding_id: string | null; readonly width: number; readonly depth: number; } | { readonly status: "sol-serial"; readonly reason: FabricDispatchSolReason; }; export interface ParallelDispatchClaim { readonly run_id: string; readonly dispatch_id: string; } export interface ParallelDispatchCoordinatorOptions { readonly repositoryRoot: string; readonly gitPath?: string; } export type LiveFabricTakeoverResult = { readonly status: "not-proposed"; readonly decision: CriticalPathResult; } | { readonly status: "waiting"; readonly trigger: CriticalPathTakeoverTrigger; readonly reason: string; readonly snapshot: ParallelDispatchSnapshot; } | { readonly status: "taken-over"; readonly trigger: CriticalPathTakeoverTrigger; readonly snapshot: ParallelDispatchSnapshot; }; /** Read-only reconstruction of one accepted fabric boundary. It is never a dispatch instruction. */ export interface FabricWaveBoundaryReplayRecord { readonly reason: WaveBoundaryReplayReason; readonly boundary_event_hash: string; readonly route: "luna-fabric"; readonly plan: ExecutionPlan; readonly plan_decisions: readonly { readonly plan_id: string; readonly proposal_id: string; readonly decision: "accepted" | "rejected"; readonly gap_codes: readonly string[]; }[]; readonly scheduler: LunaFabricSchedulerState; readonly artifacts: FabricWaveBoundaryIdentity["artifacts"]; readonly candidate_snapshot: FabricWaveBoundaryIdentity["candidate_snapshot"]; readonly recovery_budget: WaveBoundaryRecoveryBudget; } export declare class ParallelDispatchCoordinator { private readonly repositoryRoot; private readonly lifecycle; private readonly stateRoot; private readonly gitPath; private readonly statePath; private readonly registry; private queue; private readonly pendingFabricOutcomes; private readonly automaticFabricReplays; private constructor(); static open(options: ParallelDispatchCoordinatorOptions): Promise; prepare(contract: WorktreeParallelContract, ownerRoot: string): Promise; /** * Prepare one admitted Luna fabric contract. Admission is pure, so runtime capacity and the * concurrent-worktree disjointness this release can honor are enforced here and route to Sol. */ prepareFabric(value: unknown, ownerRoot: string, executionPlanValue?: unknown): Promise; private prepareRun; integrateFabricWave(ownerRoot: string, runID: string): Promise; integrateFabricWaveAndValidate(ownerRoot: string, runID: string, executable: string, args?: readonly string[], timeoutMs?: number): Promise; /** Stop one observed critical Luna attempt, then reuse the durable Sol demotion recovery. */ criticalPathInput(ownerRoot: string, runID: string, sourceIdentity: ChildTerminalIdentity): Promise; /** Stop one observed critical Luna attempt, then reuse the durable Sol demotion recovery. */ takeoverCriticalFabricUnit(ownerRoot: string, runID: string, observation: CriticalPathInput, sourceIdentity: ChildTerminalIdentity, lifecycle: CancellableChildLifecycle): Promise; demoteFailedFabricUnit(ownerRoot: string, runID: string, unitID: string): Promise; private planFabricDemotion; private advanceFabricWave; validateFabricCandidate(ownerRoot: string, runID: string, executable: string, args?: readonly string[], timeoutMs?: number): Promise; private finalizeFailedFabricValidation; acceptFabricCandidate(ownerRoot: string, runID: string, candidateHead: string, review: "pass" | "skip" | "fail", reviewFingerprint: string): Promise; bindDispatch(ownerRoot: string, callID: string, descriptor: ParallelDispatchDescriptor): Promise; acceptArtifact(ownerRoot: string, callID: string, childSessionID: string, descriptor: ParallelDispatchDescriptor, artifact: WorktreeCommitArtifact): Promise; completeCall(ownerRoot: string, callID: string, childSessionID: string | undefined, outcome: ParallelDispatchOutcome, claimed?: ParallelDispatchClaim): Promise; childLedger(ownerRoot: string, descriptor: ParallelDispatchDescriptor, callID: string, childID: string): Promise; releaseChildWorktree(ownerRoot: string, descriptor: ParallelDispatchDescriptor, callID: string, childID: string, evidence: ChildTerminalEvidence, discardOwnedChanges?: boolean): Promise; cleanupSuppressed(ownerRoot: string, runID: string): Promise; childWorktreeReleased(descriptor: ParallelDispatchDescriptor): Promise; cancel(ownerRoot: string, runID?: string): Promise; snapshot(ownerRoot: string, runID?: string): Promise; /** * Observe the same read-only descriptor used by automatic recovery, or select a historical * accepted boundary for diagnosis. A diagnostic override never replaces the automatic record. */ inspectFabricWaveBoundaryReplay(ownerRoot: string, runID: string, boundaryEventHash?: string): Promise; archives(ownerRoot: string): Promise; /** Return one terminal run archive without exposing active or preparation state as an archive. */ archive(ownerRoot: string, runID: string): Promise; reconcile(ownerRoot: string, activeCallIDs: ReadonlySet, runID?: string): Promise; private fabricOutcome; private applyFabricOutcome; private completeFabricCall; private contractTasks; private recoverWithAuthority; private reconstructFabricBoundary; private recoverFabricDemotion; private assertFabricCandidate; private builtFabricCandidate; private buildFabricCandidate; private cleanGitEnvironment; private gitBuffer; private assertFabricAuthority; private recoverFabricTransition; private recoverPreparation; private preparationMatches; private finalizePreparation; private archivePreparation; private requireRun; private reserveReady; private suppressDescendants; private archiveIfTerminal; private pushArchive; private findRunArchive; private archiveOwner; private publicArchive; private publicSnapshot; private publicFabric; private load; private save; private acquire; private git; private readRef; targetCheckedOut(targetRef: string): Promise; private deleteFabricSourceRefs; private ensureCandidateRef; private withPrepareAuthority; private withFabricOperationAuthority; private transaction; }