Expand description
§API Support Debug Lab — diagnostic library
This library is the engine behind the api-debug-lab CLI. It loads a
Case from a fixture directory or a case.json path, runs a fixed
set of rules over it, and returns a Report that ranks the firing
diagnoses by confidence.
§How the pieces fit together
fixtures/cases/<name>/case.json → Case (serde, schema-validated)
fixtures/cases/<name>/server.log → &str (lazy load via Case::load_log)
fixtures/cases/<name>/secret.txt → Vec<u8> (via Case::load_secret)
│
▼
all_rules() : Vec<Box<dyn Rule>>
│
▼ one Rule::evaluate per rule, all measured by diagnose_traced
Diagnosis[] ─ sorted by confidence desc, alphabetical tiebreak ─► Report§Determinism
Every code path here is deterministic. Headers iterate via
std::collections::BTreeMap, reproductions inline the body so
output paths never bake in machine-specific filesystem state, no
system clock or RNG is consulted. The byte-stable contract is held
to via snapshot tests in tests/snapshots.rs.
§No I/O beyond local files
No network calls. No environment variables. No global state. The
library is pure with respect to the inputs you hand it; the CLI
does its own filesystem reads via Case::load.
§Public surface
Most callers will use the re-exports below: load a case with
Case::load, call diagnose or diagnose_traced, and render
the resulting Report through Report::render.
use api_debug_lab::{Case, diagnose, Format};
use std::path::Path;
let case = Case::load("auth_missing", Path::new("fixtures")).unwrap();
let report = diagnose(&case);
print!("{}", report.render(Format::Human));
std::process::exit(report.exit_code());Re-exports§
pub use cases::Case;pub use cases::CaseLoadError;pub use cases::Severity;pub use evidence::Evidence;pub use evidence::Pointer;pub use report::Diagnosis;pub use report::Format;pub use report::Report;pub use rules::all_rules;pub use rules::diagnose;pub use rules::diagnose_traced;pub use rules::Rule;pub use rules::RuleTrace;