# Core Lifecycle and Defaults

## Lifecycle
Branch, Warehouse, Register and Device support explicit `active` / `inactive` lifecycle updates.

Guard rules:
- a branch cannot be deactivated while active warehouses, registers or devices remain
- a register cannot be deactivated while active devices are assigned
- deactivating a default warehouse/register automatically clears its default flag

## Defaults
PostgreSQL partial unique indexes enforce:
- one active default warehouse per branch
- one active default register per branch

These are database invariants, not UI conventions.

## Device assignment
A device may reference a register only when that register belongs to the same tenant and branch.

## Audit
Updates emit:
- `core.branch.updated`
- `core.warehouse.updated`
- `core.register.updated`
- `core.device.updated`
