Skip to content

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.

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.

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.

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);
}

View C# snippet source on GitHub

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"));
}

View C# snippet source on GitHub

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"));
}

View C# snippet source on GitHub

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));
}

View C# snippet source on GitHub

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, and CausedBy identity chain.
  • The original Causation entries’ 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.

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.

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;
}
}

View C# snippet source on GitHub

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.

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;
}

View C# snippet source on GitHub

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:

  1. Open the Event Log view for the event store and namespace you want to manage.
  2. Select the event you want to redact.
  3. Click the Redact button in the event detail panel.
  4. In the dialog that appears, enter the reason for the redaction.
  5. 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.