import type { GoalTodoClaimValidationPolicy } from "./transition.js"; export type { GoalTodoClaimValidationPolicy }; export declare const GOAL_TODO_CLAIM_HASH_PATTERN: RegExp; export type GoalTodoDelegationAttemptStatus = "queued" | "running" | "claim_returned" | "accepted" | "rejected" | "failed" | "unknown"; export declare const GOAL_TODO_DELEGATION_ATTEMPT_STATUSES: readonly GoalTodoDelegationAttemptStatus[]; export type GoalTodoClaimVerdict = "PASS" | "WARN" | "FAIL"; export type GoalTodoClaimRecommendedAction = "accept_claim" | "needs_review" | "reject_claim" | "block"; export type GoalTodoClaimConfidence = "LOW" | "MEDIUM" | "HIGH"; export type GoalTodoClaimValidationStatus = "passed" | "warn" | "failed" | "blocked"; export type GoalTodoDelegationLivenessStatus = "active" | "inactive" | "unknown"; /** One delegation attempt; validationPolicy is FROZEN at launch. */ export interface GoalTodoDelegationAttemptRecord { readonly attemptId: string; readonly runId?: string; readonly agent?: string; /** Parent-owned delegation depth metadata (integer >= 1, zob parity). */ readonly delegationDepth?: number; readonly status: GoalTodoDelegationAttemptStatus; readonly validationPolicy: GoalTodoClaimValidationPolicy; readonly launchedAt: number; readonly returnedAt?: number; readonly settledAt?: number; } /** The claim_returned record binding attempt + exact claim hash + policy. */ export interface GoalTodoReturnedClaim { readonly claimVersion: 1; readonly attemptId: string; readonly claimHash: string; readonly validationPolicy: GoalTodoClaimValidationPolicy; readonly evidenceRefs: readonly string[]; readonly validationCommands: readonly string[]; readonly noShip?: boolean; readonly returnedAt: number; } /** One oracle validation result; re-validations supersede until settlement * (the latest record per attempt is the effective one). * BUG-4 fix: blocking issues persist HASH-ONLY — blockingIssuesHash is the * sha256 of the JSON array in the caller's order (zob ordered-array parity) * and blockingIssuesCount carries the size; the cleartext lines never reach * the store (legacy v0.1.x lines still parse via the store adapter). */ export interface GoalTodoClaimValidationRecord { readonly validationVersion: 1; readonly attemptId: string; readonly claimHash: string; readonly validationPolicy: GoalTodoClaimValidationPolicy; readonly status: GoalTodoClaimValidationStatus; readonly verdict: GoalTodoClaimVerdict; readonly recommendedAction: GoalTodoClaimRecommendedAction; readonly noShip: boolean; readonly confidence: GoalTodoClaimConfidence; readonly blockingIssuesHash: string; readonly blockingIssuesCount: number; readonly outputHash: string; readonly evidenceRefs: readonly string[]; readonly validationCommands: readonly string[]; /** BUG-1 fix: optional canonical provenance (length-capped, strict-validated). */ readonly agent?: string; readonly runId?: string; readonly validatedAt: number; } /** sha256 over the JSON array of blocking issues in the caller's order. */ export declare function buildGoalTodoBlockingIssuesHash(blockingIssues: readonly string[]): string; /** Settlement proof produced by accept/reject (plain data; store stamps it). */ export interface GoalTodoClaimSettlementRecord { readonly settlement: "accepted" | "rejected"; readonly attemptId: string; readonly claimHash: string; readonly validationPolicy: GoalTodoClaimValidationPolicy; readonly reasonHash?: string; } /** Liveness proof shape for the later side table (plain data only). */ export interface GoalTodoDelegationLivenessProof { readonly schema: "pi-goals.delegation-liveness-proof.v1"; readonly status: GoalTodoDelegationLivenessStatus; readonly attemptId: string; readonly runId?: string; readonly source: string; readonly code: string; readonly proofAt: number; readonly bodyStored: false; } /** Pure claim side-table state: plain records keyed by attemptId. */ export interface GoalTodoClaimLifecycleState { readonly attempts: Readonly>; readonly claims: Readonly>; readonly validations: Readonly>; } export declare function createGoalTodoClaimLifecycleState(): GoalTodoClaimLifecycleState; export type GoalTodoClaimRetryPolicy = "fix_input" | "after_context_change" | "never"; export type GoalTodoClaimFailureCode = "invalid_attempt_id" | "invalid_run_id" | "invalid_agent" | "invalid_delegation_depth" | "invalid_status" | "invalid_now" | "invalid_validation_policy" | "attempt_already_launched" | "attempt_not_found" | "attempt_not_returnable" | "attempt_already_settled" | "claim_already_settled" | "claim_hash_invalid" | "claim_hash_conflict" | "claim_text_required" | "claim_not_returned" | "claim_required" | "claim_hash_mismatch" | "claim_attempt_mismatch" | "claim_policy_mismatch" | "claim_validation_policy_mismatch" | "invalid_verdict" | "invalid_recommended_action" | "invalid_no_ship" | "invalid_confidence" | "validation_output_hash_invalid" | "claim_validation_not_pass" | "reason_required"; export interface GoalTodoClaimOperationOk { readonly ok: true; readonly state: GoalTodoClaimLifecycleState; readonly record: T; } export interface GoalTodoClaimOperationErr { readonly ok: false; readonly code: GoalTodoClaimFailureCode; readonly message: string; readonly retryPolicy: GoalTodoClaimRetryPolicy; } export type GoalTodoClaimOperationResult = GoalTodoClaimOperationOk | GoalTodoClaimOperationErr; /** Exact sha256 hex of the claim text (full 64 lowercase characters). */ export declare function buildGoalTodoClaimHash(claimText: string): string; export declare function isCanonicalGoalTodoClaimHash(value: unknown): value is string; export interface LaunchGoalTodoDelegationAttemptInput { readonly attemptId: string; readonly runId?: string; readonly agent?: string; readonly status?: "queued" | "running"; readonly validationPolicy?: GoalTodoClaimValidationPolicy; readonly delegationDepth?: number; readonly now: number; } /** * Launch one delegation attempt. The validation policy is resolved exactly * once here (default parent_review, zob parity) and every later step — * return, validation, settlement — must echo the frozen value. */ export declare function launchDelegationAttempt(state: GoalTodoClaimLifecycleState, input: LaunchGoalTodoDelegationAttemptInput): GoalTodoClaimOperationResult; export interface ReturnGoalTodoClaimInput { readonly attemptId: string; readonly claimHash?: string; readonly claimText?: string; readonly evidenceRefs?: readonly string[]; readonly validationCommands?: readonly string[]; readonly noShip?: boolean; readonly now: number; } /** * Return one claim for an exact queued/running attempt. The produced * claim_returned record binds attemptId + exact full claim hash + the * launch-frozen validation policy, and carries the evidence/noShip metadata. */ export declare function returnGoalTodoClaim(state: GoalTodoClaimLifecycleState, input: ReturnGoalTodoClaimInput): GoalTodoClaimOperationResult; export interface RecordGoalTodoClaimValidationInput { readonly attemptId: string; readonly runId?: string; readonly verdict: GoalTodoClaimVerdict; readonly recommendedAction: GoalTodoClaimRecommendedAction; readonly noShip: boolean; readonly confidence: GoalTodoClaimConfidence; readonly blockingIssues?: readonly string[]; readonly outputHash: string; readonly evidenceRefs?: readonly string[]; readonly validationCommands?: readonly string[]; readonly agent?: string; readonly now: number; } /** * Record one oracle validation result for a returned oracle_required claim. * While the attempt stays claim_returned the validation may be RE-RECORDED: * each call appends a superseding validation and the LATEST one is the * effective record the accept gate consults (zob parity — batch-#2 fix); * only accept/reject settlement is final (attempt_already_settled). The * binding echoes the claim's hash and launch-frozen policy (zob parity: * parent_review claims are reviewed directly by the parent and never enter * the oracle channel). */ export declare function recordClaimValidation(state: GoalTodoClaimLifecycleState, input: RecordGoalTodoClaimValidationInput): GoalTodoClaimOperationResult; export interface SettleGoalTodoClaimInput { readonly claimHash: string; readonly attemptId: string; readonly validationPolicy: GoalTodoClaimValidationPolicy; } export interface RejectGoalTodoClaimInput extends SettleGoalTodoClaimInput { readonly reason: string; } /** Accept one returned claim with exact hash/attempt/policy echo bindings. * BUG-2 fix (zob parity, enforced — not just exposed): when the bound claim's * launch-frozen policy is oracle_required, acceptance REQUIRES an existing * validation record for that exact claim hash with verdict PASS and noShip * false; otherwise the settlement is rejected with claim_validation_not_pass * (retry after_context_change — validate first or reject the claim). * parent_review claims keep manual parent acceptance. */ export declare function settleAcceptClaim(state: GoalTodoClaimLifecycleState, input: SettleGoalTodoClaimInput): GoalTodoClaimOperationResult; /** Reject one returned claim; a non-empty reason is required and hashed. */ export declare function settleRejectClaim(state: GoalTodoClaimLifecycleState, input: RejectGoalTodoClaimInput): GoalTodoClaimOperationResult; /** The four validation dimensions the strict rule evaluates. */ export interface GoalTodoClaimValidationLike { readonly verdict: GoalTodoClaimVerdict; readonly recommendedAction: GoalTodoClaimRecommendedAction; readonly noShip: boolean; readonly confidence: GoalTodoClaimConfidence; } export type GoalTodoAutoAcceptDimension = "verdict" | "noShip" | "recommendedAction" | "confidence"; export interface GoalTodoAutoAcceptDecision { readonly autoAccept: boolean; readonly outcome: "accept" | "needs_review"; readonly failures: readonly GoalTodoAutoAcceptDimension[]; } /** * Strict rule: verdict = PASS AND noShip = false AND recommendedAction = * accept_claim AND confidence = HIGH. Anything less requires parent review; * each failing dimension is reported so callers can explain the downgrade. */ export declare function isStrictPassAutoAccept(validation: GoalTodoClaimValidationLike): GoalTodoAutoAcceptDecision; export declare function hasOnlyNoneLike(items: readonly string[]): boolean; export declare function isCanonicalGoalTodoLivenessProof(value: unknown): value is GoalTodoDelegationLivenessProof;