import type { GoalTodoStatus } from "./types.js"; /** Launch-fixed claim validation policy (zob GoalTodoClaimValidationPolicy). */ export type GoalTodoClaimValidationPolicy = "parent_review" | "oracle_required"; /** The 7 public resolve_goal_todo actions (zob ResolveGoalTodoAction). */ export type GoalTodoAction = "auto" | "complete" | "accept_claim" | "reject_claim" | "block" | "skip" | "reopen"; export declare const GOAL_TODO_ACTIONS: readonly GoalTodoAction[]; /** Canonical claim binding the state carries (claims side-table lands in 2d). */ export interface GoalTodoClaimBinding { /** Exact full 64-char lowercase hex sha256 of the returned claim. */ claimHash: string; /** Delegation attempt id the claim is bound to. */ attemptId: string; /** Launch-fixed validation policy fixed when the attempt was queued. */ validationPolicy: GoalTodoClaimValidationPolicy; } /** Minimal node state the pure transition engine operates over. */ export interface GoalTodoTransitionState { status: GoalTodoStatus; /** Required semantics for later tree gating; defaults to false. */ required?: boolean; /** Bound claim; claim-shaped statuses without it fail the claim_present guard. */ claim?: GoalTodoClaimBinding; } /** Per-action input; guards read only what their action needs. */ export interface GoalTodoTransitionInput { /** Required by block, skip, and reopen. */ reason?: string; /** Required by complete/skip from needs_user (user resolution recorded). */ userResolved?: boolean; /** Exact full 64-char lowercase hex claim hash (accept_claim/reject_claim). */ claimHash?: string; /** Exact delegation attempt id binding the claim resolution. */ attemptId?: string; /** Must echo the launch-fixed claim policy. */ validationPolicy?: GoalTodoClaimValidationPolicy; } /** Declarative guards, evaluated in table order; first failure wins. */ export type GoalTodoGuard = "claim_present" | "claim_not_bound" | "claim_hash_valid" | "claim_hash_matches" | "claim_attempt_present" | "claim_attempt_matches" | "validation_policy_present" | "validation_policy_matches" | "reason_present" | "user_resolved"; export type GoalTodoTableRejectionCode = "terminal_status" | "invalid_transition" | "active_delegation" | "explicit_accept_claim_required" | "claim_resolution_required" | "user_resolution_required"; export type GoalTodoGuardRejectionCode = "claim_resolution_required" | "reason_required" | "user_resolution_required" | "claim_required" | "claim_hash_invalid" | "claim_hash_mismatch" | "claim_attempt_required" | "claim_attempt_mismatch" | "validation_policy_required" | "claim_policy_mismatch"; export type GoalTodoRejectionCode = GoalTodoTableRejectionCode | GoalTodoGuardRejectionCode | "unknown_status" | "unknown_action"; export type GoalTodoRetryPolicy = "never" | "fix_input" | "after_context_change"; export interface GoalTodoAllowedRule { readonly allowed: true; readonly nextStatus: GoalTodoStatus; readonly code: "transition_allowed"; readonly requiredGuards: readonly GoalTodoGuard[]; } export interface GoalTodoRejectedRule { readonly allowed: false; readonly code: GoalTodoTableRejectionCode; readonly message: string; readonly retryPolicy: "never"; } export type GoalTodoTransitionRule = GoalTodoAllowedRule | GoalTodoRejectedRule; export type GoalTodoTransitionTable = Readonly>>>; /** * Frozen declarative transition table: TRANSITIONS[status][action] is either * an allowed rule (nextStatus + ordered requiredGuards) or a rejection with * an exact reason code. The engine functions below only read this table. */ export declare const TRANSITIONS: GoalTodoTransitionTable; export interface GoalTodoTransitionAuthorization { readonly allowed: true; readonly fromStatus: GoalTodoStatus; readonly action: GoalTodoAction; readonly nextStatus: GoalTodoStatus; readonly code: "transition_allowed"; readonly requiredGuards: readonly GoalTodoGuard[]; } export interface GoalTodoTransitionRejection { readonly allowed: false; readonly fromStatus: GoalTodoStatus; readonly action: GoalTodoAction; readonly code: GoalTodoRejectionCode; readonly message: string; readonly retryPolicy: GoalTodoRetryPolicy; } export type GoalTodoTransitionDecision = GoalTodoTransitionAuthorization | GoalTodoTransitionRejection; /** * Pure authorization: reads TRANSITIONS, then evaluates the rule's ordered * guards and returns the first failure as an exact rejection code. Never * mutates anything and never performs I/O. */ export declare function authorizeGoalTodoTransition(state: GoalTodoTransitionState, action: GoalTodoAction, input?: GoalTodoTransitionInput): GoalTodoTransitionDecision; /** Effects are data describing what the applied transition means downstream. */ export interface GoalTodoTransitionEffects { readonly autoResolved?: "complete"; readonly completed?: true; readonly requiredCompleted?: true; readonly claimAccepted?: true; readonly acceptedClaimHash?: string; readonly acceptedAttemptId?: string; readonly claimRejected?: true; readonly rejectedClaimHash?: string; readonly rejectedAttemptId?: string; readonly validationPolicy?: GoalTodoClaimValidationPolicy; readonly blocked?: true; readonly blockerReason?: string; readonly skipped?: true; readonly requiredSkipped?: true; readonly skipReason?: string; readonly reopened?: true; readonly reopenReason?: string; readonly reopenedFrom?: GoalTodoStatus; } export type GoalTodoTransitionResult = { readonly ok: true; readonly fromStatus: GoalTodoStatus; readonly action: GoalTodoAction; readonly nextStatus: GoalTodoStatus; readonly code: "transition_allowed"; readonly effects: GoalTodoTransitionEffects; } | { readonly ok: false; readonly fromStatus: GoalTodoStatus; readonly action: GoalTodoAction; readonly code: GoalTodoRejectionCode; readonly message: string; readonly retryPolicy: GoalTodoRetryPolicy; }; /** * Pure application: authorize, then describe the outcome as data — * { ok: true, nextStatus, effects } or { ok: false, code, message, retryPolicy }. * Applying the nextStatus to a stored node is the store layer's job (2c+). */ export declare function applyGoalTodoTransition(state: GoalTodoTransitionState, action: GoalTodoAction, input?: GoalTodoTransitionInput): GoalTodoTransitionResult; export type GoalTodoTransitionOutcomeCode = "transition_allowed" | GoalTodoTableRejectionCode; export interface GoalTodoTransitionDescriptor { readonly status: GoalTodoStatus; readonly action: GoalTodoAction; readonly allowed: boolean; readonly nextStatus?: GoalTodoStatus; readonly code: GoalTodoTransitionOutcomeCode; readonly requiredGuards: readonly GoalTodoGuard[]; readonly message?: string; readonly retryPolicy?: GoalTodoRetryPolicy; } /** Full 11 × 7 = 77 entry matrix straight from TRANSITIONS, for docs/tests. */ export declare function describeGoalTodoTransitions(): readonly GoalTodoTransitionDescriptor[];