@vorionsys/a3i 0.1.0
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/LICENSE +190 -0
- package/dist/api/handlers.d.ts +231 -0
- package/dist/api/handlers.d.ts.map +1 -0
- package/dist/api/handlers.js +279 -0
- package/dist/api/handlers.js.map +1 -0
- package/dist/api/index.d.ts +24 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +27 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/middleware.d.ts +106 -0
- package/dist/api/middleware.d.ts.map +1 -0
- package/dist/api/middleware.js +186 -0
- package/dist/api/middleware.js.map +1 -0
- package/dist/api/routes.d.ts +41 -0
- package/dist/api/routes.d.ts.map +1 -0
- package/dist/api/routes.js +91 -0
- package/dist/api/routes.js.map +1 -0
- package/dist/authorization/constraints.d.ts +75 -0
- package/dist/authorization/constraints.d.ts.map +1 -0
- package/dist/authorization/constraints.js +302 -0
- package/dist/authorization/constraints.js.map +1 -0
- package/dist/authorization/decision.d.ts +98 -0
- package/dist/authorization/decision.d.ts.map +1 -0
- package/dist/authorization/decision.js +202 -0
- package/dist/authorization/decision.js.map +1 -0
- package/dist/authorization/engine.d.ts +141 -0
- package/dist/authorization/engine.d.ts.map +1 -0
- package/dist/authorization/engine.js +339 -0
- package/dist/authorization/engine.js.map +1 -0
- package/dist/authorization/index.d.ts +10 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +13 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/banding/band-calculator.d.ts +137 -0
- package/dist/banding/band-calculator.d.ts.map +1 -0
- package/dist/banding/band-calculator.js +252 -0
- package/dist/banding/band-calculator.js.map +1 -0
- package/dist/banding/bands.d.ts +56 -0
- package/dist/banding/bands.d.ts.map +1 -0
- package/dist/banding/bands.js +200 -0
- package/dist/banding/bands.js.map +1 -0
- package/dist/banding/hysteresis.d.ts +64 -0
- package/dist/banding/hysteresis.d.ts.map +1 -0
- package/dist/banding/hysteresis.js +143 -0
- package/dist/banding/hysteresis.js.map +1 -0
- package/dist/banding/index.d.ts +10 -0
- package/dist/banding/index.d.ts.map +1 -0
- package/dist/banding/index.js +10 -0
- package/dist/banding/index.js.map +1 -0
- package/dist/canary/canary-service.d.ts +123 -0
- package/dist/canary/canary-service.d.ts.map +1 -0
- package/dist/canary/canary-service.js +353 -0
- package/dist/canary/canary-service.js.map +1 -0
- package/dist/canary/index.d.ts +12 -0
- package/dist/canary/index.d.ts.map +1 -0
- package/dist/canary/index.js +14 -0
- package/dist/canary/index.js.map +1 -0
- package/dist/canary/probe-library.d.ts +43 -0
- package/dist/canary/probe-library.d.ts.map +1 -0
- package/dist/canary/probe-library.js +655 -0
- package/dist/canary/probe-library.js.map +1 -0
- package/dist/execution/engine.d.ts +120 -0
- package/dist/execution/engine.d.ts.map +1 -0
- package/dist/execution/engine.js +220 -0
- package/dist/execution/engine.js.map +1 -0
- package/dist/execution/index.d.ts +7 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +7 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/gate/index.d.ts +12 -0
- package/dist/gate/index.d.ts.map +1 -0
- package/dist/gate/index.js +14 -0
- package/dist/gate/index.js.map +1 -0
- package/dist/gate/pre-action-gate.d.ts +87 -0
- package/dist/gate/pre-action-gate.d.ts.map +1 -0
- package/dist/gate/pre-action-gate.js +286 -0
- package/dist/gate/pre-action-gate.js.map +1 -0
- package/dist/gate/risk-classifier.d.ts +43 -0
- package/dist/gate/risk-classifier.d.ts.map +1 -0
- package/dist/gate/risk-classifier.js +157 -0
- package/dist/gate/risk-classifier.js.map +1 -0
- package/dist/hooks/executor.d.ts +56 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +217 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/index.d.ts +45 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +49 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/manager.d.ts +156 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +267 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/registry.d.ts +130 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/registry.js +238 -0
- package/dist/hooks/registry.js.map +1 -0
- package/dist/hooks/types.d.ts +226 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +41 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/observation/attestation.d.ts +102 -0
- package/dist/observation/attestation.d.ts.map +1 -0
- package/dist/observation/attestation.js +127 -0
- package/dist/observation/attestation.js.map +1 -0
- package/dist/observation/ceilings.d.ts +60 -0
- package/dist/observation/ceilings.d.ts.map +1 -0
- package/dist/observation/ceilings.js +110 -0
- package/dist/observation/ceilings.js.map +1 -0
- package/dist/observation/index.d.ts +11 -0
- package/dist/observation/index.d.ts.map +1 -0
- package/dist/observation/index.js +14 -0
- package/dist/observation/index.js.map +1 -0
- package/dist/observation/tiers.d.ts +96 -0
- package/dist/observation/tiers.d.ts.map +1 -0
- package/dist/observation/tiers.js +225 -0
- package/dist/observation/tiers.js.map +1 -0
- package/dist/orchestrator/index.d.ts +8 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +8 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +225 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator.js +302 -0
- package/dist/orchestrator/orchestrator.js.map +1 -0
- package/dist/orchestrator/proof-plane-adapter.d.ts +80 -0
- package/dist/orchestrator/proof-plane-adapter.d.ts.map +1 -0
- package/dist/orchestrator/proof-plane-adapter.js +78 -0
- package/dist/orchestrator/proof-plane-adapter.js.map +1 -0
- package/dist/trust/calculator.d.ts +60 -0
- package/dist/trust/calculator.d.ts.map +1 -0
- package/dist/trust/calculator.js +163 -0
- package/dist/trust/calculator.js.map +1 -0
- package/dist/trust/dimensions.d.ts +133 -0
- package/dist/trust/dimensions.d.ts.map +1 -0
- package/dist/trust/dimensions.js +257 -0
- package/dist/trust/dimensions.js.map +1 -0
- package/dist/trust/index.d.ts +14 -0
- package/dist/trust/index.d.ts.map +1 -0
- package/dist/trust/index.js +25 -0
- package/dist/trust/index.js.map +1 -0
- package/dist/trust/profile-service.d.ts +179 -0
- package/dist/trust/profile-service.d.ts.map +1 -0
- package/dist/trust/profile-service.js +378 -0
- package/dist/trust/profile-service.js.map +1 -0
- package/dist/trust/profile-store.d.ts +122 -0
- package/dist/trust/profile-store.d.ts.map +1 -0
- package/dist/trust/profile-store.js +132 -0
- package/dist/trust/profile-store.js.map +1 -0
- package/dist/trust/trust-calculator.d.ts +111 -0
- package/dist/trust/trust-calculator.d.ts.map +1 -0
- package/dist/trust/trust-calculator.js +271 -0
- package/dist/trust/trust-calculator.js.map +1 -0
- package/dist/trust/trust-dynamics.d.ts +152 -0
- package/dist/trust/trust-dynamics.d.ts.map +1 -0
- package/dist/trust/trust-dynamics.js +302 -0
- package/dist/trust/trust-dynamics.js.map +1 -0
- package/dist/trust/weights.d.ts +57 -0
- package/dist/trust/weights.d.ts.map +1 -0
- package/dist/trust/weights.js +75 -0
- package/dist/trust/weights.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BandCalculator - Trust band management with asymmetric transitions
|
|
3
|
+
*
|
|
4
|
+
* Key principles:
|
|
5
|
+
* - Fast demotion: Safety-critical, immediate response to issues
|
|
6
|
+
* - Slow promotion: Build trust gradually over time
|
|
7
|
+
* - Hysteresis: Prevent oscillation near thresholds
|
|
8
|
+
* - History tracking: Evidence-based promotion decisions
|
|
9
|
+
*/
|
|
10
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
11
|
+
import { TrustBand, DEFAULT_BANDING_CONFIG } from '@vorionsys/contracts';
|
|
12
|
+
import { getBand, getNextBand, getBandName } from './bands.js';
|
|
13
|
+
import { HysteresisCalculator } from './hysteresis.js';
|
|
14
|
+
/**
|
|
15
|
+
* Band transition types
|
|
16
|
+
*/
|
|
17
|
+
export var TransitionType;
|
|
18
|
+
(function (TransitionType) {
|
|
19
|
+
TransitionType["NONE"] = "none";
|
|
20
|
+
TransitionType["PROMOTION"] = "promotion";
|
|
21
|
+
TransitionType["DEMOTION"] = "demotion";
|
|
22
|
+
})(TransitionType || (TransitionType = {}));
|
|
23
|
+
/**
|
|
24
|
+
* BandCalculator - Manages trust band transitions
|
|
25
|
+
*/
|
|
26
|
+
export class BandCalculator {
|
|
27
|
+
config;
|
|
28
|
+
hysteresis;
|
|
29
|
+
historyByAgent = new Map();
|
|
30
|
+
transitionEvents = [];
|
|
31
|
+
constructor(config = {}) {
|
|
32
|
+
this.config = { ...DEFAULT_BANDING_CONFIG, ...config };
|
|
33
|
+
this.hysteresis = new HysteresisCalculator(this.config);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the trust band for a score
|
|
37
|
+
*/
|
|
38
|
+
getBand(score) {
|
|
39
|
+
return getBand(score, this.config.thresholds);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Evaluate a potential band transition
|
|
43
|
+
*/
|
|
44
|
+
evaluateTransition(agentId, currentBand, newScore, options = {}) {
|
|
45
|
+
const now = options.now ?? new Date();
|
|
46
|
+
const rawNewBand = this.getBand(newScore);
|
|
47
|
+
// No change
|
|
48
|
+
if (rawNewBand === currentBand) {
|
|
49
|
+
return {
|
|
50
|
+
allowed: false,
|
|
51
|
+
transitionType: TransitionType.NONE,
|
|
52
|
+
previousBand: currentBand,
|
|
53
|
+
newBand: currentBand,
|
|
54
|
+
reason: 'Score still within current band range',
|
|
55
|
+
timestamp: now,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Demotion - always immediate
|
|
59
|
+
if (rawNewBand < currentBand) {
|
|
60
|
+
return this.evaluateDemotion(agentId, currentBand, rawNewBand, newScore, now);
|
|
61
|
+
}
|
|
62
|
+
// Promotion - requires time and hysteresis
|
|
63
|
+
return this.evaluatePromotion(agentId, currentBand, rawNewBand, newScore, now);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Evaluate a demotion (always immediate for safety)
|
|
67
|
+
*/
|
|
68
|
+
evaluateDemotion(agentId, currentBand, _targetBand, score, now) {
|
|
69
|
+
// Apply hysteresis - need to be clearly below threshold
|
|
70
|
+
const effectiveBand = this.hysteresis.calculateBandWithHysteresis(currentBand, score);
|
|
71
|
+
if (effectiveBand === currentBand) {
|
|
72
|
+
const demotionThreshold = this.hysteresis.getDemotionThreshold(currentBand);
|
|
73
|
+
return {
|
|
74
|
+
allowed: false,
|
|
75
|
+
transitionType: TransitionType.DEMOTION,
|
|
76
|
+
previousBand: currentBand,
|
|
77
|
+
newBand: currentBand,
|
|
78
|
+
reason: 'Score within hysteresis buffer, demotion blocked',
|
|
79
|
+
scoreThreshold: demotionThreshold ?? undefined,
|
|
80
|
+
timestamp: now,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Demotion allowed
|
|
84
|
+
this.recordTransition(agentId, currentBand, effectiveBand, score, 'Score dropped below threshold', now);
|
|
85
|
+
return {
|
|
86
|
+
allowed: true,
|
|
87
|
+
transitionType: TransitionType.DEMOTION,
|
|
88
|
+
previousBand: currentBand,
|
|
89
|
+
newBand: effectiveBand,
|
|
90
|
+
reason: `Demoted from ${getBandName(currentBand)} to ${getBandName(effectiveBand)}`,
|
|
91
|
+
timestamp: now,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Evaluate a promotion (requires time at current band)
|
|
96
|
+
*/
|
|
97
|
+
evaluatePromotion(agentId, currentBand, _targetBand, score, now) {
|
|
98
|
+
// Can only promote one level at a time
|
|
99
|
+
const nextBand = getNextBand(currentBand);
|
|
100
|
+
if (nextBand === null) {
|
|
101
|
+
return {
|
|
102
|
+
allowed: false,
|
|
103
|
+
transitionType: TransitionType.PROMOTION,
|
|
104
|
+
previousBand: currentBand,
|
|
105
|
+
newBand: currentBand,
|
|
106
|
+
reason: 'Already at maximum trust band (T7)',
|
|
107
|
+
timestamp: now,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Apply hysteresis - need to be clearly above threshold
|
|
111
|
+
const effectiveBand = this.hysteresis.calculateBandWithHysteresis(currentBand, score);
|
|
112
|
+
if (effectiveBand === currentBand) {
|
|
113
|
+
const promotionThreshold = this.hysteresis.getPromotionThreshold(currentBand);
|
|
114
|
+
return {
|
|
115
|
+
allowed: false,
|
|
116
|
+
transitionType: TransitionType.PROMOTION,
|
|
117
|
+
previousBand: currentBand,
|
|
118
|
+
newBand: currentBand,
|
|
119
|
+
reason: 'Score within hysteresis buffer, promotion blocked',
|
|
120
|
+
scoreThreshold: promotionThreshold ?? undefined,
|
|
121
|
+
timestamp: now,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Check time requirement
|
|
125
|
+
const history = this.getHistory(agentId);
|
|
126
|
+
const timeCheck = this.hysteresis.canPromoteByTime(history, nextBand);
|
|
127
|
+
if (!timeCheck.allowed) {
|
|
128
|
+
const daysRemaining = timeCheck.daysRequired - timeCheck.daysAtCurrentBand;
|
|
129
|
+
return {
|
|
130
|
+
allowed: false,
|
|
131
|
+
transitionType: TransitionType.PROMOTION,
|
|
132
|
+
previousBand: currentBand,
|
|
133
|
+
newBand: currentBand,
|
|
134
|
+
reason: `Promotion requires ${timeCheck.daysRequired} days at current band (${timeCheck.daysAtCurrentBand} days so far)`,
|
|
135
|
+
daysUntilPromotion: Math.max(0, daysRemaining),
|
|
136
|
+
timestamp: now,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// Promotion allowed
|
|
140
|
+
this.recordTransition(agentId, currentBand, nextBand, score, 'Met promotion requirements', now);
|
|
141
|
+
return {
|
|
142
|
+
allowed: true,
|
|
143
|
+
transitionType: TransitionType.PROMOTION,
|
|
144
|
+
previousBand: currentBand,
|
|
145
|
+
newBand: nextBand,
|
|
146
|
+
reason: `Promoted from ${getBandName(currentBand)} to ${getBandName(nextBand)}`,
|
|
147
|
+
timestamp: now,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Record a band transition
|
|
152
|
+
*/
|
|
153
|
+
recordTransition(agentId, fromBand, toBand, score, reason, timestamp) {
|
|
154
|
+
// Update history
|
|
155
|
+
const history = this.getHistory(agentId);
|
|
156
|
+
history.push({ band: toBand, score, timestamp });
|
|
157
|
+
this.historyByAgent.set(agentId, history);
|
|
158
|
+
// Record event
|
|
159
|
+
const event = {
|
|
160
|
+
eventId: uuidv4(),
|
|
161
|
+
agentId,
|
|
162
|
+
transitionType: toBand > fromBand ? TransitionType.PROMOTION : TransitionType.DEMOTION,
|
|
163
|
+
fromBand,
|
|
164
|
+
toBand,
|
|
165
|
+
score,
|
|
166
|
+
reason,
|
|
167
|
+
timestamp,
|
|
168
|
+
};
|
|
169
|
+
this.transitionEvents.push(event);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Record a score snapshot (for history tracking)
|
|
173
|
+
*/
|
|
174
|
+
recordScoreSnapshot(agentId, band, score, timestamp = new Date()) {
|
|
175
|
+
const history = this.getHistory(agentId);
|
|
176
|
+
// Only add if band changed or first entry
|
|
177
|
+
if (history.length === 0 || history[history.length - 1].band !== band) {
|
|
178
|
+
history.push({ band, score, timestamp });
|
|
179
|
+
this.historyByAgent.set(agentId, history);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get band history for an agent
|
|
184
|
+
*/
|
|
185
|
+
getHistory(agentId) {
|
|
186
|
+
return this.historyByAgent.get(agentId) ?? [];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get transition events for an agent
|
|
190
|
+
*/
|
|
191
|
+
getTransitionEvents(agentId) {
|
|
192
|
+
return this.transitionEvents.filter((e) => e.agentId === agentId);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Calculate band stability metrics
|
|
196
|
+
*/
|
|
197
|
+
calculateStability(agentId, now = new Date()) {
|
|
198
|
+
const history = this.getHistory(agentId);
|
|
199
|
+
if (history.length === 0) {
|
|
200
|
+
return {
|
|
201
|
+
currentBand: TrustBand.T0_SANDBOX,
|
|
202
|
+
daysAtBand: 0,
|
|
203
|
+
recentTransitions: 0,
|
|
204
|
+
stable: false,
|
|
205
|
+
stabilityScore: 0,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const currentEntry = history[history.length - 1];
|
|
209
|
+
const daysAtBand = (now.getTime() - currentEntry.timestamp.getTime()) / (1000 * 60 * 60 * 24);
|
|
210
|
+
// Count transitions in last 30 days
|
|
211
|
+
const thirtyDaysAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000);
|
|
212
|
+
let recentTransitions = 0;
|
|
213
|
+
for (let i = 1; i < history.length; i++) {
|
|
214
|
+
if (history[i].timestamp > thirtyDaysAgo &&
|
|
215
|
+
history[i].band !== history[i - 1].band) {
|
|
216
|
+
recentTransitions++;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Calculate stability score
|
|
220
|
+
// - More days at band = more stable
|
|
221
|
+
// - Fewer transitions = more stable
|
|
222
|
+
const timeComponent = Math.min(1, daysAtBand / 30); // Max at 30 days
|
|
223
|
+
const transitionComponent = Math.max(0, 1 - recentTransitions * 0.2); // Penalty for transitions
|
|
224
|
+
const stabilityScore = (timeComponent + transitionComponent) / 2;
|
|
225
|
+
return {
|
|
226
|
+
currentBand: currentEntry.band,
|
|
227
|
+
daysAtBand: Math.floor(daysAtBand),
|
|
228
|
+
recentTransitions,
|
|
229
|
+
stable: stabilityScore >= 0.7,
|
|
230
|
+
stabilityScore: Math.round(stabilityScore * 100) / 100,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Clear history for an agent (for testing)
|
|
235
|
+
*/
|
|
236
|
+
clearHistory(agentId) {
|
|
237
|
+
this.historyByAgent.delete(agentId);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Get configuration
|
|
241
|
+
*/
|
|
242
|
+
getConfig() {
|
|
243
|
+
return { ...this.config };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Create a BandCalculator with default configuration
|
|
248
|
+
*/
|
|
249
|
+
export function createBandCalculator(config) {
|
|
250
|
+
return new BandCalculator(config);
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=band-calculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"band-calculator.js","sourceRoot":"","sources":["../../src/banding/band-calculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,SAAS,EAAsB,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAyB,MAAM,iBAAiB,CAAC;AAE9E;;GAEG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,+BAAa,CAAA;IACb,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;AACvB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AA8DD;;GAEG;AACH,MAAM,OAAO,cAAc;IACR,MAAM,CAAgB;IACtB,UAAU,CAAuB;IACjC,cAAc,GAAoC,IAAI,GAAG,EAAE,CAAC;IAC5D,gBAAgB,GAA0B,EAAE,CAAC;IAE9D,YAAY,SAAiC,EAAE;QAC7C,IAAI,CAAC,MAAM,GAAG,EAA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
1
|
+
/**
|
|
2
|
+
* Trust Banding - T0 to T7 trust bands with autonomy levels
|
|
3
|
+
*
|
|
4
|
+
* Trust bands map score ranges (0-1000) to autonomy levels:
|
|
5
|
+
* - T0 (0-199): Sandbox - Isolated testing, no real operations
|
|
6
|
+
* - T1 (200-349): Observed - Under active observation and supervision
|
|
7
|
+
* - T2 (350-499): Provisional - Limited operations with strict constraints
|
|
8
|
+
* - T3 (500-649): Monitored - Continuous monitoring with expanding freedom
|
|
9
|
+
* - T4 (650-799): Standard - Trusted for routine operations
|
|
10
|
+
* - T5 (800-875): Trusted - Expanded capabilities with minimal oversight
|
|
11
|
+
* - T6 (876-950): Certified - Independent operation with audit trail
|
|
12
|
+
* - T7 (951-1000): Autonomous - Full autonomy for mission-critical operations
|
|
13
|
+
*/
|
|
14
|
+
import { TrustBand, type BandThresholds, DEFAULT_BAND_THRESHOLDS } from '@vorionsys/contracts';
|
|
15
|
+
export { TrustBand, DEFAULT_BAND_THRESHOLDS };
|
|
16
|
+
/**
|
|
17
|
+
* Get the trust band for a given score
|
|
18
|
+
*/
|
|
19
|
+
export declare function getBand(score: number, thresholds?: BandThresholds): TrustBand;
|
|
20
|
+
/**
|
|
21
|
+
* Get the score range for a band
|
|
22
|
+
*/
|
|
23
|
+
export declare function getBandRange(band: TrustBand, thresholds?: BandThresholds): {
|
|
24
|
+
min: number;
|
|
25
|
+
max: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Get band name (human readable)
|
|
29
|
+
*/
|
|
30
|
+
export declare function getBandName(band: TrustBand): string;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a band can be promoted to another
|
|
33
|
+
*/
|
|
34
|
+
export declare function canPromote(from: TrustBand, to: TrustBand): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if one band is higher than another
|
|
37
|
+
*/
|
|
38
|
+
export declare function isHigherBand(a: TrustBand, b: TrustBand): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Get the next band up (for promotion)
|
|
41
|
+
*/
|
|
42
|
+
export declare function getNextBand(band: TrustBand): TrustBand | null;
|
|
43
|
+
/**
|
|
44
|
+
* Get the previous band (for demotion)
|
|
45
|
+
*/
|
|
46
|
+
export declare function getPreviousBand(band: TrustBand): TrustBand | null;
|
|
47
|
+
/**
|
|
48
|
+
* Band descriptions for documentation/UI
|
|
49
|
+
*/
|
|
50
|
+
export declare const BAND_DESCRIPTIONS: Record<TrustBand, {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
autonomyLevel: string;
|
|
54
|
+
typicalCapabilities: string[];
|
|
55
|
+
}>;
|
|
56
|
+
//# sourceMappingURL=bands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bands.d.ts","sourceRoot":"","sources":["../../src/banding/bands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/F,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAE9C;;GAEG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,cAAwC,GACnD,SAAS,CASX;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,EACf,UAAU,GAAE,cAAwC,GACnD;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAqB9B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAqBnD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,CAGlE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAG7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAGjE;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,SAAS,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAiFA,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Banding - T0 to T7 trust bands with autonomy levels
|
|
3
|
+
*
|
|
4
|
+
* Trust bands map score ranges (0-1000) to autonomy levels:
|
|
5
|
+
* - T0 (0-199): Sandbox - Isolated testing, no real operations
|
|
6
|
+
* - T1 (200-349): Observed - Under active observation and supervision
|
|
7
|
+
* - T2 (350-499): Provisional - Limited operations with strict constraints
|
|
8
|
+
* - T3 (500-649): Monitored - Continuous monitoring with expanding freedom
|
|
9
|
+
* - T4 (650-799): Standard - Trusted for routine operations
|
|
10
|
+
* - T5 (800-875): Trusted - Expanded capabilities with minimal oversight
|
|
11
|
+
* - T6 (876-950): Certified - Independent operation with audit trail
|
|
12
|
+
* - T7 (951-1000): Autonomous - Full autonomy for mission-critical operations
|
|
13
|
+
*/
|
|
14
|
+
import { TrustBand, DEFAULT_BAND_THRESHOLDS } from '@vorionsys/contracts';
|
|
15
|
+
export { TrustBand, DEFAULT_BAND_THRESHOLDS };
|
|
16
|
+
/**
|
|
17
|
+
* Get the trust band for a given score
|
|
18
|
+
*/
|
|
19
|
+
export function getBand(score, thresholds = DEFAULT_BAND_THRESHOLDS) {
|
|
20
|
+
if (score <= thresholds.T0.max)
|
|
21
|
+
return TrustBand.T0_SANDBOX;
|
|
22
|
+
if (score <= thresholds.T1.max)
|
|
23
|
+
return TrustBand.T1_OBSERVED;
|
|
24
|
+
if (score <= thresholds.T2.max)
|
|
25
|
+
return TrustBand.T2_PROVISIONAL;
|
|
26
|
+
if (score <= thresholds.T3.max)
|
|
27
|
+
return TrustBand.T3_MONITORED;
|
|
28
|
+
if (score <= thresholds.T4.max)
|
|
29
|
+
return TrustBand.T4_STANDARD;
|
|
30
|
+
if (score <= thresholds.T5.max)
|
|
31
|
+
return TrustBand.T5_TRUSTED;
|
|
32
|
+
if (score <= thresholds.T6.max)
|
|
33
|
+
return TrustBand.T6_CERTIFIED;
|
|
34
|
+
return TrustBand.T7_AUTONOMOUS;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the score range for a band
|
|
38
|
+
*/
|
|
39
|
+
export function getBandRange(band, thresholds = DEFAULT_BAND_THRESHOLDS) {
|
|
40
|
+
switch (band) {
|
|
41
|
+
case TrustBand.T0_SANDBOX:
|
|
42
|
+
return thresholds.T0;
|
|
43
|
+
case TrustBand.T1_OBSERVED:
|
|
44
|
+
return thresholds.T1;
|
|
45
|
+
case TrustBand.T2_PROVISIONAL:
|
|
46
|
+
return thresholds.T2;
|
|
47
|
+
case TrustBand.T3_MONITORED:
|
|
48
|
+
return thresholds.T3;
|
|
49
|
+
case TrustBand.T4_STANDARD:
|
|
50
|
+
return thresholds.T4;
|
|
51
|
+
case TrustBand.T5_TRUSTED:
|
|
52
|
+
return thresholds.T5;
|
|
53
|
+
case TrustBand.T6_CERTIFIED:
|
|
54
|
+
return thresholds.T6;
|
|
55
|
+
case TrustBand.T7_AUTONOMOUS:
|
|
56
|
+
return thresholds.T7;
|
|
57
|
+
default:
|
|
58
|
+
return thresholds.T0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get band name (human readable)
|
|
63
|
+
*/
|
|
64
|
+
export function getBandName(band) {
|
|
65
|
+
switch (band) {
|
|
66
|
+
case TrustBand.T0_SANDBOX:
|
|
67
|
+
return 'Sandbox';
|
|
68
|
+
case TrustBand.T1_OBSERVED:
|
|
69
|
+
return 'Observed';
|
|
70
|
+
case TrustBand.T2_PROVISIONAL:
|
|
71
|
+
return 'Provisional';
|
|
72
|
+
case TrustBand.T3_MONITORED:
|
|
73
|
+
return 'Monitored';
|
|
74
|
+
case TrustBand.T4_STANDARD:
|
|
75
|
+
return 'Standard';
|
|
76
|
+
case TrustBand.T5_TRUSTED:
|
|
77
|
+
return 'Trusted';
|
|
78
|
+
case TrustBand.T6_CERTIFIED:
|
|
79
|
+
return 'Certified';
|
|
80
|
+
case TrustBand.T7_AUTONOMOUS:
|
|
81
|
+
return 'Autonomous';
|
|
82
|
+
default:
|
|
83
|
+
return 'Unknown';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if a band can be promoted to another
|
|
88
|
+
*/
|
|
89
|
+
export function canPromote(from, to) {
|
|
90
|
+
// Can only promote one level at a time
|
|
91
|
+
return to === from + 1;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if one band is higher than another
|
|
95
|
+
*/
|
|
96
|
+
export function isHigherBand(a, b) {
|
|
97
|
+
return a > b;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the next band up (for promotion)
|
|
101
|
+
*/
|
|
102
|
+
export function getNextBand(band) {
|
|
103
|
+
if (band >= TrustBand.T7_AUTONOMOUS)
|
|
104
|
+
return null;
|
|
105
|
+
return (band + 1);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get the previous band (for demotion)
|
|
109
|
+
*/
|
|
110
|
+
export function getPreviousBand(band) {
|
|
111
|
+
if (band <= TrustBand.T0_SANDBOX)
|
|
112
|
+
return null;
|
|
113
|
+
return (band - 1);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Band descriptions for documentation/UI
|
|
117
|
+
*/
|
|
118
|
+
export const BAND_DESCRIPTIONS = {
|
|
119
|
+
[TrustBand.T0_SANDBOX]: {
|
|
120
|
+
name: 'T0 - Sandbox',
|
|
121
|
+
description: 'Isolated testing environment. No real operations allowed.',
|
|
122
|
+
autonomyLevel: 'None',
|
|
123
|
+
typicalCapabilities: [
|
|
124
|
+
'Read-only data access',
|
|
125
|
+
'Simulated operations only',
|
|
126
|
+
'Informational responses only',
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
[TrustBand.T1_OBSERVED]: {
|
|
130
|
+
name: 'T1 - Observed',
|
|
131
|
+
description: 'Under active observation. All actions are supervised.',
|
|
132
|
+
autonomyLevel: 'Minimal',
|
|
133
|
+
typicalCapabilities: [
|
|
134
|
+
'Prepare actions for review',
|
|
135
|
+
'Suggest changes',
|
|
136
|
+
'Execute approved read operations',
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
[TrustBand.T2_PROVISIONAL]: {
|
|
140
|
+
name: 'T2 - Provisional',
|
|
141
|
+
description: 'Limited operations with strict constraints and guardrails.',
|
|
142
|
+
autonomyLevel: 'Limited',
|
|
143
|
+
typicalCapabilities: [
|
|
144
|
+
'Execute low-risk operations',
|
|
145
|
+
'Write to non-critical systems',
|
|
146
|
+
'Automated responses within templates',
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
[TrustBand.T3_MONITORED]: {
|
|
150
|
+
name: 'T3 - Monitored',
|
|
151
|
+
description: 'Continuous monitoring with expanding operational freedom.',
|
|
152
|
+
autonomyLevel: 'Moderate',
|
|
153
|
+
typicalCapabilities: [
|
|
154
|
+
'Execute routine operations',
|
|
155
|
+
'Make decisions within policy',
|
|
156
|
+
'Access internal data',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
[TrustBand.T4_STANDARD]: {
|
|
160
|
+
name: 'T4 - Standard',
|
|
161
|
+
description: 'Standard autonomy. Trusted for routine operations.',
|
|
162
|
+
autonomyLevel: 'Standard',
|
|
163
|
+
typicalCapabilities: [
|
|
164
|
+
'Execute standard workflows',
|
|
165
|
+
'Access business data',
|
|
166
|
+
'Make routine decisions',
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
[TrustBand.T5_TRUSTED]: {
|
|
170
|
+
name: 'T5 - Trusted',
|
|
171
|
+
description: 'Expanded capabilities with minimal oversight required.',
|
|
172
|
+
autonomyLevel: 'High',
|
|
173
|
+
typicalCapabilities: [
|
|
174
|
+
'Execute complex workflows',
|
|
175
|
+
'Access sensitive data',
|
|
176
|
+
'Make autonomous decisions',
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
[TrustBand.T6_CERTIFIED]: {
|
|
180
|
+
name: 'T6 - Certified',
|
|
181
|
+
description: 'Independent operation with comprehensive audit trail.',
|
|
182
|
+
autonomyLevel: 'Very High',
|
|
183
|
+
typicalCapabilities: [
|
|
184
|
+
'Full system access',
|
|
185
|
+
'Critical decision making',
|
|
186
|
+
'Independent operation',
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
[TrustBand.T7_AUTONOMOUS]: {
|
|
190
|
+
name: 'T7 - Autonomous',
|
|
191
|
+
description: 'Full autonomy for mission-critical operations.',
|
|
192
|
+
autonomyLevel: 'Full',
|
|
193
|
+
typicalCapabilities: [
|
|
194
|
+
'Unrestricted system access',
|
|
195
|
+
'Autonomous mission-critical decisions',
|
|
196
|
+
'Full operational authority',
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=bands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bands.js","sourceRoot":"","sources":["../../src/banding/bands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAuB,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/F,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,OAAO,CACrB,KAAa,EACb,aAA6B,uBAAuB;IAEpD,IAAI,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,GAAG;QA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C,SAAS,CAAC,YAAY,CAAC,EAAE;QACxB,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,uDAAuD;QACpE,aAAa,EAAE,WAAW;QAC1B,mBAAmB,EAAE;YACnB,oBAAoB;YACpB,0BAA0B;YAC1B,uBAAuB;SACxB;KACF;IACD,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE;QACzB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,gDAAgD;QAC7D,aAAa,EAAE,MAAM;QACrB,mBAAmB,EAAE;YACnB,4BAA4B;YAC5B,uCAAuC;YACvC,4BAA4B;SAC7B;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hysteresis - Preventing trust band oscillation
|
|
3
|
+
*
|
|
4
|
+
* Hysteresis creates a buffer zone between band boundaries
|
|
5
|
+
* to prevent rapid switching between bands when scores
|
|
6
|
+
* hover near thresholds.
|
|
7
|
+
*/
|
|
8
|
+
import { TrustBand, type BandingConfig, DEFAULT_BANDING_CONFIG } from '@vorionsys/contracts';
|
|
9
|
+
export { DEFAULT_BANDING_CONFIG };
|
|
10
|
+
/**
|
|
11
|
+
* Band transition history entry
|
|
12
|
+
*/
|
|
13
|
+
export interface BandHistoryEntry {
|
|
14
|
+
band: TrustBand;
|
|
15
|
+
score: number;
|
|
16
|
+
timestamp: Date;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Hysteresis calculator for band transitions
|
|
20
|
+
*/
|
|
21
|
+
export declare class HysteresisCalculator {
|
|
22
|
+
private config;
|
|
23
|
+
constructor(config?: Partial<BandingConfig>);
|
|
24
|
+
/**
|
|
25
|
+
* Calculate the effective band considering hysteresis
|
|
26
|
+
*
|
|
27
|
+
* @param currentBand - The agent's current band
|
|
28
|
+
* @param newScore - The newly calculated score
|
|
29
|
+
* @returns The effective band after hysteresis
|
|
30
|
+
*/
|
|
31
|
+
calculateBandWithHysteresis(currentBand: TrustBand, newScore: number): TrustBand;
|
|
32
|
+
/**
|
|
33
|
+
* Check if promotion is allowed based on time at current band
|
|
34
|
+
*/
|
|
35
|
+
canPromoteByTime(history: BandHistoryEntry[], targetBand: TrustBand): {
|
|
36
|
+
allowed: boolean;
|
|
37
|
+
daysAtCurrentBand: number;
|
|
38
|
+
daysRequired: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Demotion is always immediate (no delay)
|
|
42
|
+
*/
|
|
43
|
+
canDemote(currentBand: TrustBand, targetBand: TrustBand): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get the minimum score needed to promote from current band
|
|
46
|
+
*/
|
|
47
|
+
getPromotionThreshold(currentBand: TrustBand): number | null;
|
|
48
|
+
/**
|
|
49
|
+
* Get the maximum score before demotion from current band
|
|
50
|
+
*/
|
|
51
|
+
getDemotionThreshold(currentBand: TrustBand): number | null;
|
|
52
|
+
/**
|
|
53
|
+
* Get the distance to the next band transition
|
|
54
|
+
*/
|
|
55
|
+
getDistanceToTransition(currentBand: TrustBand, currentScore: number): {
|
|
56
|
+
toPromotion: number | null;
|
|
57
|
+
toDemotion: number | null;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a default hysteresis calculator
|
|
62
|
+
*/
|
|
63
|
+
export declare function createHysteresisCalculator(config?: Partial<BandingConfig>): HysteresisCalculator;
|
|
64
|
+
//# sourceMappingURL=hysteresis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hysteresis.d.ts","sourceRoot":"","sources":["../../src/banding/hysteresis.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAG7F,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAA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