swt3-ai 0.6.4 → 0.6.6

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +196 -24
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cba9dd5230fdaeb9a047241cbf0ceb7bd3dfb771a40d5b7fef2a541d32e59d4
4
- data.tar.gz: 7550f8d5ea676ad0162408966e049ebe82149458d8918321b11d8dd51b85ab3c
3
+ metadata.gz: 719cc19c6202c043713079ad509eb09a4c729393ecf7488e35c6b122660e241c
4
+ data.tar.gz: 388ee4b8e7ca9810490d186066840808a088d2766546f57c2651a3d40f4fc61f
5
5
  SHA512:
6
- metadata.gz: a38259a7569fb4067b1e48be7142498031049fb8deed31616352cd878f000a52e832e470b038774a112928c3ee4661b03b41ef2993284427306688f82d6f9663
7
- data.tar.gz: 440b026afd9d18645969d9013949ba7256c50a5d81b8e06c52459475754157673c113b1e920bde60355ce307bfb151962da3c3892ce685b0fc9d597f1e93bb03
6
+ metadata.gz: 94f83a0f5ce92842abfd3bb615a412527828bff511e8179ee5bb6416cd8b6758470aae7820e9ec6274d97ed5803cbf2b599680f9ad301e0549e4f966b55093c4
7
+ data.tar.gz: 1475c12c91eb99198fef45ce8da074349d55a8d1f426a3b43c58b06da6ce7f4a8d10e200702f6555eb7285f5c40736c8988c2879e5f0f840f2c8e8d8db8c2438
data/README.md CHANGED
@@ -1,44 +1,94 @@
1
- Witness your AI. Prove it followed the rules. Cryptographic accountability for every inference, tool call, and resource access.
1
+ Add cryptographic compliance evidence to existing Ruby applications. Three lines of code. Zero external dependencies.
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/swt3-ai)](https://rubygems.org/gems/swt3-ai)
4
4
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](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. Zero external dependencies -- uses only `openssl` from the standard library.
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
- EU AI Act GPAI transparency obligations enforce **August 2, 2026**. High-risk enforcement follows **December 2, 2027**. This SDK gives you the cryptographic primitives for both.
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
- ## What's New in v0.6.4
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
- Version alignment with the full SWT3 SDK ecosystem. The protocol now spans 9 languages (Python, TypeScript, Rust, C#, Ruby, Swift, Kotlin, plus MCP and K8s agent) with 113 procedures across 61 namespaces.
14
+ ## What's New in v0.6.6
15
15
 
16
- **Why 9 languages matters:** AI systems don't run on one stack. A Python training pipeline feeds a Rust inference engine that serves a Swift mobile app monitored by a TypeScript dashboard. Every handoff is an accountability gap. Cross-language parity means the same fingerprint formula, the same signing algorithm, and the same test vectors produce identical results regardless of where the attestation happens. No translation layer. No format conversion. One protocol, verified across every runtime.
16
+ Supply chain accountability. Four new procedures, a CI/CD gate action, and OTel GenAI conventions across the ecosystem. Every improvement flows through to Ruby because fingerprints are identical across all 10 languages.
17
17
 
18
- **New in the ecosystem (v0.6.4):**
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
+ ### 4 New Procedures
25
19
 
26
- ### v0.6.3
20
+ **AI-PROV.1 (Model Provenance Chain):** Records model lineage -- base model, training pipeline, fine-tuning ancestry. The G7 Hiroshima AI SBOM framework requires provenance documentation. A `parent_model_fingerprint` parameter on model weight/adapter/quantization methods links derivative models to their ancestors. Provenance anchors verify with `mint_fingerprint` like any other anchor.
27
21
 
28
- - **v0.6.3 across the ecosystem**: Python, TypeScript, and MCP SDKs add consent witnessing (AI-CONSENT.1), output safety classification (AI-GRD.2), incident reporting (AI-INCIDENT.1), and training data provenance (AI-DATA.1). Swift and Kotlin add typed attestation structs. Core primitives in this package remain stable: the fingerprint formula and signing functions are unchanged. 32 MCP tools, 34+ frameworks, 113 procedures.
22
+ **AI-DEL.2 (Delegation Boundary):** Records what an agent is NOT permitted to do -- blocked tools, restricted scopes, escalation triggers. EU AI Act Art. 14 requires documented AI system limitations. Where AI-DEL.1 tracks permissions, AI-DEL.2 tracks constraints.
29
23
 
30
- ### v0.5.9
24
+ **AI-DENSITY.1 (Anchor Density):** Records the ratio of witnessed events to total events over a time window. Catches the slow coverage drift from 100% to 2% that nobody notices until the audit. A DensityEnforcer class in Python and TypeScript auto-fires density anchors when coverage drops.
31
25
 
32
- - **Compliance Intelligence** available in Python, TypeScript, and MCP SDKs -- offline crosswalk resolution across 34+ frameworks. Core primitives in this package remain stable and unchanged.
26
+ **AI-MCP.1 (MCP Security Posture):** Evaluates 8 security properties of an MCP server connection. Records checks passed vs. total -- never which specific checks failed. NSA and CISA flagged 200,000+ vulnerable MCP deployments in 2026. This creates evidence that security was evaluated at connection time without becoming an attack map.
27
+
28
+ **Why it matters for Ruby:** All four procedures produce anchors with the same fingerprint formula. Your Ruby code can verify any of these new anchor types with the existing `Swt3Ai::Fingerprint.mint_fingerprint` method -- no gem update required for verification. Your Rails dashboards and Sidekiq workers can process provenance and density anchors from the Python pipeline without any changes. When your Ruby monitoring layer ingests anchor data, the new procedure types are just more rows with the same verifiable fingerprint structure.
29
+
30
+ ### GitHub Action
31
+
32
+ `tenova-labs/swt3-gate-action@v1` evaluates `.swt3-gate.yml` in CI/CD. Fails the build when coverage drops. Works with any language -- the gate checks anchors on the server, not the SDK in your repo. Your Gemfile-driven CI pipeline can enforce compliance gates without installing any additional gems.
33
+
34
+ ### OTel GenAI Conventions (Python + TypeScript)
35
+
36
+ The OpenTelemetry exporters now emit `gen_ai.system`, `gen_ai.request.model`, and token usage attributes following the OTel GenAI semantic conventions. If your Ruby service consumes OTel spans from the Python or TypeScript witness pipeline, these new attributes appear automatically.
37
+
38
+ ### Updated Coverage
39
+
40
+ - 118 procedures across 64 namespaces (+AI-PROV.1, AI-DEL.2, AI-DENSITY.1, AI-MCP.1)
41
+ - 37 MCP tools (+witness_delegation_boundary, witness_anchor_density, witness_mcp_security, witness_model_provenance)
42
+ - 10 SDK languages with byte-identical output
43
+ - 36 framework crosswalks, 222 compliance guides
44
+ - 2,825 tests passing across 5 languages
45
+
46
+ ## What's New in v0.6.5
47
+
48
+ 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.
49
+
50
+ ### Probabilistic Witnessing (Python + TypeScript)
51
+
52
+ **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.
53
+
54
+ **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.
55
+
56
+ ### Governance Effectiveness Metadata (Python + TypeScript)
57
+
58
+ **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.
59
+
60
+ **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.
61
+
62
+ ### Go SDK (v0.1.0)
63
+
64
+ 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.
65
+
66
+ ### MCP Witness Middleware
67
+
68
+ `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.
69
+
70
+ ### Updated Coverage
71
+
72
+ - 114 procedures across 62 namespaces (AI-SAMPLE.1 added)
73
+ - 36 framework crosswalks
74
+ - 215 compliance guides at [sovereign.tenova.io/guides](https://sovereign.tenova.io/guides/index.html)
75
+ - 2,515 tests passing across 5 languages
76
+
77
+ ### v0.6.4
78
+
79
+ Version alignment across 10 SDKs. Pre-inference gate and chain reconstruction added in Python and TypeScript. 214 compliance guides.
33
80
 
34
81
  ## What You Get
35
82
 
36
- - **`Swt3Ai::Fingerprint.mint_fingerprint`** -- canonical SWT3 fingerprint from tenant, procedure, factors, and timestamp
37
- - **`Swt3Ai::Signing.sign_payload`** -- HMAC-SHA256 signing with optional agent identity binding
38
- - **`Swt3Ai::Fingerprint.sha256_truncated`** -- truncated SHA-256 hashing for prompts, responses, and model weights
39
- - **Types** -- `WitnessPayload`, `WitnessReceipt`, `WitnessConfig` structs and `REVOCATION_REASONS` constants
83
+ | Method | What It Does | Use Case |
84
+ |--------|-------------|----------|
85
+ | `Swt3Ai::Fingerprint.mint_fingerprint` | Canonical SWT3 fingerprint from tenant, procedure, factors, and timestamp | Every inference, tool call, or decision point |
86
+ | `Swt3Ai::Signing.sign_payload` | HMAC-SHA256 signing with optional agent identity binding | Non-repudiation for regulated systems |
87
+ | `Swt3Ai::Fingerprint.sha256_truncated` | Truncated SHA-256 hash for prompts, responses, and model weights | Hash locally, transmit only the proof |
88
+ | `WitnessPayload` / `WitnessReceipt` | Typed structs for witness data | Serialize to JSON for API calls or database storage |
89
+ | `REVOCATION_REASONS` | 7 standard reason codes for anchor revocation | Model recall, policy violation, consent withdrawal |
40
90
 
41
- All output is byte-identical to the Python, TypeScript, Swift, Rust, C#, and MCP SDKs. 9 languages, one audit trail. Verified by shared test vectors.
91
+ 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
92
 
43
93
  ## Quick Start
44
94
 
@@ -46,7 +96,86 @@ All output is byte-identical to the Python, TypeScript, Swift, Rust, C#, and MCP
46
96
  gem install swt3-ai
47
97
  ```
48
98
 
49
- Mint a fingerprint:
99
+ Or add to your Gemfile:
100
+
101
+ ```ruby
102
+ gem "swt3-ai", "~> 0.6"
103
+ ```
104
+
105
+ ### Add witnessing to a Rails controller
106
+
107
+ ```ruby
108
+ require "swt3_ai"
109
+
110
+ class InferencesController < ApplicationController
111
+ def create
112
+ result = AiService.call(params[:prompt])
113
+
114
+ # Witness the inference (3 lines)
115
+ fp = Swt3Ai::Fingerprint.mint_fingerprint(
116
+ "MY_TENANT", "AI-INF.1",
117
+ 1.0, 1.0, 0.0,
118
+ (Time.now.to_f * 1000).to_i
119
+ )
120
+ sig = Swt3Ai::Signing.sign_payload(ENV["SWT3_SIGNING_KEY"], fp, "rails-api")
121
+
122
+ render json: { result: result, fingerprint: fp, signature: sig }
123
+ end
124
+ end
125
+ ```
126
+
127
+ ### Add witnessing to a Sidekiq worker
128
+
129
+ ```ruby
130
+ class FraudScoringWorker
131
+ include Sidekiq::Job
132
+
133
+ def perform(transaction_id)
134
+ score = FraudModel.score(transaction_id)
135
+
136
+ fp = Swt3Ai::Fingerprint.mint_fingerprint(
137
+ "MY_TENANT", "AI-FAIR.1",
138
+ score, 0.85, 0.0,
139
+ (Time.now.to_f * 1000).to_i
140
+ )
141
+ WitnessLog.create!(transaction_id: transaction_id, fingerprint: fp)
142
+ end
143
+ end
144
+ ```
145
+
146
+ ### Zero-code Rack middleware
147
+
148
+ Witness every request that hits an AI endpoint without changing application code. Drop this into `config.ru` or your Rails initializer.
149
+
150
+ ```ruby
151
+ # config/initializers/swt3_middleware.rb
152
+ class Swt3WitnessMiddleware
153
+ def initialize(app)
154
+ @app = app
155
+ end
156
+
157
+ def call(env)
158
+ status, headers, response = @app.call(env)
159
+
160
+ if env["PATH_INFO"].start_with?("/api/v1/ai/")
161
+ fp = Swt3Ai::Fingerprint.mint_fingerprint(
162
+ ENV["SWT3_TENANT"], "AI-TOOL.1",
163
+ 1.0, status == 200 ? 1.0 : 0.0, 0.0,
164
+ (Time.now.to_f * 1000).to_i
165
+ )
166
+ Rails.logger.info("[SWT3] #{env['PATH_INFO']} -> #{fp}")
167
+ end
168
+
169
+ [status, headers, response]
170
+ end
171
+ end
172
+
173
+ Rails.application.config.middleware.use Swt3WitnessMiddleware
174
+ ```
175
+
176
+ 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).
177
+
178
+ ### Core primitives
50
179
 
51
180
  ```ruby
52
181
  require "swt3_ai"
@@ -71,6 +200,39 @@ echo -n "WITNESS:DEMO_TENANT:AI-INF.1:1:1:0:1774800000000" | sha256sum | cut -c1
71
200
 
72
201
  No SDK needed. Works on any machine, any language.
73
202
 
203
+ ### What an anchor looks like
204
+
205
+ A witness anchor is a single deterministic string. Grep it, index it, parse it, write OPA rules against it.
206
+
207
+ ```
208
+ SWT3-E-AWS-AI-TOOL1-PASS-1723891200-a4f8c92d0e17
209
+ | | | | | | |
210
+ | | | | | | +-- SHA-256 fingerprint (12 hex)
211
+ | | | | | +------------ epoch timestamp
212
+ | | | | +----------------- verdict (PASS / FAIL)
213
+ | | | +------------------------- procedure (AI-TOOL.1)
214
+ | | +----------------------------- cloud provider
215
+ | +-------------------------------- deployment tier (E = Enclave)
216
+ +------------------------------------ protocol prefix
217
+ ```
218
+
219
+ ## CI/CD Integration
220
+
221
+ SWT3 fits into your existing pipeline as a verification stage. Gate deployments on witness coverage the same way you gate on test coverage.
222
+
223
+ ```yaml
224
+ # .github/workflows/deploy.yml
225
+ - name: Verify Witness Anchor
226
+ run: |
227
+ # $SWT3_ANCHOR is set by your app's witness output or a CI artifact
228
+ FINGERPRINT=$(echo -n "$SWT3_ANCHOR" | cut -d'-' -f8)
229
+ curl -sf "https://sovereign.tenova.io/api/v1/verify?fingerprint=$FINGERPRINT" \
230
+ | jq -e '.verified == true' || exit 1
231
+ # No API key. Public endpoint. Just math.
232
+ ```
233
+
234
+ 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.
235
+
74
236
  ## Cross-Language Parity
75
237
 
76
238
  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 +245,20 @@ All SWT3 SDKs produce identical fingerprints from the same inputs. A unified aud
83
245
  | Rust | [swt3-ai](https://crates.io/crates/swt3-ai) | crates.io |
84
246
  | C# / .NET | [swt3-ai](https://www.nuget.org/packages/swt3-ai) | NuGet |
85
247
  | Ruby | swt3-ai (this package) | RubyGems |
248
+ | Go | [swt3-ai](https://github.com/tenova-labs/swt3-ai-go) | Go modules |
86
249
  | MCP Server | [@tenova/swt3-mcp](https://www.npmjs.com/package/@tenova/swt3-mcp) | npm + MCP Registry |
87
250
  | K8s Witness Agent | [swt3-witness](https://github.com/tenova-labs/swt3-ai/tree/main/packages/swt3-witness) | GHCR + Helm |
88
251
 
89
- The Python and TypeScript SDKs include the full witness pipeline: transparent client wrapping, buffer management, clearing engine, adapter support (OpenAI, Anthropic, Bedrock, vLLM, Ollama, LangChain, LangGraph, Microsoft AGT, Google ADK, CrewAI), trust mesh, policy-as-code, and Merkle accumulator. Use them for production AI witnessing. Use this Ruby gem for embedding fingerprint verification into Rails apps, Sidekiq workers, or Ruby-based tooling.
252
+ ### When to use which SDK
253
+
254
+ | Your Stack | SDK | What You Get |
255
+ |-----------|-----|-------------|
256
+ | 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.) |
257
+ | 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 |
258
+ | Rails, Sidekiq, Grape, Hanami | **swt3-ai (this gem)** | Fingerprint, signing, and verification primitives. Embed witnessing into controllers, workers, middleware, or rake tasks |
259
+ | MCP-enabled agents | [@tenova/swt3-mcp](https://www.npmjs.com/package/@tenova/swt3-mcp) | 37 MCP tools, transport middleware for zero-code witnessing |
260
+
261
+ 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
262
 
91
263
  ## Regulatory Coverage
92
264
 
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
4
+ version: 0.6.6
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 00:00:00.000000000 Z
11
+ date: 2026-08-25 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. 113 procedures,
56
- 61 namespaces, 9 languages, 18 profiles, 21 integrations.'
55
+ summary: 'SWT3 AI Witness SDK: cryptographic attestation for AI inference. 118 procedures,
56
+ 64 namespaces, 10 languages, 18 profiles, 21 integrations.'
57
57
  test_files: []