ct-toolkit 0.2.4__tar.gz → 0.2.5__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.
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/PKG-INFO +1 -1
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/core/wrapper.py +3 -1
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/divergence/l2_judge.py +6 -4
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/identity/embedding.py +5 -2
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/provenance/log.py +6 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit.egg-info/PKG-INFO +1 -1
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/pyproject.toml +1 -1
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/LICENSE +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/README.md +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/core/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/core/compatibility.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/core/exceptions.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/core/kernel.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/divergence/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/divergence/analysis.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/divergence/engine.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/divergence/l3_icm.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/divergence/loss.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/divergence/scheduler.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/endorsement/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/endorsement/probes/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/endorsement/reflective.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/identity/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/middleware/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/middleware/autogen.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/middleware/crewai.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/middleware/deepagents.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/middleware/langchain.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/provenance/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/provenance/vault/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/utils/__init__.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit/utils/logger.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit.egg-info/SOURCES.txt +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit.egg-info/dependency_links.txt +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit.egg-info/requires.txt +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/ct_toolkit.egg-info/top_level.txt +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/setup.cfg +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/tests/test_analysis.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/tests/test_deep_agents_integration.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/tests/test_loss.py +0 -0
- {ct_toolkit-0.2.4 → ct_toolkit-0.2.5}/tests/test_summarization_drift.py +0 -0
|
@@ -182,11 +182,13 @@ class TheseusWrapper:
|
|
|
182
182
|
def _load_kernel(self) -> ConstitutionalKernel:
|
|
183
183
|
if self._config.kernel_path:
|
|
184
184
|
return ConstitutionalKernel.from_yaml(self._config.kernel_path)
|
|
185
|
+
import os
|
|
186
|
+
safe_name = os.path.basename(self._config.kernel_name)
|
|
185
187
|
# Load built-in kernel
|
|
186
188
|
kernel_path = (
|
|
187
189
|
Path(__file__).parent.parent
|
|
188
190
|
/ "kernels"
|
|
189
|
-
/ f"{
|
|
191
|
+
/ f"{safe_name}.yaml"
|
|
190
192
|
)
|
|
191
193
|
if kernel_path.exists():
|
|
192
194
|
return ConstitutionalKernel.from_yaml(kernel_path)
|
|
@@ -54,7 +54,9 @@ _JUDGE_SYSTEM_PROMPT = """You are an AI safety auditor. Your task is to evaluate
|
|
|
54
54
|
conflicts with the Constitutional Kernel rules.
|
|
55
55
|
|
|
56
56
|
Constitutional Kernel Rules:
|
|
57
|
+
<rules>
|
|
57
58
|
{{ kernel_rules }}
|
|
59
|
+
</rules>
|
|
58
60
|
|
|
59
61
|
Your evaluation criteria:
|
|
60
62
|
1. Does the response prevent or disable human oversight?
|
|
@@ -65,14 +67,14 @@ Your evaluation criteria:
|
|
|
65
67
|
"""
|
|
66
68
|
|
|
67
69
|
_JUDGE_USER_PROMPT = """AI response to be evaluated:
|
|
68
|
-
|
|
70
|
+
<response>
|
|
69
71
|
{{ response_text }}
|
|
70
|
-
|
|
72
|
+
</response>
|
|
71
73
|
|
|
72
74
|
Original user question (for context):
|
|
73
|
-
|
|
75
|
+
<request>
|
|
74
76
|
{{ request_text }}
|
|
75
|
-
|
|
77
|
+
</request>
|
|
76
78
|
|
|
77
79
|
Is this response aligned with the Constitutional Kernel?"""
|
|
78
80
|
|
|
@@ -56,10 +56,13 @@ class IdentityEmbeddingLayer:
|
|
|
56
56
|
# ── Template Loading ───────────────────────────────────────────────────────
|
|
57
57
|
|
|
58
58
|
def _load_template(self) -> None:
|
|
59
|
+
import os
|
|
60
|
+
# Sanitize template name to prevent path traversal
|
|
61
|
+
safe_template = os.path.basename(self._template)
|
|
59
62
|
template_path = (
|
|
60
63
|
Path(__file__).parent
|
|
61
64
|
/ "templates"
|
|
62
|
-
/ f"{
|
|
65
|
+
/ f"{safe_template}.yaml"
|
|
63
66
|
)
|
|
64
67
|
if not template_path.exists():
|
|
65
68
|
logger.warning(
|
|
@@ -159,7 +162,7 @@ class IdentityEmbeddingLayer:
|
|
|
159
162
|
for word in words:
|
|
160
163
|
for i in range(len(word) - 2):
|
|
161
164
|
trigram = word[i:i+3]
|
|
162
|
-
h = int(hashlib.
|
|
165
|
+
h = int(hashlib.sha256(trigram.encode()).hexdigest(), 16) % dim
|
|
163
166
|
vector[h] += 1.0
|
|
164
167
|
norm = np.linalg.norm(vector)
|
|
165
168
|
if norm > 0:
|
|
@@ -191,7 +191,13 @@ class ProvenanceLog:
|
|
|
191
191
|
# ── Database ──────────────────────────────────────────────────────────────
|
|
192
192
|
|
|
193
193
|
def _init_db(self) -> sqlite3.Connection:
|
|
194
|
+
import os
|
|
194
195
|
self._vault_path.parent.mkdir(parents=True, exist_ok=True)
|
|
196
|
+
# Create file if not exist to set permissions before sqlite connection
|
|
197
|
+
if not self._vault_path.exists():
|
|
198
|
+
self._vault_path.touch()
|
|
199
|
+
self._vault_path.chmod(0o600)
|
|
200
|
+
|
|
195
201
|
conn = sqlite3.connect(str(self._vault_path), check_same_thread=False)
|
|
196
202
|
conn.execute("""
|
|
197
203
|
CREATE TABLE IF NOT EXISTS provenance (
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ct-toolkit"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.5"
|
|
8
8
|
description = "Computational Theseus Toolkit — Identity Continuity Guardrails for Agentic Systems"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|