nornir 0.5.0

Companion to cargo: dependency tracking, release gating, deploy, benchmarks, and documentation assembly. Project-agnostic.
//! # nornir
//!
//! A project-agnostic companion to `cargo`. Reusable building blocks
//! for release pipelines, benchmarks, and documentation written in
//! Rust, callable from thin per-project driver binaries.
//!
//! Modules:
//! - [`bench`]      benchmark harness + append-only JSONL history
//! - [`release`]    gates, publish-order walker, deploy
//! - [`deps`]       cross-crate dependency tracking (workspace-aware)
//! - [`docs`]       deterministic assembly of README / CHANGELOG / etc.
//! - [`guard`]      AI-agent guard rails: chmod -w forbidden paths
//!                  declared in `[guard].forbidden` of a nornir.toml
//! - [`introspect`] call graph + dep graph + public API extracted from
//!                  the *built* code (rustdoc JSON, cargo metadata, syn);
//!                  rendered into docs so they cannot drift from the code
//!
//! Optional features:
//! - `fixtures-maven` — canonical Maven Central JAR set as bench inputs
//!
//! Future companion crates (not in this repo):
//! - `nornir-mcp` — exposes every API here as an MCP (Model Context
//!   Protocol) tool, letting an LLM agent drive build/release/docs.
//! - `nornir-cli` — `cargo nornir ...` subcommand for human use.
//!
//! See `workspace_holger/release/SPEC.md` for the contract that
//! generated binaries implement on top of this library.

pub mod arch;
pub mod autonom;
pub mod bench;
pub mod change;
pub mod cli_outcome;
pub mod config;
pub mod coverage;
pub mod deepscan;
pub mod deps;
pub mod docs;
pub mod funnel;
pub mod gitio;
pub mod guard;
#[cfg(feature = "embed-holger")]
pub mod holger_embed;
pub mod index;
pub mod introspect;
pub mod jobs;
pub mod knowledge;
pub mod mimir;
pub mod monitor;
pub mod registry;
pub mod security;
pub mod selftest;
pub mod ssh;
pub mod release;
pub mod robot;
pub mod test_matrix;
#[cfg(feature = "vector")]
pub mod vector;
pub mod warehouse;
// `viz` builds the full egui app; `server` needs only `viz::model` (the pure
// timeline builder) for the `Viz.Timeline` RPC — submodules are gated inside.
#[cfg(any(feature = "viz", feature = "server"))]
pub mod viz;
pub mod workspace;

pub use anyhow::{Error, Result};

/// Process-wide serial lock for tests that mutate GLOBAL state (env vars, cwd, or
/// spawn `cargo metadata`). `cargo test` runs tests multi-threaded by default, so
/// two tests touching the same `HOME`/`NORNIR_VIZ_ACTIONLOG`/`cargo`-lock race
/// intermittently (each passes alone). Such tests take `let _g = nornir::serial_guard();`
/// at the top so they run one-at-a-time relative to each other. Poison-tolerant.
#[cfg(test)]
pub(crate) fn serial_guard() -> std::sync::MutexGuard<'static, ()> {
    static LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
    LOCK.lock().unwrap_or_else(|e| e.into_inner())
}