Skip to content

Inspect and repair Cratis Chronicle stream closures

When Cratis Chronicle rejects an append with StreamClosed, inspect the persisted closures to find which scope blocked it and who owns the closure. A mistaken manual close needs an operator repair; an event-driven closure reopens through a declared event. Identify the closure before choosing either path.

In the .NET client, IsStreamCompleted returns true when any persisted closure covers the scope you pass:

using Cratis.Chronicle.EventSequences;
using Cratis.Chronicle.Events;
public class InspectingIsCompleted(IEventLog eventLog)
{
public async Task<bool> IsApril(EventSourceId reportId) =>
await eventLog.IsStreamCompleted(new ClosedStreamScope(
EventSourceId: reportId,
EventStreamType: new EventStreamType("monthly-report"),
EventStreamId: new EventStreamId("2026-04")));
}

View C# snippet source on GitHub

Coverage uses the same matching rule as an append: every dimension set in the closure must be present in the scope and have the same value. A closure for an entire event source therefore covers a query for one stream of that source. A closure for just that stream does not mean the whole event source is closed.

The two-argument overload IsStreamCompleted(streamType, streamId) checks the pair across event sources. Empty values map to All and Default. Include the event source id in a ClosedStreamScope when you are investigating one source’s stream.

Use GetClosedStreams to see the stored scopes and their owners. Omit the argument to list every closure in the event sequence, or pass a scope to list closures within it:

using Cratis.Chronicle.EventSequences;
using Cratis.Chronicle.Events;
public class InspectingClosedStreams(IEventLog eventLog)
{
public async Task Print(EventSourceId reportId)
{
// Everything closed for one event source. Omit the argument to list every closure.
var closedStreams = await eventLog.GetClosedStreams(ClosedStreamScope.ForEventSource(reportId));
foreach (var closed in closedStreams)
{
var owner = closed.Origin == ClosedStreamOrigin.ClosingEvent
? $"closing event constraint '{closed.ClosedBy}'"
: "manual CompleteStream";
Console.WriteLine($"{closed.Scope} closed at {closed.SequenceNumber} ({closed.ClosedAt}) by {owner}");
}
}
}

View C# snippet source on GitHub

Each ClosedStream has:

Property Meaning
Scope The closed dimensions
Origin CompleteStream for a manual closure, ClosingEvent for an event-driven one
ClosedBy The closing constraint’s name. Null for a manual closure
SequenceNumber The closing event’s sequence number, or the event-sequence tail for a manual close. EventSequenceNumber.Unavailable when no tail was recorded
ClosedAt The closing time. Null for a closure written by an earlier version

The client call is not paged, so narrow the result on a large event sequence. The filter lists closures within the supplied scope; it is not a coverage check. For example, listing closures within one event source does not include a broader closure that applies across all sources. Use IsStreamCompleted to check coverage, and inspect the full list when a filtered result does not explain a rejection.

In the Workbench, open the closed-streams page for the selected event store and namespace. Its read-only list shows closures for the event log, including their dimensions, origin, owner, sequence number and closing time. See the Workbench for access and navigation.

Manual closures have no normal client reopen call. An operator can remove an exact manual closure with the kernel’s ReopenStreamScope command on the event sequences gRPC service. This is not part of the .NET client; it requires a tool that calls the kernel contracts.

Before calling the command, record the exact scope from the closure list and the reason for the repair. The request needs an authenticated principal with a subject. Access is controlled by your authentication and network setup; the command does not require a particular role.

The repair does not narrow, widen or split a closure. Before removing the exact manual closure, the kernel appends a StreamScopeReopened event to the system event sequence. That audit event records the target event sequence, scope and reason, with the authenticated principal as its actor. If the audit append fails, the closure is not removed.

NotCompleted means no exact closure matches. ClosedByEvent means an exact closure exists but belongs to a closing constraint rather than a manual close.

After a successful repair, check IsStreamCompleted again. Removing one exact manual closure does not remove any broader manual closure or an event-driven closure that also covers the scope. If the scope is still closed, inspect the remaining owners before attempting another append.

An event-driven closure is not repaired this way. Follow Reopen with an event to append one of its ReopenedBy events.