superlocalmemory 3.2.0 → 3.2.2

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 (35) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/README.md +61 -1
  3. package/bin/slm +29 -1
  4. package/bin/slm.bat +40 -2
  5. package/bin/slm.cmd +1 -1
  6. package/package.json +1 -1
  7. package/pyproject.toml +26 -1
  8. package/scripts/postinstall.js +33 -0
  9. package/scripts/preuninstall.js +2 -2
  10. package/src/superlocalmemory/attribution/signer.py +6 -1
  11. package/src/superlocalmemory/core/config.py +114 -1
  12. package/src/superlocalmemory/core/consolidation_engine.py +595 -0
  13. package/src/superlocalmemory/core/embeddings.py +0 -1
  14. package/src/superlocalmemory/core/engine.py +164 -674
  15. package/src/superlocalmemory/core/engine_wiring.py +474 -0
  16. package/src/superlocalmemory/core/graph_analyzer.py +199 -0
  17. package/src/superlocalmemory/core/recall_pipeline.py +247 -0
  18. package/src/superlocalmemory/core/store_pipeline.py +483 -0
  19. package/src/superlocalmemory/core/worker_pool.py +35 -12
  20. package/src/superlocalmemory/encoding/auto_linker.py +308 -0
  21. package/src/superlocalmemory/encoding/context_generator.py +175 -0
  22. package/src/superlocalmemory/encoding/temporal_validator.py +513 -0
  23. package/src/superlocalmemory/hooks/auto_invoker.py +484 -0
  24. package/src/superlocalmemory/retrieval/channel_registry.py +154 -0
  25. package/src/superlocalmemory/retrieval/engine.py +12 -0
  26. package/src/superlocalmemory/retrieval/semantic_channel.py +87 -3
  27. package/src/superlocalmemory/retrieval/spreading_activation.py +311 -0
  28. package/src/superlocalmemory/retrieval/strategy.py +6 -6
  29. package/src/superlocalmemory/retrieval/vector_store.py +386 -0
  30. package/src/superlocalmemory/server/routes/v3_api.py +576 -0
  31. package/src/superlocalmemory/storage/access_log.py +169 -0
  32. package/src/superlocalmemory/storage/database.py +288 -0
  33. package/src/superlocalmemory/storage/schema.py +10 -0
  34. package/src/superlocalmemory/storage/schema_v32.py +252 -0
  35. package/src/superlocalmemory/storage/v2_migrator.py +24 -2
package/CHANGELOG.md CHANGED
@@ -16,6 +16,40 @@ SuperLocalMemory V3 - Intelligent local memory system for AI coding assistants.
16
16
 
17
17
  ---
18
18
 
19
+ ## [3.2.2] - 2026-03-30
20
+
21
+ ### Added
22
+ - Performance improvements for retrieval pipeline
23
+ - New memory management capabilities with configurable lifecycle controls
24
+ - Enhanced dashboard with 3 additional monitoring tabs
25
+ - 9 new API endpoints for configuration and status
26
+ - 5 new MCP tools for proactive memory operations
27
+ - 5 new CLI commands for configuration management
28
+
29
+ ### Changed
30
+ - Internal retrieval architecture optimized with additional search channel
31
+ - Schema extensions for improved data management (9 new tables)
32
+ - Memory surfacing engine with multi-signal scoring
33
+
34
+ ### Performance
35
+ - Significant latency reduction in recall operations (vector-indexed retrieval)
36
+ - Idle-time memory optimization for large stores
37
+ - Reduced memory footprint for long-running sessions
38
+
39
+ ---
40
+
41
+ ## [3.2.1] - 2026-03-26
42
+
43
+ ### Fixed
44
+ - **Windows `slm --version` / `slm -v`** — `.bat` and `.cmd` wrappers now intercept `--version`/`-v` directly (fast path, no Python needed) and set `PYTHONPATH` to the npm package's `src/` directory before launching Python. Previously, Windows users hitting `slm.bat` instead of the Node.js wrapper got `unrecognized arguments: --version` because Python resolved an older pip-installed version without the flag.
45
+ - **Unix bash wrapper** (`bin/slm`) — now sets `PYTHONPATH` and intercepts `--version`/`-v`, matching the Node.js wrapper's behavior. Previously relied on npm's shim always routing to `slm-npm`.
46
+ - **`postinstall.js`** — now runs `pip install .` to install the `superlocalmemory` Python package itself (not just dependencies). Prevents stale pip-installed versions from shadowing the npm-distributed source. Falls back to `--user` for PEP 668 environments.
47
+ - **`preuninstall.js`** — corrected version string from "V2" to "V3".
48
+ - **Windows Python detection** — added `py -3` (Python Launcher for Windows) as a fallback candidate in `slm.bat`.
49
+ - **Environment parity** — all three entry points (`slm-npm`, `slm`, `slm.bat`) now set identical PyTorch memory-prevention env vars (`PYTORCH_MPS_HIGH_WATERMARK_RATIO`, `TORCH_DEVICE`, etc.).
50
+
51
+ ---
52
+
19
53
  ## [3.2.0] - 2026-03-26
20
54
 
21
55
  ### Added
@@ -347,7 +381,7 @@ We use [Semantic Versioning](https://semver.org/):
347
381
  - **MINOR:** New features (backward compatible, e.g., 2.0.0 → 2.1.0)
348
382
  - **PATCH:** Bug fixes (backward compatible, e.g., 2.1.0 → 2.1.1)
349
383
 
350
- **Current Version:** v2.8.0
384
+ **Current Version:** v3.2.2
351
385
  **Website:** [superlocalmemory.com](https://superlocalmemory.com)
352
386
  **npm:** `npm install -g superlocalmemory`
353
387
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <img src="https://superlocalmemory.com/assets/logo-mark.png" alt="SuperLocalMemory" width="200"/>
3
3
  </p>
4
4
 
5
- <h1 align="center">SuperLocalMemory V3</h1>
5
+ <h1 align="center">SuperLocalMemory V3.2</h1>
6
6
  <p align="center"><strong>The first local-only AI memory to break 74% retrieval on LoCoMo.<br/>No cloud. No APIs. No data leaves your machine.</strong></p>
7
7
 
8
8
  <p align="center">
@@ -47,6 +47,66 @@ Mathematical layers contribute **+12.7 percentage points** on average across 6 c
47
47
 
48
48
  ---
49
49
 
50
+ ## What's New in V3.2 — The Living Brain
51
+
52
+ > Your AI agent now remembers the way humans do: associatively, temporally, and with consolidation during idle time. V3.2 transforms SLM from a retrieval engine into a living memory system that surfaces what you need before you ask for it.
53
+
54
+ ### Headline Features
55
+
56
+ **100x Faster Recall** — Retrieval latency drops from ~500ms to <10ms at 10K facts. Vector KNN search replaces full-table scan. You feel the difference on the first query.
57
+
58
+ **Automatic Memory Surfacing** — Memories now come to you. A multi-signal scoring engine (similarity + recency + frequency + trust) proactively injects relevant context at session start and during conversations. No more "I forgot we decided that last week."
59
+
60
+ **Associative Retrieval (5th Channel)** — V3 had 4 retrieval channels. V3.2 adds a 5th: multi-hop spreading activation across your knowledge graph. Ask about "deployment" and it surfaces the related database migration decision three hops away.
61
+
62
+ **Temporal Intelligence** — Facts now carry time-awareness. Bi-temporal validity tracks when something was true vs. when it was recorded. Contradictions are detected automatically: "We use Postgres" + "We migrated to MySQL" triggers a conflict resolution flow.
63
+
64
+ **Sleep-Time Consolidation** — During idle periods, SLM compresses, deduplicates, and reorganizes your memory store. Redundant facts merge. Clusters tighten. Important memories get promoted to Core Memory blocks that stay permanently in context (inspired by Letta's core memory, but fully local).
65
+
66
+ **Core Memory Blocks** — Pin your most critical context (architecture decisions, team conventions, project constraints) into always-available working memory. These blocks are injected into every session automatically — your agent never starts cold.
67
+
68
+ ### By the Numbers
69
+
70
+ | Metric | V3.0 | V3.2 | Change |
71
+ |:-------|:----:|:----:|:------:|
72
+ | Recall latency (10K facts) | ~500ms | <10ms | **100x faster** |
73
+ | Retrieval channels | 4 | 5 | +spreading activation |
74
+ | MCP tools | 24 | 29 | +5 new |
75
+ | CLI commands | 16 | 21 | +5 new |
76
+ | Dashboard tabs | 17 | 20 | +3 new |
77
+ | API endpoints | — | 9 new | configuration & status |
78
+ | DB tables | 9 | 18 | +9 for temporal, consolidation, core memory |
79
+
80
+ ### Enable V3.2 Features
81
+
82
+ All new features default OFF. Zero breaking changes. Opt in when ready:
83
+
84
+ ```bash
85
+ # Turn on automatic memory surfacing
86
+ slm config set auto_invoke.enabled true
87
+
88
+ # Turn on sleep-time consolidation
89
+ slm config set consolidation.enabled true
90
+
91
+ # Turn on temporal intelligence
92
+ slm config set temporal.enabled true
93
+
94
+ # Turn on associative retrieval (5th channel)
95
+ slm config set retrieval.synapse.enabled true
96
+ ```
97
+
98
+ Or enable everything at once:
99
+
100
+ ```bash
101
+ slm config set v32_features.all true
102
+ ```
103
+
104
+ **Fully backward compatible.** All 29 MCP tools, 21 CLI commands work the same. Existing data untouched. New features activate only when you flip the switch.
105
+
106
+ > **V3.2 Paper** — Technical details, formal guarantees, and benchmark results in the upcoming companion paper. Watch the [arXiv page](https://arxiv.org/abs/2603.14588) for updates.
107
+
108
+ ---
109
+
50
110
  ## Quick Start
51
111
 
52
112
  ### Install via npm (recommended)
package/bin/slm CHANGED
@@ -2,6 +2,19 @@
2
2
  # SuperLocalMemory V3 CLI
3
3
  # Part of Qualixar | https://superlocalmemory.com
4
4
 
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ PKG_ROOT="$(dirname "$SCRIPT_DIR")"
7
+ SRC_DIR="$PKG_ROOT/src"
8
+
9
+ # Handle --version / -v directly (fast path)
10
+ for arg in "$@"; do
11
+ if [ "$arg" = "--version" ] || [ "$arg" = "-v" ]; then
12
+ VER=$(grep '"version"' "$PKG_ROOT/package.json" 2>/dev/null | head -1 | sed 's/.*"\([0-9][0-9.]*\)".*/\1/')
13
+ echo "superlocalmemory ${VER:-unknown}"
14
+ exit 0
15
+ fi
16
+ done
17
+
5
18
  # Find Python
6
19
  PYTHON=""
7
20
  for cmd in python3 python; do
@@ -12,9 +25,24 @@ for cmd in python3 python; do
12
25
  done
13
26
 
14
27
  if [ -z "$PYTHON" ]; then
15
- echo "Error: Python 3 not found. Install Python 3.10+ from python.org"
28
+ echo "Error: Python 3 not found. Install Python 3.11+ from python.org"
16
29
  exit 1
17
30
  fi
18
31
 
32
+ # Set PYTHONPATH so Python finds the npm package's src/ directory
33
+ if [ -n "$PYTHONPATH" ]; then
34
+ export PYTHONPATH="$SRC_DIR:$PYTHONPATH"
35
+ else
36
+ export PYTHONPATH="$SRC_DIR"
37
+ fi
38
+
39
+ # Prevent PyTorch Metal/MPS GPU memory reservation
40
+ export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
41
+ export PYTORCH_MPS_MEM_LIMIT=0
42
+ export PYTORCH_ENABLE_MPS_FALLBACK=1
43
+ export TOKENIZERS_PARALLELISM=false
44
+ export TORCH_DEVICE=cpu
45
+ export CUDA_VISIBLE_DEVICES=""
46
+
19
47
  # Run V3 CLI
20
48
  exec "$PYTHON" -m superlocalmemory.cli.main "$@"
package/bin/slm.bat CHANGED
@@ -6,22 +6,60 @@ REM Repository: https://github.com/qualixar/superlocalmemory
6
6
 
7
7
  setlocal enabledelayedexpansion
8
8
 
9
+ REM Resolve the package src/ directory for PYTHONPATH
10
+ set "SLM_PKG_DIR=%~dp0..\src"
11
+
12
+ REM Handle --version / -v directly (fast path, no Python needed)
13
+ if "%~1"=="--version" goto :show_version
14
+ if "%~1"=="-v" goto :show_version
15
+
9
16
  REM Find Python 3
10
- where python3 >/dev/null 2>&1
17
+ where python3 >nul 2>&1
11
18
  if %ERRORLEVEL% EQU 0 (
12
19
  set PYTHON_CMD=python3
13
20
  goto :run
14
21
  )
15
- where python >/dev/null 2>&1
22
+ where python >nul 2>&1
16
23
  if %ERRORLEVEL% EQU 0 (
17
24
  set PYTHON_CMD=python
18
25
  goto :run
19
26
  )
27
+ where py >nul 2>&1
28
+ if %ERRORLEVEL% EQU 0 (
29
+ set PYTHON_CMD=py -3
30
+ goto :run
31
+ )
20
32
 
21
33
  echo Error: Python 3.11+ not found.
22
34
  echo Install from: https://python.org/downloads/
23
35
  exit /b 1
24
36
 
37
+ :show_version
38
+ REM Read version from package.json via findstr
39
+ for /f "tokens=2 delims=:," %%a in ('findstr /C:"\"version\"" "%~dp0..\package.json"') do (
40
+ set "VER=%%~a"
41
+ set "VER=!VER: =!"
42
+ echo superlocalmemory !VER!
43
+ exit /b 0
44
+ )
45
+ echo superlocalmemory unknown
46
+ exit /b 0
47
+
25
48
  :run
49
+ REM Set PYTHONPATH so Python finds the npm package's src/ directory
50
+ if defined PYTHONPATH (
51
+ set "PYTHONPATH=%SLM_PKG_DIR%;%PYTHONPATH%"
52
+ ) else (
53
+ set "PYTHONPATH=%SLM_PKG_DIR%"
54
+ )
55
+
56
+ REM Prevent PyTorch Metal/MPS GPU memory reservation
57
+ set "PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0"
58
+ set "PYTORCH_MPS_MEM_LIMIT=0"
59
+ set "PYTORCH_ENABLE_MPS_FALLBACK=1"
60
+ set "TOKENIZERS_PARALLELISM=false"
61
+ set "TORCH_DEVICE=cpu"
62
+ set "CUDA_VISIBLE_DEVICES="
63
+
26
64
  %PYTHON_CMD% -m superlocalmemory.cli.main %*
27
65
  exit /b %ERRORLEVEL%
package/bin/slm.cmd CHANGED
@@ -1,5 +1,5 @@
1
1
  @echo off
2
2
  REM SuperLocalMemory V3 - Windows CLI (CMD variant)
3
- REM Calls slm.bat for compatibility
3
+ REM Delegates to slm.bat which handles PYTHONPATH and --version
4
4
  call "%~dp0slm.bat" %*
5
5
  exit /b %ERRORLEVEL%
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superlocalmemory",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "Information-geometric agent memory with mathematical guarantees. 4-channel retrieval, Fisher-Rao similarity, zero-LLM mode, EU AI Act compliant. Works with Claude, Cursor, Windsurf, and 17+ AI tools.",
5
5
  "keywords": [
6
6
  "ai-memory",
package/pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "superlocalmemory"
3
- version = "3.2.0"
3
+ version = "3.2.2"
4
4
  description = "Information-geometric agent memory with mathematical guarantees"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}
@@ -78,6 +78,31 @@ where = ["src"]
78
78
  [tool.pytest.ini_options]
79
79
  testpaths = ["tests"]
80
80
  pythonpath = ["src"]
81
+ markers = [
82
+ "slow: marks tests as slow (deselect with '-m \"not slow\"')",
83
+ ]
84
+
85
+ [tool.coverage.run]
86
+ source = ["superlocalmemory"]
87
+ omit = [
88
+ "*/tests/*",
89
+ "*/ui/*",
90
+ "*/cli/*",
91
+ "*/__main__.py",
92
+ ]
93
+
94
+ [tool.coverage.report]
95
+ fail_under = 0
96
+ show_missing = true
97
+ exclude_lines = [
98
+ "pragma: no cover",
99
+ "if TYPE_CHECKING:",
100
+ "if __name__ ==",
101
+ "@overload",
102
+ ]
103
+
104
+ [tool.coverage.html]
105
+ directory = "htmlcov"
81
106
 
82
107
  [tool.ruff]
83
108
  target-version = "py311"
@@ -157,6 +157,39 @@ if (pipInstall(perfDeps, 'performance')) {
157
157
  console.log('⚠ Performance deps skipped (system works fine without them).');
158
158
  }
159
159
 
160
+ // --- Step 3b: Install the superlocalmemory package itself ---
161
+ // This ensures `python -m superlocalmemory.cli.main` always resolves the
162
+ // correct version, even when invoked outside the Node.js wrapper (e.g.,
163
+ // via slm.bat on Windows or direct Python invocation).
164
+ console.log('\nInstalling superlocalmemory Python package...');
165
+ const pkgRoot = path.join(__dirname, '..');
166
+ const pipInstallPkg = spawnSync(pythonParts[0], [
167
+ ...pythonParts.slice(1), '-m', 'pip', 'install', '--quiet', '--disable-pip-version-check',
168
+ pkgRoot,
169
+ ], { stdio: 'pipe', timeout: 300000, env: { ...process.env, PATH: '/opt/homebrew/bin:/usr/local/bin:/usr/bin:' + (process.env.PATH || '') } });
170
+
171
+ if (pipInstallPkg.status === 0) {
172
+ console.log('✓ SuperLocalMemory Python package installed');
173
+ } else {
174
+ // Try with --user if PEP 668
175
+ const stderr = (pipInstallPkg.stderr || '').toString();
176
+ if (stderr.includes('externally-managed') || stderr.includes('PEP 668')) {
177
+ const retryResult = spawnSync(pythonParts[0], [
178
+ ...pythonParts.slice(1), '-m', 'pip', 'install', '--quiet', '--disable-pip-version-check',
179
+ '--user', pkgRoot,
180
+ ], { stdio: 'pipe', timeout: 300000, env: { ...process.env, PATH: '/opt/homebrew/bin:/usr/local/bin:/usr/bin:' + (process.env.PATH || '') } });
181
+ if (retryResult.status === 0) {
182
+ console.log('✓ SuperLocalMemory Python package installed (--user)');
183
+ } else {
184
+ console.log('⚠ Could not pip install the package. The Node.js wrapper (slm-npm)');
185
+ console.log(' sets PYTHONPATH automatically, so CLI will still work.');
186
+ }
187
+ } else {
188
+ console.log('⚠ Could not pip install the package. The Node.js wrapper (slm-npm)');
189
+ console.log(' sets PYTHONPATH automatically, so CLI will still work.');
190
+ }
191
+ }
192
+
160
193
  // --- Step 4: Detect V2 installation ---
161
194
  const V2_HOME = path.join(os.homedir(), '.claude-memory');
162
195
  if (fs.existsSync(V2_HOME) && fs.existsSync(path.join(V2_HOME, 'memory.db'))) {
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * SuperLocalMemory V2 - NPM Preuninstall Script
3
+ * SuperLocalMemory V3 - NPM Preuninstall Script
4
4
  *
5
5
  * Copyright (c) 2026 Varun Pratap Bhardwaj
6
6
  * Solution Architect & Original Creator
@@ -16,7 +16,7 @@ const os = require('os');
16
16
  const fs = require('fs');
17
17
 
18
18
  console.log('\n════════════════════════════════════════════════════════════');
19
- console.log(' SuperLocalMemory V2 - Uninstalling');
19
+ console.log(' SuperLocalMemory V3 - Uninstalling');
20
20
  console.log('════════════════════════════════════════════════════════════\n');
21
21
 
22
22
  const SLM_DIR = path.join(os.homedir(), '.superlocalmemory');
@@ -17,6 +17,7 @@ from __future__ import annotations
17
17
  import hashlib
18
18
  import hmac
19
19
  import os
20
+ import sys
20
21
  from datetime import datetime, timezone
21
22
  from typing import Dict
22
23
 
@@ -35,7 +36,11 @@ def _get_or_create_key() -> str:
35
36
  os.makedirs(os.path.dirname(key_path), exist_ok=True)
36
37
  with open(key_path, "w") as f:
37
38
  f.write(key)
38
- os.chmod(key_path, 0o600)
39
+ # On POSIX, restrict the key file to owner-only read/write.
40
+ # On Windows, os.chmod only supports setting the read-only flag
41
+ # and cannot enforce Unix-style permissions, so we skip it.
42
+ if sys.platform != "win32":
43
+ os.chmod(key_path, 0o600)
39
44
  return key
40
45
 
41
46
  _DEFAULT_KEY: str = _get_or_create_key()
@@ -84,13 +84,14 @@ class LLMConfig:
84
84
 
85
85
  @dataclass
86
86
  class ChannelWeights:
87
- """Retrieval channel weights — 4 channels, query-adaptive."""
87
+ """Retrieval channel weights — 5 channels, query-adaptive."""
88
88
 
89
89
  # Entity-linked facts are high-precision matches that rank above BM25.
90
90
  semantic: float = 1.2
91
91
  bm25: float = 1.0
92
92
  entity_graph: float = 1.3
93
93
  temporal: float = 1.0
94
+ spreading_activation: float = 1.0 # Phase 3: 5th channel (BC-08: default value)
94
95
 
95
96
  def as_dict(self) -> dict[str, float]:
96
97
  return {
@@ -98,6 +99,7 @@ class ChannelWeights:
98
99
  "bm25": self.bm25,
99
100
  "entity_graph": self.entity_graph,
100
101
  "temporal": self.temporal,
102
+ "spreading_activation": self.spreading_activation,
101
103
  }
102
104
 
103
105
 
@@ -207,6 +209,109 @@ class MathConfig:
207
209
  # Rate-Distortion (production only, disabled for benchmarks)
208
210
 
209
211
 
212
+ # ---------------------------------------------------------------------------
213
+ # Master Config
214
+ # ---------------------------------------------------------------------------
215
+
216
+ @dataclass(frozen=True)
217
+ class ConsolidationConfig:
218
+ """Configuration for sleep-time consolidation (Phase 5).
219
+
220
+ Feature-flagged: starts enabled=False (Rule 12).
221
+ """
222
+
223
+ enabled: bool = False # Feature flag (Rule 12)
224
+ step_count_trigger: int = 50 # Lightweight consolidation every N stores (L7)
225
+ session_trigger: bool = True # Run on session end
226
+ idle_timeout_seconds: int = 300 # 5 min inactivity
227
+ scheduled_sessions: int = 5 # Full consolidation every N sessions
228
+ core_memory_char_limit: int = 2000 # Total chars across all blocks
229
+ block_char_limit: int = 500 # Per-block character limit
230
+ compression_similarity: float = 0.85 # Dedup threshold for compression
231
+ promotion_min_access: int = 3 # Min access count for promotion
232
+ promotion_min_trust: float = 0.5 # Min trust for promotion
233
+ decay_days_threshold: int = 30 # Edge decay after N days
234
+
235
+
236
+ @dataclass(frozen=True)
237
+ class TemporalValidatorConfig:
238
+ """Configuration for temporal intelligence (Phase 4).
239
+
240
+ Feature-flagged: starts enabled=False (Rule 12).
241
+ """
242
+
243
+ enabled: bool = False
244
+ mode: str = "a" # "a" (sheaf), "b"/"c" (LLM)
245
+
246
+ # Sheaf contradiction threshold
247
+ contradiction_threshold: float = 0.45 # Mode A threshold (768d)
248
+
249
+ # LLM pre-filter threshold (lower to catch more candidates)
250
+ llm_prefilter_threshold: float = 0.30
251
+
252
+ # Max LLM checks per new fact (cost control)
253
+ max_llm_checks: int = 5
254
+
255
+ # Trust penalty for expired facts
256
+ expiration_trust_penalty: float = -0.2
257
+
258
+ # Include expired facts in historical queries
259
+ include_expired_in_history: bool = True
260
+
261
+
262
+ @dataclass(frozen=True)
263
+ class AutoInvokeConfig:
264
+ """Configuration for the Auto-Invoke Engine (Phase 2).
265
+
266
+ Feature-flagged: starts enabled=False, graduated to default on
267
+ after MRR validation passes (Rule 12).
268
+
269
+ References:
270
+ - SYNAPSE: FOK gating (fok_threshold = 0.12)
271
+ - ACT-R: base-level activation (act_r_decay = 0.5)
272
+ - Zep/Hindsight: multi-signal ranking consensus
273
+ """
274
+
275
+ enabled: bool = False # Feature flag (Rule 12)
276
+ profile_id: str = "default"
277
+
278
+ # Scoring weights (4-signal default) -- must sum to 1.0
279
+ weights: dict = field(default_factory=lambda: {
280
+ "similarity": 0.40,
281
+ "recency": 0.25,
282
+ "frequency": 0.20,
283
+ "trust": 0.15,
284
+ })
285
+
286
+ # ACT-R mode (3-signal alternative) -- must sum to 1.0
287
+ use_act_r: bool = False
288
+ act_r_weights: dict = field(default_factory=lambda: {
289
+ "similarity": 0.40,
290
+ "base_level": 0.35,
291
+ "trust": 0.25,
292
+ })
293
+ act_r_decay: float = 0.5 # Power-law decay exponent
294
+
295
+ # FOK gating (Feeling-of-Knowing)
296
+ fok_threshold: float = 0.12 # SYNAPSE minimum score gate
297
+
298
+ # Retrieval limits
299
+ max_memories_injected: int = 10
300
+ candidate_multiplier: int = 3 # candidates = limit * multiplier
301
+
302
+ # Mode A degradation weights -- must sum to 1.0
303
+ mode_a_weights: dict = field(default_factory=lambda: {
304
+ "similarity": 0.00,
305
+ "recency": 0.40,
306
+ "frequency": 0.35,
307
+ "trust": 0.25,
308
+ })
309
+
310
+ # Behavioral
311
+ include_archived: bool = False
312
+ relevance_threshold: float = 0.3 # Legacy compat with AutoRecall
313
+
314
+
210
315
  # ---------------------------------------------------------------------------
211
316
  # Master Config
212
317
  # ---------------------------------------------------------------------------
@@ -229,6 +334,13 @@ class SLMConfig:
229
334
  encoding: EncodingConfig = field(default_factory=EncodingConfig)
230
335
  retrieval: RetrievalConfig = field(default_factory=RetrievalConfig)
231
336
  math: MathConfig = field(default_factory=MathConfig)
337
+ temporal_validator: TemporalValidatorConfig = field(
338
+ default_factory=TemporalValidatorConfig,
339
+ )
340
+ auto_invoke: AutoInvokeConfig = field(default_factory=AutoInvokeConfig)
341
+ consolidation: ConsolidationConfig = field(
342
+ default_factory=ConsolidationConfig,
343
+ )
232
344
 
233
345
  def __post_init__(self) -> None:
234
346
  if self.db_path is None:
@@ -395,6 +507,7 @@ class SLMConfig:
395
507
  bm25=1.2,
396
508
  entity_graph=1.3,
397
509
  temporal=1.0,
510
+ spreading_activation=1.2, # Phase 3: SA boost in Mode C
398
511
  ),
399
512
  retrieval=RetrievalConfig(
400
513
  use_cross_encoder=True,