diffguard-core
Core orchestration and rendering layer for diffguard.
This crate is I/O-free. It coordinates parsing + rule evaluation and returns structured outputs for callers (CLI, editors, automation).
Main Responsibilities
- Run checks from unified diff text (
run_check) - Build deterministic receipts/verdicts
- Render outputs (Markdown, SARIF, JUnit, CSV, TSV)
- Render
sensor.report.v1envelopes - Compute finding fingerprints
Primary API
CheckPlanCheckRunrun_check(&CheckPlan, &ConfigFile, &str)render_markdown_for_receipt()render_sarif_for_receipt()/render_sarif_json()render_junit_for_receipt()render_csv_for_receipt()/render_tsv_for_receipt()render_sensor_report()/render_sensor_json()run_sensor()(sensor API helper)compute_fingerprint()/compute_fingerprint_raw()
run_check Example
use BTreeSet;
use ;
use ;
let plan = CheckPlan ;
let config = built_in;
let diff_text = r#"
diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,1 +1,2 @@
fn a() {}
+let x = maybe.unwrap();
"#;
let run = run_check?;
println!;
println!;
Exit Code Contract
CheckRun.exit_code is stable:
0pass2policy fail3warn-fail (whenfail_on=warn)
1 is reserved for outer tool/runtime failures, typically handled by callers.
Dependency Role
diffguard-core depends on:
diffguard-difffor unified diff parsingdiffguard-domainfor rule compilation/evaluationdiffguard-typesfor DTOs and schema-bound structures
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.