Platform engineering · Runtime
Brando: durable actors on a log.
Brando is a durable actor runtime. Each actor's decisions run as atomic, exactly-once rounds over a partitioned log. The log is the truth, it is kept forever in object storage, and replaying it rebuilds anything else.
The problem
Claims, payments and workflows share one shape. A long-lived entity takes inputs, decides what to do, records what happened, calls the outside world, waits days or a year, and must then resume correctly. Most such entities sit idle most of the time.
The usual build spreads one entity's truth across a database row, a queue, a cron table, a cache and a retry library. Every boundary between them is somewhere a crash, a duplicate or a slow node can make the entity wrong: a payment sent twice, a deadline missed, a decision made on stale state. Brando's design question is:
Brando answers it with one execution model and no second path.
The model
Commands and facts Built
Every input is a command and every outcome is a fact, each a record on a Kafka-shaped log. Databases and caches are views of the log, never sources. An actor is a kind plus a route, such as Account("a-17"). The route hashes to a partition, and one process owns each partition at a time, so an actor has exactly one writer and needs no locks.
Pure fold and decide Built
An actor declares fold(state, fact) and decide(state, command, ctx) -> Decision. Neither does I/O. Everything a round does is in its return value: facts to record, commands to send, effects to request, timers to set or cancel, and the answer. Brando commits the whole round atomically or not at all. Time comes in as ctx.now_ms(), never from a clock, so replay is exact on any machine.
Typed state in one memory budget Built
An actor's state is a set of typed slots (#[derive(Item)]). Brando checkpoints them, evicts them under the process's memory budget, and restores an actor by folding its facts since the checkpoint. Idle actors cost storage, not memory.
Fencing by ownership epoch Built
Partition ownership is granted under an epoch. Once epoch N+1 commits a decision, nothing from epoch N becomes visible, and answers are released only after a confirmed commit. A stale owner can neither commit nor write at a live key.
Durable timers Built
Named timers are set, re-set or cancelled by name, one row per name. A timer that fires is an input to the actor like any command, so deadlines and cycles survive crashes and ownership moves.
A stated dedup lifetime, and retirement Built
Every kind declares its retention, typed and with no default. A closed command's record is kept for the kind's senders' window, so a resend inside the window always meets it and is answered as before, while a live actor's records are bounded by its rate, never by every command it ever took. A kind whose actors end can retire them: an actor that has ended with nothing open keeps its rows for the kind's retention, then every row goes in one fenced statement. A retired actor still answers a resend of a command it applied, and refuses anything new with the kind's own refusal.
Indexed slots Built
A kind may declare an index over one slot of its items. The index rows are computed from the item and written by the same fenced save as the item itself, so no listing exists without its item and none is missing. A list across a kind's actors is one bounded range read of the state store: it wakes no actor, asks no owner and writes no record, and it is as of each partition's last save. Slots too large to hold whole can be declared paged and are read a page at a time.
Pipelined rounds Built
A partition's owner can decide its next round while earlier rounds wait to commit, with order kept per key. The member's one transactional producer still commits rounds serially. A simulation world checks, after every step and under crashes, expulsions and lost broker answers, that each actor's facts on the log are a prefix of its commands in the order sent and that every command is applied and answered exactly once.
API sketch
Most of this API exists today. The sketch is the shape it is converging on; the hosting builder at the end is Planned, and today the same pieces are composed through Brando's host modules.
use brando::actor::{Actor, Ctx, Decision, Folding, Items, Then};
use brando_derive::{command, Item};
struct Account;
/// Inputs. #[route] picks the actor; #[key] makes each input idempotent.
#[command(Account, reply = u64)]
enum Asked {
Credit { #[route] account: String, #[key] transfer: String, units: u64 },
Debit { #[route] account: String, #[key] transfer: String, units: u64 },
}
/// The forever log of what happened. A fact names no route:
/// it belongs to the actor that decided it.
#[derive(serde::Serialize, serde::Deserialize)]
struct Moved { by: i64 }
/// Typed state slots: one row per item, checkpointed and evictable.
#[derive(Clone, serde::Serialize, serde::Deserialize, Item)]
enum Held { Balance(i64) }
impl Actor for Account {
const KIND: Kind = Kind::new("account");
type Command = Asked;
type Fact = Moved;
type Item = Held;
type Refusal = String;
fn fold(items: &mut Folding<'_, Held>, fact: &Moved) {
let balance = items.one(Held::BALANCE).copied().unwrap_or(0);
items.set_one(Held::BALANCE, balance + fact.by);
}
fn decide(items: &Items<Held>, asked: &Asked, _: &mut Ctx) -> Decision<Self> {
let balance = items.one(Held::BALANCE).copied().unwrap_or(0);
let by = match asked {
Asked::Credit { units, .. } => *units as i64,
Asked::Debit { units, .. } => -(*units as i64),
};
if balance + by < 0 {
return Decision::refuse("short".into()); // nothing recorded, nothing sent
}
Then::new().fact(Moved { by }).answer((balance + by) as u64)
}
}Three guarantees come from the types rather than conventions:
- A decision must choose its answer.
Thenalone is not aDecision. It becomes one byanswer(reply),open()(a later round closes it) orrefuse(reason), so a decision that chooses no answer does not compile. - Resends are free. The owner answers a command it has already applied from its rows alone, with the original answer. Reusing an identity with a different payload is refused.
- Replay is exact.
foldis pure, so restoring an actor folds the same facts into the same items, a year later, anywhere.
What a round can do
| Call | Meaning | Status |
|---|---|---|
.fact(f) / .facts(..) | Record facts on the actor's forever log. | Built |
.send(cmd) | Send a command to another actor; its answer returns through Replied::answered. | Built |
.effect(e) | Request an external call: granted durably, then made at most once. The result returns through Effected::resulted. | Built |
.timer(name, at_ms) / .cancel(name) | Named durable timers. | Built |
.withdraw(&cmd) / .withdraw_effect(&req) | Take back sent work. Ungranted work is never made; granted work still reports its true outcome. | Built |
.answer(r) / .open() / .close(&cmd, r) | Answer now, leave the command open for a later round, or close an open command. | Built |
ctx.next_id() | A deterministic, replay-stable id for children and correlation. | Built |
ctx.pinned::<T>(digest) | Read an immutable, content-addressed value: a definition, a decision table, a policy version. | Built |
Optional capabilities
| Trait | Hook | Used for |
|---|---|---|
Timed | fired(items, timer, ctx) | Deadlines, cycles, SLAs |
Replied<B> | answered(items, answer, ctx) | Another actor's answer to a sent command |
Effected<E> | resulted(items, result, ctx) | An external call's outcome: done, refused, uncertain, parked or withdrawn |
Withdrawable | withdrawn(..) | Taking back what was sent |
Queried<Q> | read(items, query) -> reply | Owner-consistent reads with no write round |
Indexed | the listings of one slot's items | Ordered, paged lists across a kind's actors, such as a task inbox |
Retires | ended(items) | Retiring actors that have ended, after the kind's retention |
Redecide | each recorded decision made again | Verifying the whole forever log against its pinned definitions |
Effects: calling the world safely
A request to call an outside service is itself recorded. The call is made only after a durable grant, and its runner declares what a repeat would do at the service. Built
#[effect(reply = Receipt)]
struct SendEmail { #[key] notice: String, to: Address, body: Body }
struct Smtp { /* client */ }
#[async_trait::async_trait]
impl Runs<SendEmail> for Smtp {
// A public pin of what is called, never a credential.
fn transport(&self) -> String { "smtp://relay".into() }
fn idempotency(&self, e: &SendEmail) -> Idempotency {
Idempotency::Keyed(e.notice.clone())
}
async fn run(&self, e: &SendEmail) -> Ran<Receipt> { /* call once */ }
}| Idempotency | Meaning | If the outcome is uncertain |
|---|---|---|
Keyed(key) | The service is documented to drop a repeat carrying this key. | The call may be made again under the same key. |
Unkeyed | The call changes the service and carries no key it deduplicates by. | Never made again. The work is parked for an operator. |
Query | The call changes nothing; it is a question. | A repeat duplicates nothing; it is a question unanswered. |
- Granted before it is called. A crash before the call leaves the effect unattempted. A crash after the call leaves it uncertain, which goes to an operator, never silently back to the service.
- Retried only after a proven refusal, and only through the transport pin it started with.
- Parked, not dropped. A call that cannot be made, or an unkeyed call whose outcome is uncertain, goes to the process's park store, where an operator resolves it with a typed discard or resend. A process that hosts effects must have a park store; the type system enforces it.
The durable core
These are Brando's v1 release gates. Each is proven adversarially, in simulation and against real brokers, rather than offered as a feature.
| Gate | What must hold | Status |
|---|---|---|
| Archive and restore | Archive, trim and restart cycles keep every acknowledged fact; replay can start from any archived segment. | Built |
| Ownership fencing | Nothing from a superseded epoch becomes visible; answers wait on a confirmed commit. Proven in simulation and against Redpanda and Apache Kafka. | Built |
| External-effect uncertainty | A crash before, during or after a call gives no silent duplicate and no false success. | Built |
| Long-lived commands | Open commands survive weeks, format changes and takeovers. The dedup lifetime is now stated (each kind's senders' window) and ended actors retire; proof over long horizons is still to come. | In progress |
| Dormant actors | Millions of idle actors within an explicit storage and memory budget, with a cold-wake SLO. Waking one never hydrates its neighbours. The mechanism is built; measurement at 1M and 10M actors is not done. | In progress |
| PII erasure | Destroying a subject's key makes their data unrecoverable everywhere. Sealing exists; enforcing it at the serialization boundary is not yet done. | In progress |
| Back-pressure budgets | When storage is full, everything stays inside its configured budgets. In the lab, a full object store held partitions at their steps on backoff, with no crash and no restart storm. | Built |
| Disaster recovery | Rebuild a cluster from the durable artifacts. The rebuild path is built; RPO and RTO are not yet measured. | In progress |
Determinism is a rule. Every select! in the runtime and its Kafka client is biased, with its order stated. Static analysis in the build enforces that, together with one-way rules (one path per mechanism), a closed list of public types, and the cost ratchets described below.
The forever log
The broker holds the recent, hot tail of the log. Object storage (S3 or MinIO) holds every record, forever, in an open, verifiable format. The two tiers are one log with one offset space: a reader asks for an offset and gets the same bytes from either tier, through the same port. No application code knows which tier answered. Built
producers (actor rounds, API ingress)
│ commit (transactional)
▼
┌─────────────── broker (hot tail) ───────────────┐
│ … 4179 4180 4181 4182 4183 → │ trim ≤ min(archived, folded, floor)
└────────────────────────┬────────────────────────┘
│ archiver (one owner per partition)
▼
object store: archive/<cell>/<topic>/<partition>/<stream>/<gen>-<offset>.seg | .manifest | .sig
▲
│ spliced reader: below the broker's log start → archive; at it → broker
restores, cold actors, replays, auditsproducers: actor rounds, API ingress
│ commit (transactional)
▼
┌─── broker (hot tail) ──────────┐
│ ... 4181 4182 4183 -> │
│ trim <= min(archived, folded, │
│ floor) │
└───────────────┬────────────────┘
│ archiver
│ (one owner per partition)
▼
object store:
archive/<cell>/<topic>/
<partition>/<stream>/
<gen>-<offset>
.seg | .manifest | .sig
▲
│ spliced reader:
│ below the broker's log
│ start → archive;
│ at it → broker
restores, cold actors, replays, auditsWriting: the archiver
- One archiver owns each partition of each archived topic. It is ordinary Brando partition work: owned, fenced and restarted like any other.
- A segment is a sequence of independent zstd frames, each holding whole records.
zstd -dreads the whole object; a reader can fetch one frame by byte range. - A sealed segment is three objects: the segment, its manifest and the manifest's signature. Each is written only where nothing exists yet (
If-None-Match). No object is ever overwritten. - Each manifest names its frames, their digests, its offsets, and its predecessor's digest. The manifests form a hash chain, so a missing or substituted segment is detected, never read as empty.
- Signatures are made in their own domain, so any segment can be verified offline with only its three objects and the published keys. An audit verifies a whole archive this way.
- Nothing in a segment is a wall-clock time, so an archive is byte-reproducible from the log.
- A crash between writing an object and committing it is safe: the next owner finds the segment, checks every record against the log, and adopts it. Content that differs from the log is reported as a corrupt archive and never overwritten.
Nothing un-archived is ever trimmed
The broker never trims past min(archived, folded, floor). If the object store is full or down, the broker keeps everything. So that the broker's own disk cannot fill next, a partition whose log stands too far above the archive's cursor admits nothing more: actor rounds hold before they begin, and API ingress is refused with a retryable outage. The signal comes from the broker's answers to the process's own commits, so it costs nothing while the archive keeps up.
Cold actors at constant cost
When an owner evicts actors that have gone cold, it writes one locator object per kind, partition and cold period, listing for each cold actor the archive frames that hold its records. Waking a cold actor is one locator read plus one ranged read per frame, whatever the actor's age: a year-old actor costs the same to wake as a day-old one. Built (scale measurement In progress)
Re-deciding the whole log Built
Replay promises that the same inputs and the same pinned definition give the same decision. A verifier checks that promise over everything the log ever held, not just the broker's window: for a kind that opts in, it reads from the first archived record through the broker's tail, makes every recorded decision again from its inputs under the definition it was pinned to, and reports any decision that differs, any record it could not fold and any pin whose definition it could not read. A run is split into bounded, resumable units. Pledge's claims implement it.
The archive as the disaster-recovery source
If a broker cluster is lost, a new, empty cluster starts. Recovery appends a new lineage (generation) at the archived cursor and fences the old generation first, so a stale archiver from the lost cluster can only ever write under its own generation's keys. The spliced reader maps the single engine offset space onto the new cluster, so readers above it see one continuous log. RPO is the archive's lag: at most the segment lag bound plus one segment's fill time. Built (RPO / RTO measurement In progress)
Deterministic simulation and exact cost
A summary of how Brando is tested follows; the testing page covers the whole stack, including the endurance world, synthetic data and the lab soak.
Fault worlds Built
A deterministic simulator runs actors over an in-memory log and store, from a seed. Faults are typed per port and injected at every boundary where they can occur: crashes at every commit, rebalances, timer storms, throttled and full object stores, broker failures. Each world asserts its invariants. A failing seed is shrunk and kept as a regression. Every bug gets a failing simulation before its fix, and a defect found outside the simulation counts as a simulation gap first.
The same contracts run against real Redpanda and Apache Kafka through per-port conformance suites, which also bound the simulator: a fault is modelled only where the real adapter can actually produce it.
Exact cost ledgers Built
Every simulated scenario asserts its exact cost: statements, rows, produce requests, fetches, records and bytes, per round. There is no bound form, no <= and no tolerance: measured equals expected. The tables are checked in, and a ratchet refuses any increase without explicit approval. A change that does more work fails the build, not a dashboard a week later.
Lab results
Layers and backends
| Layer | What it holds |
|---|---|
| Products | Pledge (claims, the first product) and other applications |
| Platform | Niro: BPMN processes, CMMN cases and DMN decision tables. Castel: HTTP edge, ingest, signed links, calendars and a UI framework |
| Runtime | Brando: actors, effects, timers, correlation, indexes, ownership and the archive |
| Storage | The log port: Kafka-protocol brokers today, and an in-memory twin for simulation; the state store; the object store, which holds the forever log; crypto; the clock |
- Brando never names an application. An architecture rule refuses it.
- Niro is a process engine on Brando (its own page). Castel holds the capabilities applications share: an HTTP edge, ingest, signed links, calendars and a UI framework. Pledge, the claims product, is the first product on the stack.
- Each port has a conformance suite, run against every adapter and its in-memory twin, so simulation and production run the same contract.
| Log backend | Shape | Status |
|---|---|---|
| Kafka-protocol brokers | Transactional producers, cooperative-sticky consumer groups, group-less readers. State in Postgres. Workers hold no data, so they scale and are replaced freely. Redpanda and Apache Kafka are both tested through the conformance suites. This is the production backend. | Built |
| In-memory twin | The simulator's log and store; the specification every other backend is tested against. | Built |
What remains for v1
- Planned Broadcast subscriptions (one record per partition fanned out to subscribers), for signals.
- In progress Enforcing sealed values at the serialization boundary.
- In progress Measuring dormant actors at 1M and 10M with a cold-wake SLO, and disaster-recovery RPO and RTO.
- In progress Retention so every product store settles during an indefinite run, and one retry path for dependency outages.
- Planned The
Processhosting builder:
let process = brando::Process::new(log, store, budget) // the log, the state store, the memory budget
.actor::<Account>() // routes, owns, folds, checkpoints
.effects::<SendEmail, _>(Smtp::new(..)) // SendEmail made by Smtp
.parking_in(parked_store) // required by type once effects are hosted
.run(shutdown).await?;