swt3-ai 0.6.4 → 0.6.5
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.
- checksums.yaml +4 -4
- data/README.md +164 -24
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e1defaa0689d6035a9d6a27cc2b286838d45ff2caeb1574e04647c9d1aecd2d
|
|
4
|
+
data.tar.gz: f33f1e1ed8ec0428ef8074762135d014201d4941c8f3fb5f3547f115085a9a67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ce3f5e29bfd56858dcd84eedfcda6b3b31940f6277132a4f7c105d509cf12ccce34328d889f713f20c94046842b6fe68638304d22d9fccef89956a805e5c2ba
|
|
7
|
+
data.tar.gz: 2fda1b6a1e9eda682e740fe10a87ed1b4fbf1f9ef5df3c6d2926bd05d10d97dc24cf0c1a2c4cd1d8d5903949f73a235359379750b531702fbaad6ceedb257d29
|
data/README.md
CHANGED
|
@@ -1,44 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
Add cryptographic compliance evidence to existing Ruby applications. Three lines of code. Zero external dependencies.
|
|
2
2
|
|
|
3
3
|
[](https://rubygems.org/gems/swt3-ai)
|
|
4
4
|
[](https://github.com/tenova-labs/swt3-ai/blob/main/LICENSE)
|
|
5
5
|
|
|
6
6
|
# swt3-ai
|
|
7
7
|
|
|
8
|
-
**SWT3 AI Witness SDK for Ruby**: mint, verify, and sign SWT3 witness anchors with cross-language parity.
|
|
8
|
+
**SWT3 AI Witness SDK for Ruby**: mint, verify, and sign SWT3 witness anchors with cross-language parity. Uses only `openssl` from the standard library. No native extensions, no C bindings, no dependency risk.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Built for platform engineers who need to bolt compliance witnessing onto production Rails apps, Sidekiq workers, Grape APIs, or any Ruby service that touches AI. Your Python team trains the model; your Ruby infrastructure serves it, monitors it, and proves it followed the rules. When a model drifts at 2am, the anchor chain tells you which model version, which pipeline deployed it, and which policy approved it.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
EU AI Act GPAI transparency obligations enforced since **August 2, 2026**. High-risk enforcement follows **December 2, 2027**. This SDK gives you the cryptographic primitives for both.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## What's New in v0.6.5
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Scale governance. The protocol grew features that matter at GPAI scale, and every improvement flows through to Ruby because fingerprints are identical across all 10 languages.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
- Pre-inference gate module: authorization checkpoint before inference runs
|
|
20
|
-
- Chain reconstruction: forensic timeline rebuilding from witness anchors
|
|
21
|
-
- 10 new MCP compliance tools (33 total): gate, guardrail, HITL, consent, data provenance, RAG, output filter, incident, reconstruct, trajectory
|
|
22
|
-
- Kotlin SDK (v0.1.1): JVM/Android support with full test vector parity
|
|
23
|
-
- 185 compliance guides (5 new regulatory crosswalks)
|
|
24
|
-
- Crosswalk data: 27 frameworks, 339 procedure-framework mappings
|
|
18
|
+
### Probabilistic Witnessing (Python + TypeScript)
|
|
25
19
|
|
|
26
|
-
|
|
20
|
+
**What it does:** A new `sampling_rate` parameter (0.0-1.0) lets the full-pipeline SDKs witness a statistical sample of inferences instead of every single one. Non-witnessed inferences are counted and summarized in periodic AI-SAMPLE.1 anchors on flush. Per-procedure overrides keep safety-critical procedures at 100% while sampling high-volume inference calls.
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
**Why it matters for Ruby:** A GPAI provider processing a billion inferences per day cannot witness every single one. When your Python inference pipeline samples at 1% and your Ruby Sidekiq workers process the results, both sides produce anchors with the same fingerprint formula. The AI-SAMPLE.1 summary anchors are verifiable with this gem's `mint_fingerprint` -- same formula, same output. Your Ruby service can independently verify that the sampling was deterministic and reproducible.
|
|
29
23
|
|
|
30
|
-
###
|
|
24
|
+
### Governance Effectiveness Metadata (Python + TypeScript)
|
|
31
25
|
|
|
32
|
-
|
|
26
|
+
**What it does:** Governance witness methods now accept a `governance_metadata` dictionary recording review duration and participant count. Assessors use this to distinguish substantive governance from governance theater.
|
|
27
|
+
|
|
28
|
+
**Why it matters for Ruby:** If your Ruby service ingests governance anchors from the Python pipeline, the metadata is in the `ai_context` JSONB field at clearing levels 0-1. Your Rails dashboards and Sidekiq processors can read and display these fields without any gem changes. A 3-minute review by one person produces different metadata than a 90-minute review by five -- and your Ruby reporting layer can surface that difference.
|
|
29
|
+
|
|
30
|
+
### Go SDK (v0.1.0)
|
|
31
|
+
|
|
32
|
+
The 10th language in the SWT3 ecosystem. Core primitives: fingerprint minting, HMAC-SHA256 signing, lifecycle chain IDs. Zero dependencies. All 65 test vectors pass. Go is the dominant language for Kubernetes operators, API gateways, and inference orchestrators -- the infrastructure layer that sits between your Ruby application and the model. Same fingerprints, same signing, same audit trail.
|
|
33
|
+
|
|
34
|
+
### MCP Witness Middleware
|
|
35
|
+
|
|
36
|
+
`withSWT3(transport)` wraps any MCP transport to auto-witness every tool call. Zero code changes to tool handlers. If your Ruby service talks to MCP-enabled agents, every tool call they make now has a cryptographic anchor that your gem can independently verify.
|
|
37
|
+
|
|
38
|
+
### Updated Coverage
|
|
39
|
+
|
|
40
|
+
- 114 procedures across 62 namespaces (AI-SAMPLE.1 added)
|
|
41
|
+
- 36 framework crosswalks
|
|
42
|
+
- 215 compliance guides at [sovereign.tenova.io/guides](https://sovereign.tenova.io/guides/index.html)
|
|
43
|
+
- 2,515 tests passing across 5 languages
|
|
44
|
+
|
|
45
|
+
### v0.6.4
|
|
46
|
+
|
|
47
|
+
Version alignment across 10 SDKs. Pre-inference gate and chain reconstruction added in Python and TypeScript. 214 compliance guides.
|
|
33
48
|
|
|
34
49
|
## What You Get
|
|
35
50
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
-
|
|
51
|
+
| Method | What It Does | Use Case |
|
|
52
|
+
|--------|-------------|----------|
|
|
53
|
+
| `Swt3Ai::Fingerprint.mint_fingerprint` | Canonical SWT3 fingerprint from tenant, procedure, factors, and timestamp | Every inference, tool call, or decision point |
|
|
54
|
+
| `Swt3Ai::Signing.sign_payload` | HMAC-SHA256 signing with optional agent identity binding | Non-repudiation for regulated systems |
|
|
55
|
+
| `Swt3Ai::Fingerprint.sha256_truncated` | Truncated SHA-256 hash for prompts, responses, and model weights | Hash locally, transmit only the proof |
|
|
56
|
+
| `WitnessPayload` / `WitnessReceipt` | Typed structs for witness data | Serialize to JSON for API calls or database storage |
|
|
57
|
+
| `REVOCATION_REASONS` | 7 standard reason codes for anchor revocation | Model recall, policy violation, consent withdrawal |
|
|
40
58
|
|
|
41
|
-
All output is byte-identical to the Python, TypeScript, Swift, Rust, C#, and MCP SDKs.
|
|
59
|
+
All output is byte-identical to the Python, TypeScript, Swift, Rust, C#, Go, Kotlin, and MCP SDKs. 10 languages, one audit trail. Verified by shared test vectors.
|
|
42
60
|
|
|
43
61
|
## Quick Start
|
|
44
62
|
|
|
@@ -46,7 +64,86 @@ All output is byte-identical to the Python, TypeScript, Swift, Rust, C#, and MCP
|
|
|
46
64
|
gem install swt3-ai
|
|
47
65
|
```
|
|
48
66
|
|
|
49
|
-
|
|
67
|
+
Or add to your Gemfile:
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
gem "swt3-ai", "~> 0.6"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Add witnessing to a Rails controller
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
require "swt3_ai"
|
|
77
|
+
|
|
78
|
+
class InferencesController < ApplicationController
|
|
79
|
+
def create
|
|
80
|
+
result = AiService.call(params[:prompt])
|
|
81
|
+
|
|
82
|
+
# Witness the inference (3 lines)
|
|
83
|
+
fp = Swt3Ai::Fingerprint.mint_fingerprint(
|
|
84
|
+
"MY_TENANT", "AI-INF.1",
|
|
85
|
+
1.0, 1.0, 0.0,
|
|
86
|
+
(Time.now.to_f * 1000).to_i
|
|
87
|
+
)
|
|
88
|
+
sig = Swt3Ai::Signing.sign_payload(ENV["SWT3_SIGNING_KEY"], fp, "rails-api")
|
|
89
|
+
|
|
90
|
+
render json: { result: result, fingerprint: fp, signature: sig }
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Add witnessing to a Sidekiq worker
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
class FraudScoringWorker
|
|
99
|
+
include Sidekiq::Job
|
|
100
|
+
|
|
101
|
+
def perform(transaction_id)
|
|
102
|
+
score = FraudModel.score(transaction_id)
|
|
103
|
+
|
|
104
|
+
fp = Swt3Ai::Fingerprint.mint_fingerprint(
|
|
105
|
+
"MY_TENANT", "AI-FAIR.1",
|
|
106
|
+
score, 0.85, 0.0,
|
|
107
|
+
(Time.now.to_f * 1000).to_i
|
|
108
|
+
)
|
|
109
|
+
WitnessLog.create!(transaction_id: transaction_id, fingerprint: fp)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Zero-code Rack middleware
|
|
115
|
+
|
|
116
|
+
Witness every request that hits an AI endpoint without changing application code. Drop this into `config.ru` or your Rails initializer.
|
|
117
|
+
|
|
118
|
+
```ruby
|
|
119
|
+
# config/initializers/swt3_middleware.rb
|
|
120
|
+
class Swt3WitnessMiddleware
|
|
121
|
+
def initialize(app)
|
|
122
|
+
@app = app
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def call(env)
|
|
126
|
+
status, headers, response = @app.call(env)
|
|
127
|
+
|
|
128
|
+
if env["PATH_INFO"].start_with?("/api/v1/ai/")
|
|
129
|
+
fp = Swt3Ai::Fingerprint.mint_fingerprint(
|
|
130
|
+
ENV["SWT3_TENANT"], "AI-TOOL.1",
|
|
131
|
+
1.0, status == 200 ? 1.0 : 0.0, 0.0,
|
|
132
|
+
(Time.now.to_f * 1000).to_i
|
|
133
|
+
)
|
|
134
|
+
Rails.logger.info("[SWT3] #{env['PATH_INFO']} -> #{fp}")
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
[status, headers, response]
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
Rails.application.config.middleware.use Swt3WitnessMiddleware
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Every request matching `/api/v1/ai/*` gets a witness anchor logged. No controller changes. Works with any Rack-compatible framework (Rails, Sinatra, Grape, Hanami, Roda).
|
|
145
|
+
|
|
146
|
+
### Core primitives
|
|
50
147
|
|
|
51
148
|
```ruby
|
|
52
149
|
require "swt3_ai"
|
|
@@ -71,6 +168,39 @@ echo -n "WITNESS:DEMO_TENANT:AI-INF.1:1:1:0:1774800000000" | sha256sum | cut -c1
|
|
|
71
168
|
|
|
72
169
|
No SDK needed. Works on any machine, any language.
|
|
73
170
|
|
|
171
|
+
### What an anchor looks like
|
|
172
|
+
|
|
173
|
+
A witness anchor is a single deterministic string. Grep it, index it, parse it, write OPA rules against it.
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
SWT3-E-AWS-AI-TOOL1-PASS-1723891200-a4f8c92d0e17
|
|
177
|
+
| | | | | | |
|
|
178
|
+
| | | | | | +-- SHA-256 fingerprint (12 hex)
|
|
179
|
+
| | | | | +------------ epoch timestamp
|
|
180
|
+
| | | | +----------------- verdict (PASS / FAIL)
|
|
181
|
+
| | | +------------------------- procedure (AI-TOOL.1)
|
|
182
|
+
| | +----------------------------- cloud provider
|
|
183
|
+
| +-------------------------------- deployment tier (E = Enclave)
|
|
184
|
+
+------------------------------------ protocol prefix
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## CI/CD Integration
|
|
188
|
+
|
|
189
|
+
SWT3 fits into your existing pipeline as a verification stage. Gate deployments on witness coverage the same way you gate on test coverage.
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
# .github/workflows/deploy.yml
|
|
193
|
+
- name: Verify Witness Anchor
|
|
194
|
+
run: |
|
|
195
|
+
# $SWT3_ANCHOR is set by your app's witness output or a CI artifact
|
|
196
|
+
FINGERPRINT=$(echo -n "$SWT3_ANCHOR" | cut -d'-' -f8)
|
|
197
|
+
curl -sf "https://sovereign.tenova.io/api/v1/verify?fingerprint=$FINGERPRINT" \
|
|
198
|
+
| jq -e '.verified == true' || exit 1
|
|
199
|
+
# No API key. Public endpoint. Just math.
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
If you already sign containers with cosign and generate SBOMs with Syft or Trivy, SWT3 covers the gap those tools don't reach: what your AI decided after you deployed it. Your attestation chain extends from source commit to container image to runtime decision.
|
|
203
|
+
|
|
74
204
|
## Cross-Language Parity
|
|
75
205
|
|
|
76
206
|
All SWT3 SDKs produce identical fingerprints from the same inputs. A unified audit trail across your entire stack, verified by shared test vectors at build time.
|
|
@@ -83,10 +213,20 @@ All SWT3 SDKs produce identical fingerprints from the same inputs. A unified aud
|
|
|
83
213
|
| Rust | [swt3-ai](https://crates.io/crates/swt3-ai) | crates.io |
|
|
84
214
|
| C# / .NET | [swt3-ai](https://www.nuget.org/packages/swt3-ai) | NuGet |
|
|
85
215
|
| Ruby | swt3-ai (this package) | RubyGems |
|
|
216
|
+
| Go | [swt3-ai](https://github.com/tenova-labs/swt3-ai-go) | Go modules |
|
|
86
217
|
| MCP Server | [@tenova/swt3-mcp](https://www.npmjs.com/package/@tenova/swt3-mcp) | npm + MCP Registry |
|
|
87
218
|
| K8s Witness Agent | [swt3-witness](https://github.com/tenova-labs/swt3-ai/tree/main/packages/swt3-witness) | GHCR + Helm |
|
|
88
219
|
|
|
89
|
-
|
|
220
|
+
### When to use which SDK
|
|
221
|
+
|
|
222
|
+
| Your Stack | SDK | What You Get |
|
|
223
|
+
|-----------|-----|-------------|
|
|
224
|
+
| Python ML pipeline | [swt3-ai (PyPI)](https://pypi.org/project/swt3-ai/) | Full witness pipeline: `wrap(client)`, buffer management, clearing engine, 21 adapters (OpenAI, Anthropic, Bedrock, vLLM, Ollama, LiteLLM, LangChain, CrewAI, etc.) |
|
|
225
|
+
| TypeScript/Node API | [@tenova/swt3-ai (npm)](https://www.npmjs.com/package/@tenova/swt3-ai) | ES6 Proxy wrapping, streaming support, Vercel AI SDK adapter, OTel export |
|
|
226
|
+
| Rails, Sidekiq, Grape, Hanami | **swt3-ai (this gem)** | Fingerprint, signing, and verification primitives. Embed witnessing into controllers, workers, middleware, or rake tasks |
|
|
227
|
+
| MCP-enabled agents | [@tenova/swt3-mcp](https://www.npmjs.com/package/@tenova/swt3-mcp) | 33 MCP tools, transport middleware for zero-code witnessing |
|
|
228
|
+
|
|
229
|
+
Your Python team trains the model and wraps inference with the full pipeline. Your Ruby infrastructure witnesses every downstream decision, API call, and background job that touches the model's output. Same fingerprints, same anchors, same audit trail.
|
|
90
230
|
|
|
91
231
|
## Regulatory Coverage
|
|
92
232
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swt3-ai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- TeNova Labs
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Mint, verify, and sign SWT3 witness anchors for AI compliance. EU AI
|
|
14
14
|
Act, NIST AI RMF, CMMC, SR 11-7. Cross-language parity with Python and TypeScript
|
|
@@ -52,6 +52,6 @@ requirements: []
|
|
|
52
52
|
rubygems_version: 3.4.20
|
|
53
53
|
signing_key:
|
|
54
54
|
specification_version: 4
|
|
55
|
-
summary: 'SWT3 AI Witness SDK: cryptographic attestation for AI inference.
|
|
56
|
-
|
|
55
|
+
summary: 'SWT3 AI Witness SDK: cryptographic attestation for AI inference. 114 procedures,
|
|
56
|
+
62 namespaces, 10 languages, 18 profiles, 21 integrations.'
|
|
57
57
|
test_files: []
|