---
paths:
  - "context/**"
---

# Context Meta-Rules

Cross-file conventions. See the dedicated rule for each file type in the same directory (status-md.md / issues-md.md / mission-md.md / roadmap-md.md / overview-md.md / task-system.md / experiment-format.md / decision-records.md).

## General Rules

- **All context updates are auto-committed via git**: Incremental commits, each logical unit (experiment configuration, analysis report, status update) is committed upon completion, do not accumulate until the end of the session.
- **Value traceability**: Every value appearing in STATUS / EXP / K / reports must be traceable — specify the script + data file that produced it, or write inline arithmetic citing the data. Numbers without sources are invalid.
- **Update index after creating new files**: After creating a new file in any directory, update that directory's CORTEX.md index.
- **Decision traceability**: Each DR-NNNN within a project adds an inline reference in the project's CORTEX.md; system-level DRs are referenced in `context/CORTEX.md`.

## Index Files

`experiments/index.md`, `knowledge/index.md`, `patterns/index.md` are auto-generated by `memory-index-regen.ts` from frontmatter. **Do not manually edit**. Rebuild:

```bash
cd agent-server && node --import tsx src/memory-index-regen.ts --all
cd agent-server && node --import tsx src/memory-index-regen.ts <project>
```

## Hook Auto-Tracking

PostToolUse hook automatically records Read/Grep access to atomic files (EXP/K/PAT) in `_meta/access-log.jsonl`, computing refs and last-ref during index rebuild.

## File Type Quick Reference

| File | Dedicated rule | Update mode |
|------|----------------|-------------|
| `STATUS.md` | status-md.md | Overwrite, hard limit 120 lines |
| `ISSUES.md` | issues-md.md | Append, resolved entries deleted directly, hard limit 80 lines |
| `mission.md` | mission-md.md | Modify after user confirmation |
| `roadmap.md` | roadmap-md.md | Stable, milestones must contain testable checklist |
| `OVERVIEW.md` | overview-md.md | Synchronous update, hard limit 60 lines |
| `TASKS.yaml` | task-system.md | Read/write via cortex-task CLI, do not manually edit |
| `experiments/EXP-NNN.md` | experiment-format.md | Atomic file + frontmatter |
| `knowledge/K-NNN.md` | experiment-format.md | Atomic file + evidence field |
| `patterns/PAT-NNN.md` | experiment-format.md | Atomic file + source-experiments |
| `decisions/DR-NNNN.md` | decision-records.md | Append, keep old file when superseded |
| `_meta/access-log.jsonl` | — | Auto-written by hook |
| `*/index.md` | — | Auto-generated by memory-index-regen |
