@tenova/swt3-ai 0.5.1 → 0.5.3

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 (70) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +227 -10
  3. package/dist/buffer.d.ts +7 -1
  4. package/dist/buffer.d.ts.map +1 -1
  5. package/dist/buffer.js +38 -3
  6. package/dist/buffer.js.map +1 -1
  7. package/dist/cli.d.ts +13 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +202 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/config.d.ts +18 -5
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/config.js +346 -42
  14. package/dist/config.js.map +1 -1
  15. package/dist/demo.d.ts +1 -1
  16. package/dist/demo.d.ts.map +1 -1
  17. package/dist/demo.js +88 -4
  18. package/dist/demo.js.map +1 -1
  19. package/dist/doctor.d.ts +20 -0
  20. package/dist/doctor.d.ts.map +1 -0
  21. package/dist/doctor.js +357 -0
  22. package/dist/doctor.js.map +1 -0
  23. package/dist/environment.d.ts +34 -0
  24. package/dist/environment.d.ts.map +1 -0
  25. package/dist/environment.js +99 -0
  26. package/dist/environment.js.map +1 -0
  27. package/dist/exporters/chain-monitor.d.ts +55 -0
  28. package/dist/exporters/chain-monitor.d.ts.map +1 -0
  29. package/dist/exporters/chain-monitor.js +172 -0
  30. package/dist/exporters/chain-monitor.js.map +1 -0
  31. package/dist/hardware.d.ts +96 -0
  32. package/dist/hardware.d.ts.map +1 -0
  33. package/dist/hardware.js +265 -0
  34. package/dist/hardware.js.map +1 -0
  35. package/dist/index.d.ts +19 -3
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +10 -2
  38. package/dist/index.js.map +1 -1
  39. package/dist/merkle.d.ts +107 -0
  40. package/dist/merkle.d.ts.map +1 -0
  41. package/dist/merkle.js +226 -0
  42. package/dist/merkle.js.map +1 -0
  43. package/dist/schema.d.ts +18 -0
  44. package/dist/schema.d.ts.map +1 -0
  45. package/dist/schema.js +255 -0
  46. package/dist/schema.js.map +1 -0
  47. package/dist/trust.d.ts +100 -0
  48. package/dist/trust.d.ts.map +1 -0
  49. package/dist/trust.js +222 -0
  50. package/dist/trust.js.map +1 -0
  51. package/dist/types.d.ts +167 -11
  52. package/dist/types.d.ts.map +1 -1
  53. package/dist/types.js +42 -1
  54. package/dist/types.js.map +1 -1
  55. package/dist/wal.d.ts +69 -0
  56. package/dist/wal.d.ts.map +1 -0
  57. package/dist/wal.js +223 -0
  58. package/dist/wal.js.map +1 -0
  59. package/dist/witness.d.ts +293 -1
  60. package/dist/witness.d.ts.map +1 -1
  61. package/dist/witness.js +1234 -5
  62. package/dist/witness.js.map +1 -1
  63. package/package.json +7 -7
  64. package/templates/cost-conscious.yaml +35 -0
  65. package/templates/eu-ai-act-high-risk.yaml +56 -0
  66. package/templates/granite-sovereign.yaml +55 -0
  67. package/templates/minimal.yaml +38 -0
  68. package/templates/mythos-defense.yaml +65 -0
  69. package/templates/nist-ai-rmf.yaml +47 -0
  70. package/templates/owasp-agentic-top10.yaml +50 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2025-2026 Tenable Nova LLC
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md CHANGED
@@ -3,6 +3,7 @@ Witness your AI. Prove it followed the rules. Cryptographic accountability for e
3
3
  [![npm](https://img.shields.io/npm/v/@tenova/swt3-ai)](https://www.npmjs.com/package/@tenova/swt3-ai)
4
4
  [![Downloads](https://img.shields.io/npm/dm/@tenova/swt3-ai)](https://www.npmjs.com/package/@tenova/swt3-ai)
5
5
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/tenova-labs/swt3-ai/blob/main/LICENSE)
6
+ [![MCP Registry](https://img.shields.io/badge/MCP_Registry-io.tenova%2Fswt3--witness-blue)](https://www.npmjs.com/package/@tenova/swt3-mcp)
6
7
 
7
8
  # @tenova/swt3-ai
8
9
 
@@ -12,6 +13,72 @@ Works with OpenAI, Anthropic, AWS Bedrock, Vercel AI SDK, and any OpenAI-compati
12
13
 
13
14
  GPAI transparency obligations are enforceable now. EU AI Act high-risk enforcement begins **December 2, 2027**. This SDK gives you the evidence chain.
14
15
 
16
+ ## MCP Server -- Official Registry
17
+
18
+ `@tenova/swt3-mcp` is listed on the official Model Context Protocol Registry as `io.tenova/swt3-witness`. Zero-config compliance governance for Claude Code, Cursor, Windsurf, and any MCP-compatible host.
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "swt3-witness": {
24
+ "command": "npx",
25
+ "args": ["@tenova/swt3-mcp"]
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ Every tool call your agent makes is witnessed, Merkle-accumulated, and trust-evaluated. No code changes required. [Quick Start](https://www.npmjs.com/package/@tenova/swt3-mcp)
32
+
33
+ ## Secure Agent-to-Agent Communication
34
+
35
+ The SWT3 Trust Mesh enables mutual cryptographic verification between AI agents before they exchange data, invoke tools, or share context. When you adopt SWT3, every partner, vendor, and downstream agent that wants to interact with yours must adopt it too. Compliance becomes the connection protocol. Every agent in the mesh strengthens the network.
36
+
37
+ **You run Agent A. Your partner runs Agent B. Both install @tenova/swt3-ai:**
38
+
39
+ ```typescript
40
+ // === Your side (Agent A) ===
41
+ const witnessA = new Witness({
42
+ endpoint: "...", apiKey: "axm_...", tenantId: "YOUR_TENANT",
43
+ agentId: "agent-alpha", signingKey: "swt3_sk_your_key",
44
+ });
45
+ witnessA.trustRegistry.trustTenant("PARTNER_B_TENANT");
46
+ witnessA.trustRegistry.registerSigningKey("agent-beta", process.env.PARTNER_B_KEY!);
47
+
48
+ // === Partner's side (Agent B) ===
49
+ const witnessB = new Witness({
50
+ endpoint: "...", apiKey: "axm_...", tenantId: "PARTNER_B_TENANT",
51
+ agentId: "agent-beta", signingKey: "swt3_sk_partner_key",
52
+ });
53
+ witnessB.trustRegistry.trustTenant("YOUR_TENANT");
54
+ witnessB.trustRegistry.registerSigningKey("agent-alpha", process.env.YOUR_KEY!);
55
+
56
+ // === Handshake (both directions) ===
57
+ const credA = witnessA.presentCredential();
58
+ const resultB = witnessB.verifyTrust(credA); // B verifies A
59
+ if (resultB.granted) {
60
+ const credB = witnessB.presentCredential();
61
+ const resultA = witnessA.verifyTrust(credB); // A verifies B
62
+ if (resultA.granted) {
63
+ // Bidirectional trust established. Exchange data.
64
+ }
65
+ }
66
+ ```
67
+
68
+ Configure trust boundaries declaratively in `.swt3.yaml`:
69
+
70
+ ```yaml
71
+ trust_mesh:
72
+ mode: strict
73
+ min_trust_level: 2
74
+ require_signature: true
75
+ freshness_window: 3600
76
+ trusted_tenants: ["PARTNER_B_TENANT"]
77
+ deny_agents: ["revoked-agent-id"]
78
+ ```
79
+
80
+ All verification is local. Zero cloud overhead. No data exchanged until both agents clear the trust gate. Unsigned agents are capped at TRUST_BASIC (level 1). Add signing keys for verified trust. Add hardware attestation for sovereign trust.
81
+
15
82
  ## See It Work (No Account Needed)
16
83
 
17
84
  ```bash
@@ -216,6 +283,26 @@ witness.witnessQuantization("gptq", { bits: 4, groupSize: 128 });
216
283
 
217
284
  Maps to: EU AI Act Art. 15(4) (resilience against modification), Art. 12(2)(b) (version logging).
218
285
 
286
+ ## TPM Platform Attestation (AI-HW.3)
287
+
288
+ Prove host firmware integrity via TPM 2.0. Reads PCR registers 0-7 and mints a hardware root-of-trust anchor. All raw values are SHA-256 hashed before leaving the module:
289
+
290
+ ```typescript
291
+ // Auto-detect: reads /dev/tpm0 via tpm2-tools
292
+ witness.witnessTPMAttestation();
293
+
294
+ // Or provide a pre-computed snapshot
295
+ import { queryTPM } from "@tenova/swt3-ai";
296
+ const snapshot = queryTPM();
297
+ witness.witnessTPMAttestation({ snapshot });
298
+ ```
299
+
300
+ If no TPM is available (cloud VM, dev machine), returns a valid anchor with factor_a=0. No crash, no error. Graceful degradation by design.
301
+
302
+ Use case: sovereign/air-gapped deployments where you must prove the host was not tampered with. Combined with AI-HW.1 (GPU inventory), gives full hardware root-of-trust from silicon to model.
303
+
304
+ Maps to: NIST 800-53 SC-12 (cryptographic key establishment). Patent pending.
305
+
219
306
  ## Environmental Attestation (Residential and Edge AI)
220
307
 
221
308
  Witness the physical compute environment for distributed, edge-deployed, or residential AI nodes. Proves the hardware operated within safe thermal and power bounds during inference:
@@ -363,13 +450,108 @@ witnessB.trustRegistry.registerSigningKey("agent-alpha", process.env.AGENT_A_KEY
363
450
 
364
451
  **Zero-friction path:** Trust mesh works without signing keys. Agents without keys get TRUST_BASIC (level 1), which is sufficient for non-sensitive coordination. Add keys when you need verified or attested trust.
365
452
 
366
- **Credential auto-population:** `presentCredential()` automatically includes which procedures the agent has witnessed and whether hardware attestation (AI-HW.1) has been performed. No manual tracking needed.
453
+ **Credential auto-population:** `presentCredential()` automatically includes which procedures the agent has witnessed and whether hardware attestation (AI-HW.1 or AI-HW.3) has been performed. No manual tracking needed.
367
454
 
368
455
  Every verification (pass or fail) mints AI-TRUST.1 + AI-TRUST.2 anchors. Denials produce evidence too.
369
456
 
370
457
  Maps to: EU AI Act Art. 14 (human oversight and mutual accountability between AI systems).
371
458
 
372
- ## Gatekeeper Mode (Pre-Call Enforcement)
459
+ ## Policy-as-Code (swt3.yaml)
460
+
461
+ New in v0.5.2. Define your entire witnessing policy in a YAML file instead of passing 25+ constructor parameters:
462
+
463
+ ```bash
464
+ npx swt3 init # interactive profile picker
465
+ npx swt3 init --profile eu-ai-act-high-risk --tenant ACME
466
+ ```
467
+
468
+ This generates a `swt3.yaml` file. Then load it:
469
+
470
+ ```typescript
471
+ const witness = Witness.fromConfig(); // auto-finds swt3.yaml
472
+ const witness = Witness.fromConfig("prod.yaml"); // explicit path
473
+ ```
474
+
475
+ ### File Composition (extends)
476
+
477
+ Layer configs for environment-specific overrides:
478
+
479
+ ```yaml
480
+ # prod.yaml
481
+ extends: base.yaml
482
+ clearing_level: 2
483
+ signing_key_env: SWT3_SIGNING_KEY
484
+ ```
485
+
486
+ Supports single files or chains (`extends: [base.yaml, team.yaml]`). Merge order: extends < profile < explicit config. Cycle detection and depth limit (10) built in.
487
+
488
+ ### Built-in Profiles
489
+
490
+ Seven profiles ship with the SDK:
491
+
492
+ | Profile | Use Case |
493
+ |---------|----------|
494
+ | `eu-ai-act-high-risk` | EU AI Act high-risk: clearing 2, signing required, jurisdiction required |
495
+ | `nist-ai-rmf` | NIST AI RMF: full procedure coverage, moderate policy |
496
+ | `cost-conscious` | Token budget governance: 25K/session ceiling, cost attribution |
497
+ | `owasp-agentic-top10` | OWASP Agentic Top 10: fail-closed, 100K tokens, depth 8 |
498
+ | `mythos-defense` | Exploit chain containment: clearing 3, strict trust, depth 5 |
499
+ | `granite-sovereign` | IBM Granite on-prem: air-gap ready, hardware attestation |
500
+ | `minimal` | Development: clearing 0, no policy enforcement |
501
+
502
+ ### Diagnostics
503
+
504
+ ```bash
505
+ npx swt3 doctor # 8 checks: YAML, env vars, profile, extends, sections
506
+ npx swt3 doctor --json # machine-readable for CI/CD
507
+ ```
508
+
509
+ ### Schema Validation
510
+
511
+ Validate config files programmatically:
512
+
513
+ ```typescript
514
+ import { validateSchema } from "@tenova/swt3-ai";
515
+
516
+ const result = validateSchema(parsedYaml);
517
+ if (!result.valid) {
518
+ console.error(result.errors);
519
+ }
520
+ ```
521
+
522
+ ## Merkle Accumulator (Session-Level Integrity)
523
+
524
+ New in v0.5.2. Compute Merkle roots over batches of anchors for tamper-evident session integrity:
525
+
526
+ ```typescript
527
+ import { MerkleAccumulator, verifyMerkleProof } from "@tenova/swt3-ai";
528
+
529
+ const acc = new MerkleAccumulator({ tenantId: "ACME" });
530
+
531
+ // Accumulate fingerprints as anchors are minted
532
+ acc.add("abc123def456");
533
+ acc.add("789012345678");
534
+
535
+ // Compute session root (persisted to JSONL automatically)
536
+ const session = acc.flush();
537
+ console.log(session.root); // 64-char hex Merkle root
538
+
539
+ // Generate an inclusion proof for any fingerprint
540
+ const proof = acc.prove("abc123def456");
541
+ console.log(verifyMerkleProof("abc123def456", proof)); // true
542
+ ```
543
+
544
+ Enable via config:
545
+
546
+ ```yaml
547
+ merkle:
548
+ enabled: true
549
+ accumulator_interval: 0 # 0 = compute on every flush
550
+ ```
551
+
552
+ Cross-language parity with Python SDK. Domain-separated (SWT3:LEAF: / SWT3:NODE:) to prevent second-preimage attacks.
553
+
554
+ ## Gatekeeper Mode (Pre-Call Attestation)
373
555
 
374
556
  New in v0.3.4. Require guardrails to be active *before* the model is called, not just observed after:
375
557
 
@@ -407,6 +589,35 @@ Gatekeeper mode mints an **AI-GRD.3** anchor with:
407
589
  - **factor_b** = actual guardrail count
408
590
  - **factor_c** = 1 if gate passed, 0 if blocked
409
591
 
592
+ ## Agent Cost Governance
593
+
594
+ Every inference witnessed by the SDK captures prompt and completion token counts from the API response. Combined with `max_tokens_per_session`, this gives you a per-agent, per-session cost ceiling with a complete audit trail.
595
+
596
+ ```yaml
597
+ # .swt3.yaml
598
+ profile: cost-conscious # Built-in budget profile (25K tokens)
599
+
600
+ mcp_policy:
601
+ max_tokens_per_session: 25000 # Hard cutoff per session
602
+ fail_secure: true # Halt and record on budget exceeded
603
+ ```
604
+
605
+ ```typescript
606
+ import { Witness } from "@tenova/swt3-ai";
607
+
608
+ const witness = new Witness({ /* ... */ });
609
+ const client = witness.wrap(new OpenAI()) as OpenAI;
610
+
611
+ // Every call through the wrapped client automatically tracks tokens.
612
+ // When the session budget is exhausted, the chain enforcer halts
613
+ // further calls and mints a token_budget violation anchor.
614
+
615
+ // Manual token recording (for custom pipelines):
616
+ witness.recordSessionTokens(1500);
617
+ ```
618
+
619
+ Token usage flows into the witness ledger alongside every other anchor. Your auditor sees what the agent did, whether it complied, and what it cost -- in one export.
620
+
410
621
  ## Multi-Agent Chain Linking
411
622
 
412
623
  New in v0.3.4. Link anchors across agents in a multi-step pipeline using `cycleId`:
@@ -456,7 +667,7 @@ Each inference produces anchors for these checks. Every check maps to a regulati
456
667
 
457
668
  ### EU AI Act Article Mapping
458
669
 
459
- All 42 SWT3 AI witnessing procedures map to specific EU AI Act obligations:
670
+ All 47 SWT3 AI witnessing procedures map to specific EU AI Act obligations:
460
671
 
461
672
  | Procedure | EU AI Act Article | Obligation | Demo | Production |
462
673
  |-----------|-------------------|------------|------|------------|
@@ -473,7 +684,7 @@ All 42 SWT3 AI witnessing procedures map to specific EU AI Act obligations:
473
684
  | AI-EXPL.1 | Art. 13(1) | Transparency & Explainability | -| ✓ |
474
685
  | AI-EXPL.2 | Art. 13(3b) | Confidence Calibration | -| ✓ |
475
686
 
476
- The demo demonstrates 5 procedures using simulated data. All 42 are available in production with real inference data. 36 cross-language test vectors ensure fingerprint parity across Python, TypeScript, Rust, C#, and Ruby. [See live conformity →](https://sovereign.tenova.io/audit/axm_audit_demo_eu_ai_act_public)
687
+ The demo demonstrates 5 procedures using simulated data. All 47 are available in production with real inference data. 40 cross-language test vectors ensure fingerprint parity across Python, TypeScript, Rust, C#, and Ruby. [See live conformity →](https://sovereign.tenova.io/audit/axm_audit_demo_eu_ai_act_public)
477
688
 
478
689
  ## How Verdicts Work
479
690
 
@@ -718,15 +929,21 @@ Your prompts and responses **never leave your infrastructure**. The SDK computes
718
929
 
719
930
  ---
720
931
 
721
- ## Upgrading to v0.5.1
932
+ ## Upgrading to v0.5.2
933
+
934
+ **Policy-as-Code (new):** `swt3 init`, `swt3 doctor`, `extends:` composition, profile templates, YAML schema validator. No breaking changes.
935
+
936
+ **Merkle Accumulator (new):** `MerkleAccumulator` class for session-level integrity proofs. `merkle:` config section. No breaking changes.
937
+
938
+ **Trust Mesh (v0.5.0):** `presentCredential()` and `verifyTrust()`. No breaking changes for existing code.
722
939
 
723
- **Trust Mesh (new):** `presentCredential()` and `verifyTrust()` are new methods. No breaking changes for existing code.
940
+ **Credential signing (behavioral change):** If your Witness has a `signingKey`, credentials are now HMAC-signed automatically. Counterpart agents must register your key via `trustRegistry.registerSigningKey()` to verify the signature. Without key registration, signed credentials are denied with `signature_unverifiable`.
724
941
 
725
- **Credential signing (behavioral change):** If your Witness has a `signingKey`, credentials are now HMAC-signed automatically. Counterpart agents must register your key via `trustRegistry.registerSigningKey()` to verify the signature. Without key registration, signed credentials are denied with `signature_unverifiable`. If you were using trust mesh in v0.5.0 without signing keys, credentials are now capped at TRUST_BASIC (level 1). To restore full trust levels, both sides must exchange and register signing keys.
942
+ **TPM attestation (v0.5.2):** `witnessTPMAttestation()` for AI-HW.3. Reads PCR registers via tpm2-tools. Graceful degradation without TPM. No breaking changes.
726
943
 
727
- **Environmental attestation (new):** `witnessEnvironment()` and `witnessEnergyDraw()` are new methods for AI-ENV.1/AI-ENV.2. No breaking changes.
944
+ **Environmental attestation (v0.5.0):** `witnessEnvironment()` and `witnessEnergyDraw()` for AI-ENV.1/AI-ENV.2. No breaking changes.
728
945
 
729
- **MCP server:** 16 procedure keyword suggestions (was 8). No breaking changes.
946
+ **MCP server:** 16 procedure keyword suggestions (was 8). MCP policy section in swt3.yaml. No breaking changes.
730
947
 
731
948
  ---
732
949
 
@@ -736,7 +953,7 @@ Your prompts and responses **never leave your infrastructure**. The SDK computes
736
953
  - [10-Minute Quickstart](https://sovereign.tenova.io/guides/ai-witness-quickstart.html) -- from install to first anchor
737
954
  - [SWT3 Protocol Spec](https://sovereign.tenova.io/guides/swt3-protocol.html) -- formal specification with ABNF grammar
738
955
  - [Design Rationale](https://sovereign.tenova.io/guides/swt3-design-rationale.html) -- why every protocol decision was made
739
- - [UCT Registry](https://sovereign.tenova.io/registry) -- 162 procedures, full factor definitions
956
+ - [UCT Registry](https://sovereign.tenova.io/registry) -- full procedure catalog with factor definitions
740
957
  - [Anchor Verifier](https://sovereign.tenova.io/verify) -- verify any anchor, zero server calls
741
958
  - [EU AI Act Regulatory Architecture](https://sovereign.tenova.io/guides/futurium-submission.html) -- VI+CJT+ALF+LAVR framework mapping for conformity assessment bodies
742
959
  - [Five Eyes Agentic AI Overlay](https://sovereign.tenova.io/guides/five-eyes-overlay.html) -- CISA/NSA guidance mapped to SWT3 procedures
package/dist/buffer.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  * prevents unbounded memory growth.
11
11
  */
12
12
  import type { WitnessConfig, WitnessPayload, WitnessReceipt } from "./types.js";
13
+ import type { WriteAheadLog } from "./wal.js";
13
14
  export declare class WitnessBuffer {
14
15
  private config;
15
16
  private queue;
@@ -20,8 +21,13 @@ export declare class WitnessBuffer {
20
21
  private stopped;
21
22
  private consecutiveFailures;
22
23
  private ctaShown;
24
+ private tokenAccumulator;
23
25
  private onFlush?;
24
- constructor(config: WitnessConfig, maxRetryBuffer?: number);
26
+ private wal;
27
+ private walSeqMap;
28
+ constructor(config: WitnessConfig, maxRetryBuffer?: number, wal?: WriteAheadLog);
29
+ /** Cumulative tokens accumulated since last flush (for token_budget monitoring). */
30
+ get tokensSinceFlush(): number;
25
31
  /** Add a single payload to the buffer. */
26
32
  enqueue(payload: WitnessPayload): void;
27
33
  /** Add multiple payloads. */
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAI/F,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,KAAK,CAA8C;IAC3D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAC,CAAmE;gBAEvE,MAAM,EAAE,aAAa,EAAE,cAAc,SAA2B;IAO5E,0CAA0C;IAC1C,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAQtC,6BAA6B;IAC7B,WAAW,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI;IAI7C,yCAAyC;IACnC,KAAK,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIxC,oDAAoD;IAC9C,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAgBvC,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,oDAAoD;IACpD,IAAI,eAAe,IA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,IAAI,MAAM,CAEpB;IAED,oDAAoD;IACpD,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,2CAA2C;IAC3C,IAAI,QAAQ,IAAI,cAAc,EAAE,CAE/B;IAED,OAAO,CAAC,UAAU;YAYJ,aAAa;YAYb,SAAS;CA8GxB"}
package/dist/buffer.js CHANGED
@@ -20,19 +20,41 @@ export class WitnessBuffer {
20
20
  stopped = false;
21
21
  consecutiveFailures = 0;
22
22
  ctaShown = false;
23
+ tokenAccumulator = 0;
23
24
  onFlush;
24
- constructor(config, maxRetryBuffer = DEFAULT_MAX_RETRY_BUFFER) {
25
+ wal = null;
26
+ walSeqMap = new Map();
27
+ constructor(config, maxRetryBuffer = DEFAULT_MAX_RETRY_BUFFER, wal) {
25
28
  this.config = config;
26
29
  this.maxRetryBuffer = maxRetryBuffer;
27
30
  this.onFlush = config.onFlush;
31
+ this.wal = wal ?? null;
28
32
  this.startTimer();
29
33
  }
34
+ /** Cumulative tokens accumulated since last flush (for token_budget monitoring). */
35
+ get tokensSinceFlush() {
36
+ return this.tokenAccumulator;
37
+ }
30
38
  /** Add a single payload to the buffer. */
31
39
  enqueue(payload) {
32
40
  if (this.stopped)
33
41
  return;
42
+ // WAL: replay protection (reject duplicates) + persist to disk
43
+ if (this.wal) {
44
+ const seq = this.wal.append(payload);
45
+ if (seq === -1) {
46
+ // Duplicate fingerprint -- silently skip
47
+ return;
48
+ }
49
+ this.walSeqMap.set(payload, seq);
50
+ }
51
+ // Track token accumulation for tokenBudget flush trigger
52
+ const tokens = (payload.ai_input_tokens ?? 0) + (payload.ai_output_tokens ?? 0);
53
+ if (tokens > 0)
54
+ this.tokenAccumulator += tokens;
34
55
  this.queue.push(payload);
35
- if (this.queue.length >= this.config.bufferSize) {
56
+ const tokenBudgetHit = this.config.tokenBudget != null && this.tokenAccumulator >= this.config.tokenBudget;
57
+ if (this.queue.length >= this.config.bufferSize || tokenBudgetHit) {
36
58
  this.flushInternal();
37
59
  }
38
60
  }
@@ -89,6 +111,7 @@ export class WitnessBuffer {
89
111
  const payloads = [...this.deadLetter, ...this.queue];
90
112
  this.deadLetter = [];
91
113
  this.queue = [];
114
+ this.tokenAccumulator = 0;
92
115
  if (payloads.length === 0)
93
116
  return [];
94
117
  return this.sendBatch(payloads);
@@ -118,7 +141,7 @@ export class WitnessBuffer {
118
141
  // Client error — don't retry, don't dead-letter
119
142
  const text = await resp.text();
120
143
  // Scrub any key material that might appear in error response body
121
- const safe = text.replace(/(?:Bearer|Authorization|api[_-]?key|signing[_-]?key)[^\s,;"]*/gi, "[REDACTED]");
144
+ const safe = text.replace(/(?:Bearer|Authorization|api[_-]?key|signing[_-]?key)\s*[^\s,;"]{4,}/gi, "[REDACTED]");
122
145
  console.error(`[swt3-ai] Batch flush failed (${resp.status}): ${safe.slice(0, 200)}`);
123
146
  return [];
124
147
  }
@@ -126,6 +149,18 @@ export class WitnessBuffer {
126
149
  const receipts = result.receipts ?? [];
127
150
  this.allReceipts.push(...receipts);
128
151
  this.consecutiveFailures = 0;
152
+ // WAL: mark flushed entries
153
+ if (this.wal) {
154
+ let maxSeq = 0;
155
+ for (const p of payloads) {
156
+ const s = this.walSeqMap.get(p);
157
+ if (s !== undefined && s > maxSeq)
158
+ maxSeq = s;
159
+ this.walSeqMap.delete(p);
160
+ }
161
+ if (maxSeq > 0)
162
+ this.wal.markFlushed(maxSeq);
163
+ }
129
164
  if (result.rejected > 0) {
130
165
  console.warn(`[swt3-ai] Batch flush: ${result.accepted} accepted, ${result.rejected} rejected`);
131
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,OAAO,aAAa;IAChB,MAAM,CAAgB;IACtB,KAAK,GAAqB,EAAE,CAAC;IAC7B,UAAU,GAAqB,EAAE,CAAC;IAClC,cAAc,CAAS;IACvB,WAAW,GAAq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AC,CAAC,EAAE,CAAC,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;QACH,CAAC;QAED,oDAAoD;QACpD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;QAElC,4BAA4B;QAC5B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YACjD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC;YAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACjD,OAAO,CAAC,KAAK,CACX,qCAAqC,OAAO,kCAAkC,IAAI,CAAC,cAAc,GAAG,CACrG,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,oCAAoC,QAAQ,CAAC,MAAM,0CAA0C,IAAI,CAAC,UAAU,CAAC,MAAM,aAAa,SAAS,EAAE,CAC5I,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * SWT3 CLI -- governance tooling for AI systems.
4
+ *
5
+ * Commands:
6
+ * swt3 init Interactive governance setup
7
+ * swt3 init --profile X Non-interactive (CI/CD friendly)
8
+ * swt3 demo Run the zero-friction demo
9
+ * swt3 doctor Diagnose config health
10
+ * swt3 help Show usage
11
+ */
12
+ export declare function generateInitYaml(profile: string, tenantId: string, agentId: string): string;
13
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AA4CH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAoB3F"}