alma-memory 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. alma/__init__.py +88 -44
  2. alma/confidence/__init__.py +1 -1
  3. alma/confidence/engine.py +92 -58
  4. alma/confidence/types.py +34 -14
  5. alma/config/loader.py +3 -2
  6. alma/consolidation/__init__.py +23 -0
  7. alma/consolidation/engine.py +678 -0
  8. alma/consolidation/prompts.py +84 -0
  9. alma/core.py +15 -15
  10. alma/domains/__init__.py +6 -6
  11. alma/domains/factory.py +12 -9
  12. alma/domains/schemas.py +17 -3
  13. alma/domains/types.py +8 -4
  14. alma/events/__init__.py +75 -0
  15. alma/events/emitter.py +284 -0
  16. alma/events/storage_mixin.py +246 -0
  17. alma/events/types.py +126 -0
  18. alma/events/webhook.py +425 -0
  19. alma/exceptions.py +49 -0
  20. alma/extraction/__init__.py +31 -0
  21. alma/extraction/auto_learner.py +264 -0
  22. alma/extraction/extractor.py +420 -0
  23. alma/graph/__init__.py +81 -0
  24. alma/graph/backends/__init__.py +18 -0
  25. alma/graph/backends/memory.py +236 -0
  26. alma/graph/backends/neo4j.py +417 -0
  27. alma/graph/base.py +159 -0
  28. alma/graph/extraction.py +198 -0
  29. alma/graph/store.py +860 -0
  30. alma/harness/__init__.py +4 -4
  31. alma/harness/base.py +18 -9
  32. alma/harness/domains.py +27 -11
  33. alma/initializer/__init__.py +1 -1
  34. alma/initializer/initializer.py +51 -43
  35. alma/initializer/types.py +25 -17
  36. alma/integration/__init__.py +9 -9
  37. alma/integration/claude_agents.py +10 -10
  38. alma/integration/helena.py +32 -22
  39. alma/integration/victor.py +57 -33
  40. alma/learning/__init__.py +27 -27
  41. alma/learning/forgetting.py +198 -148
  42. alma/learning/heuristic_extractor.py +40 -24
  43. alma/learning/protocols.py +62 -14
  44. alma/learning/validation.py +7 -2
  45. alma/mcp/__init__.py +4 -4
  46. alma/mcp/__main__.py +2 -1
  47. alma/mcp/resources.py +17 -16
  48. alma/mcp/server.py +102 -44
  49. alma/mcp/tools.py +174 -37
  50. alma/progress/__init__.py +3 -3
  51. alma/progress/tracker.py +26 -20
  52. alma/progress/types.py +8 -12
  53. alma/py.typed +0 -0
  54. alma/retrieval/__init__.py +11 -11
  55. alma/retrieval/cache.py +20 -21
  56. alma/retrieval/embeddings.py +4 -4
  57. alma/retrieval/engine.py +114 -35
  58. alma/retrieval/scoring.py +73 -63
  59. alma/session/__init__.py +2 -2
  60. alma/session/manager.py +5 -5
  61. alma/session/types.py +5 -4
  62. alma/storage/__init__.py +41 -0
  63. alma/storage/azure_cosmos.py +101 -31
  64. alma/storage/base.py +157 -4
  65. alma/storage/chroma.py +1443 -0
  66. alma/storage/file_based.py +56 -20
  67. alma/storage/pinecone.py +1080 -0
  68. alma/storage/postgresql.py +1452 -0
  69. alma/storage/qdrant.py +1306 -0
  70. alma/storage/sqlite_local.py +376 -31
  71. alma/types.py +62 -14
  72. alma_memory-0.5.0.dist-info/METADATA +905 -0
  73. alma_memory-0.5.0.dist-info/RECORD +76 -0
  74. {alma_memory-0.4.0.dist-info → alma_memory-0.5.0.dist-info}/WHEEL +1 -1
  75. alma_memory-0.4.0.dist-info/METADATA +0 -488
  76. alma_memory-0.4.0.dist-info/RECORD +0 -52
  77. {alma_memory-0.4.0.dist-info → alma_memory-0.5.0.dist-info}/top_level.txt +0 -0
@@ -14,18 +14,18 @@ This module provides Helena-specific memory categories, prompts, and utilities.
14
14
  """
15
15
 
16
16
  import logging
17
- from typing import Optional, Dict, Any, List
18
17
  from dataclasses import dataclass, field
18
+ from typing import Any, Dict, List, Optional
19
19
 
20
20
  from alma.core import ALMA
21
- from alma.types import MemorySlice
22
21
  from alma.harness.domains import CodingDomain
23
22
  from alma.integration.claude_agents import (
23
+ AgentType,
24
24
  ClaudeAgentHooks,
25
25
  TaskContext,
26
26
  TaskOutcome,
27
- AgentType,
28
27
  )
28
+ from alma.types import MemorySlice
29
29
 
30
30
  logger = logging.getLogger(__name__)
31
31
 
@@ -55,6 +55,7 @@ class UITestContext(TaskContext):
55
55
 
56
56
  Extends TaskContext with UI testing-specific fields.
57
57
  """
58
+
58
59
  component_type: Optional[str] = None
59
60
  page_url: Optional[str] = None
60
61
  viewport: Optional[Dict[str, int]] = None
@@ -89,6 +90,7 @@ class UITestOutcome(TaskOutcome):
89
90
 
90
91
  Extends TaskOutcome with UI testing-specific results.
91
92
  """
93
+
92
94
  selectors_used: List[str] = field(default_factory=list)
93
95
  accessibility_issues: List[Dict[str, Any]] = field(default_factory=list)
94
96
  visual_diffs: List[str] = field(default_factory=list)
@@ -148,11 +150,13 @@ class HelenaHooks(ClaudeAgentHooks):
148
150
  patterns = []
149
151
  for h in memories.heuristics:
150
152
  if "selector" in h.condition.lower():
151
- patterns.append({
152
- "pattern": h.strategy,
153
- "confidence": h.confidence,
154
- "occurrences": h.occurrence_count,
155
- })
153
+ patterns.append(
154
+ {
155
+ "pattern": h.strategy,
156
+ "confidence": h.confidence,
157
+ "occurrences": h.occurrence_count,
158
+ }
159
+ )
156
160
 
157
161
  return patterns
158
162
 
@@ -171,11 +175,13 @@ class HelenaHooks(ClaudeAgentHooks):
171
175
  strategies = []
172
176
  for h in memories.heuristics:
173
177
  if any(kw in h.condition.lower() for kw in ["form", "validation", "input"]):
174
- strategies.append({
175
- "condition": h.condition,
176
- "strategy": h.strategy,
177
- "confidence": h.confidence,
178
- })
178
+ strategies.append(
179
+ {
180
+ "condition": h.condition,
181
+ "strategy": h.strategy,
182
+ "confidence": h.confidence,
183
+ }
184
+ )
179
185
 
180
186
  return strategies
181
187
 
@@ -194,18 +200,22 @@ class HelenaHooks(ClaudeAgentHooks):
194
200
  patterns = []
195
201
  for h in memories.heuristics:
196
202
  if any(kw in h.condition.lower() for kw in ["access", "aria", "keyboard"]):
197
- patterns.append({
198
- "condition": h.condition,
199
- "strategy": h.strategy,
200
- "confidence": h.confidence,
201
- })
203
+ patterns.append(
204
+ {
205
+ "condition": h.condition,
206
+ "strategy": h.strategy,
207
+ "confidence": h.confidence,
208
+ }
209
+ )
202
210
 
203
211
  for dk in memories.domain_knowledge:
204
212
  if dk.domain == "accessibility_testing":
205
- patterns.append({
206
- "fact": dk.fact,
207
- "source": dk.source,
208
- })
213
+ patterns.append(
214
+ {
215
+ "fact": dk.fact,
216
+ "source": dk.source,
217
+ }
218
+ )
209
219
 
210
220
  return patterns
211
221
 
@@ -14,18 +14,18 @@ This module provides Victor-specific memory categories, prompts, and utilities.
14
14
  """
15
15
 
16
16
  import logging
17
- from typing import Optional, Dict, Any, List
18
17
  from dataclasses import dataclass, field
18
+ from typing import Any, Dict, List, Optional
19
19
 
20
20
  from alma.core import ALMA
21
- from alma.types import MemorySlice
22
21
  from alma.harness.domains import CodingDomain
23
22
  from alma.integration.claude_agents import (
23
+ AgentType,
24
24
  ClaudeAgentHooks,
25
25
  TaskContext,
26
26
  TaskOutcome,
27
- AgentType,
28
27
  )
28
+ from alma.types import MemorySlice
29
29
 
30
30
  logger = logging.getLogger(__name__)
31
31
 
@@ -55,6 +55,7 @@ class APITestContext(TaskContext):
55
55
 
56
56
  Extends TaskContext with API/backend testing-specific fields.
57
57
  """
58
+
58
59
  endpoint: Optional[str] = None
59
60
  method: str = "GET"
60
61
  expected_status: Optional[int] = None
@@ -91,6 +92,7 @@ class APITestOutcome(TaskOutcome):
91
92
 
92
93
  Extends TaskOutcome with API/backend testing-specific results.
93
94
  """
95
+
94
96
  response_status: Optional[int] = None
95
97
  response_time_ms: Optional[int] = None
96
98
  response_body: Optional[Dict[str, Any]] = None
@@ -153,12 +155,14 @@ class VictorHooks(ClaudeAgentHooks):
153
155
  patterns = []
154
156
  for h in memories.heuristics:
155
157
  if "api" in h.condition.lower() or "endpoint" in h.condition.lower():
156
- patterns.append({
157
- "pattern": h.strategy,
158
- "condition": h.condition,
159
- "confidence": h.confidence,
160
- "occurrences": h.occurrence_count,
161
- })
158
+ patterns.append(
159
+ {
160
+ "pattern": h.strategy,
161
+ "condition": h.condition,
162
+ "confidence": h.confidence,
163
+ "occurrences": h.occurrence_count,
164
+ }
165
+ )
162
166
 
163
167
  return patterns
164
168
 
@@ -176,12 +180,16 @@ class VictorHooks(ClaudeAgentHooks):
176
180
 
177
181
  patterns = []
178
182
  for h in memories.heuristics:
179
- if any(kw in h.condition.lower() for kw in ["error", "exception", "validation"]):
180
- patterns.append({
181
- "condition": h.condition,
182
- "strategy": h.strategy,
183
- "confidence": h.confidence,
184
- })
183
+ if any(
184
+ kw in h.condition.lower() for kw in ["error", "exception", "validation"]
185
+ ):
186
+ patterns.append(
187
+ {
188
+ "condition": h.condition,
189
+ "strategy": h.strategy,
190
+ "confidence": h.confidence,
191
+ }
192
+ )
185
193
 
186
194
  return patterns
187
195
 
@@ -199,19 +207,26 @@ class VictorHooks(ClaudeAgentHooks):
199
207
 
200
208
  strategies = []
201
209
  for h in memories.heuristics:
202
- if any(kw in h.condition.lower() for kw in ["performance", "cache", "query", "slow"]):
203
- strategies.append({
204
- "condition": h.condition,
205
- "strategy": h.strategy,
206
- "confidence": h.confidence,
207
- })
210
+ if any(
211
+ kw in h.condition.lower()
212
+ for kw in ["performance", "cache", "query", "slow"]
213
+ ):
214
+ strategies.append(
215
+ {
216
+ "condition": h.condition,
217
+ "strategy": h.strategy,
218
+ "confidence": h.confidence,
219
+ }
220
+ )
208
221
 
209
222
  for dk in memories.domain_knowledge:
210
223
  if dk.domain in ["performance_optimization", "caching_strategies"]:
211
- strategies.append({
212
- "fact": dk.fact,
213
- "source": dk.source,
214
- })
224
+ strategies.append(
225
+ {
226
+ "fact": dk.fact,
227
+ "source": dk.source,
228
+ }
229
+ )
215
230
 
216
231
  return strategies
217
232
 
@@ -229,12 +244,17 @@ class VictorHooks(ClaudeAgentHooks):
229
244
 
230
245
  patterns = []
231
246
  for h in memories.heuristics:
232
- if any(kw in h.condition.lower() for kw in ["auth", "token", "permission", "jwt"]):
233
- patterns.append({
234
- "condition": h.condition,
235
- "strategy": h.strategy,
236
- "confidence": h.confidence,
237
- })
247
+ if any(
248
+ kw in h.condition.lower()
249
+ for kw in ["auth", "token", "permission", "jwt"]
250
+ ):
251
+ patterns.append(
252
+ {
253
+ "condition": h.condition,
254
+ "strategy": h.strategy,
255
+ "confidence": h.confidence,
256
+ }
257
+ )
238
258
 
239
259
  return patterns
240
260
 
@@ -318,11 +338,15 @@ class VictorHooks(ClaudeAgentHooks):
318
338
  sections.append(f"- **Task Type**: {test_context.task_type}")
319
339
 
320
340
  if test_context.endpoint:
321
- sections.append(f"- **Endpoint**: {test_context.method} {test_context.endpoint}")
341
+ sections.append(
342
+ f"- **Endpoint**: {test_context.method} {test_context.endpoint}"
343
+ )
322
344
  if test_context.expected_status:
323
345
  sections.append(f"- **Expected Status**: {test_context.expected_status}")
324
346
  if test_context.request_body:
325
- sections.append(f"- **Request Body**: {len(test_context.request_body)} fields")
347
+ sections.append(
348
+ f"- **Request Body**: {len(test_context.request_body)} fields"
349
+ )
326
350
 
327
351
  if test_context.is_auth_test:
328
352
  sections.append("- **Focus**: Authentication/Authorization")
alma/learning/__init__.py CHANGED
@@ -4,46 +4,46 @@ ALMA Learning Protocols.
4
4
  Provides learning, validation, forgetting, and heuristic extraction.
5
5
  """
6
6
 
7
- from alma.learning.protocols import LearningProtocol
8
- from alma.learning.validation import (
9
- ScopeValidator,
10
- ValidationResult,
11
- ValidationReport,
12
- TaskTypeValidator,
13
- validate_learning_request,
14
- )
15
7
  from alma.learning.forgetting import (
16
- # Forgetting Engine
17
- ForgettingEngine,
18
- PrunePolicy,
19
- PruneResult,
20
- PruneSummary,
21
- PruneReason,
8
+ CleanupJob,
9
+ CleanupResult,
10
+ # Cleanup Scheduling
11
+ CleanupScheduler,
12
+ # Confidence Decay
13
+ ConfidenceDecayer,
22
14
  # Decay Functions
23
15
  DecayFunction,
16
+ DecayResult,
24
17
  ExponentialDecay,
18
+ # Forgetting Engine
19
+ ForgettingEngine,
20
+ HealthAlert,
21
+ HealthThresholds,
25
22
  LinearDecay,
26
- StepDecay,
27
- NoDecay,
28
- # Confidence Decay
29
- ConfidenceDecayer,
30
- DecayResult,
23
+ MemoryHealthMetrics,
31
24
  # Memory Health Monitoring
32
25
  MemoryHealthMonitor,
33
- MemoryHealthMetrics,
34
- HealthAlert,
35
- HealthThresholds,
36
- # Cleanup Scheduling
37
- CleanupScheduler,
38
- CleanupJob,
39
- CleanupResult,
26
+ NoDecay,
27
+ PrunePolicy,
28
+ PruneReason,
29
+ PruneResult,
30
+ PruneSummary,
31
+ StepDecay,
40
32
  )
41
33
  from alma.learning.heuristic_extractor import (
34
+ ExtractionResult,
42
35
  HeuristicExtractor,
43
36
  PatternCandidate,
44
- ExtractionResult,
45
37
  extract_heuristics_from_outcome,
46
38
  )
39
+ from alma.learning.protocols import LearningProtocol
40
+ from alma.learning.validation import (
41
+ ScopeValidator,
42
+ TaskTypeValidator,
43
+ ValidationReport,
44
+ ValidationResult,
45
+ validate_learning_request,
46
+ )
47
47
 
48
48
  __all__ = [
49
49
  # Core Protocol