Skip to content
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
c035da0
docs: add autonomous PR monitoring prompt
rjmurillo-bot Dec 23, 2025
edfa094
docs: Enhance autonomous PR monitoring prompt details
rjmurillo Dec 23, 2025
3d97d40
docs(retrospective): autonomous PR monitoring session analysis
rjmurillo-bot Dec 23, 2025
de71c58
Merge remote-tracking branch 'origin/docs/autonomous-monitoring-promp…
rjmurillo-bot Dec 23, 2025
19ce786
docs: enhance autonomous monitoring prompt with Session 80 insights
rjmurillo-bot Dec 23, 2025
77a38bb
fix(protocol): complete Session End checklist MUST requirements
rjmurillo-bot Dec 23, 2025
ef6e3ea
docs(retrospective): add Cycle 8 analysis to autonomous PR monitoring…
rjmurillo-bot Dec 23, 2025
1f17889
docs(retrospective): mark Session 80 checklist complete
rjmurillo-bot Dec 23, 2025
1791fd9
docs: PR #255 Copilot security comment response
rjmurillo-bot Dec 23, 2025
e4b790f
docs: Update session log with final commit SHA
rjmurillo-bot Dec 23, 2025
6a4cffe
docs: Add Session 81 to HANDOFF.md recent sessions
rjmurillo-bot Dec 23, 2025
e4c415b
docs: Session 81 complete - add all commits to log
rjmurillo-bot Dec 23, 2025
ed445e1
retrospective: Add Iteration 5 checkpoint analysis
rjmurillo-bot Dec 23, 2025
d248cbe
docs: Add session log for PR #235 review response
rjmurillo-bot Dec 23, 2025
e9eada1
fix: Revert HANDOFF.md changes to comply with ADR-014
rjmurillo-bot Dec 23, 2025
1d9aa5c
docs: Add rate limit management for sustainable infinite monitoring
rjmurillo-bot Dec 23, 2025
3bc954a
docs: Implement self-reflection improvements for prompt sustainability
rjmurillo-bot Dec 23, 2025
df8beb2
docs: Add Skill-Documentation-007 for self-contained artifacts
rjmurillo-bot Dec 23, 2025
7e505d9
docs: Extend Skill-Documentation-007 to GitHub workflows
rjmurillo-bot Dec 23, 2025
12a9169
chore(memory): consolidate duplicates and create index (#307)
rjmurillo-bot Dec 23, 2025
c445516
chore: update issue tracker with PR #308 reference
rjmurillo-bot Dec 23, 2025
3347546
chore(memory): consolidate 4 more skill groups (#307)
rjmurillo-bot Dec 23, 2025
d97e326
chore: update issue tracker with consolidation progress
rjmurillo-bot Dec 23, 2025
7799e9b
chore: update memory-index with consolidation log
rjmurillo-bot Dec 23, 2025
9cac1f5
chore(memory): consolidate retrospectives by date (6→2)
rjmurillo-bot Dec 23, 2025
d2fdc8c
chore(memory): consolidate git-hook patterns (4→1)
rjmurillo-bot Dec 23, 2025
62f7634
chore(memory): consolidate coderabbit memories (3→1)
rjmurillo-bot Dec 23, 2025
63bcfb5
chore(memory): consolidate copilot memories (3→1)
rjmurillo-bot Dec 23, 2025
9e9744b
feat(memory): pilot tiered index architecture for Copilot domain
rjmurillo-bot Dec 23, 2025
bd1a6d5
refactor(memory): streamline skills-copilot-index
rjmurillo-bot Dec 23, 2025
384c170
refactor(memory): minimize skills-copilot-index to pure utility
rjmurillo-bot Dec 23, 2025
e96a2e3
refactor(memory): minimize copilot atomic files
rjmurillo-bot Dec 23, 2025
509cfab
docs(architecture): add ADR-017 tiered memory index architecture
rjmurillo-bot Dec 23, 2025
6ad6fd3
docs(critique): review ADR-017 tiered memory index architecture
rjmurillo-bot Dec 23, 2025
873f21d
docs(analysis): quantitative verification of ADR-017 tiered memory ar…
rjmurillo-bot Dec 23, 2025
9b45743
docs(session): update session 83 with commit SHA
rjmurillo-bot Dec 23, 2025
5c88ebe
docs(session): add canonical session end checklist
rjmurillo-bot Dec 23, 2025
27835cf
docs(session): update commit SHA to final
rjmurillo-bot Dec 23, 2025
fa18d26
docs(session): mark QA as skipped for analysis task
rjmurillo-bot Dec 23, 2025
1dfbc2a
docs(session): add starting commit for validation
rjmurillo-bot Dec 23, 2025
d43d923
docs(session): use correct QA skip format
rjmurillo-bot Dec 23, 2025
e964834
docs(handoff): add session 83 to recent sessions table
rjmurillo-bot Dec 23, 2025
8c00b30
docs(session): use required commit SHA format
rjmurillo-bot Dec 23, 2025
dbc1b1b
refactor(memory): apply activation vocabulary to memory-index
rjmurillo-bot Dec 23, 2025
baaab22
docs(architecture): refine ADR-017 per 5-agent review
rjmurillo-bot Dec 23, 2025
addbced
feat(memory): add Validate-MemoryIndex.ps1 for ADR-017 Phase 2
rjmurillo-bot Dec 24, 2025
625ff69
feat(memory): add project labels and milestones memory
rjmurillo-bot Dec 24, 2025
e7e0dc1
feat(memory): migrate CodeRabbit to tiered index (Phase 3)
rjmurillo-bot Dec 24, 2025
662115b
feat(hooks): add memory index validation to pre-commit
rjmurillo-bot Dec 24, 2025
f2aac0d
feat(memory): migrate PowerShell domain to tiered architecture
rjmurillo-bot Dec 24, 2025
56faa0e
feat(memory): migrate GitHub CLI domain to tiered architecture
rjmurillo-bot Dec 24, 2025
dd8443e
feat(memory): migrate Security domain to tiered architecture
rjmurillo-bot Dec 24, 2025
1543667
feat(memory): migrate CI Infrastructure domain to tiered architecture
rjmurillo-bot Dec 24, 2025
9dfe38e
feat(memory): migrate GitHub Extensions domain to tiered architecture
rjmurillo-bot Dec 24, 2025
126b1c2
feat(memory): migrate Gemini Code Assist domain to tiered architecture
rjmurillo-bot Dec 24, 2025
fbdc658
feat(memory): migrate jq JSON Parsing domain to tiered architecture
rjmurillo-bot Dec 24, 2025
89d7be5
feat(memory): migrate Validation domain to tiered architecture
rjmurillo-bot Dec 24, 2025
0cfa8c6
feat(memory): migrate PR Review domain to tiered architecture
rjmurillo-bot Dec 24, 2025
7a1cc7f
feat(memory): migrate Session Init and Implementation domains to tier…
rjmurillo-bot Dec 24, 2025
acf6f46
feat(memory): migrate Documentation and Planning domains to tiered ar…
rjmurillo-bot Dec 24, 2025
7dfd767
feat(memory): migrate Bash Integration and Pester Testing domains to …
rjmurillo-bot Dec 24, 2025
9846829
feat(memory): migrate Labeler and Analysis domains to tiered index
rjmurillo-bot Dec 24, 2025
1d34c10
feat(memory): migrate Architecture, Design, GraphQL, Orchestration do…
rjmurillo-bot Dec 24, 2025
725a5d6
feat(memory): migrate Git Hooks, Workflow Patterns, Linting, Protocol…
rjmurillo-bot Dec 24, 2025
d229124
feat(memory): migrate Quality, Agent Workflow, Utilities domains
rjmurillo-bot Dec 24, 2025
893dcfd
feat(memory): add standalone atomic files to memory-index routing
rjmurillo-bot Dec 24, 2025
441e1c1
docs(agents): update memory and skillbook agents for ADR-017
rjmurillo-bot Dec 24, 2025
8aa1b24
docs(agents): update shared templates for ADR-017 tiered memory
rjmurillo-bot Dec 24, 2025
5c197c9
docs(skillbook): add canonical skill formats and naming conventions
rjmurillo-bot Dec 24, 2025
dfc323a
docs(skillbook): convert format decision tree to Mermaid diagram
rjmurillo-bot Dec 24, 2025
66f4028
docs(skillbook): complete skill creation procedures for amnesiac agents
rjmurillo-bot Dec 24, 2025
1d983cc
docs(agents): fix critic-identified gaps in memory and skillbook agents
rjmurillo-bot Dec 24, 2025
136c847
docs(agents): fix critic-identified gaps in memory and skillbook agents
rjmurillo-bot Dec 24, 2025
3e80b76
fix(memory): add missing header metadata to index files
rjmurillo-bot Dec 24, 2025
6f0dbf9
docs(session): session 84 - PR #308 review comment responses
rjmurillo-bot Dec 24, 2025
ed8245a
fix: revert HANDOFF.md changes per read-only protocol
rjmurillo-bot Dec 24, 2025
7c666a8
fix(commands): use GraphQL for reviewThreads in pr-review command
rjmurillo-bot Dec 24, 2025
e6dd797
docs(session): complete session 84 - critical HANDOFF.md fix documented
rjmurillo-bot Dec 24, 2025
6028d67
feat(memory): add cache-aside pattern for GitHub data and ADR reference
rjmurillo-bot Dec 24, 2025
0884855
fix(memory): enforce lean index format, remove ephemeral cache files
rjmurillo-bot Dec 24, 2025
c40f6a4
docs(adr): add ADR-018 cache invalidation strategy
rjmurillo-bot Dec 24, 2025
ec4894d
docs(memory): add Copilot supported models reference skill
rjmurillo-bot Dec 24, 2025
a8edfeb
fix(memory): address PR 308 review comments
rjmurillo-bot Dec 24, 2025
712bdae
refactor(skillbook): enforce ONE skill format, remove bundled option
rjmurillo-bot Dec 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
458 changes: 458 additions & 0 deletions .agents/analysis/083-adr-017-quantitative-verification.md

Large diffs are not rendered by default.

322 changes: 322 additions & 0 deletions .agents/architecture/ADR-017-tiered-memory-index-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
# ADR-017: Tiered Memory Index Architecture

**Status**: Accepted
**Date**: 2025-12-23
**Deciders**: User, Claude Opus 4.5
**Consulted**: 5-agent review (Critic, Architect, Analyst, Security, Independent-Thinker)
**Context**: Issue #307 Memory Automation, PR #308

---

## Context and Problem Statement

The Serena memory system stores learned skills and patterns in `.serena/memories/`. As of 2025-12-23:

- **115 memory files** before optimization
- **~7 new skills per day** growth rate
- **O(n) discovery**: Agents call `list_memories` (100+ names), then `read_memory` multiple times

Two competing optimization strategies emerged:

1. **Consolidation**: Merge related memories into fewer, larger files (reduce `list_memories` cost)
2. **Atomicity**: Keep small, focused files (reduce per-read waste)

**Key Question**: How do we minimize total tokens loaded while maximizing retrieval precision?

---

## Decision Drivers

1. **Token Efficiency**: LLM context windows are finite and expensive
2. **Retrieval Precision**: Load only what's needed for the current task
3. **Activation Vocabulary**: LLMs match on keyword associations, not symbolic lookup
4. **No Embeddings**: Serena MCP uses lexical matching, not semantic search
5. **Scalability**: Must work at 500+ memories without degradation

---

## Considered Options

### Option 1: Flat Consolidation

**Merge all related memories into domain files (e.g., `skills-copilot`)**

| Metric | Value |
|--------|-------|
| `list_memories` cost | Low (~15 files) |
| Per-read cost | High (load all skills in domain) |
| Waste when needing 1 skill | ~67% tokens wasted |

### Option 2: Pure Atomic Files

**Keep every skill in its own file**

| Metric | Value |
|--------|-------|
| `list_memories` cost | High (100+ names) |
| Per-read cost | Low (focused content) |
| Discovery | Requires scanning many file names |

**Problem**: No efficient way to find the right file without reading many.

### Option 3: Tiered Index Architecture (CHOSEN)

**Three-level hierarchy: Top Index → Domain Index → Atomic File**

```text
Level 0: memory-index (domain routing, ~400 tokens)
Level 1: skills-{domain}-index (activation vocabulary, ~100 tokens)
Level 2: {atomic-skill} (focused content, ~150 tokens)
```

---

## Decision Outcome

**Chosen option: Option 3 - Tiered Index Architecture**

### Critical Assumption

**Memory-index caching**: Efficiency claims assume `memory-index` is loaded once per session and cached. Without caching, the architecture provides **27.6% savings**. With caching (memory-index excluded from per-retrieval cost), savings reach **81.6%**.

### Architecture

```text
memory-index.md (Level 0) - ~400 tokens, cached
├── Points to: skills-copilot-index
├── Points to: skills-coderabbit-index
└── Points to: skills-{domain}-index

skills-copilot-index.md (Level 1) - ~100 tokens
| Keywords | File |
|----------|------|
| P0 P1 P2 RICE maintenance-only ... | copilot-platform-priority |
| duplicate sub-pr close branch ... | copilot-follow-up-pr |
| false-positive triage actionability ... | copilot-pr-review |

copilot-pr-review.md (Level 2) - ~150 tokens
[Focused, actionable content only]
```

### Design Principles

#### 1. Activation Vocabulary

Each domain index contains **10-15 keywords** per skill (recommended guideline based on pilot).

```markdown
| Keywords | File |
|----------|------|
| P0 P1 P2 RICE maintenance-only Claude-Code VSCode investment | copilot-platform-priority |
```

**Why**: LLMs map tokens into vector space where **association patterns** (not symbolic logic) drive selection.

**Keyword Guidelines**:

- Use domain-specific compound terms (e.g., `pr-review`, not `review`)
- Each skill SHOULD have ≥40% unique keywords vs other skills in domain
- Include action verbs: `triage`, `close`, `duplicate`

#### 2. Zero Retrieval-Value Content Elimination

Remove anything that doesn't aid retrieval:

| Remove | Reason |
|--------|--------|
| `# Title` headers | File name is self-descriptive |
| `**Date**: ... \| **Status**: Active` | Not actionable |
| `## Index\n\nParent: ...` | Navigation context already known |
| Verbose prose | Tables are denser |

#### 3. Progressive Refinement

| Level | Purpose | Tokens | Caching |
|-------|---------|--------|---------|
| 0 | Domain routing | ~400 | Session-cached |
| 1 | Skill identification via keywords | ~100 | Per-retrieval |
| 2 | Actionable content | ~150 | Per-retrieval |

---

## Validation

### Measured Token Costs (Analyst Verification)

| File | Measured Tokens |
|------|-----------------|
| `memory-index` (minimized) | ~400 |
| `skills-copilot-index` | ~100 |
| `copilot-platform-priority` | ~130 |
| `copilot-follow-up-pr` | ~95 |
| `copilot-pr-review` | ~210 |
| `skills-coderabbit` (consolidated baseline) | ~1,415 |

### Efficiency Analysis

| Scenario | Tiered (cached) | Consolidated | Savings |
|----------|-----------------|--------------|---------|
| Single skill retrieval | ~250 tokens | ~1,415 tokens | **82%** |
| 3 skills from domain | ~535 tokens | ~1,415 tokens | **62%** |
| 9+ skills (break-even) | ~1,400 tokens | ~1,415 tokens | **~0%** |

**Break-even point**: Tiered loses efficiency when retrieving **9 or more skills** from the same domain (≥70% of domain content).

---

## Consequences

### Positive

1. **82% token reduction** for single-skill retrieval (with caching)
2. **Activation vocabulary** enables intuitive matching
3. **Scalable**: Adding skills doesn't bloat existing files
4. **Blast radius containment**: Corruption affects only one domain

### Negative

1. **More files**: 1 index + N atomic files per domain vs 1 consolidated
- **Mitigation**: Files are tiny; total bytes decrease by 64%
2. **Two reads for single skill**: Index + atomic file
- **Mitigation**: ~250 tokens vs ~1,415; net 82% savings
3. **Manual index maintenance**: New skills must be added to index
- **Mitigation**: CI validation required (see Confirmation)

### Failure Modes

| Mode | Risk | Mitigation |
|------|------|------------|
| **Index drift** | Index points to renamed/deleted file | CI validation script |
| **Keyword collision** | Overlapping keywords across skills | ≥40% unique keywords per skill |
| **Cold start** | Memory-index not cached | Accept 27.6% savings vs 82% |
| **Wrong path** | Agent picks wrong skill from keywords | Clear, specific keyword selection |

---

## Confirmation

Compliance verified via:

1. **Pre-commit hook**: Validates new skill files are indexed
2. **CI workflow**: `Validate-MemoryIndex.ps1` checks index ↔ file consistency
3. **Keyword density check**: Each skill has ≥40% unique keywords

**Blocking for Phase 3+ rollout**: Issue #307 automation must be complete.

---

## Reversibility Assessment

| Criterion | Status |
|-----------|--------|
| Rollback capability | Can revert to consolidated files in <30 minutes |
| Vendor lock-in | None (pure markdown) |
| Exit strategy | Delete indices, concatenate atomics to consolidated |
| Data migration | No data loss on rollback |
| Legacy impact | Existing consolidated memories remain functional |

---

## Abort Criteria

Stop tiered migration and evaluate rollback if:

- Token overhead >20% vs consolidated baseline
- Retrieval precision <80% (wrong file loaded frequently)
- Index maintenance >2 hours/month
- Keyword collision rate >30% within domains
- Index drift detected in >3 consecutive PRs within 30 days

---

## Sunset Trigger

This architecture is optimized for lexical matching without embeddings. When Issue #167 (Vector Memory System) is implemented:

1. Re-evaluate tiered approach vs semantic search
2. Tiered indices may become unnecessary overhead
3. Consider deprecation in favor of embedding-based retrieval

---

## Implementation

### Domain Index Format

```markdown
| Keywords | File |
|----------|------|
| keyword1 keyword2 keyword3 ... | memory-file-name |
```

No title, no metadata. Pure lookup table.

### Atomic File Format

```markdown
## Section

| Column | Column |
|--------|--------|
| Data | Data |

**Key insight**: One sentence.
```

No title, no parent pointers, no dates.

### When to Use Tiered vs Consolidated

| Use Tiered | Use Consolidated |
|------------|------------------|
| Domain has ≥3 skills | Domain has ≤2 skills |
| Typical retrieval needs ≤70% of content | Skills always retrieved together |
| Skills are independently useful | Domain is rarely accessed |

---

## Migration Path

1. **Pilot**: Copilot domain (3 skills) - COMPLETE
2. **Validate**: Measured 82% savings (with caching) - COMPLETE
3. **Tooling**: Create `Validate-MemoryIndex.ps1` - REQUIRED before Phase 3
4. **Expand**: Apply to CodeRabbit (12 skills)
5. **Generalize**: Apply to remaining high-value domains

---

## Related Decisions

- [PRD-skills-index-registry.md](../planning/PRD-skills-index-registry.md): Superseded flat registry approach
- [Issue #307](https://github.com/rjmurillo/ai-agents/issues/307): Memory automation tracking
- [Session 51](../sessions/2025-12-20-session-51-token-efficiency-debate.md): 10-agent token efficiency debate
- `.agents/critique/017-tiered-memory-index-critique.md`: 5-agent review
- `.agents/analysis/083-adr-017-quantitative-verification.md`: Token calculations

---

## References

- **Pilot Implementation**: PR #308
- **Measured Data**: Copilot domain (4 files, 535 tokens total)
- **Baseline**: Consolidated `skills-coderabbit` (1,415 tokens)
- **Agent Reviews**: Critic, Architect, Analyst, Security, Independent-Thinker

---

## Validation Checklist

Before applying to new domain:

- [ ] Domain index is pure `| Keywords | File |` table
- [ ] Each skill has 10-15 keywords with ≥40% unique
- [ ] Atomic files have no titles, dates, or parent pointers
- [ ] `memory-index` updated with domain routing
- [ ] CI validation passes (index ↔ file consistency)

---

**Supersedes**: PRD-skills-index-registry.md flat registry approach (for high-value domains)
**Amended by**: None
Loading
Loading