//! LLM evaluation primitives (W7 v1.1).
//!
//! Why this module exists: the v1.1 jury pipeline needs transport-free
//! building blocks for bias mitigation and inter-juror agreement so the
//! same logic powers the OSS runner, the future SDK hosts, and the
//! enterprise audit chain. Putting the math here keeps it next to the
//! matcher library and away from any LLM provider plumbing.
//!
//! ## Sub-modules
//!
//! - [`jury`]: bias mitigations and inter-juror agreement
//!   metrics. Both are research-backed; see the per-module
//!   docs for citations and the ADRs 0029 and 0030 for the decision
//!   record.
//! - [`provider`] and [`providers`]: `LlmProvider` trait + Anthropic,
//!   OpenAI, Mistral, and Ollama impls (ADR-0020, /321/323).
//! - [`cost`]: cost budget, deterministic sampling, and consensus-aware
//!   early termination for cost control.
//! - [`distractors`]: distractor-tool / tool-overload scoring (MCPAgentBench,
//!   MCP-Atlas). Declares how many irrelevant or near-duplicate tools to inject
//!   into the candidate list, synthesizes name-collision variants of the real
//!   tools, and folds a recorded selection into a deterministic selection
//!   accuracy with an accuracy-vs-distractor-count degradation curve. Exposes
//!   the assertable `distractors.accuracy` and `distractors.chose_distractor`
//!   targets. Pure, no model in the loop.
//! - [`error`]: `ProviderError` taxonomy shared across the provider impls.
//! - [`failure_source`]: deterministic failure-source classification to cut
//!   false CI reds (WOR-1469). Reads a failure's message, optional HTTP status,
//!   and optional tool name and assigns one of `external_dependency`,
//!   `environment`, `code_bug`, `transient`, or `unknown` with a confidence and
//!   a remediation, backed by an extensible known-external-service table. Pairs
//!   with an opt-in policy that downgrades classified transient/external
//!   failures out of the exit code. Pure, no model in the loop.
//! - [`selection`]: cross-run tool-selection aggregation and the pass^k
//!   metric for multi-run agent tests.
//! - [`tool_selection_f1`]: objective multi-server tool-selection F1 over
//!   declared equal-function sets (MSC-Bench). A selected tool is correct when
//!   it lands in the right equivalence class, so precision, recall, and F1 are
//!   computable deterministically from a recorded trace with no model in the
//!   loop. Folds the N run traces into the assertable `tool_selection.f1`,
//!   `tool_selection.precision`, and `tool_selection.recall` targets.
//! - [`stability`]: within-session Agent Stability Index sub-scores.
//!   Deterministic drift signals folded from a single multi-turn
//!   trace, complementing the cross-run model-compat drift.
//! - [`stability_aggregate`]: cross-run aggregation of the within-session
//!   stability sub-scores. Folds the N traces of a multi-run agent
//!   test into the assertable `stability.score`, `stability.weakest_score`,
//!   and `stability.variance` targets.
//! - [`consistency`]: label-free cross-run consistency metrics (tool-sequence
//!   similarity, argument consistency, early-step divergence). Deterministic,
//!   model-free reproducibility signals over the N traces, exposed as the
//!   assertable `stability.tool_sequence_similarity`,
//!   `stability.argument_consistency`, and `stability.early_divergence`
//!   targets (TRAJECT/AgentAssay consistency family; WOR-1369).
//! - [`trace_validation`]: offline AST-style validation of a recorded
//!   tool-call trace against an expected call structure (the
//!   Berkeley Function-Calling Leaderboard pattern), extended with the
//!   five trajectory match modes and golden-path efficiency scoring.
//!   Pure, no model execution; reuses the `contains` and
//!   `schema` matchers for argument shapes.
//! - [`fuzz`]: schema-driven input fuzzing. Derives malformed, boundary, and
//!   type-confused argument cases from a tool's `inputSchema` (deterministic,
//!   seeded), so the executor can check the server fails cleanly on bad input
//!   rather than crashing, hanging, or leaking. Exposes the assertable `fuzz.*`
//!   targets (arXiv:2606.05339, arXiv:2603.05637; WOR-1238).
//! - [`semantic_types`]: semantic-type inference for the negative fuzzer. Guesses
//!   a parameter's likely shape (email, url, uuid, date, currency, ...) from its
//!   name, description, and schema `format`, then offers malformed-but-right-type
//!   invalid values per type so the fuzzer probes the server's own validation,
//!   not just the schema's. Confidence-gated and pure; the format mapping stays
//!   aligned with the positive stub synthesizer (WOR-1470).
//! - [`metamorphic`]: deterministic metamorphic (oracle-free) relations over
//!   tool calls. Builds a follow-up call's arguments from a base call and a
//!   relation (idempotent, arg-order, case, whitespace, no-op filter, subset,
//!   monotone), then checks the property between the two results. Needs no
//!   golden output and no model, exposing the assertable `metamorphic.*`
//!   targets (ARMeta, LLMORPH; WOR-1237).
//! - [`narrative_trace`]: deterministic narrative-vs-trace divergence. Compares
//!   the agent's final assistant narrative against the recorded tool calls and
//!   flags claimed-but-absent, present-but-unclaimed, and arg-mismatch items,
//!   with a default gate on claimed-but-absent mutating actions. Model-free by
//!   default; an optional model-assisted mode never gates CI.
//! - [`orchestration`]: deterministic MCP-Atlas orchestration diagnostics. Folds
//!   a recorded tool-call trace plus the declared equal-function classes into
//!   five sub-scores (discovery, parameterization, syntax, error_recovery,
//!   efficiency), each an integer percent computed with no model in the loop,
//!   exposed as the assertable `orchestration.*` targets. Pairs with the
//!   name-free discovery declaration so an intent-only prompt scores its
//!   discovered path against the classes.
//! - [`recovery`]: deterministic recovery scoring for a call against an
//!   unresponsive ("dead but connected") server. Folds one timed
//!   observation into time-to-detection, time-to-recovery, and
//!   user-visible hang, with a clean-timeout flag and an assertable
//!   recovery budget. Pure, no I/O; pairs with the mock server's fault
//!   injection mode.
//! - [`reliability`]: reliability reporting beyond pass^k. A power-analysis
//!   run-count recommendation (how many runs N a target confidence-interval
//!   half-width needs, via the worst-case Wald interval) plus a
//!   reliability-decay summary (decay curve, variance amplification, graceful
//!   degradation) over the N per-run outcomes. Pass@k and pass^k stay the
//!   headline; the curves are secondary detail. Deterministic, no model in the
//!   loop, exposing the assertable `reliability.*` targets.
//! - [`sprt`]: Wald's Sequential Probability Ratio Test for the
//!   `mcptest run --repeat N` reliability verdict (WOR-1400). Updates a
//!   log-likelihood ratio of two pass-probability hypotheses after each trial
//!   and stops early the moment a boundary is crossed, so a clearly reliable or
//!   clearly broken suite spends far fewer than N runs and a borderline one
//!   returns inconclusive. Dependency-free and deterministic; maps onto the
//!   shared three-valued [`verdict::Verdict`].

pub mod consistency;
pub mod context_rot;
pub mod cost;
pub mod distractors;
pub mod error;
pub mod failure_source;
pub mod fuzz;
pub mod irt;
pub mod jury;
pub mod metamorphic;
pub mod narrative_trace;
pub mod negative_path;
pub mod orchestration;
pub mod provider;
pub mod providers;
pub mod recovery;
pub mod reliability;
pub mod rubric;
pub mod rubric_parse;
pub mod rubric_presets;
pub mod selection;
pub mod semantic_types;
pub mod sprt;
pub mod stability;
pub mod stability_aggregate;
pub mod token_efficiency;
pub mod tool_edges;
pub mod tool_selection_f1;
pub mod trace_validation;
pub mod verdict;
pub mod verdict_cache;

pub use consistency::{argument_consistency, early_divergence, tool_sequence_similarity};
pub use context_rot::{ContextPoint, ContextRotSummary};
pub use cost::{should_sample, ConsensusMethod, ConsensusTally, CostBudget};
pub use distractors::{
    catalog, degradation_curve, near_duplicates, resolve_distractor_ids, score_selection,
    CatalogEntry, Complexity, CurvePoint, DistractorScore, DistractorSource, DistractorSpec,
    BUNDLED_CATALOG,
};
pub use error::ProviderError;
pub use failure_source::{
    apply_policy, classify_failure, group_by_source, Classification, Disposition, ExternalService,
    FailurePolicy, FailureSource, SourceCount, KNOWN_EXTERNAL_SERVICES,
};
pub use narrative_trace::{
    assess_divergence, DivergenceGate, DivergenceItem, DivergenceKind, DivergenceReport,
    ExtractionMode, MutatingPolicy, Narrative, NarrativeSummary, TraceCall,
};
pub use orchestration::{fold_trace, OrchestrationCall, OrchestrationDiagnostics};
pub use provider::{
    Capabilities, CompletionOptions, Cost, FinishReason, LlmProvider, Message, ProviderId,
    Response, ResponseContent, RetryPolicy, Role, ToolCall, ToolChoice, ToolSpec, Usage,
};
pub use recovery::{
    evaluate_recovery, injected_timeout, meets_recovery_budget, score_recovery,
    RecoveryObservation, RecoveryOutcome, RecoveryReport,
};
pub use reliability::{confidence_band, recommend_runs, summarize, ReliabilitySummary};
pub use rubric_parse::{parse_rubric, RubricParseError, DEFAULT_RUBRIC_THRESHOLD};
pub use rubric_presets::{preset, PRESET_NAMES};
pub use selection::{aggregate_selection, SelectionReport};
pub use semantic_types::{
    infer, is_confident, targeted_invalids, Inference, SemanticType, CONFIDENCE_FLOOR,
};
pub use sprt::{evaluate as sprt_evaluate, SprtConfig, SprtDecision, SprtOutcome};
pub use stability::{agent_stability, drift_flags, StabilityFloors, StabilityReport};
pub use stability_aggregate::{agent_stability_across, StabilitySummary};
pub use token_efficiency::{TokenEfficiency, TokenEfficiencyInput};
pub use tool_selection_f1::{aggregate_f1, EqualFunctionSet, F1Aggregate, F1Score};
pub use trace_validation::{
    score_golden_path, score_trajectory_axes, tool_calls_from_envelope, trajectory_axes_metrics,
    validate_trace, AxesScore, DependencyEdge, ExpectedArgs, ExpectedCall, ExpectedTrace,
    GoldenPath, MatchMode, PathScore, TraceMismatch, TraceValidation,
};
pub use verdict_cache::{
    cache_path_for, default_cache_root, VerdictCache, VerdictCacheConfig, VerdictCacheError,
    VerdictCacheStats, VerdictKey, VerdictRecord, DEFAULT_TTL_SECS,
};
