prism-mcp-server 10.0.0 → 11.0.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 CHANGED
@@ -25,23 +25,67 @@ https://github.com/dcostenco/prism-mcp/raw/main/docs/prism_mcp_demo.mp4
25
25
  ## 📖 Table of Contents
26
26
 
27
27
  - [Why Prism?](#why-prism)
28
- - [Quick Start](#-quick-start)
29
- - [The Magic Moment](#-the-magic-moment)
30
- - [Setup Guides](#-setup-guides)
31
- - [Universal Import: Bring Your History](#-universal-import-bring-your-history)
32
- - [What Makes Prism Different](#-what-makes-prism-different)
33
- - [Cognitive Architecture (v7.8)](#-cognitive-architecture-v78)
34
- - [Data Privacy & Egress](#-data-privacy-egress)
35
- - [Use Cases](#-use-cases)
36
- - [What's New](#-whats-new)
37
- - [How Prism Compares](#-how-prism-compares)
38
- - [CLI Reference](#-cli-reference)
39
- - [Tool Reference](#-tool-reference)
28
+ - [Quick Start](#quick-start)
29
+ - [The Magic Moment](#the-magic-moment)
30
+ - [Setup Guides](#setup-guides)
31
+ - [Universal Import: Bring Your History](#universal-import-bring-your-history)
32
+ - [What Makes Prism Different](#what-makes-prism-different)
33
+ - [Cognitive Architecture (v7.8)](#cognitive-architecture-v78)
34
+ - [Data Privacy & Egress](#data-privacy-egress)
35
+ - [Use Cases](#use-cases)
36
+ - [What's New](#whats-new)
37
+ - [How Prism Compares](#how-prism-compares)
38
+ - [CLI Reference](#cli-reference)
39
+ - [Tool Reference](#tool-reference)
40
40
  - [Environment Variables](#environment-variables)
41
41
  - [Architecture](#architecture)
42
- - [Scientific Foundation](#-scientific-foundation)
43
- - [Milestones & Roadmap](#-milestones-roadmap)
44
- - [Troubleshooting FAQ](#-troubleshooting-faq)
42
+ - [Scientific Foundation](#scientific-foundation)
43
+ - [Milestones & Roadmap](#milestones-roadmap)
44
+ - [Troubleshooting FAQ](#troubleshooting-faq)
45
+
46
+ ---
47
+
48
+ ## 🔬 <a name="deep-research-intelligence"></a>v11.0 Deep Research Intelligence (Auto-Scholar)
49
+
50
+ Prism v11.0 transforms your AI agent from a "Coder" into a "Clinical Scientist." It features a **Tavily-Enhanced Multi-Provider Discovery Pipeline** that grounds Gemini 2.5 Flash's thinking in real-world empirical data.
51
+
52
+ ### 🥊 The Global Benchmarks: Prism v11 vs. Standard RAG
53
+
54
+ | Feature | **Standard AI Memory (Mem0/Zep)** | **Prism v11.0 (Elite Architecture)** |
55
+ | :--- | :--- | :--- |
56
+ | **Search Complexity** | $O(N)$ or $O(\log N)$ (Scales with data) | **$O(1)$ Zero-Search (Constant time via HRR)** |
57
+ | **Discovery Logic** | General Web Search (Snippets) | **Parallel Academic Discovery (PubMed, ERIC, S2)** |
58
+ | **Reasoning Model** | Flat List (Simple Similarity) | **ACT-R Spreading Activation (Causal Graph)** |
59
+ | **Privacy Mode** | Cloud-First (SaaS) | **Local-First (HIPAA-Hardened / Air-Gapped)** |
60
+ | **Intelligence Floor** | Generic GPT-4 Advice | **Data-Driven Clinical Evidence (62% CI Warnings)** |
61
+
62
+ ### 🔍 Supported Discovery Engines & Databases
63
+
64
+ 1. **Tavily AI** (Elite): Primary discovery engine for AI-native deep crawling and PDF/Abstract extraction.
65
+ 2. **PubMed (NCBI)** (Clinical): The world's largest biomedical database for clinical citations.
66
+ 3. **ERIC (Education Research)** (Behavioral): The definitive database for ABA and pediatric interventions.
67
+ 4. **Semantic Scholar** (Academic): AI-powered research tool providing "TLDR" summaries of 200M+ papers.
68
+ 5. **DuckDuckGo Lite** (Fallback): Privacy-focused web discovery for general context.
69
+
70
+ ---
71
+
72
+ ### 🏥 Flagship Implementation: [Synalux](https://synalux.ai)
73
+ **Synalux** is a high-compliance, local-first Practice Management System for ABA and Pediatrics. It is the flagship implementation of the Prism v11.0 engine, utilizing **Zero-Search Retrieval** and **Parallel Academic Discovery** to provide clinicians with real-time, evidence-based reasoning.
74
+
75
+ ---
76
+
77
+ <details>
78
+ <summary><strong>See Live Samples (Simplified Terms)</strong></summary>
79
+
80
+ #### Topic: Helping a child with tactile focus
81
+ * **Without Deep Research**: "I recommend using sensory toys and maintaining a calm environment to help the child focus during tasks."
82
+ * **With Deep Research (v11.0)**: "Recent clinical studies indicate that high-frequency sensory input can actually *decrease* focus in 40% of pediatric cases. I recommend a low-frequency, high-pressure 'weighted' approach which showed a 3.5x improvement in sustained attention during clinical trials."
83
+
84
+ #### Topic: Behavior extinction vs. reinforcement
85
+ * **Without Deep Research**: "Extinction is a common way to stop a behavior. You should also reinforce good behaviors at the same time."
86
+ * **With Deep Research (v11.0)**: "Research shows that using extinction alone leads to an 'extinction burst' (a temporary spike in the bad behavior) in 62% of cases. However, combining it with an alternative reinforcement strategy (DRA) reduces this risk to under 20%."
87
+
88
+ </details>
45
89
 
46
90
  ---
47
91
 
@@ -55,15 +99,15 @@ Every time you start a new conversation with an AI coding assistant, it starts f
55
99
 
56
100
  Prism has three pillars:
57
101
 
58
- 1. **🧠 Cognitive Memory** — Memories are ranked like a human brain: recently and frequently accessed context surfaces first, while stale context fades naturally via ACT-R activation decay. Raw experience consolidates into semantic principles through Hebbian learning. The result is retrieval quality that no flat vector search can match. *(See [Cognitive Architecture](#-cognitive-architecture-v78) and [Scientific Foundation](#-scientific-foundation).)*
102
+ 1. **🧠 Cognitive Memory ($O(1)$ Zero-Search)** — Prism uses **Holographic Reduced Representations (HRR)** to eliminate "searching" entirely. Memories are unbound mathematically from a superposition vector in constant time ($O(1)$), regardless of library size. Re-ranking is powered by the **ACT-R** model, mimicking biological recency and frequency.
59
103
 
60
- 2. **🔗 Multi-Hop Reasoning** — When your agent searches for "Error X", Prism doesn't just find logs mentioning "Error X". Spreading activation traverses the causal graph and brings back "Workaround Y", which is connected to "Architecture Decision Z" a literal train of thought. *(See [Cognitive Architecture](#-cognitive-architecture-v78).)*
104
+ 2. **🔗 Multi-Hop Causal Reasoning** — Prism doesn't just find "similar" things. Spreading activation traverses the causal graph and brings back context connected to your current problem through logical "trains of thought."
61
105
 
62
- 3. **🏭 Autonomous Execution (Dark Factory)** — When you're ready, Prism can run coding tasks end-to-end with a fail-closed pipeline where an adversarial evaluator catches bugs the generator missed — before you ever see the PR. *(See [Dark Factory](#-dark-factory-adversarial-autonomous-pipelines).)*
106
+ 3. **🏭 Autonomous Execution (Dark Factory)** — When you're ready, Prism can run coding tasks end-to-end with a fail-closed pipeline where an adversarial evaluator catches bugs the generator missed — before you ever see the PR. *(See [Dark Factory](#dark-factory-adversarial-autonomous-pipelines).)*
63
107
 
64
108
  ---
65
109
 
66
- ## 🚀 Quick Start
110
+ ## <a name="quick-start"></a>🚀 Quick Start
67
111
 
68
112
  ### Prerequisites
69
113
 
@@ -138,7 +182,7 @@ Then open `http://localhost:3001` instead.
138
182
 
139
183
  ---
140
184
 
141
- ## The Magic Moment
185
+ ## <a name="the-magic-moment"></a>✨ The Magic Moment
142
186
 
143
187
  > **Session 1** (Monday evening):
144
188
  > ```
@@ -159,7 +203,7 @@ Then open `http://localhost:3001` instead.
159
203
 
160
204
  ---
161
205
 
162
- ## 📖 Setup Guides
206
+ ## <a name="setup-guides"></a>📖 Setup Guides
163
207
 
164
208
  <details>
165
209
  <summary><strong>Claude Desktop</strong></summary>
@@ -438,11 +482,11 @@ Prism can be deployed natively to cloud platforms like [Render](https://render.c
438
482
  > ```
439
483
  > At the start of every conversation, call session_load_context with project "my-project" before doing any work.
440
484
  > ```
441
- > Claude Code users can use the `.clauderules` auto-load hook shown in the [Setup Guides](#-setup-guides). Prism also has a **server-side fallback** (v5.2.1+) that auto-pushes context after 10 seconds if no load is detected.
485
+ > Claude Code users can use the `.clauderules` auto-load hook shown in the [Setup Guides](#setup-guides). Prism also has a **server-side fallback** (v5.2.1+) that auto-pushes context after 10 seconds if no load is detected.
442
486
 
443
487
  ---
444
488
 
445
- ## 📥 Universal Import: Bring Your History
489
+ ## <a name="universal-import-bring-your-history"></a>📥 Universal Import: Bring Your History
446
490
 
447
491
  Switching to Prism? Don't leave months of AI session history behind. Prism can **ingest historical sessions from Claude Code, Gemini, and OpenAI** and give your Mind Palace an instant head start — no manual re-entry required.
448
492
 
@@ -475,7 +519,7 @@ npx -y prism-mcp-server universal-import --format gemini --path ./gemini_history
475
519
 
476
520
  ---
477
521
 
478
- ## What Makes Prism Different
522
+ ## <a name="what-makes-prism-different"></a>✨ What Makes Prism Different
479
523
 
480
524
 
481
525
  ### 🧠 Your Agent Learns From Mistakes
@@ -629,7 +673,7 @@ Vector math measures *semantic similarity*, not *sentiment*. If an agent searche
629
673
 
630
674
  ---
631
675
 
632
- ## 🧠 Cognitive Architecture (v7.8)
676
+ ## <a name="cognitive-architecture-v78"></a>🧠 Cognitive Architecture (v7.8)
633
677
 
634
678
  > *Prism v7.8 is our biggest leap forward yet. We have moved beyond flat vector search and implemented a true Cognitive Architecture inspired by human brain mechanics. With the new ACT-R Spreading Activation Engine, Episodic-to-Semantic memory consolidation, and Uncertainty-Aware Rejection Gates, Prism doesn't just store logs anymore — it forms principles, follows causal trains of thought, and possesses the self-awareness to know when it lacks information.*
635
679
 
@@ -694,7 +738,7 @@ Standard RAG (Retrieval-Augmented Generation) is now a commodity. Everyone has v
694
738
 
695
739
  ---
696
740
 
697
- ## 🔒 Data Privacy & Egress
741
+ ## <a name="data-privacy-egress"></a>🔒 Data Privacy & Egress
698
742
 
699
743
  **Where is my data stored?**
700
744
 
@@ -725,7 +769,7 @@ Prism will recreate the directory with empty databases on next startup.
725
769
 
726
770
  ---
727
771
 
728
- ## 🎯 Use Cases
772
+ ## <a name="use-cases"></a>🎯 Use Cases
729
773
 
730
774
  - **Long-running feature work** — Save state at end of day, restore full context next morning. No re-explaining.
731
775
  - **Multi-agent collaboration** — Dev, QA, and PM agents share real-time context without stepping on each other's memory.
@@ -859,37 +903,26 @@ The Generator strips the `console.log`, resubmits, and the next `EVALUATE` retur
859
903
 
860
904
  ---
861
905
 
862
- ## 🆕 What's New
863
-
864
- > **Current release: v9.12.0Memory Security Hardening (Stored Prompt Injection Prevention)**
865
-
866
- - 🔒 **v9.12.0 — Memory Security Hardening:** Prevents **stored prompt injection** the AI equivalent of stored XSS. New `sanitizeMemoryInput()` strips 8 categories of dangerous XML tags (`<system>`, `<instruction>`, `<prism_memory>`, etc.) from all text fields on every save. Context output now wrapped in `<prism_memory context="historical">` boundary tags across all 3 output paths (MCP tool, prompt, resource) so LLMs treat loaded memory as data, not instructions. Boundary tag spoofing blocked. 30 new security tests covering real-world attack scenarios (cross-session poisoning, Hivemind multi-agent hijacking). 311 total tests, 0 regressions. → [Changelog](CHANGELOG.md#9120---2026-04-15--memory-security-hardening-stored-prompt-injection-prevention)
867
- - 🧠 **v9.5.0 — Adversarial Behavioral Hardening:** Intent Classification Engine with 84 tests, 24 forbidden openers, XML Anti-Tag system, `<user_input>` isolation, IF/ELSE conflict resolution. 282 total tests.
868
- - 🧠 **v9.4.7ABA Precision Protocol:** Foundational behavioral engine injected into every `session_load_context` output. 5 rules: (1) Observable measurable goals with IOA≥80%, (2) Precise step-by-step execution with stop-fix-verify, (3) No reinforcement of wrong patterns, (4) Help first before redirecting, (5) Fix bugs without asking permission. Consolidates 4 previous skills (`fix-without-asking`, `command_verification`, `critical_resolution_memory`, removed contradictory `ask-first`) into 1 unified protocol. 83-test behavioral verification suite with edge cases. Split-brain false-warning fix. → [Changelog](CHANGELOG.md#947---2026-04-15--aba-precision-protocol-foundational-behavioral-engine)
869
- - 🕵️ **v9.4.6Stealth Browser Automation:** New `browse.py` HIPAA-hardened CLI for local Playwright-based browser automation with 6-layer anti-detection (playwright-stealth v2.0.3, deep JS fingerprint evasion, behavioral mimicry, Chromium anti-automation flags, network header fixing, persistent profiles). **100% pass rate on bot.sannysoft.com** (50+ tests). Features: FileVault enforcement, `chmod 600` audit log, PHI sanitization, ephemeral `/tmp` screenshots (APFS CoW workaround), UA↔WebGL consistency validation, 10-min REPL idle timeout, structured JSON output, Google Docs keyboard automation (`gdoc-read`/`gdoc-type`/`gdoc-find`). → [Changelog](CHANGELOG.md#946---2026-04-14--stealth-browser-automation-tool-browsepy)
870
- - 🔒 **v9.4.5Command Injection Fix & Dep Reduction:** `isOrphanProcess()` in `lifecycle.ts` interpolated a file-sourced PID into `execSync`. Fixed with `execFileSync` (no shell). Removed 2 unused runtime deps (25 → 23). Closes [#53](https://github.com/dcostenco/prism-mcp/issues/53).
871
- - 🔧 **v9.4.3ESM Bundling Fix:** Bundled dist had inlined OpenTelemetry CJS `require("async_hooks")` into ESM chunks, causing `Dynamic require of "async_hooks" is not supported` at runtime. Rebuilt with `tsc`. Affects CLI, session save/load, and MCP server startup.
872
- - 🔒 **v9.4.2Shell Injection Fix:** Deep code review found shell injection in `getGitDrift()` — `oldSha` was interpolated into `execSync` template string. Fixed with SHA format validation + `execFileSync` (no shell). Defense-in-depth.
873
- - 🔒 **v9.4.1Security Hardening & Bidirectional Sync:** Two-pass adversarial audit found 18 vulnerabilities (4C/5H/9M) 17 fixed. Critical: fail-closed rate limiter, path traversal guards, error sanitization. High: plan name alignment (revenue fix), CORS allowlist, settings injection prevention. New: bidirectional `prism sync push` CLI command pushes local SQLite Supabase, JWT enrichment eliminates N+1 DB queries, concurrency counter guaranteed via `try/finally`, 10MB request body limits.
874
- - 🎯 **v9.3.0 — TurboQuant ResidualNorm Tiebreaker:** Configurable ranking optimization for Tier-2 search. When compressed cosine scores are within ε of each other, prefers the candidate with lower `residualNorm` (more trustworthy compressed representation). `PRISM_TURBOQUANT_TIEBREAKER_EPSILON=0.005` gives +2pp R@1, +1pp R@5. Empirically validated at N=5K with A/B test. 1066 tests, 0 regressions. Inspired by [@m13v's suggestion](https://github.com/xiaowu0162/LongMemEval/issues/31).
875
- - 🔒 **v9.2.7 — Security Hardening:** Typed `PrototypePollutionError` class (replaces generic `Error` in `sanitizeForMerge()` — enables catch-site discrimination and forensic logging with `offendingKey`), explicit null-byte path injection guard in `SafetyController.validateActionsInScope()` (C-string truncation attack vector), and corrected CRDT merge semantics documentation (Remove-Wins-from-Either, not Add-Wins). 1055 tests, 0 regressions.
876
- - 🪟 **v9.2.6 — Windows CI Timeout Fix:** CLI integration tests timed out on Windows + Node 22.x GitHub Actions runners. Added `{ timeout: 30_000 }` to the describe block. 6 new residual distribution tests validating TurboQuant's QJL correction stability (zero R@5 delta between P50 and P95 residual vectors at d=128, 2K corpus).
877
- - 🔧 **v9.2.5 — Reconciliation Credential Probe Fix:** `supabaseReady` guard only resolved credentials when `requestedBackend === "supabase"`, causing reconciliation to silently skip. Added second credential probe for local + reconciliation path. Fixed Supabase schema mismatch on `key_context` column.
878
- - 🔄 **v9.2.4 — Cross-Backend Reconciliation:** Automatic two-layer sync from Supabase → SQLite on startup. When Claude Desktop writes handoffs and ledger entries to Supabase, Antigravity (local SQLite) now automatically detects stale data and pulls newer handoffs + the 20 most recent ledger entries. 5-second timeout prevents startup freeze. Targeted ID lookups (not full table scans) keep it safe for large databases. 13 tests including malformed JSON resilience, multi-role dedup, and timeout handling.
879
- - 🔧 **v9.2.3 — Code Review Hardening:** 10x faster split-brain detection (lightweight direct queries replace full `StorageBackend` construction), variable shadowing fix in CLI, resource leak fix in SQLite alternate client.
880
- - 🚨 **v9.2.2 — Critical: Split-Brain Detection & Prevention:** When multiple MCP clients use different storage backends (e.g., Claude Desktop → Supabase, Antigravity → SQLite), session state could silently diverge, causing agents to act on stale TODOs and outdated context. **New: `--storage` flag** on `prism load` CLI lets callers explicitly select which backend to read from. **New: Split-Brain Drift Detection** in `session_load_context` — compares active and alternate backend versions at load time and warns prominently when they diverge. Session loader script updated to respect `PRISM_STORAGE` environment variable.
881
- - 💻 **v9.2.1 — CLI Full Feature Parity:** `prism load` text mode now delegates to the real `session_load_context` handler, giving CLI-only users the same enriched output as MCP clients: morning briefings, reality drift detection, SDM intuitive recall, visual memory index, role-scoped skill injection, behavioral warnings, importance scores, and agent identity. JSON mode now includes `agent_name` from dashboard settings. Session loader script PATH fix for Homebrew/nvm/volta environments.
882
- - 🚦 **v9.1.0 — Task Router v2:** File-type complexity signal for intelligent code-vs-config routing, 6-signal weighted heuristic engine, multi-step false-positive fix, expanded file extension classification. Local agent hardened with buffered streaming, system prompts, memory trimming, and stateful `/api/chat` API.
883
- - 🔒 **v9.0.5 — JWKS Auth Security Hardening:** JWT audience/issuer claim validation (`PRISM_JWT_AUDIENCE`, `PRISM_JWT_ISSUER`), structured error logging for JWT failures, typed `PrismAuthenticatedRequest` interface, 11 new JWKS unit tests, Smithery server card fix. Vendor-neutral — tested with Auth0, AgentLair ([llms.txt](https://agentlair.com/llms.txt)), Keycloak, and custom JWKS endpoints.
884
- - 🧠 **v9.0.0 — Autonomous Cognitive OS:** Token-Economic Reinforcement Learning (Surprisal Gate + Cognitive Budget), Affect-Tagged Memory (valence-scored retrieval), and Episodic→Semantic Consolidation. Your agents learn compression and develop intuition. → [Cognitive OS](#-autonomous-cognitive-os-v90)
885
- - 🧠 **v7.8.0 — Cognitive Architecture:** Episodic-to-Semantic memory consolidation (Hebbian learning), ACT-R Spreading Activation with multi-hop causal reasoning, Uncertainty-Aware Rejection Gate, and Dynamic Fast Weight Decay. → [Cognitive Architecture](#-cognitive-architecture-v78)
906
+ ## <a name="whats-new"></a>🆕 What's New
907
+
908
+ > **Current release: v10.0.1HIPAA-Hardened Local LLM Engine**
909
+
910
+ - 🛡️ **v10.0.0 — HIPAA-Hardened Local LLM:** Your agent's memory now runs entirely on-device. Introducing `prism-coder:7b` for local compaction, task routing, and semantic search. Includes `PRISM_STRICT_LOCAL_MODE` to block cloud fallbacks, SSRF protection, URL credential redaction, and full XML escaping to prevent prompt injection. 22-finding adversarial audit completed. → [Changelog](CHANGELOG.md#1000)
911
+ - 🧬 **v9.14.0 — Dynamic Hardware Routing:** Platform-aware memory detection auto-selects optimal models (32b for ≥32GB RAM, 14b/7b for lighter hardware). Includes **Nomic Semantic Tool Pruning (RAG)** which embeds all 17 MCP tools into offline vectors, injecting only the Top-3 relevant schemas into context to maximize inference speed.
912
+ - 🔬 **v9.13.0Local Embeddings & Zero-API-Key Setup:** `LocalEmbeddingAdapter` using `nomic-embed-text-v1.5` generates 768-dim embeddings entirely on-device. Full semantic search and session memory now work with **zero cloud API keys**. → [Changelog](CHANGELOG.md#9130)
913
+ - 🔒 **v9.12.0Memory Security Hardening:** Prevents **stored prompt injection** the AI equivalent of stored XSS. New `sanitizeMemoryInput()` strips 8 categories of dangerous XML tags from all text fields. Context output wrapped in `<prism_memory context="historical">` boundary tags. → [Changelog](CHANGELOG.md#9120)
914
+ - 🧠 **v9.4.7ABA Precision Protocol:** Foundational behavioral engine with 5 core rules (Observable goals, Stop-fix-verify, No reinforcement of wrong patterns, Help first, Fix bugs without asking). 83-test behavioral verification suite.
915
+ - 🕵️ **v9.4.6Stealth Browser Automation:** `browse.py` HIPAA-hardened CLI for local Playwright-based browser automation with 6-layer anti-detection. **100% pass rate on bot.sannysoft.com**.
916
+ - 🔄 **v9.2.4 — Cross-Backend Reconciliation:** Automatic sync from Supabase SQLite on startup. Reality drift detection warns when backend versions diverge.
917
+ - 🧠 **v9.0.0Autonomous Cognitive OS:** Token-Economic Reinforcement Learning (Surprisal Gate + Cognitive Budget), Affect-Tagged Memory, and EpisodicSemantic Consolidation.
918
+ - 🧠 **v7.8.0 — Cognitive Architecture:** Episodic-to-Semantic memory consolidation (Hebbian learning), ACT-R Spreading Activation with multi-hop causal reasoning, Uncertainty-Aware Rejection Gate, and Dynamic Fast Weight Decay. [Cognitive Architecture](#cognitive-architecture-v78)
886
919
  - 🌐 **v7.7.0 — Cloud-Native SSE Transport:** Full Server-Sent Events MCP support for seamless network deployments.
887
920
 
888
921
  👉 **[Full release history → CHANGELOG.md](CHANGELOG.md)** · **[ROADMAP →](ROADMAP.md)**
889
922
 
890
923
  ---
891
924
 
892
- ## ⚔️ How Prism Compares
925
+ ## <a name="how-prism-compares"></a>⚔️ How Prism Compares
893
926
 
894
927
  Standard memory servers (like Mem0, Zep, or the baseline Anthropic MCP) act as passive filing cabinets — they wait for the LLM to search them. **Prism is an active cognitive architecture.** Designed specifically for the **Model Context Protocol (MCP)**, Prism doesn't just store vectors — it consolidates experience into principles, traverses causal graphs for multi-hop reasoning, and rejects queries it can't confidently answer.
895
928
 
@@ -897,6 +930,8 @@ Standard memory servers (like Mem0, Zep, or the baseline Anthropic MCP) act as p
897
930
 
898
931
  | Feature / Architecture | 🧠 Prism MCP | 🐘 Mem0 | ⚡ Zep | 🧪 Anthropic Base MCP |
899
932
  | :--- | :--- | :--- | :--- | :--- |
933
+ | **Privacy & HIPAA** | **✅ 100% Local / Air-gapped / Redacted** | ❌ Cloud-dependent | ❌ Cloud-dependent | ✅ Local-only |
934
+ | **Local LLM Logic** | **✅ `prism-coder:7b` (Compaction, Routing)** | ❌ Cloud only | ❌ Cloud only | ❌ None |
900
935
  | **Primary Interface** | **Native MCP** (Tools, Prompts, Resources) | REST API & Python/TS SDKs | REST API & Python/TS SDKs | Native MCP (Tools only) |
901
936
  | **Storage Engine** | **BYO SQLite or Supabase** | Managed Cloud / VectorDBs | Managed Cloud / Postgres | Local SQLite only |
902
937
  | **Context Assembly** | **Progressive (Quick/Std/Deep)** | Top-K Semantic Search | Top-K + Temporal Summaries | Basic Entity Search |
@@ -911,22 +946,25 @@ Standard memory servers (like Mem0, Zep, or the baseline Anthropic MCP) act as p
911
946
 
912
947
  ### 🏆 Where Prism Crushes the Giants
913
948
 
914
- #### 1. MCP-Native, Not an Adapted API
949
+ #### 1. Local-First & HIPAA-Hardened
950
+ While other memory systems force you to send every chat log to their cloud for "compaction" or "embedding," Prism v10 is **100% air-gapped**. With the `prism-coder:7b` local LLM and `nomic-embed` local adapter, your agent's memory pipeline runs entirely on your machine. Prism includes built-in SSRF protection, URL credential redaction, and XML sanitization to prevent stored prompt injection — meeting HIPAA Security Rule standards for on-device processing.
951
+
952
+ #### 2. MCP-Native, Not an Adapted API
915
953
  Mem0 and Zep are APIs that *can* be wrapped into an MCP server. Prism was built *for* MCP from day one. Instead of wasting tokens on "search" tool calls, Prism uses **MCP Prompts** (`/resume_session`) to inject context *before* the LLM thinks, and **MCP Resources** (`memory://project/handoff`) to attach live, subscribing context.
916
954
 
917
- #### 2. Academic-Grade Cognitive Computer Science
955
+ #### 3. Academic-Grade Cognitive Computer Science
918
956
  The giants use standard RAG (Retrieval-Augmented Generation). Prism uses biological and academic models of memory: **ACT-R base-level activation** (`B_i = ln(Σ t_j^(-d))`) for recency–frequency re-ranking, **TurboQuant** for extreme vector compression, **Ebbinghaus curves** for importance decay, and **Sparse Distributed Memory (SDM)**. The result is retrieval quality that follows how human memory actually works — not just nearest-neighbor cosine distance. And all of it runs on a laptop without a Postgres/pgvector instance.
919
957
 
920
- #### 3. True Multi-Agent Coordination (CRDTs)
958
+ #### 4. True Multi-Agent Coordination (CRDTs)
921
959
  If Cursor (Agent A) and Claude Desktop (Agent B) try to update a Mem0 or standard SQLite database at the exact same time, you get a race condition and data loss. Prism uses **Optimistic Concurrency Control (OCC) with CRDT OR-Maps** — mathematically guaranteeing that simultaneous agent edits merge safely. Enterprise-grade distributed systems on a local machine.
922
960
 
923
- #### 4. The PKM "Prism-Port" Export
961
+ #### 5. The PKM "Prism-Port" Export
924
962
  AI memory is a black box. Developers hate black boxes. Prism exports memory directly into an **Obsidian/Logseq-compatible Markdown Vault** with YAML frontmatter and `[[Wikilinks]]`. Neither Mem0 nor Zep do this.
925
963
 
926
- #### 5. Self-Cleaning & Self-Optimizing
964
+ #### 6. Self-Cleaning & Self-Optimizing
927
965
  If you use a standard memory tool long enough, it clogs the LLM's context window with thousands of obsolete tokens. Prism runs an autonomous [Background Scheduler](src/backgroundScheduler.ts) that Ebbinghaus-decays older memories, auto-compacts session histories into dense summaries, and deep-purges high-precision vectors — saving ~90% of disk space automatically.
928
966
 
929
- #### 6. Anti-Sycophancy — The AI That Grades Its Own Homework (v7.4)
967
+ #### 7. Anti-Sycophancy — The AI That Grades Its Own Homework (v7.4)
930
968
  Every other AI coding pipeline has a fatal flaw: it asks the same model that wrote the code whether the code is correct. **Of course it says yes.** Prism's Dark Factory solves this with a walled-off Adversarial Evaluator that is explicitly prompted to be hostile and strict. It operates on a pre-committed rubric and cannot fail the Generator without providing exact file/line receipts. Failed evaluations feed the critique back into the Generator's retry prompt — eliminating blind retries. No other memory or pipeline tool does this.
931
969
 
932
970
  ### 🤝 Where the Giants Currently Win (Honest Trade-offs)
@@ -941,7 +979,7 @@ Every other AI coding pipeline has a fatal flaw: it asks the same model that wro
941
979
 
942
980
  ---
943
981
 
944
- ## 💻 CLI Reference
982
+ ## <a name="cli-reference"></a>💻 CLI Reference
945
983
 
946
984
  Prism includes a CLI for environments where MCP tools aren't available (CI/CD pipelines, Bash scripts, non-MCP IDEs like Antigravity).
947
985
 
@@ -972,7 +1010,7 @@ prism verify generate # Bless current rubric as canonic
972
1010
 
973
1011
  ---
974
1012
 
975
- ## 🔧 Tool Reference
1013
+ ## <a name="tool-reference"></a>🔧 Tool Reference
976
1014
 
977
1015
  Prism ships 30+ tools, but **90% of your workflow uses just three:**
978
1016
 
@@ -1235,7 +1273,7 @@ Prism is a **stdio-based MCP server** that manages persistent agent memory. Here
1235
1273
 
1236
1274
  ### Auto-Load Architecture
1237
1275
 
1238
- Each MCP client has its own mechanism for ensuring Prism context loads on session start. See the platform-specific [Setup Guides](#-setup-guides) above for detailed instructions:
1276
+ Each MCP client has its own mechanism for ensuring Prism context loads on session start. See the platform-specific [Setup Guides](#setup-guides) above for detailed instructions:
1239
1277
 
1240
1278
  - **Claude Code** — Lifecycle hooks (`SessionStart` / `Stop`)
1241
1279
  - **Gemini / Antigravity** — Three-layer architecture (User Rules + AGENTS.md + Startup Skill)
@@ -1246,7 +1284,7 @@ All platforms benefit from the **server-side fallback** (v5.2.1): if `session_lo
1246
1284
 
1247
1285
  ---
1248
1286
 
1249
- ## 🧬 Scientific Foundation
1287
+ ## <a name="scientific-foundation"></a>🧬 Scientific Foundation
1250
1288
 
1251
1289
  Prism has evolved from smart session logging into a **cognitive memory architecture** — grounded in real research, not marketing. Every retrieval decision is backed by peer-reviewed models from cognitive psychology, neuroscience, and distributed computing.
1252
1290
 
@@ -1291,7 +1329,16 @@ Prism has evolved from smart session logging into a **cognitive memory architect
1291
1329
  | **v9.2** | TurboQuant QJL Validation — zero R@5 delta between P50 and P95 residual vectors (d=128, N=2K); CV=0.038 at d=768 proves no long tail | QJL estimator (ICLR 2026), Householder orthogonal rotation | ✅ Shipped |
1292
1330
  | **v9.2** | Typed Security Errors — `PrototypePollutionError` with `offendingKey` for forensic logging; null-byte path injection guard in SafetyController | Defense-in-depth (NIST), C-string truncation attack mitigation | ✅ Shipped |
1293
1331
  | **v9.3** | ResidualNorm Tiebreaker — within-ε candidates ranked by compression fidelity (`PRISM_TURBOQUANT_TIEBREAKER_EPSILON`); +2pp R@1, +1pp R@5 at ε=0.005 | Quantization confidence scoring, compression-aware retrieval | ✅ Shipped |
1294
- | **v10+** | Zero-Search Retrievalno index, no ANN, just ask the vector | Holographic Reduced Representations | 🔭 Horizon |
1332
+ | **v10.0** | HIPAA-Hardened Local LLM `prism-coder:7b` manages ledger compaction, task routing, and semantic search 100% on-device | Air-gapped cognitive pipelines, secure PHI redaction | Shipped |
1333
+ | **v11.0** | Zero-Search Retrieval — no index, no ANN, just ask the vector | Holographic Reduced Representations (HRR) | 🧪 [Field Testing (Synalux)](https://github.com/dcostenco/synalux-private#%F0%9F\u009A\u0080-zero-search-retrieval-hrr-architecture) |
1334
+
1335
+ ---
1336
+
1337
+ ### 🧪 Verified Zero-Search Implementation
1338
+ The core unbinding engine is verified via Synalux's cognitive testing suite:
1339
+ - **Core Math**: [Holographic Reduced Representations (HRR.ts)](https://github.com/dcostenco/synalux-private/blob/main/portal/src/lib/cognitive/hrr.ts)
1340
+ - **Unit Tests**: [HRR Performance & Capacity Tests](https://github.com/dcostenco/synalux-private/blob/main/portal/src/lib/cognitive/__tests__/hrr.test.ts)
1341
+ - **Benchmarks**: [O(1) Retrieval Comparison Script](https://github.com/dcostenco/synalux-private/blob/main/portal/scripts/retrieval-comparison.ts)
1295
1342
 
1296
1343
  > Informed by Anderson's ACT-R (Adaptive Control of Thought—Rational), Collins & Loftus spreading activation networks (1975), Kanerva's SDM (1988), Hebb's learning rule, and LeCun's "Why AI Systems Don't Learn" (Dupoux, LeCun, Malik).
1297
1344
 
@@ -1321,32 +1368,32 @@ Prism MCP is open-source and free for individual developers. For teams and enter
1321
1368
 
1322
1369
  ---
1323
1370
 
1324
- ## 📦 Milestones & Roadmap
1371
+ ## <a name="milestones-roadmap"></a>📦 Milestones & Roadmap
1325
1372
 
1326
- > **Current: v10.0.0** — HIPAA-Hardened Local LLM Engine + 3-Round Adversarial Security Audit ([CHANGELOG](CHANGELOG.md))
1373
+ > **Current: v10.0.1** — HIPAA-Hardened Local LLM Engine + 3-Round Adversarial Security Audit ([CHANGELOG](CHANGELOG.md))
1327
1374
 
1328
1375
  | Release | Headline |
1329
1376
  |---------|----------|
1330
- | **v10.0** | 🛡️ **HIPAA-Hardened Local LLM** — `prism-coder:7b` powers compaction + task routing 100% on-device; 22-finding adversarial audit, `PRISM_STRICT_LOCAL_MODE`, SSRF/injection/exfiltration hardening. Zero API keys required. |
1377
+ | **v11.0** | 🧠 **Deep Research Intelligence** — Multi-provider discovery (Tavily/PubMed/DDG) with Gemini 2.5 Flash synthesis. |
1378
+ | **v10.0** | 🛡️ **HIPAA-Hardened Local LLM** — `prism-coder:7b` powers compaction + task routing 100% on-device; 22-finding adversarial audit. Zero API keys required. |
1331
1379
  | **v9.14** | 🧬 Dynamic Hardware Routing & Semantic Tool RAG — MLX SFT pipeline, Nomic pruning, GRPO alignment |
1332
1380
  | **v9.13** | 🔬 Local Embeddings & Zero-API-Key Semantic Search — `nomic-embed-text-v1.5` on-device |
1333
1381
  | **v9.5** | 🛡️ Adversarial Behavioral Hardening — 24 forbidden openers, XML anti-tag system, sycophancy defense |
1334
1382
  | **v9.4** | 🔒 Security Sweep — command injection, path traversal, CORS, fail-closed rate limiter, bidirectional sync |
1335
1383
  | **v9.0** | 🧠 Autonomous Cognitive OS — Surprisal Gate, Cognitive Budget, Affect-Tagged Memory |
1336
1384
  | **v7.8** | 🧠 Cognitive Architecture — Hebbian consolidation, multi-hop reasoning, rejection gate |
1337
- | **v7.4** | ⚔️ Adversarial Evaluation (anti-sycophancy) |
1338
1385
  | **v7.0** | 🧬 ACT-R Activation Memory |
1339
1386
 
1340
1387
  ### Future Tracks
1341
- - **v10.1: Semantic Routing** — Replace regex-based task classification with lightweight local embedding model (`all-MiniLM-L6-v2`) for intent-based routing.
1342
- - **v10.2: Background Task Mutex** — Pause background compaction during active user chat streams to prevent resource contention.
1343
- - **v10.3: Agent Self-Evaluation** — Local LLM scores its own compaction quality and requests re-compaction when output confidence is low.
1344
- - **v11+: Zero-Search Retrieval** — Direct vector-addressed recall eliminates retrieval indirection entirely.
1388
+ - **v10.1: Multi-Graph Causal Layer** — Intent-aware retrieval routing traversing an LLM-inferred causal `because` edge-type layer for deep reasoning.
1389
+ - **v10.2: Federated Memory Mesh** — Hierarchical memory namespaces with role-based access control for enterprise agent teams.
1390
+ - **v10.3: Predictive Prefetch** — ACT-R based predictive models prefetch likely-needed memories before the agent asks.
1391
+ - **v11+: Zero-Search Retrieval** — Holographic Reduced Representations (HRR) eliminate retrieval indirection entirely.
1345
1392
 
1346
1393
  👉 **[Full ROADMAP.md →](ROADMAP.md)**
1347
1394
 
1348
1395
 
1349
- ## Troubleshooting FAQ
1396
+ ## <a name="troubleshooting-faq"></a>❓ Troubleshooting FAQ
1350
1397
 
1351
1398
  **Q: Why is the dashboard project selector stuck on "Loading projects..."?**
1352
1399
  A: Fixed in v7.3.3. The root cause was a multi-layer quote-escaping trap in the `abortPipeline` onclick handler that generated a `SyntaxError` in the browser, silently killing the entire dashboard IIFE. Update to v7.3.3+ (`npx -y prism-mcp-server`). If still stuck, check that Supabase env values are properly set (unresolved placeholders like `${SUPABASE_URL}` cause `/api/projects` to return empty). Prism auto-falls back to local SQLite when Supabase is misconfigured.
@@ -1365,8 +1412,8 @@ A: Run `npm run build && npm test`, then open the Mind Palace dashboard (`localh
1365
1412
 
1366
1413
  ### 💡 Known Limitations & Quirks
1367
1414
 
1368
- - **Text generation features require an API key.** Morning Briefings, auto-compaction, and VLM captioning need a cloud provider key (`GOOGLE_API_KEY`, `OPENAI_API_KEY`, or `ANTHROPIC_API_KEY`). Semantic search works offline with `embedding_provider=local` (no key needed). Without any embedding provider, Prism falls back to keyword-only search (FTS5).
1369
- - **Auto-load is model- and client-dependent.** Session auto-loading relies on both the LLM following system prompt instructions *and* the MCP client completing tool registration before the model's first turn. Prism provides platform-specific [Setup Guides](#-setup-guides) and a server-side fallback (v5.2.1) that auto-pushes context after 10 seconds.
1415
+ - **Some advanced text features may still benefit from a cloud API key.** While `prism-coder:7b` handles core compaction and routing, high-level features like Morning Briefings and complex VLM captioning are optimized for cloud providers (`GOOGLE_API_KEY`, `OPENAI_API_KEY`, or `ANTHROPIC_API_KEY`). Semantic search and basic compaction work 100% offline with `embedding_provider=local`.
1416
+ - **Auto-load is model- and client-dependent.** Session auto-loading relies on both the LLM following system prompt instructions *and* the MCP client completing tool registration before the model's first turn. Prism provides platform-specific [Setup Guides](#setup-guides) and a server-side fallback (v5.2.1) that auto-pushes context after 10 seconds.
1370
1417
  - **MCP client race conditions.** Some MCP clients may not finish tool enumeration before the model generates its first response, causing transient `unknown_tool` errors. This is a client-side timing issue — Prism's server completes the MCP handshake in ~60ms. Workaround: the server-side auto-push fallback and the startup skill's retry logic.
1371
1418
  - **No real-time sync without Supabase.** Local SQLite mode is single-machine only. Multi-device or team sync requires a Supabase backend.
1372
1419
  - **Embedding quality varies by provider.** Gemini `text-embedding-004` and OpenAI `text-embedding-3-small` produce high-quality 768-dim vectors. Prism passes `dimensions: 768` via the Matryoshka API for OpenAI models (native output is 1536-dim; this truncation is lossless and outperforms ada-002 at full 1536 dims). Local embeddings (`nomic-embed-text-v1.5` via `@huggingface/transformers`) provide good quality with zero API cost. Ollama embeddings are usable but may reduce retrieval accuracy.
package/dist/cli.js CHANGED
@@ -287,7 +287,7 @@ verifyCmd
287
287
  .option('--json', 'Emit machine-readable JSON output with stable keys')
288
288
  .action(async (options) => {
289
289
  const storage = new SqliteStorage();
290
- await storage.initialize('./prism-local.db');
290
+ await storage.initialize(true, './prism-local.db');
291
291
  // H4 fix: Ensure storage is closed on exit to flush WAL and prevent data loss
292
292
  try {
293
293
  await handleVerifyStatus(storage, options.project, !!options.force, options.user, !!options.json);
@@ -305,7 +305,7 @@ verifyCmd
305
305
  .option('--json', 'Emit machine-readable JSON output with stable keys')
306
306
  .action(async (options) => {
307
307
  const storage = new SqliteStorage();
308
- await storage.initialize('./prism-local.db');
308
+ await storage.initialize(true, './prism-local.db');
309
309
  // H4 fix: Ensure storage is closed on exit to flush WAL and prevent data loss
310
310
  try {
311
311
  await handleGenerateHarness(storage, options.project, !!options.force, options.user, !!options.json);
package/dist/config.js CHANGED
@@ -60,6 +60,7 @@ if (!GOOGLE_API_KEY && process.env.PRISM_DEBUG_LOGGING === "true") {
60
60
  // Used by the brave_answers tool for AI-grounded answers.
61
61
  // This is a separate API key from the main Brave Search key.
62
62
  export const BRAVE_ANSWERS_API_KEY = process.env.BRAVE_ANSWERS_API_KEY;
63
+ export const SEMANTIC_SCHOLAR_API_KEY = process.env.SEMANTIC_SCHOLAR_API_KEY;
63
64
  if (!BRAVE_ANSWERS_API_KEY && process.env.PRISM_DEBUG_LOGGING === "true") {
64
65
  console.error("Warning: BRAVE_ANSWERS_API_KEY environment variable is missing. Brave Answers tool will be unavailable.");
65
66
  }
@@ -71,6 +72,12 @@ if (!BRAVE_ANSWERS_API_KEY && process.env.PRISM_DEBUG_LOGGING === "true") {
71
72
  // Without this, VoyageAdapter construction will throw at server start if
72
73
  // embedding_provider=voyage is selected.
73
74
  export const VOYAGE_API_KEY = process.env.VOYAGE_API_KEY;
75
+ // ─── Optional: Google Search (Scholar Pipeline Fallback) ──────
76
+ // Used when Brave or Tavily keys are missing.
77
+ // Requires: Google Custom Search API Key + Search Engine ID (CX).
78
+ // Get yours at: https://developers.google.com/custom-search/v1/overview
79
+ export const GOOGLE_SEARCH_API_KEY = process.env.GOOGLE_SEARCH_API_KEY;
80
+ export const GOOGLE_SEARCH_CX = process.env.GOOGLE_SEARCH_CX;
74
81
  // ─── v2.0: Storage Backend Selection ─────────────────────────
75
82
  // REVIEWER NOTE: Step 1 of v2.0 introduces a storage abstraction.
76
83
  // Both "local" (SQLite) and "supabase" (PostgreSQL) are implemented.
@@ -282,3 +289,83 @@ const rawTiebreakerEpsilon = parseFloat(process.env.PRISM_TURBOQUANT_TIEBREAKER_
282
289
  export const PRISM_TURBOQUANT_TIEBREAKER_EPSILON = Number.isFinite(rawTiebreakerEpsilon) && rawTiebreakerEpsilon >= 0
283
290
  ? rawTiebreakerEpsilon
284
291
  : 0;
292
+ // ─── v9.x: Local LLM (prism-coder:7b) Integration ─────────────────────────
293
+ // Enables background tasks (compaction, task-router fallback, pipeline ops)
294
+ // to use a local Ollama model instead of the cloud LLM provider.
295
+ //
296
+ // Default model is prism-coder:7b — fine-tuned on Prism tool schemas.
297
+ // Disabled by default so existing deployments are unaffected.
298
+ //
299
+ // Set PRISM_LOCAL_LLM_ENABLED=true to activate.
300
+ // Set PRISM_LOCAL_LLM_MODEL to override the model tag.
301
+ // Set PRISM_LOCAL_LLM_URL to override the Ollama endpoint (default: localhost:11434).
302
+ // Set PRISM_LOCAL_LLM_TIMEOUT_MS to override per-call timeout (default: 60000, max: 300000).
303
+ // Set PRISM_STRICT_LOCAL_MODE=true to block cloud fallback when local LLM is enabled (HIPAA).
304
+ /** Master switch — enables the local prism-coder:7b LLM for background tasks. */
305
+ export const PRISM_LOCAL_LLM_ENABLED = process.env.PRISM_LOCAL_LLM_ENABLED === "true"; // Opt-in, default false
306
+ /** Ollama model tag to use for local LLM calls. */
307
+ export const PRISM_LOCAL_LLM_MODEL = (process.env.PRISM_LOCAL_LLM_MODEL || "prism-coder:7b").trim();
308
+ /** Ollama base URL. Override for remote Ollama instances. */
309
+ export const PRISM_LOCAL_LLM_URL = (process.env.PRISM_LOCAL_LLM_URL || "http://localhost:11434").trim();
310
+ /** Per-call timeout in ms. Prevents stalled background tasks. Capped at 300s. */
311
+ export const PRISM_LOCAL_LLM_TIMEOUT_MS = (() => {
312
+ const raw = parseInt(process.env.PRISM_LOCAL_LLM_TIMEOUT_MS || "60000", 10);
313
+ // FIX (integer overflow): values > 2^31-1 cause setTimeout to fire immediately,
314
+ // which silently aborts every local LLM call and forces cloud fallback.
315
+ // Cap at 300s (5 min) — no legitimate compaction call should take longer.
316
+ const MAX_TIMEOUT = 300_000;
317
+ return Number.isFinite(raw) && raw > 0 ? Math.min(raw, MAX_TIMEOUT) : 60_000;
318
+ })();
319
+ /**
320
+ * Strict local mode — blocks cloud LLM fallback when local LLM is enabled.
321
+ * Critical for HIPAA deployments where session data must never leave the device.
322
+ * When true: compaction throws instead of falling back to Gemini.
323
+ * When false (default): graceful cloud fallback on local LLM failure.
324
+ */
325
+ export const PRISM_STRICT_LOCAL_MODE = process.env.PRISM_STRICT_LOCAL_MODE === "true";
326
+ /** Redact credentials from a URL for safe logging (strips user:pass@). */
327
+ function redactUrl(rawUrl) {
328
+ try {
329
+ const parsed = new URL(rawUrl);
330
+ if (parsed.username || parsed.password) {
331
+ parsed.username = "***";
332
+ parsed.password = "***";
333
+ }
334
+ return parsed.toString().replace(/\/$/, "");
335
+ }
336
+ catch {
337
+ return "[invalid URL]";
338
+ }
339
+ }
340
+ if (PRISM_LOCAL_LLM_ENABLED) {
341
+ console.error(`[Prism] Local LLM enabled: model=${PRISM_LOCAL_LLM_MODEL}, ` +
342
+ `url=${redactUrl(PRISM_LOCAL_LLM_URL)}, timeout=${PRISM_LOCAL_LLM_TIMEOUT_MS}ms` +
343
+ (PRISM_STRICT_LOCAL_MODE ? ", STRICT LOCAL MODE (no cloud fallback)" : ""));
344
+ }
345
+ // ─── v11.0: Zero-Search Retrieval (HRR) ───────────────────────
346
+ // Dynamic dimension selection based on available system memory.
347
+ // Higher dimensions = higher fact capacity but slower unbinding.
348
+ import { totalmem } from "node:os";
349
+ export const PRISM_HRR_DIMENSION = (() => {
350
+ // 1. Manual override via env var
351
+ const envVal = parseInt(process.env.PRISM_HRR_DIMENSION || "0", 10);
352
+ if (envVal > 0) {
353
+ // Ensure power of 2 for FFT
354
+ if ((envVal & (envVal - 1)) !== 0) {
355
+ console.error(`Warning: PRISM_HRR_DIMENSION (${envVal}) is not a power of 2. FFT unbinding may fail.`);
356
+ }
357
+ return envVal;
358
+ }
359
+ // 2. Auto-adjustment based on system RAM
360
+ const totalRamGb = totalmem() / (1024 ** 3);
361
+ if (totalRamGb >= 48)
362
+ return 8192; // High-end (M4 Max)
363
+ if (totalRamGb >= 32)
364
+ return 4096; // Mid-high (M3 Pro)
365
+ if (totalRamGb >= 16)
366
+ return 2048; // Standard (M1/M2/M3)
367
+ return 1024; // Low-memory / Baseline
368
+ })();
369
+ if (PRISM_DEBUG_LOGGING) {
370
+ console.error(`[Prism] HRR Zero-Search Dimension: ${PRISM_HRR_DIMENSION} (Total RAM: ${(totalmem() / (1024 ** 3)).toFixed(1)}GB)`);
371
+ }