bendex-tau 0.1.0__tar.gz

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.
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: bendex-tau
3
+ Version: 0.1.0
4
+ Summary: Real-time LLM response stability monitor grounded in Fisher-Rao information geometry and the Landauer limit.
5
+ Author-email: Hannah Nine <9hannahnine@gmail.com>
6
+ License: AGPL-3.0-or-later
7
+ Project-URL: Homepage, https://bendexgeometry.com
8
+ Project-URL: Repository, https://github.com/9hannahnine-jpg/bendex-tau
9
+ Project-URL: Papers, https://figshare.com/authors/Hannah_Nine/22495979
10
+ Keywords: llm,security,prompt injection,ai safety,monitoring,information geometry,fisher-rao
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: numpy>=1.21
21
+ Requires-Dist: sentence-transformers>=2.0
22
+ Requires-Dist: openai>=1.0
23
+
24
+ # bendex-tau
25
+
26
+ Real-time LLM response stability monitor grounded in Fisher-Rao information geometry.
27
+
28
+ ## What it does
29
+
30
+ Tracks tau_sec on the trajectory of LLM responses. When an LLM is being manipulated,
31
+ its response trajectory becomes informationally unstable. tau_sec measures this in real time.
32
+
33
+ tau* = sqrt(3/2) = 1.2247 — the Landauer threshold. Not tuned. Derived.
34
+
35
+ Empirical validation at n=50 per class:
36
+ - Adversarial sessions mean min tau: 0.984
37
+ - Benign sessions mean min tau: 1.182
38
+ - p < 0.0000001 (t-test and Mann-Whitney)
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ pip install bendex-tau
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ from bendex_tau import TauMonitor
50
+ from openai import OpenAI
51
+
52
+ monitor = TauMonitor()
53
+ client = OpenAI()
54
+
55
+ response = monitor.create(
56
+ client,
57
+ session_id="session_123",
58
+ model="gpt-4o-mini",
59
+ messages=[{"role": "user", "content": "hello"}]
60
+ )
61
+
62
+ print(response.tau_sec) # stability scalar
63
+ print(response.tau_status) # stable / warning / adversarial
64
+ print(response.meta_rate) # M(tau) early warning signal
65
+ print(response.below_threshold) # True if tau crossed tau*
66
+ ```
67
+
68
+ ## Papers
69
+
70
+ Hannah Nine (2026). H2 x H2 Fisher manifold series.
71
+ https://figshare.com/authors/Hannah_Nine/22495979
72
+
73
+ Patent pending.
74
+
75
+ ## License
76
+
77
+ AGPL-3.0. Commercial license at bendexgeometry.com.
@@ -0,0 +1,54 @@
1
+ # bendex-tau
2
+
3
+ Real-time LLM response stability monitor grounded in Fisher-Rao information geometry.
4
+
5
+ ## What it does
6
+
7
+ Tracks tau_sec on the trajectory of LLM responses. When an LLM is being manipulated,
8
+ its response trajectory becomes informationally unstable. tau_sec measures this in real time.
9
+
10
+ tau* = sqrt(3/2) = 1.2247 — the Landauer threshold. Not tuned. Derived.
11
+
12
+ Empirical validation at n=50 per class:
13
+ - Adversarial sessions mean min tau: 0.984
14
+ - Benign sessions mean min tau: 1.182
15
+ - p < 0.0000001 (t-test and Mann-Whitney)
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pip install bendex-tau
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```python
26
+ from bendex_tau import TauMonitor
27
+ from openai import OpenAI
28
+
29
+ monitor = TauMonitor()
30
+ client = OpenAI()
31
+
32
+ response = monitor.create(
33
+ client,
34
+ session_id="session_123",
35
+ model="gpt-4o-mini",
36
+ messages=[{"role": "user", "content": "hello"}]
37
+ )
38
+
39
+ print(response.tau_sec) # stability scalar
40
+ print(response.tau_status) # stable / warning / adversarial
41
+ print(response.meta_rate) # M(tau) early warning signal
42
+ print(response.below_threshold) # True if tau crossed tau*
43
+ ```
44
+
45
+ ## Papers
46
+
47
+ Hannah Nine (2026). H2 x H2 Fisher manifold series.
48
+ https://figshare.com/authors/Hannah_Nine/22495979
49
+
50
+ Patent pending.
51
+
52
+ ## License
53
+
54
+ AGPL-3.0. Commercial license at bendexgeometry.com.
@@ -0,0 +1,4 @@
1
+ from .monitor import TauMonitor
2
+ from .session import TauSession
3
+ __version__ = "0.1.0"
4
+ __all__ = ["TauMonitor", "TauSession"]
@@ -0,0 +1,70 @@
1
+ from .session import TauSession
2
+ from typing import Dict, Optional
3
+
4
+ class TauResponse:
5
+ def __init__(self, openai_response, tau_data: dict):
6
+ self._response = openai_response
7
+ self.tau_sec = tau_data.get("tau_sec")
8
+ self.tau_star = tau_data.get("tau_star")
9
+ self.tau_status = tau_data.get("tau_status")
10
+ self.meta_rate = tau_data.get("meta_rate")
11
+ self.below_threshold = tau_data.get("below_threshold", False)
12
+ self.turns = tau_data.get("turns")
13
+ self.session_id = tau_data.get("session_id")
14
+ self._tau_data = tau_data
15
+
16
+ def __getattr__(self, name):
17
+ return getattr(self._response, name)
18
+
19
+ def __repr__(self):
20
+ return (
21
+ f"TauResponse(tau_sec={self.tau_sec}, "
22
+ f"tau_status={self.tau_status!r}, "
23
+ f"meta_rate={self.meta_rate}, "
24
+ f"turns={self.turns})"
25
+ )
26
+
27
+
28
+ class TauMonitor:
29
+ """
30
+ Wraps an OpenAI-compatible client to track tau_sec on response trajectories.
31
+
32
+ Usage:
33
+ from bendex_tau import TauMonitor
34
+ from openai import OpenAI
35
+
36
+ monitor = TauMonitor()
37
+ client = OpenAI()
38
+
39
+ response = monitor.create(
40
+ client,
41
+ session_id="user_123",
42
+ model="gpt-4o-mini",
43
+ messages=[{"role": "user", "content": "hello"}]
44
+ )
45
+
46
+ print(response.tau_sec)
47
+ print(response.tau_status)
48
+ print(response.meta_rate)
49
+ """
50
+
51
+ def __init__(self):
52
+ self._sessions: Dict[str, TauSession] = {}
53
+
54
+ def _get_session(self, session_id: str) -> TauSession:
55
+ if session_id not in self._sessions:
56
+ self._sessions[session_id] = TauSession(session_id)
57
+ return self._sessions[session_id]
58
+
59
+ def create(self, client, session_id: str = "default", **kwargs) -> TauResponse:
60
+ response = client.chat.completions.create(**kwargs)
61
+ text = response.choices[0].message.content or ""
62
+ tau_data = self._get_session(session_id).update(text)
63
+ return TauResponse(response, tau_data)
64
+
65
+ def get_session(self, session_id: str) -> Optional[TauSession]:
66
+ return self._sessions.get(session_id)
67
+
68
+ def reset_session(self, session_id: str):
69
+ if session_id in self._sessions:
70
+ del self._sessions[session_id]
@@ -0,0 +1,105 @@
1
+ import math
2
+ import numpy as np
3
+ from typing import Optional, List
4
+
5
+ TAU_STAR = math.sqrt(3.0 / 2.0)
6
+ T_WINDOW = 3
7
+
8
+ def _meta_rate(tau: float) -> float:
9
+ if tau <= 0:
10
+ return 0.0
11
+ return -6.0 * (3.0 - 2.0 * tau ** 2) / (tau ** 5)
12
+
13
+ class TauSession:
14
+ """
15
+ Tracks tau_sec for a single conversation session.
16
+
17
+ tau_sec is the Fisher-Rao stability scalar derived from the Landauer limit.
18
+ Below tau* (1.2247) the session has crossed into informational instability.
19
+
20
+ Reference: Nine (2026), Papers 2-3.
21
+ https://figshare.com/authors/Hannah_Nine/22495979
22
+ Patent pending.
23
+ """
24
+
25
+ def __init__(self, session_id: str = "default"):
26
+ self.session_id = session_id
27
+ self.embeddings: List[np.ndarray] = []
28
+ self.tau_history: List[float] = []
29
+ self.meta_history: List[float] = []
30
+ self._embed_model = None
31
+
32
+ def _get_model(self):
33
+ if self._embed_model is None:
34
+ from sentence_transformers import SentenceTransformer
35
+ self._embed_model = SentenceTransformer("all-MiniLM-L6-v2")
36
+ return self._embed_model
37
+
38
+ def update(self, response_text: str) -> dict:
39
+ model = self._get_model()
40
+ emb = model.encode([response_text[:512]], convert_to_numpy=True)[0]
41
+ self.embeddings.append(emb)
42
+ n = len(self.embeddings)
43
+
44
+ if n < T_WINDOW + 1:
45
+ return {
46
+ "tau_sec": None,
47
+ "tau_star": TAU_STAR,
48
+ "tau_status": "insufficient_history",
49
+ "meta_rate": None,
50
+ "turns": n,
51
+ "session_id": self.session_id,
52
+ "below_threshold": False,
53
+ }
54
+
55
+ deltas = [
56
+ np.linalg.norm(self.embeddings[i] - self.embeddings[i-1]) + 1e-8
57
+ for i in range(1, n)
58
+ ]
59
+
60
+ delta_curr = deltas[-1]
61
+ delta_prev = deltas[-2] if len(deltas) >= 2 else delta_curr
62
+ delta_old = deltas[max(0, len(deltas) - T_WINDOW)]
63
+
64
+ S_local = delta_prev / delta_curr
65
+ S_global = delta_old / delta_curr
66
+ D_sec = math.log(max(S_global, 1e-8)) - math.log(max(S_local, 1e-8))
67
+
68
+ lambda_sec = D_sec / max(n - T_WINDOW, 1)
69
+ inner = lambda_sec + 2.0
70
+ tau_sec = math.sqrt(3.0 / inner) if inner > 0 else 0.0
71
+
72
+ meta = _meta_rate(tau_sec)
73
+ self.tau_history.append(tau_sec)
74
+ self.meta_history.append(meta)
75
+
76
+ if tau_sec > TAU_STAR * 1.05:
77
+ status = "stable"
78
+ elif tau_sec > TAU_STAR:
79
+ status = "warning"
80
+ else:
81
+ status = "adversarial"
82
+
83
+ return {
84
+ "tau_sec": round(tau_sec, 6),
85
+ "tau_star": round(TAU_STAR, 6),
86
+ "tau_status": status,
87
+ "meta_rate": round(meta, 6),
88
+ "D_sec": round(D_sec, 6),
89
+ "lambda_sec": round(lambda_sec, 6),
90
+ "turns": n,
91
+ "session_id": self.session_id,
92
+ "below_threshold": tau_sec < TAU_STAR,
93
+ }
94
+
95
+ @property
96
+ def min_tau(self) -> Optional[float]:
97
+ return min(self.tau_history) if self.tau_history else None
98
+
99
+ @property
100
+ def mean_tau(self) -> Optional[float]:
101
+ return float(np.mean(self.tau_history)) if self.tau_history else None
102
+
103
+ @property
104
+ def tau_variance(self) -> Optional[float]:
105
+ return float(np.std(self.tau_history)) if len(self.tau_history) > 1 else None
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: bendex-tau
3
+ Version: 0.1.0
4
+ Summary: Real-time LLM response stability monitor grounded in Fisher-Rao information geometry and the Landauer limit.
5
+ Author-email: Hannah Nine <9hannahnine@gmail.com>
6
+ License: AGPL-3.0-or-later
7
+ Project-URL: Homepage, https://bendexgeometry.com
8
+ Project-URL: Repository, https://github.com/9hannahnine-jpg/bendex-tau
9
+ Project-URL: Papers, https://figshare.com/authors/Hannah_Nine/22495979
10
+ Keywords: llm,security,prompt injection,ai safety,monitoring,information geometry,fisher-rao
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: numpy>=1.21
21
+ Requires-Dist: sentence-transformers>=2.0
22
+ Requires-Dist: openai>=1.0
23
+
24
+ # bendex-tau
25
+
26
+ Real-time LLM response stability monitor grounded in Fisher-Rao information geometry.
27
+
28
+ ## What it does
29
+
30
+ Tracks tau_sec on the trajectory of LLM responses. When an LLM is being manipulated,
31
+ its response trajectory becomes informationally unstable. tau_sec measures this in real time.
32
+
33
+ tau* = sqrt(3/2) = 1.2247 — the Landauer threshold. Not tuned. Derived.
34
+
35
+ Empirical validation at n=50 per class:
36
+ - Adversarial sessions mean min tau: 0.984
37
+ - Benign sessions mean min tau: 1.182
38
+ - p < 0.0000001 (t-test and Mann-Whitney)
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ pip install bendex-tau
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ from bendex_tau import TauMonitor
50
+ from openai import OpenAI
51
+
52
+ monitor = TauMonitor()
53
+ client = OpenAI()
54
+
55
+ response = monitor.create(
56
+ client,
57
+ session_id="session_123",
58
+ model="gpt-4o-mini",
59
+ messages=[{"role": "user", "content": "hello"}]
60
+ )
61
+
62
+ print(response.tau_sec) # stability scalar
63
+ print(response.tau_status) # stable / warning / adversarial
64
+ print(response.meta_rate) # M(tau) early warning signal
65
+ print(response.below_threshold) # True if tau crossed tau*
66
+ ```
67
+
68
+ ## Papers
69
+
70
+ Hannah Nine (2026). H2 x H2 Fisher manifold series.
71
+ https://figshare.com/authors/Hannah_Nine/22495979
72
+
73
+ Patent pending.
74
+
75
+ ## License
76
+
77
+ AGPL-3.0. Commercial license at bendexgeometry.com.
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ bendex_tau/__init__.py
4
+ bendex_tau/monitor.py
5
+ bendex_tau/session.py
6
+ bendex_tau.egg-info/PKG-INFO
7
+ bendex_tau.egg-info/SOURCES.txt
8
+ bendex_tau.egg-info/dependency_links.txt
9
+ bendex_tau.egg-info/requires.txt
10
+ bendex_tau.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ numpy>=1.21
2
+ sentence-transformers>=2.0
3
+ openai>=1.0
@@ -0,0 +1 @@
1
+ bendex_tau
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bendex-tau"
7
+ version = "0.1.0"
8
+ description = "Real-time LLM response stability monitor grounded in Fisher-Rao information geometry and the Landauer limit."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "AGPL-3.0-or-later"}
12
+ authors = [{name = "Hannah Nine", email = "9hannahnine@gmail.com"}]
13
+ keywords = ["llm", "security", "prompt injection", "ai safety", "monitoring", "information geometry", "fisher-rao"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: Science/Research",
18
+ "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
21
+ "Topic :: Security",
22
+ ]
23
+ dependencies = [
24
+ "numpy>=1.21",
25
+ "sentence-transformers>=2.0",
26
+ "openai>=1.0",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://bendexgeometry.com"
31
+ Repository = "https://github.com/9hannahnine-jpg/bendex-tau"
32
+ Papers = "https://figshare.com/authors/Hannah_Nine/22495979"
33
+
34
+ [tool.setuptools.packages.find]
35
+ include = ["bendex_tau*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+