import type { NormalizedWorkflowSpec } from '../spec-intake/types.js';
import { type WorkforcePersonaResolver, type WorkforcePersonaSendOptions } from './workforce-persona-writer.js';
/**
 * Reviewer verdict values.
 *
 * - `pass`: artifact approved; pipeline ships the writer's output as-is.
 * - `fix`: artifact has actionable fixes; pipeline feeds them back into one
 *   writer repair attempt.
 * - `block`: artifact is fundamentally wrong; pipeline keeps the writer's
 *   output and records the verdict in metadata for the operator.
 * - `error`: the reviewer pass itself failed (resolver error, harness
 *   timeout, parser exception). Distinct from `block` so downstream
 *   automation does not misread "the reviewer crashed" as "the reviewer
 *   reviewed and approved." Only ever produced by the pipeline catch path,
 *   never emitted by the reviewer persona itself.
 */
export type WorkforcePersonaReviewVerdict = 'pass' | 'fix' | 'block' | 'error';
export type WorkforcePersonaReviewSeverity = 'critical' | 'important' | 'moderate';
export interface WorkforcePersonaReviewFix {
    severity: WorkforcePersonaReviewSeverity;
    area: string;
    finding: string;
    requestedChange: string;
}
export interface WorkforcePersonaReviewMetadata {
    personaId: string;
    tier: string;
    harness: string;
    model: string;
    selectedIntent: string;
    runId: string | null;
    warnings: string[];
    promptDigest: string;
}
export interface WorkforcePersonaReviewResult {
    verdict: WorkforcePersonaReviewVerdict;
    summary: string;
    fixes: WorkforcePersonaReviewFix[];
    raw: string;
    metadata: WorkforcePersonaReviewMetadata;
}
export interface WorkforcePersonaReviewOptions {
    repoRoot: string;
    outputPath: string;
    artifactContent: string;
    workflowName: string;
    tier?: string;
    timeoutSeconds?: number;
    installSkills?: boolean;
    installRoot?: string;
    env?: NodeJS.ProcessEnv;
    signal?: AbortSignal;
    onProgress?: WorkforcePersonaSendOptions['onProgress'];
    resolver?: WorkforcePersonaResolver;
    personaIntentCandidates?: readonly string[];
}
/**
 * Runs a Workforce persona reviewer over a freshly generated workflow
 * artifact. The reviewer resolves through the same `agent-relay-workflow`
 * intent path as the writer, but targets the `review` intent at tier
 * `best` by default so the audit pass uses the deepest-reasoning Claude
 * persona available. The reviewer returns a structured verdict the
 * pipeline can act on (pass through, feed fixes back to the writer, or
 * block).
 */
export declare function reviewWorkflowWithWorkforcePersona(spec: NormalizedWorkflowSpec, options: WorkforcePersonaReviewOptions): Promise<WorkforcePersonaReviewResult>;
/**
 * Extracts the reviewer verdict from the persona response.
 *
 * Resolution order, picked to favor the model's final-line answer over any
 * earlier draft work:
 * 1. Walk the response as Markdown via `mdast-util-from-markdown` and collect
 *    every fenced ` ```json ` code block. Try the LAST block first, then
 *    earlier blocks — Sonnet has been observed to emit one or more draft
 *    verdict JSONs followed by its final verdict, and the final block is
 *    what the persona system prompt says is authoritative.
 * 2. If no fenced block carried a valid verdict, scan the raw text from the
 *    end looking for the last balanced `{ ... }` object. This catches
 *    "prose plus unfenced JSON on the final line."
 * 3. Direct-parse the entire trimmed output as a JSON object. This catches
 *    the strict-contract case where the model returned only `{ ... }`.
 *
 * Falls back to `verdict: 'block'` with a canned summary when no candidate
 * carries a recognized verdict so the pipeline can record an auditable
 * failure rather than crashing or silently approving.
 *
 * Why mdast rather than a regex over raw text: `output.match(/```json[…]```/)`
 * picks the first match and can match across nested fences inside the
 * inlined workflow source the reviewer is auditing. The CLAUDE.md
 * "grammar-aware parsers, not regex" rule applies directly here — see the
 * `markdown-target-files.ts` precedent for the same pattern.
 */
export declare function parseReviewerVerdict(output: string): {
    verdict: WorkforcePersonaReviewVerdict;
    summary: string;
    fixes: WorkforcePersonaReviewFix[];
};
/**
 * Returns the parsed contents of every fenced ` ```json ` block in the
 * response, ordered LAST-block-first so callers can prefer the model's
 * final answer over earlier drafts. Walks the mdast tree rather than
 * regex-matching raw text so fenced blocks nested inside the workflow
 * source the reviewer is auditing do not get confused with verdict
 * blocks.
 */
export declare function extractFencedJsonBlocksLastFirst(output: string): Record<string, unknown>[];
/**
 * Renders a flat list of fix strings suitable for feeding back into the
 * writer's `validationFeedback.errors` channel. Each line carries the
 * severity prefix so the writer can prioritise inside the repair attempt.
 */
export declare function renderReviewFixesForWriter(review: WorkforcePersonaReviewResult): string[];
