@danielsimonjr/memoryjs 1.9.0 → 1.15.0
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.
- package/README.md +513 -148
- package/dist/cli/index.js +3621 -294
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +12465 -2481
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2766 -306
- package/dist/index.d.ts +2766 -306
- package/dist/index.js +21441 -11464
- package/dist/index.js.map +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# MemoryJS
|
|
2
2
|
|
|
3
|
-
[](https://github.com/danielsimonjr/memoryjs)
|
|
4
4
|
[](https://www.npmjs.com/package/@danielsimonjr/memoryjs)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://github.com/danielsimonjr/memoryjs)
|
|
7
8
|
|
|
8
|
-
A **TypeScript knowledge graph library** for managing entities, relations, and observations with **advanced search
|
|
9
|
+
A **TypeScript knowledge graph library** for managing entities, relations, and observations with **advanced search**, **hierarchical organization**, **bitemporal versioning**, **causal reasoning**, **role-based access control**, **multi-agent collaboration**, and **multiple storage backends**.
|
|
9
10
|
|
|
10
|
-
>
|
|
11
|
+
> Core library powering [@danielsimonjr/memory-mcp](https://www.npmjs.com/package/@danielsimonjr/memory-mcp). **183 TypeScript files**, **62,889 lines of code**, **6157 passing tests**, dual storage backends (JSONL/SQLite + pluggable `IMemoryBackend`), comprehensive search (BM25, TF-IDF, fuzzy with N-gram pre-filter, semantic, hybrid, temporal, LLM-planned, active iterative retrieval), and a complete **Agent Memory System** for AI agents — role profiles, entropy filtering, recursive consolidation, collaborative synthesis with conflict resolution, failure distillation, cognitive load analysis, visibility hierarchies, RBAC, optimistic concurrency, audit attribution, procedural memory, causal reasoning, and a world-model orchestrator.
|
|
11
12
|
|
|
12
13
|
## Table of Contents
|
|
13
14
|
|
|
@@ -57,30 +58,92 @@ A **TypeScript knowledge graph library** for managing entities, relations, and o
|
|
|
57
58
|
|
|
58
59
|
| Module | Files | Key Components |
|
|
59
60
|
|--------|-------|----------------|
|
|
60
|
-
| `agent/` |
|
|
61
|
-
| `core/` |
|
|
62
|
-
| `search/` |
|
|
63
|
-
| `features/` |
|
|
64
|
-
| `utils/` |
|
|
65
|
-
| `types/` |
|
|
61
|
+
| `agent/` | 61 | AgentMemoryManager, SessionManager, DecayEngine, WorkingMemoryManager, ArtifactManager, DistillationPipeline, RoleProfiles, EntropyFilter, ConsolidationScheduler, MemoryFormatter, CollaborativeSynthesis, FailureDistillation, CognitiveLoadAnalyzer, VisibilityResolver, **MemoryEngine**, **MemoryValidator**, **TrajectoryCompressor**, **ExperienceExtractor**, **CausalReasoner**, **ProcedureManager**, **WorldModelManager**, **ActiveRetrievalController**, **CollaborationAuditEnforcer**, **RbacMiddleware**, **InMemoryBackend** / **SQLiteBackend** |
|
|
62
|
+
| `core/` | 14 | ManagerContext, EntityManager (with OCC), RelationManager (with temporal validity), ObservationManager (with bitemporal axis), HierarchyManager, GraphStorage, SQLiteStorage, GraphTraversal, TransactionManager, RefIndex |
|
|
63
|
+
| `search/` | 37 | SearchManager, RankedSearch (TF-IDF), BM25Search, BooleanSearch, FuzzySearch, SemanticSearch, HybridSearchManager, NGramIndex, TemporalQueryParser, TemporalSearch, LLMQueryPlanner, LLMSearchExecutor, EmbeddingService, VectorStore |
|
|
64
|
+
| `features/` | 17 | IOManager (with RDF/Turtle/JSON-LD export), ArchiveManager, CompressionManager, StreamingExporter, FreshnessManager, AuditLog, GovernanceManager, ContradictionDetector, SemanticForget, AutoLinker |
|
|
65
|
+
| `utils/` | 26 | BatchProcessor, CompressedCache, WorkerPoolManager, MemoryMonitor, schemas (Zod) |
|
|
66
|
+
| `types/` | 7 | Entity, Relation, AgentEntity, SessionEntity, ArtifactEntity, Procedure |
|
|
67
|
+
| `security/` | 2 | **PiiRedactor** + bundled patterns (email/SSN/CC/phone/IP) |
|
|
68
|
+
| `cli/` | 16 | `memory` / `memoryjs` binary commands (entity, relation, search, observation, tag, hierarchy, graph, io, maintenance) |
|
|
66
69
|
| `workers/` | 2 | Levenshtein distance calculations |
|
|
67
70
|
|
|
68
|
-
**Total:**
|
|
71
|
+
**Total:** 183 TypeScript files | 62,889 lines of code | 6157 passing tests
|
|
69
72
|
|
|
70
|
-
###
|
|
73
|
+
### Recent additions (Unreleased — built on top of v1.14.0)
|
|
71
74
|
|
|
72
75
|
| Feature | Entry Point |
|
|
73
76
|
|---------|-------------|
|
|
74
|
-
|
|
|
77
|
+
| **η.4.4 Bitemporal Versioning** | `EntityManager.invalidateEntity()` / `entityAsOf()` / `entityTimeline()`; `ObservationManager.invalidateObservation()` / `observationsAsOf()`; `Entity.validFrom` / `validUntil` / `observationMeta[]` |
|
|
78
|
+
| **η.5.4 Linked Data Export** | `ioManager.exportGraph(g, 'turtle' \| 'rdf-xml' \| 'json-ld')` — W3C RDF 1.1; reification fallback for non-NCName predicates |
|
|
79
|
+
| **η.5.5.a Multi-Agent Conflict View** | `SynthesisResult.conflicts[]` + `CollaborativeSynthesis.resolveConflicts(result, policy)` (most_recent / highest_confidence / highest_score / trusted_agent) |
|
|
80
|
+
| **η.5.5.b Visibility Expansion** | `AgentEntity.visibleFrom` / `visibleUntil` / `allowedRoles[]`; `VisibilityResolver` adds time-window gate + role predicate |
|
|
81
|
+
| **η.5.5.c Optimistic Concurrency** | `EntityManager.updateEntity(name, updates, { expectedVersion })` → throws `VersionConflictError` on mismatch |
|
|
82
|
+
| **η.5.5.d Attribution Enforcer** | `CollaborationAuditEnforcer` — strict-mode requires `agentId` on every mutation; appends to `AuditLog` |
|
|
83
|
+
| **η.6.1 RBAC** | `ctx.rbacMiddleware.checkPermission(agentId, action, resourceType, resourceName?)`; `ctx.roleAssignmentStore` with optional JSONL persistence |
|
|
84
|
+
| **η.6.3 PII Redactor** | `new PiiRedactor().redactGraph(graph)` — pluggable regex bank with `redactWithStats()` for compliance audit trails |
|
|
85
|
+
| **3B.4 Procedural Memory** | `ctx.procedureManager.addProcedure({ steps })` / `matchProcedure(context)` / `refineProcedure(id, feedback)` (EWMA success-rate) |
|
|
86
|
+
| **3B.5 Active Retrieval** | `ctx.activeRetrieval.adaptiveRetrieve({ query })` — iterative query rewriting with token-overlap expansion |
|
|
87
|
+
| **3B.6 Causal Reasoning** | `ctx.causalReasoner.findCauses()` / `findEffects()` / `counterfactual()` / `detectCycles()` |
|
|
88
|
+
| **3B.7 World Model** | `ctx.worldModelManager.getCurrentState()` / `validateFact()` / `predictOutcome()` / `detectStateChange()` |
|
|
89
|
+
|
|
90
|
+
### v1.13.0 — Memory Intelligence Services (Phase δ)
|
|
91
|
+
|
|
92
|
+
| Feature | Entry Point |
|
|
93
|
+
|---------|-------------|
|
|
94
|
+
| Memory Validator | `ctx.memoryValidator.validateConsistency()` / `detectContradictions()` / `repairWithResolver()` / `validateTemporalOrder()` / `calculateReliability()` |
|
|
95
|
+
| Trajectory Compressor | `ctx.trajectoryCompressor.distill()` / `abstractAtLevel()` / `findRedundancies()` / `mergeRedundant()` |
|
|
96
|
+
| Experience Extractor | `ctx.experienceExtractor.extractFromContrastivePairs()` / `clusterTrajectories()` / `synthesizeExperience()` |
|
|
97
|
+
|
|
98
|
+
### v1.12.0 — Pluggable Memory Backends (Phase β)
|
|
99
|
+
|
|
100
|
+
| Feature | Entry Point |
|
|
101
|
+
|---------|-------------|
|
|
102
|
+
| `IMemoryBackend` interface | `MEMORY_BACKEND=in-memory \| sqlite` selects via `ctx.memoryBackend` |
|
|
103
|
+
| `InMemoryBackend` | Ephemeral, dedup on `(sessionId, content)` |
|
|
104
|
+
| `SQLiteBackend` | Wraps `MemoryEngine` + `DecayEngine.calculatePrdEffectiveImportance()` |
|
|
105
|
+
| Audit-tooling guard | `npm run audit:plans` PostToolUse hook catches plan-doc rot |
|
|
106
|
+
|
|
107
|
+
### v1.11.0 — Turn-Aware Memory Engine
|
|
108
|
+
|
|
109
|
+
| Feature | Entry Point |
|
|
110
|
+
|---------|-------------|
|
|
111
|
+
| `MemoryEngine` | `ctx.memoryEngine.addTurn()` / `getSessionTurns()` — four-tier dedup (exact / prefix / Jaccard / optional semantic) |
|
|
112
|
+
| `ImportanceScorer` | length × keyword × recent-turn-overlap → integer [0, 10] |
|
|
113
|
+
| O(1) exact-equality dedup | `Entity.contentHash` (SHA-256) + SQLite `idx_entities_content_hash` |
|
|
114
|
+
|
|
115
|
+
### v1.9.0 — Temporal Relations + Conversation Ingest
|
|
116
|
+
|
|
117
|
+
| Feature | Entry Point |
|
|
118
|
+
|---------|-------------|
|
|
119
|
+
| Temporal Relations | `RelationManager.invalidateRelation()` / `queryAsOf(date)` / `timeline()` |
|
|
120
|
+
| 4-Layer Wake-Up Stack | `ContextWindowManager.wakeUp({ compress })` — ~600-token context bootstrap |
|
|
121
|
+
| Conversation Ingestion | `IOManager.ingest({ messages, ...options })` — format-agnostic pipeline |
|
|
122
|
+
| Per-Agent Diary | `AgentMemoryManager.writeDiary()` / `readDiary()` |
|
|
123
|
+
| Local Embeddings (default) | `MEMORY_EMBEDDING_PROVIDER=local` — zero-config semantic search |
|
|
124
|
+
|
|
125
|
+
### v1.8.0 — Memory Versioning + Project Scoping
|
|
126
|
+
|
|
127
|
+
| Feature | Entry Point |
|
|
128
|
+
|---------|-------------|
|
|
129
|
+
| Contradiction-driven supersession | `Entity.version` / `parentEntityName` / `rootEntityName` / `supersededBy` |
|
|
130
|
+
| Project scoping | `Entity.projectId` + `MEMORY_DEFAULT_PROJECT_ID` |
|
|
131
|
+
| Two-tier deletion | `ctx.semanticForget` — exact match → 0.85 semantic fallback with audit logging |
|
|
132
|
+
|
|
133
|
+
### v1.7.0 — Multi-Agent Memory
|
|
134
|
+
|
|
135
|
+
| Feature | Entry Point |
|
|
136
|
+
|---------|-------------|
|
|
137
|
+
| Role-Aware Customization | `RoleProfileManager.apply(role)` — salience weights + budget splits |
|
|
75
138
|
| Entropy-Aware Filtering | `EntropyFilter` — Shannon entropy gate in `ConsolidationPipeline` |
|
|
76
139
|
| Recursive Memory Consolidation | `ConsolidationScheduler` — background dedup + merge to fixed point |
|
|
77
|
-
|
|
|
140
|
+
| Salience Budget Allocation | `MemoryFormatter.formatWithSalienceBudget()` |
|
|
78
141
|
| Collaborative Memory Synthesis | `CollaborativeSynthesis.synthesize(entity, hopDepth)` |
|
|
79
|
-
| Failure-Driven
|
|
142
|
+
| Failure-Driven Distillation | `FailureDistillation.distill(failureEntity)` |
|
|
80
143
|
| Cognitive Load Metrics | `CognitiveLoadAnalyzer.analyze(memories)` → `CognitiveLoadReport` |
|
|
81
|
-
| Shared
|
|
144
|
+
| Shared Visibility Hierarchies | `VisibilityResolver.canAccess()` — 5-level model |
|
|
82
145
|
|
|
83
|
-
###
|
|
146
|
+
### v1.6.0 — Governance + Temporal
|
|
84
147
|
|
|
85
148
|
| Feature | Entry Point |
|
|
86
149
|
|---------|-------------|
|
|
@@ -88,8 +151,8 @@ A **TypeScript knowledge graph library** for managing entities, relations, and o
|
|
|
88
151
|
| Artifact-Level Granularity | `ctx.agentMemory().artifactManager.createArtifact()` |
|
|
89
152
|
| Temporal Range Queries | `ctx.searchManager.searchByTime()` / `ctx.temporalSearch` |
|
|
90
153
|
| Memory Distillation Policy | `IDistillationPolicy` — wired into `ContextWindowManager` |
|
|
91
|
-
|
|
|
92
|
-
| N-gram
|
|
154
|
+
| Freshness Auditing | `ctx.freshnessManager` — TTL, confidence, staleness report |
|
|
155
|
+
| N-gram Pre-filtering | Automatic in `FuzzySearch` via `NGramIndex` |
|
|
93
156
|
| LLM Query Planner | `ctx.queryNaturalLanguage(query, llmProvider?)` |
|
|
94
157
|
| Dynamic Memory Governance | `ctx.governanceManager` — `withTransaction` / `GovernancePolicy` |
|
|
95
158
|
|
|
@@ -158,8 +221,93 @@ const ranked = await ctx.searchManager.searchRanked('runtime environment', { lim
|
|
|
158
221
|
// Boolean search
|
|
159
222
|
const filtered = await ctx.searchManager.booleanSearch('TypeScript AND runtime');
|
|
160
223
|
|
|
161
|
-
// Fuzzy search (typo-tolerant)
|
|
224
|
+
// Fuzzy search (typo-tolerant; N-gram pre-filtered)
|
|
162
225
|
const fuzzy = await ctx.searchManager.fuzzySearch('Typscript', { threshold: 0.7 });
|
|
226
|
+
|
|
227
|
+
// Active retrieval — iterative query rewriting until coverage threshold
|
|
228
|
+
const adaptive = await ctx.activeRetrieval.adaptiveRetrieve({ query: 'memory leak' });
|
|
229
|
+
console.log(adaptive.bestResults, adaptive.bestCoverage, adaptive.rounds);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### 5. Multi-agent collaboration
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
// Optimistic concurrency control — fail loudly on stale writes
|
|
236
|
+
try {
|
|
237
|
+
await ctx.entityManager.updateEntity('Alice',
|
|
238
|
+
{ importance: 9 },
|
|
239
|
+
{ expectedVersion: 3 });
|
|
240
|
+
} catch (e) {
|
|
241
|
+
if (e.name === 'VersionConflictError') {
|
|
242
|
+
// Refetch + retry
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Detect cross-agent conflicts after collaborative synthesis
|
|
247
|
+
const synth = await ctx.agentMemory().collaborativeSynthesis.synthesize('Alice');
|
|
248
|
+
const winners = ctx.agentMemory().collaborativeSynthesis.resolveConflicts(synth, {
|
|
249
|
+
strategy: 'highest_confidence',
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// Enforce attribution on every mutation
|
|
253
|
+
import { CollaborationAuditEnforcer, AuditLog } from '@danielsimonjr/memoryjs';
|
|
254
|
+
const enforcer = new CollaborationAuditEnforcer(
|
|
255
|
+
ctx.entityManager,
|
|
256
|
+
new AuditLog('./audit.jsonl'),
|
|
257
|
+
);
|
|
258
|
+
await enforcer.createEntities([{ name: 'X', entityType: 't', observations: ['fact'] }],
|
|
259
|
+
'agent-alice'); // throws AttributionRequiredError if agentId is missing
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 6. Bitemporal versioning (η.4.4)
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
// Mark an entity as no longer valid at a specific time
|
|
266
|
+
await ctx.entityManager.invalidateEntity('OldFact', '2025-12-31T00:00:00Z');
|
|
267
|
+
|
|
268
|
+
// Time-travel query
|
|
269
|
+
const past = await ctx.entityManager.entityAsOf('Alice', '2024-06-15T00:00:00Z');
|
|
270
|
+
|
|
271
|
+
// Per-observation validity windows
|
|
272
|
+
await ctx.observationManager.invalidateObservation(
|
|
273
|
+
'Alice', 'works at Acme', '2024-12-31T00:00:00Z',
|
|
274
|
+
);
|
|
275
|
+
const obsAtTime = await ctx.observationManager.observationsAsOf(
|
|
276
|
+
'Alice', '2024-06-15T00:00:00Z',
|
|
277
|
+
);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### 7. Causal reasoning + world model (3B.6 / 3B.7)
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
// Forward inference — "what does X cause?"
|
|
284
|
+
const effects = await ctx.causalReasoner.findEffects('rain', ['flooding', 'erosion']);
|
|
285
|
+
// Counterfactual — "what if we remove this edge?"
|
|
286
|
+
const surviving = await ctx.causalReasoner.counterfactual({
|
|
287
|
+
seed: 'rain', removeFrom: 'rain', removeTo: 'flooding', predict: 'flooding',
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// World model snapshot + diff
|
|
291
|
+
const before = await ctx.worldModelManager.getCurrentState();
|
|
292
|
+
// ... mutations ...
|
|
293
|
+
const after = await ctx.worldModelManager.getCurrentState();
|
|
294
|
+
const change = ctx.worldModelManager.detectStateChange(before, after);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### 8. RBAC + PII redaction (η.6.1 / η.6.3)
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
// Grant a role
|
|
301
|
+
await ctx.roleAssignmentStore.assign({
|
|
302
|
+
agentId: 'alice', role: 'writer', resourceType: 'entity',
|
|
303
|
+
});
|
|
304
|
+
ctx.rbacMiddleware.checkPermission('alice', 'write', 'entity'); // true
|
|
305
|
+
|
|
306
|
+
// Redact PII from any export
|
|
307
|
+
import { PiiRedactor } from '@danielsimonjr/memoryjs';
|
|
308
|
+
const redactor = new PiiRedactor();
|
|
309
|
+
const cleanGraph = redactor.redactGraph(graph);
|
|
310
|
+
const { text, stats } = redactor.redactWithStats(observation);
|
|
163
311
|
```
|
|
164
312
|
|
|
165
313
|
## Core Concepts
|
|
@@ -170,14 +318,39 @@ Primary nodes in the knowledge graph.
|
|
|
170
318
|
|
|
171
319
|
```typescript
|
|
172
320
|
interface Entity {
|
|
173
|
-
name: string;
|
|
174
|
-
entityType: string;
|
|
175
|
-
observations: string[];
|
|
176
|
-
parentId?: string;
|
|
177
|
-
tags?: string[];
|
|
178
|
-
importance?: number;
|
|
179
|
-
createdAt?: string;
|
|
180
|
-
lastModified?: string;
|
|
321
|
+
name: string; // Unique identifier
|
|
322
|
+
entityType: string; // Classification (person, project, concept)
|
|
323
|
+
observations: string[]; // Facts about the entity
|
|
324
|
+
parentId?: string; // Parent entity for hierarchical nesting
|
|
325
|
+
tags?: string[]; // Lowercase tags for categorization
|
|
326
|
+
importance?: number; // 0-10 scale for prioritization
|
|
327
|
+
createdAt?: string; // ISO 8601 timestamp
|
|
328
|
+
lastModified?: string; // ISO 8601 timestamp
|
|
329
|
+
|
|
330
|
+
// v1.6.0 — Freshness
|
|
331
|
+
ttl?: number; // Seconds until stale
|
|
332
|
+
confidence?: number; // [0, 1] belief strength
|
|
333
|
+
|
|
334
|
+
// v1.8.0 — Project scoping + supersession
|
|
335
|
+
projectId?: string; // Multi-project isolation
|
|
336
|
+
version?: number; // Supersession chain version (also drives η.5.5.c OCC)
|
|
337
|
+
parentEntityName?: string;
|
|
338
|
+
rootEntityName?: string;
|
|
339
|
+
isLatest?: boolean;
|
|
340
|
+
supersededBy?: string;
|
|
341
|
+
|
|
342
|
+
// v1.11.0 — Memory Engine dedup
|
|
343
|
+
contentHash?: string; // SHA-256 for O(1) Tier-1 dedup
|
|
344
|
+
|
|
345
|
+
// η.4.4 — Bitemporal validity (orthogonal to supersession)
|
|
346
|
+
validFrom?: string; // Entity valid from this instant
|
|
347
|
+
validUntil?: string; // Entity valid until this instant
|
|
348
|
+
observationMeta?: Array<{ // Per-observation validity windows
|
|
349
|
+
content: string;
|
|
350
|
+
validFrom?: string;
|
|
351
|
+
validUntil?: string;
|
|
352
|
+
recordedAt?: string; // Bitemporal axis
|
|
353
|
+
}>;
|
|
181
354
|
}
|
|
182
355
|
```
|
|
183
356
|
|
|
@@ -202,17 +375,54 @@ Discrete facts about entities. Each observation should be atomic and independent
|
|
|
202
375
|
Central access point for all managers with lazy initialization:
|
|
203
376
|
|
|
204
377
|
```typescript
|
|
205
|
-
|
|
206
|
-
ctx.
|
|
207
|
-
ctx.
|
|
208
|
-
ctx.
|
|
209
|
-
ctx.
|
|
210
|
-
ctx.
|
|
211
|
-
ctx.
|
|
212
|
-
ctx.
|
|
213
|
-
ctx.
|
|
214
|
-
ctx.
|
|
215
|
-
|
|
378
|
+
// Core
|
|
379
|
+
ctx.entityManager // Entity CRUD + hierarchy + temporal validity + OCC
|
|
380
|
+
ctx.relationManager // Relation management + temporal invalidation
|
|
381
|
+
ctx.observationManager // Observation CRUD + bitemporal axis
|
|
382
|
+
ctx.hierarchyManager // Entity tree (parents, children, ancestors)
|
|
383
|
+
ctx.searchManager // All search operations (incl. searchByTime)
|
|
384
|
+
ctx.rankedSearch // TF-IDF / BM25 ranked search
|
|
385
|
+
ctx.graphTraversal // BFS / DFS / shortest path / centrality
|
|
386
|
+
ctx.tagManager // Tag aliases + bulk operations
|
|
387
|
+
ctx.refIndex // Stable name → entity O(1) lookup
|
|
388
|
+
|
|
389
|
+
// Storage + I/O
|
|
390
|
+
ctx.ioManager // Import / export (incl. RDF/Turtle/JSON-LD) / backup / ingest
|
|
391
|
+
ctx.archiveManager // Entity archival
|
|
392
|
+
ctx.compressionManager // Duplicate detection, entity merging
|
|
393
|
+
ctx.analyticsManager // Graph statistics + validation
|
|
394
|
+
ctx.semanticForget // Two-tier deletion with audit
|
|
395
|
+
ctx.governanceManager // Transactions + policy enforcement (canCreate/Update/Delete)
|
|
396
|
+
ctx.freshnessManager // TTL/confidence freshness reports
|
|
397
|
+
|
|
398
|
+
// Search extensions
|
|
399
|
+
ctx.semanticSearch // Vector similarity (lazy; needs embedding provider)
|
|
400
|
+
ctx.temporalSearch // Natural language time-range search
|
|
401
|
+
ctx.activeRetrieval // 3B.5 — iterative query rewriting (no LLM)
|
|
402
|
+
ctx.llmQueryPlanner() // NL → StructuredQuery decomposition (optional LLM)
|
|
403
|
+
ctx.queryNaturalLanguage // Convenience wrapper around the planner
|
|
404
|
+
|
|
405
|
+
// Memory + agent
|
|
406
|
+
ctx.memoryEngine // Turn-aware conversation memory (4-tier dedup)
|
|
407
|
+
ctx.memoryBackend // Pluggable IMemoryBackend (in-memory / sqlite)
|
|
408
|
+
ctx.contextWindowManager // 4-layer wake-up stack + token budgeting
|
|
409
|
+
ctx.agentMemory() // Full Agent Memory System facade
|
|
410
|
+
|
|
411
|
+
// Memory intelligence (Phase δ)
|
|
412
|
+
ctx.memoryValidator // Validate consistency / contradictions / temporal order
|
|
413
|
+
ctx.trajectoryCompressor // Distill / abstract / merge redundant trajectories
|
|
414
|
+
ctx.experienceExtractor // Cluster trajectories → reusable experience patterns
|
|
415
|
+
ctx.patternDetector // Trigger / sequence / outcome pattern mining
|
|
416
|
+
|
|
417
|
+
// Memory theory (Phase 3B)
|
|
418
|
+
ctx.procedureManager // 3B.4 — executable procedure memory + EWMA refinement
|
|
419
|
+
ctx.causalReasoner // 3B.6 — findCauses / findEffects / counterfactual
|
|
420
|
+
ctx.worldModelManager // 3B.7 — snapshot orchestrator + state-change diff
|
|
421
|
+
|
|
422
|
+
// Access control + audit
|
|
423
|
+
ctx.roleAssignmentStore // η.6.1 — role grants registry
|
|
424
|
+
ctx.rbacMiddleware // η.6.1 — RbacPolicy.checkPermission()
|
|
425
|
+
ctx.accessTracker // Per-entity access metrics
|
|
216
426
|
```
|
|
217
427
|
|
|
218
428
|
## Storage Options
|
|
@@ -271,11 +481,15 @@ When using JSONL, related files are automatically created:
|
|
|
271
481
|
|
|
272
482
|
| Method | Description | Use Case |
|
|
273
483
|
|--------|-------------|----------|
|
|
274
|
-
| `search()` | Basic substring matching | Simple queries |
|
|
275
|
-
| `searchRanked()` | TF-IDF relevance scoring | Finding most relevant results |
|
|
276
|
-
| `booleanSearch()` | AND/OR/NOT operators | Complex filtering |
|
|
277
|
-
| `fuzzySearch()` | Levenshtein
|
|
278
|
-
| `hybridSearch()` | Semantic + lexical + symbolic | Multi-signal ranking |
|
|
484
|
+
| `searchManager.search()` | Basic substring matching | Simple queries |
|
|
485
|
+
| `searchManager.searchRanked()` | TF-IDF relevance scoring | Finding most relevant results |
|
|
486
|
+
| `searchManager.booleanSearch()` | AND/OR/NOT operators with AST | Complex filtering |
|
|
487
|
+
| `searchManager.fuzzySearch()` | Levenshtein + N-gram pre-filter | Typo tolerance |
|
|
488
|
+
| `searchManager.hybridSearch()` | Semantic + lexical + symbolic | Multi-signal ranking |
|
|
489
|
+
| `searchManager.searchByTime()` | Natural-language time ranges | "last hour", "10 minutes ago" |
|
|
490
|
+
| `activeRetrieval.adaptiveRetrieve()` | Iterative rewrite + retrieve | Adaptive coverage refinement |
|
|
491
|
+
| `queryNaturalLanguage()` | LLM-planned decomposition | Free-text queries (optional LLM provider) |
|
|
492
|
+
| `causalReasoner.findEffects()` | Causal subgraph traversal | Inference over `causes`/`enables`/`prevents` edges |
|
|
279
493
|
|
|
280
494
|
### Basic Search
|
|
281
495
|
|
|
@@ -494,16 +708,15 @@ const results = await agent.searchCrossAgent('agent_2', 'query');
|
|
|
494
708
|
|--------|-------------|
|
|
495
709
|
| `createEntities(entities)` | Create multiple entities |
|
|
496
710
|
| `deleteEntities(names)` | Delete entities by name |
|
|
497
|
-
| `
|
|
498
|
-
| `
|
|
499
|
-
| `
|
|
500
|
-
| `addTags(name, tags)`
|
|
501
|
-
| `removeTags(name, tags)` | Remove tags from entity |
|
|
711
|
+
| `getEntity(name, options?)` | Get single entity (with optional access tracking) |
|
|
712
|
+
| `updateEntity(name, updates, { expectedVersion? })` | Partial update; OCC if `expectedVersion` provided (η.5.5.c) |
|
|
713
|
+
| `batchUpdate(updates[])` | Atomic multi-entity update |
|
|
714
|
+
| `addTags(name, tags)` / `removeTags(name, tags)` | Tag management |
|
|
502
715
|
| `setImportance(name, score)` | Set importance (0-10) |
|
|
503
|
-
| `
|
|
504
|
-
| `
|
|
505
|
-
| `
|
|
506
|
-
| `
|
|
716
|
+
| `getVersionChain(name)` / `getLatestVersion(name)` | v1.8.0 supersession chains |
|
|
717
|
+
| `invalidateEntity(name, ended?)` | η.4.4 — set `validUntil` |
|
|
718
|
+
| `entityAsOf(name, asOf)` | η.4.4 — time-travel query |
|
|
719
|
+
| `entityTimeline(name)` | η.4.4 — versions sorted by `validFrom` |
|
|
507
720
|
|
|
508
721
|
### RelationManager
|
|
509
722
|
|
|
@@ -512,6 +725,18 @@ const results = await agent.searchCrossAgent('agent_2', 'query');
|
|
|
512
725
|
| `createRelations(relations)` | Create multiple relations |
|
|
513
726
|
| `getRelations(entityName)` | Get incoming/outgoing relations |
|
|
514
727
|
| `deleteRelations(relations)` | Delete specific relations |
|
|
728
|
+
| `invalidateRelation(from, type, to, ended?)` | v1.9.0 — set `validUntil` on a relation |
|
|
729
|
+
| `queryAsOf(entity, asOf, { direction? })` | v1.9.0 — relations valid at time T |
|
|
730
|
+
| `timeline(entity, { direction? })` | v1.9.0 — chronological history |
|
|
731
|
+
|
|
732
|
+
### ObservationManager
|
|
733
|
+
|
|
734
|
+
| Method | Description |
|
|
735
|
+
|--------|-------------|
|
|
736
|
+
| `addObservations(adds, dedupOptions?)` | Add observations (with optional dedup) |
|
|
737
|
+
| `deleteObservations(deletions)` | Remove specific observations |
|
|
738
|
+
| `invalidateObservation(entity, content, ended?)` | η.4.4 — set per-observation `validUntil` |
|
|
739
|
+
| `observationsAsOf(entity, asOf)` | η.4.4 — observations valid at time T |
|
|
515
740
|
|
|
516
741
|
### SearchManager
|
|
517
742
|
|
|
@@ -528,31 +753,120 @@ const results = await agent.searchCrossAgent('agent_2', 'query');
|
|
|
528
753
|
|
|
529
754
|
| Method | Description |
|
|
530
755
|
|--------|-------------|
|
|
531
|
-
| `exportGraph(
|
|
532
|
-
| `
|
|
533
|
-
| `
|
|
534
|
-
| `
|
|
756
|
+
| `exportGraph(graph, format)` | Export to `json` / `csv` / `graphml` / `gexf` / `dot` / `markdown` / `mermaid` / `turtle` / `rdf-xml` / `json-ld` |
|
|
757
|
+
| `exportGraphWithCompression(graph, format, options?)` | Brotli-compressed export |
|
|
758
|
+
| `importGraph(format, data, options)` | Import with merge strategies (`replace` / `skip` / `merge` / `fail`) |
|
|
759
|
+
| `ingest({ messages }, options?)` | v1.9.0 — conversation ingestion pipeline |
|
|
760
|
+
| `splitSessions(content, options?)` | v1.9.0 — split multi-session transcripts |
|
|
761
|
+
| `visualizeGraph(options?)` | v1.9.1 — interactive HTML visualization |
|
|
762
|
+
| `createBackup(options)` / `restoreBackup(path)` | Backup management |
|
|
535
763
|
|
|
536
764
|
### GraphTraversal
|
|
537
765
|
|
|
538
766
|
| Method | Description |
|
|
539
767
|
|--------|-------------|
|
|
540
768
|
| `findShortestPath(from, to)` | BFS shortest path |
|
|
541
|
-
| `findAllPaths(from, to, options)` | All paths with max depth |
|
|
542
|
-
| `getCentrality(options)` | Centrality metrics |
|
|
769
|
+
| `findAllPaths(from, to, maxDepth, options?)` | All paths with max depth |
|
|
770
|
+
| `getCentrality(options)` | Centrality metrics (degree / betweenness / pagerank) |
|
|
543
771
|
| `getConnectedComponents()` | Find isolated subgraphs |
|
|
544
|
-
| `bfs(start,
|
|
545
|
-
|
|
772
|
+
| `bfs(start, options)` / `dfs(start, options)` | Traversal |
|
|
773
|
+
|
|
774
|
+
### CausalReasoner (3B.6)
|
|
775
|
+
|
|
776
|
+
| Method | Description |
|
|
777
|
+
|--------|-------------|
|
|
778
|
+
| `findEffects(cause, candidates, maxDepth?)` | Forward causal inference; sorted by `Π causalStrength` |
|
|
779
|
+
| `findCauses(effect, candidates, maxDepth?)` | Backward inference (symmetric inverse) |
|
|
780
|
+
| `counterfactual({ seed, removeFrom, removeTo, predict })` | Chains surviving edge removal (pure; no graph mutation) |
|
|
781
|
+
| `detectCycles(seed, maxDepth?)` | Depth-bounded DFS over causal subgraph |
|
|
782
|
+
|
|
783
|
+
### ProcedureManager (3B.4)
|
|
784
|
+
|
|
785
|
+
| Method | Description |
|
|
786
|
+
|--------|-------------|
|
|
787
|
+
| `addProcedure({ steps, ... })` | Persist a procedure; auto-generates id |
|
|
788
|
+
| `getProcedure(id)` / `getStep(id, order)` / `getNextStep(id, order)` | Access |
|
|
789
|
+
| `openSequencer(id)` | Stateful execution cursor with fallback support |
|
|
790
|
+
| `matchProcedure(context, candidates, threshold?)` | Token-overlap match |
|
|
791
|
+
| `refineProcedure(id, { succeeded, notes? })` | EWMA success-rate update |
|
|
792
|
+
|
|
793
|
+
### WorldModelManager (3B.7)
|
|
794
|
+
|
|
795
|
+
| Method | Description |
|
|
796
|
+
|--------|-------------|
|
|
797
|
+
| `getCurrentState()` | `WorldStateSnapshot` from live graph (capped at `maxSnapshotSize`) |
|
|
798
|
+
| `validateFact(observation, entityName)` | Delegates to `MemoryValidator` if wired |
|
|
799
|
+
| `predictOutcome(action, candidates)` | Delegates to `CausalReasoner.findEffects` |
|
|
800
|
+
| `detectStateChange(before, after)` | Pure snapshot diff |
|
|
801
|
+
|
|
802
|
+
### ActiveRetrievalController (3B.5)
|
|
803
|
+
|
|
804
|
+
| Method | Description |
|
|
805
|
+
|--------|-------------|
|
|
806
|
+
| `shouldRetrieve(context)` | Cost heuristic; rejects empty / over-budget |
|
|
807
|
+
| `adaptiveRetrieve(context)` | Iterative rewrite + retrieve until coverage threshold |
|
|
808
|
+
|
|
809
|
+
### CollaborativeSynthesis (η.5.5.a)
|
|
810
|
+
|
|
811
|
+
| Method | Description |
|
|
812
|
+
|--------|-------------|
|
|
813
|
+
| `synthesize(seedEntity, context?)` | BFS + salience scoring; surfaces multi-agent `conflicts[]` |
|
|
814
|
+
| `resolveConflicts(result, policy)` | Pick winners per `most_recent` / `highest_confidence` / `highest_score` / `trusted_agent` |
|
|
815
|
+
|
|
816
|
+
### MemoryValidator (Phase δ)
|
|
817
|
+
|
|
818
|
+
| Method | Description |
|
|
819
|
+
|--------|-------------|
|
|
820
|
+
| `validateConsistency(newObs, existing)` | Composite duplicate / semantic / low-confidence check |
|
|
821
|
+
| `detectContradictions(entity)` | Delegates to `ContradictionDetector` |
|
|
822
|
+
| `repairWithResolver(entity, competing, resolver, contradiction?, options?)` | Apply `ConflictResolver` strategies |
|
|
823
|
+
| `validateTemporalOrder(observations)` | Sync `[T=ISO]` ordering check |
|
|
824
|
+
| `calculateReliability(entity)` | Confidence × confirmation × age penalty |
|
|
825
|
+
|
|
826
|
+
### RbacMiddleware (η.6.1)
|
|
827
|
+
|
|
828
|
+
| Method | Description |
|
|
829
|
+
|--------|-------------|
|
|
830
|
+
| `checkPermission(agentId, action, resourceType, resourceName?, now?)` | Returns `true` / `false`; falls back to `defaultRole` (default `reader`) |
|
|
831
|
+
| `roleAssignmentStore.assign({ agentId, role, resourceType?, scope?, validFrom?, validUntil? })` | Grant a role |
|
|
832
|
+
| `roleAssignmentStore.revoke(agentId, role, resourceType?)` | Remove a grant |
|
|
833
|
+
| `roleAssignmentStore.listActive(agentId, now?)` | Active grants at a point in time |
|
|
834
|
+
|
|
835
|
+
### PiiRedactor (η.6.3)
|
|
836
|
+
|
|
837
|
+
| Method | Description |
|
|
838
|
+
|--------|-------------|
|
|
839
|
+
| `redact(text)` | Apply patterns; returns redacted string |
|
|
840
|
+
| `redactWithStats(text)` | Returns `{ text, stats: { totalRedactedBytes, countsByPattern } }` |
|
|
841
|
+
| `redactGraph(graph)` | Apply to every observation in a graph-shaped object |
|
|
546
842
|
|
|
547
843
|
## Configuration
|
|
548
844
|
|
|
549
845
|
### Environment Variables
|
|
550
846
|
|
|
847
|
+
The full env-var reference lives in [CLAUDE.md](CLAUDE.md). Most-used:
|
|
848
|
+
|
|
551
849
|
| Variable | Description | Default |
|
|
552
850
|
|----------|-------------|---------|
|
|
553
851
|
| `MEMORY_STORAGE_TYPE` | Storage backend: `jsonl` or `sqlite` | `jsonl` |
|
|
554
|
-
| `
|
|
852
|
+
| `MEMORY_FILE_PATH` | Override storage file path | (per `ManagerContext` ctor) |
|
|
853
|
+
| `MEMORY_BACKEND` | Pluggable Memory Engine backend: `sqlite` or `in-memory` | `sqlite` |
|
|
854
|
+
| `MEMORY_EMBEDDING_PROVIDER` | Embedding provider: `openai`, `local`, or `none` | `local` |
|
|
555
855
|
| `MEMORY_OPENAI_API_KEY` | OpenAI API key (required if provider is `openai`) | - |
|
|
856
|
+
| `MEMORY_AUTO_INDEX_EMBEDDINGS` | Auto-build embedding index on entity create | `false` |
|
|
857
|
+
| `MEMORY_AUTO_DECAY` | Enable background memory decay | `false` |
|
|
858
|
+
| `MEMORY_DECAY_HALF_LIFE_HOURS` | Half-life for importance decay | `168` |
|
|
859
|
+
| `MEMORY_GOVERNANCE_ENABLED` | Enable `GovernanceManager` policy enforcement | `false` |
|
|
860
|
+
| `MEMORY_AUDIT_LOG_FILE` | Path for audit JSONL trail | - |
|
|
861
|
+
| `MEMORY_AGENT_ROLE` | Apply built-in role profile (`researcher`/`planner`/`executor`/`reviewer`/`coordinator`) | - |
|
|
862
|
+
| `MEMORY_VALIDATE_ON_STORE` | Run `MemoryValidator` before observation writes | `false` |
|
|
863
|
+
| `MEMORY_AUDIT_ATTRIBUTION_REQUIRED` | `CollaborationAuditEnforcer` strict mode | `false` |
|
|
864
|
+
| `MEMORY_RBAC_ENABLED` | Wire `RbacMiddleware` into `GovernancePolicy` | `false` |
|
|
865
|
+
| `MEMORY_DEFAULT_VISIBILITY` | Default `AgentEntity.visibility` | `private` |
|
|
866
|
+
| `SKIP_BENCHMARKS` | Skip perf benchmark tests | `false` |
|
|
867
|
+
| `LOG_LEVEL` | `debug` / `info` / `warn` / `error` | (none) |
|
|
868
|
+
|
|
869
|
+
See [CLAUDE.md](CLAUDE.md#environment-variables) for the complete list (~50 variables across decay/salience/context-window/freshness/RBAC/PRD scoring/MemoryEngine knobs).
|
|
556
870
|
|
|
557
871
|
## Development
|
|
558
872
|
|
|
@@ -565,120 +879,159 @@ const results = await agent.searchCrossAgent('agent_2', 'query');
|
|
|
565
879
|
### Build Commands
|
|
566
880
|
|
|
567
881
|
```bash
|
|
568
|
-
npm install
|
|
569
|
-
npm run build
|
|
570
|
-
npm run build:watch
|
|
571
|
-
npm
|
|
572
|
-
npm
|
|
573
|
-
npm run test:
|
|
574
|
-
npm run
|
|
882
|
+
npm install # Install dependencies
|
|
883
|
+
npm run build # Build TypeScript to dist/ (tsup; ESM + CJS dual output)
|
|
884
|
+
npm run build:watch # Watch mode compilation
|
|
885
|
+
npm run build:tsc # Bare tsc build (does NOT include workers — use tsup)
|
|
886
|
+
npm test # Run all tests
|
|
887
|
+
npm run test:watch # Watch mode testing
|
|
888
|
+
npm run test:coverage # Run with coverage report
|
|
889
|
+
npm run typecheck # Type checking without emit
|
|
890
|
+
npm run benchmark # Standalone synthetic benchmarks
|
|
891
|
+
npm run bench # Vitest performance suite
|
|
892
|
+
SKIP_BENCHMARKS=true npm test # Skip perf tests in main suite
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
### Tooling
|
|
896
|
+
|
|
897
|
+
```bash
|
|
898
|
+
npm run audit:plans # Detect plan-doc rot
|
|
899
|
+
node tools/create-dependency-graph/create-dependency-graph.ts # Refresh DEPENDENCY_GRAPH.md
|
|
900
|
+
node tools/chunking-for-files/chunking-for-files.ts split <file> # Split large files
|
|
901
|
+
node tools/chunking-for-files/chunking-for-files.ts merge <manifest> # Merge back
|
|
902
|
+
node tools/migrate-from-jsonl-to-sqlite/... # JSONL → SQLite migration
|
|
575
903
|
```
|
|
576
904
|
|
|
577
905
|
### Architecture
|
|
578
906
|
|
|
579
907
|
```
|
|
580
|
-
|
|
581
|
-
│ Layer 1: ManagerContext (Central Facade)
|
|
582
|
-
|
|
583
|
-
│ │ Lazy-initialized access to all managers │ │
|
|
584
|
-
│ └───────────────────────────────────────────────────────┘ │
|
|
585
|
-
└──────────────────────────┬──────────────────────────────────┘
|
|
908
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
909
|
+
│ Layer 1: ManagerContext (Central Facade — lazy init) │
|
|
910
|
+
└──────────────────────────┬───────────────────────────────────────┘
|
|
586
911
|
│
|
|
587
|
-
|
|
588
|
-
│ Layer 2:
|
|
589
|
-
│
|
|
590
|
-
│
|
|
591
|
-
│
|
|
592
|
-
│
|
|
593
|
-
│
|
|
594
|
-
│
|
|
595
|
-
│
|
|
596
|
-
|
|
912
|
+
┌──────────────────────────┴───────────────────────────────────────┐
|
|
913
|
+
│ Layer 2: Domain managers (40+ lazy getters) │
|
|
914
|
+
│ Core: Entity / Relation / Observation / Hierarchy / Search / │
|
|
915
|
+
│ GraphTraversal / Tags / RefIndex │
|
|
916
|
+
│ I/O: IOManager / Archive / Compression / Analytics / Audit / │
|
|
917
|
+
│ Governance / Freshness / SemanticForget │
|
|
918
|
+
│ Search: Ranked / Hybrid / Semantic / Temporal / LLMQueryPlanner │
|
|
919
|
+
│ / ActiveRetrievalController │
|
|
920
|
+
│ Memory: MemoryEngine / MemoryBackend / ContextWindowManager / │
|
|
921
|
+
│ AgentMemory(facade) │
|
|
922
|
+
│ Intel: MemoryValidator / TrajectoryCompressor / │
|
|
923
|
+
│ ExperienceExtractor / PatternDetector │
|
|
924
|
+
│ Theory: ProcedureManager / CausalReasoner / WorldModelManager │
|
|
925
|
+
│ Auth: RbacMiddleware / RoleAssignmentStore / AccessTracker │
|
|
926
|
+
└──────────────────────────┬───────────────────────────────────────┘
|
|
597
927
|
│
|
|
598
|
-
|
|
599
|
-
│ Layer 3: Storage
|
|
600
|
-
│ GraphStorage (JSONL) or SQLiteStorage (better-sqlite3)
|
|
601
|
-
|
|
928
|
+
┌──────────────────────────┴───────────────────────────────────────┐
|
|
929
|
+
│ Layer 3: Storage │
|
|
930
|
+
│ GraphStorage (JSONL) or SQLiteStorage (better-sqlite3, FTS5) │
|
|
931
|
+
│ ─ Pluggable IMemoryBackend: in-memory or sqlite-backed engine │
|
|
932
|
+
└──────────────────────────────────────────────────────────────────┘
|
|
602
933
|
```
|
|
603
934
|
|
|
604
935
|
### Project Structure
|
|
605
936
|
|
|
606
937
|
```
|
|
607
938
|
memoryjs/
|
|
608
|
-
├── src/ # Source (
|
|
939
|
+
├── src/ # Source (183 TypeScript files, 62.7K LOC)
|
|
609
940
|
│ ├── index.ts # Entry point
|
|
610
|
-
│ ├── agent/ # Agent Memory System (
|
|
941
|
+
│ ├── agent/ # Agent Memory System (61 files)
|
|
611
942
|
│ │ ├── AgentMemoryManager.ts # Unified facade
|
|
612
943
|
│ │ ├── SessionManager.ts # Session lifecycle
|
|
613
|
-
│ │ ├── WorkingMemoryManager.ts # Working memory
|
|
614
|
-
│ │ ├── EpisodicMemoryManager.ts #
|
|
615
|
-
│ │ ├── DecayEngine.ts #
|
|
616
|
-
│ │ ├── SalienceEngine.ts # Context scoring
|
|
944
|
+
│ │ ├── WorkingMemoryManager.ts # Working memory + promotion
|
|
945
|
+
│ │ ├── EpisodicMemoryManager.ts # Timeline-based events
|
|
946
|
+
│ │ ├── DecayEngine.ts # Decay (legacy + PRD scales)
|
|
947
|
+
│ │ ├── SalienceEngine.ts # Context-aware scoring
|
|
617
948
|
│ │ ├── MultiAgentMemoryManager.ts # Multi-agent support
|
|
618
|
-
│ │ ├── ConflictResolver.ts #
|
|
619
|
-
│ │ ├── ArtifactManager.ts #
|
|
620
|
-
│ │ ├──
|
|
621
|
-
│ │ ├──
|
|
622
|
-
│ │ ├──
|
|
623
|
-
│ │ ├──
|
|
624
|
-
│ │ ├── ConsolidationScheduler.ts # Background recursive dedup+merge
|
|
949
|
+
│ │ ├── ConflictResolver.ts # Concurrent-update resolution
|
|
950
|
+
│ │ ├── ArtifactManager.ts # Stable artifact entities
|
|
951
|
+
│ │ ├── DistillationPipeline.ts # Post-retrieval policy filter
|
|
952
|
+
│ │ ├── RoleProfiles.ts # 5 built-in roles + presets
|
|
953
|
+
│ │ ├── EntropyFilter.ts # Shannon entropy gate
|
|
954
|
+
│ │ ├── ConsolidationScheduler.ts # Background dedup+merge
|
|
625
955
|
│ │ ├── MemoryFormatter.ts # formatWithSalienceBudget()
|
|
626
|
-
│ │ ├── CollaborativeSynthesis.ts #
|
|
627
|
-
│ │ ├── FailureDistillation.ts # Causal
|
|
628
|
-
│ │ ├── CognitiveLoadAnalyzer.ts #
|
|
629
|
-
│ │ ├── VisibilityResolver.ts # 5-level
|
|
956
|
+
│ │ ├── CollaborativeSynthesis.ts # Multi-agent merge + ConflictView
|
|
957
|
+
│ │ ├── FailureDistillation.ts # Causal-chain lesson extraction
|
|
958
|
+
│ │ ├── CognitiveLoadAnalyzer.ts # Density + redundancy + diversity
|
|
959
|
+
│ │ ├── VisibilityResolver.ts # 5-level + role + time-window
|
|
960
|
+
│ │ ├── ContextWindowManager.ts # 4-layer wake-up stack
|
|
961
|
+
│ │ ├── MemoryEngine.ts # Turn-aware + 4-tier dedup (v1.11)
|
|
962
|
+
│ │ ├── MemoryBackend.ts # IMemoryBackend interface (v1.12)
|
|
963
|
+
│ │ ├── InMemoryBackend.ts # Ephemeral adapter
|
|
964
|
+
│ │ ├── SQLiteBackend.ts # SQLite-backed adapter
|
|
965
|
+
│ │ ├── MemoryValidator.ts # Phase δ — consistency checks
|
|
966
|
+
│ │ ├── TrajectoryCompressor.ts # Phase δ — distill / merge
|
|
967
|
+
│ │ ├── ExperienceExtractor.ts # Phase δ — pattern abstraction
|
|
968
|
+
│ │ ├── PatternDetector.ts # Sequence + outcome mining
|
|
969
|
+
│ │ ├── causal/ # 3B.6 — CausalReasoner
|
|
970
|
+
│ │ ├── procedural/ # 3B.4 — ProcedureManager + Sequencer
|
|
971
|
+
│ │ ├── retrieval/ # 3B.5 — ActiveRetrievalController
|
|
972
|
+
│ │ ├── world/ # 3B.7 — WorldModelManager + Snapshot
|
|
973
|
+
│ │ ├── rbac/ # η.6.1 — Role/Permission/Matrix/Middleware
|
|
974
|
+
│ │ ├── collaboration/ # η.5.5.d — CollaborationAuditEnforcer
|
|
630
975
|
│ │ └── ...
|
|
631
|
-
│ ├── core/ # Core managers (
|
|
632
|
-
│ │ ├── ManagerContext.ts #
|
|
633
|
-
│ │ ├── EntityManager.ts #
|
|
634
|
-
│ │ ├── RelationManager.ts #
|
|
635
|
-
│ │ ├──
|
|
636
|
-
│ │ ├──
|
|
637
|
-
│ │ ├──
|
|
638
|
-
│ │ ├──
|
|
976
|
+
│ ├── core/ # Core managers (14 files)
|
|
977
|
+
│ │ ├── ManagerContext.ts # Central facade (lazy)
|
|
978
|
+
│ │ ├── EntityManager.ts # CRUD + hierarchy + OCC + temporal
|
|
979
|
+
│ │ ├── RelationManager.ts # CRUD + temporal validity
|
|
980
|
+
│ │ ├── ObservationManager.ts # CRUD + per-obs validity windows
|
|
981
|
+
│ │ ├── HierarchyManager.ts # Tree traversal
|
|
982
|
+
│ │ ├── GraphStorage.ts # JSONL I/O + atomic writes
|
|
983
|
+
│ │ ├── SQLiteStorage.ts # SQLite + FTS5 + BM25
|
|
984
|
+
│ │ ├── GraphTraversal.ts # BFS / DFS / paths / centrality
|
|
985
|
+
│ │ ├── TransactionManager.ts # ACID batch operations
|
|
986
|
+
│ │ ├── RefIndex.ts # O(1) name → entity sidecar
|
|
639
987
|
│ │ └── ...
|
|
640
|
-
│ ├── search/ # Search
|
|
641
|
-
│ │ ├── SearchManager.ts #
|
|
642
|
-
│ │ ├──
|
|
643
|
-
│ │ ├──
|
|
644
|
-
│ │ ├── BooleanSearch.ts # AND/OR/NOT
|
|
645
|
-
│ │ ├── FuzzySearch.ts #
|
|
988
|
+
│ ├── search/ # Search (37 files)
|
|
989
|
+
│ │ ├── SearchManager.ts # Orchestrator
|
|
990
|
+
│ │ ├── RankedSearch.ts # TF-IDF
|
|
991
|
+
│ │ ├── BM25Search.ts # Okapi BM25 with stopwords
|
|
992
|
+
│ │ ├── BooleanSearch.ts # AND/OR/NOT AST
|
|
993
|
+
│ │ ├── FuzzySearch.ts # Levenshtein + N-gram pre-filter
|
|
646
994
|
│ │ ├── SemanticSearch.ts # Embedding-based
|
|
647
|
-
│ │ ├── HybridSearchManager.ts # Multi-
|
|
648
|
-
│ │ ├── NGramIndex.ts # Trigram
|
|
649
|
-
│ │ ├──
|
|
650
|
-
│ │ ├──
|
|
651
|
-
│ │ ├── LLMQueryPlanner.ts # NL → StructuredQuery decomposition
|
|
652
|
-
│ │ ├── LLMSearchExecutor.ts # LLM-planned search execution
|
|
995
|
+
│ │ ├── HybridSearchManager.ts # Multi-signal scoring
|
|
996
|
+
│ │ ├── NGramIndex.ts # Trigram + Jaccard
|
|
997
|
+
│ │ ├── TemporalSearch.ts # Time-range execution
|
|
998
|
+
│ │ ├── LLMQueryPlanner.ts # NL → StructuredQuery
|
|
653
999
|
│ │ └── ...
|
|
654
|
-
│ ├── features/ # Advanced capabilities (
|
|
655
|
-
│ │ ├── IOManager.ts # Import/export/backup
|
|
1000
|
+
│ ├── features/ # Advanced capabilities (17 files)
|
|
1001
|
+
│ │ ├── IOManager.ts # Import / export (incl. RDF/JSON-LD) / backup / ingest
|
|
656
1002
|
│ │ ├── TagManager.ts # Tag aliases
|
|
657
1003
|
│ │ ├── ArchiveManager.ts # Entity archival
|
|
658
1004
|
│ │ ├── CompressionManager.ts # Duplicate detection
|
|
659
|
-
│ │ ├── FreshnessManager.ts # TTL/confidence
|
|
660
|
-
│ │ ├── AuditLog.ts # JSONL immutable
|
|
661
|
-
│ │ ├── GovernanceManager.ts # Transactions + policy
|
|
1005
|
+
│ │ ├── FreshnessManager.ts # TTL/confidence
|
|
1006
|
+
│ │ ├── AuditLog.ts # JSONL immutable trail
|
|
1007
|
+
│ │ ├── GovernanceManager.ts # Transactions + policy
|
|
1008
|
+
│ │ ├── ContradictionDetector.ts # Semantic-similarity supersession
|
|
1009
|
+
│ │ ├── SemanticForget.ts # Two-tier deletion
|
|
662
1010
|
│ │ └── ...
|
|
663
|
-
│ ├── cli/ # CLI
|
|
664
|
-
│
|
|
665
|
-
│
|
|
666
|
-
│
|
|
667
|
-
│ │ ├── formatters.ts # Output formatting
|
|
668
|
-
│ │ ├── interactive.ts # REPL mode
|
|
669
|
-
│ │ └── options.ts # CLI option parsing
|
|
670
|
-
│ ├── types/ # TypeScript definitions (4 files)
|
|
671
|
-
│ ├── utils/ # Shared utilities (18 files)
|
|
1011
|
+
│ ├── cli/ # CLI binary (16 files)
|
|
1012
|
+
│ ├── security/ # PII redaction (2 files; η.6.3)
|
|
1013
|
+
│ ├── types/ # TypeScript definitions (7 files)
|
|
1014
|
+
│ ├── utils/ # Shared utilities (26 files)
|
|
672
1015
|
│ └── workers/ # Worker pool (2 files)
|
|
673
|
-
├── tests/ #
|
|
674
|
-
│ ├── unit/ #
|
|
675
|
-
│ ├── integration/ #
|
|
676
|
-
│
|
|
1016
|
+
├── tests/ # 6157 passing tests
|
|
1017
|
+
│ ├── unit/ # Per-module unit tests
|
|
1018
|
+
│ ├── integration/ # Cross-module workflows
|
|
1019
|
+
│ ├── edge-cases/ # Boundary conditions
|
|
1020
|
+
│ └── performance/ # Benchmarks (gated by SKIP_BENCHMARKS)
|
|
677
1021
|
├── docs/ # Documentation
|
|
678
|
-
│
|
|
679
|
-
├──
|
|
680
|
-
│ ├──
|
|
681
|
-
│
|
|
1022
|
+
│ ├── architecture/ # OVERVIEW, ARCHITECTURE, DEPENDENCY_GRAPH, etc.
|
|
1023
|
+
│ ├── development/ # ADRs (incl. ADR-011 wrap-and-extend)
|
|
1024
|
+
│ ├── guides/ # API reference, configuration, recipes
|
|
1025
|
+
│ ├── roadmap/ # ROADMAP.md
|
|
1026
|
+
│ └── superpowers/plans/ # Phase α–η implementation plans
|
|
1027
|
+
├── tools/ # Dev utilities
|
|
1028
|
+
│ ├── chunking-for-files/ # File splitting / merging
|
|
1029
|
+
│ ├── compress-for-context/ # LLM-context compression
|
|
1030
|
+
│ ├── create-dependency-graph/ # Generates DEPENDENCY_GRAPH.md
|
|
1031
|
+
│ ├── migrate-from-jsonl-to-sqlite/ # Storage migration
|
|
1032
|
+
│ └── plan-doc-audit/ # Plan-doc rot detection (audit:plans)
|
|
1033
|
+
├── CLAUDE.md # Full env-var + architecture reference
|
|
1034
|
+
├── CHANGELOG.md # Version-by-version history
|
|
682
1035
|
└── README.md # This file
|
|
683
1036
|
```
|
|
684
1037
|
|
|
@@ -691,10 +1044,22 @@ Comprehensive architecture documentation in `docs/architecture/`:
|
|
|
691
1044
|
- [COMPONENTS.md](docs/architecture/COMPONENTS.md) - Component breakdown
|
|
692
1045
|
- [DATAFLOW.md](docs/architecture/DATAFLOW.md) - Data flow patterns
|
|
693
1046
|
- [API.md](docs/architecture/API.md) - Complete API documentation
|
|
694
|
-
- [DEPENDENCY_GRAPH.md](docs/architecture/DEPENDENCY_GRAPH.md) - Module dependencies
|
|
1047
|
+
- [DEPENDENCY_GRAPH.md](docs/architecture/DEPENDENCY_GRAPH.md) - Module dependencies (auto-generated by `tools/create-dependency-graph`)
|
|
1048
|
+
- [unused-analysis.md](docs/architecture/unused-analysis.md) - Unused exports report
|
|
695
1049
|
- [TEST_COVERAGE.md](docs/architecture/TEST_COVERAGE.md) - Test coverage analysis
|
|
696
1050
|
- [AGENT_MEMORY.md](docs/architecture/AGENT_MEMORY.md) - Agent memory system design
|
|
697
1051
|
|
|
1052
|
+
ADRs and roadmap:
|
|
1053
|
+
|
|
1054
|
+
- [ARCHITECTURE_DECISIONS.md](docs/development/ARCHITECTURE_DECISIONS.md) - including ADR-011 (Phase δ wrap-and-extend pattern)
|
|
1055
|
+
- [ROADMAP.md](docs/roadmap/ROADMAP.md) - Feature roadmap with implementation details
|
|
1056
|
+
- [docs/superpowers/plans/](docs/superpowers/plans/) - Phase α–η implementation plans
|
|
1057
|
+
|
|
1058
|
+
Project-internal:
|
|
1059
|
+
|
|
1060
|
+
- [CLAUDE.md](CLAUDE.md) - Full environment-variable reference + architecture map
|
|
1061
|
+
- [CHANGELOG.md](CHANGELOG.md) - Version-by-version history
|
|
1062
|
+
|
|
698
1063
|
## License
|
|
699
1064
|
|
|
700
1065
|
**MIT License** - see [LICENSE](LICENSE)
|