@primmel/primmel 1.9.1 → 1.10.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.
@@ -14581,8 +14581,36 @@ function composePackage(rootDir, options, rootManifest, withProvenance = false)
14581
14581
  provenance.get(field).set(key, order[0]);
14582
14582
  }
14583
14583
  }
14584
+ const ownedScopes = /* @__PURE__ */ new Map();
14585
+ const harvestScopes = (id, ctx) => {
14586
+ for (const key of Object.keys(ctx.requirementClasses)) {
14587
+ if (!ownedScopes.has(key)) {
14588
+ ownedScopes.set(key, id);
14589
+ }
14590
+ }
14591
+ };
14592
+ const pinGuard = (id, next) => {
14593
+ if (ownedScopes.size === 0) {
14594
+ return;
14595
+ }
14596
+ for (const field of ["requirementClasses", "requirements"]) {
14597
+ const label = field === "requirementClasses" ? "requirement class" : "requirement";
14598
+ for (const key of Object.keys(next[field])) {
14599
+ for (const [scope, owner] of ownedScopes) {
14600
+ if (key.startsWith(scope + "/")) {
14601
+ throw new CompositionError(
14602
+ "namespace-pin-violation",
14603
+ `package "${id}" declares ${label} "${key}" under the requirement namespace "${scope}" owned by package "${owner}" \u2014 a layer-owned namespace is single-sourced: a downstream package may reference its provisions, never declare scopes or requirements at or under it (namespace-pin-violation)`
14604
+ );
14605
+ }
14606
+ }
14607
+ }
14608
+ }
14609
+ };
14610
+ harvestScopes(order[0], acc);
14584
14611
  for (const id of order.slice(1)) {
14585
14612
  const next = ctxs.get(id);
14613
+ pinGuard(id, next);
14586
14614
  for (const field of MERGE_FIELDS) {
14587
14615
  const target = acc[field];
14588
14616
  const pm = provenance.get(field);
@@ -14607,6 +14635,7 @@ function composePackage(rootDir, options, rootManifest, withProvenance = false)
14607
14635
  if (!acc.metadata && next.metadata) {
14608
14636
  acc.metadata = next.metadata;
14609
14637
  }
14638
+ harvestScopes(id, next);
14610
14639
  }
14611
14640
  for (const id of order) {
14612
14641
  const m = manifests.get(id);
@@ -16398,6 +16427,19 @@ var CHECK_RULES = [
16398
16427
  "normal",
16399
16428
  "TODO.roadmap/05"
16400
16429
  ),
16430
+ // C119 (the smart AGENTS.d/07 pin doctrine, TODO.editor/05 Q3): a
16431
+ // requirement scope a composed package declares is OWNED by that
16432
+ // package — a downstream package may reference its provisions, never
16433
+ // declare a requirement class or requirement at or under the owned
16434
+ // namespace (the strict-descendant leg; the exact-id leg is C28).
16435
+ R(
16436
+ "C119",
16437
+ "namespace-pin-violation",
16438
+ "composition",
16439
+ "error",
16440
+ "normal",
16441
+ "smart AGENTS.d/07 (TODO.editor/05 Q3)"
16442
+ ),
16401
16443
  // ── quantities / time / duality (TODO.roadmap/06) ─────────────────
16402
16444
  R(
16403
16445
  "C32",
@@ -18179,7 +18221,8 @@ function checkPackage(dir, options = {}) {
18179
18221
  "uses-resolves": "C27",
18180
18222
  "uses-no-redefine": "C28",
18181
18223
  "uses-cycle": "C29",
18182
- "requires-satisfied": "C31"
18224
+ "requires-satisfied": "C31",
18225
+ "namespace-pin-violation": "C119"
18183
18226
  };
18184
18227
  let standard;
18185
18228
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primmel/primmel",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "description": "Primmel — parser, types, and serializer for the Primmel modelling language (successor to MMEL)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",