Compliance · Erasure limits
What a @pleach/core crypto-shred erases, what it does not, and how rows held during a key outage behave.
A crypto-shred removes one subject's key from one live table. It is not proof of erasure. This page lists what a shred does and the copies it can't reach.
The payload encryption and subject-key code described here is experimental. The page describes the library only. Whether a given deployment has a key store armed is a fact about that deployment, not something this page claims.
For the erasure request itself and its signed shred proof, see GDPR right-to-erasure.
What a shred does
- One key per subject. Each
(tenantId, subjectId)has a data key (DEK), wrapped under a key-encryption key (KEK) and stored in the subject-key table. The plaintext DEK is never written to the database.SubjectKeyRegistryfrom@pleach/core/cryptomanages it. - Fields are sealed before hashing. When a writer is given a subject-key
source, it seals the allowlisted content fields of each event payload
(
SCRUBBABLE_FIELDS, from@pleach/core/scrubbers) under the row subject's DEK. This happens before the payload hash and row hash are computed. - A shred destroys the wrapped key.
SubjectKeyRegistry.shred()destroys the wrapped DEK in the live table. Sealed fields can then no longer be opened through the registry. The append-only rows aren't rewritten, so the hash chain still verifies. - Legal holds are checked only when you wire a checker. Build the registry
with a
holdCheckerand a shred is refused unless the checker answersclear. That includes a checker that throws or can't read the hold register. The check and the shred are two statements, so a hold placed between them is not seen. - A subject's key follows its scope's KEK. When a customer key is
enrolled, withdrawn or superseded, a subject's next seal replaces its key
with a new generation under the current KEK, in one compare-and-swap
statement. The old generation gets the status
retiredand stays stored and readable. A seal the binding refuses, such as a withdrawn customer key, throws and changes nothing.rollSubjectKeyforces a roll as a compromise-recovery step.rewrapSubjectDeksandverifySubjectDeksmove existing generations under the current KEK once, andcompleteis true only when a second read-only pass found nothing stale and nothing unreadable. A table without theretiredstatus and its timestamp column fails the seal closed withrotation-unsupported. A single-key table can't hold a second generation, so a seal re-wraps the same key in place. - Call-ledger rows are sealed under the user. When a row's principal has a user id, the row is sealed under that user for every actor kind, so one shred covers them. A row sealed before this rule is erased only by shredding its session subject.
- New rows after a shred depend on the key table. On a generational key
table (one with a key-generation column), new rows for a shredded subject are
sealed under the next key generation, and old rows stay unopenable
(
getOrCreateActiveDek). On a single-key table, or with a key source that lacksgetOrCreateActiveDek, nothing rotates. New rows for that subject get the erased sentinel (ERASED_FIELD_SENTINEL) in place of each sealed field. - A schema that can't erase fails before any key is stored. If the key
table declares the wrapped-key or IV column
NOT NULL, a shred can't erase. The registry's preflight then makesgetOrCreateDekthrowSubjectKeyDdlShapeErrorbefore any key is stored.
What a shred does not erase
- Backups and replicas. A backup or replica that still holds the wrapped DEK can open the ciphertext until that copy ages out. The library makes no claim that backups are erased, and offers no way to prove it. Whether a shred meets a legal erasure duty depends on your backups, not on this code.
- Plaintext written before or outside encryption. A shred can't reach rows written without a subject-key source, for example before encryption was turned on. It also can't reach a field outside the allowlist, or a row with no user, session or chat id to key on. Those rows stay plaintext.
- Rows the content-pointer verifier can't see. The verifier
(
verifyContentPointers, from@pleach/core/eventLog) grades content pointers, not rows. A row with no subject gets no keyed pointer at all. - Plaintext copies you didn't declare. After a shred, a location reads
no_verdictwith reasonkey-erased-plaintext-retainedonly when you declareretainedCopyPathsand the row holds an unsealed copy at one of them. With no paths declared, a destroyed key whose locations answer not-found gradeserased, even if the row still holds the body in plaintext. - Session subjects keyed by more than one id. A row with no user is keyed
by
session:<sessionId>, elsesession:<chatId>. Erasing a session subject must shredsession:<id>for every distinct session id and chat id its rows carry, not the chat id alone. AnON DELETE SET NULLforeign key on the row's session id moves a sealed row's subject tosession:<chatId>, and that row can then no longer be decrypted. - Copies outside the event log. A shred doesn't touch host logs, caches,
other tables, exports, or anything sent to a model provider. The verifier's
erasedverdict covers only a pointer's own locations and its own event row. A projection-checkpoint store binds its snapshots toSubjectKeyRegistry.shredEpoch(), so a snapshot folded before a shred is not restored after it. - Unkeyed digests.
sha256ContentHasheris an explicit opt-in. Its digest of a short body stays in the ledger and can confirm a guessed body after erasure. - Retired key generations. A generation roll is not erasure. The retired DEK is still wrapped under its KEK. A shred destroys every generation of the subject.
Held rows: a short in-instance bridge
A row whose seal fails on a transient key failure, such as a KMS outage, is held in the writer and sealed again on a later attempt.
| Bound | Value |
|---|---|
| Deadline | Per chain, from the first row held on that chain |
| Default deadline | 10 s |
| Maximum deadline | 5 min |
| After the deadline | One last attempt |
| Held-row space bound reached | The oldest held non-audit row gets one last attempt and expires loudly |
- Held rows keep their order. Rows are held by chain address. A later row
on a held chain waits behind the held row, so the chain keeps its write
order. Other chains aren't touched. A key-store driver failure counts as
store-failure. An audit row's digest stays pending while its row is held. - You can watch them.
EventLogWriterandcreatePgEventLogWriterboth takeonHeldRows, which reports rows held, released, exhausted, dropped, or written without a digest. It carries counts and a closed reason, never a row, a subject or a key.getHeldRowsStatus()returns what is held now, for a preflight check, and the Postgres writer'sflush()reportsheld. - Held rows live only in memory. They sit in that process's memory with their fields not yet sealed. They are not a durability guarantee.
- A lost instance loses its held rows. If the instance dies, or is frozen and never thawed, its held rows are gone. Nothing durable records them, and their loss raises no signal.
- Erasure accounting can't count on them. It can't assume a held row will be written, or refused, later.
- A row whose key was shredded is not held. Before a shred destroys a key, the pre-shred barrier asks the live writers on the same registry to seal or refuse the rows they hold for that subject. A writer it can't reach is covered by the seal-time guard. That guard drops a row recorded before the shred rather than sealing it under the new generation.
Where to go next
GDPR right-to-erasure
executeErasureRequest, the signed shred proof, and crypto-shredding vs row deletion.
Hash chain
What the row hash covers, including stored ciphertext under payload encryption.
Scrubbers
The SCRUBBABLE_FIELDS allowlist that also bounds which fields get sealed.
WORM
Retention passes and legal holds on the append-only event log.
Compliance · GDPR right-to-erasure
executeErasureRequest: the primitive for GDPR erasure requests against an append-only hash chain, and the two approaches to erasure.
Compliance · FDA Part 11 and ALCOA+
Topic summary of how Pleach mechanisms bear on FDA Part 11 and ALCOA+, whether each is on by default, and what your QMS provides.