@fabricorg/platform 0.9.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @fabricorg/platform
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fdd3e69: Add provider-neutral external mutation footprints, delegated principals, enforceable obligations,
8
+ execution attestations, and reconciliation evidence with durable host-store support.
9
+ - 714ad06: Add enforceable Fabric-family compatibility controls and durable runtime contract-version evidence.
10
+ - 43c5770: Initial pre-1.0 Fabric platform package with action, adapter, event, ID, and module contracts.
11
+ - 986636b: New public subpath `@fabricorg/platform/manifest`: a stable, JSON-serializable, versioned manifest of a `FabricModule`'s ontology (object types, subject types, id prefixes, event types, actions, policies, state machines) for downstream tooling such as semantics exporters, docs generators, and tool generators.
12
+
13
+ - `MODULE_MANIFEST_VERSION` (`1`), `ModuleManifest`, and `ModuleManifestBundle` contract types.
14
+ - `exportModuleManifest(module)` — pure, registry-free export of a single module; no registration required.
15
+ - `exportModuleManifestBundle(modules)` — versioned bundle preserving input order.
16
+ - `JsonSchemaExportableValidator` + `isJsonSchemaExportableValidator` — actions whose schema exposes `toJSONSchema()` (e.g. Zod 4) emit `parameterSchema` / `parameterSchemaFormat: "json-schema"`.
17
+ - Function fields are never serialized (`handler`, `evaluate`, `guard` → `hasGuard`, dynamic `targetState`, adapter `getInput`); the manifest contains definitions only — never raw parameter values, secrets, or runtime data.
18
+ - Deterministic: declaration order is preserved everywhere, so the same module object always produces byte-identical JSON.
19
+
20
+ All changes are additive; no breaking API changes.
21
+
22
+ ### Patch Changes
23
+
24
+ - bc7d3ab: BYO policy engine affordance + preview-safe enforcement bug fix.
25
+
26
+ - `PolicyContext.services?: FabricRuntimeServices` (mirrors `ActionContext.services`).
27
+ - `PolicyDispatchEvidence.engine?: { name; version?; metadata? }` for external-engine provenance (OPA, Cedar, Cerbos, …). `normalizeOutcome` preserves evaluator-supplied `engine` blocks.
28
+ - `PolicyDispatchEvidence.code.skipped` / `code.skipReason` for first-class preview-skip evidence.
29
+ - `evaluateCodePolicy` now honors `PolicyEvaluator.previewSafe`: in `preview` mode, non-preview-safe evaluators are skipped and yield `result: "warn"` with structured evidence. Data policies still evaluate; hybrid fallback inherits the skip.
30
+ - New docs: `governance/byo-engine` (worked OPA example, layering, failure modes, preview semantics).
31
+
32
+ All changes are additive; no breaking API changes.
33
+
3
34
  ## 0.9.0
4
35
 
5
36
  - Add versioned runtime-governance evidence shared by TypeScript and .NET hosts.
@@ -46,7 +77,7 @@
46
77
 
47
78
  - **BYO policy engine affordance.** Made it possible for code policy evaluators to delegate to external policy engines (OPA, Cedar, Cerbos, …) while keeping Fabric's `policyId.vN` and `policyVersion` canonical for audit. Three additive, vendor-neutral changes to the policy contract:
48
79
  - `PolicyContext.services?: FabricRuntimeServices` — mirrors `ActionContext.services`. Lets the runtime host inject HTTP clients, external policy engine clients, feature flags, etc. into policy evaluation without module-level globals.
49
- - `PolicyDispatchEvidence.engine?: { name; version?; metadata? }` — open-ended engine provenance slot. Adapters populate it (e.g. OPA: `decisionPath`, `bundleRevision`, `decisionId`, `inputHash`). Platform `policyId` / `policyVersion` remain load-bearing; `engine` answers "*which artifact* produced the decision?". `normalizeOutcome` merges evaluator-supplied `engine` provenance into the platform-controlled dispatch envelope so adapters can attach it without being overwritten.
80
+ - `PolicyDispatchEvidence.engine?: { name; version?; metadata? }` — open-ended engine provenance slot. Adapters populate it (e.g. OPA: `decisionPath`, `bundleRevision`, `decisionId`, `inputHash`). Platform `policyId` / `policyVersion` remain load-bearing; `engine` answers "_which artifact_ produced the decision?". `normalizeOutcome` merges evaluator-supplied `engine` provenance into the platform-controlled dispatch envelope so adapters can attach it without being overwritten.
50
81
  - `PolicyDispatchEvidence.code.skipped` / `code.skipReason` — first-class evidence shape for preview skips.
51
82
  - **Preview-safe enforcement (bug fix).** `PolicyEvaluator.previewSafe` was previously documentation-only; `evaluateCodePolicy` ran every evaluator regardless of `ctx.mode`. Now: when `ctx.mode === "preview"` and an evaluator is not declared `previewSafe: true`, the platform skips evaluation and returns `result: "warn"` with structured skip evidence (`code.skipped`, `code.skipReason`, `metadata.previewSkipped`). `warn` is the honest preview outcome: not proven pass, not proven block. Data policies are deterministic and continue to evaluate in preview unchanged. Hybrid policies inherit the skip behavior on their fallback code evaluator automatically.
52
83
  - **Docs:** new `governance/byo-engine` page — worked OPA example covering the four-piece pattern (vertical policy manifest, fact builder owned by TS, Rego house style returning structured decision shape, evaluator factory), failure-mode policy table, preview semantics, and the platform/adapter/vertical layering. `governance/policy-model` updated to reflect `services` and the `engine` evidence block.
@@ -68,7 +99,7 @@
68
99
  - New optional method on `SagaContext`: `awaitSignal?<T>(signalName: string, timeoutMs: number) => Promise<T | null>`.
69
100
  - Returns the payload of the first signal received, or `null` if the timeout fires.
70
101
  - Optional: runtimes that cannot support push-based signaling (in-memory test harnesses, simple polling drivers) may omit it. Sagas should treat absence as a fallback condition and use `sleep` + `query` polling instead.
71
- - Signal *senders* remain runtime-specific (e.g. Temporal `WorkflowClient.signal()` from an action handler activity, or an HTTP-based coordination service if an app exposes one). The platform does not prescribe the sender API to keep the runtime layer agnostic.
102
+ - Signal _senders_ remain runtime-specific (e.g. Temporal `WorkflowClient.signal()` from an action handler activity, or an HTTP-based coordination service if an app exposes one). The platform does not prescribe the sender API to keep the runtime layer agnostic.
72
103
  - **Use case:** any saga that previously polled for an external event (a user response, an upload landing, an upstream system completing) can now exit the polling loop and resume immediately when the event fires.
73
104
  - **Tests:** 77 → 81 (added 4 tests covering the optional shape, push-vs-poll fallback pattern, and runtime mock implementations).
74
105
  - **No breaking changes.** `SagaContext.awaitSignal` is optional; existing sagas and runtimes continue to work unchanged.
package/README.md CHANGED
@@ -49,6 +49,7 @@ That's what this package gives you. Nothing more.
49
49
  | `@fabricorg/platform/projections` | Replay/snapshot framework |
50
50
  | `@fabricorg/platform/adapters` | `AdapterRegistry`, retry + circuit-breaker |
51
51
  | `@fabricorg/platform/modules` | `FabricModule<TDb>`, `registerFabricModules` |
52
+ | `@fabricorg/platform/manifest` | `exportModuleManifest`, `exportModuleManifestBundle`, `ModuleManifest` |
52
53
  | `@fabricorg/platform/ids` | `createFabricId`, `FABRIC_ID_PREFIXES` |
53
54
  | `@fabricorg/platform/displays` | `DisplayRendererRegistration` |
54
55
  | `@fabricorg/platform/privacy` | Redaction + data classification |
@@ -81,6 +82,19 @@ registerFabricModules([myModule]);
81
82
 
82
83
  The platform never auto-loads a module. The host app composes them explicitly — no implicit defaults, no globals, no surprises.
83
84
 
85
+ ## Exporting a module manifest
86
+
87
+ Downstream tooling — semantics exporters, docs generators, tool generators — often needs a module's ontology as data rather than live code. `@fabricorg/platform/manifest` exports a stable, JSON-serializable, versioned description of any `FabricModule`:
88
+
89
+ ```ts
90
+ import { exportModuleManifest } from "@fabricorg/platform/manifest";
91
+
92
+ const manifest = exportModuleManifest(myModule);
93
+ const json = JSON.stringify(manifest, null, 2);
94
+ ```
95
+
96
+ `exportModuleManifest` is a pure function of the module object: it does not touch the registries and the module does not need to be registered first. Declaration order is preserved everywhere, so the same module always produces byte-identical JSON. Function fields (`handler`, policy `evaluate`, transition `guard`, dynamic `targetState`, adapter `getInput`) are never serialized — the manifest contains definitions only, never raw parameter values, secrets, or runtime data. Actions whose schema validator exposes `toJSONSchema()` (for example Zod 4) include a `parameterSchema` in JSON Schema format. Use `exportModuleManifestBundle(modules)` to export several modules at once.
97
+
84
98
  ## The action lifecycle
85
99
 
86
100
  Every `invokeAction(id, params)` call goes through:
@@ -0,0 +1,165 @@
1
+ 'use strict';
2
+
3
+ var chunkSSYKDXR4_cjs = require('./chunk-SSYKDXR4.cjs');
4
+
5
+ // manifest/index.ts
6
+ var MODULE_MANIFEST_VERSION = 1;
7
+ function isJsonSchemaExportableValidator(schema) {
8
+ return typeof schema.toJSONSchema === "function";
9
+ }
10
+ function isRecord(value) {
11
+ return value !== null && typeof value === "object" && !Array.isArray(value);
12
+ }
13
+ function exportDependency(dependency) {
14
+ const namespace = chunkSSYKDXR4_cjs.getModuleDependencyNamespace(dependency);
15
+ if (typeof dependency === "string") {
16
+ return { namespace };
17
+ }
18
+ const normalized = { namespace };
19
+ if (dependency.version !== void 0) normalized.version = dependency.version;
20
+ if (dependency.optional !== void 0) normalized.optional = dependency.optional;
21
+ return normalized;
22
+ }
23
+ function exportObjectType(objectType) {
24
+ if (typeof objectType === "string") {
25
+ return { type: objectType };
26
+ }
27
+ const normalized = { type: chunkSSYKDXR4_cjs.getObjectTypeName(objectType) };
28
+ if (objectType.displayName !== void 0) normalized.displayName = objectType.displayName;
29
+ if (objectType.idPrefix !== void 0) normalized.idPrefix = objectType.idPrefix;
30
+ return normalized;
31
+ }
32
+ function exportEventType(eventType) {
33
+ if (typeof eventType === "string") {
34
+ return { eventType, schemaVersion: 1 };
35
+ }
36
+ const normalized = {
37
+ eventType: chunkSSYKDXR4_cjs.getEventTypeName(eventType),
38
+ schemaVersion: eventType.schemaVersion
39
+ };
40
+ if (eventType.description !== void 0) normalized.description = eventType.description;
41
+ return normalized;
42
+ }
43
+ function exportAction(action) {
44
+ const manifest = {
45
+ actionId: action.actionId,
46
+ version: action.version,
47
+ kind: action.kind ?? "atomic",
48
+ idempotent: action.idempotent,
49
+ mutatesDomain: action.mutatesDomain,
50
+ emitsEvents: [...action.emitsEvents]
51
+ };
52
+ if (action.policies !== void 0) manifest.policies = [...action.policies];
53
+ if (action.requiredRoles !== void 0) manifest.requiredRoles = [...action.requiredRoles];
54
+ if (action.requiredPermissions !== void 0) {
55
+ manifest.requiredPermissions = [...action.requiredPermissions];
56
+ }
57
+ if (action.eventPhase !== void 0) manifest.eventPhase = action.eventPhase;
58
+ if (isJsonSchemaExportableValidator(action.schema)) {
59
+ manifest.parameterSchema = action.schema.toJSONSchema();
60
+ manifest.parameterSchemaFormat = "json-schema";
61
+ }
62
+ if (action.stateMachine !== void 0) {
63
+ const binding = {
64
+ entityType: action.stateMachine.entityType
65
+ };
66
+ if (typeof action.stateMachine.targetState === "string") {
67
+ binding.targetState = action.stateMachine.targetState;
68
+ }
69
+ manifest.stateMachine = binding;
70
+ }
71
+ if (action.adapterSteps !== void 0) {
72
+ manifest.adapterSteps = action.adapterSteps.map((step) => {
73
+ const exported = {
74
+ adapterType: step.adapterType,
75
+ operation: step.operation
76
+ };
77
+ if (step.retryPolicy !== void 0) exported.retryPolicy = { ...step.retryPolicy };
78
+ return exported;
79
+ });
80
+ }
81
+ return manifest;
82
+ }
83
+ function exportPolicy(policy) {
84
+ if (!isRecord(policy) || typeof policy.policyId !== "string") {
85
+ return void 0;
86
+ }
87
+ if (typeof policy.evaluate === "function") {
88
+ const exported = {
89
+ type: "code",
90
+ policyId: policy.policyId,
91
+ version: typeof policy.version === "number" ? policy.version : 1
92
+ };
93
+ if (typeof policy.previewSafe === "boolean") exported.previewSafe = policy.previewSafe;
94
+ return exported;
95
+ }
96
+ if (typeof policy.kind === "string" && typeof policy.policyVersion === "number") {
97
+ const exported = {
98
+ type: "data",
99
+ policyId: policy.policyId,
100
+ policyVersion: policy.policyVersion,
101
+ kind: policy.kind
102
+ };
103
+ if (isRecord(policy.dataDefinition)) {
104
+ exported.dataDefinition = policy.dataDefinition;
105
+ }
106
+ if (typeof policy.codeEvaluatorPolicyId === "string") {
107
+ exported.codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId;
108
+ }
109
+ if (isRecord(policy.fallback)) {
110
+ exported.fallback = policy.fallback;
111
+ }
112
+ return exported;
113
+ }
114
+ return void 0;
115
+ }
116
+ function exportStateMachine(machine) {
117
+ if (!isRecord(machine) || typeof machine.entityType !== "string" || !isRecord(machine.states) || !Array.isArray(machine.transitions)) {
118
+ return void 0;
119
+ }
120
+ const definition = machine;
121
+ return {
122
+ entityType: definition.entityType,
123
+ states: Object.values(definition.states),
124
+ transitions: definition.transitions.map((transition) => ({
125
+ from: transition.from,
126
+ to: transition.to,
127
+ causedByAction: transition.causedByAction,
128
+ hasGuard: typeof transition.guard === "function"
129
+ }))
130
+ };
131
+ }
132
+ function exportModuleManifest(module) {
133
+ const manifest = {
134
+ manifestVersion: MODULE_MANIFEST_VERSION,
135
+ namespace: module.namespace,
136
+ dependencies: (module.dependencies ?? []).map(exportDependency),
137
+ objectTypes: (module.objectTypes ?? []).map(exportObjectType),
138
+ subjectTypes: [...module.subjectTypes ?? []],
139
+ idPrefixes: (module.idPrefixes ?? []).map((registration) => ({
140
+ prefix: registration.prefix,
141
+ name: registration.name
142
+ })),
143
+ eventTypes: (module.eventTypes ?? []).map(exportEventType),
144
+ actions: (module.actions ?? []).map(exportAction),
145
+ policies: (module.policies ?? []).map(exportPolicy).filter((policy) => policy !== void 0),
146
+ stateMachines: (module.stateMachines ?? []).map(exportStateMachine).filter((machine) => machine !== void 0)
147
+ };
148
+ if (module.version !== void 0) manifest.version = module.version;
149
+ if (module.displayName !== void 0) manifest.displayName = module.displayName;
150
+ if (module.description !== void 0) manifest.description = module.description;
151
+ return manifest;
152
+ }
153
+ function exportModuleManifestBundle(modules) {
154
+ return {
155
+ manifestVersion: MODULE_MANIFEST_VERSION,
156
+ modules: modules.map(exportModuleManifest)
157
+ };
158
+ }
159
+
160
+ exports.MODULE_MANIFEST_VERSION = MODULE_MANIFEST_VERSION;
161
+ exports.exportModuleManifest = exportModuleManifest;
162
+ exports.exportModuleManifestBundle = exportModuleManifestBundle;
163
+ exports.isJsonSchemaExportableValidator = isJsonSchemaExportableValidator;
164
+ //# sourceMappingURL=chunk-54EQTOH6.cjs.map
165
+ //# sourceMappingURL=chunk-54EQTOH6.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../manifest/index.ts"],"names":["getModuleDependencyNamespace","getObjectTypeName","getEventTypeName"],"mappings":";;;;;AAwBO,IAAM,uBAAA,GAA0B;AA+HhC,SAAS,gCACf,MAAA,EAC0C;AAC1C,EAAA,OACC,OAAQ,OAAkD,YAAA,KAAiB,UAAA;AAE7E;AAEA,SAAS,SAAS,KAA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,cAAc,MAAA,CAAO,WAAA;AACpE,EAAA,IAAI,MAAA,CAAO,WAAA,KAAgB,MAAA,EAAW,QAAA,CAAS,cAAc,MAAA,CAAO,WAAA;AAEpE,EAAA,OAAO,QAAA;AACR;AAMO,SAAS,2BACf,OAAA,EACuB;AACvB,EAAA,OAAO;AAAA,IACN,eAAA,EAAiB,uBAAA;AAAA,IACjB,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,oBAAoB;AAAA,GAC1C;AACD","file":"chunk-54EQTOH6.cjs","sourcesContent":["import type {\n\tActionDefinition,\n\tAdapterStepRetryPolicy,\n\tSchemaValidator,\n} from \"../actions\";\nimport {\n\tgetEventTypeName,\n\tgetModuleDependencyNamespace,\n\tgetObjectTypeName,\n\ttype FabricModule,\n\ttype ModuleDependency,\n\ttype ModuleDependencyInput,\n} from \"../modules\";\nimport type {\n\tDataPolicyDefinition,\n\tPolicyFallbackDefinition,\n\tPolicyKind,\n} from \"../policies\";\nimport type { StateDefinition, StateMachineDefinition } from \"../state-machines\";\n\n/**\n * Version of the module manifest contract. Bump when the serialized shape\n * changes in a way consumers must detect.\n */\nexport const MODULE_MANIFEST_VERSION = 1 as const;\n\nexport interface ModuleManifestObjectType {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n}\n\nexport interface ModuleManifestIdPrefix {\n\tprefix: string;\n\tname: string;\n}\n\nexport interface ModuleManifestEventType {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n}\n\nexport interface ModuleManifestActionStateMachine {\n\tentityType: string;\n\t/** Present only when the binding declares a static target state. */\n\ttargetState?: string;\n}\n\nexport interface ModuleManifestAdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n}\n\nexport interface ModuleManifestAction {\n\tactionId: string;\n\tversion: number;\n\tkind: \"atomic\" | \"saga\";\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\temitsEvents: string[];\n\tpolicies?: string[];\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\t/**\n\t * JSON Schema for the action parameters, present only when the action's\n\t * `schema` validator implements {@link JsonSchemaExportableValidator}.\n\t */\n\tparameterSchema?: unknown;\n\tparameterSchemaFormat?: \"json-schema\";\n\tstateMachine?: ModuleManifestActionStateMachine;\n\tadapterSteps?: ModuleManifestAdapterStep[];\n}\n\nexport interface ModuleManifestCodePolicy {\n\ttype: \"code\";\n\tpolicyId: string;\n\tversion: number;\n\tpreviewSafe?: boolean;\n}\n\nexport interface ModuleManifestDataPolicy {\n\ttype: \"data\";\n\tpolicyId: string;\n\tpolicyVersion: number;\n\tkind: PolicyKind;\n\tdataDefinition?: DataPolicyDefinition;\n\tcodeEvaluatorPolicyId?: string;\n\tfallback?: PolicyFallbackDefinition;\n}\n\nexport type ModuleManifestPolicy = ModuleManifestCodePolicy | ModuleManifestDataPolicy;\n\nexport interface ModuleManifestStateMachineTransition {\n\tfrom: string;\n\tto: string;\n\tcausedByAction: string;\n\t/** `true` when the transition declares a guard function. The guard itself is never serialized. */\n\thasGuard: boolean;\n}\n\nexport interface ModuleManifestStateMachine {\n\tentityType: string;\n\t/** States in declaration order (`Object.values` order of the definition record). */\n\tstates: StateDefinition[];\n\ttransitions: ModuleManifestStateMachineTransition[];\n}\n\n/**\n * Stable, JSON-serializable description of a {@link FabricModule}'s ontology:\n * object types, subject types, id prefixes, event types, actions, policies,\n * and state machines. Intended for downstream tooling (semantics exporters,\n * docs generators, tool generators) that cannot consume live module code.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields (`handler`, `evaluate`, `guard`,\n * dynamic `targetState`, adapter `getInput`) are never serialized.\n */\nexport interface ModuleManifest {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tdependencies: ModuleDependency[];\n\tobjectTypes: ModuleManifestObjectType[];\n\tsubjectTypes: string[];\n\tidPrefixes: ModuleManifestIdPrefix[];\n\teventTypes: ModuleManifestEventType[];\n\tactions: ModuleManifestAction[];\n\tpolicies: ModuleManifestPolicy[];\n\tstateMachines: ModuleManifestStateMachine[];\n}\n\nexport interface ModuleManifestBundle {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\t/** Manifests in the input module order. */\n\tmodules: ModuleManifest[];\n}\n\n/**\n * A {@link SchemaValidator} that can also export its parameter schema as JSON\n * Schema (for example a Zod 4 schema via `z.toJSONSchema`). Keeps the platform\n * zero-dependency while letting schema-bearing actions flow into manifests.\n */\nexport interface JsonSchemaExportableValidator extends SchemaValidator {\n\ttoJSONSchema(): Record<string, unknown>;\n}\n\nexport function isJsonSchemaExportableValidator(\n\tschema: SchemaValidator,\n): schema is JsonSchemaExportableValidator {\n\treturn (\n\t\ttypeof (schema as Partial<JsonSchemaExportableValidator>).toJSONSchema === \"function\"\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction exportDependency(dependency: ModuleDependencyInput): ModuleDependency {\n\tconst namespace = getModuleDependencyNamespace(dependency);\n\tif (typeof dependency === \"string\") {\n\t\treturn { namespace };\n\t}\n\tconst normalized: ModuleDependency = { namespace };\n\tif (dependency.version !== undefined) normalized.version = dependency.version;\n\tif (dependency.optional !== undefined) normalized.optional = dependency.optional;\n\treturn normalized;\n}\n\nfunction exportObjectType(\n\tobjectType: NonNullable<FabricModule[\"objectTypes\"]>[number],\n): ModuleManifestObjectType {\n\tif (typeof objectType === \"string\") {\n\t\treturn { type: objectType };\n\t}\n\tconst normalized: ModuleManifestObjectType = { type: getObjectTypeName(objectType) };\n\tif (objectType.displayName !== undefined) normalized.displayName = objectType.displayName;\n\tif (objectType.idPrefix !== undefined) normalized.idPrefix = objectType.idPrefix;\n\treturn normalized;\n}\n\nfunction exportEventType(\n\teventType: NonNullable<FabricModule[\"eventTypes\"]>[number],\n): ModuleManifestEventType {\n\tif (typeof eventType === \"string\") {\n\t\t// String registrations carry no explicit schema version; the events\n\t\t// registry treats the bare name as the initial version of the type.\n\t\treturn { eventType, schemaVersion: 1 };\n\t}\n\tconst normalized: ModuleManifestEventType = {\n\t\teventType: getEventTypeName(eventType),\n\t\tschemaVersion: eventType.schemaVersion,\n\t};\n\tif (eventType.description !== undefined) normalized.description = eventType.description;\n\treturn normalized;\n}\n\nfunction exportAction(action: ActionDefinition): ModuleManifestAction {\n\tconst manifest: ModuleManifestAction = {\n\t\tactionId: action.actionId,\n\t\tversion: action.version,\n\t\tkind: action.kind ?? \"atomic\",\n\t\tidempotent: action.idempotent,\n\t\tmutatesDomain: action.mutatesDomain,\n\t\temitsEvents: [...action.emitsEvents],\n\t};\n\n\tif (action.policies !== undefined) manifest.policies = [...action.policies];\n\tif (action.requiredRoles !== undefined) manifest.requiredRoles = [...action.requiredRoles];\n\tif (action.requiredPermissions !== undefined) {\n\t\tmanifest.requiredPermissions = [...action.requiredPermissions];\n\t}\n\tif (action.eventPhase !== undefined) manifest.eventPhase = action.eventPhase;\n\n\tif (isJsonSchemaExportableValidator(action.schema)) {\n\t\tmanifest.parameterSchema = action.schema.toJSONSchema();\n\t\tmanifest.parameterSchemaFormat = \"json-schema\";\n\t}\n\n\tif (action.stateMachine !== undefined) {\n\t\tconst binding: ModuleManifestActionStateMachine = {\n\t\t\tentityType: action.stateMachine.entityType,\n\t\t};\n\t\tif (typeof action.stateMachine.targetState === \"string\") {\n\t\t\tbinding.targetState = action.stateMachine.targetState;\n\t\t}\n\t\tmanifest.stateMachine = binding;\n\t}\n\n\tif (action.adapterSteps !== undefined) {\n\t\tmanifest.adapterSteps = action.adapterSteps.map((step) => {\n\t\t\tconst exported: ModuleManifestAdapterStep = {\n\t\t\t\tadapterType: step.adapterType,\n\t\t\t\toperation: step.operation,\n\t\t\t};\n\t\t\tif (step.retryPolicy !== undefined) exported.retryPolicy = { ...step.retryPolicy };\n\t\t\treturn exported;\n\t\t});\n\t}\n\n\treturn manifest;\n}\n\nfunction exportPolicy(policy: unknown): ModuleManifestPolicy | undefined {\n\tif (!isRecord(policy) || typeof policy.policyId !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\t// Code evaluator: identified by its `evaluate` function (never serialized).\n\tif (typeof policy.evaluate === \"function\") {\n\t\tconst exported: ModuleManifestCodePolicy = {\n\t\t\ttype: \"code\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tversion: typeof policy.version === \"number\" ? policy.version : 1,\n\t\t};\n\t\tif (typeof policy.previewSafe === \"boolean\") exported.previewSafe = policy.previewSafe;\n\t\treturn exported;\n\t}\n\n\t// Declarative runtime policy definition: pure data, serialized as-is.\n\tif (typeof policy.kind === \"string\" && typeof policy.policyVersion === \"number\") {\n\t\tconst exported: ModuleManifestDataPolicy = {\n\t\t\ttype: \"data\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tkind: policy.kind as PolicyKind,\n\t\t};\n\t\tif (isRecord(policy.dataDefinition)) {\n\t\t\texported.dataDefinition = policy.dataDefinition as unknown as DataPolicyDefinition;\n\t\t}\n\t\tif (typeof policy.codeEvaluatorPolicyId === \"string\") {\n\t\t\texported.codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId;\n\t\t}\n\t\tif (isRecord(policy.fallback)) {\n\t\t\texported.fallback = policy.fallback as unknown as PolicyFallbackDefinition;\n\t\t}\n\t\treturn exported;\n\t}\n\n\t// Unknown policy shape: omit rather than guess.\n\treturn undefined;\n}\n\nfunction exportStateMachine(machine: unknown): ModuleManifestStateMachine | undefined {\n\tif (\n\t\t!isRecord(machine) ||\n\t\ttypeof machine.entityType !== \"string\" ||\n\t\t!isRecord(machine.states) ||\n\t\t!Array.isArray(machine.transitions)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst definition = machine as unknown as StateMachineDefinition;\n\treturn {\n\t\tentityType: definition.entityType,\n\t\tstates: Object.values(definition.states),\n\t\ttransitions: definition.transitions.map((transition) => ({\n\t\t\tfrom: transition.from,\n\t\t\tto: transition.to,\n\t\t\tcausedByAction: transition.causedByAction,\n\t\t\thasGuard: typeof transition.guard === \"function\",\n\t\t})),\n\t};\n}\n\n/**\n * Export a stable, JSON-serializable manifest of a module's ontology.\n *\n * This is a pure function of the module object: it does not read or mutate the\n * global module/action/policy/state-machine registries, and the module does\n * not need to be registered first. Declaration order is preserved everywhere\n * (nothing is sorted), so the same module object always produces a\n * byte-identical `JSON.stringify` result.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields are elided (`handler`,\n * policy `evaluate`, transition `guard` → `hasGuard`, dynamic `targetState`,\n * adapter `getInput`).\n */\nexport function exportModuleManifest(module: FabricModule<unknown>): ModuleManifest {\n\tconst manifest: ModuleManifest = {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tnamespace: module.namespace,\n\t\tdependencies: (module.dependencies ?? []).map(exportDependency),\n\t\tobjectTypes: (module.objectTypes ?? []).map(exportObjectType),\n\t\tsubjectTypes: [...(module.subjectTypes ?? [])],\n\t\tidPrefixes: (module.idPrefixes ?? []).map((registration) => ({\n\t\t\tprefix: registration.prefix,\n\t\t\tname: registration.name,\n\t\t})),\n\t\teventTypes: (module.eventTypes ?? []).map(exportEventType),\n\t\tactions: (module.actions ?? []).map(exportAction),\n\t\tpolicies: (module.policies ?? [])\n\t\t\t.map(exportPolicy)\n\t\t\t.filter((policy): policy is ModuleManifestPolicy => policy !== undefined),\n\t\tstateMachines: (module.stateMachines ?? [])\n\t\t\t.map(exportStateMachine)\n\t\t\t.filter((machine): machine is ModuleManifestStateMachine => machine !== undefined),\n\t};\n\n\tif (module.version !== undefined) manifest.version = module.version;\n\tif (module.displayName !== undefined) manifest.displayName = module.displayName;\n\tif (module.description !== undefined) manifest.description = module.description;\n\n\treturn manifest;\n}\n\n/**\n * Export manifests for a set of modules, preserving the input order.\n * Like {@link exportModuleManifest}, this is pure and registry-free.\n */\nexport function exportModuleManifestBundle(\n\tmodules: FabricModule<unknown>[],\n): ModuleManifestBundle {\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: modules.map(exportModuleManifest),\n\t};\n}\n"]}
@@ -0,0 +1,160 @@
1
+ import { getEventTypeName, getObjectTypeName, getModuleDependencyNamespace } from './chunk-35DD3H55.js';
2
+
3
+ // manifest/index.ts
4
+ var MODULE_MANIFEST_VERSION = 1;
5
+ function isJsonSchemaExportableValidator(schema) {
6
+ return typeof schema.toJSONSchema === "function";
7
+ }
8
+ function isRecord(value) {
9
+ return value !== null && typeof value === "object" && !Array.isArray(value);
10
+ }
11
+ function exportDependency(dependency) {
12
+ const namespace = getModuleDependencyNamespace(dependency);
13
+ if (typeof dependency === "string") {
14
+ return { namespace };
15
+ }
16
+ const normalized = { namespace };
17
+ if (dependency.version !== void 0) normalized.version = dependency.version;
18
+ if (dependency.optional !== void 0) normalized.optional = dependency.optional;
19
+ return normalized;
20
+ }
21
+ function exportObjectType(objectType) {
22
+ if (typeof objectType === "string") {
23
+ return { type: objectType };
24
+ }
25
+ const normalized = { type: getObjectTypeName(objectType) };
26
+ if (objectType.displayName !== void 0) normalized.displayName = objectType.displayName;
27
+ if (objectType.idPrefix !== void 0) normalized.idPrefix = objectType.idPrefix;
28
+ return normalized;
29
+ }
30
+ function exportEventType(eventType) {
31
+ if (typeof eventType === "string") {
32
+ return { eventType, schemaVersion: 1 };
33
+ }
34
+ const normalized = {
35
+ eventType: getEventTypeName(eventType),
36
+ schemaVersion: eventType.schemaVersion
37
+ };
38
+ if (eventType.description !== void 0) normalized.description = eventType.description;
39
+ return normalized;
40
+ }
41
+ function exportAction(action) {
42
+ const manifest = {
43
+ actionId: action.actionId,
44
+ version: action.version,
45
+ kind: action.kind ?? "atomic",
46
+ idempotent: action.idempotent,
47
+ mutatesDomain: action.mutatesDomain,
48
+ emitsEvents: [...action.emitsEvents]
49
+ };
50
+ if (action.policies !== void 0) manifest.policies = [...action.policies];
51
+ if (action.requiredRoles !== void 0) manifest.requiredRoles = [...action.requiredRoles];
52
+ if (action.requiredPermissions !== void 0) {
53
+ manifest.requiredPermissions = [...action.requiredPermissions];
54
+ }
55
+ if (action.eventPhase !== void 0) manifest.eventPhase = action.eventPhase;
56
+ if (isJsonSchemaExportableValidator(action.schema)) {
57
+ manifest.parameterSchema = action.schema.toJSONSchema();
58
+ manifest.parameterSchemaFormat = "json-schema";
59
+ }
60
+ if (action.stateMachine !== void 0) {
61
+ const binding = {
62
+ entityType: action.stateMachine.entityType
63
+ };
64
+ if (typeof action.stateMachine.targetState === "string") {
65
+ binding.targetState = action.stateMachine.targetState;
66
+ }
67
+ manifest.stateMachine = binding;
68
+ }
69
+ if (action.adapterSteps !== void 0) {
70
+ manifest.adapterSteps = action.adapterSteps.map((step) => {
71
+ const exported = {
72
+ adapterType: step.adapterType,
73
+ operation: step.operation
74
+ };
75
+ if (step.retryPolicy !== void 0) exported.retryPolicy = { ...step.retryPolicy };
76
+ return exported;
77
+ });
78
+ }
79
+ return manifest;
80
+ }
81
+ function exportPolicy(policy) {
82
+ if (!isRecord(policy) || typeof policy.policyId !== "string") {
83
+ return void 0;
84
+ }
85
+ if (typeof policy.evaluate === "function") {
86
+ const exported = {
87
+ type: "code",
88
+ policyId: policy.policyId,
89
+ version: typeof policy.version === "number" ? policy.version : 1
90
+ };
91
+ if (typeof policy.previewSafe === "boolean") exported.previewSafe = policy.previewSafe;
92
+ return exported;
93
+ }
94
+ if (typeof policy.kind === "string" && typeof policy.policyVersion === "number") {
95
+ const exported = {
96
+ type: "data",
97
+ policyId: policy.policyId,
98
+ policyVersion: policy.policyVersion,
99
+ kind: policy.kind
100
+ };
101
+ if (isRecord(policy.dataDefinition)) {
102
+ exported.dataDefinition = policy.dataDefinition;
103
+ }
104
+ if (typeof policy.codeEvaluatorPolicyId === "string") {
105
+ exported.codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId;
106
+ }
107
+ if (isRecord(policy.fallback)) {
108
+ exported.fallback = policy.fallback;
109
+ }
110
+ return exported;
111
+ }
112
+ return void 0;
113
+ }
114
+ function exportStateMachine(machine) {
115
+ if (!isRecord(machine) || typeof machine.entityType !== "string" || !isRecord(machine.states) || !Array.isArray(machine.transitions)) {
116
+ return void 0;
117
+ }
118
+ const definition = machine;
119
+ return {
120
+ entityType: definition.entityType,
121
+ states: Object.values(definition.states),
122
+ transitions: definition.transitions.map((transition) => ({
123
+ from: transition.from,
124
+ to: transition.to,
125
+ causedByAction: transition.causedByAction,
126
+ hasGuard: typeof transition.guard === "function"
127
+ }))
128
+ };
129
+ }
130
+ function exportModuleManifest(module) {
131
+ const manifest = {
132
+ manifestVersion: MODULE_MANIFEST_VERSION,
133
+ namespace: module.namespace,
134
+ dependencies: (module.dependencies ?? []).map(exportDependency),
135
+ objectTypes: (module.objectTypes ?? []).map(exportObjectType),
136
+ subjectTypes: [...module.subjectTypes ?? []],
137
+ idPrefixes: (module.idPrefixes ?? []).map((registration) => ({
138
+ prefix: registration.prefix,
139
+ name: registration.name
140
+ })),
141
+ eventTypes: (module.eventTypes ?? []).map(exportEventType),
142
+ actions: (module.actions ?? []).map(exportAction),
143
+ policies: (module.policies ?? []).map(exportPolicy).filter((policy) => policy !== void 0),
144
+ stateMachines: (module.stateMachines ?? []).map(exportStateMachine).filter((machine) => machine !== void 0)
145
+ };
146
+ if (module.version !== void 0) manifest.version = module.version;
147
+ if (module.displayName !== void 0) manifest.displayName = module.displayName;
148
+ if (module.description !== void 0) manifest.description = module.description;
149
+ return manifest;
150
+ }
151
+ function exportModuleManifestBundle(modules) {
152
+ return {
153
+ manifestVersion: MODULE_MANIFEST_VERSION,
154
+ modules: modules.map(exportModuleManifest)
155
+ };
156
+ }
157
+
158
+ export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator };
159
+ //# sourceMappingURL=chunk-N72WJ4AU.js.map
160
+ //# sourceMappingURL=chunk-N72WJ4AU.js.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AC,OAAA,KAAmD,OAAA,KAAY,MAAS;AAAA,GACnF;AAEA,EAAA,IAAI,MAAA,CAAO,OAAA,KAAY,MAAA,EAAW,QAAA,CAAS,UAAU,MAAA,CAAO,OAAA;AAC5D,EAAA,IAAI,MAAA,CAAO,WAAA,KAAgB,MAAA,EAAW,QAAA,CAAS,cAAc,MAAA,CAAO,WAAA;AACpE,EAAA,IAAI,MAAA,CAAO,WAAA,KAAgB,MAAA,EAAW,QAAA,CAAS,cAAc,MAAA,CAAO,WAAA;AAEpE,EAAA,OAAO,QAAA;AACR;AAMO,SAAS,2BACf,OAAA,EACuB;AACvB,EAAA,OAAO;AAAA,IACN,eAAA,EAAiB,uBAAA;AAAA,IACjB,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,oBAAoB;AAAA,GAC1C;AACD","file":"chunk-N72WJ4AU.js","sourcesContent":["import type {\n\tActionDefinition,\n\tAdapterStepRetryPolicy,\n\tSchemaValidator,\n} from \"../actions\";\nimport {\n\tgetEventTypeName,\n\tgetModuleDependencyNamespace,\n\tgetObjectTypeName,\n\ttype FabricModule,\n\ttype ModuleDependency,\n\ttype ModuleDependencyInput,\n} from \"../modules\";\nimport type {\n\tDataPolicyDefinition,\n\tPolicyFallbackDefinition,\n\tPolicyKind,\n} from \"../policies\";\nimport type { StateDefinition, StateMachineDefinition } from \"../state-machines\";\n\n/**\n * Version of the module manifest contract. Bump when the serialized shape\n * changes in a way consumers must detect.\n */\nexport const MODULE_MANIFEST_VERSION = 1 as const;\n\nexport interface ModuleManifestObjectType {\n\ttype: string;\n\tdisplayName?: string;\n\tidPrefix?: string;\n}\n\nexport interface ModuleManifestIdPrefix {\n\tprefix: string;\n\tname: string;\n}\n\nexport interface ModuleManifestEventType {\n\teventType: string;\n\tschemaVersion: number;\n\tdescription?: string;\n}\n\nexport interface ModuleManifestActionStateMachine {\n\tentityType: string;\n\t/** Present only when the binding declares a static target state. */\n\ttargetState?: string;\n}\n\nexport interface ModuleManifestAdapterStep {\n\tadapterType: string;\n\toperation: string;\n\tretryPolicy?: AdapterStepRetryPolicy;\n}\n\nexport interface ModuleManifestAction {\n\tactionId: string;\n\tversion: number;\n\tkind: \"atomic\" | \"saga\";\n\tidempotent: boolean;\n\tmutatesDomain: boolean;\n\temitsEvents: string[];\n\tpolicies?: string[];\n\trequiredRoles?: string[];\n\trequiredPermissions?: string[];\n\teventPhase?: \"before_adapters\" | \"after_adapters\";\n\t/**\n\t * JSON Schema for the action parameters, present only when the action's\n\t * `schema` validator implements {@link JsonSchemaExportableValidator}.\n\t */\n\tparameterSchema?: unknown;\n\tparameterSchemaFormat?: \"json-schema\";\n\tstateMachine?: ModuleManifestActionStateMachine;\n\tadapterSteps?: ModuleManifestAdapterStep[];\n}\n\nexport interface ModuleManifestCodePolicy {\n\ttype: \"code\";\n\tpolicyId: string;\n\tversion: number;\n\tpreviewSafe?: boolean;\n}\n\nexport interface ModuleManifestDataPolicy {\n\ttype: \"data\";\n\tpolicyId: string;\n\tpolicyVersion: number;\n\tkind: PolicyKind;\n\tdataDefinition?: DataPolicyDefinition;\n\tcodeEvaluatorPolicyId?: string;\n\tfallback?: PolicyFallbackDefinition;\n}\n\nexport type ModuleManifestPolicy = ModuleManifestCodePolicy | ModuleManifestDataPolicy;\n\nexport interface ModuleManifestStateMachineTransition {\n\tfrom: string;\n\tto: string;\n\tcausedByAction: string;\n\t/** `true` when the transition declares a guard function. The guard itself is never serialized. */\n\thasGuard: boolean;\n}\n\nexport interface ModuleManifestStateMachine {\n\tentityType: string;\n\t/** States in declaration order (`Object.values` order of the definition record). */\n\tstates: StateDefinition[];\n\ttransitions: ModuleManifestStateMachineTransition[];\n}\n\n/**\n * Stable, JSON-serializable description of a {@link FabricModule}'s ontology:\n * object types, subject types, id prefixes, event types, actions, policies,\n * and state machines. Intended for downstream tooling (semantics exporters,\n * docs generators, tool generators) that cannot consume live module code.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields (`handler`, `evaluate`, `guard`,\n * dynamic `targetState`, adapter `getInput`) are never serialized.\n */\nexport interface ModuleManifest {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\tnamespace: string;\n\tversion?: string;\n\tdisplayName?: string;\n\tdescription?: string;\n\tdependencies: ModuleDependency[];\n\tobjectTypes: ModuleManifestObjectType[];\n\tsubjectTypes: string[];\n\tidPrefixes: ModuleManifestIdPrefix[];\n\teventTypes: ModuleManifestEventType[];\n\tactions: ModuleManifestAction[];\n\tpolicies: ModuleManifestPolicy[];\n\tstateMachines: ModuleManifestStateMachine[];\n}\n\nexport interface ModuleManifestBundle {\n\tmanifestVersion: typeof MODULE_MANIFEST_VERSION;\n\t/** Manifests in the input module order. */\n\tmodules: ModuleManifest[];\n}\n\n/**\n * A {@link SchemaValidator} that can also export its parameter schema as JSON\n * Schema (for example a Zod 4 schema via `z.toJSONSchema`). Keeps the platform\n * zero-dependency while letting schema-bearing actions flow into manifests.\n */\nexport interface JsonSchemaExportableValidator extends SchemaValidator {\n\ttoJSONSchema(): Record<string, unknown>;\n}\n\nexport function isJsonSchemaExportableValidator(\n\tschema: SchemaValidator,\n): schema is JsonSchemaExportableValidator {\n\treturn (\n\t\ttypeof (schema as Partial<JsonSchemaExportableValidator>).toJSONSchema === \"function\"\n\t);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction exportDependency(dependency: ModuleDependencyInput): ModuleDependency {\n\tconst namespace = getModuleDependencyNamespace(dependency);\n\tif (typeof dependency === \"string\") {\n\t\treturn { namespace };\n\t}\n\tconst normalized: ModuleDependency = { namespace };\n\tif (dependency.version !== undefined) normalized.version = dependency.version;\n\tif (dependency.optional !== undefined) normalized.optional = dependency.optional;\n\treturn normalized;\n}\n\nfunction exportObjectType(\n\tobjectType: NonNullable<FabricModule[\"objectTypes\"]>[number],\n): ModuleManifestObjectType {\n\tif (typeof objectType === \"string\") {\n\t\treturn { type: objectType };\n\t}\n\tconst normalized: ModuleManifestObjectType = { type: getObjectTypeName(objectType) };\n\tif (objectType.displayName !== undefined) normalized.displayName = objectType.displayName;\n\tif (objectType.idPrefix !== undefined) normalized.idPrefix = objectType.idPrefix;\n\treturn normalized;\n}\n\nfunction exportEventType(\n\teventType: NonNullable<FabricModule[\"eventTypes\"]>[number],\n): ModuleManifestEventType {\n\tif (typeof eventType === \"string\") {\n\t\t// String registrations carry no explicit schema version; the events\n\t\t// registry treats the bare name as the initial version of the type.\n\t\treturn { eventType, schemaVersion: 1 };\n\t}\n\tconst normalized: ModuleManifestEventType = {\n\t\teventType: getEventTypeName(eventType),\n\t\tschemaVersion: eventType.schemaVersion,\n\t};\n\tif (eventType.description !== undefined) normalized.description = eventType.description;\n\treturn normalized;\n}\n\nfunction exportAction(action: ActionDefinition): ModuleManifestAction {\n\tconst manifest: ModuleManifestAction = {\n\t\tactionId: action.actionId,\n\t\tversion: action.version,\n\t\tkind: action.kind ?? \"atomic\",\n\t\tidempotent: action.idempotent,\n\t\tmutatesDomain: action.mutatesDomain,\n\t\temitsEvents: [...action.emitsEvents],\n\t};\n\n\tif (action.policies !== undefined) manifest.policies = [...action.policies];\n\tif (action.requiredRoles !== undefined) manifest.requiredRoles = [...action.requiredRoles];\n\tif (action.requiredPermissions !== undefined) {\n\t\tmanifest.requiredPermissions = [...action.requiredPermissions];\n\t}\n\tif (action.eventPhase !== undefined) manifest.eventPhase = action.eventPhase;\n\n\tif (isJsonSchemaExportableValidator(action.schema)) {\n\t\tmanifest.parameterSchema = action.schema.toJSONSchema();\n\t\tmanifest.parameterSchemaFormat = \"json-schema\";\n\t}\n\n\tif (action.stateMachine !== undefined) {\n\t\tconst binding: ModuleManifestActionStateMachine = {\n\t\t\tentityType: action.stateMachine.entityType,\n\t\t};\n\t\tif (typeof action.stateMachine.targetState === \"string\") {\n\t\t\tbinding.targetState = action.stateMachine.targetState;\n\t\t}\n\t\tmanifest.stateMachine = binding;\n\t}\n\n\tif (action.adapterSteps !== undefined) {\n\t\tmanifest.adapterSteps = action.adapterSteps.map((step) => {\n\t\t\tconst exported: ModuleManifestAdapterStep = {\n\t\t\t\tadapterType: step.adapterType,\n\t\t\t\toperation: step.operation,\n\t\t\t};\n\t\t\tif (step.retryPolicy !== undefined) exported.retryPolicy = { ...step.retryPolicy };\n\t\t\treturn exported;\n\t\t});\n\t}\n\n\treturn manifest;\n}\n\nfunction exportPolicy(policy: unknown): ModuleManifestPolicy | undefined {\n\tif (!isRecord(policy) || typeof policy.policyId !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\t// Code evaluator: identified by its `evaluate` function (never serialized).\n\tif (typeof policy.evaluate === \"function\") {\n\t\tconst exported: ModuleManifestCodePolicy = {\n\t\t\ttype: \"code\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tversion: typeof policy.version === \"number\" ? policy.version : 1,\n\t\t};\n\t\tif (typeof policy.previewSafe === \"boolean\") exported.previewSafe = policy.previewSafe;\n\t\treturn exported;\n\t}\n\n\t// Declarative runtime policy definition: pure data, serialized as-is.\n\tif (typeof policy.kind === \"string\" && typeof policy.policyVersion === \"number\") {\n\t\tconst exported: ModuleManifestDataPolicy = {\n\t\t\ttype: \"data\",\n\t\t\tpolicyId: policy.policyId,\n\t\t\tpolicyVersion: policy.policyVersion,\n\t\t\tkind: policy.kind as PolicyKind,\n\t\t};\n\t\tif (isRecord(policy.dataDefinition)) {\n\t\t\texported.dataDefinition = policy.dataDefinition as unknown as DataPolicyDefinition;\n\t\t}\n\t\tif (typeof policy.codeEvaluatorPolicyId === \"string\") {\n\t\t\texported.codeEvaluatorPolicyId = policy.codeEvaluatorPolicyId;\n\t\t}\n\t\tif (isRecord(policy.fallback)) {\n\t\t\texported.fallback = policy.fallback as unknown as PolicyFallbackDefinition;\n\t\t}\n\t\treturn exported;\n\t}\n\n\t// Unknown policy shape: omit rather than guess.\n\treturn undefined;\n}\n\nfunction exportStateMachine(machine: unknown): ModuleManifestStateMachine | undefined {\n\tif (\n\t\t!isRecord(machine) ||\n\t\ttypeof machine.entityType !== \"string\" ||\n\t\t!isRecord(machine.states) ||\n\t\t!Array.isArray(machine.transitions)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst definition = machine as unknown as StateMachineDefinition;\n\treturn {\n\t\tentityType: definition.entityType,\n\t\tstates: Object.values(definition.states),\n\t\ttransitions: definition.transitions.map((transition) => ({\n\t\t\tfrom: transition.from,\n\t\t\tto: transition.to,\n\t\t\tcausedByAction: transition.causedByAction,\n\t\t\thasGuard: typeof transition.guard === \"function\",\n\t\t})),\n\t};\n}\n\n/**\n * Export a stable, JSON-serializable manifest of a module's ontology.\n *\n * This is a pure function of the module object: it does not read or mutate the\n * global module/action/policy/state-machine registries, and the module does\n * not need to be registered first. Declaration order is preserved everywhere\n * (nothing is sorted), so the same module object always produces a\n * byte-identical `JSON.stringify` result.\n *\n * The manifest contains definitions only — never raw parameter values,\n * secrets, or runtime data. Function fields are elided (`handler`,\n * policy `evaluate`, transition `guard` → `hasGuard`, dynamic `targetState`,\n * adapter `getInput`).\n */\nexport function exportModuleManifest(module: FabricModule<unknown>): ModuleManifest {\n\tconst manifest: ModuleManifest = {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tnamespace: module.namespace,\n\t\tdependencies: (module.dependencies ?? []).map(exportDependency),\n\t\tobjectTypes: (module.objectTypes ?? []).map(exportObjectType),\n\t\tsubjectTypes: [...(module.subjectTypes ?? [])],\n\t\tidPrefixes: (module.idPrefixes ?? []).map((registration) => ({\n\t\t\tprefix: registration.prefix,\n\t\t\tname: registration.name,\n\t\t})),\n\t\teventTypes: (module.eventTypes ?? []).map(exportEventType),\n\t\tactions: (module.actions ?? []).map(exportAction),\n\t\tpolicies: (module.policies ?? [])\n\t\t\t.map(exportPolicy)\n\t\t\t.filter((policy): policy is ModuleManifestPolicy => policy !== undefined),\n\t\tstateMachines: (module.stateMachines ?? [])\n\t\t\t.map(exportStateMachine)\n\t\t\t.filter((machine): machine is ModuleManifestStateMachine => machine !== undefined),\n\t};\n\n\tif (module.version !== undefined) manifest.version = module.version;\n\tif (module.displayName !== undefined) manifest.displayName = module.displayName;\n\tif (module.description !== undefined) manifest.description = module.description;\n\n\treturn manifest;\n}\n\n/**\n * Export manifests for a set of modules, preserving the input order.\n * Like {@link exportModuleManifest}, this is pure and registry-free.\n */\nexport function exportModuleManifestBundle(\n\tmodules: FabricModule<unknown>[],\n): ModuleManifestBundle {\n\treturn {\n\t\tmanifestVersion: MODULE_MANIFEST_VERSION,\n\t\tmodules: modules.map(exportModuleManifest),\n\t};\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ var chunkYZKUEC2J_cjs = require('./chunk-YZKUEC2J.cjs');
3
4
  var chunkLZSE6QGQ_cjs = require('./chunk-LZSE6QGQ.cjs');
5
+ var chunk54EQTOH6_cjs = require('./chunk-54EQTOH6.cjs');
4
6
  var chunkSSYKDXR4_cjs = require('./chunk-SSYKDXR4.cjs');
5
7
  var chunkQETQGAXJ_cjs = require('./chunk-QETQGAXJ.cjs');
6
8
  var chunkNJL3US7H_cjs = require('./chunk-NJL3US7H.cjs');
7
9
  var chunkYQEXO3IQ_cjs = require('./chunk-YQEXO3IQ.cjs');
8
10
  var chunkQ3WYIWCN_cjs = require('./chunk-Q3WYIWCN.cjs');
9
11
  var chunkUV252FLT_cjs = require('./chunk-UV252FLT.cjs');
10
- var chunkYZKUEC2J_cjs = require('./chunk-YZKUEC2J.cjs');
11
12
  var chunkBWNPGRRV_cjs = require('./chunk-BWNPGRRV.cjs');
12
13
  var chunkNPVIFZQV_cjs = require('./chunk-NPVIFZQV.cjs');
13
14
  var chunkF3E5SXPN_cjs = require('./chunk-F3E5SXPN.cjs');
@@ -18,6 +19,18 @@ var chunkANPJYXBK_cjs = require('./chunk-ANPJYXBK.cjs');
18
19
 
19
20
 
20
21
 
22
+ Object.defineProperty(exports, "createDeterministicIdFactory", {
23
+ enumerable: true,
24
+ get: function () { return chunkYZKUEC2J_cjs.createDeterministicIdFactory; }
25
+ });
26
+ Object.defineProperty(exports, "createFakeActionContext", {
27
+ enumerable: true,
28
+ get: function () { return chunkYZKUEC2J_cjs.createFakeActionContext; }
29
+ });
30
+ Object.defineProperty(exports, "createInMemoryAdapterRegistry", {
31
+ enumerable: true,
32
+ get: function () { return chunkYZKUEC2J_cjs.createInMemoryAdapterRegistry; }
33
+ });
21
34
  Object.defineProperty(exports, "FABRIC_ID_PREFIXES", {
22
35
  enumerable: true,
23
36
  get: function () { return chunkLZSE6QGQ_cjs.FABRIC_ID_PREFIXES; }
@@ -34,6 +47,22 @@ Object.defineProperty(exports, "parseFabricId", {
34
47
  enumerable: true,
35
48
  get: function () { return chunkLZSE6QGQ_cjs.parseFabricId; }
36
49
  });
50
+ Object.defineProperty(exports, "MODULE_MANIFEST_VERSION", {
51
+ enumerable: true,
52
+ get: function () { return chunk54EQTOH6_cjs.MODULE_MANIFEST_VERSION; }
53
+ });
54
+ Object.defineProperty(exports, "exportModuleManifest", {
55
+ enumerable: true,
56
+ get: function () { return chunk54EQTOH6_cjs.exportModuleManifest; }
57
+ });
58
+ Object.defineProperty(exports, "exportModuleManifestBundle", {
59
+ enumerable: true,
60
+ get: function () { return chunk54EQTOH6_cjs.exportModuleManifestBundle; }
61
+ });
62
+ Object.defineProperty(exports, "isJsonSchemaExportableValidator", {
63
+ enumerable: true,
64
+ get: function () { return chunk54EQTOH6_cjs.isJsonSchemaExportableValidator; }
65
+ });
37
66
  Object.defineProperty(exports, "createModuleRegistry", {
38
67
  enumerable: true,
39
68
  get: function () { return chunkSSYKDXR4_cjs.createModuleRegistry; }
@@ -186,18 +215,6 @@ Object.defineProperty(exports, "validateTransition", {
186
215
  enumerable: true,
187
216
  get: function () { return chunkUV252FLT_cjs.validateTransition; }
188
217
  });
189
- Object.defineProperty(exports, "createDeterministicIdFactory", {
190
- enumerable: true,
191
- get: function () { return chunkYZKUEC2J_cjs.createDeterministicIdFactory; }
192
- });
193
- Object.defineProperty(exports, "createFakeActionContext", {
194
- enumerable: true,
195
- get: function () { return chunkYZKUEC2J_cjs.createFakeActionContext; }
196
- });
197
- Object.defineProperty(exports, "createInMemoryAdapterRegistry", {
198
- enumerable: true,
199
- get: function () { return chunkYZKUEC2J_cjs.createInMemoryAdapterRegistry; }
200
- });
201
218
  Object.defineProperty(exports, "ACTOR_TYPES", {
202
219
  enumerable: true,
203
220
  get: function () { return chunkBWNPGRRV_cjs.ACTOR_TYPES; }
package/dist/index.d.cts CHANGED
@@ -2,6 +2,7 @@ export { ACTOR_TYPES, ActionContext, ActionDefinition, ActionHandler, ActionId,
2
2
  export { AdapterAttempt, AdapterCircuitBreakerConfig, AdapterExecutionContext, AdapterExecutionResult, AdapterExecutor, AdapterImplementation, AdapterRegistry, AdapterRetryPolicy, ExecuteWithRetryOptions, MissingAdapterRegistrationError, ResolvedAdapterRetryPolicy, executeWithAdapterRetry, getRetryDelayMs, resolveAdapterRetryPolicy } from './adapters/index.cjs';
3
3
  export { AssetEventActorType, AssetEventEnvelope, AssetEventSubjectType, AssetEventType, EventTypeRegistry, createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType } from './events/index.cjs';
4
4
  export { FABRIC_ID_PREFIXES, FabricIdPrefix, createFabricId, isFabricId, parseFabricId } from './ids/index.cjs';
5
+ export { JsonSchemaExportableValidator, MODULE_MANIFEST_VERSION, ModuleManifest, ModuleManifestAction, ModuleManifestActionStateMachine, ModuleManifestAdapterStep, ModuleManifestBundle, ModuleManifestCodePolicy, ModuleManifestDataPolicy, ModuleManifestEventType, ModuleManifestIdPrefix, ModuleManifestObjectType, ModuleManifestPolicy, ModuleManifestStateMachine, ModuleManifestStateMachineTransition, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator } from './manifest/index.cjs';
5
6
  export { EventTypeRegistration, EventTypeRegistrationInput, FabricModule, IdPrefixRegistration, ModuleDependency, ModuleDependencyInput, ModuleDisplayRendererRegistration, ModuleRegistry, ObjectTypeRegistration, ObjectTypeRegistrationInput, PolicyRegistration, StateMachineRegistration, createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from './modules/index.cjs';
6
7
  export { FabricObjectType, assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType } from './objects/index.cjs';
7
8
  export { DataPolicyComparisonOperator, DataPolicyCondition, DataPolicyConditionResult, DataPolicyDefinition, DataPolicyLiteral, DataPolicySource, DataPolicySourceReference, DataPolicyValidationResult, PolicyContext, PolicyCorrectiveAction, PolicyCorrectiveActionBase, PolicyCorrectiveActionKind, PolicyDispatchEvidence, PolicyEvaluationMode, PolicyEvaluationResult, PolicyEvaluator, PolicyFact, PolicyFallbackDefinition, PolicyFallbackTrigger, PolicyGuidance, PolicyGuidanceValidationResult, PolicyId, PolicyInvokeActionCorrectiveAction, PolicyKind, PolicyManualCorrectiveAction, PolicyNavigateCorrectiveAction, PolicyOutcome, RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition, validatePolicyGuidance } from './policies/index.cjs';
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { ACTOR_TYPES, ActionContext, ActionDefinition, ActionHandler, ActionId,
2
2
  export { AdapterAttempt, AdapterCircuitBreakerConfig, AdapterExecutionContext, AdapterExecutionResult, AdapterExecutor, AdapterImplementation, AdapterRegistry, AdapterRetryPolicy, ExecuteWithRetryOptions, MissingAdapterRegistrationError, ResolvedAdapterRetryPolicy, executeWithAdapterRetry, getRetryDelayMs, resolveAdapterRetryPolicy } from './adapters/index.js';
3
3
  export { AssetEventActorType, AssetEventEnvelope, AssetEventSubjectType, AssetEventType, EventTypeRegistry, createEventTypeRegistry, getRegisteredEventTypes, getRegisteredSubjectTypes, isValidEventType, isValidSubjectType, registerEventType, registerSubjectType } from './events/index.js';
4
4
  export { FABRIC_ID_PREFIXES, FabricIdPrefix, createFabricId, isFabricId, parseFabricId } from './ids/index.js';
5
+ export { JsonSchemaExportableValidator, MODULE_MANIFEST_VERSION, ModuleManifest, ModuleManifestAction, ModuleManifestActionStateMachine, ModuleManifestAdapterStep, ModuleManifestBundle, ModuleManifestCodePolicy, ModuleManifestDataPolicy, ModuleManifestEventType, ModuleManifestIdPrefix, ModuleManifestObjectType, ModuleManifestPolicy, ModuleManifestStateMachine, ModuleManifestStateMachineTransition, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator } from './manifest/index.js';
5
6
  export { EventTypeRegistration, EventTypeRegistrationInput, FabricModule, IdPrefixRegistration, ModuleDependency, ModuleDependencyInput, ModuleDisplayRendererRegistration, ModuleRegistry, ObjectTypeRegistration, ObjectTypeRegistrationInput, PolicyRegistration, StateMachineRegistration, createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from './modules/index.js';
6
7
  export { FabricObjectType, assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType } from './objects/index.js';
7
8
  export { DataPolicyComparisonOperator, DataPolicyCondition, DataPolicyConditionResult, DataPolicyDefinition, DataPolicyLiteral, DataPolicySource, DataPolicySourceReference, DataPolicyValidationResult, PolicyContext, PolicyCorrectiveAction, PolicyCorrectiveActionBase, PolicyCorrectiveActionKind, PolicyDispatchEvidence, PolicyEvaluationMode, PolicyEvaluationResult, PolicyEvaluator, PolicyFact, PolicyFallbackDefinition, PolicyFallbackTrigger, PolicyGuidance, PolicyGuidanceValidationResult, PolicyId, PolicyInvokeActionCorrectiveAction, PolicyKind, PolicyManualCorrectiveAction, PolicyNavigateCorrectiveAction, PolicyOutcome, RuntimePolicyDefinition, aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition, validatePolicyGuidance } from './policies/index.js';
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
+ export { createDeterministicIdFactory, createFakeActionContext, createInMemoryAdapterRegistry } from './chunk-IFMZPLM4.js';
1
2
  export { FABRIC_ID_PREFIXES, createFabricId, isFabricId, parseFabricId } from './chunk-RALMUSOX.js';
3
+ export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator } from './chunk-N72WJ4AU.js';
2
4
  export { createModuleRegistry, getEventTypeName, getModuleDependencyNamespace, getObjectTypeName, registerFabricModule, registerFabricModules, validateModuleNamespace } from './chunk-35DD3H55.js';
3
5
  export { assertObjectType, getRegisteredObjectTypes, isValidObjectType, registerObjectType } from './chunk-I35B576X.js';
4
6
  export { aggregatePolicyOutcomes, assertPolicyId, evaluatePolicyDefinition, evaluatePolicyDefinitions, evaluateRegisteredPolicies, getRegisteredPolicyIds, registerPolicy, registerPolicyIfMissing, resolvePolicy, validateDataPolicyDefinition, validatePolicyGuidance } from './chunk-6ER62UUN.js';
5
7
  export { ANONYMIZATION_POLICY_VERSION, AnonymizationEngine, FieldRedactor, PLATFORM_PRIVACY_POLICY_VERSION, anonymizeAssetEventPayload, anonymizeEvidencePacket, anonymizeJsonValue, buildAnonymizationLifecycleEvidence, stableChecksum } from './chunk-X7WC4AYC.js';
6
8
  export { replayEvents } from './chunk-JSTGOT6P.js';
7
9
  export { getAllowedTransitions, getEntityStateClass, registerStateMachine, registerStateMachineIfMissing, resolveStateMachine, validateTransition } from './chunk-T2JLSZN6.js';
8
- export { createDeterministicIdFactory, createFakeActionContext, createInMemoryAdapterRegistry } from './chunk-IFMZPLM4.js';
9
10
  export { ACTOR_TYPES, assertActionId, assertActorType, getRegisteredActionIds, isActorType, isRegisteredActionId, registerAction, registerActionIfMissing, resolveAction, resolveRegisteredAction } from './chunk-4SMPJPJ6.js';
10
11
  export { AdapterRegistry, MissingAdapterRegistrationError, executeWithAdapterRetry, getRetryDelayMs, resolveAdapterRetryPolicy } from './chunk-3ZW5USXF.js';
11
12
  export { AgentActionPolicyRegistry } from './chunk-OFCCZ27Z.js';
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var chunk54EQTOH6_cjs = require('../chunk-54EQTOH6.cjs');
4
+ require('../chunk-SSYKDXR4.cjs');
5
+ require('../chunk-QETQGAXJ.cjs');
6
+ require('../chunk-NJL3US7H.cjs');
7
+ require('../chunk-UV252FLT.cjs');
8
+ require('../chunk-BWNPGRRV.cjs');
9
+ require('../chunk-EO4VSB2O.cjs');
10
+ require('../chunk-JAXDEK5Z.cjs');
11
+
12
+
13
+
14
+ Object.defineProperty(exports, "MODULE_MANIFEST_VERSION", {
15
+ enumerable: true,
16
+ get: function () { return chunk54EQTOH6_cjs.MODULE_MANIFEST_VERSION; }
17
+ });
18
+ Object.defineProperty(exports, "exportModuleManifest", {
19
+ enumerable: true,
20
+ get: function () { return chunk54EQTOH6_cjs.exportModuleManifest; }
21
+ });
22
+ Object.defineProperty(exports, "exportModuleManifestBundle", {
23
+ enumerable: true,
24
+ get: function () { return chunk54EQTOH6_cjs.exportModuleManifestBundle; }
25
+ });
26
+ Object.defineProperty(exports, "isJsonSchemaExportableValidator", {
27
+ enumerable: true,
28
+ get: function () { return chunk54EQTOH6_cjs.isJsonSchemaExportableValidator; }
29
+ });
30
+ //# sourceMappingURL=index.cjs.map
31
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,145 @@
1
+ import { SchemaValidator, AdapterStepRetryPolicy } from '../actions/index.cjs';
2
+ import { ModuleDependency, FabricModule } from '../modules/index.cjs';
3
+ import { PolicyKind, DataPolicyDefinition, PolicyFallbackDefinition } from '../policies/index.cjs';
4
+ import { StateDefinition } from '../state-machines/index.cjs';
5
+ import '../displays/index.cjs';
6
+
7
+ /**
8
+ * Version of the module manifest contract. Bump when the serialized shape
9
+ * changes in a way consumers must detect.
10
+ */
11
+ declare const MODULE_MANIFEST_VERSION: 1;
12
+ interface ModuleManifestObjectType {
13
+ type: string;
14
+ displayName?: string;
15
+ idPrefix?: string;
16
+ }
17
+ interface ModuleManifestIdPrefix {
18
+ prefix: string;
19
+ name: string;
20
+ }
21
+ interface ModuleManifestEventType {
22
+ eventType: string;
23
+ schemaVersion: number;
24
+ description?: string;
25
+ }
26
+ interface ModuleManifestActionStateMachine {
27
+ entityType: string;
28
+ /** Present only when the binding declares a static target state. */
29
+ targetState?: string;
30
+ }
31
+ interface ModuleManifestAdapterStep {
32
+ adapterType: string;
33
+ operation: string;
34
+ retryPolicy?: AdapterStepRetryPolicy;
35
+ }
36
+ interface ModuleManifestAction {
37
+ actionId: string;
38
+ version: number;
39
+ kind: "atomic" | "saga";
40
+ idempotent: boolean;
41
+ mutatesDomain: boolean;
42
+ emitsEvents: string[];
43
+ policies?: string[];
44
+ requiredRoles?: string[];
45
+ requiredPermissions?: string[];
46
+ eventPhase?: "before_adapters" | "after_adapters";
47
+ /**
48
+ * JSON Schema for the action parameters, present only when the action's
49
+ * `schema` validator implements {@link JsonSchemaExportableValidator}.
50
+ */
51
+ parameterSchema?: unknown;
52
+ parameterSchemaFormat?: "json-schema";
53
+ stateMachine?: ModuleManifestActionStateMachine;
54
+ adapterSteps?: ModuleManifestAdapterStep[];
55
+ }
56
+ interface ModuleManifestCodePolicy {
57
+ type: "code";
58
+ policyId: string;
59
+ version: number;
60
+ previewSafe?: boolean;
61
+ }
62
+ interface ModuleManifestDataPolicy {
63
+ type: "data";
64
+ policyId: string;
65
+ policyVersion: number;
66
+ kind: PolicyKind;
67
+ dataDefinition?: DataPolicyDefinition;
68
+ codeEvaluatorPolicyId?: string;
69
+ fallback?: PolicyFallbackDefinition;
70
+ }
71
+ type ModuleManifestPolicy = ModuleManifestCodePolicy | ModuleManifestDataPolicy;
72
+ interface ModuleManifestStateMachineTransition {
73
+ from: string;
74
+ to: string;
75
+ causedByAction: string;
76
+ /** `true` when the transition declares a guard function. The guard itself is never serialized. */
77
+ hasGuard: boolean;
78
+ }
79
+ interface ModuleManifestStateMachine {
80
+ entityType: string;
81
+ /** States in declaration order (`Object.values` order of the definition record). */
82
+ states: StateDefinition[];
83
+ transitions: ModuleManifestStateMachineTransition[];
84
+ }
85
+ /**
86
+ * Stable, JSON-serializable description of a {@link FabricModule}'s ontology:
87
+ * object types, subject types, id prefixes, event types, actions, policies,
88
+ * and state machines. Intended for downstream tooling (semantics exporters,
89
+ * docs generators, tool generators) that cannot consume live module code.
90
+ *
91
+ * The manifest contains definitions only — never raw parameter values,
92
+ * secrets, or runtime data. Function fields (`handler`, `evaluate`, `guard`,
93
+ * dynamic `targetState`, adapter `getInput`) are never serialized.
94
+ */
95
+ interface ModuleManifest {
96
+ manifestVersion: typeof MODULE_MANIFEST_VERSION;
97
+ namespace: string;
98
+ version?: string;
99
+ displayName?: string;
100
+ description?: string;
101
+ dependencies: ModuleDependency[];
102
+ objectTypes: ModuleManifestObjectType[];
103
+ subjectTypes: string[];
104
+ idPrefixes: ModuleManifestIdPrefix[];
105
+ eventTypes: ModuleManifestEventType[];
106
+ actions: ModuleManifestAction[];
107
+ policies: ModuleManifestPolicy[];
108
+ stateMachines: ModuleManifestStateMachine[];
109
+ }
110
+ interface ModuleManifestBundle {
111
+ manifestVersion: typeof MODULE_MANIFEST_VERSION;
112
+ /** Manifests in the input module order. */
113
+ modules: ModuleManifest[];
114
+ }
115
+ /**
116
+ * A {@link SchemaValidator} that can also export its parameter schema as JSON
117
+ * Schema (for example a Zod 4 schema via `z.toJSONSchema`). Keeps the platform
118
+ * zero-dependency while letting schema-bearing actions flow into manifests.
119
+ */
120
+ interface JsonSchemaExportableValidator extends SchemaValidator {
121
+ toJSONSchema(): Record<string, unknown>;
122
+ }
123
+ declare function isJsonSchemaExportableValidator(schema: SchemaValidator): schema is JsonSchemaExportableValidator;
124
+ /**
125
+ * Export a stable, JSON-serializable manifest of a module's ontology.
126
+ *
127
+ * This is a pure function of the module object: it does not read or mutate the
128
+ * global module/action/policy/state-machine registries, and the module does
129
+ * not need to be registered first. Declaration order is preserved everywhere
130
+ * (nothing is sorted), so the same module object always produces a
131
+ * byte-identical `JSON.stringify` result.
132
+ *
133
+ * The manifest contains definitions only — never raw parameter values,
134
+ * secrets, or runtime data. Function fields are elided (`handler`,
135
+ * policy `evaluate`, transition `guard` → `hasGuard`, dynamic `targetState`,
136
+ * adapter `getInput`).
137
+ */
138
+ declare function exportModuleManifest(module: FabricModule<unknown>): ModuleManifest;
139
+ /**
140
+ * Export manifests for a set of modules, preserving the input order.
141
+ * Like {@link exportModuleManifest}, this is pure and registry-free.
142
+ */
143
+ declare function exportModuleManifestBundle(modules: FabricModule<unknown>[]): ModuleManifestBundle;
144
+
145
+ export { type JsonSchemaExportableValidator, MODULE_MANIFEST_VERSION, type ModuleManifest, type ModuleManifestAction, type ModuleManifestActionStateMachine, type ModuleManifestAdapterStep, type ModuleManifestBundle, type ModuleManifestCodePolicy, type ModuleManifestDataPolicy, type ModuleManifestEventType, type ModuleManifestIdPrefix, type ModuleManifestObjectType, type ModuleManifestPolicy, type ModuleManifestStateMachine, type ModuleManifestStateMachineTransition, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator };
@@ -0,0 +1,145 @@
1
+ import { SchemaValidator, AdapterStepRetryPolicy } from '../actions/index.js';
2
+ import { ModuleDependency, FabricModule } from '../modules/index.js';
3
+ import { PolicyKind, DataPolicyDefinition, PolicyFallbackDefinition } from '../policies/index.js';
4
+ import { StateDefinition } from '../state-machines/index.js';
5
+ import '../displays/index.js';
6
+
7
+ /**
8
+ * Version of the module manifest contract. Bump when the serialized shape
9
+ * changes in a way consumers must detect.
10
+ */
11
+ declare const MODULE_MANIFEST_VERSION: 1;
12
+ interface ModuleManifestObjectType {
13
+ type: string;
14
+ displayName?: string;
15
+ idPrefix?: string;
16
+ }
17
+ interface ModuleManifestIdPrefix {
18
+ prefix: string;
19
+ name: string;
20
+ }
21
+ interface ModuleManifestEventType {
22
+ eventType: string;
23
+ schemaVersion: number;
24
+ description?: string;
25
+ }
26
+ interface ModuleManifestActionStateMachine {
27
+ entityType: string;
28
+ /** Present only when the binding declares a static target state. */
29
+ targetState?: string;
30
+ }
31
+ interface ModuleManifestAdapterStep {
32
+ adapterType: string;
33
+ operation: string;
34
+ retryPolicy?: AdapterStepRetryPolicy;
35
+ }
36
+ interface ModuleManifestAction {
37
+ actionId: string;
38
+ version: number;
39
+ kind: "atomic" | "saga";
40
+ idempotent: boolean;
41
+ mutatesDomain: boolean;
42
+ emitsEvents: string[];
43
+ policies?: string[];
44
+ requiredRoles?: string[];
45
+ requiredPermissions?: string[];
46
+ eventPhase?: "before_adapters" | "after_adapters";
47
+ /**
48
+ * JSON Schema for the action parameters, present only when the action's
49
+ * `schema` validator implements {@link JsonSchemaExportableValidator}.
50
+ */
51
+ parameterSchema?: unknown;
52
+ parameterSchemaFormat?: "json-schema";
53
+ stateMachine?: ModuleManifestActionStateMachine;
54
+ adapterSteps?: ModuleManifestAdapterStep[];
55
+ }
56
+ interface ModuleManifestCodePolicy {
57
+ type: "code";
58
+ policyId: string;
59
+ version: number;
60
+ previewSafe?: boolean;
61
+ }
62
+ interface ModuleManifestDataPolicy {
63
+ type: "data";
64
+ policyId: string;
65
+ policyVersion: number;
66
+ kind: PolicyKind;
67
+ dataDefinition?: DataPolicyDefinition;
68
+ codeEvaluatorPolicyId?: string;
69
+ fallback?: PolicyFallbackDefinition;
70
+ }
71
+ type ModuleManifestPolicy = ModuleManifestCodePolicy | ModuleManifestDataPolicy;
72
+ interface ModuleManifestStateMachineTransition {
73
+ from: string;
74
+ to: string;
75
+ causedByAction: string;
76
+ /** `true` when the transition declares a guard function. The guard itself is never serialized. */
77
+ hasGuard: boolean;
78
+ }
79
+ interface ModuleManifestStateMachine {
80
+ entityType: string;
81
+ /** States in declaration order (`Object.values` order of the definition record). */
82
+ states: StateDefinition[];
83
+ transitions: ModuleManifestStateMachineTransition[];
84
+ }
85
+ /**
86
+ * Stable, JSON-serializable description of a {@link FabricModule}'s ontology:
87
+ * object types, subject types, id prefixes, event types, actions, policies,
88
+ * and state machines. Intended for downstream tooling (semantics exporters,
89
+ * docs generators, tool generators) that cannot consume live module code.
90
+ *
91
+ * The manifest contains definitions only — never raw parameter values,
92
+ * secrets, or runtime data. Function fields (`handler`, `evaluate`, `guard`,
93
+ * dynamic `targetState`, adapter `getInput`) are never serialized.
94
+ */
95
+ interface ModuleManifest {
96
+ manifestVersion: typeof MODULE_MANIFEST_VERSION;
97
+ namespace: string;
98
+ version?: string;
99
+ displayName?: string;
100
+ description?: string;
101
+ dependencies: ModuleDependency[];
102
+ objectTypes: ModuleManifestObjectType[];
103
+ subjectTypes: string[];
104
+ idPrefixes: ModuleManifestIdPrefix[];
105
+ eventTypes: ModuleManifestEventType[];
106
+ actions: ModuleManifestAction[];
107
+ policies: ModuleManifestPolicy[];
108
+ stateMachines: ModuleManifestStateMachine[];
109
+ }
110
+ interface ModuleManifestBundle {
111
+ manifestVersion: typeof MODULE_MANIFEST_VERSION;
112
+ /** Manifests in the input module order. */
113
+ modules: ModuleManifest[];
114
+ }
115
+ /**
116
+ * A {@link SchemaValidator} that can also export its parameter schema as JSON
117
+ * Schema (for example a Zod 4 schema via `z.toJSONSchema`). Keeps the platform
118
+ * zero-dependency while letting schema-bearing actions flow into manifests.
119
+ */
120
+ interface JsonSchemaExportableValidator extends SchemaValidator {
121
+ toJSONSchema(): Record<string, unknown>;
122
+ }
123
+ declare function isJsonSchemaExportableValidator(schema: SchemaValidator): schema is JsonSchemaExportableValidator;
124
+ /**
125
+ * Export a stable, JSON-serializable manifest of a module's ontology.
126
+ *
127
+ * This is a pure function of the module object: it does not read or mutate the
128
+ * global module/action/policy/state-machine registries, and the module does
129
+ * not need to be registered first. Declaration order is preserved everywhere
130
+ * (nothing is sorted), so the same module object always produces a
131
+ * byte-identical `JSON.stringify` result.
132
+ *
133
+ * The manifest contains definitions only — never raw parameter values,
134
+ * secrets, or runtime data. Function fields are elided (`handler`,
135
+ * policy `evaluate`, transition `guard` → `hasGuard`, dynamic `targetState`,
136
+ * adapter `getInput`).
137
+ */
138
+ declare function exportModuleManifest(module: FabricModule<unknown>): ModuleManifest;
139
+ /**
140
+ * Export manifests for a set of modules, preserving the input order.
141
+ * Like {@link exportModuleManifest}, this is pure and registry-free.
142
+ */
143
+ declare function exportModuleManifestBundle(modules: FabricModule<unknown>[]): ModuleManifestBundle;
144
+
145
+ export { type JsonSchemaExportableValidator, MODULE_MANIFEST_VERSION, type ModuleManifest, type ModuleManifestAction, type ModuleManifestActionStateMachine, type ModuleManifestAdapterStep, type ModuleManifestBundle, type ModuleManifestCodePolicy, type ModuleManifestDataPolicy, type ModuleManifestEventType, type ModuleManifestIdPrefix, type ModuleManifestObjectType, type ModuleManifestPolicy, type ModuleManifestStateMachine, type ModuleManifestStateMachineTransition, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator };
@@ -0,0 +1,10 @@
1
+ export { MODULE_MANIFEST_VERSION, exportModuleManifest, exportModuleManifestBundle, isJsonSchemaExportableValidator } from '../chunk-N72WJ4AU.js';
2
+ import '../chunk-35DD3H55.js';
3
+ import '../chunk-I35B576X.js';
4
+ import '../chunk-6ER62UUN.js';
5
+ import '../chunk-T2JLSZN6.js';
6
+ import '../chunk-4SMPJPJ6.js';
7
+ import '../chunk-O5WVBQ7P.js';
8
+ import '../chunk-4YQOGV7H.js';
9
+ //# sourceMappingURL=index.js.map
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabricorg/platform",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Generic, vertical-agnostic runtime for ontology-based business applications. Provides actions, modules, events, policies, state machines, adapters, displays, projections, privacy, and evidence contracts. Zero runtime dependencies; portable across any database client and any vertical (lending, insurance, healthcare, legal, etc.).",
5
5
  "keywords": [
6
6
  "fabric",
@@ -118,6 +118,16 @@
118
118
  "default": "./dist/ids/index.cjs"
119
119
  }
120
120
  },
121
+ "./manifest": {
122
+ "import": {
123
+ "types": "./dist/manifest/index.d.ts",
124
+ "default": "./dist/manifest/index.js"
125
+ },
126
+ "require": {
127
+ "types": "./dist/manifest/index.d.cts",
128
+ "default": "./dist/manifest/index.cjs"
129
+ }
130
+ },
121
131
  "./modules": {
122
132
  "import": {
123
133
  "types": "./dist/modules/index.d.ts",