import { type BehaviorExamplePack } from './behavior-example-pack.js'; /** * Owner-labelled evidence selection (FR-03 contract fields). Provided by an * authorized Owner operation — never fabricated by an internal agent. * Shape mirrors the host-side `BehaviorExamplePackAssemblerInput` minus * I/O-only fields, so an assembler can be driven straight from a selection. */ export interface OwnerEvidenceSelection { /** Canonical pain ID the evidence belongs to (pain lineage root). */ readonly sourcePainId: string; /** Owner-selected tool call demonstrating the behaviour to block. */ readonly sourceNegativeToolCallId: number; /** Owner-selected tool calls demonstrating the behaviour to allow (1..3, unique). */ readonly positiveToolCallIds: readonly number[]; /** Owner's natural-language desired outcome — non-empty. */ readonly ownerDesiredOutcome: string; /** * B1 (PRI-983, SPEC FR-03): attach revision — 1 on first attach, +1 on every * re-attach. ABSENT = legacy record written before revision tracking. */ readonly revision?: number; /** * B1 (FR-03): `sha256:` content digest over the successfully assembled * pack (canonical JSON, same convention as the readiness verdict hash). * Resume re-assembles and refuses on mismatch — a silently stale reference * can never re-enter the model (FR-03 "拒绝无声复用旧引用"). * ABSENT = legacy record; resume refuses un-digested selections. */ readonly contentDigest?: string; /** * B1 (FR-03): authorized Owner operation label that wrote this selection * (e.g. `cli:attach` / `cli:attach:`). Evidence is only written * by an explicit Owner operation — never by an internal agent (C-04). */ readonly ownerOperation?: string; /** B1 (FR-03): ISO timestamp of the attach. ABSENT = legacy. */ readonly attachedAt?: string; } /** Stable reason codes (SPEC-PD-IAER-001 FR-04). Do not rename. */ export type OwnerEvidenceReasonCode = 'owner_behavior_examples_required' | 'owner_behavior_examples_invalid' | 'owner_behavior_examples_stale' | 'owner_behavior_examples_scope_mismatch'; /** Reserved error name for Owner evidence scope failures. Do not rename. */ export declare const OWNER_EVIDENCE_SCOPE_ERROR_NAME = "OwnerEvidenceScopeError"; /** * Structured kinds of a typed evidence-assembly failure: * - `pain_not_found` / `tool_call_not_found`: the trajectory the selection * references does not resolve (cleaned or wrong workspace) → the stable * STALE code (FR-03: a cleaned trajectory must never be silently reused); * - `session_mismatch`: a selected row belongs to another session → the * stable SCOPE code (SPEC FR-04 cross pain/session); * - `evidence_source_error`: the evidence SOURCE itself failed (trajectory * store I/O: unavailable / locked / read error) → the §6.2 storage-fault * family, deliberately NOT an FR-04 Owner-fault code. Owner-reviewer * vocabulary: a PRI-980 review fix separates "Owner labelled bad * evidence" from "the evidence source could not be read" (§6.2: 保留明确 * 的存储故障,不误判为 Owner 尚未标注). * * (The type name predates the storage kind — it is the reserved typed-error * family's stable name; do not rename, the plugin bundle relies on the * structural `name` + kind contract.) */ export type OwnerEvidenceScopeMismatchKind = 'pain_not_found' | 'tool_call_not_found' | 'session_mismatch' | 'evidence_source_error'; /** Build the typed error the plugin assembler throws for scope failures. */ export declare function createOwnerEvidenceScopeError(kind: OwnerEvidenceScopeMismatchKind, message: string): Error; export type OwnerEvidenceScopeError = Error & { readonly ownerEvidenceScopeKind: OwnerEvidenceScopeMismatchKind; }; /** Structural guard (cross-bundle safe — see module comment above). */ export declare function isOwnerEvidenceScopeError(value: unknown): value is OwnerEvidenceScopeError; /** Pre-computed assembly outcome, for callers that already ran the assembler. */ export type EvidenceAssemblyOutcome = { readonly ok: true; readonly pack: BehaviorExamplePack; } | { readonly ok: false; readonly error: unknown; }; export interface EvidenceReadinessInput { /** * Caller-declared target-channel applicability (the channel authority lives * in the A2 wiring, not here). `false` → `not_applicable`. Anything other * than an explicit `false` fails closed toward REQUIRING evidence. */ readonly channelRequiresOwnerEvidence: boolean; /** Owner selection; `undefined`/`null` = the Owner has not provided evidence. */ readonly ownerSelection?: OwnerEvidenceSelection | null; /** * Injected assembly step. Throws on failure (assembler ERR-069 fail-loud * convention); the gate captures the throw and classifies it: typed scope * kinds → the stable FR-04 codes, the typed `evidence_source_error` kind → * the §6.2 storage-fault verdict, everything else → `invalid_evidence` with * the bounded error detail — exception details are never swallowed. * Takes precedence over `assemblyResult` when both are provided. */ readonly assemblePack?: () => BehaviorExamplePack; /** Pre-assembled result, alternative to `assemblePack`. */ readonly assemblyResult?: EvidenceAssemblyOutcome; } /** * Evidence readiness verdict (FR-01 discriminant union). Field naming follows * the house style for structured refusals (reasonCode / nextAction / detail). */ export type EvidenceReadiness = { readonly status: 'ready'; readonly pack: BehaviorExamplePack; /** `sha256:` content digest of the pack (intent-hash.ts convention). */ readonly evidenceHash: string; readonly sourcePainId: string; } | { readonly status: 'owner_evidence_required'; readonly reasonCode: Extract; readonly missingFields: readonly string[]; readonly nextAction: string; } | { readonly status: 'invalid_evidence'; readonly reasonCode: OwnerEvidenceReasonCode; /** Bounded structured reason (rc-8) — why the evidence was rejected. */ readonly detail: string; readonly nextAction: string; } | { /** * The evidence SOURCE failed (trajectory store I/O — PRI-980 review * P2-1, SPEC §6.2 case 3). Deliberately NOT `invalid_evidence`: a * storage fault must never read as "Owner labelled bad evidence". * `reason` (not `reasonCode`) marks it as outside the FR-04 * Owner-fault vocabulary — callers must keep the task wake-eligible / * untouched and degrade observably, never write an owner-fault NHR * reason. */ readonly status: 'evidence_source_error'; readonly reason: 'evidence_source_error'; /** Bounded structured reason (rc-8) — the underlying failure message. */ readonly detail: string; readonly nextAction: string; } | { readonly status: 'not_applicable'; }; /** * Structural validation of the Owner selection (rc-1..rc-5). Returns the list * of field-level problems; an empty list means the selection is usable. * Semantics deliberately mirror `validateOwnerSelection` in the plugin * assembler (positive safe integers, 1..3 unique positives, non-empty text): * a present-but-unusable selection is REJECTED, never repaired here. * * PRI-982: exported as the SINGLE shape authority for the persisted * `pi_metadata.ownerEvidenceSelection` field — pitask-metadata parse reuses * this validator so the persistence layer and the readiness gate can never * diverge on what a usable selection is. Takes `unknown` (rc-1: the metadata * parse reads it from a DB row) and rejects non-objects itself. */ export declare function validateOwnerEvidenceSelectionShape(selection: unknown): string[]; /** `sha256:` content digest over the pack's canonical JSON (rc-6: one hash convention). */ export declare function computeBehaviorExamplePackDigest(pack: BehaviorExamplePack): string; /** * Pure evidence readiness judgment (FR-01). No I/O, no state — the caller * injects the assembly step and declares channel applicability. * * Decision order: * 1. channel does not require evidence → `not_applicable`; * 2. no Owner selection → `owner_evidence_required` + missingFields; * 3. selection present but structurally unusable → `invalid_evidence` * (assembler validateOwnerSelection semantics); * 4. assembly throws / pre-assembled failure → `invalid_evidence` with the * bounded error detail (never swallowed); * 5. assembled pack fails `validateBehaviorExamplePack` → `invalid_evidence` * (single validator authority); * 6. otherwise → `ready` with the pack, its `sha256:` evidence hash, * and the source pain ID. */ export declare function assessEvidenceReadiness(input: EvidenceReadinessInput): EvidenceReadiness; //# sourceMappingURL=evidence-readiness.d.ts.map