2 stable releases
Uses new Rust 2024
| new 1.6.3 | Feb 18, 2026 |
|---|---|
| 1.3.0 | Jan 31, 2026 |
#377 in Testing
Used in tokmd
105KB
2.5K
SLoC
tokmd-gate
Policy evaluation engine for tokmd analysis receipts. Enables CI gating based on code metrics.
Usage
use tokmd_gate::{PolicyConfig, evaluate_policy};
use serde_json::Value;
let receipt: Value = serde_json::from_str(receipt_json)?;
let policy = PolicyConfig::from_file("policy.toml")?;
let result = evaluate_policy(&receipt, &policy)?;
if !result.passed {
eprintln!("Policy check failed: {} errors, {} warnings", result.errors, result.warnings);
}
Policy File Format
fail_fast = false
[[rules]]
name = "max_tokens"
pointer = "/derived/totals/tokens"
op = "<="
value = 500000
level = "error"
message = "Codebase exceeds token budget"
[[rules]]
name = "min_doc_density"
pointer = "/derived/doc_density/total/ratio"
op = ">="
value = 0.1
level = "warn"
message = "Documentation below 10%"
Supported Operators
>,>=,<,<=: Numeric comparisons==,!=: Equality checksin: Value is in a listcontains: String/array contains valueexists: JSON pointer exists
License
MIT OR Apache-2.0
Dependencies
~2.4–3.5MB
~85K SLoC