@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,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Profile Service - High-level profile management
|
|
3
|
+
*
|
|
4
|
+
* Provides business logic for trust profile operations:
|
|
5
|
+
* - Create, read, update profiles
|
|
6
|
+
* - Calculate new profiles from evidence
|
|
7
|
+
* - Recalculate existing profiles
|
|
8
|
+
* - Profile history and snapshots
|
|
9
|
+
*
|
|
10
|
+
* Hook integration:
|
|
11
|
+
* - TRUST_CHANGE: Fired when a profile is created, updated, or refreshed
|
|
12
|
+
* - TRUST_VIOLATION: Fired when significant trust drops or anomalies detected
|
|
13
|
+
*/
|
|
14
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
15
|
+
import { ObservationTier, TrustBand, } from '@vorionsys/contracts';
|
|
16
|
+
import { TrustCalculator } from './trust-calculator.js';
|
|
17
|
+
import { createInMemoryStore, } from './profile-store.js';
|
|
18
|
+
/**
|
|
19
|
+
* TrustProfileService - Manages trust profiles for agents
|
|
20
|
+
*/
|
|
21
|
+
export class TrustProfileService {
|
|
22
|
+
store;
|
|
23
|
+
calculator;
|
|
24
|
+
hookManager;
|
|
25
|
+
config;
|
|
26
|
+
constructor(config = {}) {
|
|
27
|
+
this.store = config.store ?? createInMemoryStore();
|
|
28
|
+
this.calculator = new TrustCalculator(config.calculatorConfig);
|
|
29
|
+
this.hookManager = config.hookManager;
|
|
30
|
+
this.config = {
|
|
31
|
+
store: this.store,
|
|
32
|
+
calculatorConfig: config.calculatorConfig ?? {},
|
|
33
|
+
autoRecalculateAfterMs: config.autoRecalculateAfterMs ?? 24 * 60 * 60 * 1000, // 24h
|
|
34
|
+
enableCaching: config.enableCaching ?? false,
|
|
35
|
+
enableHooks: config.enableHooks ?? (config.hookManager !== undefined),
|
|
36
|
+
bandDropViolationThreshold: config.bandDropViolationThreshold ?? 1,
|
|
37
|
+
scoreDropViolationThreshold: config.scoreDropViolationThreshold ?? 20,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a new trust profile for an agent
|
|
42
|
+
*/
|
|
43
|
+
async create(agentId, observationTier, evidence, options = {}) {
|
|
44
|
+
try {
|
|
45
|
+
// Check if profile already exists
|
|
46
|
+
const existing = await this.store.get(agentId);
|
|
47
|
+
if (existing) {
|
|
48
|
+
return {
|
|
49
|
+
success: false,
|
|
50
|
+
error: `Profile already exists for agent ${agentId}. Use update() instead.`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Calculate the profile
|
|
54
|
+
const profile = this.calculator.calculate(agentId, observationTier, evidence, {
|
|
55
|
+
now: options.now,
|
|
56
|
+
});
|
|
57
|
+
// Override profile ID if provided
|
|
58
|
+
if (options.profileId) {
|
|
59
|
+
profile.profileId = options.profileId;
|
|
60
|
+
}
|
|
61
|
+
// Save to store
|
|
62
|
+
const saved = await this.store.save(profile);
|
|
63
|
+
// Fire trust change hook for new profile
|
|
64
|
+
await this.fireTrustChangeHook(null, saved, 'Profile created');
|
|
65
|
+
return {
|
|
66
|
+
success: true,
|
|
67
|
+
profile: saved,
|
|
68
|
+
isNew: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
return {
|
|
73
|
+
success: false,
|
|
74
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get a trust profile by agent ID
|
|
80
|
+
*/
|
|
81
|
+
async get(agentId) {
|
|
82
|
+
return this.store.get(agentId);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get a profile by its unique profile ID
|
|
86
|
+
*/
|
|
87
|
+
async getByProfileId(profileId) {
|
|
88
|
+
return this.store.getByProfileId(profileId);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get or create a profile for an agent
|
|
92
|
+
*/
|
|
93
|
+
async getOrCreate(agentId, observationTier, initialEvidence = [], options = {}) {
|
|
94
|
+
const existing = await this.store.get(agentId);
|
|
95
|
+
if (existing) {
|
|
96
|
+
return {
|
|
97
|
+
success: true,
|
|
98
|
+
profile: existing,
|
|
99
|
+
isNew: false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return this.create(agentId, observationTier, initialEvidence, options);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Update an existing profile with new evidence
|
|
106
|
+
*/
|
|
107
|
+
async update(agentId, newEvidence, options = {}) {
|
|
108
|
+
try {
|
|
109
|
+
const existing = await this.store.get(agentId);
|
|
110
|
+
if (!existing) {
|
|
111
|
+
return {
|
|
112
|
+
success: false,
|
|
113
|
+
error: `No profile found for agent ${agentId}. Use create() first.`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// Recalculate with new evidence
|
|
117
|
+
const updated = this.calculator.recalculate(existing, newEvidence, {
|
|
118
|
+
now: options.now,
|
|
119
|
+
});
|
|
120
|
+
// Save updated profile
|
|
121
|
+
const saved = await this.store.save(updated);
|
|
122
|
+
// Fire trust change hook
|
|
123
|
+
await this.fireTrustChangeHook(existing, saved, 'Evidence updated');
|
|
124
|
+
// Check for trust violations
|
|
125
|
+
await this.checkForViolations(existing, saved);
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
profile: saved,
|
|
129
|
+
isNew: false,
|
|
130
|
+
previousVersion: existing.version,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return {
|
|
135
|
+
success: false,
|
|
136
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Recalculate a profile with decay applied (no new evidence)
|
|
142
|
+
*/
|
|
143
|
+
async refresh(agentId, options = {}) {
|
|
144
|
+
try {
|
|
145
|
+
const existing = await this.store.get(agentId);
|
|
146
|
+
if (!existing) {
|
|
147
|
+
return {
|
|
148
|
+
success: false,
|
|
149
|
+
error: `No profile found for agent ${agentId}`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const now = options.now ?? new Date();
|
|
153
|
+
const age = now.getTime() - existing.calculatedAt.getTime();
|
|
154
|
+
// Skip if not old enough (unless forced)
|
|
155
|
+
if (!options.force && age < this.config.autoRecalculateAfterMs) {
|
|
156
|
+
return {
|
|
157
|
+
success: true,
|
|
158
|
+
profile: existing,
|
|
159
|
+
isNew: false,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
// Apply decay
|
|
163
|
+
const refreshed = this.calculator.applyDecay(existing, { now });
|
|
164
|
+
// Save updated profile
|
|
165
|
+
const saved = await this.store.save(refreshed);
|
|
166
|
+
// Fire trust change hook if there was a change
|
|
167
|
+
if (existing.band !== saved.band || existing.adjustedScore !== saved.adjustedScore) {
|
|
168
|
+
await this.fireTrustChangeHook(existing, saved, 'Decay applied');
|
|
169
|
+
await this.checkForViolations(existing, saved);
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
profile: saved,
|
|
174
|
+
isNew: false,
|
|
175
|
+
previousVersion: existing.version,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
return {
|
|
180
|
+
success: false,
|
|
181
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Delete a profile
|
|
187
|
+
*/
|
|
188
|
+
async delete(agentId) {
|
|
189
|
+
return this.store.delete(agentId);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Check if a profile exists
|
|
193
|
+
*/
|
|
194
|
+
async exists(agentId) {
|
|
195
|
+
return this.store.exists(agentId);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Query profiles with filters
|
|
199
|
+
*/
|
|
200
|
+
async query(filter, options) {
|
|
201
|
+
return this.store.query(filter, options);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get profile history for an agent
|
|
205
|
+
*/
|
|
206
|
+
async getHistory(agentId, limit) {
|
|
207
|
+
return this.store.getHistory(agentId, limit);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get summaries for multiple agents
|
|
211
|
+
*/
|
|
212
|
+
async getSummaries(agentIds) {
|
|
213
|
+
return this.store.getSummaries(agentIds);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get all agent IDs with profiles
|
|
217
|
+
*/
|
|
218
|
+
async listAgentIds(options) {
|
|
219
|
+
const result = await this.store.query({}, options);
|
|
220
|
+
return result.profiles.map((p) => p.agentId);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Bulk create or update profiles
|
|
224
|
+
*/
|
|
225
|
+
async bulkUpsert(profiles, options = {}) {
|
|
226
|
+
const results = [];
|
|
227
|
+
for (const item of profiles) {
|
|
228
|
+
const existing = await this.store.get(item.agentId);
|
|
229
|
+
if (existing) {
|
|
230
|
+
const result = await this.update(item.agentId, item.evidence, options);
|
|
231
|
+
results.push(result);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
const result = await this.create(item.agentId, item.observationTier, item.evidence, options);
|
|
235
|
+
results.push(result);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return results;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get profiles that need recalculation
|
|
242
|
+
*/
|
|
243
|
+
async getStaleProfiles(maxAge = this.config.autoRecalculateAfterMs) {
|
|
244
|
+
const cutoff = new Date(Date.now() - maxAge);
|
|
245
|
+
const result = await this.store.query({ calculatedBefore: cutoff });
|
|
246
|
+
return result.profiles;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Refresh all stale profiles
|
|
250
|
+
*/
|
|
251
|
+
async refreshStaleProfiles(maxAge, options) {
|
|
252
|
+
const stale = await this.getStaleProfiles(maxAge);
|
|
253
|
+
const results = [];
|
|
254
|
+
for (const profile of stale) {
|
|
255
|
+
const result = await this.refresh(profile.agentId, { ...options, force: true });
|
|
256
|
+
results.push(result);
|
|
257
|
+
}
|
|
258
|
+
return results;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get the underlying calculator
|
|
262
|
+
*/
|
|
263
|
+
getCalculator() {
|
|
264
|
+
return this.calculator;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get the underlying store
|
|
268
|
+
*/
|
|
269
|
+
getStore() {
|
|
270
|
+
return this.store;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Clear all profiles (for testing)
|
|
274
|
+
*/
|
|
275
|
+
async clear() {
|
|
276
|
+
await this.store.clear();
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get the hook manager
|
|
280
|
+
*/
|
|
281
|
+
getHookManager() {
|
|
282
|
+
return this.hookManager;
|
|
283
|
+
}
|
|
284
|
+
// ============================================================
|
|
285
|
+
// Private Hook Methods
|
|
286
|
+
// ============================================================
|
|
287
|
+
/**
|
|
288
|
+
* Fire trust change hook
|
|
289
|
+
*/
|
|
290
|
+
async fireTrustChangeHook(previousProfile, newProfile, reason) {
|
|
291
|
+
if (!this.config.enableHooks || !this.hookManager) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
// For new profiles, create a "zero" previous profile for comparison
|
|
295
|
+
const previous = previousProfile ?? this.createZeroProfile(newProfile.agentId);
|
|
296
|
+
await this.hookManager.executeTrustChange({
|
|
297
|
+
correlationId: uuidv4(),
|
|
298
|
+
agentId: newProfile.agentId,
|
|
299
|
+
previousProfile: previous,
|
|
300
|
+
newProfile,
|
|
301
|
+
reason,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Check for trust violations and fire hooks
|
|
306
|
+
*/
|
|
307
|
+
async checkForViolations(previousProfile, newProfile) {
|
|
308
|
+
if (!this.config.enableHooks || !this.hookManager) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const violations = [];
|
|
312
|
+
// Check for band drop
|
|
313
|
+
const bandDrop = previousProfile.band - newProfile.band;
|
|
314
|
+
if (bandDrop >= this.config.bandDropViolationThreshold) {
|
|
315
|
+
const severity = bandDrop >= 2 ? 'critical' : 'high';
|
|
316
|
+
violations.push({
|
|
317
|
+
type: 'band_drop',
|
|
318
|
+
severity,
|
|
319
|
+
details: {
|
|
320
|
+
previousBand: previousProfile.band,
|
|
321
|
+
newBand: newProfile.band,
|
|
322
|
+
bandDrop,
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
// Check for significant score drop
|
|
327
|
+
const scoreDrop = previousProfile.adjustedScore - newProfile.adjustedScore;
|
|
328
|
+
const scoreDropPercent = (scoreDrop / previousProfile.adjustedScore) * 100;
|
|
329
|
+
if (scoreDropPercent >= this.config.scoreDropViolationThreshold) {
|
|
330
|
+
const severity = scoreDropPercent >= 40 ? 'critical' : scoreDropPercent >= 30 ? 'high' : 'medium';
|
|
331
|
+
violations.push({
|
|
332
|
+
type: 'score_drop',
|
|
333
|
+
severity,
|
|
334
|
+
details: {
|
|
335
|
+
previousScore: previousProfile.adjustedScore,
|
|
336
|
+
newScore: newProfile.adjustedScore,
|
|
337
|
+
scoreDrop,
|
|
338
|
+
scoreDropPercent,
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
// Fire violation hooks
|
|
343
|
+
for (const violation of violations) {
|
|
344
|
+
await this.hookManager.executeTrustViolation({
|
|
345
|
+
correlationId: uuidv4(),
|
|
346
|
+
agentId: newProfile.agentId,
|
|
347
|
+
profile: newProfile,
|
|
348
|
+
violationType: violation.type,
|
|
349
|
+
details: violation.details,
|
|
350
|
+
severity: violation.severity,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Create a zero profile for comparison (used for new profile creation)
|
|
356
|
+
*/
|
|
357
|
+
createZeroProfile(agentId) {
|
|
358
|
+
return {
|
|
359
|
+
profileId: 'zero',
|
|
360
|
+
agentId,
|
|
361
|
+
factorScores: {},
|
|
362
|
+
compositeScore: 0,
|
|
363
|
+
observationTier: ObservationTier.BLACK_BOX,
|
|
364
|
+
adjustedScore: 0,
|
|
365
|
+
band: TrustBand.T0_SANDBOX,
|
|
366
|
+
calculatedAt: new Date(0),
|
|
367
|
+
evidence: [],
|
|
368
|
+
version: 0,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Create a TrustProfileService with default configuration
|
|
374
|
+
*/
|
|
375
|
+
export function createProfileService(config) {
|
|
376
|
+
return new TrustProfileService(config);
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=profile-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-service.js","sourceRoot":"","sources":["../../src/trust/profile-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EACL,eAAe,EACf,SAAS,GAIV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAA8B,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAML,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AA2D5B;;GAEG;AACH,MAAM,OAAO,mBAAmB;IACb,KAAK,CAAoB;IACzB,UAAU,CAAkB;IAC5B,WAAW,CAAe;IAC1B,MAAM,CAAsD;IAE7E,YAAY,SAA+B,EAAE;QAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,mBAAmB,EAAE,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC/D,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG;YACZ,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,EAAE;YAC/C,sBAAsB,EAAE,MAAM,CAAC,sBAAsB,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,MAAM;YACpF,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,KAAK;YAC5C,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC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C,UAAU;YAC1B,YAAY,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;YACzB,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,CAAC;SACX,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA6B;IAChE,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Profile Store - Abstract storage interface and implementations
|
|
3
|
+
*
|
|
4
|
+
* Provides pluggable storage backends for trust profiles:
|
|
5
|
+
* - In-memory (for testing and development)
|
|
6
|
+
* - Future: Supabase (for production)
|
|
7
|
+
*/
|
|
8
|
+
import type { TrustProfile, TrustProfileSummary } from '@vorionsys/contracts';
|
|
9
|
+
/**
|
|
10
|
+
* Profile query options
|
|
11
|
+
*/
|
|
12
|
+
export interface ProfileQueryOptions {
|
|
13
|
+
/** Maximum number of results */
|
|
14
|
+
limit?: number;
|
|
15
|
+
/** Offset for pagination */
|
|
16
|
+
offset?: number;
|
|
17
|
+
/** Order by field */
|
|
18
|
+
orderBy?: 'calculatedAt' | 'adjustedScore' | 'agentId';
|
|
19
|
+
/** Order direction */
|
|
20
|
+
orderDir?: 'asc' | 'desc';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Profile query filter
|
|
24
|
+
*/
|
|
25
|
+
export interface ProfileQueryFilter {
|
|
26
|
+
/** Filter by agent IDs */
|
|
27
|
+
agentIds?: string[];
|
|
28
|
+
/** Minimum adjusted score */
|
|
29
|
+
minScore?: number;
|
|
30
|
+
/** Maximum adjusted score */
|
|
31
|
+
maxScore?: number;
|
|
32
|
+
/** Filter by trust bands */
|
|
33
|
+
bands?: number[];
|
|
34
|
+
/** Calculated after this date */
|
|
35
|
+
calculatedAfter?: Date;
|
|
36
|
+
/** Calculated before this date */
|
|
37
|
+
calculatedBefore?: Date;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Profile query result
|
|
41
|
+
*/
|
|
42
|
+
export interface ProfileQueryResult {
|
|
43
|
+
profiles: TrustProfile[];
|
|
44
|
+
total: number;
|
|
45
|
+
offset: number;
|
|
46
|
+
limit: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Profile history entry
|
|
50
|
+
*/
|
|
51
|
+
export interface ProfileHistoryEntry {
|
|
52
|
+
profile: TrustProfile;
|
|
53
|
+
timestamp: Date;
|
|
54
|
+
reason?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Abstract interface for trust profile storage
|
|
58
|
+
*/
|
|
59
|
+
export interface TrustProfileStore {
|
|
60
|
+
/**
|
|
61
|
+
* Get a profile by agent ID
|
|
62
|
+
*/
|
|
63
|
+
get(agentId: string): Promise<TrustProfile | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Get a specific profile version by profile ID
|
|
66
|
+
*/
|
|
67
|
+
getByProfileId(profileId: string): Promise<TrustProfile | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Save a profile (creates or updates)
|
|
70
|
+
*/
|
|
71
|
+
save(profile: TrustProfile): Promise<TrustProfile>;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a profile by agent ID
|
|
74
|
+
*/
|
|
75
|
+
delete(agentId: string): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Query profiles with filters
|
|
78
|
+
*/
|
|
79
|
+
query(filter?: ProfileQueryFilter, options?: ProfileQueryOptions): Promise<ProfileQueryResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Get profile history for an agent
|
|
82
|
+
*/
|
|
83
|
+
getHistory(agentId: string, limit?: number): Promise<ProfileHistoryEntry[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Check if a profile exists for an agent
|
|
86
|
+
*/
|
|
87
|
+
exists(agentId: string): Promise<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* Get profile summaries for multiple agents
|
|
90
|
+
*/
|
|
91
|
+
getSummaries(agentIds: string[]): Promise<TrustProfileSummary[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Clear all profiles (for testing)
|
|
94
|
+
*/
|
|
95
|
+
clear(): Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* In-memory implementation of TrustProfileStore
|
|
99
|
+
* Suitable for testing and development
|
|
100
|
+
*/
|
|
101
|
+
export declare class InMemoryProfileStore implements TrustProfileStore {
|
|
102
|
+
private readonly profiles;
|
|
103
|
+
private readonly history;
|
|
104
|
+
get(agentId: string): Promise<TrustProfile | null>;
|
|
105
|
+
getByProfileId(profileId: string): Promise<TrustProfile | null>;
|
|
106
|
+
save(profile: TrustProfile): Promise<TrustProfile>;
|
|
107
|
+
delete(agentId: string): Promise<boolean>;
|
|
108
|
+
query(filter?: ProfileQueryFilter, options?: ProfileQueryOptions): Promise<ProfileQueryResult>;
|
|
109
|
+
getHistory(agentId: string, limit?: number): Promise<ProfileHistoryEntry[]>;
|
|
110
|
+
exists(agentId: string): Promise<boolean>;
|
|
111
|
+
getSummaries(agentIds: string[]): Promise<TrustProfileSummary[]>;
|
|
112
|
+
clear(): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Get count of stored profiles (for testing)
|
|
115
|
+
*/
|
|
116
|
+
get size(): number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create a new in-memory profile store
|
|
120
|
+
*/
|
|
121
|
+
export declare function createInMemoryStore(): TrustProfileStore;
|
|
122
|
+
//# sourceMappingURL=profile-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-store.d.ts","sourceRoot":"","sources":["../../src/trust/profile-store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,gCAAgC;IAChC,KAAK,CAAC,E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AAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAkBhE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,iBAAiB,CAEvD"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Profile Store - Abstract storage interface and implementations
|
|
3
|
+
*
|
|
4
|
+
* Provides pluggable storage backends for trust profiles:
|
|
5
|
+
* - In-memory (for testing and development)
|
|
6
|
+
* - Future: Supabase (for production)
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* In-memory implementation of TrustProfileStore
|
|
10
|
+
* Suitable for testing and development
|
|
11
|
+
*/
|
|
12
|
+
export class InMemoryProfileStore {
|
|
13
|
+
profiles = new Map();
|
|
14
|
+
history = new Map();
|
|
15
|
+
async get(agentId) {
|
|
16
|
+
return this.profiles.get(agentId) ?? null;
|
|
17
|
+
}
|
|
18
|
+
async getByProfileId(profileId) {
|
|
19
|
+
for (const profile of this.profiles.values()) {
|
|
20
|
+
if (profile.profileId === profileId) {
|
|
21
|
+
return profile;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
async save(profile) {
|
|
27
|
+
const existing = this.profiles.get(profile.agentId);
|
|
28
|
+
// Store current as history before updating
|
|
29
|
+
if (existing) {
|
|
30
|
+
const agentHistory = this.history.get(profile.agentId) ?? [];
|
|
31
|
+
agentHistory.push({
|
|
32
|
+
profile: { ...existing },
|
|
33
|
+
timestamp: new Date(),
|
|
34
|
+
reason: 'profile_updated',
|
|
35
|
+
});
|
|
36
|
+
this.history.set(profile.agentId, agentHistory);
|
|
37
|
+
}
|
|
38
|
+
this.profiles.set(profile.agentId, profile);
|
|
39
|
+
return profile;
|
|
40
|
+
}
|
|
41
|
+
async delete(agentId) {
|
|
42
|
+
const existed = this.profiles.has(agentId);
|
|
43
|
+
this.profiles.delete(agentId);
|
|
44
|
+
this.history.delete(agentId);
|
|
45
|
+
return existed;
|
|
46
|
+
}
|
|
47
|
+
async query(filter = {}, options = {}) {
|
|
48
|
+
let profiles = Array.from(this.profiles.values());
|
|
49
|
+
// Apply filters
|
|
50
|
+
if (filter.agentIds && filter.agentIds.length > 0) {
|
|
51
|
+
profiles = profiles.filter((p) => filter.agentIds.includes(p.agentId));
|
|
52
|
+
}
|
|
53
|
+
if (filter.minScore !== undefined) {
|
|
54
|
+
profiles = profiles.filter((p) => p.adjustedScore >= filter.minScore);
|
|
55
|
+
}
|
|
56
|
+
if (filter.maxScore !== undefined) {
|
|
57
|
+
profiles = profiles.filter((p) => p.adjustedScore <= filter.maxScore);
|
|
58
|
+
}
|
|
59
|
+
if (filter.bands && filter.bands.length > 0) {
|
|
60
|
+
profiles = profiles.filter((p) => filter.bands.includes(p.band));
|
|
61
|
+
}
|
|
62
|
+
if (filter.calculatedAfter) {
|
|
63
|
+
profiles = profiles.filter((p) => p.calculatedAt >= filter.calculatedAfter);
|
|
64
|
+
}
|
|
65
|
+
if (filter.calculatedBefore) {
|
|
66
|
+
profiles = profiles.filter((p) => p.calculatedAt <= filter.calculatedBefore);
|
|
67
|
+
}
|
|
68
|
+
const total = profiles.length;
|
|
69
|
+
// Apply sorting
|
|
70
|
+
const orderBy = options.orderBy ?? 'calculatedAt';
|
|
71
|
+
const orderDir = options.orderDir ?? 'desc';
|
|
72
|
+
profiles.sort((a, b) => {
|
|
73
|
+
let comparison = 0;
|
|
74
|
+
if (orderBy === 'calculatedAt') {
|
|
75
|
+
comparison = a.calculatedAt.getTime() - b.calculatedAt.getTime();
|
|
76
|
+
}
|
|
77
|
+
else if (orderBy === 'adjustedScore') {
|
|
78
|
+
comparison = a.adjustedScore - b.adjustedScore;
|
|
79
|
+
}
|
|
80
|
+
else if (orderBy === 'agentId') {
|
|
81
|
+
comparison = a.agentId.localeCompare(b.agentId);
|
|
82
|
+
}
|
|
83
|
+
return orderDir === 'asc' ? comparison : -comparison;
|
|
84
|
+
});
|
|
85
|
+
// Apply pagination
|
|
86
|
+
const offset = options.offset ?? 0;
|
|
87
|
+
const limit = options.limit ?? 100;
|
|
88
|
+
profiles = profiles.slice(offset, offset + limit);
|
|
89
|
+
return { profiles, total, offset, limit };
|
|
90
|
+
}
|
|
91
|
+
async getHistory(agentId, limit = 50) {
|
|
92
|
+
const history = this.history.get(agentId) ?? [];
|
|
93
|
+
return history.slice(-limit).reverse(); // Most recent first
|
|
94
|
+
}
|
|
95
|
+
async exists(agentId) {
|
|
96
|
+
return this.profiles.has(agentId);
|
|
97
|
+
}
|
|
98
|
+
async getSummaries(agentIds) {
|
|
99
|
+
const summaries = [];
|
|
100
|
+
for (const agentId of agentIds) {
|
|
101
|
+
const profile = this.profiles.get(agentId);
|
|
102
|
+
if (profile) {
|
|
103
|
+
summaries.push({
|
|
104
|
+
agentId: profile.agentId,
|
|
105
|
+
compositeScore: profile.compositeScore,
|
|
106
|
+
adjustedScore: profile.adjustedScore,
|
|
107
|
+
band: profile.band,
|
|
108
|
+
observationTier: profile.observationTier,
|
|
109
|
+
calculatedAt: profile.calculatedAt,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return summaries;
|
|
114
|
+
}
|
|
115
|
+
async clear() {
|
|
116
|
+
this.profiles.clear();
|
|
117
|
+
this.history.clear();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get count of stored profiles (for testing)
|
|
121
|
+
*/
|
|
122
|
+
get size() {
|
|
123
|
+
return this.profiles.size;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Create a new in-memory profile store
|
|
128
|
+
*/
|
|
129
|
+
export function createInMemoryStore() {
|
|
130
|
+
return new InMemoryProfileStore();
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=profile-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-store.js","sourceRoot":"","sources":["../../src/trust/profile-store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAyGH;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACd,QAAQ,GAA8B,IAAI,GAAG,EAAE,CAAC;IAChD,OAAO,GAAuC,IAAI,GAAG,EAAE,CAAC;IAEzE,KAAK,CAAC,GAAG,CAAC,OAAe;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,SAAiB;QACpC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;gBACpC,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAqB;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEpD,2CAA2C;QAC3C,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC7D,YAAY,CAAC,IAAI,CAAC;gBAChB,OAAO,EAAE,EAAE,GAAG,QAAQ,EAAE;gBACxB,SAAS,EAAE,IAAI,IAAI,EAAE;gBACrB,MAAM,EAAE,iBAAiB;aAC1B,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAClD,CAAC;QAED,IAAI,CAAC,QAAQ,CAA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