/**
 * CLEO-native goal-system contracts (Layer 4 of SG-COGNITIVE-SUBSTRATE).
 *
 * A *goal* is a DB-persisted, per-agent, turn-budgeted intent that CLEO drives
 * to completion by judging progress after every agent turn. CLEO's goal loop is
 * designed to beat two prior-art systems:
 *
 * - **Claude-Code** — a `Stop` hook + a Haiku *transcript judge* (the model
 *   reads the conversation and guesses whether the task is done). It has no
 *   turn budget and no persistence: a fresh process forgets the goal.
 * - **Hermes** — a post-turn loop with a turn budget and parse-failure
 *   auto-pause, but it still judges *fuzzy* intent against transcript text.
 *
 * CLEO's differentiator is the **evidence-gate-aware judge**: when a goal is to
 * *complete a task* (`complete T123`), the judge does NOT read the transcript.
 * It resolves the target task's actual `status` and re-uses the shipped ADR-051
 * evidence infrastructure ({@link GateEvidenceRequirement} +
 * `validateEvidenceForGate`) — the goal is satisfied ONLY when the task is
 * `done` with its required gates backed by real, validated evidence atoms
 * (commit reachable, file sha256 match, test-run hash match). Transcript text
 * can never satisfy a task-completion goal. Fuzzy goals fall back to an
 * injectable LLM judge (see {@link GoalJudge}) so the model is consulted only
 * where no machine-checkable artifact exists.
 *
 * This module is the LEAF contract: it declares the persisted record shape
 * ({@link GoalRecord}), the lifecycle status union ({@link GoalStatus}), the
 * discriminated goal-kind union ({@link GoalKind}), and the judge verdict shape
 * ({@link GoalJudgeVerdict}) that every layer (store, judge, loop, continuation,
 * CLI) agrees on. It has ZERO runtime dependencies beyond sibling contracts.
 *
 * @packageDocumentation
 * @module @cleocode/contracts/goal
 *
 * @epic T11290 EP-CLEO-GOAL-SYSTEM
 * @task T11376
 * @saga T11283 SG-COGNITIVE-SUBSTRATE
 */
/**
 * Canonical task-id shape recognized by a {@link TaskCompletionGoal}.
 *
 * Mirrors the ADR-079-r2 `SATISFIES_TASK_ID_REGEX` / evidence-atom task-id
 * grammar (`T` + 1–7 digits). Exported so the store, judge, and CLI layers
 * validate target ids against ONE pattern rather than re-deriving it.
 *
 * @public
 */
export const GOAL_TARGET_TASK_ID_REGEX = /^T[0-9]{1,7}$/;
/**
 * The set of all {@link GoalStatus} values, in lifecycle order.
 *
 * Use for runtime validation (`GOAL_STATUSES.includes(x)`) and to drive
 * exhaustive switch checks without hand-maintaining a parallel array.
 *
 * @public
 */
export const GOAL_STATUSES = Object.freeze([
    'active',
    'paused',
    'satisfied',
    'abandoned',
    'impossible',
]);
/**
 * The terminal {@link GoalStatus} values a continuation builder must NOT nudge:
 * a satisfied/abandoned/impossible goal yields no next-turn message.
 *
 * `paused` is intentionally absent — a paused goal CAN be resumed, so the
 * continuation builder still emits a nudge for it (see `buildContinuation`).
 *
 * @public
 */
export const GOAL_TERMINAL_STATUSES = Object.freeze([
    'satisfied',
    'abandoned',
    'impossible',
]);
/**
 * Type guard: is this a {@link TaskCompletionGoal} (evidence-judged)?
 *
 * @param kind - A {@link GoalKind} discriminated union value.
 * @returns `true` when the goal is judged via task status + evidence atoms.
 * @public
 */
export function isTaskCompletionGoal(kind) {
    return kind.kind === 'task-completion';
}
/**
 * Type guard: is this a {@link FuzzyGoal} (LLM-judged fallback)?
 *
 * @param kind - A {@link GoalKind} discriminated union value.
 * @returns `true` when the goal is judged by the injectable LLM judge.
 * @public
 */
export function isFuzzyGoal(kind) {
    return kind.kind === 'fuzzy';
}
/**
 * Test whether a string is a valid goal target task id (`T` + 1–7 digits).
 *
 * @param value - Candidate task id.
 * @returns `true` when `value` matches {@link GOAL_TARGET_TASK_ID_REGEX}.
 * @public
 */
export function isValidGoalTargetTaskId(value) {
    return GOAL_TARGET_TASK_ID_REGEX.test(value);
}
/**
 * Test whether a {@link GoalStatus} is terminal (no further turns / nudges that
 * advance work). A terminal status yields NO continuation.
 *
 * @param status - A goal status.
 * @returns `true` for `satisfied` / `abandoned` / `impossible`.
 * @public
 */
export function isTerminalGoalStatus(status) {
    return GOAL_TERMINAL_STATUSES.includes(status);
}
//# sourceMappingURL=goal.js.map