Skip to content

Commit 306206a

Browse files
rysweetclaude
andauthored
feat(memory): Implement 5-type memory system with automatic hooks and multi-agent review (#1905)
* fix(memory): Fix all pre-commit hook failures in memory system Fixed all ruff and pyright errors in memory system implementation: **Ruff Fixes:** - Added missing asyncio imports in test files (F821) - Removed unused imports (F401): - MemoryHookIntegration from test_hook_integration.py - TokenBudget from test_retrieval_flow.py and test_retrieval_pipeline.py - BudgetExceededError from test_token_budget.py - Fixed unused variables (F841): - test_memory_lifecycle.py: memory_id, result, request - test_storage_pipeline.py: result, pipeline (3 occurrences) **Pyright Fixes:** - Fixed datetime comparison in types.py: - Added None check in is_in_time_range method - Prevents comparison of None with datetime objects - Fixed MemoryType enum mismatch in coordinator.py: - Old MemoryType (models.py) vs new MemoryType (types.py) - Fixed filtering to use metadata["new_memory_type"] instead - Avoided assigning incompatible enum types **Files Modified:** - tests/e2e/memory/test_hook_integration.py - tests/e2e/memory/test_memory_lifecycle.py - tests/integration/memory/test_retrieval_flow.py - tests/integration/memory/test_storage_flow.py - tests/unit/memory/test_retrieval_pipeline.py - tests/unit/memory/test_storage_pipeline.py - tests/unit/memory/test_token_budget.py - src/amplihack/memory/types.py - src/amplihack/memory/coordinator.py All memory system-specific pre-commit errors resolved. Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * fix(hooks): Fix 2 MEDIUM hook API mismatches in agent_memory_hook Fixed both coordinator API mismatches found in security review: **Issue 1: Hook Retrieval API Mismatch** (lines 132-138) - WRONG: coordinator.retrieve(query=..., limit=..., agent_type=...) - FIXED: Use RetrievalQuery object with query_text, token_budget, memory_types - Added proper imports: MemoryCoordinator, RetrievalQuery - Made function async to support await coordinator.retrieve() **Issue 2: Hook Storage API Mismatch** (line 212-217) - WRONG: coordinator.store(content=..., agent_type=..., tags=...) - FIXED: Use StorageRequest with content, memory_type, context, metadata - Added proper imports: MemoryCoordinator, StorageRequest - Made function async to support await coordinator.store() Both functions now use correct coordinator API: - inject_memory_for_agents() -> async with RetrievalQuery - extract_learnings_from_conversation() -> async with StorageRequest All core memory tests passing (31/31). Related: PR #1905, Security Review (a4da197) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * fix(memory): Fix CRITICAL type mapping bug in retrieval **Bug**: Test test_multiple_memory_types_lifecycle was failing because memories stored as new types (PROCEDURAL) were retrieved as old types (PATTERN) instead of restoring the original type. **Root Cause**: Storage converts new types → old types and stores the new type in metadata['new_memory_type'], but retrieval never restored the new type from metadata. **Fix**: 1. After retrieving memories from database, restore new type from metadata 2. Convert string → NEW MemoryType enum 3. Use object.__setattr__() to bypass type checking (MemoryEntry.memory_type uses OLD enum but we need NEW enum for API compatibility) **Test Results**: - test_multiple_memory_types_lifecycle now PASSES ✅ - All 47 core memory tests passing ✅ - Pyright type checking passes ✅ **Files Changed**: - src/amplihack/memory/coordinator.py: Add type restoration in retrieve() - tests/e2e/memory/test_memory_lifecycle.py: Fix imports (use coordinator) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * test(memory): Add end-to-end agentic test scenarios with validation results Add comprehensive outside-in test scenarios that validate the 5-type memory system works from a user's perspective when installed via uvx from git branch. ## Test Scenarios Created 1. 01-smoke-test-memory-storage.yaml - Basic storage verification 2. 02-test-all-five-types.yaml - All 5 memory types functional 3. 03-test-cross-session-recall.yaml - Cross-session persistence 4. 04-test-trivial-filtering.yaml - Quality gates working 5. 05-test-hook-integration.yaml - Hooks packaged and importable 6. 06-test-selective-retrieval.yaml - Token budget enforcement ## Validation Results (ALL PASSING ✅) Tested using: uvx --from git+https://github.com/rysweet/amplihack@feat/issue-1902-5-type-memory-system ✅ TEST 1 PASSED: Basic memory storage works ✅ TEST 2 PASSED: All 5 memory types work ✅ TEST 3 PASSED: Trivial filtering works User-facing validation complete - memory system works end-to-end! Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * feat(memory): Add pluggable backend architecture with Kùzu as default Implements pluggable backend system allowing SQLite, Kùzu, or Neo4j backends. Makes Kùzu required and default backend. - Backend abstraction layer with MemoryBackend protocol - SQLiteBackend and KuzuBackend implementations - Evaluation framework for comparing backends - Kùzu moved to required dependencies - 103 passing tests Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * fix(memory): Fix Cypher injection vulnerabilities in Kùzu backend Replace all f-string interpolation with parameterized queries to prevent Cypher injection attacks. - store_memory(): 16 parameters now parameterized - retrieve_memories(): LIMIT/SKIP now parameterized - list_sessions(): LIMIT now parameterized All 103 tests still passing after security hardening. Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
1 parent a687a99 commit 306206a

File tree

85 files changed

+13596
-2448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+13596
-2448
lines changed

.claude/context/PROJECT.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Replace the sections below with information about your project.
1010

1111
---
1212

13-
## Project: [Your Project Name]
13+
## Project: feat-issue-1902-5-type-memory-system
1414

1515
## Overview
1616

17-
[Brief description of what your project does]
17+
Development framework for Claude Code with specialized agents and automated workflows.
1818

1919
## Architecture
2020

@@ -26,10 +26,11 @@ Replace the sections below with information about your project.
2626

2727
### Technology Stack
2828

29-
- **Language**: [Primary language(s)]
29+
- **Language**: Python
30+
- **Language**: JavaScript/TypeScript
31+
- **Language**: Rust
3032
- **Framework**: [Main framework if applicable]
3133
- **Database**: [Database system if applicable]
32-
- **Other Tools**: [Key dependencies or tools]
3334

3435
## Development Guidelines
3536

.claude/context/PROJECT.md.bak

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Project Context
2+
3+
**This file provides project-specific context to Claude Code agents.**
4+
5+
When amplihack is installed in your project, customize this file to describe YOUR project. This helps agents understand what you're building and provide better assistance.
6+
7+
## Quick Start
8+
9+
Replace the sections below with information about your project.
10+
11+
---
12+
13+
## Project: [Your Project Name]
14+
15+
## Overview
16+
17+
[Brief description of what your project does]
18+
19+
## Architecture
20+
21+
### Key Components
22+
23+
- **Component 1**: [Purpose and responsibilities]
24+
- **Component 2**: [Purpose and responsibilities]
25+
- **Component 3**: [Purpose and responsibilities]
26+
27+
### Technology Stack
28+
29+
- **Language**: [Primary language(s)]
30+
- **Framework**: [Main framework if applicable]
31+
- **Database**: [Database system if applicable]
32+
- **Other Tools**: [Key dependencies or tools]
33+
34+
## Development Guidelines
35+
36+
### Code Organization
37+
38+
[How is your code organized? What are the main directories?]
39+
40+
### Key Patterns
41+
42+
[What architectural patterns or conventions does your project follow?]
43+
44+
### Testing Strategy
45+
46+
[How do you test? Unit tests, integration tests, E2E?]
47+
48+
## Domain Knowledge
49+
50+
### Business Context
51+
52+
[What problem does this project solve? Who are the users?]
53+
54+
### Key Terminology
55+
56+
[Important domain-specific terms that agents should understand]
57+
58+
## Common Tasks
59+
60+
### Development Workflow
61+
62+
[How do developers typically work on this project?]
63+
64+
### Deployment Process
65+
66+
[How is the project deployed?]
67+
68+
## Important Notes
69+
70+
[Any special considerations, gotchas, or critical information]
71+
72+
---
73+
74+
## About This File
75+
76+
This file is installed by amplihack to provide project-specific context to AI agents.
77+
78+
**For more about amplihack itself**, see PROJECT_AMPLIHACK.md in this directory.
79+
80+
**Tip**: Keep this file updated as your project evolves. Accurate context leads to better AI assistance.

.claude/scenarios/mcp_manager

Lines changed: 0 additions & 1 deletion
This file was deleted.

.claude/settings.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@
2222
]
2323
}
2424
],
25-
"PreToolUse": [
26-
{
27-
"matcher": "Bash",
28-
"hooks": [
29-
{
30-
"type": "command",
31-
"command": "$CLAUDE_PROJECT_DIR/.claude/tools/amplihack/hooks/pre_tool_use.py"
32-
}
33-
]
34-
}
35-
],
3625
"PostToolUse": [
3726
{
3827
"matcher": "*",

.claude/skills/context_management/automation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
ContextExtractor,
1919
ContextRehydrator,
2020
TokenMonitor,
21-
check_status,
2221
)
2322
except ImportError:
2423
# Fallback for when running from hooks
@@ -246,7 +245,7 @@ def _handle_compaction(self, result: dict[str, Any]) -> None:
246245

247246
try:
248247
# Rehydrate context
249-
rehydrated = self.rehydrator.rehydrate(snapshot_path, level)
248+
self.rehydrator.rehydrate(snapshot_path, level)
250249

251250
result["actions_taken"].append(f"auto_rehydrated_at_{level}_level")
252251
result["warnings"].append(

.claude/skills/docx/ooxml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.claude/skills/dynamic-debugger/tests/test_config_generation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ def test_real_config_files_loadable(self, language, config_file, temp_project_di
271271

272272
def test_all_configs_have_required_fields(self, configs_dir):
273273
"""Test that all config templates have required structure."""
274-
required_template_keys = ["config"]
275-
276274
for config_file in configs_dir.glob("*.json"):
277275
with open(config_file) as f:
278276
template = json.load(f)

.claude/skills/dynamic-debugger/tests/test_session_monitoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def test_cpu_activity_tracking(self, tmp_path):
430430
# Start, low CPU, high CPU, then stop
431431
mock_get_info.side_effect = [mock_info_low, mock_info_low, mock_info_high, None]
432432

433-
with patch("sys.stdout", new=StringIO()) as fake_out:
433+
with patch("sys.stdout", new=StringIO()):
434434
monitor_session(str(pid_file), interval=0.1)
435435

436436
# Should complete without error

.claude/skills/microsoft-agent-framework/scripts/check-freshness.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def check_source_urls(self, metadata: dict) -> bool:
9898

9999
def check_github_version(self, metadata: dict) -> bool:
100100
"""Check if framework version matches latest GitHub release."""
101-
github_info = metadata.get("sources", {}).get("github_repository", {})
102101
current_version = metadata.get("framework_version", "unknown")
103102

104103
print(f"✓ Framework version: {current_version}")
@@ -156,9 +155,9 @@ def run(self) -> bool:
156155
# Run checks
157156
age_ok = self.check_documentation_age(metadata)
158157
urls_ok = self.check_source_urls(metadata)
159-
version_ok = self.check_github_version(metadata)
160-
changes_ok = self.check_breaking_changes(metadata)
161-
schedule_ok = self.check_next_verification(metadata)
158+
self.check_github_version(metadata)
159+
self.check_breaking_changes(metadata)
160+
self.check_next_verification(metadata)
162161

163162
# Report results
164163
print()

.claude/skills/outside-in-testing/examples/electron/electron-ipc-testing.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ scenario:
88
Verifies IPC communication between main and renderer processes, including
99
request/response patterns, event broadcasting, and data serialization.
1010
type: electron
11-
1211
level: 3
1312

1413
tags: [electron, ipc, advanced, main-process, renderer-process]
@@ -68,7 +67,7 @@ scenario:
6867
- action: verify_ipc_payload
6968
contains:
7069
success: true
71-
data: "{}" # Some JSON content
70+
data: "{}" # Some JSON content
7271

7372
# Test Case 4: Event Broadcasting (Main → Renderer)
7473
- action: wait_for_element
@@ -119,7 +118,7 @@ scenario:
119118
# Send IPC from first window
120119
- action: window_action
121120
window: 1
122-
action: focus
121+
type: focus
123122

124123
- action: ipc_send
125124
channel: "broadcast-message"
@@ -129,7 +128,7 @@ scenario:
129128
# Verify received in second window
130129
- action: window_action
131130
window: 2
132-
action: focus
131+
type: focus
133132

134133
- action: wait_for_element
135134
selector: ".broadcast-message"
@@ -141,7 +140,7 @@ scenario:
141140
channel: "show-open-dialog"
142141
data:
143142
title: "Select File"
144-
filters: [{name: "Text Files", extensions: ["txt"]}]
143+
filters: [{ name: "Text Files", extensions: ["txt"] }]
145144

146145
# Simulate dialog interaction (in test mode)
147146
- action: dialog_action
@@ -166,7 +165,6 @@ scenario:
166165
cleanup:
167166
- action: stop_application
168167
force: false
169-
170168
# IPC Communication Patterns:
171169

172170
# Main Process Renderer Process

0 commit comments

Comments
 (0)