Repository navigation
Kagemusha Protocol v1.0.0
Kagemusha Protocol v1.0.0
The shadow warrior that guards the gate.
Background
While the v12 Aurora specification was being finalized, implementation began on a parallel track: the Kagemusha Protocol — a security-first kernel that would serve as the foundation for the full system.
Kagemusha focused on one critical insight: security cannot be bolted on later. The kernel must be hardened from the first line of code.
What Kagemusha Delivers
Hardened Gateway
const HOST = '127.0.0.1' as const; // Hardcoded, not configurableThe gateway literally cannot bind to external interfaces. This is enforced at the code level, not configuration.
- Loopback-Only: 127.0.0.1 is hardcoded, not configurable
- Port Configurable: Default 3141, adjustable
- Fastify Backend: Modern, performant HTTP server
SHA-256 Hash-Chained Audit
Every audit event is cryptographically linked to the previous one:
Genesis Block (hash: 0x00...00)
↓
Event 1 (hash = SHA256(previous + event1))
↓
Event 2 (hash = SHA256(previous + event2))
↓
...
Tampering with any event breaks the chain and is immediately detectable.
21-Pattern Injection Detection
The sanitizer detects 21 injection patterns across 6 categories:
| Category | Patterns | Examples |
|---|---|---|
| Direct Override | 5 | "ignore previous", "new instructions" |
| Role Manipulation | 4 | "you are now", "act as" |
| Command Injection | 4 | eval(), exec(), shell commands |
| Prompt Extraction | 3 | "reveal system prompt" |
| Authority Claims | 3 | "I am the developer" |
| Data Exfiltration | 2 | "send to external" |
EventBus Architecture
All inter-layer communication flows through typed events:
// No direct function calls between layers
eventBus.emit('message:accepted', message);
eventBus.on('security:alert', handleAlert);This ensures testability, traceability, and loose coupling.
Configuration
Zod-validated configuration with type safety:
const ConfigSchema = z.object({
gateway: z.object({
port: z.number().default(3141),
host: z.literal('127.0.0.1'), // Cannot be changed
}),
// ...
});Security Principles Enforced
- Content ≠ Command — All inbound messages are data, never instructions
- Loopback-Only — Gateway binding hardcoded, cannot be overridden
- Hash Chain Integrity — Append-only audit log with cryptographic verification
- Trust Levels — SYSTEM, OPERATOR, VERIFIED, STANDARD, UNTRUSTED, HOSTILE
Why "Kagemusha"
影武者 (Kagemusha) — "Shadow Warrior" — a decoy or body double who protects the true lord. The kernel serves this role: it stands between the outside world and the system, detecting threats and protecting integrity.
Protocol: Kagemusha (影武者) — The shadow warrior
"The shadow warrior that guards the gate."