@longarc/mdash 3.1.2 → 3.1.3
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 +86 -23
- package/SECURITY.md +254 -0
- package/dist/accountability/engine.d.ts +27 -0
- package/dist/accountability/engine.d.ts.map +1 -0
- package/dist/accountability/engine.js +148 -0
- package/dist/accountability/engine.js.map +1 -0
- package/dist/accountability/types.d.ts +46 -0
- package/dist/accountability/types.d.ts.map +1 -0
- package/dist/accountability/types.js +8 -0
- package/dist/accountability/types.js.map +1 -0
- package/dist/checkpoint/engine.d.ts.map +1 -1
- package/dist/checkpoint/engine.js +4 -0
- package/dist/checkpoint/engine.js.map +1 -1
- package/dist/context/compose.d.ts +62 -0
- package/dist/context/compose.d.ts.map +1 -0
- package/dist/context/compose.js +286 -0
- package/dist/context/compose.js.map +1 -0
- package/dist/context/crypto/hash.d.ts +100 -0
- package/dist/context/crypto/hash.d.ts.map +1 -0
- package/dist/context/crypto/hash.js +248 -0
- package/dist/context/crypto/hash.js.map +1 -0
- package/dist/context/crypto/hmac.d.ts +80 -0
- package/dist/context/crypto/hmac.d.ts.map +1 -0
- package/dist/context/crypto/hmac.js +192 -0
- package/dist/context/crypto/hmac.js.map +1 -0
- package/dist/context/crypto/index.d.ts +7 -0
- package/dist/context/crypto/index.d.ts.map +1 -0
- package/dist/context/crypto/index.js +7 -0
- package/dist/context/crypto/index.js.map +1 -0
- package/dist/context/engine-v3.0-backup.d.ts +197 -0
- package/dist/context/engine-v3.0-backup.d.ts.map +1 -0
- package/dist/context/engine-v3.0-backup.js +392 -0
- package/dist/context/engine-v3.0-backup.js.map +1 -0
- package/dist/context/fragment.d.ts +99 -0
- package/dist/context/fragment.d.ts.map +1 -0
- package/dist/context/fragment.js +316 -0
- package/dist/context/fragment.js.map +1 -0
- package/dist/context/index.d.ts +99 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +180 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/provenance.d.ts +80 -0
- package/dist/context/provenance.d.ts.map +1 -0
- package/dist/context/provenance.js +294 -0
- package/dist/context/provenance.js.map +1 -0
- package/dist/context/resolve.d.ts +106 -0
- package/dist/context/resolve.d.ts.map +1 -0
- package/dist/context/resolve.js +440 -0
- package/dist/context/resolve.js.map +1 -0
- package/dist/context/store.d.ts +156 -0
- package/dist/context/store.d.ts.map +1 -0
- package/dist/context/store.js +396 -0
- package/dist/context/store.js.map +1 -0
- package/dist/context/types.d.ts +463 -0
- package/dist/context/types.d.ts.map +1 -0
- package/dist/context/types.js +94 -0
- package/dist/context/types.js.map +1 -0
- package/dist/context/utils/atomic.d.ts +76 -0
- package/dist/context/utils/atomic.d.ts.map +1 -0
- package/dist/context/utils/atomic.js +159 -0
- package/dist/context/utils/atomic.js.map +1 -0
- package/dist/context/utils/credit.d.ts +65 -0
- package/dist/context/utils/credit.d.ts.map +1 -0
- package/dist/context/utils/credit.js +164 -0
- package/dist/context/utils/credit.js.map +1 -0
- package/dist/context/utils/index.d.ts +13 -0
- package/dist/context/utils/index.d.ts.map +1 -0
- package/dist/context/utils/index.js +13 -0
- package/dist/context/utils/index.js.map +1 -0
- package/dist/context/utils/utility.d.ts +63 -0
- package/dist/context/utils/utility.d.ts.map +1 -0
- package/dist/context/utils/utility.js +141 -0
- package/dist/context/utils/utility.js.map +1 -0
- package/dist/core/commitment.d.ts +25 -2
- package/dist/core/commitment.d.ts.map +1 -1
- package/dist/core/commitment.js +44 -6
- package/dist/core/commitment.js.map +1 -1
- package/dist/core/crypto.d.ts +2 -0
- package/dist/core/crypto.d.ts.map +1 -1
- package/dist/core/crypto.js +12 -0
- package/dist/core/crypto.js.map +1 -1
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -10
- package/dist/index.js.map +1 -1
- package/dist/mcca/engine.d.ts.map +1 -1
- package/dist/mcca/engine.js +5 -4
- package/dist/mcca/engine.js.map +1 -1
- package/dist/physics/engine.d.ts +1 -0
- package/dist/physics/engine.d.ts.map +1 -1
- package/dist/physics/engine.js +36 -2
- package/dist/physics/engine.js.map +1 -1
- package/dist/provenance/api-handler.d.ts +45 -0
- package/dist/provenance/api-handler.d.ts.map +1 -0
- package/dist/provenance/api-handler.js +223 -0
- package/dist/provenance/api-handler.js.map +1 -0
- package/dist/provenance/api-types.d.ts +108 -0
- package/dist/provenance/api-types.d.ts.map +1 -0
- package/dist/provenance/api-types.js +9 -0
- package/dist/provenance/api-types.js.map +1 -0
- package/dist/provenance/index.d.ts +6 -0
- package/dist/provenance/index.d.ts.map +1 -0
- package/dist/provenance/index.js +3 -0
- package/dist/provenance/index.js.map +1 -0
- package/dist/provenance/provenance-engine.d.ts +63 -0
- package/dist/provenance/provenance-engine.d.ts.map +1 -0
- package/dist/provenance/provenance-engine.js +311 -0
- package/dist/provenance/provenance-engine.js.map +1 -0
- package/dist/provenance/types.d.ts +193 -0
- package/dist/provenance/types.d.ts.map +1 -0
- package/dist/provenance/types.js +9 -0
- package/dist/provenance/types.js.map +1 -0
- package/dist/tee/engine.d.ts.map +1 -1
- package/dist/tee/engine.js +14 -0
- package/dist/tee/engine.js.map +1 -1
- package/dist/warrant/engine.d.ts +24 -1
- package/dist/warrant/engine.d.ts.map +1 -1
- package/dist/warrant/engine.js +76 -1
- package/dist/warrant/engine.js.map +1 -1
- package/dist/zk/engine.d.ts.map +1 -1
- package/dist/zk/engine.js +7 -4
- package/dist/zk/engine.js.map +1 -1
- package/docs/SECURITY-PATCHES.md +170 -0
- package/package.json +17 -5
- package/src/__tests__/accountability.test.ts +308 -0
- package/src/__tests__/l1-verification-modes.test.ts +424 -0
- package/src/__tests__/phase1.benchmark.test.ts +94 -0
- package/src/__tests__/phase1.test.ts +0 -77
- package/src/__tests__/phase2-4.benchmark.test.ts +60 -0
- package/src/__tests__/phase2-4.test.ts +1 -52
- package/src/__tests__/provenance/api-handler.test.ts +356 -0
- package/src/__tests__/provenance/provenance-engine.test.ts +628 -0
- package/src/__tests__/sa-2026-008.test.ts +45 -0
- package/src/__tests__/sa-2026-009.test.ts +86 -0
- package/src/__tests__/sa-2026-010.test.ts +72 -0
- package/src/__tests__/sa-2026-012.test.ts +65 -0
- package/src/__tests__/sa-2026-nfc.test.ts +40 -0
- package/src/__tests__/security.test.ts +786 -0
- package/src/accountability/engine.ts +230 -0
- package/src/accountability/types.ts +58 -0
- package/src/checkpoint/engine.ts +4 -0
- package/src/context/__tests__/caret-v0.2.0.test.ts +860 -0
- package/src/context/__tests__/integration.test.ts +356 -0
- package/src/context/compose.ts +388 -0
- package/src/context/crypto/hash.ts +277 -0
- package/src/context/crypto/hmac.ts +253 -0
- package/src/context/crypto/index.ts +29 -0
- package/src/context/engine-v3.0-backup.ts +598 -0
- package/src/context/fragment.ts +454 -0
- package/src/context/index.ts +427 -0
- package/src/context/provenance.ts +380 -0
- package/src/context/resolve.ts +581 -0
- package/src/context/store.ts +503 -0
- package/src/context/types.ts +679 -0
- package/src/context/utils/atomic.ts +207 -0
- package/src/context/utils/credit.ts +224 -0
- package/src/context/utils/index.ts +13 -0
- package/src/context/utils/utility.ts +200 -0
- package/src/core/commitment.ts +129 -67
- package/src/core/crypto.ts +13 -0
- package/src/index.ts +62 -10
- package/src/mcca/engine.ts +5 -4
- package/src/physics/engine.ts +40 -3
- package/src/provenance/api-handler.ts +248 -0
- package/src/provenance/api-types.ts +112 -0
- package/src/provenance/index.ts +19 -0
- package/src/provenance/provenance-engine.ts +387 -0
- package/src/provenance/types.ts +211 -0
- package/src/tee/engine.ts +16 -0
- package/src/warrant/engine.ts +89 -1
- package/src/zk/engine.ts +8 -4
- package/tsconfig.json +1 -1
package/README.md
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
# mdash v3.
|
|
1
|
+
# mdash v3.0
|
|
2
2
|
|
|
3
3
|
> **"The best defense is the fastest seal."**
|
|
4
4
|
|
|
5
|
-
Accountability infrastructure for autonomous AI agents.
|
|
6
|
-
|
|
7
|
-
mdash proves. Kiwi runs. Eclair reveals. Roux holds. Orin reasons.
|
|
5
|
+
Accountability infrastructure for autonomous AI agents. Cryptographic attestation + warrant evaluation in a single protocol — from sub-millisecond commitments to zero-knowledge proofs.
|
|
8
6
|
|
|
9
7
|
## Architecture
|
|
10
8
|
|
|
11
9
|
```
|
|
12
10
|
┌─────────────────────────────────────────────────────────────────────────┐
|
|
13
|
-
│ APPLICATION LAYER
|
|
14
|
-
│
|
|
11
|
+
│ APPLICATION LAYER │
|
|
12
|
+
│ Kiwi │ Enterprise │
|
|
15
13
|
├─────────────────────────────────────────────────────────────────────────┤
|
|
16
|
-
│
|
|
17
|
-
│
|
|
14
|
+
│ mdash v3.0 PROTOCOL │
|
|
15
|
+
│ Warrants │ Physics │ Checkpoints │ SCA │ MCCA │ Recovery │
|
|
18
16
|
├─────────────────────────────────────────────────────────────────────────┤
|
|
19
|
-
│ THREE-LAYER ATTESTATION
|
|
20
|
-
│ L1: Commitment (<1ms) │ L2: TEE (<10ms) │ L3: ZK Proofs (async)
|
|
17
|
+
│ THREE-LAYER ATTESTATION │
|
|
18
|
+
│ L1: Commitment (<1ms) │ L2: TEE (<10ms) │ L3: ZK Proofs (async) │
|
|
21
19
|
├─────────────────────────────────────────────────────────────────────────┤
|
|
22
|
-
│ CRYPTOGRAPHIC CORE
|
|
23
|
-
│ SHA-256 │ HMAC-SHA256 │ HKDF │ Web Crypto API
|
|
20
|
+
│ CRYPTOGRAPHIC CORE │
|
|
21
|
+
│ SHA-256 │ HMAC-SHA256 │ HKDF │ Web Crypto API │
|
|
24
22
|
└─────────────────────────────────────────────────────────────────────────┘
|
|
25
23
|
```
|
|
26
24
|
|
|
27
25
|
## Installation
|
|
28
26
|
|
|
29
27
|
```bash
|
|
30
|
-
npm install @
|
|
28
|
+
npm install @longarcstudios/mdash
|
|
31
29
|
```
|
|
32
30
|
|
|
33
31
|
## Quick Start
|
|
34
32
|
|
|
35
33
|
```typescript
|
|
36
|
-
import { createMdash } from '@
|
|
34
|
+
import { createMdash } from '@longarcstudios/mdash';
|
|
37
35
|
|
|
38
36
|
// Initialize protocol with all layers
|
|
39
37
|
const mdash = createMdash({
|
|
@@ -62,13 +60,52 @@ const result = await mdash.execute({
|
|
|
62
60
|
execute: async () => {
|
|
63
61
|
return { success: true, txId: 'tx-abc123' };
|
|
64
62
|
},
|
|
65
|
-
generateZKProof: true,
|
|
63
|
+
generateZKProof: true, // For accountability proofs
|
|
66
64
|
});
|
|
67
65
|
|
|
68
66
|
console.log(result.attestation.platform); // 'simulated' | 'nitro' | 'sgx'
|
|
69
67
|
console.log(result.zkProof?.status); // 'queued' -> 'verified'
|
|
70
68
|
```
|
|
71
69
|
|
|
70
|
+
## Full Accountability Lifecycle
|
|
71
|
+
|
|
72
|
+
The `AccountabilityEngine` is the simplest way to add accountability to any agent. One class: authorize before execution, attest after.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { AccountabilityEngine } from '@longarc/mdash';
|
|
76
|
+
|
|
77
|
+
const engine = new AccountabilityEngine();
|
|
78
|
+
await engine.initialize('your-seal-key-minimum-32-characters');
|
|
79
|
+
|
|
80
|
+
// Issue a warrant — define what the agent is authorized to do
|
|
81
|
+
await engine.issueWarrant('data-agent', {
|
|
82
|
+
allowedActions: ['query-database', 'read-file', 'summarize'],
|
|
83
|
+
forbiddenActions: ['delete-database', 'execute-shell'],
|
|
84
|
+
ttlMs: 60000
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Authorized action → executes and gets cryptographic attestation
|
|
88
|
+
const result = await engine.executeAction('data-agent', 'query-database', {
|
|
89
|
+
table: 'users', limit: 100
|
|
90
|
+
});
|
|
91
|
+
console.log(result.executed); // true
|
|
92
|
+
console.log(result.verified); // true — seal is cryptographically valid
|
|
93
|
+
|
|
94
|
+
// Unauthorized action → denied before execution
|
|
95
|
+
const denied = await engine.executeAction('data-agent', 'delete-database', {
|
|
96
|
+
target: 'users'
|
|
97
|
+
});
|
|
98
|
+
console.log(denied.executed); // false
|
|
99
|
+
console.log(denied.violation); // { type: 'FORBIDDEN_ACTION', ... }
|
|
100
|
+
|
|
101
|
+
// Full audit trail
|
|
102
|
+
const audit = engine.getAuditSummary();
|
|
103
|
+
console.log(audit.authorized); // 1
|
|
104
|
+
console.log(audit.denied); // 1
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
For advanced use cases (speculative warrants, TEE attestation, ZK proofs), use `MdashProtocol` directly.
|
|
108
|
+
|
|
72
109
|
## Three-Layer Attestation Model
|
|
73
110
|
|
|
74
111
|
### L1: Commitment Layer (<1ms)
|
|
@@ -98,9 +135,9 @@ const result = await verifier.verifyRemote(attestation);
|
|
|
98
135
|
**Supported Platforms:**
|
|
99
136
|
| Platform | Memory Encryption | Remote Attestation | Key Sealing |
|
|
100
137
|
|----------|------------------|-------------------|-------------|
|
|
101
|
-
| AWS Nitro |
|
|
102
|
-
| Intel SGX |
|
|
103
|
-
| Simulated |
|
|
138
|
+
| AWS Nitro | ✓ | ✓ (PCR) | ✓ |
|
|
139
|
+
| Intel SGX | ✓ | ✓ (Quote) | ✓ |
|
|
140
|
+
| Simulated | ✗ | ✓ | HMAC |
|
|
104
141
|
|
|
105
142
|
### L3: ZK Proofs (async)
|
|
106
143
|
Mathematically bulletproof attestation for disputes and accountability.
|
|
@@ -131,6 +168,8 @@ const completed = await mdash.zk.waitForProof(zkDoc.id, 30000);
|
|
|
131
168
|
|
|
132
169
|
## MCCA v3 (Manifold-Constrained Context Architecture)
|
|
133
170
|
|
|
171
|
+
Based on DeepSeek's research on constrained context windows.
|
|
172
|
+
|
|
134
173
|
```typescript
|
|
135
174
|
// Add context with influence tracking
|
|
136
175
|
const fragment = await mdash.mcca.addFragment({
|
|
@@ -168,6 +207,30 @@ const proof = await mdash.mcca.generateCommitmentProof();
|
|
|
168
207
|
| Checkpoint Creation | <0.5ms | <1ms | Log warning |
|
|
169
208
|
| ZK Proof | 100ms-20s | async | Queue with priority |
|
|
170
209
|
|
|
210
|
+
## Accountability Proofs
|
|
211
|
+
|
|
212
|
+
Generate accountability-grade proofs:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { InsuranceClaimProof } from '@longarcstudios/mdash';
|
|
216
|
+
|
|
217
|
+
const helper = new InsuranceClaimProof(mdash.zk);
|
|
218
|
+
|
|
219
|
+
const claimProof = await helper.generateClaim({
|
|
220
|
+
claimId: 'CLM-2026-001',
|
|
221
|
+
policyId: 'POL-ENTERPRISE-001',
|
|
222
|
+
incidentDescription: 'Unauthorized transaction',
|
|
223
|
+
warrantId: 'w-12345678',
|
|
224
|
+
checkpointIds: ['cp-001', 'cp-002'],
|
|
225
|
+
actionDetails: { type: 'transfer', amount: 50000 },
|
|
226
|
+
amount: 50000,
|
|
227
|
+
currency: 'USD',
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Wait for proof generation
|
|
231
|
+
const verified = await mdash.zk.waitForProof(claimProof.id, 60000);
|
|
232
|
+
```
|
|
233
|
+
|
|
171
234
|
## Warrant System
|
|
172
235
|
|
|
173
236
|
Three-tier warrant hierarchy with speculative issuance:
|
|
@@ -234,13 +297,13 @@ npm run test:coverage # Coverage report
|
|
|
234
297
|
## Version
|
|
235
298
|
|
|
236
299
|
```typescript
|
|
237
|
-
import { VERSION } from '@
|
|
300
|
+
import { VERSION } from '@longarcstudios/mdash';
|
|
238
301
|
|
|
239
302
|
console.log(VERSION);
|
|
240
303
|
// {
|
|
241
|
-
// protocol: '3.
|
|
242
|
-
// codename: '
|
|
243
|
-
// releaseDate: '2026-
|
|
304
|
+
// protocol: '3.0.0',
|
|
305
|
+
// codename: 'Sealed Execution',
|
|
306
|
+
// releaseDate: '2026-01',
|
|
244
307
|
// features: [...]
|
|
245
308
|
// }
|
|
246
309
|
```
|
|
@@ -251,4 +314,4 @@ MIT © Long Arc Studios
|
|
|
251
314
|
|
|
252
315
|
---
|
|
253
316
|
|
|
254
|
-
*Governance without control.
|
|
317
|
+
*Governance without control. Complexity without chaos.* 🫡
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# mdash v3.0 Security Specification
|
|
2
|
+
|
|
3
|
+
> "LLM at the edges, cryptography at the core."
|
|
4
|
+
|
|
5
|
+
**Version:** 3.0.0
|
|
6
|
+
**Last Audit:** 2026-01-26
|
|
7
|
+
**Tests:** 251 passing (including 33 security-specific)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Security Model
|
|
12
|
+
|
|
13
|
+
mdash implements defense-in-depth through three cryptographic layers:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
17
|
+
│ TRUST BOUNDARY │
|
|
18
|
+
├─────────────────────────────────────────────────────────────┤
|
|
19
|
+
│ L3: ZK Proofs (async) │ Mathematical verification │
|
|
20
|
+
│ L2: TEE Attestation (<10ms)│ Hardware-rooted trust │
|
|
21
|
+
│ L1: Commitment (<1ms) │ Cryptographic sealing │
|
|
22
|
+
├─────────────────────────────────────────────────────────────┤
|
|
23
|
+
│ UNTRUSTED: Agent Actions │
|
|
24
|
+
└─────────────────────────────────────────────────────────────┘
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Core Principle:** Every agent action is untrusted until sealed, attested, and (for high-value operations) proven.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Security Invariants
|
|
32
|
+
|
|
33
|
+
### Cryptographic Core
|
|
34
|
+
|
|
35
|
+
| ID | Invariant | Enforcement |
|
|
36
|
+
|----|-----------|-------------|
|
|
37
|
+
| `CRYPTO-INV-001` | Seal keys must be ≥32 characters | `deriveKey()` throws on violation |
|
|
38
|
+
| `CRYPTO-INV-002` | All comparisons are constant-time | `constantTimeEqual()` for seals/hashes |
|
|
39
|
+
| `CRYPTO-INV-003` | Keys are non-extractable | Web Crypto API with `extractable: false` |
|
|
40
|
+
| `CRYPTO-INV-004` | Deterministic serialization | Sorted keys via `deterministicStringify()` |
|
|
41
|
+
|
|
42
|
+
### Warrant System
|
|
43
|
+
|
|
44
|
+
| ID | Invariant | Enforcement |
|
|
45
|
+
|----|-----------|-------------|
|
|
46
|
+
| `WARRANT-INV-001` | Speculative warrants expire in 60s | Cache TTL + `speculative_expires_at` |
|
|
47
|
+
| `WARRANT-INV-002` | Revocation propagates in <100ms | Immediate cache invalidation |
|
|
48
|
+
| `WARRANT-INV-003` | Activated warrants immediately sealed | L1 commitment on activation |
|
|
49
|
+
| `WARRANT-INV-004` | Re-validate before execution | TOCTOU check in `execute()` flow |
|
|
50
|
+
| `WARRANT-INV-005` | Creation rate limited per issuer | 100/minute default |
|
|
51
|
+
|
|
52
|
+
### TEE Attestation
|
|
53
|
+
|
|
54
|
+
| ID | Invariant | Enforcement |
|
|
55
|
+
|----|-----------|-------------|
|
|
56
|
+
| `TEE-INV-001` | No silent simulated mode in production | Hard fail unless `MDASH_ALLOW_SIMULATED_TEE` |
|
|
57
|
+
| `TEE-INV-002` | Attestations expire | `expires_at` checked on verify |
|
|
58
|
+
| `TEE-INV-003` | Cross-layer reference integrity | `commitment_id` must match L1 |
|
|
59
|
+
|
|
60
|
+
### Physics Engine
|
|
61
|
+
|
|
62
|
+
| ID | Invariant | Enforcement |
|
|
63
|
+
|----|-----------|-------------|
|
|
64
|
+
| `PHYSICS-INV-001` | Explicit constraint presence checks | `hasOwnProperty` not nullish coalescing |
|
|
65
|
+
| `PHYSICS-INV-002` | Fail-closed on unknown policy | Scope violation if policy not found |
|
|
66
|
+
| `PHYSICS-INV-003` | Rate limits enforced per agent | Windowed counter per `agent_id:action` |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Attack Surface & Mitigations
|
|
71
|
+
|
|
72
|
+
### 1. TOCTOU (Time-of-Check Time-of-Use)
|
|
73
|
+
|
|
74
|
+
**Vector:** Warrant revoked between authorization check and action execution.
|
|
75
|
+
|
|
76
|
+
**Mitigation:**
|
|
77
|
+
- Re-validate `isRevoked()` immediately before `execute()` callback
|
|
78
|
+
- Attestation sealed before execution begins
|
|
79
|
+
|
|
80
|
+
**Test:** `security.test.ts` → "Concurrent Access Testing"
|
|
81
|
+
|
|
82
|
+
### 2. Cache Poisoning
|
|
83
|
+
|
|
84
|
+
**Vector:** Memory corruption or shared-memory attack injects modified warrant.
|
|
85
|
+
|
|
86
|
+
**Mitigation:**
|
|
87
|
+
- `getVerified()` method checks HMAC seal on retrieval
|
|
88
|
+
- Verification key set at engine initialization
|
|
89
|
+
- Failed verification deletes entry and logs `SECURITY:` prefix
|
|
90
|
+
|
|
91
|
+
**Test:** `security.test.ts` → "Replay Attack Resistance"
|
|
92
|
+
|
|
93
|
+
### 3. Prototype Pollution
|
|
94
|
+
|
|
95
|
+
**Vector:** `__proto__` or `constructor` injection in action params/constraints.
|
|
96
|
+
|
|
97
|
+
**Mitigation:**
|
|
98
|
+
- `sanitizeObject()` recursively strips dangerous keys
|
|
99
|
+
- Applied before physics validation
|
|
100
|
+
- Blocked keys: `__proto__`, `constructor`, `prototype`
|
|
101
|
+
|
|
102
|
+
**Test:** `security.test.ts` → "Prototype Pollution Resistance"
|
|
103
|
+
|
|
104
|
+
### 4. Information Leakage
|
|
105
|
+
|
|
106
|
+
**Vector:** Error messages reveal internal state (agent IDs, warrant existence).
|
|
107
|
+
|
|
108
|
+
**Mitigation:**
|
|
109
|
+
- All authorization failures return generic `"Authorization denied"`
|
|
110
|
+
- Details logged server-side with `console.warn('[AUTH]...')`
|
|
111
|
+
- No warrant ID, agent ID, or state in thrown errors
|
|
112
|
+
|
|
113
|
+
**Test:** `security.test.ts` → "should propagate physics validation failure"
|
|
114
|
+
|
|
115
|
+
### 5. Resource Exhaustion (DoS)
|
|
116
|
+
|
|
117
|
+
**Vector:** Flood speculative warrant creation to exhaust memory.
|
|
118
|
+
|
|
119
|
+
**Mitigation:**
|
|
120
|
+
- Per-issuer rate limiting: 100 warrants/minute
|
|
121
|
+
- Speculative warrant TTL: 60 seconds max
|
|
122
|
+
- Cache cleanup on TTL expiry
|
|
123
|
+
|
|
124
|
+
**Test:** `security.test.ts` → "should handle warrant rate limiting under burst"
|
|
125
|
+
|
|
126
|
+
### 6. Constraint Bypass
|
|
127
|
+
|
|
128
|
+
**Vector:** Pass `maxAmount: undefined` explicitly to bypass policy defaults.
|
|
129
|
+
|
|
130
|
+
**Mitigation:**
|
|
131
|
+
- Explicit presence check: `hasOwnProperty.call()` + `!== undefined`
|
|
132
|
+
- Policy defaults only apply when constraint truly absent
|
|
133
|
+
|
|
134
|
+
**Test:** `security.test.ts` → "Boundary Value Fuzzing"
|
|
135
|
+
|
|
136
|
+
### 7. Replay Attacks
|
|
137
|
+
|
|
138
|
+
**Vector:** Re-present old attestation documents.
|
|
139
|
+
|
|
140
|
+
**Mitigation:**
|
|
141
|
+
- Attestation `expires_at` checked on verify
|
|
142
|
+
- Unique ID per attestation (UUID)
|
|
143
|
+
- L1 commitment reference must exist
|
|
144
|
+
- Seal verification detects tampering
|
|
145
|
+
|
|
146
|
+
**Test:** `security.test.ts` → "Replay Attack Resistance"
|
|
147
|
+
|
|
148
|
+
### 8. Weak Key Material
|
|
149
|
+
|
|
150
|
+
**Vector:** Empty or short seal keys produce weak HMACs.
|
|
151
|
+
|
|
152
|
+
**Mitigation:**
|
|
153
|
+
- `deriveKey()` requires minimum 32 characters
|
|
154
|
+
- Throws before any crypto operations
|
|
155
|
+
|
|
156
|
+
**Test:** `security.test.ts` → "should reject empty/short seal key"
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Boundary Trust Model
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
TRUSTED (server-side):
|
|
164
|
+
├── Seal key (environment variable)
|
|
165
|
+
├── Policy definitions
|
|
166
|
+
├── TEE platform configuration
|
|
167
|
+
└── Rate limit settings
|
|
168
|
+
|
|
169
|
+
UNTRUSTED (must validate):
|
|
170
|
+
├── Agent ID (any string)
|
|
171
|
+
├── Action parameters (sanitized)
|
|
172
|
+
├── Constraint values (bounds checked)
|
|
173
|
+
├── Timestamps (compared against server time)
|
|
174
|
+
└── Warrant requests (rate limited, sealed)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Error Handling Philosophy
|
|
180
|
+
|
|
181
|
+
1. **Fail closed** — Deny by default, require explicit authorization
|
|
182
|
+
2. **Log internally** — Full context for debugging
|
|
183
|
+
3. **Generic externally** — No information leakage to callers
|
|
184
|
+
4. **Audit trail** — Checkpoints created even on failure
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
// Pattern used throughout:
|
|
188
|
+
if (!authorized) {
|
|
189
|
+
console.warn(`[AUTH] Denied: ${internalDetails}`);
|
|
190
|
+
await checkpoint.onError({ ...fullContext });
|
|
191
|
+
throw new Error('Authorization denied'); // Generic
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Test Coverage
|
|
198
|
+
|
|
199
|
+
| Category | Tests | Coverage |
|
|
200
|
+
|----------|-------|----------|
|
|
201
|
+
| Cryptographic primitives | 15 | SHA-256, HMAC, constant-time |
|
|
202
|
+
| Commitment layer | 20 | Merkle tree, proofs, sealing |
|
|
203
|
+
| Warrant system | 35 | Lifecycle, cache, revocation |
|
|
204
|
+
| Checkpoint surety | 30 | Events, lattice, blast radius |
|
|
205
|
+
| TEE attestation | 20 | Platforms, verification, bridge |
|
|
206
|
+
| ZK proofs | 15 | Circuits, queue, claims |
|
|
207
|
+
| MCCA | 12 | Fragments, influence, drift |
|
|
208
|
+
| **Security (adversarial)** | **33** | **Fuzzing, TOCTOU, replay, injection** |
|
|
209
|
+
| **Total** | **251** | |
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Incident Response
|
|
214
|
+
|
|
215
|
+
If a security issue is discovered:
|
|
216
|
+
|
|
217
|
+
1. **Immediate:** Revoke affected warrants via `warrant.revoke()`
|
|
218
|
+
2. **Contain:** Rate limits will slow ongoing attacks
|
|
219
|
+
3. **Audit:** ZK proofs provide mathematical verification of historical actions
|
|
220
|
+
4. **Recover:** Checkpoint lattice identifies blast radius
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Known Behaviors (Documented, Not Vulnerabilities)
|
|
225
|
+
|
|
226
|
+
| Behavior | Status | Notes |
|
|
227
|
+
|----------|--------|-------|
|
|
228
|
+
| NaN passes constraint checks | Documented | `NaN > X` is always `false` |
|
|
229
|
+
| Negative amounts allowed | Documented | No `minAmount` in default policies |
|
|
230
|
+
| Unicode not normalized | Documented | Same visual string may hash differently |
|
|
231
|
+
| Warrant expiry mid-execution | Documented | Action completes if started before expiry |
|
|
232
|
+
|
|
233
|
+
These are tested and documented in `security.test.ts` with explicit comments.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Audit History
|
|
238
|
+
|
|
239
|
+
| Date | Auditor | Findings | Resolution |
|
|
240
|
+
|------|---------|----------|------------|
|
|
241
|
+
| 2026-01-26 | Kai (security-reasoning skill) | 7 issues (P1-P5) | All patched, 33 tests added |
|
|
242
|
+
| 2026-01-28 | Kai (security-reasoning-v2-tob-enhanced) | 0 new issues | Verified all patches, production ready |
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## References
|
|
247
|
+
|
|
248
|
+
- `security.test.ts` — Adversarial test suite
|
|
249
|
+
- `SECURITY-PATCHES.md` — Detailed patch notes from 2026-01-26 audit
|
|
250
|
+
- `security-reasoning-v2-tob-enhanced` — Enhanced reasoning skill (Trail of Bits inspired, upgraded 2026-01-28)
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
*Governance without control. Complexity without chaos.* 🫡
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.1 — AccountabilityEngine
|
|
3
|
+
*
|
|
4
|
+
* Unified consumer API: warrants + commitments in one class.
|
|
5
|
+
* Composes CommitmentEngine (attestation) and WarrantEngine (warrant lifecycle).
|
|
6
|
+
*
|
|
7
|
+
* Consumer story: import { AccountabilityEngine } from '@longarc/mdash'
|
|
8
|
+
* One class, full accountability lifecycle.
|
|
9
|
+
*/
|
|
10
|
+
import type { Commitment } from '../core/commitment.js';
|
|
11
|
+
import type { WarrantPermissions, ActionResult, AuditSummary } from './types.js';
|
|
12
|
+
export declare class AccountabilityEngine {
|
|
13
|
+
private commitmentEngine;
|
|
14
|
+
private warrantEngine;
|
|
15
|
+
private managedWarrants;
|
|
16
|
+
private auditLog;
|
|
17
|
+
private actionCounters;
|
|
18
|
+
constructor();
|
|
19
|
+
initialize(sealKey: string): Promise<void>;
|
|
20
|
+
issueWarrant(agentId: string, permissions: WarrantPermissions): Promise<void>;
|
|
21
|
+
revokeWarrant(agentId: string): void;
|
|
22
|
+
executeAction(agentId: string, action: string, params: unknown): Promise<ActionResult>;
|
|
23
|
+
getAuditSummary(): AuditSummary;
|
|
24
|
+
verifyCommitment(commitment: Commitment): Promise<boolean>;
|
|
25
|
+
private deny;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/accountability/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,KAAK,EACV,kBAAkB,EAGlB,YAAY,EAEZ,YAAY,EACb,MAAM,YAAY,CAAC;AAWpB,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,eAAe,CAA0C;IACjE,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,cAAc,CAAkC;;IAOlD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnF,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAiB9B,aAAa,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,YAAY,CAAC;IA2FxB,eAAe,IAAI,YAAY;IAWzB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhE,OAAO,CAAC,IAAI;CA2Bb"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.1 — AccountabilityEngine
|
|
3
|
+
*
|
|
4
|
+
* Unified consumer API: warrants + commitments in one class.
|
|
5
|
+
* Composes CommitmentEngine (attestation) and WarrantEngine (warrant lifecycle).
|
|
6
|
+
*
|
|
7
|
+
* Consumer story: import { AccountabilityEngine } from '@longarc/mdash'
|
|
8
|
+
* One class, full accountability lifecycle.
|
|
9
|
+
*/
|
|
10
|
+
import { CommitmentEngine } from '../core/commitment.js';
|
|
11
|
+
import { WarrantEngine } from '../warrant/engine.js';
|
|
12
|
+
export class AccountabilityEngine {
|
|
13
|
+
commitmentEngine;
|
|
14
|
+
warrantEngine;
|
|
15
|
+
managedWarrants = new Map();
|
|
16
|
+
auditLog = [];
|
|
17
|
+
actionCounters = new Map();
|
|
18
|
+
constructor() {
|
|
19
|
+
this.commitmentEngine = new CommitmentEngine();
|
|
20
|
+
this.warrantEngine = new WarrantEngine(this.commitmentEngine);
|
|
21
|
+
}
|
|
22
|
+
async initialize(sealKey) {
|
|
23
|
+
await this.commitmentEngine.initialize(sealKey);
|
|
24
|
+
await this.warrantEngine.initialize(sealKey);
|
|
25
|
+
}
|
|
26
|
+
async issueWarrant(agentId, permissions) {
|
|
27
|
+
// Create a crypto-sealed infrastructure warrant via WarrantEngine
|
|
28
|
+
const speculative = await this.warrantEngine.createSpeculative({
|
|
29
|
+
agent_id: agentId,
|
|
30
|
+
policy_id: 'accountability-default',
|
|
31
|
+
tier: 'T1',
|
|
32
|
+
constraints: {
|
|
33
|
+
maxCalls: permissions.maxExecutions,
|
|
34
|
+
},
|
|
35
|
+
duration_ms: permissions.ttlMs,
|
|
36
|
+
issued_by: 'accountability-engine',
|
|
37
|
+
});
|
|
38
|
+
// Activate immediately — consumer warrants are active on issuance
|
|
39
|
+
const activated = await this.warrantEngine.activate(speculative.id);
|
|
40
|
+
this.managedWarrants.set(agentId, {
|
|
41
|
+
agentId,
|
|
42
|
+
permissions,
|
|
43
|
+
issuedAt: Date.now(),
|
|
44
|
+
status: 'ACTIVE',
|
|
45
|
+
executionCount: 0,
|
|
46
|
+
infraWarrantId: activated.id,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
revokeWarrant(agentId) {
|
|
50
|
+
const managed = this.managedWarrants.get(agentId);
|
|
51
|
+
if (!managed)
|
|
52
|
+
return;
|
|
53
|
+
managed.status = 'REVOKED';
|
|
54
|
+
// Best-effort infrastructure-level revocation (fire-and-forget)
|
|
55
|
+
this.warrantEngine
|
|
56
|
+
.revoke(managed.infraWarrantId, 'Consumer API revocation', {
|
|
57
|
+
type: 'system',
|
|
58
|
+
id: 'accountability-engine',
|
|
59
|
+
})
|
|
60
|
+
.catch(() => {
|
|
61
|
+
// Infra warrant may have already expired from cache — local state is authoritative
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async executeAction(agentId, action, params) {
|
|
65
|
+
const managed = this.managedWarrants.get(agentId);
|
|
66
|
+
// No warrant issued for this agent
|
|
67
|
+
if (!managed) {
|
|
68
|
+
return this.deny(agentId, action, 'NO_WARRANT', `No warrant found for agent '${agentId}'`);
|
|
69
|
+
}
|
|
70
|
+
// Check infrastructure-level revocation (propagates across caches)
|
|
71
|
+
if (this.warrantEngine.isRevoked(managed.infraWarrantId)) {
|
|
72
|
+
managed.status = 'REVOKED';
|
|
73
|
+
}
|
|
74
|
+
// Revoked
|
|
75
|
+
if (managed.status === 'REVOKED') {
|
|
76
|
+
return this.deny(agentId, action, 'WARRANT_REVOKED', `Warrant for agent '${agentId}' has been revoked`, managed.infraWarrantId);
|
|
77
|
+
}
|
|
78
|
+
// Expired
|
|
79
|
+
if (Date.now() - managed.issuedAt > managed.permissions.ttlMs) {
|
|
80
|
+
managed.status = 'EXPIRED';
|
|
81
|
+
return this.deny(agentId, action, 'WARRANT_EXPIRED', `Warrant for agent '${agentId}' has expired`, managed.infraWarrantId);
|
|
82
|
+
}
|
|
83
|
+
// Execution limit
|
|
84
|
+
if (managed.permissions.maxExecutions !== undefined &&
|
|
85
|
+
managed.executionCount >= managed.permissions.maxExecutions) {
|
|
86
|
+
return this.deny(agentId, action, 'EXECUTION_LIMIT_REACHED', `Agent '${agentId}' has reached execution limit of ${managed.permissions.maxExecutions}`, managed.infraWarrantId);
|
|
87
|
+
}
|
|
88
|
+
// Forbidden action (explicit deny takes precedence)
|
|
89
|
+
if (managed.permissions.forbiddenActions.includes(action)) {
|
|
90
|
+
return this.deny(agentId, action, 'FORBIDDEN_ACTION', `Action '${action}' is explicitly forbidden for agent '${agentId}'`, managed.infraWarrantId);
|
|
91
|
+
}
|
|
92
|
+
// Not in allowed list
|
|
93
|
+
if (!managed.permissions.allowedActions.includes(action)) {
|
|
94
|
+
return this.deny(agentId, action, 'UNAUTHORIZED_ACTION', `Action '${action}' is not in the allowed list for agent '${agentId}'`, managed.infraWarrantId);
|
|
95
|
+
}
|
|
96
|
+
// ── AUTHORIZED — commit attestation ──
|
|
97
|
+
managed.executionCount++;
|
|
98
|
+
const count = (this.actionCounters.get(agentId) || 0) + 1;
|
|
99
|
+
this.actionCounters.set(agentId, count);
|
|
100
|
+
const commitId = `${agentId}-action-${count}`;
|
|
101
|
+
const commitment = await this.commitmentEngine.commit({ agentId, action, params, timestamp: Date.now() }, commitId);
|
|
102
|
+
const verified = await this.commitmentEngine.verify(commitment);
|
|
103
|
+
this.auditLog.push({
|
|
104
|
+
type: 'ATTESTED_ACTION',
|
|
105
|
+
agentId,
|
|
106
|
+
action,
|
|
107
|
+
timestamp: Date.now(),
|
|
108
|
+
commitId,
|
|
109
|
+
contentHash: commitment.content_hash,
|
|
110
|
+
verified,
|
|
111
|
+
warrantId: managed.infraWarrantId,
|
|
112
|
+
});
|
|
113
|
+
return { executed: true, commitment, verified };
|
|
114
|
+
}
|
|
115
|
+
getAuditSummary() {
|
|
116
|
+
const authorized = this.auditLog.filter(r => r.type === 'ATTESTED_ACTION').length;
|
|
117
|
+
const denied = this.auditLog.filter(r => r.type !== 'ATTESTED_ACTION').length;
|
|
118
|
+
return {
|
|
119
|
+
total: this.auditLog.length,
|
|
120
|
+
authorized,
|
|
121
|
+
denied,
|
|
122
|
+
log: [...this.auditLog],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async verifyCommitment(commitment) {
|
|
126
|
+
return this.commitmentEngine.verify(commitment);
|
|
127
|
+
}
|
|
128
|
+
deny(agentId, action, type, detail, warrantId) {
|
|
129
|
+
const violation = {
|
|
130
|
+
type,
|
|
131
|
+
agentId,
|
|
132
|
+
action,
|
|
133
|
+
timestamp: Date.now(),
|
|
134
|
+
detail,
|
|
135
|
+
warrantId,
|
|
136
|
+
};
|
|
137
|
+
this.auditLog.push({
|
|
138
|
+
type,
|
|
139
|
+
agentId,
|
|
140
|
+
action,
|
|
141
|
+
timestamp: Date.now(),
|
|
142
|
+
detail,
|
|
143
|
+
warrantId,
|
|
144
|
+
});
|
|
145
|
+
return { executed: false, violation };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/accountability/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,aAAa,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U,CAAC,CAAC;IAClD,CAAC;IAEO,IAAI,CACV,OAAe,EACf,MAAc,EACd,IAAmB,EACnB,MAAc,EACd,SAAqB;QAErB,MAAM,SAAS,GAAc;YAC3B,IAAI;YACJ,OAAO;YACP,MAAM;YACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,MAAM;YACN,SAAS;SACV,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACjB,IAAI;YACJ,OAAO;YACP,MAAM;YACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,MAAM;YACN,SAAS;SACV,CAAC,CAAC;QAEH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.1 — Accountability Engine Types
|
|
3
|
+
*
|
|
4
|
+
* Consumer-facing types for the unified accountability API.
|
|
5
|
+
* Warrants + Commitments in a single lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
import type { Commitment } from '../core/commitment.js';
|
|
8
|
+
export interface WarrantPermissions {
|
|
9
|
+
allowedActions: string[];
|
|
10
|
+
forbiddenActions: string[];
|
|
11
|
+
ttlMs: number;
|
|
12
|
+
maxExecutions?: number;
|
|
13
|
+
}
|
|
14
|
+
export type ViolationType = 'FORBIDDEN_ACTION' | 'UNAUTHORIZED_ACTION' | 'WARRANT_EXPIRED' | 'WARRANT_REVOKED' | 'EXECUTION_LIMIT_REACHED' | 'NO_WARRANT';
|
|
15
|
+
export interface Violation {
|
|
16
|
+
type: ViolationType;
|
|
17
|
+
agentId: string;
|
|
18
|
+
action: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
detail: string;
|
|
21
|
+
warrantId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ActionResult {
|
|
24
|
+
executed: boolean;
|
|
25
|
+
commitment?: Commitment;
|
|
26
|
+
verified?: boolean;
|
|
27
|
+
violation?: Violation;
|
|
28
|
+
}
|
|
29
|
+
export interface AuditRecord {
|
|
30
|
+
type: 'ATTESTED_ACTION' | ViolationType;
|
|
31
|
+
agentId: string;
|
|
32
|
+
action: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
commitId?: string;
|
|
35
|
+
contentHash?: string;
|
|
36
|
+
verified?: boolean;
|
|
37
|
+
detail?: string;
|
|
38
|
+
warrantId?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AuditSummary {
|
|
41
|
+
total: number;
|
|
42
|
+
authorized: number;
|
|
43
|
+
denied: number;
|
|
44
|
+
log: AuditRecord[];
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/accountability/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GACrB,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,GACjB,yBAAyB,GACzB,YAAY,CAAC;AAEjB,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE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