@fabricorg/compiler 0.2.0 → 1.0.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 +29 -0
- package/README.md +4 -0
- package/dist/index.cjs +119 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +109 -37
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @fabricorg/compiler
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Deliver Phase 1 correctness and contracts: payload-bound idempotency with staged enforcement,
|
|
8
|
+
capture/replay authority evidence, bounded invocation provenance, capability execution and view usage
|
|
9
|
+
semantics, event-schema compatibility classification, and deterministic conformance plans.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @fabricorg/platform@0.12.0
|
|
15
|
+
|
|
16
|
+
## 0.2.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Close final uplift audit gaps: align Host 2.x documentation and migration evidence, surface every
|
|
21
|
+
compiler/generator API to LLM consumers, make memory outbox egress directly usable, sanitize relay
|
|
22
|
+
failures, validate complete archetype state maps, support recursive JSON Schema generation, reject
|
|
23
|
+
cross-platform path traversal, synchronize artifact version stamps, and include package licenses.
|
|
24
|
+
- Classify action audit-event, idempotency, mutation, authorization, policy, capability, dependency,
|
|
25
|
+
subject, and ID-prefix changes instead of reporting them as compatible.
|
|
26
|
+
- Consume Platform as a peer dependency so applications keep a single copy of the public contracts.
|
|
27
|
+
- Fail closed when required invariant references do not resolve, with explicit certification-profile
|
|
28
|
+
evidence for Host-adapter and application-owned enforcement.
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
- @fabricorg/platform@0.11.1
|
|
31
|
+
|
|
3
32
|
## 0.2.0
|
|
4
33
|
|
|
5
34
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -4,4 +4,8 @@ Build-time compiler for versioned Fabric module manifests. It normalizes v1/v2 i
|
|
|
4
4
|
stable namespace-ordered IR and SHA-256 manifest digest, runs optional conformance adapters, classifies
|
|
5
5
|
semantic compatibility, and invokes deterministic generator targets.
|
|
6
6
|
|
|
7
|
+
Required invariants fail closed during compilation when their JSON Schema keyword, state machine,
|
|
8
|
+
or policy reference does not resolve. Host-adapter and application-owned evidence is resolved by an
|
|
9
|
+
explicit `CertificationProfile`; declaring application ownership is never treated as proof.
|
|
10
|
+
|
|
7
11
|
It does not load live modules, execute handlers, or run inside `@fabricorg/platform`.
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// index.ts
|
|
@@ -29,8 +39,9 @@ __export(index_exports, {
|
|
|
29
39
|
});
|
|
30
40
|
module.exports = __toCommonJS(index_exports);
|
|
31
41
|
var import_node_crypto = require("crypto");
|
|
42
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
32
43
|
var import_platform = require("@fabricorg/platform");
|
|
33
|
-
var FABRIC_COMPILER_VERSION = "
|
|
44
|
+
var FABRIC_COMPILER_VERSION = "1.0.0";
|
|
34
45
|
var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
35
46
|
function stableStringify(value) {
|
|
36
47
|
return JSON.stringify(sortJson(value));
|
|
@@ -52,7 +63,7 @@ function compileManifestBundle(input, options = {}) {
|
|
|
52
63
|
namespaces.add(module2.namespace);
|
|
53
64
|
}
|
|
54
65
|
const modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));
|
|
55
|
-
assertCompilerManifests(modules);
|
|
66
|
+
assertCompilerManifests(modules, options.certificationProfiles ?? []);
|
|
56
67
|
const canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });
|
|
57
68
|
return {
|
|
58
69
|
compilerVersion: FABRIC_COMPILER_VERSION,
|
|
@@ -64,7 +75,9 @@ function compileManifestBundle(input, options = {}) {
|
|
|
64
75
|
)
|
|
65
76
|
};
|
|
66
77
|
}
|
|
67
|
-
function assertCompilerManifests(modules) {
|
|
78
|
+
function assertCompilerManifests(modules, certificationProfiles) {
|
|
79
|
+
const profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));
|
|
80
|
+
if (profiles.size !== certificationProfiles.length) throw new Error("Certification profile IDs must be unique.");
|
|
68
81
|
for (const module2 of modules) {
|
|
69
82
|
if (!module2 || !/^[a-z][a-z0-9-]*$/.test(module2.namespace) || !Array.isArray(module2.objectTypes) || !Array.isArray(module2.actions) || !Array.isArray(module2.views)) throw new Error("Compiler input is not a normalized module manifest.");
|
|
70
83
|
}
|
|
@@ -74,15 +87,24 @@ function assertCompilerManifests(modules) {
|
|
|
74
87
|
if (!module2.capability.displayName?.trim() || !module2.capability.description?.trim()) throw new Error(`Module "${module2.namespace}" capability requires displayName and description.`);
|
|
75
88
|
if (!["experimental", "beta", "stable", "deprecated"].includes(module2.capability.stability)) throw new Error(`Module "${module2.namespace}" capability has invalid stability.`);
|
|
76
89
|
}
|
|
90
|
+
const certification = module2.capability?.certification;
|
|
91
|
+
const profile = certification?.required ? profiles.get(certification.profile) : void 0;
|
|
77
92
|
for (const objectType of module2.objectTypes) {
|
|
78
93
|
if (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type "${objectType.type}" in compiler input.`);
|
|
79
94
|
if (objectType.schema) (0, import_platform.assertPortableJsonSchema)(objectType.schema, `${module2.namespace}.${objectType.type}`);
|
|
80
95
|
for (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module2.namespace}.${objectType.type}.${relation.name} targets missing object type "${relation.target}".`);
|
|
96
|
+
for (const invariant of objectType.invariants ?? []) {
|
|
97
|
+
if (invariant.required && !resolvesRequiredInvariant(module2, objectType, invariant, profile)) {
|
|
98
|
+
throw new Error(`Required invariant "${module2.namespace}.${objectType.type}.${invariant.id}" has no resolvable enforcement evidence under certification profile "${certification?.profile ?? "none"}".`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
81
101
|
}
|
|
82
102
|
for (const view of module2.views) {
|
|
83
103
|
if (!view.name.startsWith(`${module2.namespace}/`)) throw new Error(`View "${view.name}" must use module namespace "${module2.namespace}/".`);
|
|
84
104
|
(0, import_platform.assertPortableJsonSchema)(view.shape, `View ${view.name}@${view.version}`);
|
|
105
|
+
if (view.usage?.collection?.filterSchema) (0, import_platform.assertPortableJsonSchema)(view.usage.collection.filterSchema, `View ${view.name}@${view.version} filter`);
|
|
85
106
|
}
|
|
107
|
+
for (const eventType of module2.eventTypes) if (eventType.schema) (0, import_platform.assertPortableJsonSchema)(eventType.schema, `Event ${eventType.eventType}@${eventType.schemaVersion}`);
|
|
86
108
|
for (const action of module2.actions) {
|
|
87
109
|
if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module2.namespace}.`) || !["atomic", "saga"].includes(action.kind) || typeof action.idempotent !== "boolean" || typeof action.mutatesDomain !== "boolean" || !Array.isArray(action.emitsEvents)) throw new Error(`Action "${action.actionId}" is not a normalized manifest action.`);
|
|
88
110
|
if (action.parameterSchema) (0, import_platform.assertPortableJsonSchema)(action.parameterSchema, `Action ${action.actionId} parameters`);
|
|
@@ -90,94 +112,154 @@ function assertCompilerManifests(modules) {
|
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
}
|
|
115
|
+
function resolvesRequiredInvariant(module2, objectType, invariant, profile) {
|
|
116
|
+
const reference = invariant.enforcementRef?.trim();
|
|
117
|
+
if (!reference) return false;
|
|
118
|
+
if (invariant.enforcement === "json-schema") {
|
|
119
|
+
const requiredMatch = /^#\/required\/([^/]+)$/.exec(reference);
|
|
120
|
+
if (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]));
|
|
121
|
+
const propertyMatch = /^#\/properties\/([^/]+)$/.exec(reference);
|
|
122
|
+
if (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1])]);
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
if (invariant.enforcement === "state-machine") return module2.stateMachines.some((machine) => machine.entityType === reference);
|
|
126
|
+
if (invariant.enforcement === "policy") return module2.policies.some((policy) => policy.policyId === reference);
|
|
127
|
+
return profile?.resolveInvariant?.({ module: module2, objectType, invariant }) === true;
|
|
128
|
+
}
|
|
129
|
+
function decodeJsonPointerToken(token) {
|
|
130
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
131
|
+
}
|
|
93
132
|
var severityRank = { compatible: 0, potentially_breaking: 1, breaking: 2 };
|
|
94
133
|
function diffModuleManifests(before, after) {
|
|
95
134
|
if (before.namespace !== after.namespace) {
|
|
96
135
|
return report([{ severity: "breaking", path: "namespace", code: "module_renamed", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);
|
|
97
136
|
}
|
|
98
137
|
const changes = [];
|
|
99
|
-
|
|
100
|
-
|
|
138
|
+
if (before.version !== after.version) changes.push({ severity: "potentially_breaking", path: "version", code: "module_version_changed", message: "Module version changed." });
|
|
139
|
+
if (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: "potentially_breaking", path: "capability", code: "capability_changed", message: "Capability roles, stability, deprecation, extension slots, or certification metadata changed." });
|
|
140
|
+
diffStringList(before.subjectTypes, after.subjectTypes, "subjectTypes", changes);
|
|
141
|
+
diffNamed(before.idPrefixes, after.idPrefixes, "idPrefixes", "prefix", changes, (oldValue, newValue, path2) => {
|
|
142
|
+
if (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: "breaking", path: path2, code: "id_prefix_changed", message: "ID prefix ownership changed." });
|
|
143
|
+
});
|
|
144
|
+
if (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: "potentially_breaking", path: "dependencies", code: "module_dependencies_changed", message: "Module dependencies changed." });
|
|
145
|
+
if (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: "potentially_breaking", path: "policies", code: "module_policies_changed", message: "Module policy definitions changed." });
|
|
146
|
+
diffNamed(before.objectTypes, after.objectTypes, "objectTypes", "type", changes, (oldValue, newValue, path2) => {
|
|
147
|
+
diffSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
101
148
|
const oldArchetype = oldValue.semantics?.["fabric.archetype"];
|
|
102
149
|
const newArchetype = newValue.semantics?.["fabric.archetype"];
|
|
103
|
-
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${
|
|
104
|
-
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${
|
|
105
|
-
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${
|
|
150
|
+
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_removed", message: "Archetype certification metadata was removed." });
|
|
151
|
+
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_mapping_changed", message: "Archetype identity, version, or state mapping changed." });
|
|
152
|
+
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path2}.relations`, "name", changes, (oldRelation, newRelation, relationPath) => {
|
|
106
153
|
if (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: "breaking", path: `${relationPath}.cardinality`, code: "relation_cardinality_changed", message: "Relation cardinality changed." });
|
|
107
154
|
if (oldRelation.target !== newRelation.target) changes.push({ severity: "breaking", path: `${relationPath}.target`, code: "relation_target_changed", message: "Relation target changed." });
|
|
108
155
|
if (!oldRelation.required && newRelation.required) changes.push({ severity: "breaking", path: `${relationPath}.required`, code: "relation_became_required", message: "Optional relation became required." });
|
|
109
156
|
if (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: "breaking", path: `${relationPath}.semantics`, code: "relation_ownership_changed", message: "Relation ownership semantics changed." });
|
|
110
157
|
if (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: "breaking", path: `${relationPath}.onTargetDelete`, code: "relation_delete_behavior_changed", message: "Relation deletion behavior changed." });
|
|
111
158
|
});
|
|
112
|
-
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${
|
|
159
|
+
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path2}.invariants`, "id", changes, (oldInvariant, newInvariant, invariantPath) => {
|
|
113
160
|
if (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: "potentially_breaking", path: invariantPath, code: "invariant_enforcement_changed", message: "Invariant enforcement ownership or reference changed." });
|
|
114
161
|
if (!oldInvariant.required && newInvariant.required) changes.push({ severity: "breaking", path: `${invariantPath}.required`, code: "invariant_became_required", message: "Invariant became required." });
|
|
115
162
|
});
|
|
116
163
|
});
|
|
117
|
-
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue,
|
|
118
|
-
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${
|
|
119
|
-
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${
|
|
164
|
+
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue, path2) => {
|
|
165
|
+
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${path2}.parameterSchema`, changes);
|
|
166
|
+
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${path2}.resultSchema`, changes);
|
|
167
|
+
if (stableStringify(oldValue.execution) !== stableStringify(newValue.execution)) changes.push({ severity: oldValue.execution ? "breaking" : "potentially_breaking", path: `${path2}.execution`, code: "action_execution_changed", message: "Action execution semantics changed and hosts or offline consumers must be reviewed." });
|
|
168
|
+
for (const field of ["version", "kind", "idempotent", "mutatesDomain", "eventPhase"]) {
|
|
169
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });
|
|
170
|
+
}
|
|
171
|
+
const oldEvents = new Set(oldValue.emitsEvents);
|
|
172
|
+
const newEvents = new Set(newValue.emitsEvents);
|
|
173
|
+
for (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: "breaking", path: `${path2}.emitsEvents.${event}`, code: "action_event_removed", message: `Declared action event "${event}" was removed.` });
|
|
174
|
+
for (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: "compatible", path: `${path2}.emitsEvents.${event}`, code: "action_event_added", message: `Declared action event "${event}" was added.` });
|
|
175
|
+
for (const field of ["policies", "requiredRoles", "requiredPermissions", "stateMachine", "adapterSteps"]) {
|
|
176
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "potentially_breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });
|
|
177
|
+
}
|
|
120
178
|
});
|
|
121
|
-
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue,
|
|
122
|
-
|
|
123
|
-
|
|
179
|
+
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue, path2) => {
|
|
180
|
+
diffEventSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
181
|
+
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${path2}.schemaVersion`, code: "event_version_decreased", message: "Event schema version decreased." });
|
|
182
|
+
else if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: "potentially_breaking", path: `${path2}.schemaVersion`, code: "event_version_changed", message: "Event schema version changed; old consumers require compatibility evidence." });
|
|
124
183
|
});
|
|
125
184
|
const oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
126
185
|
const newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
127
186
|
for (const [key, oldView] of oldViews) {
|
|
128
187
|
const newView = newViews.get(key);
|
|
129
188
|
if (!newView) changes.push({ severity: "breaking", path: `views.${key}`, code: "view_version_removed", message: `View contract "${key}" was removed.` });
|
|
130
|
-
else
|
|
189
|
+
else {
|
|
190
|
+
diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);
|
|
191
|
+
if (stableStringify(oldView.usage) !== stableStringify(newView.usage)) changes.push({ severity: "potentially_breaking", path: `views.${key}.usage`, code: "view_usage_changed", message: "View usage semantics changed and generated consumers require review." });
|
|
192
|
+
}
|
|
131
193
|
}
|
|
132
194
|
for (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: "compatible", path: `views.${key}`, code: "view_version_added", message: `View contract "${key}" was added.` });
|
|
133
|
-
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue,
|
|
195
|
+
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue, path2) => {
|
|
134
196
|
const newStates = new Set(newValue.states.map((state) => state.id));
|
|
135
|
-
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${
|
|
197
|
+
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${path2}.states.${state.id}`, code: "state_removed", message: `State "${state.id}" was removed.` });
|
|
136
198
|
const transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));
|
|
137
|
-
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${
|
|
199
|
+
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${path2}.transitions.${transition.from}->${transition.to}`, code: "transition_removed", message: "A state transition was removed or remapped." });
|
|
138
200
|
});
|
|
139
201
|
return report(changes);
|
|
140
202
|
}
|
|
141
|
-
function
|
|
203
|
+
function diffEventSchema(before, after, path2, changes) {
|
|
204
|
+
const start = changes.length;
|
|
205
|
+
diffSchema(before, after, path2, changes);
|
|
206
|
+
for (let index = start; index < changes.length; index += 1) {
|
|
207
|
+
const change = changes[index];
|
|
208
|
+
change.code = `event_${change.code}`;
|
|
209
|
+
change.message = `Event schema: ${change.message}`;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function diffStringList(before, after, path2, changes) {
|
|
213
|
+
const oldValues = new Set(before);
|
|
214
|
+
const newValues = new Set(after);
|
|
215
|
+
for (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: "breaking", path: `${path2}.${value}`, code: `${path2}_removed`, message: `Public ${path2} value "${value}" was removed.` });
|
|
216
|
+
for (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: "compatible", path: `${path2}.${value}`, code: `${path2}_added`, message: `Public ${path2} value "${value}" was added.` });
|
|
217
|
+
}
|
|
218
|
+
function diffNamed(before, after, path2, key, changes, compare) {
|
|
142
219
|
const oldMap = new Map(before.map((value) => [String(value[key]), value]));
|
|
143
220
|
const newMap = new Map(after.map((value) => [String(value[key]), value]));
|
|
144
221
|
for (const [name, value] of oldMap) {
|
|
145
222
|
const next = newMap.get(name);
|
|
146
|
-
if (!next) changes.push({ severity: "breaking", path: `${
|
|
147
|
-
else compare(value, next, `${
|
|
223
|
+
if (!next) changes.push({ severity: "breaking", path: `${path2}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} "${name}" was removed.` });
|
|
224
|
+
else compare(value, next, `${path2}.${name}`);
|
|
148
225
|
}
|
|
149
|
-
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${
|
|
226
|
+
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${path2}.${name}`, code: `${String(key)}_added`, message: `${String(key)} "${name}" was added.` });
|
|
150
227
|
}
|
|
151
|
-
function diffSchema(before, after,
|
|
228
|
+
function diffSchema(before, after, path2, changes) {
|
|
152
229
|
const changeCount = changes.length;
|
|
153
230
|
if (!before && after) {
|
|
154
|
-
changes.push({ severity: "potentially_breaking", path, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
231
|
+
changes.push({ severity: "potentially_breaking", path: path2, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
155
232
|
return;
|
|
156
233
|
}
|
|
157
234
|
if (before && !after) {
|
|
158
|
-
changes.push({ severity: "breaking", path, code: "schema_removed", message: "An existing schema was removed." });
|
|
235
|
+
changes.push({ severity: "breaking", path: path2, code: "schema_removed", message: "An existing schema was removed." });
|
|
159
236
|
return;
|
|
160
237
|
}
|
|
161
238
|
if (!before || !after) return;
|
|
162
239
|
const oldRequired = new Set(before.required ?? []);
|
|
163
|
-
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${
|
|
240
|
+
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${path2}.required.${required}`, code: "required_property_added", message: `Required property "${required}" was added.` });
|
|
164
241
|
const oldProperties = before.properties ?? {};
|
|
165
242
|
const newProperties = after.properties ?? {};
|
|
166
|
-
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${
|
|
167
|
-
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${
|
|
243
|
+
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${path2}.properties.${property}`, code: "schema_property_removed", message: `Schema property "${property}" was removed.` });
|
|
244
|
+
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${path2}.properties.${property}`, code: "schema_property_added", message: `Schema property "${property}" was added.` });
|
|
168
245
|
for (const property of Object.keys(oldProperties)) {
|
|
169
|
-
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${
|
|
246
|
+
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path2}.properties.${property}`, changes);
|
|
170
247
|
}
|
|
171
|
-
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${
|
|
172
|
-
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${
|
|
248
|
+
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${path2}.additionalProperties`, code: "additional_properties_forbidden", message: "Schema now rejects undeclared properties." });
|
|
249
|
+
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path2}.items`, changes);
|
|
173
250
|
for (const keyword of ["minimum", "maximum", "minLength", "maxLength", "pattern"]) {
|
|
174
|
-
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${
|
|
251
|
+
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${path2}.${keyword}`, code: "schema_constraint_changed", message: `Schema constraint "${keyword}" changed.` });
|
|
252
|
+
}
|
|
253
|
+
if (stableStringify(before.type) !== stableStringify(after.type)) {
|
|
254
|
+
const oldTypes = new Set(Array.isArray(before.type) ? before.type : before.type ? [before.type] : []);
|
|
255
|
+
const newTypes = new Set(Array.isArray(after.type) ? after.type : after.type ? [after.type] : []);
|
|
256
|
+
const widened = oldTypes.size > 0 && [...oldTypes].every((type) => newTypes.has(type));
|
|
257
|
+
changes.push({ severity: "breaking", path: `${path2}.type`, code: widened ? "schema_type_widened" : "schema_type_narrowed", message: widened ? "Schema type widened; generated consumers may receive a new value type." : "Schema type no longer accepts every prior type." });
|
|
175
258
|
}
|
|
176
|
-
if (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: "breaking", path: `${path}.type`, code: "schema_type_changed", message: "Schema type changed." });
|
|
177
259
|
if (before.enum && after.enum && before.enum.some((value) => !after.enum.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {
|
|
178
|
-
changes.push({ severity: "breaking", path: `${
|
|
260
|
+
changes.push({ severity: "breaking", path: `${path2}.enum`, code: "schema_enum_narrowed", message: "Schema enum no longer accepts a previously valid value." });
|
|
179
261
|
}
|
|
180
|
-
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
262
|
+
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path: path2, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
181
263
|
}
|
|
182
264
|
function report(changes) {
|
|
183
265
|
const highestSeverity = changes.reduce((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, "compatible");
|
|
@@ -187,7 +269,7 @@ async function runGenerator(target, ir) {
|
|
|
187
269
|
const files = await target.generate(ir);
|
|
188
270
|
const paths = /* @__PURE__ */ new Set();
|
|
189
271
|
return [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {
|
|
190
|
-
if (!file.path || file.path.
|
|
272
|
+
if (!file.path || import_node_path.default.isAbsolute(file.path) || import_node_path.default.win32.isAbsolute(file.path) || file.path.includes("\\") || file.path.split("/").includes("..")) throw new Error(`Generator "${target.name}" returned unsafe path "${file.path}".`);
|
|
191
273
|
if (paths.has(file.path)) throw new Error(`Generator "${target.name}" returned duplicate path "${file.path}".`);
|
|
192
274
|
paths.add(file.path);
|
|
193
275
|
return { path: file.path, content: file.content.endsWith("\n") ? file.content : `${file.content}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"0.1.0\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[]): void {\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t}\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: \"breaking\", path: `${path}.type`, code: \"schema_type_changed\", message: \"Schema type changed.\" });\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || file.path.startsWith(\"/\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,MAAM,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS;AACrG,QAAI,CAAC,KAAK,QAAQ,KAAK,KAAK,WAAW,GAAG,KAAK,KAAK,KAAK,MAAM,GAAG,EAAE,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,2BAA2B,KAAK,IAAI,IAAI;AACrK,QAAI,MAAM,IAAI,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,8BAA8B,KAAK,IAAI,IAAI;AAC9G,UAAM,IAAI,KAAK,IAAI;AACnB,WAAO,EAAE,MAAM,KAAK,MAAM,SAAS,KAAK,QAAQ,SAAS,IAAI,IAAI,KAAK,UAAU,GAAG,KAAK,OAAO;AAAA,EAAK;AAAA,EACrG,CAAC;AACF;","names":["module"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport path from \"node:path\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype DeclarativeInvariant,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"1.0.0\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface CertificationInvariantContext {\n\tmodule: ModuleManifest;\n\tobjectType: ModuleManifest[\"objectTypes\"][number];\n\tinvariant: DeclarativeInvariant;\n}\n\nexport interface CertificationProfile {\n\tid: string;\n\t/** Resolve evidence owned outside serialized Platform definitions. */\n\tresolveInvariant?(context: CertificationInvariantContext): boolean;\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[]; certificationProfiles?: CertificationProfile[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules, options.certificationProfiles ?? []);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[], certificationProfiles: CertificationProfile[]): void {\n\tconst profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));\n\tif (profiles.size !== certificationProfiles.length) throw new Error(\"Certification profile IDs must be unique.\");\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tconst certification = module.capability?.certification;\n\t\tconst profile = certification?.required ? profiles.get(certification.profile) : undefined;\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t\tfor (const invariant of objectType.invariants ?? []) {\n\t\t\t\tif (invariant.required && !resolvesRequiredInvariant(module, objectType, invariant, profile)) {\n\t\t\t\t\tthrow new Error(`Required invariant \"${module.namespace}.${objectType.type}.${invariant.id}\" has no resolvable enforcement evidence under certification profile \"${certification?.profile ?? \"none\"}\".`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t\tif (view.usage?.collection?.filterSchema) assertPortableJsonSchema(view.usage.collection.filterSchema, `View ${view.name}@${view.version} filter`);\n\t\t}\n\t\tfor (const eventType of module.eventTypes) if (eventType.schema) assertPortableJsonSchema(eventType.schema, `Event ${eventType.eventType}@${eventType.schemaVersion}`);\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nfunction resolvesRequiredInvariant(\n\tmodule: ModuleManifest,\n\tobjectType: ModuleManifest[\"objectTypes\"][number],\n\tinvariant: DeclarativeInvariant,\n\tprofile: CertificationProfile | undefined,\n): boolean {\n\tconst reference = invariant.enforcementRef?.trim();\n\tif (!reference) return false;\n\tif (invariant.enforcement === \"json-schema\") {\n\t\tconst requiredMatch = /^#\\/required\\/([^/]+)$/.exec(reference);\n\t\tif (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]!));\n\t\tconst propertyMatch = /^#\\/properties\\/([^/]+)$/.exec(reference);\n\t\tif (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1]!)]);\n\t\treturn false;\n\t}\n\tif (invariant.enforcement === \"state-machine\") return module.stateMachines.some((machine) => machine.entityType === reference);\n\tif (invariant.enforcement === \"policy\") return module.policies.some((policy) => policy.policyId === reference);\n\treturn profile?.resolveInvariant?.({ module, objectType, invariant }) === true;\n}\n\nfunction decodeJsonPointerToken(token: string): string {\n\treturn token.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tif (before.version !== after.version) changes.push({ severity: \"potentially_breaking\", path: \"version\", code: \"module_version_changed\", message: \"Module version changed.\" });\n\tif (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: \"potentially_breaking\", path: \"capability\", code: \"capability_changed\", message: \"Capability roles, stability, deprecation, extension slots, or certification metadata changed.\" });\n\tdiffStringList(before.subjectTypes, after.subjectTypes, \"subjectTypes\", changes);\n\tdiffNamed(before.idPrefixes, after.idPrefixes, \"idPrefixes\", \"prefix\", changes, (oldValue, newValue, path) => {\n\t\tif (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: \"breaking\", path, code: \"id_prefix_changed\", message: \"ID prefix ownership changed.\" });\n\t});\n\tif (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: \"potentially_breaking\", path: \"dependencies\", code: \"module_dependencies_changed\", message: \"Module dependencies changed.\" });\n\tif (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: \"potentially_breaking\", path: \"policies\", code: \"module_policies_changed\", message: \"Module policy definitions changed.\" });\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t\tif (stableStringify(oldValue.execution) !== stableStringify(newValue.execution)) changes.push({ severity: oldValue.execution ? \"breaking\" : \"potentially_breaking\", path: `${path}.execution`, code: \"action_execution_changed\", message: \"Action execution semantics changed and hosts or offline consumers must be reviewed.\" });\n\t\tfor (const field of [\"version\", \"kind\", \"idempotent\", \"mutatesDomain\", \"eventPhase\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });\n\t\t}\n\t\tconst oldEvents = new Set(oldValue.emitsEvents);\n\t\tconst newEvents = new Set(newValue.emitsEvents);\n\t\tfor (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: \"breaking\", path: `${path}.emitsEvents.${event}`, code: \"action_event_removed\", message: `Declared action event \"${event}\" was removed.` });\n\t\tfor (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: \"compatible\", path: `${path}.emitsEvents.${event}`, code: \"action_event_added\", message: `Declared action event \"${event}\" was added.` });\n\t\tfor (const field of [\"policies\", \"requiredRoles\", \"requiredPermissions\", \"stateMachine\", \"adapterSteps\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });\n\t\t}\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tdiffEventSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse {\n\t\t\tdiffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t\t\tif (stableStringify(oldView.usage) !== stableStringify(newView.usage)) changes.push({ severity: \"potentially_breaking\", path: `views.${key}.usage`, code: \"view_usage_changed\", message: \"View usage semantics changed and generated consumers require review.\" });\n\t\t}\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffEventSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst start = changes.length;\n\tdiffSchema(before, after, path, changes);\n\tfor (let index = start; index < changes.length; index += 1) {\n\t\tconst change = changes[index]!;\n\t\tchange.code = `event_${change.code}`;\n\t\tchange.message = `Event schema: ${change.message}`;\n\t}\n}\n\nfunction diffStringList(before: string[], after: string[], path: string, changes: CompatibilityChange[]): void {\n\tconst oldValues = new Set(before);\n\tconst newValues = new Set(after);\n\tfor (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: \"breaking\", path: `${path}.${value}`, code: `${path}_removed`, message: `Public ${path} value \"${value}\" was removed.` });\n\tfor (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: \"compatible\", path: `${path}.${value}`, code: `${path}_added`, message: `Public ${path} value \"${value}\" was added.` });\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) {\n\t\tconst oldTypes = new Set(Array.isArray(before.type) ? before.type : before.type ? [before.type] : []);\n\t\tconst newTypes = new Set(Array.isArray(after.type) ? after.type : after.type ? [after.type] : []);\n\t\tconst widened = oldTypes.size > 0 && [...oldTypes].every((type) => newTypes.has(type));\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.type`, code: widened ? \"schema_type_widened\" : \"schema_type_narrowed\", message: widened ? \"Schema type widened; generated consumers may receive a new value type.\" : \"Schema type no longer accepts every prior type.\" });\n\t}\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || path.isAbsolute(file.path) || path.win32.isAbsolute(file.path) || file.path.includes(\"\\\\\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAC3B,uBAAiB;AACjB,sBAQO;AAEA,IAAM,0BAA0B;AAChC,IAAM,0BAA0B,CAAC,MAAc,UAA0B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAiChH,SAAS,gBAAgB,OAAwB;AACvD,SAAO,KAAK,UAAU,SAAS,KAAK,CAAC;AACtC;AAEA,SAAS,SAAS,OAAyB;AAC1C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,QAAQ;AACnD,MAAI,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,OAAO;AAAA,MACb,OAAO,QAAQ,KAAgC,EAC7C,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,wBAAwB,MAAM,KAAK,CAAC,EAC9D,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,SAAS,KAAK,CAAC,CAAC;AAAA,IAC/C;AAAA,EACD;AACA,SAAO;AACR;AAEO,SAAS,sBACf,OACA,UAAkH,CAAC,GAChG;AACnB,QAAM,aAAS,+CAA8B,KAAK;AAClD,QAAM,aAAa,oBAAI,IAAY;AACnC,aAAWA,WAAU,OAAO,SAAS;AACpC,QAAI,WAAW,IAAIA,QAAO,SAAS,EAAG,OAAM,IAAI,MAAM,+BAA+BA,QAAO,SAAS,sBAAsB;AAC3H,eAAW,IAAIA,QAAO,SAAS;A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
-
import { ModuleManifest, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
1
|
+
import { ModuleManifest, DeclarativeInvariant, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
2
2
|
|
|
3
|
-
declare const FABRIC_COMPILER_VERSION = "
|
|
3
|
+
declare const FABRIC_COMPILER_VERSION = "1.0.0";
|
|
4
4
|
declare const compareCanonicalStrings: (left: string, right: string) => number;
|
|
5
5
|
interface CompilerConformanceAdapter<Finding = unknown> {
|
|
6
6
|
id: string;
|
|
@@ -11,6 +11,16 @@ interface CompilerConformanceResult<Finding = unknown> {
|
|
|
11
11
|
moduleNamespace: string;
|
|
12
12
|
findings: Finding[];
|
|
13
13
|
}
|
|
14
|
+
interface CertificationInvariantContext {
|
|
15
|
+
module: ModuleManifest;
|
|
16
|
+
objectType: ModuleManifest["objectTypes"][number];
|
|
17
|
+
invariant: DeclarativeInvariant;
|
|
18
|
+
}
|
|
19
|
+
interface CertificationProfile {
|
|
20
|
+
id: string;
|
|
21
|
+
/** Resolve evidence owned outside serialized Platform definitions. */
|
|
22
|
+
resolveInvariant?(context: CertificationInvariantContext): boolean;
|
|
23
|
+
}
|
|
14
24
|
interface FabricCompilerIr {
|
|
15
25
|
compilerVersion: string;
|
|
16
26
|
manifestVersion: number;
|
|
@@ -21,6 +31,7 @@ interface FabricCompilerIr {
|
|
|
21
31
|
declare function stableStringify(value: unknown): string;
|
|
22
32
|
declare function compileManifestBundle(input: ModuleManifestBundle | ModuleManifestBundleV1, options?: {
|
|
23
33
|
conformanceAdapters?: CompilerConformanceAdapter[];
|
|
34
|
+
certificationProfiles?: CertificationProfile[];
|
|
24
35
|
}): FabricCompilerIr;
|
|
25
36
|
type CompatibilitySeverity = "compatible" | "potentially_breaking" | "breaking";
|
|
26
37
|
interface CompatibilityChange {
|
|
@@ -46,4 +57,4 @@ interface GeneratorTarget {
|
|
|
46
57
|
}
|
|
47
58
|
declare function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]>;
|
|
48
59
|
|
|
49
|
-
export { type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
|
60
|
+
export { type CertificationInvariantContext, type CertificationProfile, type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ModuleManifest, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
1
|
+
import { ModuleManifest, DeclarativeInvariant, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
2
2
|
|
|
3
|
-
declare const FABRIC_COMPILER_VERSION = "
|
|
3
|
+
declare const FABRIC_COMPILER_VERSION = "1.0.0";
|
|
4
4
|
declare const compareCanonicalStrings: (left: string, right: string) => number;
|
|
5
5
|
interface CompilerConformanceAdapter<Finding = unknown> {
|
|
6
6
|
id: string;
|
|
@@ -11,6 +11,16 @@ interface CompilerConformanceResult<Finding = unknown> {
|
|
|
11
11
|
moduleNamespace: string;
|
|
12
12
|
findings: Finding[];
|
|
13
13
|
}
|
|
14
|
+
interface CertificationInvariantContext {
|
|
15
|
+
module: ModuleManifest;
|
|
16
|
+
objectType: ModuleManifest["objectTypes"][number];
|
|
17
|
+
invariant: DeclarativeInvariant;
|
|
18
|
+
}
|
|
19
|
+
interface CertificationProfile {
|
|
20
|
+
id: string;
|
|
21
|
+
/** Resolve evidence owned outside serialized Platform definitions. */
|
|
22
|
+
resolveInvariant?(context: CertificationInvariantContext): boolean;
|
|
23
|
+
}
|
|
14
24
|
interface FabricCompilerIr {
|
|
15
25
|
compilerVersion: string;
|
|
16
26
|
manifestVersion: number;
|
|
@@ -21,6 +31,7 @@ interface FabricCompilerIr {
|
|
|
21
31
|
declare function stableStringify(value: unknown): string;
|
|
22
32
|
declare function compileManifestBundle(input: ModuleManifestBundle | ModuleManifestBundleV1, options?: {
|
|
23
33
|
conformanceAdapters?: CompilerConformanceAdapter[];
|
|
34
|
+
certificationProfiles?: CertificationProfile[];
|
|
24
35
|
}): FabricCompilerIr;
|
|
25
36
|
type CompatibilitySeverity = "compatible" | "potentially_breaking" | "breaking";
|
|
26
37
|
interface CompatibilityChange {
|
|
@@ -46,4 +57,4 @@ interface GeneratorTarget {
|
|
|
46
57
|
}
|
|
47
58
|
declare function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]>;
|
|
48
59
|
|
|
49
|
-
export { type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
|
60
|
+
export { type CertificationInvariantContext, type CertificationProfile, type CompatibilityChange, type CompatibilityReport, type CompatibilitySeverity, type CompilerConformanceAdapter, type CompilerConformanceResult, FABRIC_COMPILER_VERSION, type FabricCompilerIr, type GeneratedFile, type GeneratorTarget, compareCanonicalStrings, compileManifestBundle, diffModuleManifests, runGenerator, stableStringify };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// index.ts
|
|
2
2
|
import { createHash } from "crypto";
|
|
3
|
+
import path from "path";
|
|
3
4
|
import {
|
|
4
5
|
normalizeModuleManifestBundle,
|
|
5
6
|
assertPortableJsonSchema
|
|
6
7
|
} from "@fabricorg/platform";
|
|
7
|
-
var FABRIC_COMPILER_VERSION = "
|
|
8
|
+
var FABRIC_COMPILER_VERSION = "1.0.0";
|
|
8
9
|
var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
9
10
|
function stableStringify(value) {
|
|
10
11
|
return JSON.stringify(sortJson(value));
|
|
@@ -26,7 +27,7 @@ function compileManifestBundle(input, options = {}) {
|
|
|
26
27
|
namespaces.add(module.namespace);
|
|
27
28
|
}
|
|
28
29
|
const modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));
|
|
29
|
-
assertCompilerManifests(modules);
|
|
30
|
+
assertCompilerManifests(modules, options.certificationProfiles ?? []);
|
|
30
31
|
const canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });
|
|
31
32
|
return {
|
|
32
33
|
compilerVersion: FABRIC_COMPILER_VERSION,
|
|
@@ -38,7 +39,9 @@ function compileManifestBundle(input, options = {}) {
|
|
|
38
39
|
)
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
function assertCompilerManifests(modules) {
|
|
42
|
+
function assertCompilerManifests(modules, certificationProfiles) {
|
|
43
|
+
const profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));
|
|
44
|
+
if (profiles.size !== certificationProfiles.length) throw new Error("Certification profile IDs must be unique.");
|
|
42
45
|
for (const module of modules) {
|
|
43
46
|
if (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error("Compiler input is not a normalized module manifest.");
|
|
44
47
|
}
|
|
@@ -48,15 +51,24 @@ function assertCompilerManifests(modules) {
|
|
|
48
51
|
if (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module "${module.namespace}" capability requires displayName and description.`);
|
|
49
52
|
if (!["experimental", "beta", "stable", "deprecated"].includes(module.capability.stability)) throw new Error(`Module "${module.namespace}" capability has invalid stability.`);
|
|
50
53
|
}
|
|
54
|
+
const certification = module.capability?.certification;
|
|
55
|
+
const profile = certification?.required ? profiles.get(certification.profile) : void 0;
|
|
51
56
|
for (const objectType of module.objectTypes) {
|
|
52
57
|
if (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type "${objectType.type}" in compiler input.`);
|
|
53
58
|
if (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);
|
|
54
59
|
for (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type "${relation.target}".`);
|
|
60
|
+
for (const invariant of objectType.invariants ?? []) {
|
|
61
|
+
if (invariant.required && !resolvesRequiredInvariant(module, objectType, invariant, profile)) {
|
|
62
|
+
throw new Error(`Required invariant "${module.namespace}.${objectType.type}.${invariant.id}" has no resolvable enforcement evidence under certification profile "${certification?.profile ?? "none"}".`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
66
|
for (const view of module.views) {
|
|
57
67
|
if (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View "${view.name}" must use module namespace "${module.namespace}/".`);
|
|
58
68
|
assertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);
|
|
69
|
+
if (view.usage?.collection?.filterSchema) assertPortableJsonSchema(view.usage.collection.filterSchema, `View ${view.name}@${view.version} filter`);
|
|
59
70
|
}
|
|
71
|
+
for (const eventType of module.eventTypes) if (eventType.schema) assertPortableJsonSchema(eventType.schema, `Event ${eventType.eventType}@${eventType.schemaVersion}`);
|
|
60
72
|
for (const action of module.actions) {
|
|
61
73
|
if (!/^[a-z][a-z0-9-]*\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || !["atomic", "saga"].includes(action.kind) || typeof action.idempotent !== "boolean" || typeof action.mutatesDomain !== "boolean" || !Array.isArray(action.emitsEvents)) throw new Error(`Action "${action.actionId}" is not a normalized manifest action.`);
|
|
62
74
|
if (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema, `Action ${action.actionId} parameters`);
|
|
@@ -64,94 +76,154 @@ function assertCompilerManifests(modules) {
|
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
78
|
}
|
|
79
|
+
function resolvesRequiredInvariant(module, objectType, invariant, profile) {
|
|
80
|
+
const reference = invariant.enforcementRef?.trim();
|
|
81
|
+
if (!reference) return false;
|
|
82
|
+
if (invariant.enforcement === "json-schema") {
|
|
83
|
+
const requiredMatch = /^#\/required\/([^/]+)$/.exec(reference);
|
|
84
|
+
if (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]));
|
|
85
|
+
const propertyMatch = /^#\/properties\/([^/]+)$/.exec(reference);
|
|
86
|
+
if (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1])]);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (invariant.enforcement === "state-machine") return module.stateMachines.some((machine) => machine.entityType === reference);
|
|
90
|
+
if (invariant.enforcement === "policy") return module.policies.some((policy) => policy.policyId === reference);
|
|
91
|
+
return profile?.resolveInvariant?.({ module, objectType, invariant }) === true;
|
|
92
|
+
}
|
|
93
|
+
function decodeJsonPointerToken(token) {
|
|
94
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
95
|
+
}
|
|
67
96
|
var severityRank = { compatible: 0, potentially_breaking: 1, breaking: 2 };
|
|
68
97
|
function diffModuleManifests(before, after) {
|
|
69
98
|
if (before.namespace !== after.namespace) {
|
|
70
99
|
return report([{ severity: "breaking", path: "namespace", code: "module_renamed", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);
|
|
71
100
|
}
|
|
72
101
|
const changes = [];
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
if (before.version !== after.version) changes.push({ severity: "potentially_breaking", path: "version", code: "module_version_changed", message: "Module version changed." });
|
|
103
|
+
if (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: "potentially_breaking", path: "capability", code: "capability_changed", message: "Capability roles, stability, deprecation, extension slots, or certification metadata changed." });
|
|
104
|
+
diffStringList(before.subjectTypes, after.subjectTypes, "subjectTypes", changes);
|
|
105
|
+
diffNamed(before.idPrefixes, after.idPrefixes, "idPrefixes", "prefix", changes, (oldValue, newValue, path2) => {
|
|
106
|
+
if (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: "breaking", path: path2, code: "id_prefix_changed", message: "ID prefix ownership changed." });
|
|
107
|
+
});
|
|
108
|
+
if (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: "potentially_breaking", path: "dependencies", code: "module_dependencies_changed", message: "Module dependencies changed." });
|
|
109
|
+
if (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: "potentially_breaking", path: "policies", code: "module_policies_changed", message: "Module policy definitions changed." });
|
|
110
|
+
diffNamed(before.objectTypes, after.objectTypes, "objectTypes", "type", changes, (oldValue, newValue, path2) => {
|
|
111
|
+
diffSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
75
112
|
const oldArchetype = oldValue.semantics?.["fabric.archetype"];
|
|
76
113
|
const newArchetype = newValue.semantics?.["fabric.archetype"];
|
|
77
|
-
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${
|
|
78
|
-
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${
|
|
79
|
-
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${
|
|
114
|
+
if (oldArchetype && !newArchetype) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_removed", message: "Archetype certification metadata was removed." });
|
|
115
|
+
else if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: "breaking", path: `${path2}.semantics.fabric.archetype`, code: "archetype_mapping_changed", message: "Archetype identity, version, or state mapping changed." });
|
|
116
|
+
diffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path2}.relations`, "name", changes, (oldRelation, newRelation, relationPath) => {
|
|
80
117
|
if (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: "breaking", path: `${relationPath}.cardinality`, code: "relation_cardinality_changed", message: "Relation cardinality changed." });
|
|
81
118
|
if (oldRelation.target !== newRelation.target) changes.push({ severity: "breaking", path: `${relationPath}.target`, code: "relation_target_changed", message: "Relation target changed." });
|
|
82
119
|
if (!oldRelation.required && newRelation.required) changes.push({ severity: "breaking", path: `${relationPath}.required`, code: "relation_became_required", message: "Optional relation became required." });
|
|
83
120
|
if (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: "breaking", path: `${relationPath}.semantics`, code: "relation_ownership_changed", message: "Relation ownership semantics changed." });
|
|
84
121
|
if (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: "breaking", path: `${relationPath}.onTargetDelete`, code: "relation_delete_behavior_changed", message: "Relation deletion behavior changed." });
|
|
85
122
|
});
|
|
86
|
-
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${
|
|
123
|
+
diffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path2}.invariants`, "id", changes, (oldInvariant, newInvariant, invariantPath) => {
|
|
87
124
|
if (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: "potentially_breaking", path: invariantPath, code: "invariant_enforcement_changed", message: "Invariant enforcement ownership or reference changed." });
|
|
88
125
|
if (!oldInvariant.required && newInvariant.required) changes.push({ severity: "breaking", path: `${invariantPath}.required`, code: "invariant_became_required", message: "Invariant became required." });
|
|
89
126
|
});
|
|
90
127
|
});
|
|
91
|
-
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue,
|
|
92
|
-
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${
|
|
93
|
-
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${
|
|
128
|
+
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue, path2) => {
|
|
129
|
+
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${path2}.parameterSchema`, changes);
|
|
130
|
+
diffSchema(oldValue.resultSchema, newValue.resultSchema, `${path2}.resultSchema`, changes);
|
|
131
|
+
if (stableStringify(oldValue.execution) !== stableStringify(newValue.execution)) changes.push({ severity: oldValue.execution ? "breaking" : "potentially_breaking", path: `${path2}.execution`, code: "action_execution_changed", message: "Action execution semantics changed and hosts or offline consumers must be reviewed." });
|
|
132
|
+
for (const field of ["version", "kind", "idempotent", "mutatesDomain", "eventPhase"]) {
|
|
133
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });
|
|
134
|
+
}
|
|
135
|
+
const oldEvents = new Set(oldValue.emitsEvents);
|
|
136
|
+
const newEvents = new Set(newValue.emitsEvents);
|
|
137
|
+
for (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: "breaking", path: `${path2}.emitsEvents.${event}`, code: "action_event_removed", message: `Declared action event "${event}" was removed.` });
|
|
138
|
+
for (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: "compatible", path: `${path2}.emitsEvents.${event}`, code: "action_event_added", message: `Declared action event "${event}" was added.` });
|
|
139
|
+
for (const field of ["policies", "requiredRoles", "requiredPermissions", "stateMachine", "adapterSteps"]) {
|
|
140
|
+
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "potentially_breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });
|
|
141
|
+
}
|
|
94
142
|
});
|
|
95
|
-
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue,
|
|
96
|
-
|
|
97
|
-
|
|
143
|
+
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue, path2) => {
|
|
144
|
+
diffEventSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
145
|
+
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${path2}.schemaVersion`, code: "event_version_decreased", message: "Event schema version decreased." });
|
|
146
|
+
else if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: "potentially_breaking", path: `${path2}.schemaVersion`, code: "event_version_changed", message: "Event schema version changed; old consumers require compatibility evidence." });
|
|
98
147
|
});
|
|
99
148
|
const oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
100
149
|
const newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));
|
|
101
150
|
for (const [key, oldView] of oldViews) {
|
|
102
151
|
const newView = newViews.get(key);
|
|
103
152
|
if (!newView) changes.push({ severity: "breaking", path: `views.${key}`, code: "view_version_removed", message: `View contract "${key}" was removed.` });
|
|
104
|
-
else
|
|
153
|
+
else {
|
|
154
|
+
diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);
|
|
155
|
+
if (stableStringify(oldView.usage) !== stableStringify(newView.usage)) changes.push({ severity: "potentially_breaking", path: `views.${key}.usage`, code: "view_usage_changed", message: "View usage semantics changed and generated consumers require review." });
|
|
156
|
+
}
|
|
105
157
|
}
|
|
106
158
|
for (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: "compatible", path: `views.${key}`, code: "view_version_added", message: `View contract "${key}" was added.` });
|
|
107
|
-
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue,
|
|
159
|
+
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue, path2) => {
|
|
108
160
|
const newStates = new Set(newValue.states.map((state) => state.id));
|
|
109
|
-
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${
|
|
161
|
+
for (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: "breaking", path: `${path2}.states.${state.id}`, code: "state_removed", message: `State "${state.id}" was removed.` });
|
|
110
162
|
const transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));
|
|
111
|
-
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${
|
|
163
|
+
for (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: "breaking", path: `${path2}.transitions.${transition.from}->${transition.to}`, code: "transition_removed", message: "A state transition was removed or remapped." });
|
|
112
164
|
});
|
|
113
165
|
return report(changes);
|
|
114
166
|
}
|
|
115
|
-
function
|
|
167
|
+
function diffEventSchema(before, after, path2, changes) {
|
|
168
|
+
const start = changes.length;
|
|
169
|
+
diffSchema(before, after, path2, changes);
|
|
170
|
+
for (let index = start; index < changes.length; index += 1) {
|
|
171
|
+
const change = changes[index];
|
|
172
|
+
change.code = `event_${change.code}`;
|
|
173
|
+
change.message = `Event schema: ${change.message}`;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function diffStringList(before, after, path2, changes) {
|
|
177
|
+
const oldValues = new Set(before);
|
|
178
|
+
const newValues = new Set(after);
|
|
179
|
+
for (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: "breaking", path: `${path2}.${value}`, code: `${path2}_removed`, message: `Public ${path2} value "${value}" was removed.` });
|
|
180
|
+
for (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: "compatible", path: `${path2}.${value}`, code: `${path2}_added`, message: `Public ${path2} value "${value}" was added.` });
|
|
181
|
+
}
|
|
182
|
+
function diffNamed(before, after, path2, key, changes, compare) {
|
|
116
183
|
const oldMap = new Map(before.map((value) => [String(value[key]), value]));
|
|
117
184
|
const newMap = new Map(after.map((value) => [String(value[key]), value]));
|
|
118
185
|
for (const [name, value] of oldMap) {
|
|
119
186
|
const next = newMap.get(name);
|
|
120
|
-
if (!next) changes.push({ severity: "breaking", path: `${
|
|
121
|
-
else compare(value, next, `${
|
|
187
|
+
if (!next) changes.push({ severity: "breaking", path: `${path2}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} "${name}" was removed.` });
|
|
188
|
+
else compare(value, next, `${path2}.${name}`);
|
|
122
189
|
}
|
|
123
|
-
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${
|
|
190
|
+
for (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: "compatible", path: `${path2}.${name}`, code: `${String(key)}_added`, message: `${String(key)} "${name}" was added.` });
|
|
124
191
|
}
|
|
125
|
-
function diffSchema(before, after,
|
|
192
|
+
function diffSchema(before, after, path2, changes) {
|
|
126
193
|
const changeCount = changes.length;
|
|
127
194
|
if (!before && after) {
|
|
128
|
-
changes.push({ severity: "potentially_breaking", path, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
195
|
+
changes.push({ severity: "potentially_breaking", path: path2, code: "schema_added", message: "A schema was added to an existing contract." });
|
|
129
196
|
return;
|
|
130
197
|
}
|
|
131
198
|
if (before && !after) {
|
|
132
|
-
changes.push({ severity: "breaking", path, code: "schema_removed", message: "An existing schema was removed." });
|
|
199
|
+
changes.push({ severity: "breaking", path: path2, code: "schema_removed", message: "An existing schema was removed." });
|
|
133
200
|
return;
|
|
134
201
|
}
|
|
135
202
|
if (!before || !after) return;
|
|
136
203
|
const oldRequired = new Set(before.required ?? []);
|
|
137
|
-
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${
|
|
204
|
+
for (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: "breaking", path: `${path2}.required.${required}`, code: "required_property_added", message: `Required property "${required}" was added.` });
|
|
138
205
|
const oldProperties = before.properties ?? {};
|
|
139
206
|
const newProperties = after.properties ?? {};
|
|
140
|
-
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${
|
|
141
|
-
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${
|
|
207
|
+
for (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: "breaking", path: `${path2}.properties.${property}`, code: "schema_property_removed", message: `Schema property "${property}" was removed.` });
|
|
208
|
+
for (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? "breaking" : "compatible", path: `${path2}.properties.${property}`, code: "schema_property_added", message: `Schema property "${property}" was added.` });
|
|
142
209
|
for (const property of Object.keys(oldProperties)) {
|
|
143
|
-
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${
|
|
210
|
+
if (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path2}.properties.${property}`, changes);
|
|
144
211
|
}
|
|
145
|
-
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${
|
|
146
|
-
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${
|
|
212
|
+
if (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: "breaking", path: `${path2}.additionalProperties`, code: "additional_properties_forbidden", message: "Schema now rejects undeclared properties." });
|
|
213
|
+
if (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path2}.items`, changes);
|
|
147
214
|
for (const keyword of ["minimum", "maximum", "minLength", "maxLength", "pattern"]) {
|
|
148
|
-
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${
|
|
215
|
+
if (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: "potentially_breaking", path: `${path2}.${keyword}`, code: "schema_constraint_changed", message: `Schema constraint "${keyword}" changed.` });
|
|
216
|
+
}
|
|
217
|
+
if (stableStringify(before.type) !== stableStringify(after.type)) {
|
|
218
|
+
const oldTypes = new Set(Array.isArray(before.type) ? before.type : before.type ? [before.type] : []);
|
|
219
|
+
const newTypes = new Set(Array.isArray(after.type) ? after.type : after.type ? [after.type] : []);
|
|
220
|
+
const widened = oldTypes.size > 0 && [...oldTypes].every((type) => newTypes.has(type));
|
|
221
|
+
changes.push({ severity: "breaking", path: `${path2}.type`, code: widened ? "schema_type_widened" : "schema_type_narrowed", message: widened ? "Schema type widened; generated consumers may receive a new value type." : "Schema type no longer accepts every prior type." });
|
|
149
222
|
}
|
|
150
|
-
if (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: "breaking", path: `${path}.type`, code: "schema_type_changed", message: "Schema type changed." });
|
|
151
223
|
if (before.enum && after.enum && before.enum.some((value) => !after.enum.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {
|
|
152
|
-
changes.push({ severity: "breaking", path: `${
|
|
224
|
+
changes.push({ severity: "breaking", path: `${path2}.enum`, code: "schema_enum_narrowed", message: "Schema enum no longer accepts a previously valid value." });
|
|
153
225
|
}
|
|
154
|
-
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
226
|
+
if (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: "potentially_breaking", path: path2, code: "schema_changed", message: "Schema changed and requires consumer review." });
|
|
155
227
|
}
|
|
156
228
|
function report(changes) {
|
|
157
229
|
const highestSeverity = changes.reduce((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, "compatible");
|
|
@@ -161,7 +233,7 @@ async function runGenerator(target, ir) {
|
|
|
161
233
|
const files = await target.generate(ir);
|
|
162
234
|
const paths = /* @__PURE__ */ new Set();
|
|
163
235
|
return [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {
|
|
164
|
-
if (!file.path || file.path.
|
|
236
|
+
if (!file.path || path.isAbsolute(file.path) || path.win32.isAbsolute(file.path) || file.path.includes("\\") || file.path.split("/").includes("..")) throw new Error(`Generator "${target.name}" returned unsafe path "${file.path}".`);
|
|
165
237
|
if (paths.has(file.path)) throw new Error(`Generator "${target.name}" returned duplicate path "${file.path}".`);
|
|
166
238
|
paths.add(file.path);
|
|
167
239
|
return { path: file.path, content: file.content.endsWith("\n") ? file.content : `${file.content}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"0.1.0\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[]): void {\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t}\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse diffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) changes.push({ severity: \"breaking\", path: `${path}.type`, code: \"schema_type_changed\", message: \"Schema type changed.\" });\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || file.path.startsWith(\"/\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B;AAAA,EACC;AAAA,EACA;AAAA,OAKM;AAEA,IAAM,0BAA0B;AAChC,IAAM,0BAA0B,CAAC,MAAc,UAA0B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAqBhH,SAAS,gBAAgB,OAAwB;AACvD,SAAO,KAAK,UAAU,SAAS,KAAK,CAAC;AACtC;AAEA,SAAS,SAAS,OAAyB;AAC1C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,QAAQ;AACnD,MAAI,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO,OAAO;AAAA,MACb,OAAO,QAAQ,KAAgC,EAC7C,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,wBAAwB,MAAM,KAAK,CAAC,EAC9D,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK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} from \"node:crypto\";\nimport path from \"node:path\";\nimport {\n\tnormalizeModuleManifestBundle,\n\tassertPortableJsonSchema,\n\ttype ModuleManifest,\n\ttype ModuleManifestBundle,\n\ttype ModuleManifestBundleV1,\n\ttype DeclarativeInvariant,\n\ttype PortableJsonSchema,\n} from \"@fabricorg/platform\";\n\nexport const FABRIC_COMPILER_VERSION = \"1.0.0\";\nexport const compareCanonicalStrings = (left: string, right: string): number => left < right ? -1 : left > right ? 1 : 0;\n\nexport interface CompilerConformanceAdapter<Finding = unknown> {\n\tid: string;\n\tevaluate(manifest: ModuleManifest): Finding[];\n}\n\nexport interface CompilerConformanceResult<Finding = unknown> {\n\tadapterId: string;\n\tmoduleNamespace: string;\n\tfindings: Finding[];\n}\n\nexport interface CertificationInvariantContext {\n\tmodule: ModuleManifest;\n\tobjectType: ModuleManifest[\"objectTypes\"][number];\n\tinvariant: DeclarativeInvariant;\n}\n\nexport interface CertificationProfile {\n\tid: string;\n\t/** Resolve evidence owned outside serialized Platform definitions. */\n\tresolveInvariant?(context: CertificationInvariantContext): boolean;\n}\n\nexport interface FabricCompilerIr {\n\tcompilerVersion: string;\n\tmanifestVersion: number;\n\tmanifestDigest: string;\n\tmodules: ModuleManifest[];\n\tconformance: CompilerConformanceResult[];\n}\n\nexport function stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortJson(value));\n}\n\nfunction sortJson(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortJson);\n\tif (value && typeof value === \"object\") {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t\t.sort(([left], [right]) => compareCanonicalStrings(left, right))\n\t\t\t\t.map(([key, child]) => [key, sortJson(child)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function compileManifestBundle(\n\tinput: ModuleManifestBundle | ModuleManifestBundleV1,\n\toptions: { conformanceAdapters?: CompilerConformanceAdapter[]; certificationProfiles?: CertificationProfile[] } = {},\n): FabricCompilerIr {\n\tconst bundle = normalizeModuleManifestBundle(input);\n\tconst namespaces = new Set<string>();\n\tfor (const module of bundle.modules) {\n\t\tif (namespaces.has(module.namespace)) throw new Error(`Duplicate module namespace \"${module.namespace}\" in compiler input.`);\n\t\tnamespaces.add(module.namespace);\n\t}\n\tconst modules = [...bundle.modules].sort((left, right) => compareCanonicalStrings(left.namespace, right.namespace));\n\tassertCompilerManifests(modules, options.certificationProfiles ?? []);\n\tconst canonical = stableStringify({ manifestVersion: bundle.manifestVersion, modules });\n\treturn {\n\t\tcompilerVersion: FABRIC_COMPILER_VERSION,\n\t\tmanifestVersion: bundle.manifestVersion,\n\t\tmanifestDigest: createHash(\"sha256\").update(canonical).digest(\"hex\"),\n\t\tmodules,\n\t\tconformance: (options.conformanceAdapters ?? []).flatMap((adapter) =>\n\t\t\tmodules.map((module) => ({ adapterId: adapter.id, moduleNamespace: module.namespace, findings: adapter.evaluate(module) })),\n\t\t),\n\t};\n}\n\nfunction assertCompilerManifests(modules: ModuleManifest[], certificationProfiles: CertificationProfile[]): void {\n\tconst profiles = new Map(certificationProfiles.map((profile) => [profile.id, profile]));\n\tif (profiles.size !== certificationProfiles.length) throw new Error(\"Certification profile IDs must be unique.\");\n\tfor (const module of modules) {\n\t\tif (!module || !/^[a-z][a-z0-9-]*$/.test(module.namespace) || !Array.isArray(module.objectTypes) || !Array.isArray(module.actions) || !Array.isArray(module.views)) throw new Error(\"Compiler input is not a normalized module manifest.\");\n\t}\n\tconst targets = new Set(modules.flatMap((module) => module.objectTypes.map((objectType) => `${module.namespace}.${objectType.type}`)));\n\tfor (const module of modules) {\n\t\tif (module.capability) {\n\t\t\tif (!module.capability.displayName?.trim() || !module.capability.description?.trim()) throw new Error(`Module \"${module.namespace}\" capability requires displayName and description.`);\n\t\t\tif (![\"experimental\", \"beta\", \"stable\", \"deprecated\"].includes(module.capability.stability)) throw new Error(`Module \"${module.namespace}\" capability has invalid stability.`);\n\t\t}\n\t\tconst certification = module.capability?.certification;\n\t\tconst profile = certification?.required ? profiles.get(certification.profile) : undefined;\n\t\tfor (const objectType of module.objectTypes) {\n\t\t\tif (!/^[A-Z][A-Za-z0-9]*$/.test(objectType.type)) throw new Error(`Invalid object type \"${objectType.type}\" in compiler input.`);\n\t\t\tif (objectType.schema) assertPortableJsonSchema(objectType.schema, `${module.namespace}.${objectType.type}`);\n\t\t\tfor (const relation of objectType.relations ?? []) if (!targets.has(relation.target)) throw new Error(`Relation ${module.namespace}.${objectType.type}.${relation.name} targets missing object type \"${relation.target}\".`);\n\t\t\tfor (const invariant of objectType.invariants ?? []) {\n\t\t\t\tif (invariant.required && !resolvesRequiredInvariant(module, objectType, invariant, profile)) {\n\t\t\t\t\tthrow new Error(`Required invariant \"${module.namespace}.${objectType.type}.${invariant.id}\" has no resolvable enforcement evidence under certification profile \"${certification?.profile ?? \"none\"}\".`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const view of module.views) {\n\t\t\tif (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View \"${view.name}\" must use module namespace \"${module.namespace}/\".`);\n\t\t\tassertPortableJsonSchema(view.shape, `View ${view.name}@${view.version}`);\n\t\t\tif (view.usage?.collection?.filterSchema) assertPortableJsonSchema(view.usage.collection.filterSchema, `View ${view.name}@${view.version} filter`);\n\t\t}\n\t\tfor (const eventType of module.eventTypes) if (eventType.schema) assertPortableJsonSchema(eventType.schema, `Event ${eventType.eventType}@${eventType.schemaVersion}`);\n\t\tfor (const action of module.actions) {\n\t\t\tif (!/^[a-z][a-z0-9-]*\\.[a-z][a-z0-9_]*$/.test(action.actionId) || !action.actionId.startsWith(`${module.namespace}.`) || ![\"atomic\", \"saga\"].includes(action.kind) || typeof action.idempotent !== \"boolean\" || typeof action.mutatesDomain !== \"boolean\" || !Array.isArray(action.emitsEvents)) throw new Error(`Action \"${action.actionId}\" is not a normalized manifest action.`);\n\t\t\tif (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema as PortableJsonSchema, `Action ${action.actionId} parameters`);\n\t\t\tif (action.resultSchema) assertPortableJsonSchema(action.resultSchema as PortableJsonSchema, `Action ${action.actionId} result`);\n\t\t}\n\t}\n}\n\nfunction resolvesRequiredInvariant(\n\tmodule: ModuleManifest,\n\tobjectType: ModuleManifest[\"objectTypes\"][number],\n\tinvariant: DeclarativeInvariant,\n\tprofile: CertificationProfile | undefined,\n): boolean {\n\tconst reference = invariant.enforcementRef?.trim();\n\tif (!reference) return false;\n\tif (invariant.enforcement === \"json-schema\") {\n\t\tconst requiredMatch = /^#\\/required\\/([^/]+)$/.exec(reference);\n\t\tif (requiredMatch) return Array.isArray(objectType.schema?.required) && objectType.schema.required.includes(decodeJsonPointerToken(requiredMatch[1]!));\n\t\tconst propertyMatch = /^#\\/properties\\/([^/]+)$/.exec(reference);\n\t\tif (propertyMatch) return Boolean(objectType.schema?.properties?.[decodeJsonPointerToken(propertyMatch[1]!)]);\n\t\treturn false;\n\t}\n\tif (invariant.enforcement === \"state-machine\") return module.stateMachines.some((machine) => machine.entityType === reference);\n\tif (invariant.enforcement === \"policy\") return module.policies.some((policy) => policy.policyId === reference);\n\treturn profile?.resolveInvariant?.({ module, objectType, invariant }) === true;\n}\n\nfunction decodeJsonPointerToken(token: string): string {\n\treturn token.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\nexport type CompatibilitySeverity = \"compatible\" | \"potentially_breaking\" | \"breaking\";\nexport interface CompatibilityChange {\n\tseverity: CompatibilitySeverity;\n\tpath: string;\n\tcode: string;\n\tmessage: string;\n}\nexport interface CompatibilityReport {\n\tcompatible: boolean;\n\thighestSeverity: CompatibilitySeverity;\n\tchanges: CompatibilityChange[];\n}\n\nconst severityRank: Record<CompatibilitySeverity, number> = { compatible: 0, potentially_breaking: 1, breaking: 2 };\n\nexport function diffModuleManifests(before: ModuleManifest, after: ModuleManifest): CompatibilityReport {\n\tif (before.namespace !== after.namespace) {\n\t\treturn report([{ severity: \"breaking\", path: \"namespace\", code: \"module_renamed\", message: `Module namespace changed from ${before.namespace} to ${after.namespace}.` }]);\n\t}\n\tconst changes: CompatibilityChange[] = [];\n\tif (before.version !== after.version) changes.push({ severity: \"potentially_breaking\", path: \"version\", code: \"module_version_changed\", message: \"Module version changed.\" });\n\tif (stableStringify(before.capability) !== stableStringify(after.capability)) changes.push({ severity: \"potentially_breaking\", path: \"capability\", code: \"capability_changed\", message: \"Capability roles, stability, deprecation, extension slots, or certification metadata changed.\" });\n\tdiffStringList(before.subjectTypes, after.subjectTypes, \"subjectTypes\", changes);\n\tdiffNamed(before.idPrefixes, after.idPrefixes, \"idPrefixes\", \"prefix\", changes, (oldValue, newValue, path) => {\n\t\tif (stableStringify(oldValue) !== stableStringify(newValue)) changes.push({ severity: \"breaking\", path, code: \"id_prefix_changed\", message: \"ID prefix ownership changed.\" });\n\t});\n\tif (stableStringify(before.dependencies) !== stableStringify(after.dependencies)) changes.push({ severity: \"potentially_breaking\", path: \"dependencies\", code: \"module_dependencies_changed\", message: \"Module dependencies changed.\" });\n\tif (stableStringify(before.policies) !== stableStringify(after.policies)) changes.push({ severity: \"potentially_breaking\", path: \"policies\", code: \"module_policies_changed\", message: \"Module policy definitions changed.\" });\n\tdiffNamed(before.objectTypes, after.objectTypes, \"objectTypes\", \"type\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tconst oldArchetype = oldValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tconst newArchetype = newValue.semantics?.[\"fabric.archetype\"] as { id?: unknown; version?: unknown; stateMap?: unknown } | undefined;\n\t\tif (oldArchetype && !newArchetype) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_removed\", message: \"Archetype certification metadata was removed.\" });\n\t\telse if (oldArchetype && newArchetype && stableStringify(oldArchetype) !== stableStringify(newArchetype)) changes.push({ severity: \"breaking\", path: `${path}.semantics.fabric.archetype`, code: \"archetype_mapping_changed\", message: \"Archetype identity, version, or state mapping changed.\" });\n\t\tdiffNamed(oldValue.relations ?? [], newValue.relations ?? [], `${path}.relations`, \"name\", changes, (oldRelation, newRelation, relationPath) => {\n\t\t\tif (oldRelation.cardinality !== newRelation.cardinality) changes.push({ severity: \"breaking\", path: `${relationPath}.cardinality`, code: \"relation_cardinality_changed\", message: \"Relation cardinality changed.\" });\n\t\t\tif (oldRelation.target !== newRelation.target) changes.push({ severity: \"breaking\", path: `${relationPath}.target`, code: \"relation_target_changed\", message: \"Relation target changed.\" });\n\t\t\tif (!oldRelation.required && newRelation.required) changes.push({ severity: \"breaking\", path: `${relationPath}.required`, code: \"relation_became_required\", message: \"Optional relation became required.\" });\n\t\t\tif (oldRelation.semantics !== newRelation.semantics) changes.push({ severity: \"breaking\", path: `${relationPath}.semantics`, code: \"relation_ownership_changed\", message: \"Relation ownership semantics changed.\" });\n\t\t\tif (oldRelation.onTargetDelete !== newRelation.onTargetDelete) changes.push({ severity: \"breaking\", path: `${relationPath}.onTargetDelete`, code: \"relation_delete_behavior_changed\", message: \"Relation deletion behavior changed.\" });\n\t\t});\n\t\tdiffNamed(oldValue.invariants ?? [], newValue.invariants ?? [], `${path}.invariants`, \"id\", changes, (oldInvariant, newInvariant, invariantPath) => {\n\t\t\tif (oldInvariant.enforcement !== newInvariant.enforcement || oldInvariant.enforcementRef !== newInvariant.enforcementRef) changes.push({ severity: \"potentially_breaking\", path: invariantPath, code: \"invariant_enforcement_changed\", message: \"Invariant enforcement ownership or reference changed.\" });\n\t\t\tif (!oldInvariant.required && newInvariant.required) changes.push({ severity: \"breaking\", path: `${invariantPath}.required`, code: \"invariant_became_required\", message: \"Invariant became required.\" });\n\t\t});\n\t});\n\tdiffNamed(before.actions, after.actions, \"actions\", \"actionId\", changes, (oldValue, newValue, path) => {\n\t\tdiffSchema(oldValue.parameterSchema as PortableJsonSchema | undefined, newValue.parameterSchema as PortableJsonSchema | undefined, `${path}.parameterSchema`, changes);\n\t\tdiffSchema(oldValue.resultSchema as PortableJsonSchema | undefined, newValue.resultSchema as PortableJsonSchema | undefined, `${path}.resultSchema`, changes);\n\t\tif (stableStringify(oldValue.execution) !== stableStringify(newValue.execution)) changes.push({ severity: oldValue.execution ? \"breaking\" : \"potentially_breaking\", path: `${path}.execution`, code: \"action_execution_changed\", message: \"Action execution semantics changed and hosts or offline consumers must be reviewed.\" });\n\t\tfor (const field of [\"version\", \"kind\", \"idempotent\", \"mutatesDomain\", \"eventPhase\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });\n\t\t}\n\t\tconst oldEvents = new Set(oldValue.emitsEvents);\n\t\tconst newEvents = new Set(newValue.emitsEvents);\n\t\tfor (const event of oldEvents) if (!newEvents.has(event)) changes.push({ severity: \"breaking\", path: `${path}.emitsEvents.${event}`, code: \"action_event_removed\", message: `Declared action event \"${event}\" was removed.` });\n\t\tfor (const event of newEvents) if (!oldEvents.has(event)) changes.push({ severity: \"compatible\", path: `${path}.emitsEvents.${event}`, code: \"action_event_added\", message: `Declared action event \"${event}\" was added.` });\n\t\tfor (const field of [\"policies\", \"requiredRoles\", \"requiredPermissions\", \"stateMachine\", \"adapterSteps\"] as const) {\n\t\t\tif (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed and requires consumer review.` });\n\t\t}\n\t});\n\tdiffNamed(before.eventTypes, after.eventTypes, \"eventTypes\", \"eventType\", changes, (oldValue, newValue, path) => {\n\t\tdiffEventSchema(oldValue.schema, newValue.schema, `${path}.schema`, changes);\n\t\tif (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: \"breaking\", path: `${path}.schemaVersion`, code: \"event_version_decreased\", message: \"Event schema version decreased.\" });\n\t\telse if (oldValue.schemaVersion < newValue.schemaVersion) changes.push({ severity: \"potentially_breaking\", path: `${path}.schemaVersion`, code: \"event_version_changed\", message: \"Event schema version changed; old consumers require compatibility evidence.\" });\n\t});\n\tconst oldViews = new Map(before.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tconst newViews = new Map(after.views.map((view) => [`${view.name}@${view.version}`, view]));\n\tfor (const [key, oldView] of oldViews) {\n\t\tconst newView = newViews.get(key);\n\t\tif (!newView) changes.push({ severity: \"breaking\", path: `views.${key}`, code: \"view_version_removed\", message: `View contract \"${key}\" was removed.` });\n\t\telse {\n\t\t\tdiffSchema(oldView.shape, newView.shape, `views.${key}.shape`, changes);\n\t\t\tif (stableStringify(oldView.usage) !== stableStringify(newView.usage)) changes.push({ severity: \"potentially_breaking\", path: `views.${key}.usage`, code: \"view_usage_changed\", message: \"View usage semantics changed and generated consumers require review.\" });\n\t\t}\n\t}\n\tfor (const key of newViews.keys()) if (!oldViews.has(key)) changes.push({ severity: \"compatible\", path: `views.${key}`, code: \"view_version_added\", message: `View contract \"${key}\" was added.` });\n\tdiffNamed(before.stateMachines, after.stateMachines, \"stateMachines\", \"entityType\", changes, (oldValue, newValue, path) => {\n\t\tconst newStates = new Set(newValue.states.map((state) => state.id));\n\t\tfor (const state of oldValue.states) if (!newStates.has(state.id)) changes.push({ severity: \"breaking\", path: `${path}.states.${state.id}`, code: \"state_removed\", message: `State \"${state.id}\" was removed.` });\n\t\tconst transitions = new Set(newValue.transitions.map((transition) => `${transition.from}->${transition.to}`));\n\t\tfor (const transition of oldValue.transitions) if (!transitions.has(`${transition.from}->${transition.to}`)) changes.push({ severity: \"breaking\", path: `${path}.transitions.${transition.from}->${transition.to}`, code: \"transition_removed\", message: \"A state transition was removed or remapped.\" });\n\t});\n\treturn report(changes);\n}\n\nfunction diffEventSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst start = changes.length;\n\tdiffSchema(before, after, path, changes);\n\tfor (let index = start; index < changes.length; index += 1) {\n\t\tconst change = changes[index]!;\n\t\tchange.code = `event_${change.code}`;\n\t\tchange.message = `Event schema: ${change.message}`;\n\t}\n}\n\nfunction diffStringList(before: string[], after: string[], path: string, changes: CompatibilityChange[]): void {\n\tconst oldValues = new Set(before);\n\tconst newValues = new Set(after);\n\tfor (const value of oldValues) if (!newValues.has(value)) changes.push({ severity: \"breaking\", path: `${path}.${value}`, code: `${path}_removed`, message: `Public ${path} value \"${value}\" was removed.` });\n\tfor (const value of newValues) if (!oldValues.has(value)) changes.push({ severity: \"compatible\", path: `${path}.${value}`, code: `${path}_added`, message: `Public ${path} value \"${value}\" was added.` });\n}\n\nfunction diffNamed<T extends object>(\n\tbefore: T[], after: T[], path: string, key: keyof T, changes: CompatibilityChange[], compare: (before: T, after: T, path: string) => void,\n): void {\n\tconst oldMap = new Map(before.map((value) => [String(value[key]), value]));\n\tconst newMap = new Map(after.map((value) => [String(value[key]), value]));\n\tfor (const [name, value] of oldMap) {\n\t\tconst next = newMap.get(name);\n\t\tif (!next) changes.push({ severity: \"breaking\", path: `${path}.${name}`, code: `${String(key)}_removed`, message: `${String(key)} \"${name}\" was removed.` });\n\t\telse compare(value, next, `${path}.${name}`);\n\t}\n\tfor (const name of newMap.keys()) if (!oldMap.has(name)) changes.push({ severity: \"compatible\", path: `${path}.${name}`, code: `${String(key)}_added`, message: `${String(key)} \"${name}\" was added.` });\n}\n\nfunction diffSchema(before: PortableJsonSchema | undefined, after: PortableJsonSchema | undefined, path: string, changes: CompatibilityChange[]): void {\n\tconst changeCount = changes.length;\n\tif (!before && after) { changes.push({ severity: \"potentially_breaking\", path, code: \"schema_added\", message: \"A schema was added to an existing contract.\" }); return; }\n\tif (before && !after) { changes.push({ severity: \"breaking\", path, code: \"schema_removed\", message: \"An existing schema was removed.\" }); return; }\n\tif (!before || !after) return;\n\tconst oldRequired = new Set(before.required ?? []);\n\tfor (const required of after.required ?? []) if (!oldRequired.has(required)) changes.push({ severity: \"breaking\", path: `${path}.required.${required}`, code: \"required_property_added\", message: `Required property \"${required}\" was added.` });\n\tconst oldProperties = before.properties ?? {};\n\tconst newProperties = after.properties ?? {};\n\tfor (const property of Object.keys(oldProperties)) if (!(property in newProperties)) changes.push({ severity: \"breaking\", path: `${path}.properties.${property}`, code: \"schema_property_removed\", message: `Schema property \"${property}\" was removed.` });\n\tfor (const property of Object.keys(newProperties)) if (!(property in oldProperties)) changes.push({ severity: (after.required ?? []).includes(property) ? \"breaking\" : \"compatible\", path: `${path}.properties.${property}`, code: \"schema_property_added\", message: `Schema property \"${property}\" was added.` });\n\tfor (const property of Object.keys(oldProperties)) {\n\t\tif (newProperties[property]) diffSchema(oldProperties[property], newProperties[property], `${path}.properties.${property}`, changes);\n\t}\n\tif (before.additionalProperties !== false && after.additionalProperties === false) changes.push({ severity: \"breaking\", path: `${path}.additionalProperties`, code: \"additional_properties_forbidden\", message: \"Schema now rejects undeclared properties.\" });\n\tif (before.items && after.items && !Array.isArray(before.items) && !Array.isArray(after.items)) diffSchema(before.items, after.items, `${path}.items`, changes);\n\tfor (const keyword of [\"minimum\", \"maximum\", \"minLength\", \"maxLength\", \"pattern\"] as const) {\n\t\tif (stableStringify(before[keyword]) !== stableStringify(after[keyword])) changes.push({ severity: \"potentially_breaking\", path: `${path}.${keyword}`, code: \"schema_constraint_changed\", message: `Schema constraint \"${keyword}\" changed.` });\n\t}\n\tif (stableStringify(before.type) !== stableStringify(after.type)) {\n\t\tconst oldTypes = new Set(Array.isArray(before.type) ? before.type : before.type ? [before.type] : []);\n\t\tconst newTypes = new Set(Array.isArray(after.type) ? after.type : after.type ? [after.type] : []);\n\t\tconst widened = oldTypes.size > 0 && [...oldTypes].every((type) => newTypes.has(type));\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.type`, code: widened ? \"schema_type_widened\" : \"schema_type_narrowed\", message: widened ? \"Schema type widened; generated consumers may receive a new value type.\" : \"Schema type no longer accepts every prior type.\" });\n\t}\n\tif (before.enum && after.enum && before.enum.some((value) => !after.enum!.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {\n\t\tchanges.push({ severity: \"breaking\", path: `${path}.enum`, code: \"schema_enum_narrowed\", message: \"Schema enum no longer accepts a previously valid value.\" });\n\t}\n\tif (stableStringify(before) !== stableStringify(after) && changes.length === changeCount) changes.push({ severity: \"potentially_breaking\", path, code: \"schema_changed\", message: \"Schema changed and requires consumer review.\" });\n}\n\nfunction report(changes: CompatibilityChange[]): CompatibilityReport {\n\tconst highestSeverity = changes.reduce<CompatibilitySeverity>((highest, change) => severityRank[change.severity] > severityRank[highest] ? change.severity : highest, \"compatible\");\n\treturn { compatible: highestSeverity === \"compatible\", highestSeverity, changes };\n}\n\nexport interface GeneratedFile { path: string; content: string; }\nexport interface GeneratorTarget { name: string; version: string; generate(ir: FabricCompilerIr): GeneratedFile[] | Promise<GeneratedFile[]>; }\n\nexport async function runGenerator(target: GeneratorTarget, ir: FabricCompilerIr): Promise<GeneratedFile[]> {\n\tconst files = await target.generate(ir);\n\tconst paths = new Set<string>();\n\treturn [...files].sort((left, right) => compareCanonicalStrings(left.path, right.path)).map((file) => {\n\t\tif (!file.path || path.isAbsolute(file.path) || path.win32.isAbsolute(file.path) || file.path.includes(\"\\\\\") || file.path.split(\"/\").includes(\"..\")) throw new Error(`Generator \"${target.name}\" returned unsafe path \"${file.path}\".`);\n\t\tif (paths.has(file.path)) throw new Error(`Generator \"${target.name}\" returned duplicate path \"${file.path}\".`);\n\t\tpaths.add(file.path);\n\t\treturn { path: file.path, content: file.content.endsWith(\"\\n\") ? file.content : `${file.content}\\n` };\n\t});\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AACjB;AAAA,EACC;AAAA,EACA;AAAA,OAMM;AAEA,IAAM,0BAA0B;AAChC,IAAM,0BAA0B,CAAC,MAAc,UAA0B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAiChH,SAAS,gBAAgB,OAAwB;AACvD,SAAO,KAAK,UAAU,SAAS,KAAK,CAAC;AACtC;AAEA,SAAS,SAAS,OAA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QAAQ,KAAK,WAAW,KAAK,IAAI,KAAK,KAAK,MAAM,WAAW,KAAK,IAAI,KAAK,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,MAAM,GAAG,EAAE,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,2BAA2B,KAAK,IAAI,IAAI;AACtO,QAAI,MAAM,IAAI,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,cAAc,OAAO,IAAI,8BAA8B,KAAK,IAAI,IAAI;AAC9G,UAAM,IAAI,KAAK,IAAI;AACnB,WAAO,EAAE,MAAM,KAAK,MAAM,SAAS,KAAK,QAAQ,SAAS,IAAI,IAAI,KAAK,UAAU,GAAG,KAAK,OAAO;AAAA,EAAK;AAAA,EACrG,CAAC;AACF;","names":["path"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabricorg/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Deterministic compiler IR and semantic compatibility analysis for Fabric module manifests.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,14 +24,15 @@
|
|
|
24
24
|
"README.md",
|
|
25
25
|
"CHANGELOG.md"
|
|
26
26
|
],
|
|
27
|
-
"
|
|
28
|
-
"@fabricorg/platform": "^0.
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@fabricorg/platform": "^0.12.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.10.0",
|
|
32
32
|
"tsup": "^8.5.0",
|
|
33
33
|
"typescript": "^5.7.3",
|
|
34
|
-
"vitest": "^4.1.5"
|
|
34
|
+
"vitest": "^4.1.5",
|
|
35
|
+
"@fabricorg/platform": "^0.12.0"
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=20"
|