@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,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProofPlane Adapter - Implements OrchestratorLogger for ProofPlane
|
|
3
|
+
*
|
|
4
|
+
* This adapter bridges the Orchestrator with Vorion's ProofPlane,
|
|
5
|
+
* logging all orchestration events to the immutable audit trail.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash } from 'crypto';
|
|
8
|
+
/**
|
|
9
|
+
* Hash a result for the audit trail
|
|
10
|
+
*/
|
|
11
|
+
function hashResult(result) {
|
|
12
|
+
const str = JSON.stringify(result ?? null);
|
|
13
|
+
return createHash('sha256').update(str).digest('hex').substring(0, 16);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ProofPlane adapter implementing OrchestratorLogger
|
|
17
|
+
*/
|
|
18
|
+
export class ProofPlaneAdapter {
|
|
19
|
+
proofPlane;
|
|
20
|
+
adapterId;
|
|
21
|
+
logIntentReceivedEnabled;
|
|
22
|
+
logDecisionMadeEnabled;
|
|
23
|
+
logExecutionEventsEnabled;
|
|
24
|
+
constructor(config) {
|
|
25
|
+
this.proofPlane = config.proofPlane;
|
|
26
|
+
this.adapterId = config.adapterId ?? 'a3i-orchestrator';
|
|
27
|
+
this.logIntentReceivedEnabled = config.logIntentReceived ?? true;
|
|
28
|
+
this.logDecisionMadeEnabled = config.logDecisionMade ?? true;
|
|
29
|
+
this.logExecutionEventsEnabled = config.logExecutionEvents ?? true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Log intent received
|
|
33
|
+
*/
|
|
34
|
+
async logIntentReceived(intent, correlationId) {
|
|
35
|
+
if (!this.logIntentReceivedEnabled)
|
|
36
|
+
return;
|
|
37
|
+
await this.proofPlane.logIntentReceived(intent, correlationId);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Log decision made
|
|
41
|
+
*/
|
|
42
|
+
async logDecisionMade(decision, _intent, correlationId) {
|
|
43
|
+
if (!this.logDecisionMadeEnabled)
|
|
44
|
+
return;
|
|
45
|
+
await this.proofPlane.logDecisionMade(decision, correlationId);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Log execution started
|
|
49
|
+
*/
|
|
50
|
+
async logExecutionStarted(executionId, intent, decision, correlationId) {
|
|
51
|
+
if (!this.logExecutionEventsEnabled)
|
|
52
|
+
return;
|
|
53
|
+
await this.proofPlane.logExecutionStarted(executionId, intent.intentId, decision.decisionId, this.adapterId, intent.agentId, correlationId);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Log execution completed
|
|
57
|
+
*/
|
|
58
|
+
async logExecutionCompleted(executionId, intent, result, durationMs, correlationId) {
|
|
59
|
+
if (!this.logExecutionEventsEnabled)
|
|
60
|
+
return;
|
|
61
|
+
await this.proofPlane.logExecutionCompleted(executionId, intent.intentId, durationMs, hashResult(result), intent.agentId, correlationId, 'success');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Log execution failed
|
|
65
|
+
*/
|
|
66
|
+
async logExecutionFailed(executionId, intent, error, durationMs, retryable, correlationId) {
|
|
67
|
+
if (!this.logExecutionEventsEnabled)
|
|
68
|
+
return;
|
|
69
|
+
await this.proofPlane.logExecutionFailed(executionId, intent.intentId, error.message, durationMs, retryable, intent.agentId, correlationId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create a ProofPlane adapter
|
|
74
|
+
*/
|
|
75
|
+
export function createProofPlaneAdapter(config) {
|
|
76
|
+
return new ProofPlaneAdapter(config);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=proof-plane-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof-plane-adapter.js","sourceRoot":"","sources":["../../src/orchestrator/proof-plane-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAuDpC;;GAEG;AACH,SAAS,UAAU,CAAC,MAAe;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;IAC3C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACX,UAAU,CAAsB;IAChC,SAAS,C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ACnB,MAAc,EACd,MAAe,EACf,UAAkB,EAClB,aAAqB;QAErB,IAAI,CAAC,IAAI,CAAC,yBAAyB;YAAE,OAAO;QAC5C,MAAM,IAAI,CAAC,UAAU,CAAC,qBAAqB,CACzC,WAAW,EACX,MAAM,CAAC,QAAQ,EACf,UAAU,EACV,UAAU,CAAC,MAAM,CAAC,EAClB,MAAM,CAAC,OAAO,EACd,aAAa,EACb,SAAS,CACV,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CACtB,WAAmB,EACnB,MAAc,EACd,KAAY,EACZ,UAAkB,EAClB,SAAkB,EAClB,aAAqB;QAErB,IAAI,CAAC,IAAI,CAAC,yBAAyB;YAAE,OAAO;QAC5C,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CACtC,WAAW,EACX,MAAM,CAAC,QAAQ,EACf,KAAK,CAAC,OAAO,EACb,UAAU,EACV,SAAS,EACT,MAAM,CAAC,OAAO,EACd,aAAa,CACd,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAA+B;IAE/B,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Calculator - Core trust scoring engine
|
|
3
|
+
*
|
|
4
|
+
* Calculates composite trust scores from factor scores,
|
|
5
|
+
* applying observation tier ceilings and decay over time.
|
|
6
|
+
*
|
|
7
|
+
* Uses the 16-factor trust model where each factor is scored 0.0-1.0
|
|
8
|
+
* and the composite score is the average of all factor scores x 1000.
|
|
9
|
+
*/
|
|
10
|
+
import type { TrustProfile, TrustFactorScores, TrustEvidence, ObservationTier } from '@vorionsys/contracts';
|
|
11
|
+
/**
|
|
12
|
+
* Options for trust calculation
|
|
13
|
+
*/
|
|
14
|
+
export interface CalculationOptions {
|
|
15
|
+
/** Current time (for decay calculations) */
|
|
16
|
+
now?: Date;
|
|
17
|
+
/** Apply time decay to evidence */
|
|
18
|
+
applyDecay?: boolean;
|
|
19
|
+
/** Decay rate per day (0.0 to 1.0) */
|
|
20
|
+
decayRate?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result of aggregating evidence into factor scores
|
|
24
|
+
*/
|
|
25
|
+
interface EvidenceAggregation {
|
|
26
|
+
factorScores: TrustFactorScores;
|
|
27
|
+
evidenceCount: number;
|
|
28
|
+
latestEvidence: Date | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Calculate a composite trust score from factor scores.
|
|
32
|
+
* Composite = average of all factor scores x 1000.
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateCompositeScore(factorScores: TrustFactorScores): number;
|
|
35
|
+
/**
|
|
36
|
+
* Apply observation tier ceiling to a score
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyObservationCeiling(score: number, tier: ObservationTier): number;
|
|
39
|
+
/**
|
|
40
|
+
* Aggregate evidence into factor scores
|
|
41
|
+
*/
|
|
42
|
+
export declare function aggregateEvidence(evidence: TrustEvidence[], options?: CalculationOptions): EvidenceAggregation;
|
|
43
|
+
/**
|
|
44
|
+
* Calculate a complete trust profile for an agent
|
|
45
|
+
*/
|
|
46
|
+
export declare function calculateTrustProfile(agentId: string, observationTier: ObservationTier, evidence: TrustEvidence[], options?: CalculationOptions): TrustProfile;
|
|
47
|
+
/**
|
|
48
|
+
* Recalculate trust profile with additional evidence
|
|
49
|
+
*/
|
|
50
|
+
export declare function recalculateProfile(existingProfile: TrustProfile, newEvidence: TrustEvidence[], options?: CalculationOptions): TrustProfile;
|
|
51
|
+
/**
|
|
52
|
+
* Apply time decay to a profile without adding new evidence
|
|
53
|
+
*/
|
|
54
|
+
export declare function applyDecay(profile: TrustProfile, options?: CalculationOptions): TrustProfile;
|
|
55
|
+
/**
|
|
56
|
+
* Create evidence for a trust factor
|
|
57
|
+
*/
|
|
58
|
+
export declare function createEvidence(factorCode: string, impact: number, source: string, metadata?: Record<string, unknown>): TrustEvidence;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=calculator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculator.d.ts","sourceRoot":"","sources":["../../src/trust/calculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAiB9B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4CAA4C;IAC5C,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,mBAAmB;IAC3B,YAAY,EAAE,iBAAiB,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;CAC7B;AAoBD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,iBAAiB,GAC9B,MAAM,CAOR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,eAAe,GACpB,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,GAAE,kBAAuB,GAC/B,mBAAmB,CAoDrB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,GAAE,kBAAuB,GAC/B,YAAY,CA4Bd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,aAAa,EAAE,EAC5B,OAAO,GAAE,kBAAuB,GAC/B,YAAY,CAgBd;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,kBAAuB,GAC/B,YAAY,CAUd;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,aAAa,CASf"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Calculator - Core trust scoring engine
|
|
3
|
+
*
|
|
4
|
+
* Calculates composite trust scores from factor scores,
|
|
5
|
+
* applying observation tier ceilings and decay over time.
|
|
6
|
+
*
|
|
7
|
+
* Uses the 16-factor trust model where each factor is scored 0.0-1.0
|
|
8
|
+
* and the composite score is the average of all factor scores x 1000.
|
|
9
|
+
*/
|
|
10
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
11
|
+
import { OBSERVATION_CEILINGS, DEFAULT_BANDING_CONFIG, } from '@vorionsys/contracts';
|
|
12
|
+
import { getBand } from '../banding/bands.js';
|
|
13
|
+
/** Default initial factor score for factors with no evidence (baseline) */
|
|
14
|
+
const INITIAL_FACTOR_SCORE = 0.5;
|
|
15
|
+
/** The 16 core trust factor codes */
|
|
16
|
+
const TRUST_FACTOR_CODES = [
|
|
17
|
+
'CT-COMP', 'CT-REL', 'CT-OBS', 'CT-TRANS', 'CT-ACCT', 'CT-SAFE',
|
|
18
|
+
'CT-SEC', 'CT-PRIV', 'CT-ID', 'OP-HUMAN', 'OP-ALIGN', 'OP-CONTEXT',
|
|
19
|
+
'OP-STEW', 'SF-HUM', 'SF-ADAPT', 'SF-LEARN',
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Create initial factor scores with baseline values for all 16 factors
|
|
23
|
+
*/
|
|
24
|
+
function createInitialFactorScores() {
|
|
25
|
+
const scores = {};
|
|
26
|
+
for (const code of TRUST_FACTOR_CODES) {
|
|
27
|
+
scores[code] = INITIAL_FACTOR_SCORE;
|
|
28
|
+
}
|
|
29
|
+
return scores;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Clamp a factor score to valid range [0.0, 1.0]
|
|
33
|
+
*/
|
|
34
|
+
function clampFactorScore(score) {
|
|
35
|
+
return Math.max(0.0, Math.min(1.0, score));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Calculate a composite trust score from factor scores.
|
|
39
|
+
* Composite = average of all factor scores x 1000.
|
|
40
|
+
*/
|
|
41
|
+
export function calculateCompositeScore(factorScores) {
|
|
42
|
+
const values = Object.values(factorScores);
|
|
43
|
+
if (values.length === 0)
|
|
44
|
+
return 0;
|
|
45
|
+
const average = values.reduce((a, b) => a + b, 0) / values.length;
|
|
46
|
+
// Round to 2 decimal places
|
|
47
|
+
return Math.round(average * 1000 * 100) / 100;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Apply observation tier ceiling to a score
|
|
51
|
+
*/
|
|
52
|
+
export function applyObservationCeiling(score, tier) {
|
|
53
|
+
const ceiling = OBSERVATION_CEILINGS[tier];
|
|
54
|
+
return Math.min(score, ceiling);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Aggregate evidence into factor scores
|
|
58
|
+
*/
|
|
59
|
+
export function aggregateEvidence(evidence, options = {}) {
|
|
60
|
+
const { now = new Date(), applyDecay = true, decayRate = DEFAULT_BANDING_CONFIG.decayRate } = options;
|
|
61
|
+
// Collect impacts per factor code
|
|
62
|
+
const factorImpacts = {};
|
|
63
|
+
let latestEvidence = null;
|
|
64
|
+
for (const ev of evidence) {
|
|
65
|
+
// Skip expired evidence
|
|
66
|
+
if (ev.expiresAt && ev.expiresAt < now) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Calculate decay factor if enabled
|
|
70
|
+
let impact = ev.impact;
|
|
71
|
+
if (applyDecay) {
|
|
72
|
+
const daysSinceCollection = Math.max(0, (now.getTime() - ev.collectedAt.getTime()) / (1000 * 60 * 60 * 24));
|
|
73
|
+
const decayFactor = Math.pow(1 - decayRate, daysSinceCollection);
|
|
74
|
+
impact = ev.impact * decayFactor;
|
|
75
|
+
}
|
|
76
|
+
if (!factorImpacts[ev.factorCode]) {
|
|
77
|
+
factorImpacts[ev.factorCode] = [];
|
|
78
|
+
}
|
|
79
|
+
factorImpacts[ev.factorCode].push(impact);
|
|
80
|
+
if (!latestEvidence || ev.collectedAt > latestEvidence) {
|
|
81
|
+
latestEvidence = ev.collectedAt;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Start with initial factor scores, then apply averaged impacts
|
|
85
|
+
const factorScores = createInitialFactorScores();
|
|
86
|
+
for (const [factorCode, impacts] of Object.entries(factorImpacts)) {
|
|
87
|
+
if (impacts.length > 0) {
|
|
88
|
+
const avgImpact = impacts.reduce((a, b) => a + b, 0) / impacts.length;
|
|
89
|
+
// Impacts are on -1000 to +1000 scale; factor scores are 0.0-1.0
|
|
90
|
+
// Convert impact to factor score delta: impact / 1000
|
|
91
|
+
const baseline = factorScores[factorCode] ?? INITIAL_FACTOR_SCORE;
|
|
92
|
+
factorScores[factorCode] = clampFactorScore(baseline + avgImpact / 1000);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
factorScores,
|
|
97
|
+
evidenceCount: evidence.length,
|
|
98
|
+
latestEvidence,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Calculate a complete trust profile for an agent
|
|
103
|
+
*/
|
|
104
|
+
export function calculateTrustProfile(agentId, observationTier, evidence, options = {}) {
|
|
105
|
+
const now = options.now ?? new Date();
|
|
106
|
+
// Aggregate evidence into factor scores
|
|
107
|
+
const aggregation = aggregateEvidence(evidence, options);
|
|
108
|
+
const factorScores = aggregation.factorScores;
|
|
109
|
+
// Calculate composite score (average of factor scores x 1000)
|
|
110
|
+
const compositeScore = calculateCompositeScore(factorScores);
|
|
111
|
+
// Apply observation ceiling
|
|
112
|
+
const adjustedScore = applyObservationCeiling(compositeScore, observationTier);
|
|
113
|
+
// Determine trust band
|
|
114
|
+
const band = getBand(adjustedScore);
|
|
115
|
+
return {
|
|
116
|
+
profileId: uuidv4(),
|
|
117
|
+
agentId,
|
|
118
|
+
factorScores,
|
|
119
|
+
compositeScore,
|
|
120
|
+
observationTier,
|
|
121
|
+
adjustedScore,
|
|
122
|
+
band,
|
|
123
|
+
calculatedAt: now,
|
|
124
|
+
evidence,
|
|
125
|
+
version: 1,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Recalculate trust profile with additional evidence
|
|
130
|
+
*/
|
|
131
|
+
export function recalculateProfile(existingProfile, newEvidence, options = {}) {
|
|
132
|
+
// Combine existing and new evidence
|
|
133
|
+
const allEvidence = [...existingProfile.evidence, ...newEvidence];
|
|
134
|
+
// Recalculate from scratch
|
|
135
|
+
const newProfile = calculateTrustProfile(existingProfile.agentId, existingProfile.observationTier, allEvidence, options);
|
|
136
|
+
return {
|
|
137
|
+
...newProfile,
|
|
138
|
+
version: existingProfile.version + 1,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Apply time decay to a profile without adding new evidence
|
|
143
|
+
*/
|
|
144
|
+
export function applyDecay(profile, options = {}) {
|
|
145
|
+
return calculateTrustProfile(profile.agentId, profile.observationTier, profile.evidence, {
|
|
146
|
+
...options,
|
|
147
|
+
applyDecay: true,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Create evidence for a trust factor
|
|
152
|
+
*/
|
|
153
|
+
export function createEvidence(factorCode, impact, source, metadata) {
|
|
154
|
+
return {
|
|
155
|
+
evidenceId: uuidv4(),
|
|
156
|
+
factorCode,
|
|
157
|
+
impact: Math.max(-1000, Math.min(1000, impact)),
|
|
158
|
+
source,
|
|
159
|
+
collectedAt: new Date(),
|
|
160
|
+
metadata,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=calculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculator.js","sourceRoot":"","sources":["../../src/trust/calculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAOpC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,2EAA2E;AAC3E,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,qCAAqC;AACrC,MAAM,kBAAkB,GAAG;IACzB,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS;IAC/D,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY;IAClE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU;CACnC,CAAC;AAuBX;;GAEG;AACH,SAAS,yBAAyB;IAChC,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,kBAAkB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC;IACtC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAA+B;IAE/B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC3C,IAAI,MAAM,CAAC,MAAM,KA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C1B,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,eAAe,EACvB,OAAO,CAAC,QAAQ,EAChB;QACE,GAAG,OAAO;QACV,UAAU,EAAE,IAAI;KACjB,CACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAkB,EAClB,MAAc,EACd,MAAc,EACd,QAAkC;IAElC,OAAO;QACL,UAAU,EAAE,MAAM,EAAE;QACpB,UAAU;QACV,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC/C,MAAM;QACN,WAAW,EAAE,IAAI,IAAI,EAAE;QACvB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Factor Scores - The 16-factor trust model
|
|
3
|
+
*
|
|
4
|
+
* Replaces the legacy 5-dimension model (CT, BT, GT, XT, AC) with
|
|
5
|
+
* 16 granular trust factors scored 0.0-1.0.
|
|
6
|
+
*
|
|
7
|
+
* Factor codes:
|
|
8
|
+
* CT-COMP, CT-REL, CT-OBS, CT-TRANS, CT-ACCT, CT-SAFE,
|
|
9
|
+
* CT-SEC, CT-PRIV, CT-ID, OP-HUMAN, OP-ALIGN, OP-CONTEXT,
|
|
10
|
+
* OP-STEW, SF-HUM, SF-ADAPT, SF-LEARN
|
|
11
|
+
*
|
|
12
|
+
* Composite score = average of all factor scores * 1000 (0-1000 scale)
|
|
13
|
+
*/
|
|
14
|
+
import type { TrustFactorScores } from '@vorionsys/contracts';
|
|
15
|
+
/** The 16 core trust factor codes */
|
|
16
|
+
export declare const TRUST_FACTOR_CODES: readonly ["CT-COMP", "CT-REL", "CT-OBS", "CT-TRANS", "CT-ACCT", "CT-SAFE", "CT-SEC", "CT-PRIV", "CT-ID", "OP-HUMAN", "OP-ALIGN", "OP-CONTEXT", "OP-STEW", "SF-HUM", "SF-ADAPT", "SF-LEARN"];
|
|
17
|
+
/** Initial factor scores for a new agent (neutral starting point, all 0.3) */
|
|
18
|
+
export declare const INITIAL_FACTOR_SCORES: TrustFactorScores;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use INITIAL_FACTOR_SCORES instead.
|
|
21
|
+
* Provided for backwards compatibility with code that imports INITIAL_DIMENSIONS.
|
|
22
|
+
*/
|
|
23
|
+
export declare const INITIAL_DIMENSIONS: TrustFactorScores;
|
|
24
|
+
/** Minimum valid factor score */
|
|
25
|
+
export declare const MIN_FACTOR_SCORE = 0;
|
|
26
|
+
/** Maximum valid factor score */
|
|
27
|
+
export declare const MAX_FACTOR_SCORE = 1;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use MIN_FACTOR_SCORE instead.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MIN_DIMENSION_SCORE = 0;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use MAX_FACTOR_SCORE instead.
|
|
34
|
+
*/
|
|
35
|
+
export declare const MAX_DIMENSION_SCORE = 1;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new TrustFactorScores object with validation.
|
|
38
|
+
* Merges provided scores with initial defaults and clamps all values to [0.0, 1.0].
|
|
39
|
+
*/
|
|
40
|
+
export declare function createFactorScores(partial?: TrustFactorScores): TrustFactorScores;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use createFactorScores instead.
|
|
43
|
+
* Provided for backwards compatibility with code that imports createDimensions.
|
|
44
|
+
*/
|
|
45
|
+
export declare const createDimensions: typeof createFactorScores;
|
|
46
|
+
/**
|
|
47
|
+
* Clamp a factor score to valid range [0.0, 1.0]
|
|
48
|
+
*/
|
|
49
|
+
export declare function clampScore(score: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Validate trust factor scores using Zod schema
|
|
52
|
+
* @throws if validation fails
|
|
53
|
+
*/
|
|
54
|
+
export declare function validateFactorScores(scores: unknown): TrustFactorScores;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Use validateFactorScores instead.
|
|
57
|
+
*/
|
|
58
|
+
export declare const validateDimensions: typeof validateFactorScores;
|
|
59
|
+
/**
|
|
60
|
+
* Check if factor scores are valid without throwing
|
|
61
|
+
*/
|
|
62
|
+
export declare function isValidFactorScores(scores: unknown): scores is TrustFactorScores;
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated Use isValidFactorScores instead.
|
|
65
|
+
*/
|
|
66
|
+
export declare const isValidDimensions: typeof isValidFactorScores;
|
|
67
|
+
/**
|
|
68
|
+
* Get the minimum factor score (weakest link)
|
|
69
|
+
*/
|
|
70
|
+
export declare function getMinFactor(scores: TrustFactorScores): {
|
|
71
|
+
factor: string;
|
|
72
|
+
score: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Use getMinFactor instead.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getMinDimension(scores: TrustFactorScores): {
|
|
78
|
+
dimension: string;
|
|
79
|
+
score: number;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Get the maximum factor score (strongest area)
|
|
83
|
+
*/
|
|
84
|
+
export declare function getMaxFactor(scores: TrustFactorScores): {
|
|
85
|
+
factor: string;
|
|
86
|
+
score: number;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use getMaxFactor instead.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getMaxDimension(scores: TrustFactorScores): {
|
|
92
|
+
dimension: string;
|
|
93
|
+
score: number;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Calculate factor score delta between two profiles
|
|
97
|
+
*/
|
|
98
|
+
export declare function getFactorDelta(previous: TrustFactorScores, current: TrustFactorScores): TrustFactorScores;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use getFactorDelta instead.
|
|
101
|
+
*/
|
|
102
|
+
export declare const getDimensionDelta: typeof getFactorDelta;
|
|
103
|
+
/**
|
|
104
|
+
* Apply adjustments to factor scores
|
|
105
|
+
*/
|
|
106
|
+
export declare function adjustFactorScores(scores: TrustFactorScores, adjustments: Partial<TrustFactorScores>): TrustFactorScores;
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated Use adjustFactorScores instead.
|
|
109
|
+
*/
|
|
110
|
+
export declare const adjustDimensions: typeof adjustFactorScores;
|
|
111
|
+
/**
|
|
112
|
+
* Compute composite trust score from factor scores.
|
|
113
|
+
* Composite = average of all factor scores * 1000 (0-1000 scale).
|
|
114
|
+
*/
|
|
115
|
+
export declare function computeCompositeScore(scores: TrustFactorScores): number;
|
|
116
|
+
/**
|
|
117
|
+
* Factor descriptions for documentation/UI
|
|
118
|
+
*/
|
|
119
|
+
export declare const FACTOR_DESCRIPTIONS: Record<string, {
|
|
120
|
+
name: string;
|
|
121
|
+
code: string;
|
|
122
|
+
description: string;
|
|
123
|
+
}>;
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated Use FACTOR_DESCRIPTIONS instead.
|
|
126
|
+
* Legacy alias for backwards compatibility.
|
|
127
|
+
*/
|
|
128
|
+
export declare const DIMENSION_DESCRIPTIONS: Record<string, {
|
|
129
|
+
name: string;
|
|
130
|
+
code: string;
|
|
131
|
+
description: string;
|
|
132
|
+
}>;
|
|
133
|
+
//# sourceMappingURL=dimensions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimensions.d.ts","sourceRoot":"","sources":["../../src/trust/dimensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,qCAAqC;AACrC,eAAO,MAAM,kBAAkB,6LAIrB,CAAC;AAEX,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,EAAE,iBAEnC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,iBAAyC,CAAC;AAE3E,iCAAiC;AACjC,eAAO,MAAM,gBAAgB,IAAM,CAAC;AAEpC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