import { type CandidateVerification } from "./candidate-verification.js"; import { type DecisionBasis, type DecisionCarryForward, type DecisionSupersession } from "./decision-carry-forward.js"; import { type ExtractionEnvelopeImport } from "./extraction-envelope.js"; import type { ReviewDecision } from "./review-resource.js"; /** * Per-field content and lifecycle states (#294), derived from records Survey * holds and never stored as labels. * * Only states with a producer ship. `not_found` (the source was read in full * and holds no value for the field) needs per-field chunk coverage and a * per-field dropped-proposal count from the extractor, which no producer * reports yet, so a field with no candidate in a complete run has no content * state at all. Absence of a state never means verified. */ /** The claim-metadata key under which the Surface projection carries a field's states. */ export declare const FIELD_STATE_METADATA_KEY = "survey.kontourai.io/field-state"; /** * What the extraction says about a field. * * - `value`: at least one candidate with evidence. * - `conflicting`: two or more distinct candidate values for the one claim. * - `unsupported`: every candidate has a verifier record saying contradicted * or not-addressed for its current value, and none saying supported. * - `excluded`: the extraction proposed values for the field, but the import * left every one out because its excerpt was not at its cited span. The * field was read; its proposals are unverifiable, not disproven. * - `not_covered`: no proposal at all, and the extraction reported that part * of the content was not read (a partial or failed run). */ export type FieldContentState = "value" | "conflicting" | "unsupported" | "excluded" | "not_covered"; /** * Where review stands for a field: `pending` (no decision), `accepted`, * `rejected`, `could_not_confirm`, or `superseded` (a supersession record * names the decision as replaced). */ export type FieldLifecycleState = "pending" | "accepted" | "rejected" | "could_not_confirm" | "superseded"; /** A claim slot: the claim a proposal would project to, at its path indices. */ export interface FieldSlot { readonly subjectType: string; readonly subjectId: string; readonly facet: string; readonly claimType: string; readonly fieldOrBehavior: string; readonly claimId?: string; readonly pathIndices?: readonly number[]; } /** Facts about a field that are not states. */ export interface FieldStateSignals { /** The run that produced this import stopped short or failed: other text may hold values. */ readonly incompleteRun?: true; /** Proposals for this slot the import left out because their excerpt was not at their span. */ readonly excludedProposals?: number; /** The import could not ground any candidate (its prepared artifact did not resolve or verify). */ readonly unresolvedImport?: true; } export interface FieldState { readonly importName: string; readonly slot: FieldSlot; /** The ReviewItem for this slot, when the import produced one. */ readonly reviewItemName?: string; /** Absent when no producer can state one (see the module note on `not_found`). */ readonly content?: FieldContentState; /** Absent when the slot has no review item, so there is nothing to decide. */ readonly lifecycle?: FieldLifecycleState; /** The decision the lifecycle comes from, when there is one. */ readonly decisionName?: string; /** Whether that decision was made on this round's item or carried forward from an earlier one. */ readonly decisionBasis?: DecisionBasis; readonly signals: FieldStateSignals; } export interface FieldStateImport { readonly record: ExtractionEnvelopeImport; /** * The fields the extraction was asked for, so a field with no proposal is * reported too. Without it only slots that have a proposal appear. */ readonly expectedFields?: readonly FieldSlot[]; } export interface DeriveFieldStatesInput { readonly imports: readonly FieldStateImport[]; /** Decisions on this round's items. At most one per item. */ readonly decisions?: readonly ReviewDecision[]; /** Verifier records for this round's candidates (see `CandidateVerification`). */ readonly verifications?: readonly CandidateVerification[]; /** Records that the decisions they name as prior were replaced. */ readonly supersessions?: readonly DecisionSupersession[]; /** Earlier decisions carried forward onto this round's items. */ readonly carryForwards?: readonly DecisionCarryForward[]; } /** * Derives the content and lifecycle state of every field in the given * imports. Pure: reads only its input. Each state appears only when the input * that produces it is present: no verifications, no `unsupported`; no * supersessions, no `superseded`. */ export declare function deriveFieldStates(input: DeriveFieldStatesInput): FieldState[]; /** The lifecycle a workbench decision gives its item, as `deriveFieldStates` reads it. */ export declare function lifecycleForDecision(decision: ReviewDecision | undefined): Exclude; /** The claim metadata the Surface projection carries for one field state. */ export declare function fieldStateClaimMetadata(state: FieldState): Record;