/**
 * CoherenceReviewer — Base class for all response review pipeline reviewers.
 *
 * Each reviewer is a focused LLM call checking one dimension of response quality.
 * Reviewers use prompt injection hardening (randomized boundaries, anti-injection
 * preambles, structured message passing) and fail-open semantics.
 */
import type { IntelligenceProvider } from './types.js';
/**
 * Structured org intent surfaced to reviewers. Mirrors the on-disk three-rule
 * contract from ORG-INTENT.md: constraints are mandatory, goals are defaults,
 * values shape representation, tradeoff hierarchy resolves ties.
 */
export interface OrgIntentReviewContext {
    /** Org name from the H1 heading */
    name: string;
    /** Mandatory rules — violations MUST block (severity=block, criticality=high) */
    constraints: string[];
    /** Default goals — agents may specialize, contradictions warn */
    goals: string[];
    /** Values shaping representation/tone */
    values: string[];
    /** Tradeoff hierarchy — ordered list resolving ties between values */
    tradeoffHierarchy: string[];
}
export interface ReviewResult {
    pass: boolean;
    severity: 'block' | 'warn';
    issue: string;
    suggestion: string;
    /** Reviewer name */
    reviewer: string;
    /** Latency in ms */
    latencyMs: number;
}
export interface ReviewContext {
    message: string;
    channel: string;
    isExternalFacing: boolean;
    recipientType: 'primary-user' | 'secondary-user' | 'agent' | 'external-contact';
    /** Truncated tool output summary (~500 tokens) */
    toolOutputContext?: string;
    /** Extracted URLs from message */
    extractedUrls?: string[];
    /** Agent values summary from AGENT.md Intent section */
    agentValues?: string;
    /** User values summary from USER.md */
    userValues?: string;
    /**
     * Org values from ORG-INTENT.md — DEPRECATED flat-blob form, kept for
     * backwards compatibility with custom reviewers. Prefer `orgIntent`.
     */
    orgValues?: string;
    /**
     * Structured org intent from ORG-INTENT.md. When present, the
     * three-rule contract (constraints mandatory, goals defaults, values shape)
     * is surfaced to reviewers as separate buckets instead of one flat blob.
     * Null when ORG-INTENT.md is absent, template-only, or unparseable.
     */
    orgIntent?: OrgIntentReviewContext | null;
    /** Trust level for agent recipients */
    trustLevel?: string;
    /** Relationship context (communicationStyle, formality - no free-text fields) */
    relationshipContext?: {
        communicationStyle?: string;
        formality?: string;
        themes?: string[];
    };
    /** Canonical state context — known projects, URLs, facts from CanonicalState registry */
    canonicalStateContext?: string;
}
export interface ReviewerOptions {
    /** Model to use (full ID or tier name) */
    model?: string;
    /** Timeout in ms */
    timeoutMs?: number;
    /** Mode: block, warn, or observe */
    mode?: 'block' | 'warn' | 'observe';
    /**
     * IntelligenceProvider for routing LLM calls. Required as of the path-constraint
     * lockdown (specs/provider-portability/04-anthropic-path-constraints.md): the
     * direct-Anthropic-API fallback path that previously activated when this was
     * omitted has been removed (Rule 2). Constructors of reviewers without an
     * intelligence provider will throw at first `review()` call.
     */
    intelligence?: IntelligenceProvider;
    /**
     * If set, this reviewer's LLM call waits up to this many ms (bounded) for an
     * open circuit breaker window to clear before failing open. Set only for
     * high-stakes reviewers; best-effort reviewers omit it (instant fail-open).
     */
    rateLimitWaitMs?: number;
}
export interface ReviewerHealthMetrics {
    passCount: number;
    failCount: number;
    errorCount: number;
    totalLatencyMs: number;
    jsonParseErrors: number;
}
export declare abstract class CoherenceReviewer {
    readonly name: string;
    protected readonly intelligence: IntelligenceProvider | null;
    protected readonly options: ReviewerOptions;
    readonly metrics: ReviewerHealthMetrics;
    constructor(name: string, options?: ReviewerOptions);
    /**
     * Run this reviewer against the given context.
     * Handles timing, API call, parsing, and fail-open semantics.
     */
    review(context: ReviewContext): Promise<ReviewResult>;
    /**
     * Each reviewer overrides this to build its specific prompt.
     */
    protected abstract buildPrompt(context: ReviewContext): string;
    /**
     * Generate a randomized boundary token for prompt injection hardening.
     */
    protected generateBoundary(): string;
    /**
     * Standard anti-injection preamble included at the top of every reviewer prompt.
     */
    protected buildAntiInjectionPreamble(): string;
    /**
     * Wrap a message in boundary markers, JSON-stringified for safety.
     */
    protected wrapMessage(message: string, boundary: string): string;
    /**
     * Parse a reviewer's raw response into the standard result shape.
     * Strict validation — malformed output triggers fail-open.
     */
    protected parseResponse(raw: string, name: string): {
        pass: boolean;
        severity: string;
        issue: string;
        suggestion: string;
    };
    /**
     * Run the reviewer's LLM call. Routes through the IntelligenceProvider, which
     * itself routes through the Claude CLI (Agent SDK / subscription path) per
     * Rule 2 of the path constraints. If no IntelligenceProvider is wired,
     * throws — the previous direct-Anthropic-API fallback path was removed
     * during the path-constraint lockdown (no raw `api.anthropic.com` calls
     * may live on routine inference paths).
     *
     * Wraps the provider call in a timeout race so the reviewer can fail
     * within `timeoutMs` even if the provider's own timeout is longer.
     */
    protected callApi(prompt: string): Promise<string>;
    /**
     * Map a reviewer model string (e.g., 'haiku', 'sonnet', full ID) to an
     * IntelligenceProvider tier. Reviewers default to 'haiku' → 'fast'.
     */
    private mapModelToTier;
}
//# sourceMappingURL=CoherenceReviewer.d.ts.map