import type { CompiledBuildPlan } from "./buildPlan.js"; import { type ArtifactReference, type GraphCheckpointRef, type GraphEvent, type GraphExecutionState } from "./scheduler.js"; export type BuildEffectPurpose = "worktree" | "worker" | "validator" | "human-integration" | "cleanup"; export declare const BUILD_EFFECT_ORDINAL: Readonly>; export interface BuildWorktreeAuthority { intentId: string; runId: string; planVersion: number; planHash: string; ownerNodeId: string; baseSha: string; worktreePath: string; } export type BuildWorkspaceIdentity = { kind: "shared"; } | ({ kind: "planned-worktree"; } & BuildWorktreeAuthority) | ({ kind: "owned-worktree"; ownershipReceiptHash: string; } & BuildWorktreeAuthority); export interface BuildEffectIdentityInput { runId: string; planVersion: number; planHash: string; nodeId: string; visit: number; attempt: number; purpose: BuildEffectPurpose; ordinal: number; workspace: BuildWorkspaceIdentity; } export interface BuildEffectIdentity extends BuildEffectIdentityInput { idempotencyKey: string; requestRef: string; } export interface BuildExecutionPolicy { now: string; unattended: boolean; maxReadOnlyFanOut: number; allowParallelWrites: boolean; allowWorktreeCreation: boolean; trustRepositoryCheckout: boolean; } export interface BuildNodeStart { nodeId: string; handler: "inspect" | "design" | "implement" | "validate"; workspace: "shared" | "isolated-worktree"; toolPolicy: "read-only" | "declared-writes" | "reviewed-validation"; timeoutMs: number; } export interface BuildStartBlock { nodeId: string; code: string; } export interface BuildNodeStartPlan { start: readonly Readonly[]; blocked: readonly Readonly[]; humanIntegrationNodeId?: string; } export type BuildDispatchCheckpointStatus = "intent-recorded" | "succeeded" | "failed" | "unknown"; export interface BuildDispatchCheckpoint extends BuildEffectIdentity { schemaVersion: 1; status: BuildDispatchCheckpointStatus; recordedAt: string; resultRef?: string; } export type BuildRunningActionKind = "materialize-worktree" | "invoke-worker" | "validate-outputs" | "record-human-integration" | "cleanup-worktree" | "reconcile-unknown"; export interface BuildRunningAction extends BuildEffectIdentity { kind: BuildRunningActionKind; } export interface BuildWorkerBudgetReservation { schemaVersion: 1; reservationRef: string; outerIdempotencyKey: string; outerRequestRef: string; effectRequestRef: string; runId: string; planVersion: number; planHash: string; nodeId: string; visit: number; attempt: number; intentSequence: number; eventId: string; unattended: boolean; estimatedCostUsd: number | "unknown"; observedCostUsd: number | "unknown"; inputTokens: number | "unknown"; outputTokens: number | "unknown"; modelCalls: 1; providerCalls: 1; } export interface BuildWorkerBudgetIntent { reservation: Readonly; event: Readonly; } export interface BuildHumanIntegrationDecision { schemaVersion: 1; runId: string; planVersion: number; planHash: string; nodeId: string; decision: "integrated" | "declined"; selectedCandidateNodeIds: string[]; mainWorkspaceHeadBefore: string; mainWorkspaceHeadAfter: string; mainWorkspaceIntegrated: boolean; confirmedByUser: boolean; recordedAt: string; } export interface BuildHumanIntegrationCandidateEvidence { nodeId: string; ownershipReceiptHash: string; candidateHead: string; diffSha256: string; validationArtifactSha256: readonly string[]; } export interface BuildHumanIntegrationReceipt { schemaVersion: 1; kind: "trusted-human-integration"; decisionRef: string; confirmationRef: string; inspectedBy: "trusted-runtime-git"; candidateEvidence: readonly Readonly[]; mainWorkspaceInspection: { headBefore: string; headAfter: string; statusBeforeSha256: string; statusAfterSha256: string; conflictCheckSha256: string; }; artifactRef?: Readonly; recordedAt: string; } /** * Derive a purpose-scoped effect identity. A node attempt is intentionally not * one idempotency domain: worktree creation, model invocation, validation, * integration, and cleanup each receive their own immutable ordinal. */ export declare function buildEffectIdentity(inputValue: Readonly): BuildEffectIdentity; /** Select ready nodes only. Ownership is intentionally established after the * isolated node becomes running, under a separately durable worktree intent. */ export declare function planBuildNodeStarts(compiled: Readonly, state: Readonly, policyValue: Readonly): BuildNodeStartPlan; /** * Plan the next effect for each running node from immutable checkpoints. An * intent without a durable result is never replayed; it becomes an explicit * reconciliation action. */ export declare function planRunningBuildActions(compiled: Readonly, state: Readonly, policyValue: Readonly, checkpointValues: readonly Readonly[], workspaceByNode?: Readonly>>): readonly Readonly[]; export declare function assertBuildDispatchCheckpoint(value: unknown): BuildDispatchCheckpoint; export declare function assertHumanIntegrationDecision(compiled: Readonly, state: Readonly, value: unknown): BuildHumanIntegrationDecision; export declare function createBuildHumanWaitEvent(compiled: Readonly, state: Readonly, nodeId: string, input: Readonly<{ now: string; unattended: boolean; eventId: string; }>): GraphEvent; export declare function createBuildHumanIntegrationAction(compiled: Readonly, state: Readonly, nodeId: string): BuildRunningAction; export declare function createBuildHumanIntegrationResultEvent(compiled: Readonly, state: Readonly, decisionValue: unknown, evidenceValue: unknown, graphEvidenceValue: unknown, receiptValue: unknown, checkpointValue: unknown, eventId: string): GraphEvent; /** Canonical receipt bytes shared by the pure completion check and durable artifact adapter. */ export declare function serializeBuildEffectReceipt(effectValue: Readonly, receipt: unknown): string; export declare function buildEffectReceiptSha256(effect: Readonly, receipt: unknown): string; /** * Evaluate the frozen scheduler guard before acquiring the one outer model and * provider reservation for a BUILD worker. The scheduler idempotency key binds * the immutable estimates, so a retry cannot silently increase its allowance. */ export declare function createBuildWorkerBudgetIntent(compiled: Readonly, state: Readonly, actionValue: Readonly, inputValue: Readonly<{ now: string; unattended: boolean; eventId: string; estimatedCostUsd: number | "unknown"; observedCostUsd: number | "unknown"; inputTokens: number | "unknown"; outputTokens: number | "unknown"; checkpointRef: Readonly; routingDecisionId: string; }>): BuildWorkerBudgetIntent; /** Verify that the reservation is both self-authenticating and represented by the persisted outer scheduler intent. */ export declare function assertBuildWorkerBudgetReservation(compiled: Readonly, state: Readonly, actionValue: Readonly, value: unknown): BuildWorkerBudgetReservation; /** Reconstruct a reservation after restart from its immutable scheduler intent and the same configured estimates. */ export declare function recoverBuildWorkerBudgetReservation(compiled: Readonly, state: Readonly, actionValue: Readonly, eventValue: Readonly, estimatesValue: Readonly<{ unattended: boolean; estimatedCostUsd: number | "unknown"; observedCostUsd: number | "unknown"; inputTokens: number | "unknown"; outputTokens: number | "unknown"; }>): BuildWorkerBudgetReservation;