PRISM Context Engine
6-layer context assembly that stacks information from Constitution (L0) to Keyword-level (L5), giving each agent exactly the knowledge it needs. Budgets scale with the provider's context window and increase as memory degrades.
The AI Forgets Everything
LLMs have a fixed context window. In long sessions, critical decisions made early get pushed out of memory. The agent that built your auth system has no idea what conventions were established. Every new agent starts from scratch, repeating mistakes and contradicting earlier decisions.
Context Assembly Flow
When an agent activates, the PRISM engine hook reads the current Context Bracket, determines which layers to load, and assembles the complete prompt.
How PRISM Works
Layer Resolution
The prism-engine.js hook reads agent definitions, workflow context, and keyword rules from chati.dev/. Each layer maps to a specific source: constitution.md for L0, global rules for L1, agent .md files for L2, and so on.
Bracket Filtering
Progressive Reinforcement: FRESH injects only L0-L1 (Constitution + Global) since the LLM still has full memory and does not need reinforcement. As context degrades, more layers are injected to compensate. MODERATE adds Agent and Workflow context (L0-L3). DEPLETED injects all 6 layers (L0-L5) to fight memory loss. CRITICAL also injects all 6 layers and forces a handoff or session spawn to prevent quality degradation.
Context Injection
The prism-engine.js hook intercepts agent activation, assembles filtered layers into a single context block, and injects it into the system prompt before the agent starts work.
Context Bracket Degradation
As tokens get consumed, the bracket degrades automatically. Token-based estimation (prompt length / 4) determines the bracket. FRESH needs minimal injection (LLM remembers). As brackets degrade, more layers are reinforced to compensate for memory loss. CRITICAL triggers maximum reinforcement plus forced handoff.
Priority Resolution
When rules conflict across layers, lower-numbered layers win. Constitution (L0) overrides everything, so governance is never accidentally bypassed by task-level context. Resolution is deterministic, enforced by the PRISM engine at assembly time.
Adaptive Governance
Traditional systems just cut context when memory runs low. PRISM does the opposite: as the bracket degrades, the system injects more governance rules to compensate. Weaker memory, stronger reinforcement.
Adapts automatically across providers (Claude, Gemini, Codex), scaling proportionally to each provider's context window.
Prompt Cache Optimization
PRISM splits the assembled prompt into a static prefix (L0 Constitution + L1 Global rules) and a dynamic suffix (L2-L5, changes per turn). The static prefix is marked with a boundary separator, enabling prompt cache reuse across turns within the same governance mode. Cache is invalidated on mode transitions (planning to build to deploy).
Governance Hooks
Runtime hooks that enforce constitution compliance, mode restrictions, and context injection.
Constitution Guard
ValidationEnforces Constitution Article compliance at runtime
constitution-guard.jsMode Governance
GuardEnforces mode-based write scope restrictions
mode-governance.jsModel Governance
ValidationModel tier enforcement per agent
model-governance.jsPRISM Engine
EngineContext injection and layer management
prism-engine.jsRead Protection
GuardFile read access control enforcement
read-protection.jsSession Digest
EventPer-turn memory extraction, daily digest, and pre-compaction state capture
session-digest.jsUndercover Guard
GuardSanitizes framework terms from deliverables
undercover-guard.jsStyle Guard
GuardBlocks em-dashes and emojis in output
style-guard.jsLicense Guard
EventLicense validation with 5-minute throttle
license-guard.jsRate Limiter
GuardHandles API rate limits and model fallback on 529 errors
rate-limiter.js