//! # mcptest-core
//!
//! Core engine pieces for the `mcptest` CLI. This crate owns the
//! domain model (tests, steps, expectations) and the matcher library that
//! decides whether an MCP response satisfies an expectation.
//!
//! Everything except [`report::upload`] is transport-free. The runner crate
//! composes this library with a transport to produce a working CLI. Keeping
//! the matchers and core model transport-free lets us load them from a
//! Python or JavaScript host later (see  / ADR-018) without pulling
//! an async runtime through FFI. The upload reporter is the one
//! deliberate carve-out: it must speak HTTPS to a collector, so it pulls
//! `reqwest::blocking` and lives in its own module that FFI hosts skip.
//!
//! ## Public surface
//!
//! - [`matchers`]: the built-in matchers, each producing a structured
//!   [`matchers::AssertionResult`]. The PRD §4.5 core is `exact`, `schema`,
//!   `regex`, `contains`, `snapshot`, and `llm-judge`;  adds the
//!   deterministic vocabulary `contains-all`, `contains-any`, `icontains`,
//!   `starts-with`, `is-json`, `is-valid-tools-call`, and `levenshtein`,
//!   plus the universal `not` negation wrapper.  adds `is-xml`,
//!   `is-sql`, and the async `similar` (embedding cosine) matcher.
//! - [`cache`]: cache eligibility rules engine that decides whether a
//!   given test is safe to read from or write to the cache.
//!   Includes the local filesystem-backed store and the
//!   GitHub Actions cache backend under the same trait.
//! - [`coverage`]: per-tool, arg-pair, error-path, and transport coverage
//!   tracker plus thresholds gate.
//! - [`fixtures`]: named error scenarios authored once in YAML and
//!   referenced from tests by name.
//! - [`lint`]: tool-description quality lints surfaced by
//!   `mcptest doctor --lint-descriptions`.
//! - [`cassette`]: cassette determinism normalization. The
//!   recorder/replayer file format lives in a future ticket; this crate
//!   ships only the library that detects non-deterministic values and
//!   compares normalized recordings against fresh responses.
//! - [`compliance`]: expected-failures baseline parser and matcher used
//!   by the future `mcptest compliance` runner.
//! - [`redaction`]: the single redaction policy used by every reporter,
//!   log line, cassette, and error message.
//! - [`report`]: canonical run output model + reporter trait + bundled
//!   pretty / JSON / JUnit reporters. Includes per-step timing
//!   and per-juror verdict types.
//! - [`protocol`]: JSON-RPC MCP client with handshake, request/response
//!   correlation, notification routing, and graceful shutdown.
//! - [`proxy`]: stdio man-in-the-middle recorder behind `mcptest record`.
//!   Forwards a client's JSON-RPC envelopes verbatim to a live target and
//!   rewrites a cassette crash-safe after each completed exchange.
//! - [`stub_gen`]: schema-aware test generators that turn a `tools/list`
//!   response into per-tool starter stubs or one whole-suite YAML document
//!   with valid, edge, and violation cases plus a multi-model matrix. The
//!   `mcptest init --auto-stubs` and `mcptest generate` CLIs consume it.
//! - [`auth`]: OAuth 2.1 access-token cache and refresh layer.
//!   Transport-free, so the runner crate supplies the HTTP refresher.
//! - [`baseline`]: per-test timing baseline file format and regression
//!   detector contract. Runtime detector lands in
//!   v1.1; the v1.0 scaffold ships the file shape and read/write helpers.
//! - [`diff`]: schema-diff library that classifies changes between two
//!   `tools/list` snapshots as breaking or non-breaking.
//! - [`discovery`]: `.well-known/mcp.json` fetcher and parser used by the
//!   future `mcptest discover` subcommand. Errors are typed by
//!   network layer so failures surface in the same shape as runtime errors.
//! - [`network`]: layered network error model used by every probe and
//!   request pipeline.
//! - [`transport`]: HTTP transport configuration model (custom headers,
//!   timeouts, basic TLS) consumed by the future HTTP runner.
//! - [`readiness`]: wait-for-ready polling loop and probe trait used by
//!   `mcptest run --wait-for-ready`. Transport-free; the runner
//!   plugs in an HTTP-backed probe.
//! - [`runner`]: step-timing helpers the future runner crate will call to
//!   populate [`report::TestStep`] fields. Transport-free; pure
//!   stopwatch plus RFC 3339 formatting.
//! - [`eval`]: LLM evaluation primitives. Currently houses the jury
//!   bias-mitigation engine and the inter-juror
//!   agreement metrics. Provider plumbing lives
//!   elsewhere; this module is pure math over juror outputs.
//! - [`model_compat`]: model-compatibility capture, diff, and invariant
//!   engine (W8, ADR 0026). Library entry points that the
//!   `mcptest model-baseline` CLI consumes.
//! - [`exec`]: IPC co-process dispatcher for the
//!   `mcptest exec --connection-server` mode. Holds
//!   the JSON-RPC envelope types, the session loop, and the
//!   `McpBackend` trait the CLI implements against a real MCP client.
//! - [`plugins`]: subprocess plugin protocol. Spawns a polyglot
//!   plugin binary, exchanges newline-delimited JSON over stdin/stdout,
//!   and caches the process for the run lifetime.
//! - [`policy`]: offline governance policy simulator. Turns saved artifacts
//!   into a flat fact map and evaluates declarative rules plus expiring
//!   waivers into a pass / warn / fail verdict, with no network access.
//! - [`subprocess`]: one-shot JSON subprocess helper shared by
//!   the transform step and the context-aware hooks. Spawns a command,
//!   writes one JSON value to stdin, and parses one JSON value from stdout.
//! - [`hooks`]: context-aware lifecycle hook ABI. The opt-in
//!   [`hooks::HookStep::Context`] form feeds a hook the run context as JSON
//!   on stdin and applies a small, restricted patch from its stdout.
//! - [`Error`]: typed error used by every operation in this crate.

#![deny(missing_docs)]
#![deny(rustdoc::broken_intra_doc_links)]

pub mod ablation;
pub mod auth;
pub mod badge;
pub mod bakeoff;
pub mod baseline;
pub mod benchmark_import;
pub mod cache;
pub mod capabilities;
pub mod cassette;
pub mod checks;
pub mod compliance;
pub mod composition;
pub mod concurrency;
pub mod config_scan;
pub mod conformance;
pub mod connector;
pub mod coverage;
pub mod diff;
pub mod discovery;
pub mod distill;
pub mod drift;
pub mod ecosystem;
pub mod error_anchors;
pub mod eval;
pub mod evidence;
pub mod evidence_pack;
pub mod evidence_pack_diff;
pub mod exec;
pub mod exec_policy;
pub mod executor;
pub mod extensions;
pub mod fixtures;
pub mod hooks;
pub mod interop;
pub mod ledger;
pub mod lint;
pub mod matchers;
pub mod migration;
pub mod model_compat;
pub mod network;
pub mod otel;
pub mod plugins;
pub mod policy;
pub mod posture;
pub mod profiles;
pub mod propose;
pub mod protocol;
pub mod proxy;
pub mod readiness;
pub mod redaction;
pub mod report;
pub mod runner;
pub mod runtime_faults;
pub mod scenario;
pub mod security;
pub mod stub_gen;
pub mod style;
pub mod subprocess;
pub mod suite;
pub mod target_versions;
pub mod tool_bench;
pub mod transform;
pub mod transform_jq;
pub mod transport;
pub mod version;
pub mod waivers;
pub mod workbench;

mod error;
pub use error::Error;

/// Convenient `Result` alias bound to this crate's [`Error`].
pub type Result<T> = std::result::Result<T, Error>;
