superlocalmemory 3.4.21 → 3.4.23

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 (114) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/package.json +1 -1
  3. package/pyproject.toml +2 -2
  4. package/scripts/build_entry.py +1 -1
  5. package/scripts/release_manifest.py +2 -2
  6. package/skills/slm-build-graph/SKILL.md +1 -1
  7. package/skills/slm-list-recent/SKILL.md +1 -1
  8. package/skills/slm-recall/SKILL.md +3 -3
  9. package/skills/slm-remember/SKILL.md +1 -1
  10. package/skills/slm-status/SKILL.md +1 -1
  11. package/skills/slm-switch-profile/SKILL.md +1 -1
  12. package/src/superlocalmemory/__init__.py +3 -0
  13. package/src/superlocalmemory/cli/commands.py +40 -5
  14. package/src/superlocalmemory/cli/context_commands.py +1 -1
  15. package/src/superlocalmemory/cli/db_migrate.py +1 -1
  16. package/src/superlocalmemory/cli/escape_hatch.py +1 -1
  17. package/src/superlocalmemory/cli/main.py +3 -3
  18. package/src/superlocalmemory/core/context_cache.py +2 -2
  19. package/src/superlocalmemory/core/ram_lock.py +1 -1
  20. package/src/superlocalmemory/core/recall_pipeline.py +5 -5
  21. package/src/superlocalmemory/core/security_primitives.py +2 -2
  22. package/src/superlocalmemory/core/shadow_router.py +2 -2
  23. package/src/superlocalmemory/core/slm_disabled.py +1 -1
  24. package/src/superlocalmemory/core/slmignore.py +1 -1
  25. package/src/superlocalmemory/core/topic_signature.py +3 -3
  26. package/src/superlocalmemory/evolution/budget.py +1 -1
  27. package/src/superlocalmemory/evolution/llm_dispatch.py +2 -2
  28. package/src/superlocalmemory/hooks/_outcome_common.py +1 -1
  29. package/src/superlocalmemory/hooks/adapter_base.py +1 -1
  30. package/src/superlocalmemory/hooks/antigravity_adapter.py +1 -1
  31. package/src/superlocalmemory/hooks/context_payload.py +2 -2
  32. package/src/superlocalmemory/hooks/copilot_adapter.py +1 -1
  33. package/src/superlocalmemory/hooks/cross_platform_connector.py +1 -1
  34. package/src/superlocalmemory/hooks/cursor_adapter.py +1 -1
  35. package/src/superlocalmemory/hooks/hook_handlers.py +1 -1
  36. package/src/superlocalmemory/hooks/ide_connector.py +2 -2
  37. package/src/superlocalmemory/hooks/post_tool_async_hook.py +1 -1
  38. package/src/superlocalmemory/hooks/post_tool_outcome_hook.py +1 -1
  39. package/src/superlocalmemory/hooks/prewarm_auth.py +1 -1
  40. package/src/superlocalmemory/hooks/session_registry.py +1 -1
  41. package/src/superlocalmemory/hooks/stop_outcome_hook.py +1 -1
  42. package/src/superlocalmemory/hooks/sync_loop.py +2 -2
  43. package/src/superlocalmemory/hooks/user_prompt_hook.py +1 -1
  44. package/src/superlocalmemory/hooks/user_prompt_rehash_hook.py +1 -1
  45. package/src/superlocalmemory/learning/arm_catalog.py +1 -1
  46. package/src/superlocalmemory/learning/bandit.py +1 -1
  47. package/src/superlocalmemory/learning/bandit_cache.py +1 -1
  48. package/src/superlocalmemory/learning/consolidation_cycle.py +4 -4
  49. package/src/superlocalmemory/learning/consolidation_worker.py +1 -1
  50. package/src/superlocalmemory/learning/database.py +5 -5
  51. package/src/superlocalmemory/learning/dedup_hnsw.py +1 -1
  52. package/src/superlocalmemory/learning/ensemble.py +2 -2
  53. package/src/superlocalmemory/learning/fact_outcome_joins.py +1 -1
  54. package/src/superlocalmemory/learning/forgetting_scheduler.py +2 -2
  55. package/src/superlocalmemory/learning/hnsw_dedup.py +2 -2
  56. package/src/superlocalmemory/learning/labeler.py +3 -3
  57. package/src/superlocalmemory/learning/legacy_migration.py +1 -1
  58. package/src/superlocalmemory/learning/memory_merge.py +1 -1
  59. package/src/superlocalmemory/learning/model_cache.py +1 -1
  60. package/src/superlocalmemory/learning/model_rollback.py +2 -2
  61. package/src/superlocalmemory/learning/outcome_queue.py +2 -2
  62. package/src/superlocalmemory/learning/pattern_miner.py +1 -1
  63. package/src/superlocalmemory/learning/pattern_miner_constants.py +1 -1
  64. package/src/superlocalmemory/learning/ranker.py +3 -3
  65. package/src/superlocalmemory/learning/ranker_common.py +1 -1
  66. package/src/superlocalmemory/learning/ranker_retrain_legacy.py +3 -3
  67. package/src/superlocalmemory/learning/ranker_retrain_online.py +4 -4
  68. package/src/superlocalmemory/learning/reward.py +1 -1
  69. package/src/superlocalmemory/learning/reward_archive.py +2 -2
  70. package/src/superlocalmemory/learning/reward_boost.py +2 -2
  71. package/src/superlocalmemory/learning/reward_proxy.py +4 -4
  72. package/src/superlocalmemory/learning/shadow_test.py +1 -1
  73. package/src/superlocalmemory/learning/signal_worker.py +2 -2
  74. package/src/superlocalmemory/learning/signals.py +2 -2
  75. package/src/superlocalmemory/learning/trigram_index.py +1 -1
  76. package/src/superlocalmemory/mcp/tools_context.py +1 -1
  77. package/src/superlocalmemory/mcp/tools_core.py +2 -2
  78. package/src/superlocalmemory/parameterization/soft_prompt_generator.py +3 -3
  79. package/src/superlocalmemory/server/bandit_loops.py +2 -2
  80. package/src/superlocalmemory/server/middleware/__init__.py +2 -2
  81. package/src/superlocalmemory/server/middleware/security_headers.py +3 -3
  82. package/src/superlocalmemory/server/routes/brain.py +10 -10
  83. package/src/superlocalmemory/server/routes/prewarm.py +1 -1
  84. package/src/superlocalmemory/server/security_middleware.py +21 -3
  85. package/src/superlocalmemory/server/unified_daemon.py +111 -9
  86. package/src/superlocalmemory/skills/slm-build-graph/SKILL.md +423 -0
  87. package/src/superlocalmemory/skills/slm-list-recent/SKILL.md +348 -0
  88. package/src/superlocalmemory/skills/slm-recall/SKILL.md +343 -0
  89. package/src/superlocalmemory/skills/slm-remember/SKILL.md +194 -0
  90. package/src/superlocalmemory/skills/slm-show-patterns/SKILL.md +224 -0
  91. package/src/superlocalmemory/skills/slm-status/SKILL.md +363 -0
  92. package/src/superlocalmemory/skills/slm-switch-profile/SKILL.md +442 -0
  93. package/src/superlocalmemory/storage/migration_runner.py +4 -4
  94. package/src/superlocalmemory/storage/migrations/M001_add_signal_features_columns.py +1 -1
  95. package/src/superlocalmemory/storage/migrations/M002_model_state_history.py +2 -2
  96. package/src/superlocalmemory/storage/migrations/M003_migration_log.py +1 -1
  97. package/src/superlocalmemory/storage/migrations/M004_cross_platform_sync_log.py +1 -1
  98. package/src/superlocalmemory/storage/migrations/M005_bandit_tables.py +1 -1
  99. package/src/superlocalmemory/storage/migrations/M006_action_outcomes_reward.py +1 -1
  100. package/src/superlocalmemory/storage/migrations/M007_pending_outcomes.py +1 -1
  101. package/src/superlocalmemory/storage/migrations/M009_model_lineage.py +1 -1
  102. package/src/superlocalmemory/storage/migrations/M010_evolution_config.py +2 -2
  103. package/src/superlocalmemory/storage/migrations/M011_archive_and_merge.py +1 -1
  104. package/src/superlocalmemory/storage/migrations/M012_shadow_observations.py +1 -1
  105. package/src/superlocalmemory/storage/migrations/M013_bi_temporal_columns.py +2 -2
  106. package/src/superlocalmemory/storage/migrations/__init__.py +3 -3
  107. package/src/superlocalmemory/ui/index.html +4 -0
  108. package/src/superlocalmemory/ui/js/core.js +96 -1
  109. package/src/superlocalmemory.egg-info/PKG-INFO +655 -0
  110. package/src/superlocalmemory.egg-info/SOURCES.txt +426 -0
  111. package/src/superlocalmemory.egg-info/dependency_links.txt +1 -0
  112. package/src/superlocalmemory.egg-info/entry_points.txt +2 -0
  113. package/src/superlocalmemory.egg-info/requires.txt +58 -0
  114. package/src/superlocalmemory.egg-info/top_level.txt +1 -0
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-01 §4.3
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-01 §4.3
4
4
 
5
5
  """UserPromptSubmit hook — Python fallback (compiled binary preferred).
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — Track A.2 (LLD-09 / LLD-00)
3
+ # Part of SuperLocalMemory v3.4.22 — Track A.2 (LLD-09 / LLD-00)
4
4
 
5
5
  """UserPromptSubmit rehash hook — detect re-query within 60 s.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-03 §5.1
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-03 §5.1
4
4
 
5
5
  """Static 40-arm catalog for the contextual Thompson bandit.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-03 §3 + §5.3
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-03 §3 + §5.3
4
4
 
5
5
  """Contextual Thompson-sampling bandit over discrete channel-weight arms.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-03 §5.2
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-03 §5.2
4
4
 
5
5
  """Per-(profile, stratum) posterior LRU cache for the contextual bandit.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-01 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-01 fix
4
4
 
5
5
  """ConsolidationWorker — background memory maintenance lifecycle.
6
6
 
@@ -196,7 +196,7 @@ class ConsolidationWorker:
196
196
  def _deduplicate(self, profile_id: str, dry_run: bool) -> int:
197
197
  """Find and mark near-duplicate facts.
198
198
 
199
- v3.4.21 (LLD-12): prefer HNSW ANN + entity-overlap dedup with a
199
+ v3.4.22 (LLD-12): prefer HNSW ANN + entity-overlap dedup with a
200
200
  reversible merge log. On any error (missing schema columns,
201
201
  hnswlib unavailable, RAM budget exceeded) fall back to the
202
202
  legacy prefix dedup so existing deployments keep working.
@@ -204,7 +204,7 @@ class ConsolidationWorker:
204
204
  Never DELETEs from atomic_facts — merges flip archive_status
205
205
  and write memory_merge_log rows.
206
206
  """
207
- # v3.4.21 preferred path: HNSW + memory_merge (LLD-12).
207
+ # v3.4.22 preferred path: HNSW + memory_merge (LLD-12).
208
208
  try:
209
209
  from superlocalmemory.learning.hnsw_dedup import (
210
210
  HnswDeduplicator,
@@ -227,7 +227,7 @@ class ConsolidationWorker:
227
227
  except Exception as exc:
228
228
  logger.debug("hnsw dedup unexpected error, fallback: %s", exc)
229
229
 
230
- # Legacy fallback (pre-v3.4.21 behaviour).
230
+ # Legacy fallback (pre-v3.4.22 behaviour).
231
231
  # S9-defer H-P-09: hard cap on the fallback scan so a profile
232
232
  # with 5M+ atomic_facts cannot OOM the consolidation worker
233
233
  # when hnswlib is unavailable. The fallback is a prefix-match
@@ -4,7 +4,7 @@
4
4
 
5
5
  """Sleep-Time Consolidation Worker — **back-compat shim**.
6
6
 
7
- As of v3.4.21 (F4.A Stage-8 H-01 fix), the 1344-LOC god-module was
7
+ As of v3.4.22 (F4.A Stage-8 H-01 fix), the 1344-LOC god-module was
8
8
  split into five cohesive files:
9
9
 
10
10
  - ``consolidation_cycle.py`` — :class:`ConsolidationWorker`.
@@ -91,7 +91,7 @@ class LearningDatabase:
91
91
  def path(self) -> str:
92
92
  """Read-only path to the learning SQLite database.
93
93
 
94
- S8-ARC-02 (v3.4.21): public alternative to the underscore-private
94
+ S8-ARC-02 (v3.4.22): public alternative to the underscore-private
95
95
  ``_db_path``. Callers that need a raw connection for specialised
96
96
  read patterns should prefer :meth:`ro_connection` over building
97
97
  one themselves so WAL + busy_timeout pragmas are consistent.
@@ -366,7 +366,7 @@ class LearningDatabase:
366
366
  conn.close()
367
367
 
368
368
  # ------------------------------------------------------------------
369
- # LLD-02 §4.8 — v3.4.21 writer surface
369
+ # LLD-02 §4.8 — v3.4.22 writer surface
370
370
  # ------------------------------------------------------------------
371
371
 
372
372
  def count_signals(self, profile_id: str) -> int:
@@ -395,7 +395,7 @@ class LearningDatabase:
395
395
  feature_names: list[str],
396
396
  trained_on_count: int,
397
397
  metrics: dict,
398
- model_version: str = "3.4.21",
398
+ model_version: str = "3.4.23",
399
399
  ) -> int:
400
400
  """Persist a newly trained model and flip the active flag.
401
401
 
@@ -520,7 +520,7 @@ class LearningDatabase:
520
520
  def _migration_applied(self, name: str) -> bool:
521
521
  """Return True if ``name`` is recorded complete in migration_log.
522
522
 
523
- M006 (action_outcomes.reward) lands in v3.4.21. When absent, we
523
+ M006 (action_outcomes.reward) lands in v3.4.22. When absent, we
524
524
  fall back to the position-only training query.
525
525
  """
526
526
  conn = self._connect()
@@ -556,7 +556,7 @@ class LearningDatabase:
556
556
  (False) preserves Stage 8 D9 — synthetic rows excluded unless the
557
557
  caller opts in explicitly. The UI exposes this via the
558
558
  "Migrate legacy data" flow so users consciously choose to let their
559
- pre-v3.4.21 feedback bootstrap the model.
559
+ pre-v3.4.22 feedback bootstrap the model.
560
560
 
561
561
  Returns rows sorted newest-first; the caller is expected to regroup
562
562
  by ``query_id`` before training.
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-03/H-17/H-18 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-03/H-17/H-18 fix
4
4
 
5
5
  """HNSW-backed near-duplicate detection for atomic_facts.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-03 §5.4
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-03 §5.4
4
4
 
5
5
  """Bandit / LightGBM ensemble blender.
6
6
 
@@ -137,7 +137,7 @@ def _apply_weights_score(candidate: Any, weights: dict[str, float]) -> float:
137
137
  """Compute a scalar bandit score for a candidate under the arm weights.
138
138
 
139
139
  Input shape: candidate has either ``.channel_scores`` attr OR ``score``.
140
- For v3.4.21 the bandit-only path simply uses the already-weighted ordering
140
+ For v3.4.22 the bandit-only path simply uses the already-weighted ordering
141
141
  from ``apply_channel_weights``; this helper only matters when we blend.
142
142
  """
143
143
  # Prefer pre-weighted score on the object.
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-03/H-06 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-03/H-06 fix
4
4
 
5
5
  """Parameterised JSON1-backed join helpers for ``action_outcomes``.
6
6
 
@@ -306,7 +306,7 @@ class ForgettingScheduler:
306
306
  def _soft_delete_with_audit(self, fact_id: str, profile_id: str) -> None:
307
307
  """Soft-delete a forgotten fact with compliance audit trail.
308
308
 
309
- v3.4.21 (LLD-12 §4): reward-gated. If the fact has any positive
309
+ v3.4.22 (LLD-12 §4): reward-gated. If the fact has any positive
310
310
  reward (>0.3) in the last 60 days, it is considered "still
311
311
  useful" and kept live — consolidation will retry next cycle.
312
312
 
@@ -329,7 +329,7 @@ class ForgettingScheduler:
329
329
  ) -> bool:
330
330
  """True if fact has an outcome_reward > 0.3 in the last 60 days.
331
331
 
332
- v3.4.21 (Stage 8 H-06): routes through the JSON1-backed
332
+ v3.4.22 (Stage 8 H-06): routes through the JSON1-backed
333
333
  ``fact_outcome_joins.has_recent_positive_reward`` helper —
334
334
  eliminates the substring-LIKE false-positive class.
335
335
 
@@ -1,10 +1,10 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-03/H-17/H-18 shim
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-03/H-17/H-18 shim
4
4
 
5
5
  """HNSW dedup + reward-gated archive + strong-memory boost — shim.
6
6
 
7
- As of v3.4.21 (Stage 8 H-03/H-17/H-18 fixes), the 535-LOC god-module
7
+ As of v3.4.22 (Stage 8 H-03/H-17/H-18 fixes), the 535-LOC god-module
8
8
  was split into three cohesive files:
9
9
 
10
10
  - ``dedup_hnsw.py`` — :class:`HnswDeduplicator` + fallback counter.
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-02 §4.7
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-02 §4.7
4
4
 
5
5
  """Integer-label mapping for LightGBM ``lambdarank`` training.
6
6
 
@@ -11,7 +11,7 @@ Rules:
11
11
  - Labels are integers in ``[0, 4]`` (5 relevance tiers).
12
12
  - ``label_gain`` length MUST be ``>= max(label) + 1``; we ship
13
13
  ``label_gain=[0, 1, 3, 7, 15]`` (length 5).
14
- - Prefer ``outcome_reward`` (v3.4.21) if present; else position proxy.
14
+ - Prefer ``outcome_reward`` (v3.4.22) if present; else position proxy.
15
15
  - ``NaN`` reward is treated as missing and falls through to position.
16
16
  """
17
17
 
@@ -68,7 +68,7 @@ def label_for_row(row: dict) -> int:
68
68
  return 1
69
69
  return 0
70
70
 
71
- # 3.4.21 proxy: position (0 = best, higher = worse).
71
+ # 3.4.22 proxy: position (0 = best, higher = worse).
72
72
  try:
73
73
  pos = int(row.get("position", 99))
74
74
  except (TypeError, ValueError):
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21
3
+ # Part of SuperLocalMemory v3.4.22
4
4
 
5
5
  """Legacy ``learning_feedback`` row migration — data movement only.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-12 §2.3 + §1.4
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-12 §2.3 + §1.4
4
4
 
5
5
  """Reversible merge-log writer + unmerge for consolidation.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-02 §4.4
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-02 §4.4
4
4
 
5
5
  """Active-model cache + integrity verification.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — Track A.3 (LLD-10 §5)
3
+ # Part of SuperLocalMemory v3.4.22 — Track A.3 (LLD-10 §5)
4
4
 
5
5
  """Post-promotion watch + auto-rollback (LLD-10 §5).
6
6
 
@@ -98,7 +98,7 @@ class ModelRollback:
98
98
  Regression is detected by whichever of these is true:
99
99
  * **Ratio path** (baseline ≥ ``_BASELINE_RATIO_FLOOR``, i.e. 0.05):
100
100
  ``(baseline - current) / baseline ≥ REGRESSION_THRESHOLD``.
101
- Existing v3.4.21 pre-fix semantics preserved at normal
101
+ Existing v3.4.22 pre-fix semantics preserved at normal
102
102
  baselines.
103
103
  * **Absolute path** (baseline below the ratio floor — includes
104
104
  zero and negative baselines which can happen on sparse data):
@@ -1,10 +1,10 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — Stage 9 DASH-02
3
+ # Part of SuperLocalMemory v3.4.22 — Stage 9 DASH-02
4
4
 
5
5
  """Background queue for producer-side engagement-reward recording.
6
6
 
7
- **Why this module exists.** Before v3.4.21, ``EngagementRewardModel.record_recall``
7
+ **Why this module exists.** Before v3.4.22, ``EngagementRewardModel.record_recall``
8
8
  had zero production callers. Every recall path (CLI, MCP, dashboard, daemon
9
9
  HTTP) returned results without ever creating a ``pending_outcomes`` row. The
10
10
  closed-loop learning pipeline therefore had no producer — its consumers
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-01 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-01 fix
4
4
 
5
5
  """Behavioural pattern mining for the consolidation worker.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-01 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-01 fix
4
4
 
5
5
  """Static dictionaries used by ``pattern_miner`` — extracted so the
6
6
  main module stays under the 400-LOC cap.
@@ -55,7 +55,7 @@ class AdaptiveRanker:
55
55
  available — it carries verified booster + feature_names. The legacy
56
56
  ``model_state`` bytes path remains for backward compatibility with
57
57
  3.4.20 callers; it does NOT perform SHA-256 verification and should
58
- not be used by the 3.4.21 recall path.
58
+ not be used by the 3.4.22 recall path.
59
59
  """
60
60
  self._signal_count = signal_count
61
61
  self._active = active_model
@@ -215,7 +215,7 @@ class AdaptiveRanker:
215
215
  def _load_legacy_bytes(self, state: bytes) -> None:
216
216
  """Best-effort load from raw bytes — NO SHA-256 verify.
217
217
 
218
- Kept for 3.4.20 callers. The 3.4.21 recall path uses
218
+ Kept for 3.4.20 callers. The 3.4.22 recall path uses
219
219
  ``model_cache.load_active`` which enforces verification.
220
220
  """
221
221
  try:
@@ -240,7 +240,7 @@ class AdaptiveRanker:
240
240
  # --- legacy train() shim (3.4.20 API) ------------------------------
241
241
 
242
242
  def train(self, training_data: list) -> bool:
243
- """Deprecated — v3.4.21 training lives in ``consolidation_worker``.
243
+ """Deprecated — v3.4.22 training lives in ``consolidation_worker``.
244
244
 
245
245
  Kept as a guard for 3.4.20 callers: returns False when
246
246
  training_data is below the Phase-3 threshold, True after a best-
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-01 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-01 fix
4
4
 
5
5
  """Ranker retraining helpers shared by legacy + online paths.
6
6
 
@@ -1,10 +1,10 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-07 deprecation
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-07 deprecation
4
4
 
5
5
  """Legacy ranker retrain path (signal_count >= 200 cold-start).
6
6
 
7
- **DEPRECATED** as of v3.4.21: superseded by the LLD-10 online retrain
7
+ **DEPRECATED** as of v3.4.22: superseded by the LLD-10 online retrain
8
8
  cycle in ``ranker_retrain_online.py``. Retained for two reasons:
9
9
 
10
10
  1. Back-compat — ``tests/test_learning/test_ranker_v2.py`` and
@@ -55,7 +55,7 @@ def _emit_deprecation_once() -> None:
55
55
  # survive into v3.5.x tech debt. Remove with the dashboard lineage
56
56
  # UI ship (Stage 7+) per MANIFEST-DEVIATION A.3 #3.
57
57
  warnings.warn(
58
- "ranker_retrain_legacy is deprecated as of SLM v3.4.21 and will "
58
+ "ranker_retrain_legacy is deprecated as of SLM v3.4.22 and will "
59
59
  "be REMOVED in v3.5.0 — use ranker_retrain_online._run_shadow_cycle "
60
60
  "instead. The legacy path is kept only for cold-start profiles "
61
61
  "with no active model.",
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-01 + LLD-10
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-01 + LLD-10
4
4
 
5
5
  """LLD-10 online retrain: hyperparam-capped LightGBM training + candidate
6
6
  persist + atomic lineage flip.
@@ -17,7 +17,7 @@ working without any test churn.
17
17
 
18
18
  Contract refs:
19
19
  - LLD-10 §2 (triggers), §3.2 (caps), §5 (lineage flip).
20
- - IMPLEMENTATION-MANIFEST v3.4.21 FINAL A.3.
20
+ - IMPLEMENTATION-MANIFEST v3.4.22 FINAL A.3.
21
21
  - Stage 8 H-01 (architect).
22
22
  """
23
23
 
@@ -199,7 +199,7 @@ def _train_booster(
199
199
  num_boost_round = int(params.pop("num_boost_round"))
200
200
 
201
201
  start = time.monotonic()
202
- # S9-defer H-P-08: before v3.4.21 the wall-time check fired only
202
+ # S9-defer H-P-08: before v3.4.22 the wall-time check fired only
203
203
  # AFTER ``lgb.train`` returned, which could take minutes on a
204
204
  # pathological dataset before we noticed. LightGBM's ``callbacks``
205
205
  # parameter accepts a per-iteration hook that can stop training
@@ -275,7 +275,7 @@ def _persist_candidate(
275
275
  " trained_on_count, feature_names, metrics_json, "
276
276
  " is_active, is_candidate, shadow_results_json, "
277
277
  " trained_at, updated_at) "
278
- "VALUES (?, '3.4.21', ?, ?, ?, ?, ?, 0, 1, ?, ?, ?)",
278
+ "VALUES (?, '3.4.22', ?, ?, ?, ?, ?, 0, 1, ?, ?, ?)",
279
279
  (
280
280
  profile_id, state_bytes, sha, int(trained_on_count),
281
281
  fn_json, metrics_json, shadow_json, now, now,
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — Track A.1 (LLD-08 / LLD-00)
3
+ # Part of SuperLocalMemory v3.4.22 — Track A.1 (LLD-08 / LLD-00)
4
4
 
5
5
  """EngagementRewardModel — closes the recall→outcome→label loop.
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-18/H-06 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-18/H-06 fix
4
4
 
5
5
  """Reward-gated Ebbinghaus archive.
6
6
 
@@ -10,7 +10,7 @@ positive reward in the last 60 days AND are not marked important
10
10
  updates ``atomic_facts.archive_status='archived'``.
11
11
 
12
12
  **Never issues DELETE FROM atomic_facts** (SOUL directive, LLD-12 §1 —
13
- memory is sacred across v3.4.21 with 18 000 live users).
13
+ memory is sacred across v3.4.22 with 18 000 live users).
14
14
 
15
15
  JSON1 join helper (``iter_outcomes_for_fact``) replaces the former
16
16
  ``fact_ids_json LIKE '%"<fid>"%'`` pattern so that overlapping fact_id
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — F4.A Stage-8 H-06/H-18 fix
3
+ # Part of SuperLocalMemory v3.4.22 — F4.A Stage-8 H-06/H-18 fix
4
4
 
5
5
  """Strong-memory boost + reward-aware fact selection.
6
6
 
@@ -29,7 +29,7 @@ from superlocalmemory.learning.fact_outcome_joins import (
29
29
  # Returns ``{fact_id: (count, mean_reward)}`` for outcomes with reward NOT
30
30
  # NULL. Replaces the per-fact O(F) loop of ``aggregate_reward_for_fact``
31
31
  # with one GROUP BY scan — O(F+O) instead of O(F·O). JSON1 has been
32
- # mandatory since v3.4.21 (see ``fact_outcome_joins._json1_available``
32
+ # mandatory since v3.4.22 (see ``fact_outcome_joins._json1_available``
33
33
  # contract in the module docstring); if it is missing at runtime the
34
34
  # caller falls back to the per-fact helper which retains its own
35
35
  # LIKE-based shim.
@@ -1,13 +1,13 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-03 §3.5 + §5.6
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-03 §3.5 + §5.6
4
4
 
5
- """Proxy settlement for bandit plays (v3.4.21 only).
5
+ """Proxy settlement for bandit plays (v3.4.22 only).
6
6
 
7
7
  LLD reference: ``.backup/active-brain/lld/LLD-03-contextual-bandit-and-ensemble.md``
8
8
  Section 3.5 and 5.6.
9
9
 
10
- Replaced in v3.4.21 by ``reward_from_outcomes.py`` — DO NOT extend this
10
+ Replaced in v3.4.22 by ``reward_from_outcomes.py`` — DO NOT extend this
11
11
  module beyond the proxy window contract.
12
12
 
13
13
  Policy (§3.5):
@@ -133,7 +133,7 @@ def _tool_event_hit(
133
133
  except sqlite3.Error:
134
134
  return False
135
135
 
136
- # E.2 (v3.4.21 perf): previously ran N separate LIKE '%fid%' scans,
136
+ # E.2 (v3.4.22 perf): previously ran N separate LIKE '%fid%' scans,
137
137
  # each doing a full table scan of ``tool_events`` inside the 30-second
138
138
  # window. Instead, fetch the small window once and scan its payloads
139
139
  # in Python — typically 0-few rows in a 30 s window, far cheaper than
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — Track A.3 (LLD-10 / LLD-00 §8)
3
+ # Part of SuperLocalMemory v3.4.22 — Track A.3 (LLD-10 / LLD-00 §8)
4
4
 
5
5
  """Two-phase live-recall A/B shadow validator (LLD-10 §4 + LLD-00 §8).
6
6
 
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-02 §4.2
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-02 §4.2
4
4
 
5
5
  """Background signal drain worker.
6
6
 
@@ -37,7 +37,7 @@ def _current_queue() -> "queue.Queue[SignalBatch]":
37
37
  """Resolve the queue through the public ``signals.get_queue()``
38
38
  contract. Tests monkeypatching ``signals._Q`` still win because
39
39
  ``get_queue`` reads the attribute dynamically via ``sys.modules``.
40
- S8-ARC-03 (v3.4.21): no more private ``_Q`` reach-through.
40
+ S8-ARC-03 (v3.4.22): no more private ``_Q`` reach-through.
41
41
  """
42
42
  return _signals_get_queue()
43
43
 
@@ -38,7 +38,7 @@ logger = logging.getLogger(__name__)
38
38
  # LLD-02 §4.1 — SignalBatch + enqueue + record_signal_batch
39
39
  # ===========================================================================
40
40
  #
41
- # These module-level helpers are the v3.4.21 signal pipeline. The class
41
+ # These module-level helpers are the v3.4.22 signal pipeline. The class
42
42
  # ``LearningSignals`` below stays in place for v3.4.20 compatibility (D5);
43
43
  # new writers go through ``enqueue`` / ``record_signal_batch``.
44
44
  # ---------------------------------------------------------------------------
@@ -109,7 +109,7 @@ def _bump(counter: str, n: int = 1) -> None:
109
109
  _counters[counter] = _counters.get(counter, 0) + n
110
110
 
111
111
 
112
- # S8-ARC-03 (v3.4.21): public producer/consumer contract. ``signal_worker``
112
+ # S8-ARC-03 (v3.4.22): public producer/consumer contract. ``signal_worker``
113
113
  # used to reach through ``signals._Q`` and ``signals._bump`` by name,
114
114
  # which made the private-by-convention boundary the actual test seam
115
115
  # too. These wrappers are the sanctioned surface; ``_Q`` / ``_bump`` stay
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-13 Track C.1
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-13 Track C.1
4
4
 
5
5
  """Inline trigram entity detection — hot-path Layer A of the two-layer
6
6
  entity detector defined in ``LLD-13-inline-entity-detection.md``.
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-05 §7
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-05 §7
4
4
 
5
5
  """MCP proactive-context tool — ``prestage_context``.
6
6
 
@@ -45,9 +45,9 @@ def _record_recall_hits(
45
45
  ) -> None:
46
46
  """Record honest shown-state signals (LLD-02 §4.9).
47
47
 
48
- v3.4.21: No more fake positives. For every candidate we enqueue a
48
+ v3.4.22: No more fake positives. For every candidate we enqueue a
49
49
  ``shown`` / ``not_shown`` flip based on whether it was returned in the
50
- top-K presented to the user. Outcome/reward arrives in v3.4.21 via the
50
+ top-K presented to the user. Outcome/reward arrives in v3.4.22 via the
51
51
  action-outcomes pipeline.
52
52
 
53
53
  Non-blocking: all work funnels through ``signals.enqueue_shown_flip``
@@ -131,10 +131,10 @@ class SoftPromptGenerator:
131
131
  Args:
132
132
  patterns: Extracted pattern assertions.
133
133
  profile_id: Target profile.
134
- high_reward_source_ids: Optional v3.4.21 (LLD-12 §6) filter —
134
+ high_reward_source_ids: Optional v3.4.22 (LLD-12 §6) filter —
135
135
  when provided, only patterns whose source_ids intersect
136
136
  this set are considered. When None (default), behaviour
137
- matches pre-v3.4.21 and every pattern flows through.
137
+ matches pre-v3.4.22 and every pattern flows through.
138
138
 
139
139
  Returns:
140
140
  List of SoftPromptTemplate, ordered by category priority,
@@ -146,7 +146,7 @@ class SoftPromptGenerator:
146
146
  p for p in patterns if p.category.value in enabled
147
147
  ]
148
148
 
149
- # v3.4.21 (LLD-12 §6): reward-aware filter — opt-in only.
149
+ # v3.4.22 (LLD-12 §6): reward-aware filter — opt-in only.
150
150
  if high_reward_source_ids is not None:
151
151
  filtered = [
152
152
  p for p in filtered
@@ -1,8 +1,8 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-03 §3.5 + §3.6
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-03 §3.5 + §3.6
4
4
 
5
- """Background schedulers for the v3.4.21 contextual bandit.
5
+ """Background schedulers for the v3.4.22 contextual bandit.
6
6
 
7
7
  Two asyncio tasks, both registered in the daemon lifespan:
8
8
 
@@ -1,11 +1,11 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-04 §4.2
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-04 §4.2
4
4
 
5
5
  """FastAPI middleware — strict security headers for the Brain UI (LLD-04 v2).
6
6
 
7
7
  The existing ``server/security_middleware.py`` is kept for legacy routes
8
8
  that still rely on permissive CSP (``'unsafe-inline'`` + CDNs). The
9
- middleware in this subpackage enforces the v3.4.21 policy: no inline
9
+ middleware in this subpackage enforces the v3.4.22 policy: no inline
10
10
  scripts / styles, no nonces, no CDN sources.
11
11
  """
@@ -1,6 +1,6 @@
1
1
  # Copyright (c) 2026 Varun Pratap Bhardwaj / Qualixar
2
2
  # Licensed under AGPL-3.0-or-later - see LICENSE file
3
- # Part of SuperLocalMemory v3.4.21 — LLD-04 §4.2 (v2)
3
+ # Part of SuperLocalMemory v3.4.22 — LLD-04 §4.2 (v2)
4
4
 
5
5
  """Strict security-headers ASGI middleware for the Brain UI.
6
6
 
@@ -72,7 +72,7 @@ _OWNED_NAMES: frozenset[bytes] = frozenset(name for name, _ in _HEADERS)
72
72
  # ``/ui/*``, ``/static/*``, other tabs) currently load vendor libraries
73
73
  # (Bootstrap, Bootstrap Icons, Inter font, D3, Sigma, graphology) from CDNs
74
74
  # and would break under ``script-src 'self'`` until those assets are vendored
75
- # locally (tracked for v3.4.21 vendoring work). Applying the strict set there
75
+ # locally (tracked for v3.4.22 vendoring work). Applying the strict set there
76
76
  # produced a user-visible regression during Stage 6 delivery-lead review,
77
77
  # which contradicts LLD-04's user-benefit goal. This middleware therefore
78
78
  # enforces the strict set on the routes that actually need it today —
@@ -106,7 +106,7 @@ class SecurityHeadersMiddleware:
106
106
 
107
107
  Scope: see ``_STRICT_SCOPE_PREFIXES``. Outside that scope the middleware
108
108
  passes through untouched so pre-existing dashboard CSP policy still
109
- governs index/static responses until the vendoring work in v3.4.21.
109
+ governs index/static responses until the vendoring work in v3.4.22.
110
110
  """
111
111
 
112
112
  def __init__(self, app: ASGIApp) -> None: