@vorionsys/atsf-core 0.2.0 → 0.2.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.
- package/CHANGELOG.md +67 -0
- package/LICENSE +190 -0
- package/README.md +305 -181
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +86 -4
- package/dist/api/server.js.map +1 -1
- package/dist/basis/parser.d.ts +210 -210
- package/dist/basis/parser.js.map +1 -1
- package/dist/chain/index.d.ts +147 -0
- package/dist/chain/index.d.ts.map +1 -0
- package/dist/chain/index.js +219 -0
- package/dist/chain/index.js.map +1 -0
- package/dist/common/adapters.d.ts +9 -9
- package/dist/common/adapters.d.ts.map +1 -1
- package/dist/common/adapters.js +6 -6
- package/dist/common/config.d.ts +152 -152
- package/dist/common/types.d.ts +35 -15
- package/dist/common/types.d.ts.map +1 -1
- package/dist/common/types.js.map +1 -1
- package/dist/enforce/index.d.ts +226 -16
- package/dist/enforce/index.d.ts.map +1 -1
- package/dist/enforce/index.js +196 -49
- package/dist/enforce/index.js.map +1 -1
- package/dist/governance/index.d.ts +2 -0
- package/dist/governance/index.d.ts.map +1 -1
- package/dist/governance/index.js +1 -0
- package/dist/governance/index.js.map +1 -1
- package/dist/governance/proof-bridge.d.ts +86 -0
- package/dist/governance/proof-bridge.d.ts.map +1 -0
- package/dist/governance/proof-bridge.js +139 -0
- package/dist/governance/proof-bridge.js.map +1 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/intent/index.d.ts +127 -10
- package/dist/intent/index.d.ts.map +1 -1
- package/dist/intent/index.js +121 -16
- package/dist/intent/index.js.map +1 -1
- package/dist/langchain/executor.d.ts +19 -5
- package/dist/langchain/executor.d.ts.map +1 -1
- package/dist/langchain/executor.js +287 -36
- package/dist/langchain/executor.js.map +1 -1
- package/dist/langchain/index.d.ts +2 -1
- package/dist/langchain/index.d.ts.map +1 -1
- package/dist/langchain/index.js +3 -1
- package/dist/langchain/index.js.map +1 -1
- package/dist/langchain/tools.d.ts.map +1 -1
- package/dist/langchain/tools.js +2 -1
- package/dist/langchain/tools.js.map +1 -1
- package/dist/langchain/types.d.ts +41 -0
- package/dist/langchain/types.d.ts.map +1 -1
- package/dist/layers/index.d.ts +1 -1
- package/dist/layers/index.d.ts.map +1 -1
- package/dist/persistence/file.d.ts +35 -3
- package/dist/persistence/file.d.ts.map +1 -1
- package/dist/persistence/file.js +138 -11
- package/dist/persistence/file.js.map +1 -1
- package/dist/persistence/index.d.ts +10 -1
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +15 -1
- package/dist/persistence/index.js.map +1 -1
- package/dist/persistence/sqlite.d.ts +135 -0
- package/dist/persistence/sqlite.d.ts.map +1 -0
- package/dist/persistence/sqlite.js +372 -0
- package/dist/persistence/sqlite.js.map +1 -0
- package/dist/phase6/ceiling.d.ts +177 -0
- package/dist/phase6/ceiling.d.ts.map +1 -0
- package/dist/phase6/ceiling.js +463 -0
- package/dist/phase6/ceiling.js.map +1 -0
- package/dist/phase6/context.d.ts +207 -0
- package/dist/phase6/context.d.ts.map +1 -0
- package/dist/phase6/context.js +603 -0
- package/dist/phase6/context.js.map +1 -0
- package/dist/phase6/index.d.ts +79 -0
- package/dist/phase6/index.d.ts.map +1 -0
- package/dist/phase6/index.js +152 -0
- package/dist/phase6/index.js.map +1 -0
- package/dist/phase6/presets.d.ts +148 -0
- package/dist/phase6/presets.d.ts.map +1 -0
- package/dist/phase6/presets.js +467 -0
- package/dist/phase6/presets.js.map +1 -0
- package/dist/phase6/provenance.d.ts +148 -0
- package/dist/phase6/provenance.d.ts.map +1 -0
- package/dist/phase6/provenance.js +545 -0
- package/dist/phase6/provenance.js.map +1 -0
- package/dist/phase6/role-gates/index.d.ts +7 -0
- package/dist/phase6/role-gates/index.d.ts.map +1 -0
- package/dist/phase6/role-gates/index.js +7 -0
- package/dist/phase6/role-gates/index.js.map +1 -0
- package/dist/phase6/role-gates/kernel.d.ts +84 -0
- package/dist/phase6/role-gates/kernel.d.ts.map +1 -0
- package/dist/phase6/role-gates/kernel.js +258 -0
- package/dist/phase6/role-gates/kernel.js.map +1 -0
- package/dist/phase6/role-gates/policy.d.ts +110 -0
- package/dist/phase6/role-gates/policy.d.ts.map +1 -0
- package/dist/phase6/role-gates/policy.js +157 -0
- package/dist/phase6/role-gates/policy.js.map +1 -0
- package/dist/phase6/role-gates.d.ts +164 -0
- package/dist/phase6/role-gates.d.ts.map +1 -0
- package/dist/phase6/role-gates.js +536 -0
- package/dist/phase6/role-gates.js.map +1 -0
- package/dist/phase6/types.d.ts +1829 -0
- package/dist/phase6/types.d.ts.map +1 -0
- package/dist/phase6/types.js +452 -0
- package/dist/phase6/types.js.map +1 -0
- package/dist/phase6/weight-presets/canonical.d.ts +93 -0
- package/dist/phase6/weight-presets/canonical.d.ts.map +1 -0
- package/dist/phase6/weight-presets/canonical.js +122 -0
- package/dist/phase6/weight-presets/canonical.js.map +1 -0
- package/dist/phase6/weight-presets/deltas.d.ts +144 -0
- package/dist/phase6/weight-presets/deltas.d.ts.map +1 -0
- package/dist/phase6/weight-presets/deltas.js +184 -0
- package/dist/phase6/weight-presets/deltas.js.map +1 -0
- package/dist/phase6/weight-presets/index.d.ts +8 -0
- package/dist/phase6/weight-presets/index.d.ts.map +1 -0
- package/dist/phase6/weight-presets/index.js +8 -0
- package/dist/phase6/weight-presets/index.js.map +1 -0
- package/dist/phase6/weight-presets/merger.d.ts +79 -0
- package/dist/phase6/weight-presets/merger.d.ts.map +1 -0
- package/dist/phase6/weight-presets/merger.js +161 -0
- package/dist/phase6/weight-presets/merger.js.map +1 -0
- package/dist/proof/index.d.ts +6 -0
- package/dist/proof/index.d.ts.map +1 -1
- package/dist/proof/index.js +56 -6
- package/dist/proof/index.js.map +1 -1
- package/dist/proof/merkle.d.ts +195 -0
- package/dist/proof/merkle.d.ts.map +1 -0
- package/dist/proof/merkle.js +412 -0
- package/dist/proof/merkle.js.map +1 -0
- package/dist/proof/zk-proofs.d.ts +218 -0
- package/dist/proof/zk-proofs.d.ts.map +1 -0
- package/dist/proof/zk-proofs.js +531 -0
- package/dist/proof/zk-proofs.js.map +1 -0
- package/dist/sandbox-training/challenges.d.ts +16 -0
- package/dist/sandbox-training/challenges.d.ts.map +1 -0
- package/dist/sandbox-training/challenges.js +561 -0
- package/dist/sandbox-training/challenges.js.map +1 -0
- package/dist/sandbox-training/graduation.d.ts +25 -0
- package/dist/sandbox-training/graduation.d.ts.map +1 -0
- package/dist/sandbox-training/graduation.js +143 -0
- package/dist/sandbox-training/graduation.js.map +1 -0
- package/dist/sandbox-training/index.d.ts +19 -0
- package/dist/sandbox-training/index.d.ts.map +1 -0
- package/dist/sandbox-training/index.js +22 -0
- package/dist/sandbox-training/index.js.map +1 -0
- package/dist/sandbox-training/promotion-service.d.ts +76 -0
- package/dist/sandbox-training/promotion-service.d.ts.map +1 -0
- package/dist/sandbox-training/promotion-service.js +117 -0
- package/dist/sandbox-training/promotion-service.js.map +1 -0
- package/dist/sandbox-training/runner.d.ts +58 -0
- package/dist/sandbox-training/runner.d.ts.map +1 -0
- package/dist/sandbox-training/runner.js +388 -0
- package/dist/sandbox-training/runner.js.map +1 -0
- package/dist/sandbox-training/scorer.d.ts +40 -0
- package/dist/sandbox-training/scorer.d.ts.map +1 -0
- package/dist/sandbox-training/scorer.js +79 -0
- package/dist/sandbox-training/scorer.js.map +1 -0
- package/dist/sandbox-training/types.d.ts +162 -0
- package/dist/sandbox-training/types.d.ts.map +1 -0
- package/dist/sandbox-training/types.js +32 -0
- package/dist/sandbox-training/types.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts +98 -0
- package/dist/trust-engine/ceiling-enforcement/audit.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/audit.js +160 -0
- package/dist/trust-engine/ceiling-enforcement/audit.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/index.d.ts +6 -0
- package/dist/trust-engine/ceiling-enforcement/index.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/index.js +6 -0
- package/dist/trust-engine/ceiling-enforcement/index.js.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts +112 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.d.ts.map +1 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.js +158 -0
- package/dist/trust-engine/ceiling-enforcement/kernel.js.map +1 -0
- package/dist/trust-engine/context-policy/enforcement.d.ts +62 -0
- package/dist/trust-engine/context-policy/enforcement.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/enforcement.js +104 -0
- package/dist/trust-engine/context-policy/enforcement.js.map +1 -0
- package/dist/trust-engine/context-policy/factory.d.ts +75 -0
- package/dist/trust-engine/context-policy/factory.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/factory.js +130 -0
- package/dist/trust-engine/context-policy/factory.js.map +1 -0
- package/dist/trust-engine/context-policy/index.d.ts +6 -0
- package/dist/trust-engine/context-policy/index.d.ts.map +1 -0
- package/dist/trust-engine/context-policy/index.js +6 -0
- package/dist/trust-engine/context-policy/index.js.map +1 -0
- package/dist/trust-engine/creation-modifiers/index.d.ts +5 -0
- package/dist/trust-engine/creation-modifiers/index.d.ts.map +1 -0
- package/dist/trust-engine/creation-modifiers/index.js +5 -0
- package/dist/trust-engine/creation-modifiers/index.js.map +1 -0
- package/dist/trust-engine/creation-modifiers/types.d.ts +112 -0
- package/dist/trust-engine/creation-modifiers/types.d.ts.map +1 -0
- package/dist/trust-engine/creation-modifiers/types.js +166 -0
- package/dist/trust-engine/creation-modifiers/types.js.map +1 -0
- package/dist/trust-engine/index.d.ts +54 -1
- package/dist/trust-engine/index.d.ts.map +1 -1
- package/dist/trust-engine/index.js +118 -1
- package/dist/trust-engine/index.js.map +1 -1
- package/dist/trust-engine/phase6-types.d.ts +123 -0
- package/dist/trust-engine/phase6-types.d.ts.map +1 -0
- package/dist/trust-engine/phase6-types.js +88 -0
- package/dist/trust-engine/phase6-types.js.map +1 -0
- package/package.json +42 -12
- package/dist/audit/key-manager.d.ts +0 -118
- package/dist/audit/key-manager.d.ts.map +0 -1
- package/dist/audit/key-manager.js +0 -565
- package/dist/audit/key-manager.js.map +0 -1
- package/dist/carbon-aware/carbon-metrics.d.ts +0 -151
- package/dist/carbon-aware/carbon-metrics.d.ts.map +0 -1
- package/dist/carbon-aware/carbon-metrics.js +0 -370
- package/dist/carbon-aware/carbon-metrics.js.map +0 -1
- package/dist/carbon-aware/carbon-router.d.ts +0 -101
- package/dist/carbon-aware/carbon-router.d.ts.map +0 -1
- package/dist/carbon-aware/carbon-router.js +0 -400
- package/dist/carbon-aware/carbon-router.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,271 +1,300 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @vorionsys/atsf-core
|
|
2
2
|
|
|
3
|
-
Agentic Trust Scoring Framework
|
|
3
|
+
Agentic Trust Scoring Framework (ATSF) -- the core runtime for AI agent governance, trust scoring, and policy enforcement. Implements the complete 8-tier trust model (T0-T7) on a 0-1000 scale with behavioral signal processing, time-based decay, recovery mechanics, and immutable audit trails.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @vorionsys/atsf-core
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
**Requirements:** Node.js >= 18.0.0, TypeScript >= 5.0.0
|
|
12
|
+
|
|
13
|
+
## What is ATSF?
|
|
14
|
+
|
|
15
|
+
The **Agentic Trust Scoring Framework** is a runtime governance system for AI agents. It answers the question: _"How much should this agent be trusted to act autonomously?"_
|
|
16
|
+
|
|
17
|
+
ATSF continuously evaluates agent behavior across multiple dimensions and assigns a trust score (0-1000) that maps to one of eight trust tiers. Each tier defines what an agent is allowed to do -- from isolated sandbox testing to full autonomous operation.
|
|
18
|
+
|
|
19
|
+
Key principles:
|
|
20
|
+
|
|
21
|
+
- **Trust is earned, not granted.** Agents start at low trust and must demonstrate competence to advance.
|
|
22
|
+
- **Trust decays over time.** Idle agents lose trust; active, well-behaved agents maintain or gain it.
|
|
23
|
+
- **Trust loss is asymmetric.** Trust is hard to gain and easy to lose (10:1 ratio per ATSF v2.0).
|
|
24
|
+
- **Every decision is auditable.** An immutable proof chain records all governance decisions.
|
|
25
|
+
|
|
26
|
+
## The 8-Tier Trust Model (T0-T7)
|
|
27
|
+
|
|
28
|
+
ATSF uses an 8-tier model where score ranges narrow at higher tiers, reflecting the increasing difficulty of achieving greater autonomy.
|
|
29
|
+
|
|
30
|
+
| Tier | Name | Score Range | Description |
|
|
31
|
+
|------|------|-------------|-------------|
|
|
32
|
+
| T0 | Sandbox | 0 -- 199 | Isolated testing environment, no real operations |
|
|
33
|
+
| T1 | Observed | 200 -- 349 | Read-only access, under active supervision |
|
|
34
|
+
| T2 | Provisional | 350 -- 499 | Basic operations with heavy constraints |
|
|
35
|
+
| T3 | Monitored | 500 -- 649 | Standard operations, continuous monitoring |
|
|
36
|
+
| T4 | Standard | 650 -- 799 | External API access, policy-governed |
|
|
37
|
+
| T5 | Trusted | 800 -- 875 | Cross-agent communication, minimal oversight |
|
|
38
|
+
| T6 | Certified | 876 -- 950 | Admin-level tasks, audit trail required |
|
|
39
|
+
| T7 | Autonomous | 951 -- 1000 | Full autonomy, self-governance |
|
|
40
|
+
|
|
41
|
+
## Trust Dimensions
|
|
42
|
+
|
|
43
|
+
ATSF evaluates trust across five canonical dimensions (defined in `@vorionsys/contracts`):
|
|
44
|
+
|
|
45
|
+
| Dimension | Code | Description |
|
|
46
|
+
|-----------|------|-------------|
|
|
47
|
+
| **Capability Trust** | CT | Does the agent have the required skills and competencies? |
|
|
48
|
+
| **Behavioral Trust** | BT | Has the agent acted reliably and consistently? |
|
|
49
|
+
| **Governance Trust** | GT | Is the agent properly governed and policy-compliant? |
|
|
50
|
+
| **Contextual Trust** | XT | Is the current context appropriate for the agent's actions? |
|
|
51
|
+
| **Assurance Confidence** | AC | How confident are we in our assessment of this agent? |
|
|
52
|
+
|
|
53
|
+
Default weights: CT (0.25), BT (0.25), GT (0.20), XT (0.15), AC (0.15).
|
|
54
|
+
|
|
55
|
+
The runtime trust engine also tracks four signal component categories (`behavioral`, `compliance`, `identity`, `context`) that feed into the composite score calculation.
|
|
56
|
+
|
|
11
57
|
## Quick Start
|
|
12
58
|
|
|
13
59
|
```typescript
|
|
14
|
-
import {
|
|
15
|
-
TrustEngine,
|
|
16
|
-
createTrustEngine,
|
|
17
|
-
IntentService,
|
|
18
|
-
createIntentService,
|
|
19
|
-
EnforcementService,
|
|
20
|
-
createEnforcementService,
|
|
21
|
-
} from '@vorion/atsf-core';
|
|
60
|
+
import { createTrustEngine } from '@vorionsys/atsf-core';
|
|
22
61
|
|
|
23
62
|
// Create a trust engine
|
|
24
|
-
const
|
|
63
|
+
const engine = createTrustEngine();
|
|
25
64
|
|
|
26
|
-
// Initialize an agent
|
|
27
|
-
const agent = await
|
|
28
|
-
console.log(agent.score); // 200 (
|
|
65
|
+
// Initialize an agent at T1 (Observed)
|
|
66
|
+
const agent = await engine.initializeEntity('agent-001', 1);
|
|
67
|
+
console.log(agent.score); // 200 (T1 minimum)
|
|
68
|
+
console.log(agent.level); // 1
|
|
29
69
|
|
|
30
|
-
// Record behavioral
|
|
31
|
-
await
|
|
70
|
+
// Record a behavioral signal
|
|
71
|
+
await engine.recordSignal({
|
|
32
72
|
id: crypto.randomUUID(),
|
|
33
73
|
entityId: 'agent-001',
|
|
34
74
|
type: 'behavioral.task_completed',
|
|
35
75
|
value: 0.9,
|
|
36
76
|
source: 'system',
|
|
37
77
|
timestamp: new Date().toISOString(),
|
|
38
|
-
metadata: {},
|
|
78
|
+
metadata: { task: 'data-analysis' },
|
|
39
79
|
});
|
|
40
80
|
|
|
41
|
-
// Get updated score
|
|
42
|
-
const record = await
|
|
81
|
+
// Get the updated score (includes automatic decay calculation)
|
|
82
|
+
const record = await engine.getScore('agent-001');
|
|
43
83
|
console.log(record?.score, record?.level);
|
|
44
84
|
```
|
|
45
85
|
|
|
46
|
-
##
|
|
86
|
+
## Usage Examples
|
|
87
|
+
|
|
88
|
+
### Computing Trust Scores
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { createTrustEngine } from '@vorionsys/atsf-core';
|
|
92
|
+
|
|
93
|
+
const engine = createTrustEngine({
|
|
94
|
+
decayRate: 0.01, // 1% decay per interval
|
|
95
|
+
decayIntervalMs: 60000, // 1-minute intervals
|
|
96
|
+
failureThreshold: 0.3, // Signals below 0.3 = failure
|
|
97
|
+
acceleratedDecayMultiplier: 3.0, // 3x decay on repeated failures
|
|
98
|
+
successThreshold: 0.7, // Signals above 0.7 = success
|
|
99
|
+
recoveryRate: 0.02, // 2% recovery per success signal
|
|
100
|
+
});
|
|
47
101
|
|
|
48
|
-
|
|
102
|
+
// Initialize agent
|
|
103
|
+
await engine.initializeEntity('agent-alpha', 2); // Start at T2 Provisional
|
|
104
|
+
|
|
105
|
+
// Record multiple signals to build trust
|
|
106
|
+
for (const task of completedTasks) {
|
|
107
|
+
await engine.recordSignal({
|
|
108
|
+
id: crypto.randomUUID(),
|
|
109
|
+
entityId: 'agent-alpha',
|
|
110
|
+
type: 'behavioral.task_completed',
|
|
111
|
+
value: task.successRate,
|
|
112
|
+
timestamp: new Date().toISOString(),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Calculate trust
|
|
117
|
+
const calc = await engine.calculate('agent-alpha');
|
|
118
|
+
console.log(`Score: ${calc.score}, Tier: T${calc.level}`);
|
|
119
|
+
console.log('Components:', calc.components);
|
|
120
|
+
console.log('Factors:', calc.factors);
|
|
121
|
+
```
|
|
49
122
|
|
|
50
|
-
|
|
123
|
+
### Classifying Agents into Tiers
|
|
51
124
|
|
|
52
125
|
```typescript
|
|
53
|
-
import {
|
|
126
|
+
import {
|
|
127
|
+
createTrustEngine,
|
|
128
|
+
TRUST_THRESHOLDS,
|
|
129
|
+
TRUST_LEVEL_NAMES,
|
|
130
|
+
} from '@vorionsys/atsf-core';
|
|
54
131
|
|
|
55
|
-
// Basic usage
|
|
56
132
|
const engine = createTrustEngine();
|
|
57
133
|
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
134
|
+
// Initialize agents at different tiers
|
|
135
|
+
await engine.initializeEntity('sandbox-bot', 0); // T0 Sandbox
|
|
136
|
+
await engine.initializeEntity('new-agent', 1); // T1 Observed
|
|
137
|
+
await engine.initializeEntity('proven-agent', 4); // T4 Standard
|
|
138
|
+
|
|
139
|
+
// Get tier information
|
|
140
|
+
for (const id of engine.getEntityIds()) {
|
|
141
|
+
const record = await engine.getScore(id);
|
|
142
|
+
if (record) {
|
|
143
|
+
const tierName = engine.getLevelName(record.level);
|
|
144
|
+
const { min, max } = TRUST_THRESHOLDS[record.level];
|
|
145
|
+
console.log(`${id}: T${record.level} ${tierName} (score ${record.score}, range ${min}-${max})`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
67
148
|
```
|
|
68
149
|
|
|
69
|
-
###
|
|
70
|
-
|
|
71
|
-
Constraint evaluation for governance policies.
|
|
150
|
+
### Listening to Trust Events
|
|
72
151
|
|
|
73
152
|
```typescript
|
|
74
|
-
import {
|
|
153
|
+
import { createTrustEngine } from '@vorionsys/atsf-core';
|
|
75
154
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
155
|
+
const engine = createTrustEngine();
|
|
156
|
+
|
|
157
|
+
// Listen for tier promotions/demotions
|
|
158
|
+
engine.on('trust:tier_changed', (event) => {
|
|
159
|
+
console.log(
|
|
160
|
+
`${event.entityId} ${event.direction}: ` +
|
|
161
|
+
`${event.previousLevelName} -> ${event.newLevelName}`
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Listen for failures and accelerated decay
|
|
166
|
+
engine.on('trust:failure_detected', (event) => {
|
|
167
|
+
console.log(`Failure #${event.failureCount} for ${event.entityId}`);
|
|
168
|
+
if (event.acceleratedDecayActive) {
|
|
169
|
+
console.log('Accelerated decay is now active (3x normal rate)');
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Listen for recovery milestones
|
|
174
|
+
engine.on('trust:recovery_milestone', (event) => {
|
|
175
|
+
console.log(`Recovery milestone for ${event.entityId}: ${event.details}`);
|
|
176
|
+
});
|
|
80
177
|
|
|
81
|
-
|
|
178
|
+
// Wildcard -- all trust events
|
|
179
|
+
engine.on('trust:*', (event) => {
|
|
180
|
+
console.log(`[${event.type}] ${event.entityId}`);
|
|
181
|
+
});
|
|
182
|
+
```
|
|
82
183
|
|
|
83
|
-
|
|
184
|
+
### Intent Governance Pipeline
|
|
84
185
|
|
|
85
186
|
```typescript
|
|
86
|
-
import {
|
|
187
|
+
import {
|
|
188
|
+
createIntentService,
|
|
189
|
+
createEnforcementService,
|
|
190
|
+
createProofService,
|
|
191
|
+
} from '@vorionsys/atsf-core';
|
|
87
192
|
|
|
193
|
+
// Submit an agent intent for governance evaluation
|
|
88
194
|
const intentService = createIntentService();
|
|
89
195
|
const intent = await intentService.submit({
|
|
90
196
|
entityId: 'agent-001',
|
|
91
197
|
goal: 'Send email to user',
|
|
92
198
|
context: { recipient: 'user@example.com' },
|
|
93
199
|
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Enforcement Service
|
|
97
|
-
|
|
98
|
-
Policy decision point for allow/deny/escalate decisions.
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
import { createEnforcementService } from '@vorion/atsf-core';
|
|
102
200
|
|
|
201
|
+
// Enforce governance policies
|
|
103
202
|
const enforcer = createEnforcementService({
|
|
104
203
|
defaultAction: 'deny',
|
|
105
204
|
requireMinTrustLevel: 2,
|
|
106
205
|
});
|
|
107
206
|
const decision = await enforcer.decide(context);
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Proof Service
|
|
111
|
-
|
|
112
|
-
Immutable audit chain with SHA-256 hashing.
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
import { createProofService } from '@vorion/atsf-core';
|
|
116
207
|
|
|
208
|
+
// Record an immutable proof of the decision
|
|
117
209
|
const proofService = createProofService();
|
|
118
|
-
const proof = await proofService.create({ intent, decision, inputs, outputs });
|
|
210
|
+
const proof = await proofService.create({ intent, decision, inputs: {}, outputs: {} });
|
|
119
211
|
const verification = await proofService.verify(proof.id);
|
|
212
|
+
console.log('Verified:', verification.valid);
|
|
120
213
|
```
|
|
121
214
|
|
|
122
|
-
###
|
|
123
|
-
|
|
124
|
-
Constrained execution with resource limits.
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
import { createGateway } from '@vorion/atsf-core';
|
|
128
|
-
|
|
129
|
-
const gateway = createGateway({
|
|
130
|
-
maxMemoryMb: 256,
|
|
131
|
-
timeoutMs: 30000,
|
|
132
|
-
});
|
|
133
|
-
gateway.registerHandler('email', emailHandler);
|
|
134
|
-
const result = await gateway.execute(context);
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Trust Levels (6 Tiers)
|
|
138
|
-
|
|
139
|
-
| Level | Name | Score Range |
|
|
140
|
-
|-------|------|-------------|
|
|
141
|
-
| 0 | Untrusted | 0-166 |
|
|
142
|
-
| 1 | Observed | 167-332 |
|
|
143
|
-
| 2 | Limited | 333-499 |
|
|
144
|
-
| 3 | Standard | 500-665 |
|
|
145
|
-
| 4 | Trusted | 666-832 |
|
|
146
|
-
| 5 | Certified | 833-1000 |
|
|
147
|
-
|
|
148
|
-
## Events
|
|
149
|
-
|
|
150
|
-
The Trust Engine extends `EventEmitter` and emits the following events:
|
|
215
|
+
### BASIS Rule Engine
|
|
151
216
|
|
|
152
217
|
```typescript
|
|
153
|
-
import {
|
|
154
|
-
|
|
155
|
-
const engine = new TrustEngine();
|
|
156
|
-
|
|
157
|
-
// Listen for all trust events
|
|
158
|
-
engine.on('trust:*', (event) => {
|
|
159
|
-
console.log('Trust event:', event);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// Listen for specific events
|
|
163
|
-
engine.on('trust:initialized', (event) => {
|
|
164
|
-
console.log(`Entity ${event.entityId} initialized at L${event.initialLevel}`);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
engine.on('trust:tier_changed', (event) => {
|
|
168
|
-
console.log(`${event.entityId} ${event.direction}: ${event.previousLevelName} → ${event.newLevelName}`);
|
|
169
|
-
});
|
|
218
|
+
import { createEvaluator, parseNamespace } from '@vorionsys/atsf-core';
|
|
170
219
|
|
|
171
|
-
|
|
172
|
-
console.log(`Decay: ${event.entityId} lost ${event.decayAmount} points`);
|
|
173
|
-
});
|
|
220
|
+
const evaluator = createEvaluator();
|
|
174
221
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
222
|
+
// Register governance rules
|
|
223
|
+
evaluator.registerNamespace(parseNamespace({
|
|
224
|
+
namespace: 'email.policy',
|
|
225
|
+
version: '1.0.0',
|
|
226
|
+
rules: [
|
|
227
|
+
{
|
|
228
|
+
name: 'require-trust-level',
|
|
229
|
+
when: { conditions: { minTrustLevel: 3 } },
|
|
230
|
+
evaluate: [{ condition: 'trustLevel >= 3', result: 'allow', reason: 'Sufficient trust' }],
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
}));
|
|
178
234
|
|
|
179
|
-
|
|
180
|
-
console.log(`Signal: ${event.signal.type} for ${event.entityId}`);
|
|
181
|
-
});
|
|
235
|
+
const result = await evaluator.evaluate(context);
|
|
182
236
|
```
|
|
183
237
|
|
|
184
|
-
###
|
|
185
|
-
|
|
186
|
-
| Event | Description |
|
|
187
|
-
|-------|-------------|
|
|
188
|
-
| `trust:initialized` | New entity registered |
|
|
189
|
-
| `trust:signal_recorded` | Behavioral signal recorded |
|
|
190
|
-
| `trust:score_changed` | Score changed by ≥5 points |
|
|
191
|
-
| `trust:tier_changed` | Entity promoted or demoted |
|
|
192
|
-
| `trust:decay_applied` | Trust decayed due to staleness (includes `accelerated` flag) |
|
|
193
|
-
| `trust:failure_detected` | Low-value signal detected as failure |
|
|
194
|
-
| `trust:*` | Wildcard - all events |
|
|
195
|
-
|
|
196
|
-
### Accelerated Decay
|
|
197
|
-
|
|
198
|
-
When an entity accumulates failures (signals with value < 0.3), the decay rate increases:
|
|
238
|
+
### Security Pipeline
|
|
199
239
|
|
|
200
240
|
```typescript
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
console.log(`Accelerated decay: -${event.decayAmount} points`);
|
|
211
|
-
}
|
|
241
|
+
import {
|
|
242
|
+
createSecurityPipeline,
|
|
243
|
+
createLayerConfig,
|
|
244
|
+
BaseSecurityLayer,
|
|
245
|
+
} from '@vorionsys/atsf-core';
|
|
246
|
+
|
|
247
|
+
const pipeline = createSecurityPipeline({
|
|
248
|
+
maxTotalTimeMs: 5000,
|
|
249
|
+
stopOnFirstFailure: false,
|
|
212
250
|
});
|
|
213
251
|
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
const
|
|
252
|
+
// Register security layers and execute
|
|
253
|
+
pipeline.registerLayer(mySecurityLayer);
|
|
254
|
+
const result = await pipeline.execute(input);
|
|
255
|
+
console.log(`Decision: ${result.decision}, Confidence: ${result.confidence}`);
|
|
217
256
|
```
|
|
218
257
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
Trust records can be persisted using pluggable storage backends:
|
|
258
|
+
### Persistence
|
|
222
259
|
|
|
223
260
|
```typescript
|
|
224
261
|
import {
|
|
225
262
|
createTrustEngine,
|
|
226
263
|
createFileProvider,
|
|
227
|
-
|
|
228
|
-
} from '@vorion/atsf-core';
|
|
264
|
+
} from '@vorionsys/atsf-core';
|
|
229
265
|
|
|
230
266
|
// File-based persistence
|
|
231
267
|
const fileProvider = createFileProvider({
|
|
232
268
|
path: './trust-records.json',
|
|
233
|
-
autoSaveIntervalMs: 5000,
|
|
269
|
+
autoSaveIntervalMs: 5000,
|
|
234
270
|
});
|
|
235
271
|
await fileProvider.initialize();
|
|
236
272
|
|
|
237
273
|
const engine = createTrustEngine({
|
|
238
274
|
persistence: fileProvider,
|
|
239
|
-
autoPersist: true,
|
|
275
|
+
autoPersist: true,
|
|
240
276
|
});
|
|
241
277
|
|
|
242
278
|
// Load existing records
|
|
243
279
|
await engine.loadFromPersistence();
|
|
244
280
|
|
|
245
|
-
// Records
|
|
281
|
+
// Records auto-save on changes
|
|
246
282
|
await engine.initializeEntity('agent-001', 2);
|
|
247
283
|
|
|
248
|
-
// Manual save
|
|
284
|
+
// Manual save and cleanup
|
|
249
285
|
await engine.saveToPersistence();
|
|
250
286
|
await engine.close();
|
|
251
287
|
```
|
|
252
288
|
|
|
253
|
-
|
|
254
|
-
- `MemoryPersistenceProvider` - Fast, non-persistent (default)
|
|
255
|
-
- `FilePersistenceProvider` - JSON file storage
|
|
256
|
-
|
|
257
|
-
## LangChain Integration
|
|
258
|
-
|
|
259
|
-
Integrate trust scoring with LangChain agents:
|
|
289
|
+
### LangChain Integration
|
|
260
290
|
|
|
261
291
|
```typescript
|
|
262
292
|
import {
|
|
263
293
|
createTrustEngine,
|
|
264
294
|
createTrustAwareExecutor,
|
|
265
295
|
createTrustTools,
|
|
266
|
-
} from '@
|
|
296
|
+
} from '@vorionsys/atsf-core';
|
|
267
297
|
|
|
268
|
-
// Create trust-aware executor
|
|
269
298
|
const engine = createTrustEngine();
|
|
270
299
|
const executor = createTrustAwareExecutor(engine, {
|
|
271
300
|
agentId: 'my-agent',
|
|
@@ -273,36 +302,131 @@ const executor = createTrustAwareExecutor(engine, {
|
|
|
273
302
|
minTrustLevel: 2,
|
|
274
303
|
recordToolUsage: true,
|
|
275
304
|
recordLlmCalls: true,
|
|
276
|
-
recordErrors: true,
|
|
277
305
|
});
|
|
278
306
|
await executor.initialize();
|
|
279
307
|
|
|
280
|
-
// Use callback handler with LangChain
|
|
281
|
-
const callbacks = [executor.callbackHandler];
|
|
282
|
-
|
|
283
308
|
// Execute with trust gating
|
|
284
309
|
const result = await executor.execute(async () => {
|
|
285
|
-
|
|
286
|
-
return await agent.invoke({ input: 'Hello' }, { callbacks });
|
|
310
|
+
return await agent.invoke({ input: 'Hello' }, { callbacks: [executor.callbackHandler] });
|
|
287
311
|
});
|
|
288
312
|
|
|
289
|
-
console.log(result.trustCheck.allowed);
|
|
313
|
+
console.log(result.trustCheck.allowed); // true if trust level sufficient
|
|
290
314
|
console.log(result.finalScore);
|
|
291
315
|
|
|
292
|
-
//
|
|
316
|
+
// Trust-aware tools for agents
|
|
293
317
|
const trustTools = createTrustTools(engine, 'my-agent');
|
|
294
|
-
//
|
|
295
|
-
//
|
|
318
|
+
// Available tools: check_my_trust, check_trust_requirements,
|
|
319
|
+
// get_trust_levels, report_task_success, report_task_failure
|
|
296
320
|
```
|
|
297
321
|
|
|
298
|
-
|
|
322
|
+
## API Reference
|
|
323
|
+
|
|
324
|
+
### Core Exports
|
|
325
|
+
|
|
326
|
+
| Export | Type | Description |
|
|
327
|
+
|--------|------|-------------|
|
|
328
|
+
| `TrustEngine` | Class | Main trust scoring engine with event emission |
|
|
329
|
+
| `createTrustEngine(config?)` | Function | Factory to create a TrustEngine instance |
|
|
330
|
+
| `TRUST_THRESHOLDS` | Constant | T0-T7 score range definitions |
|
|
331
|
+
| `TRUST_LEVEL_NAMES` | Constant | Human-readable tier names |
|
|
332
|
+
| `SIGNAL_WEIGHTS` | Constant | Signal component weights |
|
|
333
|
+
|
|
334
|
+
### Sub-module Exports
|
|
335
|
+
|
|
336
|
+
Import from the package root or via deep imports:
|
|
337
|
+
|
|
338
|
+
| Module Path | Key Exports | Description |
|
|
339
|
+
|-------------|-------------|-------------|
|
|
340
|
+
| `@vorionsys/atsf-core` | All below | Main entry point |
|
|
341
|
+
| `@vorionsys/atsf-core/trust-engine` | `TrustEngine`, `createTrustEngine` | Trust scoring engine |
|
|
342
|
+
| `@vorionsys/atsf-core/basis` | `createEvaluator`, `parseNamespace` | BASIS rule evaluation |
|
|
343
|
+
| `@vorionsys/atsf-core/intent` | `createIntentService`, `IntentService` | Intent submission and tracking |
|
|
344
|
+
| `@vorionsys/atsf-core/enforce` | `createEnforcementService`, `EnforcementService` | Policy decision enforcement |
|
|
345
|
+
| `@vorionsys/atsf-core/proof` | `createProofService`, `ProofService` | Immutable SHA-256 audit chain |
|
|
346
|
+
| `@vorionsys/atsf-core/chain` | `createChainAnchor`, `computeMerkleRoot` | Blockchain anchoring (Polygon) |
|
|
347
|
+
| `@vorionsys/atsf-core/cognigate` | `createGateway`, `CognigateGateway` | Constrained execution runtime |
|
|
348
|
+
| `@vorionsys/atsf-core/persistence` | `createFileProvider`, `createMemoryProvider` | Pluggable trust storage |
|
|
349
|
+
| `@vorionsys/atsf-core/langchain` | `createTrustAwareExecutor`, `createTrustTools` | LangChain integration |
|
|
350
|
+
| `@vorionsys/atsf-core/sandbox-training` | Sandbox training exports | Adversarial training boot camp |
|
|
351
|
+
| `@vorionsys/atsf-core/types` | `TrustLevel`, `TrustScore`, `Entity`, `Intent` | Core type definitions |
|
|
352
|
+
|
|
353
|
+
### Additional Exports
|
|
354
|
+
|
|
355
|
+
| Export | Description |
|
|
356
|
+
|--------|-------------|
|
|
357
|
+
| `GovernanceEngine`, `createGovernanceEngine` | Rule-based governance evaluation |
|
|
358
|
+
| `FluidWorkflowEngine`, `createFluidWorkflowEngine` | Fluid decision workflow orchestration |
|
|
359
|
+
| `SecurityPipeline`, `createSecurityPipeline` | L0-L46 typed security layer pipeline |
|
|
360
|
+
| `BaseSecurityLayer` | Abstract base class for security layers |
|
|
361
|
+
| `createPhase6TrustEngine` | Phase 6 hardened trust engine |
|
|
362
|
+
| `VorionError`, `TrustInsufficientError`, `ConstraintViolationError` | Typed error classes |
|
|
363
|
+
| `createServer`, `startServer` | Fastify-based governance API server |
|
|
364
|
+
|
|
365
|
+
### Trust Event Types
|
|
366
|
+
|
|
367
|
+
| Event | Emitted When |
|
|
368
|
+
|-------|-------------|
|
|
369
|
+
| `trust:initialized` | New entity registered |
|
|
370
|
+
| `trust:signal_recorded` | Behavioral signal recorded |
|
|
371
|
+
| `trust:score_changed` | Score changes by 5+ points |
|
|
372
|
+
| `trust:tier_changed` | Entity promoted or demoted |
|
|
373
|
+
| `trust:decay_applied` | Trust decayed (includes `accelerated` flag) |
|
|
374
|
+
| `trust:failure_detected` | Signal value below failure threshold |
|
|
375
|
+
| `trust:recovery_applied` | Recovery from successful signal |
|
|
376
|
+
| `trust:recovery_milestone` | Tier restored, full recovery, or accelerated recovery earned |
|
|
377
|
+
| `trust:*` | Wildcard -- all trust events |
|
|
378
|
+
|
|
379
|
+
## Architecture
|
|
380
|
+
|
|
381
|
+
```
|
|
382
|
+
@vorionsys/atsf-core
|
|
383
|
+
|-- trust-engine/ Trust scoring with 8-tier model, decay, and recovery
|
|
384
|
+
|-- basis/ BASIS rule evaluation engine
|
|
385
|
+
|-- intent/ Intent submission and lifecycle tracking
|
|
386
|
+
|-- enforce/ Policy decision point (allow/deny/escalate)
|
|
387
|
+
|-- proof/ Immutable SHA-256 audit chain with Merkle proofs
|
|
388
|
+
|-- chain/ Blockchain anchoring (Polygon networks)
|
|
389
|
+
|-- cognigate/ Constrained execution with resource limits
|
|
390
|
+
|-- governance/ Authority engine and fluid workflows
|
|
391
|
+
|-- layers/ L0-L46 typed security layer pipeline
|
|
392
|
+
|-- arbitration/ Multi-agent trust arbitration
|
|
393
|
+
|-- containment/ Progressive containment protocols
|
|
394
|
+
|-- contracts/ Output contracts (VorionResponse)
|
|
395
|
+
|-- provenance/ Decision provenance (DPO) tracking
|
|
396
|
+
|-- persistence/ Pluggable storage (memory, file, Supabase)
|
|
397
|
+
|-- langchain/ LangChain callback handler and trust tools
|
|
398
|
+
|-- sandbox-training/ Adversarial training boot camp
|
|
399
|
+
|-- phase6/ Trust engine hardening (advanced)
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Peer Dependencies
|
|
403
|
+
|
|
404
|
+
| Package | Required | Purpose |
|
|
405
|
+
|---------|----------|---------|
|
|
406
|
+
| `typescript` | >= 5.0.0 | Required for type definitions |
|
|
407
|
+
| `@langchain/core` | >= 0.2.0 | Optional -- LangChain integration |
|
|
408
|
+
| `better-sqlite3` | >= 9.0.0 | Optional -- SQLite persistence |
|
|
409
|
+
|
|
410
|
+
## Testing
|
|
299
411
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
412
|
+
The package has comprehensive test coverage with **401+ tests** covering trust scoring, decay mechanics, recovery paths, governance pipelines, security layers, and edge cases.
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# Run all tests
|
|
416
|
+
npm test
|
|
417
|
+
|
|
418
|
+
# Run tests in watch mode
|
|
419
|
+
npm run test:watch
|
|
420
|
+
```
|
|
305
421
|
|
|
306
422
|
## License
|
|
307
423
|
|
|
308
|
-
|
|
424
|
+
[Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
425
|
+
|
|
426
|
+
Copyright 2024-2026 Vorion
|
|
427
|
+
|
|
428
|
+
## Links
|
|
429
|
+
|
|
430
|
+
- **Repository:** [github.com/voriongit/vorion](https://github.com/voriongit/vorion/tree/main/packages/atsf-core)
|
|
431
|
+
- **Homepage:** [vorion.org](https://vorion.org)
|
|
432
|
+
- **Issues:** [github.com/voriongit/vorion/issues](https://github.com/voriongit/vorion/issues)
|
package/dist/api/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/api/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAgB,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/api/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAgB,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAgLjF;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,eAAe,CAAC,CAupB7D;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAsBjD"}
|