barycenters 1.0.0

Govern any agent, and see what /admit would have blocked. Shadow mode by default. Zero dependencies (transport injected).
Documentation
  • Coverage
  • 26.83%
    11 out of 41 items documented0 out of 15 items with examples
  • Size
  • Source code size: 18.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 482.6 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • damilolaphillips

barycenters (Rust)

Govern any agent, and see what /admit would have blocked. Ships in shadow mode. Zero dependencies — the HTTP transport is injected via the Transport trait, so you wire your own client (reqwest, ureq, std) and the crate pulls in nothing.

use barycenters::{Client, Config, Mode};

let mut c = Client::new(
    Config { endpoint: Some("https://…".into()), namespace: "acme/eng".into(), ..Default::default() },
    my_transport, // impl Transport
); // shadow by default

let d = c.admit("deploy_prod", "{\"env\":\"production\"}")?;
// shadow: admit never returns a refusal error; d.would_block tells you what enforce would do.

println!("{}", c.shadow_report().summary);
// → "2 of 17 action(s) would have been blocked by /admit"

Implement Transport once with the HTTP client of your choice:

struct MyTransport; // e.g. wrapping ureq or reqwest::blocking
impl barycenters::Transport for MyTransport {
    fn post(&self, url: &str, body: &str, idempotency_key: &str) -> Result<barycenters::Resp, ()> {
        // POST body to url with header `idempotency-key: {idempotency_key}` and content-type json;
        // return Resp { status, body } or Err(()) on transport failure.
        todo!()
    }
}

When you're ready: enforce

Flipping to Mode::Enforce is a deliberate human decision (authority_effect 0 → 1). A refusal returns AdmitError::Refused; an unreachable endpoint fails closed. Retries (default 3, transport failures only) carry one idempotency key → the service admits at-most-once; a decision is terminal and never retried.

Honest by default

No endpoint wired → the decision is AWAITING; it never fabricates a pass or a block it cannot prove. Authority enters at exactly one point, and it is a human's — this crate only asks.