| name | ari-layer-guardian |
| description | Enforce ARI's six-layer architecture and prevent dependency violations |
| triggers | ["check layer violations","validate architecture","import check","layer compliance"] |
ARI Layer Guardian
Purpose
Enforce ARI's strict six-layer architecture (ADR-004) and prevent dependency violations that could compromise security.
Layer Hierarchy
6. Interfaces (CLI) → Can import: 5, 1
↓
5. Execution (Ops) → Can import: 4, 1
↓
4. Strategic (Governance) → Can import: 3, 1
↓
3. Core (Agents) → Can import: 2, 1
↓
2. System (Router) → Can import: 1
↓
1. Kernel (Security) → Can import: NOTHING (self-contained)
Rules
- Lower layers CANNOT import from higher layers
- All layers CAN import from Kernel (types, config, event bus)
- All layers communicate via EventBus (no direct cross-layer calls)
- Kernel is self-contained (no imports from other layers)
Directory Mapping
| Layer | Directory | Components |
|---|
| 6 | src/cli/ | Commands, CLI interface |
| 5 | src/ops/ | Daemon, launchd |
| 4 | src/governance/ | Council, Arbiter, Overseer |
| 3 | src/agents/ | Core, Guardian, Planner, Executor, Memory |
| 2 | src/system/ | Router, Storage |
| 1 | src/kernel/ | Gateway, Sanitizer, Audit, EventBus, Config, Types |
Violation Detection
Check Command
grep -r "from '\.\./governance" src/agents/
grep -r "from '\.\./agents" src/system/
grep -r "from '\.\./system" src/kernel/
Valid Imports
import { EventBus } from '../kernel/event-bus.js';
import type { Message } from '../kernel/types.js';
import { Guardian } from '../agents/guardian.js';
Invalid Imports (VIOLATIONS)
import { Router } from '../system/router.js';
import { Council } from '../governance/council.js';
import { Executor } from '../agents/executor.js';
Why This Matters
Layer violations can:
- Create circular dependencies
- Bypass security boundaries
- Break audit trail integrity
- Allow privilege escalation
- Make testing impossible
Workflow
When reviewing or writing code:
- Identify the current layer from file path
- Check all imports against allowed dependencies
- Flag any violations immediately
- Suggest EventBus for cross-layer communication
EventBus Pattern
Instead of direct imports, use EventBus:
Integration with CI
Add ESLint rule to enforce:
{
"rules": {
"no-restricted-imports": ["error", {
"patterns": [
{ "from": "../system/*", "importNames": ["*"], "message": "Kernel cannot import from System" }
]
}]
}
}