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/graph/__init__.py ADDED
@@ -0,0 +1,106 @@
1
+ """
2
+ ALMA Graph Memory Module.
3
+
4
+ Graph-based memory for capturing relationships between entities.
5
+ """
6
+
7
+ from alma.graph.base import GraphBackend
8
+ from alma.graph.extraction import (
9
+ EntityExtractor,
10
+ ExtractionConfig,
11
+ )
12
+ from alma.graph.store import (
13
+ BackendGraphStore,
14
+ Entity,
15
+ GraphQuery,
16
+ GraphResult,
17
+ GraphStore,
18
+ InMemoryGraphStore,
19
+ Neo4jGraphStore,
20
+ Relationship,
21
+ create_graph_store,
22
+ )
23
+
24
+ __all__ = [
25
+ # Backend abstract base class
26
+ "GraphBackend",
27
+ # Store classes (high-level API)
28
+ "GraphStore",
29
+ "Neo4jGraphStore",
30
+ "InMemoryGraphStore",
31
+ "BackendGraphStore",
32
+ # Data classes
33
+ "Entity",
34
+ "Relationship",
35
+ "GraphQuery",
36
+ "GraphResult",
37
+ # Extraction
38
+ "EntityExtractor",
39
+ "ExtractionConfig",
40
+ # Factory functions
41
+ "create_graph_store",
42
+ "create_graph_backend",
43
+ ]
44
+
45
+
46
+ def create_graph_backend(backend: str = "neo4j", **config) -> GraphBackend:
47
+ """
48
+ Factory function to create a graph backend.
49
+
50
+ Args:
51
+ backend: Backend type ("neo4j", "memgraph", "kuzu", or "memory")
52
+ **config: Backend-specific configuration options
53
+
54
+ Returns:
55
+ Configured GraphBackend instance
56
+
57
+ Raises:
58
+ ValueError: If an unknown backend type is specified
59
+
60
+ Example:
61
+ # Create Neo4j backend
62
+ backend = create_graph_backend(
63
+ backend="neo4j",
64
+ uri="bolt://localhost:7687",
65
+ username="neo4j",
66
+ password="password"
67
+ )
68
+
69
+ # Create Memgraph backend
70
+ backend = create_graph_backend(
71
+ backend="memgraph",
72
+ uri="bolt://localhost:7687",
73
+ username="",
74
+ password=""
75
+ )
76
+
77
+ # Create Kuzu embedded backend (persistent)
78
+ backend = create_graph_backend(
79
+ backend="kuzu",
80
+ database_path="./my_graph_db"
81
+ )
82
+
83
+ # Create Kuzu embedded backend (in-memory)
84
+ backend = create_graph_backend(backend="kuzu")
85
+
86
+ # Create in-memory backend for testing
87
+ backend = create_graph_backend(backend="memory")
88
+ """
89
+ if backend == "neo4j":
90
+ from alma.graph.backends.neo4j import Neo4jBackend
91
+
92
+ return Neo4jBackend(**config)
93
+ elif backend == "memgraph":
94
+ from alma.graph.backends.memgraph import MemgraphBackend
95
+
96
+ return MemgraphBackend(**config)
97
+ elif backend == "kuzu":
98
+ from alma.graph.backends.kuzu import KuzuBackend
99
+
100
+ return KuzuBackend(**config)
101
+ elif backend == "memory":
102
+ from alma.graph.backends.memory import InMemoryBackend
103
+
104
+ return InMemoryBackend()
105
+ else:
106
+ raise ValueError(f"Unknown graph backend: {backend}")
@@ -0,0 +1,32 @@
1
+ """
2
+ ALMA Graph Memory Backends.
3
+
4
+ This package contains implementations of the GraphBackend interface
5
+ for various graph database systems.
6
+
7
+ Available backends:
8
+ - neo4j: Neo4j graph database backend
9
+ - memgraph: Memgraph graph database backend (Neo4j Bolt protocol compatible)
10
+ - kuzu: Kuzu embedded graph database backend (no server required)
11
+ - memory: In-memory backend for testing and development
12
+ """
13
+
14
+ from alma.graph.backends.memgraph import MemgraphBackend
15
+ from alma.graph.backends.memory import InMemoryBackend
16
+ from alma.graph.backends.neo4j import Neo4jBackend
17
+
18
+ # Kuzu is an optional dependency
19
+ try:
20
+ from alma.graph.backends.kuzu import KuzuBackend
21
+
22
+ _KUZU_AVAILABLE = True
23
+ except ImportError:
24
+ KuzuBackend = None # type: ignore
25
+ _KUZU_AVAILABLE = False
26
+
27
+ __all__ = [
28
+ "Neo4jBackend",
29
+ "MemgraphBackend",
30
+ "KuzuBackend",
31
+ "InMemoryBackend",
32
+ ]