@openplanr/protocol 0.6.0 → 0.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openplanr/protocol",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "description": "Canonical OpenPlanr schemas, registries, typed errors, and portable contract validation",
6
6
  "license": "MIT",
@@ -293,7 +293,7 @@
293
293
  "ownerPackage": "openplanr",
294
294
  "source": {
295
295
  "path": "packages/cli/src/cli/commands/diagram/index.ts",
296
- "digest": "sha256:6a5883e12fe9499b343bdff4a481aa94a82f06c4292ed42436e7961eb3883175"
296
+ "digest": "sha256:67aeefb682ad56cf3429a38bd98c913261cea3dbaeaf5e31ab11d873bce4b02a"
297
297
  },
298
298
  "authorityClass": "workflow",
299
299
  "machineJson": true,
@@ -377,7 +377,7 @@
377
377
  "ownerPackage": "openplanr",
378
378
  "source": {
379
379
  "path": "docs/generated/utility-command-catalog.json",
380
- "digest": "sha256:3ef32f1b1c3b37ae665bb0328b736cafcc1ad40a158875a8c7f32a7de1da1f54"
380
+ "digest": "sha256:02c19f6bd7d805e1d101c020f64270b17c785b8bffb36184da57a20755b21960"
381
381
  },
382
382
  "authorityClass": "workflow",
383
383
  "machineJson": false,
@@ -482,7 +482,7 @@
482
482
  "ownerPackage": "openplanr",
483
483
  "source": {
484
484
  "path": "packages/cli/src/cli/commands/init-deterministic.ts",
485
- "digest": "sha256:6212d9f0582ab4a8d475b479aae52ed0fedb877c60038b9f88a309d7b93bafd9"
485
+ "digest": "sha256:7bd117fac77363d2233cf91e8ae280cff7da04b6671ad4e0b3bc39af07701747"
486
486
  },
487
487
  "authorityClass": "workflow",
488
488
  "machineJson": false,
@@ -566,7 +566,7 @@
566
566
  "ownerPackage": "openplanr",
567
567
  "source": {
568
568
  "path": "docs/generated/utility-command-catalog.json",
569
- "digest": "sha256:3ef32f1b1c3b37ae665bb0328b736cafcc1ad40a158875a8c7f32a7de1da1f54"
569
+ "digest": "sha256:02c19f6bd7d805e1d101c020f64270b17c785b8bffb36184da57a20755b21960"
570
570
  },
571
571
  "authorityClass": "workflow",
572
572
  "machineJson": true,
@@ -965,7 +965,7 @@
965
965
  "ownerPackage": "openplanr",
966
966
  "source": {
967
967
  "path": "packages/cli/src/cli/commands/upgrade.ts",
968
- "digest": "sha256:5f559c4d6bf7a1b31477f71c195d086021a8f4b8bc62ba78e6eeb6b5f1b1ac5c"
968
+ "digest": "sha256:9b644add6535f982df30767f511404592edda7e813fbfcf93b167fcc38ef00fe"
969
969
  },
970
970
  "authorityClass": "workflow",
971
971
  "machineJson": false,
@@ -1948,5 +1948,5 @@
1948
1948
  ]
1949
1949
  }
1950
1950
  ],
1951
- "documentDigest": "sha256:ae3955232bf3a97fd1cae7ca01deec957232a64c0c2c3c2fb25a14963c93e310"
1951
+ "documentDigest": "sha256:e7321cb2a962c7fe7906034eb3e0c09bbf6e85de52b779faa44a50d5584cff4d"
1952
1952
  }
@@ -803,7 +803,7 @@
803
803
  {
804
804
  "skillId": "planr-diagram",
805
805
  "skillVersion": "1.1.0",
806
- "description": "Create, inspect, verify, or rerender professional offline diagrams. Use for architecture, process, sequence, data, state, or relationship visuals from intent or source.",
806
+ "description": "Create, edit, inspect, verify, or rerender professional offline diagrams. Use for architecture, process, sequence, data, state, or relationship visuals from intent or source.",
807
807
  "lifecycle": "active",
808
808
  "authorityClass": "artifact-authoring",
809
809
  "source": "skills/planr-diagram/openplanr.skill.json",
@@ -1664,5 +1664,5 @@
1664
1664
  }
1665
1665
  ],
1666
1666
  "compatibilityAliases": [],
1667
- "documentDigest": "sha256:0da63b57a763dda5fb771e48109adb301e20c1f3bea6c423dc77361f421a4562"
1667
+ "documentDigest": "sha256:b1abd9ebb9b724c02ec359e67ec05ebefb38d5b5a64ed04b415fce41b58de5cc"
1668
1668
  }
package/src/contracts.mjs CHANGED
@@ -672,9 +672,18 @@ export function assertOperateIntelligencePlanContractV2(value) {
672
672
  const schemaCache = new Map();
673
673
  const canonicalSchemaPrefix = 'https://openplanr.dev/';
674
674
 
675
+ function deepFreeze(value) {
676
+ if (value && typeof value === 'object' && !Object.isFrozen(value)) {
677
+ for (const nested of Object.values(value)) deepFreeze(nested);
678
+ Object.freeze(value);
679
+ }
680
+ return value;
681
+ }
682
+
683
+ // Validation reads the cached schema in place, so the cache must be immutable.
675
684
  function loadSchema(path) {
676
685
  if (!schemaCache.has(path)) {
677
- schemaCache.set(path, JSON.parse(readFileSync(join(packageRoot, path), 'utf8')));
686
+ schemaCache.set(path, deepFreeze(JSON.parse(readFileSync(join(packageRoot, path), 'utf8'))));
678
687
  }
679
688
  return schemaCache.get(path);
680
689
  }
@@ -748,7 +757,7 @@ export function assertOperateRoleOutputContractV2(roleId, outputContract, { role
748
757
  );
749
758
  }
750
759
  }
751
- const schema = resolveProtocolSchema(expected.schemaId, { protocolVersion: expected.schemaVersion });
760
+ const schema = sharedProtocolSchema(expected.schemaId, expected.schemaVersion);
752
761
  return {
753
762
  ...structuredClone(expected),
754
763
  path: schema.path,
@@ -831,7 +840,7 @@ export function listProtocolSchemas() {
831
840
  ));
832
841
  }
833
842
 
834
- export function resolveProtocolSchema(kind, { protocolVersion } = {}) {
843
+ function sharedProtocolSchema(kind, protocolVersion) {
835
844
  const versions = PROTOCOL_SCHEMA_REGISTRY[kind];
836
845
  if (!versions) throw new PipelineError('E_SCHEMA_UNKNOWN', `Unknown protocol artifact kind: ${kind}`);
837
846
  const path = versions[protocolVersion];
@@ -842,11 +851,10 @@ export function resolveProtocolSchema(kind, { protocolVersion } = {}) {
842
851
  `Supported versions: ${Object.keys(versions).join(', ')}.`,
843
852
  );
844
853
  }
845
- return { kind, protocolVersion, path, schema: structuredClone(loadSchema(path)) };
854
+ return { kind, protocolVersion, path, schema: loadSchema(path) };
846
855
  }
847
856
 
848
- /** Resolve a public experience schema without adding it to the 61-contract runtime kernel. */
849
- export function resolveOperateExperienceSchemaV2(kind, { protocolVersion } = {}) {
857
+ function sharedOperateExperienceSchemaV2(kind, protocolVersion) {
850
858
  const versions = experiencePaths[kind];
851
859
  if (!versions) throw new PipelineError('E_SCHEMA_UNKNOWN', `Unknown Operate experience artifact kind: ${kind}`);
852
860
  if (protocolVersion !== '2.0.0') {
@@ -859,7 +867,19 @@ export function resolveOperateExperienceSchemaV2(kind, { protocolVersion } = {})
859
867
  );
860
868
  }
861
869
  const path = versions[protocolVersion];
862
- return { kind, protocolVersion, path, schema: structuredClone(loadSchema(path)) };
870
+ return { kind, protocolVersion, path, schema: loadSchema(path) };
871
+ }
872
+
873
+ // Public resolvers hand out a mutable copy so callers can never reach the cache.
874
+ const withSchemaCopy = (resolved) => ({ ...resolved, schema: structuredClone(resolved.schema) });
875
+
876
+ export function resolveProtocolSchema(kind, { protocolVersion } = {}) {
877
+ return withSchemaCopy(sharedProtocolSchema(kind, protocolVersion));
878
+ }
879
+
880
+ /** Resolve a public experience schema without adding it to the 61-contract runtime kernel. */
881
+ export function resolveOperateExperienceSchemaV2(kind, { protocolVersion } = {}) {
882
+ return withSchemaCopy(sharedOperateExperienceSchemaV2(kind, protocolVersion));
863
883
  }
864
884
 
865
885
  function validateResolvedArtifact(value, resolved) {
@@ -870,7 +890,7 @@ function validateResolvedArtifact(value, resolved) {
870
890
  typeof base === 'string' && !base.startsWith('https://') ? base : resolved.path,
871
891
  reference,
872
892
  );
873
- const rootSchema = structuredClone(loadSchema(path));
893
+ const rootSchema = loadSchema(path);
874
894
  const schema = resolveSchemaFragment(rootSchema, reference);
875
895
  return { schema, rootSchema, base: path };
876
896
  },
@@ -916,7 +936,7 @@ export function validateProtocolArtifact(kind, value, { protocolVersion } = {})
916
936
  if (version === '1.13.0' && authoringKind) {
917
937
  return validateDiagramAuthoringArtifact(kind, value);
918
938
  }
919
- const resolved = resolveProtocolSchema(kind, { protocolVersion: version });
939
+ const resolved = sharedProtocolSchema(kind, version);
920
940
  const errors = validateResolvedArtifact(value, resolved);
921
941
  if (kind === 'guided-questionnaire' && version === '1.2.0') {
922
942
  errors.push(...guidedQuestionnaireCompatibilityErrors(value));
@@ -979,7 +999,7 @@ export function assertDashboardBootstrapV1(value) {
979
999
  }
980
1000
 
981
1001
  export function validateOperateExperienceArtifactV2(kind, value) {
982
- const resolved = resolveOperateExperienceSchemaV2(kind, { protocolVersion: '2.0.0' });
1002
+ const resolved = sharedOperateExperienceSchemaV2(kind, '2.0.0');
983
1003
  return validateResolvedArtifact(value, resolved);
984
1004
  }
985
1005
 
@@ -1444,7 +1444,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1444
1444
  "ownerPackage": "openplanr",
1445
1445
  "source": {
1446
1446
  "path": "packages/cli/src/cli/commands/diagram/index.ts",
1447
- "digest": "sha256:6a5883e12fe9499b343bdff4a481aa94a82f06c4292ed42436e7961eb3883175"
1447
+ "digest": "sha256:67aeefb682ad56cf3429a38bd98c913261cea3dbaeaf5e31ab11d873bce4b02a"
1448
1448
  },
1449
1449
  "authorityClass": "workflow",
1450
1450
  "machineJson": true,
@@ -1528,7 +1528,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1528
1528
  "ownerPackage": "openplanr",
1529
1529
  "source": {
1530
1530
  "path": "docs/generated/utility-command-catalog.json",
1531
- "digest": "sha256:3ef32f1b1c3b37ae665bb0328b736cafcc1ad40a158875a8c7f32a7de1da1f54"
1531
+ "digest": "sha256:02c19f6bd7d805e1d101c020f64270b17c785b8bffb36184da57a20755b21960"
1532
1532
  },
1533
1533
  "authorityClass": "workflow",
1534
1534
  "machineJson": false,
@@ -1633,7 +1633,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1633
1633
  "ownerPackage": "openplanr",
1634
1634
  "source": {
1635
1635
  "path": "packages/cli/src/cli/commands/init-deterministic.ts",
1636
- "digest": "sha256:6212d9f0582ab4a8d475b479aae52ed0fedb877c60038b9f88a309d7b93bafd9"
1636
+ "digest": "sha256:7bd117fac77363d2233cf91e8ae280cff7da04b6671ad4e0b3bc39af07701747"
1637
1637
  },
1638
1638
  "authorityClass": "workflow",
1639
1639
  "machineJson": false,
@@ -1717,7 +1717,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
1717
1717
  "ownerPackage": "openplanr",
1718
1718
  "source": {
1719
1719
  "path": "docs/generated/utility-command-catalog.json",
1720
- "digest": "sha256:3ef32f1b1c3b37ae665bb0328b736cafcc1ad40a158875a8c7f32a7de1da1f54"
1720
+ "digest": "sha256:02c19f6bd7d805e1d101c020f64270b17c785b8bffb36184da57a20755b21960"
1721
1721
  },
1722
1722
  "authorityClass": "workflow",
1723
1723
  "machineJson": true,
@@ -2116,7 +2116,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
2116
2116
  "ownerPackage": "openplanr",
2117
2117
  "source": {
2118
2118
  "path": "packages/cli/src/cli/commands/upgrade.ts",
2119
- "digest": "sha256:5f559c4d6bf7a1b31477f71c195d086021a8f4b8bc62ba78e6eeb6b5f1b1ac5c"
2119
+ "digest": "sha256:9b644add6535f982df30767f511404592edda7e813fbfcf93b167fcc38ef00fe"
2120
2120
  },
2121
2121
  "authorityClass": "workflow",
2122
2122
  "machineJson": false,
@@ -3099,7 +3099,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
3099
3099
  ]
3100
3100
  }
3101
3101
  ],
3102
- "documentDigest": "sha256:ae3955232bf3a97fd1cae7ca01deec957232a64c0c2c3c2fb25a14963c93e310"
3102
+ "documentDigest": "sha256:e7321cb2a962c7fe7906034eb3e0c09bbf6e85de52b779faa44a50d5584cff4d"
3103
3103
  },
3104
3104
  "skills.json": {
3105
3105
  "kind": "skill-catalog",
@@ -3906,7 +3906,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
3906
3906
  {
3907
3907
  "skillId": "planr-diagram",
3908
3908
  "skillVersion": "1.1.0",
3909
- "description": "Create, inspect, verify, or rerender professional offline diagrams. Use for architecture, process, sequence, data, state, or relationship visuals from intent or source.",
3909
+ "description": "Create, edit, inspect, verify, or rerender professional offline diagrams. Use for architecture, process, sequence, data, state, or relationship visuals from intent or source.",
3910
3910
  "lifecycle": "active",
3911
3911
  "authorityClass": "artifact-authoring",
3912
3912
  "source": "skills/planr-diagram/openplanr.skill.json",
@@ -4767,7 +4767,7 @@ export const CANONICAL_REGISTRIES = deepFreeze({
4767
4767
  }
4768
4768
  ],
4769
4769
  "compatibilityAliases": [],
4770
- "documentDigest": "sha256:0da63b57a763dda5fb771e48109adb301e20c1f3bea6c423dc77361f421a4562"
4770
+ "documentDigest": "sha256:b1abd9ebb9b724c02ec359e67ec05ebefb38d5b5a64ed04b415fce41b58de5cc"
4771
4771
  },
4772
4772
  "outputs.json": {
4773
4773
  "kind": "output-catalog",