/** * Validate Engine Operations — business logic layer. * * Contains all gate-verification and protocol-validation domain logic migrated * from `packages/cleo/src/dispatch/engines/validate-engine.ts` (ENG-MIG-7 / T1574). * * Each exported function returns `EngineResult` and is importable from * `@cleocode/core/internal` so the CLI dispatch layer can call them without * any intermediate engine file. * * @task T1574 — ENG-MIG-7 * @epic T1566 */ import type { EvidenceAtom, KnowledgeCoverage, TaskVerification, VerificationGate } from '@cleocode/contracts'; import { type EngineResult } from '../engine-result.js'; import { type EvidenceTree } from '../tasks/evidence-tree.js'; /** Parameters shared across all protocol validation operations. */ export interface ProtocolValidationParams { mode: 'task' | 'manifest'; taskId?: string; manifestFile?: string; strict?: boolean; votingMatrixFile?: string; epicId?: string; siblingCount?: number; descriptionClarity?: boolean; maxSiblings?: number; maxDepth?: number; specFile?: string; hasTaskTags?: boolean; hasContributionTags?: boolean; hasCodeChanges?: boolean; version?: string; hasChangelog?: boolean; artifactType?: string; buildPassed?: boolean; hasAttestation?: boolean; hasSbom?: boolean; adrContent?: string; status?: 'proposed' | 'accepted' | 'superseded' | 'deprecated'; hitlReviewed?: boolean; downstreamFlagged?: boolean; persistedInDb?: boolean; specMatchConfirmed?: boolean; testSuitePassed?: boolean; protocolComplianceChecked?: boolean; framework?: string; testsRun?: number; testsPassed?: number; testsFailed?: number; coveragePercent?: number; coverageThreshold?: number; ivtLoopConverged?: boolean; ivtLoopIterations?: number; } export interface GateVerifyParams { taskId: string; gate?: string; value?: boolean; agent?: string; all?: boolean; reset?: boolean; /** * Raw evidence string from CLI `--evidence` flag (T832 / ADR-051). * Required for all write operations except `reset` and `value=false`. */ evidence?: string; /** Session ID for audit trail (T832 / ADR-051 §6.1). */ sessionId?: string; /** * Acknowledge that the same evidence atom is being applied to >3 distinct * tasks in this session (T1502 / P0-6). Without this flag, such reuse * triggers a warning (or a hard reject in strict mode). */ sharedEvidence?: boolean; /** * `--no-run` (T12621). Since T13521 (owner decision) every write is * cache-only unless {@link GateVerifyParams.runTyped} is set, so this flag * only states that default explicitly; it refuses alongside `runTyped`. */ noRun?: boolean; /** * `--run-typed` (T13521): execute the task's uncached typed gates during * this write, the pre-T13521 behaviour. Without it a write executes no typed * gate command: it reads cached passes (from `cleo verify --run`), refuses * a gate the write links that has none, and records the others as not run. */ runTyped?: boolean; /** * Per-gate evidence for ONE write (T12625 · `cleo done`): each gate's own * atom string goes through the same parse → `validateAtom` → gate minimum → * `checkTaskEvidenceContext` path as `--gate … --evidence …`, and every gate * is persisted in the same transaction. Exclusive with `gate`/`all`/ * `evidence`, and refuses `CLEO_OWNER_OVERRIDE` (the override stays a * single-gate, audited `cleo verify` path). */ gateEvidence?: Partial>; /** * Validate `gateEvidence` exactly as the write would, then stop before * typed gates and persistence (T12672): `cleo done --plan` and `cleo done` * share one readiness check. `tool:` atoms are not executed (their result is * not plan-visible) and shared-evidence tracking, which records reuse, is * skipped. */ preview?: boolean; } export interface GateVerifyResult { /** Coverage assessed when evidence is recorded, independent of gate success. */ knowledgeCoverage?: KnowledgeCoverage; taskId: string; title?: string; status?: string; type?: string; verification: TaskVerification; verificationStatus: 'passed' | 'pending'; passed: boolean; round: number; requiredGates: VerificationGate[]; missingGates: VerificationGate[]; action?: 'view' | 'set_gate' | 'set_all' | 'reset' | 'preview'; gateSet?: string; gatesSet?: VerificationGate[]; /** Evidence atoms validated and persisted for this write (T832). */ evidenceStored?: EvidenceAtom[]; /** True when CLEO_OWNER_OVERRIDE bypassed evidence validation (T832). */ override?: boolean; /** * The checkout this write's evidence was bound in and the tier that chose * it ({@link resolveEvidenceTree}, T14058). Present when evidence was stored. */ evidenceRoot?: EvidenceTree; /** * Actionable next-step hint emitted when all required gates become green * after a write (policy-b: verify never auto-completes, explicit complete * is always required). Absent on view mode and when gates are still missing. * Fixes GH #94 / T919. */ hint?: string; /** * Notes on passed gates, e.g. `{ testsPassed: 'passed (flaky: )' }` * when the gate's tool run passed only on its one full rerun (T12961). * Absent when there is nothing to note. */ gateNotes?: Partial>; } /** * check.gate.verify — View or modify verification gates for a task. * * As of v2026.4.78 (T832 / ADR-051), every gate write MUST be accompanied * by structured evidence validated against git, the filesystem, and the * toolchain. `reset` mode requires no evidence. `value=false` (gate fail) * requires no evidence since failures do not need proof. * * @param projectRoot - Owning project root for task, input files and result storage. * @param params - Explicit gate verification request; typed gates run only for a positive write. * @returns Verification state or a diagnostic refusal, without completing the task. * @remarks Positive typed writes execute under the captured lifetime (two seconds for * an unscoped caller), then compare task, criteria and input snapshots in the owning * transaction. Bound results, AC links and the mandatory typed receipt commit together. * Filesystem snapshots cannot provide a transaction spanning native files and SQLite. * @example * ```ts * const result = await validateGateVerify(projectRoot, { * taskId: 'T123', gate: 'cleanupDone', evidence: 'note:cleanup reviewed', * }); * ``` * * @task T5327 * @task T832 * @task T12106 * @adr ADR-051 */ export declare function validateGateVerify(projectRoot: string, params: GateVerifyParams): Promise>; /** * check.protocol.consensus - Validate consensus protocol compliance * @task T5327 */ export declare function validateProtocolConsensus(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.contribution - Validate contribution protocol compliance * @task T5327 */ export declare function validateProtocolContribution(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.decomposition - Validate decomposition protocol compliance * @task T5327 */ export declare function validateProtocolDecomposition(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.implementation - Validate implementation protocol compliance * @task T5327 */ export declare function validateProtocolImplementation(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.specification - Validate specification protocol compliance * @task T5327 */ export declare function validateProtocolSpecification(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.research - Validate research protocol compliance * @task T260 */ export declare function validateProtocolResearch(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.architecture-decision - Validate ADR protocol compliance * @task T260 */ export declare function validateProtocolArchitectureDecision(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.validation - Validate validation-stage protocol compliance * @task T260 */ export declare function validateProtocolValidation(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.testing - Validate testing-stage protocol compliance (IVT loop) * @task T260 */ export declare function validateProtocolTesting(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.release - Validate release protocol compliance * @task T260 */ export declare function validateProtocolRelease(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.artifact-publish - Validate artifact-publish protocol compliance * @task T260 */ export declare function validateProtocolArtifactPublish(_projectRoot: string, params: ProtocolValidationParams): Promise; /** * check.protocol.provenance - Validate provenance protocol compliance * @task T260 */ export declare function validateProtocolProvenance(_projectRoot: string, params: ProtocolValidationParams): Promise; //# sourceMappingURL=engine-ops.d.ts.map