@capabilityhostprotocol/types 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/legacy.js ADDED
@@ -0,0 +1,392 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/legacy.ts
20
+ var legacy_exports = {};
21
+ __export(legacy_exports, {
22
+ ASSURANCE_TIERS: () => ASSURANCE_TIERS,
23
+ ASSURANCE_TIER_DISPLAY_NAMES: () => ASSURANCE_TIER_DISPLAY_NAMES,
24
+ ASSURANCE_TIER_ORDER: () => ASSURANCE_TIER_ORDER,
25
+ DEVELOPMENT_CONFIG: () => DEVELOPMENT_CONFIG,
26
+ EVIDENCE_TYPES: () => EVIDENCE_TYPES,
27
+ EXECUTION_OUTCOMES: () => EXECUTION_OUTCOMES,
28
+ GOVERNANCE_MODES: () => GOVERNANCE_MODES,
29
+ INVARIANT_CLASSES: () => INVARIANT_CLASSES,
30
+ INVOCATION_MODES: () => INVOCATION_MODES,
31
+ LEGACY_CHP_VERSION: () => LEGACY_CHP_VERSION,
32
+ PRODUCTION_CONFIG: () => PRODUCTION_CONFIG,
33
+ RISK_CLASSES: () => RISK_CLASSES,
34
+ RISK_CLASS_ORDER: () => RISK_CLASS_ORDER,
35
+ TESTING_CONFIG: () => TESTING_CONFIG,
36
+ blocksExecution: () => blocksExecution,
37
+ compareAssuranceTier: () => compareAssuranceTier,
38
+ compareRiskClass: () => compareRiskClass,
39
+ createCapabilityDeclaration: () => createCapabilityDeclaration,
40
+ createChildContext: () => createChildContext,
41
+ createDeclaredInvariant: () => createDeclaredInvariant,
42
+ createEvidence: () => createEvidence,
43
+ createGovernanceConfig: () => createGovernanceConfig,
44
+ createGovernedContext: () => createGovernedContext,
45
+ createHostIdentity: () => createHostIdentity,
46
+ createInvocationContext: () => createInvocationContext,
47
+ createSubjectContext: () => createSubjectContext,
48
+ elapsedMs: () => elapsedMs,
49
+ emitEvidence: () => emitEvidence,
50
+ emitsEvidence: () => emitsEvidence,
51
+ getAssuranceTierDisplayName: () => getAssuranceTierDisplayName,
52
+ getCapabilityId: () => getCapabilityId,
53
+ hasEntitlement: () => hasEntitlement,
54
+ isCapabilityDeclaration: () => isCapabilityDeclaration,
55
+ isDeclaredInvariant: () => isDeclaredInvariant,
56
+ isEvidence: () => isEvidence,
57
+ isRiskAtLeast: () => isRiskAtLeast,
58
+ meetsAssuranceTier: () => meetsAssuranceTier
59
+ });
60
+ module.exports = __toCommonJS(legacy_exports);
61
+
62
+ // src/risk.ts
63
+ var RISK_CLASSES = [
64
+ "informational",
65
+ "low",
66
+ "medium",
67
+ "high",
68
+ "critical"
69
+ ];
70
+ var RISK_CLASS_ORDER = {
71
+ informational: 0,
72
+ low: 1,
73
+ medium: 2,
74
+ high: 3,
75
+ critical: 4
76
+ };
77
+ function compareRiskClass(a, b) {
78
+ return RISK_CLASS_ORDER[a] - RISK_CLASS_ORDER[b];
79
+ }
80
+ function isRiskAtLeast(actual, required) {
81
+ return RISK_CLASS_ORDER[actual] >= RISK_CLASS_ORDER[required];
82
+ }
83
+
84
+ // src/assurance.ts
85
+ var ASSURANCE_TIERS = ["S1", "S2", "S3"];
86
+ var ASSURANCE_TIER_DISPLAY_NAMES = {
87
+ S1: "Observational",
88
+ S2: "Structural",
89
+ S3: "Attested"
90
+ };
91
+ var ASSURANCE_TIER_ORDER = {
92
+ S1: 1,
93
+ S2: 2,
94
+ S3: 3
95
+ };
96
+ function compareAssuranceTier(a, b) {
97
+ return ASSURANCE_TIER_ORDER[a] - ASSURANCE_TIER_ORDER[b];
98
+ }
99
+ function meetsAssuranceTier(actual, required) {
100
+ return ASSURANCE_TIER_ORDER[actual] >= ASSURANCE_TIER_ORDER[required];
101
+ }
102
+ function getAssuranceTierDisplayName(tier) {
103
+ return ASSURANCE_TIER_DISPLAY_NAMES[tier];
104
+ }
105
+
106
+ // src/evidence.ts
107
+ var EVIDENCE_TYPES = [
108
+ // Core Execution
109
+ "execution_started",
110
+ "execution_completed",
111
+ "execution_failed",
112
+ "execution_denied",
113
+ "execution_aborted",
114
+ // Invocation Boundary
115
+ "invocation_received",
116
+ "invocation_validated",
117
+ "invocation_rejected",
118
+ // Authorization
119
+ "entitlement_checked",
120
+ "entitlement_granted",
121
+ "entitlement_denied",
122
+ // Invariants
123
+ "invariant_checked",
124
+ "invariant_passed",
125
+ "invariant_failed",
126
+ // Resilience Primitives
127
+ "retry_attempted",
128
+ "retry_exhausted",
129
+ "timeout_exceeded",
130
+ "circuit_opened",
131
+ "circuit_closed",
132
+ "rate_limited",
133
+ // Assurance
134
+ "assurance_derived",
135
+ "assurance_degraded",
136
+ // Lineage
137
+ "lineage_traced",
138
+ "causal_link_created"
139
+ ];
140
+ function createEvidence(params) {
141
+ return {
142
+ evidence_id: crypto.randomUUID(),
143
+ evidence_type: params.evidence_type,
144
+ capability_id: params.capability_id,
145
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
146
+ subject_id: params.subject_id ?? null,
147
+ correlation_id: params.correlation_id ?? null,
148
+ assurance_tier: params.assurance_tier ?? "S1",
149
+ payload: params.payload ?? {},
150
+ trace_id: params.trace_id ?? null
151
+ };
152
+ }
153
+ function isEvidence(obj) {
154
+ if (typeof obj !== "object" || obj === null) return false;
155
+ const e = obj;
156
+ return typeof e.evidence_id === "string" && typeof e.evidence_type === "string" && typeof e.capability_id === "string" && typeof e.timestamp === "string" && typeof e.assurance_tier === "string" && typeof e.payload === "object";
157
+ }
158
+
159
+ // src/invariants.ts
160
+ var INVARIANT_CLASSES = [
161
+ "structural",
162
+ "environmental",
163
+ "data",
164
+ "temporal",
165
+ "causal"
166
+ ];
167
+ function createDeclaredInvariant(params) {
168
+ return {
169
+ invariant_id: params.invariant_id,
170
+ invariant_class: params.invariant_class,
171
+ enforcement: params.enforcement ?? "runtime",
172
+ failure_behavior: params.failure_behavior ?? "deny",
173
+ description: params.description ?? "",
174
+ parameters: params.parameters ?? {}
175
+ };
176
+ }
177
+ function isDeclaredInvariant(obj) {
178
+ if (typeof obj !== "object" || obj === null) return false;
179
+ const i = obj;
180
+ return typeof i.invariant_id === "string" && typeof i.invariant_class === "string" && typeof i.enforcement === "string" && typeof i.failure_behavior === "string";
181
+ }
182
+
183
+ // src/context.ts
184
+ function createSubjectContext(params) {
185
+ return {
186
+ subject_id: params.subject_id,
187
+ subject_type: params.subject_type ?? "user",
188
+ entitlements: params.entitlements ?? [],
189
+ metadata: params.metadata ?? {}
190
+ };
191
+ }
192
+ function hasEntitlement(subject, entitlement) {
193
+ return subject.entitlements.includes(entitlement);
194
+ }
195
+ function createInvocationContext(params) {
196
+ return {
197
+ invocation_id: crypto.randomUUID(),
198
+ capability_id: params.capability_id,
199
+ subject: params.subject,
200
+ correlation_id: params.correlation_id ?? crypto.randomUUID(),
201
+ trace_id: params.trace_id ?? null,
202
+ parent_invocation_id: params.parent_invocation_id ?? null,
203
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
204
+ metadata: params.metadata ?? {}
205
+ };
206
+ }
207
+ var EXECUTION_OUTCOMES = [
208
+ "success",
209
+ "failure",
210
+ "denied",
211
+ "timeout",
212
+ "aborted"
213
+ ];
214
+
215
+ // src/governance.ts
216
+ var GOVERNANCE_MODES = [
217
+ "enforce",
218
+ "audit",
219
+ "disabled",
220
+ "shadow"
221
+ ];
222
+ function blocksExecution(mode) {
223
+ return mode === "enforce";
224
+ }
225
+ function emitsEvidence(mode) {
226
+ return mode !== "disabled";
227
+ }
228
+ function createGovernedContext(params) {
229
+ return {
230
+ invocation_id: crypto.randomUUID(),
231
+ capability_id: params.capability_id,
232
+ subject: params.subject,
233
+ correlation_id: params.correlation_id ?? crypto.randomUUID(),
234
+ trace_id: params.trace_id ?? null,
235
+ governance_mode: params.governance_mode ?? "enforce",
236
+ risk_class: params.risk_class ?? "medium",
237
+ minimum_tier: params.minimum_tier ?? "S1",
238
+ invariants: params.invariants ?? [],
239
+ evidence: [],
240
+ metadata: params.metadata ?? {},
241
+ started_at: (/* @__PURE__ */ new Date()).toISOString()
242
+ };
243
+ }
244
+ function emitEvidence(ctx, evidence_type, payload, assurance_tier) {
245
+ const evidence = createEvidence({
246
+ evidence_type,
247
+ capability_id: ctx.capability_id,
248
+ subject_id: ctx.subject.subject_id,
249
+ correlation_id: ctx.correlation_id,
250
+ assurance_tier: assurance_tier ?? ctx.minimum_tier,
251
+ payload: payload ?? {},
252
+ trace_id: ctx.trace_id
253
+ });
254
+ ctx.evidence.push(evidence);
255
+ return evidence;
256
+ }
257
+ function createChildContext(parent, capability_id) {
258
+ return {
259
+ invocation_id: crypto.randomUUID(),
260
+ capability_id,
261
+ subject: parent.subject,
262
+ correlation_id: parent.correlation_id,
263
+ trace_id: parent.trace_id,
264
+ governance_mode: parent.governance_mode,
265
+ risk_class: parent.risk_class,
266
+ minimum_tier: parent.minimum_tier,
267
+ invariants: [],
268
+ evidence: [],
269
+ metadata: {
270
+ ...parent.metadata,
271
+ parent_invocation_id: parent.invocation_id
272
+ },
273
+ started_at: (/* @__PURE__ */ new Date()).toISOString()
274
+ };
275
+ }
276
+ function elapsedMs(ctx) {
277
+ const started = new Date(ctx.started_at).getTime();
278
+ return Date.now() - started;
279
+ }
280
+ function createGovernanceConfig(overrides) {
281
+ return {
282
+ default_mode: "enforce",
283
+ require_subject: true,
284
+ emit_evidence: true,
285
+ audit_denials: true,
286
+ default_tier: "S1",
287
+ ...overrides
288
+ };
289
+ }
290
+ var DEVELOPMENT_CONFIG = {
291
+ default_mode: "audit",
292
+ require_subject: false,
293
+ emit_evidence: true,
294
+ audit_denials: true,
295
+ default_tier: "S1"
296
+ };
297
+ var PRODUCTION_CONFIG = {
298
+ default_mode: "enforce",
299
+ require_subject: true,
300
+ emit_evidence: true,
301
+ audit_denials: true,
302
+ default_tier: "S2"
303
+ };
304
+ var TESTING_CONFIG = {
305
+ default_mode: "disabled",
306
+ require_subject: false,
307
+ emit_evidence: false,
308
+ audit_denials: false,
309
+ default_tier: "S1"
310
+ };
311
+
312
+ // src/capability.ts
313
+ function getCapabilityId(decl) {
314
+ return `${decl.name}:${decl.version}`;
315
+ }
316
+ function createCapabilityDeclaration(params) {
317
+ return {
318
+ name: params.name,
319
+ version: params.version ?? "1.0.0",
320
+ risk_class: params.risk_class ?? "medium",
321
+ description: params.description ?? "",
322
+ invariants: params.invariants ?? [],
323
+ evidence_types: params.evidence_types ?? [],
324
+ require_entitlement: params.require_entitlement ?? false,
325
+ minimum_tier: params.minimum_tier ?? "S1",
326
+ owner: params.owner ?? null,
327
+ tags: params.tags ?? []
328
+ };
329
+ }
330
+ function isCapabilityDeclaration(obj) {
331
+ if (typeof obj !== "object" || obj === null) return false;
332
+ const c = obj;
333
+ return typeof c.name === "string" && typeof c.version === "string" && typeof c.risk_class === "string" && typeof c.require_entitlement === "boolean";
334
+ }
335
+ var INVOCATION_MODES = [
336
+ "sync",
337
+ "async",
338
+ "stream",
339
+ "fire_and_forget"
340
+ ];
341
+ function createHostIdentity(params) {
342
+ return {
343
+ host_id: params.host_id,
344
+ host_type: params.host_type ?? "server",
345
+ version: params.version ?? "1.0.0",
346
+ environment: params.environment ?? "development",
347
+ metadata: params.metadata ?? {}
348
+ };
349
+ }
350
+
351
+ // src/legacy.ts
352
+ var LEGACY_CHP_VERSION = "1.0";
353
+ // Annotate the CommonJS export names for ESM import in node:
354
+ 0 && (module.exports = {
355
+ ASSURANCE_TIERS,
356
+ ASSURANCE_TIER_DISPLAY_NAMES,
357
+ ASSURANCE_TIER_ORDER,
358
+ DEVELOPMENT_CONFIG,
359
+ EVIDENCE_TYPES,
360
+ EXECUTION_OUTCOMES,
361
+ GOVERNANCE_MODES,
362
+ INVARIANT_CLASSES,
363
+ INVOCATION_MODES,
364
+ LEGACY_CHP_VERSION,
365
+ PRODUCTION_CONFIG,
366
+ RISK_CLASSES,
367
+ RISK_CLASS_ORDER,
368
+ TESTING_CONFIG,
369
+ blocksExecution,
370
+ compareAssuranceTier,
371
+ compareRiskClass,
372
+ createCapabilityDeclaration,
373
+ createChildContext,
374
+ createDeclaredInvariant,
375
+ createEvidence,
376
+ createGovernanceConfig,
377
+ createGovernedContext,
378
+ createHostIdentity,
379
+ createInvocationContext,
380
+ createSubjectContext,
381
+ elapsedMs,
382
+ emitEvidence,
383
+ emitsEvidence,
384
+ getAssuranceTierDisplayName,
385
+ getCapabilityId,
386
+ hasEntitlement,
387
+ isCapabilityDeclaration,
388
+ isDeclaredInvariant,
389
+ isEvidence,
390
+ isRiskAtLeast,
391
+ meetsAssuranceTier
392
+ });
@@ -0,0 +1,330 @@
1
+ // src/risk.ts
2
+ var RISK_CLASSES = [
3
+ "informational",
4
+ "low",
5
+ "medium",
6
+ "high",
7
+ "critical"
8
+ ];
9
+ var RISK_CLASS_ORDER = {
10
+ informational: 0,
11
+ low: 1,
12
+ medium: 2,
13
+ high: 3,
14
+ critical: 4
15
+ };
16
+ function compareRiskClass(a, b) {
17
+ return RISK_CLASS_ORDER[a] - RISK_CLASS_ORDER[b];
18
+ }
19
+ function isRiskAtLeast(actual, required) {
20
+ return RISK_CLASS_ORDER[actual] >= RISK_CLASS_ORDER[required];
21
+ }
22
+
23
+ // src/assurance.ts
24
+ var ASSURANCE_TIERS = ["S1", "S2", "S3"];
25
+ var ASSURANCE_TIER_DISPLAY_NAMES = {
26
+ S1: "Observational",
27
+ S2: "Structural",
28
+ S3: "Attested"
29
+ };
30
+ var ASSURANCE_TIER_ORDER = {
31
+ S1: 1,
32
+ S2: 2,
33
+ S3: 3
34
+ };
35
+ function compareAssuranceTier(a, b) {
36
+ return ASSURANCE_TIER_ORDER[a] - ASSURANCE_TIER_ORDER[b];
37
+ }
38
+ function meetsAssuranceTier(actual, required) {
39
+ return ASSURANCE_TIER_ORDER[actual] >= ASSURANCE_TIER_ORDER[required];
40
+ }
41
+ function getAssuranceTierDisplayName(tier) {
42
+ return ASSURANCE_TIER_DISPLAY_NAMES[tier];
43
+ }
44
+
45
+ // src/evidence.ts
46
+ var EVIDENCE_TYPES = [
47
+ // Core Execution
48
+ "execution_started",
49
+ "execution_completed",
50
+ "execution_failed",
51
+ "execution_denied",
52
+ "execution_aborted",
53
+ // Invocation Boundary
54
+ "invocation_received",
55
+ "invocation_validated",
56
+ "invocation_rejected",
57
+ // Authorization
58
+ "entitlement_checked",
59
+ "entitlement_granted",
60
+ "entitlement_denied",
61
+ // Invariants
62
+ "invariant_checked",
63
+ "invariant_passed",
64
+ "invariant_failed",
65
+ // Resilience Primitives
66
+ "retry_attempted",
67
+ "retry_exhausted",
68
+ "timeout_exceeded",
69
+ "circuit_opened",
70
+ "circuit_closed",
71
+ "rate_limited",
72
+ // Assurance
73
+ "assurance_derived",
74
+ "assurance_degraded",
75
+ // Lineage
76
+ "lineage_traced",
77
+ "causal_link_created"
78
+ ];
79
+ function createEvidence(params) {
80
+ return {
81
+ evidence_id: crypto.randomUUID(),
82
+ evidence_type: params.evidence_type,
83
+ capability_id: params.capability_id,
84
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
85
+ subject_id: params.subject_id ?? null,
86
+ correlation_id: params.correlation_id ?? null,
87
+ assurance_tier: params.assurance_tier ?? "S1",
88
+ payload: params.payload ?? {},
89
+ trace_id: params.trace_id ?? null
90
+ };
91
+ }
92
+ function isEvidence(obj) {
93
+ if (typeof obj !== "object" || obj === null) return false;
94
+ const e = obj;
95
+ return typeof e.evidence_id === "string" && typeof e.evidence_type === "string" && typeof e.capability_id === "string" && typeof e.timestamp === "string" && typeof e.assurance_tier === "string" && typeof e.payload === "object";
96
+ }
97
+
98
+ // src/invariants.ts
99
+ var INVARIANT_CLASSES = [
100
+ "structural",
101
+ "environmental",
102
+ "data",
103
+ "temporal",
104
+ "causal"
105
+ ];
106
+ function createDeclaredInvariant(params) {
107
+ return {
108
+ invariant_id: params.invariant_id,
109
+ invariant_class: params.invariant_class,
110
+ enforcement: params.enforcement ?? "runtime",
111
+ failure_behavior: params.failure_behavior ?? "deny",
112
+ description: params.description ?? "",
113
+ parameters: params.parameters ?? {}
114
+ };
115
+ }
116
+ function isDeclaredInvariant(obj) {
117
+ if (typeof obj !== "object" || obj === null) return false;
118
+ const i = obj;
119
+ return typeof i.invariant_id === "string" && typeof i.invariant_class === "string" && typeof i.enforcement === "string" && typeof i.failure_behavior === "string";
120
+ }
121
+
122
+ // src/context.ts
123
+ function createSubjectContext(params) {
124
+ return {
125
+ subject_id: params.subject_id,
126
+ subject_type: params.subject_type ?? "user",
127
+ entitlements: params.entitlements ?? [],
128
+ metadata: params.metadata ?? {}
129
+ };
130
+ }
131
+ function hasEntitlement(subject, entitlement) {
132
+ return subject.entitlements.includes(entitlement);
133
+ }
134
+ function createInvocationContext(params) {
135
+ return {
136
+ invocation_id: crypto.randomUUID(),
137
+ capability_id: params.capability_id,
138
+ subject: params.subject,
139
+ correlation_id: params.correlation_id ?? crypto.randomUUID(),
140
+ trace_id: params.trace_id ?? null,
141
+ parent_invocation_id: params.parent_invocation_id ?? null,
142
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
143
+ metadata: params.metadata ?? {}
144
+ };
145
+ }
146
+ var EXECUTION_OUTCOMES = [
147
+ "success",
148
+ "failure",
149
+ "denied",
150
+ "timeout",
151
+ "aborted"
152
+ ];
153
+
154
+ // src/governance.ts
155
+ var GOVERNANCE_MODES = [
156
+ "enforce",
157
+ "audit",
158
+ "disabled",
159
+ "shadow"
160
+ ];
161
+ function blocksExecution(mode) {
162
+ return mode === "enforce";
163
+ }
164
+ function emitsEvidence(mode) {
165
+ return mode !== "disabled";
166
+ }
167
+ function createGovernedContext(params) {
168
+ return {
169
+ invocation_id: crypto.randomUUID(),
170
+ capability_id: params.capability_id,
171
+ subject: params.subject,
172
+ correlation_id: params.correlation_id ?? crypto.randomUUID(),
173
+ trace_id: params.trace_id ?? null,
174
+ governance_mode: params.governance_mode ?? "enforce",
175
+ risk_class: params.risk_class ?? "medium",
176
+ minimum_tier: params.minimum_tier ?? "S1",
177
+ invariants: params.invariants ?? [],
178
+ evidence: [],
179
+ metadata: params.metadata ?? {},
180
+ started_at: (/* @__PURE__ */ new Date()).toISOString()
181
+ };
182
+ }
183
+ function emitEvidence(ctx, evidence_type, payload, assurance_tier) {
184
+ const evidence = createEvidence({
185
+ evidence_type,
186
+ capability_id: ctx.capability_id,
187
+ subject_id: ctx.subject.subject_id,
188
+ correlation_id: ctx.correlation_id,
189
+ assurance_tier: assurance_tier ?? ctx.minimum_tier,
190
+ payload: payload ?? {},
191
+ trace_id: ctx.trace_id
192
+ });
193
+ ctx.evidence.push(evidence);
194
+ return evidence;
195
+ }
196
+ function createChildContext(parent, capability_id) {
197
+ return {
198
+ invocation_id: crypto.randomUUID(),
199
+ capability_id,
200
+ subject: parent.subject,
201
+ correlation_id: parent.correlation_id,
202
+ trace_id: parent.trace_id,
203
+ governance_mode: parent.governance_mode,
204
+ risk_class: parent.risk_class,
205
+ minimum_tier: parent.minimum_tier,
206
+ invariants: [],
207
+ evidence: [],
208
+ metadata: {
209
+ ...parent.metadata,
210
+ parent_invocation_id: parent.invocation_id
211
+ },
212
+ started_at: (/* @__PURE__ */ new Date()).toISOString()
213
+ };
214
+ }
215
+ function elapsedMs(ctx) {
216
+ const started = new Date(ctx.started_at).getTime();
217
+ return Date.now() - started;
218
+ }
219
+ function createGovernanceConfig(overrides) {
220
+ return {
221
+ default_mode: "enforce",
222
+ require_subject: true,
223
+ emit_evidence: true,
224
+ audit_denials: true,
225
+ default_tier: "S1",
226
+ ...overrides
227
+ };
228
+ }
229
+ var DEVELOPMENT_CONFIG = {
230
+ default_mode: "audit",
231
+ require_subject: false,
232
+ emit_evidence: true,
233
+ audit_denials: true,
234
+ default_tier: "S1"
235
+ };
236
+ var PRODUCTION_CONFIG = {
237
+ default_mode: "enforce",
238
+ require_subject: true,
239
+ emit_evidence: true,
240
+ audit_denials: true,
241
+ default_tier: "S2"
242
+ };
243
+ var TESTING_CONFIG = {
244
+ default_mode: "disabled",
245
+ require_subject: false,
246
+ emit_evidence: false,
247
+ audit_denials: false,
248
+ default_tier: "S1"
249
+ };
250
+
251
+ // src/capability.ts
252
+ function getCapabilityId(decl) {
253
+ return `${decl.name}:${decl.version}`;
254
+ }
255
+ function createCapabilityDeclaration(params) {
256
+ return {
257
+ name: params.name,
258
+ version: params.version ?? "1.0.0",
259
+ risk_class: params.risk_class ?? "medium",
260
+ description: params.description ?? "",
261
+ invariants: params.invariants ?? [],
262
+ evidence_types: params.evidence_types ?? [],
263
+ require_entitlement: params.require_entitlement ?? false,
264
+ minimum_tier: params.minimum_tier ?? "S1",
265
+ owner: params.owner ?? null,
266
+ tags: params.tags ?? []
267
+ };
268
+ }
269
+ function isCapabilityDeclaration(obj) {
270
+ if (typeof obj !== "object" || obj === null) return false;
271
+ const c = obj;
272
+ return typeof c.name === "string" && typeof c.version === "string" && typeof c.risk_class === "string" && typeof c.require_entitlement === "boolean";
273
+ }
274
+ var INVOCATION_MODES = [
275
+ "sync",
276
+ "async",
277
+ "stream",
278
+ "fire_and_forget"
279
+ ];
280
+ function createHostIdentity(params) {
281
+ return {
282
+ host_id: params.host_id,
283
+ host_type: params.host_type ?? "server",
284
+ version: params.version ?? "1.0.0",
285
+ environment: params.environment ?? "development",
286
+ metadata: params.metadata ?? {}
287
+ };
288
+ }
289
+
290
+ // src/legacy.ts
291
+ var LEGACY_CHP_VERSION = "1.0";
292
+ export {
293
+ ASSURANCE_TIERS,
294
+ ASSURANCE_TIER_DISPLAY_NAMES,
295
+ ASSURANCE_TIER_ORDER,
296
+ DEVELOPMENT_CONFIG,
297
+ EVIDENCE_TYPES,
298
+ EXECUTION_OUTCOMES,
299
+ GOVERNANCE_MODES,
300
+ INVARIANT_CLASSES,
301
+ INVOCATION_MODES,
302
+ LEGACY_CHP_VERSION,
303
+ PRODUCTION_CONFIG,
304
+ RISK_CLASSES,
305
+ RISK_CLASS_ORDER,
306
+ TESTING_CONFIG,
307
+ blocksExecution,
308
+ compareAssuranceTier,
309
+ compareRiskClass,
310
+ createCapabilityDeclaration,
311
+ createChildContext,
312
+ createDeclaredInvariant,
313
+ createEvidence,
314
+ createGovernanceConfig,
315
+ createGovernedContext,
316
+ createHostIdentity,
317
+ createInvocationContext,
318
+ createSubjectContext,
319
+ elapsedMs,
320
+ emitEvidence,
321
+ emitsEvidence,
322
+ getAssuranceTierDisplayName,
323
+ getCapabilityId,
324
+ hasEntitlement,
325
+ isCapabilityDeclaration,
326
+ isDeclaredInvariant,
327
+ isEvidence,
328
+ isRiskAtLeast,
329
+ meetsAssuranceTier
330
+ };