bounda.config.ts exports defineConfig({...}) from @bounda-dev/core/config. boot() reads it,
and createApp takes the same object; createTestApp does not read it. The configuration is
checked when the app is created: an unknown key, a value of the wrong type or a duration it cannot
read throws a ConfigurationError that lists every problem with its path.
import { defineConfig } from "@bounda-dev/core/config";import { postgresql } from "@bounda-dev/postgresql";
export default defineConfig({ storage: postgresql({ url: process.env.DATABASE_URL! }), ports: { order: { notifier: "smtp" } }, runtime: { role: "worker", policies: { timeout: "1m" } },});A project that serves several tenants, each its own database, exports a function of the tenant
instead: defineConfig(({ tenant }) => ({ storage: postgresql({ url, schema: tenant }) })).
boot(), the CLI and the React Router host call it with the tenant they serve, BOUNDA_TENANT or
--tenant naming it, default without either; configForTenant({ config, tenant }) does the same
for code of your own. See tenants. Such a project may also
export tenants, a list of the tenants it serves or a function that resolves to one, which
commands that go through every tenant reach beside those its stores list, as
bounda forget-ledger prune --all-tenants
bounda tenant-key rewrap-master,
status and remove-stale do, and
so does forgetTenant in an app boot() creates, which removes the copies of the tenant’s key
those stores hold; loadProject hands it as tenants(), and boot({ config, tenants }) takes it
with a configuration given directly.
Durations are a number of milliseconds or a string: a number followed by ms, s, m, h
or d ("250ms", "1.5s", "7d"). A duration read from the environment is a string, which the
types refuse; wrap it with asDuration(process.env.X ?? "1m"), which checks it.
Top level
Section titled “Top level”storage, required. The adapter that holds the store:sqlite({...}),postgresql({...})orcloudflare(), whosebindingnames the Durable Object binding the Worker reaches it through,"STORE"by default. See adapters.readModels, default{}. A different adapter for some read models, by read model name:{ orderSummary: postgresql({ url: READ_URL }) }. The rest stay instorage. Under astoragethat declares a location, each must declare one under the same legal regime, or another with a safeguard.ports, default{}. The implementation each port uses, by module and port:{ order: { notifier: "smtp" } }. A port with one implementation may be left out; one with several must be named. The names are typed from the project. See ports.runtime. How the app runs.
Data location
Section titled “Data location”Every adapter takes location, none by default: where its database keeps the data, such as
"eu". cloudflare() takes its
jurisdiction instead, and defineTenantKeyStore and
defineForgetLedger take a location as their second argument, and so does defineKeyWrapper;
masterKey takes it beside from.
const location = "eu";
export default defineConfig({ storage: postgresql({ url: process.env.DATABASE_URL!, location }), readModels: { search: sqlite({ url: process.env.SEARCH_URL!, location }) }, runtime: { personalData: { keyWrapper: masterKey({ from: "BOUNDA_MASTER_KEY", location }), tenantKeys: postgresql({ url: process.env.TENANT_KEYS_URL!, location }), }, },});- A location is a country by its ISO 3166-1 alpha-2 code in lower case, such as
"de","ch"or"us", or an area:"eu"(the European Union),"eea"(the European Economic Area),"fedramp"and"fedramp-high"(the Durable Object jurisdictions of FedRAMP data centres in the United States), and"global"(anywhere in the world, as Workers KV keeps what it holds). The type isDataLocation. The app refuses to start on any other value,"DE","EU"and"uk"included, rather than guess where it is: a wrong guess would hide a transfer. - Locations are compared by the legal regime each is under for chapter V of the GDPR, which
regimeOfanswers: the European Economic Area for"eu","eea"and the country of every member state, including the parts ISO codes apart where the GDPR applies, the Åland Islands ("ax") and the outermost regions of France ("gf","gp","mf","mq","re","yt"); the United States for"us","fedramp"and"fedramp-high"; each other country its own; and none for"global". Keeping data in"de"under astoragein"eu", or in"fedramp"under one in"us", is no transfer; in"ch"under one in"eu"it is. - The location
storagedeclares is the app’s. The app refuses to start, withConfigurationError, andbounda personal-data inventoryto draw the record, on a read model inreadModels,personalData.keyWrapper,personalData.tenantKeysorpersonalData.forgetLedger.storethat declares none, or one under another regime without a safeguard: each carries the persons’ data, or the key that opens it, wherever it is kept, and encryption protects data from a transfer only while its keys stay behind. Astoragein"global"is refused too: it places the app’s data in no jurisdiction to judge the rest against. - A
storagethat declares none holds nothing else to one, and each store says its own. - The record of processing states each one’s location next to everything kept there, the master
key’s included, and lists every store of personal data, and the key wrapper, that declares none
as a finding, which makes the command exit
1. - Bounda cannot see where a server, a file or a process is, so a location is taken at its word; on
Cloudflare an object
checks its own jurisdiction, but not where a Worker’s secrets are kept. A local file,
memory()andmasterKeydeclare where the host runs, and the app’s processes run where its storage is. create-boundawrites"eu". See transfers out of the EEA.
Stores in another jurisdiction
Section titled “Stores in another jurisdiction”A store may be kept under another legal regime than storage’s when a safeguard of chapter V of the
GDPR allows the transfer: every adapter, masterKey, defineKeyWrapper, defineTenantKeyStore and
defineForgetLedger take safeguard beside location, one of "adequacy" (article 45),
"standard-contractual-clauses" (46(2)(c)), "binding-corporate-rules" (47), "code-of-conduct"
(46(2)(e)) or "certification" (46(2)(f)), as recipients
declare theirs. Here the keys are held in Switzerland, under its adequacy decision, and the data in
the EU:
export default defineConfig({ storage: postgresql({ url: process.env.DATABASE_URL!, location: "eu" }), runtime: { personalData: { keyWrapper: masterKey({ from: "BOUNDA_MASTER_KEY", location: "ch", safeguard: "adequacy" }), tenantKeys: postgresql({ url: process.env.TENANT_KEYS_URL!, location: "ch", safeguard: "adequacy", }), }, },});- The types take a
safeguardonly beside alocation, and"adequacy"only beside a location an adequacy decision covers (AdequateLocation), with itsadequacyScopewhere that decision covers some providers alone (PartiallyAdequateLocation). The app refuses to start, withConfigurationError, on a store kept under another regime without a safeguard, on a safeguard understorage’s regime, which is no transfer, on a safeguard onstorageitself or under astoragethat declares no location, which leaves nothing to tell a transfer by, and on aderogation: article 49 allows one for occasional transfers alone, never for data kept somewhere as long as the app runs. "adequacy"is taken for a country ofADEQUATE_COUNTRIES, those the European Commission has adopted an adequacy decision for (Andorra, Argentina, Brazil, Canada, the Faroe Islands, Guernsey, Israel, the Isle of Man, Japan, Jersey, New Zealand, the Republic of Korea, Switzerland, the United Kingdom, the United States and Uruguay, as of November 2026), and for the European Economic Area under astorageoutside it; never for"global". The decisions for Canada and the United States cover some recipients alone, as partial adequacy decisions says.- Bounda checks that list against
the Commission’s own
every week, and a new decision, a review that changes what one covers or a revocation reaches
ADEQUATE_COUNTRIESin the next release. Until you upgrade, a newly covered country takes another safeguard. A revoked one leaves the list in that release, and an app that declaresadequacyfor it, on a store or a recipient, no longer type-checks nor starts until it declares another. - Bounda also checks every week, on EUR-Lex, that each decision of the list is still in force: a decision repealed, annulled or expired, even before the Commission’s page says so, and an act in force that reads as a decision Bounda does not know (a new one, a renewal, an amendment) fail the check, and a decision whose validity ends within six months warns of it.
- The record of processing names each transfer, the legal regime it goes to, its safeguard and its
article, next to everything kept there, as article 30(1)(e) asks, and each person’s
export lists it in
transfers, as article 15(2) asks, each with itslocation,safeguard,article,regimeandpartialAdequacy, the regimeregimeOfnames: a store in"fedramp"is under"US". - The safeguard itself, the clauses signed and the transfer impact assessment are yours: Bounda
states what you declare. On Cloudflare, the keeper takes a
jurisdictionof its own.
Partial adequacy decisions
Section titled “Partial adequacy decisions”Two decisions of ADEQUATE_COUNTRIES cover some recipients in their country alone, and
PARTIAL_ADEQUACY carries each as data: the decision, its celex number on EUR-Lex, whom it
covers, the condition the recipient, or the provider that keeps a store, must meet, and the
scope that names it.
| Country | Decision | Covers | adequacyScope |
|---|---|---|---|
Canada ("ca") |
Commission Decision 2002/2/EC | recipients subject to PIPEDA, as private-sector organisations are for what they handle in commercial activities | "pipeda" |
United States ("us", "fedramp", "fedramp-high") |
Commission Implementing Decision (EU) 2023/1795 | organisations on the Data Privacy Framework List, with an active certification that covers the data, human resources data or other | "data-privacy-framework" |
A store kept there, or a recipient there, rests on "adequacy"
only beside the decision’s adequacyScope, which says you verified the condition:
export default defineConfig({ storage: postgresql({ url: process.env.DATABASE_URL!, location: "eu" }), readModels: { search: postgresql({ url: process.env.SEARCH_URL!, location: "us", safeguard: "adequacy", adequacyScope: "data-privacy-framework", }), },});- Article 45(1) lets a decision cover “one or more specified sectors” of a country, and these two
cover recipients, not the country: the Data Privacy Framework decision covers transfers to
organisations on its list alone, and the Canadian one recipients subject to PIPEDA alone. Outside
that scope there is no adequacy decision for the transfer, which article 44 then allows only on
an appropriate safeguard of article 46, such as standard contractual clauses, with the transfer
impact assessment they come with.
adequacyalone in these countries asserts a fact about the provider that Bounda cannot see, so the types and the app ask you to state it, under articles 5(2) and 24, rather than read it into a country name. - The types take
adequacyScopeonly beside"adequacy"in one of these locations, and only that location’s scope. The app refuses to start, with aConfigurationErrorthat names the decision and its condition, on"adequacy"there without it or with another country’s, and on anadequacyScopeanywhere else. - Bounda does not look the provider up: being on the list, and staying on it (a Data Privacy
Framework certification is renewed every year), is yours to verify while the transfer lasts.
The record of processing names, next to the transfer, the decision and what to verify, so a
review of the record asks it again; each person’s export and a tenant’s export give
partialAdequacy, the decision ofPARTIAL_ADEQUACY, on every such transfer, andnullon any other. - The Commission’s list writes these scopes after the two names, and the weekly check fails when they change, as when a decision becomes one for the whole country.
runtime
Section titled “runtime”role, default"all". Whatapp.start()runs in this process:"all"and"worker"run the dispatcher and the scheduled-command worker,"web"runs neither. See roles.
Commands
Section titled “Commands”commands.timeout, default"30s". How long one run of a command handler may take. Past it the dispatch rejects withHANDLER_TIMEOUT, the handler’ssignalaborts and nothing it returns is stored. Loading the aggregate and storing its events do not count.commands.concurrencyRetries, default3. How many times a command runs again when its append finds the stream moved, before aConcurrencyErrorreaches the caller. Each run gets its owntimeout.commands.idempotencyKeyLifetime, default"24h". How long a command dispatched with anidempotencyKeyis remembered, so a dispatch with the same key answers the same. Past it the key is free again, and the scheduled-command worker purges the record. See idempotent commands.
Policies
Section titled “Policies”policies.timeout, default"30s". How long one run of a policy handler may take. Past it the run is abandoned: its commands still running stop, later ones are refused withREACTION_ABANDONED, and itssignalaborts.policies.retry, default exponential, 3 attempts, 1 s to 30 s. How a failed policy run, or a failed command scheduled withdelay, is retried. Underoverrides, a policy run takes the setting of the aggregate the policy belongs to, and a scheduled command that of the aggregate it is for. See retry.policies.maxChainDepth, default25. How many hops a chain of reactions may take from the command that started it before a command is refused withCHAIN_DEPTH_EXCEEDED. Reaching it usually means two policies answer each other.
Processes
Section titled “Processes”processes.timeout, default"7d". How long a process stays open beforeat-timeout.tsruns, for a process whoseconfigdeclares notimeout.processes.handlerTimeout, default"30s". How long one run of a process handler, for an event or a deadline, may take. Past it the run is abandoned, as a policy’s is.processes.retry, default the same aspolicies.retry’s, not whatpolicies.retryis set to. How a failed process step or deadline is retried.
Each time limit also decides how long a claim lasts, so how soon another instance runs again what a stopped one left: see delivery guarantees.
Dispatcher
Section titled “Dispatcher”dispatcher.pollInterval, default"100ms". How long the dispatcher waits between passes when it polls, and the pace of the scheduled-command worker, whose pass reads when the next command is due and claims only once one is.dispatcher.idleInterval, default"30s". With an adapter that pushes notifications (PostgreSQL), how long an idle dispatcher waits for one before polling anyway. Ignored without notifications.dispatcher.batchSize, default100. Events read per subscriber per pass.dispatcher.projectionBatchTime, default"250ms". How long a projection batch keeps its transaction open before it commits what it has and leaves the rest for the next one. Rebuilds honour it.dispatcher.backoff.baseDelay,.maxDelay, default"1s","30s". How long background passes leave a subscriber alone after a failed batch:baseDelayafter the first failure, doubling up tomaxDelay. A batch that goes through resets it. See a projection that keeps failing.dispatcher.catchUp.timeout,.pollInterval, default"2s","15ms". How longcatchUpReadModels({ through }), and read-your-writes with it, waits for the read models a command changed, and how often it looks while another process holds them. Pasttimeoutit logs a warning and the request reads what is there.
Personal data
Section titled “Personal data”personalData.retention, none by default. How long, a duration or whole calendar months or years such as"6y", a person may go without an event of the app’s aggregates naming them before the runtime forgets them, asforgetdoes, withreason: "retention", every category but those an erasure exemption keeps: the retention of the default category. Each categoryapp/personal-data.tsdeclares has its own retention besides, see categories. Without either, nobody is forgotten for inactivity and nothing is recorded for it. A person with any restriction is left alone until it is lifted; one active again after being forgotten starts a new clock. Turning it on applies it to the history: whoever was already inactive for that long is forgotten in the first passes. It is app-wide and has no override per aggregate: a person’s events span aggregates, so their inactivity is one clock, not one per aggregate. See retention.personalData.keyWrapper, required when the registry marks a fieldpersonal, except overmemory(). Wraps the tenant’s key, which wraps every person’s key and the database’s in turn, so no copy opens a personal field without the master key:masterKey({ from: "BOUNDA_MASTER_KEY", previous: [...] })names the environment variables that hold the current master key and the ones used before, 32 random bytes in base64 each (openssl rand -base64 32), read from the host’s environment when the app starts; a variable missing or malformed fails the start withConfigurationError. A KMS or a vault is given throughdefineKeyWrapper. Both take alocation, where the host or the KMS keeps the master key, which astoragethat declares one requires to be the same. Versions of the tenant’s key wrapped under a previous master key are rewrapped by the worker in the background.memory()brings a master key of its own, gone with the process. See where the keys live.personalData.tenantKeys, required withkeyWrapper, except overmemory(). Where the tenant’s key lives, apart from the storage’s database: an adapter pointed at another database, such assqlite({ path: "./keys/tenant-keys.db" })orpostgresql({ url: TENANT_KEYS_URL }), a store fromdefineTenantKeyStore, or on CloudflaredurableObjectTenantKeys({ storage }), in the app’s jurisdiction, orkvTenantKeys({ binding }), for an app that names none. An adapter that points at the storage’s own database fails the start, and so, under astoragethat declares a location, does a store that declares none, or another without a safeguard:defineTenantKeyStore(create, { location, safeguard })declares one’s.forgetTenantdestroys the key there, and the copies a move left in stores the configuration no longer names (see moving a tenant’s key). See the tenant key store.personalData.forgetLedger, none by default. Where every forgetting is recorded outside the database, before it commits, by person’s id, event id, time, reason and the fingerprints of the keys it destroys, and how the app reconciles with it. Without it, a restored backup brings back everyone forgotten after it was taken. See backups. It holds:store, required. The ledger: an adapter pointed at another database thanstorage, such assqlite({ path: "./ledger/forget-ledger.db" })orpostgresql({ url }), which creates itsbounda_forget_ledgertable there on first use, withbounda_forget_ledger_marksfor the mark that tells a restore made while the app was stopped andbounda_forget_ledger_fencefor each tenant’s fence;durableObjectForgetLedger({ storage })or, for an app that names no jurisdiction,kvForgetLedger({ binding })from@bounda-dev/cloudflareon Cloudflare; or a ledger of your own throughdefineForgetLedger, whoselocationoption declares where it keeps its entries, as the record of processing states it and astoragethat declares a location requires. Every forgetting writes its intention to it before it commits, and the runtime copies everyPersonalDataForgottento it again from the stream in the background. An adapter pointing at the storage’s own database fails the start.reconcileEvery,5mby default (DEFAULT_FORGET_LEDGER_RECONCILE_EVERY_MSin@bounda-dev/core/config). The app reads the ledger when it starts and, while it runs, again this often, one instance a round, and commits again, under its own id, time and reason, each forgetting the database does not hold whose person still holds a key it names: one a restored backup rolled back, or one whose commit never happened; a restore the instances find reconciles at once. A Durable Object only runs a round on the passes it wakes for anyway; it reconciles on every start.strict,falseby default. Whenfalse, a forgetting whose intention the ledger does not take is logged and commits all the same, for the stream to copy later, but for one the ledger’s fence refuses, the tenant frozen or forgotten, which fails either way, and a ledger that cannot be read at start, or a reconciliation longer thantimeout, does not fail it: the app logs an error and reconciles in the background, andgetLag()reportsforgetLedger: { reconciled: false }meanwhile. Whentrue, nothing is forgotten that the ledger has not recorded: a forgetting whose intention it does not take fails withFORGET_LEDGER_UNAVAILABLEand forgets nobody, so trying again is safe; and the start waits for the reconciliation however long it takes, and a ledger it cannot read fails it withFORGET_LEDGER_UNRECONCILED.bounda forgottenneeds neither, since it reads the event store alone.keepFor, none by default. How long an entry is kept after the forgetting; set it longer than the oldest backup you can restore. The instance that runs a periodic round prunes the older entries after it, so a SQL ledger is pruned only while an app of the tenant runs; KV expires each key on its own, andbounda forget-ledger expiregives the keys written beforekeepForwas set theirs. Without it entries are kept until their tenant is forgotten and every recipient of its data told, which clears a tenant’s entries whateverkeepForsays.timeout,10sby default (DEFAULT_FORGET_LEDGER_TIMEOUT_MSin@bounda-dev/core/config). How long each call to the ledger may take before it is given up withFORGET_LEDGER_TIMEOUT, and how long a start that is not strict waits for the reconciliation.
Dead letters
Section titled “Dead letters”deadLetters.retention,30dby default (DEFAULT_DEAD_LETTER_RETENTION_MSin@bounda-dev/core/config). How long a dead letter is kept once it was retried or discarded. Past it, the scheduled-command worker removes it, its error text and payload with it; afailedletter is never removed. A letter that names a person whose processing is restricted stays until the restriction is lifted, unless what it holds of them no longer opens, their key gone, since nothing of theirs is left in it to keep. A process instance whose letter was discarded stays given up after the letter is gone. It is app-wide. See keeping resolved letters.
Subscriber failures
Section titled “Subscriber failures”subscriberFailures.retention,30dby default (DEFAULT_SUBSCRIBER_FAILURE_RETENTION_MSin@bounda-dev/core/config). How long the last failure of a subscriber is kept once the subscriber got past it, or, for a subscriber the app no longer runs, once it last failed on it. Past it, the scheduled-command worker removes it, its error text with it; a failure a subscriber is still stuck on stays. A failure whose text is sealed under a person whose processing is restricted stays until the restriction is lifted, unless the text no longer opens, its person forgotten, since nothing of theirs is left in it to keep. It is app-wide. See error text.
Telemetry
Section titled “Telemetry”telemetry.errorText,"omit"by default. Whether the runtime’s log lines and spans carry the text of an error. With"omit"they carry its class and itscodealone: the message of an error a handler throws may quote personal data it read, and logs and traces keep it in the clear, whereforgetnever reaches. Errors whose message Bounda writes from names and ids alone, such asConcurrencyErroror a dead letter not found, keep it."include"adds the message and the stack of every error, for development;createTestAppand the dev server of@bounda-dev/react-routerdefault to it, andbounda --error-textturns it on for one command. The environment variableBOUNDA_ERROR_TEXToverrides it, as.dev.varsdoes in development on Cloudflare. See error text.
Per aggregate
Section titled “Per aggregate”overrides, default{}. Settings for one aggregate, by aggregate name:commands.timeout,policiesandprocesseswith the keys above, andsnapshot. What an override leaves out comes from the app’s settings.overrides.<aggregate>.snapshot, none by default. Opts the aggregate into snapshots of its state, written in the background and loaded from instead of the stream’s first event:every, required. A stream is snapshotted each time its version reaches a multiple ofevery.verify, default0.01. The share of the loads from a snapshot, 0 to 1, checked against a fold of the whole stream. A snapshot that folds to another state is logged, dropped and not used. An app fromcreateTestAppchecks every load and throwsSnapshotErrorinstead.version, default1. Part of what a snapshot is valid for, next to thestateFingerprintthe generator computes from the modules that shape the state. Raise it to retire every snapshot of the aggregate when the fold changed through something the fingerprint cannot see, such as a package or a module behind a path alias.
A process can set its own lifetime in its config,
({ events }) => ({ startedBy: [...], timeout: "48h" }), which wins over processes.timeout and
over an override.
policies.retry and processes.retry take the same shape. strategy is required whenever
retry is given; the other keys fall back to the defaults.
| Key | Default | What it does |
|---|---|---|
strategy |
"exponential" |
"none" gives up on the first failure; "fixed" waits baseDelay each time; "linear" waits baseDelay times the retry number; "exponential" doubles baseDelay with each retry. |
maxAttempts |
3 |
Runs in all, the first one included, before the failure becomes a dead letter. |
baseDelay |
"1s" |
The first wait. |
maxDelay |
"30s" |
No wait is longer than this. |
Only failures that may pass are retried. A rejection is an answer, not a failure; a payload that
does not validate, a missing module, a broken configuration, a chain that went too deep or events
that do not fit the aggregate (VALIDATION_FAILED, NOT_FOUND, INVALID_CONFIGURATION,
CHAIN_DEPTH_EXCEEDED, CREATION_ORDER) become a dead letter at once, since they would fail the
same way again. See errors.
runtime: { policies: { retry: { strategy: "exponential", maxAttempts: 5, maxDelay: "2m" } }, overrides: { // a policy whose command can never succeed on a second try; the commands scheduled for // `order` are not retried either order: { policies: { retry: { strategy: "none" } } }, },},Outside bounda.config.ts
Section titled “Outside bounda.config.ts”- React Router: the
bounda()Vite plugin takesconsistencyanddebounceMs; see its options. - Cloudflare:
createBoundaObjecttakespassesPerAlarm,createWorkertakestenantOfandconsistency, andconnecttakesconsistency; see the Cloudflare adapter. With React Router,app/tenant.tsnames the tenant; see on Cloudflare. - Tests:
createTestApptakes its ownportsandconfig; see testing.