Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dbf8752
feat!: retire event types and seal what they stored by the marks ever…
benatespina Dec 4, 2026
ea6858a
fix: name a retired timeout event for on-timeout.ts, and word E13 and…
benatespina Dec 4, 2026
5d73ce5
test(core): refuse to restart older code once newer code wrote a type…
benatespina Dec 4, 2026
960d67a
fix(core): renew the backfill's lease through a hold, so instances on…
benatespina Dec 4, 2026
dc9b073
feat(core): record how far a walk sealed every value under each set o…
benatespina Dec 4, 2026
5a18494
feat(core): seal a retired type's clear values under the set a walk l…
benatespina Dec 4, 2026
15bb363
test(core): pin when the backfill records its sets sealed
benatespina Dec 4, 2026
a2ec3c8
feat(core): let the set a walk last sealed under alone settle a field…
benatespina Dec 4, 2026
d896499
fix(core): fence recording a walk's sets sealed against leases taken …
benatespina Dec 4, 2026
435daf4
feat(core)!: retire personal-data categories, and refuse a store that…
benatespina Dec 4, 2026
663040e
feat(core,cli): name retired personal-data categories in types, and r…
benatespina Dec 4, 2026
8df1881
feat(core)!: let redact reach any field of every event type, by what …
benatespina Dec 4, 2026
c29f76e
test(core): pin that a rebuild refuses a retired type whose recorded …
benatespina Dec 4, 2026
ae1355d
fix(core): keep a redaction's fields one type, so a generic registry'…
benatespina Dec 4, 2026
48de3a0
docs(core): say where a retired personal-data category is named, in t…
benatespina Dec 4, 2026
d80109a
fix(core): seal a retired type's failures for whom the marks the stor…
benatespina Dec 4, 2026
a2238f7
refactor(core): name the categories the kernel writes as declared or …
benatespina Dec 4, 2026
acbceaf
test(cli): pin that the inventory says a retired category is retired,…
benatespina Dec 4, 2026
8b438d3
fix(core,postgresql)!: record every category a stored write names, no…
benatespina Dec 4, 2026
0770357
docs: retire event types and personal-data categories, redact by enve…
benatespina Dec 4, 2026
2c2548c
chore: changeset for retired event types and categories, and redactio…
benatespina Dec 4, 2026
96e398d
fix(core): refuse a rebuild on a category the store recorded that the…
benatespina Dec 4, 2026
aaa6f0f
docs: say every write that names a category records it, the rebuild r…
benatespina Dec 4, 2026
987d8f0
test(core): type the named-categories test's configuration as Config
benatespina Dec 4, 2026
74a1ca0
test(core): cover what the event-store wrappers pass through for mark…
benatespina Dec 4, 2026
fcdc936
test(cli): pin the order of retired events and a foreign handler of n…
benatespina Dec 4, 2026
a7f5760
test(core): kill the mutants left on the stores' marks and categories…
benatespina Dec 4, 2026
d4e68a9
fix(core): settle an old value written after a redaction in a stream …
benatespina Dec 4, 2026
96e413b
docs: say a redaction settles an old value written after it in any ev…
benatespina Dec 4, 2026
19c4c8a
test(core): kill the mutants left on the backfill's recording of sets…
benatespina Dec 4, 2026
58ee95a
test(core): kill the mutants left on a start's checks of retired type…
benatespina Dec 4, 2026
0cd5bfd
chore: raise the coverage thresholds for lines and branches
benatespina Dec 4, 2026
186fe8d
test(cli): compare the emitted registry's path with forward slashes, …
benatespina Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/redact-by-envelope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bounda-dev/core": minor
---

`redact` reaches any field of every event type of the app, and of every process lifecycle event that carries its state, a retired type and one that marks nothing now included, by what the stored event holds: a value sealed for the person, or one in the clear where its type marks it, or, for a retired type, where a set of marks the store recorded does. `RedactedFields.fields` takes any field name, offering the marked ones by name, and only a stream and type the app knows nothing of is refused before the store is read. **Breaking:** a field the event does not hold, or holds sealed for another person, which a redaction passed over before, resolving without sealing it, is refused with `ValidationError` (`redact cannot reach the event <id>: it holds no "<field>"`, `… it holds "<field>" sealed for another person`), nothing redacted or recorded; and a field its type does not mark, refused before whatever the event held, is reached when the event holds it sealed for the person and refused as `it holds "<field>" in the clear` when it does not. The reconciliation of the forget ledger redacts again by each field's envelope, a field no longer marked included, and so does the settling of a redaction, for an old value work running at it wrote after it in any event of the person, of an aggregate or a process this code no longer has included. The personal-data export lists every field the store holds sealed for the person under the category its envelope names, an event of a retired type and a field no longer marked included, and the tenant export restricts each field by the restrictions of the person its envelope names.
7 changes: 7 additions & 0 deletions .changeset/retired-event-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@bounda-dev/core": minor
"@bounda-dev/cli": minor
"@bounda-dev/postgresql": minor
---

An aggregate retires an event type it no longer records with a module that exports only `export const retired = true`: the type has no builder, no `+types` and no member in the aggregate's events, every fold skips it, so the aggregate's snapshots are retired, and its events are read as stored in whatever schema version wrote them. `bounda generate` refuses such a module that exports anything else, an `<event>.upcast.ts` next to it, and a process handler, a policy or a projection named after it, and boot refuses an `on`, a process `config` or a `correlate` that names it. A delayed policy run whose policy no longer handles its event's type, retired or not, is dropped and settled, with a warning. A process's dead letter names the instance it failed in, `instanceId`, so a process that failed on an event whose type was retired since is retried, letting the event through, or discarded. **Breaking:** an app, a rebuild, `bounda forget-ledger prune` and `bounda forget-ledger stranded` refuse with a `ConfigurationError` (`The store holds events this code does not account for:`) a store holding events of a type of one of the app's aggregates that no module names, which was read as stored before: retire it. They refuse too a retired type whose events opened streams of an aggregate whose state `begin` sets up: keep its module. Every start records what each event type it has a module for marks personal, once per set of marks, in the new `bounda_event_marks`, and the backfill seals what a retired type still holds in the clear by those marks, where they disagree under the set a walk last sealed the whole store under with no instance on other marks running, which the store keeps as `sealed_through`; a retired type no start recorded marks for, whose marks seal in a category `bounda.personal-data.ts` neither declares nor retires, or whose marks disagree with no such walk, is refused (`The store holds events of retired types this code cannot seal:`), at start and again by the backfill, an export and a redaction: deploy once with the module, on a tenant that is not frozen, before retiring it. An app whose store holds events of types an earlier deploy marked personal needs the key wrapper and the forget ledger even when its schemas mark nothing any more. The backfill never writes back in the clear what an upcaster carries, or makes from a sealed value, under a key the current schema does not declare, and its walk renews its lease while it is held, so instances on other marks see it running. A storage migration, on SQLite and PostgreSQL, adds `bounda_event_marks`, an `opened` column to `bounda_event_types`, filled from the events at version 1 the store holds, and an `instance_id` column to `bounda_dead_letters`, filled from the `ProcessFailed` that names each letter. Every start writes the marks it records the first time it meets them, and one that marks personal data takes the backfill's lease, on a tenant open to writes. **Breaking for an adapter of your own:** `EventStore` gains `recordMarks`, `marksOf` and `recordSealed`, which a transaction's event store stages with the rest; `StoredEventType` gains `opened`; `StoredDeadLetter` gains `instanceId`; and `StorageTransaction` gains `checkpointStore`, whose writes commit with the transaction's, transactions running one at a time. `eventStoreContract`, `storageTransactionContract`, `deadLetterStoreContract` and `storageSchemaContract` cover them.
7 changes: 7 additions & 0 deletions .changeset/retired-personal-categories.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@bounda-dev/core": minor
"@bounda-dev/cli": minor
"@bounda-dev/postgresql": minor
---

A personal-data category the app no longer collects anything in is retired in `bounda.personal-data.ts`, its whole declaration kept with `retired: true`. It leaves `PersonalCategoryName`, so a field marked in it, an automated decision on it, a recipient declared for it and a port whose `returnsPersonalData` names it do not compile, and the app refuses to start on them; `forget`, `restrict`, `unrestrict` and `expectForgotten` take its name, typed `PersonalCategoryName | RetiredPersonalCategoryName`, as every runtime event and output that names a category is; and what it holds stays under its retention and exemptions. `RetiredPersonalCategoryName` and `RetiredPersonalCategoriesOf` are exported from `@bounda-dev/core`, and `AppRetiredPersonalCategory` from `@bounda-dev/core/register`. `bounda generate` writes `RetiredPersonalCategory` in `.bounda/types.ts` and registers `retiredPersonalCategories` in `.bounda/register.d.ts`: run it after upgrading. The personal-data export (`PERSONAL_DATA_EXPORT_VERSION` 3), the record of processing activities (`PERSONAL_DATA_INVENTORY_VERSION` 3) and the tenant export (`TENANT_EXPORT_VERSION` 10) say of each category whether it is `retired`, and `bounda personal-data inventory` prints one as `name (retired)`. **Breaking:** a category the store recorded, by a key given in it or by a write it holds that names it (a restriction or its lifts, a forgetting of a person or of a tenant, a redaction, a disclosure, a recipient's declaration or an entry of the forget ledger), and that the file neither declares nor retires, refuses the start, a rebuild of a read model, `bounda forget-ledger prune` and `bounda forget-ledger stranded` with a `ConfigurationError` naming it, forgetting nothing, where its keys were forgotten at once before: this code cannot tell a category it dropped from one newer code declares. Declare it again, its whole declaration with `retired: true`, and keep the entry for good. The storage migration, on SQLite and PostgreSQL, records every category the restrictions, forgettings, redactions, disclosures and recipient declarations the store already holds name, so the first start after upgrading may refuse a category dropped earlier that only those named: retire it. **Breaking for an adapter of your own:** `PersonalKeyStore` gains `recordCategories`, which records categories as `add` records a key's, in the transaction when called inside one, refused behind the tenant's fence as any write is; `personalKeyStoreContract` and `storageTransactionContract` cover it, and `fillNamedCategoriesStatements`, from `@bounda-dev/core/adapter/sql`, gives a SQL adapter's migration the statements that record what the writes a store already holds name.
36 changes: 34 additions & 2 deletions docs/src/content/docs/adapters/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ it brings them up to the version the installed Bounda expects
| Table | Holds |
| --- | --- |
| `bounda_events` | Every event, with its stream version, a global position and the person it names, if any, which [`exportPersonalData`](/guides/personal-data/#exporting-a-persons-data) reads by |
| `bounda_event_types` | Each kind of event the store holds, by aggregate type, type and schema version, which every append records in its own transaction and a start [checks against the code](/guides/changing-events/#what-the-runtime-checks) |
| `bounda_event_types` | Each kind of event the store holds, by aggregate type, type and schema version, and whether an event of it opened a stream, which every append records in its own transaction and a start [checks against the code](/guides/changing-events/#what-the-runtime-checks) |
| `bounda_event_marks` | Each set of [personal marks](/guides/personal-data/) an event type had, by aggregate type, type and a fingerprint of the marks, in the order first recorded and with when: written once and never removed, so a type's marks outlive its module. `sealed_through` is the position through which the backfill last sealed every value under the set while no instance on other marks ran, kept only on the set of the type that did so last |
| `bounda_checkpoints` | How far each projection, the policy runner, the process runner, the retention and the [forget ledger](/guides/personal-data/#backups)'s copy have read, where a paused rebuild stands, the time of the last ledger entry the database applied, when the last reconciliation ran and the wait of one that failed, when the [key rotation](/guides/personal-data/#rotating-the-tenants-key) was last found complete, the leases of the [background jobs](/guides/deployment/#more-than-one-instance), the counters that tell a [restore](/guides/personal-data/#restores), and, for a read model in a database of its own, the event each of its checkpoints stands at, there, and how far it reached, in the storage's |
| `bounda_inbox` | Which handler already completed for which event, so a retry does not run it again |
| `bounda_scheduled_commands` | Scheduled commands, process deadlines and timeouts, and delayed policy runs, each with when it was scheduled |
| `bounda_dead_letters` | Handler runs that gave up, with the error, the attempt count and the persons the work names, removed once retried or discarded longer ago than [`runtime.deadLetters.retention`](/reference/configuration/#dead-letters) |
| `bounda_dead_letters` | Handler runs that gave up, with the error, the attempt count, the persons the work names and, for a process, the instance it failed in, removed once retried or discarded longer ago than [`runtime.deadLetters.retention`](/reference/configuration/#dead-letters) |
| `bounda_idempotency_keys` | What a command dispatched with an `idempotencyKey` answered, the key with it, sealed under the keys of the persons it names, or under the database's key when it names nobody, and filed under an HMAC of the key until it expires; an answer erased with a person's data leaves that HMAC alone |
| `bounda_personal_keys` | One key per person, which their [personal fields](/guides/personal-data/) are encrypted with, wrapped under the [tenant's key](/guides/personal-data/#where-the-keys-live) whose version it names, and the key's fingerprint, and the wait of a rewrap that failed; `forget` deletes it |
| `bounda_index_keys` | The database's key, which derives the [blind indexes](/guides/personal-data/#sealed-at-rest) of the database's read models and seals snapshots and the remembered answers that name nobody, wrapped as a person's key is, and its fingerprint |
Expand Down Expand Up @@ -175,6 +176,37 @@ SQL that names the read model's table by hand keeps writing to the live table du
through `table`, and keep `client` for what `table` cannot say.
:::

## An adapter of your own

An adapter implements the stores `@bounda-dev/core/adapter` declares and proves them with the
contracts of `@bounda-dev/core/adapter/testing`, `eventStoreContract`, `storageTransactionContract`,
`deadLetterStoreContract`, `storageSchemaContract` and the rest, which every adapter here passes. One
over a SQLite engine gets them all from [`createSqliteAdapter`](/adapters/sqlite/). Since 0.6.0, one
of its own also implements:

- **The marks of each event type.** `EventStore.recordMarks` records each set of marks an event type
had, by aggregate type, type and fingerprint, once and never removed; `marksOf` reads them back in
the order they were first recorded, for one type or for every type; `recordSealed` raises a set's
`sealedThrough` to the position given, never lowers it, and clears it on the type's other sets
sealed no further, so the set sealed last holds the highest. Each is a write refused behind the
tenant's fence, as `append` is, and a transaction's event store stages them with the rest.
- **Which kinds opened a stream.** `StoredEventType.opened`, set once an event of the kind is
appended at version 1 of its stream, or a `reseal` writes one there, and never taken back.
- **The instance of a process letter.** `StoredDeadLetter.instanceId`, kept and read back as given.
- **Categories a write names.** `PersonalKeyStore.recordCategories` records categories in the
catalogue `recordedCategories` reads, as `add` records a key's, in the transaction when called
inside one, and refused behind the tenant's fence as any write is; recording one again changes
nothing. A migration over SQL records those the writes a store already holds name with
`fillNamedCategoriesStatements`, from `@bounda-dev/core/adapter/sql`.
- **Checkpoints in a transaction.** `StorageTransaction.checkpointStore` writes checkpoints with
the transaction's other writes, or not at all. Transactions run one at a time, so a checkpoint the
work reads is written by no other transaction until it ends: the runtime takes the backfill's
lease in one, and records a walk's sets sealed only in one that finds no lease of other marks taken
since the walk read them.

An adapter written for an earlier Bounda does not type-check against 0.6.0 until it has the methods
and fields above, and does not pass the contracts until it keeps what they hold.

## Which one to deploy

| | SQLite and libSQL | PostgreSQL | Cloudflare |
Expand Down
Loading
Loading