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

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 || {};
@@ -265,13 +286,34 @@ function mergeExtendsBundle(base, child) {
265
286
  relationshipTargetMatrix,
266
287
  };
267
288
 
289
+ // Structural schema: when the child has none, it inherits the base schema — but
290
+ // its added types must be valid against the base's $defs enum too, otherwise
291
+ // whole-graph validation (validateAgainstSchema) rejects elements of the added
292
+ // types. Extend the inherited schema enum in place (clone, never mutate base).
293
+ let schemaDocument = child.schemaDocument || base.schemaDocument;
294
+ if (!child.schemaDocument && base.schemaDocument) {
295
+ const extraElementTypes = Object.keys(addElementTypes).filter(Boolean);
296
+ const extraRelationshipTypes = Object.keys(addRelationships).filter(Boolean);
297
+ const extraFromConfigElements = Array.isArray(config.elementTypes) ? config.elementTypes : [];
298
+ const extraFromConfigRelationships = Array.isArray(config.relationshipTypes) ? config.relationshipTypes : [];
299
+ if (extraElementTypes.length || extraRelationshipTypes.length || extraFromConfigElements.length || extraFromConfigRelationships.length) {
300
+ schemaDocument = deepCloneJson(base.schemaDocument);
301
+ extendSchemaEnum(schemaDocument, ELEMENT_ENUM_KEYS, extraElementTypes.concat(extraFromConfigElements));
302
+ extendSchemaEnum(schemaDocument, RELATIONSHIP_ENUM_KEYS, extraRelationshipTypes.concat(extraFromConfigRelationships));
303
+ }
304
+ }
305
+
268
306
  return {
269
307
  ...child,
270
308
  schema: child.schema || base.schema,
271
- schemaDocument: child.schemaDocument || base.schemaDocument,
309
+ schemaDocument,
272
310
  rules,
273
311
  config,
274
312
  inheritedFrom: base.dir,
313
+ chainDirs: Array.from(new Set([
314
+ ...(Array.isArray(base.chainDirs) && base.chainDirs.length > 0 ? base.chainDirs : [path.resolve(base.dir).toLowerCase()]),
315
+ path.resolve(child.dir).toLowerCase(),
316
+ ])),
275
317
  };
276
318
  }
277
319
 
@@ -766,9 +808,36 @@ function buildOntology(bundle) {
766
808
  return bundle.kind === 'default' ? buildClassMatrixOntology(bundle) : buildTypeMatrixOntology(bundle);
767
809
  }
768
810
 
811
+ // Cheap on-disk fingerprint of a bundle (and its extends chain) so a running MCP
812
+ // picks up edits to the bundle files without a restart: the ontology cache key
813
+ // changes when any key file's mtime/size changes.
814
+ function bundleFingerprint(bundle) {
815
+ const dirs = Array.isArray(bundle.chainDirs) && bundle.chainDirs.length > 0
816
+ ? bundle.chainDirs
817
+ : [path.resolve(bundle.dir).toLowerCase()];
818
+ const statFile = (absolutePath) => {
819
+ try {
820
+ const stat = fs.statSync(absolutePath);
821
+ return `${Math.round(stat.mtimeMs)}:${stat.size}`;
822
+ } catch {
823
+ return '-';
824
+ }
825
+ };
826
+ const parts = [];
827
+ for (const dir of dirs) {
828
+ for (const name of [SCHEMA_BASENAME, CONFIG_BASENAME, RULES_BASENAME]) {
829
+ parts.push(`${name}=${statFile(path.join(dir, name))}`);
830
+ }
831
+ }
832
+ if (bundle.config && typeof bundle.config.rules === 'string' && bundle.config.rules.trim() !== '') {
833
+ parts.push(`rules=${statFile(path.resolve(bundle.dir, bundle.config.rules))}`);
834
+ }
835
+ return parts.join('|');
836
+ }
837
+
769
838
  function loadSchemaBundleAndOntology(workspaceRoot, options = {}) {
770
839
  const bundle = resolveSchemaBundle(workspaceRoot, options);
771
- const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}`;
840
+ const cacheKey = `${bundle.kind}:${path.resolve(bundle.dir).toLowerCase()}:${bundleFingerprint(bundle)}`;
772
841
  if (ontologyCache.has(cacheKey)) {
773
842
  return { bundle, ontology: ontologyCache.get(cacheKey) };
774
843
  }
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.5",
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": {