import type { AcceptanceCriterion, CommandEvidence, CommandExpectation, Evidence, WorkNode } from "../schema/workspec.js"; export type GitTreeIdentity = Readonly<{ kind: "git"; worktreePath: string; resolvedCommit: string; }>; export type TreeIdentity = GitTreeIdentity; export interface ExecutionWindow { startedAt: string; finishedAt: string; durationMs: number; } export type TreeMonitoringMethod = "fs.watch" | "none"; export type TreeMonitoringMode = "recursive" | "directory-fallback" | "none"; export type TreeMonitoringResidualRace = "events-after-final-drain-may-be-missed" | "not-monitored"; export interface TreeMonitoringProof { method: TreeMonitoringMethod; mode: TreeMonitoringMode; window: ExecutionWindow; residualRace: TreeMonitoringResidualRace; } export interface CommandExecutionProof extends ExecutionWindow { kind: "command-proof"; /** Missing only in legacy Linux cache records; new executions always set this. */ containment?: "systemd-scope" | "process-group"; authoredCommand: string; /** Absent in legacy proofs and when the spec uses the default timeout. */ timeout_ms?: number; gitPath: string; executorPath: string; shellPath: string; expectation: CommandExpectation; stdout: string; stderr: string; exitCode: number | null; signal: NodeJS.Signals | null; outputMatched: string; inherit_env?: readonly string[]; untrackedPaths?: readonly string[]; monitoring: TreeMonitoringProof; tree: TreeIdentity; } export interface NamedInputDigest { path: string; digest: string; bytes: number; } export interface AgentJudgmentProof extends ExecutionWindow { kind: "agent-proof"; agent: string; rubric: string; rubricDigest: string; inputs: [NamedInputDigest, ...NamedInputDigest[]]; verdict: "approve"; dispatchReceipt: string; tree: TreeIdentity; } export interface UserConfirmationProof extends ExecutionWindow { kind: "user-proof"; prompt: string; challenge: string; sessionId: string; sessionFile: string; entryId: string; entryTimestamp: string; tree: TreeIdentity; } export type CriterionProof = CommandExecutionProof | AgentJudgmentProof | UserConfirmationProof; export type VerificationFailure = { code: "positive-floor-missing"; message: string; } | { code: "spawn-error"; message: string; errorCode?: string; } | { code: "cleanup-unavailable"; message: string; } | { code: "cleanup-failed"; message: string; } | { code: "timeout"; message: string; timedOut: true; } | { code: "aborted"; message: string; } | { code: "output-limit"; message: string; } | { code: "shell-unavailable"; message: string; exitCode: 126 | 127; } | { code: "signaled"; message: string; signal: NodeJS.Signals; } | { code: "exit-mismatch"; message: string; expected: number; actual: number | null; } | { code: "output-mismatch"; message: string; expected: string; } | { code: "environment-unavailable"; message: string; names: readonly string[]; } | { code: "tree-identity-unavailable"; message: string; } | { code: "tree-mismatch"; message: string; expected: string; actual: string; } | { code: "tree-dirty"; message: string; } | { code: "tree-changed"; message: string; } | { code: "input-missing"; message: string; path: string; } | { code: "input-unreadable"; message: string; path: string; } | { code: "input-not-file"; message: string; path: string; } | { code: "input-too-large"; message: string; path: string; } | { code: "input-path-escape"; message: string; path: string; } | { code: "agent-inputs-empty"; message: string; } | { code: "agent-unavailable"; message: string; } | { code: "agent-rejected"; message: string; } | { code: "agent-malformed"; message: string; } | { code: "dispatch-failed"; message: string; } | { code: "executable-unavailable"; message: string; executable: string; } | { code: "user-confirmation-required"; message: string; challenge: string; } | { code: "user-not-confirmed"; message: string; } | { code: "session-unavailable"; message: string; } | { code: "checklist-incomplete"; message: string; indexes: number[]; } | { code: "checklist-accounting"; message: string; } | { code: "no-execution-evidence"; message: string; } | { code: "verification-aborted"; message: string; }; export interface CriterionAttempt { kind: Evidence["kind"]; evidence: Evidence; startedAt: string; finishedAt: string; tree: TreeIdentity; stdout?: string; stderr?: string; exitCode?: number | null; signal?: NodeJS.Signals | null; } export interface FailedCriterionResult { outcome: "failed"; criterion: Pick; attempt: CriterionAttempt; failures: [VerificationFailure, ...VerificationFailure[]]; } /** A passed criterion is trusted only by the verifier instance that made it. */ export interface PassedCriterionResult extends ExecutionWindow { readonly outcome: "passed"; readonly criterion: Readonly>; readonly proof: CriterionProof; } export type CriterionResult = PassedCriterionResult | FailedCriterionResult; export interface ChecklistItemResult { index: number; item: string; done: boolean; tree: TreeIdentity; } export interface IncompleteChecklistResults { outcome: "incomplete"; items: ChecklistItemResult[]; failures: [VerificationFailure, ...VerificationFailure[]]; tree: TreeIdentity; } /** A complete checklist is trusted only by the verifier instance that made it. */ export interface CompleteChecklistResults { readonly outcome: "complete"; readonly items: readonly ChecklistItemResult[]; readonly failures: readonly []; readonly tree: TreeIdentity; } export type ChecklistResults = CompleteChecklistResults | ObservedCompleteChecklistResults | IncompleteChecklistResults; /** A passed node is trusted only by the verifier instance that made it. */ export interface NodeVerificationRecord { readonly outcome: "passed"; readonly nodeId: string; readonly tree: TreeIdentity; readonly criteria: readonly [PassedCriterionResult, ...PassedCriterionResult[]]; readonly checklist: CompleteChecklistResults; readonly recordedAt: string; } export interface FailedVerification { outcome: "failed"; nodeId: string; tree: TreeIdentity; criteria: CriterionResult[]; checklist: ChecklistResults; recordedAt: string; } export type VerificationResult = NodeVerificationRecord | FailedVerification; /** Cache updates are trusted only by the verifier instance that made them. */ export interface VerificationCacheUpdate { readonly kind: "verification-cache-update"; readonly specPath: string; readonly nodeId: string; readonly recordedAt: string; readonly tree: TreeIdentity; readonly record: VerificationResult; } declare const observedRecordBrand: unique symbol; export interface ObservedPassedCriterionResult extends ExecutionWindow { readonly outcome: "passed"; readonly criterion: Readonly>; readonly proof: CriterionProof; } export type ObservedCriterionResult = ObservedPassedCriterionResult | FailedCriterionResult; export interface ObservedCompleteChecklistResults { readonly outcome: "complete"; readonly items: readonly ChecklistItemResult[]; readonly failures: readonly []; readonly tree: TreeIdentity; } export type ObservedChecklistResults = ObservedCompleteChecklistResults | IncompleteChecklistResults; export interface ObservedNodeVerificationRecord { readonly [observedRecordBrand]?: true; readonly outcome: "passed"; readonly nodeId: string; readonly tree: TreeIdentity; readonly criteria: readonly ObservedPassedCriterionResult[]; readonly checklist: ObservedChecklistResults; readonly recordedAt: string; } export interface ObservedFailedVerification { readonly outcome: "failed"; readonly nodeId: string; readonly tree: TreeIdentity; readonly criteria: readonly ObservedCriterionResult[]; readonly checklist: ObservedChecklistResults; readonly recordedAt: string; } export type ObservedVerificationResult = ObservedNodeVerificationRecord | ObservedFailedVerification; export interface ObservedVerificationCacheUpdate { readonly kind: "verification-cache-update"; readonly specPath: string; readonly nodeId: string; readonly recordedAt: string; readonly tree: TreeIdentity; readonly record: ObservedVerificationResult; } export declare function isCriterionPassed(_result: unknown): _result is PassedCriterionResult; export declare function isNodePassed(_result: unknown): _result is NodeVerificationRecord; /** Reports a persisted record's observation without treating it as execution authority. */ export declare function isObservedNodePassed(result: ObservedVerificationResult): result is ObservedNodeVerificationRecord; export declare function evidenceKind(evidence: Evidence): Evidence["kind"]; export type VerificationNodeInput = { node: WorkNode; tree: TreeIdentity; criteria: readonly AcceptanceCriterion[]; }; export type CommandAttempt = { evidence: CommandEvidence; startedAt: string; finishedAt: string; tree: TreeIdentity; }; /** Convert a verifier result to an immutable observation without carrying its authority. */ export declare function observeVerificationResult(result: VerificationResult): ObservedVerificationResult; /** Decode untrusted serialized cache data for reporting; it never restores verifier authority. */ export declare function decodeVerificationCacheUpdate(value: unknown): ObservedVerificationCacheUpdate | undefined; export declare function isCompleteChecklist(_value: unknown): _value is CompleteChecklistResults; export {};