ct-toolkit 0.3.40__tar.gz → 0.4.1__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.3.40/ct_toolkit.egg-info → ct_toolkit-0.4.1}/PKG-INFO +100 -25
- ct_toolkit-0.3.40/PKG-INFO → ct_toolkit-0.4.1/README.md +67 -64
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/__init__.py +3 -2
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/cli.py +169 -6
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/kernel.py +105 -4
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/wrapper.py +853 -37
- ct_toolkit-0.4.1/ct_toolkit/divergence/engine.py +722 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/divergence/l2_judge.py +122 -27
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/divergence/l3_icm.py +94 -5
- ct_toolkit-0.4.1/ct_toolkit/identity/embedding.py +445 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/middleware/langchain.py +59 -0
- ct_toolkit-0.4.1/ct_toolkit/provenance/log.py +753 -0
- ct_toolkit-0.4.1/ct_toolkit/server.py +1198 -0
- ct_toolkit-0.4.1/ct_toolkit/utils/telemetry.py +272 -0
- ct_toolkit-0.4.1/ct_toolkit.egg-info/PKG-INFO +253 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit.egg-info/SOURCES.txt +7 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit.egg-info/requires.txt +33 -7
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/pyproject.toml +43 -13
- ct_toolkit-0.4.1/tests/test_async_and_streaming.py +196 -0
- ct_toolkit-0.4.1/tests/test_background_latency.py +248 -0
- ct_toolkit-0.4.1/tests/test_distributed_headers_and_cli.py +331 -0
- ct_toolkit-0.4.1/tests/test_enterprise_db_and_otel.py +226 -0
- ct_toolkit-0.4.1/tests/test_l1_semantic.py +147 -0
- ct_toolkit-0.4.1/tests/test_optional_dependencies.py +57 -0
- ct_toolkit-0.3.40/README.md +0 -129
- ct_toolkit-0.3.40/ct_toolkit/divergence/engine.py +0 -361
- ct_toolkit-0.3.40/ct_toolkit/identity/embedding.py +0 -223
- ct_toolkit-0.3.40/ct_toolkit/provenance/log.py +0 -436
- ct_toolkit-0.3.40/ct_toolkit/server.py +0 -186
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/LICENSE +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/__main__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/async_wrapper.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/circuit_breaker.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/compatibility.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/compression_guard.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/exceptions.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/core/integrity.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/divergence/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/divergence/analysis.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/divergence/loss.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/divergence/scheduler.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/endorsement/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/endorsement/probes/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/endorsement/reflective.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/identity/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/identity/templates/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/identity/templates/defense.yaml +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/identity/templates/finance.yaml +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/identity/templates/general.yaml +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/identity/templates/medical.yaml +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/kernels/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/kernels/default.yaml +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/kernels/defense.yaml +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/middleware/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/middleware/autogen.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/middleware/crewai.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/middleware/deepagents.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/middleware/litellm.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/profile_checksums.sha256 +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/provenance/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/provenance/vault/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/utils/__init__.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/utils/logger.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/utils/metrics.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit/utils/sensitive_masker.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit.egg-info/dependency_links.txt +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit.egg-info/entry_points.txt +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/ct_toolkit.egg-info/top_level.txt +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/setup.cfg +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/tests/test_analysis.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/tests/test_cli.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/tests/test_cli_extended.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/tests/test_deep_agents_integration.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/tests/test_loss.py +0 -0
- {ct_toolkit-0.3.40 → ct_toolkit-0.4.1}/tests/test_summarization_drift.py +0 -0
|
@@ -1,34 +1,47 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ct-toolkit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Computational Theseus Toolkit — Identity Continuity Guardrails for Agentic Systems
|
|
5
5
|
Author: Hakan Damar
|
|
6
6
|
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://theseus-guard.github.io/ct-toolkit/
|
|
8
|
+
Project-URL: Documentation, https://theseus-guard.github.io/ct-toolkit/
|
|
9
|
+
Project-URL: Repository, https://github.com/Theseus-Guard/ct-toolkit
|
|
10
|
+
Project-URL: Issues, https://github.com/Theseus-Guard/ct-toolkit/issues
|
|
7
11
|
Keywords: llm,ai-safety,identity-continuity,guardrails,alignment
|
|
8
12
|
Requires-Python: <3.14,>=3.11
|
|
9
13
|
Description-Content-Type: text/markdown
|
|
10
14
|
License-File: LICENSE
|
|
11
|
-
Requires-Dist: instructor>=1.3.0
|
|
12
15
|
Requires-Dist: anyio>=4.14.2
|
|
13
16
|
Requires-Dist: litellm>=1.104.0
|
|
14
|
-
Requires-Dist: aiohttp>=3.14.
|
|
15
|
-
Requires-Dist: pillow>=11.3.0
|
|
17
|
+
Requires-Dist: aiohttp>=3.14.4
|
|
16
18
|
Requires-Dist: numpy>=1.26.0
|
|
17
19
|
Requires-Dist: pyyaml>=6.0
|
|
18
20
|
Requires-Dist: pydantic>=2.5.0
|
|
19
21
|
Requires-Dist: cryptography>=48.0.1
|
|
20
22
|
Requires-Dist: SQLAlchemy>=2.0.0
|
|
21
23
|
Requires-Dist: httpx>=0.27.0
|
|
22
|
-
Requires-Dist: rich>=13.0.0
|
|
23
24
|
Requires-Dist: jinja2>=3.1.0
|
|
24
25
|
Requires-Dist: pyasn1>=0.6.4
|
|
25
|
-
Requires-Dist: typer[all]>=0.12.0
|
|
26
|
-
Requires-Dist: fastapi>=0.110.0
|
|
27
|
-
Requires-Dist: starlette>=1.3.1
|
|
28
|
-
Requires-Dist: uvicorn>=0.29.0
|
|
29
|
-
Requires-Dist: langsmith>=0.8.18
|
|
30
26
|
Requires-Dist: urllib3>=2.8.0
|
|
31
27
|
Requires-Dist: idna>=3.15
|
|
28
|
+
Provides-Extra: server
|
|
29
|
+
Requires-Dist: fastapi>=0.110.0; extra == "server"
|
|
30
|
+
Requires-Dist: starlette>=1.3.1; extra == "server"
|
|
31
|
+
Requires-Dist: uvicorn>=0.29.0; extra == "server"
|
|
32
|
+
Provides-Extra: cli
|
|
33
|
+
Requires-Dist: rich>=13.0.0; extra == "cli"
|
|
34
|
+
Requires-Dist: typer[all]>=0.12.0; extra == "cli"
|
|
35
|
+
Provides-Extra: observability
|
|
36
|
+
Requires-Dist: opentelemetry-api>=1.25.0; extra == "observability"
|
|
37
|
+
Requires-Dist: opentelemetry-sdk>=1.25.0; extra == "observability"
|
|
38
|
+
Requires-Dist: langsmith>=0.8.18; extra == "observability"
|
|
39
|
+
Provides-Extra: structured
|
|
40
|
+
Requires-Dist: instructor>=1.3.0; extra == "structured"
|
|
41
|
+
Provides-Extra: vision
|
|
42
|
+
Requires-Dist: pillow>=11.3.0; extra == "vision"
|
|
43
|
+
Provides-Extra: postgres
|
|
44
|
+
Requires-Dist: psycopg[binary]>=3.1.0; extra == "postgres"
|
|
32
45
|
Provides-Extra: ollama
|
|
33
46
|
Requires-Dist: ollama>=0.2.0; extra == "ollama"
|
|
34
47
|
Provides-Extra: langchain
|
|
@@ -40,6 +53,16 @@ Requires-Dist: mkdocs-material>=9.7.7; extra == "docs"
|
|
|
40
53
|
Requires-Dist: pymdown-extensions>=10.21.3; extra == "docs"
|
|
41
54
|
Provides-Extra: ml
|
|
42
55
|
Requires-Dist: torch>=2.13.0; extra == "ml"
|
|
56
|
+
Requires-Dist: fastembed>=0.3.0; extra == "ml"
|
|
57
|
+
Provides-Extra: all
|
|
58
|
+
Requires-Dist: fastapi>=0.110.0; extra == "all"
|
|
59
|
+
Requires-Dist: starlette>=1.3.1; extra == "all"
|
|
60
|
+
Requires-Dist: uvicorn>=0.29.0; extra == "all"
|
|
61
|
+
Requires-Dist: rich>=13.0.0; extra == "all"
|
|
62
|
+
Requires-Dist: typer[all]>=0.12.0; extra == "all"
|
|
63
|
+
Requires-Dist: instructor>=1.3.0; extra == "all"
|
|
64
|
+
Requires-Dist: pillow>=11.3.0; extra == "all"
|
|
65
|
+
Requires-Dist: langsmith>=0.8.18; extra == "all"
|
|
43
66
|
Provides-Extra: dev
|
|
44
67
|
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
45
68
|
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
@@ -54,20 +77,61 @@ Dynamic: license-file
|
|
|
54
77
|
[](https://www.python.org/)
|
|
55
78
|
[](LICENSE)
|
|
56
79
|
[](https://pypi.org/project/ct-toolkit/)
|
|
57
|
-
[](https://
|
|
80
|
+
[](https://theseus-guard.github.io/ct-toolkit/)
|
|
58
81
|
[](https://pepy.tech/projects/ct-toolkit)
|
|
59
|
-
[](https://codecov.io/gh/Theseus-Guard/ct-toolkit)
|
|
60
83
|
|
|
61
84
|
CT Toolkit is an open-source security layer designed to preserve the **identity continuity** of AI agents over time. It implements the **Nested Agentic Architecture (NAA)** framework to prevent **Sequential Self-Compression (SSC)** in multi-agent hierarchies.
|
|
62
85
|
|
|
86
|
+
```text
|
|
87
|
+
$ ct-toolkit status
|
|
88
|
+
|
|
89
|
+
_______ _ _ ______ _____ ______ _ _ _____ _____ _ _ _____ _____
|
|
90
|
+
|__ __| | | | ____|/ ____| ____| | | |/ ____| / ____| | | | /\ | __ \| __ \
|
|
91
|
+
| | | |__| | |__ | (___ | |__ | | | | (___ | | __| | | | / \ | |__) | | | |
|
|
92
|
+
| | | __ | __| \___ \| __| | | | |\___ \ | | |_ | | | | / /\ \ | _ /| | | |
|
|
93
|
+
| | | | | | |____ ____) | |____| |__| |____) | | |__| | |__| |/ ____ \| | \ \| |__| |
|
|
94
|
+
|_| |_| |_|______|_____/|______|_____/|_____/ \_____|\____//_/ \_\_| \_\_____/
|
|
95
|
+
|
|
96
|
+
Computational Theseus Toolkit (CT Toolkit) v0.4.1
|
|
97
|
+
Identity Continuity Guardrails for Agentic Systems
|
|
98
|
+
|
|
99
|
+
╭──────────────────── CT Toolkit Audit & Telemetry Status ─────────────────────╮
|
|
100
|
+
│ Vault: ./ct_provenance.db (local) │
|
|
101
|
+
│ Chain Integrity: VALID (HMAC Verified) │
|
|
102
|
+
│ Verified Active Entries: 4 (showing last 4) │
|
|
103
|
+
│ Divergence Score (Avg / Max): 0.1525 / 0.3800 │
|
|
104
|
+
│ Head Hash: 9c64cb51a479c52c207b7fa8c3197a75... │
|
|
105
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
106
|
+
|
|
107
|
+
Divergence Tier Breakdown (L1 / L2 / L3)
|
|
108
|
+
┏━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┓
|
|
109
|
+
┃ Tier ┃ Count ┃ Share ┃
|
|
110
|
+
┡━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━┩
|
|
111
|
+
│ OK │ 1 │ 33.3% │
|
|
112
|
+
│ L1_WARNING │ 1 │ 33.3% │
|
|
113
|
+
│ L2_JUDGE │ 1 │ 33.3% │
|
|
114
|
+
│ L3_ICM │ 0 │ 0.0% │
|
|
115
|
+
└────────────┴───────┴───────┘
|
|
116
|
+
|
|
117
|
+
Staged Kernel Rules (Sandbox Cooldown)
|
|
118
|
+
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
|
|
119
|
+
┃ Endorsement ID ┃ Commitment ┃ Rule Text ┃ Status ┃
|
|
120
|
+
┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
|
|
121
|
+
│ end-9f8a7b6c │ fin_integrity_01 │ Require dual │ ACTIVE COOLDOWN │
|
|
122
|
+
│ │ │ sign-off for │ (1799s left) │
|
|
123
|
+
│ │ │ adjustments > $10k │ │
|
|
124
|
+
└────────────────┴──────────────────┴────────────────────┴─────────────────────┘
|
|
125
|
+
```
|
|
126
|
+
|
|
63
127
|
---
|
|
64
128
|
|
|
65
129
|
## 📖 Official Documentation
|
|
66
130
|
|
|
67
131
|
For full API reference, architecture details, examples, and integration guides, visit our documentation site:
|
|
68
|
-
👉 [**https://
|
|
132
|
+
👉 [**https://theseus-guard.github.io/ct-toolkit/**](https://theseus-guard.github.io/ct-toolkit/)
|
|
69
133
|
|
|
70
|
-
- [**Live Examples & Case Studies**](https://
|
|
134
|
+
- [**Live Examples & Case Studies**](https://theseus-guard.github.io/ct-toolkit/examples/): Real-world scenarios like Financial Auditor Integrity.
|
|
71
135
|
- [**FastAPI Integration Test Project**](https://github.com/hakandamar/ct-toolkit-fastapi): Reference FastAPI app for validating CT Toolkit end-to-end across L1/L2/L3 guardrails and provenance logs with local model infrastructure.
|
|
72
136
|
- [**Deep Agents Integration Test Project**](https://github.com/hakandamar/ct-toolkit-deep-agents): Reference Deep Agents app for validating CT Toolkit end-to-end with hierarchical agent workflows, L1/L2/L3 guardrails, and provenance logs.
|
|
73
137
|
|
|
@@ -77,21 +141,27 @@ For full API reference, architecture details, examples, and integration guides,
|
|
|
77
141
|
|
|
78
142
|
In complex agentic workflows, LLMs tend to "drift" from their original instructions. CT Toolkit provides the mathematical and cryptographic guardrails to ensure your agents remain aligned with their core constitution, even across deep hierarchies.
|
|
79
143
|
|
|
144
|
+
- **Async & Streaming Guardrails (`achat`)**: Native `async/await` and streaming (`stream=True`) support with non-blocking background execution for shadow requests and L3 ICM probes.
|
|
145
|
+
- **Contrastive Semantic L1 Engine**: Provider-independent embeddings (`litellm`, `ollama`, local `fastembed`) with positive/negative anchor analysis and semantic rule conflict detection.
|
|
80
146
|
- **Staged Approval (Cooldown)**: Verify risky kernel updates in a sandbox via shadow requests before production promotion.
|
|
81
147
|
- **Passive Context Compression Detection**: Automatically detects silent provider-side history compression (e.g., OpenAI/Anthropic).
|
|
82
|
-
- **Constitutional Kernels**: Axiomatic identity anchors.
|
|
83
|
-
- **Standalone Auditor CLI**: Rapidly audit any LLM endpoint
|
|
148
|
+
- **Constitutional Kernels & Distributed Propagation**: Axiomatic identity anchors with HMAC-SHA256 signed HTTP header propagation (`propagate_headers` / `from_headers`).
|
|
149
|
+
- **Standalone Auditor & Status CLI**: Rapidly audit any LLM endpoint (`ct-toolkit audit`) and inspect provenance integrity & divergence tiers (`ct-toolkit status` / `dashboard`).
|
|
84
150
|
- **Autonomous Self-Correction**: Active L2->L1 feedback loop that retries and corrects divergent responses before they reach the user.
|
|
85
|
-
- **
|
|
86
|
-
|
|
87
|
-
|
|
151
|
+
- **Enterprise Provenance & Observability**: Immutable HMAC-signed hash chain supporting SQLite and PostgreSQL/SQLAlchemy with paginated verification and OpenTelemetry (OTel) spans/metrics.
|
|
152
|
+
|
|
153
|
+

|
|
88
154
|
|
|
89
155
|
---
|
|
90
156
|
|
|
91
157
|
## Quick Start
|
|
92
158
|
|
|
93
159
|
```bash
|
|
160
|
+
# Core lightweight install
|
|
94
161
|
pip install ct-toolkit
|
|
162
|
+
|
|
163
|
+
# Or install with optional extras (cli, server, enterprise, embeddings, observability, all)
|
|
164
|
+
pip install "ct-toolkit[all]"
|
|
95
165
|
```
|
|
96
166
|
|
|
97
167
|
```python
|
|
@@ -103,18 +173,24 @@ config = WrapperConfig(compression_passive_detection=True)
|
|
|
103
173
|
# One-line injection for any LLM provider
|
|
104
174
|
client = TheseusWrapper(provider="openai", config=config)
|
|
105
175
|
|
|
106
|
-
#
|
|
176
|
+
# Sync or async (`await client.achat(...)`) with automatic drift analysis
|
|
107
177
|
response = client.chat("What are your core security axioms?")
|
|
108
178
|
|
|
109
179
|
print(response.content)
|
|
110
180
|
print(f"Divergence Score: {response.divergence_score}")
|
|
111
181
|
```
|
|
112
182
|
|
|
113
|
-
### 🔍 Standalone Auditor (CLI)
|
|
183
|
+
### 🔍 Standalone Auditor & Dashboard (CLI & Web UI)
|
|
114
184
|
|
|
115
|
-
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) directly from your terminal:
|
|
185
|
+
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) and inspect your provenance chain directly from your terminal or in the interactive Web Audit Dashboard:
|
|
116
186
|
|
|
117
187
|
```bash
|
|
188
|
+
# View Provenance Chain integrity, L1/L2/L3 tier breakdown, and staged rules in terminal
|
|
189
|
+
ct-toolkit status --vault ./ct_provenance.db
|
|
190
|
+
|
|
191
|
+
# Launch the interactive Web Audit & Telemetry Dashboard at http://127.0.0.1:8001/dashboard
|
|
192
|
+
ct-toolkit dashboard --web --vault ./ct_provenance.db --port 8001
|
|
193
|
+
|
|
118
194
|
# Audit a local Ollama model
|
|
119
195
|
ct-toolkit audit --url http://localhost:11434/v1 --kernel defense
|
|
120
196
|
|
|
@@ -142,10 +218,9 @@ The L2 judge does not evaluate Jinja2 expressions in user requests or model resp
|
|
|
142
218
|
|
|
143
219
|
| Metric | Status |
|
|
144
220
|
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
145
|
-
| **Tests** | ✅
|
|
221
|
+
| **Tests** | ✅ 426 passed, 3 skipped (100% success rate, 90%+ coverage) |
|
|
146
222
|
| **Downloads** | [](https://pepy.tech/projects/ct-toolkit) |
|
|
147
|
-
| **Last Phase** | ✅ v0.
|
|
148
|
-
| **Current Goal** | 🔶 Phase 7: Multi-Agent Synchronization (Integration) |
|
|
223
|
+
| **Last Phase** | ✅ v0.4.1: aiohttp 3.14.5 DoS/header-timeout/cookie-Secure fixes (Dependabot #74-76) |
|
|
149
224
|
|
|
150
225
|
### Framework & Model Support
|
|
151
226
|
|
|
@@ -1,52 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: ct-toolkit
|
|
3
|
-
Version: 0.3.40
|
|
4
|
-
Summary: Computational Theseus Toolkit — Identity Continuity Guardrails for Agentic Systems
|
|
5
|
-
Author: Hakan Damar
|
|
6
|
-
License: Apache-2.0
|
|
7
|
-
Keywords: llm,ai-safety,identity-continuity,guardrails,alignment
|
|
8
|
-
Requires-Python: <3.14,>=3.11
|
|
9
|
-
Description-Content-Type: text/markdown
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
Requires-Dist: instructor>=1.3.0
|
|
12
|
-
Requires-Dist: anyio>=4.14.2
|
|
13
|
-
Requires-Dist: litellm>=1.104.0
|
|
14
|
-
Requires-Dist: aiohttp>=3.14.3
|
|
15
|
-
Requires-Dist: pillow>=11.3.0
|
|
16
|
-
Requires-Dist: numpy>=1.26.0
|
|
17
|
-
Requires-Dist: pyyaml>=6.0
|
|
18
|
-
Requires-Dist: pydantic>=2.5.0
|
|
19
|
-
Requires-Dist: cryptography>=48.0.1
|
|
20
|
-
Requires-Dist: SQLAlchemy>=2.0.0
|
|
21
|
-
Requires-Dist: httpx>=0.27.0
|
|
22
|
-
Requires-Dist: rich>=13.0.0
|
|
23
|
-
Requires-Dist: jinja2>=3.1.0
|
|
24
|
-
Requires-Dist: pyasn1>=0.6.4
|
|
25
|
-
Requires-Dist: typer[all]>=0.12.0
|
|
26
|
-
Requires-Dist: fastapi>=0.110.0
|
|
27
|
-
Requires-Dist: starlette>=1.3.1
|
|
28
|
-
Requires-Dist: uvicorn>=0.29.0
|
|
29
|
-
Requires-Dist: langsmith>=0.8.18
|
|
30
|
-
Requires-Dist: urllib3>=2.8.0
|
|
31
|
-
Requires-Dist: idna>=3.15
|
|
32
|
-
Provides-Extra: ollama
|
|
33
|
-
Requires-Dist: ollama>=0.2.0; extra == "ollama"
|
|
34
|
-
Provides-Extra: langchain
|
|
35
|
-
Requires-Dist: langchain-core>=1.3.3; extra == "langchain"
|
|
36
|
-
Provides-Extra: autogen
|
|
37
|
-
Requires-Dist: pyautogen>=0.4.0; extra == "autogen"
|
|
38
|
-
Provides-Extra: docs
|
|
39
|
-
Requires-Dist: mkdocs-material>=9.7.7; extra == "docs"
|
|
40
|
-
Requires-Dist: pymdown-extensions>=10.21.3; extra == "docs"
|
|
41
|
-
Provides-Extra: ml
|
|
42
|
-
Requires-Dist: torch>=2.13.0; extra == "ml"
|
|
43
|
-
Provides-Extra: dev
|
|
44
|
-
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
45
|
-
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
46
|
-
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
47
|
-
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
48
|
-
Dynamic: license-file
|
|
49
|
-
|
|
50
1
|
# Computational Theseus Toolkit (CT Toolkit)
|
|
51
2
|
|
|
52
3
|
> **Identity Continuity Guardrails for Agentic Systems**
|
|
@@ -54,20 +5,61 @@ Dynamic: license-file
|
|
|
54
5
|
[](https://www.python.org/)
|
|
55
6
|
[](LICENSE)
|
|
56
7
|
[](https://pypi.org/project/ct-toolkit/)
|
|
57
|
-
[](https://
|
|
8
|
+
[](https://theseus-guard.github.io/ct-toolkit/)
|
|
58
9
|
[](https://pepy.tech/projects/ct-toolkit)
|
|
59
|
-
[](https://codecov.io/gh/Theseus-Guard/ct-toolkit)
|
|
60
11
|
|
|
61
12
|
CT Toolkit is an open-source security layer designed to preserve the **identity continuity** of AI agents over time. It implements the **Nested Agentic Architecture (NAA)** framework to prevent **Sequential Self-Compression (SSC)** in multi-agent hierarchies.
|
|
62
13
|
|
|
14
|
+
```text
|
|
15
|
+
$ ct-toolkit status
|
|
16
|
+
|
|
17
|
+
_______ _ _ ______ _____ ______ _ _ _____ _____ _ _ _____ _____
|
|
18
|
+
|__ __| | | | ____|/ ____| ____| | | |/ ____| / ____| | | | /\ | __ \| __ \
|
|
19
|
+
| | | |__| | |__ | (___ | |__ | | | | (___ | | __| | | | / \ | |__) | | | |
|
|
20
|
+
| | | __ | __| \___ \| __| | | | |\___ \ | | |_ | | | | / /\ \ | _ /| | | |
|
|
21
|
+
| | | | | | |____ ____) | |____| |__| |____) | | |__| | |__| |/ ____ \| | \ \| |__| |
|
|
22
|
+
|_| |_| |_|______|_____/|______|_____/|_____/ \_____|\____//_/ \_\_| \_\_____/
|
|
23
|
+
|
|
24
|
+
Computational Theseus Toolkit (CT Toolkit) v0.4.1
|
|
25
|
+
Identity Continuity Guardrails for Agentic Systems
|
|
26
|
+
|
|
27
|
+
╭──────────────────── CT Toolkit Audit & Telemetry Status ─────────────────────╮
|
|
28
|
+
│ Vault: ./ct_provenance.db (local) │
|
|
29
|
+
│ Chain Integrity: VALID (HMAC Verified) │
|
|
30
|
+
│ Verified Active Entries: 4 (showing last 4) │
|
|
31
|
+
│ Divergence Score (Avg / Max): 0.1525 / 0.3800 │
|
|
32
|
+
│ Head Hash: 9c64cb51a479c52c207b7fa8c3197a75... │
|
|
33
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
34
|
+
|
|
35
|
+
Divergence Tier Breakdown (L1 / L2 / L3)
|
|
36
|
+
┏━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┓
|
|
37
|
+
┃ Tier ┃ Count ┃ Share ┃
|
|
38
|
+
┡━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━┩
|
|
39
|
+
│ OK │ 1 │ 33.3% │
|
|
40
|
+
│ L1_WARNING │ 1 │ 33.3% │
|
|
41
|
+
│ L2_JUDGE │ 1 │ 33.3% │
|
|
42
|
+
│ L3_ICM │ 0 │ 0.0% │
|
|
43
|
+
└────────────┴───────┴───────┘
|
|
44
|
+
|
|
45
|
+
Staged Kernel Rules (Sandbox Cooldown)
|
|
46
|
+
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
|
|
47
|
+
┃ Endorsement ID ┃ Commitment ┃ Rule Text ┃ Status ┃
|
|
48
|
+
┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
|
|
49
|
+
│ end-9f8a7b6c │ fin_integrity_01 │ Require dual │ ACTIVE COOLDOWN │
|
|
50
|
+
│ │ │ sign-off for │ (1799s left) │
|
|
51
|
+
│ │ │ adjustments > $10k │ │
|
|
52
|
+
└────────────────┴──────────────────┴────────────────────┴─────────────────────┘
|
|
53
|
+
```
|
|
54
|
+
|
|
63
55
|
---
|
|
64
56
|
|
|
65
57
|
## 📖 Official Documentation
|
|
66
58
|
|
|
67
59
|
For full API reference, architecture details, examples, and integration guides, visit our documentation site:
|
|
68
|
-
👉 [**https://
|
|
60
|
+
👉 [**https://theseus-guard.github.io/ct-toolkit/**](https://theseus-guard.github.io/ct-toolkit/)
|
|
69
61
|
|
|
70
|
-
- [**Live Examples & Case Studies**](https://
|
|
62
|
+
- [**Live Examples & Case Studies**](https://theseus-guard.github.io/ct-toolkit/examples/): Real-world scenarios like Financial Auditor Integrity.
|
|
71
63
|
- [**FastAPI Integration Test Project**](https://github.com/hakandamar/ct-toolkit-fastapi): Reference FastAPI app for validating CT Toolkit end-to-end across L1/L2/L3 guardrails and provenance logs with local model infrastructure.
|
|
72
64
|
- [**Deep Agents Integration Test Project**](https://github.com/hakandamar/ct-toolkit-deep-agents): Reference Deep Agents app for validating CT Toolkit end-to-end with hierarchical agent workflows, L1/L2/L3 guardrails, and provenance logs.
|
|
73
65
|
|
|
@@ -77,21 +69,27 @@ For full API reference, architecture details, examples, and integration guides,
|
|
|
77
69
|
|
|
78
70
|
In complex agentic workflows, LLMs tend to "drift" from their original instructions. CT Toolkit provides the mathematical and cryptographic guardrails to ensure your agents remain aligned with their core constitution, even across deep hierarchies.
|
|
79
71
|
|
|
72
|
+
- **Async & Streaming Guardrails (`achat`)**: Native `async/await` and streaming (`stream=True`) support with non-blocking background execution for shadow requests and L3 ICM probes.
|
|
73
|
+
- **Contrastive Semantic L1 Engine**: Provider-independent embeddings (`litellm`, `ollama`, local `fastembed`) with positive/negative anchor analysis and semantic rule conflict detection.
|
|
80
74
|
- **Staged Approval (Cooldown)**: Verify risky kernel updates in a sandbox via shadow requests before production promotion.
|
|
81
75
|
- **Passive Context Compression Detection**: Automatically detects silent provider-side history compression (e.g., OpenAI/Anthropic).
|
|
82
|
-
- **Constitutional Kernels**: Axiomatic identity anchors.
|
|
83
|
-
- **Standalone Auditor CLI**: Rapidly audit any LLM endpoint
|
|
76
|
+
- **Constitutional Kernels & Distributed Propagation**: Axiomatic identity anchors with HMAC-SHA256 signed HTTP header propagation (`propagate_headers` / `from_headers`).
|
|
77
|
+
- **Standalone Auditor & Status CLI**: Rapidly audit any LLM endpoint (`ct-toolkit audit`) and inspect provenance integrity & divergence tiers (`ct-toolkit status` / `dashboard`).
|
|
84
78
|
- **Autonomous Self-Correction**: Active L2->L1 feedback loop that retries and corrects divergent responses before they reach the user.
|
|
85
|
-
- **
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
- **Enterprise Provenance & Observability**: Immutable HMAC-signed hash chain supporting SQLite and PostgreSQL/SQLAlchemy with paginated verification and OpenTelemetry (OTel) spans/metrics.
|
|
80
|
+
|
|
81
|
+

|
|
88
82
|
|
|
89
83
|
---
|
|
90
84
|
|
|
91
85
|
## Quick Start
|
|
92
86
|
|
|
93
87
|
```bash
|
|
88
|
+
# Core lightweight install
|
|
94
89
|
pip install ct-toolkit
|
|
90
|
+
|
|
91
|
+
# Or install with optional extras (cli, server, enterprise, embeddings, observability, all)
|
|
92
|
+
pip install "ct-toolkit[all]"
|
|
95
93
|
```
|
|
96
94
|
|
|
97
95
|
```python
|
|
@@ -103,18 +101,24 @@ config = WrapperConfig(compression_passive_detection=True)
|
|
|
103
101
|
# One-line injection for any LLM provider
|
|
104
102
|
client = TheseusWrapper(provider="openai", config=config)
|
|
105
103
|
|
|
106
|
-
#
|
|
104
|
+
# Sync or async (`await client.achat(...)`) with automatic drift analysis
|
|
107
105
|
response = client.chat("What are your core security axioms?")
|
|
108
106
|
|
|
109
107
|
print(response.content)
|
|
110
108
|
print(f"Divergence Score: {response.divergence_score}")
|
|
111
109
|
```
|
|
112
110
|
|
|
113
|
-
### 🔍 Standalone Auditor (CLI)
|
|
111
|
+
### 🔍 Standalone Auditor & Dashboard (CLI & Web UI)
|
|
114
112
|
|
|
115
|
-
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) directly from your terminal:
|
|
113
|
+
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) and inspect your provenance chain directly from your terminal or in the interactive Web Audit Dashboard:
|
|
116
114
|
|
|
117
115
|
```bash
|
|
116
|
+
# View Provenance Chain integrity, L1/L2/L3 tier breakdown, and staged rules in terminal
|
|
117
|
+
ct-toolkit status --vault ./ct_provenance.db
|
|
118
|
+
|
|
119
|
+
# Launch the interactive Web Audit & Telemetry Dashboard at http://127.0.0.1:8001/dashboard
|
|
120
|
+
ct-toolkit dashboard --web --vault ./ct_provenance.db --port 8001
|
|
121
|
+
|
|
118
122
|
# Audit a local Ollama model
|
|
119
123
|
ct-toolkit audit --url http://localhost:11434/v1 --kernel defense
|
|
120
124
|
|
|
@@ -142,10 +146,9 @@ The L2 judge does not evaluate Jinja2 expressions in user requests or model resp
|
|
|
142
146
|
|
|
143
147
|
| Metric | Status |
|
|
144
148
|
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
145
|
-
| **Tests** | ✅
|
|
149
|
+
| **Tests** | ✅ 426 passed, 3 skipped (100% success rate, 90%+ coverage) |
|
|
146
150
|
| **Downloads** | [](https://pepy.tech/projects/ct-toolkit) |
|
|
147
|
-
| **Last Phase** | ✅ v0.
|
|
148
|
-
| **Current Goal** | 🔶 Phase 7: Multi-Agent Synchronization (Integration) |
|
|
151
|
+
| **Last Phase** | ✅ v0.4.1: aiohttp 3.14.5 DoS/header-timeout/cookie-Secure fixes (Dependabot #74-76) |
|
|
149
152
|
|
|
150
153
|
### Framework & Model Support
|
|
151
154
|
|
|
@@ -12,7 +12,7 @@ Identity Continuity Guardrails for LLM Systems.
|
|
|
12
12
|
print(response.content)
|
|
13
13
|
print(response.divergence_score)
|
|
14
14
|
"""
|
|
15
|
-
from ct_toolkit.core.wrapper import TheseusWrapper, WrapperConfig, CTResponse
|
|
15
|
+
from ct_toolkit.core.wrapper import TheseusWrapper, WrapperConfig, CTResponse, CTStreamChunk
|
|
16
16
|
from ct_toolkit.core.kernel import ConstitutionalKernel
|
|
17
17
|
from ct_toolkit.core.compatibility import CompatibilityLayer
|
|
18
18
|
from ct_toolkit.core.exceptions import (
|
|
@@ -23,12 +23,13 @@ from ct_toolkit.core.exceptions import (
|
|
|
23
23
|
ChainIntegrityError,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
__version__ = "0.
|
|
26
|
+
__version__ = "0.4.1"
|
|
27
27
|
|
|
28
28
|
__all__ = [
|
|
29
29
|
"TheseusWrapper",
|
|
30
30
|
"WrapperConfig",
|
|
31
31
|
"CTResponse",
|
|
32
|
+
"CTStreamChunk",
|
|
32
33
|
"ConstitutionalKernel",
|
|
33
34
|
"CompatibilityLayer",
|
|
34
35
|
"AxiomaticViolationError",
|