@fabricorg/platform 0.1.1 → 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.
Files changed (122) hide show
  1. package/dist/actions/index.cjs +48 -0
  2. package/dist/actions/index.cjs.map +1 -0
  3. package/dist/actions/index.d.cts +116 -0
  4. package/dist/actions/index.js +1 -57
  5. package/dist/actions/index.js.map +1 -1
  6. package/dist/adapters/index.cjs +28 -0
  7. package/dist/adapters/index.cjs.map +1 -0
  8. package/dist/adapters/index.d.cts +83 -0
  9. package/dist/adapters/index.js +1 -99
  10. package/dist/adapters/index.js.map +1 -1
  11. package/dist/chunk-3A6FU3KV.js +67 -0
  12. package/dist/chunk-3A6FU3KV.js.map +1 -0
  13. package/dist/chunk-3F6FKQZA.js +89 -0
  14. package/dist/chunk-3F6FKQZA.js.map +1 -0
  15. package/dist/chunk-3ZW5USXF.js +101 -0
  16. package/dist/chunk-3ZW5USXF.js.map +1 -0
  17. package/dist/chunk-4YQOGV7H.js +55 -0
  18. package/dist/chunk-4YQOGV7H.js.map +1 -0
  19. package/dist/chunk-6FMW4NF6.js +59 -0
  20. package/dist/chunk-6FMW4NF6.js.map +1 -0
  21. package/dist/chunk-7KJHGAZY.cjs +99 -0
  22. package/dist/chunk-7KJHGAZY.cjs.map +1 -0
  23. package/dist/chunk-GB2PSZ33.cjs +74 -0
  24. package/dist/chunk-GB2PSZ33.cjs.map +1 -0
  25. package/dist/chunk-I35B576X.js +30 -0
  26. package/dist/chunk-I35B576X.js.map +1 -0
  27. package/dist/chunk-IFMZPLM4.js +27 -0
  28. package/dist/chunk-IFMZPLM4.js.map +1 -0
  29. package/dist/chunk-JAXDEK5Z.cjs +63 -0
  30. package/dist/chunk-JAXDEK5Z.cjs.map +1 -0
  31. package/dist/chunk-JSTGOT6P.js +181 -0
  32. package/dist/chunk-JSTGOT6P.js.map +1 -0
  33. package/dist/chunk-KOC4A7A4.js +544 -0
  34. package/dist/chunk-KOC4A7A4.js.map +1 -0
  35. package/dist/chunk-KQEBNUZI.cjs +70 -0
  36. package/dist/chunk-KQEBNUZI.cjs.map +1 -0
  37. package/dist/chunk-LHCSVEFT.cjs +8 -0
  38. package/dist/chunk-LHCSVEFT.cjs.map +1 -0
  39. package/dist/chunk-LYX73U3P.cjs +195 -0
  40. package/dist/chunk-LYX73U3P.cjs.map +1 -0
  41. package/dist/chunk-LZSE6QGQ.cjs +60 -0
  42. package/dist/chunk-LZSE6QGQ.cjs.map +1 -0
  43. package/dist/chunk-N24NLCZ6.js +6 -0
  44. package/dist/chunk-N24NLCZ6.js.map +1 -0
  45. package/dist/chunk-NPVIFZQV.cjs +107 -0
  46. package/dist/chunk-NPVIFZQV.cjs.map +1 -0
  47. package/dist/chunk-OZLZHISS.js +3 -0
  48. package/dist/chunk-OZLZHISS.js.map +1 -0
  49. package/dist/chunk-PG5LYTUX.cjs +4 -0
  50. package/dist/chunk-PG5LYTUX.cjs.map +1 -0
  51. package/dist/chunk-PXMKCAQI.js +187 -0
  52. package/dist/chunk-PXMKCAQI.js.map +1 -0
  53. package/dist/chunk-Q3WYIWCN.cjs +183 -0
  54. package/dist/chunk-Q3WYIWCN.cjs.map +1 -0
  55. package/dist/chunk-QETQGAXJ.cjs +35 -0
  56. package/dist/chunk-QETQGAXJ.cjs.map +1 -0
  57. package/dist/chunk-RALMUSOX.js +55 -0
  58. package/dist/chunk-RALMUSOX.js.map +1 -0
  59. package/dist/chunk-SDXDHVTV.cjs +555 -0
  60. package/dist/chunk-SDXDHVTV.cjs.map +1 -0
  61. package/dist/chunk-YZKUEC2J.cjs +31 -0
  62. package/dist/chunk-YZKUEC2J.cjs.map +1 -0
  63. package/dist/displays/index.cjs +24 -0
  64. package/dist/displays/index.cjs.map +1 -0
  65. package/dist/displays/index.d.cts +34 -0
  66. package/dist/displays/index.js +1 -87
  67. package/dist/displays/index.js.map +1 -1
  68. package/dist/events/index.cjs +36 -0
  69. package/dist/events/index.cjs.map +1 -0
  70. package/dist/events/index.d.cts +35 -0
  71. package/dist/events/index.js +1 -53
  72. package/dist/events/index.js.map +1 -1
  73. package/dist/evidence/index.cjs +6 -0
  74. package/dist/evidence/index.cjs.map +1 -0
  75. package/dist/evidence/index.d.cts +43 -0
  76. package/dist/evidence/index.js +1 -1
  77. package/dist/ids/index.cjs +24 -0
  78. package/dist/ids/index.cjs.map +1 -0
  79. package/dist/ids/index.d.cts +19 -0
  80. package/dist/ids/index.js +1 -53
  81. package/dist/ids/index.js.map +1 -1
  82. package/dist/index.cjs +268 -0
  83. package/dist/index.cjs.map +1 -0
  84. package/dist/index.d.cts +13 -0
  85. package/dist/index.js +13 -1355
  86. package/dist/index.js.map +1 -1
  87. package/dist/modules/index.cjs +42 -0
  88. package/dist/modules/index.cjs.map +1 -0
  89. package/dist/modules/index.d.cts +73 -0
  90. package/dist/modules/index.js +7 -373
  91. package/dist/modules/index.js.map +1 -1
  92. package/dist/objects/index.cjs +24 -0
  93. package/dist/objects/index.cjs.map +1 -0
  94. package/dist/objects/index.d.cts +7 -0
  95. package/dist/objects/index.js +1 -28
  96. package/dist/objects/index.js.map +1 -1
  97. package/dist/policies/index.cjs +48 -0
  98. package/dist/policies/index.cjs.map +1 -0
  99. package/dist/policies/index.d.cts +143 -0
  100. package/dist/policies/index.js +1 -542
  101. package/dist/policies/index.js.map +1 -1
  102. package/dist/privacy/index.cjs +12 -0
  103. package/dist/privacy/index.cjs.map +1 -0
  104. package/dist/privacy/index.d.cts +77 -0
  105. package/dist/privacy/index.js +1 -4
  106. package/dist/privacy/index.js.map +1 -1
  107. package/dist/projections/index.cjs +12 -0
  108. package/dist/projections/index.cjs.map +1 -0
  109. package/dist/projections/index.d.cts +52 -0
  110. package/dist/projections/index.js +1 -179
  111. package/dist/projections/index.js.map +1 -1
  112. package/dist/state-machines/index.cjs +32 -0
  113. package/dist/state-machines/index.cjs.map +1 -0
  114. package/dist/state-machines/index.d.cts +60 -0
  115. package/dist/state-machines/index.js +1 -65
  116. package/dist/state-machines/index.js.map +1 -1
  117. package/dist/testing/index.cjs +21 -0
  118. package/dist/testing/index.cjs.map +1 -0
  119. package/dist/testing/index.d.cts +19 -0
  120. package/dist/testing/index.js +2 -56
  121. package/dist/testing/index.js.map +1 -1
  122. package/package.json +196 -111
@@ -1,375 +1,9 @@
1
- import assert from 'assert';
2
-
3
- // actions/index.ts
4
- var registry = /* @__PURE__ */ new Map();
5
- function assertActionId(actionId) {
6
- if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(actionId)) {
7
- throw new Error(`Invalid action ID: ${actionId}`);
8
- }
9
- }
10
- function registerAction(definition) {
11
- assertActionId(definition.actionId);
12
- if (registry.has(definition.actionId)) {
13
- throw new Error(`Action "${definition.actionId}" is already registered`);
14
- }
15
- if (definition.mutatesDomain && definition.emitsEvents.length === 0) {
16
- throw new Error(
17
- `Action "${definition.actionId}" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`
18
- );
19
- }
20
- registry.set(definition.actionId, definition);
21
- }
22
- function registerActionIfMissing(definition) {
23
- if (!registry.has(definition.actionId)) {
24
- registerAction(definition);
25
- }
26
- }
27
- var registry2 = /* @__PURE__ */ new Map();
28
- function registerDisplayRenderer(eventType, renderer) {
29
- registry2.set(eventType, renderer);
30
- }
31
- function resolveDisplayRenderer(eventType) {
32
- return registry2.get(eventType);
33
- }
34
- function denormalizeDisplaySnapshot(payload) {
35
- if (payload !== null && typeof payload === "object" && "_displaySnapshot" in payload && payload._displaySnapshot !== null && typeof payload._displaySnapshot === "object" && "title" in payload._displaySnapshot) {
36
- return payload._displaySnapshot;
37
- }
38
- if (payload !== null && typeof payload === "object" && "_projectionSnapshot" in payload && payload._projectionSnapshot !== null && typeof payload._projectionSnapshot === "object" && "display" in payload._projectionSnapshot && payload._projectionSnapshot.display !== null && typeof payload._projectionSnapshot.display === "object" && "title" in payload._projectionSnapshot.display) {
39
- const snapshot = payload._projectionSnapshot;
40
- return {
41
- ...snapshot.display,
42
- _cachedDisplay: {
43
- source: "projection_snapshot",
44
- cursor: snapshot.eventCursor,
45
- checksum: snapshot.checksum,
46
- generatedAt: snapshot.updatedAt
47
- }
48
- };
49
- }
50
- return void 0;
51
- }
52
- async function renderEventDisplay(eventType, payload, ctx) {
53
- const snapshot = denormalizeDisplaySnapshot(payload);
54
- if (snapshot) {
55
- return snapshot;
56
- }
57
- const renderer = resolveDisplayRenderer(eventType);
58
- if (!renderer) {
59
- return {
60
- title: eventType,
61
- subtitle: "No display renderer registered for this event type."
62
- };
63
- }
64
- return await renderer(payload, ctx);
65
- }
66
- async function _runInlineTests() {
67
- const testEventType = "__TestEvent__";
68
- registerDisplayRenderer(testEventType, (payload) => ({
69
- title: `Test: ${payload.name}`,
70
- subtitle: "registered renderer"
71
- }));
72
- const renderer = resolveDisplayRenderer(testEventType);
73
- assert.ok(renderer, "resolveDisplayRenderer should return the registered renderer");
74
- const result = await renderEventDisplay(testEventType, { name: "Alice" });
75
- assert.strictEqual(result.title, "Test: Alice");
76
- assert.strictEqual(result.subtitle, "registered renderer");
77
- const snapshot = {
78
- title: "Snapshot Title",
79
- subtitle: "snapshot subtitle",
80
- stateLabel: "archived",
81
- primaryFacts: [{ label: "ID", value: "123" }]
82
- };
83
- const snapshotResult = await renderEventDisplay(testEventType, {
84
- _displaySnapshot: snapshot
85
- });
86
- assert.deepStrictEqual(snapshotResult, snapshot);
87
- const fallback = await renderEventDisplay("__UnknownEvent__", {});
88
- assert.strictEqual(fallback.title, "__UnknownEvent__");
89
- assert.strictEqual(fallback.subtitle, "No display renderer registered for this event type.");
90
- registerDisplayRenderer("__AsyncEvent__", async (_payload, ctx) => {
91
- return {
92
- title: `Async: ${ctx?.tenantId ?? "no-ctx"}`
93
- };
94
- });
95
- const asyncResult = await renderEventDisplay(
96
- "__AsyncEvent__",
97
- {},
98
- { tenantId: "t-1", spaceId: "s-1", db: {} }
99
- );
100
- assert.strictEqual(asyncResult.title, "Async: t-1");
101
- console.log("\u2705 display engine inline tests passed");
102
- }
103
- if (import.meta.url === `file://${process.argv[1]}`) {
104
- _runInlineTests().catch((err) => {
105
- console.error("\u274C display engine inline tests failed", err);
106
- process.exit(1);
107
- });
108
- }
109
-
110
- // events/index.ts
111
- var eventTypeRegistry = /* @__PURE__ */ new Set([
112
- "ComplianceBlocked",
113
- "StateTransitioned",
114
- "AdapterInvocationStarted",
115
- "AdapterInvocationSucceeded",
116
- "AdapterInvocationFailed",
117
- "WebhookReceived"
118
- ]);
119
- var dynamicSubjectTypes = /* @__PURE__ */ new Set();
120
- var dynamicEventTypes = /* @__PURE__ */ new Set();
121
- function registerSubjectType(type) {
122
- dynamicSubjectTypes.add(type);
123
- }
124
- function registerEventType(type) {
125
- dynamicEventTypes.add(type);
126
- }
127
- function isValidEventType(type) {
128
- return eventTypeRegistry.has(type) || dynamicEventTypes.has(type);
129
- }
130
-
131
- // objects/index.ts
132
- var objectTypeRegistry = /* @__PURE__ */ new Set([
133
- "AssetEvent",
134
- "ActionInvocation",
135
- "PolicyEvaluation",
136
- "ApprovalRequest",
137
- "ConsentRecord",
138
- "AgentRun"
139
- ]);
140
- function assertObjectType(type) {
141
- if (!/^[A-Z][a-zA-Z0-9]*$/.test(type)) {
142
- throw new Error(
143
- `Invalid object type: "${type}". Object types must be PascalCase alphanumeric.`
144
- );
145
- }
146
- }
147
- function registerObjectType(type) {
148
- assertObjectType(type);
149
- objectTypeRegistry.add(type);
150
- }
151
-
152
- // policies/index.ts
153
- function assertPolicyId(policyId) {
154
- if (!/^[a-z][a-z0-9_-]*(\.[a-z][a-z0-9_-]*)*\.v[0-9]+$/.test(policyId)) {
155
- throw new Error(`Invalid policy ID: ${policyId}`);
156
- }
157
- }
158
- var registry3 = /* @__PURE__ */ new Map();
159
- function registerPolicy(evaluator) {
160
- assertPolicyId(evaluator.policyId);
161
- const existing = registry3.get(evaluator.policyId);
162
- if (existing && existing !== evaluator) {
163
- throw new Error(
164
- `Conflicting policy registration for "${evaluator.policyId}". A different evaluator is already registered.`
165
- );
166
- }
167
- registry3.set(evaluator.policyId, evaluator);
168
- }
169
- function registerPolicyIfMissing(evaluator) {
170
- if (!registry3.has(evaluator.policyId)) {
171
- registerPolicy(evaluator);
172
- return;
173
- }
174
- const existing = registry3.get(evaluator.policyId);
175
- if (existing && existing !== evaluator) {
176
- throw new Error(
177
- `Conflicting policy registration for "${evaluator.policyId}". A different evaluator is already registered.`
178
- );
179
- }
180
- }
181
-
182
- // state-machines/engine.ts
183
- var registry4 = /* @__PURE__ */ new Map();
184
- function registerStateMachine(def) {
185
- if (registry4.has(def.entityType)) {
186
- throw new Error(`State machine for entity type "${def.entityType}" is already registered.`);
187
- }
188
- registry4.set(def.entityType, def);
189
- }
190
- function registerStateMachineIfMissing(def) {
191
- if (!registry4.has(def.entityType)) {
192
- registerStateMachine(def);
193
- }
194
- }
195
-
196
- // modules/index.ts
197
- var registeredModuleNamespaces = /* @__PURE__ */ new Set();
198
- function getModuleDependencyNamespace(dependency) {
199
- return typeof dependency === "string" ? dependency : dependency.namespace;
200
- }
201
- function getObjectTypeName(objectType) {
202
- return typeof objectType === "string" ? objectType : objectType.type;
203
- }
204
- function getEventTypeName(eventType) {
205
- return typeof eventType === "string" ? eventType : eventType.eventType;
206
- }
207
- function validateModuleNamespace(namespace) {
208
- if (!namespace) {
209
- throw new Error("Module namespace cannot be empty");
210
- }
211
- if (!/^[a-z][a-z0-9-]*$/.test(namespace)) {
212
- throw new Error(
213
- `Invalid module namespace: "${namespace}". Must be lowercase letters, numbers, and hyphens only.`
214
- );
215
- }
216
- }
217
- function createModuleRegistry(modules = []) {
218
- const registered = /* @__PURE__ */ new Map();
219
- for (const module of modules) {
220
- validateModuleNamespace(module.namespace);
221
- if (registered.has(module.namespace)) {
222
- throw new Error(`Duplicate FabricModule namespace "${module.namespace}".`);
223
- }
224
- registered.set(module.namespace, module);
225
- }
226
- return { modules: registered };
227
- }
228
- function validateIdentifierList(values, label, namespace) {
229
- for (const value of values ?? []) {
230
- if (!value) {
231
- throw new Error(`Module "${namespace}" has an empty ${label} entry.`);
232
- }
233
- }
234
- }
235
- function validateManifest(module, context = {}) {
236
- validateModuleNamespace(module.namespace);
237
- const dependencies = (module.dependencies ?? []).map(getModuleDependencyNamespace);
238
- const objectTypes = (module.objectTypes ?? []).map(getObjectTypeName);
239
- const eventTypes = (module.eventTypes ?? []).map(getEventTypeName);
240
- for (const dependency of dependencies) {
241
- validateModuleNamespace(dependency);
242
- if (dependency === module.namespace) {
243
- throw new Error(`Module "${module.namespace}" cannot depend on itself.`);
244
- }
245
- if (context.availableNamespaces && !context.availableNamespaces.has(dependency)) {
246
- throw new Error(`Module "${module.namespace}" depends on missing module "${dependency}".`);
247
- }
248
- }
249
- validateIdentifierList(objectTypes, "objectTypes", module.namespace);
250
- validateIdentifierList(module.subjectTypes, "subjectTypes", module.namespace);
251
- validateIdentifierList(eventTypes, "eventTypes", module.namespace);
252
- for (const objectType of objectTypes) {
253
- if (!/^[A-Z][a-zA-Z0-9]*$/.test(objectType)) {
254
- throw new Error(
255
- `Invalid object type: "${objectType}". Object types must be PascalCase alphanumeric.`
256
- );
257
- }
258
- }
259
- for (const action of module.actions ?? []) {
260
- if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(action.actionId)) {
261
- throw new Error(`Invalid action ID: ${action.actionId}`);
262
- }
263
- if (action.namespace !== module.namespace) {
264
- throw new Error(
265
- `Action "${action.actionId}" declares namespace "${action.namespace}" but is registered by module "${module.namespace}".`
266
- );
267
- }
268
- if (!action.actionId.startsWith(`${module.namespace}.`)) {
269
- throw new Error(
270
- `Action "${action.actionId}" must start with module namespace "${module.namespace}."`
271
- );
272
- }
273
- if (action.mutatesDomain && action.emitsEvents.length === 0) {
274
- throw new Error(
275
- `Action "${action.actionId}" mutates domain but emits no events. Every mutating action must emit at least one AssetEvent.`
276
- );
277
- }
278
- }
279
- for (const descriptor of module.displayRenderers ?? []) {
280
- const isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;
281
- const isModuleEventType = eventTypes.includes(descriptor.eventType);
282
- if (!isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {
283
- throw new Error(
284
- `Display renderer registered for unknown event type "${descriptor.eventType}". Register the event type before adding a display renderer.`
285
- );
286
- }
287
- }
288
- }
289
- function sortModulesByDependency(modules, registeredNamespaces = registeredModuleNamespaces) {
290
- const modulesByNamespace = /* @__PURE__ */ new Map();
291
- for (const module of modules) {
292
- validateModuleNamespace(module.namespace);
293
- if (modulesByNamespace.has(module.namespace)) {
294
- throw new Error(`Duplicate Fabric module namespace "${module.namespace}".`);
295
- }
296
- modulesByNamespace.set(module.namespace, module);
297
- }
298
- const sorted = [];
299
- const visiting = /* @__PURE__ */ new Set();
300
- const visited = /* @__PURE__ */ new Set();
301
- function visit(module, path) {
302
- if (visited.has(module.namespace)) {
303
- return;
304
- }
305
- if (visiting.has(module.namespace)) {
306
- throw new Error(
307
- `Cyclic Fabric module dependency detected: ${[...path, module.namespace].join(" -> ")}`
308
- );
309
- }
310
- visiting.add(module.namespace);
311
- for (const dependency of (module.dependencies ?? []).map(getModuleDependencyNamespace)) {
312
- const dependencyModule = modulesByNamespace.get(dependency);
313
- if (!dependencyModule) {
314
- if (registeredNamespaces.has(dependency)) {
315
- continue;
316
- }
317
- throw new Error(`Module "${module.namespace}" depends on missing module "${dependency}".`);
318
- }
319
- visit(dependencyModule, [...path, module.namespace]);
320
- }
321
- visiting.delete(module.namespace);
322
- visited.add(module.namespace);
323
- sorted.push(module);
324
- }
325
- for (const module of modules) {
326
- visit(module, []);
327
- }
328
- return sorted;
329
- }
330
- function registerFabricModule(module) {
331
- validateManifest(module, { availableNamespaces: registeredModuleNamespaces });
332
- for (const objectType of module.objectTypes ?? []) {
333
- registerObjectType(getObjectTypeName(objectType));
334
- }
335
- for (const subjectType of module.subjectTypes ?? []) {
336
- registerSubjectType(subjectType);
337
- }
338
- for (const eventType of module.eventTypes ?? []) {
339
- registerEventType(getEventTypeName(eventType));
340
- }
341
- for (const policy of module.policies ?? []) {
342
- registerPolicyIfMissing(policy);
343
- }
344
- for (const machine of module.stateMachines ?? []) {
345
- registerStateMachineIfMissing(machine);
346
- }
347
- for (const action of module.actions ?? []) {
348
- registerActionIfMissing(action);
349
- }
350
- for (const descriptor of module.displayRenderers ?? []) {
351
- registerDisplayRenderer(descriptor.eventType, descriptor.renderer);
352
- }
353
- registeredModuleNamespaces.add(module.namespace);
354
- }
355
- function registerFabricModules(modules) {
356
- const availableNamespaces = /* @__PURE__ */ new Set([
357
- ...registeredModuleNamespaces,
358
- ...modules.map((module) => module.namespace)
359
- ]);
360
- const plannedEventTypes = new Set(
361
- modules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName))
362
- );
363
- for (const module of modules) {
364
- validateManifest(module, { availableNamespaces, plannedEventTypes });
365
- }
366
- const sortedModules = sortModulesByDependency(modules);
367
- for (const module of sortedModules) {
368
- registerFabricModule(module);
369
- }
370
- return sortedModules;
371
- }
372
-
373
- export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace };
1
+ export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from '../chunk-PXMKCAQI.js';
2
+ import '../chunk-I35B576X.js';
3
+ import '../chunk-KOC4A7A4.js';
4
+ import '../chunk-3A6FU3KV.js';
5
+ import '../chunk-6FMW4NF6.js';
6
+ import '../chunk-3F6FKQZA.js';
7
+ import '../chunk-4YQOGV7H.js';
374
8
  //# sourceMappingURL=index.js.map
375
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../actions/index.ts","../../displays/index.ts","../../events/index.ts","../../objects/index.ts","../../policies/index.ts","../../state-machines/engine.ts","../../modules/index.ts"],"names":["registry"],"mappings":";;;AA+JA,IAAM,QAAA,uBAAe,GAAA,EAAgC;AAE9C,SAAS,eAAe,QAAA,EAAgD;AAC9E,EAAA,IAAI,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rD,EAAA,KAAA,MAAW,UAAU,aAAA,EAAe;AACnC,IAAA,oBAAA,CAAqB,MAAM,CAAA;AAAA,EAC5B;AAEA,EAAA,OAAO,aAAA;AACR","file":"index.js","sourcesContent":["export type ActionId = `${string}.${string}`;\n\nexport interface SchemaParseIssue {\n\tpath: PropertyKey[];\n\tmessage: string;\n}\n\nexport type SchemaParseResult<T = unknown> =\n\t| { success: true; data: T }\n\t| { success: false; error: { issues: SchemaParseIssue[] } };\n\nexport interface SchemaValidator<T = unknown> {\n\tparse(input: unknown): T;\n\tsafeParse(input: unknown): SchemaParseResult<T>;\n}\n\nexport type ActorType =\n\t| \"natural_person\"\n\t| \"agent\"\n\t| \"system\"\n\t| \"service_account\"\n\t| \"external_system\"\n\t| \"integration\";\n\nexport const ACTOR_TYPES: readonly ActorType[] = [\n\t\"natural_person\",\n\t\"agent\",\n\t\"system\",\n\t\"service_account\",\n\t\"external_system\",\n\t\"integration\",\n] as const;\n\nexport function isActorType(value: string): value is ActorType {\n\treturn (ACTOR_TYPES as readonly string[]).includes(value);\n}\n\nexport function assertActorType(value: string): asserts value is ActorType {\n\tif (!isActorType(value)) {\n\t\tthrow new Error(`Invalid actorType: ${value}`);\n\t}\n}\n\nexport type ActionStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"blocked_by_policy\"\n\t| \"waiting_for_approval\"\n\t| \"validation_failed\";\n\nexport interface FabricRuntimeServices {\n\treadonly [serviceName: string]: unknown;\n}\n\nexport interface ActionContext<TDb = unknown> {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tactorId: string;\n\tactorType: ActorType;\n\tcorrelationId: string;\n\tcausationId?: string;\n\tdb: TDb;\n\tservices?: FabricRuntimeServices;\n}\n\nexport interface ActionResult {\n\tsuccess: boolean;\n\tdata?: Record<string, unknown>;\n\terror?: string;\n}\n\nexport type ActionHandler<TDb = unknown> = (\n\tctx: ActionContext<TDb>,\n\tparams: unknown,\n) => Promise<ActionResult>;\n\nexport interface AdapterStepRetryPolicy {\n\tidempotent: boolean;\n\tmaxAttempts?: number;\n\tinitialDelayMs?: number;\n\tbackoffMultiplier?: number;\n\tmaxDelayMs?: number;\n}\n\nexport interface AdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n\tgetInput: (\n\t\tparams: unknown,\n\t\thandlerResult: Record<string, unknown>,\n\t) => Record<string, unknown> | undefined;\n}\n\nexport interface ActionStateMachineBinding {\n\tentityType: string;\n\ttargetState: string | ((params: unknown) => string);\n\tgetEntityId: (params: unknown) => string | undefined;\n}\n\nexport interface ActionDefinition<TDb = unknown> {\n\tactionId: ActionId;\n\tnamespace: string;\n\tversion: number;\n\tschema: SchemaValidator;\n\thandler?: ActionHandler<TDb>;\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\tpolicies?: `${string}.v${number}`[];\n\temitsEvents: string[];\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\tstateMachine?: ActionStateMachineBinding;\n\tadapterSteps?: AdapterStep[];\n\t/**\n\t * If \"saga\", the action is a multi-step orchestration. The worker dispatches\n\t * to a registered saga implementation instead of running `handler` directly.\n\t */\n\tkind?: \"atomic\" | \"saga\";\n}\n\nexport interface SagaContext {\n\tactionInvocationId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tparameters: unknown;\n\tsleep?: (delayMs: number) => Promise<void>;\n\tquery?: <T = unknown>(model: string, operation: string, args: unknown) => Promise<T>;\n}\n\nexport interface SagaChildActionInput {\n\tsuffix: string;\n\tactionId: string;\n\tparameters: Record<string, unknown>;\n}\n\nexport type SagaRunChild = (input: SagaChildActionInput) => Promise<Record<string, unknown>>;\n\nexport interface SagaCompletionEvent {\n\teventType: string;\n\tsubjectType: string;\n\tsubjectId: string;\n\tpayload: unknown;\n\teventSchemaVersion?: number;\n}\n\nexport interface SagaCompletion {\n\tresultData: Record<string, unknown>;\n\tevent?: SagaCompletionEvent;\n}\n\nexport type SagaImplementation = (\n\tctx: SagaContext,\n\trunChild: SagaRunChild,\n) => Promise<SagaCompletion>;\n\nconst registry = new Map<ActionId, ActionDefinition>();\n\nexport function assertActionId(actionId: string): asserts actionId is ActionId {\n\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(actionId)) {\n\t\tthrow new Error(`Invalid action ID: ${actionId}`);\n\t}\n}\n\nexport function registerAction(definition: ActionDefinition): void {\n\tassertActionId(definition.actionId);\n\n\tif (registry.has(definition.actionId)) {\n\t\tthrow new Error(`Action \"${definition.actionId}\" is already registered`);\n\t}\n\n\tif (definition.mutatesDomain && definition.emitsEvents.length === 0) {\n\t\tthrow new Error(\n\t\t\t`Action \"${definition.actionId}\" mutates domain but emits no events. ` +\n\t\t\t\t`Every mutating action must emit at least one AssetEvent.`,\n\t\t);\n\t}\n\n\tregistry.set(definition.actionId, definition);\n}\n\nexport function resolveAction(actionId: ActionId): ActionDefinition | undefined {\n\treturn registry.get(actionId);\n}\n\nexport function isRegisteredActionId(actionId: string): actionId is ActionId {\n\treturn registry.has(actionId as ActionId);\n}\n\nexport function resolveRegisteredAction(actionId: string): ActionDefinition | undefined {\n\tif (!isRegisteredActionId(actionId)) {\n\t\treturn undefined;\n\t}\n\n\treturn resolveAction(actionId);\n}\n\nexport function getRegisteredActionIds(): ActionId[] {\n\treturn Array.from(registry.keys());\n}\n\nexport function registerActionIfMissing(definition: ActionDefinition): void {\n\tif (!registry.has(definition.actionId)) {\n\t\tregisterAction(definition);\n\t}\n}\n","import assert from \"node:assert\";\n\nexport interface DisplayDescriptor {\n\ttitle: string;\n\tsubtitle?: string;\n\tstateLabel?: string;\n\tprimaryFacts?: Array<{ label: string; value: string }>;\n}\n\nexport interface CachedDisplayDescriptor extends DisplayDescriptor {\n\t_cachedDisplay?: {\n\t\tsource: \"event_payload\" | \"projection_snapshot\";\n\t\tcursor?: string | null;\n\t\tchecksum?: string;\n\t\tgeneratedAt?: string;\n\t};\n}\n\nexport type DisplayDatabaseClient = any;\n\nexport interface DisplayContext<TDb = DisplayDatabaseClient> {\n\ttenantId: string;\n\tspaceId: string;\n\tdb: TDb;\n}\n\nexport type DisplayRenderer = (\n\tpayload: unknown,\n\tctx?: DisplayContext,\n) => DisplayDescriptor | Promise<DisplayDescriptor>;\n\nexport interface DisplayRendererRegistration {\n\teventType: string;\n\trenderer: DisplayRenderer;\n}\n\nconst registry = new Map<string, DisplayRenderer>();\n\nexport function registerDisplayRenderer(eventType: string, renderer: DisplayRenderer): void {\n\tregistry.set(eventType, renderer);\n}\n\nexport function resolveDisplayRenderer(eventType: string): DisplayRenderer | undefined {\n\treturn registry.get(eventType);\n}\n\nexport function denormalizeDisplaySnapshot(payload: unknown): CachedDisplayDescriptor | undefined {\n\tif (\n\t\tpayload !== null &&\n\t\ttypeof payload === \"object\" &&\n\t\t\"_displaySnapshot\" in payload &&\n\t\tpayload._displaySnapshot !== null &&\n\t\ttypeof payload._displaySnapshot === \"object\" &&\n\t\t\"title\" in payload._displaySnapshot\n\t) {\n\t\treturn payload._displaySnapshot as CachedDisplayDescriptor;\n\t}\n\n\tif (\n\t\tpayload !== null &&\n\t\ttypeof payload === \"object\" &&\n\t\t\"_projectionSnapshot\" in payload &&\n\t\tpayload._projectionSnapshot !== null &&\n\t\ttypeof payload._projectionSnapshot === \"object\" &&\n\t\t\"display\" in payload._projectionSnapshot &&\n\t\tpayload._projectionSnapshot.display !== null &&\n\t\ttypeof payload._projectionSnapshot.display === \"object\" &&\n\t\t\"title\" in payload._projectionSnapshot.display\n\t) {\n\t\tconst snapshot = payload._projectionSnapshot as {\n\t\t\tdisplay: DisplayDescriptor;\n\t\t\teventCursor?: string | null;\n\t\t\tchecksum?: string;\n\t\t\tupdatedAt?: string;\n\t\t};\n\t\treturn {\n\t\t\t...snapshot.display,\n\t\t\t_cachedDisplay: {\n\t\t\t\tsource: \"projection_snapshot\",\n\t\t\t\tcursor: snapshot.eventCursor,\n\t\t\t\tchecksum: snapshot.checksum,\n\t\t\t\tgeneratedAt: snapshot.updatedAt,\n\t\t\t},\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport async function renderEventDisplay(\n\teventType: string,\n\tpayload: unknown,\n\tctx?: DisplayContext,\n): Promise<CachedDisplayDescriptor> {\n\tconst snapshot = denormalizeDisplaySnapshot(payload);\n\tif (snapshot) {\n\t\treturn snapshot;\n\t}\n\n\tconst renderer = resolveDisplayRenderer(eventType);\n\tif (!renderer) {\n\t\treturn {\n\t\t\ttitle: eventType,\n\t\t\tsubtitle: \"No display renderer registered for this event type.\",\n\t\t};\n\t}\n\n\treturn await renderer(payload, ctx);\n}\n\n// Inline test: verify registry round-trip, snapshot denormalization, and fallback.\nasync function _runInlineTests(): Promise<void> {\n\tconst testEventType = \"__TestEvent__\";\n\n\t// 1. Registry round-trip\n\tregisterDisplayRenderer(testEventType, (payload) => ({\n\t\ttitle: `Test: ${(payload as { name: string }).name}`,\n\t\tsubtitle: \"registered renderer\",\n\t}));\n\n\tconst renderer = resolveDisplayRenderer(testEventType);\n\tassert.ok(renderer, \"resolveDisplayRenderer should return the registered renderer\");\n\n\tconst result = await renderEventDisplay(testEventType, { name: \"Alice\" });\n\tassert.strictEqual(result.title, \"Test: Alice\");\n\tassert.strictEqual(result.subtitle, \"registered renderer\");\n\n\t// 2. Snapshot denormalization takes precedence over renderer\n\tconst snapshot: DisplayDescriptor = {\n\t\ttitle: \"Snapshot Title\",\n\t\tsubtitle: \"snapshot subtitle\",\n\t\tstateLabel: \"archived\",\n\t\tprimaryFacts: [{ label: \"ID\", value: \"123\" }],\n\t};\n\tconst snapshotResult = await renderEventDisplay(testEventType, {\n\t\t_displaySnapshot: snapshot,\n\t});\n\tassert.deepStrictEqual(snapshotResult, snapshot);\n\n\t// 3. Fallback for unregistered event type\n\tconst fallback = await renderEventDisplay(\"__UnknownEvent__\", {});\n\tassert.strictEqual(fallback.title, \"__UnknownEvent__\");\n\tassert.strictEqual(fallback.subtitle, \"No display renderer registered for this event type.\");\n\n\t// 4. Async renderer with context\n\tregisterDisplayRenderer(\"__AsyncEvent__\", async (_payload, ctx) => {\n\t\treturn {\n\t\t\ttitle: `Async: ${ctx?.tenantId ?? \"no-ctx\"}`,\n\t\t};\n\t});\n\tconst asyncResult = await renderEventDisplay(\n\t\t\"__AsyncEvent__\",\n\t\t{},\n\t\t{ tenantId: \"t-1\", spaceId: \"s-1\", db: {} },\n\t);\n\tassert.strictEqual(asyncResult.title, \"Async: t-1\");\n\n\tconsole.log(\"✅ display engine inline tests passed\");\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n\t_runInlineTests().catch((err) => {\n\t\tconsole.error(\"❌ display engine inline tests failed\", err);\n\t\tprocess.exit(1);\n\t});\n}\n","export interface AssetEventEnvelope<TPayload = unknown> {\n\tid: string;\n\ttenantId: string;\n\tspaceId: string;\n\teventType: string;\n\teventSchemaVersion: number;\n\tsubjectType: string;\n\tsubjectId: string;\n\tactorId: string;\n\tactorType: string;\n\tactionInvocationId?: string;\n\tpayload: TPayload;\n\tsequence: number;\n\toccurredAt: Date;\n\trecordedAt: Date;\n\tcorrelationId: string;\n\tcausationId?: string;\n}\n\nconst subjectTypeRegistry = new Set<string>([\n\t\"ActionInvocation\",\n\t\"PolicyEvaluation\",\n\t\"AdapterInvocation\",\n]);\n\nconst eventTypeRegistry = new Set<string>([\n\t\"ComplianceBlocked\",\n\t\"StateTransitioned\",\n\t\"AdapterInvocationStarted\",\n\t\"AdapterInvocationSucceeded\",\n\t\"AdapterInvocationFailed\",\n\t\"WebhookReceived\",\n]);\n\nconst dynamicSubjectTypes = new Set<string>();\nconst dynamicEventTypes = new Set<string>();\n\nexport type AssetEventSubjectType = string;\nexport type AssetEventType = string;\nexport type AssetEventActorType = \"natural_person\" | \"agent\" | \"adapter\" | \"system\" | \"service_account\" | \"external_system\" | \"integration\";\n\nexport function registerSubjectType(type: string): void {\n\tdynamicSubjectTypes.add(type);\n}\n\nexport function isValidSubjectType(type: string): boolean {\n\treturn subjectTypeRegistry.has(type) || dynamicSubjectTypes.has(type);\n}\n\nexport function getRegisteredSubjectTypes(): string[] {\n\treturn Array.from(new Set([...subjectTypeRegistry, ...dynamicSubjectTypes]));\n}\n\nexport function registerEventType(type: string): void {\n\tdynamicEventTypes.add(type);\n}\n\nexport function isValidEventType(type: string): boolean {\n\treturn eventTypeRegistry.has(type) || dynamicEventTypes.has(type);\n}\n\nexport function getRegisteredEventTypes(): string[] {\n\treturn Array.from(new Set([...eventTypeRegistry, ...dynamicEventTypes]));\n}\n\nexport interface EventTypeRegistry {\n\tregister(eventType: string): void;\n\thas(eventType: string): boolean;\n\tlist(): string[];\n}\n\nexport function createEventTypeRegistry(initialEventTypes: string[] = []): EventTypeRegistry {\n\tconst eventTypes = new Set(initialEventTypes);\n\treturn {\n\t\tregister(eventType) {\n\t\t\tif (!eventType) {\n\t\t\t\tthrow new Error(\"Event type cannot be empty\");\n\t\t\t}\n\t\t\teventTypes.add(eventType);\n\t\t},\n\t\thas(eventType) {\n\t\t\treturn eventTypes.has(eventType);\n\t\t},\n\t\tlist() {\n\t\t\treturn Array.from(eventTypes).sort();\n\t\t},\n\t};\n}\n","const objectTypeRegistry = new Set<string>([\n\t\"AssetEvent\",\n\t\"ActionInvocation\",\n\t\"PolicyEvaluation\",\n\t\"ApprovalRequest\",\n\t\"ConsentRecord\",\n\t\"AgentRun\",\n]);\n\nexport type FabricObjectType = string;\n\nexport function assertObjectType(type: string): asserts type is FabricObjectType {\n\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(type)) {\n\t\tthrow new Error(\n\t\t\t`Invalid object type: \"${type}\". Object types must be PascalCase alphanumeric.`,\n\t\t);\n\t}\n}\n\nexport function registerObjectType(type: string): void {\n\tassertObjectType(type);\n\tobjectTypeRegistry.add(type);\n}\n\nexport function isValidObjectType(type: string): boolean {\n\treturn objectTypeRegistry.has(type);\n}\n\nexport function getRegisteredObjectTypes(): string[] {\n\treturn Array.from(objectTypeRegistry);\n}\n","export type PolicyEvaluationResult = \"pass\" | \"warn\" | \"block\";\n\nexport type PolicyKind = \"code\" | \"data\" | \"hybrid\";\n\nexport type PolicyId = `${string}.v${number}`;\n\nexport type PolicyEvaluationMode = \"preview\" | \"execute\";\n\nexport function assertPolicyId(policyId: string): asserts policyId is PolicyId {\n\tif (!/^[a-z][a-z0-9_-]*(\\.[a-z][a-z0-9_-]*)*\\.v[0-9]+$/.test(policyId)) {\n\t\tthrow new Error(`Invalid policy ID: ${policyId}`);\n\t}\n}\n\nexport interface PolicyContext<TDb = unknown> {\n\ttenantId: string;\n\tspaceId: string;\n\tactionInvocationId: string;\n\tactionId: string;\n\tparameters: unknown;\n\tdb: TDb;\n\tnow?: Date;\n\tmode?: PolicyEvaluationMode;\n}\n\nexport interface PolicyOutcome {\n\tpolicyId: PolicyId;\n\tpolicyVersion: number;\n\tpolicyKind?: PolicyKind;\n\tresult: PolicyEvaluationResult;\n\treason?: string;\n\tmetadata?: Record<string, unknown>;\n\tdispatchEvidence?: PolicyDispatchEvidence;\n}\n\nexport interface PolicyEvaluator<TDb = unknown> {\n\tpolicyId: PolicyId;\n\tversion: number;\n\tkind?: Extract<PolicyKind, \"code\">;\n\tpreviewSafe?: boolean;\n\tevaluate: (ctx: PolicyContext<TDb>) => Promise<PolicyOutcome>;\n}\n\nexport type DataPolicySource = \"parameters\" | \"context\";\n\nexport type DataPolicyLiteral = string | number | boolean | null;\n\nexport type DataPolicyComparisonOperator =\n\t| \"exists\"\n\t| \"equals\"\n\t| \"notEquals\"\n\t| \"gt\"\n\t| \"gte\"\n\t| \"lt\"\n\t| \"lte\";\n\nexport interface DataPolicySourceReference {\n\tsource: DataPolicySource;\n\tpath: string;\n}\n\nexport type DataPolicyCondition =\n\t| {\n\t\t\tconditionId: string;\n\t\t\ttype: \"always\";\n\t\t\tresult: PolicyEvaluationResult;\n\t\t\treason?: string;\n\t\t}\n\t| {\n\t\t\tconditionId: string;\n\t\t\ttype: \"parameter\";\n\t\t\tpath: string;\n\t\t\toperator: DataPolicyComparisonOperator;\n\t\t\tvalue?: DataPolicyLiteral;\n\t\t\tonPass?: PolicyEvaluationResult;\n\t\t\tonFail?: PolicyEvaluationResult;\n\t\t\treason?: string;\n\t\t}\n\t| {\n\t\t\tconditionId: string;\n\t\t\ttype: \"comparison\";\n\t\t\tleft: DataPolicySourceReference;\n\t\t\toperator: DataPolicyComparisonOperator;\n\t\t\tvalue?: DataPolicyLiteral;\n\t\t\tonPass?: PolicyEvaluationResult;\n\t\t\tonFail?: PolicyEvaluationResult;\n\t\t\treason?: string;\n\t\t}\n\t| {\n\t\t\tconditionId: string;\n\t\t\ttype: \"all\" | \"any\";\n\t\t\tconditions: DataPolicyCondition[];\n\t\t\tonPass?: PolicyEvaluationResult;\n\t\t\tonFail?: PolicyEvaluationResult;\n\t\t\treason?: string;\n\t\t}\n\t| {\n\t\t\tconditionId: string;\n\t\t\ttype: \"not\";\n\t\t\tcondition: DataPolicyCondition;\n\t\t\tonPass?: PolicyEvaluationResult;\n\t\t\tonFail?: PolicyEvaluationResult;\n\t\t\treason?: string;\n\t\t};\n\nexport interface DataPolicyDefinition {\n\tconditions: DataPolicyCondition[];\n\tdefaultResult?: PolicyEvaluationResult;\n\treason?: string;\n}\n\nexport interface DataPolicyValidationResult {\n\tvalid: boolean;\n\terrors: string[];\n}\n\nconst DATA_POLICY_MAX_DEPTH = 5;\nconst DATA_POLICY_MAX_CONDITIONS_PER_NODE = 20;\nconst DATA_POLICY_MAX_TOTAL_CONDITIONS = 100;\nconst DATA_POLICY_MAX_PATH_SEGMENTS = 12;\nconst DATA_POLICY_MAX_STRING_LENGTH = 500;\n\nconst DATA_POLICY_CONTEXT_PATHS = new Set([\n\t\"tenantId\",\n\t\"spaceId\",\n\t\"actionInvocationId\",\n\t\"actionId\",\n\t\"mode\",\n]);\n\nconst DATA_POLICY_COMPARISON_OPERATORS = new Set<DataPolicyComparisonOperator>([\n\t\"exists\",\n\t\"equals\",\n\t\"notEquals\",\n\t\"gt\",\n\t\"gte\",\n\t\"lt\",\n\t\"lte\",\n]);\n\nconst POLICY_RESULTS = new Set<PolicyEvaluationResult>([\"pass\", \"warn\", \"block\"]);\n\nexport interface PolicyFallbackDefinition {\n\tcodeEvaluatorPolicyId: PolicyId;\n\tonResults?: PolicyEvaluationResult[];\n\ttriggers?: PolicyFallbackTrigger[];\n\treason?: string;\n}\n\nexport type PolicyFallbackTrigger =\n\t| \"data_result\"\n\t| \"missing_data_definition\"\n\t| \"invalid_data_definition\";\n\nexport interface DataPolicyConditionResult {\n\tconditionId: string;\n\tpassed: boolean;\n\tresult: PolicyEvaluationResult;\n\treason?: string;\n}\n\nexport interface RuntimePolicyDefinition {\n\tpolicyId: PolicyId;\n\tpolicyVersion: number;\n\tkind: PolicyKind;\n\tdataDefinition?: DataPolicyDefinition;\n\tcodeEvaluatorPolicyId?: PolicyId;\n\tfallback?: PolicyFallbackDefinition;\n}\n\nexport interface PolicyDispatchEvidence {\n\tpolicyKind: PolicyKind;\n\tpolicyId?: PolicyId;\n\tpolicyVersion?: number;\n\tdispatchPath: Array<\"data\" | \"code\" | \"fallback\">;\n\tdata?: {\n\t\tdefinitionVersion: number;\n\t\tdefinitionStatus: \"evaluated\" | \"missing\" | \"invalid\";\n\t\tconditionResults: DataPolicyConditionResult[];\n\t\tvalidationErrors?: string[];\n\t};\n\tcode?: {\n\t\trequestedPolicyId?: PolicyId;\n\t\tpolicyId: PolicyId;\n\t\tversion?: number;\n\t\tregistered: boolean;\n\t};\n\tfallback?: {\n\t\tused: boolean;\n\t\ttrigger: PolicyFallbackTrigger | \"not_triggered\";\n\t\treason: string;\n\t\tfromResult?: PolicyEvaluationResult;\n\t\tdefinitionVersion: number;\n\t\tcodeEvaluatorPolicyId: PolicyId;\n\t};\n}\n\nconst registry = new Map<PolicyId, PolicyEvaluator>();\n\nexport function registerPolicy(evaluator: PolicyEvaluator): void {\n\tassertPolicyId(evaluator.policyId);\n\n\tconst existing = registry.get(evaluator.policyId);\n\tif (existing && existing !== evaluator) {\n\t\tthrow new Error(\n\t\t\t`Conflicting policy registration for \"${evaluator.policyId}\". ` +\n\t\t\t\t`A different evaluator is already registered.`,\n\t\t);\n\t}\n\n\tregistry.set(evaluator.policyId, evaluator);\n}\n\nexport function registerPolicyIfMissing(evaluator: PolicyEvaluator): void {\n\tif (!registry.has(evaluator.policyId)) {\n\t\tregisterPolicy(evaluator);\n\t\treturn;\n\t}\n\n\tconst existing = registry.get(evaluator.policyId);\n\tif (existing && existing !== evaluator) {\n\t\tthrow new Error(\n\t\t\t`Conflicting policy registration for \"${evaluator.policyId}\". ` +\n\t\t\t\t`A different evaluator is already registered.`,\n\t\t);\n\t}\n}\n\nexport function resolvePolicy(policyId: PolicyId): PolicyEvaluator | undefined {\n\treturn registry.get(policyId);\n}\n\nexport function getRegisteredPolicyIds(): PolicyId[] {\n\treturn Array.from(registry.keys());\n}\n\nexport async function evaluateRegisteredPolicies(\n\tpolicyIds: PolicyId[],\n\tctx: PolicyContext,\n): Promise<PolicyOutcome[]> {\n\treturn evaluatePolicyDefinitions(\n\t\tpolicyIds.map((policyId) => ({\n\t\t\tpolicyId,\n\t\t\tpolicyVersion: parsePolicyVersion(policyId),\n\t\t\tkind: \"code\",\n\t\t\tcodeEvaluatorPolicyId: policyId,\n\t\t})),\n\t\tctx,\n\t);\n}\n\nexport async function evaluatePolicyDefinitions(\n\tpolicies: RuntimePolicyDefinition[],\n\tctx: PolicyContext,\n): Promise<PolicyOutcome[]> {\n\tconst outcomes: PolicyOutcome[] = [];\n\n\tfor (const policy of policies) {\n\t\tassertPolicyId(policy.policyId);\n\t\toutcomes.push(await evaluatePolicyDefinition(policy, ctx));\n\t}\n\n\treturn outcomes;\n}\n\nexport async function evaluatePolicyDefinition(\n\tpolicy: RuntimePolicyDefinition,\n\tctx: PolicyContext,\n): Promise<PolicyOutcome> {\n\tif (policy.kind === \"data\") {\n\t\treturn evaluateDataPolicy(policy, ctx);\n\t}\n\n\tif (policy.kind === \"code\") {\n\t\treturn evaluateCodePolicy(policy, ctx);\n\t}\n\n\treturn evaluateHybridPolicy(policy, ctx);\n}\n\nasync function evaluateCodePolicy(\n\tpolicy: RuntimePolicyDefinition,\n\tctx: PolicyContext,\n): Promise<PolicyOutcome> {\n\tconst codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId ?? policy.policyId;\n\tconst evaluator = registry.get(codeEvaluatorPolicyId);\n\n\tif (!evaluator) {\n\t\treturn {\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tpolicyKind: policy.kind,\n\t\t\tresult: \"block\",\n\t\t\treason: `No evaluator registered for policy ${codeEvaluatorPolicyId}`,\n\t\t\tmetadata: {\n\t\t\t\tmissingCodeEvaluatorPolicyId: codeEvaluatorPolicyId,\n\t\t\t},\n\t\t\tdispatchEvidence: {\n\t\t\t\tpolicyKind: policy.kind,\n\t\t\t\tpolicyId: policy.policyId,\n\t\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\t\tdispatchPath: [\"code\"],\n\t\t\t\tcode: {\n\t\t\t\t\trequestedPolicyId: codeEvaluatorPolicyId,\n\t\t\t\t\tpolicyId: codeEvaluatorPolicyId,\n\t\t\t\t\tregistered: false,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tconst outcome = await evaluator.evaluate(ctx);\n\treturn normalizeOutcome(policy, outcome, {\n\t\tpolicyKind: policy.kind,\n\t\tpolicyId: policy.policyId,\n\t\tpolicyVersion: policy.policyVersion,\n\t\tdispatchPath: [\"code\"],\n\t\tcode: {\n\t\t\trequestedPolicyId: codeEvaluatorPolicyId,\n\t\t\tpolicyId: evaluator.policyId,\n\t\t\tversion: evaluator.version,\n\t\t\tregistered: true,\n\t\t},\n\t});\n}\n\nasync function evaluateHybridPolicy(\n\tpolicy: RuntimePolicyDefinition,\n\tctx: PolicyContext,\n): Promise<PolicyOutcome> {\n\tconst dataOutcome = evaluateDataPolicy(policy, ctx);\n\tconst fallback = policy.fallback;\n\tconst fallbackDecision = fallback\n\t\t? resolveFallbackDecision(policy, dataOutcome, fallback)\n\t\t: { shouldFallback: false, trigger: \"not_triggered\" as const };\n\n\tif (!fallback || !fallbackDecision.shouldFallback) {\n\t\tif (fallback && dataOutcome.dispatchEvidence) {\n\t\t\treturn {\n\t\t\t\t...dataOutcome,\n\t\t\t\tdispatchEvidence: {\n\t\t\t\t\t...dataOutcome.dispatchEvidence,\n\t\t\t\t\tfallback: {\n\t\t\t\t\t\tused: false,\n\t\t\t\t\t\ttrigger: \"not_triggered\",\n\t\t\t\t\t\treason: \"Data policy result did not trigger fallback\",\n\t\t\t\t\t\tfromResult: dataOutcome.result,\n\t\t\t\t\t\tdefinitionVersion: policy.policyVersion,\n\t\t\t\t\t\tcodeEvaluatorPolicyId: fallback.codeEvaluatorPolicyId,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn dataOutcome;\n\t}\n\n\tconst codePolicy: RuntimePolicyDefinition = {\n\t\tpolicyId: policy.policyId,\n\t\tpolicyVersion: policy.policyVersion,\n\t\tkind: \"hybrid\",\n\t\tcodeEvaluatorPolicyId: fallback.codeEvaluatorPolicyId,\n\t};\n\tconst codeOutcome = await evaluateCodePolicy(codePolicy, ctx);\n\n\treturn normalizeOutcome(policy, codeOutcome, {\n\t\t...(codeOutcome.dispatchEvidence ?? {\n\t\t\tpolicyKind: \"hybrid\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tdispatchPath: [\"code\"],\n\t\t}),\n\t\tpolicyKind: \"hybrid\",\n\t\tpolicyId: policy.policyId,\n\t\tpolicyVersion: policy.policyVersion,\n\t\tdispatchPath: [\"data\", \"fallback\", \"code\"],\n\t\tdata: dataOutcome.dispatchEvidence?.data,\n\t\tfallback: {\n\t\t\tused: true,\n\t\t\ttrigger: fallbackDecision.trigger,\n\t\t\treason: fallback.reason ?? \"Data policy result triggered code fallback\",\n\t\t\tfromResult: dataOutcome.result,\n\t\t\tdefinitionVersion: policy.policyVersion,\n\t\t\tcodeEvaluatorPolicyId: fallback.codeEvaluatorPolicyId,\n\t\t},\n\t});\n}\n\nfunction resolveFallbackDecision(\n\tpolicy: RuntimePolicyDefinition,\n\tdataOutcome: PolicyOutcome,\n\tfallback: PolicyFallbackDefinition,\n): { shouldFallback: boolean; trigger: PolicyFallbackTrigger | \"not_triggered\" } {\n\tconst allowedTriggers = fallback.triggers ?? [\n\t\t\"data_result\",\n\t\t\"missing_data_definition\",\n\t\t\"invalid_data_definition\",\n\t];\n\tconst definitionStatus = dataOutcome.dispatchEvidence?.data?.definitionStatus;\n\n\tif (definitionStatus === \"missing\") {\n\t\treturn {\n\t\t\tshouldFallback: allowedTriggers.includes(\"missing_data_definition\"),\n\t\t\ttrigger: \"missing_data_definition\",\n\t\t};\n\t}\n\n\tif (definitionStatus === \"invalid\") {\n\t\treturn {\n\t\t\tshouldFallback: allowedTriggers.includes(\"invalid_data_definition\"),\n\t\t\ttrigger: \"invalid_data_definition\",\n\t\t};\n\t}\n\n\tconst fallbackResults = fallback.onResults ?? [\"warn\", \"block\"];\n\treturn {\n\t\tshouldFallback:\n\t\t\tpolicy.kind === \"hybrid\" &&\n\t\t\tallowedTriggers.includes(\"data_result\") &&\n\t\t\tfallbackResults.includes(dataOutcome.result),\n\t\ttrigger: \"data_result\",\n\t};\n}\n\nfunction evaluateDataPolicy(policy: RuntimePolicyDefinition, ctx: PolicyContext): PolicyOutcome {\n\tconst definition = policy.dataDefinition;\n\n\tif (!definition) {\n\t\treturn {\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tpolicyKind: policy.kind,\n\t\t\tresult: \"block\",\n\t\t\treason: \"Data policy definition is missing\",\n\t\t\tdispatchEvidence: {\n\t\t\t\tpolicyKind: policy.kind,\n\t\t\t\tpolicyId: policy.policyId,\n\t\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\t\tdispatchPath: [\"data\"],\n\t\t\t\tdata: {\n\t\t\t\t\tdefinitionVersion: policy.policyVersion,\n\t\t\t\t\tdefinitionStatus: \"missing\",\n\t\t\t\t\tconditionResults: [],\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tconst validation = validateDataPolicyDefinition(definition);\n\tif (!validation.valid) {\n\t\treturn {\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tpolicyKind: policy.kind,\n\t\t\tresult: \"block\",\n\t\t\treason: `Invalid data policy definition: ${validation.errors.join(\"; \")}`,\n\t\t\tmetadata: {\n\t\t\t\tvalidationErrors: validation.errors,\n\t\t\t},\n\t\t\tdispatchEvidence: {\n\t\t\t\tpolicyKind: policy.kind,\n\t\t\t\tpolicyId: policy.policyId,\n\t\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\t\tdispatchPath: [\"data\"],\n\t\t\t\tdata: {\n\t\t\t\t\tdefinitionVersion: policy.policyVersion,\n\t\t\t\t\tdefinitionStatus: \"invalid\",\n\t\t\t\t\tconditionResults: [],\n\t\t\t\t\tvalidationErrors: validation.errors,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}\n\n\tconst evaluations = definition.conditions.map((condition) => evaluateDataPolicyCondition(condition, ctx));\n\tconst conditionResults = evaluations.flatMap((evaluation) => evaluation.evidence);\n\tconst topLevelResults = evaluations.map((evaluation) => evaluation.result);\n\tconst aggregate =\n\t\ttopLevelResults.find((result) => result.result === \"block\") ??\n\t\ttopLevelResults.find((result) => result.result === \"warn\");\n\tconst result = aggregate?.result ?? definition.defaultResult ?? \"pass\";\n\n\treturn {\n\t\tpolicyId: policy.policyId,\n\t\tpolicyVersion: policy.policyVersion,\n\t\tpolicyKind: policy.kind,\n\t\tresult,\n\t\treason: aggregate?.reason ?? definition.reason,\n\t\tmetadata: {\n\t\t\tconditionCount: definition.conditions.length,\n\t\t\tfailedConditionId: aggregate?.conditionId,\n\t\t},\n\t\tdispatchEvidence: {\n\t\t\tpolicyKind: policy.kind,\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tdispatchPath: [\"data\"],\n\t\t\tdata: {\n\t\t\t\tdefinitionVersion: policy.policyVersion,\n\t\t\t\tdefinitionStatus: \"evaluated\",\n\t\t\t\tconditionResults,\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function validateDataPolicyDefinition(\n\tdefinition: DataPolicyDefinition,\n): DataPolicyValidationResult {\n\tconst errors: string[] = [];\n\n\tif (!Array.isArray(definition.conditions) || definition.conditions.length === 0) {\n\t\terrors.push(\"conditions must contain at least one condition\");\n\t} else if (definition.conditions.length > DATA_POLICY_MAX_CONDITIONS_PER_NODE) {\n\t\terrors.push(\n\t\t\t`conditions must contain at most ${DATA_POLICY_MAX_CONDITIONS_PER_NODE} top-level conditions`,\n\t\t);\n\t}\n\n\tif (definition.defaultResult && !POLICY_RESULTS.has(definition.defaultResult)) {\n\t\terrors.push(\"defaultResult must be pass, warn, or block\");\n\t}\n\n\tlet totalConditions = 0;\n\tfor (const condition of definition.conditions ?? []) {\n\t\tvalidateDataPolicyCondition(condition, errors, 1, () => {\n\t\t\ttotalConditions += 1;\n\t\t});\n\t}\n\n\tif (totalConditions > DATA_POLICY_MAX_TOTAL_CONDITIONS) {\n\t\terrors.push(`policy must contain at most ${DATA_POLICY_MAX_TOTAL_CONDITIONS} total conditions`);\n\t}\n\n\treturn { valid: errors.length === 0, errors };\n}\n\nfunction validateDataPolicyCondition(\n\tcondition: DataPolicyCondition,\n\terrors: string[],\n\tdepth: number,\n\tcount: () => void,\n): void {\n\tcount();\n\n\tif (!condition || typeof condition !== \"object\") {\n\t\terrors.push(\"condition must be an object\");\n\t\treturn;\n\t}\n\n\tif (depth > DATA_POLICY_MAX_DEPTH) {\n\t\terrors.push(`condition depth must not exceed ${DATA_POLICY_MAX_DEPTH}`);\n\t\treturn;\n\t}\n\n\tif (!isNonEmptyBoundedString(condition.conditionId)) {\n\t\terrors.push(\"conditionId must be a non-empty bounded string\");\n\t}\n\n\tvalidateOptionalPolicyResult(\"onPass\" in condition ? condition.onPass : undefined, \"onPass\", errors);\n\tvalidateOptionalPolicyResult(\"onFail\" in condition ? condition.onFail : undefined, \"onFail\", errors);\n\n\tif (condition.reason !== undefined && !isNonEmptyBoundedString(condition.reason)) {\n\t\terrors.push(`condition ${condition.conditionId} reason must be a bounded string`);\n\t}\n\n\tif (condition.type === \"always\") {\n\t\tif (!POLICY_RESULTS.has(condition.result)) {\n\t\t\terrors.push(`condition ${condition.conditionId} result must be pass, warn, or block`);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (condition.type === \"parameter\") {\n\t\tvalidatePath(condition.path, `condition ${condition.conditionId} path`, errors);\n\t\tvalidateComparison(condition.operator, condition.value, condition.conditionId, errors);\n\t\treturn;\n\t}\n\n\tif (condition.type === \"comparison\") {\n\t\tvalidateSourceReference(condition.left, condition.conditionId, errors);\n\t\tvalidateComparison(condition.operator, condition.value, condition.conditionId, errors);\n\t\treturn;\n\t}\n\n\tif (condition.type === \"all\" || condition.type === \"any\") {\n\t\tif (!Array.isArray(condition.conditions) || condition.conditions.length === 0) {\n\t\t\terrors.push(`condition ${condition.conditionId} must contain child conditions`);\n\t\t\treturn;\n\t\t}\n\n\t\tif (condition.conditions.length > DATA_POLICY_MAX_CONDITIONS_PER_NODE) {\n\t\t\terrors.push(\n\t\t\t\t`condition ${condition.conditionId} must contain at most ${DATA_POLICY_MAX_CONDITIONS_PER_NODE} child conditions`,\n\t\t\t);\n\t\t}\n\n\t\tfor (const child of condition.conditions) {\n\t\t\tvalidateDataPolicyCondition(child, errors, depth + 1, count);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (condition.type === \"not\") {\n\t\tvalidateDataPolicyCondition(condition.condition, errors, depth + 1, count);\n\t\treturn;\n\t}\n\n\terrors.push(`condition ${condition.conditionId} has unsupported type`);\n}\n\nfunction validateOptionalPolicyResult(\n\tresult: PolicyEvaluationResult | undefined,\n\tfieldName: string,\n\terrors: string[],\n): void {\n\tif (result !== undefined && !POLICY_RESULTS.has(result)) {\n\t\terrors.push(`${fieldName} must be pass, warn, or block`);\n\t}\n}\n\nfunction validateSourceReference(\n\treference: DataPolicySourceReference,\n\tconditionId: string,\n\terrors: string[],\n): void {\n\tif (!reference || typeof reference !== \"object\") {\n\t\terrors.push(`condition ${conditionId} left must be a source reference`);\n\t\treturn;\n\t}\n\n\tif (reference.source !== \"parameters\" && reference.source !== \"context\") {\n\t\terrors.push(`condition ${conditionId} source must be parameters or context`);\n\t}\n\n\tvalidatePath(reference.path, `condition ${conditionId} left.path`, errors);\n\n\tif (reference.source === \"context\" && !DATA_POLICY_CONTEXT_PATHS.has(reference.path)) {\n\t\terrors.push(`condition ${conditionId} uses an unsupported context path`);\n\t}\n}\n\nfunction validateComparison(\n\toperator: DataPolicyComparisonOperator,\n\tvalue: DataPolicyLiteral | undefined,\n\tconditionId: string,\n\terrors: string[],\n): void {\n\tif (!DATA_POLICY_COMPARISON_OPERATORS.has(operator)) {\n\t\terrors.push(`condition ${conditionId} has unsupported operator`);\n\t\treturn;\n\t}\n\n\tif (operator === \"exists\") {\n\t\treturn;\n\t}\n\n\tif (!isDataPolicyLiteral(value)) {\n\t\terrors.push(`condition ${conditionId} comparison value must be a bounded literal`);\n\t\treturn;\n\t}\n\n\tif ([\"gt\", \"gte\", \"lt\", \"lte\"].includes(operator) && typeof value !== \"number\") {\n\t\terrors.push(`condition ${conditionId} numeric comparison requires a number value`);\n\t}\n}\n\nfunction validatePath(path: string, fieldName: string, errors: string[]): void {\n\tif (!isNonEmptyBoundedString(path)) {\n\t\terrors.push(`${fieldName} must be a non-empty bounded string`);\n\t\treturn;\n\t}\n\n\tconst segments = path.split(\".\");\n\tif (segments.length > DATA_POLICY_MAX_PATH_SEGMENTS) {\n\t\terrors.push(`${fieldName} must contain at most ${DATA_POLICY_MAX_PATH_SEGMENTS} segments`);\n\t\treturn;\n\t}\n\n\tfor (const segment of segments) {\n\t\tif (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(segment)) {\n\t\t\terrors.push(`${fieldName} contains an invalid path segment`);\n\t\t\treturn;\n\t\t}\n\n\t\tif ([\"__proto__\", \"constructor\", \"prototype\"].includes(segment)) {\n\t\t\terrors.push(`${fieldName} contains a forbidden path segment`);\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nfunction isDataPolicyLiteral(value: unknown): value is DataPolicyLiteral {\n\tif (value === null || typeof value === \"number\" || typeof value === \"boolean\") {\n\t\treturn true;\n\t}\n\n\treturn typeof value === \"string\" && value.length <= DATA_POLICY_MAX_STRING_LENGTH;\n}\n\nfunction isNonEmptyBoundedString(value: unknown): value is string {\n\treturn typeof value === \"string\" && value.length > 0 && value.length <= DATA_POLICY_MAX_STRING_LENGTH;\n}\n\nfunction evaluateDataPolicyCondition(\n\tcondition: DataPolicyCondition,\n\tctx: PolicyContext,\n): { result: DataPolicyConditionResult; evidence: DataPolicyConditionResult[] } {\n\tif (condition.type === \"always\") {\n\t\tconst result = {\n\t\t\tconditionId: condition.conditionId,\n\t\t\tpassed: condition.result === \"pass\",\n\t\t\tresult: condition.result,\n\t\t\treason: condition.reason,\n\t\t};\n\t\treturn { result, evidence: [result] };\n\t}\n\n\tif (condition.type === \"all\" || condition.type === \"any\") {\n\t\tconst childEvaluations = condition.conditions.map((child) => evaluateDataPolicyCondition(child, ctx));\n\t\tconst passed =\n\t\t\tcondition.type === \"all\"\n\t\t\t\t? childEvaluations.every((evaluation) => evaluation.result.passed)\n\t\t\t\t: childEvaluations.some((evaluation) => evaluation.result.passed);\n\t\tconst result = {\n\t\t\tconditionId: condition.conditionId,\n\t\t\tpassed,\n\t\t\tresult: passed ? (condition.onPass ?? \"pass\") : (condition.onFail ?? \"block\"),\n\t\t\treason: passed ? undefined : condition.reason,\n\t\t};\n\n\t\treturn {\n\t\t\tresult,\n\t\t\tevidence: [result, ...childEvaluations.flatMap((evaluation) => evaluation.evidence)],\n\t\t};\n\t}\n\n\tif (condition.type === \"not\") {\n\t\tconst childEvaluation = evaluateDataPolicyCondition(condition.condition, ctx);\n\t\tconst passed = !childEvaluation.result.passed;\n\t\tconst result = {\n\t\t\tconditionId: condition.conditionId,\n\t\t\tpassed,\n\t\t\tresult: passed ? (condition.onPass ?? \"pass\") : (condition.onFail ?? \"block\"),\n\t\t\treason: passed ? undefined : condition.reason,\n\t\t};\n\n\t\treturn { result, evidence: [result, ...childEvaluation.evidence] };\n\t}\n\n\tif (condition.type !== \"parameter\" && condition.type !== \"comparison\") {\n\t\tconst result: DataPolicyConditionResult = {\n\t\t\tconditionId: condition.conditionId,\n\t\t\tpassed: false,\n\t\t\tresult: \"block\",\n\t\t\treason: \"Unsupported data policy condition type\",\n\t\t};\n\t\treturn { result, evidence: [result] };\n\t}\n\n\tconst value =\n\t\tcondition.type === \"parameter\"\n\t\t\t? readPath(ctx.parameters, condition.path)\n\t\t\t: readDataPolicySource(ctx, condition.left);\n\tconst operator = condition.operator;\n\tconst expected = condition.value;\n\tconst passed = evaluateOperator(value, operator, expected);\n\tconst result = {\n\t\tconditionId: condition.conditionId,\n\t\tpassed,\n\t\tresult: passed ? (condition.onPass ?? \"pass\") : (condition.onFail ?? \"block\"),\n\t\treason: passed ? undefined : condition.reason,\n\t};\n\treturn { result, evidence: [result] };\n}\n\nfunction evaluateOperator(\n\tactual: unknown,\n\toperator: DataPolicyComparisonOperator,\n\texpected: unknown,\n): boolean {\n\tswitch (operator) {\n\t\tcase \"exists\":\n\t\t\treturn actual !== undefined && actual !== null && actual !== \"\";\n\t\tcase \"equals\":\n\t\t\treturn actual === expected;\n\t\tcase \"notEquals\":\n\t\t\treturn actual !== expected;\n\t\tcase \"gt\":\n\t\t\treturn typeof actual === \"number\" && typeof expected === \"number\" && actual > expected;\n\t\tcase \"gte\":\n\t\t\treturn typeof actual === \"number\" && typeof expected === \"number\" && actual >= expected;\n\t\tcase \"lt\":\n\t\t\treturn typeof actual === \"number\" && typeof expected === \"number\" && actual < expected;\n\t\tcase \"lte\":\n\t\t\treturn typeof actual === \"number\" && typeof expected === \"number\" && actual <= expected;\n\t}\n}\n\nfunction readDataPolicySource(ctx: PolicyContext, reference: DataPolicySourceReference): unknown {\n\tif (reference.source === \"parameters\") {\n\t\treturn readPath(ctx.parameters, reference.path);\n\t}\n\n\treturn readPath(\n\t\t{\n\t\t\ttenantId: ctx.tenantId,\n\t\t\tspaceId: ctx.spaceId,\n\t\t\tactionInvocationId: ctx.actionInvocationId,\n\t\t\tactionId: ctx.actionId,\n\t\t\tmode: ctx.mode,\n\t\t},\n\t\treference.path,\n\t);\n}\n\nfunction readPath(source: unknown, path: string): unknown {\n\tif (!source || typeof source !== \"object\") {\n\t\treturn undefined;\n\t}\n\n\treturn path.split(\".\").reduce<unknown>((current, segment) => {\n\t\tif (!current || typeof current !== \"object\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn (current as Record<string, unknown>)[segment];\n\t}, source);\n}\n\nfunction normalizeOutcome(\n\tpolicy: RuntimePolicyDefinition,\n\toutcome: PolicyOutcome,\n\tdispatchEvidence: PolicyDispatchEvidence,\n): PolicyOutcome {\n\treturn {\n\t\t...outcome,\n\t\tpolicyId: policy.policyId,\n\t\tpolicyVersion: policy.policyVersion,\n\t\tpolicyKind: policy.kind,\n\t\tmetadata: {\n\t\t\t...(outcome.metadata ?? {}),\n\t\t\tcodePolicyId: dispatchEvidence.code?.policyId ?? outcome.policyId,\n\t\t\tcodePolicyVersion: dispatchEvidence.code?.version ?? outcome.policyVersion,\n\t\t},\n\t\tdispatchEvidence,\n\t};\n}\n\nfunction parsePolicyVersion(policyId: PolicyId): number {\n\tconst segments = policyId.split(\".v\");\n\treturn Number(segments[segments.length - 1] ?? 1);\n}\n\nexport function aggregatePolicyOutcomes(outcomes: PolicyOutcome[]): PolicyOutcome | undefined {\n\treturn (\n\t\toutcomes.find((outcome) => outcome.result === \"block\") ??\n\t\toutcomes.find((outcome) => outcome.result === \"warn\")\n\t);\n}\n\n","import type { StateClass, StateDefinition } from \"./index\";\n\nexport interface StateMachineDefinition {\n\tentityType: string;\n\tstates: Record<string, StateDefinition>;\n\ttransitions: Array<{\n\t\tfrom: string;\n\t\tto: string;\n\t\tcausedByAction: string;\n\t\tguard?: (ctx: TransitionContext) => boolean | Promise<boolean>;\n\t}>;\n}\n\nexport type StateMachineDatabaseClient = any;\n\nexport interface TransitionContext<TDb = StateMachineDatabaseClient> {\n\tentity: Record<string, unknown>;\n\tactionInvocationId: string;\n\tactorId: string;\n\tparameters: unknown;\n\tdb: TDb;\n}\n\nconst registry = new Map<string, StateMachineDefinition>();\n\n/**\n * Register a state-machine definition for an entity type.\n * Throws if a definition for this entity type is already registered.\n */\nexport function registerStateMachine(def: StateMachineDefinition): void {\n\tif (registry.has(def.entityType)) {\n\t\tthrow new Error(`State machine for entity type \"${def.entityType}\" is already registered.`);\n\t}\n\tregistry.set(def.entityType, def);\n}\n\n/**\n * Register a state-machine definition only if one for this entity type\n * is not already registered. Idempotent — safe to call multiple times.\n */\nexport function registerStateMachineIfMissing(def: StateMachineDefinition): void {\n\tif (!registry.has(def.entityType)) {\n\t\tregisterStateMachine(def);\n\t}\n}\n\n/**\n * Resolve a previously registered state-machine definition by entity type.\n */\nexport function resolveStateMachine(entityType: string): StateMachineDefinition | undefined {\n\treturn registry.get(entityType);\n}\n\n/**\n * Validate whether a transition is allowed for the given entity type,\n * from state, to state, and action ID.\n */\nexport function validateTransition(\n\tentityType: string,\n\tfrom: string,\n\tto: string,\n\tactionId: string,\n): { valid: boolean; error?: string } {\n\tconst sm = registry.get(entityType);\n\tif (!sm) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `No state machine registered for entity type \"${entityType}\".`,\n\t\t};\n\t}\n\n\tconst fromDef = sm.states[from];\n\tif (!fromDef) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `State \"${from}\" does not exist in state machine for entity type \"${entityType}\".`,\n\t\t};\n\t}\n\n\tconst toDef = sm.states[to];\n\tif (!toDef) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `State \"${to}\" does not exist in state machine for entity type \"${entityType}\".`,\n\t\t};\n\t}\n\n\tconst transitionExists = sm.transitions.some(\n\t\t(t) => t.from === from && t.to === to && t.causedByAction === actionId,\n\t);\n\tif (!transitionExists) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `Transition from \"${from}\" to \"${to}\" via action \"${actionId}\" is not defined for entity type \"${entityType}\".`,\n\t\t};\n\t}\n\n\treturn { valid: true };\n}\n\n/**\n * Get all allowed transitions from a given state for an entity type.\n */\nexport function getAllowedTransitions(\n\tentityType: string,\n\tfrom: string,\n): Array<{ to: string; causedByAction: string }> {\n\tconst sm = registry.get(entityType);\n\tif (!sm) {\n\t\treturn [];\n\t}\n\treturn sm.transitions\n\t\t.filter((t) => t.from === from)\n\t\t.map((t) => ({ to: t.to, causedByAction: t.causedByAction }));\n}\n\n/**\n * Get the StateClass of a given state for an entity type.\n */\nexport function getEntityStateClass(entityType: string, state: string): StateClass | undefined {\n\tconst sm = registry.get(entityType);\n\tif (!sm) {\n\t\treturn undefined;\n\t}\n\treturn sm.states[state]?.stateClass;\n}\n","import { registerActionIfMissing, type ActionDefinition } from \"../actions\";\nimport { registerDisplayRenderer, type DisplayRenderer } from \"../displays\";\nimport { isValidEventType, registerEventType, registerSubjectType } from \"../events\";\nimport { registerObjectType } from \"../objects\";\nimport { registerPolicyIfMissing, type PolicyEvaluator } from \"../policies\";\nimport { registerStateMachineIfMissing, type StateMachineDefinition } from \"../state-machines\";\n\nexport interface ModuleDependency {\n\tnamespace: string;\n\tversion?: string;\n\toptional?: boolean;\n}\n\nexport type ModuleDependencyInput = string | ModuleDependency;\n\nexport interface IdPrefixRegistration {\n\tprefix: string;\n\tname: string;\n\tmodule: string;\n}\n\nexport interface EventTypeRegistration {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n}\n\nexport type EventTypeRegistrationInput = string | EventTypeRegistration;\n\nexport interface ObjectTypeRegistration {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n\tisCoreModuleType?: boolean;\n}\n\nexport type ObjectTypeRegistrationInput = string | ObjectTypeRegistration;\n\nexport interface ModuleDisplayRendererRegistration {\n\teventType: string;\n\trenderer: (payload: unknown, ctx?: any) => unknown;\n}\n\nexport interface PolicyRegistration {\n\tid: string;\n\tversion?: string;\n\tdescription?: string;\n}\n\nexport interface StateMachineRegistration {\n\tentityType: string;\n\tstates: string[];\n}\n\nexport interface FabricModule<TDb = unknown> {\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tdependencies?: ModuleDependencyInput[];\n\tobjectTypes?: ObjectTypeRegistrationInput[];\n\tsubjectTypes?: string[];\n\tidPrefixes?: IdPrefixRegistration[];\n\teventTypes?: EventTypeRegistrationInput[];\n\tactions?: ActionDefinition<TDb>[];\n\tpolicies?: unknown[];\n\tstateMachines?: unknown[];\n\tdisplayRenderers?: ModuleDisplayRendererRegistration[];\n\tadapterDefinitions?: unknown[];\n\tpermissions?: unknown[];\n\troles?: unknown[];\n\tredactionRules?: unknown[];\n\tdataClassifications?: unknown[];\n\tretentionRules?: unknown[];\n\tevidenceRenderers?: unknown[];\n}\n\nexport interface ModuleRegistry<TDb = unknown> {\n\tmodules: ReadonlyMap<string, FabricModule<TDb>>;\n}\n\ninterface ModuleValidationContext {\n\tavailableNamespaces?: Set<string>;\n\tplannedEventTypes?: Set<string>;\n}\n\nconst registeredModuleNamespaces = new Set<string>();\n\nexport function getModuleDependencyNamespace(dependency: ModuleDependencyInput): string {\n\treturn typeof dependency === \"string\" ? dependency : dependency.namespace;\n}\n\nexport function getObjectTypeName(objectType: ObjectTypeRegistrationInput): string {\n\treturn typeof objectType === \"string\" ? objectType : objectType.type;\n}\n\nexport function getEventTypeName(eventType: EventTypeRegistrationInput): string {\n\treturn typeof eventType === \"string\" ? eventType : eventType.eventType;\n}\n\nexport function validateModuleNamespace(namespace: string): void {\n\tif (!namespace) {\n\t\tthrow new Error(\"Module namespace cannot be empty\");\n\t}\n\tif (!/^[a-z][a-z0-9-]*$/.test(namespace)) {\n\t\tthrow new Error(\n\t\t\t`Invalid module namespace: \"${namespace}\". Must be lowercase letters, numbers, and hyphens only.`,\n\t\t);\n\t}\n}\n\nexport function createModuleRegistry<TDb = unknown>(\n\tmodules: FabricModule<TDb>[] = [],\n): ModuleRegistry<TDb> {\n\tconst registered = new Map<string, FabricModule<TDb>>();\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (registered.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate FabricModule namespace \"${module.namespace}\".`);\n\t\t}\n\t\tregistered.set(module.namespace, module);\n\t}\n\treturn { modules: registered };\n}\n\nfunction validateIdentifierList(\n\tvalues: string[] | undefined,\n\tlabel: string,\n\tnamespace: string,\n): void {\n\tfor (const value of values ?? []) {\n\t\tif (!value) {\n\t\t\tthrow new Error(`Module \"${namespace}\" has an empty ${label} entry.`);\n\t\t}\n\t}\n}\n\nfunction validateManifest(module: FabricModule<any>, context: ModuleValidationContext = {}): void {\n\tvalidateModuleNamespace(module.namespace);\n\n\tconst dependencies = (module.dependencies ?? []).map(getModuleDependencyNamespace);\n\tconst objectTypes = (module.objectTypes ?? []).map(getObjectTypeName);\n\tconst eventTypes = (module.eventTypes ?? []).map(getEventTypeName);\n\n\tfor (const dependency of dependencies) {\n\t\tvalidateModuleNamespace(dependency);\n\t\tif (dependency === module.namespace) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" cannot depend on itself.`);\n\t\t}\n\t\tif (context.availableNamespaces && !context.availableNamespaces.has(dependency)) {\n\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t}\n\t}\n\n\tvalidateIdentifierList(objectTypes, \"objectTypes\", module.namespace);\n\tvalidateIdentifierList(module.subjectTypes, \"subjectTypes\", module.namespace);\n\tvalidateIdentifierList(eventTypes, \"eventTypes\", module.namespace);\n\n\tfor (const objectType of objectTypes) {\n\t\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(objectType)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid object type: \"${objectType}\". Object types must be PascalCase alphanumeric.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId)) {\n\t\t\tthrow new Error(`Invalid action ID: ${action.actionId}`);\n\t\t}\n\n\t\tif (action.namespace !== module.namespace) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" declares namespace \"${action.namespace}\" ` +\n\t\t\t\t\t`but is registered by module \"${module.namespace}\".`,\n\t\t\t);\n\t\t}\n\n\t\tif (!action.actionId.startsWith(`${module.namespace}.`)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" must start with module namespace \"${module.namespace}.\"`,\n\t\t\t);\n\t\t}\n\n\t\tif (action.mutatesDomain && action.emitsEvents.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Action \"${action.actionId}\" mutates domain but emits no events. ` +\n\t\t\t\t\t`Every mutating action must emit at least one AssetEvent.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tconst isPlannedEventType = context.plannedEventTypes?.has(descriptor.eventType) ?? false;\n\t\tconst isModuleEventType = eventTypes.includes(descriptor.eventType);\n\t\tif (!isValidEventType(descriptor.eventType) && !isModuleEventType && !isPlannedEventType) {\n\t\t\tthrow new Error(\n\t\t\t\t`Display renderer registered for unknown event type \"${descriptor.eventType}\". ` +\n\t\t\t\t\t`Register the event type before adding a display renderer.`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction sortModulesByDependency(\n\tmodules: FabricModule<any>[],\n\tregisteredNamespaces = registeredModuleNamespaces,\n): FabricModule<any>[] {\n\tconst modulesByNamespace = new Map<string, FabricModule<any>>();\n\n\tfor (const module of modules) {\n\t\tvalidateModuleNamespace(module.namespace);\n\t\tif (modulesByNamespace.has(module.namespace)) {\n\t\t\tthrow new Error(`Duplicate Fabric module namespace \"${module.namespace}\".`);\n\t\t}\n\t\tmodulesByNamespace.set(module.namespace, module);\n\t}\n\n\tconst sorted: FabricModule<any>[] = [];\n\tconst visiting = new Set<string>();\n\tconst visited = new Set<string>();\n\n\tfunction visit(module: FabricModule<any>, path: string[]): void {\n\t\tif (visited.has(module.namespace)) {\n\t\t\treturn;\n\t\t}\n\t\tif (visiting.has(module.namespace)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cyclic Fabric module dependency detected: ${[...path, module.namespace].join(\" -> \")}`,\n\t\t\t);\n\t\t}\n\n\t\tvisiting.add(module.namespace);\n\t\tfor (const dependency of (module.dependencies ?? []).map(getModuleDependencyNamespace)) {\n\t\t\tconst dependencyModule = modulesByNamespace.get(dependency);\n\t\t\tif (!dependencyModule) {\n\t\t\t\tif (registeredNamespaces.has(dependency)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow new Error(`Module \"${module.namespace}\" depends on missing module \"${dependency}\".`);\n\t\t\t}\n\t\t\tvisit(dependencyModule, [...path, module.namespace]);\n\t\t}\n\t\tvisiting.delete(module.namespace);\n\t\tvisited.add(module.namespace);\n\t\tsorted.push(module);\n\t}\n\n\tfor (const module of modules) {\n\t\tvisit(module, []);\n\t}\n\n\treturn sorted;\n}\n\nexport function registerFabricModule(module: FabricModule<any>): void {\n\tvalidateManifest(module, { availableNamespaces: registeredModuleNamespaces });\n\n\tfor (const objectType of module.objectTypes ?? []) {\n\t\tregisterObjectType(getObjectTypeName(objectType));\n\t}\n\n\tfor (const subjectType of module.subjectTypes ?? []) {\n\t\tregisterSubjectType(subjectType);\n\t}\n\n\tfor (const eventType of module.eventTypes ?? []) {\n\t\tregisterEventType(getEventTypeName(eventType));\n\t}\n\n\tfor (const policy of module.policies ?? []) {\n\t\tregisterPolicyIfMissing(policy as PolicyEvaluator);\n\t}\n\n\tfor (const machine of module.stateMachines ?? []) {\n\t\tregisterStateMachineIfMissing(machine as StateMachineDefinition);\n\t}\n\n\tfor (const action of module.actions ?? []) {\n\t\tregisterActionIfMissing(action);\n\t}\n\n\tfor (const descriptor of module.displayRenderers ?? []) {\n\t\tregisterDisplayRenderer(descriptor.eventType, descriptor.renderer as DisplayRenderer);\n\t}\n\n\tregisteredModuleNamespaces.add(module.namespace);\n}\n\nexport function registerFabricModules(modules: FabricModule<any>[]): FabricModule<any>[] {\n\tconst availableNamespaces = new Set([\n\t\t...registeredModuleNamespaces,\n\t\t...modules.map((module) => module.namespace),\n\t]);\n\tconst plannedEventTypes = new Set(\n\t\tmodules.flatMap((module) => (module.eventTypes ?? []).map(getEventTypeName)),\n\t);\n\n\tfor (const module of modules) {\n\t\tvalidateManifest(module, { availableNamespaces, plannedEventTypes });\n\t}\n\n\tconst sortedModules = sortModulesByDependency(modules);\n\tfor (const module of sortedModules) {\n\t\tregisterFabricModule(module);\n\t}\n\n\treturn sortedModules;\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var chunkQETQGAXJ_cjs = require('../chunk-QETQGAXJ.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "assertObjectType", {
8
+ enumerable: true,
9
+ get: function () { return chunkQETQGAXJ_cjs.assertObjectType; }
10
+ });
11
+ Object.defineProperty(exports, "getRegisteredObjectTypes", {
12
+ enumerable: true,
13
+ get: function () { return chunkQETQGAXJ_cjs.getRegisteredObjectTypes; }
14
+ });
15
+ Object.defineProperty(exports, "isValidObjectType", {
16
+ enumerable: true,
17
+ get: function () { return chunkQETQGAXJ_cjs.isValidObjectType; }
18
+ });
19
+ Object.defineProperty(exports, "registerObjectType", {
20
+ enumerable: true,
21
+ get: function () { return chunkQETQGAXJ_cjs.registerObjectType; }
22
+ });
23
+ //# sourceMappingURL=index.cjs.map
24
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,7 @@
1
+ type FabricObjectType = string;
2
+ declare function assertObjectType(type: string): asserts type is FabricObjectType;
3
+ declare function registerObjectType(type: string): void;
4
+ declare function isValidObjectType(type: string): boolean;
5
+ declare function getRegisteredObjectTypes(): string[];
6
+
7
+ export { type FabricObjectType, assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType };
@@ -1,30 +1,3 @@
1
- // objects/index.ts
2
- var objectTypeRegistry = /* @__PURE__ */ new Set([
3
- "AssetEvent",
4
- "ActionInvocation",
5
- "PolicyEvaluation",
6
- "ApprovalRequest",
7
- "ConsentRecord",
8
- "AgentRun"
9
- ]);
10
- function assertObjectType(type) {
11
- if (!/^[A-Z][a-zA-Z0-9]*$/.test(type)) {
12
- throw new Error(
13
- `Invalid object type: "${type}". Object types must be PascalCase alphanumeric.`
14
- );
15
- }
16
- }
17
- function registerObjectType(type) {
18
- assertObjectType(type);
19
- objectTypeRegistry.add(type);
20
- }
21
- function isValidObjectType(type) {
22
- return objectTypeRegistry.has(type);
23
- }
24
- function getRegisteredObjectTypes() {
25
- return Array.from(objectTypeRegistry);
26
- }
27
-
28
- export { assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType };
1
+ export { assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType } from '../chunk-I35B576X.js';
29
2
  //# sourceMappingURL=index.js.map
30
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../objects/index.ts"],"names":[],"mappings":";AAAA,IAAM,kBAAA,uBAAyB,GAAA,CAAY;AAAA,EAC1C,YAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACD,CAAC,CAAA;AAIM,SAAS,iBAAiB,IAAA,EAAgD;AAChF,EAAA,IAAI,CAAC,qBAAA,CAAsB,IAAA,CAAK,IAAI,CAAA,EAAG;AACtC,IAAA,MAAM,IAAI,KAAA;AAAA,MACT,yBAAyB,IAAI,CAAA,gDAAA;AAAA,KAC9B;AAAA,EACD;AACD;AAEO,SAAS,mBAAmB,IAAA,EAAoB;AACtD,EAAA,gBAAA,CAAiB,IAAI,CAAA;AACrB,EAAA,kBAAA,CAAmB,IAAI,IAAI,CAAA;AAC5B;AAEO,SAAS,kBAAkB,IAAA,EAAuB;AACxD,EAAA,OAAO,kBAAA,CAAmB,IAAI,IAAI,CAAA;AACnC;AAEO,SAAS,wBAAA,GAAqC;AACpD,EAAA,OAAO,KAAA,CAAM,KAAK,kBAAkB,CAAA;AACrC","file":"index.js","sourcesContent":["const objectTypeRegistry = new Set<string>([\n\t\"AssetEvent\",\n\t\"ActionInvocation\",\n\t\"PolicyEvaluation\",\n\t\"ApprovalRequest\",\n\t\"ConsentRecord\",\n\t\"AgentRun\",\n]);\n\nexport type FabricObjectType = string;\n\nexport function assertObjectType(type: string): asserts type is FabricObjectType {\n\tif (!/^[A-Z][a-zA-Z0-9]*$/.test(type)) {\n\t\tthrow new Error(\n\t\t\t`Invalid object type: \"${type}\". Object types must be PascalCase alphanumeric.`,\n\t\t);\n\t}\n}\n\nexport function registerObjectType(type: string): void {\n\tassertObjectType(type);\n\tobjectTypeRegistry.add(type);\n}\n\nexport function isValidObjectType(type: string): boolean {\n\treturn objectTypeRegistry.has(type);\n}\n\nexport function getRegisteredObjectTypes(): string[] {\n\treturn Array.from(objectTypeRegistry);\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}