prismcortex 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prismcortex/__init__.py +40 -0
- prismcortex/adapters/__init__.py +20 -0
- prismcortex/adapters/ann.py +104 -0
- prismcortex/adapters/prism.py +174 -0
- prismcortex/adapters/reference.py +381 -0
- prismcortex/auth.py +81 -0
- prismcortex/determinism.py +75 -0
- prismcortex/engine.py +524 -0
- prismcortex/factory.py +48 -0
- prismcortex/labels.py +114 -0
- prismcortex/licensing.py +94 -0
- prismcortex/llm/__init__.py +1 -0
- prismcortex/llm/gemini.py +176 -0
- prismcortex/models.py +207 -0
- prismcortex/policy.py +64 -0
- prismcortex/ports.py +121 -0
- prismcortex/salience.py +44 -0
- prismcortex/server.py +520 -0
- prismcortex/server_helpers.py +74 -0
- prismcortex/static/index.html +94 -0
- prismcortex/tenant.py +103 -0
- prismcortex/tracing.py +85 -0
- prismcortex-0.2.1.dist-info/METADATA +175 -0
- prismcortex-0.2.1.dist-info/RECORD +27 -0
- prismcortex-0.2.1.dist-info/WHEEL +5 -0
- prismcortex-0.2.1.dist-info/licenses/LICENSE +21 -0
- prismcortex-0.2.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>PrismCortex Audit Console</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root { --bg: #0f1419; --panel: #1a2332; --text: #e7ecf3; --accent: #5b9bd5; --warn: #e6a23c; }
|
|
9
|
+
* { box-sizing: border-box; }
|
|
10
|
+
body { font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); margin: 0; padding: 1rem; }
|
|
11
|
+
h1 { font-size: 1.25rem; margin: 0 0 1rem; }
|
|
12
|
+
.row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
|
|
13
|
+
input, button, textarea { background: var(--panel); border: 1px solid #334; color: var(--text); padding: 0.5rem; border-radius: 4px; }
|
|
14
|
+
input { min-width: 200px; }
|
|
15
|
+
textarea { width: 100%; min-height: 80px; }
|
|
16
|
+
button { background: var(--accent); border: none; cursor: pointer; font-weight: 600; }
|
|
17
|
+
section { background: var(--panel); padding: 1rem; border-radius: 8px; margin-bottom: 1rem; }
|
|
18
|
+
pre { white-space: pre-wrap; font-size: 0.85rem; overflow: auto; max-height: 320px; }
|
|
19
|
+
.warn { color: var(--warn); }
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<h1>PrismCortex Audit Console</h1>
|
|
24
|
+
<div class="row">
|
|
25
|
+
<label>API Key <input id="key" type="password" placeholder="X-API-Key" /></label>
|
|
26
|
+
<label>Base URL <input id="base" value="" placeholder="http://localhost:8080" /></label>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<section>
|
|
30
|
+
<h2>Recall & Explain</h2>
|
|
31
|
+
<textarea id="query" placeholder="What is our deploy budget?"></textarea>
|
|
32
|
+
<div class="row" style="margin-top:0.5rem">
|
|
33
|
+
<button onclick="recall()">Recall</button>
|
|
34
|
+
<button onclick="explain()">Explain</button>
|
|
35
|
+
<button onclick="replayCert()">Replay certificate</button>
|
|
36
|
+
<input id="at" placeholder="Time-travel ISO (optional)" />
|
|
37
|
+
<button onclick="recallAt()">Recall @ time</button>
|
|
38
|
+
</div>
|
|
39
|
+
<pre id="out"></pre>
|
|
40
|
+
</section>
|
|
41
|
+
|
|
42
|
+
<section>
|
|
43
|
+
<h2>Conflicts & Audit</h2>
|
|
44
|
+
<div class="row">
|
|
45
|
+
<button onclick="conflicts()">List conflicts</button>
|
|
46
|
+
<button onclick="audit()">Audit stats</button>
|
|
47
|
+
<button onclick="dashboard()">Dashboard</button>
|
|
48
|
+
</div>
|
|
49
|
+
<pre id="auditOut"></pre>
|
|
50
|
+
</section>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
function base() { return document.getElementById('base').value || ''; }
|
|
54
|
+
function headers() {
|
|
55
|
+
const h = { 'Content-Type': 'application/json' };
|
|
56
|
+
const k = document.getElementById('key').value;
|
|
57
|
+
if (k) h['X-API-Key'] = k;
|
|
58
|
+
return h;
|
|
59
|
+
}
|
|
60
|
+
async function api(path, opts = {}) {
|
|
61
|
+
const r = await fetch(base() + path, { ...opts, headers: { ...headers(), ...(opts.headers || {}) } });
|
|
62
|
+
const t = await r.text();
|
|
63
|
+
try { return JSON.stringify(JSON.parse(t), null, 2); } catch { return t; }
|
|
64
|
+
}
|
|
65
|
+
async function recall() {
|
|
66
|
+
const q = document.getElementById('query').value;
|
|
67
|
+
document.getElementById('out').textContent = await api('/recall', { method: 'POST', body: JSON.stringify({ query: q }) });
|
|
68
|
+
}
|
|
69
|
+
async function explain() {
|
|
70
|
+
const q = document.getElementById('query').value;
|
|
71
|
+
document.getElementById('out').textContent = await api('/explain', { method: 'POST', body: JSON.stringify({ query: q }) });
|
|
72
|
+
}
|
|
73
|
+
async function replayCert() {
|
|
74
|
+
const q = encodeURIComponent(document.getElementById('query').value);
|
|
75
|
+
document.getElementById('out').textContent = await api('/replay_certificate?query=' + q);
|
|
76
|
+
}
|
|
77
|
+
async function recallAt() {
|
|
78
|
+
const q = document.getElementById('query').value;
|
|
79
|
+
const at = document.getElementById('at').value;
|
|
80
|
+
const url = '/recall_at' + (at ? '?at=' + encodeURIComponent(at) : '');
|
|
81
|
+
document.getElementById('out').textContent = await api(url, { method: 'POST', body: JSON.stringify({ query: q }) });
|
|
82
|
+
}
|
|
83
|
+
async function conflicts() {
|
|
84
|
+
document.getElementById('auditOut').textContent = await api('/conflicts');
|
|
85
|
+
}
|
|
86
|
+
async function audit() {
|
|
87
|
+
document.getElementById('auditOut').textContent = await api('/audit');
|
|
88
|
+
}
|
|
89
|
+
async function dashboard() {
|
|
90
|
+
document.getElementById('auditOut').textContent = await api('/dashboard');
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
</body>
|
|
94
|
+
</html>
|
prismcortex/tenant.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Multi-tenant memory isolation — one Memory (graph + cache + staging) per tenant."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import threading
|
|
6
|
+
|
|
7
|
+
from .engine import Memory
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TenantMemoryManager:
|
|
11
|
+
"""Builds and caches isolated Memory instances keyed by tenant_id + region."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, data_dir: str, backend: str, *, use_ann: bool = True) -> None:
|
|
14
|
+
self._data_dir = data_dir
|
|
15
|
+
self._backend = backend
|
|
16
|
+
self._use_ann = use_ann
|
|
17
|
+
self._memories: dict[str, Memory] = {}
|
|
18
|
+
self._generations: dict[str, int] = {}
|
|
19
|
+
self._llms: dict[str, object] = {}
|
|
20
|
+
self._lock = threading.Lock()
|
|
21
|
+
|
|
22
|
+
def _key(self, tenant_id: str, region: str) -> str:
|
|
23
|
+
return f"{region}:{tenant_id}"
|
|
24
|
+
|
|
25
|
+
def peek(self, tenant_id: str, region: str = "default"):
|
|
26
|
+
key = self._key(tenant_id, region)
|
|
27
|
+
with self._lock:
|
|
28
|
+
if key in self._memories:
|
|
29
|
+
return self._memories[key], self._llms[key]
|
|
30
|
+
return None, None
|
|
31
|
+
|
|
32
|
+
def generation(self, tenant_id: str, region: str = "default") -> int:
|
|
33
|
+
return self._generations.get(self._key(tenant_id, region), 0)
|
|
34
|
+
|
|
35
|
+
def reset(self, tenant_id: str, region: str = "default") -> None:
|
|
36
|
+
key = self._key(tenant_id, region)
|
|
37
|
+
with self._lock:
|
|
38
|
+
mem = self._memories.pop(key, None)
|
|
39
|
+
if mem is not None and hasattr(mem.resonance, "shutdown"):
|
|
40
|
+
try:
|
|
41
|
+
mem.resonance.shutdown()
|
|
42
|
+
except Exception: # noqa: BLE001
|
|
43
|
+
pass
|
|
44
|
+
self._generations[key] = self._generations.get(key, 0) + 1
|
|
45
|
+
self._llms.pop(key, None)
|
|
46
|
+
|
|
47
|
+
def get(self, tenant_id: str, region: str = "default") -> tuple[Memory, object]:
|
|
48
|
+
key = self._key(tenant_id, region)
|
|
49
|
+
with self._lock:
|
|
50
|
+
if key in self._memories:
|
|
51
|
+
return self._memories[key], self._llms[key]
|
|
52
|
+
mem, llm = self._build(tenant_id, region)
|
|
53
|
+
self._memories[key] = mem
|
|
54
|
+
self._llms[key] = llm
|
|
55
|
+
return mem, llm
|
|
56
|
+
|
|
57
|
+
def _build(self, tenant_id: str, region: str) -> tuple[Memory, object]:
|
|
58
|
+
from .adapters.prism import PrismLibCache
|
|
59
|
+
from .adapters.reference import InProcessMesh, ListStaging
|
|
60
|
+
from .server_helpers import CountingGemini
|
|
61
|
+
|
|
62
|
+
key = self._key(tenant_id, region)
|
|
63
|
+
gen = self._generations.get(key, 0)
|
|
64
|
+
tenant_dir = os.path.join(self._data_dir, "tenants", region, tenant_id)
|
|
65
|
+
os.makedirs(tenant_dir, exist_ok=True)
|
|
66
|
+
|
|
67
|
+
llm = CountingGemini(model=os.environ.get("PRISMCORTEX_MODEL"))
|
|
68
|
+
cache = PrismLibCache(db_path=os.path.join(tenant_dir, f"cache_{gen}.db"))
|
|
69
|
+
|
|
70
|
+
if self._backend == "prism":
|
|
71
|
+
from .adapters.prism import PrismLangProjector, PrismResonanceAdapter
|
|
72
|
+
|
|
73
|
+
projector = PrismLangProjector(tenant_id=f"{tenant_id}:{region}")
|
|
74
|
+
resonance = PrismResonanceAdapter(
|
|
75
|
+
embedding_dim=projector.dim,
|
|
76
|
+
state_path=os.path.join(tenant_dir, f"resonance_{gen}.db"),
|
|
77
|
+
onnx_path=os.path.join(self._data_dir, "resonance_engine.onnx"),
|
|
78
|
+
)
|
|
79
|
+
else:
|
|
80
|
+
from .adapters.reference import HashingProjector, InProcessResonance
|
|
81
|
+
|
|
82
|
+
projector = HashingProjector(dim=384)
|
|
83
|
+
resonance = InProcessResonance()
|
|
84
|
+
|
|
85
|
+
if self._use_ann:
|
|
86
|
+
from .adapters.ann import AnnGraphStore
|
|
87
|
+
store = AnnGraphStore(tenant_id=tenant_id)
|
|
88
|
+
else:
|
|
89
|
+
from .adapters.reference import InMemoryGraphStore
|
|
90
|
+
store = InMemoryGraphStore()
|
|
91
|
+
|
|
92
|
+
mem = Memory(
|
|
93
|
+
projector=projector,
|
|
94
|
+
extractor=llm,
|
|
95
|
+
renderer=llm,
|
|
96
|
+
store=store,
|
|
97
|
+
resonance=resonance,
|
|
98
|
+
cache=cache,
|
|
99
|
+
mesh=InProcessMesh(),
|
|
100
|
+
staging=ListStaging(),
|
|
101
|
+
tenant_id=tenant_id,
|
|
102
|
+
)
|
|
103
|
+
return mem, llm
|
prismcortex/tracing.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Lightweight request tracing — structured spans without a heavy OTEL dependency.
|
|
2
|
+
|
|
3
|
+
Each request gets a trace_id; engine operations emit span events into JSON logs.
|
|
4
|
+
Set PRISMCORTEX_TRACE=1 (default on) to enable.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import contextvars
|
|
9
|
+
import os
|
|
10
|
+
import time
|
|
11
|
+
import uuid
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
from typing import Any, Optional
|
|
14
|
+
|
|
15
|
+
_TRACE_ON = os.environ.get("PRISMCORTEX_TRACE", "1") != "0"
|
|
16
|
+
_current: contextvars.ContextVar[Optional["Trace"]] = contextvars.ContextVar("trace", default=None)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class Span:
|
|
21
|
+
name: str
|
|
22
|
+
start: float
|
|
23
|
+
end: Optional[float] = None
|
|
24
|
+
attrs: dict[str, Any] = field(default_factory=dict)
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def ms(self) -> float:
|
|
28
|
+
end = self.end or time.perf_counter()
|
|
29
|
+
return round((end - self.start) * 1000, 2)
|
|
30
|
+
|
|
31
|
+
def finish(self, **attrs: Any) -> None:
|
|
32
|
+
self.end = time.perf_counter()
|
|
33
|
+
self.attrs.update(attrs)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class Trace:
|
|
38
|
+
trace_id: str
|
|
39
|
+
spans: list[Span] = field(default_factory=list)
|
|
40
|
+
|
|
41
|
+
def span(self, name: str, **attrs: Any) -> Span:
|
|
42
|
+
s = Span(name=name, start=time.perf_counter(), attrs=dict(attrs))
|
|
43
|
+
self.spans.append(s)
|
|
44
|
+
return s
|
|
45
|
+
|
|
46
|
+
def to_dict(self) -> dict:
|
|
47
|
+
return {
|
|
48
|
+
"trace_id": self.trace_id,
|
|
49
|
+
"spans": [{"name": s.name, "ms": s.ms, **s.attrs} for s in self.spans],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def start_trace(trace_id: Optional[str] = None) -> Trace:
|
|
54
|
+
t = Trace(trace_id=trace_id or uuid.uuid4().hex[:16])
|
|
55
|
+
_current.set(t)
|
|
56
|
+
return t
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def current_trace() -> Optional[Trace]:
|
|
60
|
+
return _current.get()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def trace_enabled() -> bool:
|
|
64
|
+
return _TRACE_ON
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class traced:
|
|
68
|
+
"""Context manager: ``with traced("digest"): ...``"""
|
|
69
|
+
|
|
70
|
+
def __init__(self, name: str, **attrs: Any) -> None:
|
|
71
|
+
self.name = name
|
|
72
|
+
self.attrs = attrs
|
|
73
|
+
self.span: Optional[Span] = None
|
|
74
|
+
|
|
75
|
+
def __enter__(self) -> Span:
|
|
76
|
+
tr = _current.get()
|
|
77
|
+
if tr is None or not _TRACE_ON:
|
|
78
|
+
self.span = Span(name=self.name, start=time.perf_counter())
|
|
79
|
+
return self.span
|
|
80
|
+
self.span = tr.span(self.name, **self.attrs)
|
|
81
|
+
return self.span
|
|
82
|
+
|
|
83
|
+
def __exit__(self, *exc) -> None:
|
|
84
|
+
if self.span:
|
|
85
|
+
self.span.finish()
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prismcortex
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Deterministic, auditable, self-consolidating memory for AI agents
|
|
5
|
+
Author-email: Amin Parva <info@insightits.com>
|
|
6
|
+
Maintainer-email: Insight IT Solutions LLC <info@insightits.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2026 Amin Parva / Insight IT Solutions LLC
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://www.insightits.com/products/prismcortex.html
|
|
30
|
+
Project-URL: Documentation, https://github.com/insightitsGit/PrismCortex#readme
|
|
31
|
+
Project-URL: Repository, https://github.com/insightitsGit/PrismCortex
|
|
32
|
+
Project-URL: Bug Tracker, https://github.com/insightitsGit/PrismCortex/issues
|
|
33
|
+
Keywords: llm,memory,agents,knowledge-graph,deterministic,rag,bitemporal,audit,agent-memory,compliance
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
42
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
43
|
+
Requires-Python: >=3.10
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Requires-Dist: pydantic>=2.5
|
|
47
|
+
Requires-Dist: numpy>=1.24
|
|
48
|
+
Requires-Dist: cryptography>=42
|
|
49
|
+
Provides-Extra: prism
|
|
50
|
+
Requires-Dist: prismlang>=0.1.1; extra == "prism"
|
|
51
|
+
Requires-Dist: prismlib>=0.4.0; extra == "prism"
|
|
52
|
+
Requires-Dist: prismrag-patch>=0.2.1; extra == "prism"
|
|
53
|
+
Requires-Dist: prismresonance>=0.3.0; extra == "prism"
|
|
54
|
+
Provides-Extra: gemini
|
|
55
|
+
Requires-Dist: google-genai>=0.3.0; extra == "gemini"
|
|
56
|
+
Provides-Extra: server
|
|
57
|
+
Requires-Dist: fastapi>=0.110; extra == "server"
|
|
58
|
+
Requires-Dist: uvicorn[standard]>=0.27; extra == "server"
|
|
59
|
+
Provides-Extra: dev
|
|
60
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
61
|
+
Requires-Dist: google-genai>=0.3.0; extra == "dev"
|
|
62
|
+
Requires-Dist: fastapi>=0.110; extra == "dev"
|
|
63
|
+
Requires-Dist: uvicorn[standard]>=0.27; extra == "dev"
|
|
64
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
65
|
+
Provides-Extra: bench
|
|
66
|
+
Requires-Dist: mem0ai>=2.0; extra == "bench"
|
|
67
|
+
Requires-Dist: zep-cloud>=2.0; extra == "bench"
|
|
68
|
+
Dynamic: license-file
|
|
69
|
+
|
|
70
|
+
# PrismCortex
|
|
71
|
+
|
|
72
|
+
**Deterministic, auditable, self-consolidating memory for AI agents.**
|
|
73
|
+
|
|
74
|
+
Most agent "memory" is an append-only chat log that you stuff back into the context
|
|
75
|
+
window until it overflows. PrismCortex does what a brain does instead: it **digests**
|
|
76
|
+
each turn into a knowledge graph, **consolidates** uncertain facts in the background
|
|
77
|
+
(like sleep), and demotes the LLM from *thinker* to *renderer* — it only paints the
|
|
78
|
+
facts you hand it. Change the memory and only the affected answers change; everything
|
|
79
|
+
is traceable to the exact facts and source events behind it.
|
|
80
|
+
|
|
81
|
+
It's the orchestration layer over five shipped Insight ITS packages — PrismLang,
|
|
82
|
+
PrismRAG, PrismResonance, PrismLib, and Chorus Fabric — behind one tiny API.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from prismcortex import reference_memory
|
|
86
|
+
|
|
87
|
+
mem = reference_memory(cache_path=".prismcortex_cache/demo.json")
|
|
88
|
+
|
|
89
|
+
mem.digest("My production deploy budget is $40,000.")
|
|
90
|
+
print(mem.recall("What's my deploy budget?").answer) # → "$40,000"
|
|
91
|
+
|
|
92
|
+
mem.digest("Correction: my deploy budget is now $55,000.") # fast-tracked (ALERT)
|
|
93
|
+
print(mem.recall("What's my deploy budget?").answer) # → "$55,000"
|
|
94
|
+
# …and the $40,000 fact is still on record, time-stamped, for audit/time-travel.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Why it's different
|
|
98
|
+
|
|
99
|
+
| | Append-only RAG | PrismCortex |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| Storage | every chat turn | graph topology (the *gist*) |
|
|
102
|
+
| Updates | append + hope retrieval ranks it | bitemporal: invalidate old, add new, keep history |
|
|
103
|
+
| Determinism | none (logs + LLM both drift) | content-addressed render cache, replay-identical |
|
|
104
|
+
| Cost | re-extract context every call | salience-gated writes, cached reads |
|
|
105
|
+
| Audit | grep the logs | every answer → exact facts + source events |
|
|
106
|
+
|
|
107
|
+
## What you get that a vector store can't
|
|
108
|
+
|
|
109
|
+
| Capability | What it does |
|
|
110
|
+
|---|---|
|
|
111
|
+
| **Explainability** (`/explain`) | Every answer returns its **evidence trail** — the exact facts, their source events, and confidence. A vector store returns memories; only a provenance graph returns *evidence*. |
|
|
112
|
+
| **Confidence + freshness** | Each recall reports how reinforced its facts are (0–1) and when they were last confirmed. |
|
|
113
|
+
| **Time-travel / audit** | Corrections invalidate but **retain** the old fact as a queryable bitemporal record (a paid feature in Mem0 OSS). |
|
|
114
|
+
| **Bounded memory** | `sleep()` prunes the coldest facts to a cap — the active set **plateaus** instead of growing forever; pruned facts are kept for audit. |
|
|
115
|
+
| **~12× smaller index** | 128-dim vectors vs the 1536–3072-dim default elsewhere; plus entity-dedup. |
|
|
116
|
+
| **Sovereign** | Self-hosted, your data, offline-keyed — no third-party SaaS. |
|
|
117
|
+
|
|
118
|
+
These are validated in `benchmarks/` (incl. a fair head-to-head vs Mem0 in `vs_mem0.py`).
|
|
119
|
+
|
|
120
|
+
## Determinism, honestly
|
|
121
|
+
|
|
122
|
+
We do **not** claim "temperature 0 → identical output" — that's false for any shared
|
|
123
|
+
API model (batching + floating-point non-associativity flip near-tied tokens). Instead:
|
|
124
|
+
|
|
125
|
+
- **Content-addressed rendering.** The cache key is a hash of the exact retrieved
|
|
126
|
+
subgraph + query + template + **pinned model snapshot**. The model is invoked at most
|
|
127
|
+
once per unique (query, memory-version); its answer is frozen and replayed
|
|
128
|
+
byte-for-byte. A changed fact changes the key, so a stale answer is *unreachable* —
|
|
129
|
+
invalidation and determinism are the same mechanism.
|
|
130
|
+
- **Extractive facts.** Numbers, names, ids, and dates are substituted from the graph,
|
|
131
|
+
not generated, and a verification pass rejects fabricated values — so the *facts* are
|
|
132
|
+
deterministic even on the first render; only prose phrasing can vary (then it's frozen).
|
|
133
|
+
|
|
134
|
+
Scope: replay-determinism, pinned model snapshot, snapshot sources (not live feeds).
|
|
135
|
+
First-render *token* determinism requires the self-hosted sovereign tier. See
|
|
136
|
+
[`DESIGN.md`](DESIGN.md) §2.
|
|
137
|
+
|
|
138
|
+
## Architecture (one engine, five swappable ports)
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
digest(text) ─▶ salience gate ─▶ extract gist ─▶ delta in RAM
|
|
142
|
+
├─ certain / urgent ─▶ commit (version++)
|
|
143
|
+
└─ uncertain ───────▶ staging buffer
|
|
144
|
+
│ sleep()
|
|
145
|
+
consolidate ─▶ commit (version++)
|
|
146
|
+
|
|
147
|
+
recall(query) ─▶ retrieve subgraph @version ─▶ content-address ─▶ cache hit? replay
|
|
148
|
+
miss? render once → freeze
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
| Port | Reference adapter | Production (`pip install prismcortex[prism]`) |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| Gist projection | hashing-trick embeddings | `prismlang` |
|
|
154
|
+
| Graph store (bitemporal) | in-memory | `prismrag-patch` |
|
|
155
|
+
| Weight / salience / sleep | in-process | `prismresonance` |
|
|
156
|
+
| Render cache (durable) | JSON file | `prismlib` (cache-as-failover) |
|
|
157
|
+
| Mesh broadcast | in-process | `prismlib` cluster / Chorus |
|
|
158
|
+
| Extraction + rendering | — | **real Gemini** (`prismcortex[gemini]`) |
|
|
159
|
+
|
|
160
|
+
## Install & test
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pip install -e . # core
|
|
164
|
+
pip install -e ".[gemini]" # + real Gemini extraction/rendering
|
|
165
|
+
|
|
166
|
+
pytest tests/test_graph_engine.py # deterministic substrate — no API key
|
|
167
|
+
GEMINI_API_KEY=... pytest # full end-to-end with real Gemini
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Licensing
|
|
171
|
+
|
|
172
|
+
Open-core (MIT). The core (`digest`/`recall`, bitemporal graph, determinism cache) is
|
|
173
|
+
free. Commercial modules (audit console, consolidation-at-scale, multi-agent mesh, the
|
|
174
|
+
sovereign determinism tier) are gated by an **offline signed license key** — no
|
|
175
|
+
phone-home, works air-gapped. See [`DESIGN.md`](DESIGN.md) §7.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
prismcortex/__init__.py,sha256=ByzYI60rbojLdu2QmTDVM7Jvbav7WXlr4-X2srt-DEs,951
|
|
2
|
+
prismcortex/auth.py,sha256=gq0n8o7W7woHz9m1p3bkYyHodI4e3a5-nlrLCf1L1p4,2244
|
|
3
|
+
prismcortex/determinism.py,sha256=GMtRN2eUreDEKeArkSZz-K-asFSB_q0ffMB95qC62sU,2795
|
|
4
|
+
prismcortex/engine.py,sha256=JbmcyCqnDD1kuQf7ei8X9PrVBRnV96e_heOykadt_Oo,24482
|
|
5
|
+
prismcortex/factory.py,sha256=iLWVtdbm--HdKCrEoNwYo8MKdWdmSnDelm4pbdxFo9w,1363
|
|
6
|
+
prismcortex/labels.py,sha256=ocujNny3V1EkFkAJobmHV796vms6v2FPtm_M5fyyFPk,3827
|
|
7
|
+
prismcortex/licensing.py,sha256=dE_sz4r24-QxLoVZ0962FSu03o3s_14KGs20G4D5cbU,3593
|
|
8
|
+
prismcortex/models.py,sha256=y8rv-aYSLP13x7adm8iudkMzNuuR7mDqSzjA9nCoomg,6701
|
|
9
|
+
prismcortex/policy.py,sha256=C9GqMMNo2c9OhD8T79cQKvi6ajOxt6fh5Oxworprjrg,2322
|
|
10
|
+
prismcortex/ports.py,sha256=lxQxqY0Qo7bvqcsSb-XLgud43fe2_XtAwyqaWY0Nep4,4284
|
|
11
|
+
prismcortex/salience.py,sha256=ytJ9GCYI2J-8PGD_ihbM-Aw7FQOWwJIPiVOSq4O-MXk,1677
|
|
12
|
+
prismcortex/server.py,sha256=cqhAb022eLuOM_tTIiYT7ReJUfEcZ7huhjVsowDxDvU,19283
|
|
13
|
+
prismcortex/server_helpers.py,sha256=zRzdWi5du0-kGDWjE8qqkdB_DCfILh3CHbql85qDOgE,2231
|
|
14
|
+
prismcortex/tenant.py,sha256=M2f7OhaOrU9G0ehJ9q3iRi02iObH50OMThwvFd9p1Zk,3910
|
|
15
|
+
prismcortex/tracing.py,sha256=zn8Xuh8bL9tbB9OlVSNsvVQMY6F9Cu2BAiBnnOcBhy8,2264
|
|
16
|
+
prismcortex/adapters/__init__.py,sha256=RZJQhKJ9ey7RgWAMGFkwwChJDtDDT2K3TS3V-9lMcEk,395
|
|
17
|
+
prismcortex/adapters/ann.py,sha256=_ILp5RcYlDa0KMm-jkZPK-Liyq29DsYPQVeYPs6mKu0,4085
|
|
18
|
+
prismcortex/adapters/prism.py,sha256=e815yYh1bKwO14k1Zw61VoV2YQMG6lJM-PWQj_-k0h4,6869
|
|
19
|
+
prismcortex/adapters/reference.py,sha256=v-Im3Wkr1Ru-_BtKc5liEeXrEyu1vg_HJ0u7sLHPwOg,15889
|
|
20
|
+
prismcortex/llm/__init__.py,sha256=hYYEEk-WWKeibre--955z8HmALPeoN7o1qzBeuH3o4w,34
|
|
21
|
+
prismcortex/llm/gemini.py,sha256=iLGmdQq17C7PYFe8Y9xIz2Ik5CuxONl53bpc0eH6gvc,8174
|
|
22
|
+
prismcortex/static/index.html,sha256=QLgKHsGfzjwOMaNPBovug-3x-S-L-iEgG7ENJORgAmo,4109
|
|
23
|
+
prismcortex-0.2.1.dist-info/licenses/LICENSE,sha256=BrQL4yAN1-qU0eQbC582-dA96o8wt9wOo4f9YjyMV_8,1094
|
|
24
|
+
prismcortex-0.2.1.dist-info/METADATA,sha256=zh14GlB1OsG4ihE08UgqUws3yl0aSOVl95ZkxmZEjxc,9232
|
|
25
|
+
prismcortex-0.2.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
26
|
+
prismcortex-0.2.1.dist-info/top_level.txt,sha256=bBOlOwn73NtC9zl1gac5YXQV77sEAw0qfvSx6ReIC4Y,12
|
|
27
|
+
prismcortex-0.2.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Amin Parva / Insight IT Solutions LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
prismcortex
|