Self-hosting the crate

Embed the open-source floodwall Rust crate in your own control plane, with no account and no service.

Floodwall is an open-source Rust crate, MIT licensed, with no dependencies beyond std. Embed it in your own control plane and you need no account and no service: you run the plane, keep the ledger and wire approvals into your own tools. Floodwall Cloud runs this same crate. The source is at github.com/erphq/floodwall.

Cargo.toml
[dependencies]
floodwall = { git = "https://github.com/erphq/floodwall" }

A plane in a few lines#

rust
use floodwall::{Admission, Floodwall, Gate, Outcome, RateLimit, SchedulerConfig, Verdict};
use floodwall::intent::{Action, AgentId, BlastRadius, Intent, Priority};
use floodwall::policy::{BlastNeedsPriority, NoGlobalDestroy, ResourceAllowlist};

// Hold up to 1024 waiting intents; let each agent burst 8, refill 1/tick.
let admission = Admission::new(1024, RateLimit::new(8.0, 1.0));

// Three policies, combined deny-overrides.
let gate = Gate::new()
    .with(NoGlobalDestroy)                         // never nuke prod without a human
    .with(BlastNeedsPriority)                      // wide-blast changes need real urgency
    .with(ResourceAllowlist::new(["web", "api"])); // off-list resources are deferred

let mut plane = Floodwall::new(admission, gate).with_scheduler(
    SchedulerConfig::default().with_default_limit(2).with_conflict_window(10),
);

let intent = Intent::new(1, AgentId::new("reconciler-7"),
    Action::Scale { resource: "web".into(), replicas: 5 }, Priority::Normal, BlastRadius::Service);
let key = intent.key();
plane.submit(intent, 0).unwrap(); // 0 = logical time

// One scheduling pass: everything that may start now is ruled on and recorded.
let report = plane.tick(0);
assert_eq!(report.decisions[0].verdict, Verdict::Admit);

// Apply the change, then report back. Until you do, it holds its place.
plane.complete(&key, Outcome::Succeeded, 3).unwrap();
assert!(plane.ledger().verify());

Time is a logical tick you supply, so the plane is deterministic and testable: Floodwall Cloud uses one tick a second. Floodwall decides; it never executes. An admitted intent is in flight until you call complete, so report back even when a change fails.

The pieces#

You wantCall
Rules as dataGate::new().with_rules(&text)?: the rules language, with a parse error's line and column
A policy that needs the outside worldImplement Policy: fn name(&self) and fn evaluate(&self, &Intent) -> Verdict
People to decide held intentsplane.held(), plane.release(&key, "alice", now), plane.expire(…)
A lease on work in flightSchedulerConfig::with_lease(Some(Lease::Fail(30)))
AgingSchedulerConfig::with_aging(Some(Aging::new(20, Priority::Normal)))
Signed intents.with_keyring(Keyring::new().with("deployer", key)), and intent.signed(&signing_key)
CheckpointsLedger::new().with_checkpoints(64).with_signer(plane_key)
A ledger on disk that survives restartsLedger::create(path); after a restart, a plane built the same way, then .resume(Ledger::open(path)?, tick)
An export auditors can checkledger.export_jsonl(&mut file), checked by verify-ledger.mjs
Metricsplane.stats().prometheus(), for a /metrics endpoint
New settings without losing historyplane.reconfigure(settings, label, now)

A deferred intent#

rust
plane.submit(intent, 0).unwrap();
plane.tick(0); // "billing" is off the allowlist: deferred and held

for held in plane.held() {
    println!("{}: {}", held.intent.key(), held.reason);
}

// A human signs off. Its deferrals are waived on the next pass.
plane.release(&key, "alice", 5).unwrap();
let report = plane.tick(5);
assert_eq!(report.decisions[0].released_by.as_deref(), Some("alice"));

Keeping the ledger on disk#

Ledger::create(path) starts a ledger in a new file, and Floodwall::resume picks a plane up again from it after a restart or a crash: build the plane the same way, then plane.resume(Ledger::open(&path)?, tick). Every intent that gets in and every decision is written and synced before the call that made it returns, a second writer is locked out, and a crash mid-write costs only the unfinished last line. The replay makes the same calls at the same ticks and checks each writes exactly the record the ledger holds, so the queue, rate limits, what is in flight, conflict claims and holds come back as they were.

Try it#

sh
git clone https://github.com/erphq/floodwall && cd floodwall
cargo run --release                     # the demo: 4000 intents from five agents, through the wall
cargo run --example production          # the production guardrails, at the gate
cargo test

The README has every example above in full (they are compiled as tests), and src/host.rs is the JSON interface Floodwall Cloud drives the crate through, if you want to run it out of process.