First principles
Chapter 2 of 11
The six pillars
Six design rules shape every part of Napalm and compile one schema file into a verified backend.
Most databases let you drop a column while live queries still read it. Adding separate object storage, job queues and read replicas splits permissions and transactions across half a dozen systems.
Try it
Remove body from Note in your starter app and push the schema. Napalm refuses the migration before anything changes.
One typed graph#
Rows, binary files (ext::files::File), search indexes (ext::ai::index), background jobs, agent grants and tenant roots all live as typed entities and links in one schema.
type Note { required owner: ext::auth::Identity; required title: str; required body: str; deferred index ext::ai::index(embedding_model := 'openai/text-embedding-3-small') on (.title ++ '\n\n' ++ .body); index fts::index on (( fts::with_options(.title, language := fts::Language.eng, weight_category := fts::Weight.A), fts::with_options(.body, language := fts::Language.eng, weight_category := fts::Weight.B) )); } type Attachment extending ext::files::File { required owner: ext::auth::Identity; access policy owner_has_full_access allow all using (.owner ?= global caller);}Files, search indexes, background jobs and grants obey the same access rules and transaction snapshots as your rows without separate sync workers.
Caller-bound#
Every stored type starts closed. Napalm binds verified caller identity (global caller or service globals) inside PostgreSQL, and access rules walk links in the same EdgeQL language as queries.
global caller := global ext::auth::ClientTokenIdentity; type Note { access policy owner_has_full_access allow all using (.owner ?= global caller);}One typed schema
Rows, files, indexes, jobs and grants share one graph in dbschema/default.gel.
Closed by default
Every stored type stays locked until an access policy opens a path from caller identity.
Those rules govern reads, writes, signed file URLs, vector search, actions, background jobs and MCP tools while planning in a fraction of the memory of nested SQL policies. Expiring rules check datetime_of_statement() without a cleanup job, and org tokens (napalm_…) manage clusters without reading customer field values.
Compiled#
Your schema and .edgeql files carry static types and cardinalities, so Napalm checks every query against the schema and access policies before anything runs.
napalm generate notes --lang tsnapalm schema push rejects breaking migrations before applying changes, compiles each read and every touched policy into one SQL statement and type-checks generated /ask queries before execution.
Commit-atomic#
Every write commits or rolls back as one atomic unit across rows, queued jobs, webhooks and live subscriptions. A rolled-back write sends no webhooks, queues no jobs and changes nothing on live screens. Dry-run proposals return exact before-and-after rows and roll back.
with note := (insert Note { owner := global caller, title := <str>$title, body := <str>$body }), job := (insert ext::napalm::Job { query := 'sendReminder', variables := <json>(note := <str>note.id) }),select note { id }After commit, Napalm-Bookmark and Napalm-Position carry the commit position across reads and workers. Live queries on one screen advance at the same commit, replicas never serve state older than a caller’s writes, webhook workers read up-to-date rows and backups retain deleted files across your restore window.
Distributed from links#
Traditional sharding adds a tenant_id column to every table and every query. In Napalm, your schema declares ordinary required links while cluster topology scales underneath.
napalm clusters scale <cluster> --engines 2 --replicas 1Topology scales beneath unchanged links
Required links co-locate each tenant’s graph so Napalm splits busy roots across shards behind one unchanging endpoint.
Required links place and move customer graphs across shards, bookmarks route reads to caught-up replicas and search indexes grow past 100 million vectors without changing a query.
Checked and fault-tested#
Napalm verifies access and durability mechanically before and after deploy. Schema pushes reject broken queries and unplaceable links before touching data.
napalm schema push notes --reviewnapalm explain-access notes <note-id> --as ben@example.comValue-blind rule traces
explain-access and people reach audit policies without exposing customer field values.
Automated fault campaigns
Every release faces bounded faults in the public chaos lab before rollout.
In production, explain-access, people reach, insights and dry-run /ask inspect permissions and query plans without changing main or exposing field values. Every release also runs automated fault campaigns in the public chaos lab. Incomplete evidence is marked Inconclusive, never Passed.
Every person, service, operator and agent enters your system through a distinct boundary.