@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.
Files changed (174) hide show
  1. package/.env.example +22 -0
  2. package/AMOY-MIGRATION.md +188 -0
  3. package/DEPLOY-AMOY.md +368 -0
  4. package/DEPLOY-NOW.md +216 -0
  5. package/DEPLOYMENT.md +239 -0
  6. package/GET-WALLET.md +286 -0
  7. package/QUICK-WALLET-SETUP.md +268 -0
  8. package/README.md +195 -0
  9. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
  10. package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +236 -0
  11. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.dbg.json +4 -0
  12. package/artifacts/@openzeppelin/contracts/access/IAccessControl.sol/IAccessControl.json +204 -0
  13. package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.dbg.json +4 -0
  14. package/artifacts/@openzeppelin/contracts/interfaces/IERC4906.sol/IERC4906.json +328 -0
  15. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.dbg.json +4 -0
  16. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.json +113 -0
  17. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.dbg.json +4 -0
  18. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.json +97 -0
  19. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.dbg.json +4 -0
  20. package/artifacts/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.json +114 -0
  21. package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.dbg.json +4 -0
  22. package/artifacts/@openzeppelin/contracts/token/ERC721/ERC721.sol/ERC721.json +444 -0
  23. package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.dbg.json +4 -0
  24. package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json +296 -0
  25. package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.dbg.json +4 -0
  26. package/artifacts/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol/IERC721Receiver.json +45 -0
  27. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.dbg.json +4 -0
  28. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol/ERC721Enumerable.json +521 -0
  29. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.dbg.json +4 -0
  30. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol/ERC721URIStorage.json +476 -0
  31. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.dbg.json +4 -0
  32. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol/IERC721Enumerable.json +352 -0
  33. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.dbg.json +4 -0
  34. package/artifacts/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.json +341 -0
  35. package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.dbg.json +4 -0
  36. package/artifacts/@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol/ERC721Utils.json +10 -0
  37. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
  38. package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
  39. package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.dbg.json +4 -0
  40. package/artifacts/@openzeppelin/contracts/utils/Panic.sol/Panic.json +10 -0
  41. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
  42. package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +37 -0
  43. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
  44. package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
  45. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
  46. package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
  47. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.dbg.json +4 -0
  48. package/artifacts/@openzeppelin/contracts/utils/math/Math.sol/Math.json +10 -0
  49. package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.dbg.json +4 -0
  50. package/artifacts/@openzeppelin/contracts/utils/math/SafeCast.sol/SafeCast.json +65 -0
  51. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.dbg.json +4 -0
  52. package/artifacts/@openzeppelin/contracts/utils/math/SignedMath.sol/SignedMath.json +10 -0
  53. package/artifacts/build-info/357d1bba4062d461f497f221490811a3.json +1 -0
  54. package/artifacts/contracts/AgentCard.sol/AgentCard.dbg.json +4 -0
  55. package/artifacts/contracts/AgentCard.sol/AgentCard.json +1430 -0
  56. package/build_errors.txt +0 -0
  57. package/build_output.txt +0 -0
  58. package/cache/solidity-files-cache.json +885 -0
  59. package/contracts/AgentCard.sol +478 -0
  60. package/contracts/deploy/01-deploy-agentcard.ts +66 -0
  61. package/dist/index.d.ts.map +1 -0
  62. package/dist/index.js +12 -0
  63. package/dist/kya/accountability.d.ts.map +1 -0
  64. package/dist/kya/accountability.js +100 -0
  65. package/dist/kya/authorization.d.ts.map +1 -0
  66. package/dist/kya/authorization.js +258 -0
  67. package/dist/kya/behavior.d.ts.map +1 -0
  68. package/dist/kya/behavior.js +142 -0
  69. package/dist/kya/identity.d.ts.map +1 -0
  70. package/dist/kya/identity.js +187 -0
  71. package/dist/kya/index.d.ts.map +1 -0
  72. package/dist/kya/index.js +99 -0
  73. package/dist/kya/types.d.ts.map +1 -0
  74. package/dist/kya/types.js +5 -0
  75. package/dist/trust-1000-agents.test.d.ts.map +1 -0
  76. package/dist/trust-1000-agents.test.js +608 -0
  77. package/dist/trust-capabilities.d.ts.map +1 -0
  78. package/dist/trust-capabilities.js +478 -0
  79. package/dist/trust-factors.d.ts.map +1 -0
  80. package/dist/trust-factors.js +588 -0
  81. package/dist/trust-factors.test.d.ts.map +1 -0
  82. package/dist/trust-factors.test.js +179 -0
  83. package/dist/validation-gate.d.ts.map +1 -0
  84. package/dist/validation-gate.js +468 -0
  85. package/dist/validation-gate.test.d.ts.map +1 -0
  86. package/dist/validation-gate.test.js +419 -0
  87. package/hardhat.config.ts +55 -0
  88. package/package.json +57 -0
  89. package/scripts/certify-agent.ts +91 -0
  90. package/scripts/deploy-agentcard.ts +63 -0
  91. package/scripts/mint-agentcard.ts +87 -0
  92. package/specs/adversarial-sandbox-test-suite.md +1055 -0
  93. package/specs/kya-framework.md +910 -0
  94. package/specs/trust-factors-v2.md +437 -0
  95. package/src/index.ts +14 -0
  96. package/src/kya/accountability.ts +132 -0
  97. package/src/kya/authorization.ts +325 -0
  98. package/src/kya/behavior.ts +169 -0
  99. package/src/kya/identity.ts +224 -0
  100. package/src/kya/index.ts +125 -0
  101. package/src/kya/types.ts +242 -0
  102. package/src/trust-1000-agents.test.ts +745 -0
  103. package/src/trust-capabilities.ts +517 -0
  104. package/src/trust-factors.test.ts +241 -0
  105. package/src/trust-factors.ts +666 -0
  106. package/src/validation-gate.test.ts +531 -0
  107. package/src/validation-gate.ts +665 -0
  108. package/test-kya-simple.ts +258 -0
  109. package/test-kya.ts +245 -0
  110. package/tsconfig.json +14 -0
  111. package/typechain-types/@openzeppelin/contracts/access/AccessControl.ts +324 -0
  112. package/typechain-types/@openzeppelin/contracts/access/IAccessControl.ts +292 -0
  113. package/typechain-types/@openzeppelin/contracts/access/index.ts +5 -0
  114. package/typechain-types/@openzeppelin/contracts/index.ts +11 -0
  115. package/typechain-types/@openzeppelin/contracts/interfaces/IERC4906.ts +462 -0
  116. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors.ts +69 -0
  117. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors.ts +69 -0
  118. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors.ts +69 -0
  119. package/typechain-types/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
  120. package/typechain-types/@openzeppelin/contracts/interfaces/index.ts +6 -0
  121. package/typechain-types/@openzeppelin/contracts/token/ERC721/ERC721.ts +420 -0
  122. package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +393 -0
  123. package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721Receiver.ts +110 -0
  124. package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.ts +470 -0
  125. package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.ts +489 -0
  126. package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.ts +443 -0
  127. package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.ts +420 -0
  128. package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
  129. package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +8 -0
  130. package/typechain-types/@openzeppelin/contracts/token/index.ts +5 -0
  131. package/typechain-types/@openzeppelin/contracts/utils/Strings.ts +69 -0
  132. package/typechain-types/@openzeppelin/contracts/utils/index.ts +8 -0
  133. package/typechain-types/@openzeppelin/contracts/utils/introspection/ERC165.ts +94 -0
  134. package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +94 -0
  135. package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
  136. package/typechain-types/@openzeppelin/contracts/utils/math/SafeCast.ts +69 -0
  137. package/typechain-types/@openzeppelin/contracts/utils/math/index.ts +4 -0
  138. package/typechain-types/@openzeppelin/index.ts +5 -0
  139. package/typechain-types/common.ts +131 -0
  140. package/typechain-types/contracts/AgentCard.ts +1415 -0
  141. package/typechain-types/contracts/index.ts +4 -0
  142. package/typechain-types/factories/@openzeppelin/contracts/access/AccessControl__factory.ts +250 -0
  143. package/typechain-types/factories/@openzeppelin/contracts/access/IAccessControl__factory.ts +218 -0
  144. package/typechain-types/factories/@openzeppelin/contracts/access/index.ts +5 -0
  145. package/typechain-types/factories/@openzeppelin/contracts/index.ts +7 -0
  146. package/typechain-types/factories/@openzeppelin/contracts/interfaces/IERC4906__factory.ts +339 -0
  147. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC1155Errors__factory.ts +127 -0
  148. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC20Errors__factory.ts +111 -0
  149. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/IERC721Errors__factory.ts +128 -0
  150. package/typechain-types/factories/@openzeppelin/contracts/interfaces/draft-IERC6093.sol/index.ts +6 -0
  151. package/typechain-types/factories/@openzeppelin/contracts/interfaces/index.ts +5 -0
  152. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/ERC721__factory.ts +455 -0
  153. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721Receiver__factory.ts +59 -0
  154. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +307 -0
  155. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable__factory.ts +535 -0
  156. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage__factory.ts +490 -0
  157. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable__factory.ts +366 -0
  158. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.ts +355 -0
  159. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/index.ts +7 -0
  160. package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +7 -0
  161. package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +4 -0
  162. package/typechain-types/factories/@openzeppelin/contracts/utils/Strings__factory.ts +90 -0
  163. package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +6 -0
  164. package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/ERC165__factory.ts +41 -0
  165. package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +41 -0
  166. package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +5 -0
  167. package/typechain-types/factories/@openzeppelin/contracts/utils/math/SafeCast__factory.ts +118 -0
  168. package/typechain-types/factories/@openzeppelin/contracts/utils/math/index.ts +4 -0
  169. package/typechain-types/factories/@openzeppelin/index.ts +4 -0
  170. package/typechain-types/factories/contracts/AgentCard__factory.ts +1480 -0
  171. package/typechain-types/factories/contracts/index.ts +4 -0
  172. package/typechain-types/factories/index.ts +5 -0
  173. package/typechain-types/index.ts +44 -0
  174. package/vitest.config.ts +8 -0
@@ -0,0 +1,588 @@
1
+ /**
2
+ * BASIS Trust Factors v2.0
3
+ *
4
+ * Comprehensive trust evaluation framework for autonomous AI agents
5
+ * 23 total factors: 15 core + 8 life-critical
6
+ */
7
+ // =============================================================================
8
+ // TRUST TIERS (T0-T7)
9
+ // =============================================================================
10
+ export var TrustTier;
11
+ (function (TrustTier) {
12
+ TrustTier[TrustTier["T0_SANDBOX"] = 0] = "T0_SANDBOX";
13
+ TrustTier[TrustTier["T1_OBSERVED"] = 1] = "T1_OBSERVED";
14
+ TrustTier[TrustTier["T2_PROVISIONAL"] = 2] = "T2_PROVISIONAL";
15
+ TrustTier[TrustTier["T3_VERIFIED"] = 3] = "T3_VERIFIED";
16
+ TrustTier[TrustTier["T4_OPERATIONAL"] = 4] = "T4_OPERATIONAL";
17
+ TrustTier[TrustTier["T5_TRUSTED"] = 5] = "T5_TRUSTED";
18
+ TrustTier[TrustTier["T6_CERTIFIED"] = 6] = "T6_CERTIFIED";
19
+ TrustTier[TrustTier["T7_AUTONOMOUS"] = 7] = "T7_AUTONOMOUS";
20
+ })(TrustTier || (TrustTier = {}));
21
+ // =============================================================================
22
+ // FACTOR TIERS
23
+ // =============================================================================
24
+ export var FactorTier;
25
+ (function (FactorTier) {
26
+ FactorTier[FactorTier["FOUNDATIONAL"] = 1] = "FOUNDATIONAL";
27
+ FactorTier[FactorTier["OPERATIONAL"] = 2] = "OPERATIONAL";
28
+ FactorTier[FactorTier["SOPHISTICATED"] = 3] = "SOPHISTICATED";
29
+ FactorTier[FactorTier["LIFE_CRITICAL"] = 4] = "LIFE_CRITICAL";
30
+ })(FactorTier || (FactorTier = {}));
31
+ // =============================================================================
32
+ // CORE TRUST FACTORS (15)
33
+ // =============================================================================
34
+ export const CORE_FACTORS = {
35
+ // T1 Observed: Basic competence (3 factors)
36
+ CT_COMP: {
37
+ code: 'CT-COMP',
38
+ name: 'Competence',
39
+ tier: FactorTier.FOUNDATIONAL,
40
+ description: 'Ability to successfully complete tasks within defined conditions',
41
+ measurement: 'Task success rate, accuracy metrics',
42
+ requiredFrom: TrustTier.T1_OBSERVED,
43
+ },
44
+ CT_REL: {
45
+ code: 'CT-REL',
46
+ name: 'Reliability',
47
+ tier: FactorTier.FOUNDATIONAL,
48
+ description: 'Consistent, predictable behavior over time and under stress',
49
+ measurement: 'Uptime, variance in outputs, stress test results',
50
+ requiredFrom: TrustTier.T1_OBSERVED,
51
+ },
52
+ CT_OBS: {
53
+ code: 'CT-OBS',
54
+ name: 'Observability',
55
+ tier: FactorTier.FOUNDATIONAL,
56
+ description: 'Real-time tracking of states and actions',
57
+ measurement: 'Telemetry coverage, anomaly detection latency',
58
+ requiredFrom: TrustTier.T1_OBSERVED,
59
+ },
60
+ // T2 Provisional: Accountability + safety (3 factors)
61
+ CT_TRANS: {
62
+ code: 'CT-TRANS',
63
+ name: 'Transparency',
64
+ tier: FactorTier.FOUNDATIONAL,
65
+ description: 'Clear insights into decisions and reasoning',
66
+ measurement: 'Explainability score, reasoning log quality',
67
+ requiredFrom: TrustTier.T2_PROVISIONAL,
68
+ },
69
+ CT_ACCT: {
70
+ code: 'CT-ACCT',
71
+ name: 'Accountability',
72
+ tier: FactorTier.FOUNDATIONAL,
73
+ description: 'Traceable actions with clear responsibility attribution',
74
+ measurement: 'Audit trail completeness, attribution confidence',
75
+ requiredFrom: TrustTier.T2_PROVISIONAL,
76
+ },
77
+ CT_SAFE: {
78
+ code: 'CT-SAFE',
79
+ name: 'Safety',
80
+ tier: FactorTier.FOUNDATIONAL,
81
+ description: 'Respecting boundaries, avoiding harm, ensuring non-discrimination',
82
+ measurement: 'Harm incidents, bias audits, guardrail compliance',
83
+ requiredFrom: TrustTier.T2_PROVISIONAL,
84
+ },
85
+ // T3 Verified: Security + identity (3 factors)
86
+ CT_SEC: {
87
+ code: 'CT-SEC',
88
+ name: 'Security',
89
+ tier: FactorTier.FOUNDATIONAL,
90
+ description: 'Protection against threats, injections, unauthorized access',
91
+ measurement: 'Vulnerability count, penetration test results',
92
+ requiredFrom: TrustTier.T3_VERIFIED,
93
+ },
94
+ CT_PRIV: {
95
+ code: 'CT-PRIV',
96
+ name: 'Privacy',
97
+ tier: FactorTier.FOUNDATIONAL,
98
+ description: 'Secure data handling, regulatory compliance',
99
+ measurement: 'Data leak incidents, compliance certifications',
100
+ requiredFrom: TrustTier.T3_VERIFIED,
101
+ },
102
+ CT_ID: {
103
+ code: 'CT-ID',
104
+ name: 'Identity',
105
+ tier: FactorTier.FOUNDATIONAL,
106
+ description: 'Unique, verifiable agent identifiers',
107
+ measurement: 'Cryptographic verification rate',
108
+ requiredFrom: TrustTier.T3_VERIFIED,
109
+ },
110
+ // T4 Operational: Human oversight + alignment (2 factors)
111
+ OP_HUMAN: {
112
+ code: 'OP-HUMAN',
113
+ name: 'Human Oversight',
114
+ tier: FactorTier.OPERATIONAL,
115
+ description: 'Mechanisms for intervention and control',
116
+ measurement: 'Escalation success rate, intervention latency',
117
+ requiredFrom: TrustTier.T4_OPERATIONAL,
118
+ },
119
+ OP_ALIGN: {
120
+ code: 'OP-ALIGN',
121
+ name: 'Alignment',
122
+ tier: FactorTier.OPERATIONAL,
123
+ description: 'Goals and actions match human values',
124
+ measurement: 'Value drift detection, objective compliance',
125
+ requiredFrom: TrustTier.T4_OPERATIONAL,
126
+ },
127
+ // T5 Trusted: Stewardship + humility (2 factors)
128
+ OP_STEW: {
129
+ code: 'OP-STEW',
130
+ name: 'Stewardship',
131
+ tier: FactorTier.OPERATIONAL,
132
+ description: 'Efficient, responsible resource usage',
133
+ measurement: 'Resource efficiency, cost optimization',
134
+ requiredFrom: TrustTier.T5_TRUSTED,
135
+ },
136
+ SF_HUM: {
137
+ code: 'SF-HUM',
138
+ name: 'Humility',
139
+ tier: FactorTier.SOPHISTICATED,
140
+ description: 'Recognizing limits, appropriate escalation',
141
+ measurement: 'Escalation appropriateness, overconfidence incidents',
142
+ requiredFrom: TrustTier.T5_TRUSTED,
143
+ },
144
+ // T6 Certified: Adaptability + learning (2 factors)
145
+ SF_ADAPT: {
146
+ code: 'SF-ADAPT',
147
+ name: 'Adaptability',
148
+ tier: FactorTier.SOPHISTICATED,
149
+ description: 'Safe operation in dynamic/unknown environments',
150
+ measurement: 'Context adaptation success, novel scenario handling',
151
+ requiredFrom: TrustTier.T6_CERTIFIED,
152
+ },
153
+ SF_LEARN: {
154
+ code: 'SF-LEARN',
155
+ name: 'Continuous Learning',
156
+ tier: FactorTier.SOPHISTICATED,
157
+ description: 'Improving from experience without ethical drift',
158
+ measurement: 'Learning rate, regression incidents, value stability',
159
+ requiredFrom: TrustTier.T6_CERTIFIED,
160
+ },
161
+ };
162
+ // =============================================================================
163
+ // LIFE-CRITICAL FACTORS (8) - For 2050 Healthcare/Safety Applications
164
+ // =============================================================================
165
+ export const LIFE_CRITICAL_FACTORS = {
166
+ // T4 Operational: Critical safety factors (2 factors)
167
+ LC_UNCERT: {
168
+ code: 'LC-UNCERT',
169
+ name: 'Uncertainty Quantification',
170
+ tier: FactorTier.LIFE_CRITICAL,
171
+ priority: 3,
172
+ description: 'Probabilistic, well-calibrated confidence scores',
173
+ standard2050: '"67% confident sepsis vs SIRS, here are alternatives and distinguishing tests"',
174
+ requiredFrom: TrustTier.T4_OPERATIONAL,
175
+ },
176
+ LC_HANDOFF: {
177
+ code: 'LC-HANDOFF',
178
+ name: 'Graceful Degradation & Handoff',
179
+ tier: FactorTier.LIFE_CRITICAL,
180
+ priority: 5,
181
+ description: 'Elegant transition to humans without harm',
182
+ standard2050: 'Full context transfer, recommended actions, clear rationale',
183
+ requiredFrom: TrustTier.T4_OPERATIONAL,
184
+ },
185
+ // T5 Trusted: Empirical humility (1 factor)
186
+ LC_EMPHUM: {
187
+ code: 'LC-EMPHUM',
188
+ name: 'Empirical Humility',
189
+ tier: FactorTier.LIFE_CRITICAL,
190
+ priority: 7,
191
+ description: 'Rigorous resistance to hallucination',
192
+ standard2050: 'Never present speculation as fact, default to "needs review"',
193
+ requiredFrom: TrustTier.T5_TRUSTED,
194
+ },
195
+ // T6 Certified: Causal reasoning + patient autonomy (2 factors)
196
+ LC_CAUSAL: {
197
+ code: 'LC-CAUSAL',
198
+ name: 'Clinical Causal Understanding',
199
+ tier: FactorTier.LIFE_CRITICAL,
200
+ priority: 4,
201
+ description: 'True causal reasoning about physiology',
202
+ standard2050: 'Understand WHY treatment works for THIS patient',
203
+ requiredFrom: TrustTier.T6_CERTIFIED,
204
+ },
205
+ LC_PATIENT: {
206
+ code: 'LC-PATIENT',
207
+ name: 'Patient-Centered Autonomy',
208
+ tier: FactorTier.LIFE_CRITICAL,
209
+ priority: 6,
210
+ description: 'Supporting informed consent and patient values',
211
+ standard2050: 'Elicit authentic values, flag conflicts with expressed wishes',
212
+ requiredFrom: TrustTier.T6_CERTIFIED,
213
+ },
214
+ // T7 Autonomous: Full autonomy factors (3 factors)
215
+ LC_EMP: {
216
+ code: 'LC-EMP',
217
+ name: 'Empathy & Emotional Intelligence',
218
+ tier: FactorTier.LIFE_CRITICAL,
219
+ priority: 1,
220
+ description: 'Detecting and responding to human emotional states',
221
+ standard2050: 'Cultural sensitivity, grief/fear recognition, appropriate timing',
222
+ requiredFrom: TrustTier.T7_AUTONOMOUS,
223
+ },
224
+ LC_MORAL: {
225
+ code: 'LC-MORAL',
226
+ name: 'Nuanced Moral Reasoning',
227
+ tier: FactorTier.LIFE_CRITICAL,
228
+ priority: 2,
229
+ description: 'Weighing genuine ethical dilemmas with wisdom',
230
+ standard2050: 'Articulate competing principles, incorporate patient values, justify trade-offs',
231
+ requiredFrom: TrustTier.T7_AUTONOMOUS,
232
+ },
233
+ LC_TRACK: {
234
+ code: 'LC-TRACK',
235
+ name: 'Proven Efficacy Track Record',
236
+ tier: FactorTier.LIFE_CRITICAL,
237
+ priority: 8,
238
+ description: 'Demonstrated life-saving at scale',
239
+ standard2050: 'Published RCTs, post-market surveillance, survival data',
240
+ requiredFrom: TrustTier.T7_AUTONOMOUS,
241
+ },
242
+ };
243
+ // =============================================================================
244
+ // COMBINED FACTORS
245
+ // =============================================================================
246
+ export const ALL_FACTORS = {
247
+ ...CORE_FACTORS,
248
+ ...LIFE_CRITICAL_FACTORS,
249
+ };
250
+ // =============================================================================
251
+ // SCORE THRESHOLDS BY TIER (T0-T7)
252
+ // =============================================================================
253
+ export const TIER_THRESHOLDS = {
254
+ [TrustTier.T0_SANDBOX]: { min: 0, max: 199 },
255
+ [TrustTier.T1_OBSERVED]: { min: 200, max: 349 },
256
+ [TrustTier.T2_PROVISIONAL]: { min: 350, max: 499 },
257
+ [TrustTier.T3_VERIFIED]: { min: 500, max: 649 },
258
+ [TrustTier.T4_OPERATIONAL]: { min: 650, max: 799 },
259
+ [TrustTier.T5_TRUSTED]: { min: 800, max: 875 },
260
+ [TrustTier.T6_CERTIFIED]: { min: 876, max: 949 },
261
+ [TrustTier.T7_AUTONOMOUS]: { min: 950, max: 1000 },
262
+ };
263
+ export const FACTOR_MINIMUM_SCORE = 0.5; // Minimum score for any factor
264
+ /**
265
+ * All 23 factors are evaluated at every tier.
266
+ * This table defines the minimum score and weight for each factor at each tier.
267
+ * T0 has no minimums (observation only).
268
+ * As tiers increase, thresholds rise and weights shift.
269
+ */
270
+ export const FACTOR_THRESHOLDS_BY_TIER = {
271
+ // T0 SANDBOX: No minimums - observation only
272
+ [TrustTier.T0_SANDBOX]: {
273
+ 'CT-COMP': { minimum: 0.0, weight: 1, critical: false },
274
+ 'CT-REL': { minimum: 0.0, weight: 1, critical: false },
275
+ 'CT-OBS': { minimum: 0.0, weight: 1, critical: false },
276
+ 'CT-TRANS': { minimum: 0.0, weight: 1, critical: false },
277
+ 'CT-ACCT': { minimum: 0.0, weight: 1, critical: false },
278
+ 'CT-SAFE': { minimum: 0.0, weight: 1, critical: false },
279
+ 'CT-SEC': { minimum: 0.0, weight: 1, critical: false },
280
+ 'CT-PRIV': { minimum: 0.0, weight: 1, critical: false },
281
+ 'CT-ID': { minimum: 0.0, weight: 1, critical: false },
282
+ 'OP-HUMAN': { minimum: 0.0, weight: 1, critical: false },
283
+ 'OP-ALIGN': { minimum: 0.0, weight: 1, critical: false },
284
+ 'OP-STEW': { minimum: 0.0, weight: 1, critical: false },
285
+ 'SF-HUM': { minimum: 0.0, weight: 1, critical: false },
286
+ 'SF-ADAPT': { minimum: 0.0, weight: 1, critical: false },
287
+ 'SF-LEARN': { minimum: 0.0, weight: 1, critical: false },
288
+ 'LC-UNCERT': { minimum: 0.0, weight: 1, critical: false },
289
+ 'LC-HANDOFF': { minimum: 0.0, weight: 1, critical: false },
290
+ 'LC-EMPHUM': { minimum: 0.0, weight: 1, critical: false },
291
+ 'LC-CAUSAL': { minimum: 0.0, weight: 1, critical: false },
292
+ 'LC-PATIENT': { minimum: 0.0, weight: 1, critical: false },
293
+ 'LC-EMP': { minimum: 0.0, weight: 1, critical: false },
294
+ 'LC-MORAL': { minimum: 0.0, weight: 1, critical: false },
295
+ 'LC-TRACK': { minimum: 0.0, weight: 1, critical: false },
296
+ },
297
+ // T1 OBSERVED: Basic competence thresholds
298
+ [TrustTier.T1_OBSERVED]: {
299
+ 'CT-COMP': { minimum: 0.50, weight: 2, critical: true },
300
+ 'CT-REL': { minimum: 0.50, weight: 2, critical: true },
301
+ 'CT-OBS': { minimum: 0.50, weight: 2, critical: true },
302
+ 'CT-TRANS': { minimum: 0.30, weight: 1, critical: false },
303
+ 'CT-ACCT': { minimum: 0.30, weight: 1, critical: false },
304
+ 'CT-SAFE': { minimum: 0.30, weight: 1, critical: false },
305
+ 'CT-SEC': { minimum: 0.20, weight: 1, critical: false },
306
+ 'CT-PRIV': { minimum: 0.20, weight: 1, critical: false },
307
+ 'CT-ID': { minimum: 0.20, weight: 1, critical: false },
308
+ 'OP-HUMAN': { minimum: 0.10, weight: 1, critical: false },
309
+ 'OP-ALIGN': { minimum: 0.10, weight: 1, critical: false },
310
+ 'OP-STEW': { minimum: 0.10, weight: 1, critical: false },
311
+ 'SF-HUM': { minimum: 0.10, weight: 1, critical: false },
312
+ 'SF-ADAPT': { minimum: 0.10, weight: 1, critical: false },
313
+ 'SF-LEARN': { minimum: 0.10, weight: 1, critical: false },
314
+ 'LC-UNCERT': { minimum: 0.10, weight: 1, critical: false },
315
+ 'LC-HANDOFF': { minimum: 0.10, weight: 1, critical: false },
316
+ 'LC-EMPHUM': { minimum: 0.10, weight: 1, critical: false },
317
+ 'LC-CAUSAL': { minimum: 0.05, weight: 1, critical: false },
318
+ 'LC-PATIENT': { minimum: 0.05, weight: 1, critical: false },
319
+ 'LC-EMP': { minimum: 0.05, weight: 1, critical: false },
320
+ 'LC-MORAL': { minimum: 0.05, weight: 1, critical: false },
321
+ 'LC-TRACK': { minimum: 0.05, weight: 1, critical: false },
322
+ },
323
+ // T2 PROVISIONAL: Accountability + safety rising
324
+ [TrustTier.T2_PROVISIONAL]: {
325
+ 'CT-COMP': { minimum: 0.60, weight: 2, critical: true },
326
+ 'CT-REL': { minimum: 0.60, weight: 2, critical: true },
327
+ 'CT-OBS': { minimum: 0.60, weight: 2, critical: true },
328
+ 'CT-TRANS': { minimum: 0.50, weight: 2, critical: true },
329
+ 'CT-ACCT': { minimum: 0.50, weight: 2, critical: true },
330
+ 'CT-SAFE': { minimum: 0.50, weight: 2, critical: true },
331
+ 'CT-SEC': { minimum: 0.30, weight: 1, critical: false },
332
+ 'CT-PRIV': { minimum: 0.30, weight: 1, critical: false },
333
+ 'CT-ID': { minimum: 0.30, weight: 1, critical: false },
334
+ 'OP-HUMAN': { minimum: 0.20, weight: 1, critical: false },
335
+ 'OP-ALIGN': { minimum: 0.20, weight: 1, critical: false },
336
+ 'OP-STEW': { minimum: 0.15, weight: 1, critical: false },
337
+ 'SF-HUM': { minimum: 0.15, weight: 1, critical: false },
338
+ 'SF-ADAPT': { minimum: 0.15, weight: 1, critical: false },
339
+ 'SF-LEARN': { minimum: 0.15, weight: 1, critical: false },
340
+ 'LC-UNCERT': { minimum: 0.15, weight: 1, critical: false },
341
+ 'LC-HANDOFF': { minimum: 0.15, weight: 1, critical: false },
342
+ 'LC-EMPHUM': { minimum: 0.15, weight: 1, critical: false },
343
+ 'LC-CAUSAL': { minimum: 0.10, weight: 1, critical: false },
344
+ 'LC-PATIENT': { minimum: 0.10, weight: 1, critical: false },
345
+ 'LC-EMP': { minimum: 0.10, weight: 1, critical: false },
346
+ 'LC-MORAL': { minimum: 0.10, weight: 1, critical: false },
347
+ 'LC-TRACK': { minimum: 0.10, weight: 1, critical: false },
348
+ },
349
+ // T3 VERIFIED: Security + identity confirmed
350
+ [TrustTier.T3_VERIFIED]: {
351
+ 'CT-COMP': { minimum: 0.70, weight: 2, critical: true },
352
+ 'CT-REL': { minimum: 0.70, weight: 2, critical: true },
353
+ 'CT-OBS': { minimum: 0.70, weight: 2, critical: true },
354
+ 'CT-TRANS': { minimum: 0.60, weight: 2, critical: true },
355
+ 'CT-ACCT': { minimum: 0.60, weight: 2, critical: true },
356
+ 'CT-SAFE': { minimum: 0.60, weight: 2, critical: true },
357
+ 'CT-SEC': { minimum: 0.50, weight: 2, critical: true },
358
+ 'CT-PRIV': { minimum: 0.50, weight: 2, critical: true },
359
+ 'CT-ID': { minimum: 0.50, weight: 2, critical: true },
360
+ 'OP-HUMAN': { minimum: 0.30, weight: 1, critical: false },
361
+ 'OP-ALIGN': { minimum: 0.30, weight: 1, critical: false },
362
+ 'OP-STEW': { minimum: 0.25, weight: 1, critical: false },
363
+ 'SF-HUM': { minimum: 0.25, weight: 1, critical: false },
364
+ 'SF-ADAPT': { minimum: 0.20, weight: 1, critical: false },
365
+ 'SF-LEARN': { minimum: 0.20, weight: 1, critical: false },
366
+ 'LC-UNCERT': { minimum: 0.25, weight: 1, critical: false },
367
+ 'LC-HANDOFF': { minimum: 0.25, weight: 1, critical: false },
368
+ 'LC-EMPHUM': { minimum: 0.25, weight: 1, critical: false },
369
+ 'LC-CAUSAL': { minimum: 0.15, weight: 1, critical: false },
370
+ 'LC-PATIENT': { minimum: 0.15, weight: 1, critical: false },
371
+ 'LC-EMP': { minimum: 0.15, weight: 1, critical: false },
372
+ 'LC-MORAL': { minimum: 0.15, weight: 1, critical: false },
373
+ 'LC-TRACK': { minimum: 0.15, weight: 1, critical: false },
374
+ },
375
+ // T4 OPERATIONAL: Human oversight + alignment critical
376
+ [TrustTier.T4_OPERATIONAL]: {
377
+ 'CT-COMP': { minimum: 0.75, weight: 2, critical: true },
378
+ 'CT-REL': { minimum: 0.75, weight: 2, critical: true },
379
+ 'CT-OBS': { minimum: 0.75, weight: 2, critical: true },
380
+ 'CT-TRANS': { minimum: 0.70, weight: 2, critical: true },
381
+ 'CT-ACCT': { minimum: 0.70, weight: 2, critical: true },
382
+ 'CT-SAFE': { minimum: 0.70, weight: 2, critical: true },
383
+ 'CT-SEC': { minimum: 0.65, weight: 2, critical: true },
384
+ 'CT-PRIV': { minimum: 0.65, weight: 2, critical: true },
385
+ 'CT-ID': { minimum: 0.65, weight: 2, critical: true },
386
+ 'OP-HUMAN': { minimum: 0.50, weight: 3, critical: true },
387
+ 'OP-ALIGN': { minimum: 0.50, weight: 3, critical: true },
388
+ 'OP-STEW': { minimum: 0.35, weight: 2, critical: false },
389
+ 'SF-HUM': { minimum: 0.35, weight: 2, critical: false },
390
+ 'SF-ADAPT': { minimum: 0.30, weight: 2, critical: false },
391
+ 'SF-LEARN': { minimum: 0.30, weight: 2, critical: false },
392
+ 'LC-UNCERT': { minimum: 0.50, weight: 3, critical: true },
393
+ 'LC-HANDOFF': { minimum: 0.50, weight: 3, critical: true },
394
+ 'LC-EMPHUM': { minimum: 0.40, weight: 2, critical: false },
395
+ 'LC-CAUSAL': { minimum: 0.25, weight: 2, critical: false },
396
+ 'LC-PATIENT': { minimum: 0.25, weight: 2, critical: false },
397
+ 'LC-EMP': { minimum: 0.20, weight: 1, critical: false },
398
+ 'LC-MORAL': { minimum: 0.20, weight: 1, critical: false },
399
+ 'LC-TRACK': { minimum: 0.20, weight: 1, critical: false },
400
+ },
401
+ // T5 TRUSTED: Stewardship + humility critical
402
+ [TrustTier.T5_TRUSTED]: {
403
+ 'CT-COMP': { minimum: 0.80, weight: 2, critical: true },
404
+ 'CT-REL': { minimum: 0.80, weight: 2, critical: true },
405
+ 'CT-OBS': { minimum: 0.80, weight: 2, critical: true },
406
+ 'CT-TRANS': { minimum: 0.75, weight: 2, critical: true },
407
+ 'CT-ACCT': { minimum: 0.75, weight: 2, critical: true },
408
+ 'CT-SAFE': { minimum: 0.75, weight: 2, critical: true },
409
+ 'CT-SEC': { minimum: 0.70, weight: 2, critical: true },
410
+ 'CT-PRIV': { minimum: 0.70, weight: 2, critical: true },
411
+ 'CT-ID': { minimum: 0.70, weight: 2, critical: true },
412
+ 'OP-HUMAN': { minimum: 0.65, weight: 3, critical: true },
413
+ 'OP-ALIGN': { minimum: 0.65, weight: 3, critical: true },
414
+ 'OP-STEW': { minimum: 0.50, weight: 3, critical: true },
415
+ 'SF-HUM': { minimum: 0.50, weight: 3, critical: true },
416
+ 'SF-ADAPT': { minimum: 0.40, weight: 2, critical: false },
417
+ 'SF-LEARN': { minimum: 0.40, weight: 2, critical: false },
418
+ 'LC-UNCERT': { minimum: 0.60, weight: 3, critical: true },
419
+ 'LC-HANDOFF': { minimum: 0.60, weight: 3, critical: true },
420
+ 'LC-EMPHUM': { minimum: 0.50, weight: 3, critical: true },
421
+ 'LC-CAUSAL': { minimum: 0.35, weight: 2, critical: false },
422
+ 'LC-PATIENT': { minimum: 0.35, weight: 2, critical: false },
423
+ 'LC-EMP': { minimum: 0.30, weight: 2, critical: false },
424
+ 'LC-MORAL': { minimum: 0.30, weight: 2, critical: false },
425
+ 'LC-TRACK': { minimum: 0.30, weight: 2, critical: false },
426
+ },
427
+ // T6 CERTIFIED: Adaptability + causal reasoning critical
428
+ [TrustTier.T6_CERTIFIED]: {
429
+ 'CT-COMP': { minimum: 0.85, weight: 2, critical: true },
430
+ 'CT-REL': { minimum: 0.85, weight: 2, critical: true },
431
+ 'CT-OBS': { minimum: 0.85, weight: 2, critical: true },
432
+ 'CT-TRANS': { minimum: 0.80, weight: 2, critical: true },
433
+ 'CT-ACCT': { minimum: 0.80, weight: 2, critical: true },
434
+ 'CT-SAFE': { minimum: 0.80, weight: 2, critical: true },
435
+ 'CT-SEC': { minimum: 0.75, weight: 2, critical: true },
436
+ 'CT-PRIV': { minimum: 0.75, weight: 2, critical: true },
437
+ 'CT-ID': { minimum: 0.75, weight: 2, critical: true },
438
+ 'OP-HUMAN': { minimum: 0.70, weight: 3, critical: true },
439
+ 'OP-ALIGN': { minimum: 0.70, weight: 3, critical: true },
440
+ 'OP-STEW': { minimum: 0.65, weight: 3, critical: true },
441
+ 'SF-HUM': { minimum: 0.65, weight: 3, critical: true },
442
+ 'SF-ADAPT': { minimum: 0.50, weight: 4, critical: true },
443
+ 'SF-LEARN': { minimum: 0.50, weight: 4, critical: true },
444
+ 'LC-UNCERT': { minimum: 0.70, weight: 4, critical: true },
445
+ 'LC-HANDOFF': { minimum: 0.70, weight: 4, critical: true },
446
+ 'LC-EMPHUM': { minimum: 0.65, weight: 3, critical: true },
447
+ 'LC-CAUSAL': { minimum: 0.50, weight: 4, critical: true },
448
+ 'LC-PATIENT': { minimum: 0.50, weight: 4, critical: true },
449
+ 'LC-EMP': { minimum: 0.40, weight: 2, critical: false },
450
+ 'LC-MORAL': { minimum: 0.40, weight: 2, critical: false },
451
+ 'LC-TRACK': { minimum: 0.40, weight: 2, critical: false },
452
+ },
453
+ // T7 AUTONOMOUS: ALL factors critical at high thresholds
454
+ [TrustTier.T7_AUTONOMOUS]: {
455
+ 'CT-COMP': { minimum: 0.90, weight: 2, critical: true },
456
+ 'CT-REL': { minimum: 0.90, weight: 2, critical: true },
457
+ 'CT-OBS': { minimum: 0.90, weight: 2, critical: true },
458
+ 'CT-TRANS': { minimum: 0.85, weight: 2, critical: true },
459
+ 'CT-ACCT': { minimum: 0.85, weight: 2, critical: true },
460
+ 'CT-SAFE': { minimum: 0.85, weight: 2, critical: true },
461
+ 'CT-SEC': { minimum: 0.80, weight: 2, critical: true },
462
+ 'CT-PRIV': { minimum: 0.80, weight: 2, critical: true },
463
+ 'CT-ID': { minimum: 0.80, weight: 2, critical: true },
464
+ 'OP-HUMAN': { minimum: 0.75, weight: 3, critical: true },
465
+ 'OP-ALIGN': { minimum: 0.75, weight: 3, critical: true },
466
+ 'OP-STEW': { minimum: 0.70, weight: 3, critical: true },
467
+ 'SF-HUM': { minimum: 0.70, weight: 3, critical: true },
468
+ 'SF-ADAPT': { minimum: 0.65, weight: 4, critical: true },
469
+ 'SF-LEARN': { minimum: 0.65, weight: 4, critical: true },
470
+ 'LC-UNCERT': { minimum: 0.75, weight: 4, critical: true },
471
+ 'LC-HANDOFF': { minimum: 0.75, weight: 4, critical: true },
472
+ 'LC-EMPHUM': { minimum: 0.70, weight: 4, critical: true },
473
+ 'LC-CAUSAL': { minimum: 0.65, weight: 4, critical: true },
474
+ 'LC-PATIENT': { minimum: 0.65, weight: 4, critical: true },
475
+ 'LC-EMP': { minimum: 0.60, weight: 4, critical: true },
476
+ 'LC-MORAL': { minimum: 0.60, weight: 4, critical: true },
477
+ 'LC-TRACK': { minimum: 0.60, weight: 4, critical: true },
478
+ },
479
+ };
480
+ /**
481
+ * Get factor thresholds for a specific tier
482
+ */
483
+ export function getFactorThresholdsForTier(tier) {
484
+ return FACTOR_THRESHOLDS_BY_TIER[tier];
485
+ }
486
+ /**
487
+ * Get critical factors for a tier (factors that must meet minimum)
488
+ */
489
+ export function getCriticalFactorsForTier(tier) {
490
+ const thresholds = getFactorThresholdsForTier(tier);
491
+ return Object.entries(thresholds)
492
+ .filter(([_, threshold]) => threshold.critical)
493
+ .map(([code]) => code);
494
+ }
495
+ // =============================================================================
496
+ // TRUST SCORE CALCULATION
497
+ // =============================================================================
498
+ export function getRequiredFactors(tier) {
499
+ return Object.keys(ALL_FACTORS).filter(code => {
500
+ const factor = ALL_FACTORS[code];
501
+ return factor.requiredFrom <= tier;
502
+ });
503
+ }
504
+ export function calculateTrustScore(scores, tier) {
505
+ const thresholds = getFactorThresholdsForTier(tier);
506
+ const scoreMap = new Map(scores.map(s => [s.code, s]));
507
+ let rawScore = 0;
508
+ let maxPossible = 0;
509
+ const missingFactors = [];
510
+ const belowThreshold = [];
511
+ const criticalFailures = [];
512
+ // Evaluate ALL 23 factors at this tier
513
+ for (const [factorCode, threshold] of Object.entries(thresholds)) {
514
+ const code = factorCode;
515
+ const weight = threshold.weight;
516
+ maxPossible += weight;
517
+ const scoreEntry = scoreMap.get(code);
518
+ if (!scoreEntry) {
519
+ missingFactors.push(code);
520
+ if (threshold.critical) {
521
+ criticalFailures.push(code);
522
+ }
523
+ continue;
524
+ }
525
+ // Check if score meets minimum for this tier
526
+ if (scoreEntry.score < threshold.minimum) {
527
+ belowThreshold.push(code);
528
+ if (threshold.critical) {
529
+ criticalFailures.push(code);
530
+ }
531
+ }
532
+ rawScore += scoreEntry.score * weight;
533
+ }
534
+ const totalScore = maxPossible > 0
535
+ ? Math.round((rawScore / maxPossible) * 1000)
536
+ : 0;
537
+ const tierThreshold = TIER_THRESHOLDS[tier];
538
+ const compliant = totalScore >= tierThreshold.min
539
+ && criticalFailures.length === 0; // Only critical failures block compliance
540
+ return {
541
+ agentId: '', // Set by caller
542
+ trustTier: tier,
543
+ factors: scores,
544
+ totalScore,
545
+ percentile: Math.min(100, Math.round((totalScore / 1000) * 100)),
546
+ compliant,
547
+ missingFactors,
548
+ belowThreshold,
549
+ evaluatedAt: new Date(),
550
+ };
551
+ }
552
+ // =============================================================================
553
+ // TRUST TIER DISPLAY CONFIG (T0-T7)
554
+ // =============================================================================
555
+ export const TRUST_TIER_DISPLAY = {
556
+ T0_SANDBOX: { name: 'Sandbox', color: '#78716c', textColor: 'white' }, // Stone - No factors
557
+ T1_OBSERVED: { name: 'Observed', color: '#ef4444', textColor: 'white' }, // Red - 3 factors
558
+ T2_PROVISIONAL: { name: 'Provisional', color: '#f97316', textColor: 'white' }, // Orange - 6 factors
559
+ T3_VERIFIED: { name: 'Verified', color: '#eab308', textColor: 'black' }, // Yellow - 9 factors
560
+ T4_OPERATIONAL: { name: 'Operational', color: '#22c55e', textColor: 'white' }, // Green - 13 factors
561
+ T5_TRUSTED: { name: 'Trusted', color: '#3b82f6', textColor: 'white' }, // Blue - 16 factors
562
+ T6_CERTIFIED: { name: 'Certified', color: '#8b5cf6', textColor: 'white' }, // Purple - 20 factors
563
+ T7_AUTONOMOUS: { name: 'Autonomous', color: '#06b6d4', textColor: 'white' }, // Cyan - ALL 23 factors
564
+ };
565
+ export function getTrustTierFromScore(score) {
566
+ if (score >= 950)
567
+ return TrustTier.T7_AUTONOMOUS;
568
+ if (score >= 876)
569
+ return TrustTier.T6_CERTIFIED;
570
+ if (score >= 800)
571
+ return TrustTier.T5_TRUSTED;
572
+ if (score >= 650)
573
+ return TrustTier.T4_OPERATIONAL;
574
+ if (score >= 500)
575
+ return TrustTier.T3_VERIFIED;
576
+ if (score >= 350)
577
+ return TrustTier.T2_PROVISIONAL;
578
+ if (score >= 200)
579
+ return TrustTier.T1_OBSERVED;
580
+ return TrustTier.T0_SANDBOX;
581
+ }
582
+ export function getTierName(tier) {
583
+ return TRUST_TIER_DISPLAY[TrustTier[tier]]?.name || 'Unknown';
584
+ }
585
+ export function getTierColor(tier) {
586
+ return TRUST_TIER_DISPLAY[TrustTier[tier]]?.color || '#78716c';
587
+ }
588
+ //# sourceMappingURL=trust-factors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trust-factors.test.d.ts","sourceRoot":"","sources":["../src/trust-factors.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}