@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,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook System Types - Type definitions for the hook system
|
|
3
|
+
*
|
|
4
|
+
* Hooks allow extensibility at key points in the authorization
|
|
5
|
+
* and execution lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
import type { Intent, Decision, TrustProfile, ProofEvent } from '@vorionsys/contracts';
|
|
8
|
+
/**
|
|
9
|
+
* Hook lifecycle phases
|
|
10
|
+
*/
|
|
11
|
+
export declare enum HookPhase {
|
|
12
|
+
/** Before authorization decision */
|
|
13
|
+
PRE_AUTHORIZE = "pre-authorize",
|
|
14
|
+
/** After authorization decision */
|
|
15
|
+
POST_AUTHORIZE = "post-authorize",
|
|
16
|
+
/** Before action execution */
|
|
17
|
+
PRE_EXECUTE = "pre-execute",
|
|
18
|
+
/** After successful execution */
|
|
19
|
+
POST_EXECUTE = "post-execute",
|
|
20
|
+
/** After failed execution */
|
|
21
|
+
EXECUTION_FAILED = "execution-failed",
|
|
22
|
+
/** When trust score changes */
|
|
23
|
+
TRUST_CHANGE = "trust-change",
|
|
24
|
+
/** When a trust violation occurs */
|
|
25
|
+
TRUST_VIOLATION = "trust-violation",
|
|
26
|
+
/** When a proof event is emitted */
|
|
27
|
+
EVENT_EMITTED = "event-emitted"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Hook execution priority
|
|
31
|
+
* Lower numbers execute first
|
|
32
|
+
*/
|
|
33
|
+
export declare enum HookPriority {
|
|
34
|
+
CRITICAL = 0,
|
|
35
|
+
HIGH = 100,
|
|
36
|
+
NORMAL = 500,
|
|
37
|
+
LOW = 900,
|
|
38
|
+
MONITOR = 1000
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Result of hook execution
|
|
42
|
+
*/
|
|
43
|
+
export interface HookResult {
|
|
44
|
+
/** Whether the hook succeeded */
|
|
45
|
+
success: boolean;
|
|
46
|
+
/** Whether to abort the operation (for pre- hooks) */
|
|
47
|
+
abort?: boolean;
|
|
48
|
+
/** Reason for abort */
|
|
49
|
+
abortReason?: string;
|
|
50
|
+
/** Modified data (if applicable) */
|
|
51
|
+
modified?: unknown;
|
|
52
|
+
/** Error if hook failed */
|
|
53
|
+
error?: Error;
|
|
54
|
+
/** Execution time in ms */
|
|
55
|
+
durationMs: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Context passed to all hooks
|
|
59
|
+
*/
|
|
60
|
+
export interface HookContext {
|
|
61
|
+
/** Unique ID for this hook execution chain */
|
|
62
|
+
executionId: string;
|
|
63
|
+
/** Correlation ID for tracing */
|
|
64
|
+
correlationId: string;
|
|
65
|
+
/** Timestamp when the hook chain started */
|
|
66
|
+
startedAt: Date;
|
|
67
|
+
/** Custom metadata */
|
|
68
|
+
metadata: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Context for pre-authorize hooks
|
|
72
|
+
*/
|
|
73
|
+
export interface PreAuthorizeContext extends HookContext {
|
|
74
|
+
/** The intent being authorized */
|
|
75
|
+
intent: Intent;
|
|
76
|
+
/** Agent's trust profile (if available) */
|
|
77
|
+
profile?: TrustProfile;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Context for post-authorize hooks
|
|
81
|
+
*/
|
|
82
|
+
export interface PostAuthorizeContext extends HookContext {
|
|
83
|
+
/** The original intent */
|
|
84
|
+
intent: Intent;
|
|
85
|
+
/** The authorization decision */
|
|
86
|
+
decision: Decision;
|
|
87
|
+
/** Agent's trust profile */
|
|
88
|
+
profile: TrustProfile;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Context for pre-execute hooks
|
|
92
|
+
*/
|
|
93
|
+
export interface PreExecuteContext extends HookContext {
|
|
94
|
+
/** The authorization decision */
|
|
95
|
+
decision: Decision;
|
|
96
|
+
/** The original intent */
|
|
97
|
+
intent: Intent;
|
|
98
|
+
/** Agent's trust profile */
|
|
99
|
+
profile: TrustProfile;
|
|
100
|
+
/** Execution parameters */
|
|
101
|
+
params?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Context for post-execute hooks
|
|
105
|
+
*/
|
|
106
|
+
export interface PostExecuteContext extends HookContext {
|
|
107
|
+
/** The authorization decision */
|
|
108
|
+
decision: Decision;
|
|
109
|
+
/** The original intent */
|
|
110
|
+
intent: Intent;
|
|
111
|
+
/** Execution result */
|
|
112
|
+
result: unknown;
|
|
113
|
+
/** Execution duration in ms */
|
|
114
|
+
durationMs: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Context for execution-failed hooks
|
|
118
|
+
*/
|
|
119
|
+
export interface ExecutionFailedContext extends HookContext {
|
|
120
|
+
/** The authorization decision */
|
|
121
|
+
decision: Decision;
|
|
122
|
+
/** The original intent */
|
|
123
|
+
intent: Intent;
|
|
124
|
+
/** The error that occurred */
|
|
125
|
+
error: Error;
|
|
126
|
+
/** Execution duration before failure in ms */
|
|
127
|
+
durationMs: number;
|
|
128
|
+
/** Whether the operation can be retried */
|
|
129
|
+
retryable: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Context for trust-change hooks
|
|
133
|
+
*/
|
|
134
|
+
export interface TrustChangeContext extends HookContext {
|
|
135
|
+
/** Agent ID */
|
|
136
|
+
agentId: string;
|
|
137
|
+
/** Previous trust profile */
|
|
138
|
+
previousProfile: TrustProfile;
|
|
139
|
+
/** New trust profile */
|
|
140
|
+
newProfile: TrustProfile;
|
|
141
|
+
/** Reason for the change */
|
|
142
|
+
reason: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Context for trust-violation hooks
|
|
146
|
+
*/
|
|
147
|
+
export interface TrustViolationContext extends HookContext {
|
|
148
|
+
/** Agent ID */
|
|
149
|
+
agentId: string;
|
|
150
|
+
/** Current trust profile */
|
|
151
|
+
profile: TrustProfile;
|
|
152
|
+
/** Type of violation */
|
|
153
|
+
violationType: string;
|
|
154
|
+
/** Violation details */
|
|
155
|
+
details: Record<string, unknown>;
|
|
156
|
+
/** Severity level */
|
|
157
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Context for event-emitted hooks
|
|
161
|
+
*/
|
|
162
|
+
export interface EventEmittedContext extends HookContext {
|
|
163
|
+
/** The emitted proof event */
|
|
164
|
+
event: ProofEvent;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Union type for all hook contexts
|
|
168
|
+
*/
|
|
169
|
+
export type AnyHookContext = PreAuthorizeContext | PostAuthorizeContext | PreExecuteContext | PostExecuteContext | ExecutionFailedContext | TrustChangeContext | TrustViolationContext | EventEmittedContext;
|
|
170
|
+
/**
|
|
171
|
+
* Hook handler function signature
|
|
172
|
+
*/
|
|
173
|
+
export type HookHandler<T extends AnyHookContext = AnyHookContext> = (context: T) => HookResult | Promise<HookResult>;
|
|
174
|
+
/**
|
|
175
|
+
* Hook definition
|
|
176
|
+
*/
|
|
177
|
+
export interface HookDefinition<T extends AnyHookContext = AnyHookContext> {
|
|
178
|
+
/** Unique hook ID */
|
|
179
|
+
id: string;
|
|
180
|
+
/** Hook name for display */
|
|
181
|
+
name: string;
|
|
182
|
+
/** Hook phase */
|
|
183
|
+
phase: HookPhase;
|
|
184
|
+
/** Execution priority */
|
|
185
|
+
priority: HookPriority;
|
|
186
|
+
/** The hook handler function */
|
|
187
|
+
handler: HookHandler<T>;
|
|
188
|
+
/** Whether the hook is enabled */
|
|
189
|
+
enabled: boolean;
|
|
190
|
+
/** Timeout in ms (default: 5000) */
|
|
191
|
+
timeoutMs?: number;
|
|
192
|
+
/** Whether to continue on error */
|
|
193
|
+
continueOnError?: boolean;
|
|
194
|
+
/** Optional filter function */
|
|
195
|
+
filter?: (context: T) => boolean;
|
|
196
|
+
/** Hook metadata */
|
|
197
|
+
metadata?: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Summary of hook execution
|
|
201
|
+
*/
|
|
202
|
+
export interface HookExecutionSummary {
|
|
203
|
+
/** Hook phase */
|
|
204
|
+
phase: HookPhase;
|
|
205
|
+
/** Number of hooks executed */
|
|
206
|
+
hooksExecuted: number;
|
|
207
|
+
/** Number of hooks that succeeded */
|
|
208
|
+
succeeded: number;
|
|
209
|
+
/** Number of hooks that failed */
|
|
210
|
+
failed: number;
|
|
211
|
+
/** Number of hooks that were skipped */
|
|
212
|
+
skipped: number;
|
|
213
|
+
/** Whether any hook requested abort */
|
|
214
|
+
aborted: boolean;
|
|
215
|
+
/** Abort reason (if aborted) */
|
|
216
|
+
abortReason?: string;
|
|
217
|
+
/** Total execution time in ms */
|
|
218
|
+
totalDurationMs: number;
|
|
219
|
+
/** Individual hook results */
|
|
220
|
+
results: Array<{
|
|
221
|
+
hookId: string;
|
|
222
|
+
hookName: string;
|
|
223
|
+
result: HookResult;
|
|
224
|
+
}>;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hooks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,oBAAY,SAAS;IACnB,oCAAoC;IACpC,aAAa,kBAAkB;IAC/B,mCAAmC;IACnC,cAAc,mBAAmB;IACjC,8BAA8B;IAC9B,WAAW,gBAAgB;IAC3B,iCAAiC;IACjC,YAAY,iBAAiB;IAC7B,6BAA6B;IAC7B,gBAAgB,qBAAqB;IACrC,+BAA+B;IAC/B,YAAY,iBAAiB;IAC7B,oCAAoC;IACpC,eAAe,oBAAoB;IACnC,oCAAoC;IACpC,aAAa,kBAAkB;CAChC;AAED;;;GAGG;AACH,oBAAY,YAAY;IACtB,QAAQ,IAAI;IACZ,IAAI,MAAM;IACV,MAAM,MAAM;IACZ,GAAG,MAAM;IACT,OAAO,OAAO;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,sDAAsD;IACtD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2BAA2B;IAC3B,KAAK,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
2
|
+
* Hook System Types - Type definitions for the hook system
|
|
3
|
+
*
|
|
4
|
+
* Hooks allow extensibility at key points in the authorization
|
|
5
|
+
* and execution lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Hook lifecycle phases
|
|
9
|
+
*/
|
|
10
|
+
export var HookPhase;
|
|
11
|
+
(function (HookPhase) {
|
|
12
|
+
/** Before authorization decision */
|
|
13
|
+
HookPhase["PRE_AUTHORIZE"] = "pre-authorize";
|
|
14
|
+
/** After authorization decision */
|
|
15
|
+
HookPhase["POST_AUTHORIZE"] = "post-authorize";
|
|
16
|
+
/** Before action execution */
|
|
17
|
+
HookPhase["PRE_EXECUTE"] = "pre-execute";
|
|
18
|
+
/** After successful execution */
|
|
19
|
+
HookPhase["POST_EXECUTE"] = "post-execute";
|
|
20
|
+
/** After failed execution */
|
|
21
|
+
HookPhase["EXECUTION_FAILED"] = "execution-failed";
|
|
22
|
+
/** When trust score changes */
|
|
23
|
+
HookPhase["TRUST_CHANGE"] = "trust-change";
|
|
24
|
+
/** When a trust violation occurs */
|
|
25
|
+
HookPhase["TRUST_VIOLATION"] = "trust-violation";
|
|
26
|
+
/** When a proof event is emitted */
|
|
27
|
+
HookPhase["EVENT_EMITTED"] = "event-emitted";
|
|
28
|
+
})(HookPhase || (HookPhase = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Hook execution priority
|
|
31
|
+
* Lower numbers execute first
|
|
32
|
+
*/
|
|
33
|
+
export var HookPriority;
|
|
34
|
+
(function (HookPriority) {
|
|
35
|
+
HookPriority[HookPriority["CRITICAL"] = 0] = "CRITICAL";
|
|
36
|
+
HookPriority[HookPriority["HIGH"] = 100] = "HIGH";
|
|
37
|
+
HookPriority[HookPriority["NORMAL"] = 500] = "NORMAL";
|
|
38
|
+
HookPriority[HookPriority["LOW"] = 900] = "LOW";
|
|
39
|
+
HookPriority[HookPriority["MONITOR"] = 1000] = "MONITOR";
|
|
40
|
+
})(HookPriority || (HookPriority = {}));
|
|
41
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/hooks/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,MAAM,CAAN,IAAY,SAiBX;AAjBD,WAAY,SAAS;IACnB,oCAAoC;IACpC,4CAA+B,CAAA;IAC/B,mCAAmC;IACnC,8CAAiC,CAAA;IACjC,8BAA8B;IAC9B,wCAA2B,CAAA;IAC3B,iCAAiC;IACjC,0CAA6B,CAAA;IAC7B,6BAA6B;IAC7B,kDAAqC,CAAA;IACrC,+BAA+B;IAC/B,0CAA6B,CAAA;IAC7B,oCAAoC;IACpC,gDAAmC,CAAA;IACnC,oCAAoC;IACpC,4CAA+B,CAAA;AACjC,CAAC,EAjBW,SAAS,KAAT,SAAS,QAiBpB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,iDAAU,CAAA;IACV,qDAAY,CAAA;IACZ,+CAAS,CAAA;IACT,wDAAc,CAAA;AAChB,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vorion/a3i - Agent Anchor AI Trust Engine
|
|
3
|
+
*
|
|
4
|
+
* The A3I package provides trust scoring, banding, and authorization
|
|
5
|
+
* for AI agents within the Vorion platform.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export * from './trust/index.js';
|
|
10
|
+
export * from './banding/index.js';
|
|
11
|
+
export * from './observation/index.js';
|
|
12
|
+
export * from './authorization/index.js';
|
|
13
|
+
export * from './api/index.js';
|
|
14
|
+
export * from './hooks/index.js';
|
|
15
|
+
export * from './execution/index.js';
|
|
16
|
+
export * from './orchestrator/index.js';
|
|
17
|
+
export * from './canary/index.js';
|
|
18
|
+
export * from './gate/index.js';
|
|
19
|
+
export declare const VERSION = "0.1.0";
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,iBAAiB,CAAC;AAGhC,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vorion/a3i - Agent Anchor AI Trust Engine
|
|
3
|
+
*
|
|
4
|
+
* The A3I package provides trust scoring, banding, and authorization
|
|
5
|
+
* for AI agents within the Vorion platform.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
// Trust module
|
|
10
|
+
export * from './trust/index.js';
|
|
11
|
+
// Banding module
|
|
12
|
+
export * from './banding/index.js';
|
|
13
|
+
// Observation module
|
|
14
|
+
export * from './observation/index.js';
|
|
15
|
+
// Authorization module
|
|
16
|
+
export * from './authorization/index.js';
|
|
17
|
+
// API module
|
|
18
|
+
export * from './api/index.js';
|
|
19
|
+
// Hooks module
|
|
20
|
+
export * from './hooks/index.js';
|
|
21
|
+
// Execution module
|
|
22
|
+
export * from './execution/index.js';
|
|
23
|
+
// Orchestrator module
|
|
24
|
+
export * from './orchestrator/index.js';
|
|
25
|
+
// Canary Probe module (ATSF v2.0)
|
|
26
|
+
export * from './canary/index.js';
|
|
27
|
+
// Pre-Action Gate module (ATSF v2.0)
|
|
28
|
+
export * from './gate/index.js';
|
|
29
|
+
// Version
|
|
30
|
+
export const VERSION = '0.1.0';
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAe;AACf,cAAc,kBAAkB,CAAC;AAEjC,iBAAiB;AACjB,cAAc,oBAAoB,CAAC;AAEnC,qBAAqB;AACrB,cAAc,wBAAwB,CAAC;AAEvC,uBAAuB;AACvB,cAAc,0BAA0B,CAAC;AAEzC,aAAa;AACb,cAAc,gBAAgB,CAAC;AAE/B,eAAe;AACf,cAAc,kBAAkB,CAAC;AAEjC,mBAAmB;AACnB,cAAc,sBAAsB,CAAC;AAErC,sBAAsB;AACtB,cAAc,yBAAyB,CAAC;AAExC,kCAAkC;AAClC,cAAc,mBAAmB,CAAC;AAElC,qCAAqC;AACrC,cAAc,iBAAiB,CAAC;AAEhC,UAAU;AACV,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attestation - Cryptographic proof of agent integrity
|
|
3
|
+
*
|
|
4
|
+
* For ATTESTED_BOX tier, we need hardware-backed proofs
|
|
5
|
+
* that the agent code and configuration match expected values.
|
|
6
|
+
*/
|
|
7
|
+
import { ObservationTier } from '@vorionsys/contracts';
|
|
8
|
+
/**
|
|
9
|
+
* Types of cryptographic attestation
|
|
10
|
+
*/
|
|
11
|
+
export declare enum AttestationType {
|
|
12
|
+
/** No attestation */
|
|
13
|
+
NONE = "none",
|
|
14
|
+
/** Software-only hash verification */
|
|
15
|
+
SOFTWARE_HASH = "software_hash",
|
|
16
|
+
/** TPM-backed attestation */
|
|
17
|
+
TPM_QUOTE = "tpm_quote",
|
|
18
|
+
/** Intel SGX enclave quote */
|
|
19
|
+
SGX_QUOTE = "sgx_quote",
|
|
20
|
+
/** AMD SEV-SNP report */
|
|
21
|
+
SEV_SNP_REPORT = "sev_snp",
|
|
22
|
+
/** Intel TDX quote */
|
|
23
|
+
TDX_QUOTE = "tdx_quote",
|
|
24
|
+
/** NVIDIA Confidential Computing (H100) */
|
|
25
|
+
NVIDIA_CC = "nvidia_cc"
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hardware attestation types
|
|
29
|
+
*/
|
|
30
|
+
export declare const HARDWARE_ATTESTATION_TYPES: Set<AttestationType>;
|
|
31
|
+
/**
|
|
32
|
+
* Map attestation type to observation tier
|
|
33
|
+
*/
|
|
34
|
+
export declare function getObservationTierForAttestation(type: AttestationType): ObservationTier;
|
|
35
|
+
/**
|
|
36
|
+
* Attestation evidence
|
|
37
|
+
*/
|
|
38
|
+
export interface AttestationEvidence {
|
|
39
|
+
/** Unique attestation ID */
|
|
40
|
+
attestationId: string;
|
|
41
|
+
/** Type of attestation */
|
|
42
|
+
attestationType: AttestationType;
|
|
43
|
+
/** When attestation was created */
|
|
44
|
+
timestamp: Date;
|
|
45
|
+
/** SHA-256 hash of orchestration code */
|
|
46
|
+
codeHash: string;
|
|
47
|
+
/** SHA-256 hash of model weights (if accessible) */
|
|
48
|
+
weightsHash?: string;
|
|
49
|
+
/** SHA-256 hash of configuration */
|
|
50
|
+
configHash: string;
|
|
51
|
+
/** Raw attestation quote from TEE */
|
|
52
|
+
platformQuote?: string;
|
|
53
|
+
/** PCR/RTMR measurement values */
|
|
54
|
+
measurementRegisters?: Record<string, string>;
|
|
55
|
+
/** Certificate chain for verification */
|
|
56
|
+
certificateChain: string[];
|
|
57
|
+
/** Who verified this attestation */
|
|
58
|
+
verifiedBy?: string;
|
|
59
|
+
/** When verification occurred */
|
|
60
|
+
verificationTimestamp?: Date;
|
|
61
|
+
/** Expected hash of code */
|
|
62
|
+
goldenImageHash?: string;
|
|
63
|
+
/** Does current hash match golden image? */
|
|
64
|
+
matchesGoldenImage?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Verification result
|
|
68
|
+
*/
|
|
69
|
+
export interface AttestationVerificationResult {
|
|
70
|
+
/** Is the attestation valid? */
|
|
71
|
+
valid: boolean;
|
|
72
|
+
/** Is it hardware-backed? */
|
|
73
|
+
hardwareBacked: boolean;
|
|
74
|
+
/** Does it match the golden image? */
|
|
75
|
+
matchesGoldenImage: boolean;
|
|
76
|
+
/** Resulting observation tier */
|
|
77
|
+
observationTier: ObservationTier;
|
|
78
|
+
/** Any issues found */
|
|
79
|
+
issues: string[];
|
|
80
|
+
/** Verification timestamp */
|
|
81
|
+
verifiedAt: Date;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create attestation evidence
|
|
85
|
+
*/
|
|
86
|
+
export declare function createAttestationEvidence(options: Omit<AttestationEvidence, 'attestationId' | 'timestamp'>): AttestationEvidence;
|
|
87
|
+
/**
|
|
88
|
+
* Check if attestation is hardware-backed
|
|
89
|
+
*/
|
|
90
|
+
export declare function isHardwareBacked(attestation: AttestationEvidence): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Verify attestation evidence
|
|
93
|
+
*
|
|
94
|
+
* Note: This is a simplified verification. Real implementation
|
|
95
|
+
* would verify cryptographic signatures against TEE manufacturer roots.
|
|
96
|
+
*/
|
|
97
|
+
export declare function verifyAttestation(attestation: AttestationEvidence): AttestationVerificationResult;
|
|
98
|
+
/**
|
|
99
|
+
* Compute SHA-256 hash (placeholder - would use crypto in real impl)
|
|
100
|
+
*/
|
|
101
|
+
export declare function computeHash(data: string): string;
|
|
102
|
+
//# sourceMappingURL=attestation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../../src/observation/attestation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,oBAAY,eAAe;IACzB,qBAAqB;IAC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B,EAAE,OAAO,CAAC;IAC5B,iCAAiC;IACjC,eAAe,EAAE,eAAe,CAAC;IACjC,uBAAuB;IACvB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6BAA6B;IAC7B,UAAU,EAAE,IAAI,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,GAAG,WAAW,CAAC,GAChE,mBAAmB,CAMrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,mBAAmB,GAC/B,6BAA6B,CA8C/B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUhD"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attestation - Cryptographic proof of agent integrity
|
|
3
|
+
*
|
|
4
|
+
* For ATTESTED_BOX tier, we need hardware-backed proofs
|
|
5
|
+
* that the agent code and configuration match expected values.
|
|
6
|
+
*/
|
|
7
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
+
import { ObservationTier } from '@vorionsys/contracts';
|
|
9
|
+
/**
|
|
10
|
+
* Types of cryptographic attestation
|
|
11
|
+
*/
|
|
12
|
+
export var AttestationType;
|
|
13
|
+
(function (AttestationType) {
|
|
14
|
+
/** No attestation */
|
|
15
|
+
AttestationType["NONE"] = "none";
|
|
16
|
+
/** Software-only hash verification */
|
|
17
|
+
AttestationType["SOFTWARE_HASH"] = "software_hash";
|
|
18
|
+
/** TPM-backed attestation */
|
|
19
|
+
AttestationType["TPM_QUOTE"] = "tpm_quote";
|
|
20
|
+
/** Intel SGX enclave quote */
|
|
21
|
+
AttestationType["SGX_QUOTE"] = "sgx_quote";
|
|
22
|
+
/** AMD SEV-SNP report */
|
|
23
|
+
AttestationType["SEV_SNP_REPORT"] = "sev_snp";
|
|
24
|
+
/** Intel TDX quote */
|
|
25
|
+
AttestationType["TDX_QUOTE"] = "tdx_quote";
|
|
26
|
+
/** NVIDIA Confidential Computing (H100) */
|
|
27
|
+
AttestationType["NVIDIA_CC"] = "nvidia_cc";
|
|
28
|
+
})(AttestationType || (AttestationType = {}));
|
|
29
|
+
/**
|
|
30
|
+
* Hardware attestation types
|
|
31
|
+
*/
|
|
32
|
+
export const HARDWARE_ATTESTATION_TYPES = new Set([
|
|
33
|
+
AttestationType.TPM_QUOTE,
|
|
34
|
+
AttestationType.SGX_QUOTE,
|
|
35
|
+
AttestationType.SEV_SNP_REPORT,
|
|
36
|
+
AttestationType.TDX_QUOTE,
|
|
37
|
+
AttestationType.NVIDIA_CC,
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* Map attestation type to observation tier
|
|
41
|
+
*/
|
|
42
|
+
export function getObservationTierForAttestation(type) {
|
|
43
|
+
if (HARDWARE_ATTESTATION_TYPES.has(type)) {
|
|
44
|
+
return ObservationTier.ATTESTED_BOX;
|
|
45
|
+
}
|
|
46
|
+
if (type === AttestationType.SOFTWARE_HASH) {
|
|
47
|
+
return ObservationTier.WHITE_BOX;
|
|
48
|
+
}
|
|
49
|
+
return ObservationTier.BLACK_BOX;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create attestation evidence
|
|
53
|
+
*/
|
|
54
|
+
export function createAttestationEvidence(options) {
|
|
55
|
+
return {
|
|
56
|
+
attestationId: uuidv4(),
|
|
57
|
+
timestamp: new Date(),
|
|
58
|
+
...options,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if attestation is hardware-backed
|
|
63
|
+
*/
|
|
64
|
+
export function isHardwareBacked(attestation) {
|
|
65
|
+
return HARDWARE_ATTESTATION_TYPES.has(attestation.attestationType);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Verify attestation evidence
|
|
69
|
+
*
|
|
70
|
+
* Note: This is a simplified verification. Real implementation
|
|
71
|
+
* would verify cryptographic signatures against TEE manufacturer roots.
|
|
72
|
+
*/
|
|
73
|
+
export function verifyAttestation(attestation) {
|
|
74
|
+
const issues = [];
|
|
75
|
+
// Check attestation type
|
|
76
|
+
const hardwareBacked = isHardwareBacked(attestation);
|
|
77
|
+
if (!hardwareBacked && attestation.attestationType !== AttestationType.SOFTWARE_HASH) {
|
|
78
|
+
issues.push('No valid attestation type');
|
|
79
|
+
}
|
|
80
|
+
// Check required hashes
|
|
81
|
+
if (!attestation.codeHash) {
|
|
82
|
+
issues.push('Missing code hash');
|
|
83
|
+
}
|
|
84
|
+
if (!attestation.configHash) {
|
|
85
|
+
issues.push('Missing config hash');
|
|
86
|
+
}
|
|
87
|
+
// Check hardware-specific requirements
|
|
88
|
+
if (hardwareBacked && !attestation.platformQuote) {
|
|
89
|
+
issues.push('Hardware attestation requires platform quote');
|
|
90
|
+
}
|
|
91
|
+
// Check golden image
|
|
92
|
+
const matchesGoldenImage = attestation.matchesGoldenImage ?? false;
|
|
93
|
+
if (attestation.goldenImageHash && !matchesGoldenImage) {
|
|
94
|
+
issues.push('Code hash does not match golden image');
|
|
95
|
+
}
|
|
96
|
+
// Check certificate chain
|
|
97
|
+
if (hardwareBacked && attestation.certificateChain.length === 0) {
|
|
98
|
+
issues.push('Hardware attestation requires certificate chain');
|
|
99
|
+
}
|
|
100
|
+
const valid = issues.length === 0;
|
|
101
|
+
const observationTier = valid
|
|
102
|
+
? getObservationTierForAttestation(attestation.attestationType)
|
|
103
|
+
: ObservationTier.BLACK_BOX;
|
|
104
|
+
return {
|
|
105
|
+
valid,
|
|
106
|
+
hardwareBacked,
|
|
107
|
+
matchesGoldenImage,
|
|
108
|
+
observationTier,
|
|
109
|
+
issues,
|
|
110
|
+
verifiedAt: new Date(),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Compute SHA-256 hash (placeholder - would use crypto in real impl)
|
|
115
|
+
*/
|
|
116
|
+
export function computeHash(data) {
|
|
117
|
+
// In real implementation, use crypto.subtle.digest or crypto.createHash
|
|
118
|
+
// This is a placeholder that would need proper crypto implementation
|
|
119
|
+
let hash = 0;
|
|
120
|
+
for (let i = 0; i < data.length; i++) {
|
|
121
|
+
const char = data.charCodeAt(i);
|
|
122
|
+
hash = ((hash << 5) - hash) + char;
|
|
123
|
+
hash = hash & hash;
|
|
124
|
+
}
|
|
125
|
+
return Math.abs(hash).toString(16).padStart(64, '0');
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=attestation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.js","sourceRoot":"","sources":["../../src/observation/attestation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAN,IAAY,eAeX;AAfD,WAAY,eAAe;IACzB,qBAAqB;IACrB,gCAAa,CAAA;IACb,sCAAsC;IACtC,kDAA+B,CAAA;IAC/B,6BAA6B;IAC7B,0CAAuB,CAAA;IACvB,8BAA8B;IAC9B,0CAAuB,CAAA;IACvB,yBAAyB;IACzB,6CAA0B,CAAA;IAC1B,sBAAsB;IACtB,0CAAuB,CAAA;IACvB,2CAA2C;IAC3C,0CAAuB,CAAA;AACzB,CAAC,EAfW,eAAe,KAAf,eAAe,QAe1B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IAChD,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,cAAc;IAC9B,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,SAAS;CAC1B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAC9C,IAAqB;IAErB,IAAI,0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CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust Ceilings - Score limits based on observation tier
|
|
3
|
+
*
|
|
4
|
+
* Key insight: Cannot fully trust what you cannot inspect.
|
|
5
|
+
* API-accessed proprietary models are capped at 60% max trust.
|
|
6
|
+
*/
|
|
7
|
+
import { ObservationTier, OBSERVATION_CEILINGS } from '@vorionsys/contracts';
|
|
8
|
+
export { OBSERVATION_CEILINGS };
|
|
9
|
+
/**
|
|
10
|
+
* Apply trust ceiling based on observation tier
|
|
11
|
+
*
|
|
12
|
+
* @param score - The raw trust score (0-100)
|
|
13
|
+
* @param tier - The observation tier
|
|
14
|
+
* @returns The adjusted score after applying ceiling
|
|
15
|
+
*/
|
|
16
|
+
export declare function applyCeiling(score: number, tier: ObservationTier): number;
|
|
17
|
+
/**
|
|
18
|
+
* Calculate how much trust is being lost to the ceiling
|
|
19
|
+
*/
|
|
20
|
+
export declare function getCeilingLoss(score: number, tier: ObservationTier): number;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a score is at the ceiling
|
|
23
|
+
*/
|
|
24
|
+
export declare function isAtCeiling(score: number, tier: ObservationTier): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get the room for improvement (how much higher can trust go)
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRoomForImprovement(currentScore: number, tier: ObservationTier): number;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate what tier would be needed to achieve a target score
|
|
31
|
+
*/
|
|
32
|
+
export declare function requiredTierForScore(targetScore: number): ObservationTier | null;
|
|
33
|
+
/**
|
|
34
|
+
* Ceiling impact analysis
|
|
35
|
+
*/
|
|
36
|
+
export interface CeilingAnalysis {
|
|
37
|
+
/** Original score before ceiling */
|
|
38
|
+
originalScore: number;
|
|
39
|
+
/** Score after ceiling applied */
|
|
40
|
+
adjustedScore: number;
|
|
41
|
+
/** Trust points lost to ceiling */
|
|
42
|
+
ceilingLoss: number;
|
|
43
|
+
/** Is the score currently at the ceiling? */
|
|
44
|
+
atCeiling: boolean;
|
|
45
|
+
/** Room for improvement within current tier */
|
|
46
|
+
improvementRoom: number;
|
|
47
|
+
/** Would a tier upgrade unlock more trust? */
|
|
48
|
+
tierUpgradeWouldHelp: boolean;
|
|
49
|
+
/** Next tier that would unlock more trust */
|
|
50
|
+
nextUnlockingTier: ObservationTier | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Analyze the impact of trust ceiling on a score
|
|
54
|
+
*/
|
|
55
|
+
export declare function analyzeCeilingImpact(score: number, tier: ObservationTier): CeilingAnalysis;
|
|
56
|
+
/**
|
|
57
|
+
* Format ceiling information for display
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatCeilingInfo(tier: ObservationTier): string;
|
|
60
|
+
//# sourceMappingURL=ceilings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ceilings.d.ts","sourceRoot":"","sources":["../../src/observation/ceilings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAGzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAG3E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAGzE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,eAAe,GACpB,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,GAClB,eAAe,GAAG,IA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