## Context BooCode has no structured behavioral enforcement. Agent behavior is guided by system prompts and CLAUDE.md — advisory, not enforceable. The `boocontext-audit` package (already TypeScript, already in /opt/forks) provides a complete behavioral compliance engine: Guideline model, 6-batch matcher, relational resolver, audit trail, and graded recovery. ## Goals / Non-Goals **Goals:** - Import boocontext-audit's Guideline model (condition/action rules with criticality) - Import multi-batch matcher (Observational, Actionable, PreviouslyApplied, Disambiguation, ResponseAnalysis, LowCriticality) - Import RelationalResolver (DEPENDS_ON, PRIORITIZES, ENTAILS, TAG_ALL, TAG_PRIORITIZES) - Import audit middleware (PostToolUse, Stop, UserPromptSubmit hooks) - Import graded context recovery (L0-L4) - Wire guideline evaluation into agent's inference loop **Non-Goals:** - Journey DAG integration (future scope) - MCP middleware integration (focus on in-process hooks) ## Decisions - **Direct import from local fork**: boocontext-audit is at `/opt/forks/boocontext-audit/`. Use workspace dependency or npm link. - **Guideline storage**: InMemoryGuidelineStore for development, FileRelationshipStore for production. - **Batch execution**: Run observable + actionable batches in parallel, then disambiguation, then response analysis. - **SchematicGenerator**: Abstract LLM caller. Configure per-batch model (use cheap model for matching, expensive for disambiguation). - **Audit hooks**: Wire PostToolUse → appendToBuffer(), Stop → flushBuffer(), UserPromptSubmit → injectSessionContext(). - **Recovery**: Load L0 (index) by default. L2 (user corrections) on /recover. L3 (full) on /recover full. ## Risks / Trade-offs - **LLM overhead**: Each batch is an LLM call. 6 batches × N guidelines could be expensive. Mitigation: batch size limits, parallel execution. - **Cold start**: No guidelines exist initially. Users must define them. Ship with 5-10 built-in safety guidelines. - **boocontext-audit maturity**: v0.1.0. Review code quality before direct import.