import { type Static } from '@sinclair/typebox'; import type { GoldenTraceDecision } from '../golden-trace.js'; import type { RuleContextV2 } from './rule-context-v2.js'; /** * Attack type for adversarial cases (PRD Decision 4). * - boundary: probe ambiguous edges of principle text * - omission: satisfy all-but-one condition the code may have skipped * - inversion: mutate a positive case so it should become negative */ export type AdversarialAttackType = 'boundary' | 'omission' | 'inversion'; export interface AdversarialCase { readonly caseId: string; readonly attackType: AdversarialAttackType; readonly toolName: string; readonly params: Record; /** GoldenTraceDecision, NOT RuleHostDecision. */ readonly expectedDecision: GoldenTraceDecision; readonly rationale: string; /** * Optional v2 rule context (PRI-485 Phase 6). When present, the case carries * a fabricated RuleContextV2 the sandbox uses to evaluate the rule with * history/facts (in addition to the action snapshot). Absent on v1 adversarial * cases for backward compatibility. Runtime-validated via validateRuleContextV2. */ readonly ruleContext?: RuleContextV2; } export interface AdversarialFailedCase { readonly caseId: string; readonly attackType: AdversarialAttackType; /** * PRI-634 PR-A (SPEC §14): present ONLY when the rule produced a real * decision that mismatched the expected one. Never carries an errorType * value — legacy artifacts that stored e.g. actualDecision='runtime_error' * are normalized by readers (repair-replay-resolver), not migrated. */ readonly actualDecision?: string; readonly expectedDecision: string; readonly rationale: string; /** * PRI-634 PR-A: sandbox error classification (runtime_error / timeout / * syntax_error / validation_failed / forbidden_pattern / unknown). * Present on runtime-written evidence; absent on legacy artifacts. */ readonly errorType?: string; /** * PRI-634 PR-A: bounded safe failure message from the deterministic replay * sandbox. Present on runtime-written evidence; absent on legacy artifacts. */ readonly message?: string; } export interface EvaluatorCodeReview { readonly intentConsistency: { readonly aligned: boolean; readonly explanation: string; }; readonly scopePrecision: { readonly verdict: 'precise' | 'too_broad' | 'too_narrow'; readonly explanation: string; }; readonly traceCoverage: { readonly sufficient: boolean; readonly gaps: readonly string[]; readonly explanation: string; }; } export interface EvaluatorAdversarialResult { readonly passed: boolean; readonly failedCases: readonly AdversarialFailedCase[]; /** * PRI-634-F R2 (review P2): layered failure attribution from the replay * gate ({layer, reasonCode}) — preserved on the evaluator artifact so * repair/telemetry consumers answer "哪一层负责" without re-parsing case * text. Absent when the replay passed. */ readonly failure?: { readonly layer: string; readonly reasonCode: string; }; } /** * PRI-630 收敛契约: 第二轮及之后,评估器必须对上轮 review contract 的每个 * 稳定需求 id 裁定 resolved / still_open / regressed。 */ export type PriorRequirementStatus = 'resolved' | 'still_open' | 'regressed'; export interface PriorRequirementStatusEntry { readonly id: string; readonly status: PriorRequirementStatus; } export interface EvaluatorEvaluation { readonly decision: 'approved' | 'needs_revision' | 'rejected'; readonly summary: string; readonly score: number; readonly strengths: readonly string[]; readonly concerns: readonly string[]; readonly requiredChanges: readonly string[]; /** PRI-630: 上轮需求的逐条核销 (仅有上轮上下文时合法;首轮省略) */ readonly priorRequirementStatuses?: readonly PriorRequirementStatusEntry[]; /** * PRI-630 P1 评审修复: 输入需求的 ledger echo ({id, statement, status}) — * 下一轮上下文的身份载体,保证 requirement id 跨轮稳定。 */ readonly requirementLedger?: readonly { readonly id: string; readonly statement: string; readonly status: PriorRequirementStatus; }[]; } export interface EvaluatorSourceTrace { readonly artificerArtifactId: string; readonly scribeArtifactId?: string; readonly philosopherArtifactId?: string; readonly dreamerArtifactId?: string; } export interface EvaluatorOutputV1 { readonly taskId: string; readonly sourceArtificerArtifactId: string; readonly evaluation: EvaluatorEvaluation; readonly sourceTrace: EvaluatorSourceTrace; readonly risks: readonly string[]; readonly generatedAt: string; } /** * EvaluatorOutputV2 — V1 plus code review + adversarial attack fields * (PRD Decision 2, ADR-0014 Amendment 2026-06-17). * * All V2 fields are optional: they appear only when the upstream Artificer * output is V2 (code-bearing). V1 Artificer → Evaluator skips code review * entirely (no codeReview, no adversarialCases). Use `isEvaluatorOutputV2()` * after `validate()` to decide which assembly path applies. * * Layer 2 (progressive disclosure, design §6.5) adds two more optional fields: * - painCoverage: how well the dreamer covered the original pain signal * - compressionFidelity: per-dimension coverage of the dreamer 5-dim in the * principle text (required dims only in missingDimensions; optional dims in * optionalUncovered; excluded dims never appear — design §6.5.1) */ export interface EvaluatorPainCoverage { readonly fullyCovered: boolean; readonly uncoveredAspects: readonly string[]; readonly explanation: string; } export interface EvaluatorCompressionFidelity { readonly betterDecisionCovered: boolean; readonly rationaleCovered: boolean; readonly riskLevelCovered: boolean; readonly badDecisionCovered: boolean; /** Required dimensions missing from the principle text (required-only). */ readonly missingDimensions: readonly string[]; /** Optional dimensions not covered (diagnostic only, never flags). */ readonly optionalUncovered: readonly string[]; readonly explanation: string; } export interface EvaluatorOutputV2 extends EvaluatorOutputV1 { readonly codeReview?: EvaluatorCodeReview; readonly adversarialCases?: readonly AdversarialCase[]; readonly adversarialResult?: EvaluatorAdversarialResult; /** Layer 2 progressive disclosure (design §6.5). */ readonly painCoverage?: EvaluatorPainCoverage; /** Layer 2 progressive disclosure (design §6.5.1). */ readonly compressionFidelity?: EvaluatorCompressionFidelity; } export declare const EVALUATOR_DECISIONS: readonly ['approved', 'needs_revision', 'rejected']; export declare const PriorRequirementStatusEntrySchema: import("@sinclair/typebox").TObject<{ id: import("@sinclair/typebox").TString; status: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"resolved">, import("@sinclair/typebox").TLiteral<"still_open">, import("@sinclair/typebox").TLiteral<"regressed">]>; }>; export declare const RequirementLedgerEntrySchema: import("@sinclair/typebox").TObject<{ id: import("@sinclair/typebox").TString; statement: import("@sinclair/typebox").TString; status: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"resolved">, import("@sinclair/typebox").TLiteral<"still_open">, import("@sinclair/typebox").TLiteral<"regressed">]>; }>; export declare const EvaluatorEvaluationSchema: import("@sinclair/typebox").TObject<{ decision: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"approved">, import("@sinclair/typebox").TLiteral<"needs_revision">, import("@sinclair/typebox").TLiteral<"rejected">]>; summary: import("@sinclair/typebox").TString; score: import("@sinclair/typebox").TNumber; strengths: import("@sinclair/typebox").TArray; concerns: import("@sinclair/typebox").TArray; requiredChanges: import("@sinclair/typebox").TArray; priorRequirementStatuses: import("@sinclair/typebox").TOptional, import("@sinclair/typebox").TLiteral<"still_open">, import("@sinclair/typebox").TLiteral<"regressed">]>; }>>>; requirementLedger: import("@sinclair/typebox").TOptional, import("@sinclair/typebox").TLiteral<"still_open">, import("@sinclair/typebox").TLiteral<"regressed">]>; }>>>; }>; export declare const EvaluatorSourceTraceSchema: import("@sinclair/typebox").TObject<{ artificerArtifactId: import("@sinclair/typebox").TString; scribeArtifactId: import("@sinclair/typebox").TOptional; philosopherArtifactId: import("@sinclair/typebox").TOptional; dreamerArtifactId: import("@sinclair/typebox").TOptional; }>; export declare const EvaluatorOutputV1Schema: import("@sinclair/typebox").TObject<{ taskId: import("@sinclair/typebox").TString; sourceArtificerArtifactId: import("@sinclair/typebox").TString; evaluation: import("@sinclair/typebox").TObject<{ decision: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"approved">, import("@sinclair/typebox").TLiteral<"needs_revision">, import("@sinclair/typebox").TLiteral<"rejected">]>; summary: import("@sinclair/typebox").TString; score: import("@sinclair/typebox").TNumber; strengths: import("@sinclair/typebox").TArray; concerns: import("@sinclair/typebox").TArray; requiredChanges: import("@sinclair/typebox").TArray; priorRequirementStatuses: import("@sinclair/typebox").TOptional, import("@sinclair/typebox").TLiteral<"still_open">, import("@sinclair/typebox").TLiteral<"regressed">]>; }>>>; requirementLedger: import("@sinclair/typebox").TOptional, import("@sinclair/typebox").TLiteral<"still_open">, import("@sinclair/typebox").TLiteral<"regressed">]>; }>>>; }>; sourceTrace: import("@sinclair/typebox").TObject<{ artificerArtifactId: import("@sinclair/typebox").TString; scribeArtifactId: import("@sinclair/typebox").TOptional; philosopherArtifactId: import("@sinclair/typebox").TOptional; dreamerArtifactId: import("@sinclair/typebox").TOptional; }>; risks: import("@sinclair/typebox").TArray; generatedAt: import("@sinclair/typebox").TString; }>; export type EvaluatorOutputV1TB = Static; export interface EvaluatorValidationResult { readonly valid: boolean; readonly errors: readonly string[]; readonly errorCategory?: string; } /** * Runtime type guard distinguishing V2 (code-review/adversarial-bearing) * evaluator output from V1. A V2 output is one where at least one V2 field * is present AND well-formed. Use after `validate()` (Runtime Contract Rule 2). */ export declare function isEvaluatorOutputV2(output: unknown): output is EvaluatorOutputV2; export interface EvaluatorValidator { validate(output: unknown, taskId: string, expectedSourceArtificerArtifactId?: string, convergence?: EvaluatorConvergenceContext): Promise; } export interface EvaluatorExpectedRequirement { /** 上轮分配的稳定 id (req-N) */ readonly id: string; /** 上轮注入上下文的陈述原文 — ledger 必须 verbatim echo */ readonly statement: string; } export interface EvaluatorConvergenceContext { /** * 评审轮 2 P1: authoritative 修复轮契约 — runner 从上一轮上下文原样传入。 * repair round 的 priorRequirementStatuses 与 requirementLedger 都以此为准 * 做机器校验 (存在/完整/不重复/不重编号/statement 原文/status 互洽)。 */ readonly expectedRequirements?: readonly EvaluatorExpectedRequirement[]; } export declare class DefaultEvaluatorValidator implements EvaluatorValidator { validate(output: unknown, taskId: string, expectedSourceArtificerArtifactId?: string, convergence?: EvaluatorConvergenceContext): Promise; } //# sourceMappingURL=evaluator-output.d.ts.map