Skip to content

PII

PII classification and release behavior are shared Chronicle compliance topics.

Choose a TypeScript task: select the subject for event PII or release a raw stored document. Classification and erasure policy remain in the shared guides.

For an existing application, check stored-event consequences before changing subject annotations or key-deletion procedures.

Upgrade note: this fixes previously ignored event annotations, so newly appended events carrying @subject() can now use a different encryption key. Events appended before this fix with @subject() but no explicit subject were encrypted under the event source identifier’s key. Existing stored events are not re-encrypted. To erase that older PII, you must also delete the event source identifier’s key (or use the existing erase APIs for that identifier), in addition to the subject’s key. Deleting the event source’s key also erases other PII protected by that same key. If your erasure process deletes the event source identifier’s key, events appended after upgrading that carry @subject() are no longer protected by that key; erase the subject’s key instead.

When an event source identifies a registration or transaction rather than a person, mark the event’s person identifier with @subject() (imported from @cratis/chronicle/compliance). Chronicle uses the resolved subject’s encryption key to protect the event’s PII. Before changing key-deletion procedures, follow Erasing a subject and the upgrade note above; this page is not a complete-erasure checklist.

Single append and both appendMany overloads select the subject in this order:

  1. The explicit subject: a batch entry’s subject overrides the call’s AppendOptions.subject.
  2. The value of the event’s first property marked @subject().
  3. The event source identifier.

Null or undefined annotation values fall back to the event source. String values, including empty and whitespace-only strings, are sent as-is. Chronicle falls back to the event source identifier for both the stored context subject and the PII encryption key when the selected subject is empty or whitespace-only. An explicit empty string option still blocks the annotation, so that event uses the event source’s key. Concept values and other non-string values use toString(); a null or empty result falls back. There is no event id property convention.

Transactional appends resolve the annotation when the unit of work commits. EventScenario uses the same precedence for single and batch appends and for its given-event seeds; it does not emulate PII encryption or erasure. Kernel event seeding uses a separate contract that has no subject field in Chronicle 19.26.2, so it cannot select an annotated subject.

Releasing PII can disclose personal data. Apply your application’s authorization rules before calling a release API; classification and stored subject metadata do not establish permission.

For a typed instance with one subject, keep using readModels.release(type, instance) or releaseMany(type, instances); those APIs are unchanged.

If you read a read model directly from its store, use readModels.releaseDocument(ReadModelType, document) to release its PII. Supply the discovered read model class with its runtime field types and PII metadata, and the raw JSON document with its stored __subject and __subjects fields. Do not convert the document to a class instance first: that can discard the subject metadata needed for joined data.

The result is a new plain Record<string, unknown>, not an AccountSummary instance. Only schema-declared top-level properties are returned; storage-only fields, including __subject and __subjects, are removed. The input document and its nested values are not mutated.

Subject selection follows the stored metadata:

  • __subjects maps top-level property names to non-empty subject strings. Each mapping applies to the property’s entire subtree, including arrays. Null or empty mapping values are ignored, so those properties use the default subject. A non-object __subjects value is treated as an empty map. Dotted paths such as contact.phone are not supported.
  • __subject is a non-empty string used for properties without a mapping. Null or an empty string means there is no default subject. Whitespace-only subject strings are valid and passed through unchanged.
  • Properties with neither subject are copied unchanged, without release. There is no fallback to id or @subject().

The client makes one release call per distinct subject, using only that subject’s properties and their schemas. If a call reports HasError, fails in transport, or returns malformed, missing, or conflicting properties, the whole operation rejects. Non-string subjects other than null, reserved subject-map names, and mappings for document properties absent from the schema also reject. Mappings for properties absent from the document are ignored after validating their subject values. You never receive a partially merged document. Errors omit kernel and transport details because they can contain PII.

Chronicle 19.26.2 can replace individual values with empty values after a per-property decryption failure while still returning HasError: false. The client cannot detect these unreported failures and does not guess from an empty value. Track this limitation in Chronicle issue 4480.

For example, given your configured store, discovered AccountSummary read model, and a raw stored document:

const released = await store.readModels.releaseDocument(AccountSummary, document);