@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/src/physics/engine.ts
CHANGED
|
@@ -289,6 +289,7 @@ export class PhysicsEngine {
|
|
|
289
289
|
|
|
290
290
|
/**
|
|
291
291
|
* Check a specific constraint
|
|
292
|
+
* P4 SECURITY: Explicit presence checks prevent trust escalation
|
|
292
293
|
*/
|
|
293
294
|
private async checkConstraint(
|
|
294
295
|
constraint: PhysicsConstraint,
|
|
@@ -298,8 +299,38 @@ export class PhysicsEngine {
|
|
|
298
299
|
switch (constraint.type) {
|
|
299
300
|
case 'max_amount': {
|
|
300
301
|
const amount = action.params.amount as number | undefined;
|
|
301
|
-
|
|
302
|
-
|
|
302
|
+
|
|
303
|
+
// SA-2026-011: Explicit NaN and negative rejection
|
|
304
|
+
// NaN > X is always false in JS, bypassing maxAmount constraints.
|
|
305
|
+
// Negative amounts have no floor without explicit check.
|
|
306
|
+
if (amount !== undefined) {
|
|
307
|
+
if (typeof amount !== 'number' || isNaN(amount)) {
|
|
308
|
+
return {
|
|
309
|
+
type: 'amount_exceeded',
|
|
310
|
+
constraint,
|
|
311
|
+
message: 'Amount is not a valid number',
|
|
312
|
+
severity: 'block',
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (amount < 0) {
|
|
316
|
+
return {
|
|
317
|
+
type: 'amount_exceeded',
|
|
318
|
+
constraint,
|
|
319
|
+
message: 'Negative amounts are not permitted',
|
|
320
|
+
severity: 'block',
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// P4 SECURITY: Explicit presence check - warrant must define maxAmount
|
|
326
|
+
// or policy default applies. Explicitly passing undefined is NOT the same
|
|
327
|
+
// as not having the constraint.
|
|
328
|
+
const hasWarrantLimit = Object.prototype.hasOwnProperty.call(warrantConstraints, 'maxAmount')
|
|
329
|
+
&& warrantConstraints.maxAmount !== undefined;
|
|
330
|
+
const limit = hasWarrantLimit
|
|
331
|
+
? warrantConstraints.maxAmount!
|
|
332
|
+
: (constraint.params.limit as number);
|
|
333
|
+
|
|
303
334
|
if (amount !== undefined && amount > limit) {
|
|
304
335
|
return {
|
|
305
336
|
type: 'amount_exceeded',
|
|
@@ -313,7 +344,13 @@ export class PhysicsEngine {
|
|
|
313
344
|
|
|
314
345
|
case 'domain_allowlist': {
|
|
315
346
|
const domain = action.params.domain as string | undefined;
|
|
316
|
-
|
|
347
|
+
|
|
348
|
+
// P4 SECURITY: Same pattern - explicit presence check
|
|
349
|
+
const hasWarrantDomains = Object.prototype.hasOwnProperty.call(warrantConstraints, 'allowedDomains')
|
|
350
|
+
&& warrantConstraints.allowedDomains !== undefined;
|
|
351
|
+
const allowed = hasWarrantDomains
|
|
352
|
+
? warrantConstraints.allowedDomains!
|
|
353
|
+
: (constraint.params.domains as string[]);
|
|
317
354
|
|
|
318
355
|
if (domain && allowed.length > 0 && !allowed.includes(domain)) {
|
|
319
356
|
return {
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.1 - Provenance API Handler
|
|
3
|
+
*
|
|
4
|
+
* Wires HTTP request/response types to the ProvenanceEngine.
|
|
5
|
+
* This is the door: external parties call through here to
|
|
6
|
+
* attest, verify, and inspect model provenance.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ProvenanceEngine } from './provenance-engine.js';
|
|
10
|
+
import type {
|
|
11
|
+
AttestRequest,
|
|
12
|
+
AttestResponse,
|
|
13
|
+
VerifyRequest,
|
|
14
|
+
VerifyResponse,
|
|
15
|
+
ChainResponse,
|
|
16
|
+
} from './api-types.js';
|
|
17
|
+
|
|
18
|
+
export class ProvenanceApiHandler {
|
|
19
|
+
private engine: ProvenanceEngine;
|
|
20
|
+
|
|
21
|
+
constructor(engine: ProvenanceEngine) {
|
|
22
|
+
this.engine = engine;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Handle POST /provenance/attest
|
|
27
|
+
*
|
|
28
|
+
* Validates the request, creates the identity attestation,
|
|
29
|
+
* and returns the attestation ID and L1 hash.
|
|
30
|
+
*/
|
|
31
|
+
async handleAttest(req: AttestRequest): Promise<{ status: number; body: AttestResponse }> {
|
|
32
|
+
// Validate required fields
|
|
33
|
+
const missing: string[] = [];
|
|
34
|
+
if (!req.model?.name) missing.push('model.name');
|
|
35
|
+
if (!req.model?.version) missing.push('model.version');
|
|
36
|
+
if (!req.model?.provider) missing.push('model.provider');
|
|
37
|
+
if (!req.deployment?.environment) missing.push('deployment.environment');
|
|
38
|
+
|
|
39
|
+
if (missing.length > 0) {
|
|
40
|
+
return {
|
|
41
|
+
status: 400,
|
|
42
|
+
body: {
|
|
43
|
+
attestationId: '',
|
|
44
|
+
l1Hash: '',
|
|
45
|
+
timestamp: '',
|
|
46
|
+
status: 'error',
|
|
47
|
+
error: `Missing required fields: ${missing.join(', ')}`,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check for duplicate (409)
|
|
53
|
+
const existing = this.engine.getIdentity(req.model.name, req.model.version);
|
|
54
|
+
if (existing) {
|
|
55
|
+
return {
|
|
56
|
+
status: 409,
|
|
57
|
+
body: {
|
|
58
|
+
attestationId: existing.id,
|
|
59
|
+
l1Hash: existing.attestation.l1Hash,
|
|
60
|
+
timestamp: existing.attestation.timestamp,
|
|
61
|
+
status: 'error',
|
|
62
|
+
error: `Attestation for ${req.model.name}:${req.model.version} already exists`,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const constraints = {
|
|
69
|
+
safetyTier: req.constraints.safetyTier,
|
|
70
|
+
authorizedDomains: req.constraints.authorizedDomains,
|
|
71
|
+
excludedDomains: req.constraints.excludedDomains,
|
|
72
|
+
maxContextWindow: req.constraints.maxContextWindow,
|
|
73
|
+
reasoningEnabled: req.constraints.reasoningEnabled,
|
|
74
|
+
custom: req.constraints.custom || {},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const attestation = await this.engine.createIdentityAttestation(
|
|
78
|
+
req.model,
|
|
79
|
+
constraints,
|
|
80
|
+
req.deployment
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
status: 201,
|
|
85
|
+
body: {
|
|
86
|
+
attestationId: attestation.id,
|
|
87
|
+
l1Hash: attestation.attestation.l1Hash,
|
|
88
|
+
timestamp: attestation.attestation.timestamp,
|
|
89
|
+
status: 'created',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
} catch (err) {
|
|
93
|
+
return {
|
|
94
|
+
status: 500,
|
|
95
|
+
body: {
|
|
96
|
+
attestationId: '',
|
|
97
|
+
l1Hash: '',
|
|
98
|
+
timestamp: '',
|
|
99
|
+
status: 'error',
|
|
100
|
+
error: err instanceof Error ? err.message : 'Internal error',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Handle POST /provenance/verify
|
|
108
|
+
*
|
|
109
|
+
* Validates the request, runs provenance verification,
|
|
110
|
+
* and returns the chain verdict with optional ZK proof.
|
|
111
|
+
*/
|
|
112
|
+
async handleVerify(req: VerifyRequest): Promise<{ status: number; body: VerifyResponse }> {
|
|
113
|
+
if (!req.modelName) {
|
|
114
|
+
return {
|
|
115
|
+
status: 400,
|
|
116
|
+
body: {
|
|
117
|
+
status: 'error',
|
|
118
|
+
chain: { isComplete: false, confidence: 0, assessment: '', flags: [] },
|
|
119
|
+
timestamp: '',
|
|
120
|
+
responseHash: '',
|
|
121
|
+
error: 'Missing required field: modelName',
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const response = await this.engine.verifyProvenance({
|
|
128
|
+
queryType: req.queryType || 'full_chain',
|
|
129
|
+
modelName: req.modelName,
|
|
130
|
+
modelVersion: req.modelVersion,
|
|
131
|
+
timeWindow: req.timeWindow,
|
|
132
|
+
requireHardwareAttestation: req.requireHardwareAttestation || false,
|
|
133
|
+
generateZkProof: req.generateZkProof || false,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const isVerified = response.chain.verdict.isComplete;
|
|
137
|
+
const isPartial = !isVerified && response.chain.verdict.confidence > 0;
|
|
138
|
+
const httpStatus = isVerified ? 200 : (response.chain.verdict.flags.includes('no_identity') ? 404 : 200);
|
|
139
|
+
|
|
140
|
+
let verifyStatus: VerifyResponse['status'];
|
|
141
|
+
if (isVerified) {
|
|
142
|
+
verifyStatus = 'verified';
|
|
143
|
+
} else if (isPartial) {
|
|
144
|
+
verifyStatus = 'partial';
|
|
145
|
+
} else {
|
|
146
|
+
verifyStatus = 'unverified';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
status: httpStatus,
|
|
151
|
+
body: {
|
|
152
|
+
status: verifyStatus,
|
|
153
|
+
chain: {
|
|
154
|
+
isComplete: response.chain.verdict.isComplete,
|
|
155
|
+
confidence: response.chain.verdict.confidence,
|
|
156
|
+
assessment: response.chain.verdict.assessment,
|
|
157
|
+
flags: response.chain.verdict.flags,
|
|
158
|
+
},
|
|
159
|
+
zkProof: response.zkProof,
|
|
160
|
+
timestamp: response.timestamp,
|
|
161
|
+
responseHash: response.responseHash,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
} catch (err) {
|
|
165
|
+
return {
|
|
166
|
+
status: 500,
|
|
167
|
+
body: {
|
|
168
|
+
status: 'error',
|
|
169
|
+
chain: { isComplete: false, confidence: 0, assessment: '', flags: [] },
|
|
170
|
+
timestamp: '',
|
|
171
|
+
responseHash: '',
|
|
172
|
+
error: err instanceof Error ? err.message : 'Internal error',
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Handle GET /provenance/chain/:modelId
|
|
180
|
+
*
|
|
181
|
+
* Retrieves the full provenance chain for a model.
|
|
182
|
+
* modelId format: "name:version"
|
|
183
|
+
*/
|
|
184
|
+
async handleGetChain(modelId: string): Promise<{ status: number; body: ChainResponse }> {
|
|
185
|
+
const [modelName, modelVersion] = modelId.split(':');
|
|
186
|
+
|
|
187
|
+
const chain = this.engine.getChain(modelName, modelVersion);
|
|
188
|
+
if (!chain) {
|
|
189
|
+
// Try verifying to build a minimal chain from identity
|
|
190
|
+
const identity = this.engine.getIdentity(modelName, modelVersion);
|
|
191
|
+
if (!identity) {
|
|
192
|
+
return {
|
|
193
|
+
status: 404,
|
|
194
|
+
body: {
|
|
195
|
+
modelId,
|
|
196
|
+
identity: { name: modelName || '', version: modelVersion || '', provider: '', attestedAt: '', l1Hash: '' },
|
|
197
|
+
warrants: { total: 0, active: 0, revoked: 0, chainHash: '' },
|
|
198
|
+
behavior: { totalSessions: 0, totalActions: 0, violations: 0 },
|
|
199
|
+
verdict: { isComplete: false, confidence: 0, assessment: 'Model not found', flags: ['no_identity'] },
|
|
200
|
+
chainAttestation: { l1Hash: '', timestamp: '' },
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Build minimal chain from identity alone
|
|
206
|
+
const minimalChain = await this.engine.buildProvenanceChain(identity, [], []);
|
|
207
|
+
return {
|
|
208
|
+
status: 200,
|
|
209
|
+
body: this.mapChainResponse(modelId, minimalChain),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
status: 200,
|
|
215
|
+
body: this.mapChainResponse(modelId, chain),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private mapChainResponse(
|
|
220
|
+
modelId: string,
|
|
221
|
+
chain: import('./types.js').ProvenanceChain
|
|
222
|
+
): ChainResponse {
|
|
223
|
+
return {
|
|
224
|
+
modelId,
|
|
225
|
+
identity: {
|
|
226
|
+
name: chain.identity.model.name,
|
|
227
|
+
version: chain.identity.model.version,
|
|
228
|
+
provider: chain.identity.model.provider,
|
|
229
|
+
attestedAt: chain.identity.attestation.timestamp,
|
|
230
|
+
l1Hash: chain.identity.attestation.l1Hash,
|
|
231
|
+
},
|
|
232
|
+
warrants: {
|
|
233
|
+
total: chain.warrantHistory.totalWarrants,
|
|
234
|
+
active: chain.warrantHistory.activeWarrants,
|
|
235
|
+
revoked: chain.warrantHistory.revokedWarrants,
|
|
236
|
+
chainHash: chain.warrantHistory.warrantChainHash,
|
|
237
|
+
},
|
|
238
|
+
behavior: {
|
|
239
|
+
totalSessions: chain.behavioralRecord.totalSessions,
|
|
240
|
+
totalActions: chain.behavioralRecord.totalActions,
|
|
241
|
+
violations: chain.behavioralRecord.violations,
|
|
242
|
+
latestDriftScore: chain.behavioralRecord.latestDriftReport?.compositeScore,
|
|
243
|
+
},
|
|
244
|
+
verdict: chain.verdict,
|
|
245
|
+
chainAttestation: chain.chainAttestation,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mdash v3.1 - Provenance API Types
|
|
3
|
+
*
|
|
4
|
+
* HTTP request/response types for the provenance API surface.
|
|
5
|
+
* These types define the contract between external callers
|
|
6
|
+
* and the ProvenanceEngine.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* POST /provenance/attest
|
|
11
|
+
* Called by model providers to register a model's identity.
|
|
12
|
+
*/
|
|
13
|
+
export interface AttestRequest {
|
|
14
|
+
model: {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
manifestHash?: string;
|
|
18
|
+
provider: string;
|
|
19
|
+
};
|
|
20
|
+
constraints: {
|
|
21
|
+
safetyTier: string;
|
|
22
|
+
authorizedDomains: string[];
|
|
23
|
+
excludedDomains: string[];
|
|
24
|
+
maxContextWindow: number;
|
|
25
|
+
reasoningEnabled: boolean;
|
|
26
|
+
custom?: Record<string, string | number | boolean>;
|
|
27
|
+
};
|
|
28
|
+
deployment: {
|
|
29
|
+
environment: string;
|
|
30
|
+
region?: string;
|
|
31
|
+
tenantId?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface AttestResponse {
|
|
36
|
+
attestationId: string;
|
|
37
|
+
l1Hash: string;
|
|
38
|
+
timestamp: string;
|
|
39
|
+
status: 'created' | 'error';
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* POST /provenance/verify
|
|
45
|
+
* Called by verifiers to check a model's provenance.
|
|
46
|
+
*/
|
|
47
|
+
export interface VerifyRequest {
|
|
48
|
+
modelName: string;
|
|
49
|
+
modelVersion?: string;
|
|
50
|
+
queryType: 'identity' | 'constraints' | 'behavior' | 'full_chain';
|
|
51
|
+
timeWindow?: {
|
|
52
|
+
start: string;
|
|
53
|
+
end: string;
|
|
54
|
+
};
|
|
55
|
+
requireHardwareAttestation?: boolean;
|
|
56
|
+
generateZkProof?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface VerifyResponse {
|
|
60
|
+
status: 'verified' | 'unverified' | 'partial' | 'error';
|
|
61
|
+
chain: {
|
|
62
|
+
isComplete: boolean;
|
|
63
|
+
confidence: number;
|
|
64
|
+
assessment: string;
|
|
65
|
+
flags: string[];
|
|
66
|
+
};
|
|
67
|
+
zkProof?: {
|
|
68
|
+
claim: string;
|
|
69
|
+
proof: string;
|
|
70
|
+
verificationKey: string;
|
|
71
|
+
};
|
|
72
|
+
timestamp: string;
|
|
73
|
+
responseHash: string;
|
|
74
|
+
error?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* GET /provenance/chain/:modelId
|
|
79
|
+
* Called by regulators to retrieve the full provenance chain.
|
|
80
|
+
*/
|
|
81
|
+
export interface ChainResponse {
|
|
82
|
+
modelId: string;
|
|
83
|
+
identity: {
|
|
84
|
+
name: string;
|
|
85
|
+
version: string;
|
|
86
|
+
provider: string;
|
|
87
|
+
attestedAt: string;
|
|
88
|
+
l1Hash: string;
|
|
89
|
+
};
|
|
90
|
+
warrants: {
|
|
91
|
+
total: number;
|
|
92
|
+
active: number;
|
|
93
|
+
revoked: number;
|
|
94
|
+
chainHash: string;
|
|
95
|
+
};
|
|
96
|
+
behavior: {
|
|
97
|
+
totalSessions: number;
|
|
98
|
+
totalActions: number;
|
|
99
|
+
violations: number;
|
|
100
|
+
latestDriftScore?: number;
|
|
101
|
+
};
|
|
102
|
+
verdict: {
|
|
103
|
+
isComplete: boolean;
|
|
104
|
+
confidence: number;
|
|
105
|
+
assessment: string;
|
|
106
|
+
flags: string[];
|
|
107
|
+
};
|
|
108
|
+
chainAttestation: {
|
|
109
|
+
l1Hash: string;
|
|
110
|
+
timestamp: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
ModelIdentityAttestation,
|
|
3
|
+
ProvenanceChain,
|
|
4
|
+
ProvenanceQuery,
|
|
5
|
+
ProvenanceResponse,
|
|
6
|
+
GlossEntry,
|
|
7
|
+
} from './types.js';
|
|
8
|
+
|
|
9
|
+
export { ProvenanceEngine } from './provenance-engine.js';
|
|
10
|
+
export type { DriftReportInput } from './provenance-engine.js';
|
|
11
|
+
|
|
12
|
+
export { ProvenanceApiHandler } from './api-handler.js';
|
|
13
|
+
export type {
|
|
14
|
+
AttestRequest,
|
|
15
|
+
AttestResponse,
|
|
16
|
+
VerifyRequest,
|
|
17
|
+
VerifyResponse,
|
|
18
|
+
ChainResponse,
|
|
19
|
+
} from './api-types.js';
|