Skip to content

Commit 6028d67

Browse files
rjmurillo-botclaude
andcommitted
feat(memory): add cache-aside pattern for GitHub data and ADR reference
## New Memory Domains ### Cache-Aside Pattern (Reduce API Calls) - github-open-prs-cache: Open PRs with 30-min TTL - github-open-issues-cache: Open issues with 1-hour TTL ### Reference Indexes - adr-reference-index: Quick lookup for ADRs in .agents/architecture/ - issue-307-memory-automation: Expansion proposal for memory domains ## Cache Pattern Agents check memory first, refresh from API only when stale: 1. Read cache memory 2. Check timestamp vs TTL 3. If FRESH: use cached data 4. If STALE: query API, update memory ## Token Savings - ~2,600 tokens for all caches - Saves 10-30 GitHub API calls per session - ADR index avoids reading 20+ individual files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e6dd797 commit 6028d67

File tree

5 files changed

+263
-36
lines changed

5 files changed

+263
-36
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ADR Reference Index
2+
3+
**Purpose**: Quick lookup for Architecture Decision Records
4+
**Location**: `.agents/architecture/ADR-*.md`
5+
**Updated**: 2025-12-23
6+
7+
This is a REFERENCE index, not a skills index. ADRs live in `.agents/architecture/`, not `.serena/memories/`.
8+
9+
## Active ADRs by Topic
10+
11+
### Agent System
12+
| ADR | Title | Keywords |
13+
|-----|-------|----------|
14+
| ADR-002 | Agent Model Selection Optimization | model haiku sonnet opus routing |
15+
| ADR-003 | Agent Tool Selection Criteria | tool allocation agent |
16+
| ADR-007 | Memory-First Architecture | memory context retrieval |
17+
| ADR-009 | Parallel-Safe Multi-Agent Design | parallel worktree isolation |
18+
| ADR-010 | Quality Gates with Evaluator-Optimizer | quality gate evaluator |
19+
| ADR-014a | Distributed Handoff Architecture | handoff session log |
20+
21+
### CI/CD and Workflows
22+
| ADR | Title | Keywords |
23+
|-----|-------|----------|
24+
| ADR-004 | Pre-Commit Hook as Validation Orchestration | pre-commit hook validation |
25+
| ADR-006 | Thin Workflows, Testable Modules | thin workflow bash module |
26+
| ADR-008 | Protocol Automation via Lifecycle Hooks | protocol automation lifecycle |
27+
| ADR-014b | GitHub Actions ARM Runner Migration | arm runner macos |
28+
| ADR-015a | Artifact Storage Minimization | artifact storage retention |
29+
| ADR-015b | PR Automation Concurrency and Safety | pr automation lock concurrency |
30+
| ADR-016 | Workflow Execution Optimization | workflow cache optimization |
31+
32+
### Standards and Patterns
33+
| ADR | Title | Keywords |
34+
|-----|-------|----------|
35+
| ADR-001 | Markdown Linting Configuration | markdown lint autofix |
36+
| ADR-005 | PowerShell-Only Scripting Standard | powershell ps1 pwsh |
37+
| ADR-017 | Tiered Memory Index Architecture | memory index L1 L2 L3 tier |
38+
39+
### Proposed (Not Yet Implemented)
40+
| ADR | Title | Status |
41+
|-----|-------|--------|
42+
| ADR-011 | Session State MCP | Proposed |
43+
| ADR-012 | Skill Catalog MCP | Proposed |
44+
| ADR-013 | Agent Orchestration MCP | Proposed |
45+
46+
## How to Read an ADR
47+
48+
```text
49+
Read(".agents/architecture/ADR-NNN-title.md")
50+
```
51+
52+
## Related Memories
53+
54+
- adr-014-review-findings (analysis of ADR-014)
55+
- adr-017-quantitative-analysis (metrics for ADR-017)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# GitHub Open Issues Cache
2+
3+
**Last Updated**: 2025-12-23T21:00:00Z
4+
**TTL**: 1 hour
5+
**Next Refresh**: After 2025-12-24T00:00:00Z (or on issue state change)
6+
7+
## Cache-Aside Pattern
8+
9+
Before querying GitHub API for open issues:
10+
1. Read this memory
11+
2. Check if `now < Next Refresh`
12+
3. If FRESH: use cached data
13+
4. If STALE: query API, update this file
14+
15+
## Priority Issues
16+
17+
### P0 (Critical)
18+
| Issue | Title | Labels |
19+
|-------|-------|--------|
20+
| #307 | Memory Automation: Index, Consolidation, and Smart Retrieval | agent-memory, agent-qa, P0 |
21+
22+
### P1 (Important)
23+
| Issue | Title | Labels |
24+
|-------|-------|--------|
25+
| #318 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
26+
| #317 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
27+
| #316 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
28+
| #314 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
29+
| #312 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
30+
| #309 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
31+
| #306 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
32+
| #305 | [ALERT] PR Maintenance Workflow Failed | bug, automation, P1 |
33+
| #304 | Harden PowerShell module supply chain in CI/CD | security, P1 |
34+
| #289 | Implement GitHub MCP skill for Claude Code and VS Code | skills, P1 |
35+
| #286 | Rewrite simple GitHub skills to use gh CLI directly | skills, P1 |
36+
37+
### P2 (Normal)
38+
| Issue | Title | Labels |
39+
|-------|-------|--------|
40+
| #311 | Migrate legacy consolidated memories to tiered index | agent-memory, P2 |
41+
| #297 | Agent Drift Detected - 2025-12-23 | drift-detected, P2 |
42+
| #293 | Add merged-PR detection to empty diff categorization | enhancement, P2 |
43+
| #292 | Add PR number validation to Copilot follow-up detection | enhancement, P2 |
44+
| #291 | Improve Pester test coverage for Detect-CopilotFollowUpPR.ps1 | enhancement, P2 |
45+
| #288 | Document hybrid PowerShell architecture decision | documentation, P2 |
46+
| #284 | Implement -NoProfile when shelling out to pwsh | enhancement, P2 |
47+
48+
## By Category
49+
50+
**Workflow Alerts (Duplicates)**: #318, #317, #316, #314, #312, #309, #306, #305
51+
- Root cause: PR maintenance workflow failing repeatedly
52+
- Consider: Consolidating into single tracking issue
53+
54+
**Memory/Skills**: #307, #311
55+
**Security**: #304
56+
**GitHub Integration**: #289, #286
57+
**Documentation**: #288, #297
58+
**Enhancements**: #293, #292, #291, #284
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# GitHub Open PRs Cache
2+
3+
**Last Updated**: 2025-12-23T21:00:00Z
4+
**TTL**: 30 minutes
5+
**Next Refresh**: After 2025-12-24T00:00:00Z (or on PR state change)
6+
7+
## Cache-Aside Pattern
8+
9+
Before querying GitHub API for open PRs:
10+
1. Read this memory
11+
2. Check if `now < Next Refresh`
12+
3. If FRESH: use cached data
13+
4. If STALE: query API, update this file
14+
15+
## Open Pull Requests (10 total)
16+
17+
| PR | Title | Branch | Author |
18+
|----|-------|--------|--------|
19+
| #315 | feat(skill): add ADR review skill | feat/adr-review | rjmurillo |
20+
| #313 | fix(pr-maintenance): remove exit code 1 for blocked PRs | copilot/investigate-workflow-failure | copilot-swe-agent |
21+
| #310 | docs(adr): add model routing policy to minimize false PASS | docs/adr-017 | rjmurillo |
22+
| #308 | feat(memory): implement ADR-017 tiered memory index architecture | memory-automation-index-consolidation | rjmurillo-bot |
23+
| #301 | docs: autonomous PR monitoring prompt and retrospective | combined-pr-branch | rjmurillo-bot |
24+
| #300 | docs(retrospective): autonomous PR monitoring session analysis | docs/autonomous-pr-monitoring-retrospective | rjmurillo-bot |
25+
| #299 | docs: add autonomous PR monitoring prompt | docs/autonomous-monitoring-prompt | rjmurillo-bot |
26+
| #285 | perf: Add -NoProfile to pwsh invocations for 72% faster execution | feat/284-noprofile | rjmurillo-bot |
27+
| #269 | docs(orchestrator): add Phase 4 pre-PR validation workflow | copilot/add-pre-pr-validation-workflow | copilot-swe-agent |
28+
| #255 | feat(github-skill): enhance skill for Claude effectiveness | feat/skill-leverage | rjmurillo-bot |
29+
30+
## Quick Lookup
31+
32+
**By Author**:
33+
- rjmurillo: #315, #310
34+
- rjmurillo-bot: #308, #301, #300, #299, #285, #255
35+
- copilot-swe-agent: #313, #269
36+
37+
**Ready for Review**: #308, #315, #310
38+
**Draft/WIP**: #301, #300, #299, #285, #269, #255
Lines changed: 102 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,102 @@
1-
# Issue #307: Memory Automation
2-
3-
**Issue**: https://github.com/rjmurillo/ai-agents/issues/307
4-
**Created**: 2025-12-23
5-
**Status**: PR #308 created
6-
**PR**: https://github.com/rjmurillo/ai-agents/pull/308
7-
8-
## Scope
9-
10-
Implement memory automation to reduce cognitive load:
11-
12-
1. **Memory Index** - 1-line summaries, topic tags, staleness detection
13-
2. **Session Init Gate** - Enforce initialization, not just checklist
14-
3. **Skill Consolidation** - Deduplicate 70+ skill memories
15-
4. **Artifact Quality Gate** - Validate Skill-007 compliance
16-
17-
## Current Progress
18-
19-
- [x] Created issue #307
20-
- [x] Created `automation-priorities-2025-12` memory with analysis
21-
- [x] Memory index with summaries (`memory-index`)
22-
- [x] Consolidated user preferences (2→1)
23-
- [x] Consolidated session init skills (2→1)
24-
- [x] Consolidated PR review memories (3→1)
25-
- [x] Consolidated skill-documentation-* (4→1)
26-
- [x] Consolidated skill-planning-* (3→1)
27-
- [x] Consolidated skill-orchestration-* (3→1)
28-
- [x] Consolidated skill-protocol-* (4→1) - NEW collection
29-
- [ ] Additional skill consolidation (more opportunities exist)
30-
- [ ] Artifact quality gate (deferred)
31-
32-
## Related Memories
33-
34-
- `automation-priorities-2025-12` - Strategic analysis
35-
- `skills-*` - 30+ memories to consolidate
36-
- `skill-*` - 40+ memories to consolidate
1+
# Issue #307: Memory Automation Expansion Proposal
2+
3+
## Current State (ADR-017 Complete)
4+
5+
- **Domain Indexes**: 30 skill domains
6+
- **Indexed Files**: 197 atomic skills
7+
- **Token Efficiency**: 82% savings with session caching
8+
9+
## Proposed Cache-Aside Memory Domains
10+
11+
### Priority 1: High-Value Caches (Reduce GitHub API calls)
12+
13+
| Domain | Cache Target | TTL | Invalidation Trigger |
14+
|--------|--------------|-----|----------------------|
15+
| `github-open-issues-cache` | Open issues list | 1 hour | Issue created/closed webhook |
16+
| `github-open-prs-cache` | Open PRs list | 30 min | PR opened/merged/closed |
17+
| `github-labels-milestones-cache` | Labels and milestones | 24 hours | Manual or on change |
18+
19+
**Benefit**: Agents frequently query open issues/PRs. Caching saves 10-20 API calls per session.
20+
21+
### Priority 2: Architecture Reference (Rarely Changes)
22+
23+
| Domain | Source | Content |
24+
|--------|--------|---------|
25+
| `skills-adr-index` | `.agents/architecture/ADR-*.md` | ADR summaries and decision keywords |
26+
27+
**ADR Index Format**:
28+
```markdown
29+
| ADR | Title | Status | Keywords |
30+
|-----|-------|--------|----------|
31+
| ADR-001 | Markdown Linting | Active | lint markdown fix autofix |
32+
| ADR-017 | Tiered Memory | Active | memory index tier L1 L2 L3 |
33+
```
34+
35+
### Priority 3: Governance Reference
36+
37+
| Domain | Source | Content |
38+
|--------|--------|---------|
39+
| `skills-governance-index` | `.agents/governance/*.md` | Governance policies and constraints |
40+
41+
### Priority 4: Session Context (Optional)
42+
43+
| Domain | Purpose | Scope |
44+
|--------|---------|-------|
45+
| `active-session-context` | Current session state | Single session, cleared on end |
46+
47+
## Cache-Aside Pattern Implementation
48+
49+
```text
50+
1. Agent needs data (e.g., open PRs)
51+
2. Check memory: mcp__serena__read_memory("github-open-prs-cache")
52+
3. If MISS or STALE:
53+
a. Query GitHub API
54+
b. Write to memory with timestamp
55+
c. Use data
56+
4. If HIT and FRESH:
57+
a. Use cached data directly
58+
```
59+
60+
### Staleness Check
61+
62+
Each cache file includes header:
63+
64+
```markdown
65+
# GitHub Open PRs Cache
66+
67+
**Last Updated**: 2025-12-23T20:30:00Z
68+
**TTL**: 30 minutes
69+
**Next Refresh**: After 2025-12-23T21:00:00Z
70+
71+
## Cached Data
72+
...
73+
```
74+
75+
Agent checks: `if (now > next_refresh) { refresh_cache() }`
76+
77+
## Excluded from Caching (Not Recommended)
78+
79+
| Domain | Reason |
80+
|--------|--------|
81+
| Sessions | Too transient, high churn, low reuse value |
82+
| Planning artifacts | Already in `.agents/planning/`, not frequently queried |
83+
| PR comments state | Changes too rapidly during review |
84+
85+
## Implementation Tasks
86+
87+
1. [ ] Create `skills-adr-index.md` domain index
88+
2. [ ] Create `skills-governance-index.md` domain index
89+
3. [ ] Create cache refresh scripts for GitHub data
90+
4. [ ] Add cache staleness check to agent memory protocol
91+
5. [ ] Update `memory-index.md` with new domains
92+
93+
## Token Cost Analysis
94+
95+
| Cache Domain | Size | Read Cost | Savings per Session |
96+
|--------------|------|-----------|---------------------|
97+
| ADR index | ~500 tokens | 1 read | Avoids 20 file reads |
98+
| Open issues | ~1,000 tokens | 1 read | Avoids 3-5 API calls |
99+
| Open PRs | ~800 tokens | 1 read | Avoids 2-3 API calls |
100+
| Labels/Milestones | ~300 tokens | 1 read | Avoids 2 API calls |
101+
102+
**Total**: ~2,600 tokens for 4 domains vs 10-30 API calls saved

.serena/memories/memory-index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
| security vulnerability TOCTOU secret injection | skills-security-index |
1212
| planning task file path scope breakdown | skills-planning-index |
1313
| architecture ADR model composite tool allocation producer-consumer | skills-architecture-index |
14+
| adr decision record active proposed superseded rationale | adr-reference-index |
1415
| design agent specialization entry-criteria limitation composability | skills-design-index |
1516
| implementation code feature bug fix test TDD additive | skills-implementation-index |
1617
| orchestration agent coordination parallel handoff dispatch | skills-orchestration-index |
@@ -40,6 +41,15 @@
4041
| cva refactoring variant consolidation template generate | skills-cva-refactoring |
4142
| phase3 agent skill session handoff template verification | skills-agent-workflow-phase3 |
4243

44+
## GitHub Cache (Cache-Aside Pattern)
45+
46+
| Cache Keywords | Memory File | TTL |
47+
|----------------|-------------|-----|
48+
| open pr list pull request ready review | github-open-prs-cache | 30 min |
49+
| open issue list bug enhancement priority | github-open-issues-cache | 1 hour |
50+
51+
**Usage**: Read cache first. If stale (check timestamp), refresh from API and update memory.
52+
4353
## User Constraints (MUST READ)
4454

4555
| Constraint | Memory |

0 commit comments

Comments
 (0)