Cause and effect · for builders

Karma.

Cause and effect, and the database that keeps it. Every action and its consequence is a signed fact. Karma’s engine turns that history into live views of every shape, ready to query. Dharma decides what may happen; Karma remembers what did.

01 · Projection first

You read projections, not history.

Most databases compute an answer when you ask. Karma keeps the answers ready. A contract declares up front the views it needs, and Karma maintains each one continuously as new facts arrive, instead of computing it on demand. A query reads a view that is already up to date, however long the history grows.

facts→projections→compiled pipelines→queries
Facts, as they are certified
  1. v1RequestMira, for HermesLumon Industries · Moon · 120 units · 2 crates
  2. v2CheckCrateBendercrate 1 of 2
  3. v3CheckCrateBendercrate 2 of 2
  4. v4PayHermespaid
  5. v5ConfirmLeelanot the one who asked
  6. v6ShipFryto the Moon
Projections, kept current
Delivery · tablegeneration 4,812
customerdestinationunitsstatus
Lumon IndustriesMoon120Shipped
Los Pollos HermanosAlbuquerque40Requested
Duff BrewerySpringfield200Confirmed
By status · totals

1 requested · 1 confirmed · 1 shipped

Search · text index

“moon” → Lumon Industries

A read pins generation 4,812 and sees it whole while new facts keep arriving.| where status == Requested→ Los Pollos Hermanos · 2 ms
Declared in the contract today

Queries and projections are written next to the rules, so what can be read is known, checked and indexed before the first record exists.

A read sees one moment in the engine

A query pins one generation of the projections and reads it whole, while new facts keep arriving. It never sees half of a change.

Rules read them too today

An action can check what a projection says before it is accepted: “no other rule like this one exists yet”, “this delegation is still active”.

History stays the truth today

A projection is only ever derived. Any of them can be rebuilt from the facts, and a new one can be added later over everything already recorded.

std.commerce.published_publicationsexcerpt
projection PublishedPublications    trigger action.*    source state    batch_window 0ms    query        std.commerce.storefront_publication        | where published == true        | select subject, seq, property, market, channel, product_subject, category_subject, slug, subtitle, description, image_path, featured, sort_order    emit upsert published_publications

Real: a projection declared in a contract. Every action on a storefront publication updates the published list, with no delay.

com.cmdv.btd.import_cutoffexcerpt
external    datasets: [existing: List<SubjectRef<ImportCutoffRule>> from Existing] action Define(editor: Identity, supplier_id: Identity, scope: Text(len=20), scope_id: Identity, specificity: Int, days_before_handoff: Int, origin_timezone: Text(len=50), cutoff_minute: Int?)    validate        dataset.existing.len == 0

Real: an action that validates against a dataset. A second rule for the same supplier and scope is refused before it is written.

02 · Multimodal

Every shape of data, in one place.

Tables, text, vectors, graphs, places and time series usually live in five different systems, copied from one to the next and always slightly out of step. Karma’s engine holds them together, fed by the same signed facts and under the same rules. There is no second store to keep in sync: one engine instead of a message queue, a cache, a vector database, a graph database and an analytics warehouse glued together.

Tables

Filters, sorting, joins across records.

in contracts today
Analytics

Scans, grouped totals, joins, star paths.

in contracts today
Full text

Ranked search (BM25), hybrid ranking.

in contracts today
Expressions

Computed fields, scores, finance functions, rolling totals.

computed fields today
Vectors

Exact and approximate nearest neighbours (HNSW, quantized, filtered).

in the engine
Graph

Traversal, shortest path, components, PageRank.

in the engine
Geo

Grid cells (H3), near, coverings, areas.

in the engine
Time series

Latest value, as-of, horizon and window joins.

in the engine
One question, four kinds of data in the worksPlanet Express

“Delivery partners within 50 km of the Moon base, whose notes read like ‘handles fragile cargo’, with an on-time rate above 95% this quarter.”

  • Tablespartners, their notes, their deliveriestoday
  • Geonear the Moon baseengine
  • Text and vectorsby words today; by meaning in the enginepartly
  • Totals over timeon-time rate per partner, this quartertoday
The same question in Karma’s pipe language engine
deliveries| where partner_kind = `courier and ts between $quarter_start $quarter_end| geo within dropoff radius $r from $moon_base| vsearch notes_embedding near $fragile_cargo top 100| group by partner sum on_time

$r = 50 km · $fragile_cargo = “handles fragile cargo”. Shape from Karma’s own pipe-language example; not yet written from a contract.

Mira’s answer
Moon Base Movers12 km · 98% on time · “fragile cargo is our specialty”
Kif’s Lunar Freight41 km · 96% on time · “careful with anything that breaks”
Karma’s engine, measured
~2.6Mdurable rows per second, ingested
~1.0Mprepared queries per second, while ingesting
2.3 µsquery p50 · 15.1 µs p99
~9 msfrom a new fact to a queryable answer
~2Mmixed multimodal queries per second · p99 ~14 µs
3–4.5Mfull-text (BM25) queries per second

Measured on a single Apple Silicon machine, on prepared queries over maintained projections; Linux numbers are coming, and durable ingest there may be lower. Cold, ad-hoc analytics are slower by design, and high-recall vector search is the engine’s weakest area today. These are the engine’s numbers, not what Mandala does end to end today.

Where this stands: every mode above exists in Karma’s engine and is measured there. From your contracts today, queries reach tables, joins, grouping and totals, computed fields and text search. Making the whole engine the one behind your contracts, so a contract can declare vector, text, place, graph and time indexes and query them together, is being designed now.

03 · Signed facts

The unit is a signed fact, not a row.

Nothing in Karma is updated in place. Each action is a new fact: who acted, for whom, when, under which rule, with which details, linked to the fact before it on the same record. Your current state is what those facts add up to.

“Why is it like this?” always has an answer

Open any record and read the facts that made it, in order, each with its signature.

Acting for someone is visible

The accomplice acts by your delegation, never as you. Its own signature says so.

A history that can’t be quietly rewritten

Each fact names the one before it. Changing the past would break every link after it, and anyone you share a part with can check it.

09:04 · 14 OctAI✓ verified
Mira asked to pay Tyrell Corporation $7,240 for invoice #2041.
signed by Mira, on behalf of Hermes, for Planet Express
under rule · Second approver for large payments
whoMira, the accomplice
on behalf ofHermes
forPlanet Express
when14 Oct, 09:04
under ruleSecond approver
sealMira’s own seal
A receipt, as the journal keeps itone line per fact
{  "at_ms": 1791983040000,  "tenant": "planet-express",  "namespace": "com.planetexpress.delivery",  "subject": "delivery-lumon-0412",  "id": "9f3c2a71…e81d",  "version": 1,  "assertion": "b41e07d9…3a6c",  "actor": "mira",  "action": "Request",  "args": { "customer": "Lumon Industries", "destination": "Moon", "units": 120, "crates": 2, "credit_terms": false }}

The real shape, with the cast’s values. actor is whose signature it carries, here Mira’s own; assertion is the signed fact it receipts; version counts the record’s facts.

04 · Agreement

Agreed, at the strength you choose.

A fact counts once it is certified: the machines that hold your Karma agree on it, in order, using Raft, and it is written to disk. Each contract says how strong that has to be. A payment waits for the disk. A chat message can be acknowledged at once and written a moment later.

mandala.alma.messagefront matter
---namespace: mandala.alma.messageversion: 1.0.0durability: buffered(100ms)---

Real: the accomplice’s messages are acknowledged at once and on disk within 100 ms. Its approvals stay confirmed.

ClassAnswered whenA crash can loseFor
confirmedthe defaulton disknothingpayments, stock, orders, approvals, identity
groupedon disk, sharing one write with neighbours (up to 2 ms)nothingmost business records
buffered(100ms)at once; on disk within the windowat most the last windowdrafts, likes, presence, chat traces

The compiler refuses buffered for anything about money, stock, identity, approvals or outward effects. A stronger write always carries every weaker one before it to disk, so a payment never survives without what it read.

05 · Local first

Your devices, apart and back together.

Your Mandala runs on each of your devices. Each one keeps working offline and records what you do as signed intents, stamped with a clock that orders them across devices. When they meet again, each sends what the other lacks, and both apply everything in the same order.

Hermes’s phoneboth offline · 09:58 to 10:20Hermes’s desk
AddItem Bubble wrap, 3 rolls10:01 · seq 211
commutes
AddItem Slurm, 2 cases10:04 · seq 318
Pay Tyrell invoice #204110:02 · seq 212
exclusive
Pay Tyrell invoice #204110:05 · seq 319
Back online: each sends what the other lacks, and both apply it in clock order.
Office supplies

Bubble wrap, 3 rolls · Slurm, 2 cases

both kept, on both devices
Invoice #2041, paid twice?

Each device paid while apart, where no rule could see the other. Each refuses the other’s payment and keeps it as a conflict record. Hermes settles it under “Didn’t merge”.

refconflict-7c1e4b90a3d25f68-319
namespacestd.business.payable
actionPay
recordpayable-tyrell-2041
device · seq7c1e4b90… · 319
arguments{"payment_reference": "PE-5521"}
reasonrefused: state.status == "approved"
resolvedfalse

The contract says how each action merges.

commutes

Order doesn’t matter: adding an item, recording a payment. Both sides are kept.

last_writer

The later change wins; the earlier one is noted as superseded.

exclusive, the default

Applied only if the rules still allow it. Otherwise it becomes a conflict record for you to settle. Nothing is lost silently.

Devices are enrolled under your identity, and only enrolled devices are trusted. They find each other directly, on your network or across the internet, without a service in the middle.

std.personal.shopping_itemfront matter
---namespace: std.personal.shopping_itemversion: 1.0.0merge: AddItem=commutes, Check=last_writer, Remove=last_writer---
std.business.payablefront matter
---namespace: std.business.payableversion: 1.1.0merge: Receive=commutes, Review=last_writer, Approve=exclusive, Pay=exclusive, Reject=exclusive---

Real: two devices can each add groceries on their own. Paying an invoice can’t merge by itself, so the other device’s payment becomes a std.sync.conflict record instead of disappearing.

06 · Between businesses

Two businesses, one record.

Two Mandalas talk directly. Orders, invoices and receipts travel between them as signed documents. Each side checks what arrives against its own Dharma before accepting it, and both keep the same record of what was sent and what was decided.

MDMassive DynamicNina’s Mandala · New Yorksent order MD-0451
Invoice #204914 Oct
From Tyrell Corporation to Massive Dynamic
Owl, artificial, 1
$48,000
Delivery by Planet Express
$1,250
Sales tax
$3,940
Total
$53,190
signed by Tyrell Corporationreceived by Massive Dynamic
TCTyrell CorporationDr. Tyrell’s Mandala · Los Angelessent invoice #2049
A bad signature never gets in

A document is checked against its sender’s signature before anything is recorded. A forged one is refused.

Routed or reviewed

From someone you recognize, for a kind of document you trust them with, it goes straight into the work. Anything else waits for a person to look.

Trust stays yours

Whom you recognize, and for what, is decided by your own records only. An introduction from a partner lets you recognize someone new, trusted with nothing until you say so.

Who acted for them

Each document records who acted for the sender. Proving that with a grant you can check yourself is next.

Massive Dynamic · std.exchange.documentreceived
directionin
counterpart_nameTyrell Corporation
counterpart_key5be1d07a…c4f2
acted_byRachael, for Tyrell Corporation
kindinvoice
titleInvoice #2049
digeste3a9f412…07bd
statusrouted → accepted

Tyrell is a recognized supplier trusted with invoices, so #2049 went straight to Nina’s payables. The whole document is kept by its digest; Tyrell’s Mandala keeps the same document as sent.

07 · Guarantees

All or nothing. Once. Back fast.

runningAll or nothing

A step that writes several records, even under different contracts, goes as one batch under a single decision: all of it or none. In the server engine, records certified by different groups work the same way: each group prepares its part, then one decision commits them all.

runningRetry without fear

A write sent twice is done once. The retry gets the original receipt back, so a flaky network never pays an invoice twice.

in the worksCheckpoints for fast restarts

Karma’s engine saves projections as checkpoints and, on restart, applies only the facts certified since. That works for new deployments of the server engine. Bringing it to homes that already have a history is being built; until then, a restart rebuilds projections from the history.

08 · Status

What runs today, and what’s next.

running

Signed facts and receipts for every business write; atomic batches and retries that return the original receipt; projections and contract queries; durability classes; merge rules, intents and conflict records between your devices; device enrollment; signed documents, relationships and introductions between identities; contract upgrades with migrations.

in the server engine

Atomic writes across certification groups; strong reads across them; durable refusals; checkpoints with recovery from the facts certified since.

in Karma’s engine

Projections with generations and pinned reads; analytics, full-text, vector, graph, geo and time-series indexes; the hybrid query across them.

in the works

The full engine behind your contracts: indexes of every shape declared in a contract and queried together; pinned reads; checkpoints for existing homes; proof of who acted for a sender; public discovery of businesses; records from before a device joined; the accomplice’s own conversations in device sync.

Dharma says what may happen. Karma remembers what did, and why.

Does my data go to a shared network?

No. Each Mandala keeps its own Karma on your own machines. Only what you send someone travels, as a signed document.

Can I correct a mistake?

Yes, with a new action, such as voiding a transaction. The mistake and the correction both stay in the history, which is the point.

What if two of my devices disagree?

The contract decides: some changes merge on their own, the latest wins for others, and the rest become a conflict you settle. You see it under “Didn’t merge”.

Can I take my history with me?

Yes. Rules and Karma are yours and export in a readable form, signatures included.