alma-memory 0.4.0__py3-none-any.whl → 0.5.1__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 (94) hide show
  1. alma/__init__.py +121 -45
  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 +136 -28
  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 +265 -0
  22. alma/extraction/extractor.py +420 -0
  23. alma/graph/__init__.py +106 -0
  24. alma/graph/backends/__init__.py +32 -0
  25. alma/graph/backends/kuzu.py +624 -0
  26. alma/graph/backends/memgraph.py +432 -0
  27. alma/graph/backends/memory.py +236 -0
  28. alma/graph/backends/neo4j.py +417 -0
  29. alma/graph/base.py +159 -0
  30. alma/graph/extraction.py +198 -0
  31. alma/graph/store.py +860 -0
  32. alma/harness/__init__.py +4 -4
  33. alma/harness/base.py +18 -9
  34. alma/harness/domains.py +27 -11
  35. alma/initializer/__init__.py +1 -1
  36. alma/initializer/initializer.py +51 -43
  37. alma/initializer/types.py +25 -17
  38. alma/integration/__init__.py +9 -9
  39. alma/integration/claude_agents.py +32 -20
  40. alma/integration/helena.py +32 -22
  41. alma/integration/victor.py +57 -33
  42. alma/learning/__init__.py +27 -27
  43. alma/learning/forgetting.py +198 -148
  44. alma/learning/heuristic_extractor.py +40 -24
  45. alma/learning/protocols.py +65 -17
  46. alma/learning/validation.py +7 -2
  47. alma/mcp/__init__.py +4 -4
  48. alma/mcp/__main__.py +2 -1
  49. alma/mcp/resources.py +17 -16
  50. alma/mcp/server.py +102 -44
  51. alma/mcp/tools.py +180 -45
  52. alma/observability/__init__.py +84 -0
  53. alma/observability/config.py +302 -0
  54. alma/observability/logging.py +424 -0
  55. alma/observability/metrics.py +583 -0
  56. alma/observability/tracing.py +440 -0
  57. alma/progress/__init__.py +3 -3
  58. alma/progress/tracker.py +26 -20
  59. alma/progress/types.py +8 -12
  60. alma/py.typed +0 -0
  61. alma/retrieval/__init__.py +11 -11
  62. alma/retrieval/cache.py +20 -21
  63. alma/retrieval/embeddings.py +4 -4
  64. alma/retrieval/engine.py +179 -39
  65. alma/retrieval/scoring.py +73 -63
  66. alma/session/__init__.py +2 -2
  67. alma/session/manager.py +5 -5
  68. alma/session/types.py +5 -4
  69. alma/storage/__init__.py +70 -0
  70. alma/storage/azure_cosmos.py +414 -133
  71. alma/storage/base.py +215 -4
  72. alma/storage/chroma.py +1443 -0
  73. alma/storage/constants.py +103 -0
  74. alma/storage/file_based.py +59 -28
  75. alma/storage/migrations/__init__.py +21 -0
  76. alma/storage/migrations/base.py +321 -0
  77. alma/storage/migrations/runner.py +323 -0
  78. alma/storage/migrations/version_stores.py +337 -0
  79. alma/storage/migrations/versions/__init__.py +11 -0
  80. alma/storage/migrations/versions/v1_0_0.py +373 -0
  81. alma/storage/pinecone.py +1080 -0
  82. alma/storage/postgresql.py +1559 -0
  83. alma/storage/qdrant.py +1306 -0
  84. alma/storage/sqlite_local.py +504 -60
  85. alma/testing/__init__.py +46 -0
  86. alma/testing/factories.py +301 -0
  87. alma/testing/mocks.py +389 -0
  88. alma/types.py +62 -14
  89. alma_memory-0.5.1.dist-info/METADATA +939 -0
  90. alma_memory-0.5.1.dist-info/RECORD +93 -0
  91. {alma_memory-0.4.0.dist-info → alma_memory-0.5.1.dist-info}/WHEEL +1 -1
  92. alma_memory-0.4.0.dist-info/METADATA +0 -488
  93. alma_memory-0.4.0.dist-info/RECORD +0 -52
  94. {alma_memory-0.4.0.dist-info → alma_memory-0.5.1.dist-info}/top_level.txt +0 -0
alma/session/manager.py CHANGED
@@ -4,14 +4,14 @@ Session Manager.
4
4
  Manages session continuity, handoffs, and quick context reload.
5
5
  """
6
6
 
7
- from datetime import datetime, timezone
8
- from typing import Optional, List, Dict, Any, Callable
9
- import uuid
10
7
  import logging
8
+ import uuid
9
+ from datetime import datetime, timezone
10
+ from typing import Any, Callable, Dict, List, Optional
11
11
 
12
12
  from alma.session.types import (
13
- SessionHandoff,
14
13
  SessionContext,
14
+ SessionHandoff,
15
15
  SessionOutcome,
16
16
  )
17
17
 
@@ -281,7 +281,7 @@ class SessionManager:
281
281
 
282
282
  # Trim to max
283
283
  if len(self._handoffs[agent]) > self.max_handoffs:
284
- self._handoffs[agent] = self._handoffs[agent][-self.max_handoffs:]
284
+ self._handoffs[agent] = self._handoffs[agent][-self.max_handoffs :]
285
285
 
286
286
  # TODO: Persist to storage backend when integrated
287
287
 
alma/session/types.py CHANGED
@@ -4,11 +4,10 @@ Session Management Types.
4
4
  Data models for session continuity and handoffs.
5
5
  """
6
6
 
7
+ import uuid
7
8
  from dataclasses import dataclass, field
8
9
  from datetime import datetime, timezone
9
- from typing import Optional, List, Dict, Any, Literal
10
- import uuid
11
-
10
+ from typing import Any, Dict, List, Literal, Optional
12
11
 
13
12
  SessionOutcome = Literal["success", "failure", "interrupted", "unknown"]
14
13
 
@@ -276,7 +275,9 @@ class SessionContext:
276
275
  if "branch" in self.codebase_state:
277
276
  lines.append(f"Branch: {self.codebase_state['branch']}")
278
277
  if "uncommitted" in self.codebase_state:
279
- lines.append(f"Uncommitted Changes: {self.codebase_state['uncommitted']}")
278
+ lines.append(
279
+ f"Uncommitted Changes: {self.codebase_state['uncommitted']}"
280
+ )
280
281
 
281
282
  # Rules
282
283
  if self.rules_of_engagement:
alma/storage/__init__.py CHANGED
@@ -1,20 +1,90 @@
1
1
  """ALMA Storage Backends."""
2
2
 
3
3
  from alma.storage.base import StorageBackend
4
+ from alma.storage.constants import (
5
+ AZURE_COSMOS_CONTAINER_NAMES,
6
+ POSTGRESQL_TABLE_NAMES,
7
+ SQLITE_TABLE_NAMES,
8
+ MemoryType,
9
+ get_table_name,
10
+ get_table_names,
11
+ )
4
12
  from alma.storage.file_based import FileBasedStorage
13
+ from alma.storage.migrations import (
14
+ Migration,
15
+ MigrationError,
16
+ MigrationRegistry,
17
+ MigrationRunner,
18
+ SchemaVersion,
19
+ )
5
20
  from alma.storage.sqlite_local import SQLiteStorage
6
21
 
7
22
  # Azure Cosmos DB is optional - requires azure-cosmos package
8
23
  try:
9
24
  from alma.storage.azure_cosmos import AzureCosmosStorage
25
+
10
26
  _HAS_AZURE = True
11
27
  except ImportError:
12
28
  AzureCosmosStorage = None # type: ignore
13
29
  _HAS_AZURE = False
14
30
 
31
+ # PostgreSQL is optional - requires psycopg package
32
+ try:
33
+ from alma.storage.postgresql import PostgreSQLStorage
34
+
35
+ _HAS_POSTGRES = True
36
+ except ImportError:
37
+ PostgreSQLStorage = None # type: ignore
38
+ _HAS_POSTGRES = False
39
+
40
+ # Qdrant is optional - requires qdrant-client package
41
+ try:
42
+ from alma.storage.qdrant import QdrantStorage
43
+
44
+ _HAS_QDRANT = True
45
+ except ImportError:
46
+ QdrantStorage = None # type: ignore
47
+ _HAS_QDRANT = False
48
+
49
+ # ChromaDB is optional - requires chromadb package
50
+ try:
51
+ from alma.storage.chroma import ChromaStorage
52
+
53
+ _HAS_CHROMA = True
54
+ except ImportError:
55
+ ChromaStorage = None # type: ignore
56
+ _HAS_CHROMA = False
57
+
58
+ # Pinecone is optional - requires pinecone-client package
59
+ try:
60
+ from alma.storage.pinecone import PineconeStorage
61
+
62
+ _HAS_PINECONE = True
63
+ except ImportError:
64
+ PineconeStorage = None # type: ignore
65
+ _HAS_PINECONE = False
66
+
15
67
  __all__ = [
68
+ # Storage backends
16
69
  "StorageBackend",
17
70
  "FileBasedStorage",
18
71
  "SQLiteStorage",
19
72
  "AzureCosmosStorage",
73
+ "PostgreSQLStorage",
74
+ "QdrantStorage",
75
+ "ChromaStorage",
76
+ "PineconeStorage",
77
+ # Migration framework
78
+ "Migration",
79
+ "MigrationError",
80
+ "MigrationRegistry",
81
+ "MigrationRunner",
82
+ "SchemaVersion",
83
+ # Constants for consistent naming
84
+ "MemoryType",
85
+ "get_table_name",
86
+ "get_table_names",
87
+ "POSTGRESQL_TABLE_NAMES",
88
+ "SQLITE_TABLE_NAMES",
89
+ "AZURE_COSMOS_CONTAINER_NAMES",
20
90
  ]