# LS1013: Domain Event Sits Outside the Events Folder

## Intent

LS1013 is a compiler check that reports a domain event, a record of a completed business fact, declared outside its aggregate's Events folder, where the model builder looks for events, so the event would exist in code with no record naming it. This page states what the rule reports, where the error sits, and how to move the event into the Events folder.

## Reference

### What the Rule Enforces

LS1013 enforces [Organize a module by aggregate and concept](https://litespec.dev/2.0.0/backend/domain.md#organize-a-module-by-aggregate-and-concept) (`litespec/backend/domain#organize-a-module-by-aggregate-and-concept`). It runs in Domain only. Its category is `LiteSpec.Domain`. It reports an error and is enabled by default, as the [Analyzers overview](https://litespec.dev/2.0.0/analyzers/README.md) describes.

### What the Rule Reports

The rule reports any type that implements an interface named `IDomainEvent` unless its file sits under a folder named `Events`. The diagnostic sits on the type name, and its message names the file the event lives in.

### Failing Example

```csharp
// Posts/OrderPlacedEvent.cs
public sealed record OrderPlacedEvent(OrderId OrderId) : IDomainEvent;
```

### Passing Example

```csharp
// Posts/Events/OrderPlacedEvent.cs
public sealed record OrderPlacedEvent(OrderId OrderId) : IDomainEvent;
```

### How to Fix

Move the event into the `Events` folder of the aggregate it belongs to, keeping its `{Aggregate}{PastFact}Event` name.

## Notes

### What the Rule Ignores

The rule does not report interfaces that merely extend `IDomainEvent`, or types that implement no such interface. It accepts any folder depth as long as one folder segment is named `Events`. It does not run outside Domain.
