# Compliance · Erasure limits (/docs/compliance/erasure-limits)



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](/docs/compliance/gdpr-erasure).

## What a shred does [#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. `SubjectKeyRegistry`
  from `@pleach/core/crypto` manages 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](/docs/hash-chain) still verifies.
* **Legal holds are checked only when you wire a checker.** Build the registry
  with a `holdChecker` and a shred is refused unless the checker answers
  `clear`. 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 `retired` and stays stored and
  readable. A seal the binding refuses, such as a withdrawn customer key,
  throws and changes nothing. `rollSubjectKey` forces a roll as a
  compromise-recovery step. `rewrapSubjectDeks` and `verifySubjectDeks` move
  existing generations under the current KEK once, and `complete` is true only
  when a second read-only pass found nothing stale and nothing unreadable. A
  table without the `retired` status and its timestamp column fails the seal
  closed with `rotation-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
  lacks `getOrCreateActiveDek`, 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 makes `getOrCreateDek` throw
  `SubjectKeyDdlShapeError` before any key is stored.

## What a shred does not erase [#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_verdict` with reason `key-erased-plaintext-retained` only when you
  declare `retainedCopyPaths` and the row holds an unsealed copy at one of
  them. With no paths declared, a destroyed key whose locations answer
  not-found grades `erased`, 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>`, else `session:<chatId>`. Erasing a session subject
  must shred `session:<id>` for every distinct session id and chat id its rows
  carry, not the chat id alone. An `ON DELETE SET NULL` foreign key on the
  row's session id moves a sealed row's subject to `session:<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
  `erased` verdict covers only a pointer's own locations and its own event row.
  A projection-checkpoint store binds its snapshots to
  `SubjectKeyRegistry.shredEpoch()`, so a snapshot folded before a shred is not
  restored after it.
* **Unkeyed digests.** `sha256ContentHasher` is 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 [#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.** `EventLogWriter` and `createPgEventLogWriter` both
  take `onHeldRows`, 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's `flush()` reports `held`.
* **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 [#where-to-go-next]

<Cards>
  <Card title="GDPR right-to-erasure" href="/docs/compliance/gdpr-erasure" description="executeErasureRequest, the signed shred proof, and crypto-shredding vs row deletion." />

  <Card title="Hash chain" href="/docs/hash-chain" description="What the row hash covers, including stored ciphertext under payload encryption." />

  <Card title="Scrubbers" href="/docs/scrubbers" description="The SCRUBBABLE_FIELDS allowlist that also bounds which fields get sealed." />

  <Card title="WORM" href="/docs/worm" description="Retention passes and legal holds on the append-only event log." />
</Cards>
