@vorionsys/runtime 0.1.1 → 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 (4) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +191 -0
  3. package/README.md +465 -57
  4. package/package.json +19 -7
package/CHANGELOG.md ADDED
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@vorionsys/runtime` will be documented in this file.
4
+
5
+ This project adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.2] - 2026-02-17
8
+
9
+ ### Changed
10
+ - Standardized package metadata for npm publish
11
+
12
+ ## [0.1.1] - 2025-02-11
13
+
14
+ ### Changed
15
+
16
+ - TrustFacade trust tier names and score ranges now derived from `@vorionsys/shared-constants` (single source of truth for the 8-tier trust model).
17
+ - Improved trust-facade types to export `sharedScoreToTier` from shared-constants.
18
+
19
+ ### Fixed
20
+
21
+ - Gate trust cache correctly handles admission expiration checks.
22
+
23
+ ## [0.1.0] - 2025-01-31
24
+
25
+ ### Added
26
+
27
+ - **TrustFacade** -- Unified trust interface combining Gate Trust (admission control) and Dynamic Trust (per-action authorization).
28
+ - `admit()` -- one-time agent registration with observation-tier-based scoring.
29
+ - `authorize()` -- per-action authorization with <50ms latency target.
30
+ - `fullCheck()` -- combined admission + authorization in a single call.
31
+ - `recordSignal()` -- asymmetric trust signal processing (10:1 loss-to-gain ratio).
32
+ - `revoke()` -- immediate agent revocation with cache invalidation.
33
+ - Observation tiers (BLACK_BOX / GRAY_BOX / WHITE_BOX) with trust score ceilings.
34
+ - Decision tiers (GREEN / YELLOW / RED) with tier-appropriate constraints and refinements.
35
+ - **ProofCommitter** -- Zero-latency cryptographic proof system.
36
+ - Synchronous SHA-256 hash commitment (<1ms hot path).
37
+ - Async Merkle-tree batching with configurable buffer size and flush interval.
38
+ - Optional Ed25519 signing for batch integrity.
39
+ - `InMemoryProofStore` for testing and development.
40
+ - **IntentPipeline** -- End-to-end intent orchestration.
41
+ - Full lifecycle: Intent -> Gate Check -> Authorization -> Execution -> Proof.
42
+ - Pluggable execution handlers per action type.
43
+ - Automatic trust signal recording on execution outcomes.
44
+ - Quick `check()` for authorization-only queries.
45
+ - Built-in metrics (totalIntents, allowRate, avgProcessingTimeMs).
46
+ - **SQLiteProofStore** -- Persistent proof storage with WAL mode and prepared statements.
47
+ - **SQLiteTrustStore** -- Persistent agent trust records and signal history with WAL mode.
48
+ - **Logger** -- pino-based logger with pretty-printing in development.
49
+ - Subpath exports for tree-shakeable imports (`/trust-facade`, `/proof-committer`, `/intent-pipeline`, `/stores`).
50
+
51
+ [0.1.1]: https://github.com/vorionsys/vorion/compare/@vorionsys/runtime@0.1.0...@vorionsys/runtime@0.1.1
52
+ [0.1.0]: https://github.com/vorionsys/vorion/releases/tag/@vorionsys/runtime@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2025 Vorion
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @vorionsys/runtime
2
2
 
3
- Orchestration layer for AI agent governance. Combines Gate Trust (admission control) and Dynamic Trust (real-time scoring) into a unified, fast decision system.
3
+ Orchestration layer for AI agent governance, built on the [Vorion](https://github.com/vorionsys/vorion) trust framework and aligned with the BASIS (Baseline Authority for Safe & Interoperable Systems) specification.
4
+
5
+ Combines **Gate Trust** (one-time admission control) and **Dynamic Trust** (per-action real-time scoring) into a unified, fast decision system with cryptographic proof of every governance decision.
4
6
 
5
7
  ## Installation
6
8
 
@@ -8,55 +10,118 @@ Orchestration layer for AI agent governance. Combines Gate Trust (admission cont
8
10
  npm install @vorionsys/runtime
9
11
  ```
10
12
 
13
+ **Peer dependencies** (optional, enhance functionality):
14
+
15
+ ```bash
16
+ npm install @vorionsys/atsf-core @vorionsys/contracts
17
+ ```
18
+
11
19
  ## Quick Start
12
20
 
13
21
  ```typescript
14
- import { createTrustFacade } from '@vorionsys/runtime';
22
+ import {
23
+ createTrustFacade,
24
+ createProofCommitter,
25
+ createIntentPipeline,
26
+ } from '@vorionsys/runtime';
15
27
 
28
+ // 1. Create the trust facade (Gate Trust + Dynamic Trust)
16
29
  const facade = createTrustFacade();
17
30
 
18
- // Admit an agent (Gate Trust)
31
+ // 2. Create the proof committer (cryptographic audit trail)
32
+ const committer = createProofCommitter();
33
+
34
+ // 3. Wire them together with the intent pipeline
35
+ const pipeline = createIntentPipeline(facade, committer);
36
+
37
+ // 4. Admit an agent (Gate Trust - "the door")
19
38
  const admission = await facade.admit({
20
39
  agentId: 'agent-123',
21
40
  name: 'DataProcessor',
22
- capabilities: ['read:*', 'write:documents'],
41
+ capabilities: ['read:data', 'write:reports'],
23
42
  observationTier: 'GRAY_BOX',
24
43
  });
25
44
 
26
- // Authorize an action (Dynamic Trust)
45
+ console.log(admission.admitted); // true
46
+ console.log(admission.initialScore); // 200 (GRAY_BOX initial)
47
+ console.log(admission.observationCeiling); // 800
48
+
49
+ // 5. Authorize an action (Dynamic Trust - "the handshake")
27
50
  const auth = await facade.authorize('agent-123', {
28
51
  type: 'read',
29
- resource: 'documents/report.pdf',
52
+ resource: 'data/users',
30
53
  });
31
54
 
32
55
  if (auth.allowed) {
33
- // Action permitted - execute with constraints
34
- console.log('Tier:', auth.tier);
35
- console.log('Constraints:', auth.constraints);
56
+ console.log('Decision tier:', auth.tier); // 'GREEN'
57
+ console.log('Constraints:', auth.constraints); // { timeoutMs, maxOperations, ... }
36
58
  }
37
59
  ```
38
60
 
39
- ## Features
61
+ ## What It Provides
62
+
63
+ | Component | Purpose |
64
+ |---|---|
65
+ | **TrustFacade** | Unified API combining gate trust (admission) and dynamic trust (per-action authorization) with an 8-tier trust model (T0-T7) |
66
+ | **ProofCommitter** | Zero-latency synchronous hash commitment (<1ms) with async Merkle-tree batching and optional Ed25519 signing |
67
+ | **IntentPipeline** | End-to-end orchestration: Intent -> Gate Check -> Authorization -> Execution -> Proof |
68
+ | **SQLiteProofStore** | Persistent proof storage backed by better-sqlite3 with WAL mode |
69
+ | **SQLiteTrustStore** | Persistent agent trust records and signal history backed by better-sqlite3 |
70
+ | **InMemoryProofStore** | In-memory proof store for testing and development |
71
+
72
+ ## Core Concepts
73
+
74
+ ### Trust Tiers (T0-T7)
75
+
76
+ Agents are assigned a numeric trust score (0-1000) that maps to one of eight tiers:
77
+
78
+ | Tier | Name | Score Range |
79
+ |------|------|-------------|
80
+ | T0 | Untrusted | 0-99 |
81
+ | T1 | Provisional | 100-199 |
82
+ | T2 | Basic | 200-349 |
83
+ | T3 | Monitored | 350-499 |
84
+ | T4 | Standard | 500-649 |
85
+ | T5 | Trusted | 650-799 |
86
+ | T6 | Elevated | 800-899 |
87
+ | T7 | Autonomous | 900-1000 |
88
+
89
+ ### Observation Tiers
90
+
91
+ Agent visibility determines the maximum trust score (ceiling) an agent can achieve:
92
+
93
+ - **BLACK_BOX** -- Opaque internals, ceiling at 500 (max T3)
94
+ - **GRAY_BOX** -- Partial visibility, ceiling at 800 (max T5)
95
+ - **WHITE_BOX** -- Full visibility, ceiling at 1000 (max T7)
96
+
97
+ ### Decision Tiers
98
+
99
+ Every authorization returns one of three decision tiers:
100
+
101
+ - **GREEN** -- Allowed with standard constraints
102
+ - **YELLOW** -- Allowed with additional constraints and refinement options
103
+ - **RED** -- Denied
40
104
 
41
- - **TrustFacade**: Unified API combining gate trust and dynamic trust
42
- - **ProofCommitter**: Zero-latency proof event batching and commitment
43
- - **IntentPipeline**: Orchestrated intent processing with pluggable handlers
44
- - **SQLite Stores**: Persistent trust and proof stores backed by better-sqlite3
45
- - **Trust Signals**: Record success/failure signals that update agent trust scores
46
- - **Configurable**: Full configuration for thresholds, timeouts, and behavior
105
+ ### Asymmetric Trust Dynamics
106
+
107
+ Trust is hard to earn and easy to lose. Decay and recovery dynamics are policy-configurable, preventing rapid trust escalation while enforcing accountability.
47
108
 
48
109
  ## Subpath Imports
49
110
 
111
+ Each major component is available as a subpath import:
112
+
50
113
  ```typescript
51
- // Core facade
52
- import { createTrustFacade, TrustFacade } from '@vorionsys/runtime';
53
- import { createTrustFacade } from '@vorionsys/runtime/trust-facade';
114
+ // Root -- all exports
115
+ import { createTrustFacade, createProofCommitter, createIntentPipeline } from '@vorionsys/runtime';
116
+
117
+ // Trust facade only
118
+ import { createTrustFacade, TrustFacade } from '@vorionsys/runtime/trust-facade';
54
119
 
55
- // Intent pipeline
56
- import { createIntentPipeline } from '@vorionsys/runtime/intent-pipeline';
120
+ // Proof committer only
121
+ import { createProofCommitter, ProofCommitter } from '@vorionsys/runtime/proof-committer';
57
122
 
58
- // Proof committer
59
- import { createProofCommitter } from '@vorionsys/runtime/proof-committer';
123
+ // Intent pipeline only
124
+ import { createIntentPipeline, IntentPipeline } from '@vorionsys/runtime/intent-pipeline';
60
125
 
61
126
  // Persistent stores
62
127
  import { createSQLiteProofStore, createSQLiteTrustStore } from '@vorionsys/runtime/stores';
@@ -66,80 +131,397 @@ import { createSQLiteProofStore, createSQLiteTrustStore } from '@vorionsys/runti
66
131
 
67
132
  ### TrustFacade
68
133
 
69
- The primary API for agent governance:
134
+ The primary API for agent governance. Implements the `TrustGate` interface.
70
135
 
71
136
  ```typescript
137
+ import { createTrustFacade, type TrustFacadeConfig } from '@vorionsys/runtime';
138
+
72
139
  const facade = createTrustFacade({
73
- // All config is optional with sensible defaults
140
+ // All fields are optional with sensible defaults
141
+ gateTrustCacheTtlMs: 3600000, // Cache gate trust results for 1 hour
142
+ maxAuthorizationLatencyMs: 50, // Target latency for authorize()
143
+ useAtsfForPersistence: true, // Use ATSF-core for persistence
144
+ useA3iForDynamics: true, // Use A3I for trust dynamics
145
+ primaryScoreSource: 'atsf', // Primary source for trust scores
74
146
  });
147
+ ```
75
148
 
76
- // Admit agent (gate trust check)
77
- const admission = await facade.admit(credentials);
78
- // { admitted: boolean, tier: TrustTier, score: number, ... }
149
+ #### `facade.admit(agent: AgentCredentials): Promise<AdmissionResult>`
79
150
 
80
- // Authorize action (dynamic trust check)
81
- const auth = await facade.authorize(agentId, action);
82
- // { allowed: boolean, tier: DecisionTier, reason: string, constraints: Constraints }
151
+ Gate trust check -- called once at agent registration. Result is cached.
83
152
 
84
- // Full check (admit + authorize in one call)
85
- const result = await facade.fullCheck(credentials, action);
153
+ ```typescript
154
+ const result = await facade.admit({
155
+ agentId: 'agent-123',
156
+ name: 'My Agent',
157
+ capabilities: ['read:data', 'write:reports'],
158
+ observationTier: 'WHITE_BOX', // 'BLACK_BOX' | 'GRAY_BOX' | 'WHITE_BOX'
159
+ metadata: { version: '1.0' }, // optional
160
+ });
161
+
162
+ // AdmissionResult:
163
+ // {
164
+ // admitted: boolean,
165
+ // initialTier: TrustTier, // 0-7
166
+ // initialScore: number, // e.g. 300 for WHITE_BOX
167
+ // observationCeiling: number, // e.g. 1000 for WHITE_BOX
168
+ // capabilities: string[],
169
+ // expiresAt: Date,
170
+ // reason?: string, // set when admitted === false
171
+ // }
172
+ ```
86
173
 
87
- // Record trust signal
88
- await facade.recordSignal(agentId, {
89
- type: 'success',
90
- source: 'sdk',
91
- weight: 0.1,
174
+ #### `facade.authorize(agentId: string, action: Action): Promise<AuthorizationResult>`
175
+
176
+ Dynamic trust check -- called on every action. Must be fast (<50ms target).
177
+
178
+ ```typescript
179
+ const auth = await facade.authorize('agent-123', {
180
+ type: 'read', // 'read' | 'write' | 'delete' | 'execute' | ...
181
+ resource: 'data/users',
182
+ context: { limit: 100 }, // optional
92
183
  });
184
+
185
+ // AuthorizationResult:
186
+ // {
187
+ // allowed: boolean,
188
+ // tier: DecisionTier, // 'GREEN' | 'YELLOW' | 'RED'
189
+ // currentScore: number,
190
+ // currentTier: TrustTier,
191
+ // constraints?: Constraints, // timeoutMs, maxOperations, resourceLimits
192
+ // refinements?: Refinement[], // YELLOW decisions include refinement options
193
+ // reason: string,
194
+ // latencyMs: number,
195
+ // }
93
196
  ```
94
197
 
198
+ #### `facade.fullCheck(agent: AgentCredentials, action: Action): Promise<FullCheckResult>`
199
+
200
+ Combined admission + authorization in a single call. Useful for first-time agent interactions.
201
+
202
+ ```typescript
203
+ const result = await facade.fullCheck(agentCredentials, action);
204
+
205
+ // FullCheckResult:
206
+ // {
207
+ // admission: AdmissionResult,
208
+ // authorization?: AuthorizationResult, // only present if admission.admitted === true
209
+ // }
210
+ ```
211
+
212
+ #### `facade.recordSignal(signal: TrustSignal): Promise<void>`
213
+
214
+ Record a trust signal that updates the agent's dynamic trust score.
215
+
216
+ ```typescript
217
+ await facade.recordSignal({
218
+ agentId: 'agent-123',
219
+ type: 'success', // 'success' | 'failure' | 'violation' | 'neutral'
220
+ weight: 0.5, // 0-1
221
+ source: 'execution-engine',
222
+ context: { intentId: '...' }, // optional
223
+ });
224
+ ```
225
+
226
+ #### `facade.getScore(agentId: string): Promise<number | null>`
227
+
228
+ Returns the current trust score, or `null` if the agent is unknown.
229
+
230
+ #### `facade.getTier(agentId: string): Promise<TrustTier | null>`
231
+
232
+ Returns the current trust tier (0-7), or `null` if the agent is unknown.
233
+
234
+ #### `facade.revoke(agentId: string, reason: string): Promise<void>`
235
+
236
+ Revoke an agent's admission. Clears cached trust data and prevents future authorizations until re-admitted.
237
+
238
+ ---
239
+
95
240
  ### ProofCommitter
96
241
 
97
- Zero-latency proof event batching:
242
+ Zero-latency cryptographic proof system. Synchronous hash commitment on the hot path (<1ms), with asynchronous Merkle-tree batching on the cold path.
98
243
 
99
244
  ```typescript
245
+ import { createProofCommitter, type ProofCommitterConfig } from '@vorionsys/runtime';
246
+
100
247
  const committer = createProofCommitter({
101
- batchSize: 100,
102
- flushIntervalMs: 5000,
248
+ maxBufferSize: 100, // Auto-flush when buffer reaches this size
249
+ flushIntervalMs: 100, // Periodic flush interval
250
+ enableSigning: false, // Enable Ed25519 signing
251
+ privateKey: undefined, // Base64-encoded Ed25519 private key (required if signing enabled)
103
252
  });
253
+ ```
254
+
255
+ #### `committer.commit(event: ProofEvent): string`
104
256
 
105
- // Commit proof events (batched automatically)
106
- committer.commit(proofEvent);
257
+ Synchronous hot-path commitment. Returns a commitment ID. Target: <1ms.
107
258
 
108
- // Force flush
109
- await committer.flush();
259
+ ```typescript
260
+ const commitmentId = committer.commit({
261
+ type: 'intent_submitted', // ProofEventType
262
+ entityId: 'agent-123',
263
+ payload: { action: 'read', resource: 'data/users' },
264
+ timestamp: Date.now(),
265
+ correlationId: 'corr-456', // optional, for linking related events
266
+ });
110
267
  ```
111
268
 
269
+ **ProofEventType values:** `'intent_submitted'` | `'decision_made'` | `'execution_started'` | `'execution_completed'` | `'trust_signal'` | `'agent_admitted'` | `'agent_revoked'` | `'parity_violation'`
270
+
271
+ #### `committer.flush(): Promise<void>`
272
+
273
+ Force-flush the buffer. Builds a Merkle tree, optionally signs, and persists to the proof store.
274
+
275
+ #### `committer.stop(): Promise<void>`
276
+
277
+ Flush remaining events and stop the periodic flush timer. Call this on shutdown.
278
+
279
+ #### `committer.getCommitment(commitmentId: string): Promise<ProofCommitment | null>`
280
+
281
+ Retrieve a commitment from the store by ID.
282
+
283
+ #### `committer.getCommitmentsForEntity(entityId: string): Promise<ProofCommitment[]>`
284
+
285
+ Retrieve all commitments for a given entity (agent, intent, etc.).
286
+
287
+ #### `committer.verifyCommitment(commitment: ProofCommitment): boolean`
288
+
289
+ Verify a commitment's SHA-256 hash matches the original event.
290
+
291
+ #### `committer.getMetrics()`
292
+
293
+ Returns `{ totalCommitments, totalBatches, avgFlushTimeMs, bufferSize }`.
294
+
295
+ #### `committer.getBufferSize(): number`
296
+
297
+ Returns the number of uncommitted events in the buffer.
298
+
299
+ ---
300
+
112
301
  ### IntentPipeline
113
302
 
114
- Orchestrated intent processing:
303
+ Orchestrates the full agent intent lifecycle: **Intent -> Gate Check -> Authorization -> Execution -> Proof**.
304
+
305
+ ```typescript
306
+ import { createIntentPipeline, type IntentPipelineConfig } from '@vorionsys/runtime';
307
+
308
+ const pipeline = createIntentPipeline(trustFacade, proofCommitter, {
309
+ verboseLogging: false, // Enable detailed logging
310
+ timeoutMs: 5000, // Maximum processing time
311
+ autoRecordSignals: true, // Auto-record trust signals on execution
312
+ });
313
+ ```
314
+
315
+ #### `pipeline.registerHandler(actionType: string, handler: ExecutionHandler): void`
316
+
317
+ Register an execution handler for an action type.
115
318
 
116
319
  ```typescript
117
- const pipeline = createIntentPipeline({
118
- handlers: [myHandler],
320
+ pipeline.registerHandler('read', async (intent, context) => {
321
+ // Execute the intent
322
+ const data = await myDatabase.query(intent.action.resource);
323
+ return { success: true, result: data };
324
+ });
325
+
326
+ pipeline.registerHandler('write', async (intent, context) => {
327
+ try {
328
+ await myDatabase.write(intent.action.resource, intent.metadata);
329
+ return { success: true };
330
+ } catch (err) {
331
+ return { success: false, error: err.message };
332
+ }
119
333
  });
334
+ ```
335
+
336
+ #### `pipeline.submit(credentials: AgentCredentials, action: Action, metadata?: Record<string, unknown>): Promise<IntentResult>`
120
337
 
121
- const result = await pipeline.process(intent);
122
- // { allowed: boolean, decision: Decision, proofId: string }
338
+ Submit an intent for full processing (gate check, authorization, execution, proof).
339
+
340
+ ```typescript
341
+ const result = await pipeline.submit(
342
+ {
343
+ agentId: 'agent-123',
344
+ name: 'DataProcessor',
345
+ capabilities: ['read:data'],
346
+ observationTier: 'GRAY_BOX',
347
+ },
348
+ { type: 'read', resource: 'data/users' },
349
+ { limit: 50 }, // optional metadata
350
+ );
351
+
352
+ // IntentResult:
353
+ // {
354
+ // intentId: string,
355
+ // allowed: boolean,
356
+ // tier: DecisionTier, // 'GREEN' | 'YELLOW' | 'RED'
357
+ // reason: string,
358
+ // commitmentId: string, // proof commitment ID
359
+ // constraints?: string[],
360
+ // processingTimeMs: number,
361
+ // }
123
362
  ```
124
363
 
364
+ #### `pipeline.check(credentials: AgentCredentials, action: Action): Promise<{ allowed, tier, reason }>`
365
+
366
+ Quick authorization check without execution.
367
+
368
+ #### `pipeline.getMetrics()`
369
+
370
+ Returns `{ totalIntents, allowedIntents, deniedIntents, avgProcessingTimeMs, allowRate }`.
371
+
372
+ #### `pipeline.flushProofs(): Promise<void>`
373
+
374
+ Flush all pending proof commitments.
375
+
376
+ #### `pipeline.stop(): Promise<void>`
377
+
378
+ Stop the pipeline and flush remaining proofs.
379
+
380
+ ---
381
+
125
382
  ### Persistent Stores
126
383
 
384
+ SQLite-backed stores for production use. Both use WAL mode by default for better write concurrency.
385
+
386
+ #### SQLiteProofStore
387
+
127
388
  ```typescript
128
- import { createSQLiteProofStore, createSQLiteTrustStore } from '@vorionsys/runtime/stores';
389
+ import { createSQLiteProofStore } from '@vorionsys/runtime/stores';
390
+
391
+ const proofStore = createSQLiteProofStore({
392
+ dbPath: './data/proofs.db', // Use ':memory:' for in-memory
393
+ walMode: true, // default: true
394
+ });
395
+
396
+ // Pass to ProofCommitter
397
+ const committer = createProofCommitter({ maxBufferSize: 100 }, proofStore);
398
+
399
+ // Query proofs
400
+ const commitment = await proofStore.getCommitment('commitment-id');
401
+ const batch = await proofStore.getBatch('batch-id');
402
+ const entityProofs = await proofStore.getCommitmentsForEntity('agent-123');
403
+
404
+ // Housekeeping
405
+ proofStore.getStats(); // { batches: number, commitments: number }
406
+ proofStore.close(); // Close DB connection on shutdown
407
+ ```
408
+
409
+ #### SQLiteTrustStore
410
+
411
+ ```typescript
412
+ import { createSQLiteTrustStore } from '@vorionsys/runtime/stores';
413
+
414
+ const trustStore = createSQLiteTrustStore({
415
+ dbPath: './data/trust.db', // Use ':memory:' for in-memory
416
+ walMode: true, // default: true
417
+ });
418
+
419
+ // Save/retrieve agent trust records
420
+ await trustStore.saveAgent(agentRecord);
421
+ const agent = await trustStore.getAgent('agent-123');
422
+
423
+ // Update scores
424
+ await trustStore.updateScore('agent-123', 450, 3);
425
+
426
+ // Revoke
427
+ await trustStore.revokeAgent('agent-123', 'Policy violation');
428
+
429
+ // Record and query trust signals
430
+ await trustStore.recordSignal(signalRecord);
431
+ const signals = await trustStore.getSignals('agent-123', 50);
129
432
 
130
- // Proof store
131
- const proofStore = createSQLiteProofStore({ path: './data/proofs.db' });
433
+ // List active agents
434
+ const agents = await trustStore.listActiveAgents();
132
435
 
133
- // Trust store
134
- const trustStore = createSQLiteTrustStore({ path: './data/trust.db' });
436
+ // Housekeeping
437
+ trustStore.getStats(); // { agents, activeAgents, signals }
438
+ trustStore.close();
439
+ ```
440
+
441
+ #### InMemoryProofStore
442
+
443
+ ```typescript
444
+ import { InMemoryProofStore } from '@vorionsys/runtime';
445
+
446
+ const store = new InMemoryProofStore();
447
+ // Same ProofStore interface, useful for testing
448
+ store.getStats(); // { batches: number, commitments: number }
449
+ store.clear(); // Reset all data
450
+ ```
451
+
452
+ ---
453
+
454
+ ### Logger
455
+
456
+ ```typescript
457
+ import { createLogger } from '@vorionsys/runtime';
458
+
459
+ const logger = createLogger({
460
+ component: 'my-component',
461
+ level: 'debug', // optional, defaults to LOG_LEVEL env var or 'info'
462
+ });
463
+ ```
464
+
465
+ Uses [pino](https://github.com/pinojs/pino) with pretty-printing in non-production environments.
466
+
467
+ ## Full Example: Intent Pipeline
468
+
469
+ ```typescript
470
+ import {
471
+ createTrustFacade,
472
+ createProofCommitter,
473
+ createIntentPipeline,
474
+ createSQLiteProofStore,
475
+ } from '@vorionsys/runtime';
476
+
477
+ // Set up persistent proof storage
478
+ const proofStore = createSQLiteProofStore({ dbPath: './data/proofs.db' });
479
+
480
+ // Create the governance stack
481
+ const facade = createTrustFacade();
482
+ const committer = createProofCommitter({ maxBufferSize: 50 }, proofStore);
483
+ const pipeline = createIntentPipeline(facade, committer, {
484
+ autoRecordSignals: true,
485
+ });
486
+
487
+ // Register execution handlers
488
+ pipeline.registerHandler('read', async (intent) => {
489
+ const data = await fetchData(intent.action.resource);
490
+ return { success: true, result: data };
491
+ });
492
+
493
+ // Submit an intent
494
+ const result = await pipeline.submit(
495
+ {
496
+ agentId: 'data-agent',
497
+ name: 'Data Agent',
498
+ capabilities: ['read:data'],
499
+ observationTier: 'GRAY_BOX',
500
+ },
501
+ { type: 'read', resource: 'data/reports' },
502
+ );
503
+
504
+ if (result.allowed) {
505
+ console.log(`Intent ${result.intentId} processed in ${result.processingTimeMs}ms`);
506
+ console.log(`Decision: ${result.tier}, Proof: ${result.commitmentId}`);
507
+ } else {
508
+ console.log(`Denied: ${result.reason}`);
509
+ }
510
+
511
+ // Graceful shutdown
512
+ await pipeline.stop();
513
+ proofStore.close();
135
514
  ```
136
515
 
137
516
  ## TypeScript
138
517
 
518
+ All types are exported from the root entry point:
519
+
139
520
  ```typescript
140
521
  import type {
141
- TrustFacadeConfig,
522
+ // Trust Facade
142
523
  TrustGate,
524
+ TrustFacadeConfig,
143
525
  AgentCredentials,
144
526
  AdmissionResult,
145
527
  Action,
@@ -148,21 +530,47 @@ import type {
148
530
  TrustSignal,
149
531
  TrustTier,
150
532
  DecisionTier,
533
+ ObservationTier,
151
534
  Constraints,
535
+ Refinement,
536
+
537
+ // Proof Committer
152
538
  ProofEvent,
539
+ ProofEventType,
540
+ ProofCommitment,
541
+ ProofBatch,
153
542
  ProofCommitterConfig,
154
543
  ProofStore,
544
+
545
+ // Intent Pipeline
155
546
  Intent,
156
547
  IntentResult,
548
+ PipelineContext,
157
549
  IntentPipelineConfig,
158
550
  ExecutionHandler,
551
+
552
+ // Stores
159
553
  SQLiteProofStoreConfig,
160
554
  SQLiteTrustStoreConfig,
161
555
  TrustStore,
162
556
  AgentTrustRecord,
557
+ TrustSignalRecord,
558
+
559
+ // Logger
560
+ LoggerOptions,
163
561
  } from '@vorionsys/runtime';
164
562
  ```
165
563
 
564
+ ## Requirements
565
+
566
+ - Node.js >= 18.0.0
567
+ - TypeScript >= 5.0 (peer dependency)
568
+
166
569
  ## License
167
570
 
168
- MIT
571
+ [Apache-2.0](./LICENSE)
572
+
573
+ ## Links
574
+
575
+ - [Vorion Monorepo](https://github.com/vorionsys/vorion)
576
+ - [BASIS Specification](https://github.com/vorionsys/vorion/tree/main/docs) -- Baseline Authority for Safe & Interoperable Systems
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vorionsys/runtime",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Vorion Runtime - Orchestration layer for AI agent governance",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -31,19 +31,23 @@
31
31
  }
32
32
  },
33
33
  "files": [
34
- "dist"
34
+ "dist",
35
+ "README.md",
36
+ "LICENSE",
37
+ "CHANGELOG.md"
35
38
  ],
36
39
  "scripts": {
37
40
  "build": "tsc",
38
41
  "dev": "tsc --watch",
39
42
  "test": "vitest run",
40
43
  "test:watch": "vitest",
44
+ "test:coverage": "vitest run --coverage",
41
45
  "typecheck": "tsc --noEmit",
42
46
  "lint": "eslint src",
43
- "clean": "rm -rf dist"
47
+ "clean": "rimraf dist"
44
48
  },
45
49
  "dependencies": {
46
- "@vorionsys/shared-constants": "*",
50
+ "@vorionsys/shared-constants": "^1.0.1",
47
51
  "better-sqlite3": "^11.0.0",
48
52
  "pino": "^9.0.0",
49
53
  "pino-pretty": "^11.0.0"
@@ -73,15 +77,23 @@
73
77
  "trust",
74
78
  "governance",
75
79
  "runtime",
76
- "vorion"
80
+ "vorion",
81
+ "basis",
82
+ "safety",
83
+ "orchestration",
84
+ "proof",
85
+ "audit"
77
86
  ],
78
87
  "author": "Vorion <team@vorion.org>",
79
- "license": "MIT",
88
+ "license": "Apache-2.0",
80
89
  "repository": {
81
90
  "type": "git",
82
- "url": "https://github.com/voriongit/vorion.git",
91
+ "url": "git+https://github.com/vorionsys/vorion.git",
83
92
  "directory": "packages/runtime"
84
93
  },
94
+ "bugs": {
95
+ "url": "https://github.com/vorionsys/vorion/issues"
96
+ },
85
97
  "homepage": "https://vorion.org",
86
98
  "engines": {
87
99
  "node": ">=18.0.0"