archgraph-argo-beta 0.27.0-beta.4 → 0.27.0-beta.6

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.
@@ -212,6 +212,27 @@ function mergeMatrixInto(target, source) {
212
212
  return target;
213
213
  }
214
214
 
215
+ // Append added types to a JSON-Schema enum def (the element/relationship type
216
+ // universe), so a schema-less inheriting Profile's own added types are structurally
217
+ // valid — not just present at the ontology level.
218
+ function extendSchemaEnum(schemaDocument, enumKeys, additions) {
219
+ const defs = schemaDocument && typeof schemaDocument.$defs === 'object' ? schemaDocument.$defs : null;
220
+ if (!defs) {
221
+ return;
222
+ }
223
+ for (const key of enumKeys) {
224
+ const node = defs[key];
225
+ if (node && Array.isArray(node.enum)) {
226
+ for (const value of additions) {
227
+ if (typeof value === 'string' && value !== '' && !node.enum.includes(value)) {
228
+ node.enum.push(value);
229
+ }
230
+ }
231
+ return;
232
+ }
233
+ }
234
+ }
235
+
215
236
  function mergeExtendsBundle(base, child) {
216
237
  const baseRules = base.rules || {};
217
238
  const childRules = child.rules || {};
@@ -254,7 +275,10 @@ function mergeExtendsBundle(base, child) {
254
275
  mergeMatrixInto(relationshipTargetMatrix, childRules.relationshipTargetMatrix || {});
255
276
  mergeMatrixInto(relationshipTargetMatrix, config.overrideMatrix || {});
256
277
 
257
- const dialect = childRules.dialect || baseRules.dialect || 'archimate-class-matrix';
278
+ // Inherit the base dialect as-is; never default to a specific dialect NAME here
279
+ // (that would couple the generic merge to one modeling language). When both are
280
+ // absent the ontology builder decides from the bundle's declared rules.
281
+ const dialect = childRules.dialect || baseRules.dialect;
258
282
  const rules = {
259
283
  ...baseRules,
260
284
  ...childRules,
@@ -265,13 +289,34 @@ function mergeExtendsBundle(base, child) {
265
289
  relationshipTargetMatrix,
266
290
  };
267
291
 
292
+ // Structural schema: when the child has none, it inherits the base schema — but
293
+ // its added types must be valid against the base's $defs enum too, otherwise
294
+ // whole-graph validation (validateAgainstSchema) rejects elements of the added
295
+ // types. Extend the inherited schema enum in place (clone, never mutate base).
296
+ let schemaDocument = child.schemaDocument || base.schemaDocument;
297
+ if (!child.schemaDocument && base.schemaDocument) {
298
+ const extraElementTypes = Object.keys(addElementTypes).filter(Boolean);
299
+ const extraRelationshipTypes = Object.keys(addRelationships).filter(Boolean);
300
+ const extraFromConfigElements = Array.isArray(config.elementTypes) ? config.elementTypes : [];
301
+ const extraFromConfigRelationships = Array.isArray(config.relationshipTypes) ? config.relationshipTypes : [];
302
+ if (extraElementTypes.length || extraRelationshipTypes.length || extraFromConfigElements.length || extraFromConfigRelationships.length) {
303
+ schemaDocument = deepCloneJson(base.schemaDocument);
304
+ extendSchemaEnum(schemaDocument, ELEMENT_ENUM_KEYS, extraElementTypes.concat(extraFromConfigElements));
305
+ extendSchemaEnum(schemaDocument, RELATIONSHIP_ENUM_KEYS, extraRelationshipTypes.concat(extraFromConfigRelationships));
306
+ }
307
+ }
308
+
268
309
  return {
269
310
  ...child,
270
311
  schema: child.schema || base.schema,
271
- schemaDocument: child.schemaDocument || base.schemaDocument,
312
+ schemaDocument,
272
313
  rules,
273
314
  config,
274
315
  inheritedFrom: base.dir,
316
+ chainDirs: Array.from(new Set([
317
+ ...(Array.isArray(base.chainDirs) && base.chainDirs.length > 0 ? base.chainDirs : [path.resolve(base.dir).toLowerCase()]),
318
+ path.resolve(child.dir).toLowerCase(),
319
+ ])),
275
320
  };
276
321
  }
277
322
 
@@ -766,9 +811,36 @@ function buildOntology(bundle) {
766
811
  return bundle.kind === 'default' ? buildClassMatrixOntology(bundle) : buildTypeMatrixOntology(bundle);
767
812
  }
768
813
 
814
+ // Cheap on-disk fingerprint of a bundle (and its extends chain) so a running MCP
815
+ // picks up edits to the bundle files without a restart: the ontology cache key
816
+ // changes when any key file's mtime/size changes.
817
+ function bundleFingerprint(bundle) {
818
+ const dirs = Array.isArray(bundle.chainDirs) && bundle.chainDirs.length > 0
819
+ ? bundle.chainDirs
820
+ : [path.resolve(bundle.dir).toLowerCase()];
821
+ const statFile = (absolutePath) => {
822
+ try {
823
+ const stat = fs.statSync(absolutePath);
824
+ return `${Math.round(stat.mtimeMs)}:${stat.size}`;
825
+ } catch {
826
+ return '-';
827
+ }
828
+ };
829
+ const parts = [];
830
+ for (const dir of dirs) {
831
+ for (const name of [SCHEMA_BASENAME, CONFIG_BASENAME, RULES_BASENAME]) {
832
+ parts.push(`${name}=${statFile(path.join(dir, name))}`);
833
+ }
834
+ }
835
+ if (bundle.config && typeof bundle.config.rules === 'string' && bundle.config.rules.trim() !== '') {
836
+ parts.push(`rules=${statFile(path.resolve(bundle.dir, bundle.config.rules))}`);
837
+ }
838
+ return parts.join('|');
839
+ }
840
+
769
841
  function loadSchemaBundleAndOntology(workspaceRoot, options = {}) {
770
842
  const bundle = resolveSchemaBundle(workspaceRoot, options);
771
- const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}`;
843
+ const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}:${bundleFingerprint(bundle)}`;
772
844
  if (ontologyCache.has(cacheKey)) {
773
845
  return { bundle, ontology: ontologyCache.get(cacheKey) };
774
846
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archgraph-argo-beta",
3
- "version": "0.27.0-beta.4",
3
+ "version": "0.27.0-beta.6",
4
4
  "description": "Deploy the ArchGraph ARGO toolchain, skills, and rules (schema, scripts, argo-init skill, global rule) with one command.",
5
5
  "license": "MIT",
6
6
  "bin": {