Cratis Chronicle event redaction and its erasure boundaries
Redaction in Cratis Chronicle replaces a stored event’s payload with a marker while keeping its sequence number and audit metadata. Use it when event content must be removed, but treat it as one part of an erasure workflow: it does not remove every copy of the data or every identifier associated with the event.
Why redaction keeps the event slot
Section titled “Why redaction keeps the event slot”Observers use sequence numbers to track their progress. Keeping the slot means those positions still refer to the same place in history after redaction. Chronicle replaces the content in place, changes the event type to the internal EventRedacted type, and stores the reason and selected original audit fields in the marker.
Later reads and replays see the marker rather than the original payload. The event’s context records the redaction action, so you can distinguish who requested redaction from the identity chain that caused the original event. Keeping that context also means redaction is not anonymous history.
When to use redaction
Section titled “When to use redaction”Use redaction to remove sensitive content from selected events, including events identified during a right-to-erasure workflow. An event-source request selects events by their event source identifier in the target sequence; it does not discover every event whose payload refers to that person.
Review retained identifiers, tags, subject values, and audit metadata as part of that workflow. They can still contain personal information. Keep sensitive details out of the redaction reason too. For subject-key erasure, use Erasing a subject, and review the broader regulatory responsibilities.
Do not use redaction to undo a business decision. Record a cancellation or reversal as a new event; compensation can link it to the event it offsets. Use revision when content needs correction but the original should remain stored.
Redacting a single event
Section titled “Redacting a single event”To redact one specific event by its sequence number, call Redact on the event sequence and provide a reason:
using Cratis.Chronicle.Events;using Cratis.Chronicle.EventSequences;
public class RedactionUnknownReasonService(IEventLog eventLog){ public Task Redact(EventSequenceNumber sequenceNumber) => eventLog.Redact(sequenceNumber, RedactionReason.Unknown);}import io.cratis.chronicle.IEventStoreimport io.cratis.chronicle.eventSequences.EventSequenceNumberimport io.cratis.chronicle.eventSequences.RedactionReason
/** * Redacts a single event by sequence number without stating a specific reason. */suspend fun redactUnknown(store: IEventStore, sequenceNumber: Long) = store.eventLog.redact(EventSequenceNumber(sequenceNumber), RedactionReason.unknown)import io.cratis.chronicle.EventStore;
import io.cratis.chronicle.java.EventLogJavaBridge;
class EventsRedactionBySequenceNumberUnknown { // Redacts a single event by sequence number without stating a specific reason. "Unknown" is // the same value RedactionReason.unknown carries on the wire. void redact(EventStore store, long sequenceNumber) { EventLogJavaBridge.redact(store.getEventLog(), sequenceNumber, "Unknown"); }}defmodule MyApp.RedactionUnknownReasonService do alias Cratis.Chronicle.EventSequences.EventLog
def redact(sequence_number) do EventLog.redact(sequence_number, "Unknown") endendimport { EventSequenceNumber, IEventLog } from '@cratis/chronicle';
class RedactionUnknownReasonService { constructor(private readonly eventLog: IEventLog) {}
// The TypeScript client always requires an explicit reason - there is no // "unknown reason" default overload. redact(sequenceNumber: EventSequenceNumber): Promise<void> { return this.eventLog.redact(sequenceNumber, 'Unknown'); }}Always provide a meaningful reason when possible:
using Cratis.Chronicle.Events;using Cratis.Chronicle.EventSequences;
public class RedactionWithReasonService(IEventLog eventLog){ public Task Redact(EventSequenceNumber sequenceNumber) => eventLog.Redact(sequenceNumber, new RedactionReason("GDPR erasure request"));}import io.cratis.chronicle.IEventStoreimport io.cratis.chronicle.eventSequences.EventSequenceNumberimport io.cratis.chronicle.eventSequences.RedactionReason
/** * Redacts a single event by sequence number with a meaningful reason. */suspend fun redactWithReason(store: IEventStore, sequenceNumber: Long) = store.eventLog.redact(EventSequenceNumber(sequenceNumber), RedactionReason("GDPR erasure request"))import io.cratis.chronicle.EventStore;
import io.cratis.chronicle.java.EventLogJavaBridge;
class EventsRedactionBySequenceNumberWithReason { // Redacts a single event by sequence number with a meaningful reason. void redact(EventStore store, long sequenceNumber) { EventLogJavaBridge.redact(store.getEventLog(), sequenceNumber, "GDPR erasure request"); }}defmodule MyApp.RedactionWithReasonService do alias Cratis.Chronicle.EventSequences.EventLog
def redact(sequence_number) do EventLog.redact(sequence_number, "GDPR erasure request") endendimport { EventSequenceNumber, IEventLog } from '@cratis/chronicle';
class RedactionWithReasonService { constructor(private readonly eventLog: IEventLog) {}
redact(sequenceNumber: EventSequenceNumber): Promise<void> { return this.eventLog.redact(sequenceNumber, 'GDPR erasure request'); }}Redacting all events for an event source
Section titled “Redacting all events for an event source”Pass the event source identifier and a reason to redact its events in the target event sequence. This selects by event source, not by compliance subject or references inside event content:
using Cratis.Chronicle.Events;using Cratis.Chronicle.EventSequences;
public class RedactionByEventSourceService(IEventLog eventLog){ public Task RedactAccount(EventSourceId eventSourceId) => eventLog.Redact(eventSourceId, new RedactionReason("Account deletion requested"));}import io.cratis.chronicle.IEventStoreimport io.cratis.chronicle.eventSequences.RedactionReason
/** * Redacts every event associated with a particular event source - for example, to erase all * data for a specific user. */suspend fun redactAccount(store: IEventStore, eventSourceId: String) = store.eventLog.redactForEventSource(eventSourceId, RedactionReason("Account deletion requested"))import io.cratis.chronicle.EventStore;
import java.util.List;
import io.cratis.chronicle.java.EventLogJavaBridge;
class EventsRedactionByEventSource { // Redacts every event associated with a particular event source. void redactAccount(EventStore store, String eventSourceId) { EventLogJavaBridge.redactForEventSource(store.getEventLog(), eventSourceId, "Account deletion requested", List.of()); }}defmodule MyApp.RedactionByEventSourceService do alias Cratis.Chronicle.EventSequences.EventLog
def redact_account(event_source_id) do EventLog.redact_for_event_source(event_source_id, "Account deletion requested") endendimport { IEventLog } from '@cratis/chronicle';
class RedactionByEventSourceService { constructor(private readonly eventLog: IEventLog) {}
redactAccount(eventSourceId: string): Promise<void> { return this.eventLog.redactForEventSource(eventSourceId, 'Account deletion requested'); }}If you only want to redact a specific type of event rather than all events for the event source, provide the event types:
using Cratis.Chronicle.Events;using Cratis.Chronicle.EventSequences;
[EventType]public record RedactionPersonalDetailsRecorded(string Name, string SocialSecurityNumber);
[EventType]public record RedactionAddressChanged(string Street, string City);
public class RedactionByEventSourceAndTypesService(IEventLog eventLog){ public Task RedactPersonalData(EventSourceId eventSourceId) => eventLog.Redact( eventSourceId, new RedactionReason("PII erasure"), typeof(RedactionPersonalDetailsRecorded), typeof(RedactionAddressChanged));}import io.cratis.chronicle.IEventStoreimport io.cratis.chronicle.events.EventTypeimport io.cratis.chronicle.eventSequences.RedactionReason
@EventTypedata class RedactionPersonalDetailsRecorded(val name: String = "", val socialSecurityNumber: String = "")
@EventTypedata class RedactionAddressChanged(val street: String = "", val city: String = "")
/** * Redacts only the given event types for an event source, leaving every other event type intact. */suspend fun redactPersonalData(store: IEventStore, eventSourceId: String) = store.eventLog.redactForEventSource( eventSourceId, RedactionReason("PII erasure"), listOf(RedactionPersonalDetailsRecorded::class, RedactionAddressChanged::class) )import io.cratis.chronicle.EventStore;import io.cratis.chronicle.events.EventType;
import java.util.List;
import io.cratis.chronicle.java.EventLogJavaBridge;
@EventTyperecord RedactionPersonalDetailsRecorded(String name, String socialSecurityNumber) {}
@EventTyperecord RedactionAddressChanged(String street, String city) {}
class EventsRedactionByEventSourceAndTypes { // Redacts only the given event types for an event source, leaving every other event type intact. void redactPersonalData(EventStore store, String eventSourceId) { EventLogJavaBridge.redactForEventSource( store.getEventLog(), eventSourceId, "PII erasure", List.of(RedactionPersonalDetailsRecorded.class, RedactionAddressChanged.class)); }}defmodule MyApp.Events.RedactionPersonalDetailsRecorded do use Cratis.Chronicle.Events.EventType, id: "redaction-personal-details-recorded"
defstruct [:name, :social_security_number]end
defmodule MyApp.Events.RedactionAddressChanged do use Cratis.Chronicle.Events.EventType, id: "redaction-address-changed"
defstruct [:street, :city]end
defmodule MyApp.RedactionByEventSourceAndTypesService do alias Cratis.Chronicle.EventSequences.EventLog alias MyApp.Events.{RedactionAddressChanged, RedactionPersonalDetailsRecorded}
def redact_personal_data(event_source_id) do EventLog.redact_for_event_source(event_source_id, "PII erasure", [ RedactionPersonalDetailsRecorded, RedactionAddressChanged ]) endendimport { eventType, IEventLog } from '@cratis/chronicle';import { field } from '@cratis/fundamentals';
@eventType()class RedactionPersonalDetailsRecorded { @field(String) readonly name: string; @field(String) readonly socialSecurityNumber: string;
constructor(name: string = '', socialSecurityNumber: string = '') { this.name = name; this.socialSecurityNumber = socialSecurityNumber; }}
@eventType()class RedactionAddressChanged { @field(String) readonly street: string; @field(String) readonly city: string;
constructor(street: string = '', city: string = '') { this.street = street; this.city = city; }}
class RedactionByEventSourceAndTypesService { constructor(private readonly eventLog: IEventLog) {}
redactPersonalData(eventSourceId: string): Promise<void> { return this.eventLog.redactForEventSource( eventSourceId, 'PII erasure', [RedactionPersonalDetailsRecorded, RedactionAddressChanged]); }}How it works
Section titled “How it works”Redaction is modelled as a system event in the system event sequence. When you call Redact, Chronicle appends an EventRedactionRequested (for a single event) or an EventsRedactedForEventSource (for an event source) system event to the internal system sequence. A built-in reactor observes these system events and performs the actual in-place replacement in the target event sequence.
The replacement stores an EventRedacted content record inside the event document that captures:
- The reason for the redaction.
- The original event type, so auditors know what kind of event was removed.
- The original
Occurred,CorrelationId, andCausedByidentity chain. - The original
Causationentries’ types and occurrence times, without their property values.
The event’s own audit context reflects the redaction action. The original payload, revision history, and content hashes are removed from event sequence storage. Routing identifiers, tags, and subject values remain. The marker retains the original audit fields listed above, but not the original causation property values.
Redaction does not reach copies made earlier, such as database oplogs, backups, exports, or events forwarded through outbox/inbox. Nor does replacing the stored payload retract a message or erase a derived read model by itself. Handle those copies and effects separately before reporting an erasure request complete.
Observing redacted events in Reactors and Reducers
Section titled “Observing redacted events in Reactors and Reducers”After replacement, Chronicle requests replay for affected observers marked replayable. Depending on their partitioning, this can replay one event-source partition or the whole observer. Non-replayable observers are not automatically rebuilt.
A reactor or reducer that handles both the original event type and EventRedacted can process the marker when it reads that position. Use that handler to clean up derived state or request downstream cleanup. This is not an immediate notification to every consumer, and replay can run other handlers again; review their external effects.
Why subscribe to EventRedacted?
Section titled “Why subscribe to EventRedacted?”A reducer’s handler can remove or sanitise state derived from the original event. A reactor’s handler can notify another system that it needs to remove a copy. Implement and monitor that work explicitly: receiving a marker does not prove the downstream cleanup succeeded.
Subscribing in a Reactor
Section titled “Subscribing in a Reactor”In .NET, add a handler accepting EventRedacted alongside the original event types you handle. The kernel filters markers by those original types, so an unrelated redaction does not invoke this handler.
using Cratis.Chronicle.Events;using Cratis.Chronicle.EventSequences;using Cratis.Chronicle.Reactors;
[EventType]public record RedactionPersonRegistered(string Name);
public class RedactionPersonReactor : IReactor{ public Task Registered(RedactionPersonRegistered @event, EventContext context) { // Handle the original event return Task.CompletedTask; }
public Task Redacted(EventRedacted @event, EventContext context) { // Called only when a RedactionPersonRegistered event (a type this reactor handles) is redacted. // @event.OriginalEventType is typeof(RedactionPersonRegistered). // Use this to undo any side effects produced by the original event. return Task.CompletedTask; }}Kotlin does not support this workflow yet.Java does not support this workflow yet.Elixir does not support this workflow yet.TypeScript does not support this workflow yet.The EventRedacted record is defined in Cratis.Chronicle.Events and carries:
| Property | Description |
|---|---|
Reason |
The RedactionReason provided at the time of redaction. |
OriginalEventType |
The CLR Type of the event that was redacted. |
Occurred |
When the original event occurred. |
CorrelationId |
The correlation identifier of the original event. |
Causation |
The original causation types and occurrence times, without property values. |
CausedBy |
The identity chain that caused the original event. |
Subscribing in a Reducer
Section titled “Subscribing in a Reducer”In .NET, include EventRedacted handling in the IReducerFor<TReadModel> implementation to decide what state should remain when it processes a redaction marker:
using Cratis.Chronicle.Events;using Cratis.Chronicle.EventSequences;using Cratis.Chronicle.Reducers;
[EventType]public record RedactionReducerPersonRegistered(string Name);
public record RedactionPersonReadModel(string Name);
public class RedactionPersonReadModelReducer : IReducerFor<RedactionPersonReadModel>{ public RedactionPersonReadModel Registered(RedactionReducerPersonRegistered @event, RedactionPersonReadModel? current, EventContext context) => (current ?? new RedactionPersonReadModel(string.Empty)) with { Name = @event.Name };
public RedactionPersonReadModel? Redacted(EventRedacted @event, RedactionPersonReadModel? current, EventContext context) => // Return null to remove the read model, or return a sanitised version null;}Kotlin does not support this workflow yet.Java does not support this workflow yet.Elixir does not support this workflow yet.TypeScript does not support this workflow yet.Filtering guarantee
Section titled “Filtering guarantee”The EventRedacted event is delivered to an observer only if the observer was already subscribed to the original event type. An observer that subscribes to [PersonRegistered, EventRedacted] will not receive an EventRedacted notification when an unrelated event type (e.g. OrderPlaced) is redacted.
The Workbench lets you redact events without writing any code:
- Open the Event Log view for the event store and namespace you want to manage.
- Select the event you want to redact.
- Click the Redact button in the event detail panel.
- In the dialog that appears, enter the reason for the redaction.
- Click OK to confirm.
Confirming records the redaction request; a built-in reactor applies it asynchronously. Reopen the event to check that the marker has replaced its payload, then inspect affected observers for replay progress and failures. Before reporting an erasure complete, also check the retained metadata, copies, and derived state identified in your erasure workflow.