@longarc/mdash 3.0.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/README.md +278 -0
- package/dist/checkpoint/engine.d.ts +208 -0
- package/dist/checkpoint/engine.d.ts.map +1 -0
- package/dist/checkpoint/engine.js +369 -0
- package/dist/checkpoint/engine.js.map +1 -0
- package/dist/context/engine.d.ts +197 -0
- package/dist/context/engine.d.ts.map +1 -0
- package/dist/context/engine.js +392 -0
- package/dist/context/engine.js.map +1 -0
- package/dist/core/commitment.d.ts +154 -0
- package/dist/core/commitment.d.ts.map +1 -0
- package/dist/core/commitment.js +305 -0
- package/dist/core/commitment.js.map +1 -0
- package/dist/core/crypto.d.ts +100 -0
- package/dist/core/crypto.d.ts.map +1 -0
- package/dist/core/crypto.js +243 -0
- package/dist/core/crypto.js.map +1 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -0
- package/dist/mcca/engine.d.ts +260 -0
- package/dist/mcca/engine.d.ts.map +1 -0
- package/dist/mcca/engine.js +518 -0
- package/dist/mcca/engine.js.map +1 -0
- package/dist/physics/engine.d.ts +165 -0
- package/dist/physics/engine.d.ts.map +1 -0
- package/dist/physics/engine.js +371 -0
- package/dist/physics/engine.js.map +1 -0
- package/dist/tee/engine.d.ts +285 -0
- package/dist/tee/engine.d.ts.map +1 -0
- package/dist/tee/engine.js +505 -0
- package/dist/tee/engine.js.map +1 -0
- package/dist/warrant/engine.d.ts +195 -0
- package/dist/warrant/engine.d.ts.map +1 -0
- package/dist/warrant/engine.js +409 -0
- package/dist/warrant/engine.js.map +1 -0
- package/dist/zk/engine.d.ts +243 -0
- package/dist/zk/engine.d.ts.map +1 -0
- package/dist/zk/engine.js +489 -0
- package/dist/zk/engine.js.map +1 -0
- package/package.json +25 -0
- package/src/__tests__/phase1.test.ts +1120 -0
- package/src/__tests__/phase2-4.test.ts +898 -0
- package/src/checkpoint/engine.ts +532 -0
- package/src/context/engine.ts +598 -0
- package/src/core/commitment.ts +438 -0
- package/src/core/crypto.ts +304 -0
- package/src/index.ts +320 -0
- package/src/mcca/engine.ts +778 -0
- package/src/physics/engine.ts +563 -0
- package/src/tee/engine.ts +810 -0
- package/src/warrant/engine.ts +625 -0
- package/src/zk/engine.ts +730 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.0 - Warrant System
|
|
3
|
+
*
|
|
4
|
+
* Speculative warrant issuance with cryptographic invalidation.
|
|
5
|
+
* Target: <10ms activation (cache hit)
|
|
6
|
+
*
|
|
7
|
+
* Invariants:
|
|
8
|
+
* - WARRANT-INV-001: Speculative warrants expire within 60s if not activated
|
|
9
|
+
* - WARRANT-INV-002: Revocation propagates to all caches within 100ms
|
|
10
|
+
* - WARRANT-INV-003: Activated warrants immediately sealed (L1)
|
|
11
|
+
*/
|
|
12
|
+
import { Hash, Seal, Timestamp, WarrantId } from '../core/crypto.js';
|
|
13
|
+
import { CommitmentEngine } from '../core/commitment.js';
|
|
14
|
+
export type WarrantState = 'DRAFT' | 'PENDING' | 'SPECULATIVE' | 'ACTIVE' | 'REVOKED' | 'EXPIRED' | 'ARCHIVED';
|
|
15
|
+
export type WarrantTier = 'T1' | 'T2' | 'T3';
|
|
16
|
+
export interface WarrantConstraints {
|
|
17
|
+
/** Maximum number of invocations */
|
|
18
|
+
maxCalls?: number;
|
|
19
|
+
/** Maximum execution time (ms) */
|
|
20
|
+
maxTime?: number;
|
|
21
|
+
/** Maximum financial exposure */
|
|
22
|
+
maxAmount?: number;
|
|
23
|
+
/** Allowed destination accounts (for financial) */
|
|
24
|
+
allowedAccounts?: string[];
|
|
25
|
+
/** Required 2FA */
|
|
26
|
+
require2FA?: boolean;
|
|
27
|
+
/** Allowed domains */
|
|
28
|
+
allowedDomains?: string[];
|
|
29
|
+
/** Custom constraints */
|
|
30
|
+
custom?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export interface Warrant {
|
|
33
|
+
/** Unique warrant identifier */
|
|
34
|
+
id: WarrantId;
|
|
35
|
+
/** Agent this warrant governs */
|
|
36
|
+
agent_id: string;
|
|
37
|
+
/** Policy template reference */
|
|
38
|
+
policy_id: string;
|
|
39
|
+
/** Current state */
|
|
40
|
+
state: WarrantState;
|
|
41
|
+
/** Liability tier */
|
|
42
|
+
tier: WarrantTier;
|
|
43
|
+
/** Operational constraints */
|
|
44
|
+
constraints: WarrantConstraints;
|
|
45
|
+
/** Creation timestamp */
|
|
46
|
+
created_at: Timestamp;
|
|
47
|
+
/** Activation timestamp (null if not yet activated) */
|
|
48
|
+
activated_at: Timestamp | null;
|
|
49
|
+
/** Expiration timestamp */
|
|
50
|
+
expires_at: Timestamp;
|
|
51
|
+
/** Revocation timestamp (null if not revoked) */
|
|
52
|
+
revoked_at: Timestamp | null;
|
|
53
|
+
/** Revocation reason */
|
|
54
|
+
revocation_reason?: string;
|
|
55
|
+
/** Issuer identity */
|
|
56
|
+
issued_by: string;
|
|
57
|
+
/** HMAC seal */
|
|
58
|
+
seal: Seal;
|
|
59
|
+
/** Protocol version */
|
|
60
|
+
version: 'v3.0';
|
|
61
|
+
}
|
|
62
|
+
export interface SpeculativeWarrant extends Warrant {
|
|
63
|
+
state: 'SPECULATIVE';
|
|
64
|
+
/** Speculative expiry (60s from creation) */
|
|
65
|
+
speculative_expires_at: Timestamp;
|
|
66
|
+
/** Pre-computed activation seal */
|
|
67
|
+
activation_seal: Seal;
|
|
68
|
+
}
|
|
69
|
+
export interface WarrantEvent {
|
|
70
|
+
warrant_id: WarrantId;
|
|
71
|
+
event_type: 'created' | 'activated' | 'revoked' | 'expired' | 'archived';
|
|
72
|
+
timestamp: Timestamp;
|
|
73
|
+
actor: {
|
|
74
|
+
type: 'user' | 'system';
|
|
75
|
+
id: string;
|
|
76
|
+
email?: string;
|
|
77
|
+
};
|
|
78
|
+
reason: string | undefined;
|
|
79
|
+
previous_state: WarrantState;
|
|
80
|
+
new_state: WarrantState;
|
|
81
|
+
hash: Hash;
|
|
82
|
+
parent_hash: Hash | null;
|
|
83
|
+
}
|
|
84
|
+
export declare class WarrantCache {
|
|
85
|
+
private cache;
|
|
86
|
+
private speculative;
|
|
87
|
+
private revocations;
|
|
88
|
+
private readonly DEFAULT_TTL;
|
|
89
|
+
private readonly SPECULATIVE_TTL;
|
|
90
|
+
/**
|
|
91
|
+
* Store a warrant in cache
|
|
92
|
+
*/
|
|
93
|
+
set(warrant: Warrant | SpeculativeWarrant, ttl?: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Get a warrant from cache
|
|
96
|
+
* Returns null if not found, expired, or revoked
|
|
97
|
+
*/
|
|
98
|
+
get(id: WarrantId): Warrant | SpeculativeWarrant | null;
|
|
99
|
+
/**
|
|
100
|
+
* Get speculative warrants for an agent
|
|
101
|
+
* For pre-staged activation
|
|
102
|
+
*/
|
|
103
|
+
getSpeculativeForAgent(agentId: string): SpeculativeWarrant[];
|
|
104
|
+
/**
|
|
105
|
+
* Record a revocation
|
|
106
|
+
* Propagates immediately (WARRANT-INV-002)
|
|
107
|
+
*/
|
|
108
|
+
revoke(id: WarrantId): void;
|
|
109
|
+
/**
|
|
110
|
+
* Check if a warrant is revoked
|
|
111
|
+
*/
|
|
112
|
+
isRevoked(id: WarrantId): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Clear expired entries
|
|
115
|
+
*/
|
|
116
|
+
cleanup(): number;
|
|
117
|
+
/**
|
|
118
|
+
* Get cache statistics
|
|
119
|
+
*/
|
|
120
|
+
getStats(): {
|
|
121
|
+
size: number;
|
|
122
|
+
speculative: number;
|
|
123
|
+
revocations: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export declare class WarrantEngine {
|
|
127
|
+
private key;
|
|
128
|
+
private cache;
|
|
129
|
+
private commitmentEngine;
|
|
130
|
+
private eventLog;
|
|
131
|
+
private lastEventHash;
|
|
132
|
+
constructor(commitmentEngine: CommitmentEngine);
|
|
133
|
+
/**
|
|
134
|
+
* Initialize the engine with a seal key
|
|
135
|
+
*/
|
|
136
|
+
initialize(sealKey: string): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Create a speculative warrant (pre-staged)
|
|
139
|
+
* WARRANT-INV-001: Expires in 60s if not activated
|
|
140
|
+
*/
|
|
141
|
+
createSpeculative(params: {
|
|
142
|
+
agent_id: string;
|
|
143
|
+
policy_id: string;
|
|
144
|
+
tier: WarrantTier;
|
|
145
|
+
constraints: WarrantConstraints;
|
|
146
|
+
duration_ms: number;
|
|
147
|
+
issued_by: string;
|
|
148
|
+
}): Promise<SpeculativeWarrant>;
|
|
149
|
+
/**
|
|
150
|
+
* Activate a speculative warrant
|
|
151
|
+
* Target: <10ms (cache hit)
|
|
152
|
+
* WARRANT-INV-003: Immediately sealed (L1)
|
|
153
|
+
*/
|
|
154
|
+
activate(id: WarrantId): Promise<Warrant>;
|
|
155
|
+
/**
|
|
156
|
+
* Revoke a warrant
|
|
157
|
+
* WARRANT-INV-002: Propagates to all caches within 100ms
|
|
158
|
+
*/
|
|
159
|
+
revoke(id: WarrantId, reason: string, actor: {
|
|
160
|
+
type: 'user' | 'system';
|
|
161
|
+
id: string;
|
|
162
|
+
}): Promise<Warrant>;
|
|
163
|
+
/**
|
|
164
|
+
* Check if an action is authorized by warrant
|
|
165
|
+
* Returns matching warrant or null
|
|
166
|
+
*/
|
|
167
|
+
checkAuthorization(params: {
|
|
168
|
+
agent_id: string;
|
|
169
|
+
action: string;
|
|
170
|
+
amount?: number;
|
|
171
|
+
domain?: string;
|
|
172
|
+
}): Promise<Warrant | null>;
|
|
173
|
+
/**
|
|
174
|
+
* Check if action meets warrant constraints
|
|
175
|
+
*/
|
|
176
|
+
private meetsConstraints;
|
|
177
|
+
/**
|
|
178
|
+
* Log a warrant event with hash chain
|
|
179
|
+
*/
|
|
180
|
+
private logEvent;
|
|
181
|
+
/**
|
|
182
|
+
* Get event log for a warrant
|
|
183
|
+
*/
|
|
184
|
+
getEventLog(warrantId?: WarrantId): WarrantEvent[];
|
|
185
|
+
/**
|
|
186
|
+
* Get cache statistics
|
|
187
|
+
*/
|
|
188
|
+
getCacheStats(): ReturnType<WarrantCache['getStats']>;
|
|
189
|
+
}
|
|
190
|
+
export declare const TIER_LIMITS: Record<WarrantTier, {
|
|
191
|
+
maxExposure: number;
|
|
192
|
+
maxCalls: number;
|
|
193
|
+
requiresApproval: boolean;
|
|
194
|
+
}>;
|
|
195
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/warrant/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,SAAS,EAMV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAMzD,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,SAAS,GACT,aAAa,GACb,QAAQ,GACR,SAAS,GACT,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sBAAsB;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,yBAAyB;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WA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.
|
|
5
|
+
* Target: <10ms activation (cache hit)
|
|
6
|
+
*
|
|
7
|
+
* Invariants:
|
|
8
|
+
* - WARRANT-INV-001: Speculative warrants expire within 60s if not activated
|
|
9
|
+
* - WARRANT-INV-002: Revocation propagates to all caches within 100ms
|
|
10
|
+
* - WARRANT-INV-003: Activated warrants immediately sealed (L1)
|
|
11
|
+
*/
|
|
12
|
+
import { generateWarrantId, generateTimestamp, sha256Object, hmacSeal, deriveKey, } from '../core/crypto.js';
|
|
13
|
+
export class WarrantCache {
|
|
14
|
+
cache = new Map();
|
|
15
|
+
speculative = new Map(); // agent_id -> warrant_ids
|
|
16
|
+
revocations = new Set();
|
|
17
|
+
DEFAULT_TTL = 5 * 60 * 1000; // 5 minutes
|
|
18
|
+
SPECULATIVE_TTL = 60 * 1000; // 60 seconds (WARRANT-INV-001)
|
|
19
|
+
/**
|
|
20
|
+
* Store a warrant in cache
|
|
21
|
+
*/
|
|
22
|
+
set(warrant, ttl) {
|
|
23
|
+
const effectiveTtl = warrant.state === 'SPECULATIVE'
|
|
24
|
+
? this.SPECULATIVE_TTL
|
|
25
|
+
: (ttl || this.DEFAULT_TTL);
|
|
26
|
+
this.cache.set(warrant.id, {
|
|
27
|
+
warrant,
|
|
28
|
+
cached_at: Date.now(),
|
|
29
|
+
ttl_ms: effectiveTtl,
|
|
30
|
+
});
|
|
31
|
+
// Track speculative warrants by agent
|
|
32
|
+
if (warrant.state === 'SPECULATIVE') {
|
|
33
|
+
const existing = this.speculative.get(warrant.agent_id) || [];
|
|
34
|
+
existing.push(warrant.id);
|
|
35
|
+
this.speculative.set(warrant.agent_id, existing);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a warrant from cache
|
|
40
|
+
* Returns null if not found, expired, or revoked
|
|
41
|
+
*/
|
|
42
|
+
get(id) {
|
|
43
|
+
// Check revocation first (WARRANT-INV-002)
|
|
44
|
+
if (this.revocations.has(id)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const entry = this.cache.get(id);
|
|
48
|
+
if (!entry) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
// Check TTL
|
|
52
|
+
if (Date.now() - entry.cached_at > entry.ttl_ms) {
|
|
53
|
+
this.cache.delete(id);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return entry.warrant;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get speculative warrants for an agent
|
|
60
|
+
* For pre-staged activation
|
|
61
|
+
*/
|
|
62
|
+
getSpeculativeForAgent(agentId) {
|
|
63
|
+
const ids = this.speculative.get(agentId) || [];
|
|
64
|
+
const warrants = [];
|
|
65
|
+
for (const id of ids) {
|
|
66
|
+
const warrant = this.get(id);
|
|
67
|
+
if (warrant && warrant.state === 'SPECULATIVE') {
|
|
68
|
+
warrants.push(warrant);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return warrants;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Record a revocation
|
|
75
|
+
* Propagates immediately (WARRANT-INV-002)
|
|
76
|
+
*/
|
|
77
|
+
revoke(id) {
|
|
78
|
+
this.revocations.add(id);
|
|
79
|
+
this.cache.delete(id);
|
|
80
|
+
// Remove from speculative tracking
|
|
81
|
+
for (const [agentId, ids] of this.speculative) {
|
|
82
|
+
const filtered = ids.filter(i => i !== id);
|
|
83
|
+
if (filtered.length !== ids.length) {
|
|
84
|
+
this.speculative.set(agentId, filtered);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if a warrant is revoked
|
|
90
|
+
*/
|
|
91
|
+
isRevoked(id) {
|
|
92
|
+
return this.revocations.has(id);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Clear expired entries
|
|
96
|
+
*/
|
|
97
|
+
cleanup() {
|
|
98
|
+
let removed = 0;
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
for (const [id, entry] of this.cache) {
|
|
101
|
+
if (now - entry.cached_at > entry.ttl_ms) {
|
|
102
|
+
this.cache.delete(id);
|
|
103
|
+
removed++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return removed;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get cache statistics
|
|
110
|
+
*/
|
|
111
|
+
getStats() {
|
|
112
|
+
return {
|
|
113
|
+
size: this.cache.size,
|
|
114
|
+
speculative: Array.from(this.speculative.values()).flat().length,
|
|
115
|
+
revocations: this.revocations.size,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// WARRANT ENGINE
|
|
121
|
+
// ============================================================================
|
|
122
|
+
export class WarrantEngine {
|
|
123
|
+
key = null;
|
|
124
|
+
cache;
|
|
125
|
+
commitmentEngine;
|
|
126
|
+
eventLog = [];
|
|
127
|
+
lastEventHash = null;
|
|
128
|
+
constructor(commitmentEngine) {
|
|
129
|
+
this.cache = new WarrantCache();
|
|
130
|
+
this.commitmentEngine = commitmentEngine;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Initialize the engine with a seal key
|
|
134
|
+
*/
|
|
135
|
+
async initialize(sealKey) {
|
|
136
|
+
this.key = await deriveKey(sealKey);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Create a speculative warrant (pre-staged)
|
|
140
|
+
* WARRANT-INV-001: Expires in 60s if not activated
|
|
141
|
+
*/
|
|
142
|
+
async createSpeculative(params) {
|
|
143
|
+
if (!this.key) {
|
|
144
|
+
throw new Error('Engine not initialized. Call initialize() first.');
|
|
145
|
+
}
|
|
146
|
+
const startTime = performance.now();
|
|
147
|
+
const id = generateWarrantId();
|
|
148
|
+
const now = generateTimestamp();
|
|
149
|
+
const expiresAt = new Date(Date.now() + params.duration_ms).toISOString();
|
|
150
|
+
const speculativeExpiresAt = new Date(Date.now() + 60000).toISOString();
|
|
151
|
+
// Pre-compute activation seal
|
|
152
|
+
const activationData = {
|
|
153
|
+
_v: 1,
|
|
154
|
+
id,
|
|
155
|
+
agent_id: params.agent_id,
|
|
156
|
+
activated: true,
|
|
157
|
+
};
|
|
158
|
+
const activationSeal = await hmacSeal(activationData, this.key);
|
|
159
|
+
// Seal the warrant
|
|
160
|
+
const warrantData = {
|
|
161
|
+
_v: 1,
|
|
162
|
+
id,
|
|
163
|
+
agent_id: params.agent_id,
|
|
164
|
+
policy_id: params.policy_id,
|
|
165
|
+
state: 'SPECULATIVE',
|
|
166
|
+
tier: params.tier,
|
|
167
|
+
constraints: params.constraints,
|
|
168
|
+
created_at: now,
|
|
169
|
+
expires_at: expiresAt,
|
|
170
|
+
issued_by: params.issued_by,
|
|
171
|
+
};
|
|
172
|
+
const seal = await hmacSeal(warrantData, this.key);
|
|
173
|
+
const warrant = {
|
|
174
|
+
id,
|
|
175
|
+
agent_id: params.agent_id,
|
|
176
|
+
policy_id: params.policy_id,
|
|
177
|
+
state: 'SPECULATIVE',
|
|
178
|
+
tier: params.tier,
|
|
179
|
+
constraints: params.constraints,
|
|
180
|
+
created_at: now,
|
|
181
|
+
activated_at: null,
|
|
182
|
+
expires_at: expiresAt,
|
|
183
|
+
revoked_at: null,
|
|
184
|
+
issued_by: params.issued_by,
|
|
185
|
+
seal,
|
|
186
|
+
version: 'v3.0',
|
|
187
|
+
speculative_expires_at: speculativeExpiresAt,
|
|
188
|
+
activation_seal: activationSeal,
|
|
189
|
+
};
|
|
190
|
+
// Cache for fast activation
|
|
191
|
+
this.cache.set(warrant);
|
|
192
|
+
// Log event
|
|
193
|
+
await this.logEvent({
|
|
194
|
+
warrant_id: id,
|
|
195
|
+
event_type: 'created',
|
|
196
|
+
actor: { type: 'user', id: params.issued_by },
|
|
197
|
+
previous_state: 'DRAFT',
|
|
198
|
+
new_state: 'SPECULATIVE',
|
|
199
|
+
});
|
|
200
|
+
const elapsed = performance.now() - startTime;
|
|
201
|
+
if (elapsed > 10) {
|
|
202
|
+
console.warn(`Speculative warrant creation exceeded target: ${elapsed.toFixed(2)}ms`);
|
|
203
|
+
}
|
|
204
|
+
return warrant;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Activate a speculative warrant
|
|
208
|
+
* Target: <10ms (cache hit)
|
|
209
|
+
* WARRANT-INV-003: Immediately sealed (L1)
|
|
210
|
+
*/
|
|
211
|
+
async activate(id) {
|
|
212
|
+
if (!this.key) {
|
|
213
|
+
throw new Error('Engine not initialized. Call initialize() first.');
|
|
214
|
+
}
|
|
215
|
+
const startTime = performance.now();
|
|
216
|
+
// Try cache first
|
|
217
|
+
const cached = this.cache.get(id);
|
|
218
|
+
if (!cached) {
|
|
219
|
+
throw new Error(`Warrant not found or expired: ${id}`);
|
|
220
|
+
}
|
|
221
|
+
if (cached.state !== 'SPECULATIVE') {
|
|
222
|
+
throw new Error(`Warrant not in SPECULATIVE state: ${cached.state}`);
|
|
223
|
+
}
|
|
224
|
+
const specWarrant = cached;
|
|
225
|
+
// Check speculative expiry (WARRANT-INV-001)
|
|
226
|
+
if (new Date(specWarrant.speculative_expires_at) < new Date()) {
|
|
227
|
+
this.cache.revoke(id);
|
|
228
|
+
throw new Error('Speculative warrant expired (60s limit)');
|
|
229
|
+
}
|
|
230
|
+
const now = generateTimestamp();
|
|
231
|
+
// Create activated warrant
|
|
232
|
+
const activatedWarrant = {
|
|
233
|
+
id: specWarrant.id,
|
|
234
|
+
agent_id: specWarrant.agent_id,
|
|
235
|
+
policy_id: specWarrant.policy_id,
|
|
236
|
+
state: 'ACTIVE',
|
|
237
|
+
tier: specWarrant.tier,
|
|
238
|
+
constraints: specWarrant.constraints,
|
|
239
|
+
created_at: specWarrant.created_at,
|
|
240
|
+
activated_at: now,
|
|
241
|
+
expires_at: specWarrant.expires_at,
|
|
242
|
+
revoked_at: null,
|
|
243
|
+
issued_by: specWarrant.issued_by,
|
|
244
|
+
seal: specWarrant.seal, // Original seal preserved
|
|
245
|
+
version: 'v3.0',
|
|
246
|
+
};
|
|
247
|
+
// WARRANT-INV-003: Immediately seal via commitment layer
|
|
248
|
+
await this.commitmentEngine.commit(activatedWarrant, `warrant:${id}`);
|
|
249
|
+
// Update cache
|
|
250
|
+
this.cache.set(activatedWarrant);
|
|
251
|
+
// Log event
|
|
252
|
+
await this.logEvent({
|
|
253
|
+
warrant_id: id,
|
|
254
|
+
event_type: 'activated',
|
|
255
|
+
actor: { type: 'system', id: 'warrant-engine' },
|
|
256
|
+
previous_state: 'SPECULATIVE',
|
|
257
|
+
new_state: 'ACTIVE',
|
|
258
|
+
});
|
|
259
|
+
const elapsed = performance.now() - startTime;
|
|
260
|
+
if (elapsed > 10) {
|
|
261
|
+
console.warn(`Warrant activation exceeded target: ${elapsed.toFixed(2)}ms`);
|
|
262
|
+
}
|
|
263
|
+
return activatedWarrant;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Revoke a warrant
|
|
267
|
+
* WARRANT-INV-002: Propagates to all caches within 100ms
|
|
268
|
+
*/
|
|
269
|
+
async revoke(id, reason, actor) {
|
|
270
|
+
if (!this.key) {
|
|
271
|
+
throw new Error('Engine not initialized. Call initialize() first.');
|
|
272
|
+
}
|
|
273
|
+
const startTime = performance.now();
|
|
274
|
+
const warrant = this.cache.get(id);
|
|
275
|
+
if (!warrant) {
|
|
276
|
+
throw new Error(`Warrant not found: ${id}`);
|
|
277
|
+
}
|
|
278
|
+
if (warrant.state === 'REVOKED' || warrant.state === 'ARCHIVED') {
|
|
279
|
+
throw new Error(`Warrant already ${warrant.state}`);
|
|
280
|
+
}
|
|
281
|
+
const previousState = warrant.state;
|
|
282
|
+
const now = generateTimestamp();
|
|
283
|
+
// Create revoked warrant
|
|
284
|
+
const revokedWarrant = {
|
|
285
|
+
...warrant,
|
|
286
|
+
state: 'REVOKED',
|
|
287
|
+
revoked_at: now,
|
|
288
|
+
revocation_reason: reason,
|
|
289
|
+
};
|
|
290
|
+
// Seal revocation
|
|
291
|
+
await this.commitmentEngine.commit({ warrant_id: id, revoked_at: now, reason }, `revocation:${id}`);
|
|
292
|
+
// WARRANT-INV-002: Immediate cache revocation
|
|
293
|
+
this.cache.revoke(id);
|
|
294
|
+
// Log event
|
|
295
|
+
await this.logEvent({
|
|
296
|
+
warrant_id: id,
|
|
297
|
+
event_type: 'revoked',
|
|
298
|
+
actor,
|
|
299
|
+
reason,
|
|
300
|
+
previous_state: previousState,
|
|
301
|
+
new_state: 'REVOKED',
|
|
302
|
+
});
|
|
303
|
+
const elapsed = performance.now() - startTime;
|
|
304
|
+
if (elapsed > 100) {
|
|
305
|
+
console.warn(`Warrant revocation exceeded propagation target: ${elapsed.toFixed(2)}ms`);
|
|
306
|
+
}
|
|
307
|
+
return revokedWarrant;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Check if an action is authorized by warrant
|
|
311
|
+
* Returns matching warrant or null
|
|
312
|
+
*/
|
|
313
|
+
async checkAuthorization(params) {
|
|
314
|
+
const startTime = performance.now();
|
|
315
|
+
// Get speculative warrants for agent
|
|
316
|
+
const specWarrants = this.cache.getSpeculativeForAgent(params.agent_id);
|
|
317
|
+
for (const warrant of specWarrants) {
|
|
318
|
+
// Check constraints
|
|
319
|
+
if (this.meetsConstraints(warrant.constraints, params)) {
|
|
320
|
+
// Activate on first matching warrant
|
|
321
|
+
const activated = await this.activate(warrant.id);
|
|
322
|
+
const elapsed = performance.now() - startTime;
|
|
323
|
+
if (elapsed > 10) {
|
|
324
|
+
console.warn(`Authorization check exceeded target: ${elapsed.toFixed(2)}ms`);
|
|
325
|
+
}
|
|
326
|
+
return activated;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Check if action meets warrant constraints
|
|
333
|
+
*/
|
|
334
|
+
meetsConstraints(constraints, action) {
|
|
335
|
+
// Check amount limit
|
|
336
|
+
if (constraints.maxAmount !== undefined && action.amount !== undefined) {
|
|
337
|
+
if (action.amount > constraints.maxAmount) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// Check domain allowlist
|
|
342
|
+
if (constraints.allowedDomains && action.domain) {
|
|
343
|
+
if (!constraints.allowedDomains.includes(action.domain)) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Log a warrant event with hash chain
|
|
351
|
+
*/
|
|
352
|
+
async logEvent(params) {
|
|
353
|
+
const timestamp = generateTimestamp();
|
|
354
|
+
const event = {
|
|
355
|
+
warrant_id: params.warrant_id,
|
|
356
|
+
event_type: params.event_type,
|
|
357
|
+
timestamp,
|
|
358
|
+
actor: params.actor,
|
|
359
|
+
reason: params.reason,
|
|
360
|
+
previous_state: params.previous_state,
|
|
361
|
+
new_state: params.new_state,
|
|
362
|
+
hash: '', // Will be computed
|
|
363
|
+
parent_hash: this.lastEventHash,
|
|
364
|
+
};
|
|
365
|
+
// Compute event hash
|
|
366
|
+
event.hash = await sha256Object({
|
|
367
|
+
...event,
|
|
368
|
+
hash: undefined, // Exclude from hash computation
|
|
369
|
+
});
|
|
370
|
+
this.eventLog.push(event);
|
|
371
|
+
this.lastEventHash = event.hash;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Get event log for a warrant
|
|
375
|
+
*/
|
|
376
|
+
getEventLog(warrantId) {
|
|
377
|
+
if (warrantId) {
|
|
378
|
+
return this.eventLog.filter(e => e.warrant_id === warrantId);
|
|
379
|
+
}
|
|
380
|
+
return [...this.eventLog];
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Get cache statistics
|
|
384
|
+
*/
|
|
385
|
+
getCacheStats() {
|
|
386
|
+
return this.cache.getStats();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// ============================================================================
|
|
390
|
+
// TIER DEFINITIONS
|
|
391
|
+
// ============================================================================
|
|
392
|
+
export const TIER_LIMITS = {
|
|
393
|
+
T1: {
|
|
394
|
+
maxExposure: 1000,
|
|
395
|
+
maxCalls: 100,
|
|
396
|
+
requiresApproval: false,
|
|
397
|
+
},
|
|
398
|
+
T2: {
|
|
399
|
+
maxExposure: 100000,
|
|
400
|
+
maxCalls: 1000,
|
|
401
|
+
requiresApproval: false,
|
|
402
|
+
},
|
|
403
|
+
T3: {
|
|
404
|
+
maxExposure: Infinity,
|
|
405
|
+
maxCalls: Infinity,
|
|
406
|
+
requiresApproval: true,
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/warrant/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAKL,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,MAAM,mBAAmB,CAAC;AAqG3B,MAAM,OAAO,YAAY;IACf,KAAK,GAA+B,IAAI,GAAG,EAAE,CAAC;IAC9C,WAAW,GAA6B,IAAI,GAAG,EAAE,CAAC,CAAC,0BAA0B;IAC7E,WAAW,GAAmB,IAAI,GAAG,EAAE,CAAC;IAE/B,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;IACzC,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,+BAA+B;IAE7E;;OAEG;IACH,GAAG,CAAC,OAAqC,EAAE,GAAY;QACrD,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,KAAK,aAAa;YAClD,CAAC,CAAC,IAAI,CAAC,eAAe;YACtB,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;QAE9B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE;YACzB,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,MAA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