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.
Advance Trigger
EventAuto-advances the pipeline on handoff write in autonomous mode
advance-trigger.jsBrief Validator
ValidationValidates Brief handoff completeness before pipeline advance
brief-validator.jsConstitution Guard
ValidationEnforces Constitution Article compliance at runtime
constitution-guard.jsLicense Guard
EventLicense validation with 5-minute throttle
license-guard.jsMode Governance
GuardEnforces mode-based write scope restrictions
mode-governance.jsModel Governance
ValidationModel tier enforcement per agent (deep / balanced / lightweight)
model-governance.jsPost-Dev
EventTriggers QA-Implementation auto-review on Dev completion
post-dev.jsPRISM Engine
EngineContext layer (L0–L5) injection per agent turn
prism-engine.jsRead Protection
GuardFile read access control by agent and mode
read-protection.jsReasoning Escalator
EngineArticle XXIII tier escalation between Balanced and Deep Reasoning models
reasoning-escalator.jsReference Trigger
EventCaptures visual references (screenshots, Figma URLs) during Brief
reference-trigger.jsSession Digest
EventPer-turn memory extraction, daily digest, and pre-compaction state capture
session-digest.jsStyle Guard
GuardBlocks em-dashes and emojis in generated output
style-guard.jsTeam Quality Gate
ValidationArticle XXI team mailbox protocol enforcement when team mode is active
team-quality-gate.jsUndercover Guard
GuardSanitizes framework terms from user-facing deliverables
undercover-guard.js