@fabricorg/compiler 0.2.1 → 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 +13 -0
- package/dist/index.cjs +24 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
3
16
|
## 0.2.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
41
41
|
var import_node_crypto = require("crypto");
|
|
42
42
|
var import_node_path = __toESM(require("path"), 1);
|
|
43
43
|
var import_platform = require("@fabricorg/platform");
|
|
44
|
-
var FABRIC_COMPILER_VERSION = "0.
|
|
44
|
+
var FABRIC_COMPILER_VERSION = "1.0.0";
|
|
45
45
|
var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
46
46
|
function stableStringify(value) {
|
|
47
47
|
return JSON.stringify(sortJson(value));
|
|
@@ -102,7 +102,9 @@ function assertCompilerManifests(modules, certificationProfiles) {
|
|
|
102
102
|
for (const view of module2.views) {
|
|
103
103
|
if (!view.name.startsWith(`${module2.namespace}/`)) throw new Error(`View "${view.name}" must use module namespace "${module2.namespace}/".`);
|
|
104
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`);
|
|
105
106
|
}
|
|
107
|
+
for (const eventType of module2.eventTypes) if (eventType.schema) (0, import_platform.assertPortableJsonSchema)(eventType.schema, `Event ${eventType.eventType}@${eventType.schemaVersion}`);
|
|
106
108
|
for (const action of module2.actions) {
|
|
107
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.`);
|
|
108
110
|
if (action.parameterSchema) (0, import_platform.assertPortableJsonSchema)(action.parameterSchema, `Action ${action.actionId} parameters`);
|
|
@@ -162,6 +164,7 @@ function diffModuleManifests(before, after) {
|
|
|
162
164
|
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue, path2) => {
|
|
163
165
|
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${path2}.parameterSchema`, changes);
|
|
164
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." });
|
|
165
168
|
for (const field of ["version", "kind", "idempotent", "mutatesDomain", "eventPhase"]) {
|
|
166
169
|
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });
|
|
167
170
|
}
|
|
@@ -174,6 +177,7 @@ function diffModuleManifests(before, after) {
|
|
|
174
177
|
}
|
|
175
178
|
});
|
|
176
179
|
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue, path2) => {
|
|
180
|
+
diffEventSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
177
181
|
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${path2}.schemaVersion`, code: "event_version_decreased", message: "Event schema version decreased." });
|
|
178
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." });
|
|
179
183
|
});
|
|
@@ -182,7 +186,10 @@ function diffModuleManifests(before, after) {
|
|
|
182
186
|
for (const [key, oldView] of oldViews) {
|
|
183
187
|
const newView = newViews.get(key);
|
|
184
188
|
if (!newView) changes.push({ severity: "breaking", path: `views.${key}`, code: "view_version_removed", message: `View contract "${key}" was removed.` });
|
|
185
|
-
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
|
+
}
|
|
186
193
|
}
|
|
187
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.` });
|
|
188
195
|
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue, path2) => {
|
|
@@ -193,6 +200,15 @@ function diffModuleManifests(before, after) {
|
|
|
193
200
|
});
|
|
194
201
|
return report(changes);
|
|
195
202
|
}
|
|
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
|
+
}
|
|
196
212
|
function diffStringList(before, after, path2, changes) {
|
|
197
213
|
const oldValues = new Set(before);
|
|
198
214
|
const newValues = new Set(after);
|
|
@@ -234,7 +250,12 @@ function diffSchema(before, after, path2, changes) {
|
|
|
234
250
|
for (const keyword of ["minimum", "maximum", "minLength", "maxLength", "pattern"]) {
|
|
235
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.` });
|
|
236
252
|
}
|
|
237
|
-
if (stableStringify(before.type) !== stableStringify(after.type))
|
|
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." });
|
|
258
|
+
}
|
|
238
259
|
if (before.enum && after.enum && before.enum.some((value) => !after.enum.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {
|
|
239
260
|
changes.push({ severity: "breaking", path: `${path2}.enum`, code: "schema_enum_narrowed", message: "Schema enum no longer accepts a previously valid value." });
|
|
240
261
|
}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 = \"0.2.1\";\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}\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\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\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 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)) 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 || 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;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M,OAAO,SAAS,EAAE;AACtC,QAAM,QAAQ,oBAAI,IAAY;AAC9B,SAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,UAAU,wBAAwB,KAAK,MAAM,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS;AACrG,QAAI,CAAC,KAAK,QAAQ,iBAAAA,QAAK,WAAW,KAAK,IAAI,KAAK,iBAAAA,QAAK,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":["module","path"]}
|
|
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,Q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AAI;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","path"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModuleManifest, DeclarativeInvariant, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
2
2
|
|
|
3
|
-
declare const FABRIC_COMPILER_VERSION = "0.
|
|
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;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModuleManifest, DeclarativeInvariant, ModuleManifestBundle, ModuleManifestBundleV1 } from '@fabricorg/platform';
|
|
2
2
|
|
|
3
|
-
declare const FABRIC_COMPILER_VERSION = "0.
|
|
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;
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
normalizeModuleManifestBundle,
|
|
6
6
|
assertPortableJsonSchema
|
|
7
7
|
} from "@fabricorg/platform";
|
|
8
|
-
var FABRIC_COMPILER_VERSION = "0.
|
|
8
|
+
var FABRIC_COMPILER_VERSION = "1.0.0";
|
|
9
9
|
var compareCanonicalStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
10
10
|
function stableStringify(value) {
|
|
11
11
|
return JSON.stringify(sortJson(value));
|
|
@@ -66,7 +66,9 @@ function assertCompilerManifests(modules, certificationProfiles) {
|
|
|
66
66
|
for (const view of module.views) {
|
|
67
67
|
if (!view.name.startsWith(`${module.namespace}/`)) throw new Error(`View "${view.name}" must use module namespace "${module.namespace}/".`);
|
|
68
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`);
|
|
69
70
|
}
|
|
71
|
+
for (const eventType of module.eventTypes) if (eventType.schema) assertPortableJsonSchema(eventType.schema, `Event ${eventType.eventType}@${eventType.schemaVersion}`);
|
|
70
72
|
for (const action of module.actions) {
|
|
71
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.`);
|
|
72
74
|
if (action.parameterSchema) assertPortableJsonSchema(action.parameterSchema, `Action ${action.actionId} parameters`);
|
|
@@ -126,6 +128,7 @@ function diffModuleManifests(before, after) {
|
|
|
126
128
|
diffNamed(before.actions, after.actions, "actions", "actionId", changes, (oldValue, newValue, path2) => {
|
|
127
129
|
diffSchema(oldValue.parameterSchema, newValue.parameterSchema, `${path2}.parameterSchema`, changes);
|
|
128
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." });
|
|
129
132
|
for (const field of ["version", "kind", "idempotent", "mutatesDomain", "eventPhase"]) {
|
|
130
133
|
if (stableStringify(oldValue[field]) !== stableStringify(newValue[field])) changes.push({ severity: "breaking", path: `${path2}.${field}`, code: `action_${field}_changed`, message: `Action ${field} changed.` });
|
|
131
134
|
}
|
|
@@ -138,6 +141,7 @@ function diffModuleManifests(before, after) {
|
|
|
138
141
|
}
|
|
139
142
|
});
|
|
140
143
|
diffNamed(before.eventTypes, after.eventTypes, "eventTypes", "eventType", changes, (oldValue, newValue, path2) => {
|
|
144
|
+
diffEventSchema(oldValue.schema, newValue.schema, `${path2}.schema`, changes);
|
|
141
145
|
if (oldValue.schemaVersion > newValue.schemaVersion) changes.push({ severity: "breaking", path: `${path2}.schemaVersion`, code: "event_version_decreased", message: "Event schema version decreased." });
|
|
142
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." });
|
|
143
147
|
});
|
|
@@ -146,7 +150,10 @@ function diffModuleManifests(before, after) {
|
|
|
146
150
|
for (const [key, oldView] of oldViews) {
|
|
147
151
|
const newView = newViews.get(key);
|
|
148
152
|
if (!newView) changes.push({ severity: "breaking", path: `views.${key}`, code: "view_version_removed", message: `View contract "${key}" was removed.` });
|
|
149
|
-
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
|
+
}
|
|
150
157
|
}
|
|
151
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.` });
|
|
152
159
|
diffNamed(before.stateMachines, after.stateMachines, "stateMachines", "entityType", changes, (oldValue, newValue, path2) => {
|
|
@@ -157,6 +164,15 @@ function diffModuleManifests(before, after) {
|
|
|
157
164
|
});
|
|
158
165
|
return report(changes);
|
|
159
166
|
}
|
|
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
|
+
}
|
|
160
176
|
function diffStringList(before, after, path2, changes) {
|
|
161
177
|
const oldValues = new Set(before);
|
|
162
178
|
const newValues = new Set(after);
|
|
@@ -198,7 +214,12 @@ function diffSchema(before, after, path2, changes) {
|
|
|
198
214
|
for (const keyword of ["minimum", "maximum", "minLength", "maxLength", "pattern"]) {
|
|
199
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.` });
|
|
200
216
|
}
|
|
201
|
-
if (stableStringify(before.type) !== stableStringify(after.type))
|
|
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." });
|
|
222
|
+
}
|
|
202
223
|
if (before.enum && after.enum && before.enum.some((value) => !after.enum.some((newValue) => stableStringify(newValue) === stableStringify(value)))) {
|
|
203
224
|
changes.push({ severity: "breaking", path: `${path2}.enum`, code: "schema_enum_narrowed", message: "Schema enum no longer accepts a previously valid value." });
|
|
204
225
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 = \"0.2.1\";\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}\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\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\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 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)) 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 || 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,O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UAAU,wBAAwB,KAAK,MAAM,MAAM,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS;AACrG,QAAI,CAAC,KAAK,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"]}
|
|
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,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,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,SAAS,8BAA8B,KAAK;AAClD,QAAM,aAAa,oBAAI,IAAY;AACnC,aAAW,UAAU,OAAO,SAAS;AACpC,QAAI,WAAW,IAAI,OAAO,SAAS,EAAG,OAAM,IAAI,MAAM,+BAA+B,OAAO,SAAS,sBAAsB;AAC3H,eAA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
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",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"CHANGELOG.md"
|
|
26
26
|
],
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@fabricorg/platform": "^0.
|
|
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
34
|
"vitest": "^4.1.5",
|
|
35
|
-
"@fabricorg/platform": "^0.
|
|
35
|
+
"@fabricorg/platform": "^0.12.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=20"
|