import type { ToolResult } from '../../types/index.js';
import type { FormatGateOutput } from '../../types/spec/inputs.js';
import type { Spec } from '../../types/spec/core.js';
import type { EscalateResult } from '../../types/escalator.js';
/**
 * The reason why the validate gate blocked a `done` transition.
 * Each reason maps to a specific fix-hint shown to the LLM.
 */
export type ValidateGateBlockReason = 'validate_score_below_threshold' | 'validate_gate_no_criteria' | 'validate_gate_crash' | 'validate_gate_timeout' | 'validate_gate_unreachable';
/**
 * Return type for `runValidateGate`.
 *
 * - `blocked: true`  → caller MUST block the transition and surface the reason.
 * - `blocked: false, forced: false` → validate passed with a real score.
 * - `blocked: false, forced: true`  → forceStatus bypass; audit-logged by caller.
 */
export type ValidateGateResult = {
    blocked: true;
    score: number | null;
    reason: ValidateGateBlockReason;
    errorMessage?: string;
} | {
    blocked: false;
    score: number;
    forced: false;
} | {
    blocked: false;
    score: number | null;
    forced: true;
    forcedReason: string;
};
/**
 * SPEC-721 / SPEC-222 Trigger 1: Run validate engine before marking done.
 *
 * Fail-CLOSED: timeout, crash, or null score → blocked (not allowed through).
 * The only escape hatch is `forceStatus=true` with a `forceStatusReason` ≥100 chars.
 *
 * The timeout lives inside this function (Promise.race) so we own the reason string.
 * Callers must NOT wrap this with `withToolTimeout` — doing so would silently convert
 * timeout into `blocked: false` (the exact bypass this spec closes).
 *
 * @param spec            The spec being transitioned.
 * @param projectPath     Project root for the validate engine.
 * @param forceStatus     Whether the LLM explicitly wants to bypass the gate.
 * @param forceStatusReason  Why — required and ≥100 chars when forceStatus=true.
 * @param budgetMs        Max milliseconds to wait for validate. Default: 9000.
 */
export declare function runValidateGate(spec: Spec, projectPath: string, forceStatus: boolean, forceStatusReason: string | undefined, budgetMs?: number, reviewContext?: {
    projectId: string;
    specId: string;
}): Promise<ValidateGateResult>;
/**
 * Checks the DoD gate before transitioning to 'done'.
 * Returns an error ToolResult if blocked (unless force=true), null if passed.
 */
export declare function checkDodGate(spec: Spec, specId: string, projectId: string, projectPath: string | undefined, _force: boolean): Promise<ToolResult | null>;
/**
 * SPEC-335: Security gate — blocks 'done' transition if critical CVEs are found.
 * Only runs when projectPath is available. Never throws — best-effort.
 * Returns an error ToolResult if blocked, null if passed or skipped.
 *
 * Exported for testing; callers should prefer checkDoneGates for the full gate suite.
 */
export declare function checkSecurityGate(projectPath: string | undefined, specId: string, force?: boolean): Promise<ToolResult | null>;
/** Return value for checkDoneGates — separates blocking errors from force-bypass warnings. */
export interface DoneGateResult {
    /** Non-null means gate blocked — caller MUST return this as an error response. */
    blocked: ToolResult | null;
    /**
     * Non-null when force=true bypassed failing DoD items.
     * Caller should surface this as a warning in the success response.
     */
    forcedBypassWarning: string | null;
}
/**
 * SPEC-725: Check the validation-report artifact gate before marking done.
 * SPEC-1050: Fail closed. A done transition requires a fresh validation-report
 * with reviewer evidence and all validation gates passing.
 */
export declare function checkValidationReportGate(specId: string, projectId: string, force: boolean | undefined): Promise<ToolResult | null>;
/** SPEC-1051: Write spec-review evidence when a spec enters review. */
export declare function writeSpecReviewArtifact(spec: Spec, specId: string, projectId: string): Promise<ToolResult | null>;
/** SPEC-1051: Approval requires a dedicated spec reviewer artifact. */
export declare function checkSpecReviewGate(specId: string, projectId: string, _forceApprove: boolean | undefined): Promise<ToolResult | null>;
/**
 * SPEC-335: Combined done-gates runner — DoD + security.
 * When force=true, gates are not blocking but failing items are recorded in
 * the project's force-bypass-log.json for traceability (guard: done ≠ implemented).
 */
export declare function checkDoneGates(spec: Spec, specId: string, projectId: string, projectPath: string | undefined, force: boolean | undefined): Promise<DoneGateResult>;
export interface ComplianceGateResult {
    skipped: boolean;
    score: number | null;
    issues: string[];
    blocked: boolean;
}
/**
 * SPEC-447: Runs the compliance check when transitioning to 'review'.
 * Never blocks the transition if the compliance engine is unavailable or fails.
 */
export declare function checkComplianceGate(specId: string, projectId: string, projectPath: string | undefined): Promise<ComplianceGateResult>;
/** SPEC-642: Block done if QA gate has not run and passed. */
export declare function checkQaGate(specId: string, projectPath: string | undefined, force: boolean): Promise<ToolResult | null>;
/**
 * SPEC-716 / SPEC-780: Format gate for transition to 'approved'.
 *
 * - newStatus !== 'approved' → returns `{ blockResult: null, qualityWarnings: [] }` (gate inert)
 * - validateSpecFormat returns valid → `{ blockResult: null, qualityWarnings: [] }`
 * - validateSpecFormat returns invalid AND `forceApprove !== true` → `{ blockResult: <SPEC_FORMAT_INVALID>, qualityWarnings: [] }` (block, legacy behavior)
 * - validateSpecFormat returns invalid AND `forceApprove === true` → `{ blockResult: null, qualityWarnings: <serialized errors> }` (proceed; warnings written to spec frontmatter by caller, mirroring SPEC-769 readiness gate)
 *
 * Best-effort: never throws — gate is skipped on unexpected errors.
 */
export declare function checkApprovedFormatGate(spec: Spec, newStatus: string, forceApprove?: boolean | undefined): Promise<FormatGateOutput>;
/**
 * Run the validate gate wrapped in withEscalation for bounded retries.
 *
 * On budget exhaustion, returns an escalation sentinel with decision='retry'|'abort'.
 * The caller is responsible for surfacing the decision as interactiveQuestions.
 *
 * @param spec            - The spec being transitioned.
 * @param projectPath     - Project root for the validate engine.
 * @param projectId       - Project ID for retry counter persistence.
 * @param specId          - Spec ID for retry counter keying.
 * @param frontmatterSha  - Frontmatter SHA for retry counter keying.
 * @param forceStatus     - Whether to bypass the gate.
 * @param forceStatusReason - Required when forceStatus=true.
 * @param budgetMs        - Max milliseconds for validate.
 */
export declare function runValidateGateWithEscalation(spec: Spec, projectPath: string, projectId: string, specId: string, frontmatterSha: string, forceStatus: boolean, forceStatusReason: string | undefined, budgetMs?: number): Promise<EscalateResult<ValidateGateResult>>;
//# sourceMappingURL=dod-gates.d.ts.map