CHR0010: Model-bound projection event types must be from the same event store
Rule Description
Section titled “Rule Description”A model-bound projection subscribes to one event store’s event stream. Referencing event types from multiple event stores would require multiple subscriptions, which Chronicle does not support for a single projection. Ensure all event types referenced by the projection’s attributes belong to the same event store, or split into separate projections—one per event store.
Severity
Section titled “Severity”Error
Example
Section titled “Example”Violation
Section titled “Violation”using Cratis.Chronicle.Events;using Cratis.Chronicle.Projections.ModelBound;
[EventType("customer-registered")][EventStore("customers")]public record Chr0010ViolationCustomerRegistered(string Name);
[EventType("order-placed")][EventStore("orders")]public record Chr0010ViolationOrderPlaced(decimal Amount);
// Error CHR0010: Projection 'Chr0010ViolationCustomerSummary' references event types from// multiple event stores: "customers", "orders". All event types in a projection must// originate from the same event store.[FromEvent<Chr0010ViolationCustomerRegistered>]public record Chr0010ViolationCustomerSummary( string Name, [property: SetFrom<Chr0010ViolationOrderPlaced>] decimal TotalSpent);using Cratis.Chronicle.Events;using Cratis.Chronicle.Projections.ModelBound;
[EventType("customer-registered")][EventStore("customers")]public record Chr0010FixCustomerRegistered(string Name);
[EventType("customer-spent")][EventStore("customers")]public record Chr0010FixCustomerSpent(decimal Amount);
// All event types belong to the same event store: "customers".[FromEvent<Chr0010FixCustomerRegistered>]public record Chr0010FixCustomerSummary( string Name, [property: AddFrom<Chr0010FixCustomerSpent>] decimal TotalSpent);Why This Rule Exists
Section titled “Why This Rule Exists”Chronicle routes events from a single event store to each observer. A projection that declares attributes referencing events from different stores would require Chronicle to multiplex subscriptions, which the observer model does not support. This rule catches the misconfiguration at compile time instead of failing when the client connects.
Split projections that genuinely need to project events from different stores into one projection per store, each subscribing to its own event stream.
Related Rules
Section titled “Related Rules”- CHR0008: Reactor event types must be from the same event store — the same contract for reactors.
- CHR0009: Reducer event types must be from the same event store — the same contract for reducers.
- CHR0011: Declarative projection event types must be from the same event store — the same contract for fluent projections.