@vorionsys/contracts 0.1.0 → 0.1.2

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 (219) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE +190 -0
  3. package/README.md +435 -0
  4. package/dist/aci/index.d.ts +6 -62
  5. package/dist/aci/index.d.ts.map +1 -1
  6. package/dist/aci/index.js +22 -152
  7. package/dist/aci/index.js.map +1 -1
  8. package/dist/canonical/agent.d.ts +2 -2
  9. package/dist/canonical/agent.d.ts.map +1 -1
  10. package/dist/canonical/agent.js +146 -130
  11. package/dist/canonical/agent.js.map +1 -1
  12. package/dist/canonical/governance.d.ts +1 -1
  13. package/dist/canonical/governance.js +134 -120
  14. package/dist/canonical/governance.js.map +1 -1
  15. package/dist/canonical/index.d.ts +1 -0
  16. package/dist/canonical/index.d.ts.map +1 -1
  17. package/dist/canonical/index.js +26 -8
  18. package/dist/canonical/index.js.map +1 -1
  19. package/dist/canonical/intent.d.ts +8 -15
  20. package/dist/canonical/intent.d.ts.map +1 -1
  21. package/dist/canonical/intent.js +91 -82
  22. package/dist/canonical/intent.js.map +1 -1
  23. package/dist/canonical/middleware.d.ts +513 -0
  24. package/dist/canonical/middleware.d.ts.map +1 -0
  25. package/dist/canonical/middleware.js +218 -0
  26. package/dist/canonical/middleware.js.map +1 -0
  27. package/dist/canonical/risk-level.d.ts +1 -1
  28. package/dist/canonical/risk-level.js +66 -46
  29. package/dist/canonical/risk-level.js.map +1 -1
  30. package/dist/canonical/trust-band.d.ts +1 -1
  31. package/dist/canonical/trust-band.js +39 -28
  32. package/dist/canonical/trust-band.js.map +1 -1
  33. package/dist/canonical/trust-score.d.ts +1 -1
  34. package/dist/canonical/trust-score.js +46 -29
  35. package/dist/canonical/trust-score.js.map +1 -1
  36. package/dist/canonical/trust-signal.d.ts +13 -13
  37. package/dist/canonical/trust-signal.js +91 -78
  38. package/dist/canonical/trust-signal.js.map +1 -1
  39. package/dist/canonical/validation.js +148 -102
  40. package/dist/canonical/validation.js.map +1 -1
  41. package/dist/{aci → car}/attestation.d.ts +73 -73
  42. package/dist/{aci → car}/attestation.d.ts.map +1 -1
  43. package/dist/{aci → car}/attestation.js +69 -59
  44. package/dist/car/attestation.js.map +1 -0
  45. package/dist/car/car-string.d.ts +846 -0
  46. package/dist/car/car-string.d.ts.map +1 -0
  47. package/dist/car/car-string.js +734 -0
  48. package/dist/car/car-string.js.map +1 -0
  49. package/dist/{aci → car}/domains.d.ts +3 -3
  50. package/dist/{aci → car}/domains.d.ts.map +1 -1
  51. package/dist/{aci → car}/domains.js +57 -39
  52. package/dist/car/domains.js.map +1 -0
  53. package/dist/{aci → car}/effective-permission.d.ts +8 -8
  54. package/dist/{aci → car}/effective-permission.d.ts.map +1 -1
  55. package/dist/{aci → car}/effective-permission.js +59 -46
  56. package/dist/car/effective-permission.js.map +1 -0
  57. package/dist/{aci → car}/identity.d.ts +235 -129
  58. package/dist/car/identity.d.ts.map +1 -0
  59. package/dist/{aci → car}/identity.js +125 -105
  60. package/dist/car/identity.js.map +1 -0
  61. package/dist/car/index.d.ts +104 -0
  62. package/dist/car/index.d.ts.map +1 -0
  63. package/dist/car/index.js +401 -0
  64. package/dist/car/index.js.map +1 -0
  65. package/dist/car/jwt-claims.d.ts +1364 -0
  66. package/dist/car/jwt-claims.d.ts.map +1 -0
  67. package/dist/car/jwt-claims.js +388 -0
  68. package/dist/car/jwt-claims.js.map +1 -0
  69. package/dist/{aci → car}/levels.d.ts +5 -5
  70. package/dist/{aci → car}/levels.d.ts.map +1 -1
  71. package/dist/{aci → car}/levels.js +81 -62
  72. package/dist/car/levels.js.map +1 -0
  73. package/dist/{aci → car}/mapping.d.ts +5 -5
  74. package/dist/{aci → car}/mapping.d.ts.map +1 -1
  75. package/dist/{aci → car}/mapping.js +96 -76
  76. package/dist/car/mapping.js.map +1 -0
  77. package/dist/{aci → car}/skills.d.ts +4 -4
  78. package/dist/{aci → car}/skills.d.ts.map +1 -1
  79. package/dist/{aci → car}/skills.js +72 -50
  80. package/dist/car/skills.js.map +1 -0
  81. package/dist/{aci → car}/tiers.d.ts +3 -3
  82. package/dist/{aci → car}/tiers.d.ts.map +1 -1
  83. package/dist/{aci → car}/tiers.js +140 -113
  84. package/dist/car/tiers.js.map +1 -0
  85. package/dist/common/index.d.ts +1 -0
  86. package/dist/common/index.d.ts.map +1 -1
  87. package/dist/common/index.js +18 -1
  88. package/dist/common/index.js.map +1 -1
  89. package/dist/common/primitives.d.ts +9 -7
  90. package/dist/common/primitives.d.ts.map +1 -1
  91. package/dist/common/primitives.js +30 -25
  92. package/dist/common/primitives.js.map +1 -1
  93. package/dist/common/types.d.ts +328 -0
  94. package/dist/common/types.d.ts.map +1 -0
  95. package/dist/common/types.js +61 -0
  96. package/dist/common/types.js.map +1 -0
  97. package/dist/db/agents.d.ts +1914 -0
  98. package/dist/db/agents.d.ts.map +1 -0
  99. package/dist/db/agents.js +283 -0
  100. package/dist/db/agents.js.map +1 -0
  101. package/dist/db/api-keys.d.ts +506 -0
  102. package/dist/db/api-keys.d.ts.map +1 -0
  103. package/dist/db/api-keys.js +101 -0
  104. package/dist/db/api-keys.js.map +1 -0
  105. package/dist/db/escalations.d.ts +554 -0
  106. package/dist/db/escalations.d.ts.map +1 -0
  107. package/dist/db/escalations.js +100 -0
  108. package/dist/db/escalations.js.map +1 -0
  109. package/dist/db/index.d.ts +20 -0
  110. package/dist/db/index.d.ts.map +1 -0
  111. package/dist/db/index.js +47 -0
  112. package/dist/db/index.js.map +1 -0
  113. package/dist/db/intents.d.ts +535 -0
  114. package/dist/db/intents.d.ts.map +1 -0
  115. package/dist/db/intents.js +93 -0
  116. package/dist/db/intents.js.map +1 -0
  117. package/dist/db/merkle.d.ts +475 -0
  118. package/dist/db/merkle.d.ts.map +1 -0
  119. package/dist/db/merkle.js +103 -0
  120. package/dist/db/merkle.js.map +1 -0
  121. package/dist/db/operations.d.ts +256 -0
  122. package/dist/db/operations.d.ts.map +1 -0
  123. package/dist/db/operations.js +68 -0
  124. package/dist/db/operations.js.map +1 -0
  125. package/dist/db/policy-versions.d.ts +149 -0
  126. package/dist/db/policy-versions.d.ts.map +1 -0
  127. package/dist/db/policy-versions.js +44 -0
  128. package/dist/db/policy-versions.js.map +1 -0
  129. package/dist/db/proofs.d.ts +412 -0
  130. package/dist/db/proofs.d.ts.map +1 -0
  131. package/dist/db/proofs.js +66 -0
  132. package/dist/db/proofs.js.map +1 -0
  133. package/dist/db/rbac.d.ts +882 -0
  134. package/dist/db/rbac.d.ts.map +1 -0
  135. package/dist/db/rbac.js +189 -0
  136. package/dist/db/rbac.js.map +1 -0
  137. package/dist/db/service-accounts.d.ts +783 -0
  138. package/dist/db/service-accounts.d.ts.map +1 -0
  139. package/dist/db/service-accounts.js +179 -0
  140. package/dist/db/service-accounts.js.map +1 -0
  141. package/dist/db/trust.d.ts +603 -0
  142. package/dist/db/trust.d.ts.map +1 -0
  143. package/dist/db/trust.js +111 -0
  144. package/dist/db/trust.js.map +1 -0
  145. package/dist/db/webhooks.d.ts +382 -0
  146. package/dist/db/webhooks.d.ts.map +1 -0
  147. package/dist/db/webhooks.js +94 -0
  148. package/dist/db/webhooks.js.map +1 -0
  149. package/dist/flags.d.ts +214 -0
  150. package/dist/flags.d.ts.map +1 -0
  151. package/dist/flags.js +443 -0
  152. package/dist/flags.js.map +1 -0
  153. package/dist/index.d.ts +3 -1
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +47 -4
  156. package/dist/index.js.map +1 -1
  157. package/dist/v2/canary-probe.js +10 -7
  158. package/dist/v2/canary-probe.js.map +1 -1
  159. package/dist/v2/component.js +2 -1
  160. package/dist/v2/component.js.map +1 -1
  161. package/dist/v2/decision.js +5 -2
  162. package/dist/v2/decision.js.map +1 -1
  163. package/dist/v2/enums.js +28 -25
  164. package/dist/v2/enums.js.map +1 -1
  165. package/dist/v2/evidence.js +75 -72
  166. package/dist/v2/evidence.js.map +1 -1
  167. package/dist/v2/execution.js +2 -1
  168. package/dist/v2/execution.js.map +1 -1
  169. package/dist/v2/index.js +29 -13
  170. package/dist/v2/index.js.map +1 -1
  171. package/dist/v2/intent.js +2 -1
  172. package/dist/v2/intent.js.map +1 -1
  173. package/dist/v2/policy-bundle.js +5 -2
  174. package/dist/v2/policy-bundle.js.map +1 -1
  175. package/dist/v2/pre-action-gate.js +10 -7
  176. package/dist/v2/pre-action-gate.js.map +1 -1
  177. package/dist/v2/proof-event.d.ts +3 -1
  178. package/dist/v2/proof-event.d.ts.map +1 -1
  179. package/dist/v2/proof-event.js +2 -1
  180. package/dist/v2/proof-event.js.map +1 -1
  181. package/dist/v2/retention.js +104 -101
  182. package/dist/v2/retention.js.map +1 -1
  183. package/dist/v2/trust-delta.js +5 -2
  184. package/dist/v2/trust-delta.js.map +1 -1
  185. package/dist/v2/trust-profile.js +12 -9
  186. package/dist/v2/trust-profile.js.map +1 -1
  187. package/dist/validators/decision.d.ts +2 -2
  188. package/dist/validators/decision.js +49 -46
  189. package/dist/validators/decision.js.map +1 -1
  190. package/dist/validators/enums.js +14 -11
  191. package/dist/validators/enums.js.map +1 -1
  192. package/dist/validators/index.js +30 -9
  193. package/dist/validators/index.js.map +1 -1
  194. package/dist/validators/intent.js +40 -37
  195. package/dist/validators/intent.js.map +1 -1
  196. package/dist/validators/proof-event.d.ts +3 -0
  197. package/dist/validators/proof-event.d.ts.map +1 -1
  198. package/dist/validators/proof-event.js +103 -99
  199. package/dist/validators/proof-event.js.map +1 -1
  200. package/dist/validators/trust-profile.js +40 -37
  201. package/dist/validators/trust-profile.js.map +1 -1
  202. package/package.json +81 -15
  203. package/dist/aci/aci-string.d.ts +0 -539
  204. package/dist/aci/aci-string.d.ts.map +0 -1
  205. package/dist/aci/aci-string.js +0 -563
  206. package/dist/aci/aci-string.js.map +0 -1
  207. package/dist/aci/attestation.js.map +0 -1
  208. package/dist/aci/domains.js.map +0 -1
  209. package/dist/aci/effective-permission.js.map +0 -1
  210. package/dist/aci/identity.d.ts.map +0 -1
  211. package/dist/aci/identity.js.map +0 -1
  212. package/dist/aci/jwt-claims.d.ts +0 -756
  213. package/dist/aci/jwt-claims.d.ts.map +0 -1
  214. package/dist/aci/jwt-claims.js +0 -335
  215. package/dist/aci/jwt-claims.js.map +0 -1
  216. package/dist/aci/levels.js.map +0 -1
  217. package/dist/aci/mapping.js.map +0 -1
  218. package/dist/aci/skills.js.map +0 -1
  219. package/dist/aci/tiers.js.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@vorionsys/contracts` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.2] - 2026-02-17
9
+
10
+ ### Changed
11
+ - Pinned internal workspace dependencies to real version ranges for npm publish
12
+
13
+ ## [0.1.1] - 2026-02-16
14
+
15
+ ### Added
16
+ - Comprehensive README with full API reference, usage examples, and subpath import documentation
17
+ - CHANGELOG.md for tracking version history
18
+ - Extended keywords in package.json for npm discoverability
19
+
20
+ ### Changed
21
+ - Updated package.json `files` field to include README.md, CHANGELOG.md, and LICENSE instead of non-existent `schemas` directory
22
+ - Improved package.json description to mention Zod validators and TypeScript types
23
+
24
+ ### Fixed
25
+ - README license section now correctly states Apache-2.0 (was incorrectly listed as MIT)
26
+
27
+ ## [0.1.0] - 2026-01-15
28
+
29
+ ### Added
30
+ - Initial release of `@vorionsys/contracts`
31
+ - v2 contract types: Intent, Decision, FluidDecision, TrustProfile, ProofEvent, PolicyBundle
32
+ - Trust system: TrustBand (T0-T7), ObservationTier, TrustDimensions, TrustWeights, TrustDynamics
33
+ - Decision system: DecisionTier (GREEN/YELLOW/RED), RefinementAction, WorkflowState, FluidDecision
34
+ - ATSF v2.0 types: CanaryProbe, CanaryCategory, PreActionGate, RiskLevel, GateVerification
35
+ - ERPL compliance types: Evidence and Retention contracts
36
+ - Canonical agent types with Zod schemas: AgentConfig, AgentTask, AgentLifecycleStatus, AgentRuntimeStatus, AgentPermission, AgentSpecialization, AgentCapability
37
+ - Canonical governance module: trust bands, trust scores, risk levels, trust signals, middleware types
38
+ - CAR (Categorical Agent Registry): parseCAR/generateCAR, CapabilityLevel (L0-L7), CertificationTier, RuntimeTier, attestations, JWT claims, effective permissions, domain/skill bitmasks
39
+ - Validators module: Zod schemas for Intent, Decision, TrustProfile, ProofEvent with utility functions (validate, safeValidate, formatValidationErrors)
40
+ - Common primitives: UUIDSchema, SemVerSchema, TimestampSchema, HashSchema, ActorSchema, TrustBandSchema, AutonomyLevelSchema
41
+ - Feature flag registry: FLAGS constant, FLAG_METADATA, isFeatureEnabled, getEnabledFeatures, getFlagsByCategory, getFlagsByPhase
42
+ - Database schemas: Drizzle ORM table definitions for agents, tenants, attestations, proofs, and more
43
+ - ACI module (deprecated alias for CAR, backwards compatibility)
44
+ - Subpath exports for granular imports: /common, /v2, /validators, /car, /aci, /canonical, /db
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Vorion, Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,435 @@
1
+ # @vorionsys/contracts
2
+
3
+ Shared schemas, types, and validators for the Vorion platform -- the single source of truth for trust profiles, intents, decisions, proof events, governance types, and feature flags used across all Vorion services.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @vorionsys/contracts
9
+ ```
10
+
11
+ **Peer dependency:** TypeScript >= 5.0 (required for type inference).
12
+
13
+ ## What This Package Provides
14
+
15
+ | Category | Description |
16
+ |---|---|
17
+ | **v2 Contract Types** | TypeScript interfaces for Intent, Decision, TrustProfile, ProofEvent, PolicyBundle, CanaryProbe, PreActionGate, Evidence, and Retention |
18
+ | **Enums & Constants** | `TrustBand`, `ObservationTier`, `DecisionTier`, `ActionType`, `DataSensitivity`, `ProofEventType`, `RiskLevel`, and more |
19
+ | **Canonical Agent Types** | Zod-validated schemas for agent lifecycle, runtime status, capabilities, permissions, tasks, configuration, and governance |
20
+ | **CAR (Categorical Agent Registry)** | Agent identity, CAR string parsing/generation, capability levels (L0-L7), certification/runtime tiers (T0-T7), attestations, JWT claims, effective permissions, domain/skill bitmasks |
21
+ | **Validators** | Zod schemas for runtime validation of intents, decisions, trust profiles, and proof events |
22
+ | **Common Primitives** | UUID, SemVer, Timestamp, Hash, Actor, TrustBand, AutonomyLevel, Severity, and RiskLevel schemas |
23
+ | **Feature Flags** | Centralized `FLAGS` registry with metadata, categories, and utility functions |
24
+ | **Database Schemas** | Drizzle ORM table definitions for agents, tenants, attestations, proofs, and more |
25
+
26
+ ## Quick Start
27
+
28
+ ```typescript
29
+ import {
30
+ // Enums
31
+ ObservationTier,
32
+ TrustBand,
33
+ DecisionTier,
34
+ ActionType,
35
+
36
+ // Interfaces (v2 contracts)
37
+ type Intent,
38
+ type Decision,
39
+ type TrustProfile,
40
+ type ProofEvent,
41
+
42
+ // Canonical agent schemas (Zod)
43
+ agentConfigSchema,
44
+ agentLifecycleStatusSchema,
45
+
46
+ // Feature flags
47
+ FLAGS,
48
+ isFeatureEnabled,
49
+
50
+ // Canonical namespace
51
+ Canonical,
52
+ } from '@vorionsys/contracts';
53
+
54
+ // Use enums directly
55
+ const band = TrustBand.T4_STANDARD;
56
+ const tier = ObservationTier.GRAY_BOX;
57
+
58
+ // Validate agent config with Zod
59
+ const config = agentConfigSchema.parse({
60
+ agentId: 'agent-001',
61
+ userId: 'user-001',
62
+ userRole: 'operator',
63
+ status: 'active',
64
+ trustScore: 750,
65
+ name: 'Invoice Processor',
66
+ capabilities: ['execute', 'external'],
67
+ });
68
+
69
+ // Check feature flags
70
+ if (isFeatureEnabled(FLAGS.TRUST_EDGE_CACHE)) {
71
+ // edge caching is enabled
72
+ }
73
+ ```
74
+
75
+ ## Subpath Imports
76
+
77
+ The package exposes granular entry points so you only import what you need:
78
+
79
+ ```typescript
80
+ // Root -- v2 types + canonical agent types + feature flags
81
+ import { TrustBand, ObservationTier, FLAGS } from '@vorionsys/contracts';
82
+
83
+ // Common shared primitives and legacy types
84
+ import { UUIDSchema, ActorSchema, TrustBandSchema } from '@vorionsys/contracts/common';
85
+
86
+ // v2 contract types
87
+ import type { Intent, Decision, TrustProfile } from '@vorionsys/contracts/v2';
88
+
89
+ // Zod validators for v2 types
90
+ import {
91
+ intentSchema,
92
+ decisionSchema,
93
+ trustProfileSchema,
94
+ validate,
95
+ safeValidate,
96
+ } from '@vorionsys/contracts/validators';
97
+
98
+ // CAR (Categorical Agent Registry) -- identity, capabilities, tiers
99
+ import {
100
+ parseCAR,
101
+ generateCAR,
102
+ CapabilityLevel,
103
+ CertificationTier,
104
+ RuntimeTier,
105
+ calculateEffectivePermission,
106
+ } from '@vorionsys/contracts/car';
107
+
108
+ // Canonical governance types
109
+ import {
110
+ type TrustBandName,
111
+ type TrustScoreRange,
112
+ type RiskLevel,
113
+ } from '@vorionsys/contracts/canonical';
114
+
115
+ // Canonical governance (direct subpath)
116
+ import { ... } from '@vorionsys/contracts/canonical/governance';
117
+
118
+ // Database schemas (Drizzle ORM)
119
+ import { agents, tenants, type Agent } from '@vorionsys/contracts/db';
120
+ ```
121
+
122
+ ## Usage Examples
123
+
124
+ ### Validating Data with Zod Schemas
125
+
126
+ ```typescript
127
+ import {
128
+ intentSchema,
129
+ validate,
130
+ safeValidate,
131
+ formatValidationErrors,
132
+ } from '@vorionsys/contracts/validators';
133
+
134
+ // Throws ZodError on invalid data
135
+ const intent = validate(intentSchema, incomingData);
136
+
137
+ // Returns a result object instead of throwing
138
+ const result = safeValidate(intentSchema, incomingData);
139
+ if (result.success) {
140
+ console.log('Valid intent:', result.data);
141
+ } else {
142
+ console.error(formatValidationErrors(result.errors));
143
+ }
144
+ ```
145
+
146
+ ### Canonical Agent Configuration
147
+
148
+ ```typescript
149
+ import {
150
+ agentConfigSchema,
151
+ agentCapabilitySchema,
152
+ type AgentConfig,
153
+ type AgentLifecycleStatus,
154
+ canTransitionLifecycleStatus,
155
+ } from '@vorionsys/contracts';
156
+
157
+ // Validate and narrow types
158
+ const config: AgentConfig = agentConfigSchema.parse(rawData);
159
+
160
+ // Check lifecycle transitions
161
+ const canActivate = canTransitionLifecycleStatus('training', 'active'); // true
162
+ const canArchive = canTransitionLifecycleStatus('archived', 'active'); // false
163
+ ```
164
+
165
+ ### CAR String Parsing and Generation
166
+
167
+ ```typescript
168
+ import {
169
+ parseCAR,
170
+ generateCAR,
171
+ CapabilityLevel,
172
+ calculateEffectivePermission,
173
+ CertificationTier,
174
+ RuntimeTier,
175
+ } from '@vorionsys/contracts/car';
176
+
177
+ // Parse a CAR string into its components
178
+ const parsed = parseCAR('a3i.acme-corp.invoice-bot:ABF-L3@1.0.0');
179
+ // => { registry: 'a3i', organization: 'acme-corp', agentClass: 'invoice-bot',
180
+ // domains: ['A', 'B', 'F'], level: 3, version: '1.0.0' }
181
+
182
+ // Generate a CAR string
183
+ const car = generateCAR({
184
+ registry: 'a3i',
185
+ organization: 'acme-corp',
186
+ agentClass: 'invoice-bot',
187
+ domains: ['A', 'B', 'F'],
188
+ level: CapabilityLevel.L3_EXECUTE,
189
+ version: '1.0.0',
190
+ });
191
+ // => 'a3i.acme-corp.invoice-bot:ABF-L3@1.0.0'
192
+
193
+ // Calculate effective permission
194
+ const permission = calculateEffectivePermission({
195
+ certificationTier: CertificationTier.T3_MONITORED,
196
+ competenceLevel: CapabilityLevel.L4_STANDARD,
197
+ runtimeTier: RuntimeTier.T3_MONITORED,
198
+ observabilityCeiling: 4,
199
+ contextPolicyCeiling: 3,
200
+ });
201
+ ```
202
+
203
+ ### Feature Flags
204
+
205
+ ```typescript
206
+ import {
207
+ FLAGS,
208
+ isFeatureEnabled,
209
+ getEnabledFeatures,
210
+ getFlagsByCategory,
211
+ getFlagMeta,
212
+ type FeatureFlag,
213
+ } from '@vorionsys/contracts';
214
+
215
+ // Check a flag (uses defaultEnabled from metadata)
216
+ if (isFeatureEnabled(FLAGS.PROOF_STREAMING)) {
217
+ // enable streaming proof pipeline
218
+ }
219
+
220
+ // Check with overrides (useful for testing)
221
+ const enabled = isFeatureEnabled(FLAGS.ZK_PROOFS, {
222
+ [FLAGS.ZK_PROOFS]: true,
223
+ });
224
+
225
+ // Get all trust-related flags
226
+ const trustFlags = getFlagsByCategory('trust');
227
+
228
+ // Get metadata for a flag
229
+ const meta = getFlagMeta(FLAGS.MERKLE_PROOFS);
230
+ // => { flag: 'merkle_proofs', name: 'Merkle Proofs', category: 'crypto', phase: 7, ... }
231
+ ```
232
+
233
+ ### Common Primitives
234
+
235
+ ```typescript
236
+ import {
237
+ UUIDSchema,
238
+ TimestampSchema,
239
+ HashSchema,
240
+ ActorSchema,
241
+ TrustBandSchema,
242
+ DecisionOutcomeSchema,
243
+ type Actor,
244
+ type UUID,
245
+ } from '@vorionsys/contracts/common';
246
+
247
+ // Validate a UUID
248
+ const id: UUID = UUIDSchema.parse('550e8400-e29b-41d4-a716-446655440000');
249
+
250
+ // Validate an actor
251
+ const actor: Actor = ActorSchema.parse({
252
+ type: 'AGENT',
253
+ id: 'agent-001',
254
+ name: 'Invoice Bot',
255
+ });
256
+ ```
257
+
258
+ ## API Reference
259
+
260
+ ### Root Exports (`@vorionsys/contracts`)
261
+
262
+ Re-exports everything from v2 contracts, canonical agent types, and feature flags.
263
+
264
+ #### Enums
265
+
266
+ | Export | Description |
267
+ |---|---|
268
+ | `TrustBand` | Trust bands T0 (Sandbox) through T7 (Autonomous) |
269
+ | `ObservationTier` | Observation tiers: BLACK_BOX, GRAY_BOX, WHITE_BOX, ATTESTED_BOX, VERIFIED_BOX |
270
+ | `DecisionTier` | Three-tier governance: GREEN, YELLOW, RED |
271
+ | `ActionType` | Action categories: read, write, delete, execute, communicate, transfer |
272
+ | `DataSensitivity` | Data classification: PUBLIC, INTERNAL, CONFIDENTIAL, RESTRICTED |
273
+ | `Reversibility` | Action reversibility: REVERSIBLE, PARTIALLY_REVERSIBLE, IRREVERSIBLE |
274
+ | `ProofEventType` | Proof event types: intent_received, decision_made, trust_delta, etc. |
275
+ | `ComponentType` | Component registry types: agent, service, adapter, policy_bundle |
276
+ | `ComponentStatus` | Lifecycle: active, deprecated, retired |
277
+ | `ApprovalType` | Approval types: none, human_review, automated_check, multi_party |
278
+ | `RefinementAction` | Refinement actions for YELLOW decisions |
279
+ | `WorkflowState` | Workflow lifecycle states |
280
+ | `DenialReason` | Structured denial reason codes |
281
+ | `RiskProfile` | Temporal risk profiles for outcome tracking |
282
+
283
+ #### Interfaces (v2 Contracts)
284
+
285
+ | Export | Description |
286
+ |---|---|
287
+ | `TrustProfile` | Complete agent trust state with dimensions, weights, and evidence |
288
+ | `TrustDimensions` | Five trust dimensions: CT, BT, GT, XT, AC |
289
+ | `Intent` | Agent action request with resource scope and context |
290
+ | `Decision` | Authorization result with constraints and reasoning |
291
+ | `FluidDecision` | Extended decision with GREEN/YELLOW/RED tiers and refinement |
292
+ | `ProofEvent` | Immutable hash-chained audit trail entry |
293
+ | `PolicyBundle` | Collection of governance policy rules |
294
+ | `CanaryProbe` | ATSF v2.0 continuous behavioral verification probe |
295
+ | `PreActionGateConfig` | Pre-action verification gate configuration |
296
+ | `WorkflowInstance` | Tracks intent lifecycle through governance |
297
+
298
+ #### Constants
299
+
300
+ | Export | Description |
301
+ |---|---|
302
+ | `OBSERVATION_CEILINGS` | Trust ceiling values per observation tier |
303
+ | `DEFAULT_TRUST_WEIGHTS` | Default weights for trust dimensions |
304
+ | `DEFAULT_BAND_THRESHOLDS` | Score thresholds for T0-T7 bands |
305
+ | `DEFAULT_TRUST_DYNAMICS` | Asymmetric trust gain/loss configuration |
306
+ | `DEFAULT_CANARY_CONFIG` | Canary probe injection defaults |
307
+ | `DEFAULT_GATE_CONFIG` | Pre-action gate defaults |
308
+ | `TRUST_THRESHOLDS` | Trust thresholds per risk level |
309
+ | `EVIDENCE_TYPE_MULTIPLIERS` | Weight multipliers per evidence type |
310
+ | `RISK_PROFILE_WINDOWS` | Outcome windows per risk profile |
311
+
312
+ #### Feature Flags
313
+
314
+ | Export | Description |
315
+ |---|---|
316
+ | `FLAGS` | Feature flag registry (const object) |
317
+ | `FLAG_METADATA` | Metadata for each flag (name, description, category, phase) |
318
+ | `FeatureFlag` | Type for flag string values |
319
+ | `FeatureFlagMeta` | Interface for flag metadata |
320
+ | `isFeatureEnabled(flag, overrides?)` | Check if a flag is enabled |
321
+ | `getEnabledFeatures(overrides?)` | Get all enabled flags |
322
+ | `getFlagsByCategory(category)` | Get flags by category |
323
+ | `getFlagsByPhase(phase)` | Get flags by implementation phase |
324
+ | `getFlagMeta(flag)` | Get metadata for a flag |
325
+
326
+ #### Canonical Agent Types
327
+
328
+ | Export | Description |
329
+ |---|---|
330
+ | `AgentLifecycleStatus` | draft, training, active, suspended, archived |
331
+ | `AgentRuntimeStatus` | IDLE, WORKING, PAUSED, ERROR, OFFLINE |
332
+ | `AgentPermission` | execute, external, delegate, spawn, admin |
333
+ | `AgentSpecialization` | core, security, development, operations, etc. |
334
+ | `AgentConfig` | Full agent configuration interface |
335
+ | `AgentTask` | Task assignment structure |
336
+ | `agentConfigSchema` | Zod schema for AgentConfig validation |
337
+ | `agentTaskSchema` | Zod schema for AgentTask validation |
338
+ | `agentCapabilitySchema` | Zod schema for AgentCapability validation |
339
+ | `canTransitionLifecycleStatus()` | Validates lifecycle state transitions |
340
+
341
+ ### Validators (`@vorionsys/contracts/validators`)
342
+
343
+ | Export | Description |
344
+ |---|---|
345
+ | `intentSchema` | Zod schema for Intent validation |
346
+ | `decisionSchema` | Zod schema for Decision validation |
347
+ | `trustProfileSchema` | Zod schema for TrustProfile validation |
348
+ | `proofEventSchema` | Zod schema for ProofEvent validation |
349
+ | `trustDimensionsSchema` | Zod schema for TrustDimensions |
350
+ | `validate(schema, data)` | Validates and throws on failure |
351
+ | `safeValidate(schema, data)` | Validates and returns result object |
352
+ | `formatValidationErrors(errors)` | Formats ZodIssue[] for display |
353
+
354
+ ### CAR Module (`@vorionsys/contracts/car`)
355
+
356
+ | Export | Description |
357
+ |---|---|
358
+ | `parseCAR(str)` / `tryParseCAR(str)` | Parse CAR strings into components |
359
+ | `generateCAR(options)` | Generate CAR string from components |
360
+ | `validateCAR(str)` / `isValidCAR(str)` | Validate CAR string format |
361
+ | `CapabilityLevel` | Enum: L0_NONE through L7_AUTONOMOUS |
362
+ | `CertificationTier` | Enum: T0_SANDBOX through T7_AUTONOMOUS |
363
+ | `RuntimeTier` | Enum: T0_SANDBOX through T7_AUTONOMOUS |
364
+ | `calculateEffectivePermission()` | Compute effective permission from context |
365
+ | `createAgentIdentity()` | Create a new AgentIdentity record |
366
+ | `generateJWTClaims()` | Generate OIDC JWT claims for an agent |
367
+ | `createAttestation()` / `verifyAttestation()` | Attestation management |
368
+ | `encodeDomains()` / `decodeDomains()` | Domain bitmask operations |
369
+ | `encodeSkills()` / `decodeSkills()` | Skill bitmask operations |
370
+
371
+ ### Common Module (`@vorionsys/contracts/common`)
372
+
373
+ | Export | Description |
374
+ |---|---|
375
+ | `UUIDSchema` | Zod UUID validator |
376
+ | `SemVerSchema` | Zod SemVer string validator |
377
+ | `TimestampSchema` | Zod ISO datetime validator |
378
+ | `HashSchema` | Zod SHA-256 hex string validator |
379
+ | `ActorSchema` | Zod Actor object validator |
380
+ | `TrustBandSchema` | Zod TrustBand enum validator (T0-T7) |
381
+ | `AutonomyLevelSchema` | Zod AutonomyLevel enum validator |
382
+ | `DecisionOutcomeSchema` | Zod DecisionOutcome enum validator |
383
+ | `SeveritySchema` | Zod Severity level validator |
384
+ | `RiskLevelSchema` | Zod RiskLevel validator |
385
+ | `VorionError` | Base error class with code and details |
386
+ | `TrustInsufficientError` | Typed error for trust level failures |
387
+
388
+ ### Canonical Module (`@vorionsys/contracts/canonical`)
389
+
390
+ Governance and agent classification schemas including trust bands, trust scores, risk levels, trust signals, governance rules, and middleware types with runtime Zod validation.
391
+
392
+ ### Database Module (`@vorionsys/contracts/db`)
393
+
394
+ Drizzle ORM table definitions for the platform database: `agents`, `tenants`, `attestations`, `stateTransitions`, `approvalRequests`, `apiKeys`, `intents`, `operations`, `proofs`, `merkle`, `escalations`, `webhooks`, `policyVersions`, `rbac`, `trust`, and `serviceAccounts`.
395
+
396
+ ## TypeScript
397
+
398
+ All interfaces are exported as TypeScript types. Zod schemas can be used for runtime validation and type inference:
399
+
400
+ ```typescript
401
+ import type { z } from 'zod';
402
+ import { intentSchema } from '@vorionsys/contracts/validators';
403
+ import { agentConfigSchema } from '@vorionsys/contracts';
404
+
405
+ // Infer types from Zod schemas
406
+ type ValidatedIntent = z.infer<typeof intentSchema>;
407
+ type ValidatedAgentConfig = z.infer<typeof agentConfigSchema>;
408
+ ```
409
+
410
+ For v2 contract interfaces (non-Zod), import types directly:
411
+
412
+ ```typescript
413
+ import type {
414
+ Intent,
415
+ Decision,
416
+ FluidDecision,
417
+ TrustProfile,
418
+ ProofEvent,
419
+ PolicyBundle,
420
+ } from '@vorionsys/contracts';
421
+ ```
422
+
423
+ ## Requirements
424
+
425
+ - Node.js >= 18.0.0
426
+ - TypeScript >= 5.0.0 (peer dependency)
427
+ - Runtime dependency: `zod` >= 3.24
428
+
429
+ ## License
430
+
431
+ Apache-2.0
432
+
433
+ ## Repository
434
+
435
+ [https://github.com/voriongit/vorion](https://github.com/voriongit/vorion)