{%- set docs = documentation if documentation else {} -%}
{%- set key_files = docs.get('key_files', []) -%}
{%- set context_file = docs.get('context_file', 'docs/CONTEXT.md') -%}
{%- set decisions_file = docs.get('decisions_file', 'docs/DECISIONS.md') -%}
{%- set changelog_file = docs.get('changelog_file', 'docs/CHANGELOG.md') -%}
# IX. Context Management

## 9.1 Key File Responsibilities

| File | Purpose | Update Trigger |
|------|---------|----------------|
{% for f in key_files -%}
| `{{ f.get('path', '') }}` | {{ f.get('purpose', '') }} | {{ f.get('update_trigger', '') }} |
{% endfor %}
## 9.2 Context Restoration Protocol

When starting a new dialogue, the AI should:
1. Read `CONTRIBUTING_AI.md` to understand collaboration rules
2. Read `{{ context_file }}` to restore current state
3. Read `{{ decisions_file }}` to review confirmed and pending decisions
4. Run `git log --oneline -10` to review recent progress
5. Ask the user about the goal of this dialogue

## 9.3 Context Save Protocol

At the end of each dialogue, the AI should:
1. Update `{{ context_file }}` to save current state
2. Update `{{ changelog_file }}` to record outputs from this session
3. If new decisions were made, update `{{ decisions_file }}`
4. **Must execute git commit** to record this dialogue's outputs

---
