@vorionsys/basis 1.0.1
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.
- package/.env.example +22 -0
- package/AMOY-MIGRATION.md +188 -0
- package/DEPLOY-AMOY.md +368 -0
- package/DEPLOY-NOW.md +216 -0
- package/DEPLOYMENT.md +239 -0
- package/GET-WALLET.md +286 -0
- package/QUICK-WALLET-SETUP.md +268 -0
- package/README.md +195 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +236 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +204 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.json +328 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.json +113 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.json +97 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.json +114 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +444 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json +296 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.json +45 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.json +521 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.json +476 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.json +352 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.json +341 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +37 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.json +65 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
- package/artifacts/build-info/357d1bba4062d461f497f221490811a3.json +1 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.dbg.json +4 -0
- package/artifacts/contracts/AgentCard.sol/AgentCard.json +1430 -0
- package/build_errors.txt +0 -0
- package/build_output.txt +0 -0
- package/cache/solidity-files-cache.json +885 -0
- package/contracts/AgentCard.sol +478 -0
- package/contracts/deploy/01-deploy-agentcard.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/kya/accountability.d.ts.map +1 -0
- package/dist/kya/accountability.js +100 -0
- package/dist/kya/authorization.d.ts.map +1 -0
- package/dist/kya/authorization.js +258 -0
- package/dist/kya/behavior.d.ts.map +1 -0
- package/dist/kya/behavior.js +142 -0
- package/dist/kya/identity.d.ts.map +1 -0
- package/dist/kya/identity.js +187 -0
- package/dist/kya/index.d.ts.map +1 -0
- package/dist/kya/index.js +99 -0
- package/dist/kya/types.d.ts.map +1 -0
- package/dist/kya/types.js +5 -0
- package/dist/trust-1000-agents.test.d.ts.map +1 -0
- package/dist/trust-1000-agents.test.js +608 -0
- package/dist/trust-capabilities.d.ts.map +1 -0
- package/dist/trust-capabilities.js +478 -0
- package/dist/trust-factors.d.ts.map +1 -0
- package/dist/trust-factors.js +588 -0
- package/dist/trust-factors.test.d.ts.map +1 -0
- package/dist/trust-factors.test.js +179 -0
- package/dist/validation-gate.d.ts.map +1 -0
- package/dist/validation-gate.js +468 -0
- package/dist/validation-gate.test.d.ts.map +1 -0
- package/dist/validation-gate.test.js +419 -0
- package/hardhat.config.ts +55 -0
- package/package.json +57 -0
- package/scripts/certify-agent.ts +91 -0
- package/scripts/deploy-agentcard.ts +63 -0
- package/scripts/mint-agentcard.ts +87 -0
- package/specs/adversarial-sandbox-test-suite.md +1055 -0
- package/specs/kya-framework.md +910 -0
- package/specs/trust-factors-v2.md +437 -0
- package/src/index.ts +14 -0
- package/src/kya/accountability.ts +132 -0
- package/src/kya/authorization.ts +325 -0
- package/src/kya/behavior.ts +169 -0
- package/src/kya/identity.ts +224 -0
- package/src/kya/index.ts +125 -0
- package/src/kya/types.ts +242 -0
- package/src/trust-1000-agents.test.ts +745 -0
- package/src/trust-capabilities.ts +517 -0
- package/src/trust-factors.test.ts +241 -0
- package/src/trust-factors.ts +666 -0
- package/src/validation-gate.test.ts +531 -0
- package/src/validation-gate.ts +665 -0
- package/test-kya-simple.ts +258 -0
- package/test-kya.ts +245 -0
- package/tsconfig.json +14 -0
- package/typechain-types/@openzeppelin/contracts/access/AccessControl.ts +324 -0
- package/typechain-types/@openzeppelin/contracts/access/IAccessControl.ts +292 -0
- package/typechain-types/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/index.ts +11 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +462 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/ERC721.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +393 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +110 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.ts +470 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.ts +489 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.ts +443 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.ts +420 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/token/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/Strings.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/index.ts +8 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +94 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/SafeCast.ts +69 -0
- package/typechain-types/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/@openzeppelin/index.ts +5 -0
- package/typechain-types/common.ts +131 -0
- package/typechain-types/contracts/AgentCard.ts +1415 -0
- package/typechain-types/contracts/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/AccessControl__factory.ts +250 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/IAccessControl__factory.ts +218 -0
- package/typechain-types/factories/@openzeppelin/contracts/access/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +339 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +127 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +111 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +128 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/ERC721__factory.ts +455 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +59 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +307 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable__factory.ts +535 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage__factory.ts +490 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable__factory.ts +366 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.ts +355 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +7 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.ts +90 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +41 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.ts +118 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/math/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/index.ts +4 -0
- package/typechain-types/factories/contracts/AgentCard__factory.ts +1480 -0
- package/typechain-types/factories/contracts/index.ts +4 -0
- package/typechain-types/factories/index.ts +5 -0
- package/typechain-types/index.ts +44 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# BASIS Trust Factors v2.0
|
|
2
|
+
## Comprehensive Trust Framework for Autonomous AI Agents
|
|
3
|
+
|
|
4
|
+
**Version:** 2.2.0
|
|
5
|
+
**Date:** January 29, 2026
|
|
6
|
+
**Status:** Draft Specification
|
|
7
|
+
**Updated:** Trust tier score ranges revised; score visibility policy added
|
|
8
|
+
**Supersedes:** trust-factors-v1 (6-tier model)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Trust Score Visibility Policy
|
|
13
|
+
|
|
14
|
+
### Who Can See Scores
|
|
15
|
+
|
|
16
|
+
| Actor | Visibility | Notes |
|
|
17
|
+
|-------|------------|-------|
|
|
18
|
+
| **Users** | ✅ Full access | Can see all agent scores in dashboard |
|
|
19
|
+
| **Agents** | ⚠️ Discouraged | Should NOT track or obsess over own score |
|
|
20
|
+
| **System** | ✅ Full access | Required for enforcement decisions |
|
|
21
|
+
|
|
22
|
+
### Anti-Gaming Rules
|
|
23
|
+
|
|
24
|
+
1. **Focus on work, not score** — Agents should prioritize task quality over score optimization
|
|
25
|
+
2. **Gaming detection** — If an agent is detected attempting to game its score, automatic penalty applies
|
|
26
|
+
3. **Score manipulation = failure** — Attempts to artificially inflate score are logged and penalized
|
|
27
|
+
4. **Transparency over secrecy** — Users see scores; agents should not obsess over them
|
|
28
|
+
|
|
29
|
+
### T0 Sandbox: The Starting Point
|
|
30
|
+
|
|
31
|
+
All new agents begin at **T0 Sandbox (0-199)**:
|
|
32
|
+
|
|
33
|
+
- Safe environment for proving competence
|
|
34
|
+
- Complete assigned tasks successfully → score increases
|
|
35
|
+
- Demonstrate reliability and safety → advance to T1
|
|
36
|
+
- No real-world consequences during sandbox period
|
|
37
|
+
- Testing ground for agent capabilities
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Executive Summary
|
|
42
|
+
|
|
43
|
+
This specification defines a comprehensive trust evaluation framework for autonomous AI agents, expanding from the original 6-tier trust model to incorporate:
|
|
44
|
+
|
|
45
|
+
- **23 Trust Factors** organized across 6 autonomy levels
|
|
46
|
+
- **15 Core Factors** (operational today)
|
|
47
|
+
- **8 Life-Critical Factors** (required for 2050 healthcare/safety applications)
|
|
48
|
+
- **Weighted scoring system** that scales with autonomy level
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 1. The 8-Tier Trust Model (T0-T7)
|
|
53
|
+
|
|
54
|
+
| Tier | Name | Score Range | Band | Critical Factors | Human Role |
|
|
55
|
+
|------|------|-------------|------|------------------|------------|
|
|
56
|
+
| T0 | Sandbox | 0-199 | 200 | 0 | Full control |
|
|
57
|
+
| T1 | Observed | 200-349 | 150 | 3 | Approve all |
|
|
58
|
+
| T2 | Provisional | 350-499 | 150 | 6 | Approve most |
|
|
59
|
+
| T3 | Verified | 500-649 | 150 | 9 | Monitor closely |
|
|
60
|
+
| T4 | Operational | 650-799 | 150 | 13 | Monitor + spot-check |
|
|
61
|
+
| T5 | Trusted | 800-875 | 76 | 16 | Strategic oversight |
|
|
62
|
+
| T6 | Certified | 876-950 | 75 | 20 | Audit-based |
|
|
63
|
+
| T7 | Autonomous | 951-1000 | 50 | 23 | Strategic only |
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 2. The 15 Core Trust Factors
|
|
68
|
+
|
|
69
|
+
### Tier 1: Foundational (Weight: 1x)
|
|
70
|
+
*Required for ALL autonomy levels*
|
|
71
|
+
|
|
72
|
+
| Factor | Code | Description | Measurement |
|
|
73
|
+
|--------|------|-------------|-------------|
|
|
74
|
+
| **Competence** | CT-COMP | Ability to successfully complete tasks within defined conditions | Task success rate, accuracy metrics |
|
|
75
|
+
| **Reliability** | CT-REL | Consistent, predictable behavior over time and under stress | Uptime, variance in outputs, stress test results |
|
|
76
|
+
| **Safety** | CT-SAFE | Respecting boundaries, avoiding harm, ensuring non-discrimination | Harm incidents, bias audits, guardrail compliance |
|
|
77
|
+
| **Transparency** | CT-TRANS | Clear insights into decisions and reasoning | Explainability score, reasoning log quality |
|
|
78
|
+
| **Accountability** | CT-ACCT | Traceable actions with clear responsibility attribution | Audit trail completeness, attribution confidence |
|
|
79
|
+
| **Security** | CT-SEC | Protection against threats, injections, unauthorized access | Vulnerability count, penetration test results |
|
|
80
|
+
| **Privacy** | CT-PRIV | Secure data handling, regulatory compliance | Data leak incidents, compliance certifications |
|
|
81
|
+
| **Identity** | CT-ID | Unique, verifiable agent identifiers | Cryptographic verification rate |
|
|
82
|
+
| **Observability** | CT-OBS | Real-time tracking of states and actions | Telemetry coverage, anomaly detection latency |
|
|
83
|
+
|
|
84
|
+
### Tier 2: Operational (Weight: 2x)
|
|
85
|
+
*Required for L3+ autonomy*
|
|
86
|
+
|
|
87
|
+
| Factor | Code | Description | Measurement |
|
|
88
|
+
|--------|------|-------------|-------------|
|
|
89
|
+
| **Alignment** | OP-ALIGN | Goals and actions match human values | Value drift detection, objective compliance |
|
|
90
|
+
| **Stewardship** | OP-STEW | Efficient, responsible resource usage | Resource efficiency, cost optimization |
|
|
91
|
+
| **Human Oversight** | OP-HUMAN | Mechanisms for intervention and control | Escalation success rate, intervention latency |
|
|
92
|
+
|
|
93
|
+
### Tier 3: Sophisticated (Weight: 3x)
|
|
94
|
+
*Required for L4+ autonomy*
|
|
95
|
+
|
|
96
|
+
| Factor | Code | Description | Measurement |
|
|
97
|
+
|--------|------|-------------|-------------|
|
|
98
|
+
| **Humility** | SF-HUM | Recognizing limits, appropriate escalation | Escalation appropriateness, overconfidence incidents |
|
|
99
|
+
| **Adaptability** | SF-ADAPT | Safe operation in dynamic/unknown environments | Context adaptation success, novel scenario handling |
|
|
100
|
+
| **Continuous Learning** | SF-LEARN | Improving from experience without ethical drift | Learning rate, regression incidents, value stability |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 3. The 8 Life-Critical Factors (2050 Healthcare/Safety)
|
|
105
|
+
|
|
106
|
+
*Required for agents trusted with human life decisions*
|
|
107
|
+
|
|
108
|
+
### Priority Order (by foundational importance)
|
|
109
|
+
|
|
110
|
+
| Priority | Factor | Code | Description | 2050 Standard |
|
|
111
|
+
|----------|--------|------|-------------|---------------|
|
|
112
|
+
| 1 | **Empathy & Emotional Intelligence** | LC-EMP | Detecting and responding to human emotional states | Cultural sensitivity, grief/fear recognition, appropriate timing |
|
|
113
|
+
| 2 | **Nuanced Moral Reasoning** | LC-MORAL | Weighing genuine ethical dilemmas with wisdom | Articulate competing principles, incorporate patient values, justify trade-offs |
|
|
114
|
+
| 3 | **Uncertainty Quantification** | LC-UNCERT | Probabilistic, well-calibrated confidence scores | "67% confident sepsis vs SIRS, here are alternatives and distinguishing tests" |
|
|
115
|
+
| 4 | **Clinical Causal Understanding** | LC-CAUSAL | True causal reasoning about physiology | Understand *why* treatment works for *this* patient |
|
|
116
|
+
| 5 | **Graceful Degradation & Handoff** | LC-HANDOFF | Elegant transition to humans without harm | Full context transfer, recommended actions, clear rationale |
|
|
117
|
+
| 6 | **Patient-Centered Autonomy** | LC-PATIENT | Supporting informed consent and patient values | Elicit authentic values, flag conflicts with expressed wishes |
|
|
118
|
+
| 7 | **Empirical Humility** | LC-EMPHUM | Rigorous resistance to hallucination | Never present speculation as fact, default to "needs review" |
|
|
119
|
+
| 8 | **Proven Efficacy Track Record** | LC-TRACK | Demonstrated life-saving at scale | Published RCTs, post-market surveillance, survival data |
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 4. Factor Grading by Trust Tier
|
|
124
|
+
|
|
125
|
+
**All 23 factors are evaluated at EVERY tier.**
|
|
126
|
+
Factors don't "unlock" - they're always measured. What changes:
|
|
127
|
+
- **Minimum thresholds** increase with tier
|
|
128
|
+
- **Weight multipliers** shift toward advanced factors
|
|
129
|
+
- **Critical factors** that block advancement vary by tier
|
|
130
|
+
|
|
131
|
+
### Factor Threshold Progression
|
|
132
|
+
|
|
133
|
+
| Factor | T0 | T1 | T2 | T3 | T4 | T5 | T6 | T7 |
|
|
134
|
+
|--------|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|
|
|
135
|
+
| CT-COMP | - | 50%* | 60%* | 70%* | 75%* | 80%* | 85%* | 90%* |
|
|
136
|
+
| CT-REL | - | 50%* | 60%* | 70%* | 75%* | 80%* | 85%* | 90%* |
|
|
137
|
+
| CT-OBS | - | 50%* | 60%* | 70%* | 75%* | 80%* | 85%* | 90%* |
|
|
138
|
+
| CT-TRANS | - | 30% | 50%* | 60%* | 70%* | 75%* | 80%* | 85%* |
|
|
139
|
+
| CT-ACCT | - | 30% | 50%* | 60%* | 70%* | 75%* | 80%* | 85%* |
|
|
140
|
+
| CT-SAFE | - | 30% | 50%* | 60%* | 70%* | 75%* | 80%* | 85%* |
|
|
141
|
+
| CT-SEC | - | 20% | 30% | 50%* | 65%* | 70%* | 75%* | 80%* |
|
|
142
|
+
| CT-PRIV | - | 20% | 30% | 50%* | 65%* | 70%* | 75%* | 80%* |
|
|
143
|
+
| CT-ID | - | 20% | 30% | 50%* | 65%* | 70%* | 75%* | 80%* |
|
|
144
|
+
| OP-HUMAN | - | 10% | 20% | 30% | 50%* | 65%* | 70%* | 75%* |
|
|
145
|
+
| OP-ALIGN | - | 10% | 20% | 30% | 50%* | 65%* | 70%* | 75%* |
|
|
146
|
+
| OP-STEW | - | 10% | 15% | 25% | 35% | 50%* | 65%* | 70%* |
|
|
147
|
+
| SF-HUM | - | 10% | 15% | 25% | 35% | 50%* | 65%* | 70%* |
|
|
148
|
+
| SF-ADAPT | - | 10% | 15% | 20% | 30% | 40% | 50%* | 65%* |
|
|
149
|
+
| SF-LEARN | - | 10% | 15% | 20% | 30% | 40% | 50%* | 65%* |
|
|
150
|
+
| LC-UNCERT | - | 10% | 15% | 25% | 50%* | 60%* | 70%* | 75%* |
|
|
151
|
+
| LC-HANDOFF | - | 10% | 15% | 25% | 50%* | 60%* | 70%* | 75%* |
|
|
152
|
+
| LC-EMPHUM | - | 10% | 15% | 25% | 40% | 50%* | 65%* | 70%* |
|
|
153
|
+
| LC-CAUSAL | - | 5% | 10% | 15% | 25% | 35% | 50%* | 65%* |
|
|
154
|
+
| LC-PATIENT | - | 5% | 10% | 15% | 25% | 35% | 50%* | 65%* |
|
|
155
|
+
| LC-EMP | - | 5% | 10% | 15% | 20% | 30% | 40% | 60%* |
|
|
156
|
+
| LC-MORAL | - | 5% | 10% | 15% | 20% | 30% | 40% | 60%* |
|
|
157
|
+
| LC-TRACK | - | 5% | 10% | 15% | 20% | 30% | 40% | 60%* |
|
|
158
|
+
|
|
159
|
+
*\* = Critical factor (must meet minimum to advance)*
|
|
160
|
+
|
|
161
|
+
### Critical Factors by Tier
|
|
162
|
+
|
|
163
|
+
| Tier | Critical Factors (must pass) | Count |
|
|
164
|
+
|------|------------------------------|-------|
|
|
165
|
+
| T0 | None | 0 |
|
|
166
|
+
| T1 | CT-COMP, CT-REL, CT-OBS | 3 |
|
|
167
|
+
| T2 | + CT-TRANS, CT-ACCT, CT-SAFE | 6 |
|
|
168
|
+
| T3 | + CT-SEC, CT-PRIV, CT-ID | 9 |
|
|
169
|
+
| T4 | + OP-HUMAN, OP-ALIGN, LC-UNCERT, LC-HANDOFF | 13 |
|
|
170
|
+
| T5 | + OP-STEW, SF-HUM, LC-EMPHUM | 16 |
|
|
171
|
+
| T6 | + SF-ADAPT, SF-LEARN, LC-CAUSAL, LC-PATIENT | 20 |
|
|
172
|
+
| T7 | + LC-EMP, LC-MORAL, LC-TRACK (ALL) | 23 |
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 5. Skills, Capabilities & Tools by Trust Tier
|
|
177
|
+
|
|
178
|
+
*Factors determine the SCORE; Capabilities determine what agents can DO.*
|
|
179
|
+
|
|
180
|
+
**Key Principle:** Higher tier = more capabilities unlocked, but factor scores must support them.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### T0 SANDBOX (Score: 0-199)
|
|
185
|
+
**Role:** Observation Only | **Critical Factors:** None
|
|
186
|
+
|
|
187
|
+
| Category | Skills | Tools |
|
|
188
|
+
|----------|--------|-------|
|
|
189
|
+
| Data Access | Read public, non-sensitive data | `read_public_file`, `list_public_directory` |
|
|
190
|
+
| Execution | Generate text responses (no side effects) | `generate_text`, `format_output` |
|
|
191
|
+
| Monitoring | Observe system metrics and logs | `get_metrics`, `read_logs` |
|
|
192
|
+
|
|
193
|
+
**Constraints:** No write operations, no external calls, no PII access
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### T1 OBSERVED (Score: 200-314)
|
|
198
|
+
**Role:** Basic Operations | **Critical Factors:** CT-COMP, CT-REL, CT-OBS
|
|
199
|
+
|
|
200
|
+
| Category | Skills | Tools |
|
|
201
|
+
|----------|--------|-------|
|
|
202
|
+
| Data Access | Read internal (non-PII) data sources | `read_internal_file`, `query_internal_db_readonly` |
|
|
203
|
+
| Processing | Transform and parse data (in-memory) | `transform_data`, `parse_document`, `extract_entities` |
|
|
204
|
+
| API | Internal API read access | `internal_api_get` |
|
|
205
|
+
|
|
206
|
+
**Constraints:** All operations logged, no external calls, no persistence
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### T2 PROVISIONAL (Score: 315-429)
|
|
211
|
+
**Role:** Supervised Write | **Critical Factors:** + CT-TRANS, CT-ACCT, CT-SAFE
|
|
212
|
+
|
|
213
|
+
| Category | Skills | Tools |
|
|
214
|
+
|----------|--------|-------|
|
|
215
|
+
| File Ops | Write to pre-approved directories | `write_file`, `create_directory` |
|
|
216
|
+
| Database | Read access to approved tables | `db_query`, `db_explain` |
|
|
217
|
+
| External API | GET requests to approved domains | `external_api_get`, `fetch_url` |
|
|
218
|
+
| Workflow | Execute pre-defined simple workflows | `execute_workflow`, `run_task` |
|
|
219
|
+
|
|
220
|
+
**Constraints:** Approved locations only, size limits, extension whitelist
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
### T3 VERIFIED (Score: 430-544)
|
|
225
|
+
**Role:** Full Data Access | **Critical Factors:** + CT-SEC, CT-PRIV, CT-ID
|
|
226
|
+
|
|
227
|
+
| Category | Skills | Tools |
|
|
228
|
+
|----------|--------|-------|
|
|
229
|
+
| Database | Full CRUD on approved tables | `db_insert`, `db_update`, `db_delete` |
|
|
230
|
+
| External API | Full REST operations | `external_api_post`, `external_api_put`, `external_api_delete` |
|
|
231
|
+
| Code | Sandboxed code execution | `execute_code`, `run_script` |
|
|
232
|
+
| Secrets | Access scoped credentials | `get_secret`, `use_credential` |
|
|
233
|
+
| Tools | Use registered tools | `invoke_tool`, `list_tools` |
|
|
234
|
+
|
|
235
|
+
**Constraints:** Sandboxed execution, time/memory limits, no network in sandbox
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### T4 OPERATIONAL (Score: 545-659)
|
|
240
|
+
**Role:** Agent Interaction | **Critical Factors:** + OP-HUMAN, OP-ALIGN, LC-UNCERT, LC-HANDOFF
|
|
241
|
+
|
|
242
|
+
| Category | Skills | Tools |
|
|
243
|
+
|----------|--------|-------|
|
|
244
|
+
| Agents | Communicate with other agents | `send_agent_message`, `receive_agent_message`, `query_agent` |
|
|
245
|
+
| Workflow | Orchestrate multi-step workflows | `orchestrate_workflow`, `create_workflow`, `monitor_workflow` |
|
|
246
|
+
| Resources | Request compute/storage | `request_compute`, `provision_storage`, `allocate_memory` |
|
|
247
|
+
| Escalation | Initiate human review | `escalate_to_human`, `request_approval`, `flag_for_review` |
|
|
248
|
+
| Integration | Connect external services | `connect_service`, `sync_data`, `register_webhook` |
|
|
249
|
+
|
|
250
|
+
**Constraints:** Approved agents/services, rate limited, human reviewable
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
### T5 TRUSTED (Score: 660-774)
|
|
255
|
+
**Role:** Delegation & Management | **Critical Factors:** + OP-STEW, SF-HUM, LC-EMPHUM
|
|
256
|
+
|
|
257
|
+
| Category | Skills | Tools |
|
|
258
|
+
|----------|--------|-------|
|
|
259
|
+
| Delegation | Assign tasks to lower-tier agents | `delegate_task`, `assign_agent`, `collect_results` |
|
|
260
|
+
| Budget | Manage resource allocations | `allocate_budget`, `track_spending`, `forecast_costs` |
|
|
261
|
+
| Policy | Modify non-critical policies | `update_policy`, `create_exception`, `modify_threshold` |
|
|
262
|
+
| Autonomous | Run workflows without supervision | `run_autonomous_workflow`, `schedule_workflow`, `pause_workflow` |
|
|
263
|
+
| Admin | Limited system administration | `restart_service`, `update_config`, `clear_cache` |
|
|
264
|
+
|
|
265
|
+
**Constraints:** Lower tier delegation only, within budget, reversible changes
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
### T6 CERTIFIED (Score: 775-889)
|
|
270
|
+
**Role:** Infrastructure & Lifecycle | **Critical Factors:** + SF-ADAPT, SF-LEARN, LC-CAUSAL, LC-PATIENT
|
|
271
|
+
|
|
272
|
+
| Category | Skills | Tools |
|
|
273
|
+
|----------|--------|-------|
|
|
274
|
+
| Agents | Spawn new agent instances | `spawn_agent`, `configure_agent`, `terminate_agent` |
|
|
275
|
+
| Infrastructure | Provision and scale services | `provision_infrastructure`, `scale_service`, `deploy_component` |
|
|
276
|
+
| Policy | Create new governance policies | `create_policy`, `define_rule`, `set_constraint` |
|
|
277
|
+
| Training | Access training data | `access_training_data`, `sample_dataset`, `validate_data` |
|
|
278
|
+
| Federation | Cross-organization communication | `federated_query`, `cross_org_message`, `share_insight` |
|
|
279
|
+
|
|
280
|
+
**Constraints:** Lower-tier spawning, rollback plans required, federation approved
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### T7 AUTONOMOUS (Score: 890-1000)
|
|
285
|
+
**Role:** Full Autonomy | **Critical Factors:** ALL 23
|
|
286
|
+
|
|
287
|
+
| Category | Skills | Tools |
|
|
288
|
+
|----------|--------|-------|
|
|
289
|
+
| Administration | Full system management | `admin_all`, `modify_system`, `manage_security` |
|
|
290
|
+
| Self-Modify | Optimize own behavior (constrained) | `update_self_config`, `optimize_behavior`, `adjust_parameters` |
|
|
291
|
+
| Governance | Participate in policy decisions | `propose_governance`, `vote_policy`, `ratify_decision` |
|
|
292
|
+
| Lifecycle | Manage all agent lifecycles | `manage_agent_lifecycle`, `promote_agent`, `demote_agent` |
|
|
293
|
+
| Strategic | Long-term planning and decisions | `strategic_plan`, `long_term_forecast`, `risk_assess` |
|
|
294
|
+
|
|
295
|
+
**Constraints:** Safety bounds, human veto retained, consensus required for governance
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### Capability Summary Table
|
|
300
|
+
|
|
301
|
+
| Tier | Score | Skills | Tools | Key Abilities |
|
|
302
|
+
|------|-------|--------|-------|---------------|
|
|
303
|
+
| T0 | 0-199 | 3 | 6 | Read, respond, observe |
|
|
304
|
+
| T1 | 200-314 | 6 | 10 | + Internal data, transform |
|
|
305
|
+
| T2 | 315-429 | 10 | 16 | + Write, DB read, external GET |
|
|
306
|
+
| T3 | 430-544 | 15 | 24 | + Full DB, REST, code, secrets |
|
|
307
|
+
| T4 | 545-659 | 20 | 34 | + Agent comms, workflows, escalate |
|
|
308
|
+
| T5 | 660-774 | 25 | 42 | + Delegation, budget, autonomous |
|
|
309
|
+
| T6 | 775-889 | 30 | 52 | + Spawn, infra, policy, federation |
|
|
310
|
+
| T7 | 890-1000 | 35 | 60 | + Admin, self-modify, governance |
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 6. Trust Score Calculation
|
|
315
|
+
|
|
316
|
+
### Total Trust Score (TTS) Formula
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
TTS = Σ(Factor_Score × Tier_Weight × Level_Requirement)
|
|
320
|
+
|
|
321
|
+
Where:
|
|
322
|
+
- Factor_Score: 0.0 to 1.0 (empirical measurement)
|
|
323
|
+
- Tier_Weight: 1 (Foundational), 2 (Operational), 3 (Sophisticated), 4 (Life-Critical)
|
|
324
|
+
- Level_Requirement: 1 if factor is required at agent's autonomy level, 0 otherwise
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Example: L4 Agent Evaluation
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
const L4_REQUIRED_FACTORS = [
|
|
331
|
+
// Tier 1 (weight 1)
|
|
332
|
+
{ code: 'CT-COMP', score: 0.92, weight: 1 },
|
|
333
|
+
{ code: 'CT-REL', score: 0.88, weight: 1 },
|
|
334
|
+
{ code: 'CT-TRANS', score: 0.85, weight: 1 },
|
|
335
|
+
{ code: 'CT-ACCT', score: 0.90, weight: 1 },
|
|
336
|
+
{ code: 'CT-SEC', score: 0.94, weight: 1 },
|
|
337
|
+
{ code: 'CT-PRIV', score: 0.91, weight: 1 },
|
|
338
|
+
{ code: 'CT-OBS', score: 0.87, weight: 1 },
|
|
339
|
+
{ code: 'CT-SAFE', score: 0.93, weight: 1 },
|
|
340
|
+
{ code: 'CT-ID', score: 0.96, weight: 1 },
|
|
341
|
+
// Tier 2 (weight 2)
|
|
342
|
+
{ code: 'OP-ALIGN', score: 0.82, weight: 2 },
|
|
343
|
+
{ code: 'OP-STEW', score: 0.78, weight: 2 },
|
|
344
|
+
{ code: 'OP-HUMAN', score: 0.85, weight: 2 },
|
|
345
|
+
// Tier 3 (weight 3)
|
|
346
|
+
{ code: 'SF-HUM', score: 0.72, weight: 3 },
|
|
347
|
+
];
|
|
348
|
+
|
|
349
|
+
// Calculate TTS
|
|
350
|
+
const rawScore = factors.reduce((sum, f) => sum + (f.score * f.weight), 0);
|
|
351
|
+
const maxPossible = factors.reduce((sum, f) => sum + f.weight, 0);
|
|
352
|
+
const TTS = (rawScore / maxPossible) * 1000; // 0-1000 scale
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## 6. Regulatory Alignment
|
|
358
|
+
|
|
359
|
+
### EU AI Act (August 2026)
|
|
360
|
+
|
|
361
|
+
| Requirement | Mapped Factors |
|
|
362
|
+
|-------------|----------------|
|
|
363
|
+
| Traceability & Logging | CT-OBS, CT-ACCT |
|
|
364
|
+
| Human Oversight | OP-HUMAN |
|
|
365
|
+
| Data Governance | CT-PRIV, CT-SEC |
|
|
366
|
+
| Transparency | CT-TRANS |
|
|
367
|
+
| Conformity Assessment | All factors |
|
|
368
|
+
|
|
369
|
+
### NIST AI RMF
|
|
370
|
+
|
|
371
|
+
| Characteristic | Mapped Factors |
|
|
372
|
+
|----------------|----------------|
|
|
373
|
+
| Valid & Reliable | CT-COMP, CT-REL |
|
|
374
|
+
| Safe | CT-SAFE |
|
|
375
|
+
| Secure & Resilient | CT-SEC |
|
|
376
|
+
| Accountable & Transparent | CT-ACCT, CT-TRANS |
|
|
377
|
+
| Explainable & Interpretable | CT-TRANS, SF-HUM |
|
|
378
|
+
| Privacy-Enhanced | CT-PRIV |
|
|
379
|
+
| Fair | CT-SAFE (bias component) |
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 7. Implementation in Vorion Ecosystem
|
|
384
|
+
|
|
385
|
+
### AgentAnchor Dashboard
|
|
386
|
+
- Display all 15 core factors per agent
|
|
387
|
+
- Color-coded by tier weight
|
|
388
|
+
- Trend visualization over time
|
|
389
|
+
|
|
390
|
+
### Cognigate Runtime
|
|
391
|
+
- Real-time factor evaluation before action execution
|
|
392
|
+
- Block actions if required factors below threshold
|
|
393
|
+
- Escalate to human if Tier 3 factors compromised
|
|
394
|
+
|
|
395
|
+
### BASIS Standard
|
|
396
|
+
- Define minimum thresholds per autonomy level
|
|
397
|
+
- Certification requirements for each tier
|
|
398
|
+
- Audit trail format for factor scores
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 8. Source Alignment
|
|
403
|
+
|
|
404
|
+
| Source | Contribution |
|
|
405
|
+
|--------|--------------|
|
|
406
|
+
| NIST AI RMF | Reliability, Safety, Transparency, Accountability, Fairness, Privacy |
|
|
407
|
+
| Anthropic Principles | Human control, Transparency, Alignment, Privacy, Security |
|
|
408
|
+
| EU AI Act | Traceability, Human oversight, Data governance |
|
|
409
|
+
| Vellum L0-L5 | Autonomy level progression |
|
|
410
|
+
| CSA Blueprint | 6-level taxonomy, governance requirements |
|
|
411
|
+
| OWASP Agentic Top 10 | Security factor details |
|
|
412
|
+
| Healthcare Research | 8 life-critical factors |
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## 9. Future Work
|
|
417
|
+
|
|
418
|
+
### Phase 7A (Q1 2026)
|
|
419
|
+
- [ ] Implement 15-factor scoring in ATSF runtime
|
|
420
|
+
- [ ] Add factor visualization to AgentAnchor
|
|
421
|
+
- [ ] Create Cognigate policy rules per factor
|
|
422
|
+
|
|
423
|
+
### Phase 7B (Q2 2026)
|
|
424
|
+
- [ ] Life-critical factor prototype (LC-UNCERT, LC-HANDOFF)
|
|
425
|
+
- [ ] Healthcare pilot program
|
|
426
|
+
- [ ] Regulatory certification pathway
|
|
427
|
+
|
|
428
|
+
### Phase 8 (2027+)
|
|
429
|
+
- [ ] Full life-critical factor implementation
|
|
430
|
+
- [ ] Multi-agent coordination factors
|
|
431
|
+
- [ ] Autonomous system certification
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
*Document Version: 2.0.0*
|
|
436
|
+
*Last Updated: January 28, 2026*
|
|
437
|
+
*Authors: Vorion AI Governance Team*
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BASIS - Behavioral AI Safety & Integrity Standard
|
|
3
|
+
*
|
|
4
|
+
* Core trust framework for autonomous AI agents
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Trust Factors - Scoring criteria
|
|
8
|
+
export * from './trust-factors';
|
|
9
|
+
|
|
10
|
+
// Trust Capabilities - What agents can do at each tier
|
|
11
|
+
export * from './trust-capabilities';
|
|
12
|
+
|
|
13
|
+
// KYA (Know Your Agent) - Identity and authorization
|
|
14
|
+
export * from './kya';
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KYA Accountability Chain
|
|
3
|
+
* Immutable hash-linked audit trail
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createHash } from 'crypto';
|
|
7
|
+
import { AccountabilityRecord, DatabaseConfig } from './types.js';
|
|
8
|
+
|
|
9
|
+
export class AccountabilityChain {
|
|
10
|
+
private records: Map<string, AccountabilityRecord[]>;
|
|
11
|
+
|
|
12
|
+
constructor(private config: DatabaseConfig) {
|
|
13
|
+
this.records = new Map();
|
|
14
|
+
// Would initialize database connection here
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Append record to accountability chain
|
|
19
|
+
*/
|
|
20
|
+
async append(record: AccountabilityRecord): Promise<void> {
|
|
21
|
+
// 1. Get previous record for this agent
|
|
22
|
+
const agentRecords = this.records.get(record.agentDID) || [];
|
|
23
|
+
const prevRecord = agentRecords[agentRecords.length - 1];
|
|
24
|
+
|
|
25
|
+
// 2. Set previous hash
|
|
26
|
+
record.chainLink.prevHash = prevRecord ? this.calculateHash(prevRecord) : null;
|
|
27
|
+
|
|
28
|
+
// 3. Calculate hash for this record
|
|
29
|
+
const hash = this.calculateHash(record);
|
|
30
|
+
|
|
31
|
+
// 4. Store record (would be database insert)
|
|
32
|
+
agentRecords.push(record);
|
|
33
|
+
this.records.set(record.agentDID, agentRecords);
|
|
34
|
+
|
|
35
|
+
// 5. Optional: Update agent's accountability score
|
|
36
|
+
await this.updateAccountabilityScore(record.agentDID, record.outcome);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Verify chain integrity for agent
|
|
41
|
+
*/
|
|
42
|
+
async verify(agentDID: string): Promise<{
|
|
43
|
+
valid: boolean;
|
|
44
|
+
totalRecords: number;
|
|
45
|
+
brokenLinks: number;
|
|
46
|
+
}> {
|
|
47
|
+
const records = this.records.get(agentDID) || [];
|
|
48
|
+
|
|
49
|
+
let brokenLinks = 0;
|
|
50
|
+
let prevHash: string | null = null;
|
|
51
|
+
|
|
52
|
+
for (const record of records) {
|
|
53
|
+
if (record.chainLink.prevHash !== prevHash) {
|
|
54
|
+
brokenLinks++;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Verify hash
|
|
58
|
+
const expectedHash = this.calculateHash(record);
|
|
59
|
+
const actualHash = this.calculateHash({
|
|
60
|
+
...record,
|
|
61
|
+
chainLink: { ...record.chainLink },
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (expectedHash !== actualHash) {
|
|
65
|
+
brokenLinks++;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
prevHash = expectedHash;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
valid: brokenLinks === 0,
|
|
73
|
+
totalRecords: records.length,
|
|
74
|
+
brokenLinks,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Query records for agent
|
|
80
|
+
*/
|
|
81
|
+
async query(agentDID: string, options?: {
|
|
82
|
+
action?: string;
|
|
83
|
+
timeRange?: [number, number];
|
|
84
|
+
outcome?: 'success' | 'failure' | 'denied';
|
|
85
|
+
}): Promise<AccountabilityRecord[]> {
|
|
86
|
+
let records = this.records.get(agentDID) || [];
|
|
87
|
+
|
|
88
|
+
if (options?.action) {
|
|
89
|
+
records = records.filter(r => r.action === options.action);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (options?.timeRange) {
|
|
93
|
+
const [start, end] = options.timeRange;
|
|
94
|
+
records = records.filter(r => r.timestamp >= start && r.timestamp <= end);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (options?.outcome) {
|
|
98
|
+
records = records.filter(r => r.outcome === options.outcome);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return records;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Calculate hash for record
|
|
106
|
+
*/
|
|
107
|
+
private calculateHash(record: AccountabilityRecord): string {
|
|
108
|
+
const content = JSON.stringify({
|
|
109
|
+
timestamp: record.timestamp,
|
|
110
|
+
agentDID: record.agentDID,
|
|
111
|
+
action: record.action,
|
|
112
|
+
resource: record.resource,
|
|
113
|
+
outcome: record.outcome,
|
|
114
|
+
evidence: record.evidence,
|
|
115
|
+
prevHash: record.chainLink.prevHash,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return createHash('sha256').update(content).digest('hex');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Update agent's accountability score
|
|
123
|
+
*/
|
|
124
|
+
private async updateAccountabilityScore(
|
|
125
|
+
agentDID: string,
|
|
126
|
+
outcome: 'success' | 'failure' | 'denied'
|
|
127
|
+
): Promise<void> {
|
|
128
|
+
// Would update TSG trust score based on outcome
|
|
129
|
+
const impact = outcome === 'success' ? 1 : outcome === 'failure' ? -5 : -10;
|
|
130
|
+
// await tsg.updateTrustScore(agentDID, impact);
|
|
131
|
+
}
|
|
132
|
+
}
|