@aigrc/core 0.1.0 → 0.2.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/dist/air/index.d.mts +1669 -0
- package/dist/air/index.d.ts +1669 -0
- package/dist/air/index.js +450 -0
- package/dist/air/index.js.map +1 -0
- package/dist/air/index.mjs +410 -0
- package/dist/air/index.mjs.map +1 -0
- package/dist/governance-lock/index.d.mts +903 -0
- package/dist/governance-lock/index.d.ts +903 -0
- package/dist/governance-lock/index.js +444 -0
- package/dist/governance-lock/index.js.map +1 -0
- package/dist/governance-lock/index.mjs +389 -0
- package/dist/governance-lock/index.mjs.map +1 -0
- package/dist/index.d.mts +467 -4
- package/dist/index.d.ts +467 -4
- package/dist/index.js +2213 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2114 -2
- package/dist/index.mjs.map +1 -1
- package/dist/schemas/index.d.mts +1950 -29
- package/dist/schemas/index.d.ts +1950 -29
- package/dist/schemas/index.js +354 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/index.mjs +332 -1
- package/dist/schemas/index.mjs.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// src/governance-lock/index.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import * as yaml from "yaml";
|
|
4
|
+
var GovernanceLockSignatureSchema = z.object({
|
|
5
|
+
/** Signer identity (email or system ID) */
|
|
6
|
+
signer: z.string().min(1),
|
|
7
|
+
/** Role of the signer (e.g., "CISO", "PolicyOwner", "SecurityLead") */
|
|
8
|
+
role: z.string().optional(),
|
|
9
|
+
/** Algorithm used: RS256 (RSA-SHA256) or ES256 (ECDSA-P256) */
|
|
10
|
+
algorithm: z.enum(["RS256", "ES256"]),
|
|
11
|
+
/** Base64-encoded signature */
|
|
12
|
+
signature: z.string().min(1),
|
|
13
|
+
/** When the signature was created */
|
|
14
|
+
signed_at: z.string().datetime(),
|
|
15
|
+
/** Key ID for key rotation support */
|
|
16
|
+
key_id: z.string().optional(),
|
|
17
|
+
/** Expiration of this signature (optional, separate from lock expiration) */
|
|
18
|
+
expires_at: z.string().datetime().optional(),
|
|
19
|
+
/** Certificate chain for verification (optional) */
|
|
20
|
+
certificate_chain: z.array(z.string()).optional()
|
|
21
|
+
});
|
|
22
|
+
var GovernanceLockPolicySourceSchema = z.object({
|
|
23
|
+
/** Unique identifier for this source */
|
|
24
|
+
id: z.string().min(1),
|
|
25
|
+
/** Type of source */
|
|
26
|
+
type: z.enum(["pdf", "url", "confluence", "jira", "manual"]),
|
|
27
|
+
/** URI to the source document */
|
|
28
|
+
uri: z.string(),
|
|
29
|
+
/** SHA-256 hash of the source content at time of compilation */
|
|
30
|
+
content_hash: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
31
|
+
/** When the source was fetched */
|
|
32
|
+
fetched_at: z.string().datetime(),
|
|
33
|
+
/** Title of the policy document */
|
|
34
|
+
title: z.string().optional(),
|
|
35
|
+
/** Version of the policy document */
|
|
36
|
+
version: z.string().optional()
|
|
37
|
+
});
|
|
38
|
+
var GovernanceLockRegistryConstraintsSchema = z.object({
|
|
39
|
+
/** List of approved vendor IDs */
|
|
40
|
+
allowed_vendor_ids: z.array(z.string()).default([]),
|
|
41
|
+
/** List of blocked vendor IDs */
|
|
42
|
+
blocked_vendor_ids: z.array(z.string()).default([]),
|
|
43
|
+
/** List of approved region codes */
|
|
44
|
+
allowed_region_codes: z.array(z.string()).default([]),
|
|
45
|
+
/** List of blocked region codes */
|
|
46
|
+
blocked_region_codes: z.array(z.string()).default([]),
|
|
47
|
+
/** List of approved model patterns */
|
|
48
|
+
allowed_model_patterns: z.array(z.string()).default([]),
|
|
49
|
+
/** List of blocked model patterns */
|
|
50
|
+
blocked_model_patterns: z.array(z.string()).default([]),
|
|
51
|
+
/** Maximum model parameters allowed */
|
|
52
|
+
max_model_parameters: z.number().positive().optional()
|
|
53
|
+
});
|
|
54
|
+
var GovernanceLockRuntimeConstraintsSchema = z.object({
|
|
55
|
+
/** Whether PII filtering is required */
|
|
56
|
+
pii_filter_enabled: z.boolean().default(false),
|
|
57
|
+
/** PII filter action */
|
|
58
|
+
pii_filter_action: z.enum(["redact", "block", "warn", "audit"]).optional(),
|
|
59
|
+
/** Whether toxicity filtering is required */
|
|
60
|
+
toxicity_filter_enabled: z.boolean().default(false),
|
|
61
|
+
/** Toxicity threshold */
|
|
62
|
+
toxicity_threshold: z.number().min(0).max(1).optional(),
|
|
63
|
+
/** Data retention period in days */
|
|
64
|
+
data_retention_days: z.number().int().min(0).default(90),
|
|
65
|
+
/** Whether watermarking is required */
|
|
66
|
+
watermark_enabled: z.boolean().default(false),
|
|
67
|
+
/** Logging level */
|
|
68
|
+
logging_level: z.enum(["none", "errors", "all"]).default("all"),
|
|
69
|
+
/** Maximum tokens per request */
|
|
70
|
+
max_tokens_per_request: z.number().int().positive().optional(),
|
|
71
|
+
/** Maximum cost per day in USD */
|
|
72
|
+
max_cost_per_day_usd: z.number().positive().optional(),
|
|
73
|
+
/** Kill switch enabled */
|
|
74
|
+
kill_switch_enabled: z.boolean().default(true)
|
|
75
|
+
});
|
|
76
|
+
var GovernanceLockBuildConstraintsSchema = z.object({
|
|
77
|
+
/** Require Golden Thread linkage */
|
|
78
|
+
require_golden_thread: z.boolean().default(true),
|
|
79
|
+
/** Require asset card */
|
|
80
|
+
require_asset_card: z.boolean().default(true),
|
|
81
|
+
/** Require risk classification */
|
|
82
|
+
require_risk_classification: z.boolean().default(true),
|
|
83
|
+
/** Require model card */
|
|
84
|
+
require_model_card: z.boolean().default(false),
|
|
85
|
+
/** Require security review for high risk */
|
|
86
|
+
require_security_review: z.boolean().default(false),
|
|
87
|
+
/** Block merge on validation failure */
|
|
88
|
+
block_on_failure: z.boolean().default(true),
|
|
89
|
+
/** Generate SARIF report */
|
|
90
|
+
generate_sarif: z.boolean().default(true),
|
|
91
|
+
/** Allowed environments */
|
|
92
|
+
allowed_environments: z.array(z.string()).default(["development", "staging", "production"])
|
|
93
|
+
});
|
|
94
|
+
var GovernanceLockConstraintsSchema = z.object({
|
|
95
|
+
/** Registry constraints (vendor/model/region) */
|
|
96
|
+
registry: GovernanceLockRegistryConstraintsSchema.default({}),
|
|
97
|
+
/** Runtime constraints */
|
|
98
|
+
runtime: GovernanceLockRuntimeConstraintsSchema.default({}),
|
|
99
|
+
/** Build constraints */
|
|
100
|
+
build: GovernanceLockBuildConstraintsSchema.default({})
|
|
101
|
+
});
|
|
102
|
+
var GovernanceLockSchema = z.object({
|
|
103
|
+
/** Schema version for forward compatibility */
|
|
104
|
+
version: z.literal("1.0"),
|
|
105
|
+
/** When this lock file was generated */
|
|
106
|
+
generated_at: z.string().datetime(),
|
|
107
|
+
/** SHA-256 hash of the compiled policy (AIR) */
|
|
108
|
+
policy_hash: z.string().regex(/^sha256:[a-f0-9]{64}$/),
|
|
109
|
+
/** Name of this policy lock */
|
|
110
|
+
name: z.string().min(1).max(200).optional(),
|
|
111
|
+
/** Description of this lock file */
|
|
112
|
+
description: z.string().max(500).optional(),
|
|
113
|
+
/** Policy sources that contributed to this lock */
|
|
114
|
+
policy_sources: z.array(GovernanceLockPolicySourceSchema).default([]),
|
|
115
|
+
/** Compiled constraints (subset of AIR) */
|
|
116
|
+
constraints: GovernanceLockConstraintsSchema.default({}),
|
|
117
|
+
/** Digital signatures from policy owners */
|
|
118
|
+
signatures: z.array(GovernanceLockSignatureSchema).default([]),
|
|
119
|
+
/** When this lock file expires (forces re-compilation) */
|
|
120
|
+
expires_at: z.string().datetime(),
|
|
121
|
+
/** Tool/system that generated this lock */
|
|
122
|
+
generated_by: z.string().default("aigrc-policy-compiler"),
|
|
123
|
+
/** Version of the generator */
|
|
124
|
+
generator_version: z.string().default("1.0.0"),
|
|
125
|
+
/** Organization this lock belongs to */
|
|
126
|
+
organization: z.string().optional(),
|
|
127
|
+
/** Environment this lock is for */
|
|
128
|
+
environment: z.string().optional(),
|
|
129
|
+
/** Reference to the full AIR document (optional) */
|
|
130
|
+
air_reference: z.object({
|
|
131
|
+
/** AIR document ID */
|
|
132
|
+
id: z.string().uuid(),
|
|
133
|
+
/** AIR document location (URI) */
|
|
134
|
+
location: z.string().optional(),
|
|
135
|
+
/** AIR document hash */
|
|
136
|
+
hash: z.string().regex(/^sha256:[a-f0-9]{64}$/)
|
|
137
|
+
}).optional(),
|
|
138
|
+
/** Custom metadata fields */
|
|
139
|
+
metadata: z.record(z.unknown()).optional()
|
|
140
|
+
});
|
|
141
|
+
async function computeHash(data) {
|
|
142
|
+
const encoder = new TextEncoder();
|
|
143
|
+
const dataBuffer = encoder.encode(data);
|
|
144
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", dataBuffer);
|
|
145
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
146
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
147
|
+
return `sha256:${hashHex}`;
|
|
148
|
+
}
|
|
149
|
+
async function createGovernanceLock(air, options = {}) {
|
|
150
|
+
const now = /* @__PURE__ */ new Date();
|
|
151
|
+
const expiresAt = new Date(now);
|
|
152
|
+
expiresAt.setDate(expiresAt.getDate() + (options.expiresInDays ?? 30));
|
|
153
|
+
const airForHashing = { ...air, signatures: [] };
|
|
154
|
+
const policyHash = await computeHash(JSON.stringify(airForHashing));
|
|
155
|
+
const constraints = {
|
|
156
|
+
registry: {
|
|
157
|
+
allowed_vendor_ids: air.registry.allowed_vendors.map((v) => v.id),
|
|
158
|
+
blocked_vendor_ids: air.registry.blocked_vendors,
|
|
159
|
+
allowed_region_codes: air.registry.allowed_regions.map((r) => r.code),
|
|
160
|
+
blocked_region_codes: air.registry.blocked_regions,
|
|
161
|
+
allowed_model_patterns: air.registry.allowed_models.map((m) => m.version_pattern ?? m.id),
|
|
162
|
+
blocked_model_patterns: air.registry.blocked_models,
|
|
163
|
+
max_model_parameters: air.registry.max_model_parameters
|
|
164
|
+
},
|
|
165
|
+
runtime: {
|
|
166
|
+
pii_filter_enabled: air.runtime.pii_filter?.enabled ?? false,
|
|
167
|
+
pii_filter_action: air.runtime.pii_filter?.action,
|
|
168
|
+
toxicity_filter_enabled: air.runtime.toxicity_filter?.enabled ?? false,
|
|
169
|
+
toxicity_threshold: air.runtime.toxicity_filter?.threshold,
|
|
170
|
+
data_retention_days: air.runtime.data_retention_days,
|
|
171
|
+
watermark_enabled: air.runtime.watermark_enabled,
|
|
172
|
+
logging_level: air.runtime.logging_level,
|
|
173
|
+
max_tokens_per_request: air.runtime.max_tokens_per_request,
|
|
174
|
+
max_cost_per_day_usd: air.runtime.max_cost_per_day_usd,
|
|
175
|
+
kill_switch_enabled: air.runtime.kill_switch?.enabled ?? true
|
|
176
|
+
},
|
|
177
|
+
build: {
|
|
178
|
+
require_golden_thread: air.build.require_golden_thread,
|
|
179
|
+
require_asset_card: air.build.require_asset_card,
|
|
180
|
+
require_risk_classification: air.build.require_risk_classification,
|
|
181
|
+
require_model_card: air.build.require_model_card,
|
|
182
|
+
require_security_review: air.build.require_security_review,
|
|
183
|
+
block_on_failure: air.build.block_on_failure,
|
|
184
|
+
generate_sarif: air.build.generate_sarif,
|
|
185
|
+
allowed_environments: air.build.allowed_environments
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const policySources = air.policy_sources.map((s) => ({
|
|
189
|
+
id: s.id,
|
|
190
|
+
type: s.type,
|
|
191
|
+
uri: s.uri,
|
|
192
|
+
content_hash: s.content_hash,
|
|
193
|
+
fetched_at: s.fetched_at,
|
|
194
|
+
title: s.title,
|
|
195
|
+
version: s.version
|
|
196
|
+
}));
|
|
197
|
+
return {
|
|
198
|
+
version: "1.0",
|
|
199
|
+
generated_at: now.toISOString(),
|
|
200
|
+
policy_hash: policyHash,
|
|
201
|
+
name: options.name ?? air.name,
|
|
202
|
+
description: options.description,
|
|
203
|
+
policy_sources: policySources,
|
|
204
|
+
constraints,
|
|
205
|
+
signatures: [],
|
|
206
|
+
expires_at: expiresAt.toISOString(),
|
|
207
|
+
generated_by: air.metadata.generated_by,
|
|
208
|
+
generator_version: air.metadata.compiler_version,
|
|
209
|
+
organization: options.organization ?? air.metadata.organization,
|
|
210
|
+
environment: options.environment ?? air.metadata.environment,
|
|
211
|
+
air_reference: {
|
|
212
|
+
id: air.id,
|
|
213
|
+
hash: policyHash
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function validateGovernanceLock(lock, options = {}) {
|
|
218
|
+
const errors = [];
|
|
219
|
+
const warnings = [];
|
|
220
|
+
const parseResult = GovernanceLockSchema.safeParse(lock);
|
|
221
|
+
if (!parseResult.success) {
|
|
222
|
+
return {
|
|
223
|
+
valid: false,
|
|
224
|
+
errors: parseResult.error.errors.map((e) => `${e.path.join(".")}: ${e.message}`),
|
|
225
|
+
warnings: [],
|
|
226
|
+
expired: false,
|
|
227
|
+
daysUntilExpiration: 0,
|
|
228
|
+
signed: false,
|
|
229
|
+
validSignatureCount: 0,
|
|
230
|
+
policyHashValid: false
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
const parsed = parseResult.data;
|
|
234
|
+
const now = /* @__PURE__ */ new Date();
|
|
235
|
+
const expiresAt = new Date(parsed.expires_at);
|
|
236
|
+
const daysUntilExpiration = Math.ceil((expiresAt.getTime() - now.getTime()) / (1e3 * 60 * 60 * 24));
|
|
237
|
+
const expired = expiresAt < now;
|
|
238
|
+
if (options.checkExpiration !== false && expired) {
|
|
239
|
+
errors.push(`Lock file expired on ${parsed.expires_at}`);
|
|
240
|
+
}
|
|
241
|
+
if (daysUntilExpiration > 0 && daysUntilExpiration <= 7) {
|
|
242
|
+
warnings.push(`Lock file expires in ${daysUntilExpiration} days`);
|
|
243
|
+
}
|
|
244
|
+
const signed = parsed.signatures.length > 0;
|
|
245
|
+
if (options.requireSignatures && !signed) {
|
|
246
|
+
errors.push("Lock file requires at least one signature");
|
|
247
|
+
}
|
|
248
|
+
let validSignatureCount = 0;
|
|
249
|
+
for (const sig of parsed.signatures) {
|
|
250
|
+
if (sig.expires_at) {
|
|
251
|
+
const sigExpiresAt = new Date(sig.expires_at);
|
|
252
|
+
if (sigExpiresAt < now) {
|
|
253
|
+
warnings.push(`Signature from ${sig.signer} has expired`);
|
|
254
|
+
} else {
|
|
255
|
+
validSignatureCount++;
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
validSignatureCount++;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
let policyHashValid = true;
|
|
262
|
+
if (options.expectedPolicyHash) {
|
|
263
|
+
if (parsed.policy_hash !== options.expectedPolicyHash) {
|
|
264
|
+
errors.push(`Policy hash mismatch: expected ${options.expectedPolicyHash}, got ${parsed.policy_hash}`);
|
|
265
|
+
policyHashValid = false;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
valid: errors.length === 0,
|
|
270
|
+
errors,
|
|
271
|
+
warnings,
|
|
272
|
+
expired,
|
|
273
|
+
daysUntilExpiration,
|
|
274
|
+
signed,
|
|
275
|
+
validSignatureCount,
|
|
276
|
+
policyHashValid
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function parseGovernanceLockYAML(content) {
|
|
280
|
+
const parsed = yaml.parse(content);
|
|
281
|
+
return GovernanceLockSchema.parse(parsed);
|
|
282
|
+
}
|
|
283
|
+
function parseGovernanceLockJSON(content) {
|
|
284
|
+
const parsed = JSON.parse(content);
|
|
285
|
+
return GovernanceLockSchema.parse(parsed);
|
|
286
|
+
}
|
|
287
|
+
function serializeGovernanceLockYAML(lock) {
|
|
288
|
+
return yaml.stringify(lock, {
|
|
289
|
+
indent: 2,
|
|
290
|
+
lineWidth: 120
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function serializeGovernanceLockJSON(lock, pretty = true) {
|
|
294
|
+
return pretty ? JSON.stringify(lock, null, 2) : JSON.stringify(lock);
|
|
295
|
+
}
|
|
296
|
+
function isGovernanceLockExpired(lock) {
|
|
297
|
+
return new Date(lock.expires_at) < /* @__PURE__ */ new Date();
|
|
298
|
+
}
|
|
299
|
+
function getDaysUntilExpiration(lock) {
|
|
300
|
+
const now = /* @__PURE__ */ new Date();
|
|
301
|
+
const expiresAt = new Date(lock.expires_at);
|
|
302
|
+
return Math.ceil((expiresAt.getTime() - now.getTime()) / (1e3 * 60 * 60 * 24));
|
|
303
|
+
}
|
|
304
|
+
function isVendorAllowedByLock(vendorId, lock) {
|
|
305
|
+
const { registry } = lock.constraints;
|
|
306
|
+
if (registry.blocked_vendor_ids.includes(vendorId)) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
if (registry.allowed_vendor_ids.length > 0) {
|
|
310
|
+
return registry.allowed_vendor_ids.includes(vendorId);
|
|
311
|
+
}
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
function isModelAllowedByLock(modelId, lock) {
|
|
315
|
+
const { registry } = lock.constraints;
|
|
316
|
+
for (const pattern of registry.blocked_model_patterns) {
|
|
317
|
+
if (matchesPattern(modelId, pattern)) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (registry.allowed_model_patterns.length > 0) {
|
|
322
|
+
return registry.allowed_model_patterns.some(
|
|
323
|
+
(pattern) => matchesPattern(modelId, pattern)
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
function isRegionAllowedByLock(regionCode, lock) {
|
|
329
|
+
const { registry } = lock.constraints;
|
|
330
|
+
if (registry.blocked_region_codes.includes(regionCode)) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
if (registry.allowed_region_codes.length > 0) {
|
|
334
|
+
return registry.allowed_region_codes.includes(regionCode);
|
|
335
|
+
}
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
function matchesPattern(value, pattern) {
|
|
339
|
+
if (pattern === "*") {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
if (pattern.endsWith("*")) {
|
|
343
|
+
return value.startsWith(pattern.slice(0, -1));
|
|
344
|
+
}
|
|
345
|
+
if (pattern.startsWith("*")) {
|
|
346
|
+
return value.endsWith(pattern.slice(1));
|
|
347
|
+
}
|
|
348
|
+
return value === pattern;
|
|
349
|
+
}
|
|
350
|
+
function createSigningPayload(lock) {
|
|
351
|
+
const forSigning = {
|
|
352
|
+
version: lock.version,
|
|
353
|
+
generated_at: lock.generated_at,
|
|
354
|
+
policy_hash: lock.policy_hash,
|
|
355
|
+
expires_at: lock.expires_at,
|
|
356
|
+
constraints: lock.constraints
|
|
357
|
+
};
|
|
358
|
+
return JSON.stringify(forSigning);
|
|
359
|
+
}
|
|
360
|
+
function addSignature(lock, signature) {
|
|
361
|
+
return {
|
|
362
|
+
...lock,
|
|
363
|
+
signatures: [...lock.signatures, signature]
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
export {
|
|
367
|
+
GovernanceLockBuildConstraintsSchema,
|
|
368
|
+
GovernanceLockConstraintsSchema,
|
|
369
|
+
GovernanceLockPolicySourceSchema,
|
|
370
|
+
GovernanceLockRegistryConstraintsSchema,
|
|
371
|
+
GovernanceLockRuntimeConstraintsSchema,
|
|
372
|
+
GovernanceLockSchema,
|
|
373
|
+
GovernanceLockSignatureSchema,
|
|
374
|
+
addSignature,
|
|
375
|
+
computeHash,
|
|
376
|
+
createGovernanceLock,
|
|
377
|
+
createSigningPayload,
|
|
378
|
+
getDaysUntilExpiration,
|
|
379
|
+
isGovernanceLockExpired,
|
|
380
|
+
isModelAllowedByLock,
|
|
381
|
+
isRegionAllowedByLock,
|
|
382
|
+
isVendorAllowedByLock,
|
|
383
|
+
parseGovernanceLockJSON,
|
|
384
|
+
parseGovernanceLockYAML,
|
|
385
|
+
serializeGovernanceLockJSON,
|
|
386
|
+
serializeGovernanceLockYAML,
|
|
387
|
+
validateGovernanceLock
|
|
388
|
+
};
|
|
389
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/governance-lock/index.ts"],"sourcesContent":["/**\n * governance.lock File Format\n *\n * The governance.lock file pins policy version to code version, similar to\n * package-lock.json. It is generated by the Policy Compiler and verified\n * by the Supply Chain Firewall in IDE, CI/CD, and runtime.\n *\n * @see I2E_Engine_Specification_v1.md Section 4.2.3\n * @module @aigrc/core/governance-lock\n */\n\nimport { z } from \"zod\";\nimport * as yaml from \"yaml\";\nimport type { AIR, AIRPolicySource } from \"../air\";\n\n// ─────────────────────────────────────────────────────────────────\n// SIGNATURE SCHEMA\n// Cryptographic signatures from policy owners\n// ─────────────────────────────────────────────────────────────────\n\nexport const GovernanceLockSignatureSchema = z.object({\n /** Signer identity (email or system ID) */\n signer: z.string().min(1),\n /** Role of the signer (e.g., \"CISO\", \"PolicyOwner\", \"SecurityLead\") */\n role: z.string().optional(),\n /** Algorithm used: RS256 (RSA-SHA256) or ES256 (ECDSA-P256) */\n algorithm: z.enum([\"RS256\", \"ES256\"]),\n /** Base64-encoded signature */\n signature: z.string().min(1),\n /** When the signature was created */\n signed_at: z.string().datetime(),\n /** Key ID for key rotation support */\n key_id: z.string().optional(),\n /** Expiration of this signature (optional, separate from lock expiration) */\n expires_at: z.string().datetime().optional(),\n /** Certificate chain for verification (optional) */\n certificate_chain: z.array(z.string()).optional(),\n});\n\nexport type GovernanceLockSignature = z.infer<typeof GovernanceLockSignatureSchema>;\n\n// ─────────────────────────────────────────────────────────────────\n// POLICY SOURCE REFERENCE SCHEMA\n// References to source policy documents with integrity hashes\n// ─────────────────────────────────────────────────────────────────\n\nexport const GovernanceLockPolicySourceSchema = z.object({\n /** Unique identifier for this source */\n id: z.string().min(1),\n /** Type of source */\n type: z.enum([\"pdf\", \"url\", \"confluence\", \"jira\", \"manual\"]),\n /** URI to the source document */\n uri: z.string(),\n /** SHA-256 hash of the source content at time of compilation */\n content_hash: z.string().regex(/^sha256:[a-f0-9]{64}$/),\n /** When the source was fetched */\n fetched_at: z.string().datetime(),\n /** Title of the policy document */\n title: z.string().optional(),\n /** Version of the policy document */\n version: z.string().optional(),\n});\n\nexport type GovernanceLockPolicySource = z.infer<typeof GovernanceLockPolicySourceSchema>;\n\n// ─────────────────────────────────────────────────────────────────\n// COMPILED CONSTRAINTS SCHEMA\n// Subset of AIR constraints included in governance.lock\n// ─────────────────────────────────────────────────────────────────\n\nexport const GovernanceLockRegistryConstraintsSchema = z.object({\n /** List of approved vendor IDs */\n allowed_vendor_ids: z.array(z.string()).default([]),\n /** List of blocked vendor IDs */\n blocked_vendor_ids: z.array(z.string()).default([]),\n /** List of approved region codes */\n allowed_region_codes: z.array(z.string()).default([]),\n /** List of blocked region codes */\n blocked_region_codes: z.array(z.string()).default([]),\n /** List of approved model patterns */\n allowed_model_patterns: z.array(z.string()).default([]),\n /** List of blocked model patterns */\n blocked_model_patterns: z.array(z.string()).default([]),\n /** Maximum model parameters allowed */\n max_model_parameters: z.number().positive().optional(),\n});\n\nexport type GovernanceLockRegistryConstraints = z.infer<typeof GovernanceLockRegistryConstraintsSchema>;\n\nexport const GovernanceLockRuntimeConstraintsSchema = z.object({\n /** Whether PII filtering is required */\n pii_filter_enabled: z.boolean().default(false),\n /** PII filter action */\n pii_filter_action: z.enum([\"redact\", \"block\", \"warn\", \"audit\"]).optional(),\n /** Whether toxicity filtering is required */\n toxicity_filter_enabled: z.boolean().default(false),\n /** Toxicity threshold */\n toxicity_threshold: z.number().min(0).max(1).optional(),\n /** Data retention period in days */\n data_retention_days: z.number().int().min(0).default(90),\n /** Whether watermarking is required */\n watermark_enabled: z.boolean().default(false),\n /** Logging level */\n logging_level: z.enum([\"none\", \"errors\", \"all\"]).default(\"all\"),\n /** Maximum tokens per request */\n max_tokens_per_request: z.number().int().positive().optional(),\n /** Maximum cost per day in USD */\n max_cost_per_day_usd: z.number().positive().optional(),\n /** Kill switch enabled */\n kill_switch_enabled: z.boolean().default(true),\n});\n\nexport type GovernanceLockRuntimeConstraints = z.infer<typeof GovernanceLockRuntimeConstraintsSchema>;\n\nexport const GovernanceLockBuildConstraintsSchema = z.object({\n /** Require Golden Thread linkage */\n require_golden_thread: z.boolean().default(true),\n /** Require asset card */\n require_asset_card: z.boolean().default(true),\n /** Require risk classification */\n require_risk_classification: z.boolean().default(true),\n /** Require model card */\n require_model_card: z.boolean().default(false),\n /** Require security review for high risk */\n require_security_review: z.boolean().default(false),\n /** Block merge on validation failure */\n block_on_failure: z.boolean().default(true),\n /** Generate SARIF report */\n generate_sarif: z.boolean().default(true),\n /** Allowed environments */\n allowed_environments: z.array(z.string()).default([\"development\", \"staging\", \"production\"]),\n});\n\nexport type GovernanceLockBuildConstraints = z.infer<typeof GovernanceLockBuildConstraintsSchema>;\n\nexport const GovernanceLockConstraintsSchema = z.object({\n /** Registry constraints (vendor/model/region) */\n registry: GovernanceLockRegistryConstraintsSchema.default({}),\n /** Runtime constraints */\n runtime: GovernanceLockRuntimeConstraintsSchema.default({}),\n /** Build constraints */\n build: GovernanceLockBuildConstraintsSchema.default({}),\n});\n\nexport type GovernanceLockConstraints = z.infer<typeof GovernanceLockConstraintsSchema>;\n\n// ─────────────────────────────────────────────────────────────────\n// GOVERNANCE.LOCK SCHEMA\n// The complete governance.lock file format\n// ─────────────────────────────────────────────────────────────────\n\nexport const GovernanceLockSchema = z.object({\n /** Schema version for forward compatibility */\n version: z.literal(\"1.0\"),\n /** When this lock file was generated */\n generated_at: z.string().datetime(),\n /** SHA-256 hash of the compiled policy (AIR) */\n policy_hash: z.string().regex(/^sha256:[a-f0-9]{64}$/),\n /** Name of this policy lock */\n name: z.string().min(1).max(200).optional(),\n /** Description of this lock file */\n description: z.string().max(500).optional(),\n /** Policy sources that contributed to this lock */\n policy_sources: z.array(GovernanceLockPolicySourceSchema).default([]),\n /** Compiled constraints (subset of AIR) */\n constraints: GovernanceLockConstraintsSchema.default({}),\n /** Digital signatures from policy owners */\n signatures: z.array(GovernanceLockSignatureSchema).default([]),\n /** When this lock file expires (forces re-compilation) */\n expires_at: z.string().datetime(),\n /** Tool/system that generated this lock */\n generated_by: z.string().default(\"aigrc-policy-compiler\"),\n /** Version of the generator */\n generator_version: z.string().default(\"1.0.0\"),\n /** Organization this lock belongs to */\n organization: z.string().optional(),\n /** Environment this lock is for */\n environment: z.string().optional(),\n /** Reference to the full AIR document (optional) */\n air_reference: z.object({\n /** AIR document ID */\n id: z.string().uuid(),\n /** AIR document location (URI) */\n location: z.string().optional(),\n /** AIR document hash */\n hash: z.string().regex(/^sha256:[a-f0-9]{64}$/),\n }).optional(),\n /** Custom metadata fields */\n metadata: z.record(z.unknown()).optional(),\n});\n\nexport type GovernanceLock = z.infer<typeof GovernanceLockSchema>;\n\n// ─────────────────────────────────────────────────────────────────\n// VALIDATION RESULT SCHEMA\n// Result of validating a governance.lock file\n// ─────────────────────────────────────────────────────────────────\n\nexport interface GovernanceLockValidationResult {\n /** Whether the lock file is valid */\n valid: boolean;\n /** Validation errors */\n errors: string[];\n /** Validation warnings */\n warnings: string[];\n /** Whether the lock file has expired */\n expired: boolean;\n /** Days until expiration (negative if expired) */\n daysUntilExpiration: number;\n /** Whether signatures are present */\n signed: boolean;\n /** Number of valid signatures */\n validSignatureCount: number;\n /** Whether policy hash is valid */\n policyHashValid: boolean;\n}\n\n// ─────────────────────────────────────────────────────────────────\n// HELPER FUNCTIONS\n// ─────────────────────────────────────────────────────────────────\n\n/**\n * Computes SHA-256 hash of a string\n */\nasync function computeHash(data: string): Promise<string> {\n // Use Web Crypto API (works in Node.js 18+ and browsers)\n const encoder = new TextEncoder();\n const dataBuffer = encoder.encode(data);\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", dataBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray.map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `sha256:${hashHex}`;\n}\n\n/**\n * Creates a governance.lock from an AIR document\n */\nexport async function createGovernanceLock(\n air: AIR,\n options: {\n expiresInDays?: number;\n name?: string;\n description?: string;\n organization?: string;\n environment?: string;\n } = {}\n): Promise<GovernanceLock> {\n const now = new Date();\n const expiresAt = new Date(now);\n expiresAt.setDate(expiresAt.getDate() + (options.expiresInDays ?? 30));\n\n // Compute policy hash from AIR content (excluding signatures)\n const airForHashing = { ...air, signatures: [] };\n const policyHash = await computeHash(JSON.stringify(airForHashing));\n\n // Extract simplified constraints from AIR\n const constraints: GovernanceLockConstraints = {\n registry: {\n allowed_vendor_ids: air.registry.allowed_vendors.map(v => v.id),\n blocked_vendor_ids: air.registry.blocked_vendors,\n allowed_region_codes: air.registry.allowed_regions.map(r => r.code),\n blocked_region_codes: air.registry.blocked_regions,\n allowed_model_patterns: air.registry.allowed_models.map(m => m.version_pattern ?? m.id),\n blocked_model_patterns: air.registry.blocked_models,\n max_model_parameters: air.registry.max_model_parameters,\n },\n runtime: {\n pii_filter_enabled: air.runtime.pii_filter?.enabled ?? false,\n pii_filter_action: air.runtime.pii_filter?.action,\n toxicity_filter_enabled: air.runtime.toxicity_filter?.enabled ?? false,\n toxicity_threshold: air.runtime.toxicity_filter?.threshold,\n data_retention_days: air.runtime.data_retention_days,\n watermark_enabled: air.runtime.watermark_enabled,\n logging_level: air.runtime.logging_level,\n max_tokens_per_request: air.runtime.max_tokens_per_request,\n max_cost_per_day_usd: air.runtime.max_cost_per_day_usd,\n kill_switch_enabled: air.runtime.kill_switch?.enabled ?? true,\n },\n build: {\n require_golden_thread: air.build.require_golden_thread,\n require_asset_card: air.build.require_asset_card,\n require_risk_classification: air.build.require_risk_classification,\n require_model_card: air.build.require_model_card,\n require_security_review: air.build.require_security_review,\n block_on_failure: air.build.block_on_failure,\n generate_sarif: air.build.generate_sarif,\n allowed_environments: air.build.allowed_environments,\n },\n };\n\n // Map AIR policy sources to lock format\n const policySources: GovernanceLockPolicySource[] = air.policy_sources.map(s => ({\n id: s.id,\n type: s.type,\n uri: s.uri,\n content_hash: s.content_hash,\n fetched_at: s.fetched_at,\n title: s.title,\n version: s.version,\n }));\n\n return {\n version: \"1.0\",\n generated_at: now.toISOString(),\n policy_hash: policyHash,\n name: options.name ?? air.name,\n description: options.description,\n policy_sources: policySources,\n constraints,\n signatures: [],\n expires_at: expiresAt.toISOString(),\n generated_by: air.metadata.generated_by,\n generator_version: air.metadata.compiler_version,\n organization: options.organization ?? air.metadata.organization,\n environment: options.environment ?? air.metadata.environment,\n air_reference: {\n id: air.id,\n hash: policyHash,\n },\n };\n}\n\n/**\n * Validates a governance.lock file\n */\nexport function validateGovernanceLock(\n lock: unknown,\n options: {\n /** Whether to check expiration */\n checkExpiration?: boolean;\n /** Whether to require signatures */\n requireSignatures?: boolean;\n /** Expected policy hash (for integrity check) */\n expectedPolicyHash?: string;\n } = {}\n): GovernanceLockValidationResult {\n const errors: string[] = [];\n const warnings: string[] = [];\n\n // Parse and validate schema\n const parseResult = GovernanceLockSchema.safeParse(lock);\n if (!parseResult.success) {\n return {\n valid: false,\n errors: parseResult.error.errors.map(e => `${e.path.join(\".\")}: ${e.message}`),\n warnings: [],\n expired: false,\n daysUntilExpiration: 0,\n signed: false,\n validSignatureCount: 0,\n policyHashValid: false,\n };\n }\n\n const parsed = parseResult.data;\n const now = new Date();\n const expiresAt = new Date(parsed.expires_at);\n const daysUntilExpiration = Math.ceil((expiresAt.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));\n const expired = expiresAt < now;\n\n // Check expiration\n if (options.checkExpiration !== false && expired) {\n errors.push(`Lock file expired on ${parsed.expires_at}`);\n }\n\n // Warn if expiring soon (within 7 days)\n if (daysUntilExpiration > 0 && daysUntilExpiration <= 7) {\n warnings.push(`Lock file expires in ${daysUntilExpiration} days`);\n }\n\n // Check signatures\n const signed = parsed.signatures.length > 0;\n if (options.requireSignatures && !signed) {\n errors.push(\"Lock file requires at least one signature\");\n }\n\n // Check signature expiration\n let validSignatureCount = 0;\n for (const sig of parsed.signatures) {\n if (sig.expires_at) {\n const sigExpiresAt = new Date(sig.expires_at);\n if (sigExpiresAt < now) {\n warnings.push(`Signature from ${sig.signer} has expired`);\n } else {\n validSignatureCount++;\n }\n } else {\n validSignatureCount++;\n }\n }\n\n // Check policy hash\n let policyHashValid = true;\n if (options.expectedPolicyHash) {\n if (parsed.policy_hash !== options.expectedPolicyHash) {\n errors.push(`Policy hash mismatch: expected ${options.expectedPolicyHash}, got ${parsed.policy_hash}`);\n policyHashValid = false;\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n expired,\n daysUntilExpiration,\n signed,\n validSignatureCount,\n policyHashValid,\n };\n}\n\n/**\n * Parses a governance.lock file from YAML string\n */\nexport function parseGovernanceLockYAML(content: string): GovernanceLock {\n const parsed = yaml.parse(content);\n return GovernanceLockSchema.parse(parsed);\n}\n\n/**\n * Parses a governance.lock file from JSON string\n */\nexport function parseGovernanceLockJSON(content: string): GovernanceLock {\n const parsed = JSON.parse(content);\n return GovernanceLockSchema.parse(parsed);\n}\n\n/**\n * Serializes a governance.lock to YAML\n */\nexport function serializeGovernanceLockYAML(lock: GovernanceLock): string {\n return yaml.stringify(lock, {\n indent: 2,\n lineWidth: 120,\n });\n}\n\n/**\n * Serializes a governance.lock to JSON\n */\nexport function serializeGovernanceLockJSON(lock: GovernanceLock, pretty = true): string {\n return pretty ? JSON.stringify(lock, null, 2) : JSON.stringify(lock);\n}\n\n/**\n * Checks if a governance.lock file is expired\n */\nexport function isGovernanceLockExpired(lock: GovernanceLock): boolean {\n return new Date(lock.expires_at) < new Date();\n}\n\n/**\n * Gets the number of days until a governance.lock expires\n */\nexport function getDaysUntilExpiration(lock: GovernanceLock): number {\n const now = new Date();\n const expiresAt = new Date(lock.expires_at);\n return Math.ceil((expiresAt.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));\n}\n\n/**\n * Checks if a vendor is allowed by the governance.lock\n */\nexport function isVendorAllowedByLock(vendorId: string, lock: GovernanceLock): boolean {\n const { registry } = lock.constraints;\n\n // Check blocked list first\n if (registry.blocked_vendor_ids.includes(vendorId)) {\n return false;\n }\n\n // Check allowed list (if specified)\n if (registry.allowed_vendor_ids.length > 0) {\n return registry.allowed_vendor_ids.includes(vendorId);\n }\n\n // If no allowed list, allow by default (except blocked)\n return true;\n}\n\n/**\n * Checks if a model is allowed by the governance.lock\n */\nexport function isModelAllowedByLock(modelId: string, lock: GovernanceLock): boolean {\n const { registry } = lock.constraints;\n\n // Check blocked patterns\n for (const pattern of registry.blocked_model_patterns) {\n if (matchesPattern(modelId, pattern)) {\n return false;\n }\n }\n\n // Check allowed patterns (if specified)\n if (registry.allowed_model_patterns.length > 0) {\n return registry.allowed_model_patterns.some(pattern =>\n matchesPattern(modelId, pattern)\n );\n }\n\n // If no allowed list, allow by default (except blocked)\n return true;\n}\n\n/**\n * Checks if a region is allowed by the governance.lock\n */\nexport function isRegionAllowedByLock(regionCode: string, lock: GovernanceLock): boolean {\n const { registry } = lock.constraints;\n\n // Check blocked list first\n if (registry.blocked_region_codes.includes(regionCode)) {\n return false;\n }\n\n // Check allowed list (if specified)\n if (registry.allowed_region_codes.length > 0) {\n return registry.allowed_region_codes.includes(regionCode);\n }\n\n // If no allowed list, allow by default (except blocked)\n return true;\n}\n\n/**\n * Simple pattern matching (supports wildcards)\n */\nfunction matchesPattern(value: string, pattern: string): boolean {\n if (pattern === \"*\") {\n return true;\n }\n if (pattern.endsWith(\"*\")) {\n return value.startsWith(pattern.slice(0, -1));\n }\n if (pattern.startsWith(\"*\")) {\n return value.endsWith(pattern.slice(1));\n }\n return value === pattern;\n}\n\n/**\n * Creates a canonical string for signing\n */\nexport function createSigningPayload(lock: GovernanceLock): string {\n // Create a deterministic representation excluding signatures\n const forSigning = {\n version: lock.version,\n generated_at: lock.generated_at,\n policy_hash: lock.policy_hash,\n expires_at: lock.expires_at,\n constraints: lock.constraints,\n };\n return JSON.stringify(forSigning);\n}\n\n/**\n * Adds a signature to a governance.lock\n * Note: Actual cryptographic signing is delegated to external libraries\n */\nexport function addSignature(\n lock: GovernanceLock,\n signature: GovernanceLockSignature\n): GovernanceLock {\n return {\n ...lock,\n signatures: [...lock.signatures, signature],\n };\n}\n\n/**\n * Computes a hash for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