@primmel/primmel 1.19.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +53 -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 +519 -132
  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/conformanceTest.d.ts.map +1 -1
  48. package/dist/src/ser-des/config/conformanceTest.js +310 -0
  49. package/dist/src/ser-des/config/conformanceTest.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 +14 -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 +9 -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/ConformanceTest.d.ts +86 -0
  100. package/dist/src/types/ConformanceTest.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 +14 -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 +1659 -1629
  120. package/dist-cli/primmel.mjs +2015 -875
  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 = {
@@ -9169,6 +9054,227 @@ function parseInstances(block) {
9169
9054
  }
9170
9055
  return out;
9171
9056
  }
9057
+ function parseProgramArgs(block) {
9058
+ const out = {};
9059
+ const t = tokenize(block);
9060
+ let i = 0;
9061
+ while (i < t.length) {
9062
+ const key = stripColon(t[i++]);
9063
+ if (i >= t.length) {
9064
+ break;
9065
+ }
9066
+ if (t[i] === ":") {
9067
+ i++;
9068
+ }
9069
+ if (i < t.length) {
9070
+ const read = readValueToken(t, i);
9071
+ out[key] = stripWrapping(read.text);
9072
+ i = read.next;
9073
+ }
9074
+ }
9075
+ return out;
9076
+ }
9077
+ function parseVerify(block) {
9078
+ const v = { read: "", tolerance: "" };
9079
+ const t = tokenize(block);
9080
+ let i = 0;
9081
+ while (i < t.length) {
9082
+ const cmd = t[i++];
9083
+ if (i >= t.length) {
9084
+ break;
9085
+ }
9086
+ if (cmd === "read") {
9087
+ v.read = stripWrapping(t[i++]);
9088
+ } else if (cmd === "tolerance") {
9089
+ v.tolerance = stripWrapping(t[i++]);
9090
+ } else {
9091
+ unwrapBlock(t[i++]);
9092
+ }
9093
+ }
9094
+ return v;
9095
+ }
9096
+ function parseProgramBody(block, entryKeyword, makeEntry, parseEntryFacets, errCtx) {
9097
+ const program = {
9098
+ description: "",
9099
+ entries: [],
9100
+ sourceRefs: []
9101
+ };
9102
+ const t = tokenize(block);
9103
+ let i = 0;
9104
+ while (i < t.length) {
9105
+ const command = t[i++];
9106
+ if (i >= t.length) {
9107
+ throw new Error(
9108
+ `Parsing error: ${errCtx}: Expecting value for ${command}`
9109
+ );
9110
+ }
9111
+ if (command === "description") {
9112
+ program.description = stripWrapping(t[i++]);
9113
+ } else if (command === "source") {
9114
+ program.sourceRefs.push(readSource(unwrapBlock(t[i++])));
9115
+ } else if (command === "ref") {
9116
+ const rr = parseRef(t, i, stripWrapping, unwrapBlock);
9117
+ foldRefIntoLegacy(program, rr.ref);
9118
+ i = rr.next;
9119
+ } else if (command === entryKeyword) {
9120
+ const entry = makeEntry();
9121
+ let value = t[i++];
9122
+ if (!value.startsWith("{")) {
9123
+ entry.order = Number(stripWrapping(value));
9124
+ value = i < t.length && t[i].startsWith("{") ? t[i++] : "";
9125
+ }
9126
+ if (value.startsWith("{")) {
9127
+ parseEntryFacets(unwrapBlock(value), entry);
9128
+ }
9129
+ program.entries.push(entry);
9130
+ } else {
9131
+ i = skipUnknownValue(t, i, command);
9132
+ }
9133
+ }
9134
+ return program;
9135
+ }
9136
+ function parsePreparation(block, id) {
9137
+ return parseProgramBody(
9138
+ block,
9139
+ "step",
9140
+ () => ({
9141
+ order: null,
9142
+ action: "",
9143
+ drive: "",
9144
+ args: {},
9145
+ hold: "",
9146
+ verify: null
9147
+ }),
9148
+ (stepBlock, step) => {
9149
+ forEachEntry(
9150
+ stepBlock,
9151
+ (facet, value) => {
9152
+ if (facet === "action") {
9153
+ step.action = unwrapped(value);
9154
+ } else if (facet === "drive") {
9155
+ step.drive = stripWrapping(value());
9156
+ } else if (facet === "args") {
9157
+ step.args = parseProgramArgs(unwrapBlock(value()));
9158
+ } else if (facet === "hold") {
9159
+ step.hold = stripWrapping(value());
9160
+ } else if (facet === "verify") {
9161
+ step.verify = parseVerify(unwrapBlock(value()));
9162
+ } else {
9163
+ return false;
9164
+ }
9165
+ return true;
9166
+ },
9167
+ { construct: "conformance_test.preparation", id }
9168
+ );
9169
+ },
9170
+ `conformance_test.preparation. ID ${id}`
9171
+ );
9172
+ }
9173
+ function parseStimulus(block, id) {
9174
+ return parseProgramBody(
9175
+ block,
9176
+ "point",
9177
+ () => ({
9178
+ order: null,
9179
+ drive: "",
9180
+ args: {},
9181
+ hold: "",
9182
+ freshWithin: "",
9183
+ acceptance: ""
9184
+ }),
9185
+ (pointBlock, point) => {
9186
+ forEachEntry(
9187
+ pointBlock,
9188
+ (facet, value) => {
9189
+ if (facet === "drive") {
9190
+ point.drive = stripWrapping(value());
9191
+ } else if (facet === "args") {
9192
+ point.args = parseProgramArgs(unwrapBlock(value()));
9193
+ } else if (facet === "hold") {
9194
+ point.hold = stripWrapping(value());
9195
+ } else if (facet === "fresh_within") {
9196
+ point.freshWithin = stripWrapping(value());
9197
+ } else if (facet === "acceptance") {
9198
+ point.acceptance = stripWrapping(value());
9199
+ } else {
9200
+ return false;
9201
+ }
9202
+ return true;
9203
+ },
9204
+ { construct: "conformance_test.stimulus", id }
9205
+ );
9206
+ },
9207
+ `conformance_test.stimulus. ID ${id}`
9208
+ );
9209
+ }
9210
+ function dumpProgramArgs(args2) {
9211
+ const keys = Object.keys(args2);
9212
+ if (keys.length === 0) {
9213
+ return "";
9214
+ }
9215
+ return " args { " + keys.map((k) => k + ': "' + escapeString(args2[k]) + '"').join(" ") + " }";
9216
+ }
9217
+ function dumpPreparation(program) {
9218
+ let out = " preparation {\n";
9219
+ if (program.description !== "") {
9220
+ out += ' description "' + escapeString(program.description) + '"\n';
9221
+ }
9222
+ for (const step of program.entries) {
9223
+ out += " step" + (step.order !== null ? " " + step.order : "") + " {";
9224
+ if (step.action !== "") {
9225
+ out += ' action "' + escapeString(step.action) + '"';
9226
+ }
9227
+ if (step.drive !== "") {
9228
+ out += " drive " + dumpBareSafe(step.drive);
9229
+ }
9230
+ out += dumpProgramArgs(step.args);
9231
+ if (step.hold !== "") {
9232
+ out += " hold " + dumpBareSafe(step.hold);
9233
+ }
9234
+ if (step.verify) {
9235
+ out += " verify {";
9236
+ if (step.verify.read !== "") {
9237
+ out += " read " + dumpBareSafe(step.verify.read);
9238
+ }
9239
+ if (step.verify.tolerance !== "") {
9240
+ out += " tolerance " + dumpBareSafe(step.verify.tolerance);
9241
+ }
9242
+ out += " }";
9243
+ }
9244
+ out += " }\n";
9245
+ }
9246
+ for (const src of program.sourceRefs) {
9247
+ out += dumpSourceRefAsRef(src, " ", escapeString);
9248
+ }
9249
+ return out + " }\n";
9250
+ }
9251
+ function dumpStimulus(program) {
9252
+ let out = " stimulus {\n";
9253
+ if (program.description !== "") {
9254
+ out += ' description "' + escapeString(program.description) + '"\n';
9255
+ }
9256
+ for (const point of program.entries) {
9257
+ out += " point" + (point.order !== null ? " " + point.order : "") + " {";
9258
+ if (point.drive !== "") {
9259
+ out += " drive " + dumpBareSafe(point.drive);
9260
+ }
9261
+ out += dumpProgramArgs(point.args);
9262
+ if (point.hold !== "") {
9263
+ out += " hold " + dumpBareSafe(point.hold);
9264
+ }
9265
+ if (point.freshWithin !== "") {
9266
+ out += " fresh_within " + dumpBareSafe(point.freshWithin);
9267
+ }
9268
+ if (point.acceptance !== "") {
9269
+ out += " acceptance " + dumpBareSafe(point.acceptance);
9270
+ }
9271
+ out += " }\n";
9272
+ }
9273
+ for (const src of program.sourceRefs) {
9274
+ out += dumpSourceRefAsRef(src, " ", escapeString);
9275
+ }
9276
+ return out + " }\n";
9277
+ }
9172
9278
  var parseConformanceTest = function(id, data) {
9173
9279
  const result = {
9174
9280
  id,
@@ -9180,6 +9286,8 @@ var parseConformanceTest = function(id, data) {
9180
9286
  bindsTo: [],
9181
9287
  applicability: [],
9182
9288
  procedure: [],
9289
+ preparation: null,
9290
+ stimulus: null,
9183
9291
  measurements: [],
9184
9292
  kind: "",
9185
9293
  obligation: "",
@@ -9302,6 +9410,10 @@ var parseConformanceTest = function(id, data) {
9302
9410
  }
9303
9411
  } else if (keyword === "procedure_steps") {
9304
9412
  result.procedureSteps = readStringList(value());
9413
+ } else if (keyword === "preparation") {
9414
+ result.preparation = parsePreparation(unwrapBlock(value()), id);
9415
+ } else if (keyword === "stimulus") {
9416
+ result.stimulus = parseStimulus(unwrapBlock(value()), id);
9305
9417
  } else if (keyword === "kind") {
9306
9418
  result.kind = stripWrapping(value());
9307
9419
  } else if (keyword === "obligation") {
@@ -9432,6 +9544,12 @@ var dumpConformanceTest = function(ct) {
9432
9544
  if (ct.procedureSteps && ct.procedureSteps.length > 0) {
9433
9545
  out += " procedure_steps { " + ct.procedureSteps.join(" ") + " }\n";
9434
9546
  }
9547
+ if (ct.preparation) {
9548
+ out += dumpPreparation(ct.preparation);
9549
+ }
9550
+ if (ct.stimulus) {
9551
+ out += dumpStimulus(ct.stimulus);
9552
+ }
9435
9553
  if (ct.measurements.length > 0) {
9436
9554
  out += " validate_measurement {\n";
9437
9555
  for (const m of ct.measurements) {
@@ -10993,7 +11111,7 @@ function readLimit(block) {
10993
11111
  } else if (cmd === "notes") {
10994
11112
  limit.notes = stripWrapping(t[i++]);
10995
11113
  } else if (cmd === "quantity") {
10996
- const quantity = { kind: "", unit: "" };
11114
+ const quantity2 = { kind: "", unit: "" };
10997
11115
  const qt = tokenize(unwrapBlock(t[i++]));
10998
11116
  let k = 0;
10999
11117
  while (k < qt.length) {
@@ -11002,14 +11120,14 @@ function readLimit(block) {
11002
11120
  break;
11003
11121
  }
11004
11122
  if (qc === "kind") {
11005
- quantity.kind = stripWrapping(qt[k++]);
11123
+ quantity2.kind = stripWrapping(qt[k++]);
11006
11124
  } else if (qc === "unit") {
11007
- quantity.unit = stripWrapping(qt[k++]);
11125
+ quantity2.unit = stripWrapping(qt[k++]);
11008
11126
  } else {
11009
11127
  unwrapBlock(qt[k++]);
11010
11128
  }
11011
11129
  }
11012
- limit.quantity = quantity;
11130
+ limit.quantity = quantity2;
11013
11131
  } else if (cmd === "accepts") {
11014
11132
  limit.accepts = readAccepts(unwrapBlock(t[i++]));
11015
11133
  } else if (cmd === "acceptance") {
@@ -12450,6 +12568,8 @@ function parseDimension(id, block) {
12450
12568
  dim.source = readSource(unwrapBlock(t[i++]));
12451
12569
  } else if (cmd === "values") {
12452
12570
  dim.values = parseDimensionValues(unwrapBlock(t[i++]));
12571
+ } else if (cmd === "payload_class") {
12572
+ dim.payloadClass = stripColon(stripWrapping(t[i++]));
12453
12573
  } else if (cmd === "values_of") {
12454
12574
  dim.valuesOf = stripWrapping(t[i++]);
12455
12575
  } else if (cmd === "ref") {
@@ -12558,6 +12678,9 @@ function dumpDimension(d, indent) {
12558
12678
  if (d.description) {
12559
12679
  out += inner + 'description "' + escapeString(d.description) + '"\n';
12560
12680
  }
12681
+ if (d.payloadClass) {
12682
+ out += inner + "payload_class " + d.payloadClass + "\n";
12683
+ }
12561
12684
  out += dumpSource2("reference", d.source, inner);
12562
12685
  if (d.valuesOf) {
12563
12686
  out += inner + "values_of " + d.valuesOf + "\n";
@@ -12955,6 +13078,8 @@ var parseAttributeDefinition = function(id, data) {
12955
13078
  result.note = stripWrapping(t[i++]);
12956
13079
  } else if (cmd === "irdi") {
12957
13080
  result.irdi = stripWrapping(t[i++]);
13081
+ } else if (cmd === "class") {
13082
+ result.classRef = stripColon(stripWrapping(t[i++]));
12958
13083
  } else if (cmd === "derived") {
12959
13084
  result.derived = stripWrapping(t[i++]);
12960
13085
  } else if (cmd === "ref") {
@@ -13034,6 +13159,9 @@ var dumpAttributeDefinition = function(a) {
13034
13159
  if (a.irdi) {
13035
13160
  out += ' irdi "' + escapeString(a.irdi) + '"\n';
13036
13161
  }
13162
+ if (a.classRef) {
13163
+ out += " class " + a.classRef + "\n";
13164
+ }
13037
13165
  if (a.derived) {
13038
13166
  out += ' derived "' + escapeString(a.derived) + '"\n';
13039
13167
  }
@@ -14177,6 +14305,16 @@ function parseInstanceHas(block, result) {
14177
14305
  }
14178
14306
  }
14179
14307
  }
14308
+ function readQuantity2(tokens) {
14309
+ if (tokens.length === 0) {
14310
+ return { value: "" };
14311
+ }
14312
+ const first = stripWrapping(tokens[0]);
14313
+ if (tokens.length === 1) {
14314
+ return { value: first };
14315
+ }
14316
+ return { value: first, unit: tokens.slice(1).map(stripWrapping).join(" ") };
14317
+ }
14180
14318
  var parseInstance = function(id, data) {
14181
14319
  const result = {
14182
14320
  id,
@@ -14198,6 +14336,13 @@ var parseInstance = function(id, data) {
14198
14336
  }
14199
14337
  if (cmd === "of") {
14200
14338
  result.of = stripWrapping(t[i++]);
14339
+ } else if (t[i] === "=" && i + 1 < t.length) {
14340
+ i++;
14341
+ const valueTokens = [];
14342
+ while (i < t.length && t[i] !== "}" && !(i + 1 < t.length && t[i + 1] === "=")) {
14343
+ valueTokens.push(t[i++]);
14344
+ }
14345
+ result.has.attributes[cmd] = readQuantity2(valueTokens);
14201
14346
  } else if (cmd === "level") {
14202
14347
  result.level = stripWrapping(t[i++]);
14203
14348
  } else if (cmd === "model") {
@@ -14815,25 +14960,146 @@ var dumpEvaluationProfile = function(p) {
14815
14960
  return out;
14816
14961
  };
14817
14962
 
14818
- // src/ser-des/config/certificateTemplate.ts
14819
- var CERTIFICATE_OBLIGATIONS = ["mandatory", "optional"];
14820
- function readIdList6(block) {
14821
- return tokenize(stripWrapping(block)).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
14822
- }
14823
- var parseCertificateTemplate = (id, data) => {
14824
- const template = {
14963
+ // src/ser-des/config/attestation.ts
14964
+ var parseAttestation = (id, data) => {
14965
+ const a = {
14825
14966
  id,
14826
- numberFormat: "",
14827
- dimensionLabels: null,
14828
- characteristics: [],
14829
- anrSection: null
14967
+ subject: "",
14968
+ promises: "",
14969
+ basis: [],
14970
+ authority: { role: "", name: "" },
14971
+ statement: "",
14972
+ limits: [],
14973
+ claims: [],
14974
+ referenceIds: []
14830
14975
  };
14831
14976
  forEachEntry(
14832
14977
  data,
14833
14978
  (keyword, value) => {
14834
- if (keyword === "number_format") {
14835
- template.numberFormat = stripWrapping(value());
14836
- } else if (keyword === "dimension_labels") {
14979
+ if (keyword === "subject") {
14980
+ a.subject = stripWrapping(stripColon(value()));
14981
+ } else if (keyword === "promises") {
14982
+ a.promises = stripWrapping(stripColon(value()));
14983
+ } else if (keyword === "basis") {
14984
+ const kind = stripWrapping(stripColon(value()));
14985
+ const eid = stripWrapping(value());
14986
+ a.basis.push({ kind, id: eid });
14987
+ } else if (keyword === "authority") {
14988
+ const role = stripWrapping(stripColon(value()));
14989
+ const name = stripWrapping(value());
14990
+ a.authority = { role, name };
14991
+ } else if (keyword === "statement") {
14992
+ a.statement = stripWrapping(value());
14993
+ } else if (keyword === "limits") {
14994
+ forEachEntry(
14995
+ unwrapBlock(value()),
14996
+ (label, text) => {
14997
+ const limit = {
14998
+ label: stripColon(label),
14999
+ text: stripWrapping(text())
15000
+ };
15001
+ a.limits.push(limit);
15002
+ return true;
15003
+ },
15004
+ { construct: "attestation", id }
15005
+ );
15006
+ } else if (keyword === "claims") {
15007
+ forEachEntry(
15008
+ unwrapBlock(value()),
15009
+ (promise, claimValue) => {
15010
+ const claim = {
15011
+ promise: stripColon(promise),
15012
+ declared: "",
15013
+ validatedBy: ""
15014
+ };
15015
+ forEachEntry(
15016
+ unwrapBlock(claimValue()),
15017
+ (k2, v2) => {
15018
+ if (k2 === "declared") {
15019
+ claim.declared = stripWrapping(stripColon(v2()));
15020
+ } else if (k2 === "validated_by") {
15021
+ claim.validatedBy = stripWrapping(stripColon(v2()));
15022
+ } else {
15023
+ return false;
15024
+ }
15025
+ return true;
15026
+ },
15027
+ { construct: "attestation", id }
15028
+ );
15029
+ a.claims.push(claim);
15030
+ return true;
15031
+ },
15032
+ { construct: "attestation", id }
15033
+ );
15034
+ } else {
15035
+ return false;
15036
+ }
15037
+ return true;
15038
+ },
15039
+ { construct: "attestation", id }
15040
+ );
15041
+ return (ctx) => {
15042
+ ctx.attestations[id] = a;
15043
+ return ctx;
15044
+ };
15045
+ };
15046
+ var dumpAttestation = function(a) {
15047
+ let out = "attestation " + dumpBareSafe(a.id) + " {\n";
15048
+ if (a.subject) {
15049
+ out += " subject " + dumpBareSafe(a.subject) + "\n";
15050
+ }
15051
+ if (a.promises) {
15052
+ out += " promises " + dumpBareSafe(a.promises) + "\n";
15053
+ }
15054
+ for (const b of a.basis) {
15055
+ out += " basis " + dumpBareSafe(b.kind) + ' "' + b.id.replace(/"/g, '\\"') + '"\n';
15056
+ }
15057
+ if (a.authority.role || a.authority.name) {
15058
+ out += " authority " + dumpBareSafe(a.authority.role) + ' "' + a.authority.name.replace(/"/g, '\\"') + '"\n';
15059
+ }
15060
+ if (a.statement) {
15061
+ out += ' statement "' + a.statement.replace(/"/g, '\\"') + '"\n';
15062
+ }
15063
+ if (a.limits.length > 0) {
15064
+ out += " limits {\n";
15065
+ for (const l of a.limits) {
15066
+ out += " " + dumpBareSafe(l.label) + ' "' + l.text.replace(/"/g, '\\"') + '"\n';
15067
+ }
15068
+ out += " }\n";
15069
+ }
15070
+ if (a.claims.length > 0) {
15071
+ out += " claims {\n";
15072
+ for (const c of a.claims) {
15073
+ out += " " + dumpBareSafe(c.promise) + " {\n";
15074
+ out += " declared " + dumpBareSafe(c.declared) + "\n";
15075
+ out += " validated_by " + dumpBareSafe(c.validatedBy) + "\n";
15076
+ out += " }\n";
15077
+ }
15078
+ out += " }\n";
15079
+ }
15080
+ out += "}\n";
15081
+ return out;
15082
+ };
15083
+
15084
+ // src/ser-des/config/certificateTemplate.ts
15085
+ var CERTIFICATE_OBLIGATIONS = ["mandatory", "optional"];
15086
+ function readIdList6(block) {
15087
+ return tokenize(stripWrapping(block)).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
15088
+ }
15089
+ var parseCertificateTemplate = (id, data) => {
15090
+ const template = {
15091
+ id,
15092
+ numberFormat: "",
15093
+ dimensionLabels: null,
15094
+ characteristics: [],
15095
+ anrSection: null
15096
+ };
15097
+ forEachEntry(
15098
+ data,
15099
+ (keyword, value) => {
15100
+ if (keyword === "number_format") {
15101
+ template.numberFormat = stripWrapping(value());
15102
+ } else if (keyword === "dimension_labels") {
14837
15103
  const labels = { pattern: "", separator: "" };
14838
15104
  forEachEntry(
14839
15105
  unwrapBlock(value()),
@@ -15112,6 +15378,8 @@ var parseArtifactDefinition = function(id, data) {
15112
15378
  result.description = stripWrapping(t[i++]);
15113
15379
  } else if (cmd === "content_contract") {
15114
15380
  result.contentContract = parseContentContract(unwrapBlock(t[i++]));
15381
+ } else if (cmd === "contract_from") {
15382
+ result.contractFrom = stripColon(stripWrapping(t[i++]));
15115
15383
  } else if (cmd === "produced_when") {
15116
15384
  const kind = stripWrapping(t[i++] ?? "");
15117
15385
  if (kind === "per_interval") {
@@ -15167,6 +15435,9 @@ var dumpArtifactDefinition = function(d) {
15167
15435
  if (d.description) {
15168
15436
  out += ' description "' + escapeString(d.description) + '"\n';
15169
15437
  }
15438
+ if (d.contractFrom) {
15439
+ out += " contract_from " + d.contractFrom + "\n";
15440
+ }
15170
15441
  const c = d.contentContract;
15171
15442
  const hasContract = c.fields.length > 0 || c.structure || c.media.length > 0;
15172
15443
  if (hasContract) {
@@ -18170,6 +18441,68 @@ var dumpDecisionRule = function(r) {
18170
18441
  return out;
18171
18442
  };
18172
18443
 
18444
+ // src/ser-des/config/processSequence.ts
18445
+ function parseProcessSequence(block) {
18446
+ return tokenizePackage(block).map(stripColon).map(stripWrapping).filter((s) => s.length > 0);
18447
+ }
18448
+ function parseProcessRegister(id, block) {
18449
+ const register = {
18450
+ id,
18451
+ label: "",
18452
+ clause: "",
18453
+ maintainer: "",
18454
+ published: "",
18455
+ entries: ""
18456
+ };
18457
+ forEachEntry(
18458
+ block,
18459
+ (keyword, value) => {
18460
+ if (keyword === "label") {
18461
+ register.label = stripWrapping(value());
18462
+ } else if (keyword === "clause") {
18463
+ register.clause = stripWrapping(value());
18464
+ } else if (keyword === "maintainer") {
18465
+ register.maintainer = stripWrapping(value());
18466
+ } else if (keyword === "published") {
18467
+ register.published = stripWrapping(value());
18468
+ } else if (keyword === "entries") {
18469
+ register.entries = stripWrapping(value());
18470
+ } else {
18471
+ return false;
18472
+ }
18473
+ return true;
18474
+ },
18475
+ { construct: "process_model register", id }
18476
+ );
18477
+ return register;
18478
+ }
18479
+ function dumpProcessSequence(sequence) {
18480
+ if (sequence.length === 0) {
18481
+ return "";
18482
+ }
18483
+ return "sequence { " + sequence.map(dumpBareSafe).join(" ") + " }";
18484
+ }
18485
+ function dumpProcessRegister(r, indent) {
18486
+ let out = indent + "register " + dumpBareSafe(r.id) + " {\n";
18487
+ if (r.label) {
18488
+ out += indent + ' label "' + escapeString(r.label) + '"\n';
18489
+ }
18490
+ if (r.clause) {
18491
+ out += indent + ' clause "' + escapeString(r.clause) + '"\n';
18492
+ }
18493
+ if (r.maintainer) {
18494
+ out += indent + " maintainer " + dumpBareSafe(r.maintainer) + "\n";
18495
+ }
18496
+ if (r.published) {
18497
+ out += indent + ' published "' + escapeString(r.published) + '"\n';
18498
+ }
18499
+ if (r.entries) {
18500
+ out += indent + ' entries "' + escapeString(r.entries) + '"\n';
18501
+ }
18502
+ out += indent + "}\n";
18503
+ return out;
18504
+ }
18505
+
18173
18506
  // src/ser-des/config/documentModule.ts
18174
18507
  var parseDocumentModule = (id, data) => {
18175
18508
  const module = {
@@ -18504,234 +18837,6 @@ var dumpPartAnnex = function(a) {
18504
18837
  return out;
18505
18838
  };
18506
18839
 
18507
- // src/ser-des/config/storyline.ts
18508
- function readRecordValue(token) {
18509
- if (token.startsWith("{")) {
18510
- return tokenize(unwrapBlock(token)).filter((s) => s.length > 0).map(coerceValueToken);
18511
- }
18512
- return coerceValueToken(token);
18513
- }
18514
- function readRecordFields(block) {
18515
- const fields = {};
18516
- const t = tokenize(block);
18517
- let i = 0;
18518
- while (i < t.length) {
18519
- const key = t[i++];
18520
- if (i >= t.length) {
18521
- break;
18522
- }
18523
- fields[stripColon(key)] = readRecordValue(t[i++]);
18524
- }
18525
- return fields;
18526
- }
18527
- function dumpRecordFields(fields, indent) {
18528
- let out = "";
18529
- for (const [key, value] of Object.entries(fields)) {
18530
- if (Array.isArray(value)) {
18531
- out += indent + key + " { " + value.map(dumpScalarToken).join(" ") + " }\n";
18532
- } else {
18533
- out += indent + key + " " + dumpScalarToken(value) + "\n";
18534
- }
18535
- }
18536
- return out;
18537
- }
18538
- function parseParticipants(block) {
18539
- const sections = [];
18540
- const t = tokenize(block);
18541
- let i = 0;
18542
- while (i < t.length) {
18543
- const sid = stripWrapping(t[i++]);
18544
- if (i >= t.length || !t[i].startsWith("{")) {
18545
- break;
18546
- }
18547
- const section = { id: sid, entries: [] };
18548
- const st = tokenize(unwrapBlock(t[i++]));
18549
- let j = 0;
18550
- while (j < st.length) {
18551
- const eid = stripWrapping(st[j++]);
18552
- if (j >= st.length || !st[j].startsWith("{")) {
18553
- break;
18554
- }
18555
- section.entries.push({
18556
- id: eid,
18557
- fields: readRecordFields(unwrapBlock(st[j++]))
18558
- });
18559
- }
18560
- sections.push(section);
18561
- }
18562
- return sections;
18563
- }
18564
- var parseDemoWorld = (id, data) => {
18565
- const world = {
18566
- id,
18567
- standard: "",
18568
- description: "",
18569
- participants: []
18570
- };
18571
- forEachEntry(
18572
- data,
18573
- (keyword, value) => {
18574
- if (keyword === "standard") {
18575
- world.standard = stripWrapping(value());
18576
- } else if (keyword === "description") {
18577
- world.description = stripWrapping(value());
18578
- } else if (keyword === "participants") {
18579
- world.participants = parseParticipants(unwrapBlock(value()));
18580
- } else {
18581
- return false;
18582
- }
18583
- return true;
18584
- },
18585
- { construct: "demo_world", id }
18586
- );
18587
- return (ctx) => {
18588
- ctx.demoWorlds[id] = world;
18589
- return ctx;
18590
- };
18591
- };
18592
- var dumpDemoWorld = function(w) {
18593
- let out = "demo_world " + w.id + " {\n";
18594
- if (w.standard) {
18595
- out += " standard " + dumpBareSafe(w.standard) + "\n";
18596
- }
18597
- if (w.description) {
18598
- out += ' description "' + escapeString(w.description) + '"\n';
18599
- }
18600
- if (w.participants.length > 0) {
18601
- out += " participants {\n";
18602
- for (const s of w.participants) {
18603
- out += " " + dumpBareSafe(s.id) + " {\n";
18604
- for (const e of s.entries) {
18605
- out += " " + dumpBareSafe(e.id) + " {\n";
18606
- out += dumpRecordFields(e.fields, " ");
18607
- out += " }\n";
18608
- }
18609
- out += " }\n";
18610
- }
18611
- out += " }\n";
18612
- }
18613
- out += "}\n";
18614
- return out;
18615
- };
18616
- function parseSubjectEntries(block) {
18617
- const entries = [];
18618
- const t = tokenize(block);
18619
- let i = 0;
18620
- while (i < t.length) {
18621
- const kind = stripWrapping(t[i++]);
18622
- if (i >= t.length) {
18623
- break;
18624
- }
18625
- const eid = stripWrapping(t[i++]);
18626
- const entry = { kind, id: eid, fields: {} };
18627
- if (i < t.length && t[i].startsWith("{")) {
18628
- entry.fields = readRecordFields(unwrapBlock(t[i++]));
18629
- }
18630
- entries.push(entry);
18631
- }
18632
- return entries;
18633
- }
18634
- var parseStoryline = (id, data) => {
18635
- const storyline = {
18636
- id,
18637
- name: "",
18638
- idPrefix: "",
18639
- party: { laboratory: "", authority: "" },
18640
- subject: [],
18641
- records: [],
18642
- notes: []
18643
- };
18644
- forEachEntry(
18645
- data,
18646
- (keyword, value, peek) => {
18647
- if (keyword === "name") {
18648
- storyline.name = stripWrapping(value());
18649
- } else if (keyword === "id_prefix") {
18650
- storyline.idPrefix = stripWrapping(value());
18651
- } else if (keyword === "party") {
18652
- const pt = tokenize(unwrapBlock(value()));
18653
- for (let j = 0; j + 1 < pt.length; j += 2) {
18654
- if (pt[j] === "laboratory") {
18655
- storyline.party.laboratory = stripWrapping(pt[j + 1]);
18656
- } else if (pt[j] === "authority") {
18657
- storyline.party.authority = stripWrapping(pt[j + 1]);
18658
- }
18659
- }
18660
- } else if (keyword === "subject") {
18661
- storyline.subject = parseSubjectEntries(unwrapBlock(value()));
18662
- } else if (keyword === "record") {
18663
- const store = stripWrapping(value());
18664
- const idHead = peek();
18665
- if (idHead === void 0 || idHead.startsWith("{")) {
18666
- throw new Error(
18667
- `Parsing error: storyline. ID ${id}: record ${store} is missing its id and block`
18668
- );
18669
- }
18670
- const rid = stripWrapping(value());
18671
- const blockHead = peek();
18672
- if (blockHead === void 0 || !blockHead.startsWith("{")) {
18673
- throw new Error(
18674
- `Parsing error: storyline. ID ${id}: record ${store} ${rid} is missing its block`
18675
- );
18676
- }
18677
- storyline.records.push({
18678
- store,
18679
- id: rid,
18680
- fields: readRecordFields(unwrapBlock(value()))
18681
- });
18682
- } else if (keyword === "note") {
18683
- storyline.notes.push(stripWrapping(value()));
18684
- } else {
18685
- return false;
18686
- }
18687
- return true;
18688
- },
18689
- { construct: "storyline", id }
18690
- );
18691
- return (ctx) => {
18692
- ctx.storylines[id] = storyline;
18693
- return ctx;
18694
- };
18695
- };
18696
- var dumpStoryline = function(s) {
18697
- let out = "storyline " + s.id + " {\n";
18698
- if (s.name) {
18699
- out += ' name "' + escapeString(s.name) + '"\n';
18700
- }
18701
- if (s.idPrefix) {
18702
- out += " id_prefix " + dumpBareSafe(s.idPrefix) + "\n";
18703
- }
18704
- if (s.party.laboratory || s.party.authority) {
18705
- out += " party {";
18706
- if (s.party.laboratory) {
18707
- out += " laboratory " + dumpBareSafe(s.party.laboratory);
18708
- }
18709
- if (s.party.authority) {
18710
- out += " authority " + dumpBareSafe(s.party.authority);
18711
- }
18712
- out += " }\n";
18713
- }
18714
- if (s.subject.length > 0) {
18715
- out += " subject {\n";
18716
- for (const e of s.subject) {
18717
- out += " " + dumpBareSafe(e.kind) + " " + dumpBareSafe(e.id) + " {\n";
18718
- out += dumpRecordFields(e.fields, " ");
18719
- out += " }\n";
18720
- }
18721
- out += " }\n";
18722
- }
18723
- for (const r of s.records) {
18724
- out += " record " + dumpBareSafe(r.store) + " " + dumpBareSafe(r.id) + " {\n";
18725
- out += dumpRecordFields(r.fields, " ");
18726
- out += " }\n";
18727
- }
18728
- for (const n of s.notes) {
18729
- out += ' note "' + escapeString(n) + '"\n';
18730
- }
18731
- out += "}\n";
18732
- return out;
18733
- };
18734
-
18735
18840
  // src/ser-des/config/index.ts
18736
18841
  function defineConstruct(def) {
18737
18842
  return def;
@@ -18762,33 +18867,12 @@ var CONSTRUCTS = [
18762
18867
  }),
18763
18868
  // The abstract-process model's file-level home (smart TODO.roadmap/40
18764
18869
  // batch 2): the pipeline sequence + the participant/expert registers.
18765
- defineConstruct({
18766
- keyword: "process_model",
18767
- field: "processModels",
18768
- takesID: true,
18769
- parse: parseProcessModel,
18770
- dump: dumpProcessModel
18771
- }),
18772
18870
  // The certification workflow step register (smart TODO.roadmap/40
18773
18871
  // batch 3) — process-adjacent but NOT the abstract-process machinery;
18774
18872
  // the rec-overlay deep merge (OVERLAY_DEEP_MERGE_FIELDS) lands here.
18775
- defineConstruct({
18776
- keyword: "workflow_config",
18777
- field: "workflowConfigs",
18778
- takesID: true,
18779
- parse: parseWorkflowConfig,
18780
- dump: dumpWorkflowConfig
18781
- }),
18782
18873
  // The named pipeline stage (smart TODO.roadmap/40 batch 5) — groups
18783
18874
  // the workflow constructs per stage; the members-resolve discipline
18784
18875
  // is C142's.
18785
- defineConstruct({
18786
- keyword: "workflow_stage",
18787
- field: "workflowStages",
18788
- takesID: true,
18789
- parse: parseWorkflowStage,
18790
- dump: dumpWorkflowStage
18791
- }),
18792
18876
  defineConstruct({
18793
18877
  keyword: "approval",
18794
18878
  field: "approvals",
@@ -18964,6 +19048,16 @@ var CONSTRUCTS = [
18964
19048
  // The certificate rendering contract (smart TODO.roadmap/40 batch 3)
18965
19049
  // — form-adjacent (the certificate is the issuing-side document);
18966
19050
  // singleton per package.
19051
+ // The attestation (the typed kernel; clause 19) — the claim that a
19052
+ // third party has verified a subject against a declared promise set,
19053
+ // carrying the lineage of the claims (C150/C151 check the references).
19054
+ defineConstruct({
19055
+ keyword: "attestation",
19056
+ field: "attestations",
19057
+ takesID: true,
19058
+ parse: parseAttestation,
19059
+ dump: dumpAttestation
19060
+ }),
18967
19061
  defineConstruct({
18968
19062
  keyword: "certificate_template",
18969
19063
  field: "certificateTemplates",
@@ -19353,24 +19447,6 @@ var CONSTRUCTS = [
19353
19447
  parse: parsePartAnnex,
19354
19448
  dump: dumpPartAnnex
19355
19449
  }),
19356
- // The demo seeds (smart TODO.roadmap/40 batch 4) — one demo_world per
19357
- // package (file-level metadata + the OPEN participants registry) and
19358
- // one storyline per flow; the record-value sub-grammar follows the
19359
- // quantity.ts dumpScalarToken conventions.
19360
- defineConstruct({
19361
- keyword: "demo_world",
19362
- field: "demoWorlds",
19363
- takesID: true,
19364
- parse: parseDemoWorld,
19365
- dump: dumpDemoWorld
19366
- }),
19367
- defineConstruct({
19368
- keyword: "storyline",
19369
- field: "storylines",
19370
- takesID: true,
19371
- parse: parseStoryline,
19372
- dump: dumpStoryline
19373
- }),
19374
19450
  // Primmel v3 twin interface (TODO.roadmap/32 — doctrine ch. 14 §14.4):
19375
19451
  // the connector-profile registry. Endpoints and serve bindings are NOT
19376
19452
  // top-level constructs — they are subject anatomy slots (is.endpoints /
@@ -19432,7 +19508,12 @@ function buildParserConfig(constructs) {
19432
19508
  if (!c.field) {
19433
19509
  continue;
19434
19510
  }
19435
- const entry = { takesID: c.takesID, parse: c.parse, field: c.field };
19511
+ const entry = {
19512
+ takesID: c.takesID,
19513
+ parse: c.parse,
19514
+ field: c.field,
19515
+ ...c.deprecated ? { deprecated: c.deprecated } : {}
19516
+ };
19436
19517
  out[c.keyword] = entry;
19437
19518
  for (const alias of c.aliases ?? []) {
19438
19519
  out[alias] = entry;
@@ -19715,7 +19796,6 @@ var MERGE_FIELDS = [
19715
19796
  "processes",
19716
19797
  // The abstract-process models (smart TODO.roadmap/40 batch 2) compose
19717
19798
  // like the processes they sequence, with uses-no-redefine semantics.
19718
- "processModels",
19719
19799
  "pages",
19720
19800
  "gateways",
19721
19801
  "regs",
@@ -19769,6 +19849,7 @@ var MERGE_FIELDS = [
19769
19849
  // like the subject anatomy they extend, with uses-no-redefine
19770
19850
  // semantics.
19771
19851
  "promiseSets",
19852
+ "attestations",
19772
19853
  // The applicant-facing documentation register (smart TODO.roadmap/40
19773
19854
  // batch 3) composes with uses-no-redefine semantics.
19774
19855
  "applicationDeclarations",
@@ -19782,10 +19863,8 @@ var MERGE_FIELDS = [
19782
19863
  "certificateTemplates",
19783
19864
  // The certification workflow step register (smart TODO.roadmap/40
19784
19865
  // batch 3) — the rec-overlay deep merge (OVERLAY_DEEP_MERGE_FIELDS).
19785
- "workflowConfigs",
19786
19866
  // The named pipeline stages (smart TODO.roadmap/40 batch 5) compose
19787
19867
  // with uses-no-redefine semantics.
19788
- "workflowStages",
19789
19868
  // The verification pathways (smart TODO.roadmap/40 batch 3) compose
19790
19869
  // with uses-no-redefine semantics.
19791
19870
  "verificationPathways",
@@ -19837,8 +19916,6 @@ var MERGE_FIELDS = [
19837
19916
  "documentModules",
19838
19917
  "informativeAnnexes",
19839
19918
  "partAnnexes",
19840
- "demoWorlds",
19841
- "storylines",
19842
19919
  // The pre-existing drift closed (the packages-as-SSOT epic): these
19843
19920
  // collections existed as constructs but were never merged, so `uses`
19844
19921
  // composition silently dropped them — comments, predicates, the
@@ -19861,13 +19938,17 @@ var OVERLAY_DEEP_MERGE_FIELDS = /* @__PURE__ */ new Set([
19861
19938
  // The workflow step register (B3.7): a rec package's overlay-marked
19862
19939
  // workflow_config merges field-wise into the core skeleton (steps
19863
19940
  // union by id in first-seen order, gates append as a union).
19864
- "workflowConfigs",
19865
19941
  // The OIML-CS test-report checklist (B3.10): a rec package's
19866
19942
  // overlay-marked test_report_checklist merges field-wise into the
19867
19943
  // oiml-cs base — entry scalars land IN PLACE (the base order
19868
19944
  // survives; append-at-end would reorder the composition-point
19869
19945
  // entries to the tail).
19870
- "testReportChecklists"
19946
+ "testReportChecklists",
19947
+ // The entity classes (the smart core's #data plane): a rec
19948
+ // package's overlay-marked class merges field-wise into the core's
19949
+ // — attributes union by id in first-seen order (the rec's added
19950
+ // fields land beside the core's), scalars override.
19951
+ "dataclasses"
19871
19952
  ]);
19872
19953
  function isPlainRecord(v) {
19873
19954
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -20029,7 +20110,7 @@ function composePackage(rootDir, options, rootManifest, withProvenance = false)
20029
20110
  )) {
20030
20111
  const prior = pm.get(key);
20031
20112
  if (prior !== void 0) {
20032
- const isOverlay = typeof value === "object" && value !== null && value.overlay === true && (field === "terms" || OVERLAY_DEEP_MERGE_FIELDS.has(field));
20113
+ const isOverlay = typeof value === "object" && value !== null && value.overlay === true && (field === "terms" || field === "processes" || OVERLAY_DEEP_MERGE_FIELDS.has(field));
20033
20114
  if (!isOverlay) {
20034
20115
  throw new CompositionError(
20035
20116
  "uses-no-redefine",
@@ -20794,10 +20875,8 @@ var TIER_BY_FIELD = {
20794
20875
  certificateTemplates: "secondary",
20795
20876
  // The certification workflow step register (smart TODO.roadmap/40
20796
20877
  // batch 3) — operational wiring, tertiary.
20797
- workflowConfigs: "tertiary",
20798
20878
  // The named pipeline stages (smart TODO.roadmap/40 batch 5) —
20799
20879
  // operational wiring, tertiary.
20800
- workflowStages: "tertiary",
20801
20880
  // The verification pathways (smart TODO.roadmap/40 batch 3) —
20802
20881
  // operational wiring, tertiary.
20803
20882
  verificationPathways: "tertiary",
@@ -20837,7 +20916,6 @@ var TIER_BY_FIELD = {
20837
20916
  // Process models (smart TODO.roadmap/40 batch 2) are tertiary beside
20838
20917
  // processes: the pipeline sequence/registers are the abstract-process
20839
20918
  // model's file-level furniture.
20840
- processModels: "tertiary",
20841
20919
  // Document modules (smart TODO.roadmap/40 batch 2) are tertiary beside
20842
20920
  // processes: the module is the pipeline's document-level furniture.
20843
20921
  documentModules: "tertiary",
@@ -20863,8 +20941,6 @@ var TIER_BY_FIELD = {
20863
20941
  // the model.
20864
20942
  informativeAnnexes: "cross-cutting",
20865
20943
  partAnnexes: "cross-cutting",
20866
- demoWorlds: "tertiary",
20867
- storylines: "tertiary",
20868
20944
  // Invariants (smart gap-close E9) are cross-cutting beside notes: the
20869
20945
  // typed replacement for the note-family encoding — doctrine about the
20870
20946
  // model, not machinery inside it (the enforcement claims point at the
@@ -21842,6 +21918,29 @@ var CHECK_RULES = [
21842
21918
  "normal",
21843
21919
  "TODO.roadmap/03"
21844
21920
  ),
21921
+ // ── the power-type discipline (the reconfiguration phase 8; the CDD
21922
+ // family's central modelling relationship, and the CDDAL interop
21923
+ // requirement): every instance can serve as the definition of further
21924
+ // instantiation. C155 keeps the of-chain coherent — an instance that
21925
+ // instantiates another instance carries no upward subject-chain link,
21926
+ // and the of-graph is acyclic. C156 reaches the definition side: a
21927
+ // class's extends names a class or an instance.
21928
+ R(
21929
+ "C155",
21930
+ "power-type-chain",
21931
+ "instantiation",
21932
+ "error",
21933
+ "normal",
21934
+ "the reconfiguration phase 8 (TODO.reconfigure/09-subjects-twins-attestation.md, the power-type clause)"
21935
+ ),
21936
+ R(
21937
+ "C156",
21938
+ "class-extends-resolves",
21939
+ "instantiation",
21940
+ "warning",
21941
+ "normal",
21942
+ "the reconfiguration phase 8 (TODO.reconfigure/09-subjects-twins-attestation.md, the power-type clause)"
21943
+ ),
21845
21944
  // ── mapping (TODO.roadmap/04) ─────────────────────────────────────
21846
21945
  R(
21847
21946
  "C21",
@@ -22068,28 +22167,6 @@ var CHECK_RULES = [
22068
22167
  "normal",
22069
22168
  "smart TODO.roadmap/40 batch 4 (the packages-as-SSOT epic)"
22070
22169
  ),
22071
- // C129 (smart TODO.roadmap/40 batch 4; the packages-as-SSOT epic): the
22072
- // demo-seed shapes — the storyline's id_prefix pattern (register-free),
22073
- // the party laboratory/authority → the demo_world participant seeds
22074
- // (gated on that register), the record stores → the entity-class stores
22075
- // (gated), and the in-construct record cross-references (a record field
22076
- // keyed by a sibling record's store names a sibling of that store —
22077
- // ungated). Field-level discipline stays app-side.
22078
- R(
22079
- "C129",
22080
- "storyline-shape",
22081
- "composition",
22082
- "error",
22083
- "normal",
22084
- "smart TODO.roadmap/40 batch 4 (the packages-as-SSOT epic)"
22085
- ),
22086
- // C130 (smart TODO.roadmap/40 batch 3; the packages-as-SSOT epic): the
22087
- // identity_slot / aspect registers — the ≥1-presentation shape leg, the
22088
- // aspect reference legs (term_ref → term, component → instrument
22089
- // component, attribute → attribute_definition, contains → identity path
22090
- // OR bare attribute/dimension id), and the R28 bind-path consumer leg
22091
- // (model.identity.<slot> / model.aspects.<id> in requirement/test
22092
- // binds_to), each leg gated on its target register (the C58 doctrine).
22093
22170
  R(
22094
22171
  "C130",
22095
22172
  "identity-and-aspect-references",
@@ -22845,6 +22922,106 @@ var CHECK_RULES = [
22845
22922
  "normal",
22846
22923
  "smart architecture-gaps-2026-07.md E10, data/schemas/test-sequences.yaml"
22847
22924
  ),
22925
+ // ── the executable test programs (smart TODO.twin-demo/03 — the
22926
+ // model-drive bindings) ──
22927
+ // The conformance test's preparation/stimulus facets are the
22928
+ // machine-executable half of the test declaration. C147 is the
22929
+ // program shape: entry orders are positive integers unique in the
22930
+ // program; a preparation step carries action AND/OR drive; a verify
22931
+ // block carries read AND tolerance; a stimulus point carries a drive
22932
+ // and an acceptance reference. C148 is the duration discipline: hold
22933
+ // and fresh_within parse as duration windows (the serve contract's
22934
+ // vocabulary), and a stimulus point declares fresh_within (§14.12's
22935
+ // no-stale-semantics doctrine). Reference RESOLUTION (the drive
22936
+ // operation names against the twin kind's declared vocabulary, the
22937
+ // acceptance/tolerance refs against requirement nodes) is the
22938
+ // consumer-side conformance leg's job — the kernel checks
22939
+ // syntax/shape only (the C92/C93 vs R39 split).
22940
+ R(
22941
+ "C147",
22942
+ "test-program-shape",
22943
+ "base",
22944
+ "error",
22945
+ "normal",
22946
+ "smart TODO.twin-demo/03 (the model-drive bindings)"
22947
+ ),
22948
+ R(
22949
+ "C148",
22950
+ "test-program-duration",
22951
+ "base",
22952
+ "error",
22953
+ "normal",
22954
+ "smart TODO.twin-demo/03 (the model-drive bindings)"
22955
+ ),
22956
+ // ── the deprecation report (phase 2 of the reconfiguration): a
22957
+ // construct whose definition carries a migration note warns on every
22958
+ // use; the retirement phase removes the constructs and the rule
22959
+ // burns down to empty.
22960
+ R(
22961
+ "C154",
22962
+ "construct-deprecated",
22963
+ "base",
22964
+ "warning",
22965
+ "normal",
22966
+ "the reconfiguration phase 2 (TODO.reconfigure/09-migration-plan.md)"
22967
+ ),
22968
+ // ── the attestation (the typed kernel, clause 19): the claim that a
22969
+ // third party has verified a subject against a declared promise set.
22970
+ // C150 resolves its subject, promise set, basis, authority, and claim
22971
+ // references; C151 requires the claim lineage — a mandatory
22972
+ // characteristic is carried by lineage, never restated.
22973
+ // ── the typed kernel R3 (the reconfiguration): the closed-derivation
22974
+ // rule. A derivation expression names only declared definitions —
22975
+ // calculations, tables, symbols, measurements, and attributes — and
22976
+ // the checker rejects anything else, naming the missing declaration.
22977
+ R(
22978
+ "C149",
22979
+ "closed-derivation-references-declared",
22980
+ "quantities",
22981
+ "error",
22982
+ "normal",
22983
+ "the typed kernel R3 (TODO.reconfigure/03-typed-kernel.md)"
22984
+ ),
22985
+ R(
22986
+ "C150",
22987
+ "attestation-references-resolve",
22988
+ "attestation",
22989
+ "error",
22990
+ "normal",
22991
+ "the typed kernel clause 19 (TODO.reconfigure/07-subjects-twins-attestation.md)"
22992
+ ),
22993
+ R(
22994
+ "C151",
22995
+ "attestation-claim-lineage",
22996
+ "attestation",
22997
+ "error",
22998
+ "normal",
22999
+ "the typed kernel clause 19 (TODO.reconfigure/07-subjects-twins-attestation.md)"
23000
+ ),
23001
+ // ── the typed payload rule (the typed kernel R2, clause 10): a
23002
+ // dimension that declares payload_class types every value's
23003
+ // definition — the class resolves, the payload fields are fields of
23004
+ // that class, and every value carries its definition.
23005
+ R(
23006
+ "C152",
23007
+ "payload-typed-by-class",
23008
+ "quantities",
23009
+ "error",
23010
+ "normal",
23011
+ "the typed kernel R2 (TODO.reconfigure/03-typed-kernel.md)"
23012
+ ),
23013
+ // ── the contract-derivation facet (the typed kernel, clause 10): an
23014
+ // artifact definition whose content is the projection of declared
23015
+ // claims derives its contract; the reference resolves and never
23016
+ // combines with inline fields.
23017
+ R(
23018
+ "C153",
23019
+ "artifact-contract-derivation",
23020
+ "artifacts",
23021
+ "error",
23022
+ "normal",
23023
+ "the typed kernel clause 10 (TODO.reconfigure/07-subjects-twins-attestation.md)"
23024
+ ),
22848
23025
  // ── the per-test evaluation-formula traces (smart gap-close E11,
22849
23026
  // analysis/architecture-gaps-2026-07.md; the smart contract
22850
23027
  // data/schemas/formulas-used.yaml) ──
@@ -23192,6 +23369,50 @@ function activeRuleIds(level) {
23192
23369
  );
23193
23370
  }
23194
23371
 
23372
+ // src/instance-resolution.ts
23373
+ function classPrototype(standard, classId) {
23374
+ const classes = new Map((standard.dataclasses ?? []).map((c) => [c.id, c]));
23375
+ const instances = new Map((standard.instances ?? []).map((i) => [i.id, i]));
23376
+ const seen = /* @__PURE__ */ new Set([classId]);
23377
+ let cur = classes.get(classId);
23378
+ while (cur && cur.extends) {
23379
+ const target = cur.extends;
23380
+ if (seen.has(target)) {
23381
+ return null;
23382
+ }
23383
+ seen.add(target);
23384
+ const inst = instances.get(target);
23385
+ if (inst) {
23386
+ return inst;
23387
+ }
23388
+ cur = classes.get(target);
23389
+ }
23390
+ return null;
23391
+ }
23392
+ function delegationSuccessors(standard) {
23393
+ const out = /* @__PURE__ */ new Map();
23394
+ for (const inst of standard.instances ?? []) {
23395
+ const upward = inst.model || inst.group || inst.family;
23396
+ if (upward) {
23397
+ out.set(inst.id, upward);
23398
+ continue;
23399
+ }
23400
+ if (!inst.of) {
23401
+ continue;
23402
+ }
23403
+ const direct = (standard.instances ?? []).find((i) => i.id === inst.of);
23404
+ if (direct) {
23405
+ out.set(inst.id, direct.id);
23406
+ continue;
23407
+ }
23408
+ const prototype = classPrototype(standard, inst.of);
23409
+ if (prototype) {
23410
+ out.set(inst.id, prototype.id);
23411
+ }
23412
+ }
23413
+ return out;
23414
+ }
23415
+
23195
23416
  // src/check-allowlist.ts
23196
23417
  import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
23197
23418
  import { join as join2 } from "path";
@@ -24092,7 +24313,9 @@ function checkPackage(dir, options = {}) {
24092
24313
  });
24093
24314
  standard = loaded.standard;
24094
24315
  for (const i of loaded.issues) {
24095
- if (i.code === "provides-unconsumed") {
24316
+ if (i.code === "construct-deprecated") {
24317
+ warn("C154", i.message);
24318
+ } else if (i.code === "provides-unconsumed") {
24096
24319
  warn("C30", i.message);
24097
24320
  } else if (i.code === "extends-deprecated") {
24098
24321
  warn("C27", i.message);
@@ -24122,6 +24345,10 @@ function checkPackage(dir, options = {}) {
24122
24345
  issues.push(...checkDimensions(standard));
24123
24346
  issues.push(...checkReferences(standard));
24124
24347
  issues.push(...checkVerdictChains(standard));
24348
+ issues.push(...checkClosedDerivations(standard));
24349
+ issues.push(...checkAttestations(standard));
24350
+ issues.push(...checkTypedPayloads(standard));
24351
+ issues.push(...checkArtifactContracts(standard));
24125
24352
  const reqIds = new Set(
24126
24353
  (standard.requirements ?? []).map((r) => r.id)
24127
24354
  );
@@ -24131,12 +24358,11 @@ function checkPackage(dir, options = {}) {
24131
24358
  const attrIds = new Set(
24132
24359
  (standard.attributeDefinitions ?? []).map((a) => a.id)
24133
24360
  );
24361
+ const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
24134
24362
  const behaviorIds = new Set(
24135
24363
  (standard.behaviors ?? []).map((b) => b.id)
24136
24364
  );
24137
- const subjectIds = new Set(
24138
- (standard.subjects ?? []).map((s) => s.id)
24139
- );
24365
+ const subjectIds = new Set((standard.subjects ?? []).map((s) => s.id));
24140
24366
  const symbolIds = new Set((standard.symbols ?? []).map((s) => s.id));
24141
24367
  const dimIds = /* @__PURE__ */ new Map();
24142
24368
  const dimCardinality = /* @__PURE__ */ new Map();
@@ -24694,7 +24920,7 @@ function checkPackage(dir, options = {}) {
24694
24920
  );
24695
24921
  for (const d of standard.artifactDefinitions ?? []) {
24696
24922
  const c = d.contentContract;
24697
- if (c.fields.length === 0) {
24923
+ if (!d.contractFrom && c.fields.length === 0) {
24698
24924
  err(
24699
24925
  "C45",
24700
24926
  `artifact definition ${d.id}: content contract declares no fields \u2014 a definition must contract SOME content (artifact-def-contract)`
@@ -25280,15 +25506,6 @@ function checkPackage(dir, options = {}) {
25280
25506
  }
25281
25507
  }
25282
25508
  }
25283
- for (const m of standard.processModels ?? []) {
25284
- const where = `process_model ${m.id}`;
25285
- for (const s of m.sequence ?? []) {
25286
- resolveProcessRef(where, "sequence", s);
25287
- }
25288
- for (const r of m.registers ?? []) {
25289
- resolveOrganAp(`${where} register ${r.id}`, "maintainer", r.maintainer);
25290
- }
25291
- }
25292
25509
  }
25293
25510
  {
25294
25511
  const OCL_CHECK = /^ocl\{[\s\S]*\}$/;
@@ -25601,7 +25818,6 @@ function checkPackage(dir, options = {}) {
25601
25818
  }
25602
25819
  }
25603
25820
  {
25604
- const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
25605
25821
  const KNOWN_OUTCOMES = new Set(MONITOR_OUTCOMES);
25606
25822
  const KNOWN_ACTIONS = new Set(MONITOR_ESCALATION_ACTIONS);
25607
25823
  const KNOWN_STREAMS = new Set(MONITOR_STREAMS);
@@ -25953,6 +26169,7 @@ function checkPackage(dir, options = {}) {
25953
26169
  };
25954
26170
  const instrumentIds = new Set((standard.instruments ?? []).map((i) => i.id));
25955
26171
  const instanceIds = new Set((standard.instances ?? []).map((i) => i.id));
26172
+ const dataclassIds = new Set((standard.dataclasses ?? []).map((c) => c.id));
25956
26173
  const attrScopes = new Map(
25957
26174
  (standard.attributeDefinitions ?? []).map((a) => [a.id, a.scope])
25958
26175
  );
@@ -26057,10 +26274,43 @@ function checkPackage(dir, options = {}) {
26057
26274
  );
26058
26275
  }
26059
26276
  }
26060
- if (!subjectIds.has(inst.of) && !instrumentIds.has(inst.of)) {
26277
+ if (!subjectIds.has(inst.of) && !instrumentIds.has(inst.of) && !instanceIds.has(inst.of) && !dataclassIds.has(inst.of)) {
26061
26278
  err(
26062
26279
  "C20",
26063
- `instance ${inst.id}: of "${inst.of}" is not a declared subject or instrument (instance-of-resolves)`
26280
+ `instance ${inst.id}: of "${inst.of}" is not a declared subject, instrument, class, or instance (instance-of-resolves)`
26281
+ );
26282
+ }
26283
+ if (instanceIds.has(inst.of)) {
26284
+ const links = ["model", "group", "family"].filter(
26285
+ (k) => inst[k]
26286
+ );
26287
+ if (links.length > 0) {
26288
+ err(
26289
+ "C155",
26290
+ `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)`
26291
+ );
26292
+ }
26293
+ }
26294
+ }
26295
+ const delegation = delegationSuccessors(standard);
26296
+ const ofAdj = /* @__PURE__ */ new Map();
26297
+ for (const [from, to] of delegation) {
26298
+ if (instanceIds.has(to)) {
26299
+ ofAdj.set(from, [to]);
26300
+ }
26301
+ }
26302
+ const ofCycle = findCycle(ofAdj);
26303
+ if (ofCycle) {
26304
+ err(
26305
+ "C155",
26306
+ `the power-type of-chain is cyclic: ${ofCycle.join(" \u2192 ")} (power-type-chain)`
26307
+ );
26308
+ }
26309
+ for (const c of standard.dataclasses ?? []) {
26310
+ if (c.extends && !dataclassIds.has(c.extends) && !instanceIds.has(c.extends)) {
26311
+ warn(
26312
+ "C156",
26313
+ `class ${c.id}: extends "${c.extends}" is not a declared class or instance (class-extends-resolves)`
26064
26314
  );
26065
26315
  }
26066
26316
  }
@@ -26803,6 +27053,97 @@ function checkPackage(dir, options = {}) {
26803
27053
  }
26804
27054
  }
26805
27055
  }
27056
+ {
27057
+ for (const ct of standard.conformanceTests ?? []) {
27058
+ const prep = ct.preparation;
27059
+ if (prep) {
27060
+ const orders = /* @__PURE__ */ new Set();
27061
+ for (const step of prep.entries) {
27062
+ const at = step.order !== null ? `preparation step ${step.order}` : "a preparation step";
27063
+ if (step.order === null || !Number.isInteger(step.order) || step.order < 1) {
27064
+ err(
27065
+ "C147",
27066
+ `conformance_test ${ct.id}: ${at} declares no positive-integer order (got ${step.order === null ? "none" : step.order}) \u2014 the step order is a positive integer (test-program-shape)`
27067
+ );
27068
+ } else if (orders.has(step.order)) {
27069
+ err(
27070
+ "C147",
27071
+ `conformance_test ${ct.id}: preparation step order ${step.order} is declared twice \u2014 the order is unique within the program (test-program-shape)`
27072
+ );
27073
+ } else {
27074
+ orders.add(step.order);
27075
+ }
27076
+ if (step.action === "" && step.drive === "") {
27077
+ err(
27078
+ "C147",
27079
+ `conformance_test ${ct.id}: ${at} declares neither action nor drive \u2014 a preparation step carries a prose action AND/OR a drive reference (test-program-shape)`
27080
+ );
27081
+ }
27082
+ if (step.verify && (step.verify.read === "" || step.verify.tolerance === "")) {
27083
+ err(
27084
+ "C147",
27085
+ `conformance_test ${ct.id}: ${at} declares a verify block without ${step.verify.read === "" ? "read" : "tolerance"} \u2014 the verification names what to read AND the tolerance reference (test-program-shape)`
27086
+ );
27087
+ }
27088
+ if (step.hold !== "" && parseFreshnessWindow(step.hold) === null) {
27089
+ err(
27090
+ "C148",
27091
+ `conformance_test ${ct.id}: ${at} hold "${step.hold}" is not a parseable duration (shorthand 500ms/5s/1min/1h/1d or ISO 8601 with fixed-length components, e.g. PT30M) (test-program-duration)`
27092
+ );
27093
+ }
27094
+ }
27095
+ }
27096
+ const stim = ct.stimulus;
27097
+ if (stim) {
27098
+ const orders = /* @__PURE__ */ new Set();
27099
+ for (const point of stim.entries) {
27100
+ const at = point.order !== null ? `stimulus point ${point.order}` : "a stimulus point";
27101
+ if (point.order === null || !Number.isInteger(point.order) || point.order < 1) {
27102
+ err(
27103
+ "C147",
27104
+ `conformance_test ${ct.id}: ${at} declares no positive-integer order (got ${point.order === null ? "none" : point.order}) \u2014 the point order is a positive integer (test-program-shape)`
27105
+ );
27106
+ } else if (orders.has(point.order)) {
27107
+ err(
27108
+ "C147",
27109
+ `conformance_test ${ct.id}: stimulus point order ${point.order} is declared twice \u2014 the order is unique within the program (test-program-shape)`
27110
+ );
27111
+ } else {
27112
+ orders.add(point.order);
27113
+ }
27114
+ if (point.drive === "") {
27115
+ err(
27116
+ "C147",
27117
+ `conformance_test ${ct.id}: ${at} declares no drive \u2014 a stimulus point names the drive operation (test-program-shape)`
27118
+ );
27119
+ }
27120
+ if (point.acceptance === "") {
27121
+ err(
27122
+ "C147",
27123
+ `conformance_test ${ct.id}: ${at} declares no acceptance \u2014 a stimulus point names the MPE/requirement node it is judged against (test-program-shape)`
27124
+ );
27125
+ }
27126
+ if (point.hold !== "" && parseFreshnessWindow(point.hold) === null) {
27127
+ err(
27128
+ "C148",
27129
+ `conformance_test ${ct.id}: ${at} hold "${point.hold}" is not a parseable duration (shorthand 500ms/5s/1min/1h/1d or ISO 8601 with fixed-length components, e.g. PT30M) (test-program-duration)`
27130
+ );
27131
+ }
27132
+ if (point.freshWithin === "") {
27133
+ err(
27134
+ "C148",
27135
+ `conformance_test ${ct.id}: ${at} declares no fresh_within \u2014 a measurement point's read carries its freshness bound (\xA714.12: no stale semantics) (test-program-duration)`
27136
+ );
27137
+ } else if (parseFreshnessWindow(point.freshWithin) === null) {
27138
+ err(
27139
+ "C148",
27140
+ `conformance_test ${ct.id}: ${at} fresh_within "${point.freshWithin}" is not a parseable freshness window (shorthand 500ms/5s/1min/1h/1d or ISO 8601 with fixed-length components, e.g. PT5S) (test-program-duration)`
27141
+ );
27142
+ }
27143
+ }
27144
+ }
27145
+ }
27146
+ }
26806
27147
  {
26807
27148
  for (const fu of standard.formulasUsed ?? []) {
26808
27149
  if (stripWrapping(fu.id) === "") {
@@ -27219,67 +27560,6 @@ function checkPackage(dir, options = {}) {
27219
27560
  }
27220
27561
  }
27221
27562
  }
27222
- {
27223
- const participantSeeds = /* @__PURE__ */ new Set();
27224
- for (const w of standard.demoWorlds ?? []) {
27225
- for (const section of w.participants ?? []) {
27226
- for (const e of section.entries ?? []) {
27227
- participantSeeds.add(e.id);
27228
- }
27229
- }
27230
- }
27231
- const entityStores = new Set(
27232
- (standard.dataclasses ?? []).map((c) => c.store).filter((s) => !!s)
27233
- );
27234
- for (const s of standard.storylines ?? []) {
27235
- const where = `storyline ${s.id}`;
27236
- if (s.idPrefix && !/^[a-z0-9-]+$/.test(s.idPrefix)) {
27237
- err(
27238
- "C129",
27239
- `${where}: id_prefix "${s.idPrefix}" does not match ^[a-z0-9-]+$ \u2014 the id-minting prefix is a lowercase slug (storyline-shape)`
27240
- );
27241
- }
27242
- if (participantSeeds.size > 0) {
27243
- for (const [slot, ref] of [
27244
- ["laboratory", s.party.laboratory],
27245
- ["authority", s.party.authority]
27246
- ]) {
27247
- if (ref && !participantSeeds.has(ref)) {
27248
- err(
27249
- "C129",
27250
- `${where}: party ${slot} "${ref}" is not a declared participant seed (storyline-shape)`
27251
- );
27252
- }
27253
- }
27254
- }
27255
- const siblingStores = /* @__PURE__ */ new Map();
27256
- for (const r of s.records ?? []) {
27257
- if (entityStores.size > 0 && !entityStores.has(r.store)) {
27258
- err(
27259
- "C129",
27260
- `${where}: record store "${r.store}" is not a declared entity-class store (storyline-shape)`
27261
- );
27262
- }
27263
- let ids = siblingStores.get(r.store);
27264
- if (!ids) {
27265
- ids = /* @__PURE__ */ new Set();
27266
- siblingStores.set(r.store, ids);
27267
- }
27268
- ids.add(r.id);
27269
- }
27270
- for (const r of s.records ?? []) {
27271
- for (const [key, value] of Object.entries(r.fields)) {
27272
- const targets = siblingStores.get(key);
27273
- if (targets !== void 0 && !Array.isArray(value) && !targets.has(String(value))) {
27274
- err(
27275
- "C129",
27276
- `${where}: record ${r.store} ${r.id}: ${key} "${String(value)}" is not a sibling ${key} record of this storyline (storyline-shape)`
27277
- );
27278
- }
27279
- }
27280
- }
27281
- }
27282
- }
27283
27563
  {
27284
27564
  const slotIds = new Set((standard.identitySlots ?? []).map((s) => s.id));
27285
27565
  const aspectIds = new Set((standard.aspects ?? []).map((a) => a.id));
@@ -27650,40 +27930,11 @@ function checkPackage(dir, options = {}) {
27650
27930
  }
27651
27931
  }
27652
27932
  {
27653
- const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
27654
- const dataclassIds = /* @__PURE__ */ new Set();
27933
+ const dataclassIds2 = /* @__PURE__ */ new Set();
27655
27934
  for (const c of standard.dataclasses ?? []) {
27656
- dataclassIds.add(c.id);
27935
+ dataclassIds2.add(c.id);
27657
27936
  if (c.id.includes("#")) {
27658
- dataclassIds.add(c.id.slice(0, c.id.indexOf("#")));
27659
- }
27660
- }
27661
- const CLEAN_TOKEN = /^[A-Za-z_][A-Za-z0-9_]*$/;
27662
- for (const w of standard.workflowConfigs ?? []) {
27663
- for (const s of w.steps ?? []) {
27664
- const where = `workflow_config ${w.id}: step ${s.id}`;
27665
- if (s.actor && roleIds.size > 0 && !roleIds.has(s.actor)) {
27666
- err(
27667
- "C137",
27668
- `${where}: actor "${s.actor}" is not a declared role (workflow-config-references)`
27669
- );
27670
- }
27671
- for (const [facet, list] of [
27672
- ["inputs", s.inputs],
27673
- ["outputs", s.outputs]
27674
- ]) {
27675
- for (const entry of list) {
27676
- if (!CLEAN_TOKEN.test(entry)) {
27677
- continue;
27678
- }
27679
- if (dataclassIds.size > 0 && !dataclassIds.has(entry)) {
27680
- err(
27681
- "C137",
27682
- `${where}: ${facet} entry "${entry}" is not a declared data class (workflow-config-references)`
27683
- );
27684
- }
27685
- }
27686
- }
27937
+ dataclassIds2.add(c.id.slice(0, c.id.indexOf("#")));
27687
27938
  }
27688
27939
  }
27689
27940
  }
@@ -27920,35 +28171,6 @@ function checkPackage(dir, options = {}) {
27920
28171
  }
27921
28172
  }
27922
28173
  }
27923
- const stageApprovalIds = new Set((standard.approvals ?? []).map((a) => a.id));
27924
- const stageGatewayIds = new Set((standard.gateways ?? []).map((g) => g.id));
27925
- for (const s of standard.workflowStages ?? []) {
27926
- const where = `workflow_stage ${s.id}`;
27927
- for (const el of s.elements ?? []) {
27928
- if (gwProcessIds.size > 0 && !gwProcessIds.has(el)) {
27929
- err(
27930
- "C142",
27931
- `${where}: element "${el}" is not a declared process (gateway-edges-resolve)`
27932
- );
27933
- }
27934
- }
27935
- for (const a of s.approvals ?? []) {
27936
- if (stageApprovalIds.size > 0 && !stageApprovalIds.has(a)) {
27937
- err(
27938
- "C142",
27939
- `${where}: approval "${a}" is not a declared approval (gateway-edges-resolve)`
27940
- );
27941
- }
27942
- }
27943
- for (const g of s.gateways ?? []) {
27944
- if (stageGatewayIds.size > 0 && !stageGatewayIds.has(g)) {
27945
- err(
27946
- "C142",
27947
- `${where}: gateway "${g}" is not a declared gateway (gateway-edges-resolve)`
27948
- );
27949
- }
27950
- }
27951
- }
27952
28174
  }
27953
28175
  {
27954
28176
  const approvalRoleIds = new Set((standard.roles ?? []).map((r) => r.id));
@@ -29092,38 +29314,400 @@ function textAddressKey(item, segment) {
29092
29314
  }
29093
29315
  return false;
29094
29316
  }
29095
- function checkSpellingCodes(standard) {
29317
+ function checkArtifactContracts(standard) {
29096
29318
  const issues = [];
29097
29319
  const err = (check, message) => issues.push({ check, severity: "error", message });
29098
- const warn = (check, message) => issues.push({ check, severity: "warning", message });
29099
- const m = standard.packageManifest;
29100
- if (m?.defaultSpelling) {
29101
- const parsed = parseSpellingCode(m.defaultSpelling);
29102
- if (typeof parsed === "string") {
29320
+ const setIds = /* @__PURE__ */ new Set();
29321
+ for (const ps of standard.promiseSets ?? []) {
29322
+ setIds.add(ps.id);
29323
+ setIds.add(`${ps.id}.promise_set`);
29324
+ }
29325
+ for (const s of standard.subjects ?? []) {
29326
+ if ((s.is?.promises ?? []).length > 0) {
29327
+ setIds.add(s.id);
29328
+ setIds.add(`${s.id}.promise_set`);
29329
+ }
29330
+ }
29331
+ for (const d of standard.artifactDefinitions ?? []) {
29332
+ if (!d.contractFrom) {
29333
+ continue;
29334
+ }
29335
+ if (!setIds.has(d.contractFrom)) {
29103
29336
  err(
29104
- "C89",
29105
- `package "${m.id}": default_spelling "${m.defaultSpelling}" \u2014 ${parsed} (spelling-code-wellformed)`
29337
+ "C153",
29338
+ `artifact_definition ${d.id}: contract_from "${d.contractFrom}" does not resolve to a declared promise set (artifact-contract-derivation)`
29106
29339
  );
29107
29340
  }
29108
- if ((m.spellings ?? []).length > 0 && !m.spellings.includes(m.defaultSpelling)) {
29341
+ const c = d.contentContract;
29342
+ if (c.fields.length > 0 || c.structure || c.media.length > 0) {
29109
29343
  err(
29110
- "C89",
29111
- `package "${m.id}": default_spelling "${m.defaultSpelling}" is not in the declared spellings set (spelling-code-wellformed)`
29344
+ "C153",
29345
+ `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)`
29112
29346
  );
29113
29347
  }
29114
29348
  }
29115
- for (const s of m?.spellings ?? []) {
29116
- const parsed = parseSpellingCode(s);
29117
- if (typeof parsed === "string") {
29349
+ return issues;
29350
+ }
29351
+ function checkTypedPayloads(standard) {
29352
+ const issues = [];
29353
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29354
+ const classFields = /* @__PURE__ */ new Map();
29355
+ for (const c of standard.dataclasses ?? []) {
29356
+ classFields.set(c.id, new Set(c.attributes.map((a) => a.id)));
29357
+ }
29358
+ const instanceShape = (id) => {
29359
+ const inst = (standard.instances ?? []).find((i) => i.id === id);
29360
+ if (!inst) {
29361
+ return void 0;
29362
+ }
29363
+ let cur = inst;
29364
+ const seen = /* @__PURE__ */ new Set([cur.id]);
29365
+ while (cur.of) {
29366
+ const next = (standard.instances ?? []).find((i) => i.id === cur.of);
29367
+ if (!next || seen.has(next.id)) {
29368
+ break;
29369
+ }
29370
+ seen.add(next.id);
29371
+ cur = next;
29372
+ }
29373
+ return cur.of !== "" ? classFields.get(cur.of) : void 0;
29374
+ };
29375
+ const typedFields = (id) => classFields.get(id) ?? instanceShape(id);
29376
+ const checkDim = (owner, d) => {
29377
+ if (!d.payloadClass) {
29378
+ return;
29379
+ }
29380
+ const fields = typedFields(d.payloadClass);
29381
+ if (!fields) {
29118
29382
  err(
29119
- "C89",
29120
- `package "${m.id}": declared spelling "${s}" \u2014 ${parsed} (spelling-code-wellformed)`
29383
+ "C152",
29384
+ `${owner} dimension ${d.id}: payload_class "${d.payloadClass}" is not a declared class (payload-typed-by-class)`
29121
29385
  );
29386
+ return;
29387
+ }
29388
+ for (const v of d.values) {
29389
+ const keys = Object.keys(v.payload ?? {});
29390
+ if (keys.length === 0) {
29391
+ err(
29392
+ "C152",
29393
+ `${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)`
29394
+ );
29395
+ continue;
29396
+ }
29397
+ for (const key of keys) {
29398
+ if (!fields.has(key)) {
29399
+ err(
29400
+ "C152",
29401
+ `${owner} dimension ${d.id}: value ${v.id} payload field "${key}" is not a field of class "${d.payloadClass}" (payload-typed-by-class)`
29402
+ );
29403
+ }
29404
+ }
29405
+ }
29406
+ };
29407
+ for (const inst of standard.instruments ?? []) {
29408
+ for (const d of inst.dimensions ?? []) {
29409
+ checkDim(`instrument ${inst.id}`, d);
29122
29410
  }
29123
29411
  }
29124
- const texts = standard.texts ?? [];
29125
- if (texts.length === 0) {
29126
- return issues;
29412
+ for (const d of standard.dimensions ?? []) {
29413
+ checkDim("top-level", d);
29414
+ }
29415
+ for (const a of standard.attributeDefinitions ?? []) {
29416
+ if (a.classRef && !typedFields(a.classRef)) {
29417
+ err(
29418
+ "C152",
29419
+ `attribute_definition ${a.id}: class "${a.classRef}" is not a declared class (payload-typed-by-class)`
29420
+ );
29421
+ }
29422
+ }
29423
+ return issues;
29424
+ }
29425
+ function checkAttestations(standard) {
29426
+ const issues = [];
29427
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29428
+ const roleIds = new Set((standard.roles ?? []).map((r) => r.id));
29429
+ const instanceIds = new Set((standard.instances ?? []).map((i) => i.id));
29430
+ const verdictIds = new Set((standard.verdicts ?? []).map((v) => v.id));
29431
+ const setViews = /* @__PURE__ */ new Map();
29432
+ for (const ps of standard.promiseSets ?? []) {
29433
+ setViews.set(ps.id, { promises: ps.promises });
29434
+ setViews.set(`${ps.id}.promise_set`, { promises: ps.promises });
29435
+ }
29436
+ for (const s of standard.subjects ?? []) {
29437
+ if ((s.is?.promises ?? []).length > 0) {
29438
+ setViews.set(s.id, { promises: s.is.promises });
29439
+ }
29440
+ }
29441
+ const resolveSet = (ref) => setViews.get(ref) ?? setViews.get(ref.split(".").slice(1).join(".")) ?? null;
29442
+ const mandatoryOf = (view) => {
29443
+ const out = /* @__PURE__ */ new Set();
29444
+ for (const p of view.promises) {
29445
+ if (p.certificate?.obligation === "mandatory") {
29446
+ out.add(p.id);
29447
+ }
29448
+ }
29449
+ return out;
29450
+ };
29451
+ for (const a of standard.attestations ?? []) {
29452
+ if (!a.subject) {
29453
+ err(
29454
+ "C150",
29455
+ `attestation ${a.id}: no subject facet (attestation-references-resolve)`
29456
+ );
29457
+ } else if (!instanceIds.has(a.subject)) {
29458
+ err(
29459
+ "C150",
29460
+ `attestation ${a.id}: subject "${a.subject}" is not a declared instance (attestation-references-resolve)`
29461
+ );
29462
+ }
29463
+ if (!a.promises) {
29464
+ err(
29465
+ "C150",
29466
+ `attestation ${a.id}: no promises facet (attestation-references-resolve)`
29467
+ );
29468
+ }
29469
+ const set = a.promises ? resolveSet(a.promises) : null;
29470
+ if (a.promises && !set) {
29471
+ err(
29472
+ "C150",
29473
+ `attestation ${a.id}: promises "${a.promises}" does not resolve to a declared promise set (attestation-references-resolve)`
29474
+ );
29475
+ }
29476
+ for (const b of a.basis) {
29477
+ if (!b.kind || !b.id) {
29478
+ err(
29479
+ "C150",
29480
+ `attestation ${a.id}: a basis entry needs an evidence kind and an id (attestation-references-resolve)`
29481
+ );
29482
+ }
29483
+ }
29484
+ if (a.authority.role && roleIds.size > 0 && !roleIds.has(a.authority.role)) {
29485
+ err(
29486
+ "C150",
29487
+ `attestation ${a.id}: authority role "${a.authority.role}" is not a declared role (attestation-references-resolve)`
29488
+ );
29489
+ }
29490
+ const carried = new Set(a.claims.map((c) => c.promise));
29491
+ for (const c of a.claims) {
29492
+ if (set && !set.promises.some((p) => p.id === c.promise)) {
29493
+ err(
29494
+ "C150",
29495
+ `attestation ${a.id}: claim "${c.promise}" is not a promise of "${a.promises}" (attestation-references-resolve)`
29496
+ );
29497
+ }
29498
+ if (!c.declared) {
29499
+ err(
29500
+ "C151",
29501
+ `attestation ${a.id}: claim "${c.promise}" carries no declaration reference (attestation-claim-lineage)`
29502
+ );
29503
+ }
29504
+ if (!c.validatedBy) {
29505
+ err(
29506
+ "C151",
29507
+ `attestation ${a.id}: claim "${c.promise}" carries no verdict reference (attestation-claim-lineage)`
29508
+ );
29509
+ } else if (verdictIds.size > 0 && !c.validatedBy.startsWith("/") && !verdictIds.has(c.validatedBy)) {
29510
+ err(
29511
+ "C150",
29512
+ `attestation ${a.id}: claim "${c.promise}" names verdict "${c.validatedBy}", which is not declared (attestation-references-resolve)`
29513
+ );
29514
+ }
29515
+ }
29516
+ if (set) {
29517
+ for (const pid of mandatoryOf(set)) {
29518
+ if (!carried.has(pid)) {
29519
+ err(
29520
+ "C151",
29521
+ `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)`
29522
+ );
29523
+ }
29524
+ }
29525
+ }
29526
+ }
29527
+ return issues;
29528
+ }
29529
+ var CLOSED_DERIVATION_STOP = /* @__PURE__ */ new Set([
29530
+ "self",
29531
+ "p",
29532
+ "ocl",
29533
+ "true",
29534
+ "false",
29535
+ "null",
29536
+ "undefined",
29537
+ // OCL navigation and collection operators
29538
+ "and",
29539
+ "or",
29540
+ "not",
29541
+ "implies",
29542
+ "if",
29543
+ "then",
29544
+ "else",
29545
+ "endif",
29546
+ "xor",
29547
+ "let",
29548
+ "in",
29549
+ "exists",
29550
+ "forAll",
29551
+ "select",
29552
+ "reject",
29553
+ "collect",
29554
+ "isEmpty",
29555
+ "size",
29556
+ "sum",
29557
+ "min",
29558
+ "max",
29559
+ "abs",
29560
+ "round",
29561
+ "floor",
29562
+ "sqrt",
29563
+ "includes",
29564
+ "excludes",
29565
+ "includesAll",
29566
+ "excludesAll",
29567
+ "count",
29568
+ "first",
29569
+ "last",
29570
+ "asSet",
29571
+ "asOrderedSet",
29572
+ "asSequence",
29573
+ "asBag",
29574
+ "sortedBy",
29575
+ "iterate",
29576
+ "oclIsUndefined",
29577
+ "oclIsKindOf",
29578
+ "oclIsTypeOf",
29579
+ "allInstances",
29580
+ // table-lookup engine vocabulary (the lookup facet names these)
29581
+ "lookup",
29582
+ "profile",
29583
+ // OCL collection statistics and arithmetic
29584
+ "average",
29585
+ "mean",
29586
+ "size",
29587
+ "div",
29588
+ "mod",
29589
+ "collect"
29590
+ ]);
29591
+ var CLOSED_DERIVATION_PATH_RE = /\b[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)+/g;
29592
+ var CLOSED_DERIVATION_IDENT_RE = /[A-Za-z_][A-Za-z0-9_]*/g;
29593
+ function checkClosedDerivations(standard) {
29594
+ const issues = [];
29595
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29596
+ const declared = /* @__PURE__ */ new Set();
29597
+ for (const c of standard.calculations ?? []) {
29598
+ declared.add(c.id);
29599
+ declared.add(c.name);
29600
+ }
29601
+ for (const tb of standard.tables ?? []) {
29602
+ declared.add(tb.id);
29603
+ }
29604
+ for (const s of standard.symbols ?? []) {
29605
+ declared.add(s.id);
29606
+ }
29607
+ for (const v of standard.variables ?? []) {
29608
+ declared.add(v.id);
29609
+ }
29610
+ for (const a of standard.attributeDefinitions ?? []) {
29611
+ declared.add(a.id);
29612
+ }
29613
+ for (const e of standard.enums ?? []) {
29614
+ declared.add(e.id);
29615
+ }
29616
+ for (const d of standard.dataclasses ?? []) {
29617
+ declared.add(d.id);
29618
+ }
29619
+ for (const inst of standard.instruments ?? []) {
29620
+ for (const d of inst.dimensions ?? []) {
29621
+ declared.add(d.id);
29622
+ }
29623
+ }
29624
+ for (const d of standard.dimensions ?? []) {
29625
+ declared.add(d.id);
29626
+ }
29627
+ for (const c of standard.calculations ?? []) {
29628
+ if (c.output?.name) {
29629
+ declared.add(c.output.name);
29630
+ }
29631
+ for (const i of c.inputs ?? []) {
29632
+ declared.add(i.name);
29633
+ }
29634
+ }
29635
+ const localsOf = (extra) => /* @__PURE__ */ new Set([...declared, ...extra]);
29636
+ const checkExpression = (expr, locals, where) => {
29637
+ if (!expr) {
29638
+ return;
29639
+ }
29640
+ const noLiterals = expr.replace(/'[^']*'/g, " ");
29641
+ const noLambdas = noLiterals.replace(
29642
+ /\b([A-Za-z_][A-Za-z0-9_]*)\s*\|/g,
29643
+ " "
29644
+ );
29645
+ const stripped = noLambdas.replace(CLOSED_DERIVATION_PATH_RE, " ");
29646
+ const seen = /* @__PURE__ */ new Set();
29647
+ for (const raw of stripped.match(CLOSED_DERIVATION_IDENT_RE) ?? []) {
29648
+ if (CLOSED_DERIVATION_STOP.has(raw) || locals.has(raw) || seen.has(raw) || /^[a-z][0-9]?$/.test(raw)) {
29649
+ continue;
29650
+ }
29651
+ seen.add(raw);
29652
+ err(
29653
+ "C149",
29654
+ `${where}: expression references "${raw}", which no declared calculation, table, symbol, measurement, or attribute defines (closed-derivation-references-declared)`
29655
+ );
29656
+ }
29657
+ };
29658
+ for (const a of standard.attributeDefinitions ?? []) {
29659
+ checkExpression(a.derived, localsOf([]), `attribute_definition ${a.id}`);
29660
+ }
29661
+ for (const c of standard.calculations ?? []) {
29662
+ const inputs = (c.inputs ?? []).map((i) => i.name);
29663
+ checkExpression(c.expression, localsOf(inputs), `calculation ${c.id}`);
29664
+ }
29665
+ for (const s of standard.symbols ?? []) {
29666
+ if (s.formula?.expression) {
29667
+ checkExpression(
29668
+ s.formula.expression,
29669
+ localsOf(s.formula.inputs ?? []),
29670
+ `symbol ${s.id}`
29671
+ );
29672
+ }
29673
+ }
29674
+ for (const v of standard.verdicts ?? []) {
29675
+ checkExpression(v.derive, localsOf(v.inputs ?? []), `verdict ${v.id}`);
29676
+ }
29677
+ return issues;
29678
+ }
29679
+ function checkSpellingCodes(standard) {
29680
+ const issues = [];
29681
+ const err = (check, message) => issues.push({ check, severity: "error", message });
29682
+ const warn = (check, message) => issues.push({ check, severity: "warning", message });
29683
+ const m = standard.packageManifest;
29684
+ if (m?.defaultSpelling) {
29685
+ const parsed = parseSpellingCode(m.defaultSpelling);
29686
+ if (typeof parsed === "string") {
29687
+ err(
29688
+ "C89",
29689
+ `package "${m.id}": default_spelling "${m.defaultSpelling}" \u2014 ${parsed} (spelling-code-wellformed)`
29690
+ );
29691
+ }
29692
+ if ((m.spellings ?? []).length > 0 && !m.spellings.includes(m.defaultSpelling)) {
29693
+ err(
29694
+ "C89",
29695
+ `package "${m.id}": default_spelling "${m.defaultSpelling}" is not in the declared spellings set (spelling-code-wellformed)`
29696
+ );
29697
+ }
29698
+ }
29699
+ for (const s of m?.spellings ?? []) {
29700
+ const parsed = parseSpellingCode(s);
29701
+ if (typeof parsed === "string") {
29702
+ err(
29703
+ "C89",
29704
+ `package "${m.id}": declared spelling "${s}" \u2014 ${parsed} (spelling-code-wellformed)`
29705
+ );
29706
+ }
29707
+ }
29708
+ const texts = standard.texts ?? [];
29709
+ if (texts.length === 0) {
29710
+ return issues;
29127
29711
  }
29128
29712
  const elements = /* @__PURE__ */ new Map();
29129
29713
  const ID_COLLECTIONS = [
@@ -31076,9 +31660,229 @@ function renderJsonLd(prefixes, triples) {
31076
31660
 
31077
31661
  // src/export/retrieval.ts
31078
31662
  import { createHash } from "node:crypto";
31079
- import { readdirSync as readdirSync4, readFileSync as readFileSync6, statSync as statSync3 } from "node:fs";
31080
- import { join as join5, relative } from "node:path";
31081
- var RETRIEVAL_PROJECTION = "primmel-retrieval/1";
31663
+ import { readdirSync as readdirSync4, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
31664
+ import { join as join6, relative } from "node:path";
31665
+
31666
+ // src/export/unitsdb.ts
31667
+ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
31668
+ import { join as join5 } from "node:path";
31669
+ function loadUnitsDb(dir) {
31670
+ if (!dir) {
31671
+ return null;
31672
+ }
31673
+ try {
31674
+ const entries = [];
31675
+ const jsonPath = join5(dir, "units.json");
31676
+ if (!existsSync6(jsonPath)) {
31677
+ return null;
31678
+ }
31679
+ const parsed = JSON.parse(readFileSync6(jsonPath, "utf8")).units;
31680
+ if (!Array.isArray(parsed)) {
31681
+ return null;
31682
+ }
31683
+ for (const u of parsed) {
31684
+ const identifiers = u.identifiers ?? [];
31685
+ const unitsml = identifiers.find((i) => i.type === "unitsml")?.id;
31686
+ if (!unitsml) {
31687
+ continue;
31688
+ }
31689
+ const nist = identifiers.find((i) => i.type === "nist")?.id;
31690
+ const scale = u.scale_reference?.id;
31691
+ const symbols = (u.symbols ?? []).map((s) => String(s.ascii ?? s.id)).filter(Boolean);
31692
+ const entry = {
31693
+ unitsml,
31694
+ ...nist ? { nist } : {},
31695
+ ...scale ? { scale } : {},
31696
+ symbols
31697
+ };
31698
+ entries.push(entry);
31699
+ }
31700
+ const bySymbol = /* @__PURE__ */ new Map();
31701
+ const byUnitsml = /* @__PURE__ */ new Map();
31702
+ const spellings = (s) => [
31703
+ s,
31704
+ s.replace(/\*([a-zA-ZμΩ°]+)\^-1\b/g, "/$1")
31705
+ ];
31706
+ for (const e of entries) {
31707
+ byUnitsml.set(e.unitsml, e);
31708
+ for (const s of e.symbols) {
31709
+ for (const sp of spellings(s)) {
31710
+ bySymbol.set(sp, e);
31711
+ }
31712
+ }
31713
+ }
31714
+ return { bySymbol, byUnitsml };
31715
+ } catch {
31716
+ return null;
31717
+ }
31718
+ }
31719
+ function unitsDbEntryFor(db, unit) {
31720
+ return db?.bySymbol.get(unit) ?? null;
31721
+ }
31722
+
31723
+ // src/export/yaml-lite.ts
31724
+ var NUMERIC2 = /^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/;
31725
+ function parseScalar(raw) {
31726
+ const s = raw.trim();
31727
+ if (s === "" || s === "~" || s === "null" || s === "Null" || s === "NULL") {
31728
+ return null;
31729
+ }
31730
+ if (s === "true" || s === "True" || s === "TRUE") {
31731
+ return true;
31732
+ }
31733
+ if (s === "false" || s === "False" || s === "FALSE") {
31734
+ return false;
31735
+ }
31736
+ if (NUMERIC2.test(s)) {
31737
+ return Number(s);
31738
+ }
31739
+ if (s[0] === '"' || s[0] === "'") {
31740
+ return unquote(s, s[0]);
31741
+ }
31742
+ return s;
31743
+ }
31744
+ function unquote(s, q) {
31745
+ if (s.length < 2 || s[s.length - 1] !== q) {
31746
+ return s;
31747
+ }
31748
+ const body = s.slice(1, -1);
31749
+ if (q === "'") {
31750
+ return body.replace(/''/g, "'");
31751
+ }
31752
+ let out = "";
31753
+ for (let i = 0; i < body.length; i++) {
31754
+ const c = body[i];
31755
+ if (c !== "\\" || i === body.length - 1) {
31756
+ out += c;
31757
+ continue;
31758
+ }
31759
+ const e = body[++i];
31760
+ if (e === "n") {
31761
+ out += "\n";
31762
+ } else if (e === "t") {
31763
+ out += " ";
31764
+ } else if (e === "r") {
31765
+ out += "\r";
31766
+ } else if (e === "0") {
31767
+ out += "\0";
31768
+ } else if (e === "\\" || e === '"') {
31769
+ out += e;
31770
+ } else {
31771
+ out += "\\" + e;
31772
+ }
31773
+ }
31774
+ return out;
31775
+ }
31776
+ function splitKey(text) {
31777
+ const colon = text.indexOf(":");
31778
+ if (colon <= 0) {
31779
+ return null;
31780
+ }
31781
+ const key = text.slice(0, colon);
31782
+ if (/[\s"']/.test(key)) {
31783
+ return null;
31784
+ }
31785
+ return [key, text.slice(colon + 1)];
31786
+ }
31787
+ function parseValue(lines, i, indent) {
31788
+ if (i >= lines.length) {
31789
+ return [i, null];
31790
+ }
31791
+ const t = lines[i].text;
31792
+ if (t === "-" || t.startsWith("- ")) {
31793
+ return parseSequence(lines, i, indent);
31794
+ }
31795
+ return parseMapping(lines, i, indent);
31796
+ }
31797
+ function parseSequence(lines, i, indent) {
31798
+ const out = [];
31799
+ while (i < lines.length && lines[i].indent === indent && (lines[i].text === "-" || lines[i].text.startsWith("- "))) {
31800
+ const content = lines[i].text === "-" ? "" : lines[i].text.slice(2).trim();
31801
+ if (content === "") {
31802
+ i++;
31803
+ const next = i < lines.length ? lines[i].indent : -1;
31804
+ if (next > indent) {
31805
+ const [end, value] = parseValue(lines, i, next);
31806
+ out.push(value);
31807
+ i = end;
31808
+ } else {
31809
+ out.push(null);
31810
+ }
31811
+ continue;
31812
+ }
31813
+ const nested = content === "-" || content.startsWith("- ");
31814
+ if (nested || splitKey(content) !== null) {
31815
+ lines[i] = { indent: indent + 2, text: content };
31816
+ const [end, value] = nested ? parseSequence(lines, i, indent + 2) : parseMapping(lines, i, indent + 2);
31817
+ out.push(value);
31818
+ i = end;
31819
+ } else {
31820
+ out.push(parseScalar(content));
31821
+ i++;
31822
+ }
31823
+ }
31824
+ return [i, out];
31825
+ }
31826
+ function parseMapping(lines, i, indent) {
31827
+ const map = {};
31828
+ while (i < lines.length) {
31829
+ const line = lines[i];
31830
+ if (line.indent !== indent || line.text === "-" || line.text.startsWith("- ")) {
31831
+ break;
31832
+ }
31833
+ const kv = splitKey(line.text);
31834
+ if (!kv) {
31835
+ break;
31836
+ }
31837
+ const [key, rest] = kv;
31838
+ i++;
31839
+ if (rest.trim() === "") {
31840
+ const next = i < lines.length ? lines[i].indent : -1;
31841
+ if (next > indent) {
31842
+ const [end, value] = parseValue(lines, i, next);
31843
+ map[key] = value;
31844
+ i = end;
31845
+ } else {
31846
+ map[key] = null;
31847
+ }
31848
+ } else {
31849
+ map[key] = parseScalar(rest);
31850
+ }
31851
+ }
31852
+ return [i, map];
31853
+ }
31854
+ function parseYamlBlock(text) {
31855
+ const scanned = [];
31856
+ for (const raw of text.split("\n")) {
31857
+ if (raw.trim() === "") {
31858
+ continue;
31859
+ }
31860
+ scanned.push({
31861
+ indent: raw.length - raw.trimStart().length,
31862
+ text: raw.trim()
31863
+ });
31864
+ }
31865
+ if (scanned.length === 0 || splitKey(scanned[0].text) === null) {
31866
+ return void 0;
31867
+ }
31868
+ const bases = /* @__PURE__ */ new Set([
31869
+ scanned[0].indent,
31870
+ scanned[1]?.indent ?? scanned[0].indent
31871
+ ]);
31872
+ for (const base of bases) {
31873
+ const lines = scanned.map(
31874
+ (l) => l === scanned[0] && l.indent < base ? { indent: base, text: l.text } : l
31875
+ );
31876
+ const [end, map] = parseMapping(lines, 0, base);
31877
+ if (end === lines.length && Object.keys(map).length > 0) {
31878
+ return map;
31879
+ }
31880
+ }
31881
+ return void 0;
31882
+ }
31883
+
31884
+ // src/export/retrieval.ts
31885
+ var RETRIEVAL_PROJECTION = "primmel-retrieval/2";
31082
31886
  var RETRIEVAL_FACET_VERSION = "retrieval-facet/1";
31083
31887
  function sortDeep(v) {
31084
31888
  if (Array.isArray(v)) {
@@ -31107,7 +31911,7 @@ function* walkPackage(dir) {
31107
31911
  if (entry === ".DS_Store") {
31108
31912
  continue;
31109
31913
  }
31110
- const p = join5(dir, entry);
31914
+ const p = join6(dir, entry);
31111
31915
  if (statSync3(p).isDirectory()) {
31112
31916
  yield* walkPackage(p);
31113
31917
  } else {
@@ -31120,7 +31924,7 @@ function packageSourceHash(dir) {
31120
31924
  for (const file of walkPackage(dir)) {
31121
31925
  h.update(relative(dir, file));
31122
31926
  h.update("\0");
31123
- h.update(createHash("sha256").update(readFileSync6(file)).digest());
31927
+ h.update(createHash("sha256").update(readFileSync7(file)).digest());
31124
31928
  h.update("\n");
31125
31929
  }
31126
31930
  return h.digest("hex");
@@ -31235,11 +32039,94 @@ function passportOf(unit) {
31235
32039
  expression: unit.expression ?? "",
31236
32040
  units: unit.units ?? [],
31237
32041
  applicability: applicabilitySummary(unit.applicability),
31238
- acceptance: unit.acceptance ?? "",
32042
+ acceptance: acceptanceSummary(unit),
31239
32043
  provenance: (unit.clauses ?? []).map((c) => c.urn),
31240
32044
  content_hash: unit.content_hash
31241
32045
  };
31242
32046
  }
32047
+ function acceptanceDecisionOf(a) {
32048
+ if (!a) {
32049
+ return void 0;
32050
+ }
32051
+ const out = {
32052
+ ...present(a.rule) ? { rule: a.rule } : {}
32053
+ };
32054
+ if (a.guardBand) {
32055
+ out.guard_band = { kind: a.guardBand.kind, value: a.guardBand.value };
32056
+ }
32057
+ if (a.uncertainty) {
32058
+ out.uncertainty = { max_ratio_to_mpe: a.uncertainty.maxRatioToMpe };
32059
+ }
32060
+ if (present(a.criterion)) {
32061
+ out.criterion = a.criterion;
32062
+ }
32063
+ if (a.statistics) {
32064
+ out.statistics = {
32065
+ method: a.statistics.method,
32066
+ on_basis_of: a.statistics.onBasisOf,
32067
+ permits: a.statistics.permits
32068
+ };
32069
+ }
32070
+ return Object.keys(out).length > 0 ? out : void 0;
32071
+ }
32072
+ function criteriaItemOf(c) {
32073
+ const item = { name: c.item };
32074
+ if (present(c.requirementId)) {
32075
+ item.target = c.requirementId;
32076
+ }
32077
+ if (present(c.criterion)) {
32078
+ item.criterion = c.criterion;
32079
+ }
32080
+ if (present(c.passIf)) {
32081
+ item.pass_if = c.passIf;
32082
+ }
32083
+ if (c.accepts) {
32084
+ item.accepts = {
32085
+ verdict: c.accepts.verdict,
32086
+ op: c.accepts.op,
32087
+ limit: c.accepts.limit
32088
+ };
32089
+ }
32090
+ if (c.optional) {
32091
+ item.optional = true;
32092
+ }
32093
+ if (present(c.description)) {
32094
+ item.description = c.description;
32095
+ }
32096
+ if (present(c.reference)) {
32097
+ item.reference = c.reference;
32098
+ }
32099
+ return item;
32100
+ }
32101
+ function testAcceptanceCriteriaOf(t) {
32102
+ const out = {
32103
+ ...present(t.acceptanceCriteriaType) ? { type: t.acceptanceCriteriaType } : {},
32104
+ ...present(t.acceptanceCriteriaDescription) ? { description: t.acceptanceCriteriaDescription } : {},
32105
+ ...present(t.acceptancePassIf) ? { pass_if: t.acceptancePassIf } : {},
32106
+ ...presentList(t.acceptanceCriteria) ? { items: t.acceptanceCriteria.map(criteriaItemOf) } : {}
32107
+ };
32108
+ return Object.keys(out).length > 0 ? out : void 0;
32109
+ }
32110
+ function acceptanceSummary(unit) {
32111
+ if (unit.accepts) {
32112
+ return `${unit.accepts.verdict} ${unit.accepts.op} ${unit.accepts.limit}`;
32113
+ }
32114
+ const criteria = unit.acceptance_criteria;
32115
+ if (criteria && typeof criteria === "object") {
32116
+ const passIf = criteria["pass_if"];
32117
+ if (present(passIf)) {
32118
+ return passIf;
32119
+ }
32120
+ const description = criteria["description"];
32121
+ if (present(description)) {
32122
+ return description;
32123
+ }
32124
+ }
32125
+ if (unit.acceptance?.rule) {
32126
+ return unit.acceptance.rule;
32127
+ }
32128
+ return "";
32129
+ }
31243
32130
  var BASE_URN_PARTS = /^urn:oiml:pub:([rdbge]):(\d[\d-]*)(?::(\d{4}))?$/i;
31244
32131
  function retrievalDocParts(baseUrn) {
31245
32132
  const m = BASE_URN_PARTS.exec(baseUrn);
@@ -31398,6 +32285,8 @@ function scopeOf(id) {
31398
32285
  var present = (s) => typeof s === "string" && s.length > 0;
31399
32286
  var presentList = (xs) => xs && xs.length > 0 ? xs : void 0;
31400
32287
  function requirementUnit(r) {
32288
+ const decision = acceptanceDecisionOf(r.limit?.acceptance);
32289
+ const criteria = present(r.acceptanceCriteria) ? parseYamlBlock(r.acceptanceCriteria) ?? r.acceptanceCriteria : void 0;
31401
32290
  return assemble(
31402
32291
  {
31403
32292
  id: r.id,
@@ -31415,9 +32304,14 @@ function requirementUnit(r) {
31415
32304
  ...presentList(r.applicability) ? { applicability: r.applicability } : {},
31416
32305
  ...presentList(r.bindsTo) ? { binds_to: r.bindsTo } : {},
31417
32306
  ...r.limit?.accepts ? {
31418
- acceptance: `${r.limit.accepts.verdict} ${r.limit.accepts.op} ${r.limit.accepts.limit}`
32307
+ accepts: {
32308
+ verdict: r.limit.accepts.verdict,
32309
+ op: r.limit.accepts.op,
32310
+ limit: r.limit.accepts.limit
32311
+ }
31419
32312
  } : {},
31420
- ...present(r.acceptanceCriteria) ? { acceptance_criteria: r.acceptanceCriteria } : {},
32313
+ ...decision ? { acceptance: decision } : {},
32314
+ ...criteria !== void 0 ? { acceptance_criteria: criteria } : {},
31421
32315
  ...present(r.verificationMethod) ? {
31422
32316
  verification: {
31423
32317
  method: r.verificationMethod,
@@ -31433,16 +32327,10 @@ function requirementUnit(r) {
31433
32327
  function conformanceTestUnit(t) {
31434
32328
  const payload = {
31435
32329
  ...present(t.kind) ? { test_kind: t.kind } : {},
31436
- ...present(t.methodRef) ? { method_ref: t.methodRef } : {},
31437
- ...presentList(t.preconditions) ? {
31438
- preconditions: t.preconditions.map((p) => ({
31439
- id: p.id,
31440
- check: p.check,
31441
- description: p.description,
31442
- on_violation: p.onViolation
31443
- }))
31444
- } : {}
32330
+ ...present(t.methodRef) ? { method_ref: t.methodRef } : {}
31445
32331
  };
32332
+ const decision = acceptanceDecisionOf(t.acceptance);
32333
+ const criteria = testAcceptanceCriteriaOf(t);
31446
32334
  return assemble(
31447
32335
  {
31448
32336
  id: t.id,
@@ -31456,7 +32344,17 @@ function conformanceTestUnit(t) {
31456
32344
  ...presentList(t.applicability) ? { applicability: t.applicability } : {},
31457
32345
  ...presentList(t.targets) ? { targets: t.targets } : {},
31458
32346
  ...presentList(t.bindsTo) ? { binds_to: t.bindsTo } : {},
31459
- ...present(t.acceptancePassIf) ? { acceptance: t.acceptancePassIf } : present(t.acceptanceCriteriaDescription) ? { acceptance: t.acceptanceCriteriaDescription } : {},
32347
+ ...decision ? { acceptance: decision } : {},
32348
+ ...criteria ? { acceptance_criteria: criteria } : {},
32349
+ ...presentList(t.preconditions) ? {
32350
+ preconditions: t.preconditions.map((p) => ({
32351
+ id: p.id,
32352
+ check: p.check,
32353
+ ...present(p.description) ? { description: p.description } : {},
32354
+ ...present(p.onViolation) ? { on_violation: p.onViolation } : {},
32355
+ ...present(p.onUnresolvable) ? { on_unresolvable: p.onUnresolvable } : {}
32356
+ }))
32357
+ } : {},
31460
32358
  ...presentList(t.dependencies) ? { dependencies: t.dependencies } : {},
31461
32359
  ...Object.keys(payload).length > 0 ? { payload } : {}
31462
32360
  },
@@ -31615,9 +32513,15 @@ function constraintUnit(c) {
31615
32513
  ...present(c.name) ? { name: c.name } : {},
31616
32514
  ...present(c.violationMeaning) ? { statement: c.violationMeaning } : {},
31617
32515
  ...present(c.check) ? { expression: c.check } : {},
32516
+ // The violation semantics first-class (ask 8) — the construct's
32517
+ // own keyword vocabulary, out of the payload grab bag. `statement`
32518
+ // and `expression` stay: the generic prose/expression slots the
32519
+ // passport and the consumer's grounding text read.
32520
+ ...present(c.check) ? { check: c.check } : {},
32521
+ ...present(c.violationMeaning) ? { violation_meaning: c.violationMeaning } : {},
32522
+ ...present(c.onViolation) ? { on_violation: c.onViolation } : {},
31618
32523
  payload: {
31619
- ...present(c.stereotype) ? { stereotype: c.stereotype } : {},
31620
- ...present(c.onViolation) ? { on_violation: c.onViolation } : {}
32524
+ ...present(c.stereotype) ? { stereotype: c.stereotype } : {}
31621
32525
  }
31622
32526
  },
31623
32527
  collectClauses(c)
@@ -31640,7 +32544,7 @@ function characteristicUnit(v) {
31640
32544
  ...presentList(v.inputs) ? { expression_inputs: v.inputs } : {}
31641
32545
  } : {},
31642
32546
  ...units ? { units } : {},
31643
- ...v.acceptance && present(v.acceptance.rule) ? { acceptance: v.acceptance.rule } : {},
32547
+ ...acceptanceDecisionOf(v.acceptance) ? { acceptance: acceptanceDecisionOf(v.acceptance) } : {},
31644
32548
  ...Object.keys(payload).length > 0 ? { payload } : {}
31645
32549
  },
31646
32550
  collectClauses(v)
@@ -31697,6 +32601,76 @@ function sequenceUnit(s) {
31697
32601
  collectClauses({ sourceRefs: s.sourceRefs, refs: s.refs })
31698
32602
  );
31699
32603
  }
32604
+ function conditionSetUnit(cs, registers, db = null) {
32605
+ const unitsBySymbol = /* @__PURE__ */ new Map();
32606
+ for (const reg of registers ?? []) {
32607
+ const siUnitByKind = new Map(reg.kinds.map((k) => [k.id, k.siUnit]));
32608
+ for (const u of reg.units ?? []) {
32609
+ const siUnit = siUnitByKind.get(u.kind);
32610
+ if (siUnit) {
32611
+ unitsBySymbol.set(u.symbol, {
32612
+ kind: u.kind,
32613
+ factorToSI: u.factorToSI,
32614
+ offsetToSI: u.offsetToSI,
32615
+ siUnit
32616
+ });
32617
+ }
32618
+ }
32619
+ }
32620
+ const siOf = (value, unit) => {
32621
+ const def = unitsBySymbol.get(unit);
32622
+ if (!def) {
32623
+ return void 0;
32624
+ }
32625
+ const n = Number(String(value).replace(",", "."));
32626
+ if (!Number.isFinite(n)) {
32627
+ return void 0;
32628
+ }
32629
+ return { value: n * def.factorToSI + def.offsetToSI, unit: def.siUnit };
32630
+ };
32631
+ const payload = {
32632
+ role: cs.role,
32633
+ ...cs.subject ? { subject: cs.subject } : {},
32634
+ entries: cs.entries.map((e) => {
32635
+ const si = siOf(e.value, e.unit);
32636
+ const ud = unitsDbEntryFor(db, e.unit);
32637
+ return {
32638
+ quantity_kind: e.quantityKind,
32639
+ value: e.value,
32640
+ unit: e.unit,
32641
+ tolerance: e.tolerance,
32642
+ ...si ? { si } : {},
32643
+ ...ud ? {
32644
+ unitsdb: {
32645
+ unitsml: ud.unitsml,
32646
+ ...ud.scale ? { scale: ud.scale } : {}
32647
+ }
32648
+ } : {},
32649
+ ...e.note ? { note: e.note } : {}
32650
+ };
32651
+ })
32652
+ };
32653
+ return assemble(
32654
+ {
32655
+ id: `/condition/${cs.id}`,
32656
+ kind: "condition_set",
32657
+ name: cs.id,
32658
+ statement: [
32659
+ `${cs.role} condition set`,
32660
+ ...cs.description ? [cs.description] : [],
32661
+ ...cs.entries.map(
32662
+ (e) => `${e.quantityKind.replace(/_/g, " ")}: ${e.value} ${e.unit} \xB1${e.tolerance}`
32663
+ )
32664
+ ].join(" \u2014 "),
32665
+ payload
32666
+ },
32667
+ collectClauses({
32668
+ sourceRefs: cs.sources,
32669
+ refs: cs.refs,
32670
+ source: cs.source
32671
+ })
32672
+ );
32673
+ }
31700
32674
  function noteUnit(n) {
31701
32675
  return assemble(
31702
32676
  {
@@ -31737,11 +32711,16 @@ function dimensionUnit(d) {
31737
32711
  const payload = {
31738
32712
  ...present(d.scope) ? { scope: d.scope } : {},
31739
32713
  ...present(d.cardinality) ? { cardinality: d.cardinality } : {},
32714
+ // The typed payload (the typed kernel R2): a value IS its
32715
+ // definition — the class's fields ride the value, and the class
32716
+ // reference rides the dimension.
32717
+ ...present(d.payloadClass) ? { payload_class: d.payloadClass } : {},
31740
32718
  values: d.values.map((v) => ({
31741
32719
  id: v.id,
31742
32720
  ...present(v.label) ? { label: v.label } : {},
31743
32721
  ...presentList(v.implies) ? { implies: v.implies } : {},
31744
- ...present(v.termRef) ? { term_ref: v.termRef } : {}
32722
+ ...present(v.termRef) ? { term_ref: v.termRef } : {},
32723
+ ...Object.keys(v.payload ?? {}).length > 0 ? { payload: v.payload } : {}
31745
32724
  }))
31746
32725
  };
31747
32726
  return assemble(
@@ -31796,6 +32775,7 @@ function packageBlock(standard) {
31796
32775
  };
31797
32776
  }
31798
32777
  function exportStandardRetrieval(standard, options = {}) {
32778
+ const unitsDb = loadUnitsDb(process.env.UNITSDB_DIR);
31799
32779
  const pkg = packageBlock(standard);
31800
32780
  const built = [];
31801
32781
  const push = (content, elementId) => {
@@ -31834,6 +32814,9 @@ function exportStandardRetrieval(standard, options = {}) {
31834
32814
  for (const s of standard.testSequences ?? []) {
31835
32815
  push(sequenceUnit(s), s.id);
31836
32816
  }
32817
+ for (const cs of standard.conditionSets ?? []) {
32818
+ push(conditionSetUnit(cs, standard.quantityRegisters, unitsDb), cs.id);
32819
+ }
31837
32820
  for (const n of standard.notes ?? []) {
31838
32821
  push(noteUnit(n), n.id);
31839
32822
  }
@@ -32113,18 +33096,171 @@ function exportPackageImpact(dir) {
32113
33096
  };
32114
33097
  }
32115
33098
 
33099
+ // src/export/cddal.ts
33100
+ import { readFileSync as readFileSync8, readdirSync as readdirSync5 } from "node:fs";
33101
+ import { basename, join as join7, resolve as resolve5 } from "node:path";
33102
+ var CDDAL_PROJECTION_VERSION = "primmel-cddal/1";
33103
+ function escapeCddalString(s) {
33104
+ return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
33105
+ }
33106
+ function quote(s) {
33107
+ return `"${escapeCddalString(s)}"`;
33108
+ }
33109
+ function safeSymbol(id) {
33110
+ const s = id.replace(/[^A-Za-z0-9_]+/g, "_");
33111
+ return /^[0-9]/.test(s) ? `N${s}` : s;
33112
+ }
33113
+ function isSafeIdentifier(id) {
33114
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(id);
33115
+ }
33116
+ function codeAssignment(id) {
33117
+ return isSafeIdentifier(id) ? id : quote(id);
33118
+ }
33119
+ function quantity(v) {
33120
+ return quote(
33121
+ v.unit !== void 0 && v.unit !== "" ? `${v.value} ${v.unit}` : String(v.value)
33122
+ );
33123
+ }
33124
+ function readL10n(files, read) {
33125
+ const out = /* @__PURE__ */ new Map();
33126
+ const block = /text\s+([\w./#-]+)\s*\{([\s\S]*?)\}/g;
33127
+ const spell = /spell\s+([\w-]+)\s+"((?:[^"\\]|\\.)*)"/g;
33128
+ for (const f of files.filter((f2) => /(^|\/)l10n\.[^/]+\.prl$/.test(f2))) {
33129
+ const src = read(f);
33130
+ for (const m of src.matchAll(block)) {
33131
+ const addr = m[1];
33132
+ const tail = addr.split("/").pop() ?? addr;
33133
+ for (const sp of (m[2] ?? "").matchAll(spell)) {
33134
+ const list = out.get(tail) ?? [];
33135
+ list.push({ tag: sp[1], value: sp[2] });
33136
+ out.set(tail, list);
33137
+ }
33138
+ }
33139
+ }
33140
+ return out;
33141
+ }
33142
+ function l10nDefinitions(l10n, id, field) {
33143
+ return l10n.get(`${id}.${field}`) ?? [];
33144
+ }
33145
+ function projectCddal(model, packageId, l10n = /* @__PURE__ */ new Map()) {
33146
+ const lines = [
33147
+ `# ${CDDAL_PROJECTION_VERSION} \u2014 the dictionary subset of ${packageId}`,
33148
+ "# (generated by primmel export cddal \u2014 never authored, never re-imported)",
33149
+ ""
33150
+ ];
33151
+ const stats = {
33152
+ classes: 0,
33153
+ instances: 0,
33154
+ assignments: 0,
33155
+ properties: 0,
33156
+ valueLists: 0
33157
+ };
33158
+ const attrDefs = new Map(
33159
+ (model.attributeDefinitions ?? []).map((a) => [a.id, a])
33160
+ );
33161
+ for (const c of model.dataclasses) {
33162
+ stats.classes++;
33163
+ lines.push(`instance ${safeSymbol(c.id)} < MDC_C002 {`);
33164
+ lines.push(` code: ${codeAssignment(c.id)}`);
33165
+ if (c.description) {
33166
+ lines.push(` definition.en: ${quote(c.description)}`);
33167
+ for (const alt of l10nDefinitions(l10n, c.id, "description")) {
33168
+ lines.push(` definition.${alt.tag}: ${quote(alt.value)}`);
33169
+ }
33170
+ }
33171
+ lines.push(
33172
+ ` superclass: ${c.extends !== void 0 ? safeSymbol(c.extends) : "UNIVERSE"}`
33173
+ );
33174
+ if (c.attributes.length > 0) {
33175
+ lines.push(
33176
+ ` applicable_properties: { ${c.attributes.map((a) => safeSymbol(a.id)).join(", ")} }`
33177
+ );
33178
+ }
33179
+ lines.push("}");
33180
+ lines.push("");
33181
+ for (const a of c.attributes) {
33182
+ const def = attrDefs.get(a.id);
33183
+ if (!def) {
33184
+ continue;
33185
+ }
33186
+ const irdi = def.irdi || def.correspondences?.find((x) => x.scheme === "iec-cdd")?.concept;
33187
+ stats.properties++;
33188
+ lines.push(`instance ${safeSymbol(a.id)} < MDC_C003 {`);
33189
+ lines.push(
33190
+ ` code: ${codeAssignment(irdi !== void 0 && irdi !== "" ? irdi : a.id)}`
33191
+ );
33192
+ if (def.definition) {
33193
+ lines.push(` definition.en: ${quote(def.definition)}`);
33194
+ for (const alt of l10nDefinitions(l10n, a.id, "definition")) {
33195
+ lines.push(` definition.${alt.tag}: ${quote(alt.value)}`);
33196
+ }
33197
+ }
33198
+ lines.push("}");
33199
+ lines.push("");
33200
+ }
33201
+ }
33202
+ for (const e of model.enums ?? []) {
33203
+ stats.valueLists++;
33204
+ lines.push(`instance ${safeSymbol(e.id)} < MDC_C005 {`);
33205
+ lines.push(` code: ${codeAssignment(e.id)}`);
33206
+ if (e.values.length > 0) {
33207
+ lines.push(
33208
+ ` MDC_P043: ( ${e.values.map((v) => safeSymbol(v.id)).join(", ")} )`
33209
+ );
33210
+ }
33211
+ lines.push("}");
33212
+ lines.push("");
33213
+ for (const v of e.values) {
33214
+ lines.push(`instance ${safeSymbol(v.id)} < MDC_C010 {`);
33215
+ lines.push(` code: ${codeAssignment(v.id)}`);
33216
+ lines.push("}");
33217
+ lines.push("");
33218
+ }
33219
+ }
33220
+ for (const inst of model.instances) {
33221
+ stats.instances++;
33222
+ lines.push(`instance ${safeSymbol(inst.id)} < MDC_C002 {`);
33223
+ lines.push(` code: ${codeAssignment(inst.id)}`);
33224
+ if (inst.of) {
33225
+ lines.push(` superclass: ${safeSymbol(inst.of)}`);
33226
+ }
33227
+ for (const [id, v] of Object.entries(inst.has?.attributes ?? {})) {
33228
+ stats.assignments++;
33229
+ lines.push(` ${safeSymbol(id)}: ${quantity(v)}`);
33230
+ }
33231
+ lines.push("}");
33232
+ lines.push("");
33233
+ }
33234
+ if (stats.classes === 0 && stats.instances === 0 && stats.valueLists === 0) {
33235
+ throw new Error(
33236
+ "no dictionary content: the CDDAL projection carries classes and instances"
33237
+ );
33238
+ }
33239
+ return {
33240
+ version: CDDAL_PROJECTION_VERSION,
33241
+ cddal: lines.join("\n"),
33242
+ stats
33243
+ };
33244
+ }
33245
+ function exportPackageCddal(dir) {
33246
+ const model = loadPackage(dir);
33247
+ const l10nFiles = readdirSync5(dir).filter((e) => /^l10n\.[^/]+\.prl$/.test(e)).map((e) => join7(dir, e));
33248
+ const l10n = readL10n(l10nFiles, (p) => readFileSync8(p, "utf8"));
33249
+ return projectCddal(model, basename(resolve5(dir)), l10n);
33250
+ }
33251
+
32116
33252
  // src/package-diff.ts
32117
- import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "fs";
32118
- import { join as join6 } from "path";
33253
+ import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync9 } from "fs";
33254
+ import { join as join8 } from "path";
32119
33255
  function packageMappings(dir, standard) {
32120
33256
  const profiles = [...standard.mapProfiles ?? []];
32121
- if (existsSync6(dir)) {
32122
- for (const entry of readdirSync5(dir).sort()) {
33257
+ if (existsSync7(dir)) {
33258
+ for (const entry of readdirSync6(dir).sort()) {
32123
33259
  if (!entry.endsWith(".prm")) {
32124
33260
  continue;
32125
33261
  }
32126
33262
  profiles.push(
32127
- ...prmToMapProfiles(loadPrm(readFileSync7(join6(dir, entry), "utf8")))
33263
+ ...prmToMapProfiles(loadPrm(readFileSync9(join8(dir, entry), "utf8")))
32128
33264
  );
32129
33265
  }
32130
33266
  }
@@ -32133,17 +33269,17 @@ function packageMappings(dir, standard) {
32133
33269
  }
32134
33270
  function packageClauseTexts(dir) {
32135
33271
  const out = /* @__PURE__ */ new Map();
32136
- const prdDir = join6(dir, "sources-prd");
32137
- if (!existsSync6(prdDir)) {
33272
+ const prdDir = join8(dir, "sources-prd");
33273
+ if (!existsSync7(prdDir)) {
32138
33274
  return out;
32139
33275
  }
32140
- for (const entry of readdirSync5(prdDir).sort()) {
33276
+ for (const entry of readdirSync6(prdDir).sort()) {
32141
33277
  if (!entry.endsWith(".sentences.json")) {
32142
33278
  continue;
32143
33279
  }
32144
33280
  let payload;
32145
33281
  try {
32146
- payload = JSON.parse(readFileSync7(join6(prdDir, entry), "utf8"));
33282
+ payload = JSON.parse(readFileSync9(join8(prdDir, entry), "utf8"));
32147
33283
  } catch {
32148
33284
  continue;
32149
33285
  }
@@ -32193,18 +33329,18 @@ function diffPackageDirs(dirA, dirB, options = {}) {
32193
33329
  // scripts/check.mts
32194
33330
  var CHECK_USAGE = "Usage: primmel check [--strict] [--audit] [--coverage] [--rules] [--with <pkg-id>=<dir>]\u2026 <package-dir>";
32195
33331
  var DIFF_USAGE = "Usage: primmel diff [--json] [--exit-code] [--compare-texts] [--with <pkg-id>=<dir>]\u2026 <a> <b>";
32196
- var EXPORT_USAGE = "Usage: primmel export reqif|rdf|retrieval|impact <package-dir> [--out <file>] [--format turtle|jsonld]";
33332
+ var EXPORT_USAGE = "Usage: primmel export reqif|rdf|retrieval|impact|cddal <package-dir> [--out <file>] [--format turtle|jsonld]";
32197
33333
  function readablePackageDirProblem(target, needsManifest) {
32198
33334
  try {
32199
33335
  if (!statSync4(target).isDirectory()) {
32200
33336
  return "not a directory";
32201
33337
  }
32202
- readdirSync6(target);
33338
+ readdirSync7(target);
32203
33339
  } catch (e) {
32204
33340
  const err = e;
32205
33341
  return err.code === "ENOENT" ? "no such directory" : err.message;
32206
33342
  }
32207
- if (needsManifest && !existsSync7(join7(target, "package.primmel"))) {
33343
+ if (needsManifest && !existsSync8(join9(target, "package.primmel"))) {
32208
33344
  return "no package.primmel found";
32209
33345
  }
32210
33346
  return null;
@@ -32363,7 +33499,7 @@ function diffCli(args2) {
32363
33499
  }
32364
33500
  function exportCli(args2) {
32365
33501
  const surface = args2[0];
32366
- if (surface !== "reqif" && surface !== "rdf" && surface !== "retrieval" && surface !== "impact") {
33502
+ if (surface !== "reqif" && surface !== "rdf" && surface !== "retrieval" && surface !== "impact" && surface !== "cddal") {
32367
33503
  console.error(EXPORT_USAGE);
32368
33504
  process.exit(2);
32369
33505
  }
@@ -32398,7 +33534,11 @@ function exportCli(args2) {
32398
33534
  let document;
32399
33535
  let summary;
32400
33536
  try {
32401
- if (surface === "impact") {
33537
+ if (surface === "cddal") {
33538
+ const result = exportPackageCddal(dir);
33539
+ document = result.cddal;
33540
+ summary = `${n(result.stats.classes, "class", "classes")}, ${n(result.stats.instances, "instance", "instances")}, ${n(result.stats.assignments, "assignment", "assignments")}`;
33541
+ } else if (surface === "impact") {
32402
33542
  const result = exportPackageImpact(dir);
32403
33543
  document = result.json;
32404
33544
  const s = result.stats;