@fabricorg/platform 0.8.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 +39 -2
- package/README.md +14 -0
- package/dist/chunk-3OWMPDBD.js +30 -0
- package/dist/chunk-3OWMPDBD.js.map +1 -0
- package/dist/chunk-54EQTOH6.cjs +165 -0
- package/dist/chunk-54EQTOH6.cjs.map +1 -0
- package/dist/chunk-ANPJYXBK.cjs +34 -0
- package/dist/chunk-ANPJYXBK.cjs.map +1 -0
- package/dist/chunk-N72WJ4AU.js +160 -0
- package/dist/chunk-N72WJ4AU.js.map +1 -0
- package/dist/governance/index.cjs +10 -2
- package/dist/governance/index.d.cts +15 -1
- package/dist/governance/index.d.ts +15 -1
- package/dist/governance/index.js +1 -1
- package/dist/index.cjs +40 -15
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/manifest/index.cjs +31 -0
- package/dist/manifest/index.cjs.map +1 -0
- package/dist/manifest/index.d.cts +145 -0
- package/dist/manifest/index.d.ts +145 -0
- package/dist/manifest/index.js +10 -0
- package/dist/manifest/index.js.map +1 -0
- package/package.json +11 -1
- package/dist/chunk-C72F6IRQ.cjs +0 -20
- package/dist/chunk-C72F6IRQ.cjs.map +0 -1
- package/dist/chunk-WGJBT66A.js +0 -18
- package/dist/chunk-WGJBT66A.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
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
|
+
|
|
34
|
+
## 0.9.0
|
|
35
|
+
|
|
36
|
+
- Add versioned runtime-governance evidence shared by TypeScript and .NET hosts.
|
|
37
|
+
- Publish the canonical governance contract generation and validation helpers.
|
|
38
|
+
- Add language-neutral Fabric-family compatibility and conformance contracts.
|
|
39
|
+
|
|
3
40
|
## 0.8.0 — 2026-07-20
|
|
4
41
|
|
|
5
42
|
- Add provider-neutral external mutation governance contracts for footprints, delegated execution
|
|
@@ -40,7 +77,7 @@
|
|
|
40
77
|
|
|
41
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:
|
|
42
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.
|
|
43
|
-
- `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 "
|
|
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.
|
|
44
81
|
- `PolicyDispatchEvidence.code.skipped` / `code.skipReason` — first-class evidence shape for preview skips.
|
|
45
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.
|
|
46
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.
|
|
@@ -62,7 +99,7 @@
|
|
|
62
99
|
- New optional method on `SagaContext`: `awaitSignal?<T>(signalName: string, timeoutMs: number) => Promise<T | null>`.
|
|
63
100
|
- Returns the payload of the first signal received, or `null` if the timeout fires.
|
|
64
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.
|
|
65
|
-
- Signal
|
|
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.
|
|
66
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.
|
|
67
104
|
- **Tests:** 77 → 81 (added 4 tests covering the optional shape, push-vs-poll fallback pattern, and runtime mock implementations).
|
|
68
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,30 @@
|
|
|
1
|
+
// governance/index.ts
|
|
2
|
+
var FABRIC_GOVERNANCE_CONTRACT_VERSION = 1;
|
|
3
|
+
function assertMutationGovernanceContext(value) {
|
|
4
|
+
if (!Number.isInteger(value.footprint.version) || value.footprint.version < 1) {
|
|
5
|
+
throw new Error("Mutation footprint version must be a positive integer");
|
|
6
|
+
}
|
|
7
|
+
for (const entry of value.footprint.resources) {
|
|
8
|
+
if (!entry.resource.provider.trim()) throw new Error("Resource provider is required");
|
|
9
|
+
if (!entry.resource.resourceType.trim()) throw new Error("Resource type is required");
|
|
10
|
+
if (!entry.resource.resourceId.trim()) throw new Error("Resource id is required");
|
|
11
|
+
}
|
|
12
|
+
if (!value.executionPrincipal.principalId.trim()) {
|
|
13
|
+
throw new Error("Execution principal id is required");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function assertGovernanceRuntimeEvidence(value) {
|
|
17
|
+
if (!Number.isInteger(value.governanceContractVersion) || value.governanceContractVersion < 1) {
|
|
18
|
+
throw new Error("Governance contract version must be a positive integer");
|
|
19
|
+
}
|
|
20
|
+
if (!Number.isInteger(value.hostContractVersion) || value.hostContractVersion < 1) {
|
|
21
|
+
throw new Error("Host contract version must be a positive integer");
|
|
22
|
+
}
|
|
23
|
+
if (value.providerBridge && (!value.providerBridge.name.trim() || !value.providerBridge.version.trim())) {
|
|
24
|
+
throw new Error("Provider bridge name and version are required");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { FABRIC_GOVERNANCE_CONTRACT_VERSION, assertGovernanceRuntimeEvidence, assertMutationGovernanceContext };
|
|
29
|
+
//# sourceMappingURL=chunk-3OWMPDBD.js.map
|
|
30
|
+
//# sourceMappingURL=chunk-3OWMPDBD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../governance/index.ts"],"names":[],"mappings":";AAIO,IAAM,kCAAA,GAAqC;AA4G3C,SAAS,gCACf,KAAA,EACO;AACP,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,KAAA,CAAM,SAAA,CAAU,OAAO,CAAA,IAAK,KAAA,CAAM,SAAA,CAAU,OAAA,GAAU,CAAA,EAAG;AAC9E,I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acketReference } from \"../evidence\";\n\n/** Language-neutral governance contract version shared by TypeScript and .NET. */\nexport const FABRIC_GOVERNANCE_CONTRACT_VERSION = 1 as const;\n\nexport type ExternalResourceOperation =\n\t| \"read\"\n\t| \"create\"\n\t| \"update\"\n\t| \"delete\"\n\t| \"execute\"\n\t| \"publish\";\n\n/** Provider-neutral identity for infrastructure touched by a governed mutation. */\nexport interface ExternalResourceRef {\n\tprovider: string;\n\tresourceType: string;\n\tresourceId: string;\n\tdisplayName?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface MutationFootprintEntry {\n\tresource: ExternalResourceRef;\n\toperation: ExternalResourceOperation;\n\tdataClassifications?: string[];\n}\n\n/** Durable declaration of the external effects an invocation is allowed to produce. */\nexport interface MutationFootprint {\n\tversion: number;\n\tresources: MutationFootprintEntry[];\n}\n\n/** Effective execution identity, including the delegation chain that produced it. */\nexport interface ExecutionPrincipal {\n\tprincipalId: string;\n\tprincipalType: ActorType | string;\n\tprovider?: string;\n\tdelegatedBy?: ExecutionPrincipal;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type PolicyObligationStatus = \"pending\" | \"satisfied\" | \"waived\" | \"failed\";\n\nexport interface PolicyObligation {\n\tid: string;\n\ttype: string;\n\tstatus: PolicyObligationStatus;\n\trequired?: boolean;\n\tdescription?: string;\n\tevidenceReferences?: EvidencePacketReference[];\n\tmetadata?: Record<string, unknown>;\n}\n\n/** Audit-safe proof returned by an external execution provider. */\nexport interface ExecutionAttestation {\n\tprovider: string;\n\toperation: string;\n\texternalOperationId?: string;\n\tresource?: ExternalResourceRef;\n\tevidenceReferences: EvidencePacketReference[];\n\tsatisfiesObligations?: string[];\n\tstartedAt: Date | string;\n\tcompletedAt?: Date | string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ReconciliationStatus = \"not_required\" | \"pending\" | \"reconciled\" | \"failed\";\n\nexport interface ExternalReconciliation {\n\tstatus: ReconciliationStatus;\n\tprovider: string;\n\texternalOperationId?: string;\n\tattempt: number;\n\treason?: string;\n\tevidenceReferences?: EvidencePacketReference[];\n\tobservedAt: Date | string;\n}\n\nexport interface MutationGovernanceContext {\n\tfootprint: MutationFootprint;\n\texecutionPrincipal: ExecutionPrincipal;\n}\n\n/** Runtime generations durably attached to every new hosted invocation. */\nexport interface GovernanceRuntimeEvidence {\n\tgovernanceContractVersion: number;\n\thostContractVersion: number;\n\thostPackageVersion?: string;\n\tproviderBridge?: {\n\t\tname: string;\n\t\tversion: string;\n\t};\n\tpolicyRulesetVersion?: string;\n}\n\nexport interface MutationGovernanceResolutionInput {\n\tactionInvocationId: string;\n\tactionId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tactorId: string;\n\tactorType: ActorType;\n\tparameters: unknown;\n}\n\nexport type MutationGovernanceResolver = (\n\tinput: MutationGovernanceResolutionInput,\n) => Promise<MutationGovernanceContext> | MutationGovernanceContext;\n\nexport function assertMutationGovernanceContext(\n\tvalue: MutationGovernanceContext,\n): void {\n\tif (!Number.isInteger(value.footprint.version) || value.footprint.version < 1) {\n\t\tthrow new Error(\"Mutation footprint version must be a positive integer\");\n\t}\n\tfor (const entry of value.footprint.resources) {\n\t\tif (!entry.resource.provider.trim()) throw new Error(\"Resource provider is required\");\n\t\tif (!entry.resource.resourceType.trim()) throw new Error(\"Resource type is required\");\n\t\tif (!entry.resource.resourceId.trim()) throw new Error(\"Resource id is required\");\n\t}\n\tif (!value.executionPrincipal.principalId.trim()) {\n\t\tthrow new Error(\"Execution principal id is required\");\n\t}\n}\n\nexport function assertGovernanceRuntimeEvidence(value: GovernanceRuntimeEvidence): void {\n\tif (!Number.isInteger(value.governanceContractVersion) || value.governanceContractVersion < 1) {\n\t\tthrow new Error(\"Governance contract version must be a positive integer\");\n\t}\n\tif (!Number.isInteger(value.hostContractVersion) || value.hostContractVersion < 1) {\n\t\tthrow new Error(\"Host contract version must be a positive integer\");\n\t}\n\tif (value.providerBridge && (!value.providerBridge.name.trim() || !value.providerBridge.version.trim())) {\n\t\tthrow new Error(\"Provider bridge name and version are required\");\n\t}\n}\n"]}
|
|
@@ -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-54EQT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IAAiB,EAAC,EACvC,GAAA,CAAI,kBAAkB,CAAA,CACtB,MAAA,CAAO,CAAC,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-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,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// governance/index.ts
|
|
4
|
+
var FABRIC_GOVERNANCE_CONTRACT_VERSION = 1;
|
|
5
|
+
function assertMutationGovernanceContext(value) {
|
|
6
|
+
if (!Number.isInteger(value.footprint.version) || value.footprint.version < 1) {
|
|
7
|
+
throw new Error("Mutation footprint version must be a positive integer");
|
|
8
|
+
}
|
|
9
|
+
for (const entry of value.footprint.resources) {
|
|
10
|
+
if (!entry.resource.provider.trim()) throw new Error("Resource provider is required");
|
|
11
|
+
if (!entry.resource.resourceType.trim()) throw new Error("Resource type is required");
|
|
12
|
+
if (!entry.resource.resourceId.trim()) throw new Error("Resource id is required");
|
|
13
|
+
}
|
|
14
|
+
if (!value.executionPrincipal.principalId.trim()) {
|
|
15
|
+
throw new Error("Execution principal id is required");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function assertGovernanceRuntimeEvidence(value) {
|
|
19
|
+
if (!Number.isInteger(value.governanceContractVersion) || value.governanceContractVersion < 1) {
|
|
20
|
+
throw new Error("Governance contract version must be a positive integer");
|
|
21
|
+
}
|
|
22
|
+
if (!Number.isInteger(value.hostContractVersion) || value.hostContractVersion < 1) {
|
|
23
|
+
throw new Error("Host contract version must be a positive integer");
|
|
24
|
+
}
|
|
25
|
+
if (value.providerBridge && (!value.providerBridge.name.trim() || !value.providerBridge.version.trim())) {
|
|
26
|
+
throw new Error("Provider bridge name and version are required");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.FABRIC_GOVERNANCE_CONTRACT_VERSION = FABRIC_GOVERNANCE_CONTRACT_VERSION;
|
|
31
|
+
exports.assertGovernanceRuntimeEvidence = assertGovernanceRuntimeEvidence;
|
|
32
|
+
exports.assertMutationGovernanceContext = assertMutationGovernanceContext;
|
|
33
|
+
//# sourceMappingURL=chunk-ANPJYXBK.cjs.map
|
|
34
|
+
//# sourceMappingURL=chunk-ANPJYXBK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../governance/index.ts"],"names":[],"mappings":";;;AAIO,IAAM,kCAAA,GAAqC;AA4G3C,SAAS,gCACf,KAAA,EACO;AACP,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,KAAA,CAAM,SAAA,CAAU,OAAO,CAAA,IAAK,KAAA,CAAM,SAAA,CAAU,OAAA,GAAU,CAAA,EAAG;AAC9E,IAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,EACxE;AACA,EAAA,KAAA,MAAW,KAAA,IAAS,KAAA,CAAM,SAAA,CAAU,SAAA,EAAW;AAC9C,IAAA,IAAI,CAAC,MAAM,QAAA,CAAS,QAAA,CAAS,MAAK,EAAG,MAAM,IAAI,KAAA,CAAM,+BAA+B,CAAA;AACpF,IAAA,IAAI,CAAC,MAAM,QAAA,CAAS,YAAA,CAAa,MAAK,EAAG,MAAM,IAAI,KAAA,CAAM,2BAA2B,CAAA;AACpF,IAAA,IAAI,CAAC,MAAM,QAAA,CAAS,UAAA,CAAW,MAAK,EAAG,MAAM,IAAI,KAAA,CAAM,yBAAyB,CAAA;AAAA,EACjF;AACA,EAAA,IAAI,CAAC,KAAA,CAAM,kBAAA,CAAmB,WAAA,CAAY,MAAK,EAAG;AACjD,IAAA,MAAM,IAAI,MAAM,oCAAoC,CAAA;AAAA,EACrD;AACD;AAEO,SAAS,gCAAgC,KAAA,EAAwC;AACvF,EAAA,IAAI,CAAC,OAAO,SAAA,CAAU,KAAA,CAAM,yBAAyB,CAAA,IAAK,KAAA,CAAM,4BAA4B,CAAA,EAAG;AAC9F,IAAA,MAAM,IAAI,MAAM,wDAAwD,CAAA;AAAA,EACzE;AACA,EAAA,IAAI,CAAC,OAAO,SAAA,CAAU,KAAA,CAAM,mBAAmB,CAAA,IAAK,KAAA,CAAM,sBAAsB,CAAA,EAAG;AAClF,IAAA,MAAM,IAAI,MAAM,kDAAkD,CAAA;AAAA,EACnE;AACA,EAAA,IAAI,KAAA,CAAM,cAAA,KAAmB,CAAC,KAAA,CAAM,cAAA,CAAe,IAAA,CAAK,IAAA,EAAK,IAAK,CAAC,KAAA,CAAM,cAAA,CAAe,OAAA,CAAQ,MAAK,CAAA,EAAI;AACxG,IAAA,MAAM,IAAI,MAAM,+CAA+C,CAAA;AAAA,EAChE;AACD","file":"chunk-ANPJYXBK.cjs","sourcesContent":["import type { ActorType } from \"../actions\";\nimport type { EvidencePacketReference } from \"../evidence\";\n\n/** Language-neutral governance contract version shared by TypeScript and .NET. */\nexport const FABRIC_GOVERNANCE_CONTRACT_VERSION = 1 as const;\n\nexport type ExternalResourceOperation =\n\t| \"read\"\n\t| \"create\"\n\t| \"update\"\n\t| \"delete\"\n\t| \"execute\"\n\t| \"publish\";\n\n/** Provider-neutral identity for infrastructure touched by a governed mutation. */\nexport interface ExternalResourceRef {\n\tprovider: string;\n\tresourceType: string;\n\tresourceId: string;\n\tdisplayName?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface MutationFootprintEntry {\n\tresource: ExternalResourceRef;\n\toperation: ExternalResourceOperation;\n\tdataClassifications?: string[];\n}\n\n/** Durable declaration of the external effects an invocation is allowed to produce. */\nexport interface MutationFootprint {\n\tversion: number;\n\tresources: MutationFootprintEntry[];\n}\n\n/** Effective execution identity, including the delegation chain that produced it. */\nexport interface ExecutionPrincipal {\n\tprincipalId: string;\n\tprincipalType: ActorType | string;\n\tprovider?: string;\n\tdelegatedBy?: ExecutionPrincipal;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type PolicyObligationStatus = \"pending\" | \"satisfied\" | \"waived\" | \"failed\";\n\nexport interface PolicyObligation {\n\tid: string;\n\ttype: string;\n\tstatus: PolicyObligationStatus;\n\trequired?: boolean;\n\tdescription?: string;\n\tevidenceReferences?: EvidencePacketReference[];\n\tmetadata?: Record<string, unknown>;\n}\n\n/** Audit-safe proof returned by an external execution provider. */\nexport interface ExecutionAttestation {\n\tprovider: string;\n\toperation: string;\n\texternalOperationId?: string;\n\tresource?: ExternalResourceRef;\n\tevidenceReferences: EvidencePacketReference[];\n\tsatisfiesObligations?: string[];\n\tstartedAt: Date | string;\n\tcompletedAt?: Date | string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport type ReconciliationStatus = \"not_required\" | \"pending\" | \"reconciled\" | \"failed\";\n\nexport interface ExternalReconciliation {\n\tstatus: ReconciliationStatus;\n\tprovider: string;\n\texternalOperationId?: string;\n\tattempt: number;\n\treason?: string;\n\tevidenceReferences?: EvidencePacketReference[];\n\tobservedAt: Date | string;\n}\n\nexport interface MutationGovernanceContext {\n\tfootprint: MutationFootprint;\n\texecutionPrincipal: ExecutionPrincipal;\n}\n\n/** Runtime generations durably attached to every new hosted invocation. */\nexport interface GovernanceRuntimeEvidence {\n\tgovernanceContractVersion: number;\n\thostContractVersion: number;\n\thostPackageVersion?: string;\n\tproviderBridge?: {\n\t\tname: string;\n\t\tversion: string;\n\t};\n\tpolicyRulesetVersion?: string;\n}\n\nexport interface MutationGovernanceResolutionInput {\n\tactionInvocationId: string;\n\tactionId: string;\n\ttenantId: string;\n\tspaceId: string;\n\tactorId: string;\n\tactorType: ActorType;\n\tparameters: unknown;\n}\n\nexport type MutationGovernanceResolver = (\n\tinput: MutationGovernanceResolutionInput,\n) => Promise<MutationGovernanceContext> | MutationGovernanceContext;\n\nexport function assertMutationGovernanceContext(\n\tvalue: MutationGovernanceContext,\n): void {\n\tif (!Number.isInteger(value.footprint.version) || value.footprint.version < 1) {\n\t\tthrow new Error(\"Mutation footprint version must be a positive integer\");\n\t}\n\tfor (const entry of value.footprint.resources) {\n\t\tif (!entry.resource.provider.trim()) throw new Error(\"Resource provider is required\");\n\t\tif (!entry.resource.resourceType.trim()) throw new Error(\"Resource type is required\");\n\t\tif (!entry.resource.resourceId.trim()) throw new Error(\"Resource id is required\");\n\t}\n\tif (!value.executionPrincipal.principalId.trim()) {\n\t\tthrow new Error(\"Execution principal id is required\");\n\t}\n}\n\nexport function assertGovernanceRuntimeEvidence(value: GovernanceRuntimeEvidence): void {\n\tif (!Number.isInteger(value.governanceContractVersion) || value.governanceContractVersion < 1) {\n\t\tthrow new Error(\"Governance contract version must be a positive integer\");\n\t}\n\tif (!Number.isInteger(value.hostContractVersion) || value.hostContractVersion < 1) {\n\t\tthrow new Error(\"Host contract version must be a positive integer\");\n\t}\n\tif (value.providerBridge && (!value.providerBridge.name.trim() || !value.providerBridge.version.trim())) {\n\t\tthrow new Error(\"Provider bridge name and version are required\");\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.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../manifest/index.ts"],"names":[],"mappings":";;;AAwBO,IAAM,uBAAA,GAA0B;AA+HhC,SAAS,gCACf,MAAA,EAC0C;AAC1C,EAAA,OACC,OAAQ,OAAkD,YAAA,KAAiB,UAAA;AAE7E;AAEA,SAAS,SAAS,KAAA,EAAkD;AACnE,EAAA,OAAO,KAAA,KAAU,QAAQ,OAAO,KAAA,KAAU,YAAY,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC3E;AAEA,SAAS,iBAAiB,UAAA,EAAqD;AAC9E,EAAA,MAAM,SAAA,GAAY,6BAA6B,UAAU,CAAA;AACzD,EAAA,IAAI,OAAO,eAAe,QAAA,EAAU;AACnC,IAAA,OAAO,EAAE,SAAA,EAAU;AAAA,EACpB;AACA,EAAA,MAAM,UAAA,GAA+B,EAAE,SAAA,EAAU;AACjD,EAAA,IAAI,UAAA,CAAW,OAAA,KAAY,MAAA,EAAW,UAAA,CAAW,UAAU,UAAA,CAAW,OAAA;AACtE,EAAA,IAAI,UAAA,CAAW,QAAA,KA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A,IAAc,EAAC,EAAG,GAAA,CAAI,CAAC,YAAA,MAAkB;AAAA,MAC5D,QAAQ,YAAA,CAAa,MAAA;AAAA,MACrB,MAAM,YAAA,CAAa;AAAA,KACpB,CAAE,CAAA;AAAA,IACF,aAAa,MAAA,CAAO,UAAA,IAAc,EAAC,EAAG,IAAI,eAAe,CAAA;AAAA,IACzD,UAAU,MAAA,CAAO,OAAA,IAAW,EAAC,EAAG,IAAI,YAAY,CAAA;AAAA,IAChD,QAAA,EAAA,CAAW,MAAA,CAAO,QAAA,IAAY,EAAC,EAC7B,GAAA,CAAI,YAAY,CAAA,CAChB,MAAA,CAAO,CAAC,MAAA,KAA2C,MAAA,KAAW,MAAS,CAAA;AAAA,IACzE,aAAA,EAAA,CAAgB,MAAA,CAAO,aAAA,IAAiB,EAAC,EACvC,GAAA,CAAI,kBAAkB,CAAA,CACtB,MAAA,CAAO,CAAC,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"]}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkANPJYXBK_cjs = require('../chunk-ANPJYXBK.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
Object.defineProperty(exports, "FABRIC_GOVERNANCE_CONTRACT_VERSION", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkANPJYXBK_cjs.FABRIC_GOVERNANCE_CONTRACT_VERSION; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "assertGovernanceRuntimeEvidence", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkANPJYXBK_cjs.assertGovernanceRuntimeEvidence; }
|
|
14
|
+
});
|
|
7
15
|
Object.defineProperty(exports, "assertMutationGovernanceContext", {
|
|
8
16
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkANPJYXBK_cjs.assertMutationGovernanceContext; }
|
|
10
18
|
});
|
|
11
19
|
//# sourceMappingURL=index.cjs.map
|
|
12
20
|
//# sourceMappingURL=index.cjs.map
|