---
title: Code analysis
description: Build-time diagnostics for Arc's optional Chronicle integration, including their heuristics and boundaries.
---


These `ARCCHR####` Roslyn diagnostics belong to **Arc's Chronicle integration**, not to standalone Arc or every project that references pure Chronicle. They catch integration mistakes while you build, so a misplaced key, ambiguous identity, or unsupported handler shape is visible before a request reaches production.

## Rules overview

| Rule | Severity | What it checks |
| --- | --- | --- |
| [ARCCHR0001](/arc/backend/csharp/chronicle/code-analysis/arcchr0001/) | Error | Recognized aggregate event-handler candidates have supported signatures. |
| [ARCCHR0002](#arcchr0002-ambiguous-command-identity) | Warning | Multiple candidate command identities without an explicit provider/recognized return exemption. |
| [ARCCHR0003](/arc/backend/csharp/chronicle/code-analysis/arcchr0003/) | Warning | Reactor access to the default event log instead of returned side effects. |
| [ARCCHR0004](/arc/backend/csharp/chronicle/code-analysis/arcchr0004/) | Warning | Explicit id supplied to `[EventType]`. |
| [ARCCHR0005](/arc/backend/csharp/chronicle/code-analysis/arcchr0005/) | Warning | Chronicle usage and `AddCratisArc` appear in one project without integration setup. |
| [ARCCHR0006](/arc/backend/csharp/chronicle/code-analysis/arcchr0006/) | Warning | Manual reactor command execution without method- or class-level `[OnceOnly]`. |
| [ARCCHR0007](#arcchr0007-command-handler-injects-ieventlog) | Warning | A command `Handle()` or `Provide()` parameter is `IEventLog` or an implementing type. |
| [ARCCHR0008](/arc/backend/csharp/chronicle/code-analysis/arcchr0008/) | Warning | Data annotations `[Key]` used where Chronicle key resolution applies. |
| [ARCCHR0009](/arc/backend/csharp/chronicle/code-analysis/arcchr0009/) | Warning | Likely secret command values lack audit exclusion metadata. |
| [ARCCHR0010](/arc/backend/csharp/chronicle/code-analysis/arcchr0010/) | Warning | A keyless command returns a raw Guid beside statically identifiable untargeted events. |

## ARCCHR0002: ambiguous command identity

Use one identity candidate or implement `ICanProvideEventSourceId`. Positional Chronicle `[Key]` and the matching property count as one candidate. Recognized explicit identity/wrapper return signatures can exempt the command.

This analyzer's candidate convention includes implicit conversions; runtime discovery does not generally do so. A conversion-only `ConceptAs<Guid>` is not a safe runtime identity declaration. Use `EventSourceId<Guid>` ancestry or a selected key. Neither a clean analyzer result nor a return exemption proves that input-time aggregate/read-model dependencies use your intended id. See [identity timing](/arc/backend/csharp/chronicle/resolving-event-source-id/).

## ARCCHR0007: command handler injects IEventLog

Prefer [returned events](/arc/backend/csharp/chronicle/commands/events/). This rule matches `IEventLog` (and implementing-type) parameters on `Handle()` and `Provide()`, including read-only use; it does not inspect whether they append. Deliberate exact-revision reads or advanced explicit transactional appends may warrant a narrow suppression. The API remains supported at runtime, with the boundaries in [Transactional commands](/arc/backend/csharp/chronicle/commands/transactional-commands/). A warning is not a runtime prohibition.

## Quick fixes

| Rule | Fix |
| --- | --- |
| [ARCCHR0008](/arc/backend/csharp/chronicle/code-analysis/arcchr0008/) | Rewrite to the fully qualified Chronicle Key attribute. |
| [ARCCHR0010](/arc/backend/csharp/chronicle/code-analysis/arcchr0010/#quick-fix) | Compiler-checked local replacement with `EventSourceId<Guid>` for supported direct tuple syntax. |

The other rules have no automatic fix. A fix can change behavior: in particular ARCCHR0010 changes the persistence target when the Guid was an ordinary response.

## Installation

Install the optional Arc integration package:

```bash
dotnet add package Cratis.Arc.Chronicle
```

It brings in `Cratis.Arc.Chronicle.CodeAnalysis`, which supplies these analyzers and code fixes. Complete the [integration setup](/arc/backend/csharp/chronicle/cratis-package/) to connect Arc's command pipeline to Chronicle.

Pure `Cratis.Chronicle` provides event sourcing without Arc; referencing it alone does not install Arc's integration diagnostics. If a diagnostic is missing, check that your application's resolved dependencies include `Cratis.Arc.Chronicle.CodeAnalysis`.
