Context Rules — Agent Routing & Context Loading
This rule governs how the agent loads and prioritizes context within the workspace. It defines the loading order, project isolation boundaries, beads lifecycle, and the Two-Tier Progressive Disclosure mechanism for rules.
1. Context Loading Priority
MUST load context in this sequence (highest priority first):
- Project Contract —
Projects/<project>/project.md - Project Rules —
Projects/<project>/.agent/rules/ - Workspace Rules —
.agent/rules/ - Artifacts —
Projects/<project>/artifacts/ - Active Memory —
Projects/<project>/.beads/ - Abstract Knowledge —
Areas/ - Reference —
Resources/
2. Isolation & Relevance
- MUST search active project folder first.
- MUST NOT read from
Archive/unless user requests historical data. - MUST NOT scan other projects unless working on integration.
- SHOULD prefer
.beads/over general docs for recurring issues.
3. Beads Lifecycle
Beads capture project-specific decisions, failures, and quirks in Projects/<project>/.beads/. They are allowed to be messy and partial during active development.
MUST perform “Graduation Review” before archiving — move valuable knowledge to Areas/, Resources/, or .agent/rules/.
4. Rules Loading — Two-Tier Progressive Disclosure
Tier 1 (ALWAYS): Read .agent/rules.md (~20 lines, ~200 tokens). Memorize the trigger table, load rule files on demand.
Tier 2 (CONDITIONAL): Check Projects/<project>/.agent/rules.md. If exists, read index and load rules when triggers match. If missing, skip.
Standard Index Format
| Rule | Trigger | File | Pri |
| :-------- | :--------------------- | :---------- | :-- |
| Rule Name | When to load this rule | filename.md | 🔴 |
File Guards Format
Optional extension of agent-behavior.md §4:
## File Guards
| File pattern | MUST re-read | Reason |
| :------------- | :----------- | :-------------------- |
| `path/to/file` | rule-name.md | Why this guard exists |
References
- Rule Layers & Trigger Index — Architecture overview
- Defense-in-Depth: Context Recovery — 4-layer protection
- Agent Behavior — Context Recovery protocol