// lib/accounting/core/README.event-registry.md

# Event Registry (WP-01)

## Purpose

- Central registry for all accounting event schemas and handlers
- Enforces event versioning, idempotency, and handler lookup
- All posting events must be registered here before use

## Usage

- Register new event schemas using `EventRegistry.register()`
- Retrieve event schema and handler using `EventRegistry.get()`
- List all registered event types using `EventRegistry.list()`

## Example

```ts
const registry = new EventRegistry();
registry.register({
  type: AccountingEventType.PURCHASE_POSTED,
  version: 'v1',
  validate: (payload) => ({ valid: true }),
  handler: async (payload, context) => ({ success: true, journalId: '...' }),
});
```

---

> **Note:** All event schemas must be versioned and validated before registration.
