Skip to content

ARCCHR0005: Chronicle is used but not wired up

Running Arc without Chronicle is a valid, supported setup — AddCratisArc on its own backs commands and queries with MongoDB or EF Core and never needs an event store. So a missing WithChronicle() is only a problem when the project actually uses Chronicle. This rule fires when a project calls AddCratisArc (without WithChronicle() or AddCratis()) yet does one of the following in the same project:

  • declares an aggregate root;
  • declares a reactor or a reducer;
  • declares a projection — fluent (IProjectionFor<>) or model-bound (a read model with [FromEvent<T>], [SetFrom<T>], [SetValue<T>], or any other Cratis.Chronicle.Projections attribute);
  • declares an [EventType] event;
  • injects a Chronicle service such as IEventLog or IEventStore (appending events, returning events from a command handler, reading the event store).

Detection is by namespace: implementing any interface, or applying any attribute (on the type or its properties), from the Cratis.Chronicle namespace counts as Chronicle usage — so new Chronicle features are covered automatically.

In any of those cases the event store is required, so a command, query, reactor, or reducer that touches Chronicle fails to resolve at runtime.

The rule only reports when the setup call and the Chronicle usage live in the same project. When Arc is set up in a separate host project, it stays silent — and when the project genuinely doesn’t use Chronicle, it never fires.

Warning

using Cratis.Chronicle.Events;
var builder = WebApplication.CreateBuilder(args);
// ARCCHR0005: Chronicle artifacts exist, but Chronicle is never wired up
builder.AddCratisArc();
var app = builder.Build();
app.UseCratisArc();
app.Run();
[EventType]
public record AuthorRegistered(string Name);

This is a host fragment with a deliberate ARCCHR0005 diagnostic. Supply the ASP.NET/Arc extension imports and packages; the type declaration follows all top-level statements.

For this ASP.NET Core host, reference the Cratis package (dotnet add package Cratis). Cratis.Arc.Chronicle alone supplies the generic-host integration, not all the ASP.NET Core extensions used here. Add the Chronicle client with the explicitly qualified ASP.NET Core WithChronicle() overload; this avoids ambiguity when both Cratis.Arc and Microsoft.AspNetCore.Builder are imported:

builder.AddCratisArc(configureBuilder: arc =>
Microsoft.AspNetCore.Builder.ArcBuilderExtensions.WithChronicle(arc));
var app = builder.Build();
app.UseCratisArc();
app.UseCratisChronicle();
app.Run();

Or use the all-in-one AddCratis(), which wires Arc, the Chronicle client, and identity together. Its header-based identity adapter requires trusted authenticated ingress:

builder.AddCratis();
var app = builder.Build();
app.UseCratis();
app.Run();

AddCratisArc deliberately supports running Arc without an event store, backed by MongoDB or EF Core. That flexibility means the framework cannot assume Chronicle is wanted — so forgetting WithChronicle() is a silent mistake that only surfaces the first time an event is appended or read. This rule catches it at compile time, before the application runs.

  • None