Expand description
§agentcontract
Rust implementation of the AgentContract specification.
Behavioral contracts for AI agents — declare what an agent must, must not, and can do, enforced on every run.
§Quick Start
use agentcontract::{load_contract, ContractRunner, RunContext};
let contract = load_contract("my-agent.contract.yaml").unwrap();
let runner = ContractRunner::new(contract);
let ctx = RunContext {
input: "What are the GxP requirements?".into(),
output: "Per 21 CFR Part 211...".into(),
duration_ms: 1200.0,
..Default::default()
};
let result = runner.run(&ctx);
if !result.passed {
for v in result.blocking_violations() {
eprintln!("[{}] {}: {}", v.action_taken, v.clause_name, v.details);
}
}Re-exports§
pub use audit::AuditWriter;pub use errors::ContractError;pub use errors::ContractViolation;pub use loader::load_contract;pub use models::Contract;pub use runner::ContractRunner;pub use runner::RunResult;pub use runner::ViolationRecord;pub use validators::RunContext;
Modules§
- audit
- Append-only JSONL audit writer with SHA-256 entry hashing.
- errors
- Error types for agentcontract-rs.
- loader
- Contract loader — reads and parses YAML or JSON contract files.
- models
- Serde models for the AgentContract specification.
- runner
- ContractRunner — evaluates a Contract against a RunContext.
- validators
- Validator modules — pattern, latency, cost.