import type { ConfidenceBasis, DerivationEdge, EvidenceMethod, EvidenceType, ImpactLevel, TrustStatus } from "@kontourai/surface"; export type RawSourceKind = "uploaded-document" | "web-page" | "api-record" | "manual-entry" | "policy-standard" | "inquiry-question" | "agent-utterance" | "system-schema"; export type ProvenanceResolution = "extraction" | "testimony" | "supersession" | "precedence-selection" | "carry-forward" | "observation"; export type LocatorScheme = "pdf" | "text" | "html" | "structured-field" | "text-span"; export interface RawSource { id: string; kind: RawSourceKind; resolution?: ProvenanceResolution; sourceRef: string; observedAt: string; fetchedAt?: string; checksum?: string; locatorScheme: LocatorScheme; inlineText?: string; standardVersion?: string; paragraphRef?: string; metadata?: Record; } export interface Extraction { id: string; sourceId: string; target: string; value: unknown; confidence?: number; locator?: string; excerpt?: string; extractor: string; extractedAt: string; metadata?: Record; } /** * `rejected`: a review rejected every candidate in the set and selected none * (for example rejecting all conflicting values for one claim). */ export type CandidateSetStatus = "resolved" | "needs-review" | "conflict" | "escalated" | "rejected"; export type EscalationDimension = "framing" | "completeness" | "conclusion" | "citation"; export interface Candidate { id: string; extractionId: string; value: unknown; confidence?: number; sourceRank?: number; rejectionReason?: string; metadata?: Record; } export interface CandidateSet { id: string; target: string; candidates: Candidate[]; selectedCandidateId?: string; status: CandidateSetStatus; rationale?: string; metadata?: Record; } export type ReviewStatus = Extract; export type ReviewResolution = "accepted" | "rejected" | "held" | "could_not_confirm"; export type ReviewAuthorizingKind = "explicit-statement" | "exchange" | "authorized-action"; export interface ReviewAuthorizingExplicitStatement { kind: "explicit-statement"; statement: string; source?: string; } export interface ReviewAuthorizingExchange { kind: "exchange"; prompt: string; response: string; source?: string; } export interface ReviewAuthorizingAuthorizedAction { kind: "authorized-action"; promptRef: string; renderedPrompt: string; action: "affirmed-control" | "typed"; authorityRef: string; } export type ReviewAuthorizing = ReviewAuthorizingExplicitStatement | ReviewAuthorizingExchange | ReviewAuthorizingAuthorizedAction; export interface ReviewOutcome { id: string; candidateSetId: string; candidateId?: string; status: ReviewStatus; /** Explicit terminal resolution for this review round. Absent outcomes retain * the legacy status-inference behavior. */ resolution?: ReviewResolution; /** Required, non-empty explanation when resolution is `could_not_confirm`. */ resolutionReason?: string; /** Evidence of attempts made before the reviewer concluded they could not confirm. */ attemptEvidenceIds?: string[]; actor?: string; reviewedAt?: string; rationale?: string; evidenceIds?: string[]; withinComfortZone?: boolean; comfortZoneNote?: string; /** Optional testimony provenance. When present, records how this decision * was authorized — interpreted by downstream verifiers for admissibility. */ authorizing?: ReviewAuthorizing; metadata?: Record; } export interface EscalationRecord { id: string; target: string; dimension: EscalationDimension; reason: string; raisedBy: string; raisedAt: string; attachToClaimId?: string; resolvedBy?: string; metadata?: Record; } /** * The reading dimension of an {@link Interpretation} (#259, generalizing #16): * * - `"policy-standard"` — the original reading of how a policy-standard * paragraph applies to the claim. This kind keeps the hard requirement that * the anchor raw source is `kind: "policy-standard"`. * - `"gleaned"` — what this result taught: an authored reading of what the * anchored source material showed for the claim. * - `"answerImpact"` — how the reading moved the inquiry answer the claim * feeds (see {@link InterpretationAnswerImpact}); requires `answerImpact`. * * Additive-optional: a record with no `readingKind` is a `"policy-standard"` * reading, so existing batches keep their exact prior validation and * projection behavior. Interpretations never enter canonical review-proof * bytes regardless of kind. */ export type InterpretationReadingKind = "policy-standard" | "gleaned" | "answerImpact"; /** * How an `"answerImpact"` reading moved the inquiry answer its claim feeds: * the result `supported` the answer, `narrowed` it, or was recorded as an * `accepted-risk`. "Answer" means the inquiry answer (inquiry-mapping); * downstream decisions stay with consumers. */ export type InterpretationAnswerImpact = "supported" | "narrowed" | "accepted-risk"; export interface Interpretation { id: string; appliesToTarget?: string; appliesToClaimId?: string; /** * Which reading dimension this record carries. Absent means * `"policy-standard"` (the pre-#259 behavior, unchanged). */ readingKind?: InterpretationReadingKind; /** * Required when `readingKind` is `"answerImpact"`; illegal for any other * kind. The structured impact beside the free-text `reading`. */ answerImpact?: InterpretationAnswerImpact; anchorsToSourceId: string; /** * Locator inside the anchor source: the rule paragraph for a * `"policy-standard"` reading, or the result location the producer read for * `"gleaned"` / `"answerImpact"` readings. */ ruleLocator: string; reading: string; actor: string; recordedAt: string; metadata?: Record; } export interface ClaimTarget { id: string; candidateSetId: string; candidateId?: string; subjectType: string; subjectId: string; /** * Producer-defined grouping or namespace for this claim (Hachure schema 5, * surface@2.0.0: Claim.surface -> Claim.facet). Projected onto the emitted * Claim's `facet` field by {@link buildSurveyTrustBundle}. */ facet: string; claimType: string; fieldOrBehavior: string; value?: unknown; status?: TrustStatus; impactLevel: ImpactLevel; createdAt?: string; updatedAt?: string; evidenceType?: EvidenceType; evidenceMethod?: EvidenceMethod; confidenceBasis?: ConfidenceBasis; derivedFrom?: string[]; derivationEdges?: DerivationEdge[]; collectedBy: string; actor?: string; eventMethod?: string; metadata?: Record; } /** * Shape-contract version for the flat record arrays in a {@link SurveyInput} * batch (`rawSources`, `extractions`, `candidateSets`, `reviewOutcomes`, * `claims`). Stamped by {@link SurveyInputBuilder.build} when a batch does not * set one of its own. See `docs/record-contracts.md` for the compatibility * policy — a future breaking change to any of those record shapes must bump * this constant and document the migration before release. */ export declare const SURVEY_INPUT_CONTRACT_VERSION = "1"; export interface SurveyInput { /** * Identifies the shape contract for the record arrays in this batch. Optional * and defaults to {@link SURVEY_INPUT_CONTRACT_VERSION} when omitted, so * batches built before this field existed remain valid. Compatibility marker * only — Survey does not gate records on it. See `docs/record-contracts.md`. */ contractVersion?: string; source: string; generatedAt: string; rawSources: RawSource[]; extractions: Extraction[]; candidateSets: CandidateSet[]; reviewOutcomes: ReviewOutcome[]; claims: ClaimTarget[]; escalations?: EscalationRecord[]; interpretations?: Interpretation[]; }