@primmel/primmel 1.20.0 → 1.21.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.
Files changed (141) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +7 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/check-rules.d.ts +1 -1
  6. package/dist/src/check-rules.d.ts.map +1 -1
  7. package/dist/src/check-rules.js +36 -15
  8. package/dist/src/check-rules.js.map +1 -1
  9. package/dist/src/check.d.ts +4 -0
  10. package/dist/src/check.d.ts.map +1 -1
  11. package/dist/src/check.js +446 -138
  12. package/dist/src/check.js.map +1 -1
  13. package/dist/src/export/cddal.d.ts +25 -0
  14. package/dist/src/export/cddal.d.ts.map +1 -0
  15. package/dist/src/export/cddal.js +213 -0
  16. package/dist/src/export/cddal.js.map +1 -0
  17. package/dist/src/export/retrieval.d.ts +147 -6
  18. package/dist/src/export/retrieval.d.ts.map +1 -1
  19. package/dist/src/export/retrieval.js +254 -25
  20. package/dist/src/export/retrieval.js.map +1 -1
  21. package/dist/src/export/unitsdb.d.ts +19 -0
  22. package/dist/src/export/unitsdb.d.ts.map +1 -0
  23. package/dist/src/export/unitsdb.js +82 -0
  24. package/dist/src/export/unitsdb.js.map +1 -0
  25. package/dist/src/export/yaml-lite.d.ts +13 -0
  26. package/dist/src/export/yaml-lite.d.ts.map +1 -0
  27. package/dist/src/export/yaml-lite.js +219 -0
  28. package/dist/src/export/yaml-lite.js.map +1 -0
  29. package/dist/src/instance-resolution.d.ts +19 -0
  30. package/dist/src/instance-resolution.d.ts.map +1 -1
  31. package/dist/src/instance-resolution.js +87 -1
  32. package/dist/src/instance-resolution.js.map +1 -1
  33. package/dist/src/model-diff.d.ts.map +1 -1
  34. package/dist/src/model-diff.js +0 -5
  35. package/dist/src/model-diff.js.map +1 -1
  36. package/dist/src/runtime.d.ts +143 -0
  37. package/dist/src/runtime.d.ts.map +1 -0
  38. package/dist/src/runtime.js +648 -0
  39. package/dist/src/runtime.js.map +1 -0
  40. package/dist/src/ser-des/config/artifact.d.ts.map +1 -1
  41. package/dist/src/ser-des/config/artifact.js +6 -0
  42. package/dist/src/ser-des/config/artifact.js.map +1 -1
  43. package/dist/src/ser-des/config/attestation.d.ts +5 -0
  44. package/dist/src/ser-des/config/attestation.d.ts.map +1 -0
  45. package/dist/src/ser-des/config/attestation.js +143 -0
  46. package/dist/src/ser-des/config/attestation.js.map +1 -0
  47. package/dist/src/ser-des/config/certificateTemplate.d.ts.map +1 -1
  48. package/dist/src/ser-des/config/certificateTemplate.js +7 -1
  49. package/dist/src/ser-des/config/certificateTemplate.js.map +1 -1
  50. package/dist/src/ser-des/config/data.d.ts.map +1 -1
  51. package/dist/src/ser-des/config/data.js +98 -0
  52. package/dist/src/ser-des/config/data.js.map +1 -1
  53. package/dist/src/ser-des/config/documentModule.js +5 -5
  54. package/dist/src/ser-des/config/documentModule.js.map +1 -1
  55. package/dist/src/ser-des/config/index.d.ts +8 -0
  56. package/dist/src/ser-des/config/index.d.ts.map +1 -1
  57. package/dist/src/ser-des/config/index.js +22 -49
  58. package/dist/src/ser-des/config/index.js.map +1 -1
  59. package/dist/src/ser-des/config/instance.d.ts.map +1 -1
  60. package/dist/src/ser-des/config/instance.js +24 -0
  61. package/dist/src/ser-des/config/instance.js.map +1 -1
  62. package/dist/src/ser-des/config/process.d.ts.map +1 -1
  63. package/dist/src/ser-des/config/process.js +8 -0
  64. package/dist/src/ser-des/config/process.js.map +1 -1
  65. package/dist/src/ser-des/config/processSequence.d.ts +19 -0
  66. package/dist/src/ser-des/config/processSequence.d.ts.map +1 -0
  67. package/dist/src/ser-des/config/processSequence.js +77 -0
  68. package/dist/src/ser-des/config/processSequence.js.map +1 -0
  69. package/dist/src/ser-des/config/quantity.d.ts +4 -1
  70. package/dist/src/ser-des/config/quantity.d.ts.map +1 -1
  71. package/dist/src/ser-des/config/quantity.js +63 -1
  72. package/dist/src/ser-des/config/quantity.js.map +1 -1
  73. package/dist/src/ser-des/config/subject.d.ts.map +1 -1
  74. package/dist/src/ser-des/config/subject.js +20 -0
  75. package/dist/src/ser-des/config/subject.js.map +1 -1
  76. package/dist/src/ser-des/index.d.ts +4 -1
  77. package/dist/src/ser-des/index.d.ts.map +1 -1
  78. package/dist/src/ser-des/index.js +3 -1
  79. package/dist/src/ser-des/index.js.map +1 -1
  80. package/dist/src/ser-des/package.d.ts.map +1 -1
  81. package/dist/src/ser-des/package.js +24 -7
  82. package/dist/src/ser-des/package.js.map +1 -1
  83. package/dist/src/ser-des/parse.d.ts +24 -0
  84. package/dist/src/ser-des/parse.d.ts.map +1 -1
  85. package/dist/src/ser-des/parse.js +69 -33
  86. package/dist/src/ser-des/parse.js.map +1 -1
  87. package/dist/src/ser-des/shape-front-end.d.ts +8 -0
  88. package/dist/src/ser-des/shape-front-end.d.ts.map +1 -0
  89. package/dist/src/ser-des/shape-front-end.js +215 -0
  90. package/dist/src/ser-des/shape-front-end.js.map +1 -0
  91. package/dist/src/ser-des/types.d.ts +4 -10
  92. package/dist/src/ser-des/types.d.ts.map +1 -1
  93. package/dist/src/types/Artifact.d.ts +7 -0
  94. package/dist/src/types/Artifact.d.ts.map +1 -1
  95. package/dist/src/types/Attestation.d.ts +60 -0
  96. package/dist/src/types/Attestation.d.ts.map +1 -0
  97. package/dist/src/types/Attestation.js +20 -0
  98. package/dist/src/types/Attestation.js.map +1 -0
  99. package/dist/src/types/CertificateTemplate.d.ts +4 -0
  100. package/dist/src/types/CertificateTemplate.d.ts.map +1 -1
  101. package/dist/src/types/DocumentModule.d.ts +1 -1
  102. package/dist/src/types/DocumentModule.d.ts.map +1 -1
  103. package/dist/src/types/Instance.d.ts +6 -2
  104. package/dist/src/types/Instance.d.ts.map +1 -1
  105. package/dist/src/types/ProcessModel.d.ts +0 -11
  106. package/dist/src/types/ProcessModel.d.ts.map +1 -1
  107. package/dist/src/types/ProcessModel.js +2 -28
  108. package/dist/src/types/ProcessModel.js.map +1 -1
  109. package/dist/src/types/Quantity.d.ts +22 -0
  110. package/dist/src/types/Quantity.d.ts.map +1 -1
  111. package/dist/src/types/Standard.d.ts +2 -13
  112. package/dist/src/types/Standard.d.ts.map +1 -1
  113. package/dist/src/types/Subject.d.ts +18 -0
  114. package/dist/src/types/Subject.d.ts.map +1 -1
  115. package/dist/src/types/data.d.ts +13 -0
  116. package/dist/src/types/data.d.ts.map +1 -1
  117. package/dist/src/types/process.d.ts +8 -0
  118. package/dist/src/types/process.d.ts.map +1 -1
  119. package/dist-browser/index.mjs +1756 -1832
  120. package/dist-cli/primmel.mjs +1659 -847
  121. package/package.json +15 -3
  122. package/dist/src/ser-des/config/processModel.d.ts +0 -13
  123. package/dist/src/ser-des/config/processModel.d.ts.map +0 -1
  124. package/dist/src/ser-des/config/processModel.js +0 -163
  125. package/dist/src/ser-des/config/processModel.js.map +0 -1
  126. package/dist/src/ser-des/config/storyline.d.ts +0 -7
  127. package/dist/src/ser-des/config/storyline.d.ts.map +0 -1
  128. package/dist/src/ser-des/config/storyline.js +0 -264
  129. package/dist/src/ser-des/config/storyline.js.map +0 -1
  130. package/dist/src/ser-des/config/workflowConfig.d.ts +0 -5
  131. package/dist/src/ser-des/config/workflowConfig.d.ts.map +0 -1
  132. package/dist/src/ser-des/config/workflowConfig.js +0 -129
  133. package/dist/src/ser-des/config/workflowConfig.js.map +0 -1
  134. package/dist/src/ser-des/config/workflowStage.d.ts +0 -5
  135. package/dist/src/ser-des/config/workflowStage.d.ts.map +0 -1
  136. package/dist/src/ser-des/config/workflowStage.js +0 -96
  137. package/dist/src/ser-des/config/workflowStage.js.map +0 -1
  138. package/dist/src/types/Storyline.d.ts +0 -62
  139. package/dist/src/types/Storyline.d.ts.map +0 -1
  140. package/dist/src/types/Storyline.js +0 -51
  141. package/dist/src/types/Storyline.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // scripts/check.mts
4
- import { existsSync as existsSync7, readdirSync as readdirSync6, statSync as statSync4, writeFileSync } from "node:fs";
5
- import { join as join7 } from "node:path";
4
+ import { existsSync as existsSync8, readdirSync as readdirSync7, statSync as statSync4, writeFileSync } from "node:fs";
5
+ import { join as join9 } from "node:path";
6
6
 
7
7
  // src/check.ts
8
8
  import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
@@ -186,6 +186,52 @@ function createDuplicateIdChecker() {
186
186
  // src/ser-des/parse.ts
187
187
  function parse(mmelString, parsers, options = {}) {
188
188
  const tokens = tokenizeWithPositions(mmelString);
189
+ const declarations = [];
190
+ let i = 0;
191
+ while (i < tokens.length) {
192
+ const tok = tokens[i++];
193
+ const cfg = parsers[tok.value];
194
+ if (!cfg) {
195
+ if (options.strict) {
196
+ throw new Error(
197
+ `Unknown keyword "${tok.value}" at line ${tok.start.line} col ${tok.start.col}. Use lenient mode (default) to skip unknown keywords.`
198
+ );
199
+ }
200
+ continue;
201
+ }
202
+ if (cfg.takesID) {
203
+ if (i + 1 > tokens.length) {
204
+ throw new Error(
205
+ `Keyword "${tok.value}" at line ${tok.start.line} col ${tok.start.col} expects an ID and payload, but only ${tokens.length - i + 1} token(s) remain.`
206
+ );
207
+ }
208
+ const idTok = tokens[i++];
209
+ const payloadTok = tokens[i++];
210
+ declarations.push({
211
+ keyword: tok.value,
212
+ id: idTok.value,
213
+ payload: payloadTok.value,
214
+ start: tok.start,
215
+ end: payloadTok.end
216
+ });
217
+ } else {
218
+ if (i >= tokens.length) {
219
+ throw new Error(
220
+ `Keyword "${tok.value}" at line ${tok.start.line} col ${tok.start.col} expects a payload, but no tokens remain.`
221
+ );
222
+ }
223
+ const payloadTok = tokens[i++];
224
+ declarations.push({
225
+ keyword: tok.value,
226
+ payload: payloadTok.value,
227
+ start: tok.start,
228
+ end: payloadTok.end
229
+ });
230
+ }
231
+ }
232
+ return parseDeclarations(declarations, parsers, options);
233
+ }
234
+ function parseDeclarations(declarations, parsers, options = {}) {
189
235
  const dupChecker = createDuplicateIdChecker();
190
236
  const constructs = [];
191
237
  let ctx = {
@@ -196,7 +242,6 @@ function parse(mmelString, parsers, options = {}) {
196
242
  roles: {},
197
243
  processes: {},
198
244
  // The abstract-process models (smart TODO.roadmap/40 batch 2)
199
- processModels: {},
200
245
  pages: {},
201
246
  gateways: {},
202
247
  regs: {},
@@ -258,11 +303,10 @@ function parse(mmelString, parsers, options = {}) {
258
303
  evaluationDimensions: {},
259
304
  evaluationProfiles: {},
260
305
  // The certificate rendering contract (batch 3)
306
+ attestations: {},
261
307
  certificateTemplates: {},
262
308
  // The certification workflow step register (batch 3)
263
- workflowConfigs: {},
264
309
  // The named pipeline stages (batch 5)
265
- workflowStages: {},
266
310
  // The verification pathways (batch 3)
267
311
  verificationPathways: {},
268
312
  // The selection rules (batch 3)
@@ -298,8 +342,6 @@ function parse(mmelString, parsers, options = {}) {
298
342
  documentModules: {},
299
343
  informativeAnnexes: {},
300
344
  partAnnexes: {},
301
- demoWorlds: {},
302
- storylines: {},
303
345
  // Primmel v3 twin interface (TODO.roadmap/32)
304
346
  connectorProfiles: {},
305
347
  // Primmel v3 continuous compliance (TODO.roadmap/34)
@@ -322,11 +364,23 @@ function parse(mmelString, parsers, options = {}) {
322
364
  // Issue collection (duplicate IDs, etc.)
323
365
  issues: []
324
366
  };
325
- let i = 0;
326
- while (i < tokens.length) {
327
- const tok = tokens[i++];
328
- const keyword = tok.value;
367
+ for (const decl of declarations) {
368
+ const tok = { start: decl.start };
369
+ const keyword = decl.keyword;
329
370
  const cfg = parsers[keyword];
371
+ if (cfg?.deprecated) {
372
+ ctx.issues.push({
373
+ severity: "warning",
374
+ code: "construct-deprecated",
375
+ construct: keyword,
376
+ message: `construct "${keyword}" at line ${tok.start.line} col ${tok.start.col} is deprecated: ${cfg.deprecated} (construct-deprecated)`,
377
+ position: {
378
+ line: tok.start.line,
379
+ col: tok.start.col,
380
+ offset: tok.start.offset
381
+ }
382
+ });
383
+ }
330
384
  if (!cfg) {
331
385
  if (options.strict) {
332
386
  throw new Error(
@@ -337,13 +391,8 @@ function parse(mmelString, parsers, options = {}) {
337
391
  }
338
392
  let updateCtx;
339
393
  if (cfg.takesID) {
340
- if (i + 1 > tokens.length) {
341
- throw new Error(
342
- `Keyword "${keyword}" at line ${tok.start.line} col ${tok.start.col} expects an ID and payload, but only ${tokens.length - i + 1} token(s) remain.`
343
- );
344
- }
345
- const idTok = tokens[i++];
346
- const payloadTok = tokens[i++];
394
+ const idTok = { value: decl.id ?? "", start: decl.start };
395
+ const payloadTok = { value: decl.payload ?? "", end: decl.start };
347
396
  if (cfg.field) {
348
397
  const issue = dupChecker.check(
349
398
  cfg.field,
@@ -361,24 +410,19 @@ function parse(mmelString, parsers, options = {}) {
361
410
  id: idTok.value,
362
411
  keyword,
363
412
  start: tok.start,
364
- end: payloadTok.end
413
+ end: decl.end ?? payloadTok.end
365
414
  });
366
415
  }
367
416
  updateCtx = cfg.parse(idTok.value, payloadTok.value);
368
417
  } else {
369
- if (i >= tokens.length) {
370
- throw new Error(
371
- `Keyword "${keyword}" at line ${tok.start.line} col ${tok.start.col} expects a payload, but no tokens remain.`
372
- );
373
- }
374
- const payloadTok = tokens[i++];
418
+ const payloadTok = { value: decl.payload ?? "", end: decl.start };
375
419
  if (options.withProvenance) {
376
420
  constructs.push({
377
421
  field: cfg.field ?? keyword,
378
422
  id: "",
379
423
  keyword,
380
424
  start: tok.start,
381
- end: payloadTok.end
425
+ end: decl.end ?? payloadTok.end
382
426
  });
383
427
  }
384
428
  updateCtx = cfg.parse(payloadTok.value);
@@ -1867,10 +1911,21 @@ var parseDataClass = function(id, data) {
1867
1911
  result.helper = details.trim() === "true";
1868
1912
  return;
1869
1913
  }
1914
+ if (head === "overlay") {
1915
+ result.overlay = details.replace(/[{}\s]/g, "") === "true";
1916
+ return;
1917
+ }
1870
1918
  if (head === "extends") {
1871
1919
  result.extends = details.trim();
1872
1920
  return;
1873
1921
  }
1922
+ const lutaml = head.match(/^attribute\s+(\S+?)\s*,\s*(\S+)\s*$/);
1923
+ if (lutaml) {
1924
+ result.attributes.push(
1925
+ parseLutamlAttribute(lutaml[1], lutaml[2], details)
1926
+ );
1927
+ return;
1928
+ }
1874
1929
  result.attributes.push(parseDataAttribute(head, details));
1875
1930
  },
1876
1931
  { construct: "class", id }
@@ -1880,6 +1935,52 @@ var parseDataClass = function(id, data) {
1880
1935
  return ctx;
1881
1936
  };
1882
1937
  };
1938
+ var parseLutamlAttribute = (name, type, details) => {
1939
+ const result = {
1940
+ id: name,
1941
+ type,
1942
+ modality: "",
1943
+ cardinality: "",
1944
+ definition: "",
1945
+ ref: [],
1946
+ satisfy: [],
1947
+ _relations: { ref: [] },
1948
+ surface: "lutaml"
1949
+ };
1950
+ const wrapped = details.startsWith("{") ? details : `{ ${details} }`;
1951
+ forEachEntry(
1952
+ wrapped,
1953
+ (keyword, value, peek) => {
1954
+ if (keyword === "definition") {
1955
+ result.definition = unwrapped(value);
1956
+ } else if (keyword === "cardinality") {
1957
+ result.cardinality = value().trim();
1958
+ } else if (keyword === "modality") {
1959
+ result.modality = value();
1960
+ } else if (keyword === "values") {
1961
+ const facets = /* @__PURE__ */ new Set([
1962
+ "definition",
1963
+ "cardinality",
1964
+ "values",
1965
+ "modality",
1966
+ "reference"
1967
+ ]);
1968
+ const vals = [value()];
1969
+ while (peek() !== void 0 && !facets.has(peek())) {
1970
+ vals.push(value());
1971
+ }
1972
+ result.enumValues = vals;
1973
+ } else if (keyword === "reference") {
1974
+ result._relations.ref = tokenizePackage(value());
1975
+ } else {
1976
+ value();
1977
+ }
1978
+ return true;
1979
+ },
1980
+ { construct: "class", id: name }
1981
+ );
1982
+ return result;
1983
+ };
1883
1984
  var parseDataAttribute = (basic, details) => {
1884
1985
  const result = {
1885
1986
  id: "",
@@ -1953,6 +2054,7 @@ var resolveDataClass = function(ctx, unresolved) {
1953
2054
  ...unresolved.store !== void 0 ? { store: unresolved.store } : {},
1954
2055
  ...unresolved.indexes !== void 0 ? { indexes: unresolved.indexes } : {},
1955
2056
  ...unresolved.helper !== void 0 ? { helper: unresolved.helper } : {},
2057
+ ...unresolved.overlay !== void 0 ? { overlay: unresolved.overlay } : {},
1956
2058
  ...unresolved.extends !== void 0 ? { extends: unresolved.extends } : {},
1957
2059
  ...unresolved.description !== void 0 ? { description: unresolved.description } : {},
1958
2060
  ...unresolved.ref !== void 0 ? { ref: unresolved.ref } : {}
@@ -1987,6 +2089,9 @@ var dumpDataClass = function(dataclass) {
1987
2089
  if (dataclass.helper !== void 0) {
1988
2090
  out += " helper { " + dataclass.helper + " }\n";
1989
2091
  }
2092
+ if (dataclass.overlay) {
2093
+ out += " overlay { true }\n";
2094
+ }
1990
2095
  if (dataclass.extends) {
1991
2096
  out += " extends { " + dataclass.extends + " }\n";
1992
2097
  }
@@ -2006,6 +2111,26 @@ var dumpDataClass = function(dataclass) {
2006
2111
  return out;
2007
2112
  };
2008
2113
  var toDataAttributeModel = (attribute) => {
2114
+ if (attribute.surface === "lutaml") {
2115
+ const lutaml = " attribute " + attribute.id + ", " + attribute.type + " {";
2116
+ const facets = [];
2117
+ if (attribute.definition !== "") {
2118
+ facets.push('definition "' + escapeString(attribute.definition) + '"');
2119
+ }
2120
+ if (attribute.cardinality !== "") {
2121
+ facets.push("cardinality " + attribute.cardinality);
2122
+ }
2123
+ if (attribute.enumValues && attribute.enumValues.length > 0) {
2124
+ facets.push("values " + attribute.enumValues.join(" "));
2125
+ }
2126
+ if (attribute.modality !== "") {
2127
+ facets.push("modality " + attribute.modality);
2128
+ }
2129
+ if (facets.length === 0) {
2130
+ return lutaml + " }\n";
2131
+ }
2132
+ return lutaml + " " + facets.join(" ") + " }\n";
2133
+ }
2009
2134
  let out = " " + attribute.id;
2010
2135
  if (attribute.type !== "") {
2011
2136
  out += ": " + attribute.type;
@@ -2398,6 +2523,8 @@ function readQuantityBlock(content) {
2398
2523
  out.uncertainty = coerceValueToken(t[i++]);
2399
2524
  } else if (cmd === "tolerance") {
2400
2525
  out.tolerance = coerceValueToken(t[i++]);
2526
+ } else if (cmd === "provenance") {
2527
+ out.provenance = readProvenanceBlock(unwrapBlock(t[i++]));
2401
2528
  } else {
2402
2529
  unwrapBlock(t[i++]);
2403
2530
  }
@@ -2405,7 +2532,53 @@ function readQuantityBlock(content) {
2405
2532
  return out;
2406
2533
  }
2407
2534
  function needsQuantityBlock(v) {
2408
- return v.quantityKind !== void 0 || v.uncertainty !== void 0 || v.tolerance !== void 0;
2535
+ return v.quantityKind !== void 0 || v.uncertainty !== void 0 || v.tolerance !== void 0 || v.provenance !== void 0;
2536
+ }
2537
+ function readProvenanceBlock(content) {
2538
+ const out = { source: "" };
2539
+ const t = tokenize(content);
2540
+ let i = 0;
2541
+ while (i < t.length) {
2542
+ const cmd = t[i++];
2543
+ if (i >= t.length) {
2544
+ break;
2545
+ }
2546
+ if (cmd === "source") {
2547
+ out.source = stripWrapping(t[i++]);
2548
+ } else if (cmd === "page") {
2549
+ out.page = String(coerceValueToken(t[i++]));
2550
+ } else if (cmd === "entry_wording") {
2551
+ out.entryWording = stripWrapping(t[i++]);
2552
+ } else if (cmd === "read_at") {
2553
+ out.readAt = stripColon(stripWrapping(t[i++]));
2554
+ } else if (cmd === "declaration") {
2555
+ out.declaration = stripColon(stripWrapping(t[i++]));
2556
+ } else if (cmd === "verdict") {
2557
+ out.verdict = stripColon(stripWrapping(t[i++]));
2558
+ } else {
2559
+ unwrapBlock(t[i++]);
2560
+ }
2561
+ }
2562
+ return out;
2563
+ }
2564
+ function dumpProvenanceBlock(p) {
2565
+ const parts = ['source "' + escapeString(p.source) + '"'];
2566
+ if (p.page !== void 0) {
2567
+ parts.push("page " + dumpScalarToken(p.page));
2568
+ }
2569
+ if (p.entryWording !== void 0) {
2570
+ parts.push('entry_wording "' + escapeString(p.entryWording) + '"');
2571
+ }
2572
+ if (p.readAt !== void 0) {
2573
+ parts.push("read_at " + dumpScalarToken(p.readAt));
2574
+ }
2575
+ if (p.declaration !== void 0) {
2576
+ parts.push("declaration " + dumpScalarToken(p.declaration));
2577
+ }
2578
+ if (p.verdict !== void 0) {
2579
+ parts.push("verdict " + dumpScalarToken(p.verdict));
2580
+ }
2581
+ return "{ " + parts.join(" ") + " }";
2409
2582
  }
2410
2583
  function dumpScalarToken(v) {
2411
2584
  if (typeof v === "number") {
@@ -2440,6 +2613,9 @@ function dumpQuantityBlock(v) {
2440
2613
  if (v.tolerance !== void 0) {
2441
2614
  parts.push("tolerance " + dumpScalarToken(v.tolerance));
2442
2615
  }
2616
+ if (v.provenance !== void 0) {
2617
+ parts.push("provenance " + dumpProvenanceBlock(v.provenance));
2618
+ }
2443
2619
  return "{ " + parts.join(" ") + " }";
2444
2620
  }
2445
2621
 
@@ -3074,6 +3250,8 @@ var parseProcess = function(id, data) {
3074
3250
  result.machineSteps = tokenize(stripWrapping(value())).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
3075
3251
  } else if (keyword === "name") {
3076
3252
  result.name = unwrapped(value);
3253
+ } else if (keyword === "overlay") {
3254
+ result.overlay = value() === "true";
3077
3255
  } else if (keyword === "actor") {
3078
3256
  result._relations.actor = value();
3079
3257
  } else if (keyword === "parent") {
@@ -3329,6 +3507,9 @@ function dumpDoes(flow) {
3329
3507
  var dumpProcess = function(process2, ctx) {
3330
3508
  let out = "process " + process2.id + " {\n";
3331
3509
  out += ' name "' + escapeString(process2.name) + '"\n';
3510
+ if (process2.overlay) {
3511
+ out += " overlay true\n";
3512
+ }
3332
3513
  if (process2.summary) {
3333
3514
  out += ' summary "' + escapeString(process2.summary) + '"\n';
3334
3515
  }
@@ -3568,348 +3749,52 @@ var dumpProcess = function(process2, ctx) {
3568
3749
  return out;
3569
3750
  };
3570
3751
 
3571
- // src/ser-des/config/processModel.ts
3572
- function parseProcessSequence(block) {
3573
- return tokenizePackage(block).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
3574
- }
3575
- function parseProcessRegister(id, block) {
3576
- const register = {
3577
- id,
3578
- label: "",
3579
- clause: "",
3580
- maintainer: "",
3581
- published: "",
3582
- entries: ""
3583
- };
3584
- forEachEntry(
3585
- block,
3586
- (keyword, value) => {
3587
- if (keyword === "label") {
3588
- register.label = stripWrapping(value());
3589
- } else if (keyword === "clause") {
3590
- register.clause = stripWrapping(value());
3591
- } else if (keyword === "maintainer") {
3592
- register.maintainer = stripWrapping(value());
3593
- } else if (keyword === "published") {
3594
- register.published = stripWrapping(value());
3595
- } else if (keyword === "entries") {
3596
- register.entries = stripWrapping(value());
3597
- } else {
3598
- return false;
3599
- }
3600
- return true;
3601
- },
3602
- { construct: "process_model register", id }
3603
- );
3604
- return register;
3752
+ // src/ser-des/config/verificationPathway.ts
3753
+ var VERIFICATION_KINDS = [
3754
+ "initial",
3755
+ "subsequent",
3756
+ "periodic",
3757
+ "in-service"
3758
+ ];
3759
+ var TRIGGER_KINDS = ["timer", "signal"];
3760
+ var LIMITS_MODES = ["same-as-type-evaluation", "override"];
3761
+ function readIdList(block) {
3762
+ return tokenize(stripWrapping(block)).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
3605
3763
  }
3606
- var parseProcessModel = (id, data) => {
3607
- const model = {
3608
- id,
3609
- sequence: [],
3610
- registers: [],
3611
- source: { doc: "", clause: "" }
3612
- };
3613
- forEachEntry(
3614
- data,
3615
- (keyword, value, peek) => {
3616
- if (keyword === "sequence") {
3617
- model.sequence = parseProcessSequence(unwrapBlock(value()));
3618
- } else if (keyword === "register") {
3619
- const regId = stripWrapping(value());
3620
- const head = peek();
3621
- if (head === void 0 || !head.startsWith("{")) {
3622
- throw new Error(
3623
- `Parsing error: process_model. ID ${id}: register ${regId} is missing its block`
3624
- );
3625
- }
3626
- model.registers.push(parseProcessRegister(regId, unwrapBlock(value())));
3627
- } else if (keyword === "source") {
3628
- model.source = readSource(unwrapBlock(value()));
3629
- } else {
3630
- return false;
3631
- }
3632
- return true;
3633
- },
3634
- { construct: "process_model", id }
3635
- );
3636
- return (ctx) => {
3637
- ctx.processModels[id] = model;
3638
- return ctx;
3639
- };
3640
- };
3641
- function dumpProcessSequence(sequence) {
3642
- if (sequence.length === 0) {
3643
- return "";
3764
+ function readWindow(block) {
3765
+ const window = { years: 0, months: 0 };
3766
+ const t = tokenize(unwrapBlock(block));
3767
+ for (let i = 0; i + 1 < t.length; i += 2) {
3768
+ if (t[i] === "years") {
3769
+ window.years = parseInt(stripWrapping(t[i + 1]), 10) || 0;
3770
+ } else if (t[i] === "months") {
3771
+ window.months = parseInt(stripWrapping(t[i + 1]), 10) || 0;
3772
+ }
3644
3773
  }
3645
- return "sequence { " + sequence.map(dumpBareSafe).join(" ") + " }";
3774
+ return window;
3646
3775
  }
3647
- function dumpProcessRegister(r, indent) {
3648
- let out = indent + "register " + dumpBareSafe(r.id) + " {\n";
3649
- if (r.label) {
3650
- out += indent + ' label "' + escapeString(r.label) + '"\n';
3651
- }
3652
- if (r.clause) {
3653
- out += indent + ' clause "' + escapeString(r.clause) + '"\n';
3654
- }
3655
- if (r.maintainer) {
3656
- out += indent + " maintainer " + dumpBareSafe(r.maintainer) + "\n";
3657
- }
3658
- if (r.published) {
3659
- out += indent + ' published "' + escapeString(r.published) + '"\n';
3776
+ function dumpWindow(w, indent) {
3777
+ let out = indent + "window {";
3778
+ if (w.years > 0) {
3779
+ out += " years " + w.years;
3660
3780
  }
3661
- if (r.entries) {
3662
- out += indent + ' entries "' + escapeString(r.entries) + '"\n';
3781
+ if (w.months > 0) {
3782
+ out += " months " + w.months;
3663
3783
  }
3664
- out += indent + "}\n";
3665
- return out;
3784
+ return out + " }\n";
3666
3785
  }
3667
- var dumpProcessModel = function(m) {
3668
- let out = "process_model " + m.id + " {\n";
3669
- const seq = dumpProcessSequence(m.sequence);
3670
- if (seq) {
3671
- out += " " + seq + "\n";
3672
- }
3673
- for (const r of m.registers) {
3674
- out += dumpProcessRegister(r, " ");
3786
+ function dumpSourceLines(src, indent) {
3787
+ if (!src.doc && !src.clause) {
3788
+ return "";
3675
3789
  }
3676
- if (m.source.doc || m.source.clause) {
3677
- out += " source {\n";
3678
- if (m.source.doc) {
3679
- out += ' doc "' + escapeString(m.source.doc) + '"\n';
3680
- }
3681
- if (m.source.clause) {
3682
- out += ' clause "' + escapeString(m.source.clause) + '"\n';
3683
- }
3684
- out += " }\n";
3790
+ let out = indent + "source {\n";
3791
+ if (src.doc) {
3792
+ out += indent + ' doc "' + escapeString(src.doc) + '"\n';
3685
3793
  }
3686
- out += "}\n";
3687
- return out;
3688
- };
3689
-
3690
- // src/ser-des/config/workflowConfig.ts
3691
- var WORKFLOW_PHASES = [
3692
- "intake",
3693
- "dispatch",
3694
- "testing",
3695
- "evaluation",
3696
- "issuance"
3697
- ];
3698
- function readTokenList(block) {
3699
- return tokenize(stripWrapping(block)).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
3700
- }
3701
- function dumpTokenList(keyword, ids, indent) {
3702
- if (ids.length === 0) {
3703
- return "";
3794
+ if (src.clause) {
3795
+ out += indent + ' clause "' + escapeString(src.clause) + '"\n';
3704
3796
  }
3705
- return indent + keyword + " { " + ids.map(dumpBareSafe).join(" ") + " }\n";
3706
- }
3707
- var parseWorkflowConfig = (id, data) => {
3708
- const config = { id, overlay: false, steps: [] };
3709
- forEachEntry(
3710
- data,
3711
- (keyword, value) => {
3712
- if (keyword === "overlay") {
3713
- config.overlay = value() === "true";
3714
- } else if (keyword === "step") {
3715
- const step = {
3716
- id: stripWrapping(stripColon(value())),
3717
- phase: null,
3718
- actor: null,
3719
- label: null,
3720
- description: null,
3721
- inputs: [],
3722
- outputs: [],
3723
- gates: []
3724
- };
3725
- forEachEntry(
3726
- unwrapBlock(value()),
3727
- (k2, v2) => {
3728
- if (k2 === "phase") {
3729
- const p = stripWrapping(v2());
3730
- if (!WORKFLOW_PHASES.includes(p)) {
3731
- throw new Error(
3732
- `Parsing error: workflow_config. ID ${id}: Unknown phase "${p}" (valid: ${WORKFLOW_PHASES.join(", ")})`
3733
- );
3734
- }
3735
- step.phase = p;
3736
- } else if (k2 === "actor") {
3737
- step.actor = stripWrapping(v2());
3738
- } else if (k2 === "label") {
3739
- step.label = stripWrapping(v2());
3740
- } else if (k2 === "description") {
3741
- step.description = stripWrapping(v2());
3742
- } else if (k2 === "inputs") {
3743
- step.inputs = readTokenList(v2());
3744
- } else if (k2 === "outputs") {
3745
- step.outputs = readTokenList(v2());
3746
- } else if (k2 === "gates") {
3747
- step.gates = readTokenList(v2());
3748
- } else {
3749
- return false;
3750
- }
3751
- return true;
3752
- },
3753
- { construct: "workflow_config", id }
3754
- );
3755
- config.steps.push(step);
3756
- } else {
3757
- return false;
3758
- }
3759
- return true;
3760
- },
3761
- { construct: "workflow_config", id }
3762
- );
3763
- return (ctx) => {
3764
- ctx.workflowConfigs[id] = config;
3765
- return ctx;
3766
- };
3767
- };
3768
- var dumpWorkflowConfig = function(c) {
3769
- let out = "workflow_config " + dumpBareSafe(c.id) + " {\n";
3770
- if (c.overlay) {
3771
- out += " overlay true\n";
3772
- }
3773
- for (const s of c.steps) {
3774
- out += " step " + dumpBareSafe(s.id) + " {\n";
3775
- if (s.phase) {
3776
- out += " phase " + s.phase + "\n";
3777
- }
3778
- if (s.actor) {
3779
- out += " actor " + dumpBareSafe(s.actor) + "\n";
3780
- }
3781
- if (s.label) {
3782
- out += ' label "' + escapeString(s.label) + '"\n';
3783
- }
3784
- if (s.description) {
3785
- out += ' description "' + escapeString(s.description) + '"\n';
3786
- }
3787
- out += dumpTokenList("inputs", s.inputs, " ");
3788
- out += dumpTokenList("outputs", s.outputs, " ");
3789
- if (s.gates.length > 0) {
3790
- out += " gates { " + s.gates.map((g) => '"' + escapeString(g) + '"').join(" ") + " }\n";
3791
- }
3792
- out += " }\n";
3793
- }
3794
- out += "}\n";
3795
- return out;
3796
- };
3797
-
3798
- // src/ser-des/config/workflowStage.ts
3799
- function readTokenList2(block) {
3800
- return tokenize(stripWrapping(block)).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
3801
- }
3802
- function dumpTokenList2(keyword, ids) {
3803
- if (ids.length === 0) {
3804
- return "";
3805
- }
3806
- return " " + keyword + " { " + ids.map(dumpBareSafe).join(" ") + " }\n";
3807
- }
3808
- var parseWorkflowStage = (id, data) => {
3809
- const stage = {
3810
- id,
3811
- label: "",
3812
- description: "",
3813
- elements: [],
3814
- startEvent: "",
3815
- endEvents: [],
3816
- approvals: [],
3817
- gateways: []
3818
- };
3819
- forEachEntry(
3820
- data,
3821
- (keyword, value) => {
3822
- if (keyword === "label") {
3823
- stage.label = stripWrapping(value());
3824
- } else if (keyword === "description") {
3825
- stage.description = stripWrapping(value());
3826
- } else if (keyword === "elements") {
3827
- stage.elements = readTokenList2(value());
3828
- } else if (keyword === "start_event") {
3829
- stage.startEvent = stripWrapping(value());
3830
- } else if (keyword === "end_events") {
3831
- stage.endEvents = readTokenList2(value());
3832
- } else if (keyword === "approvals") {
3833
- stage.approvals = readTokenList2(value());
3834
- } else if (keyword === "gateways") {
3835
- stage.gateways = readTokenList2(value());
3836
- } else {
3837
- return false;
3838
- }
3839
- return true;
3840
- },
3841
- { construct: "workflow_stage", id }
3842
- );
3843
- return (ctx) => {
3844
- ctx.workflowStages[id] = stage;
3845
- return ctx;
3846
- };
3847
- };
3848
- var dumpWorkflowStage = function(s) {
3849
- let out = "workflow_stage " + dumpBareSafe(s.id) + " {\n";
3850
- if (s.label) {
3851
- out += ' label "' + escapeString(s.label) + '"\n';
3852
- }
3853
- if (s.description) {
3854
- out += ' description "' + escapeString(s.description) + '"\n';
3855
- }
3856
- out += dumpTokenList2("elements", s.elements);
3857
- if (s.startEvent) {
3858
- out += " start_event " + dumpBareSafe(s.startEvent) + "\n";
3859
- }
3860
- out += dumpTokenList2("end_events", s.endEvents);
3861
- out += dumpTokenList2("approvals", s.approvals);
3862
- out += dumpTokenList2("gateways", s.gateways);
3863
- out += "}\n";
3864
- return out;
3865
- };
3866
-
3867
- // src/ser-des/config/verificationPathway.ts
3868
- var VERIFICATION_KINDS = [
3869
- "initial",
3870
- "subsequent",
3871
- "periodic",
3872
- "in-service"
3873
- ];
3874
- var TRIGGER_KINDS = ["timer", "signal"];
3875
- var LIMITS_MODES = ["same-as-type-evaluation", "override"];
3876
- function readIdList(block) {
3877
- return tokenize(stripWrapping(block)).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
3878
- }
3879
- function readWindow(block) {
3880
- const window = { years: 0, months: 0 };
3881
- const t = tokenize(unwrapBlock(block));
3882
- for (let i = 0; i + 1 < t.length; i += 2) {
3883
- if (t[i] === "years") {
3884
- window.years = parseInt(stripWrapping(t[i + 1]), 10) || 0;
3885
- } else if (t[i] === "months") {
3886
- window.months = parseInt(stripWrapping(t[i + 1]), 10) || 0;
3887
- }
3888
- }
3889
- return window;
3890
- }
3891
- function dumpWindow(w, indent) {
3892
- let out = indent + "window {";
3893
- if (w.years > 0) {
3894
- out += " years " + w.years;
3895
- }
3896
- if (w.months > 0) {
3897
- out += " months " + w.months;
3898
- }
3899
- return out + " }\n";
3900
- }
3901
- function dumpSourceLines(src, indent) {
3902
- if (!src.doc && !src.clause) {
3903
- return "";
3904
- }
3905
- let out = indent + "source {\n";
3906
- if (src.doc) {
3907
- out += indent + ' doc "' + escapeString(src.doc) + '"\n';
3908
- }
3909
- if (src.clause) {
3910
- out += indent + ' clause "' + escapeString(src.clause) + '"\n';
3911
- }
3912
- return out + indent + "}\n";
3797
+ return out + indent + "}\n";
3913
3798
  }
3914
3799
  var parseVerificationPathway = (id, data) => {
3915
3800
  const pathway = {
@@ -11226,7 +11111,7 @@ function readLimit(block) {
11226
11111
  } else if (cmd === "notes") {
11227
11112
  limit.notes = stripWrapping(t[i++]);
11228
11113
  } else if (cmd === "quantity") {
11229
- const quantity = { kind: "", unit: "" };
11114
+ const quantity2 = { kind: "", unit: "" };
11230
11115
  const qt = tokenize(unwrapBlock(t[i++]));
11231
11116
  let k = 0;
11232
11117
  while (k < qt.length) {
@@ -11235,14 +11120,14 @@ function readLimit(block) {
11235
11120
  break;
11236
11121
  }
11237
11122
  if (qc === "kind") {
11238
- quantity.kind = stripWrapping(qt[k++]);
11123
+ quantity2.kind = stripWrapping(qt[k++]);
11239
11124
  } else if (qc === "unit") {
11240
- quantity.unit = stripWrapping(qt[k++]);
11125
+ quantity2.unit = stripWrapping(qt[k++]);
11241
11126
  } else {
11242
11127
  unwrapBlock(qt[k++]);
11243
11128
  }
11244
11129
  }
11245
- limit.quantity = quantity;
11130
+ limit.quantity = quantity2;
11246
11131
  } else if (cmd === "accepts") {
11247
11132
  limit.accepts = readAccepts(unwrapBlock(t[i++]));
11248
11133
  } else if (cmd === "acceptance") {
@@ -12683,6 +12568,8 @@ function parseDimension(id, block) {
12683
12568
  dim.source = readSource(unwrapBlock(t[i++]));
12684
12569
  } else if (cmd === "values") {
12685
12570
  dim.values = parseDimensionValues(unwrapBlock(t[i++]));
12571
+ } else if (cmd === "payload_class") {
12572
+ dim.payloadClass = stripColon(stripWrapping(t[i++]));
12686
12573
  } else if (cmd === "values_of") {
12687
12574
  dim.valuesOf = stripWrapping(t[i++]);
12688
12575
  } else if (cmd === "ref") {
@@ -12791,6 +12678,9 @@ function dumpDimension(d, indent) {
12791
12678
  if (d.description) {
12792
12679
  out += inner + 'description "' + escapeString(d.description) + '"\n';
12793
12680
  }
12681
+ if (d.payloadClass) {
12682
+ out += inner + "payload_class " + d.payloadClass + "\n";
12683
+ }
12794
12684
  out += dumpSource2("reference", d.source, inner);
12795
12685
  if (d.valuesOf) {
12796
12686
  out += inner + "values_of " + d.valuesOf + "\n";
@@ -13154,6 +13044,8 @@ var parseAttributeDefinition = function(id, data) {
13154
13044
  }
13155
13045
  if (cmd === "symbol") {
13156
13046
  result.symbol = stripWrapping(t[i++]);
13047
+ } else if (cmd === "overlay") {
13048
+ result.overlay = stripWrapping(t[i++]) === "true";
13157
13049
  } else if (cmd === "name") {
13158
13050
  result.name = stripWrapping(t[i++]);
13159
13051
  } else if (cmd === "definition") {
@@ -13188,6 +13080,8 @@ var parseAttributeDefinition = function(id, data) {
13188
13080
  result.note = stripWrapping(t[i++]);
13189
13081
  } else if (cmd === "irdi") {
13190
13082
  result.irdi = stripWrapping(t[i++]);
13083
+ } else if (cmd === "class") {
13084
+ result.classRef = stripColon(stripWrapping(t[i++]));
13191
13085
  } else if (cmd === "derived") {
13192
13086
  result.derived = stripWrapping(t[i++]);
13193
13087
  } else if (cmd === "ref") {
@@ -13211,6 +13105,9 @@ var parseAttributeDefinition = function(id, data) {
13211
13105
  };
13212
13106
  var dumpAttributeDefinition = function(a) {
13213
13107
  let out = "attribute_definition " + a.id + " {\n";
13108
+ if (a.overlay) {
13109
+ out += " overlay true\n";
13110
+ }
13214
13111
  if (a.symbol) {
13215
13112
  out += ' symbol "' + escapeString(a.symbol) + '"\n';
13216
13113
  }
@@ -13267,6 +13164,9 @@ var dumpAttributeDefinition = function(a) {
13267
13164
  if (a.irdi) {
13268
13165
  out += ' irdi "' + escapeString(a.irdi) + '"\n';
13269
13166
  }
13167
+ if (a.classRef) {
13168
+ out += " class " + a.classRef + "\n";
13169
+ }
13270
13170
  if (a.derived) {
13271
13171
  out += ' derived "' + escapeString(a.derived) + '"\n';
13272
13172
  }
@@ -14410,6 +14310,16 @@ function parseInstanceHas(block, result) {
14410
14310
  }
14411
14311
  }
14412
14312
  }
14313
+ function readQuantity2(tokens) {
14314
+ if (tokens.length === 0) {
14315
+ return { value: "" };
14316
+ }
14317
+ const first = stripWrapping(tokens[0]);
14318
+ if (tokens.length === 1) {
14319
+ return { value: first };
14320
+ }
14321
+ return { value: first, unit: tokens.slice(1).map(stripWrapping).join(" ") };
14322
+ }
14413
14323
  var parseInstance = function(id, data) {
14414
14324
  const result = {
14415
14325
  id,
@@ -14431,6 +14341,13 @@ var parseInstance = function(id, data) {
14431
14341
  }
14432
14342
  if (cmd === "of") {
14433
14343
  result.of = stripWrapping(t[i++]);
14344
+ } else if (t[i] === "=" && i + 1 < t.length) {
14345
+ i++;
14346
+ const valueTokens = [];
14347
+ while (i < t.length && t[i] !== "}" && !(i + 1 < t.length && t[i + 1] === "=")) {
14348
+ valueTokens.push(t[i++]);
14349
+ }
14350
+ result.has.attributes[cmd] = readQuantity2(valueTokens);
14434
14351
  } else if (cmd === "level") {
14435
14352
  result.level = stripWrapping(t[i++]);
14436
14353
  } else if (cmd === "model") {
@@ -15048,6 +14965,127 @@ var dumpEvaluationProfile = function(p) {
15048
14965
  return out;
15049
14966
  };
15050
14967
 
14968
+ // src/ser-des/config/attestation.ts
14969
+ var parseAttestation = (id, data) => {
14970
+ const a = {
14971
+ id,
14972
+ subject: "",
14973
+ promises: "",
14974
+ basis: [],
14975
+ authority: { role: "", name: "" },
14976
+ statement: "",
14977
+ limits: [],
14978
+ claims: [],
14979
+ referenceIds: []
14980
+ };
14981
+ forEachEntry(
14982
+ data,
14983
+ (keyword, value) => {
14984
+ if (keyword === "subject") {
14985
+ a.subject = stripWrapping(stripColon(value()));
14986
+ } else if (keyword === "promises") {
14987
+ a.promises = stripWrapping(stripColon(value()));
14988
+ } else if (keyword === "basis") {
14989
+ const kind = stripWrapping(stripColon(value()));
14990
+ const eid = stripWrapping(value());
14991
+ a.basis.push({ kind, id: eid });
14992
+ } else if (keyword === "authority") {
14993
+ const role = stripWrapping(stripColon(value()));
14994
+ const name = stripWrapping(value());
14995
+ a.authority = { role, name };
14996
+ } else if (keyword === "statement") {
14997
+ a.statement = stripWrapping(value());
14998
+ } else if (keyword === "limits") {
14999
+ forEachEntry(
15000
+ unwrapBlock(value()),
15001
+ (label, text) => {
15002
+ const limit = {
15003
+ label: stripColon(label),
15004
+ text: stripWrapping(text())
15005
+ };
15006
+ a.limits.push(limit);
15007
+ return true;
15008
+ },
15009
+ { construct: "attestation", id }
15010
+ );
15011
+ } else if (keyword === "claims") {
15012
+ forEachEntry(
15013
+ unwrapBlock(value()),
15014
+ (promise, claimValue) => {
15015
+ const claim = {
15016
+ promise: stripColon(promise),
15017
+ declared: "",
15018
+ validatedBy: ""
15019
+ };
15020
+ forEachEntry(
15021
+ unwrapBlock(claimValue()),
15022
+ (k2, v2) => {
15023
+ if (k2 === "declared") {
15024
+ claim.declared = stripWrapping(stripColon(v2()));
15025
+ } else if (k2 === "validated_by") {
15026
+ claim.validatedBy = stripWrapping(stripColon(v2()));
15027
+ } else {
15028
+ return false;
15029
+ }
15030
+ return true;
15031
+ },
15032
+ { construct: "attestation", id }
15033
+ );
15034
+ a.claims.push(claim);
15035
+ return true;
15036
+ },
15037
+ { construct: "attestation", id }
15038
+ );
15039
+ } else {
15040
+ return false;
15041
+ }
15042
+ return true;
15043
+ },
15044
+ { construct: "attestation", id }
15045
+ );
15046
+ return (ctx) => {
15047
+ ctx.attestations[id] = a;
15048
+ return ctx;
15049
+ };
15050
+ };
15051
+ var dumpAttestation = function(a) {
15052
+ let out = "attestation " + dumpBareSafe(a.id) + " {\n";
15053
+ if (a.subject) {
15054
+ out += " subject " + dumpBareSafe(a.subject) + "\n";
15055
+ }
15056
+ if (a.promises) {
15057
+ out += " promises " + dumpBareSafe(a.promises) + "\n";
15058
+ }
15059
+ for (const b of a.basis) {
15060
+ out += " basis " + dumpBareSafe(b.kind) + ' "' + b.id.replace(/"/g, '\\"') + '"\n';
15061
+ }
15062
+ if (a.authority.role || a.authority.name) {
15063
+ out += " authority " + dumpBareSafe(a.authority.role) + ' "' + a.authority.name.replace(/"/g, '\\"') + '"\n';
15064
+ }
15065
+ if (a.statement) {
15066
+ out += ' statement "' + a.statement.replace(/"/g, '\\"') + '"\n';
15067
+ }
15068
+ if (a.limits.length > 0) {
15069
+ out += " limits {\n";
15070
+ for (const l of a.limits) {
15071
+ out += " " + dumpBareSafe(l.label) + ' "' + l.text.replace(/"/g, '\\"') + '"\n';
15072
+ }
15073
+ out += " }\n";
15074
+ }
15075
+ if (a.claims.length > 0) {
15076
+ out += " claims {\n";
15077
+ for (const c of a.claims) {
15078
+ out += " " + dumpBareSafe(c.promise) + " {\n";
15079
+ out += " declared " + dumpBareSafe(c.declared) + "\n";
15080
+ out += " validated_by " + dumpBareSafe(c.validatedBy) + "\n";
15081
+ out += " }\n";
15082
+ }
15083
+ out += " }\n";
15084
+ }
15085
+ out += "}\n";
15086
+ return out;
15087
+ };
15088
+
15051
15089
  // src/ser-des/config/certificateTemplate.ts
15052
15090
  var CERTIFICATE_OBLIGATIONS = ["mandatory", "optional"];
15053
15091
  function readIdList6(block) {
@@ -15064,7 +15102,9 @@ var parseCertificateTemplate = (id, data) => {
15064
15102
  forEachEntry(
15065
15103
  data,
15066
15104
  (keyword, value) => {
15067
- if (keyword === "number_format") {
15105
+ if (keyword === "overlay") {
15106
+ template.overlay = stripWrapping(value()) === "true";
15107
+ } else if (keyword === "number_format") {
15068
15108
  template.numberFormat = stripWrapping(value());
15069
15109
  } else if (keyword === "dimension_labels") {
15070
15110
  const labels = { pattern: "", separator: "" };
@@ -15165,6 +15205,9 @@ var parseCertificateTemplate = (id, data) => {
15165
15205
  };
15166
15206
  var dumpCertificateTemplate = function(t) {
15167
15207
  let out = "certificate_template " + dumpBareSafe(t.id) + " {\n";
15208
+ if (t.overlay) {
15209
+ out += " overlay true\n";
15210
+ }
15168
15211
  if (t.numberFormat) {
15169
15212
  out += ' number_format "' + escapeString(t.numberFormat) + '"\n';
15170
15213
  }
@@ -15345,6 +15388,8 @@ var parseArtifactDefinition = function(id, data) {
15345
15388
  result.description = stripWrapping(t[i++]);
15346
15389
  } else if (cmd === "content_contract") {
15347
15390
  result.contentContract = parseContentContract(unwrapBlock(t[i++]));
15391
+ } else if (cmd === "contract_from") {
15392
+ result.contractFrom = stripColon(stripWrapping(t[i++]));
15348
15393
  } else if (cmd === "produced_when") {
15349
15394
  const kind = stripWrapping(t[i++] ?? "");
15350
15395
  if (kind === "per_interval") {
@@ -15400,6 +15445,9 @@ var dumpArtifactDefinition = function(d) {
15400
15445
  if (d.description) {
15401
15446
  out += ' description "' + escapeString(d.description) + '"\n';
15402
15447
  }
15448
+ if (d.contractFrom) {
15449
+ out += " contract_from " + d.contractFrom + "\n";
15450
+ }
15403
15451
  const c = d.contentContract;
15404
15452
  const hasContract = c.fields.length > 0 || c.structure || c.media.length > 0;
15405
15453
  if (hasContract) {
@@ -18403,6 +18451,68 @@ var dumpDecisionRule = function(r) {
18403
18451
  return out;
18404
18452
  };
18405
18453
 
18454
+ // src/ser-des/config/processSequence.ts
18455
+ function parseProcessSequence(block) {
18456
+ return tokenizePackage(block).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
18457
+ }
18458
+ function parseProcessRegister(id, block) {
18459
+ const register = {
18460
+ id,
18461
+ label: "",
18462
+ clause: "",
18463
+ maintainer: "",
18464
+ published: "",
18465
+ entries: ""
18466
+ };
18467
+ forEachEntry(
18468
+ block,
18469
+ (keyword, value) => {
18470
+ if (keyword === "label") {
18471
+ register.label = stripWrapping(value());
18472
+ } else if (keyword === "clause") {
18473
+ register.clause = stripWrapping(value());
18474
+ } else if (keyword === "maintainer") {
18475
+ register.maintainer = stripWrapping(value());
18476
+ } else if (keyword === "published") {
18477
+ register.published = stripWrapping(value());
18478
+ } else if (keyword === "entries") {
18479
+ register.entries = stripWrapping(value());
18480
+ } else {
18481
+ return false;
18482
+ }
18483
+ return true;
18484
+ },
18485
+ { construct: "process_model register", id }
18486
+ );
18487
+ return register;
18488
+ }
18489
+ function dumpProcessSequence(sequence) {
18490
+ if (sequence.length === 0) {
18491
+ return "";
18492
+ }
18493
+ return "sequence { " + sequence.map(dumpBareSafe).join(" ") + " }";
18494
+ }
18495
+ function dumpProcessRegister(r, indent) {
18496
+ let out = indent + "register " + dumpBareSafe(r.id) + " {\n";
18497
+ if (r.label) {
18498
+ out += indent + ' label "' + escapeString(r.label) + '"\n';
18499
+ }
18500
+ if (r.clause) {
18501
+ out += indent + ' clause "' + escapeString(r.clause) + '"\n';
18502
+ }
18503
+ if (r.maintainer) {
18504
+ out += indent + " maintainer " + dumpBareSafe(r.maintainer) + "\n";
18505
+ }
18506
+ if (r.published) {
18507
+ out += indent + ' published "' + escapeString(r.published) + '"\n';
18508
+ }
18509
+ if (r.entries) {
18510
+ out += indent + ' entries "' + escapeString(r.entries) + '"\n';
18511
+ }
18512
+ out += indent + "}\n";
18513
+ return out;
18514
+ }
18515
+
18406
18516
  // src/ser-des/config/documentModule.ts
18407
18517
  var parseDocumentModule = (id, data) => {
18408
18518
  const module = {
@@ -18737,234 +18847,6 @@ var dumpPartAnnex = function(a) {
18737
18847
  return out;
18738
18848
  };
18739
18849
 
18740
- // src/ser-des/config/storyline.ts
18741
- function readRecordValue(token) {
18742
- if (token.startsWith("{")) {
18743
- return tokenize(unwrapBlock(token)).filter((s) => s.length > 0).map(coerceValueToken);
18744
- }
18745
- return coerceValueToken(token);
18746
- }
18747
- function readRecordFields(block) {
18748
- const fields = {};
18749
- const t = tokenize(block);
18750
- let i = 0;
18751
- while (i < t.length) {
18752
- const key = t[i++];
18753
- if (i >= t.length) {
18754
- break;
18755
- }
18756
- fields[stripColon(key)] = readRecordValue(t[i++]);
18757
- }
18758
- return fields;
18759
- }
18760
- function dumpRecordFields(fields, indent) {
18761
- let out = "";
18762
- for (const [key, value] of Object.entries(fields)) {
18763
- if (Array.isArray(value)) {
18764
- out += indent + key + " { " + value.map(dumpScalarToken).join(" ") + " }\n";
18765
- } else {
18766
- out += indent + key + " " + dumpScalarToken(value) + "\n";
18767
- }
18768
- }
18769
- return out;
18770
- }
18771
- function parseParticipants(block) {
18772
- const sections = [];
18773
- const t = tokenize(block);
18774
- let i = 0;
18775
- while (i < t.length) {
18776
- const sid = stripWrapping(t[i++]);
18777
- if (i >= t.length || !t[i].startsWith("{")) {
18778
- break;
18779
- }
18780
- const section = { id: sid, entries: [] };
18781
- const st = tokenize(unwrapBlock(t[i++]));
18782
- let j = 0;
18783
- while (j < st.length) {
18784
- const eid = stripWrapping(st[j++]);
18785
- if (j >= st.length || !st[j].startsWith("{")) {
18786
- break;
18787
- }
18788
- section.entries.push({
18789
- id: eid,
18790
- fields: readRecordFields(unwrapBlock(st[j++]))
18791
- });
18792
- }
18793
- sections.push(section);
18794
- }
18795
- return sections;
18796
- }
18797
- var parseDemoWorld = (id, data) => {
18798
- const world = {
18799
- id,
18800
- standard: "",
18801
- description: "",
18802
- participants: []
18803
- };
18804
- forEachEntry(
18805
- data,
18806
- (keyword, value) => {
18807
- if (keyword === "standard") {
18808
- world.standard = stripWrapping(value());
18809
- } else if (keyword === "description") {
18810
- world.description = stripWrapping(value());
18811
- } else if (keyword === "participants") {
18812
- world.participants = parseParticipants(unwrapBlock(value()));
18813
- } else {
18814
- return false;
18815
- }
18816
- return true;
18817
- },
18818
- { construct: "demo_world", id }
18819
- );
18820
- return (ctx) => {
18821
- ctx.demoWorlds[id] = world;
18822
- return ctx;
18823
- };
18824
- };
18825
- var dumpDemoWorld = function(w) {
18826
- let out = "demo_world " + w.id + " {\n";
18827
- if (w.standard) {
18828
- out += " standard " + dumpBareSafe(w.standard) + "\n";
18829
- }
18830
- if (w.description) {
18831
- out += ' description "' + escapeString(w.description) + '"\n';
18832
- }
18833
- if (w.participants.length > 0) {
18834
- out += " participants {\n";
18835
- for (const s of w.participants) {
18836
- out += " " + dumpBareSafe(s.id) + " {\n";
18837
- for (const e of s.entries) {
18838
- out += " " + dumpBareSafe(e.id) + " {\n";
18839
- out += dumpRecordFields(e.fields, " ");
18840
- out += " }\n";
18841
- }
18842
- out += " }\n";
18843
- }
18844
- out += " }\n";
18845
- }
18846
- out += "}\n";
18847
- return out;
18848
- };
18849
- function parseSubjectEntries(block) {
18850
- const entries = [];
18851
- const t = tokenize(block);
18852
- let i = 0;
18853
- while (i < t.length) {
18854
- const kind = stripWrapping(t[i++]);
18855
- if (i >= t.length) {
18856
- break;
18857
- }
18858
- const eid = stripWrapping(t[i++]);
18859
- const entry = { kind, id: eid, fields: {} };
18860
- if (i < t.length && t[i].startsWith("{")) {
18861
- entry.fields = readRecordFields(unwrapBlock(t[i++]));
18862
- }
18863
- entries.push(entry);
18864
- }
18865
- return entries;
18866
- }
18867
- var parseStoryline = (id, data) => {
18868
- const storyline = {
18869
- id,
18870
- name: "",
18871
- idPrefix: "",
18872
- party: { laboratory: "", authority: "" },
18873
- subject: [],
18874
- records: [],
18875
- notes: []
18876
- };
18877
- forEachEntry(
18878
- data,
18879
- (keyword, value, peek) => {
18880
- if (keyword === "name") {
18881
- storyline.name = stripWrapping(value());
18882
- } else if (keyword === "id_prefix") {
18883
- storyline.idPrefix = stripWrapping(value());
18884
- } else if (keyword === "party") {
18885
- const pt = tokenize(unwrapBlock(value()));
18886
- for (let j = 0; j + 1 < pt.length; j += 2) {
18887
- if (pt[j] === "laboratory") {
18888
- storyline.party.laboratory = stripWrapping(pt[j + 1]);
18889
- } else if (pt[j] === "authority") {
18890
- storyline.party.authority = stripWrapping(pt[j + 1]);
18891
- }
18892
- }
18893
- } else if (keyword === "subject") {
18894
- storyline.subject = parseSubjectEntries(unwrapBlock(value()));
18895
- } else if (keyword === "record") {
18896
- const store = stripWrapping(value());
18897
- const idHead = peek();
18898
- if (idHead === void 0 || idHead.startsWith("{")) {
18899
- throw new Error(
18900
- `Parsing error: storyline. ID ${id}: record ${store} is missing its id and block`
18901
- );
18902
- }
18903
- const rid = stripWrapping(value());
18904
- const blockHead = peek();
18905
- if (blockHead === void 0 || !blockHead.startsWith("{")) {
18906
- throw new Error(
18907
- `Parsing error: storyline. ID ${id}: record ${store} ${rid} is missing its block`
18908
- );
18909
- }
18910
- storyline.records.push({
18911
- store,
18912
- id: rid,
18913
- fields: readRecordFields(unwrapBlock(value()))
18914
- });
18915
- } else if (keyword === "note") {
18916
- storyline.notes.push(stripWrapping(value()));
18917
- } else {
18918
- return false;
18919
- }
18920
- return true;
18921
- },
18922
- { construct: "storyline", id }
18923
- );
18924
- return (ctx) => {
18925
- ctx.storylines[id] = storyline;
18926
- return ctx;
18927
- };
18928
- };
18929
- var dumpStoryline = function(s) {
18930
- let out = "storyline " + s.id + " {\n";
18931
- if (s.name) {
18932
- out += ' name "' + escapeString(s.name) + '"\n';
18933
- }
18934
- if (s.idPrefix) {
18935
- out += " id_prefix " + dumpBareSafe(s.idPrefix) + "\n";
18936
- }
18937
- if (s.party.laboratory || s.party.authority) {
18938
- out += " party {";
18939
- if (s.party.laboratory) {
18940
- out += " laboratory " + dumpBareSafe(s.party.laboratory);
18941
- }
18942
- if (s.party.authority) {
18943
- out += " authority " + dumpBareSafe(s.party.authority);
18944
- }
18945
- out += " }\n";
18946
- }
18947
- if (s.subject.length > 0) {
18948
- out += " subject {\n";
18949
- for (const e of s.subject) {
18950
- out += " " + dumpBareSafe(e.kind) + " " + dumpBareSafe(e.id) + " {\n";
18951
- out += dumpRecordFields(e.fields, " ");
18952
- out += " }\n";
18953
- }
18954
- out += " }\n";
18955
- }
18956
- for (const r of s.records) {
18957
- out += " record " + dumpBareSafe(r.store) + " " + dumpBareSafe(r.id) + " {\n";
18958
- out += dumpRecordFields(r.fields, " ");
18959
- out += " }\n";
18960
- }
18961
- for (const n of s.notes) {
18962
- out += ' note "' + escapeString(n) + '"\n';
18963
- }
18964
- out += "}\n";
18965
- return out;
18966
- };
18967
-
18968
18850
  // src/ser-des/config/index.ts
18969
18851
  function defineConstruct(def) {
18970
18852
  return def;
@@ -18995,33 +18877,12 @@ var CONSTRUCTS = [
18995
18877
  }),
18996
18878
  // The abstract-process model's file-level home (smart TODO.roadmap/40
18997
18879
  // batch 2): the pipeline sequence + the participant/expert registers.
18998
- defineConstruct({
18999
- keyword: "process_model",
19000
- field: "processModels",
19001
- takesID: true,
19002
- parse: parseProcessModel,
19003
- dump: dumpProcessModel
19004
- }),
19005
18880
  // The certification workflow step register (smart TODO.roadmap/40
19006
18881
  // batch 3) — process-adjacent but NOT the abstract-process machinery;
19007
18882
  // the rec-overlay deep merge (OVERLAY_DEEP_MERGE_FIELDS) lands here.
19008
- defineConstruct({
19009
- keyword: "workflow_config",
19010
- field: "workflowConfigs",
19011
- takesID: true,
19012
- parse: parseWorkflowConfig,
19013
- dump: dumpWorkflowConfig
19014
- }),
19015
18883
  // The named pipeline stage (smart TODO.roadmap/40 batch 5) — groups
19016
18884
  // the workflow constructs per stage; the members-resolve discipline
19017
18885
  // is C142's.
19018
- defineConstruct({
19019
- keyword: "workflow_stage",
19020
- field: "workflowStages",
19021
- takesID: true,
19022
- parse: parseWorkflowStage,
19023
- dump: dumpWorkflowStage
19024
- }),
19025
18886
  defineConstruct({
19026
18887
  keyword: "approval",
19027
18888
  field: "approvals",
@@ -19197,6 +19058,16 @@ var CONSTRUCTS = [
19197
19058
  // The certificate rendering contract (smart TODO.roadmap/40 batch 3)
19198
19059
  // — form-adjacent (the certificate is the issuing-side document);
19199
19060
  // singleton per package.
19061
+ // The attestation (the typed kernel; clause 19) — the claim that a
19062
+ // third party has verified a subject against a declared promise set,
19063
+ // carrying the lineage of the claims (C150/C151 check the references).
19064
+ defineConstruct({
19065
+ keyword: "attestation",
19066
+ field: "attestations",
19067
+ takesID: true,
19068
+ parse: parseAttestation,
19069
+ dump: dumpAttestation
19070
+ }),
19200
19071
  defineConstruct({
19201
19072
  keyword: "certificate_template",
19202
19073
  field: "certificateTemplates",
@@ -19586,24 +19457,6 @@ var CONSTRUCTS = [
19586
19457
  parse: parsePartAnnex,
19587
19458
  dump: dumpPartAnnex
19588
19459
  }),
19589
- // The demo seeds (smart TODO.roadmap/40 batch 4) — one demo_world per
19590
- // package (file-level metadata + the OPEN participants registry) and
19591
- // one storyline per flow; the record-value sub-grammar follows the
19592
- // quantity.ts dumpScalarToken conventions.
19593
- defineConstruct({
19594
- keyword: "demo_world",
19595
- field: "demoWorlds",
19596
- takesID: true,
19597
- parse: parseDemoWorld,
19598
- dump: dumpDemoWorld
19599
- }),
19600
- defineConstruct({
19601
- keyword: "storyline",
19602
- field: "storylines",
19603
- takesID: true,
19604
- parse: parseStoryline,
19605
- dump: dumpStoryline
19606
- }),
19607
19460
  // Primmel v3 twin interface (TODO.roadmap/32 — doctrine ch. 14 §14.4):
19608
19461
  // the connector-profile registry. Endpoints and serve bindings are NOT
19609
19462
  // top-level constructs — they are subject anatomy slots (is.endpoints /
@@ -19665,7 +19518,12 @@ function buildParserConfig(constructs) {
19665
19518
  if (!c.field) {
19666
19519
  continue;
19667
19520
  }
19668
- const entry = { takesID: c.takesID, parse: c.parse, field: c.field };
19521
+ const entry = {
19522
+ takesID: c.takesID,
19523
+ parse: c.parse,
19524
+ field: c.field,
19525
+ ...c.deprecated ? { deprecated: c.deprecated } : {}
19526
+ };
19669
19527
  out[c.keyword] = entry;
19670
19528
  for (const alias of c.aliases ?? []) {
19671
19529
  out[alias] = entry;
@@ -19948,7 +19806,6 @@ var MERGE_FIELDS = [
19948
19806
  "processes",
19949
19807
  // The abstract-process models (smart TODO.roadmap/40 batch 2) compose
19950
19808
  // like the processes they sequence, with uses-no-redefine semantics.
19951
- "processModels",
19952
19809
  "pages",
19953
19810
  "gateways",
19954
19811
  "regs",
@@ -20002,6 +19859,7 @@ var MERGE_FIELDS = [
20002
19859
  // like the subject anatomy they extend, with uses-no-redefine
20003
19860
  // semantics.
20004
19861
  "promiseSets",
19862
+ "attestations",
20005
19863
  // The applicant-facing documentation register (smart TODO.roadmap/40
20006
19864
  // batch 3) composes with uses-no-redefine semantics.
20007
19865
  "applicationDeclarations",
@@ -20015,10 +19873,8 @@ var MERGE_FIELDS = [
20015
19873
  "certificateTemplates",
20016
19874
  // The certification workflow step register (smart TODO.roadmap/40
20017
19875
  // batch 3) — the rec-overlay deep merge (OVERLAY_DEEP_MERGE_FIELDS).
20018
- "workflowConfigs",
20019
19876
  // The named pipeline stages (smart TODO.roadmap/40 batch 5) compose
20020
19877
  // with uses-no-redefine semantics.
20021
- "workflowStages",
20022
19878
  // The verification pathways (smart TODO.roadmap/40 batch 3) compose
20023
19879
  // with uses-no-redefine semantics.
20024
19880
  "verificationPathways",
@@ -20070,8 +19926,6 @@ var MERGE_FIELDS = [
20070
19926
  "documentModules",
20071
19927
  "informativeAnnexes",
20072
19928
  "partAnnexes",
20073
- "demoWorlds",
20074
- "storylines",
20075
19929
  // The pre-existing drift closed (the packages-as-SSOT epic): these
20076
19930
  // collections existed as constructs but were never merged, so `uses`
20077
19931
  // composition silently dropped them — comments, predicates, the
@@ -20094,13 +19948,23 @@ var OVERLAY_DEEP_MERGE_FIELDS = /* @__PURE__ */ new Set([
20094
19948
  // The workflow step register (B3.7): a rec package's overlay-marked
20095
19949
  // workflow_config merges field-wise into the core skeleton (steps
20096
19950
  // union by id in first-seen order, gates append as a union).
20097
- "workflowConfigs",
20098
19951
  // The OIML-CS test-report checklist (B3.10): a rec package's
20099
19952
  // overlay-marked test_report_checklist merges field-wise into the
20100
19953
  // oiml-cs base — entry scalars land IN PLACE (the base order
20101
19954
  // survives; append-at-end would reorder the composition-point
20102
19955
  // entries to the tail).
20103
- "testReportChecklists"
19956
+ "testReportChecklists",
19957
+ // The entity classes (the smart core's #data plane): a rec
19958
+ // package's overlay-marked class merges field-wise into the core's
19959
+ // — attributes union by id in first-seen order (the rec's added
19960
+ // fields land beside the core's), scalars override.
19961
+ "dataclasses",
19962
+ // The quantity registers: an IDENTICAL unit/kind redeclaration is
19963
+ // idempotent under composition (the IEC family declares kV/degC per
19964
+ // package for standalone self-containment; the merged register
19965
+ // unions them away by id — first-seen wins). A DIFFERING entry with
19966
+ // the same id overrides field-wise, the extension semantics.
19967
+ "quantityRegisters"
20104
19968
  ]);
20105
19969
  function isPlainRecord(v) {
20106
19970
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -20262,7 +20126,7 @@ function composePackage(rootDir, options, rootManifest, withProvenance = false)
20262
20126
  )) {
20263
20127
  const prior = pm.get(key);
20264
20128
  if (prior !== void 0) {
20265
- const isOverlay = typeof value === "object" && value !== null && value.overlay === true && (field === "terms" || OVERLAY_DEEP_MERGE_FIELDS.has(field));
20129
+ const isOverlay = typeof value === "object" && value !== null && value.overlay === true && (field === "terms" || field === "processes" || field === "attributeDefinitions" || field === "certificateTemplates" || OVERLAY_DEEP_MERGE_FIELDS.has(field));
20266
20130
  if (!isOverlay) {
20267
20131
  throw new CompositionError(
20268
20132
  "uses-no-redefine",
@@ -20317,6 +20181,9 @@ function composePackage(rootDir, options, rootManifest, withProvenance = false)
20317
20181
  }
20318
20182
  const compositionIssues = [];
20319
20183
  order.forEach((id, i) => {
20184
+ if (i === order.length - 1) {
20185
+ return;
20186
+ }
20320
20187
  const m = manifests.get(id);
20321
20188
  const downstream = order.slice(i + 1);
20322
20189
  for (const p of m.provides ?? []) {
@@ -21027,10 +20894,8 @@ var TIER_BY_FIELD = {
21027
20894
  certificateTemplates: "secondary",
21028
20895
  // The certification workflow step register (smart TODO.roadmap/40
21029
20896
  // batch 3) — operational wiring, tertiary.
21030
- workflowConfigs: "tertiary",
21031
20897
  // The named pipeline stages (smart TODO.roadmap/40 batch 5) —
21032
20898
  // operational wiring, tertiary.
21033
- workflowStages: "tertiary",
21034
20899
  // The verification pathways (smart TODO.roadmap/40 batch 3) —
21035
20900
  // operational wiring, tertiary.
21036
20901
  verificationPathways: "tertiary",
@@ -21070,7 +20935,6 @@ var TIER_BY_FIELD = {
21070
20935
  // Process models (smart TODO.roadmap/40 batch 2) are tertiary beside
21071
20936
  // processes: the pipeline sequence/registers are the abstract-process
21072
20937
  // model's file-level furniture.
21073
- processModels: "tertiary",
21074
20938
  // Document modules (smart TODO.roadmap/40 batch 2) are tertiary beside
21075
20939
  // processes: the module is the pipeline's document-level furniture.
21076
20940
  documentModules: "tertiary",
@@ -21096,8 +20960,6 @@ var TIER_BY_FIELD = {
21096
20960
  // the model.
21097
20961
  informativeAnnexes: "cross-cutting",
21098
20962
  partAnnexes: "cross-cutting",
21099
- demoWorlds: "tertiary",
21100
- storylines: "tertiary",
21101
20963
  // Invariants (smart gap-close E9) are cross-cutting beside notes: the
21102
20964
  // typed replacement for the note-family encoding — doctrine about the
21103
20965
  // model, not machinery inside it (the enforcement claims point at the
@@ -22075,6 +21937,29 @@ var CHECK_RULES = [
22075
21937
  "normal",
22076
21938
  "TODO.roadmap/03"
22077
21939
  ),
21940
+ // ── the power-type discipline (the reconfiguration phase 8; the CDD
21941
+ // family's central modelling relationship, and the CDDAL interop
21942
+ // requirement): every instance can serve as the definition of further
21943
+ // instantiation. C155 keeps the of-chain coherent — an instance that
21944
+ // instantiates another instance carries no upward subject-chain link,
21945
+ // and the of-graph is acyclic. C156 reaches the definition side: a
21946
+ // class's extends names a class or an instance.
21947
+ R(
21948
+ "C155",
21949
+ "power-type-chain",
21950
+ "instantiation",
21951
+ "error",
21952
+ "normal",
21953
+ "the reconfiguration phase 8 (TODO.reconfigure/09-subjects-twins-attestation.md, the power-type clause)"
21954
+ ),
21955
+ R(
21956
+ "C156",
21957
+ "class-extends-resolves",
21958
+ "instantiation",
21959
+ "warning",
21960
+ "normal",
21961
+ "the reconfiguration phase 8 (TODO.reconfigure/09-subjects-twins-attestation.md, the power-type clause)"
21962
+ ),
22078
21963
  // ── mapping (TODO.roadmap/04) ─────────────────────────────────────
22079
21964
  R(
22080
21965
  "C21",
@@ -22301,28 +22186,6 @@ var CHECK_RULES = [
22301
22186
  "normal",
22302
22187
  "smart TODO.roadmap/40 batch 4 (the packages-as-SSOT epic)"
22303
22188
  ),
22304
- // C129 (smart TODO.roadmap/40 batch 4; the packages-as-SSOT epic): the
22305
- // demo-seed shapes — the storyline's id_prefix pattern (register-free),
22306
- // the party laboratory/authority → the demo_world participant seeds
22307
- // (gated on that register), the record stores → the entity-class stores
22308
- // (gated), and the in-construct record cross-references (a record field
22309
- // keyed by a sibling record's store names a sibling of that store —
22310
- // ungated). Field-level discipline stays app-side.
22311
- R(
22312
- "C129",
22313
- "storyline-shape",
22314
- "composition",
22315
- "error",
22316
- "normal",
22317
- "smart TODO.roadmap/40 batch 4 (the packages-as-SSOT epic)"
22318
- ),
22319
- // C130 (smart TODO.roadmap/40 batch 3; the packages-as-SSOT epic): the
22320
- // identity_slot / aspect registers — the ≥1-presentation shape leg, the
22321
- // aspect reference legs (term_ref → term, component → instrument
22322
- // component, attribute → attribute_definition, contains → identity path
22323
- // OR bare attribute/dimension id), and the R28 bind-path consumer leg
22324
- // (model.identity.<slot> / model.aspects.<id> in requirement/test
22325
- // binds_to), each leg gated on its target register (the C58 doctrine).
22326
22189
  R(
22327
22190
  "C130",
22328
22191
  "identity-and-aspect-references",
@@ -23109,6 +22972,75 @@ var CHECK_RULES = [
23109
22972
  "normal",
23110
22973
  "smart TODO.twin-demo/03 (the model-drive bindings)"
23111
22974
  ),
22975
+ // ── the deprecation report (phase 2 of the reconfiguration): a
22976
+ // construct whose definition carries a migration note warns on every
22977
+ // use; the retirement phase removes the constructs and the rule
22978
+ // burns down to empty.
22979
+ R(
22980
+ "C154",
22981
+ "construct-deprecated",
22982
+ "base",
22983
+ "warning",
22984
+ "normal",
22985
+ "the reconfiguration phase 2 (TODO.reconfigure/09-migration-plan.md)"
22986
+ ),
22987
+ // ── the attestation (the typed kernel, clause 19): the claim that a
22988
+ // third party has verified a subject against a declared promise set.
22989
+ // C150 resolves its subject, promise set, basis, authority, and claim
22990
+ // references; C151 requires the claim lineage — a mandatory
22991
+ // characteristic is carried by lineage, never restated.
22992
+ // ── the typed kernel R3 (the reconfiguration): the closed-derivation
22993
+ // rule. A derivation expression names only declared definitions —
22994
+ // calculations, tables, symbols, measurements, and attributes — and
22995
+ // the checker rejects anything else, naming the missing declaration.
22996
+ R(
22997
+ "C149",
22998
+ "closed-derivation-references-declared",
22999
+ "quantities",
23000
+ "error",
23001
+ "normal",
23002
+ "the typed kernel R3 (TODO.reconfigure/03-typed-kernel.md)"
23003
+ ),
23004
+ R(
23005
+ "C150",
23006
+ "attestation-references-resolve",
23007
+ "attestation",
23008
+ "error",
23009
+ "normal",
23010
+ "the typed kernel clause 19 (TODO.reconfigure/07-subjects-twins-attestation.md)"
23011
+ ),
23012
+ R(
23013
+ "C151",
23014
+ "attestation-claim-lineage",
23015
+ "attestation",
23016
+ "error",
23017
+ "normal",
23018
+ "the typed kernel clause 19 (TODO.reconfigure/07-subjects-twins-attestation.md)"
23019
+ ),
23020
+ // ── the typed payload rule (the typed kernel R2, clause 10): a
23021
+ // dimension that declares payload_class types every value's
23022
+ // definition — the class resolves, the payload fields are fields of
23023
+ // that class, and every value carries its definition.
23024
+ R(
23025
+ "C152",
23026
+ "payload-typed-by-class",
23027
+ "quantities",
23028
+ "error",
23029
+ "normal",
23030
+ "the typed kernel R2 (TODO.reconfigure/03-typed-kernel.md)"
23031
+ ),
23032
+ // ── the contract-derivation facet (the typed kernel, clause 10): an
23033
+ // artifact definition whose content is the projection of declared
23034
+ // claims derives its contract; the reference resolves and never
23035
+ // combines with inline fields.
23036
+ R(
23037
+ "C153",
23038
+ "artifact-contract-derivation",
23039
+ "artifacts",
23040
+ "error",
23041
+ "normal",
23042
+ "the typed kernel clause 10 (TODO.reconfigure/07-subjects-twins-attestation.md)"
23043
+ ),
23112
23044
  // ── the per-test evaluation-formula traces (smart gap-close E11,
23113
23045
  // analysis/architecture-gaps-2026-07.md; the smart contract
23114
23046
  // data/schemas/formulas-used.yaml) ──
@@ -23456,6 +23388,50 @@ function activeRuleIds(level) {
23456
23388
  );
23457
23389
  }
23458
23390
 
23391
+ // src/instance-resolution.ts
23392
+ function classPrototype(standard, classId) {
23393
+ const classes = new Map((standard.dataclasses ?? []).map((c) => [c.id, c]));
23394
+ const instances = new Map((standard.instances ?? []).map((i) => [i.id, i]));
23395
+ const seen = /* @__PURE__ */ new Set([classId]);
23396
+ let cur = classes.get(classId);
23397
+ while (cur && cur.extends) {
23398
+ const target = cur.extends;
23399
+ if (seen.has(target)) {
23400
+ return null;
23401
+ }
23402
+ seen.add(target);
23403
+ const inst = instances.get(target);
23404
+ if (inst) {
23405
+ return inst;
23406
+ }
23407
+ cur = classes.get(target);
23408
+ }
23409
+ return null;
23410
+ }
23411
+ function delegationSuccessors(standard) {
23412
+ const out = /* @__PURE__ */ new Map();
23413
+ for (const inst of standard.instances ?? []) {
23414
+ const upward = inst.model || inst.group || inst.family;
23415
+ if (upward) {
23416
+ out.set(inst.id, upward);
23417
+ continue;
23418
+ }
23419
+ if (!inst.of) {
23420
+ continue;
23421
+ }
23422
+ const direct = (standard.instances ?? []).find((i) => i.id === inst.of);
23423
+ if (direct) {
23424
+ out.set(inst.id, direct.id);
23425
+ continue;
23426
+ }
23427
+ const prototype = classPrototype(standard, inst.of);
23428
+ if (prototype) {
23429
+ out.set(inst.id, prototype.id);
23430
+ }
23431
+ }
23432
+ return out;
23433
+ }
23434
+
23459
23435
  // src/check-allowlist.ts
23460
23436
  import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
23461
23437
  import { join as join2 } from "path";
@@ -24356,7 +24332,9 @@ function checkPackage(dir, options = {}) {
24356
24332
  });
24357
24333
  standard = loaded.standard;
24358
24334
  for (const i of loaded.issues) {
24359
- if (i.code === "provides-unconsumed") {
24335
+ if (i.code === "construct-deprecated") {
24336
+ warn("C154", i.message);
24337
+ } else if (i.code === "provides-unconsumed") {
24360
24338
  warn("C30", i.message);
24361
24339
  } else if (i.code === "extends-deprecated") {
24362
24340
  warn("C27", i.message);
@@ -24386,6 +24364,10 @@ function checkPackage(dir, options = {}) {
24386
24364
  issues.push(...checkDimensions(standard));
24387
24365
  issues.push(...checkReferences(standard));
24388
24366
  issues.push(...checkVerdictChains(standard));
24367
+ issues.push(...checkClosedDerivations(standard));
24368
+ issues.push(...checkAttestations(standard));
24369
+ issues.push(...checkTypedPayloads(standard));
24370
+ issues.push(...checkArtifactContracts(standard));
24389
24371
  const reqIds = new Set(
24390
24372
  (standard.requirements ?? []).map((r) => r.id)
24391
24373
  );
@@ -24395,12 +24377,11 @@ function checkPackage(dir, options = {}) {
24395
24377
  const attrIds = new Set(
24396
24378
  (standard.attributeDefinitions ?? []).map((a) => a.id)
24397
24379
  );
24380
+ const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
24398
24381
  const behaviorIds = new Set(
24399
24382
  (standard.behaviors ?? []).map((b) => b.id)
24400
24383
  );
24401
- const subjectIds = new Set(
24402
- (standard.subjects ?? []).map((s) => s.id)
24403
- );
24384
+ const subjectIds = new Set((standard.subjects ?? []).map((s) => s.id));
24404
24385
  const symbolIds = new Set((standard.symbols ?? []).map((s) => s.id));
24405
24386
  const dimIds = /* @__PURE__ */ new Map();
24406
24387
  const dimCardinality = /* @__PURE__ */ new Map();
@@ -24958,7 +24939,7 @@ function checkPackage(dir, options = {}) {
24958
24939
  );
24959
24940
  for (const d of standard.artifactDefinitions ?? []) {
24960
24941
  const c = d.contentContract;
24961
- if (c.fields.length === 0) {
24942
+ if (!d.contractFrom && c.fields.length === 0) {
24962
24943
  err(
24963
24944
  "C45",
24964
24945
  `artifact definition ${d.id}: content contract declares no fields \u2014 a definition must contract SOME content (artifact-def-contract)`
@@ -25544,15 +25525,6 @@ function checkPackage(dir, options = {}) {
25544
25525
  }
25545
25526
  }
25546
25527
  }
25547
- for (const m of standard.processModels ?? []) {
25548
- const where = `process_model ${m.id}`;
25549
- for (const s of m.sequence ?? []) {
25550
- resolveProcessRef(where, "sequence", s);
25551
- }
25552
- for (const r of m.registers ?? []) {
25553
- resolveOrganAp(`${where} register ${r.id}`, "maintainer", r.maintainer);
25554
- }
25555
- }
25556
25528
  }
25557
25529
  {
25558
25530
  const OCL_CHECK = /^ocl\{[\s\S]*\}$/;
@@ -25865,7 +25837,6 @@ function checkPackage(dir, options = {}) {
25865
25837
  }
25866
25838
  }
25867
25839
  {
25868
- const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
25869
25840
  const KNOWN_OUTCOMES = new Set(MONITOR_OUTCOMES);
25870
25841
  const KNOWN_ACTIONS = new Set(MONITOR_ESCALATION_ACTIONS);
25871
25842
  const KNOWN_STREAMS = new Set(MONITOR_STREAMS);
@@ -26217,6 +26188,10 @@ function checkPackage(dir, options = {}) {
26217
26188
  };
26218
26189
  const instrumentIds = new Set((standard.instruments ?? []).map((i) => i.id));
26219
26190
  const instanceIds = new Set((standard.instances ?? []).map((i) => i.id));
26191
+ const dataclassIds = new Set((standard.dataclasses ?? []).map((c) => c.id));
26192
+ const dataclassBareIds = new Set(
26193
+ (standard.dataclasses ?? []).map((c) => c.id.split("#")[0])
26194
+ );
26220
26195
  const attrScopes = new Map(
26221
26196
  (standard.attributeDefinitions ?? []).map((a) => [a.id, a.scope])
26222
26197
  );
@@ -26321,10 +26296,43 @@ function checkPackage(dir, options = {}) {
26321
26296
  );
26322
26297
  }
26323
26298
  }
26324
- if (!subjectIds.has(inst.of) && !instrumentIds.has(inst.of)) {
26299
+ if (!subjectIds.has(inst.of) && !instrumentIds.has(inst.of) && !instanceIds.has(inst.of) && !dataclassIds.has(inst.of)) {
26325
26300
  err(
26326
26301
  "C20",
26327
- `instance ${inst.id}: of "${inst.of}" is not a declared subject or instrument (instance-of-resolves)`
26302
+ `instance ${inst.id}: of "${inst.of}" is not a declared subject, instrument, class, or instance (instance-of-resolves)`
26303
+ );
26304
+ }
26305
+ if (instanceIds.has(inst.of)) {
26306
+ const links = ["model", "group", "family"].filter(
26307
+ (k) => inst[k]
26308
+ );
26309
+ if (links.length > 0) {
26310
+ err(
26311
+ "C155",
26312
+ `instance ${inst.id}: of "${inst.of}" names an instance and the instance carries an upward ${links.join("/")} link \u2014 the power-type chain and the subject-chain profile do not mix (power-type-chain)`
26313
+ );
26314
+ }
26315
+ }
26316
+ }
26317
+ const delegation = delegationSuccessors(standard);
26318
+ const ofAdj = /* @__PURE__ */ new Map();
26319
+ for (const [from, to] of delegation) {
26320
+ if (instanceIds.has(to)) {
26321
+ ofAdj.set(from, [to]);
26322
+ }
26323
+ }
26324
+ const ofCycle = findCycle(ofAdj);
26325
+ if (ofCycle) {
26326
+ err(
26327
+ "C155",
26328
+ `the power-type of-chain is cyclic: ${ofCycle.join(" \u2192 ")} (power-type-chain)`
26329
+ );
26330
+ }
26331
+ for (const c of standard.dataclasses ?? []) {
26332
+ if (c.extends && !dataclassIds.has(c.extends) && !dataclassBareIds.has(c.extends) && !instanceIds.has(c.extends)) {
26333
+ warn(
26334
+ "C156",
26335
+ `class ${c.id}: extends "${c.extends}" is not a declared class or instance (class-extends-resolves)`
26328
26336
  );
26329
26337
  }
26330
26338
  }
@@ -27204,6 +27212,7 @@ function checkPackage(dir, options = {}) {
27204
27212
  }
27205
27213
  const unitToKind = /* @__PURE__ */ new Map();
27206
27214
  const unitHome = /* @__PURE__ */ new Map();
27215
+ const unitEntry = /* @__PURE__ */ new Map();
27207
27216
  const registersExist = (standard.quantityRegisters ?? []).length > 0;
27208
27217
  for (const reg of standard.quantityRegisters ?? []) {
27209
27218
  for (const u of reg.units) {
@@ -27213,15 +27222,19 @@ function checkPackage(dir, options = {}) {
27213
27222
  `quantity_register ${reg.id}: unit "${u.id}" declares kind "${u.kind}", which no quantity_register declares (quantity-coherence)`
27214
27223
  );
27215
27224
  }
27225
+ const entry = `${u.kind}|${u.factorToSI}|${u.offsetToSI ?? ""}|${u.symbol}`;
27216
27226
  for (const key of new Set([u.id, u.symbol].filter((s) => s))) {
27217
27227
  const prior = unitHome.get(key);
27218
27228
  if (prior !== void 0) {
27219
- err(
27220
- "C33",
27221
- `quantity_register ${reg.id}: unit "${u.id}" ("${key}") redefines a unit already declared by register "${prior}" \u2014 a package extends the register, it never redefines entries (quantity-coherence)`
27222
- );
27229
+ if (unitEntry.get(key) !== entry) {
27230
+ err(
27231
+ "C33",
27232
+ `quantity_register ${reg.id}: unit "${u.id}" ("${key}") redefines a unit already declared by register "${prior}" \u2014 a package extends the register, it never redefines entries (quantity-coherence)`
27233
+ );
27234
+ }
27223
27235
  } else {
27224
27236
  unitHome.set(key, reg.id);
27237
+ unitEntry.set(key, entry);
27225
27238
  unitToKind.set(key, u.kind);
27226
27239
  }
27227
27240
  }
@@ -27574,67 +27587,6 @@ function checkPackage(dir, options = {}) {
27574
27587
  }
27575
27588
  }
27576
27589
  }
27577
- {
27578
- const participantSeeds = /* @__PURE__ */ new Set();
27579
- for (const w of standard.demoWorlds ?? []) {
27580
- for (const section of w.participants ?? []) {
27581
- for (const e of section.entries ?? []) {
27582
- participantSeeds.add(e.id);
27583
- }
27584
- }
27585
- }
27586
- const entityStores = new Set(
27587
- (standard.dataclasses ?? []).map((c) => c.store).filter((s) => !!s)
27588
- );
27589
- for (const s of standard.storylines ?? []) {
27590
- const where = `storyline ${s.id}`;
27591
- if (s.idPrefix && !/^[a-z0-9-]+$/.test(s.idPrefix)) {
27592
- err(
27593
- "C129",
27594
- `${where}: id_prefix "${s.idPrefix}" does not match ^[a-z0-9-]+$ \u2014 the id-minting prefix is a lowercase slug (storyline-shape)`
27595
- );
27596
- }
27597
- if (participantSeeds.size > 0) {
27598
- for (const [slot, ref] of [
27599
- ["laboratory", s.party.laboratory],
27600
- ["authority", s.party.authority]
27601
- ]) {
27602
- if (ref && !participantSeeds.has(ref)) {
27603
- err(
27604
- "C129",
27605
- `${where}: party ${slot} "${ref}" is not a declared participant seed (storyline-shape)`
27606
- );
27607
- }
27608
- }
27609
- }
27610
- const siblingStores = /* @__PURE__ */ new Map();
27611
- for (const r of s.records ?? []) {
27612
- if (entityStores.size > 0 && !entityStores.has(r.store)) {
27613
- err(
27614
- "C129",
27615
- `${where}: record store "${r.store}" is not a declared entity-class store (storyline-shape)`
27616
- );
27617
- }
27618
- let ids = siblingStores.get(r.store);
27619
- if (!ids) {
27620
- ids = /* @__PURE__ */ new Set();
27621
- siblingStores.set(r.store, ids);
27622
- }
27623
- ids.add(r.id);
27624
- }
27625
- for (const r of s.records ?? []) {
27626
- for (const [key, value] of Object.entries(r.fields)) {
27627
- const targets = siblingStores.get(key);
27628
- if (targets !== void 0 && !Array.isArray(value) && !targets.has(String(value))) {
27629
- err(
27630
- "C129",
27631
- `${where}: record ${r.store} ${r.id}: ${key} "${String(value)}" is not a sibling ${key} record of this storyline (storyline-shape)`
27632
- );
27633
- }
27634
- }
27635
- }
27636
- }
27637
- }
27638
27590
  {
27639
27591
  const slotIds = new Set((standard.identitySlots ?? []).map((s) => s.id));
27640
27592
  const aspectIds = new Set((standard.aspects ?? []).map((a) => a.id));
@@ -28005,40 +27957,11 @@ function checkPackage(dir, options = {}) {
28005
27957
  }
28006
27958
  }
28007
27959
  {
28008
- const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
28009
- const dataclassIds = /* @__PURE__ */ new Set();
27960
+ const dataclassIds2 = /* @__PURE__ */ new Set();
28010
27961
  for (const c of standard.dataclasses ?? []) {
28011
- dataclassIds.add(c.id);
27962
+ dataclassIds2.add(c.id);
28012
27963
  if (c.id.includes("#")) {
28013
- dataclassIds.add(c.id.slice(0, c.id.indexOf("#")));
28014
- }
28015
- }
28016
- const CLEAN_TOKEN = /^[A-Za-z_][A-Za-z0-9_]*$/;
28017
- for (const w of standard.workflowConfigs ?? []) {
28018
- for (const s of w.steps ?? []) {
28019
- const where = `workflow_config ${w.id}: step ${s.id}`;
28020
- if (s.actor && roleIds.size > 0 && !roleIds.has(s.actor)) {
28021
- err(
28022
- "C137",
28023
- `${where}: actor "${s.actor}" is not a declared role (workflow-config-references)`
28024
- );
28025
- }
28026
- for (const [facet, list] of [
28027
- ["inputs", s.inputs],
28028
- ["outputs", s.outputs]
28029
- ]) {
28030
- for (const entry of list) {
28031
- if (!CLEAN_TOKEN.test(entry)) {
28032
- continue;
28033
- }
28034
- if (dataclassIds.size > 0 && !dataclassIds.has(entry)) {
28035
- err(
28036
- "C137",
28037
- `${where}: ${facet} entry "${entry}" is not a declared data class (workflow-config-references)`
28038
- );
28039
- }
28040
- }
28041
- }
27964
+ dataclassIds2.add(c.id.slice(0, c.id.indexOf("#")));
28042
27965
  }
28043
27966
  }
28044
27967
  }
@@ -28275,35 +28198,6 @@ function checkPackage(dir, options = {}) {
28275
28198
  }
28276
28199
  }
28277
28200
  }
28278
- const stageApprovalIds = new Set((standard.approvals ?? []).map((a) => a.id));
28279
- const stageGatewayIds = new Set((standard.gateways ?? []).map((g) => g.id));
28280
- for (const s of standard.workflowStages ?? []) {
28281
- const where = `workflow_stage ${s.id}`;
28282
- for (const el of s.elements ?? []) {
28283
- if (gwProcessIds.size > 0 && !gwProcessIds.has(el)) {
28284
- err(
28285
- "C142",
28286
- `${where}: element "${el}" is not a declared process (gateway-edges-resolve)`
28287
- );
28288
- }
28289
- }
28290
- for (const a of s.approvals ?? []) {
28291
- if (stageApprovalIds.size > 0 && !stageApprovalIds.has(a)) {
28292
- err(
28293
- "C142",
28294
- `${where}: approval "${a}" is not a declared approval (gateway-edges-resolve)`
28295
- );
28296
- }
28297
- }
28298
- for (const g of s.gateways ?? []) {
28299
- if (stageGatewayIds.size > 0 && !stageGatewayIds.has(g)) {
28300
- err(
28301
- "C142",
28302
- `${where}: gateway "${g}" is not a declared gateway (gateway-edges-resolve)`
28303
- );
28304
- }
28305
- }
28306
- }
28307
28201
  }
28308
28202
  {
28309
28203
  const approvalRoleIds = new Set((standard.roles ?? []).map((r) => r.id));
@@ -29447,6 +29341,368 @@ function textAddressKey(item, segment) {
29447
29341
  }
29448
29342
  return false;
29449
29343
  }
29344
+ function checkArtifactContracts(standard) {
29345
+ const issues = [];
29346
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29347
+ const setIds = /* @__PURE__ */ new Set();
29348
+ for (const ps of standard.promiseSets ?? []) {
29349
+ setIds.add(ps.id);
29350
+ setIds.add(`${ps.id}.promise_set`);
29351
+ }
29352
+ for (const s of standard.subjects ?? []) {
29353
+ if ((s.is?.promises ?? []).length > 0) {
29354
+ setIds.add(s.id);
29355
+ setIds.add(`${s.id}.promise_set`);
29356
+ }
29357
+ }
29358
+ for (const d of standard.artifactDefinitions ?? []) {
29359
+ if (!d.contractFrom) {
29360
+ continue;
29361
+ }
29362
+ if (!setIds.has(d.contractFrom)) {
29363
+ err(
29364
+ "C153",
29365
+ `artifact_definition ${d.id}: contract_from "${d.contractFrom}" does not resolve to a declared promise set (artifact-contract-derivation)`
29366
+ );
29367
+ }
29368
+ const c = d.contentContract;
29369
+ if (c.fields.length > 0 || c.structure || c.media.length > 0) {
29370
+ err(
29371
+ "C153",
29372
+ `artifact_definition ${d.id}: declares both contract_from and inline contract fields \u2014 the derived contract is the referenced set's projection, never a restatement (artifact-contract-derivation)`
29373
+ );
29374
+ }
29375
+ }
29376
+ return issues;
29377
+ }
29378
+ function checkTypedPayloads(standard) {
29379
+ const issues = [];
29380
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29381
+ const classFields = /* @__PURE__ */ new Map();
29382
+ for (const c of standard.dataclasses ?? []) {
29383
+ classFields.set(c.id, new Set(c.attributes.map((a) => a.id)));
29384
+ }
29385
+ const instanceShape = (id) => {
29386
+ const inst = (standard.instances ?? []).find((i) => i.id === id);
29387
+ if (!inst) {
29388
+ return void 0;
29389
+ }
29390
+ let cur = inst;
29391
+ const seen = /* @__PURE__ */ new Set([cur.id]);
29392
+ while (cur.of) {
29393
+ const next = (standard.instances ?? []).find((i) => i.id === cur.of);
29394
+ if (!next || seen.has(next.id)) {
29395
+ break;
29396
+ }
29397
+ seen.add(next.id);
29398
+ cur = next;
29399
+ }
29400
+ return cur.of !== "" ? classFields.get(cur.of) : void 0;
29401
+ };
29402
+ const typedFields = (id) => classFields.get(id) ?? instanceShape(id);
29403
+ const checkDim = (owner, d) => {
29404
+ if (!d.payloadClass) {
29405
+ return;
29406
+ }
29407
+ const fields = typedFields(d.payloadClass);
29408
+ if (!fields) {
29409
+ err(
29410
+ "C152",
29411
+ `${owner} dimension ${d.id}: payload_class "${d.payloadClass}" is not a declared class (payload-typed-by-class)`
29412
+ );
29413
+ return;
29414
+ }
29415
+ for (const v of d.values) {
29416
+ const keys = Object.keys(v.payload ?? {});
29417
+ if (keys.length === 0) {
29418
+ err(
29419
+ "C152",
29420
+ `${owner} dimension ${d.id}: value ${v.id} carries no payload \u2014 a value of a payload_class dimension IS its definition (payload-typed-by-class)`
29421
+ );
29422
+ continue;
29423
+ }
29424
+ for (const key of keys) {
29425
+ if (!fields.has(key)) {
29426
+ err(
29427
+ "C152",
29428
+ `${owner} dimension ${d.id}: value ${v.id} payload field "${key}" is not a field of class "${d.payloadClass}" (payload-typed-by-class)`
29429
+ );
29430
+ }
29431
+ }
29432
+ }
29433
+ };
29434
+ for (const inst of standard.instruments ?? []) {
29435
+ for (const d of inst.dimensions ?? []) {
29436
+ checkDim(`instrument ${inst.id}`, d);
29437
+ }
29438
+ }
29439
+ for (const d of standard.dimensions ?? []) {
29440
+ checkDim("top-level", d);
29441
+ }
29442
+ for (const a of standard.attributeDefinitions ?? []) {
29443
+ if (a.classRef && !typedFields(a.classRef)) {
29444
+ err(
29445
+ "C152",
29446
+ `attribute_definition ${a.id}: class "${a.classRef}" is not a declared class (payload-typed-by-class)`
29447
+ );
29448
+ }
29449
+ }
29450
+ return issues;
29451
+ }
29452
+ function checkAttestations(standard) {
29453
+ const issues = [];
29454
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29455
+ const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
29456
+ const instanceIds = new Set((standard.instances ?? []).map((i) => i.id));
29457
+ const verdictIds = new Set((standard.verdicts ?? []).map((v) => v.id));
29458
+ const setViews = /* @__PURE__ */ new Map();
29459
+ for (const ps of standard.promiseSets ?? []) {
29460
+ setViews.set(ps.id, { promises: ps.promises });
29461
+ setViews.set(`${ps.id}.promise_set`, { promises: ps.promises });
29462
+ }
29463
+ for (const s of standard.subjects ?? []) {
29464
+ if ((s.is?.promises ?? []).length > 0) {
29465
+ setViews.set(s.id, { promises: s.is.promises });
29466
+ }
29467
+ }
29468
+ const resolveSet = (ref) => setViews.get(ref) ?? setViews.get(ref.split(".").slice(1).join(".")) ?? null;
29469
+ const mandatoryOf = (view) => {
29470
+ const out = /* @__PURE__ */ new Set();
29471
+ for (const p of view.promises) {
29472
+ if (p.certificate?.obligation === "mandatory") {
29473
+ out.add(p.id);
29474
+ }
29475
+ }
29476
+ return out;
29477
+ };
29478
+ for (const a of standard.attestations ?? []) {
29479
+ if (!a.subject) {
29480
+ err(
29481
+ "C150",
29482
+ `attestation ${a.id}: no subject facet (attestation-references-resolve)`
29483
+ );
29484
+ } else if (!instanceIds.has(a.subject)) {
29485
+ err(
29486
+ "C150",
29487
+ `attestation ${a.id}: subject "${a.subject}" is not a declared instance (attestation-references-resolve)`
29488
+ );
29489
+ }
29490
+ if (!a.promises) {
29491
+ err(
29492
+ "C150",
29493
+ `attestation ${a.id}: no promises facet (attestation-references-resolve)`
29494
+ );
29495
+ }
29496
+ const set = a.promises ? resolveSet(a.promises) : null;
29497
+ if (a.promises && !set) {
29498
+ err(
29499
+ "C150",
29500
+ `attestation ${a.id}: promises "${a.promises}" does not resolve to a declared promise set (attestation-references-resolve)`
29501
+ );
29502
+ }
29503
+ for (const b of a.basis) {
29504
+ if (!b.kind || !b.id) {
29505
+ err(
29506
+ "C150",
29507
+ `attestation ${a.id}: a basis entry needs an evidence kind and an id (attestation-references-resolve)`
29508
+ );
29509
+ }
29510
+ }
29511
+ if (a.authority.role && roleIds.size > 0 && !roleIds.has(a.authority.role)) {
29512
+ err(
29513
+ "C150",
29514
+ `attestation ${a.id}: authority role "${a.authority.role}" is not a declared role (attestation-references-resolve)`
29515
+ );
29516
+ }
29517
+ const carried = new Set(a.claims.map((c) => c.promise));
29518
+ for (const c of a.claims) {
29519
+ if (set && !set.promises.some((p) => p.id === c.promise)) {
29520
+ err(
29521
+ "C150",
29522
+ `attestation ${a.id}: claim "${c.promise}" is not a promise of "${a.promises}" (attestation-references-resolve)`
29523
+ );
29524
+ }
29525
+ if (!c.declared) {
29526
+ err(
29527
+ "C151",
29528
+ `attestation ${a.id}: claim "${c.promise}" carries no declaration reference (attestation-claim-lineage)`
29529
+ );
29530
+ }
29531
+ if (!c.validatedBy) {
29532
+ err(
29533
+ "C151",
29534
+ `attestation ${a.id}: claim "${c.promise}" carries no verdict reference (attestation-claim-lineage)`
29535
+ );
29536
+ } else if (verdictIds.size > 0 && !c.validatedBy.startsWith("/") && !verdictIds.has(c.validatedBy)) {
29537
+ err(
29538
+ "C150",
29539
+ `attestation ${a.id}: claim "${c.promise}" names verdict "${c.validatedBy}", which is not declared (attestation-references-resolve)`
29540
+ );
29541
+ }
29542
+ }
29543
+ if (set) {
29544
+ for (const pid of mandatoryOf(set)) {
29545
+ if (!carried.has(pid)) {
29546
+ err(
29547
+ "C151",
29548
+ `attestation ${a.id}: the mandatory promise "${pid}" of "${a.promises}" is carried by no claim \u2014 a mandatory characteristic is carried by lineage, never restated (attestation-claim-lineage)`
29549
+ );
29550
+ }
29551
+ }
29552
+ }
29553
+ }
29554
+ return issues;
29555
+ }
29556
+ var CLOSED_DERIVATION_STOP = /* @__PURE__ */ new Set([
29557
+ "self",
29558
+ "p",
29559
+ "ocl",
29560
+ "true",
29561
+ "false",
29562
+ "null",
29563
+ "undefined",
29564
+ // OCL navigation and collection operators
29565
+ "and",
29566
+ "or",
29567
+ "not",
29568
+ "implies",
29569
+ "if",
29570
+ "then",
29571
+ "else",
29572
+ "endif",
29573
+ "xor",
29574
+ "let",
29575
+ "in",
29576
+ "exists",
29577
+ "forAll",
29578
+ "select",
29579
+ "reject",
29580
+ "collect",
29581
+ "isEmpty",
29582
+ "size",
29583
+ "sum",
29584
+ "min",
29585
+ "max",
29586
+ "abs",
29587
+ "round",
29588
+ "floor",
29589
+ "sqrt",
29590
+ "includes",
29591
+ "excludes",
29592
+ "includesAll",
29593
+ "excludesAll",
29594
+ "count",
29595
+ "first",
29596
+ "last",
29597
+ "asSet",
29598
+ "asOrderedSet",
29599
+ "asSequence",
29600
+ "asBag",
29601
+ "sortedBy",
29602
+ "iterate",
29603
+ "oclIsUndefined",
29604
+ "oclIsKindOf",
29605
+ "oclIsTypeOf",
29606
+ "allInstances",
29607
+ // table-lookup engine vocabulary (the lookup facet names these)
29608
+ "lookup",
29609
+ "profile",
29610
+ // OCL collection statistics and arithmetic
29611
+ "average",
29612
+ "mean",
29613
+ "size",
29614
+ "div",
29615
+ "mod",
29616
+ "collect"
29617
+ ]);
29618
+ var CLOSED_DERIVATION_PATH_RE = /\b[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)+/g;
29619
+ var CLOSED_DERIVATION_IDENT_RE = /[A-Za-z_][A-Za-z0-9_]*/g;
29620
+ function checkClosedDerivations(standard) {
29621
+ const issues = [];
29622
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29623
+ const declared = /* @__PURE__ */ new Set();
29624
+ for (const c of standard.calculations ?? []) {
29625
+ declared.add(c.id);
29626
+ declared.add(c.name);
29627
+ }
29628
+ for (const tb of standard.tables ?? []) {
29629
+ declared.add(tb.id);
29630
+ }
29631
+ for (const s of standard.symbols ?? []) {
29632
+ declared.add(s.id);
29633
+ }
29634
+ for (const v of standard.variables ?? []) {
29635
+ declared.add(v.id);
29636
+ }
29637
+ for (const a of standard.attributeDefinitions ?? []) {
29638
+ declared.add(a.id);
29639
+ }
29640
+ for (const e of standard.enums ?? []) {
29641
+ declared.add(e.id);
29642
+ }
29643
+ for (const d of standard.dataclasses ?? []) {
29644
+ declared.add(d.id);
29645
+ }
29646
+ for (const inst of standard.instruments ?? []) {
29647
+ for (const d of inst.dimensions ?? []) {
29648
+ declared.add(d.id);
29649
+ }
29650
+ }
29651
+ for (const d of standard.dimensions ?? []) {
29652
+ declared.add(d.id);
29653
+ }
29654
+ for (const c of standard.calculations ?? []) {
29655
+ if (c.output?.name) {
29656
+ declared.add(c.output.name);
29657
+ }
29658
+ for (const i of c.inputs ?? []) {
29659
+ declared.add(i.name);
29660
+ }
29661
+ }
29662
+ const localsOf = (extra) => /* @__PURE__ */ new Set([...declared, ...extra]);
29663
+ const checkExpression = (expr, locals, where) => {
29664
+ if (!expr) {
29665
+ return;
29666
+ }
29667
+ const noLiterals = expr.replace(/'[^']*'/g, " ");
29668
+ const noLambdas = noLiterals.replace(
29669
+ /\b([A-Za-z_][A-Za-z0-9_]*)\s*\|/g,
29670
+ " "
29671
+ );
29672
+ const stripped = noLambdas.replace(CLOSED_DERIVATION_PATH_RE, " ");
29673
+ const seen = /* @__PURE__ */ new Set();
29674
+ for (const raw of stripped.match(CLOSED_DERIVATION_IDENT_RE) ?? []) {
29675
+ if (CLOSED_DERIVATION_STOP.has(raw) || locals.has(raw) || seen.has(raw) || /^[a-z][0-9]?$/.test(raw)) {
29676
+ continue;
29677
+ }
29678
+ seen.add(raw);
29679
+ err(
29680
+ "C149",
29681
+ `${where}: expression references "${raw}", which no declared calculation, table, symbol, measurement, or attribute defines (closed-derivation-references-declared)`
29682
+ );
29683
+ }
29684
+ };
29685
+ for (const a of standard.attributeDefinitions ?? []) {
29686
+ checkExpression(a.derived, localsOf([]), `attribute_definition ${a.id}`);
29687
+ }
29688
+ for (const c of standard.calculations ?? []) {
29689
+ const inputs = (c.inputs ?? []).map((i) => i.name);
29690
+ checkExpression(c.expression, localsOf(inputs), `calculation ${c.id}`);
29691
+ }
29692
+ for (const s of standard.symbols ?? []) {
29693
+ if (s.formula?.expression) {
29694
+ checkExpression(
29695
+ s.formula.expression,
29696
+ localsOf(s.formula.inputs ?? []),
29697
+ `symbol ${s.id}`
29698
+ );
29699
+ }
29700
+ }
29701
+ for (const v of standard.verdicts ?? []) {
29702
+ checkExpression(v.derive, localsOf(v.inputs ?? []), `verdict ${v.id}`);
29703
+ }
29704
+ return issues;
29705
+ }
29450
29706
  function checkSpellingCodes(standard) {
29451
29707
  const issues = [];
29452
29708
  const err = (check, message) => issues.push({ check, severity: "error", message });
@@ -31431,9 +31687,229 @@ function renderJsonLd(prefixes, triples) {
31431
31687
 
31432
31688
  // src/export/retrieval.ts
31433
31689
  import { createHash } from "node:crypto";
31434
- import { readdirSync as readdirSync4, readFileSync as readFileSync6, statSync as statSync3 } from "node:fs";
31435
- import { join as join5, relative } from "node:path";
31436
- var RETRIEVAL_PROJECTION = "primmel-retrieval/1";
31690
+ import { readdirSync as readdirSync4, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
31691
+ import { join as join6, relative } from "node:path";
31692
+
31693
+ // src/export/unitsdb.ts
31694
+ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
31695
+ import { join as join5 } from "node:path";
31696
+ function loadUnitsDb(dir) {
31697
+ if (!dir) {
31698
+ return null;
31699
+ }
31700
+ try {
31701
+ const entries = [];
31702
+ const jsonPath = join5(dir, "units.json");
31703
+ if (!existsSync6(jsonPath)) {
31704
+ return null;
31705
+ }
31706
+ const parsed = JSON.parse(readFileSync6(jsonPath, "utf8")).units;
31707
+ if (!Array.isArray(parsed)) {
31708
+ return null;
31709
+ }
31710
+ for (const u of parsed) {
31711
+ const identifiers = u.identifiers ?? [];
31712
+ const unitsml = identifiers.find((i) => i.type === "unitsml")?.id;
31713
+ if (!unitsml) {
31714
+ continue;
31715
+ }
31716
+ const nist = identifiers.find((i) => i.type === "nist")?.id;
31717
+ const scale = u.scale_reference?.id;
31718
+ const symbols = (u.symbols ?? []).map((s) => String(s.ascii ?? s.id)).filter(Boolean);
31719
+ const entry = {
31720
+ unitsml,
31721
+ ...nist ? { nist } : {},
31722
+ ...scale ? { scale } : {},
31723
+ symbols
31724
+ };
31725
+ entries.push(entry);
31726
+ }
31727
+ const bySymbol = /* @__PURE__ */ new Map();
31728
+ const byUnitsml = /* @__PURE__ */ new Map();
31729
+ const spellings = (s) => [
31730
+ s,
31731
+ s.replace(/\*([a-zA-ZμΩ°]+)\^-1\b/g, "/$1")
31732
+ ];
31733
+ for (const e of entries) {
31734
+ byUnitsml.set(e.unitsml, e);
31735
+ for (const s of e.symbols) {
31736
+ for (const sp of spellings(s)) {
31737
+ bySymbol.set(sp, e);
31738
+ }
31739
+ }
31740
+ }
31741
+ return { bySymbol, byUnitsml };
31742
+ } catch {
31743
+ return null;
31744
+ }
31745
+ }
31746
+ function unitsDbEntryFor(db, unit) {
31747
+ return db?.bySymbol.get(unit) ?? null;
31748
+ }
31749
+
31750
+ // src/export/yaml-lite.ts
31751
+ var NUMERIC2 = /^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/;
31752
+ function parseScalar(raw) {
31753
+ const s = raw.trim();
31754
+ if (s === "" || s === "~" || s === "null" || s === "Null" || s === "NULL") {
31755
+ return null;
31756
+ }
31757
+ if (s === "true" || s === "True" || s === "TRUE") {
31758
+ return true;
31759
+ }
31760
+ if (s === "false" || s === "False" || s === "FALSE") {
31761
+ return false;
31762
+ }
31763
+ if (NUMERIC2.test(s)) {
31764
+ return Number(s);
31765
+ }
31766
+ if (s[0] === '"' || s[0] === "'") {
31767
+ return unquote(s, s[0]);
31768
+ }
31769
+ return s;
31770
+ }
31771
+ function unquote(s, q) {
31772
+ if (s.length < 2 || s[s.length - 1] !== q) {
31773
+ return s;
31774
+ }
31775
+ const body = s.slice(1, -1);
31776
+ if (q === "'") {
31777
+ return body.replace(/''/g, "'");
31778
+ }
31779
+ let out = "";
31780
+ for (let i = 0; i < body.length; i++) {
31781
+ const c = body[i];
31782
+ if (c !== "\\" || i === body.length - 1) {
31783
+ out += c;
31784
+ continue;
31785
+ }
31786
+ const e = body[++i];
31787
+ if (e === "n") {
31788
+ out += "\n";
31789
+ } else if (e === "t") {
31790
+ out += " ";
31791
+ } else if (e === "r") {
31792
+ out += "\r";
31793
+ } else if (e === "0") {
31794
+ out += "\0";
31795
+ } else if (e === "\\" || e === '"') {
31796
+ out += e;
31797
+ } else {
31798
+ out += "\\" + e;
31799
+ }
31800
+ }
31801
+ return out;
31802
+ }
31803
+ function splitKey(text) {
31804
+ const colon = text.indexOf(":");
31805
+ if (colon <= 0) {
31806
+ return null;
31807
+ }
31808
+ const key = text.slice(0, colon);
31809
+ if (/[\s"']/.test(key)) {
31810
+ return null;
31811
+ }
31812
+ return [key, text.slice(colon + 1)];
31813
+ }
31814
+ function parseValue(lines, i, indent) {
31815
+ if (i >= lines.length) {
31816
+ return [i, null];
31817
+ }
31818
+ const t = lines[i].text;
31819
+ if (t === "-" || t.startsWith("- ")) {
31820
+ return parseSequence(lines, i, indent);
31821
+ }
31822
+ return parseMapping(lines, i, indent);
31823
+ }
31824
+ function parseSequence(lines, i, indent) {
31825
+ const out = [];
31826
+ while (i < lines.length && lines[i].indent === indent && (lines[i].text === "-" || lines[i].text.startsWith("- "))) {
31827
+ const content = lines[i].text === "-" ? "" : lines[i].text.slice(2).trim();
31828
+ if (content === "") {
31829
+ i++;
31830
+ const next = i < lines.length ? lines[i].indent : -1;
31831
+ if (next > indent) {
31832
+ const [end, value] = parseValue(lines, i, next);
31833
+ out.push(value);
31834
+ i = end;
31835
+ } else {
31836
+ out.push(null);
31837
+ }
31838
+ continue;
31839
+ }
31840
+ const nested = content === "-" || content.startsWith("- ");
31841
+ if (nested || splitKey(content) !== null) {
31842
+ lines[i] = { indent: indent + 2, text: content };
31843
+ const [end, value] = nested ? parseSequence(lines, i, indent + 2) : parseMapping(lines, i, indent + 2);
31844
+ out.push(value);
31845
+ i = end;
31846
+ } else {
31847
+ out.push(parseScalar(content));
31848
+ i++;
31849
+ }
31850
+ }
31851
+ return [i, out];
31852
+ }
31853
+ function parseMapping(lines, i, indent) {
31854
+ const map = {};
31855
+ while (i < lines.length) {
31856
+ const line = lines[i];
31857
+ if (line.indent !== indent || line.text === "-" || line.text.startsWith("- ")) {
31858
+ break;
31859
+ }
31860
+ const kv = splitKey(line.text);
31861
+ if (!kv) {
31862
+ break;
31863
+ }
31864
+ const [key, rest] = kv;
31865
+ i++;
31866
+ if (rest.trim() === "") {
31867
+ const next = i < lines.length ? lines[i].indent : -1;
31868
+ if (next > indent) {
31869
+ const [end, value] = parseValue(lines, i, next);
31870
+ map[key] = value;
31871
+ i = end;
31872
+ } else {
31873
+ map[key] = null;
31874
+ }
31875
+ } else {
31876
+ map[key] = parseScalar(rest);
31877
+ }
31878
+ }
31879
+ return [i, map];
31880
+ }
31881
+ function parseYamlBlock(text) {
31882
+ const scanned = [];
31883
+ for (const raw of text.split("\n")) {
31884
+ if (raw.trim() === "") {
31885
+ continue;
31886
+ }
31887
+ scanned.push({
31888
+ indent: raw.length - raw.trimStart().length,
31889
+ text: raw.trim()
31890
+ });
31891
+ }
31892
+ if (scanned.length === 0 || splitKey(scanned[0].text) === null) {
31893
+ return void 0;
31894
+ }
31895
+ const bases = /* @__PURE__ */ new Set([
31896
+ scanned[0].indent,
31897
+ scanned[1]?.indent ?? scanned[0].indent
31898
+ ]);
31899
+ for (const base of bases) {
31900
+ const lines = scanned.map(
31901
+ (l) => l === scanned[0] && l.indent < base ? { indent: base, text: l.text } : l
31902
+ );
31903
+ const [end, map] = parseMapping(lines, 0, base);
31904
+ if (end === lines.length && Object.keys(map).length > 0) {
31905
+ return map;
31906
+ }
31907
+ }
31908
+ return void 0;
31909
+ }
31910
+
31911
+ // src/export/retrieval.ts
31912
+ var RETRIEVAL_PROJECTION = "primmel-retrieval/2";
31437
31913
  var RETRIEVAL_FACET_VERSION = "retrieval-facet/1";
31438
31914
  function sortDeep(v) {
31439
31915
  if (Array.isArray(v)) {
@@ -31462,7 +31938,7 @@ function* walkPackage(dir) {
31462
31938
  if (entry === ".DS_Store") {
31463
31939
  continue;
31464
31940
  }
31465
- const p = join5(dir, entry);
31941
+ const p = join6(dir, entry);
31466
31942
  if (statSync3(p).isDirectory()) {
31467
31943
  yield* walkPackage(p);
31468
31944
  } else {
@@ -31475,7 +31951,7 @@ function packageSourceHash(dir) {
31475
31951
  for (const file of walkPackage(dir)) {
31476
31952
  h.update(relative(dir, file));
31477
31953
  h.update("\0");
31478
- h.update(createHash("sha256").update(readFileSync6(file)).digest());
31954
+ h.update(createHash("sha256").update(readFileSync7(file)).digest());
31479
31955
  h.update("\n");
31480
31956
  }
31481
31957
  return h.digest("hex");
@@ -31590,11 +32066,94 @@ function passportOf(unit) {
31590
32066
  expression: unit.expression ?? "",
31591
32067
  units: unit.units ?? [],
31592
32068
  applicability: applicabilitySummary(unit.applicability),
31593
- acceptance: unit.acceptance ?? "",
32069
+ acceptance: acceptanceSummary(unit),
31594
32070
  provenance: (unit.clauses ?? []).map((c) => c.urn),
31595
32071
  content_hash: unit.content_hash
31596
32072
  };
31597
32073
  }
32074
+ function acceptanceDecisionOf(a) {
32075
+ if (!a) {
32076
+ return void 0;
32077
+ }
32078
+ const out = {
32079
+ ...present(a.rule) ? { rule: a.rule } : {}
32080
+ };
32081
+ if (a.guardBand) {
32082
+ out.guard_band = { kind: a.guardBand.kind, value: a.guardBand.value };
32083
+ }
32084
+ if (a.uncertainty) {
32085
+ out.uncertainty = { max_ratio_to_mpe: a.uncertainty.maxRatioToMpe };
32086
+ }
32087
+ if (present(a.criterion)) {
32088
+ out.criterion = a.criterion;
32089
+ }
32090
+ if (a.statistics) {
32091
+ out.statistics = {
32092
+ method: a.statistics.method,
32093
+ on_basis_of: a.statistics.onBasisOf,
32094
+ permits: a.statistics.permits
32095
+ };
32096
+ }
32097
+ return Object.keys(out).length > 0 ? out : void 0;
32098
+ }
32099
+ function criteriaItemOf(c) {
32100
+ const item = { name: c.item };
32101
+ if (present(c.requirementId)) {
32102
+ item.target = c.requirementId;
32103
+ }
32104
+ if (present(c.criterion)) {
32105
+ item.criterion = c.criterion;
32106
+ }
32107
+ if (present(c.passIf)) {
32108
+ item.pass_if = c.passIf;
32109
+ }
32110
+ if (c.accepts) {
32111
+ item.accepts = {
32112
+ verdict: c.accepts.verdict,
32113
+ op: c.accepts.op,
32114
+ limit: c.accepts.limit
32115
+ };
32116
+ }
32117
+ if (c.optional) {
32118
+ item.optional = true;
32119
+ }
32120
+ if (present(c.description)) {
32121
+ item.description = c.description;
32122
+ }
32123
+ if (present(c.reference)) {
32124
+ item.reference = c.reference;
32125
+ }
32126
+ return item;
32127
+ }
32128
+ function testAcceptanceCriteriaOf(t) {
32129
+ const out = {
32130
+ ...present(t.acceptanceCriteriaType) ? { type: t.acceptanceCriteriaType } : {},
32131
+ ...present(t.acceptanceCriteriaDescription) ? { description: t.acceptanceCriteriaDescription } : {},
32132
+ ...present(t.acceptancePassIf) ? { pass_if: t.acceptancePassIf } : {},
32133
+ ...presentList(t.acceptanceCriteria) ? { items: t.acceptanceCriteria.map(criteriaItemOf) } : {}
32134
+ };
32135
+ return Object.keys(out).length > 0 ? out : void 0;
32136
+ }
32137
+ function acceptanceSummary(unit) {
32138
+ if (unit.accepts) {
32139
+ return `${unit.accepts.verdict} ${unit.accepts.op} ${unit.accepts.limit}`;
32140
+ }
32141
+ const criteria = unit.acceptance_criteria;
32142
+ if (criteria && typeof criteria === "object") {
32143
+ const passIf = criteria["pass_if"];
32144
+ if (present(passIf)) {
32145
+ return passIf;
32146
+ }
32147
+ const description = criteria["description"];
32148
+ if (present(description)) {
32149
+ return description;
32150
+ }
32151
+ }
32152
+ if (unit.acceptance?.rule) {
32153
+ return unit.acceptance.rule;
32154
+ }
32155
+ return "";
32156
+ }
31598
32157
  var BASE_URN_PARTS = /^urn:oiml:pub:([rdbge]):(\d[\d-]*)(?::(\d{4}))?$/i;
31599
32158
  function retrievalDocParts(baseUrn) {
31600
32159
  const m = BASE_URN_PARTS.exec(baseUrn);
@@ -31753,6 +32312,8 @@ function scopeOf(id) {
31753
32312
  var present = (s) => typeof s === "string" && s.length > 0;
31754
32313
  var presentList = (xs) => xs && xs.length > 0 ? xs : void 0;
31755
32314
  function requirementUnit(r) {
32315
+ const decision = acceptanceDecisionOf(r.limit?.acceptance);
32316
+ const criteria = present(r.acceptanceCriteria) ? parseYamlBlock(r.acceptanceCriteria) ?? r.acceptanceCriteria : void 0;
31756
32317
  return assemble(
31757
32318
  {
31758
32319
  id: r.id,
@@ -31770,9 +32331,14 @@ function requirementUnit(r) {
31770
32331
  ...presentList(r.applicability) ? { applicability: r.applicability } : {},
31771
32332
  ...presentList(r.bindsTo) ? { binds_to: r.bindsTo } : {},
31772
32333
  ...r.limit?.accepts ? {
31773
- acceptance: `${r.limit.accepts.verdict} ${r.limit.accepts.op} ${r.limit.accepts.limit}`
32334
+ accepts: {
32335
+ verdict: r.limit.accepts.verdict,
32336
+ op: r.limit.accepts.op,
32337
+ limit: r.limit.accepts.limit
32338
+ }
31774
32339
  } : {},
31775
- ...present(r.acceptanceCriteria) ? { acceptance_criteria: r.acceptanceCriteria } : {},
32340
+ ...decision ? { acceptance: decision } : {},
32341
+ ...criteria !== void 0 ? { acceptance_criteria: criteria } : {},
31776
32342
  ...present(r.verificationMethod) ? {
31777
32343
  verification: {
31778
32344
  method: r.verificationMethod,
@@ -31788,16 +32354,10 @@ function requirementUnit(r) {
31788
32354
  function conformanceTestUnit(t) {
31789
32355
  const payload = {
31790
32356
  ...present(t.kind) ? { test_kind: t.kind } : {},
31791
- ...present(t.methodRef) ? { method_ref: t.methodRef } : {},
31792
- ...presentList(t.preconditions) ? {
31793
- preconditions: t.preconditions.map((p) => ({
31794
- id: p.id,
31795
- check: p.check,
31796
- description: p.description,
31797
- on_violation: p.onViolation
31798
- }))
31799
- } : {}
32357
+ ...present(t.methodRef) ? { method_ref: t.methodRef } : {}
31800
32358
  };
32359
+ const decision = acceptanceDecisionOf(t.acceptance);
32360
+ const criteria = testAcceptanceCriteriaOf(t);
31801
32361
  return assemble(
31802
32362
  {
31803
32363
  id: t.id,
@@ -31811,7 +32371,17 @@ function conformanceTestUnit(t) {
31811
32371
  ...presentList(t.applicability) ? { applicability: t.applicability } : {},
31812
32372
  ...presentList(t.targets) ? { targets: t.targets } : {},
31813
32373
  ...presentList(t.bindsTo) ? { binds_to: t.bindsTo } : {},
31814
- ...present(t.acceptancePassIf) ? { acceptance: t.acceptancePassIf } : present(t.acceptanceCriteriaDescription) ? { acceptance: t.acceptanceCriteriaDescription } : {},
32374
+ ...decision ? { acceptance: decision } : {},
32375
+ ...criteria ? { acceptance_criteria: criteria } : {},
32376
+ ...presentList(t.preconditions) ? {
32377
+ preconditions: t.preconditions.map((p) => ({
32378
+ id: p.id,
32379
+ check: p.check,
32380
+ ...present(p.description) ? { description: p.description } : {},
32381
+ ...present(p.onViolation) ? { on_violation: p.onViolation } : {},
32382
+ ...present(p.onUnresolvable) ? { on_unresolvable: p.onUnresolvable } : {}
32383
+ }))
32384
+ } : {},
31815
32385
  ...presentList(t.dependencies) ? { dependencies: t.dependencies } : {},
31816
32386
  ...Object.keys(payload).length > 0 ? { payload } : {}
31817
32387
  },
@@ -31970,9 +32540,15 @@ function constraintUnit(c) {
31970
32540
  ...present(c.name) ? { name: c.name } : {},
31971
32541
  ...present(c.violationMeaning) ? { statement: c.violationMeaning } : {},
31972
32542
  ...present(c.check) ? { expression: c.check } : {},
32543
+ // The violation semantics first-class (ask 8) — the construct's
32544
+ // own keyword vocabulary, out of the payload grab bag. `statement`
32545
+ // and `expression` stay: the generic prose/expression slots the
32546
+ // passport and the consumer's grounding text read.
32547
+ ...present(c.check) ? { check: c.check } : {},
32548
+ ...present(c.violationMeaning) ? { violation_meaning: c.violationMeaning } : {},
32549
+ ...present(c.onViolation) ? { on_violation: c.onViolation } : {},
31973
32550
  payload: {
31974
- ...present(c.stereotype) ? { stereotype: c.stereotype } : {},
31975
- ...present(c.onViolation) ? { on_violation: c.onViolation } : {}
32551
+ ...present(c.stereotype) ? { stereotype: c.stereotype } : {}
31976
32552
  }
31977
32553
  },
31978
32554
  collectClauses(c)
@@ -31995,7 +32571,7 @@ function characteristicUnit(v) {
31995
32571
  ...presentList(v.inputs) ? { expression_inputs: v.inputs } : {}
31996
32572
  } : {},
31997
32573
  ...units ? { units } : {},
31998
- ...v.acceptance && present(v.acceptance.rule) ? { acceptance: v.acceptance.rule } : {},
32574
+ ...acceptanceDecisionOf(v.acceptance) ? { acceptance: acceptanceDecisionOf(v.acceptance) } : {},
31999
32575
  ...Object.keys(payload).length > 0 ? { payload } : {}
32000
32576
  },
32001
32577
  collectClauses(v)
@@ -32052,6 +32628,76 @@ function sequenceUnit(s) {
32052
32628
  collectClauses({ sourceRefs: s.sourceRefs, refs: s.refs })
32053
32629
  );
32054
32630
  }
32631
+ function conditionSetUnit(cs, registers, db = null) {
32632
+ const unitsBySymbol = /* @__PURE__ */ new Map();
32633
+ for (const reg of registers ?? []) {
32634
+ const siUnitByKind = new Map(reg.kinds.map((k) => [k.id, k.siUnit]));
32635
+ for (const u of reg.units ?? []) {
32636
+ const siUnit = siUnitByKind.get(u.kind);
32637
+ if (siUnit) {
32638
+ unitsBySymbol.set(u.symbol, {
32639
+ kind: u.kind,
32640
+ factorToSI: u.factorToSI,
32641
+ offsetToSI: u.offsetToSI,
32642
+ siUnit
32643
+ });
32644
+ }
32645
+ }
32646
+ }
32647
+ const siOf = (value, unit) => {
32648
+ const def = unitsBySymbol.get(unit);
32649
+ if (!def) {
32650
+ return void 0;
32651
+ }
32652
+ const n = Number(String(value).replace(",", "."));
32653
+ if (!Number.isFinite(n)) {
32654
+ return void 0;
32655
+ }
32656
+ return { value: n * def.factorToSI + def.offsetToSI, unit: def.siUnit };
32657
+ };
32658
+ const payload = {
32659
+ role: cs.role,
32660
+ ...cs.subject ? { subject: cs.subject } : {},
32661
+ entries: cs.entries.map((e) => {
32662
+ const si = siOf(e.value, e.unit);
32663
+ const ud = unitsDbEntryFor(db, e.unit);
32664
+ return {
32665
+ quantity_kind: e.quantityKind,
32666
+ value: e.value,
32667
+ unit: e.unit,
32668
+ tolerance: e.tolerance,
32669
+ ...si ? { si } : {},
32670
+ ...ud ? {
32671
+ unitsdb: {
32672
+ unitsml: ud.unitsml,
32673
+ ...ud.scale ? { scale: ud.scale } : {}
32674
+ }
32675
+ } : {},
32676
+ ...e.note ? { note: e.note } : {}
32677
+ };
32678
+ })
32679
+ };
32680
+ return assemble(
32681
+ {
32682
+ id: `/condition/${cs.id}`,
32683
+ kind: "condition_set",
32684
+ name: cs.id,
32685
+ statement: [
32686
+ `${cs.role} condition set`,
32687
+ ...cs.description ? [cs.description] : [],
32688
+ ...cs.entries.map(
32689
+ (e) => `${e.quantityKind.replace(/_/g, " ")}: ${e.value} ${e.unit} \xB1${e.tolerance}`
32690
+ )
32691
+ ].join(" \u2014 "),
32692
+ payload
32693
+ },
32694
+ collectClauses({
32695
+ sourceRefs: cs.sources,
32696
+ refs: cs.refs,
32697
+ source: cs.source
32698
+ })
32699
+ );
32700
+ }
32055
32701
  function noteUnit(n) {
32056
32702
  return assemble(
32057
32703
  {
@@ -32092,11 +32738,16 @@ function dimensionUnit(d) {
32092
32738
  const payload = {
32093
32739
  ...present(d.scope) ? { scope: d.scope } : {},
32094
32740
  ...present(d.cardinality) ? { cardinality: d.cardinality } : {},
32741
+ // The typed payload (the typed kernel R2): a value IS its
32742
+ // definition — the class's fields ride the value, and the class
32743
+ // reference rides the dimension.
32744
+ ...present(d.payloadClass) ? { payload_class: d.payloadClass } : {},
32095
32745
  values: d.values.map((v) => ({
32096
32746
  id: v.id,
32097
32747
  ...present(v.label) ? { label: v.label } : {},
32098
32748
  ...presentList(v.implies) ? { implies: v.implies } : {},
32099
- ...present(v.termRef) ? { term_ref: v.termRef } : {}
32749
+ ...present(v.termRef) ? { term_ref: v.termRef } : {},
32750
+ ...Object.keys(v.payload ?? {}).length > 0 ? { payload: v.payload } : {}
32100
32751
  }))
32101
32752
  };
32102
32753
  return assemble(
@@ -32151,6 +32802,7 @@ function packageBlock(standard) {
32151
32802
  };
32152
32803
  }
32153
32804
  function exportStandardRetrieval(standard, options = {}) {
32805
+ const unitsDb = loadUnitsDb(process.env.UNITSDB_DIR);
32154
32806
  const pkg = packageBlock(standard);
32155
32807
  const built = [];
32156
32808
  const push = (content, elementId) => {
@@ -32189,6 +32841,9 @@ function exportStandardRetrieval(standard, options = {}) {
32189
32841
  for (const s of standard.testSequences ?? []) {
32190
32842
  push(sequenceUnit(s), s.id);
32191
32843
  }
32844
+ for (const cs of standard.conditionSets ?? []) {
32845
+ push(conditionSetUnit(cs, standard.quantityRegisters, unitsDb), cs.id);
32846
+ }
32192
32847
  for (const n of standard.notes ?? []) {
32193
32848
  push(noteUnit(n), n.id);
32194
32849
  }
@@ -32468,18 +33123,171 @@ function exportPackageImpact(dir) {
32468
33123
  };
32469
33124
  }
32470
33125
 
33126
+ // src/export/cddal.ts
33127
+ import { readFileSync as readFileSync8, readdirSync as readdirSync5 } from "node:fs";
33128
+ import { basename, join as join7, resolve as resolve5 } from "node:path";
33129
+ var CDDAL_PROJECTION_VERSION = "primmel-cddal/1";
33130
+ function escapeCddalString(s) {
33131
+ return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
33132
+ }
33133
+ function quote(s) {
33134
+ return `"${escapeCddalString(s)}"`;
33135
+ }
33136
+ function safeSymbol(id) {
33137
+ const s = id.replace(/[^A-Za-z0-9_]+/g, "_");
33138
+ return /^[0-9]/.test(s) ? `N${s}` : s;
33139
+ }
33140
+ function isSafeIdentifier(id) {
33141
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(id);
33142
+ }
33143
+ function codeAssignment(id) {
33144
+ return isSafeIdentifier(id) ? id : quote(id);
33145
+ }
33146
+ function quantity(v) {
33147
+ return quote(
33148
+ v.unit !== void 0 && v.unit !== "" ? `${v.value} ${v.unit}` : String(v.value)
33149
+ );
33150
+ }
33151
+ function readL10n(files, read) {
33152
+ const out = /* @__PURE__ */ new Map();
33153
+ const block = /text\s+([\w./#-]+)\s*\{([\s\S]*?)\}/g;
33154
+ const spell = /spell\s+([\w-]+)\s+"((?:[^"\\]|\\.)*)"/g;
33155
+ for (const f of files.filter((f2) => /(^|\/)l10n\.[^/]+\.prl$/.test(f2))) {
33156
+ const src = read(f);
33157
+ for (const m of src.matchAll(block)) {
33158
+ const addr = m[1];
33159
+ const tail = addr.split("/").pop() ?? addr;
33160
+ for (const sp of (m[2] ?? "").matchAll(spell)) {
33161
+ const list = out.get(tail) ?? [];
33162
+ list.push({ tag: sp[1], value: sp[2] });
33163
+ out.set(tail, list);
33164
+ }
33165
+ }
33166
+ }
33167
+ return out;
33168
+ }
33169
+ function l10nDefinitions(l10n, id, field) {
33170
+ return l10n.get(`${id}.${field}`) ?? [];
33171
+ }
33172
+ function projectCddal(model, packageId, l10n = /* @__PURE__ */ new Map()) {
33173
+ const lines = [
33174
+ `# ${CDDAL_PROJECTION_VERSION} \u2014 the dictionary subset of ${packageId}`,
33175
+ "# (generated by primmel export cddal \u2014 never authored, never re-imported)",
33176
+ ""
33177
+ ];
33178
+ const stats = {
33179
+ classes: 0,
33180
+ instances: 0,
33181
+ assignments: 0,
33182
+ properties: 0,
33183
+ valueLists: 0
33184
+ };
33185
+ const attrDefs = new Map(
33186
+ (model.attributeDefinitions ?? []).map((a) => [a.id, a])
33187
+ );
33188
+ for (const c of model.dataclasses) {
33189
+ stats.classes++;
33190
+ lines.push(`instance ${safeSymbol(c.id)} < MDC_C002 {`);
33191
+ lines.push(` code: ${codeAssignment(c.id)}`);
33192
+ if (c.description) {
33193
+ lines.push(` definition.en: ${quote(c.description)}`);
33194
+ for (const alt of l10nDefinitions(l10n, c.id, "description")) {
33195
+ lines.push(` definition.${alt.tag}: ${quote(alt.value)}`);
33196
+ }
33197
+ }
33198
+ lines.push(
33199
+ ` superclass: ${c.extends !== void 0 ? safeSymbol(c.extends) : "UNIVERSE"}`
33200
+ );
33201
+ if (c.attributes.length > 0) {
33202
+ lines.push(
33203
+ ` applicable_properties: { ${c.attributes.map((a) => safeSymbol(a.id)).join(", ")} }`
33204
+ );
33205
+ }
33206
+ lines.push("}");
33207
+ lines.push("");
33208
+ for (const a of c.attributes) {
33209
+ const def = attrDefs.get(a.id);
33210
+ if (!def) {
33211
+ continue;
33212
+ }
33213
+ const irdi = def.irdi || def.correspondences?.find((x) => x.scheme === "iec-cdd")?.concept;
33214
+ stats.properties++;
33215
+ lines.push(`instance ${safeSymbol(a.id)} < MDC_C003 {`);
33216
+ lines.push(
33217
+ ` code: ${codeAssignment(irdi !== void 0 && irdi !== "" ? irdi : a.id)}`
33218
+ );
33219
+ if (def.definition) {
33220
+ lines.push(` definition.en: ${quote(def.definition)}`);
33221
+ for (const alt of l10nDefinitions(l10n, a.id, "definition")) {
33222
+ lines.push(` definition.${alt.tag}: ${quote(alt.value)}`);
33223
+ }
33224
+ }
33225
+ lines.push("}");
33226
+ lines.push("");
33227
+ }
33228
+ }
33229
+ for (const e of model.enums ?? []) {
33230
+ stats.valueLists++;
33231
+ lines.push(`instance ${safeSymbol(e.id)} < MDC_C005 {`);
33232
+ lines.push(` code: ${codeAssignment(e.id)}`);
33233
+ if (e.values.length > 0) {
33234
+ lines.push(
33235
+ ` MDC_P043: ( ${e.values.map((v) => safeSymbol(v.id)).join(", ")} )`
33236
+ );
33237
+ }
33238
+ lines.push("}");
33239
+ lines.push("");
33240
+ for (const v of e.values) {
33241
+ lines.push(`instance ${safeSymbol(v.id)} < MDC_C010 {`);
33242
+ lines.push(` code: ${codeAssignment(v.id)}`);
33243
+ lines.push("}");
33244
+ lines.push("");
33245
+ }
33246
+ }
33247
+ for (const inst of model.instances) {
33248
+ stats.instances++;
33249
+ lines.push(`instance ${safeSymbol(inst.id)} < MDC_C002 {`);
33250
+ lines.push(` code: ${codeAssignment(inst.id)}`);
33251
+ if (inst.of) {
33252
+ lines.push(` superclass: ${safeSymbol(inst.of)}`);
33253
+ }
33254
+ for (const [id, v] of Object.entries(inst.has?.attributes ?? {})) {
33255
+ stats.assignments++;
33256
+ lines.push(` ${safeSymbol(id)}: ${quantity(v)}`);
33257
+ }
33258
+ lines.push("}");
33259
+ lines.push("");
33260
+ }
33261
+ if (stats.classes === 0 && stats.instances === 0 && stats.valueLists === 0) {
33262
+ throw new Error(
33263
+ "no dictionary content: the CDDAL projection carries classes and instances"
33264
+ );
33265
+ }
33266
+ return {
33267
+ version: CDDAL_PROJECTION_VERSION,
33268
+ cddal: lines.join("\n"),
33269
+ stats
33270
+ };
33271
+ }
33272
+ function exportPackageCddal(dir) {
33273
+ const model = loadPackage(dir);
33274
+ const l10nFiles = readdirSync5(dir).filter((e) => /^l10n\.[^/]+\.prl$/.test(e)).map((e) => join7(dir, e));
33275
+ const l10n = readL10n(l10nFiles, (p) => readFileSync8(p, "utf8"));
33276
+ return projectCddal(model, basename(resolve5(dir)), l10n);
33277
+ }
33278
+
32471
33279
  // src/package-diff.ts
32472
- import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "fs";
32473
- import { join as join6 } from "path";
33280
+ import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync9 } from "fs";
33281
+ import { join as join8 } from "path";
32474
33282
  function packageMappings(dir, standard) {
32475
33283
  const profiles = [...standard.mapProfiles ?? []];
32476
- if (existsSync6(dir)) {
32477
- for (const entry of readdirSync5(dir).sort()) {
33284
+ if (existsSync7(dir)) {
33285
+ for (const entry of readdirSync6(dir).sort()) {
32478
33286
  if (!entry.endsWith(".prm")) {
32479
33287
  continue;
32480
33288
  }
32481
33289
  profiles.push(
32482
- ...prmToMapProfiles(loadPrm(readFileSync7(join6(dir, entry), "utf8")))
33290
+ ...prmToMapProfiles(loadPrm(readFileSync9(join8(dir, entry), "utf8")))
32483
33291
  );
32484
33292
  }
32485
33293
  }
@@ -32488,17 +33296,17 @@ function packageMappings(dir, standard) {
32488
33296
  }
32489
33297
  function packageClauseTexts(dir) {
32490
33298
  const out = /* @__PURE__ */ new Map();
32491
- const prdDir = join6(dir, "sources-prd");
32492
- if (!existsSync6(prdDir)) {
33299
+ const prdDir = join8(dir, "sources-prd");
33300
+ if (!existsSync7(prdDir)) {
32493
33301
  return out;
32494
33302
  }
32495
- for (const entry of readdirSync5(prdDir).sort()) {
33303
+ for (const entry of readdirSync6(prdDir).sort()) {
32496
33304
  if (!entry.endsWith(".sentences.json")) {
32497
33305
  continue;
32498
33306
  }
32499
33307
  let payload;
32500
33308
  try {
32501
- payload = JSON.parse(readFileSync7(join6(prdDir, entry), "utf8"));
33309
+ payload = JSON.parse(readFileSync9(join8(prdDir, entry), "utf8"));
32502
33310
  } catch {
32503
33311
  continue;
32504
33312
  }
@@ -32548,18 +33356,18 @@ function diffPackageDirs(dirA, dirB, options = {}) {
32548
33356
  // scripts/check.mts
32549
33357
  var CHECK_USAGE = "Usage: primmel check [--strict] [--audit] [--coverage] [--rules] [--with <pkg-id>=<dir>]\u2026 <package-dir>";
32550
33358
  var DIFF_USAGE = "Usage: primmel diff [--json] [--exit-code] [--compare-texts] [--with <pkg-id>=<dir>]\u2026 <a> <b>";
32551
- var EXPORT_USAGE = "Usage: primmel export reqif|rdf|retrieval|impact <package-dir> [--out <file>] [--format turtle|jsonld]";
33359
+ var EXPORT_USAGE = "Usage: primmel export reqif|rdf|retrieval|impact|cddal <package-dir> [--out <file>] [--format turtle|jsonld]";
32552
33360
  function readablePackageDirProblem(target, needsManifest) {
32553
33361
  try {
32554
33362
  if (!statSync4(target).isDirectory()) {
32555
33363
  return "not a directory";
32556
33364
  }
32557
- readdirSync6(target);
33365
+ readdirSync7(target);
32558
33366
  } catch (e) {
32559
33367
  const err = e;
32560
33368
  return err.code === "ENOENT" ? "no such directory" : err.message;
32561
33369
  }
32562
- if (needsManifest && !existsSync7(join7(target, "package.primmel"))) {
33370
+ if (needsManifest && !existsSync8(join9(target, "package.primmel"))) {
32563
33371
  return "no package.primmel found";
32564
33372
  }
32565
33373
  return null;
@@ -32718,7 +33526,7 @@ function diffCli(args2) {
32718
33526
  }
32719
33527
  function exportCli(args2) {
32720
33528
  const surface = args2[0];
32721
- if (surface !== "reqif" && surface !== "rdf" && surface !== "retrieval" && surface !== "impact") {
33529
+ if (surface !== "reqif" && surface !== "rdf" && surface !== "retrieval" && surface !== "impact" && surface !== "cddal") {
32722
33530
  console.error(EXPORT_USAGE);
32723
33531
  process.exit(2);
32724
33532
  }
@@ -32753,7 +33561,11 @@ function exportCli(args2) {
32753
33561
  let document;
32754
33562
  let summary;
32755
33563
  try {
32756
- if (surface === "impact") {
33564
+ if (surface === "cddal") {
33565
+ const result = exportPackageCddal(dir);
33566
+ document = result.cddal;
33567
+ summary = `${n(result.stats.classes, "class", "classes")}, ${n(result.stats.instances, "instance", "instances")}, ${n(result.stats.assignments, "assignment", "assignments")}`;
33568
+ } else if (surface === "impact") {
32757
33569
  const result = exportPackageImpact(dir);
32758
33570
  document = result.json;
32759
33571
  const s = result.stats;