Context Routing
Deterministic context routing avoids full-load prompts while preserving all canonical rule sources.
Machine-readable routing source:
configs/ai/context-routing.json
Load policy
Always load:
PROMPT.mdPROMPTS.md- Root Gate
- this page
- Active Rules and Gates
Baseline load for unclear or cross-cutting tasks:
/docs/core/governance/docs/core/coding-style-guide/docs/core/definition-of-done
Hierarchical instruction inheritance
Instruction loading follows a parent chain:
- root
AGENTS.md, - nearest parent-scope
AGENTS.mdfiles from top to bottom, - current scope prompt/docs resolved by routing.
Every non-root AGENTS.md must load its nearest parent AGENTS.md.
This applies to any subtree (apps/**, packages/**, tools/**, and deeper nested folders).
The rule model is path-based only: parent folder rules flow downward regardless of naming conventions.
Conditional routing table
| Trigger | Required context |
|---|---|
packages/schema/** touched | packages/schema/PROMPT.md, /docs/packages/schema, /docs/schema |
| Schema APIs or parsing/type-safety changes | /docs/schema/index, /docs/schema/schema-factory, /docs/schema/type-safety |
packages/client/** touched | packages/client/PROMPT.md, /docs/packages/client, /docs/core/generators, /docs/core/schema-doc-and-generated-jsdoc |
packages/runtime/** touched | packages/runtime/PROMPT.md, /docs/technical/runtime-design, /docs/technical/architecture, /docs/technical/event-flow, /docs/technical/roadmap |
packages/sync/**, packages/react/**, or framework adapter packages touched | /docs/packages/sync, /docs/packages/react, /docs/technical/architecture, /docs/core/coding-style-guide |
| Transport/runtime-lifecycle/server flow changes | /docs/technical/runtime-design, /docs/technical/architecture, /docs/technical/event-flow, /docs/technical/roadmap |
| Testing, mocks, branch behavior, quality review | /docs/core/testing-and-quality |
| Repo policy, contributor workflow, CI, scripts | /docs/core/contributing, /docs/core/governance |
Package/folder-specific instruction work (**/AGENTS.md, package instructions, specialization config) | /docs/ai/specializations, configs/ai/specializations.json |
| Multi-agent role council config/skills updates | configs/ai/multi-agent-council.json, /docs/ai/multi-agent-council, /docs/ai/approach-and-rationale |
| Product/repository context or historical rationale | /docs/core/project-context, /docs/core/change-history |
| Docs navigation/package catalog changes | /docs/packages/index |
Fallback behavior
If routing is ambiguous:
- start with baseline load,
- extract active rules,
- load one additional context source at a time until scope is unambiguous.
Regression and enforcement
- Routing fixtures and load budgets are validated by
pnpm check:policies. - AI routing metrics can be inspected with
pnpm metrics:ai-control. - The policy runner prints an aggregated summary after all checks complete (no fail-fast at first issue).