sentrix 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.
Files changed (56) hide show
  1. sentrix-0.1.0/.github/workflows/docs.yml +26 -0
  2. sentrix-0.1.0/.github/workflows/publish.yml +29 -0
  3. sentrix-0.1.0/.github/workflows/tests.yml +40 -0
  4. sentrix-0.1.0/.gitignore +14 -0
  5. sentrix-0.1.0/PKG-INFO +336 -0
  6. sentrix-0.1.0/README.md +302 -0
  7. sentrix-0.1.0/docs/auto-dataset.md +52 -0
  8. sentrix-0.1.0/docs/ci.md +38 -0
  9. sentrix-0.1.0/docs/dashboard.md +22 -0
  10. sentrix-0.1.0/docs/eval.md +51 -0
  11. sentrix-0.1.0/docs/fingerprint.md +41 -0
  12. sentrix-0.1.0/docs/guard.md +50 -0
  13. sentrix-0.1.0/docs/images/dashboard.svg +165 -0
  14. sentrix-0.1.0/docs/images/heatmap.svg +106 -0
  15. sentrix-0.1.0/docs/images/red-team-report.svg +44 -0
  16. sentrix-0.1.0/docs/index.md +84 -0
  17. sentrix-0.1.0/docs/monitor.md +33 -0
  18. sentrix-0.1.0/docs/quickstart.md +76 -0
  19. sentrix-0.1.0/mkdocs.yml +69 -0
  20. sentrix-0.1.0/pyproject.toml +55 -0
  21. sentrix-0.1.0/sentrix/__init__.py +131 -0
  22. sentrix-0.1.0/sentrix/cli.py +396 -0
  23. sentrix-0.1.0/sentrix/compliance/__init__.py +4 -0
  24. sentrix-0.1.0/sentrix/compliance/reporter.py +344 -0
  25. sentrix-0.1.0/sentrix/db.py +251 -0
  26. sentrix-0.1.0/sentrix/eval/__init__.py +15 -0
  27. sentrix-0.1.0/sentrix/eval/compare.py +230 -0
  28. sentrix-0.1.0/sentrix/eval/dataset.py +143 -0
  29. sentrix-0.1.0/sentrix/eval/experiment.py +288 -0
  30. sentrix-0.1.0/sentrix/eval/scorers.py +199 -0
  31. sentrix-0.1.0/sentrix/git_tracker.py +212 -0
  32. sentrix-0.1.0/sentrix/guard/__init__.py +14 -0
  33. sentrix-0.1.0/sentrix/guard/agent.py +239 -0
  34. sentrix-0.1.0/sentrix/guard/attacks.py +188 -0
  35. sentrix-0.1.0/sentrix/guard/auto_dataset.py +113 -0
  36. sentrix-0.1.0/sentrix/guard/fingerprint.py +213 -0
  37. sentrix-0.1.0/sentrix/guard/rag_scanner.py +217 -0
  38. sentrix-0.1.0/sentrix/guard/red_team.py +278 -0
  39. sentrix-0.1.0/sentrix/interceptor.py +119 -0
  40. sentrix-0.1.0/sentrix/monitor/__init__.py +5 -0
  41. sentrix-0.1.0/sentrix/monitor/daemon.py +132 -0
  42. sentrix-0.1.0/sentrix/monitor/drift.py +249 -0
  43. sentrix-0.1.0/sentrix/monitor/tracer.py +178 -0
  44. sentrix-0.1.0/sentrix/plugins/__init__.py +4 -0
  45. sentrix-0.1.0/sentrix/plugins/registry.py +138 -0
  46. sentrix-0.1.0/sentrix/pricing.py +103 -0
  47. sentrix-0.1.0/sentrix/providers.py +146 -0
  48. sentrix-0.1.0/sentrix/review/__init__.py +4 -0
  49. sentrix-0.1.0/sentrix/review/annotations.py +193 -0
  50. sentrix-0.1.0/sentrix/server/__init__.py +1 -0
  51. sentrix-0.1.0/sentrix/server/app.py +306 -0
  52. sentrix-0.1.0/tests/conftest.py +40 -0
  53. sentrix-0.1.0/tests/test_eval.py +140 -0
  54. sentrix-0.1.0/tests/test_git_tracker.py +55 -0
  55. sentrix-0.1.0/tests/test_guard.py +177 -0
  56. sentrix-0.1.0/tests/test_monitor.py +90 -0
@@ -0,0 +1,26 @@
1
+ name: Deploy Docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ deploy:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.11"
21
+
22
+ - name: Install MkDocs
23
+ run: pip install mkdocs-material
24
+
25
+ - name: Deploy docs
26
+ run: mkdocs gh-deploy --force
@@ -0,0 +1,29 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ environment: pypi
11
+ permissions:
12
+ id-token: write
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.11"
21
+
22
+ - name: Install build tools
23
+ run: pip install hatch build
24
+
25
+ - name: Build package
26
+ run: python -m build
27
+
28
+ - name: Publish to PyPI
29
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,40 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ pip install -e ".[eval]"
27
+ pip install pytest pytest-cov ruff
28
+
29
+ - name: Lint
30
+ run: ruff check sentrix/
31
+
32
+ - name: Run tests
33
+ run: pytest tests/ -v --tb=short --cov=sentrix --cov-report=xml
34
+
35
+ - name: Upload coverage
36
+ uses: codecov/codecov-action@v4
37
+ if: matrix.python-version == '3.11'
38
+ with:
39
+ file: ./coverage.xml
40
+ fail_ci_if_error: false
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ venv/
8
+ .env
9
+ *.db
10
+ .pytest_cache/
11
+ .coverage
12
+ coverage.xml
13
+ site/
14
+ .DS_Store
sentrix-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,336 @@
1
+ Metadata-Version: 2.4
2
+ Name: sentrix
3
+ Version: 0.1.0
4
+ Summary: Red-team, eval, and monitor your LLMs. Security-first, Python-native.
5
+ Project-URL: Homepage, https://github.com/pinexai/sentrix
6
+ Project-URL: Documentation, https://pinexai.github.io/sentrix
7
+ Project-URL: Repository, https://github.com/pinexai/sentrix
8
+ Project-URL: Issues, https://github.com/pinexai/sentrix/issues
9
+ License: MIT
10
+ Keywords: ai,eval,jailbreak,llm,observability,red-team,safety,security
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Security
20
+ Requires-Python: >=3.10
21
+ Provides-Extra: eval
22
+ Requires-Dist: jsonschema>=4.0; extra == 'eval'
23
+ Provides-Extra: full
24
+ Requires-Dist: fastapi>=0.100; extra == 'full'
25
+ Requires-Dist: jsonschema>=4.0; extra == 'full'
26
+ Requires-Dist: sentence-transformers>=2.0; extra == 'full'
27
+ Requires-Dist: uvicorn>=0.20; extra == 'full'
28
+ Requires-Dist: websockets>=11.0; extra == 'full'
29
+ Provides-Extra: server
30
+ Requires-Dist: fastapi>=0.100; extra == 'server'
31
+ Requires-Dist: uvicorn>=0.20; extra == 'server'
32
+ Requires-Dist: websockets>=11.0; extra == 'server'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # sentrix — LLM Security Testing
36
+
37
+ <p align="center">
38
+ <a href="https://pypi.org/project/sentrix/"><img src="https://img.shields.io/pypi/v/sentrix?color=blueviolet" alt="PyPI"></a>
39
+ <a href="https://pypi.org/project/sentrix/"><img src="https://img.shields.io/pypi/pyversions/sentrix?color=blueviolet" alt="Python"></a>
40
+ <a href="https://github.com/pinexai/sentrix/actions/workflows/tests.yml"><img src="https://img.shields.io/github/actions/workflow/status/pinexai/sentrix/tests.yml?label=tests" alt="Tests"></a>
41
+ <a href="https://github.com/pinexai/sentrix/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blueviolet" alt="MIT license"></a>
42
+ <img src="https://img.shields.io/badge/zero-dependencies-brightgreen" alt="zero deps">
43
+ </p>
44
+
45
+ <p align="center">
46
+ <b>Red-team, fingerprint, and monitor your LLMs — pure Python, zero config.</b><br>
47
+ Find vulnerabilities before your users do.
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://pinexai.github.io/sentrix/">Documentation</a> ·
52
+ <a href="https://pinexai.github.io/sentrix/quickstart/">Quick Start</a> ·
53
+ <a href="https://pinexai.github.io/sentrix/guard/">Red Teaming</a> ·
54
+ <a href="https://pinexai.github.io/sentrix/fingerprint/">Attack Heatmap</a> ·
55
+ <a href="https://github.com/pinexai/sentrix/issues">Issues</a>
56
+ </p>
57
+
58
+ ---
59
+
60
+ ## What is sentrix?
61
+
62
+ `sentrix` is a Python-native LLM security suite. In one `pip install`, you get automated red teaming, vulnerability fingerprinting across models, adversarial test generation, compliance reporting, and production monitoring — with a local SQLite store and a built-in dashboard. No YAML. No Node.js.
63
+
64
+ **Here's what the attack heatmap looks like:**
65
+
66
+ <p align="center">
67
+ <img src="docs/images/heatmap.svg" alt="sentrix attack heatmap — vulnerability matrix across models and attack plugins" width="720">
68
+ </p>
69
+
70
+ **And the web dashboard:**
71
+
72
+ <p align="center">
73
+ <img src="docs/images/dashboard.svg" alt="sentrix web dashboard — 7-tab real-time security monitoring" width="760">
74
+ </p>
75
+
76
+ **Red team report from the CLI:**
77
+
78
+ <p align="center">
79
+ <img src="docs/images/red-team-report.svg" alt="sentrix red team report output" width="680">
80
+ </p>
81
+
82
+ ---
83
+
84
+ ## Quick Start
85
+
86
+ ```bash
87
+ pip install sentrix
88
+ ```
89
+
90
+ ```python
91
+ import sentrix
92
+
93
+ sentrix.init() # enable SQLite persistence + SDK cost tracking
94
+
95
+ def my_chatbot(prompt: str) -> str:
96
+ return call_llm(prompt)
97
+
98
+ # Red team your chatbot
99
+ report = sentrix.red_team(my_chatbot, plugins=["jailbreak", "pii", "harmful"])
100
+ report.summary()
101
+ ```
102
+
103
+ Or from the CLI:
104
+
105
+ ```bash
106
+ sentrix scan myapp:chatbot --plugins jailbreak,pii,harmful --n 20
107
+ sentrix serve # open dashboard at localhost:7234
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Three killer features
113
+
114
+ ### 1. Auto-generate adversarial test cases
115
+
116
+ No manual test writing. sentrix reads your function's signature and docstring, calls an LLM, and generates N test cases covering jailbreaks, PII extraction, injection attacks, and normal usage.
117
+
118
+ ```python
119
+ def my_chatbot(message: str) -> str:
120
+ """Answer user questions helpfully and safely. Refuse harmful requests."""
121
+ ...
122
+
123
+ ds = sentrix.auto_dataset(my_chatbot, n=50, focus="adversarial")
124
+ # → 50 test cases generated for free
125
+ print(f"Generated {len(ds)} test cases")
126
+ ```
127
+
128
+ ### 2. Attack heatmap across models
129
+
130
+ Run the full attack suite against multiple models simultaneously. Get a vulnerability fingerprint showing exactly which attack categories break which models — so you can pick the cheapest safe option.
131
+
132
+ ```python
133
+ fp = sentrix.guard.fingerprint({
134
+ "gpt-4o-mini": gpt_fn,
135
+ "claude-haiku": claude_fn,
136
+ "llama-3": llama_fn,
137
+ }, plugins=["jailbreak", "pii", "harmful", "hallucination", "injection"])
138
+
139
+ fp.heatmap()
140
+ print(f"Safest model: {fp.safest_model()}")
141
+ print(f"Most vulnerable: {fp.most_vulnerable_model()}")
142
+ ```
143
+
144
+ ### 3. Git-aware CI security gates
145
+
146
+ Every scan is tagged with the git commit SHA. Block PRs if the vulnerability rate regresses vs. `main`.
147
+
148
+ ```bash
149
+ sentrix scan myapp:chatbot --git-compare main --fail-on-regression
150
+ # → exits 1 if vuln rate increased by >5% vs main branch
151
+ # → writes summary to $GITHUB_STEP_SUMMARY
152
+ ```
153
+
154
+ ```yaml
155
+ # .github/workflows/security.yml
156
+ - run: sentrix scan myapp:chatbot --git-compare origin/main --fail-on-regression
157
+ env:
158
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Attack plugins
164
+
165
+ | Plugin | What it probes |
166
+ |---|---|
167
+ | `jailbreak` | Role-play overrides, DAN variants, persona jailbreaks |
168
+ | `pii` | PII extraction, system prompt leakage, training data fishing |
169
+ | `harmful` | Dangerous information, CBRN, illegal activity requests |
170
+ | `hallucination` | False premises, leading questions, factual traps |
171
+ | `injection` | Indirect prompt injection via user-controlled data |
172
+ | `competitor` | Brand manipulation, competitor endorsement attacks |
173
+
174
+ All plugins ship 15–20 templates each. Community plugins via `sentrix plugin install <name>`.
175
+
176
+ ---
177
+
178
+ ## Evaluation & monitoring
179
+
180
+ ```python
181
+ # Evaluate quality with 9 built-in scorers
182
+ ds = sentrix.dataset("qa-suite")
183
+ ds.add(input="What is 2+2?", expected_output="4")
184
+
185
+ exp = sentrix.experiment(
186
+ "math-eval",
187
+ dataset=ds,
188
+ fn=my_chatbot,
189
+ scorers=[sentrix.scorers.exact_match, sentrix.scorers.no_pii],
190
+ )
191
+ results = exp.run(pass_threshold=0.8)
192
+ results.summary()
193
+
194
+ # Compare models — Pareto frontier included
195
+ comparison = sentrix.compare_models(
196
+ models={"gpt-4o-mini": gpt_fn, "claude-haiku": claude_fn},
197
+ dataset=ds,
198
+ scorers=[sentrix.scorers.llm_judge(criteria="accuracy")],
199
+ )
200
+ comparison.summary() # → shows Pareto frontier + best value model
201
+
202
+ # Production tracing
203
+ with sentrix.trace("user-request", input=user_msg, user_id="u123") as t:
204
+ response = my_chatbot(user_msg)
205
+ t.output = response
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Compliance reports
211
+
212
+ Generate audit-ready reports mapped to OWASP LLM Top 10, NIST AI RMF, EU AI Act, and SOC2 — automatically evidence-linked to your red team scan results.
213
+
214
+ ```bash
215
+ sentrix compliance --framework owasp_llm_top10 --output report.html
216
+ sentrix compliance --framework eu_ai_act --output audit.html
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Supply chain & RAG security
222
+
223
+ Scan your RAG document corpus for poisoned inputs, PII leakage, and system prompt tampering — zero LLM calls required, pure regex pattern matching.
224
+
225
+ ```python
226
+ from sentrix.guard.rag_scanner import scan_rag
227
+
228
+ report = scan_rag(
229
+ documents=my_docs,
230
+ system_prompt=my_system_prompt,
231
+ baseline_hash="abc123...", # tamper detection
232
+ )
233
+ report.summary()
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Why sentrix over promptfoo?
239
+
240
+ | | **sentrix** | promptfoo |
241
+ |---|---|---|
242
+ | Language | **Python** (pip install) | TypeScript (npm install) |
243
+ | Configuration | **Zero config** | YAML required |
244
+ | Attack heatmap across models | **✅** | ❌ |
245
+ | Auto test generation from fn signature | **✅** | ❌ |
246
+ | Git-aware regression tracking | **✅** | ❌ |
247
+ | Cost tracking per scan | **✅** | ❌ |
248
+ | Production monitoring + tracing | **✅** | ❌ |
249
+ | RAG supply chain security | **✅** | ❌ |
250
+ | Human review + annotation queue | **✅** | ❌ |
251
+ | Compliance reports (OWASP / NIST / EU AI Act) | **✅** | ❌ |
252
+ | Community plugin ecosystem | **✅** | Limited |
253
+ | Offline / privacy mode (Ollama) | **✅** | ❌ |
254
+ | Local SQLite — no external backend | **✅** | ❌ |
255
+ | Built-in web dashboard | **✅** | Limited |
256
+
257
+ ---
258
+
259
+ ## Install options
260
+
261
+ ```bash
262
+ pip install sentrix # core — zero required dependencies
263
+ pip install sentrix[server] # + FastAPI dashboard (sentrix serve)
264
+ pip install sentrix[eval] # + JSON schema validation scorer
265
+ pip install sentrix[full] # everything
266
+ ```
267
+
268
+ **LLM providers** — install only what you use:
269
+
270
+ ```bash
271
+ pip install openai # for OpenAI models
272
+ pip install anthropic # for Claude models
273
+ pip install google-generativeai # for Gemini models
274
+ # offline: ollama pull llama3 # no API key needed
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Full CLI reference
280
+
281
+ ```bash
282
+ # Security scanning
283
+ sentrix scan myapp:chatbot # red team
284
+ sentrix scan myapp:chatbot --plugins all --n 50 # full scan
285
+ sentrix scan myapp:chatbot --git-compare main # + regression gate
286
+ sentrix fingerprint myapp:gpt_fn myapp:claude_fn # attack heatmap
287
+
288
+ # Test generation
289
+ sentrix auto-dataset myapp:chatbot --n 50 --focus adversarial
290
+
291
+ # Evaluation
292
+ sentrix eval run experiment.py --fail-below 0.8
293
+
294
+ # Security for agents & RAG
295
+ sentrix scan-agent myapp:my_agent
296
+ sentrix scan-rag --docs ./data/ --system-prompt prompt.txt
297
+
298
+ # Compliance
299
+ sentrix compliance --framework owasp_llm_top10 --output report.html
300
+
301
+ # Monitoring
302
+ sentrix monitor watch myapp:chatbot --interval 60 --webhook $SLACK_URL
303
+ sentrix monitor drift --baseline my-eval --window 24
304
+
305
+ # Plugin ecosystem
306
+ sentrix plugin list
307
+ sentrix plugin install advanced-jailbreak
308
+
309
+ # Dashboard & info
310
+ sentrix serve # open at :7234
311
+ sentrix history # past scans
312
+ sentrix costs --days 7 # cost breakdown
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Learn more
318
+
319
+ - [Quick Start](https://pinexai.github.io/sentrix/quickstart/)
320
+ - [Red Teaming Guide](https://pinexai.github.io/sentrix/guard/)
321
+ - [Attack Heatmap](https://pinexai.github.io/sentrix/fingerprint/)
322
+ - [Auto Test Generation](https://pinexai.github.io/sentrix/auto-dataset/)
323
+ - [Evaluation Framework](https://pinexai.github.io/sentrix/eval/)
324
+ - [Production Monitoring](https://pinexai.github.io/sentrix/monitor/)
325
+ - [CI/CD Integration](https://pinexai.github.io/sentrix/ci/)
326
+ - [Dashboard Guide](https://pinexai.github.io/sentrix/dashboard/)
327
+
328
+ ---
329
+
330
+ ## Contributing
331
+
332
+ Issues and PRs welcome. See [github.com/pinexai/sentrix](https://github.com/pinexai/sentrix).
333
+
334
+ ---
335
+
336
+ <p align="center">MIT license · Built by <a href="https://github.com/pinexai">pinexai</a></p>