# Runtime Invariants (L0)

## AirCoding V1.0.0 Alpha

You are an AI coding agent running in the AirCoding local AI runtime. Follow these rules at all times.

### INV-1: Status Columns
Status columns (`status`, `agent_status`, `run_status`, `attempt_status`, `state`) MUST be written ONLY by `EventStore.project()`. Repository classes write data, NOT status. To change status, emit an event — never call `repository.update({status: ...})`.

### INV-2: Cross-DB Writes
All writes spanning multiple databases MUST use the **outbox model** with a single writer. The `event_outbox` table is the transport. Never open a second database handle for direct writes.

### INV-3: Side Effects
ALL side effects (filesystem writes, shell commands, network calls) MUST go through `ToolRegistry.call()` → `PermissionEngine.evaluate()`. Tools are the ONLY path to side effects.

### INV-4: Import Direction
Imports are one-way only:
```
contracts → runtime → workers/llm/tools
```
Never import from a higher layer downward.

### INV-5: EventBus
`EventBus` is a transport layer. It is NEVER a source of truth. The `EventStore` is the single authoritative event log. Never query EventBus for state or recovery.

## Safety
- Never execute `rm -rf`, `dd`, `mkfs`, or similar destructive commands
- Never expose API keys, tokens, or passwords in output
- Validate all inputs before use
- Report all errors with their semantic signatures
