import type { ValidationOutcome, ValidationScope } from "./validation-budget.js"; import type { GoalReport } from "./goal-report.js"; export declare const GOAL_BOUND_SCHEMA_VERSION: "0.1"; export declare const GOAL_BOUND_METADATA_KEY: "sortie-dogs.goal-bound/v1"; export type GoalDeliveryMode = "planning-only" | "mvp-first" | "repair-first" | "controlled-change"; export type GoalStopReason = "completed" | "stopped" | "stop_budget" | "stop_no_progress" | "external_dependency" | "awaiting_user" | "agent_changed" | "persistence_unavailable"; export type GoalPhase = "active" | "stopped" | "terminal"; export interface GoalBudget { readonly max_units: number; readonly time_ms: number | null; readonly cost_usd: number | null; readonly source: "policy-default" | "accepted-plan" | "user-revision"; } export interface GoalEvidence { readonly evidence_id: string; readonly goal_id: string; readonly goal_revision: number; readonly scope_epoch: number; readonly acceptance_fingerprint: string; readonly measurement: { readonly criterion_ids: readonly string[]; readonly target: string; readonly entrypoint: string; readonly workload: string; readonly oracle_coverage: readonly string[]; readonly build_boundary: "included" | "excluded" | "not-applicable"; }; readonly identity: { readonly source: string; readonly candidate: string; readonly fixture: string; }; /** Host-owned snapshot recipe. Required when acceptance binds to the current protected source/candidate. */ readonly protected_binding?: { readonly manifest_hash: string; readonly project_root: string; readonly manifest_path: string; readonly source_paths: readonly string[]; readonly candidate_paths: readonly string[]; }; readonly execution: { readonly command: readonly string[]; readonly exit_code: number | null; readonly outcome: "pass" | "fail" | "skip" | "cancel"; readonly started_at: string; readonly ended_at: string; readonly units: readonly string[]; }; readonly proof_scope: "requested-full" | "supporting-proxy" | "document-deliverable" | "expected-negative"; } export interface GoalAcceptanceCriterion { readonly criterion_id: string; readonly target: string; readonly entrypoint: string; readonly workload: string; readonly oracle_coverage: readonly string[]; readonly build_boundary: "included" | "excluded" | "not-applicable"; readonly source: string; readonly candidate: string; readonly source_binding?: "declared" | "current-protected"; readonly candidate_binding?: "declared" | "current-protected"; readonly validation_command?: string; readonly fixture: string; readonly proof_scope: "requested-full" | "document-deliverable" | "expected-negative"; readonly expected_outcome: "pass" | "fail"; } export interface GoalAcceptanceContract { readonly criteria: readonly GoalAcceptanceCriterion[]; } export interface GoalTerminalReceipt { readonly goal_id: string; readonly terminal_revision: number; readonly acceptance_fingerprint: string; readonly started_at: string; readonly ended_at: string; readonly status: "succeeded" | "stopped"; readonly stop_reason: GoalStopReason; readonly unit_ids: readonly string[]; readonly session_ids: readonly string[]; readonly evidence_refs: readonly string[]; readonly milestone_at: string | null; } interface GoalEventBase { readonly at: string; } export interface GoalValidationRetryAuthorization { readonly authority: "operator-repair-validation-retry"; readonly operator_run_id: string; readonly unit_id: string; readonly operator_generation: number; readonly plan_hash: string; readonly control_hash: string; readonly goal_fingerprint: string; readonly repair_fingerprint: string; } export interface GoalValidationReopen extends GoalValidationRetryAuthorization { readonly prior_reservation_id: string; readonly prior_operation_id: string; } export type GoalFlightEvent = (GoalEventBase & { readonly kind: "goal.accepted"; readonly goal_id: string; readonly revision: 1; readonly scope_epoch: 1; readonly acceptance_fingerprint: string; readonly origin_user_message_id: string; readonly origin_session_id: string; readonly selected_agent: string; readonly delivery: GoalDeliveryMode; readonly budget: GoalBudget; readonly acceptance_contract: GoalAcceptanceContract | null; }) | (GoalEventBase & { readonly kind: "goal.user-continued"; readonly goal_id: string; readonly origin_user_message_id: string; readonly session_id: string; readonly selected_agent: string; }) | (GoalEventBase & { readonly kind: "goal.revised"; readonly goal_id: string; readonly revision: number; readonly scope_epoch: number; readonly acceptance_fingerprint: string; readonly origin_user_message_id: string; readonly session_id: string; readonly selected_agent: string; readonly delivery: GoalDeliveryMode; readonly budget: GoalBudget; readonly acceptance_contract: GoalAcceptanceContract | null; readonly reset_no_progress?: boolean; }) | (GoalEventBase & { readonly kind: "ticket.issued"; readonly ticket_id: string; readonly goal_id: string; readonly revision: number; readonly scope_epoch: number; readonly checkpoint: string; readonly sequence: number; readonly session_id: string; readonly origin_user_message_id: string; }) | (GoalEventBase & { readonly kind: "ticket.consumed"; readonly ticket_id: string; readonly goal_id: string; readonly receiving_message_id: string; readonly session_id: string; readonly origin_user_message_id: string; }) | (GoalEventBase & { readonly kind: "dispatch.reserved"; readonly reservation_id: string; readonly goal_id: string; readonly unit_id: string; readonly session_id: string; readonly ticket_id: string | null; }) | (GoalEventBase & { readonly kind: "unit.settled"; readonly reservation_id: string; readonly receipt_id: string; readonly goal_id: string; readonly unit_id: string; readonly disposition: "succeeded" | "failed" | "cancelled"; /** Missing on pre-v0.9.1 ledgers and therefore interpreted as an acceptance result. */ readonly result_class?: "acceptance" | "process-defect" | "interrupted"; readonly progress_fingerprint: string | null; readonly evidence: readonly GoalEvidence[]; readonly elapsed_ms: number | null; readonly cost_usd: number | null; }) | (GoalEventBase & { readonly kind: "unit.evidence-reconciled"; readonly goal_id: string; readonly unit_id: string; readonly previous_receipt_id: string; readonly evidence: readonly GoalEvidence[]; }) | (GoalEventBase & { readonly kind: "validation.admission"; readonly goal_id: string; readonly reservation_id: string; readonly operation_id: string; readonly evidence_key: string; readonly scope: ValidationScope | null; readonly decision: "ALLOW" | "SKIP" | "DENY"; readonly reason: string; readonly consumed: number; readonly limit: number; readonly saved_ms?: number; readonly reopen?: GoalValidationReopen; }) | (GoalEventBase & { readonly kind: "validation.settled"; readonly goal_id: string; readonly reservation_id: string; readonly operation_id: string; readonly evidence_key: string; readonly outcome: ValidationOutcome; readonly exit_code: number | null; readonly evidence_fingerprint?: string; readonly duration_ms?: number; readonly reason?: string; }) | (GoalEventBase & { readonly kind: "goal.replanned"; readonly goal_id: string; readonly revision: number; readonly reason: "no-progress"; }) | (GoalEventBase & { readonly kind: "goal.terminal"; readonly goal_id: string; readonly receipt: GoalTerminalReceipt; }) | (GoalEventBase & { readonly kind: "goal.reported"; readonly goal_id: string; readonly report: GoalReport; }); export interface GoalFlightEventRecord { readonly sequence: number; readonly previous_hash: string | null; readonly event_hash: string; readonly event: GoalFlightEvent; } export interface GoalTicketState { readonly ticket_id: string; readonly revision: number; readonly scope_epoch: number; readonly checkpoint: string; readonly sequence: number; readonly session_id: string; readonly origin_user_message_id: string; readonly receiving_message_id: string | null; } export interface GoalFlightState { readonly goal_id: string | null; readonly revision: number; readonly scope_epoch: number; readonly acceptance_fingerprint: string | null; readonly origin_user_message_id: string | null; readonly latest_user_message_id: string | null; readonly selected_agent: string | null; readonly delivery: GoalDeliveryMode | null; readonly budget: GoalBudget | null; readonly acceptance_contract: GoalAcceptanceContract | null; readonly consumed_units: number; readonly consumed_time_ms: number | null; readonly consumed_cost_usd: number | null; readonly phase: GoalPhase; readonly stop_reason: GoalStopReason | null; readonly no_progress_results: number; readonly replan_used: boolean; readonly replan_required: boolean; readonly tickets: readonly GoalTicketState[]; readonly outstanding_reservations: readonly { readonly reservation_id: string; readonly unit_id: string; readonly session_id: string; }[]; readonly validation_budget: { readonly consumed: number; readonly reservations: readonly { readonly reservation_id: string; readonly operation_id: string; readonly evidence_key: string; }[]; readonly evidence_keys: readonly string[]; readonly limit: number | null; readonly completed: number; readonly skipped: number; readonly rejected: number; readonly redundant_time_ms: number; readonly durations_ms: readonly number[]; }; readonly unit_ids: readonly string[]; readonly session_ids: readonly string[]; readonly evidence_refs: readonly string[]; readonly satisfied_criteria: readonly string[]; readonly receipt: GoalTerminalReceipt | null; } export declare class GoalBoundError extends Error { readonly code: "invalid" | "transition" | "budget" | "ticket" | "evidence"; constructor(code: GoalBoundError["code"], message: string); } export declare function goalFingerprint(value: unknown): string; export declare function selectGoalDelivery(input: { readonly declared_intent: "design" | "registration" | "implementation" | "repair" | "controlled-change"; readonly requested_usable_path_established: boolean; readonly irreversible_or_major_scope: boolean; readonly explicit_mode?: GoalDeliveryMode; }): GoalDeliveryMode; export declare function validGoalEvidence(value: GoalEvidence, state: Pick): boolean; export declare function reduceGoalFlight(records: readonly GoalFlightEventRecord[]): GoalFlightState; export {};