alma-memory 0.5.1__py3-none-any.whl → 0.7.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.
- alma/__init__.py +296 -226
- alma/compression/__init__.py +33 -0
- alma/compression/pipeline.py +980 -0
- alma/confidence/__init__.py +47 -47
- alma/confidence/engine.py +540 -540
- alma/confidence/types.py +351 -351
- alma/config/loader.py +157 -157
- alma/consolidation/__init__.py +23 -23
- alma/consolidation/engine.py +678 -678
- alma/consolidation/prompts.py +84 -84
- alma/core.py +1189 -430
- alma/domains/__init__.py +30 -30
- alma/domains/factory.py +359 -359
- alma/domains/schemas.py +448 -448
- alma/domains/types.py +272 -272
- alma/events/__init__.py +75 -75
- alma/events/emitter.py +285 -284
- alma/events/storage_mixin.py +246 -246
- alma/events/types.py +126 -126
- alma/events/webhook.py +425 -425
- alma/exceptions.py +49 -49
- alma/extraction/__init__.py +31 -31
- alma/extraction/auto_learner.py +265 -265
- alma/extraction/extractor.py +420 -420
- alma/graph/__init__.py +106 -106
- alma/graph/backends/__init__.py +32 -32
- alma/graph/backends/kuzu.py +624 -624
- alma/graph/backends/memgraph.py +432 -432
- alma/graph/backends/memory.py +236 -236
- alma/graph/backends/neo4j.py +417 -417
- alma/graph/base.py +159 -159
- alma/graph/extraction.py +198 -198
- alma/graph/store.py +860 -860
- alma/harness/__init__.py +35 -35
- alma/harness/base.py +386 -386
- alma/harness/domains.py +705 -705
- alma/initializer/__init__.py +37 -37
- alma/initializer/initializer.py +418 -418
- alma/initializer/types.py +250 -250
- alma/integration/__init__.py +62 -62
- alma/integration/claude_agents.py +444 -444
- alma/integration/helena.py +423 -423
- alma/integration/victor.py +471 -471
- alma/learning/__init__.py +101 -86
- alma/learning/decay.py +878 -0
- alma/learning/forgetting.py +1446 -1446
- alma/learning/heuristic_extractor.py +390 -390
- alma/learning/protocols.py +374 -374
- alma/learning/validation.py +346 -346
- alma/mcp/__init__.py +123 -45
- alma/mcp/__main__.py +156 -156
- alma/mcp/resources.py +122 -122
- alma/mcp/server.py +955 -591
- alma/mcp/tools.py +3254 -509
- alma/observability/__init__.py +91 -84
- alma/observability/config.py +302 -302
- alma/observability/guidelines.py +170 -0
- alma/observability/logging.py +424 -424
- alma/observability/metrics.py +583 -583
- alma/observability/tracing.py +440 -440
- alma/progress/__init__.py +21 -21
- alma/progress/tracker.py +607 -607
- alma/progress/types.py +250 -250
- alma/retrieval/__init__.py +134 -53
- alma/retrieval/budget.py +525 -0
- alma/retrieval/cache.py +1304 -1061
- alma/retrieval/embeddings.py +202 -202
- alma/retrieval/engine.py +850 -427
- alma/retrieval/modes.py +365 -0
- alma/retrieval/progressive.py +560 -0
- alma/retrieval/scoring.py +344 -344
- alma/retrieval/trust_scoring.py +637 -0
- alma/retrieval/verification.py +797 -0
- alma/session/__init__.py +19 -19
- alma/session/manager.py +442 -399
- alma/session/types.py +288 -288
- alma/storage/__init__.py +101 -90
- alma/storage/archive.py +233 -0
- alma/storage/azure_cosmos.py +1259 -1259
- alma/storage/base.py +1083 -583
- alma/storage/chroma.py +1443 -1443
- alma/storage/constants.py +103 -103
- alma/storage/file_based.py +614 -614
- alma/storage/migrations/__init__.py +21 -21
- alma/storage/migrations/base.py +321 -321
- alma/storage/migrations/runner.py +323 -323
- alma/storage/migrations/version_stores.py +337 -337
- alma/storage/migrations/versions/__init__.py +11 -11
- alma/storage/migrations/versions/v1_0_0.py +373 -373
- alma/storage/migrations/versions/v1_1_0_workflow_context.py +551 -0
- alma/storage/pinecone.py +1080 -1080
- alma/storage/postgresql.py +1948 -1559
- alma/storage/qdrant.py +1306 -1306
- alma/storage/sqlite_local.py +3041 -1457
- alma/testing/__init__.py +46 -46
- alma/testing/factories.py +301 -301
- alma/testing/mocks.py +389 -389
- alma/types.py +292 -264
- alma/utils/__init__.py +19 -0
- alma/utils/tokenizer.py +521 -0
- alma/workflow/__init__.py +83 -0
- alma/workflow/artifacts.py +170 -0
- alma/workflow/checkpoint.py +311 -0
- alma/workflow/context.py +228 -0
- alma/workflow/outcomes.py +189 -0
- alma/workflow/reducers.py +393 -0
- {alma_memory-0.5.1.dist-info → alma_memory-0.7.0.dist-info}/METADATA +210 -72
- alma_memory-0.7.0.dist-info/RECORD +112 -0
- alma_memory-0.5.1.dist-info/RECORD +0 -93
- {alma_memory-0.5.1.dist-info → alma_memory-0.7.0.dist-info}/WHEEL +0 -0
- {alma_memory-0.5.1.dist-info → alma_memory-0.7.0.dist-info}/top_level.txt +0 -0
alma/domains/schemas.py
CHANGED
|
@@ -1,448 +1,448 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Pre-built Domain Schemas.
|
|
3
|
-
|
|
4
|
-
Standard domain schemas for common use cases.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from alma.domains.types import DomainSchema
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def get_coding_schema() -> DomainSchema:
|
|
11
|
-
"""
|
|
12
|
-
Pre-built schema for coding workflows.
|
|
13
|
-
|
|
14
|
-
This is the formalized version of ALMA's original Helena/Victor schema.
|
|
15
|
-
Suitable for: Frontend testing, backend testing, general development.
|
|
16
|
-
"""
|
|
17
|
-
schema = DomainSchema.create(
|
|
18
|
-
name="coding",
|
|
19
|
-
description="Memory schema for software development workflows",
|
|
20
|
-
learning_categories=[
|
|
21
|
-
"testing_strategies",
|
|
22
|
-
"selector_patterns",
|
|
23
|
-
"api_design_patterns",
|
|
24
|
-
"error_handling",
|
|
25
|
-
"performance_optimization",
|
|
26
|
-
"debugging_techniques",
|
|
27
|
-
"code_review_patterns",
|
|
28
|
-
"refactoring_strategies",
|
|
29
|
-
],
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
# Entity types
|
|
33
|
-
schema.add_entity_type(
|
|
34
|
-
name="feature",
|
|
35
|
-
description="A software feature or capability",
|
|
36
|
-
attributes=["status", "tests", "files", "priority", "owner"],
|
|
37
|
-
)
|
|
38
|
-
schema.add_entity_type(
|
|
39
|
-
name="bug",
|
|
40
|
-
description="A software defect or issue",
|
|
41
|
-
attributes=["severity", "reproduction_steps", "fix", "status", "root_cause"],
|
|
42
|
-
)
|
|
43
|
-
schema.add_entity_type(
|
|
44
|
-
name="test",
|
|
45
|
-
description="A test case or test suite",
|
|
46
|
-
attributes=["type", "status", "coverage", "flaky", "last_run"],
|
|
47
|
-
)
|
|
48
|
-
schema.add_entity_type(
|
|
49
|
-
name="component",
|
|
50
|
-
description="A code component or module",
|
|
51
|
-
attributes=["path", "type", "dependencies", "tests"],
|
|
52
|
-
)
|
|
53
|
-
schema.add_entity_type(
|
|
54
|
-
name="api_endpoint",
|
|
55
|
-
description="An API endpoint",
|
|
56
|
-
attributes=["method", "path", "request_schema", "response_schema", "auth"],
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
# Relationships
|
|
60
|
-
schema.add_relationship_type(
|
|
61
|
-
name="tests",
|
|
62
|
-
description="Test covers a feature or component",
|
|
63
|
-
source_type="test",
|
|
64
|
-
target_type="feature",
|
|
65
|
-
)
|
|
66
|
-
schema.add_relationship_type(
|
|
67
|
-
name="fixes",
|
|
68
|
-
description="Commit or change fixes a bug",
|
|
69
|
-
source_type="feature",
|
|
70
|
-
target_type="bug",
|
|
71
|
-
)
|
|
72
|
-
schema.add_relationship_type(
|
|
73
|
-
name="depends_on",
|
|
74
|
-
description="Component depends on another component",
|
|
75
|
-
source_type="component",
|
|
76
|
-
target_type="component",
|
|
77
|
-
)
|
|
78
|
-
schema.add_relationship_type(
|
|
79
|
-
name="implements",
|
|
80
|
-
description="Component implements an API endpoint",
|
|
81
|
-
source_type="component",
|
|
82
|
-
target_type="api_endpoint",
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
return schema
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
def get_research_schema() -> DomainSchema:
|
|
89
|
-
"""
|
|
90
|
-
Pre-built schema for research workflows.
|
|
91
|
-
|
|
92
|
-
Suitable for: Literature review, hypothesis testing, academic research.
|
|
93
|
-
"""
|
|
94
|
-
schema = DomainSchema.create(
|
|
95
|
-
name="research",
|
|
96
|
-
description="Memory schema for research and academic workflows",
|
|
97
|
-
learning_categories=[
|
|
98
|
-
"literature_review_patterns",
|
|
99
|
-
"methodology_selection",
|
|
100
|
-
"data_analysis_strategies",
|
|
101
|
-
"citation_patterns",
|
|
102
|
-
"hypothesis_formulation",
|
|
103
|
-
"experiment_design",
|
|
104
|
-
"peer_review_patterns",
|
|
105
|
-
"synthesis_techniques",
|
|
106
|
-
],
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
# Entity types
|
|
110
|
-
schema.add_entity_type(
|
|
111
|
-
name="paper",
|
|
112
|
-
description="An academic paper or article",
|
|
113
|
-
attributes=[
|
|
114
|
-
"title",
|
|
115
|
-
"authors",
|
|
116
|
-
"year",
|
|
117
|
-
"citations",
|
|
118
|
-
"abstract",
|
|
119
|
-
"venue",
|
|
120
|
-
"doi",
|
|
121
|
-
],
|
|
122
|
-
)
|
|
123
|
-
schema.add_entity_type(
|
|
124
|
-
name="hypothesis",
|
|
125
|
-
description="A research hypothesis",
|
|
126
|
-
attributes=[
|
|
127
|
-
"statement",
|
|
128
|
-
"confidence",
|
|
129
|
-
"evidence_for",
|
|
130
|
-
"evidence_against",
|
|
131
|
-
"status",
|
|
132
|
-
],
|
|
133
|
-
)
|
|
134
|
-
schema.add_entity_type(
|
|
135
|
-
name="experiment",
|
|
136
|
-
description="An experiment or study",
|
|
137
|
-
attributes=["method", "results", "conclusions", "status", "sample_size"],
|
|
138
|
-
)
|
|
139
|
-
schema.add_entity_type(
|
|
140
|
-
name="dataset",
|
|
141
|
-
description="A dataset used in research",
|
|
142
|
-
attributes=["name", "size", "format", "source", "license"],
|
|
143
|
-
)
|
|
144
|
-
schema.add_entity_type(
|
|
145
|
-
name="finding",
|
|
146
|
-
description="A research finding or insight",
|
|
147
|
-
attributes=["summary", "significance", "confidence", "supporting_evidence"],
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
# Relationships
|
|
151
|
-
schema.add_relationship_type(
|
|
152
|
-
name="cites",
|
|
153
|
-
description="Paper cites another paper",
|
|
154
|
-
source_type="paper",
|
|
155
|
-
target_type="paper",
|
|
156
|
-
)
|
|
157
|
-
schema.add_relationship_type(
|
|
158
|
-
name="tests",
|
|
159
|
-
description="Experiment tests a hypothesis",
|
|
160
|
-
source_type="experiment",
|
|
161
|
-
target_type="hypothesis",
|
|
162
|
-
)
|
|
163
|
-
schema.add_relationship_type(
|
|
164
|
-
name="uses",
|
|
165
|
-
description="Experiment uses a dataset",
|
|
166
|
-
source_type="experiment",
|
|
167
|
-
target_type="dataset",
|
|
168
|
-
)
|
|
169
|
-
schema.add_relationship_type(
|
|
170
|
-
name="supports",
|
|
171
|
-
description="Finding supports a hypothesis",
|
|
172
|
-
source_type="finding",
|
|
173
|
-
target_type="hypothesis",
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
return schema
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def get_sales_schema() -> DomainSchema:
|
|
180
|
-
"""
|
|
181
|
-
Pre-built schema for sales workflows.
|
|
182
|
-
|
|
183
|
-
Suitable for: Lead management, customer conversations, deal tracking.
|
|
184
|
-
"""
|
|
185
|
-
schema = DomainSchema.create(
|
|
186
|
-
name="sales",
|
|
187
|
-
description="Memory schema for sales and customer engagement workflows",
|
|
188
|
-
learning_categories=[
|
|
189
|
-
"objection_handling",
|
|
190
|
-
"closing_techniques",
|
|
191
|
-
"qualification_patterns",
|
|
192
|
-
"follow_up_timing",
|
|
193
|
-
"value_proposition",
|
|
194
|
-
"discovery_questions",
|
|
195
|
-
"relationship_building",
|
|
196
|
-
"negotiation_strategies",
|
|
197
|
-
],
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
# Entity types
|
|
201
|
-
schema.add_entity_type(
|
|
202
|
-
name="lead",
|
|
203
|
-
description="A potential customer or prospect",
|
|
204
|
-
attributes=["stage", "value", "next_action", "source", "company", "title"],
|
|
205
|
-
)
|
|
206
|
-
schema.add_entity_type(
|
|
207
|
-
name="objection",
|
|
208
|
-
description="A customer objection or concern",
|
|
209
|
-
attributes=["type", "response", "outcome", "context"],
|
|
210
|
-
)
|
|
211
|
-
schema.add_entity_type(
|
|
212
|
-
name="conversation",
|
|
213
|
-
description="A customer interaction",
|
|
214
|
-
attributes=["channel", "sentiment", "result", "summary", "follow_up"],
|
|
215
|
-
)
|
|
216
|
-
schema.add_entity_type(
|
|
217
|
-
name="deal",
|
|
218
|
-
description="A sales deal or opportunity",
|
|
219
|
-
attributes=["stage", "value", "close_date", "probability", "stakeholders"],
|
|
220
|
-
)
|
|
221
|
-
schema.add_entity_type(
|
|
222
|
-
name="product",
|
|
223
|
-
description="A product or service being sold",
|
|
224
|
-
attributes=["name", "price", "features", "competitors"],
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
# Relationships
|
|
228
|
-
schema.add_relationship_type(
|
|
229
|
-
name="converts_to",
|
|
230
|
-
description="Lead converts to a deal",
|
|
231
|
-
source_type="lead",
|
|
232
|
-
target_type="deal",
|
|
233
|
-
)
|
|
234
|
-
schema.add_relationship_type(
|
|
235
|
-
name="raised",
|
|
236
|
-
description="Lead raised an objection",
|
|
237
|
-
source_type="lead",
|
|
238
|
-
target_type="objection",
|
|
239
|
-
)
|
|
240
|
-
schema.add_relationship_type(
|
|
241
|
-
name="had",
|
|
242
|
-
description="Lead had a conversation",
|
|
243
|
-
source_type="lead",
|
|
244
|
-
target_type="conversation",
|
|
245
|
-
)
|
|
246
|
-
schema.add_relationship_type(
|
|
247
|
-
name="interested_in",
|
|
248
|
-
description="Lead is interested in a product",
|
|
249
|
-
source_type="lead",
|
|
250
|
-
target_type="product",
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
return schema
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
def get_general_schema() -> DomainSchema:
|
|
257
|
-
"""
|
|
258
|
-
Minimal schema for general-purpose agents.
|
|
259
|
-
|
|
260
|
-
This is a flexible schema that can be extended for any domain.
|
|
261
|
-
Suitable for: General assistants, tool-using agents, custom workflows.
|
|
262
|
-
"""
|
|
263
|
-
schema = DomainSchema.create(
|
|
264
|
-
name="general",
|
|
265
|
-
description="Minimal, flexible schema for general-purpose agents",
|
|
266
|
-
learning_categories=[
|
|
267
|
-
"task_patterns",
|
|
268
|
-
"error_recovery",
|
|
269
|
-
"tool_usage",
|
|
270
|
-
"efficiency_patterns",
|
|
271
|
-
"user_preferences",
|
|
272
|
-
"context_switching",
|
|
273
|
-
],
|
|
274
|
-
)
|
|
275
|
-
|
|
276
|
-
# Entity types (minimal but extensible)
|
|
277
|
-
schema.add_entity_type(
|
|
278
|
-
name="task",
|
|
279
|
-
description="A unit of work to be completed",
|
|
280
|
-
attributes=["title", "status", "priority", "category"],
|
|
281
|
-
)
|
|
282
|
-
schema.add_entity_type(
|
|
283
|
-
name="resource",
|
|
284
|
-
description="A resource used or created",
|
|
285
|
-
attributes=["type", "path", "status", "metadata"],
|
|
286
|
-
)
|
|
287
|
-
schema.add_entity_type(
|
|
288
|
-
name="goal",
|
|
289
|
-
description="An objective or target",
|
|
290
|
-
attributes=["description", "status", "deadline", "progress"],
|
|
291
|
-
)
|
|
292
|
-
schema.add_entity_type(
|
|
293
|
-
name="context",
|
|
294
|
-
description="A context or environment state",
|
|
295
|
-
attributes=["name", "state", "active"],
|
|
296
|
-
)
|
|
297
|
-
|
|
298
|
-
# Relationships (minimal)
|
|
299
|
-
schema.add_relationship_type(
|
|
300
|
-
name="achieves",
|
|
301
|
-
description="Task contributes to a goal",
|
|
302
|
-
source_type="task",
|
|
303
|
-
target_type="goal",
|
|
304
|
-
)
|
|
305
|
-
schema.add_relationship_type(
|
|
306
|
-
name="uses",
|
|
307
|
-
description="Task uses a resource",
|
|
308
|
-
source_type="task",
|
|
309
|
-
target_type="resource",
|
|
310
|
-
)
|
|
311
|
-
schema.add_relationship_type(
|
|
312
|
-
name="requires",
|
|
313
|
-
description="Task requires a context",
|
|
314
|
-
source_type="task",
|
|
315
|
-
target_type="context",
|
|
316
|
-
)
|
|
317
|
-
|
|
318
|
-
return schema
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
def get_customer_support_schema() -> DomainSchema:
|
|
322
|
-
"""
|
|
323
|
-
Pre-built schema for customer support workflows.
|
|
324
|
-
|
|
325
|
-
Suitable for: Ticket handling, escalation, knowledge base management.
|
|
326
|
-
"""
|
|
327
|
-
schema = DomainSchema.create(
|
|
328
|
-
name="customer_support",
|
|
329
|
-
description="Memory schema for customer support workflows",
|
|
330
|
-
learning_categories=[
|
|
331
|
-
"issue_classification",
|
|
332
|
-
"resolution_patterns",
|
|
333
|
-
"escalation_criteria",
|
|
334
|
-
"customer_sentiment",
|
|
335
|
-
"knowledge_retrieval",
|
|
336
|
-
"follow_up_patterns",
|
|
337
|
-
"edge_case_handling",
|
|
338
|
-
],
|
|
339
|
-
)
|
|
340
|
-
|
|
341
|
-
# Entity types
|
|
342
|
-
schema.add_entity_type(
|
|
343
|
-
name="ticket",
|
|
344
|
-
description="A customer support ticket",
|
|
345
|
-
attributes=["status", "priority", "category", "customer_id", "resolution"],
|
|
346
|
-
)
|
|
347
|
-
schema.add_entity_type(
|
|
348
|
-
name="article",
|
|
349
|
-
description="A knowledge base article",
|
|
350
|
-
attributes=["title", "content", "category", "views", "helpful_votes"],
|
|
351
|
-
)
|
|
352
|
-
schema.add_entity_type(
|
|
353
|
-
name="customer",
|
|
354
|
-
description="A customer profile",
|
|
355
|
-
attributes=["tier", "history", "sentiment", "preferences"],
|
|
356
|
-
)
|
|
357
|
-
schema.add_entity_type(
|
|
358
|
-
name="issue",
|
|
359
|
-
description="A known issue or problem",
|
|
360
|
-
attributes=["description", "status", "workaround", "affected_customers"],
|
|
361
|
-
)
|
|
362
|
-
|
|
363
|
-
# Relationships
|
|
364
|
-
schema.add_relationship_type(
|
|
365
|
-
name="resolves",
|
|
366
|
-
description="Article resolves a ticket",
|
|
367
|
-
source_type="article",
|
|
368
|
-
target_type="ticket",
|
|
369
|
-
)
|
|
370
|
-
schema.add_relationship_type(
|
|
371
|
-
name="submitted_by",
|
|
372
|
-
description="Ticket submitted by customer",
|
|
373
|
-
source_type="ticket",
|
|
374
|
-
target_type="customer",
|
|
375
|
-
)
|
|
376
|
-
schema.add_relationship_type(
|
|
377
|
-
name="related_to",
|
|
378
|
-
description="Ticket related to a known issue",
|
|
379
|
-
source_type="ticket",
|
|
380
|
-
target_type="issue",
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
return schema
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
def get_content_creation_schema() -> DomainSchema:
|
|
387
|
-
"""
|
|
388
|
-
Pre-built schema for content creation workflows.
|
|
389
|
-
|
|
390
|
-
Suitable for: Blog writing, social media, marketing content.
|
|
391
|
-
"""
|
|
392
|
-
schema = DomainSchema.create(
|
|
393
|
-
name="content_creation",
|
|
394
|
-
description="Memory schema for content creation workflows",
|
|
395
|
-
learning_categories=[
|
|
396
|
-
"writing_patterns",
|
|
397
|
-
"engagement_optimization",
|
|
398
|
-
"audience_targeting",
|
|
399
|
-
"seo_strategies",
|
|
400
|
-
"content_formatting",
|
|
401
|
-
"voice_and_tone",
|
|
402
|
-
"visual_content_patterns",
|
|
403
|
-
],
|
|
404
|
-
)
|
|
405
|
-
|
|
406
|
-
# Entity types
|
|
407
|
-
schema.add_entity_type(
|
|
408
|
-
name="content",
|
|
409
|
-
description="A piece of content",
|
|
410
|
-
attributes=["type", "title", "status", "platform", "performance_metrics"],
|
|
411
|
-
)
|
|
412
|
-
schema.add_entity_type(
|
|
413
|
-
name="audience",
|
|
414
|
-
description="A target audience segment",
|
|
415
|
-
attributes=["name", "demographics", "interests", "pain_points"],
|
|
416
|
-
)
|
|
417
|
-
schema.add_entity_type(
|
|
418
|
-
name="campaign",
|
|
419
|
-
description="A content campaign",
|
|
420
|
-
attributes=["name", "goal", "start_date", "end_date", "budget"],
|
|
421
|
-
)
|
|
422
|
-
schema.add_entity_type(
|
|
423
|
-
name="template",
|
|
424
|
-
description="A content template",
|
|
425
|
-
attributes=["type", "structure", "usage_count", "effectiveness"],
|
|
426
|
-
)
|
|
427
|
-
|
|
428
|
-
# Relationships
|
|
429
|
-
schema.add_relationship_type(
|
|
430
|
-
name="targets",
|
|
431
|
-
description="Content targets an audience",
|
|
432
|
-
source_type="content",
|
|
433
|
-
target_type="audience",
|
|
434
|
-
)
|
|
435
|
-
schema.add_relationship_type(
|
|
436
|
-
name="part_of",
|
|
437
|
-
description="Content is part of a campaign",
|
|
438
|
-
source_type="content",
|
|
439
|
-
target_type="campaign",
|
|
440
|
-
)
|
|
441
|
-
schema.add_relationship_type(
|
|
442
|
-
name="uses",
|
|
443
|
-
description="Content uses a template",
|
|
444
|
-
source_type="content",
|
|
445
|
-
target_type="template",
|
|
446
|
-
)
|
|
447
|
-
|
|
448
|
-
return schema
|
|
1
|
+
"""
|
|
2
|
+
Pre-built Domain Schemas.
|
|
3
|
+
|
|
4
|
+
Standard domain schemas for common use cases.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from alma.domains.types import DomainSchema
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_coding_schema() -> DomainSchema:
|
|
11
|
+
"""
|
|
12
|
+
Pre-built schema for coding workflows.
|
|
13
|
+
|
|
14
|
+
This is the formalized version of ALMA's original Helena/Victor schema.
|
|
15
|
+
Suitable for: Frontend testing, backend testing, general development.
|
|
16
|
+
"""
|
|
17
|
+
schema = DomainSchema.create(
|
|
18
|
+
name="coding",
|
|
19
|
+
description="Memory schema for software development workflows",
|
|
20
|
+
learning_categories=[
|
|
21
|
+
"testing_strategies",
|
|
22
|
+
"selector_patterns",
|
|
23
|
+
"api_design_patterns",
|
|
24
|
+
"error_handling",
|
|
25
|
+
"performance_optimization",
|
|
26
|
+
"debugging_techniques",
|
|
27
|
+
"code_review_patterns",
|
|
28
|
+
"refactoring_strategies",
|
|
29
|
+
],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Entity types
|
|
33
|
+
schema.add_entity_type(
|
|
34
|
+
name="feature",
|
|
35
|
+
description="A software feature or capability",
|
|
36
|
+
attributes=["status", "tests", "files", "priority", "owner"],
|
|
37
|
+
)
|
|
38
|
+
schema.add_entity_type(
|
|
39
|
+
name="bug",
|
|
40
|
+
description="A software defect or issue",
|
|
41
|
+
attributes=["severity", "reproduction_steps", "fix", "status", "root_cause"],
|
|
42
|
+
)
|
|
43
|
+
schema.add_entity_type(
|
|
44
|
+
name="test",
|
|
45
|
+
description="A test case or test suite",
|
|
46
|
+
attributes=["type", "status", "coverage", "flaky", "last_run"],
|
|
47
|
+
)
|
|
48
|
+
schema.add_entity_type(
|
|
49
|
+
name="component",
|
|
50
|
+
description="A code component or module",
|
|
51
|
+
attributes=["path", "type", "dependencies", "tests"],
|
|
52
|
+
)
|
|
53
|
+
schema.add_entity_type(
|
|
54
|
+
name="api_endpoint",
|
|
55
|
+
description="An API endpoint",
|
|
56
|
+
attributes=["method", "path", "request_schema", "response_schema", "auth"],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Relationships
|
|
60
|
+
schema.add_relationship_type(
|
|
61
|
+
name="tests",
|
|
62
|
+
description="Test covers a feature or component",
|
|
63
|
+
source_type="test",
|
|
64
|
+
target_type="feature",
|
|
65
|
+
)
|
|
66
|
+
schema.add_relationship_type(
|
|
67
|
+
name="fixes",
|
|
68
|
+
description="Commit or change fixes a bug",
|
|
69
|
+
source_type="feature",
|
|
70
|
+
target_type="bug",
|
|
71
|
+
)
|
|
72
|
+
schema.add_relationship_type(
|
|
73
|
+
name="depends_on",
|
|
74
|
+
description="Component depends on another component",
|
|
75
|
+
source_type="component",
|
|
76
|
+
target_type="component",
|
|
77
|
+
)
|
|
78
|
+
schema.add_relationship_type(
|
|
79
|
+
name="implements",
|
|
80
|
+
description="Component implements an API endpoint",
|
|
81
|
+
source_type="component",
|
|
82
|
+
target_type="api_endpoint",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
return schema
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def get_research_schema() -> DomainSchema:
|
|
89
|
+
"""
|
|
90
|
+
Pre-built schema for research workflows.
|
|
91
|
+
|
|
92
|
+
Suitable for: Literature review, hypothesis testing, academic research.
|
|
93
|
+
"""
|
|
94
|
+
schema = DomainSchema.create(
|
|
95
|
+
name="research",
|
|
96
|
+
description="Memory schema for research and academic workflows",
|
|
97
|
+
learning_categories=[
|
|
98
|
+
"literature_review_patterns",
|
|
99
|
+
"methodology_selection",
|
|
100
|
+
"data_analysis_strategies",
|
|
101
|
+
"citation_patterns",
|
|
102
|
+
"hypothesis_formulation",
|
|
103
|
+
"experiment_design",
|
|
104
|
+
"peer_review_patterns",
|
|
105
|
+
"synthesis_techniques",
|
|
106
|
+
],
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# Entity types
|
|
110
|
+
schema.add_entity_type(
|
|
111
|
+
name="paper",
|
|
112
|
+
description="An academic paper or article",
|
|
113
|
+
attributes=[
|
|
114
|
+
"title",
|
|
115
|
+
"authors",
|
|
116
|
+
"year",
|
|
117
|
+
"citations",
|
|
118
|
+
"abstract",
|
|
119
|
+
"venue",
|
|
120
|
+
"doi",
|
|
121
|
+
],
|
|
122
|
+
)
|
|
123
|
+
schema.add_entity_type(
|
|
124
|
+
name="hypothesis",
|
|
125
|
+
description="A research hypothesis",
|
|
126
|
+
attributes=[
|
|
127
|
+
"statement",
|
|
128
|
+
"confidence",
|
|
129
|
+
"evidence_for",
|
|
130
|
+
"evidence_against",
|
|
131
|
+
"status",
|
|
132
|
+
],
|
|
133
|
+
)
|
|
134
|
+
schema.add_entity_type(
|
|
135
|
+
name="experiment",
|
|
136
|
+
description="An experiment or study",
|
|
137
|
+
attributes=["method", "results", "conclusions", "status", "sample_size"],
|
|
138
|
+
)
|
|
139
|
+
schema.add_entity_type(
|
|
140
|
+
name="dataset",
|
|
141
|
+
description="A dataset used in research",
|
|
142
|
+
attributes=["name", "size", "format", "source", "license"],
|
|
143
|
+
)
|
|
144
|
+
schema.add_entity_type(
|
|
145
|
+
name="finding",
|
|
146
|
+
description="A research finding or insight",
|
|
147
|
+
attributes=["summary", "significance", "confidence", "supporting_evidence"],
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
# Relationships
|
|
151
|
+
schema.add_relationship_type(
|
|
152
|
+
name="cites",
|
|
153
|
+
description="Paper cites another paper",
|
|
154
|
+
source_type="paper",
|
|
155
|
+
target_type="paper",
|
|
156
|
+
)
|
|
157
|
+
schema.add_relationship_type(
|
|
158
|
+
name="tests",
|
|
159
|
+
description="Experiment tests a hypothesis",
|
|
160
|
+
source_type="experiment",
|
|
161
|
+
target_type="hypothesis",
|
|
162
|
+
)
|
|
163
|
+
schema.add_relationship_type(
|
|
164
|
+
name="uses",
|
|
165
|
+
description="Experiment uses a dataset",
|
|
166
|
+
source_type="experiment",
|
|
167
|
+
target_type="dataset",
|
|
168
|
+
)
|
|
169
|
+
schema.add_relationship_type(
|
|
170
|
+
name="supports",
|
|
171
|
+
description="Finding supports a hypothesis",
|
|
172
|
+
source_type="finding",
|
|
173
|
+
target_type="hypothesis",
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
return schema
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def get_sales_schema() -> DomainSchema:
|
|
180
|
+
"""
|
|
181
|
+
Pre-built schema for sales workflows.
|
|
182
|
+
|
|
183
|
+
Suitable for: Lead management, customer conversations, deal tracking.
|
|
184
|
+
"""
|
|
185
|
+
schema = DomainSchema.create(
|
|
186
|
+
name="sales",
|
|
187
|
+
description="Memory schema for sales and customer engagement workflows",
|
|
188
|
+
learning_categories=[
|
|
189
|
+
"objection_handling",
|
|
190
|
+
"closing_techniques",
|
|
191
|
+
"qualification_patterns",
|
|
192
|
+
"follow_up_timing",
|
|
193
|
+
"value_proposition",
|
|
194
|
+
"discovery_questions",
|
|
195
|
+
"relationship_building",
|
|
196
|
+
"negotiation_strategies",
|
|
197
|
+
],
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
# Entity types
|
|
201
|
+
schema.add_entity_type(
|
|
202
|
+
name="lead",
|
|
203
|
+
description="A potential customer or prospect",
|
|
204
|
+
attributes=["stage", "value", "next_action", "source", "company", "title"],
|
|
205
|
+
)
|
|
206
|
+
schema.add_entity_type(
|
|
207
|
+
name="objection",
|
|
208
|
+
description="A customer objection or concern",
|
|
209
|
+
attributes=["type", "response", "outcome", "context"],
|
|
210
|
+
)
|
|
211
|
+
schema.add_entity_type(
|
|
212
|
+
name="conversation",
|
|
213
|
+
description="A customer interaction",
|
|
214
|
+
attributes=["channel", "sentiment", "result", "summary", "follow_up"],
|
|
215
|
+
)
|
|
216
|
+
schema.add_entity_type(
|
|
217
|
+
name="deal",
|
|
218
|
+
description="A sales deal or opportunity",
|
|
219
|
+
attributes=["stage", "value", "close_date", "probability", "stakeholders"],
|
|
220
|
+
)
|
|
221
|
+
schema.add_entity_type(
|
|
222
|
+
name="product",
|
|
223
|
+
description="A product or service being sold",
|
|
224
|
+
attributes=["name", "price", "features", "competitors"],
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
# Relationships
|
|
228
|
+
schema.add_relationship_type(
|
|
229
|
+
name="converts_to",
|
|
230
|
+
description="Lead converts to a deal",
|
|
231
|
+
source_type="lead",
|
|
232
|
+
target_type="deal",
|
|
233
|
+
)
|
|
234
|
+
schema.add_relationship_type(
|
|
235
|
+
name="raised",
|
|
236
|
+
description="Lead raised an objection",
|
|
237
|
+
source_type="lead",
|
|
238
|
+
target_type="objection",
|
|
239
|
+
)
|
|
240
|
+
schema.add_relationship_type(
|
|
241
|
+
name="had",
|
|
242
|
+
description="Lead had a conversation",
|
|
243
|
+
source_type="lead",
|
|
244
|
+
target_type="conversation",
|
|
245
|
+
)
|
|
246
|
+
schema.add_relationship_type(
|
|
247
|
+
name="interested_in",
|
|
248
|
+
description="Lead is interested in a product",
|
|
249
|
+
source_type="lead",
|
|
250
|
+
target_type="product",
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
return schema
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def get_general_schema() -> DomainSchema:
|
|
257
|
+
"""
|
|
258
|
+
Minimal schema for general-purpose agents.
|
|
259
|
+
|
|
260
|
+
This is a flexible schema that can be extended for any domain.
|
|
261
|
+
Suitable for: General assistants, tool-using agents, custom workflows.
|
|
262
|
+
"""
|
|
263
|
+
schema = DomainSchema.create(
|
|
264
|
+
name="general",
|
|
265
|
+
description="Minimal, flexible schema for general-purpose agents",
|
|
266
|
+
learning_categories=[
|
|
267
|
+
"task_patterns",
|
|
268
|
+
"error_recovery",
|
|
269
|
+
"tool_usage",
|
|
270
|
+
"efficiency_patterns",
|
|
271
|
+
"user_preferences",
|
|
272
|
+
"context_switching",
|
|
273
|
+
],
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
# Entity types (minimal but extensible)
|
|
277
|
+
schema.add_entity_type(
|
|
278
|
+
name="task",
|
|
279
|
+
description="A unit of work to be completed",
|
|
280
|
+
attributes=["title", "status", "priority", "category"],
|
|
281
|
+
)
|
|
282
|
+
schema.add_entity_type(
|
|
283
|
+
name="resource",
|
|
284
|
+
description="A resource used or created",
|
|
285
|
+
attributes=["type", "path", "status", "metadata"],
|
|
286
|
+
)
|
|
287
|
+
schema.add_entity_type(
|
|
288
|
+
name="goal",
|
|
289
|
+
description="An objective or target",
|
|
290
|
+
attributes=["description", "status", "deadline", "progress"],
|
|
291
|
+
)
|
|
292
|
+
schema.add_entity_type(
|
|
293
|
+
name="context",
|
|
294
|
+
description="A context or environment state",
|
|
295
|
+
attributes=["name", "state", "active"],
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
# Relationships (minimal)
|
|
299
|
+
schema.add_relationship_type(
|
|
300
|
+
name="achieves",
|
|
301
|
+
description="Task contributes to a goal",
|
|
302
|
+
source_type="task",
|
|
303
|
+
target_type="goal",
|
|
304
|
+
)
|
|
305
|
+
schema.add_relationship_type(
|
|
306
|
+
name="uses",
|
|
307
|
+
description="Task uses a resource",
|
|
308
|
+
source_type="task",
|
|
309
|
+
target_type="resource",
|
|
310
|
+
)
|
|
311
|
+
schema.add_relationship_type(
|
|
312
|
+
name="requires",
|
|
313
|
+
description="Task requires a context",
|
|
314
|
+
source_type="task",
|
|
315
|
+
target_type="context",
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
return schema
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def get_customer_support_schema() -> DomainSchema:
|
|
322
|
+
"""
|
|
323
|
+
Pre-built schema for customer support workflows.
|
|
324
|
+
|
|
325
|
+
Suitable for: Ticket handling, escalation, knowledge base management.
|
|
326
|
+
"""
|
|
327
|
+
schema = DomainSchema.create(
|
|
328
|
+
name="customer_support",
|
|
329
|
+
description="Memory schema for customer support workflows",
|
|
330
|
+
learning_categories=[
|
|
331
|
+
"issue_classification",
|
|
332
|
+
"resolution_patterns",
|
|
333
|
+
"escalation_criteria",
|
|
334
|
+
"customer_sentiment",
|
|
335
|
+
"knowledge_retrieval",
|
|
336
|
+
"follow_up_patterns",
|
|
337
|
+
"edge_case_handling",
|
|
338
|
+
],
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
# Entity types
|
|
342
|
+
schema.add_entity_type(
|
|
343
|
+
name="ticket",
|
|
344
|
+
description="A customer support ticket",
|
|
345
|
+
attributes=["status", "priority", "category", "customer_id", "resolution"],
|
|
346
|
+
)
|
|
347
|
+
schema.add_entity_type(
|
|
348
|
+
name="article",
|
|
349
|
+
description="A knowledge base article",
|
|
350
|
+
attributes=["title", "content", "category", "views", "helpful_votes"],
|
|
351
|
+
)
|
|
352
|
+
schema.add_entity_type(
|
|
353
|
+
name="customer",
|
|
354
|
+
description="A customer profile",
|
|
355
|
+
attributes=["tier", "history", "sentiment", "preferences"],
|
|
356
|
+
)
|
|
357
|
+
schema.add_entity_type(
|
|
358
|
+
name="issue",
|
|
359
|
+
description="A known issue or problem",
|
|
360
|
+
attributes=["description", "status", "workaround", "affected_customers"],
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
# Relationships
|
|
364
|
+
schema.add_relationship_type(
|
|
365
|
+
name="resolves",
|
|
366
|
+
description="Article resolves a ticket",
|
|
367
|
+
source_type="article",
|
|
368
|
+
target_type="ticket",
|
|
369
|
+
)
|
|
370
|
+
schema.add_relationship_type(
|
|
371
|
+
name="submitted_by",
|
|
372
|
+
description="Ticket submitted by customer",
|
|
373
|
+
source_type="ticket",
|
|
374
|
+
target_type="customer",
|
|
375
|
+
)
|
|
376
|
+
schema.add_relationship_type(
|
|
377
|
+
name="related_to",
|
|
378
|
+
description="Ticket related to a known issue",
|
|
379
|
+
source_type="ticket",
|
|
380
|
+
target_type="issue",
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
return schema
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def get_content_creation_schema() -> DomainSchema:
|
|
387
|
+
"""
|
|
388
|
+
Pre-built schema for content creation workflows.
|
|
389
|
+
|
|
390
|
+
Suitable for: Blog writing, social media, marketing content.
|
|
391
|
+
"""
|
|
392
|
+
schema = DomainSchema.create(
|
|
393
|
+
name="content_creation",
|
|
394
|
+
description="Memory schema for content creation workflows",
|
|
395
|
+
learning_categories=[
|
|
396
|
+
"writing_patterns",
|
|
397
|
+
"engagement_optimization",
|
|
398
|
+
"audience_targeting",
|
|
399
|
+
"seo_strategies",
|
|
400
|
+
"content_formatting",
|
|
401
|
+
"voice_and_tone",
|
|
402
|
+
"visual_content_patterns",
|
|
403
|
+
],
|
|
404
|
+
)
|
|
405
|
+
|
|
406
|
+
# Entity types
|
|
407
|
+
schema.add_entity_type(
|
|
408
|
+
name="content",
|
|
409
|
+
description="A piece of content",
|
|
410
|
+
attributes=["type", "title", "status", "platform", "performance_metrics"],
|
|
411
|
+
)
|
|
412
|
+
schema.add_entity_type(
|
|
413
|
+
name="audience",
|
|
414
|
+
description="A target audience segment",
|
|
415
|
+
attributes=["name", "demographics", "interests", "pain_points"],
|
|
416
|
+
)
|
|
417
|
+
schema.add_entity_type(
|
|
418
|
+
name="campaign",
|
|
419
|
+
description="A content campaign",
|
|
420
|
+
attributes=["name", "goal", "start_date", "end_date", "budget"],
|
|
421
|
+
)
|
|
422
|
+
schema.add_entity_type(
|
|
423
|
+
name="template",
|
|
424
|
+
description="A content template",
|
|
425
|
+
attributes=["type", "structure", "usage_count", "effectiveness"],
|
|
426
|
+
)
|
|
427
|
+
|
|
428
|
+
# Relationships
|
|
429
|
+
schema.add_relationship_type(
|
|
430
|
+
name="targets",
|
|
431
|
+
description="Content targets an audience",
|
|
432
|
+
source_type="content",
|
|
433
|
+
target_type="audience",
|
|
434
|
+
)
|
|
435
|
+
schema.add_relationship_type(
|
|
436
|
+
name="part_of",
|
|
437
|
+
description="Content is part of a campaign",
|
|
438
|
+
source_type="content",
|
|
439
|
+
target_type="campaign",
|
|
440
|
+
)
|
|
441
|
+
schema.add_relationship_type(
|
|
442
|
+
name="uses",
|
|
443
|
+
description="Content uses a template",
|
|
444
|
+
source_type="content",
|
|
445
|
+
target_type="template",
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
return schema
|