@primmel/primmel 1.6.1 → 1.8.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/src/check-rules.d.ts +1 -1
- package/dist/src/check-rules.d.ts.map +1 -1
- package/dist/src/check-rules.js +24 -2
- package/dist/src/check-rules.js.map +1 -1
- package/dist/src/check.d.ts.map +1 -1
- package/dist/src/check.js +204 -0
- package/dist/src/check.js.map +1 -1
- package/dist/src/ser-des/config/artifact.d.ts.map +1 -1
- package/dist/src/ser-des/config/artifact.js +8 -0
- package/dist/src/ser-des/config/artifact.js.map +1 -1
- package/dist/src/ser-des/config/calculation.d.ts.map +1 -1
- package/dist/src/ser-des/config/calculation.js +9 -0
- package/dist/src/ser-des/config/calculation.js.map +1 -1
- package/dist/src/ser-des/config/competenceKind.d.ts.map +1 -1
- package/dist/src/ser-des/config/competenceKind.js +10 -1
- package/dist/src/ser-des/config/competenceKind.js.map +1 -1
- package/dist/src/ser-des/config/conformanceTest.d.ts.map +1 -1
- package/dist/src/ser-des/config/conformanceTest.js +6 -0
- package/dist/src/ser-des/config/conformanceTest.js.map +1 -1
- package/dist/src/ser-des/config/constraint.d.ts.map +1 -1
- package/dist/src/ser-des/config/constraint.js +10 -1
- package/dist/src/ser-des/config/constraint.js.map +1 -1
- package/dist/src/ser-des/config/correspondence.d.ts +19 -0
- package/dist/src/ser-des/config/correspondence.d.ts.map +1 -0
- package/dist/src/ser-des/config/correspondence.js +107 -0
- package/dist/src/ser-des/config/correspondence.js.map +1 -0
- package/dist/src/ser-des/config/data.d.ts.map +1 -1
- package/dist/src/ser-des/config/data.js +4 -2
- package/dist/src/ser-des/config/data.js.map +1 -1
- package/dist/src/ser-des/config/dataspace.d.ts +9 -0
- package/dist/src/ser-des/config/dataspace.d.ts.map +1 -0
- package/dist/src/ser-des/config/dataspace.js +269 -0
- package/dist/src/ser-des/config/dataspace.js.map +1 -0
- package/dist/src/ser-des/config/field-parser.d.ts.map +1 -1
- package/dist/src/ser-des/config/field-parser.js +11 -0
- package/dist/src/ser-des/config/field-parser.js.map +1 -1
- package/dist/src/ser-des/config/form.d.ts.map +1 -1
- package/dist/src/ser-des/config/form.js +8 -0
- package/dist/src/ser-des/config/form.js.map +1 -1
- package/dist/src/ser-des/config/formulasUsed.d.ts.map +1 -1
- package/dist/src/ser-des/config/formulasUsed.js +6 -0
- package/dist/src/ser-des/config/formulasUsed.js.map +1 -1
- package/dist/src/ser-des/config/index.d.ts.map +1 -1
- package/dist/src/ser-des/config/index.js +10 -0
- package/dist/src/ser-des/config/index.js.map +1 -1
- package/dist/src/ser-des/config/packageManifest.d.ts.map +1 -1
- package/dist/src/ser-des/config/packageManifest.js +10 -0
- package/dist/src/ser-des/config/packageManifest.js.map +1 -1
- package/dist/src/ser-des/config/policy.d.ts +9 -0
- package/dist/src/ser-des/config/policy.d.ts.map +1 -0
- package/dist/src/ser-des/config/policy.js +192 -0
- package/dist/src/ser-des/config/policy.js.map +1 -0
- package/dist/src/ser-des/config/process.d.ts.map +1 -1
- package/dist/src/ser-des/config/process.js +6 -0
- package/dist/src/ser-des/config/process.js.map +1 -1
- package/dist/src/ser-des/config/referenceMaterial.d.ts.map +1 -1
- package/dist/src/ser-des/config/referenceMaterial.js +6 -0
- package/dist/src/ser-des/config/referenceMaterial.js.map +1 -1
- package/dist/src/ser-des/config/requirement.d.ts.map +1 -1
- package/dist/src/ser-des/config/requirement.js +8 -0
- package/dist/src/ser-des/config/requirement.js.map +1 -1
- package/dist/src/ser-des/config/subject.d.ts.map +1 -1
- package/dist/src/ser-des/config/subject.js +37 -0
- package/dist/src/ser-des/config/subject.js.map +1 -1
- package/dist/src/ser-des/config/symbol.d.ts.map +1 -1
- package/dist/src/ser-des/config/symbol.js +10 -2
- package/dist/src/ser-des/config/symbol.js.map +1 -1
- package/dist/src/ser-des/config/table.d.ts.map +1 -1
- package/dist/src/ser-des/config/table.js +10 -1
- package/dist/src/ser-des/config/table.js.map +1 -1
- package/dist/src/ser-des/config/term.d.ts.map +1 -1
- package/dist/src/ser-des/config/term.js +9 -0
- package/dist/src/ser-des/config/term.js.map +1 -1
- package/dist/src/ser-des/config/testPointSet.d.ts.map +1 -1
- package/dist/src/ser-des/config/testPointSet.js +6 -0
- package/dist/src/ser-des/config/testPointSet.js.map +1 -1
- package/dist/src/ser-des/config/testSequence.d.ts.map +1 -1
- package/dist/src/ser-des/config/testSequence.js +8 -0
- package/dist/src/ser-des/config/testSequence.js.map +1 -1
- package/dist/src/ser-des/config/trustRef.d.ts +13 -0
- package/dist/src/ser-des/config/trustRef.d.ts.map +1 -0
- package/dist/src/ser-des/config/trustRef.js +51 -0
- package/dist/src/ser-des/config/trustRef.js.map +1 -0
- package/dist/src/ser-des/config/verdict.d.ts.map +1 -1
- package/dist/src/ser-des/config/verdict.js +7 -0
- package/dist/src/ser-des/config/verdict.js.map +1 -1
- package/dist/src/ser-des/index.d.ts +1 -1
- package/dist/src/ser-des/index.d.ts.map +1 -1
- package/dist/src/ser-des/index.js +3 -1
- package/dist/src/ser-des/index.js.map +1 -1
- package/dist/src/ser-des/package.d.ts +68 -0
- package/dist/src/ser-des/package.d.ts.map +1 -1
- package/dist/src/ser-des/package.js +155 -23
- package/dist/src/ser-des/package.js.map +1 -1
- package/dist/src/ser-des/parse-block.d.ts +9 -6
- package/dist/src/ser-des/parse-block.d.ts.map +1 -1
- package/dist/src/ser-des/parse-block.js +50 -21
- package/dist/src/ser-des/parse-block.js.map +1 -1
- package/dist/src/ser-des/parse.d.ts +8 -0
- package/dist/src/ser-des/parse.d.ts.map +1 -1
- package/dist/src/ser-des/parse.js +28 -0
- package/dist/src/ser-des/parse.js.map +1 -1
- package/dist/src/ser-des/types.d.ts +19 -0
- package/dist/src/ser-des/types.d.ts.map +1 -1
- package/dist/src/types/Artifact.d.ts +2 -0
- package/dist/src/types/Artifact.d.ts.map +1 -1
- package/dist/src/types/Calculation.d.ts +2 -0
- package/dist/src/types/Calculation.d.ts.map +1 -1
- package/dist/src/types/CompetenceKind.d.ts +2 -0
- package/dist/src/types/CompetenceKind.d.ts.map +1 -1
- package/dist/src/types/ConformanceTest.d.ts +2 -0
- package/dist/src/types/ConformanceTest.d.ts.map +1 -1
- package/dist/src/types/Constraint.d.ts +2 -0
- package/dist/src/types/Constraint.d.ts.map +1 -1
- package/dist/src/types/Correspondence.d.ts +27 -0
- package/dist/src/types/Correspondence.d.ts.map +1 -0
- package/dist/src/types/Correspondence.js +23 -0
- package/dist/src/types/Correspondence.js.map +1 -0
- package/dist/src/types/Dataspace.d.ts +60 -0
- package/dist/src/types/Dataspace.d.ts.map +1 -0
- package/dist/src/types/Dataspace.js +36 -0
- package/dist/src/types/Dataspace.js.map +1 -0
- package/dist/src/types/Form.d.ts +5 -0
- package/dist/src/types/Form.d.ts.map +1 -1
- package/dist/src/types/FormulasUsed.d.ts +2 -0
- package/dist/src/types/FormulasUsed.d.ts.map +1 -1
- package/dist/src/types/Package.d.ts +4 -0
- package/dist/src/types/Package.d.ts.map +1 -1
- package/dist/src/types/Policy.d.ts +40 -0
- package/dist/src/types/Policy.d.ts.map +1 -0
- package/dist/src/types/Policy.js +48 -0
- package/dist/src/types/Policy.js.map +1 -0
- package/dist/src/types/ReferenceMaterial.d.ts +2 -0
- package/dist/src/types/ReferenceMaterial.d.ts.map +1 -1
- package/dist/src/types/Requirement.d.ts +2 -0
- package/dist/src/types/Requirement.d.ts.map +1 -1
- package/dist/src/types/Standard.d.ts +4 -0
- package/dist/src/types/Standard.d.ts.map +1 -1
- package/dist/src/types/Subject.d.ts +11 -0
- package/dist/src/types/Subject.d.ts.map +1 -1
- package/dist/src/types/Symbol.d.ts +2 -0
- package/dist/src/types/Symbol.d.ts.map +1 -1
- package/dist/src/types/Table.d.ts +4 -0
- package/dist/src/types/Table.d.ts.map +1 -1
- package/dist/src/types/Term.d.ts +2 -0
- package/dist/src/types/Term.d.ts.map +1 -1
- package/dist/src/types/TestPointSet.d.ts +2 -0
- package/dist/src/types/TestPointSet.d.ts.map +1 -1
- package/dist/src/types/TestSequence.d.ts +2 -0
- package/dist/src/types/TestSequence.d.ts.map +1 -1
- package/dist/src/types/TrustRef.d.ts +10 -0
- package/dist/src/types/TrustRef.d.ts.map +1 -0
- package/dist/src/types/TrustRef.js +28 -0
- package/dist/src/types/TrustRef.js.map +1 -0
- package/dist/src/types/Verdict.d.ts +2 -0
- package/dist/src/types/Verdict.d.ts.map +1 -1
- package/dist/src/types/process.d.ts +2 -0
- package/dist/src/types/process.d.ts.map +1 -1
- package/dist-browser/index.mjs +1691 -1274
- package/dist-cli/primmel.mjs +1144 -31
- package/package.json +1 -1
package/dist-cli/primmel.mjs
CHANGED
|
@@ -187,6 +187,7 @@ function createDuplicateIdChecker() {
|
|
|
187
187
|
function parse(mmelString, parsers, options = {}) {
|
|
188
188
|
const tokens = tokenizeWithPositions(mmelString);
|
|
189
189
|
const dupChecker = createDuplicateIdChecker();
|
|
190
|
+
const constructs = [];
|
|
190
191
|
let ctx = {
|
|
191
192
|
root: "",
|
|
192
193
|
metadata: null,
|
|
@@ -262,6 +263,9 @@ function parse(mmelString, parsers, options = {}) {
|
|
|
262
263
|
formulasUsed: {},
|
|
263
264
|
// Primmel v3 ISO 24229 multilinguality (TODO.roadmap/25)
|
|
264
265
|
texts: {},
|
|
266
|
+
// Primmel v3.1 dataspace + trust (TODO.primmel/10)
|
|
267
|
+
dataspaces: {},
|
|
268
|
+
policies: {},
|
|
265
269
|
// Issue collection (duplicate IDs, etc.)
|
|
266
270
|
issues: []
|
|
267
271
|
};
|
|
@@ -298,6 +302,15 @@ function parse(mmelString, parsers, options = {}) {
|
|
|
298
302
|
ctx.issues.push(issue);
|
|
299
303
|
}
|
|
300
304
|
}
|
|
305
|
+
if (options.withProvenance) {
|
|
306
|
+
constructs.push({
|
|
307
|
+
field: cfg.field ?? keyword,
|
|
308
|
+
id: idTok.value,
|
|
309
|
+
keyword,
|
|
310
|
+
start: tok.start,
|
|
311
|
+
end: payloadTok.end
|
|
312
|
+
});
|
|
313
|
+
}
|
|
301
314
|
updateCtx = cfg.parse(idTok.value, payloadTok.value);
|
|
302
315
|
} else {
|
|
303
316
|
if (i >= tokens.length) {
|
|
@@ -306,6 +319,15 @@ function parse(mmelString, parsers, options = {}) {
|
|
|
306
319
|
);
|
|
307
320
|
}
|
|
308
321
|
const payloadTok = tokens[i++];
|
|
322
|
+
if (options.withProvenance) {
|
|
323
|
+
constructs.push({
|
|
324
|
+
field: cfg.field ?? keyword,
|
|
325
|
+
id: "",
|
|
326
|
+
keyword,
|
|
327
|
+
start: tok.start,
|
|
328
|
+
end: payloadTok.end
|
|
329
|
+
});
|
|
330
|
+
}
|
|
309
331
|
updateCtx = cfg.parse(payloadTok.value);
|
|
310
332
|
}
|
|
311
333
|
const next = updateCtx(ctx);
|
|
@@ -314,6 +336,9 @@ function parse(mmelString, parsers, options = {}) {
|
|
|
314
336
|
}
|
|
315
337
|
ctx = next;
|
|
316
338
|
}
|
|
339
|
+
if (options.withProvenance) {
|
|
340
|
+
ctx.constructs = constructs;
|
|
341
|
+
}
|
|
317
342
|
return ctx;
|
|
318
343
|
}
|
|
319
344
|
|
|
@@ -395,12 +420,18 @@ function forEachEntry(data, visitor, errCtx) {
|
|
|
395
420
|
() => t[i]
|
|
396
421
|
);
|
|
397
422
|
if (!claimed) {
|
|
398
|
-
if (keyword === "ref") {
|
|
423
|
+
if (keyword === "ref" || keyword === "corresponds") {
|
|
399
424
|
i++;
|
|
400
425
|
i++;
|
|
401
426
|
if (i < t.length && t[i].startsWith("{")) {
|
|
402
427
|
i++;
|
|
403
428
|
}
|
|
429
|
+
} else if (keyword === "trust_ref") {
|
|
430
|
+
i++;
|
|
431
|
+
if (t[i] === "key") {
|
|
432
|
+
i++;
|
|
433
|
+
i++;
|
|
434
|
+
}
|
|
404
435
|
} else {
|
|
405
436
|
i++;
|
|
406
437
|
}
|
|
@@ -408,7 +439,7 @@ function forEachEntry(data, visitor, errCtx) {
|
|
|
408
439
|
}
|
|
409
440
|
}
|
|
410
441
|
function skipUnknownValue(t, i, keyword) {
|
|
411
|
-
if (keyword === "ref") {
|
|
442
|
+
if (keyword === "ref" || keyword === "corresponds") {
|
|
412
443
|
i++;
|
|
413
444
|
if (i < t.length) {
|
|
414
445
|
i++;
|
|
@@ -418,6 +449,18 @@ function skipUnknownValue(t, i, keyword) {
|
|
|
418
449
|
}
|
|
419
450
|
return i;
|
|
420
451
|
}
|
|
452
|
+
if (keyword === "trust_ref") {
|
|
453
|
+
if (i < t.length) {
|
|
454
|
+
i++;
|
|
455
|
+
}
|
|
456
|
+
if (t[i] === "key") {
|
|
457
|
+
i++;
|
|
458
|
+
if (i < t.length) {
|
|
459
|
+
i++;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return i;
|
|
463
|
+
}
|
|
421
464
|
if (i < t.length) {
|
|
422
465
|
i++;
|
|
423
466
|
}
|
|
@@ -432,8 +475,12 @@ function forEachAttribute(data, visitor, errCtx) {
|
|
|
432
475
|
while (i < t.length) {
|
|
433
476
|
if (t[i] === "ref") {
|
|
434
477
|
const nameParts2 = [t[i++]];
|
|
435
|
-
if (i < t.length)
|
|
436
|
-
|
|
478
|
+
if (i < t.length) {
|
|
479
|
+
nameParts2.push(t[i++]);
|
|
480
|
+
}
|
|
481
|
+
if (i < t.length) {
|
|
482
|
+
nameParts2.push(t[i++]);
|
|
483
|
+
}
|
|
437
484
|
let blockContent = "";
|
|
438
485
|
if (i < t.length && t[i].charAt(0) === "{") {
|
|
439
486
|
blockContent = unwrapBlock(t[i++]);
|
|
@@ -642,7 +689,9 @@ var parseDataClass = function(id, data) {
|
|
|
642
689
|
const ref = { predicate: m[1], target: m[2] };
|
|
643
690
|
if (details) {
|
|
644
691
|
const noteMatch = /note\s+"([^"]*)"/.exec(details) ?? /note\s+(\S+)/.exec(details);
|
|
645
|
-
if (noteMatch)
|
|
692
|
+
if (noteMatch) {
|
|
693
|
+
ref.note = noteMatch[1];
|
|
694
|
+
}
|
|
646
695
|
}
|
|
647
696
|
result.ref ??= [];
|
|
648
697
|
result.ref.push(ref);
|
|
@@ -792,7 +841,9 @@ var dumpDataClass = function(dataclass) {
|
|
|
792
841
|
if (dataclass.ref && dataclass.ref.length > 0) {
|
|
793
842
|
for (const r of dataclass.ref) {
|
|
794
843
|
out += " ref " + r.predicate + ' "' + escapeString(r.target) + '"';
|
|
795
|
-
if (r.note)
|
|
844
|
+
if (r.note) {
|
|
845
|
+
out += ' { note "' + escapeString(r.note) + '" }';
|
|
846
|
+
}
|
|
796
847
|
out += "\n";
|
|
797
848
|
}
|
|
798
849
|
}
|
|
@@ -1259,6 +1310,86 @@ function dumpSourceRefAsRef(src, indent, escapeString2) {
|
|
|
1259
1310
|
return `${indent}source { doc "${escapeString2(src.doc ?? "")}" clause "${escapeString2(String(src.clause ?? ""))}"` + (src.fragment ? ` fragment "${escapeString2(src.fragment)}"` : "") + " }\n";
|
|
1260
1311
|
}
|
|
1261
1312
|
|
|
1313
|
+
// src/ser-des/config/correspondence.ts
|
|
1314
|
+
function parseCorresponds(t, i, stripWrapping2) {
|
|
1315
|
+
if (t[i] === void 0) {
|
|
1316
|
+
throw new Error(
|
|
1317
|
+
"Parsing error: corresponds: Expecting value for corresponds (the scheme and the concept)"
|
|
1318
|
+
);
|
|
1319
|
+
}
|
|
1320
|
+
const scheme = stripWrapping2(t[i++]);
|
|
1321
|
+
if (t[i] === void 0) {
|
|
1322
|
+
throw new Error(
|
|
1323
|
+
"Parsing error: corresponds: Expecting value for corresponds (the concept)"
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
const corr = {
|
|
1327
|
+
scheme,
|
|
1328
|
+
concept: stripWrapping2(t[i++]),
|
|
1329
|
+
projections: []
|
|
1330
|
+
};
|
|
1331
|
+
if (i < t.length && t[i].startsWith("{")) {
|
|
1332
|
+
const block = unwrapBlock(t[i++]);
|
|
1333
|
+
forEachEntry(
|
|
1334
|
+
block,
|
|
1335
|
+
(keyword, value, peek) => {
|
|
1336
|
+
if (keyword === "projection") {
|
|
1337
|
+
const codec = stripWrapping2(value());
|
|
1338
|
+
const entries = [];
|
|
1339
|
+
const next = peek();
|
|
1340
|
+
if (next && next.startsWith("{")) {
|
|
1341
|
+
forEachEntry(
|
|
1342
|
+
unwrapBlock(value()),
|
|
1343
|
+
(k, kv) => {
|
|
1344
|
+
entries.push({ key: k, value: stripWrapping2(kv()) });
|
|
1345
|
+
return true;
|
|
1346
|
+
},
|
|
1347
|
+
{ construct: "corresponds.projection", id: codec }
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
corr.projections.push({ codec, entries });
|
|
1351
|
+
return true;
|
|
1352
|
+
}
|
|
1353
|
+
return false;
|
|
1354
|
+
},
|
|
1355
|
+
{ construct: "corresponds", id: corr.scheme }
|
|
1356
|
+
);
|
|
1357
|
+
}
|
|
1358
|
+
return { corr, next: i };
|
|
1359
|
+
}
|
|
1360
|
+
function parseCorrespondsFromReaders(value, peek, stripWrapping2) {
|
|
1361
|
+
const parts = [value(), value()];
|
|
1362
|
+
const next = peek();
|
|
1363
|
+
if (next && next.startsWith("{")) {
|
|
1364
|
+
parts.push(value());
|
|
1365
|
+
}
|
|
1366
|
+
return parseCorresponds(parts, 0, stripWrapping2).corr;
|
|
1367
|
+
}
|
|
1368
|
+
function dumpCorrespondences(corrs, indent, escapeString2, dumpBareSafe2) {
|
|
1369
|
+
if (!corrs || corrs.length === 0) {
|
|
1370
|
+
return "";
|
|
1371
|
+
}
|
|
1372
|
+
let out = "";
|
|
1373
|
+
for (const c of corrs) {
|
|
1374
|
+
out += `${indent}corresponds ${dumpBareSafe2(c.scheme)} "${escapeString2(c.concept)}"`;
|
|
1375
|
+
if (c.projections.length === 0) {
|
|
1376
|
+
out += "\n";
|
|
1377
|
+
continue;
|
|
1378
|
+
}
|
|
1379
|
+
out += " {\n";
|
|
1380
|
+
for (const p of c.projections) {
|
|
1381
|
+
out += `${indent} projection ${dumpBareSafe2(p.codec)} {`;
|
|
1382
|
+
for (const e of p.entries) {
|
|
1383
|
+
out += ` ${dumpBareSafe2(e.key)} ${dumpBareSafe2(e.value)}`;
|
|
1384
|
+
}
|
|
1385
|
+
out += " }\n";
|
|
1386
|
+
}
|
|
1387
|
+
out += `${indent}}
|
|
1388
|
+
`;
|
|
1389
|
+
}
|
|
1390
|
+
return out;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1262
1393
|
// src/ser-des/config/series.ts
|
|
1263
1394
|
function parseSeriesDecl(block) {
|
|
1264
1395
|
const decl = { axes: [], cellSymbol: "", cellUnit: "" };
|
|
@@ -1667,6 +1798,10 @@ function parseFormField(name, block, type) {
|
|
|
1667
1798
|
field.refs.push(r.ref);
|
|
1668
1799
|
}
|
|
1669
1800
|
i = r.next;
|
|
1801
|
+
} else if (cmd === "corresponds") {
|
|
1802
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
1803
|
+
(field.correspondences ??= []).push(cc.corr);
|
|
1804
|
+
i = cc.next;
|
|
1670
1805
|
} else if (cmd === "specification_reference") {
|
|
1671
1806
|
field.specificationReference = stripWrapping(t[i++]);
|
|
1672
1807
|
} else if (cmd === "applicability") {
|
|
@@ -2015,6 +2150,16 @@ function dumpFormField(field, indent) {
|
|
|
2015
2150
|
);
|
|
2016
2151
|
}
|
|
2017
2152
|
}
|
|
2153
|
+
if (field.correspondences && field.correspondences.length > 0) {
|
|
2154
|
+
inner.push(
|
|
2155
|
+
dumpCorrespondences(
|
|
2156
|
+
field.correspondences,
|
|
2157
|
+
"",
|
|
2158
|
+
escapeString,
|
|
2159
|
+
dumpBareSafe
|
|
2160
|
+
).trimEnd()
|
|
2161
|
+
);
|
|
2162
|
+
}
|
|
2018
2163
|
if (field.specificationReference) {
|
|
2019
2164
|
inner.push(
|
|
2020
2165
|
'specification_reference "' + escapeString(field.specificationReference) + '"'
|
|
@@ -2710,6 +2855,10 @@ var parseProcess = function(id, data) {
|
|
|
2710
2855
|
if (!foldRefIntoLegacy(result, r)) {
|
|
2711
2856
|
(result.refs ??= []).push(r);
|
|
2712
2857
|
}
|
|
2858
|
+
} else if (keyword === "corresponds") {
|
|
2859
|
+
(result.correspondences ??= []).push(
|
|
2860
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
2861
|
+
);
|
|
2713
2862
|
} else {
|
|
2714
2863
|
return false;
|
|
2715
2864
|
}
|
|
@@ -2977,6 +3126,12 @@ var dumpProcess = function(process2, ctx) {
|
|
|
2977
3126
|
out += dumpSourceRefAsRef(src, " ", escapeString);
|
|
2978
3127
|
}
|
|
2979
3128
|
out += dumpRefs(process2.refs, " ", escapeString);
|
|
3129
|
+
out += dumpCorrespondences(
|
|
3130
|
+
process2.correspondences,
|
|
3131
|
+
" ",
|
|
3132
|
+
escapeString,
|
|
3133
|
+
dumpBareSafe
|
|
3134
|
+
);
|
|
2980
3135
|
if (process2.parent && (process2.children.length === 0 || !ctx?.nested)) {
|
|
2981
3136
|
out += " parent " + process2.parent + "\n";
|
|
2982
3137
|
}
|
|
@@ -3724,8 +3879,12 @@ var parseTable = function(id, data) {
|
|
|
3724
3879
|
(result.refs ??= []).push(rr.ref);
|
|
3725
3880
|
}
|
|
3726
3881
|
i = rr.next;
|
|
3882
|
+
} else if (command === "corresponds") {
|
|
3883
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
3884
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
3885
|
+
i = cc.next;
|
|
3727
3886
|
} else {
|
|
3728
|
-
i
|
|
3887
|
+
i = skipUnknownValue(t, i, command);
|
|
3729
3888
|
}
|
|
3730
3889
|
} else {
|
|
3731
3890
|
throw new Error(
|
|
@@ -3796,6 +3955,12 @@ var dumpTable = function(t) {
|
|
|
3796
3955
|
if (t.sourceDiscrepancy) {
|
|
3797
3956
|
out += dumpSourceDiscrepancy(t.sourceDiscrepancy, " ") + "\n";
|
|
3798
3957
|
}
|
|
3958
|
+
out += dumpCorrespondences(
|
|
3959
|
+
t.correspondences,
|
|
3960
|
+
" ",
|
|
3961
|
+
escapeString,
|
|
3962
|
+
dumpBareSafe
|
|
3963
|
+
);
|
|
3799
3964
|
if (t.overrides && Object.keys(t.overrides).length > 0) {
|
|
3800
3965
|
out += " overrides { ";
|
|
3801
3966
|
for (const [key, o] of Object.entries(t.overrides)) {
|
|
@@ -4318,6 +4483,10 @@ var parseForm = function(id, data) {
|
|
|
4318
4483
|
result.refs = [...result.refs ?? [], r.ref];
|
|
4319
4484
|
}
|
|
4320
4485
|
i = r.next;
|
|
4486
|
+
} else if (command === "corresponds") {
|
|
4487
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
4488
|
+
result.correspondences = [...result.correspondences ?? [], cc.corr];
|
|
4489
|
+
i = cc.next;
|
|
4321
4490
|
} else if (command === "calculation_context") {
|
|
4322
4491
|
result.calculationContext = parseCalculationContext(
|
|
4323
4492
|
unwrapBlock(t[i++])
|
|
@@ -4610,6 +4779,12 @@ var dumpForm = function(f) {
|
|
|
4610
4779
|
out += " ref " + r.predicate + ' "' + escapeString(r.target) + '"' + (r.note ? ' { note "' + escapeString(r.note) + '" }' : "") + "\n";
|
|
4611
4780
|
}
|
|
4612
4781
|
}
|
|
4782
|
+
out += dumpCorrespondences(
|
|
4783
|
+
f.correspondences,
|
|
4784
|
+
" ",
|
|
4785
|
+
escapeString,
|
|
4786
|
+
dumpBareSafe
|
|
4787
|
+
);
|
|
4613
4788
|
if (f.calculationContext) {
|
|
4614
4789
|
const cc = f.calculationContext;
|
|
4615
4790
|
let line = " calculation_context { ";
|
|
@@ -4882,6 +5057,12 @@ var parseSymbol = function(id, data) {
|
|
|
4882
5057
|
}
|
|
4883
5058
|
return true;
|
|
4884
5059
|
}
|
|
5060
|
+
if (command === "corresponds") {
|
|
5061
|
+
(result.correspondences ??= []).push(
|
|
5062
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
5063
|
+
);
|
|
5064
|
+
return true;
|
|
5065
|
+
}
|
|
4885
5066
|
if (command === "name") {
|
|
4886
5067
|
result.name = unwrapped(value);
|
|
4887
5068
|
} else if (command === "definition") {
|
|
@@ -5032,6 +5213,12 @@ var dumpSymbol = function(s) {
|
|
|
5032
5213
|
}
|
|
5033
5214
|
out += " }\n";
|
|
5034
5215
|
}
|
|
5216
|
+
out += dumpCorrespondences(
|
|
5217
|
+
s.correspondences,
|
|
5218
|
+
" ",
|
|
5219
|
+
escapeString,
|
|
5220
|
+
dumpBareSafe
|
|
5221
|
+
);
|
|
5035
5222
|
out += "}\n";
|
|
5036
5223
|
return out;
|
|
5037
5224
|
};
|
|
@@ -5085,6 +5272,10 @@ var parseCalculation = function(id, data) {
|
|
|
5085
5272
|
(result.refs ??= []).push(rr.ref);
|
|
5086
5273
|
}
|
|
5087
5274
|
i = rr.next;
|
|
5275
|
+
} else if (command === "corresponds") {
|
|
5276
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
5277
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
5278
|
+
i = cc.next;
|
|
5088
5279
|
} else if (command === "source") {
|
|
5089
5280
|
const inner = tokenize(unwrapBlock(t[i++]));
|
|
5090
5281
|
const src = {
|
|
@@ -5356,6 +5547,12 @@ var dumpCalculation = function(c) {
|
|
|
5356
5547
|
for (const r of c.refs ?? []) {
|
|
5357
5548
|
out += " ref " + r.predicate + ' "' + escapeString(r.target) + '"' + (r.note ? ' { note "' + escapeString(r.note) + '" }' : "") + "\n";
|
|
5358
5549
|
}
|
|
5550
|
+
out += dumpCorrespondences(
|
|
5551
|
+
c.correspondences,
|
|
5552
|
+
" ",
|
|
5553
|
+
escapeString,
|
|
5554
|
+
dumpBareSafe
|
|
5555
|
+
);
|
|
5359
5556
|
if (c.ref.length > 0) {
|
|
5360
5557
|
out += " reference {\n";
|
|
5361
5558
|
for (const r of c.ref) {
|
|
@@ -6641,8 +6838,12 @@ var parseCompetenceKind = function(id, data) {
|
|
|
6641
6838
|
(result.refs ??= []).push(rr.ref);
|
|
6642
6839
|
}
|
|
6643
6840
|
i = rr.next;
|
|
6841
|
+
} else if (keyword === "corresponds") {
|
|
6842
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
6843
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
6844
|
+
i = cc.next;
|
|
6644
6845
|
} else {
|
|
6645
|
-
i
|
|
6846
|
+
i = skipUnknownValue(t, i, keyword);
|
|
6646
6847
|
}
|
|
6647
6848
|
}
|
|
6648
6849
|
return (ctx) => {
|
|
@@ -6664,6 +6865,12 @@ var dumpCompetenceKind = function(k) {
|
|
|
6664
6865
|
for (const ms of k.methodStandards) {
|
|
6665
6866
|
out += " method_standard " + ms.id + ' "' + escapeString(ms.title) + '"\n';
|
|
6666
6867
|
}
|
|
6868
|
+
out += dumpCorrespondences(
|
|
6869
|
+
k.correspondences,
|
|
6870
|
+
" ",
|
|
6871
|
+
escapeString,
|
|
6872
|
+
dumpBareSafe
|
|
6873
|
+
);
|
|
6667
6874
|
out += "}\n";
|
|
6668
6875
|
return out;
|
|
6669
6876
|
};
|
|
@@ -7108,6 +7315,10 @@ var parseConformanceTest = function(id, data) {
|
|
|
7108
7315
|
if (!foldRefIntoLegacy(result, rr)) {
|
|
7109
7316
|
(result.refs ??= []).push(rr);
|
|
7110
7317
|
}
|
|
7318
|
+
} else if (keyword === "corresponds") {
|
|
7319
|
+
(result.correspondences ??= []).push(
|
|
7320
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
7321
|
+
);
|
|
7111
7322
|
} else if (keyword === "binds_to") {
|
|
7112
7323
|
result.bindsTo = tokenizePackage(value());
|
|
7113
7324
|
} else if (keyword === "applicability") {
|
|
@@ -7466,6 +7677,12 @@ var dumpConformanceTest = function(ct) {
|
|
|
7466
7677
|
if (ct.sourceDiscrepancy) {
|
|
7467
7678
|
out += dumpSourceDiscrepancy(ct.sourceDiscrepancy, " ") + "\n";
|
|
7468
7679
|
}
|
|
7680
|
+
out += dumpCorrespondences(
|
|
7681
|
+
ct.correspondences,
|
|
7682
|
+
" ",
|
|
7683
|
+
escapeString,
|
|
7684
|
+
dumpBareSafe
|
|
7685
|
+
);
|
|
7469
7686
|
out += "}\n";
|
|
7470
7687
|
return out;
|
|
7471
7688
|
};
|
|
@@ -7494,6 +7711,12 @@ var parseTerm = function(id, data) {
|
|
|
7494
7711
|
}
|
|
7495
7712
|
return true;
|
|
7496
7713
|
}
|
|
7714
|
+
if (command === "corresponds") {
|
|
7715
|
+
(result.correspondences ??= []).push(
|
|
7716
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
7717
|
+
);
|
|
7718
|
+
return true;
|
|
7719
|
+
}
|
|
7497
7720
|
if (command === "label") {
|
|
7498
7721
|
result.label = unwrapped(value);
|
|
7499
7722
|
} else if (command === "definition") {
|
|
@@ -7613,6 +7836,12 @@ var dumpTerm = function(term) {
|
|
|
7613
7836
|
}
|
|
7614
7837
|
out += " }\n";
|
|
7615
7838
|
}
|
|
7839
|
+
out += dumpCorrespondences(
|
|
7840
|
+
term.correspondences,
|
|
7841
|
+
" ",
|
|
7842
|
+
escapeString,
|
|
7843
|
+
dumpBareSafe
|
|
7844
|
+
);
|
|
7616
7845
|
out += "}\n";
|
|
7617
7846
|
return out;
|
|
7618
7847
|
};
|
|
@@ -7689,6 +7918,10 @@ var parseVerdict = function(id, data) {
|
|
|
7689
7918
|
if (!foldRefIntoLegacy(result, r)) {
|
|
7690
7919
|
(result.refs ??= []).push(r);
|
|
7691
7920
|
}
|
|
7921
|
+
} else if (keyword === "corresponds") {
|
|
7922
|
+
(result.correspondences ??= []).push(
|
|
7923
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
7924
|
+
);
|
|
7692
7925
|
} else {
|
|
7693
7926
|
return false;
|
|
7694
7927
|
}
|
|
@@ -7733,6 +7966,12 @@ var dumpVerdict = function(v) {
|
|
|
7733
7966
|
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
7734
7967
|
}
|
|
7735
7968
|
out += dumpRefs(v.refs, " ", escapeString);
|
|
7969
|
+
out += dumpCorrespondences(
|
|
7970
|
+
v.correspondences,
|
|
7971
|
+
" ",
|
|
7972
|
+
escapeString,
|
|
7973
|
+
dumpBareSafe
|
|
7974
|
+
);
|
|
7736
7975
|
out += "}\n";
|
|
7737
7976
|
return out;
|
|
7738
7977
|
};
|
|
@@ -7902,6 +8141,10 @@ var parseReferenceMaterial = function(id, data) {
|
|
|
7902
8141
|
if (!foldRefIntoLegacy(result, r)) {
|
|
7903
8142
|
(result.refs ??= []).push(r);
|
|
7904
8143
|
}
|
|
8144
|
+
} else if (keyword === "corresponds") {
|
|
8145
|
+
(result.correspondences ??= []).push(
|
|
8146
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
8147
|
+
);
|
|
7905
8148
|
} else if (keyword === "identity_fields") {
|
|
7906
8149
|
result.identityFields = parseIdentityFields(unwrapBlock(value()));
|
|
7907
8150
|
} else if (keyword === "constraints") {
|
|
@@ -7934,6 +8177,12 @@ var dumpReferenceMaterial = function(m) {
|
|
|
7934
8177
|
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
7935
8178
|
}
|
|
7936
8179
|
out += dumpRefs(m.refs, " ", escapeString);
|
|
8180
|
+
out += dumpCorrespondences(
|
|
8181
|
+
m.correspondences,
|
|
8182
|
+
" ",
|
|
8183
|
+
escapeString,
|
|
8184
|
+
dumpBareSafe
|
|
8185
|
+
);
|
|
7937
8186
|
if (m.identityFields.length > 0) {
|
|
7938
8187
|
out += " identity_fields {\n";
|
|
7939
8188
|
for (const f of m.identityFields) {
|
|
@@ -8122,8 +8371,12 @@ var parseConstraint = function(id, data) {
|
|
|
8122
8371
|
(result.refs ??= []).push(rr.ref);
|
|
8123
8372
|
}
|
|
8124
8373
|
i = rr.next;
|
|
8374
|
+
} else if (keyword === "corresponds") {
|
|
8375
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
8376
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
8377
|
+
i = cc.next;
|
|
8125
8378
|
} else {
|
|
8126
|
-
i
|
|
8379
|
+
i = skipUnknownValue(t, i, keyword);
|
|
8127
8380
|
}
|
|
8128
8381
|
}
|
|
8129
8382
|
return (ctx) => {
|
|
@@ -8149,6 +8402,12 @@ var dumpConstraint = function(c) {
|
|
|
8149
8402
|
if (c.source && (c.source.doc || c.source.clause)) {
|
|
8150
8403
|
out += ' source { doc "' + escapeString(c.source.doc) + '" clause "' + escapeString(c.source.clause) + '"' + (c.source.fragment ? ' fragment "' + escapeString(c.source.fragment) + '"' : "") + " }\n";
|
|
8151
8404
|
}
|
|
8405
|
+
out += dumpCorrespondences(
|
|
8406
|
+
c.correspondences,
|
|
8407
|
+
" ",
|
|
8408
|
+
escapeString,
|
|
8409
|
+
dumpBareSafe
|
|
8410
|
+
);
|
|
8152
8411
|
out += "}\n";
|
|
8153
8412
|
return out;
|
|
8154
8413
|
};
|
|
@@ -8334,6 +8593,10 @@ var parseTestPointSet = function(id, data) {
|
|
|
8334
8593
|
if (!foldRefIntoLegacy(result, r)) {
|
|
8335
8594
|
(result.refs ??= []).push(r);
|
|
8336
8595
|
}
|
|
8596
|
+
} else if (keyword === "corresponds") {
|
|
8597
|
+
(result.correspondences ??= []).push(
|
|
8598
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
8599
|
+
);
|
|
8337
8600
|
} else if (keyword === "cardinality") {
|
|
8338
8601
|
result.cardinality = parseCardinality(unwrapBlock(value()));
|
|
8339
8602
|
} else if (keyword === "repetitions_per_point") {
|
|
@@ -8362,6 +8625,12 @@ var dumpTestPointSet = function(s) {
|
|
|
8362
8625
|
out += dumpSourceRefAsRef(src, " ", escapeString);
|
|
8363
8626
|
}
|
|
8364
8627
|
out += dumpRefs(s.refs, " ", escapeString);
|
|
8628
|
+
out += dumpCorrespondences(
|
|
8629
|
+
s.correspondences,
|
|
8630
|
+
" ",
|
|
8631
|
+
escapeString,
|
|
8632
|
+
dumpBareSafe
|
|
8633
|
+
);
|
|
8365
8634
|
const ckeys = Object.keys(s.cardinality);
|
|
8366
8635
|
if (ckeys.length > 0) {
|
|
8367
8636
|
out += " cardinality {\n";
|
|
@@ -8667,6 +8936,10 @@ var parseRequirement = function(id, data) {
|
|
|
8667
8936
|
(result.refs ??= []).push(r.ref);
|
|
8668
8937
|
}
|
|
8669
8938
|
i = r.next;
|
|
8939
|
+
} else if (cmd === "corresponds") {
|
|
8940
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
8941
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
8942
|
+
i = cc.next;
|
|
8670
8943
|
} else {
|
|
8671
8944
|
i = skipUnknownValue(t, i, cmd);
|
|
8672
8945
|
}
|
|
@@ -8811,6 +9084,12 @@ var dumpRequirement = function(r) {
|
|
|
8811
9084
|
for (const ref of r.refs ?? []) {
|
|
8812
9085
|
out += " ref " + ref.predicate + ' "' + escapeString(ref.target) + '"' + (ref.note ? ' { note "' + escapeString(ref.note) + '" }' : "") + "\n";
|
|
8813
9086
|
}
|
|
9087
|
+
out += dumpCorrespondences(
|
|
9088
|
+
r.correspondences,
|
|
9089
|
+
" ",
|
|
9090
|
+
escapeString,
|
|
9091
|
+
dumpBareSafe
|
|
9092
|
+
);
|
|
8814
9093
|
out += "}\n";
|
|
8815
9094
|
return out;
|
|
8816
9095
|
};
|
|
@@ -8994,6 +9273,10 @@ var parsePackage = function(data) {
|
|
|
8994
9273
|
(manifest.refs ??= []).push(r.ref);
|
|
8995
9274
|
}
|
|
8996
9275
|
i = r.next;
|
|
9276
|
+
} else if (cmd === "corresponds") {
|
|
9277
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
9278
|
+
(manifest.correspondences ??= []).push(cc.corr);
|
|
9279
|
+
i = cc.next;
|
|
8997
9280
|
} else if (cmd === "scheme_type" || cmd === "schemeType") {
|
|
8998
9281
|
manifest.schemeType = stripWrapping(t[i++]);
|
|
8999
9282
|
} else if (cmd === "provides") {
|
|
@@ -9698,6 +9981,10 @@ var parseInstrument = function(id, data) {
|
|
|
9698
9981
|
(result.refs ??= []).push(rr.ref);
|
|
9699
9982
|
}
|
|
9700
9983
|
i = rr.next;
|
|
9984
|
+
} else if (cmd === "corresponds") {
|
|
9985
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
9986
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
9987
|
+
i = cc.next;
|
|
9701
9988
|
} else {
|
|
9702
9989
|
i = skipUnknownValue(t, i, cmd);
|
|
9703
9990
|
}
|
|
@@ -10200,6 +10487,12 @@ var dumpInstrument = function(inst) {
|
|
|
10200
10487
|
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
10201
10488
|
}
|
|
10202
10489
|
out += dumpRefs(inst.refs, " ", escapeString);
|
|
10490
|
+
out += dumpCorrespondences(
|
|
10491
|
+
inst.correspondences,
|
|
10492
|
+
" ",
|
|
10493
|
+
escapeString,
|
|
10494
|
+
dumpBareSafe
|
|
10495
|
+
);
|
|
10203
10496
|
out += dumpIdList("reference", inst.referenceIds, " ");
|
|
10204
10497
|
out += "}\n";
|
|
10205
10498
|
return out;
|
|
@@ -10272,6 +10565,10 @@ var parseAttributeDefinition = function(id, data) {
|
|
|
10272
10565
|
(result.refs ??= []).push(rr.ref);
|
|
10273
10566
|
}
|
|
10274
10567
|
i = rr.next;
|
|
10568
|
+
} else if (cmd === "corresponds") {
|
|
10569
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
10570
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
10571
|
+
i = cc.next;
|
|
10275
10572
|
} else {
|
|
10276
10573
|
i = skipUnknownValue(t, i, cmd);
|
|
10277
10574
|
}
|
|
@@ -10297,6 +10594,12 @@ var dumpAttributeDefinition = function(a) {
|
|
|
10297
10594
|
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
10298
10595
|
}
|
|
10299
10596
|
out += dumpRefs(a.refs, " ", escapeString);
|
|
10597
|
+
out += dumpCorrespondences(
|
|
10598
|
+
a.correspondences,
|
|
10599
|
+
" ",
|
|
10600
|
+
escapeString,
|
|
10601
|
+
dumpBareSafe
|
|
10602
|
+
);
|
|
10300
10603
|
if (a.quantityKind) {
|
|
10301
10604
|
out += " quantity_kind " + a.quantityKind + "\n";
|
|
10302
10605
|
}
|
|
@@ -10374,6 +10677,10 @@ var parseCapability = function(id, data) {
|
|
|
10374
10677
|
(result.refs ??= []).push(rr.ref);
|
|
10375
10678
|
}
|
|
10376
10679
|
i = rr.next;
|
|
10680
|
+
} else if (cmd === "corresponds") {
|
|
10681
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
10682
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
10683
|
+
i = cc.next;
|
|
10377
10684
|
} else {
|
|
10378
10685
|
i = skipUnknownValue(t, i, cmd);
|
|
10379
10686
|
}
|
|
@@ -10401,6 +10708,12 @@ var dumpCapability = function(c) {
|
|
|
10401
10708
|
out += dumpIdList("verified_by_tests", c.verifiedByTests, " ");
|
|
10402
10709
|
out += dumpIdList("reference", c.referenceIds, " ");
|
|
10403
10710
|
out += dumpRefs(c.refs, " ", escapeString);
|
|
10711
|
+
out += dumpCorrespondences(
|
|
10712
|
+
c.correspondences,
|
|
10713
|
+
" ",
|
|
10714
|
+
escapeString,
|
|
10715
|
+
dumpBareSafe
|
|
10716
|
+
);
|
|
10404
10717
|
out += "}\n";
|
|
10405
10718
|
return out;
|
|
10406
10719
|
};
|
|
@@ -10441,6 +10754,10 @@ var parseBehavior = function(id, data) {
|
|
|
10441
10754
|
(result.refs ??= []).push(rr.ref);
|
|
10442
10755
|
}
|
|
10443
10756
|
i = rr.next;
|
|
10757
|
+
} else if (cmd === "corresponds") {
|
|
10758
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
10759
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
10760
|
+
i = cc.next;
|
|
10444
10761
|
} else {
|
|
10445
10762
|
i = skipUnknownValue(t, i, cmd);
|
|
10446
10763
|
}
|
|
@@ -10466,6 +10783,12 @@ var dumpBehavior = function(b) {
|
|
|
10466
10783
|
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
10467
10784
|
}
|
|
10468
10785
|
out += dumpRefs(b.refs, " ", escapeString);
|
|
10786
|
+
out += dumpCorrespondences(
|
|
10787
|
+
b.correspondences,
|
|
10788
|
+
" ",
|
|
10789
|
+
escapeString,
|
|
10790
|
+
dumpBareSafe
|
|
10791
|
+
);
|
|
10469
10792
|
out += dumpIdList("verified_by", b.verifiedBy, " ");
|
|
10470
10793
|
out += "}\n";
|
|
10471
10794
|
return out;
|
|
@@ -10518,6 +10841,10 @@ var parseConditionSet = function(id, data) {
|
|
|
10518
10841
|
} else {
|
|
10519
10842
|
(result.refs ??= []).push(rr.ref);
|
|
10520
10843
|
}
|
|
10844
|
+
} else if (cmd === "corresponds") {
|
|
10845
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
10846
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
10847
|
+
i = cc.next;
|
|
10521
10848
|
} else if (cmd === "reference") {
|
|
10522
10849
|
result.referenceIds = readReference(t[i++]);
|
|
10523
10850
|
} else {
|
|
@@ -10604,6 +10931,12 @@ var dumpConditionSet = function(cs) {
|
|
|
10604
10931
|
}
|
|
10605
10932
|
out += dumpIdList("reference", cs.referenceIds, " ");
|
|
10606
10933
|
out += dumpRefs(cs.refs, " ", escapeString);
|
|
10934
|
+
out += dumpCorrespondences(
|
|
10935
|
+
cs.correspondences,
|
|
10936
|
+
" ",
|
|
10937
|
+
escapeString,
|
|
10938
|
+
dumpBareSafe
|
|
10939
|
+
);
|
|
10607
10940
|
out += "}\n";
|
|
10608
10941
|
return out;
|
|
10609
10942
|
};
|
|
@@ -11599,6 +11932,10 @@ var parseArtifactDefinition = function(id, data) {
|
|
|
11599
11932
|
(result.refs ??= []).push(rr.ref);
|
|
11600
11933
|
}
|
|
11601
11934
|
i = rr.next;
|
|
11935
|
+
} else if (cmd === "corresponds") {
|
|
11936
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
11937
|
+
(result.correspondences ??= []).push(cc.corr);
|
|
11938
|
+
i = cc.next;
|
|
11602
11939
|
} else {
|
|
11603
11940
|
i = skipUnknownValue(t, i, cmd);
|
|
11604
11941
|
}
|
|
@@ -11666,6 +12003,12 @@ var dumpArtifactDefinition = function(d) {
|
|
|
11666
12003
|
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
11667
12004
|
}
|
|
11668
12005
|
out += dumpRefs(d.refs, " ", escapeString);
|
|
12006
|
+
out += dumpCorrespondences(
|
|
12007
|
+
d.correspondences,
|
|
12008
|
+
" ",
|
|
12009
|
+
escapeString,
|
|
12010
|
+
dumpBareSafe
|
|
12011
|
+
);
|
|
11669
12012
|
out += dumpIdList2("reference", d.referenceIds, " ");
|
|
11670
12013
|
out += "}\n";
|
|
11671
12014
|
return out;
|
|
@@ -12257,6 +12600,10 @@ var parseTestSequence = function(id, data) {
|
|
|
12257
12600
|
sequence.refs = [...sequence.refs ?? [], rr.ref];
|
|
12258
12601
|
}
|
|
12259
12602
|
i = rr.next;
|
|
12603
|
+
} else if (command === "corresponds") {
|
|
12604
|
+
const cc = parseCorresponds(t, i, stripWrapping);
|
|
12605
|
+
sequence.correspondences = [...sequence.correspondences ?? [], cc.corr];
|
|
12606
|
+
i = cc.next;
|
|
12260
12607
|
} else if (command === "source") {
|
|
12261
12608
|
sequence.sourceRefs.push(readSource(unwrapBlock(t[i++])));
|
|
12262
12609
|
} else if (command === "step") {
|
|
@@ -12318,6 +12665,12 @@ var dumpTestSequence = function(seq) {
|
|
|
12318
12665
|
for (const src of seq.sourceRefs) {
|
|
12319
12666
|
out += dumpSourceRefAsRef(src, " ", escapeString);
|
|
12320
12667
|
}
|
|
12668
|
+
out += dumpCorrespondences(
|
|
12669
|
+
seq.correspondences,
|
|
12670
|
+
" ",
|
|
12671
|
+
escapeString,
|
|
12672
|
+
dumpBareSafe
|
|
12673
|
+
);
|
|
12321
12674
|
out += "}\n";
|
|
12322
12675
|
return out;
|
|
12323
12676
|
};
|
|
@@ -12352,6 +12705,10 @@ var parseFormulasUsed = function(id, data) {
|
|
|
12352
12705
|
if (!foldRefIntoLegacy(trace, r)) {
|
|
12353
12706
|
(trace.refs ??= []).push(r);
|
|
12354
12707
|
}
|
|
12708
|
+
} else if (command === "corresponds") {
|
|
12709
|
+
(trace.correspondences ??= []).push(
|
|
12710
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
12711
|
+
);
|
|
12355
12712
|
} else if (command === "source") {
|
|
12356
12713
|
trace.sourceRefs.push(readSource(unwrapBlock(value())));
|
|
12357
12714
|
} else {
|
|
@@ -12383,6 +12740,12 @@ var dumpFormulasUsed = function(fu) {
|
|
|
12383
12740
|
for (const src of fu.sourceRefs) {
|
|
12384
12741
|
out += dumpSourceRefAsRef(src, " ", escapeString);
|
|
12385
12742
|
}
|
|
12743
|
+
out += dumpCorrespondences(
|
|
12744
|
+
fu.correspondences,
|
|
12745
|
+
" ",
|
|
12746
|
+
escapeString,
|
|
12747
|
+
dumpBareSafe
|
|
12748
|
+
);
|
|
12386
12749
|
out += "}\n";
|
|
12387
12750
|
return out;
|
|
12388
12751
|
};
|
|
@@ -12675,6 +13038,392 @@ var dualConstruct = {
|
|
|
12675
13038
|
dump: dumpDual
|
|
12676
13039
|
};
|
|
12677
13040
|
|
|
13041
|
+
// src/ser-des/config/trustRef.ts
|
|
13042
|
+
function parseTrustRefFromReaders(value, peek, stripWrapping2) {
|
|
13043
|
+
const ref = { org: stripWrapping2(value()), kid: "" };
|
|
13044
|
+
if (peek() === "key") {
|
|
13045
|
+
value();
|
|
13046
|
+
ref.kid = stripWrapping2(value());
|
|
13047
|
+
}
|
|
13048
|
+
return ref;
|
|
13049
|
+
}
|
|
13050
|
+
function dumpTrustRef(ref, indent, dumpBareSafe2) {
|
|
13051
|
+
let out = `${indent}trust_ref ${dumpBareSafe2(ref.org)}`;
|
|
13052
|
+
if (ref.kid !== "") {
|
|
13053
|
+
out += ` key ${dumpBareSafe2(ref.kid)}`;
|
|
13054
|
+
}
|
|
13055
|
+
return out + "\n";
|
|
13056
|
+
}
|
|
13057
|
+
|
|
13058
|
+
// src/ser-des/config/dataspace.ts
|
|
13059
|
+
var parseDataspace = function(id, data) {
|
|
13060
|
+
const ds = {
|
|
13061
|
+
id,
|
|
13062
|
+
name: "",
|
|
13063
|
+
description: "",
|
|
13064
|
+
participantClasses: [],
|
|
13065
|
+
artifactClasses: [],
|
|
13066
|
+
policies: [],
|
|
13067
|
+
defaultPolicy: "",
|
|
13068
|
+
trustAnchors: [],
|
|
13069
|
+
compatibleWith: [],
|
|
13070
|
+
source: null,
|
|
13071
|
+
sourceRefs: []
|
|
13072
|
+
};
|
|
13073
|
+
forEachEntry(
|
|
13074
|
+
data,
|
|
13075
|
+
(command, value, peek) => {
|
|
13076
|
+
if (command === "name") {
|
|
13077
|
+
ds.name = unwrapped(value);
|
|
13078
|
+
} else if (command === "description") {
|
|
13079
|
+
ds.description = unwrapped(value);
|
|
13080
|
+
} else if (command === "participant_class") {
|
|
13081
|
+
const pc = {
|
|
13082
|
+
id: stripWrapping(value()),
|
|
13083
|
+
label: "",
|
|
13084
|
+
description: ""
|
|
13085
|
+
};
|
|
13086
|
+
const next = peek();
|
|
13087
|
+
if (next && next.startsWith("{")) {
|
|
13088
|
+
forEachEntry(
|
|
13089
|
+
unwrapBlock(value()),
|
|
13090
|
+
(facet, facetValue) => {
|
|
13091
|
+
if (facet === "label") {
|
|
13092
|
+
pc.label = unwrapped(facetValue);
|
|
13093
|
+
} else if (facet === "description") {
|
|
13094
|
+
pc.description = unwrapped(facetValue);
|
|
13095
|
+
} else {
|
|
13096
|
+
return false;
|
|
13097
|
+
}
|
|
13098
|
+
return true;
|
|
13099
|
+
},
|
|
13100
|
+
{ construct: "dataspace.participant_class", id: pc.id }
|
|
13101
|
+
);
|
|
13102
|
+
}
|
|
13103
|
+
ds.participantClasses.push(pc);
|
|
13104
|
+
} else if (command === "artifact_class") {
|
|
13105
|
+
const ac = {
|
|
13106
|
+
id: stripWrapping(value()),
|
|
13107
|
+
label: "",
|
|
13108
|
+
description: "",
|
|
13109
|
+
element: "",
|
|
13110
|
+
policy: ""
|
|
13111
|
+
};
|
|
13112
|
+
const next = peek();
|
|
13113
|
+
if (next && next.startsWith("{")) {
|
|
13114
|
+
forEachEntry(
|
|
13115
|
+
unwrapBlock(value()),
|
|
13116
|
+
(facet, facetValue) => {
|
|
13117
|
+
if (facet === "label") {
|
|
13118
|
+
ac.label = unwrapped(facetValue);
|
|
13119
|
+
} else if (facet === "description") {
|
|
13120
|
+
ac.description = unwrapped(facetValue);
|
|
13121
|
+
} else if (facet === "element") {
|
|
13122
|
+
ac.element = stripWrapping(facetValue());
|
|
13123
|
+
} else if (facet === "policy") {
|
|
13124
|
+
ac.policy = stripWrapping(facetValue());
|
|
13125
|
+
} else {
|
|
13126
|
+
return false;
|
|
13127
|
+
}
|
|
13128
|
+
return true;
|
|
13129
|
+
},
|
|
13130
|
+
{ construct: "dataspace.artifact_class", id: ac.id }
|
|
13131
|
+
);
|
|
13132
|
+
}
|
|
13133
|
+
ds.artifactClasses.push(ac);
|
|
13134
|
+
} else if (command === "policies") {
|
|
13135
|
+
ds.policies = readEntryTokens(value());
|
|
13136
|
+
} else if (command === "default_policy") {
|
|
13137
|
+
ds.defaultPolicy = stripWrapping(value());
|
|
13138
|
+
} else if (command === "trust_anchor") {
|
|
13139
|
+
const ta = {
|
|
13140
|
+
id: stripWrapping(value()),
|
|
13141
|
+
trustRef: null,
|
|
13142
|
+
role: "",
|
|
13143
|
+
description: ""
|
|
13144
|
+
};
|
|
13145
|
+
const next = peek();
|
|
13146
|
+
if (next && next.startsWith("{")) {
|
|
13147
|
+
forEachEntry(
|
|
13148
|
+
unwrapBlock(value()),
|
|
13149
|
+
(facet, facetValue, facetPeek) => {
|
|
13150
|
+
if (facet === "trust_ref") {
|
|
13151
|
+
ta.trustRef = parseTrustRefFromReaders(
|
|
13152
|
+
facetValue,
|
|
13153
|
+
facetPeek,
|
|
13154
|
+
stripWrapping
|
|
13155
|
+
);
|
|
13156
|
+
} else if (facet === "role") {
|
|
13157
|
+
ta.role = stripWrapping(facetValue());
|
|
13158
|
+
} else if (facet === "description") {
|
|
13159
|
+
ta.description = unwrapped(facetValue);
|
|
13160
|
+
} else {
|
|
13161
|
+
return false;
|
|
13162
|
+
}
|
|
13163
|
+
return true;
|
|
13164
|
+
},
|
|
13165
|
+
{ construct: "dataspace.trust_anchor", id: ta.id }
|
|
13166
|
+
);
|
|
13167
|
+
}
|
|
13168
|
+
ds.trustAnchors.push(ta);
|
|
13169
|
+
} else if (command === "compatible_with") {
|
|
13170
|
+
ds.compatibleWith = readEntryTokens(value());
|
|
13171
|
+
} else if (command === "source") {
|
|
13172
|
+
const src = readSource(unwrapBlock(value()));
|
|
13173
|
+
ds.sourceRefs.push(src);
|
|
13174
|
+
if (!ds.source) {
|
|
13175
|
+
ds.source = src;
|
|
13176
|
+
}
|
|
13177
|
+
} else if (command === "ref") {
|
|
13178
|
+
const r = parseRefFromReaders(value, peek, stripWrapping, unwrapBlock);
|
|
13179
|
+
if (!foldRefIntoLegacy(ds, r)) {
|
|
13180
|
+
(ds.refs ??= []).push(r);
|
|
13181
|
+
}
|
|
13182
|
+
} else if (command === "corresponds") {
|
|
13183
|
+
(ds.correspondences ??= []).push(
|
|
13184
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
13185
|
+
);
|
|
13186
|
+
} else {
|
|
13187
|
+
return false;
|
|
13188
|
+
}
|
|
13189
|
+
return true;
|
|
13190
|
+
},
|
|
13191
|
+
{ construct: "dataspace", id }
|
|
13192
|
+
);
|
|
13193
|
+
return (ctx) => {
|
|
13194
|
+
ctx.dataspaces[id] = ds;
|
|
13195
|
+
return ctx;
|
|
13196
|
+
};
|
|
13197
|
+
};
|
|
13198
|
+
var dumpDataspace = function(d) {
|
|
13199
|
+
let out = "dataspace " + d.id + " {\n";
|
|
13200
|
+
if (d.name) {
|
|
13201
|
+
out += ' name "' + escapeString(d.name) + '"\n';
|
|
13202
|
+
}
|
|
13203
|
+
if (d.description) {
|
|
13204
|
+
out += ' description "' + escapeString(d.description) + '"\n';
|
|
13205
|
+
}
|
|
13206
|
+
for (const pc of d.participantClasses) {
|
|
13207
|
+
out += " participant_class " + dumpBareSafe(pc.id) + " {\n";
|
|
13208
|
+
if (pc.label) {
|
|
13209
|
+
out += ' label "' + escapeString(pc.label) + '"\n';
|
|
13210
|
+
}
|
|
13211
|
+
if (pc.description) {
|
|
13212
|
+
out += ' description "' + escapeString(pc.description) + '"\n';
|
|
13213
|
+
}
|
|
13214
|
+
out += " }\n";
|
|
13215
|
+
}
|
|
13216
|
+
for (const ac of d.artifactClasses) {
|
|
13217
|
+
out += " artifact_class " + dumpBareSafe(ac.id) + " {\n";
|
|
13218
|
+
if (ac.label) {
|
|
13219
|
+
out += ' label "' + escapeString(ac.label) + '"\n';
|
|
13220
|
+
}
|
|
13221
|
+
if (ac.description) {
|
|
13222
|
+
out += ' description "' + escapeString(ac.description) + '"\n';
|
|
13223
|
+
}
|
|
13224
|
+
if (ac.element) {
|
|
13225
|
+
out += " element " + dumpBareSafe(ac.element) + "\n";
|
|
13226
|
+
}
|
|
13227
|
+
if (ac.policy) {
|
|
13228
|
+
out += " policy " + dumpBareSafe(ac.policy) + "\n";
|
|
13229
|
+
}
|
|
13230
|
+
out += " }\n";
|
|
13231
|
+
}
|
|
13232
|
+
if (d.policies.length > 0) {
|
|
13233
|
+
out += " policies { " + d.policies.map(dumpBareSafe).join(" ") + " }\n";
|
|
13234
|
+
}
|
|
13235
|
+
if (d.defaultPolicy) {
|
|
13236
|
+
out += " default_policy " + dumpBareSafe(d.defaultPolicy) + "\n";
|
|
13237
|
+
}
|
|
13238
|
+
for (const ta of d.trustAnchors) {
|
|
13239
|
+
out += " trust_anchor " + dumpBareSafe(ta.id) + " {\n";
|
|
13240
|
+
if (ta.trustRef) {
|
|
13241
|
+
out += dumpTrustRef(ta.trustRef, " ", dumpBareSafe);
|
|
13242
|
+
}
|
|
13243
|
+
if (ta.role) {
|
|
13244
|
+
out += " role " + dumpBareSafe(ta.role) + "\n";
|
|
13245
|
+
}
|
|
13246
|
+
if (ta.description) {
|
|
13247
|
+
out += ' description "' + escapeString(ta.description) + '"\n';
|
|
13248
|
+
}
|
|
13249
|
+
out += " }\n";
|
|
13250
|
+
}
|
|
13251
|
+
if (d.compatibleWith.length > 0) {
|
|
13252
|
+
out += " compatible_with { " + d.compatibleWith.map(dumpBareSafe).join(" ") + " }\n";
|
|
13253
|
+
}
|
|
13254
|
+
const sources = d.sourceRefs && d.sourceRefs.length > 0 ? d.sourceRefs : d.source ? [d.source] : [];
|
|
13255
|
+
for (const s of sources) {
|
|
13256
|
+
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
13257
|
+
}
|
|
13258
|
+
out += dumpRefs(d.refs, " ", escapeString);
|
|
13259
|
+
out += dumpCorrespondences(
|
|
13260
|
+
d.correspondences,
|
|
13261
|
+
" ",
|
|
13262
|
+
escapeString,
|
|
13263
|
+
dumpBareSafe
|
|
13264
|
+
);
|
|
13265
|
+
out += "}\n";
|
|
13266
|
+
return out;
|
|
13267
|
+
};
|
|
13268
|
+
var dataspaceConstruct = {
|
|
13269
|
+
keyword: "dataspace",
|
|
13270
|
+
field: "dataspaces",
|
|
13271
|
+
takesID: true,
|
|
13272
|
+
parse: parseDataspace,
|
|
13273
|
+
dump: dumpDataspace
|
|
13274
|
+
};
|
|
13275
|
+
|
|
13276
|
+
// src/types/Policy.ts
|
|
13277
|
+
var POLICY_RULE_KINDS = [
|
|
13278
|
+
"permission",
|
|
13279
|
+
"obligation",
|
|
13280
|
+
"prohibition"
|
|
13281
|
+
];
|
|
13282
|
+
|
|
13283
|
+
// src/ser-des/config/policy.ts
|
|
13284
|
+
var parsePolicy = function(id, data) {
|
|
13285
|
+
const policy = {
|
|
13286
|
+
id,
|
|
13287
|
+
name: "",
|
|
13288
|
+
description: "",
|
|
13289
|
+
governs: [],
|
|
13290
|
+
defaultPosture: null,
|
|
13291
|
+
rules: [],
|
|
13292
|
+
source: null,
|
|
13293
|
+
sourceRefs: []
|
|
13294
|
+
};
|
|
13295
|
+
forEachEntry(
|
|
13296
|
+
data,
|
|
13297
|
+
(command, value, peek) => {
|
|
13298
|
+
if (command === "name") {
|
|
13299
|
+
policy.name = unwrapped(value);
|
|
13300
|
+
} else if (command === "description") {
|
|
13301
|
+
policy.description = unwrapped(value);
|
|
13302
|
+
} else if (command === "governs") {
|
|
13303
|
+
policy.governs = readEntryTokens(value());
|
|
13304
|
+
} else if (command === "default_posture") {
|
|
13305
|
+
const v = stripWrapping(value());
|
|
13306
|
+
if (v !== "true" && v !== "false") {
|
|
13307
|
+
throw new Error(
|
|
13308
|
+
`Parsing error: policy. ID ${id}: default_posture is true | false, got "${v}"`
|
|
13309
|
+
);
|
|
13310
|
+
}
|
|
13311
|
+
policy.defaultPosture = v === "true";
|
|
13312
|
+
} else if (command === "rule") {
|
|
13313
|
+
const rule = {
|
|
13314
|
+
id: stripWrapping(value()),
|
|
13315
|
+
kind: "",
|
|
13316
|
+
action: "",
|
|
13317
|
+
artifact: "",
|
|
13318
|
+
constraints: []
|
|
13319
|
+
};
|
|
13320
|
+
const next = peek();
|
|
13321
|
+
if (next && next.startsWith("{")) {
|
|
13322
|
+
forEachEntry(
|
|
13323
|
+
unwrapBlock(value()),
|
|
13324
|
+
(facet, facetValue) => {
|
|
13325
|
+
if (facet === "kind") {
|
|
13326
|
+
const k = stripWrapping(facetValue());
|
|
13327
|
+
if (!POLICY_RULE_KINDS.includes(k)) {
|
|
13328
|
+
throw new Error(
|
|
13329
|
+
`Parsing error: policy.rule. ID ${rule.id}: unknown rule kind "${k}" \u2014 rule kinds are ${POLICY_RULE_KINDS.join(" | ")} (fail-closed: a misspelt kind never parses into a rule that says nothing)`
|
|
13330
|
+
);
|
|
13331
|
+
}
|
|
13332
|
+
rule.kind = k;
|
|
13333
|
+
} else if (facet === "action") {
|
|
13334
|
+
rule.action = stripWrapping(facetValue());
|
|
13335
|
+
} else if (facet === "artifact") {
|
|
13336
|
+
rule.artifact = stripWrapping(facetValue());
|
|
13337
|
+
} else if (facet === "constraint") {
|
|
13338
|
+
rule.constraints.push(unwrapped(facetValue));
|
|
13339
|
+
} else {
|
|
13340
|
+
return false;
|
|
13341
|
+
}
|
|
13342
|
+
return true;
|
|
13343
|
+
},
|
|
13344
|
+
{ construct: "policy.rule", id: rule.id }
|
|
13345
|
+
);
|
|
13346
|
+
}
|
|
13347
|
+
policy.rules.push(rule);
|
|
13348
|
+
} else if (command === "source") {
|
|
13349
|
+
const src = readSource(unwrapBlock(value()));
|
|
13350
|
+
policy.sourceRefs.push(src);
|
|
13351
|
+
if (!policy.source) {
|
|
13352
|
+
policy.source = src;
|
|
13353
|
+
}
|
|
13354
|
+
} else if (command === "ref") {
|
|
13355
|
+
const r = parseRefFromReaders(value, peek, stripWrapping, unwrapBlock);
|
|
13356
|
+
if (!foldRefIntoLegacy(policy, r)) {
|
|
13357
|
+
(policy.refs ??= []).push(r);
|
|
13358
|
+
}
|
|
13359
|
+
} else if (command === "corresponds") {
|
|
13360
|
+
(policy.correspondences ??= []).push(
|
|
13361
|
+
parseCorrespondsFromReaders(value, peek, stripWrapping)
|
|
13362
|
+
);
|
|
13363
|
+
} else {
|
|
13364
|
+
return false;
|
|
13365
|
+
}
|
|
13366
|
+
return true;
|
|
13367
|
+
},
|
|
13368
|
+
{ construct: "policy", id }
|
|
13369
|
+
);
|
|
13370
|
+
return (ctx) => {
|
|
13371
|
+
ctx.policies[id] = policy;
|
|
13372
|
+
return ctx;
|
|
13373
|
+
};
|
|
13374
|
+
};
|
|
13375
|
+
var dumpPolicy = function(p) {
|
|
13376
|
+
let out = "policy " + p.id + " {\n";
|
|
13377
|
+
if (p.name) {
|
|
13378
|
+
out += ' name "' + escapeString(p.name) + '"\n';
|
|
13379
|
+
}
|
|
13380
|
+
if (p.description) {
|
|
13381
|
+
out += ' description "' + escapeString(p.description) + '"\n';
|
|
13382
|
+
}
|
|
13383
|
+
if (p.defaultPosture !== null) {
|
|
13384
|
+
out += " default_posture " + (p.defaultPosture ? "true" : "false") + "\n";
|
|
13385
|
+
}
|
|
13386
|
+
if (p.governs.length > 0) {
|
|
13387
|
+
out += " governs { " + p.governs.map(dumpBareSafe).join(" ") + " }\n";
|
|
13388
|
+
}
|
|
13389
|
+
for (const r of p.rules) {
|
|
13390
|
+
out += " rule " + dumpBareSafe(r.id) + " {\n";
|
|
13391
|
+
if (r.kind) {
|
|
13392
|
+
out += " kind " + r.kind + "\n";
|
|
13393
|
+
}
|
|
13394
|
+
if (r.action) {
|
|
13395
|
+
out += " action " + dumpBareSafe(r.action) + "\n";
|
|
13396
|
+
}
|
|
13397
|
+
if (r.artifact) {
|
|
13398
|
+
out += " artifact " + dumpBareSafe(r.artifact) + "\n";
|
|
13399
|
+
}
|
|
13400
|
+
for (const c of r.constraints) {
|
|
13401
|
+
out += ' constraint "' + escapeString(c) + '"\n';
|
|
13402
|
+
}
|
|
13403
|
+
out += " }\n";
|
|
13404
|
+
}
|
|
13405
|
+
const sources = p.sourceRefs && p.sourceRefs.length > 0 ? p.sourceRefs : p.source ? [p.source] : [];
|
|
13406
|
+
for (const s of sources) {
|
|
13407
|
+
out += dumpSourceRefAsRef(s, " ", escapeString);
|
|
13408
|
+
}
|
|
13409
|
+
out += dumpRefs(p.refs, " ", escapeString);
|
|
13410
|
+
out += dumpCorrespondences(
|
|
13411
|
+
p.correspondences,
|
|
13412
|
+
" ",
|
|
13413
|
+
escapeString,
|
|
13414
|
+
dumpBareSafe
|
|
13415
|
+
);
|
|
13416
|
+
out += "}\n";
|
|
13417
|
+
return out;
|
|
13418
|
+
};
|
|
13419
|
+
var policyConstruct = {
|
|
13420
|
+
keyword: "policy",
|
|
13421
|
+
field: "policies",
|
|
13422
|
+
takesID: true,
|
|
13423
|
+
parse: parsePolicy,
|
|
13424
|
+
dump: dumpPolicy
|
|
13425
|
+
};
|
|
13426
|
+
|
|
12678
13427
|
// src/ser-des/config/activityArchetype.ts
|
|
12679
13428
|
var parseActivityArchetype = (id, data) => {
|
|
12680
13429
|
const archetype = {
|
|
@@ -13084,7 +13833,15 @@ var CONSTRUCTS = [
|
|
|
13084
13833
|
takesID: true,
|
|
13085
13834
|
parse: parseText,
|
|
13086
13835
|
dump: dumpText
|
|
13087
|
-
})
|
|
13836
|
+
}),
|
|
13837
|
+
// Primmel v3.1 dataspace + trust (TODO.primmel/10; MN 114 clause 19):
|
|
13838
|
+
// the dataspace definition as a model object, and the usage-policy set
|
|
13839
|
+
// in Primmel's own policy grammar (ODRL is a codec output, never an
|
|
13840
|
+
// import). The trust_ref form and the corresponds facet are shared
|
|
13841
|
+
// sub-structures (config/trustRef.ts, config/correspondence.ts), not
|
|
13842
|
+
// top-level constructs.
|
|
13843
|
+
dataspaceConstruct,
|
|
13844
|
+
policyConstruct
|
|
13088
13845
|
];
|
|
13089
13846
|
function buildParserConfig(constructs) {
|
|
13090
13847
|
const out = {};
|
|
@@ -13230,6 +13987,55 @@ function packageFiles(dir) {
|
|
|
13230
13987
|
}
|
|
13231
13988
|
return files;
|
|
13232
13989
|
}
|
|
13990
|
+
function countNewlines(text) {
|
|
13991
|
+
let n = 0;
|
|
13992
|
+
for (let i = 0; i < text.length; i++) {
|
|
13993
|
+
if (text.charAt(i) === "\n") {
|
|
13994
|
+
n++;
|
|
13995
|
+
}
|
|
13996
|
+
}
|
|
13997
|
+
return n;
|
|
13998
|
+
}
|
|
13999
|
+
function chunkify(files) {
|
|
14000
|
+
const chunks = [];
|
|
14001
|
+
let offset = 0;
|
|
14002
|
+
let line = 1;
|
|
14003
|
+
for (const f of files) {
|
|
14004
|
+
if (f.role !== "content") {
|
|
14005
|
+
continue;
|
|
14006
|
+
}
|
|
14007
|
+
const text = preprocessIncludes(f.path);
|
|
14008
|
+
chunks.push({ path: f.path, text, start: offset, lineStart: line });
|
|
14009
|
+
offset += text.length + 2;
|
|
14010
|
+
line += countNewlines(text) + 2;
|
|
14011
|
+
}
|
|
14012
|
+
return chunks;
|
|
14013
|
+
}
|
|
14014
|
+
function joinChunks(chunks) {
|
|
14015
|
+
return chunks.map((c) => c.text).join("\n\n");
|
|
14016
|
+
}
|
|
14017
|
+
function mapConstructs(parsed, chunks, packageId) {
|
|
14018
|
+
const out = {};
|
|
14019
|
+
let ci = 0;
|
|
14020
|
+
for (const c of parsed) {
|
|
14021
|
+
while (ci + 1 < chunks.length && c.start.offset >= chunks[ci + 1].start) {
|
|
14022
|
+
ci++;
|
|
14023
|
+
}
|
|
14024
|
+
const chunk = chunks[ci];
|
|
14025
|
+
const local = (p) => ({
|
|
14026
|
+
line: p.line - chunk.lineStart + 1,
|
|
14027
|
+
col: p.col,
|
|
14028
|
+
offset: p.offset - chunk.start
|
|
14029
|
+
});
|
|
14030
|
+
const source = {
|
|
14031
|
+
file: chunk.path,
|
|
14032
|
+
...packageId !== void 0 ? { package: packageId } : {},
|
|
14033
|
+
span: { start: local(c.start), end: local(c.end) }
|
|
14034
|
+
};
|
|
14035
|
+
(out[c.field] ??= {})[c.id] = source;
|
|
14036
|
+
}
|
|
14037
|
+
return out;
|
|
14038
|
+
}
|
|
13233
14039
|
function readPackageManifest(path) {
|
|
13234
14040
|
const manifestPath = join(resolve3(path), "package.primmel");
|
|
13235
14041
|
if (!existsSync2(manifestPath)) {
|
|
@@ -13248,24 +14054,21 @@ function readPackageManifest(path) {
|
|
|
13248
14054
|
}
|
|
13249
14055
|
return manifest;
|
|
13250
14056
|
}
|
|
13251
|
-
function loadPackageInternal(dir, options = {}) {
|
|
14057
|
+
function loadPackageInternal(dir, options = {}, withProvenance = false) {
|
|
13252
14058
|
const files = packageFiles(dir);
|
|
13253
14059
|
if (files.length === 0) {
|
|
13254
14060
|
throw new Error(`loadPackage: no package files found in ${resolve3(dir)}`);
|
|
13255
14061
|
}
|
|
13256
14062
|
let manifest = null;
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
if (f.role === "manifest") {
|
|
13260
|
-
manifest = readPackageManifest(dir);
|
|
13261
|
-
} else {
|
|
13262
|
-
chunks.push(preprocessIncludes(f.path));
|
|
13263
|
-
}
|
|
14063
|
+
if (files.some((f) => f.role === "manifest")) {
|
|
14064
|
+
manifest = readPackageManifest(dir);
|
|
13264
14065
|
}
|
|
14066
|
+
const chunks = chunkify(files);
|
|
13265
14067
|
if (manifest && options.resolvePackage && effectiveUses(manifest).length > 0) {
|
|
13266
|
-
return composePackage(dir, options, manifest);
|
|
14068
|
+
return composePackage(dir, options, manifest, withProvenance);
|
|
13267
14069
|
}
|
|
13268
|
-
const
|
|
14070
|
+
const parseOptions = withProvenance ? { ...options, withProvenance: true } : options;
|
|
14071
|
+
const ctx = parse(joinChunks(chunks), PARSER_CONFIG, parseOptions);
|
|
13269
14072
|
if (manifest) {
|
|
13270
14073
|
ctx.packageManifest = manifest;
|
|
13271
14074
|
const deprecated = extendsDeprecationIssue(manifest);
|
|
@@ -13274,7 +14077,15 @@ function loadPackageInternal(dir, options = {}) {
|
|
|
13274
14077
|
}
|
|
13275
14078
|
}
|
|
13276
14079
|
const standard = resolve(ctx, RESOLVER_CONFIG);
|
|
13277
|
-
|
|
14080
|
+
const result = { standard, issues: ctx.issues };
|
|
14081
|
+
if (withProvenance) {
|
|
14082
|
+
const manifestFile = files.find((f) => f.role === "manifest")?.path;
|
|
14083
|
+
result.provenance = {
|
|
14084
|
+
...manifestFile !== void 0 ? { manifest: manifestFile } : {},
|
|
14085
|
+
constructs: mapConstructs(ctx.constructs ?? [], chunks, manifest?.id)
|
|
14086
|
+
};
|
|
14087
|
+
}
|
|
14088
|
+
return result;
|
|
13278
14089
|
}
|
|
13279
14090
|
function loadPackageWithIssues(dir, options = {}) {
|
|
13280
14091
|
return loadPackageInternal(dir, options);
|
|
@@ -13373,15 +14184,11 @@ var MERGE_FIELDS = [
|
|
|
13373
14184
|
"texts"
|
|
13374
14185
|
];
|
|
13375
14186
|
function parsePackageContent(dir, options) {
|
|
13376
|
-
const chunks =
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
chunks.push(preprocessIncludes(f.path));
|
|
13380
|
-
}
|
|
13381
|
-
}
|
|
13382
|
-
return parse(chunks.join("\n\n"), PARSER_CONFIG, options);
|
|
14187
|
+
const chunks = chunkify(packageFiles(dir));
|
|
14188
|
+
const ctx = parse(joinChunks(chunks), PARSER_CONFIG, options);
|
|
14189
|
+
return { ctx, chunks };
|
|
13383
14190
|
}
|
|
13384
|
-
function composePackage(rootDir, options, rootManifest) {
|
|
14191
|
+
function composePackage(rootDir, options, rootManifest, withProvenance = false) {
|
|
13385
14192
|
const locate = options.resolvePackage;
|
|
13386
14193
|
const rootId = rootManifest.id;
|
|
13387
14194
|
const dirs = /* @__PURE__ */ new Map([[rootId, resolve3(rootDir)]]);
|
|
@@ -13432,9 +14239,13 @@ function composePackage(rootDir, options, rootManifest) {
|
|
|
13432
14239
|
order.push(id);
|
|
13433
14240
|
};
|
|
13434
14241
|
visit(rootId);
|
|
14242
|
+
const parseOptions = withProvenance ? { ...options, withProvenance: true } : options;
|
|
13435
14243
|
const ctxs = /* @__PURE__ */ new Map();
|
|
14244
|
+
const pkgChunks = /* @__PURE__ */ new Map();
|
|
13436
14245
|
for (const id of order) {
|
|
13437
|
-
|
|
14246
|
+
const parsed = parsePackageContent(dirs.get(id), parseOptions);
|
|
14247
|
+
ctxs.set(id, parsed.ctx);
|
|
14248
|
+
pkgChunks.set(id, parsed.chunks);
|
|
13438
14249
|
}
|
|
13439
14250
|
const provenance = /* @__PURE__ */ new Map();
|
|
13440
14251
|
for (const field of MERGE_FIELDS) {
|
|
@@ -13519,11 +14330,32 @@ function composePackage(rootDir, options, rootManifest) {
|
|
|
13519
14330
|
}
|
|
13520
14331
|
acc.packageManifest = rootManifest;
|
|
13521
14332
|
const standard = resolve(acc, RESOLVER_CONFIG);
|
|
13522
|
-
|
|
14333
|
+
const result = {
|
|
13523
14334
|
standard,
|
|
13524
14335
|
issues: [...acc.issues, ...compositionIssues],
|
|
13525
14336
|
composition: { root: rootId, order }
|
|
13526
14337
|
};
|
|
14338
|
+
if (withProvenance) {
|
|
14339
|
+
const constructs = {};
|
|
14340
|
+
for (const id of order) {
|
|
14341
|
+
const perPackage = mapConstructs(
|
|
14342
|
+
ctxs.get(id).constructs ?? [],
|
|
14343
|
+
pkgChunks.get(id),
|
|
14344
|
+
id
|
|
14345
|
+
);
|
|
14346
|
+
for (const [field, byId2] of Object.entries(perPackage)) {
|
|
14347
|
+
const target = constructs[field] ??= {};
|
|
14348
|
+
for (const [constructId, source] of Object.entries(byId2)) {
|
|
14349
|
+
target[constructId] = source;
|
|
14350
|
+
}
|
|
14351
|
+
}
|
|
14352
|
+
}
|
|
14353
|
+
result.provenance = {
|
|
14354
|
+
manifest: join(resolve3(rootDir), "package.primmel"),
|
|
14355
|
+
constructs
|
|
14356
|
+
};
|
|
14357
|
+
}
|
|
14358
|
+
return result;
|
|
13527
14359
|
}
|
|
13528
14360
|
|
|
13529
14361
|
// src/ser-des/prm.ts
|
|
@@ -15859,6 +16691,63 @@ var CHECK_RULES = [
|
|
|
15859
16691
|
"error",
|
|
15860
16692
|
"normal",
|
|
15861
16693
|
"docs/primmel/18 \xA718.6 (the unified reference/relation construct)"
|
|
16694
|
+
),
|
|
16695
|
+
// ── the dataspace family (TODO.primmel/10; MN 114 v3.1 clause 19) ──
|
|
16696
|
+
// The v3.1 extension set: the dataspace definition, the policy
|
|
16697
|
+
// construct (Primmel's own policy grammar; ODRL is a codec output),
|
|
16698
|
+
// the trust_ref form (opaque addressing — the checker verifies shape,
|
|
16699
|
+
// NEVER resolution: the trust plane's membership is runtime fact), and
|
|
16700
|
+
// the generalized corresponds annotations. C104: the dataspace's
|
|
16701
|
+
// references resolve (policy register, default policy, per-class
|
|
16702
|
+
// overrides, content elements, the compatibility register). C105:
|
|
16703
|
+
// every trust anchor carries its trust_ref with an organization
|
|
16704
|
+
// identifier. C106: a dataspace with no governance citation warns (an
|
|
16705
|
+
// orphan definition). C107: the policy shape — at least one rule,
|
|
16706
|
+
// every rule with its action, rule artifacts inside the governs
|
|
16707
|
+
// register, governed classes resolving, at most one default-posture
|
|
16708
|
+
// policy per class. C108: one corresponds entry per scheme per
|
|
16709
|
+
// element (an error — the bridges read unambiguous mappings), and the
|
|
16710
|
+
// irdi legacy spelling agreeing with `corresponds iec-cdd` (a warning
|
|
16711
|
+
// leg).
|
|
16712
|
+
R(
|
|
16713
|
+
"C104",
|
|
16714
|
+
"dataspace-references-resolve",
|
|
16715
|
+
"dataspace",
|
|
16716
|
+
"error",
|
|
16717
|
+
"normal",
|
|
16718
|
+
"TODO.primmel/10, MN 114 clause 19.1"
|
|
16719
|
+
),
|
|
16720
|
+
R(
|
|
16721
|
+
"C105",
|
|
16722
|
+
"dataspace-trust-anchor-shape",
|
|
16723
|
+
"dataspace",
|
|
16724
|
+
"error",
|
|
16725
|
+
"normal",
|
|
16726
|
+
"TODO.primmel/10, MN 114 clauses 19.1/19.3"
|
|
16727
|
+
),
|
|
16728
|
+
R(
|
|
16729
|
+
"C106",
|
|
16730
|
+
"dataspace-governance-provenance",
|
|
16731
|
+
"dataspace",
|
|
16732
|
+
"warning",
|
|
16733
|
+
"normal",
|
|
16734
|
+
"TODO.primmel/10, MN 114 clause 19.1"
|
|
16735
|
+
),
|
|
16736
|
+
R(
|
|
16737
|
+
"C107",
|
|
16738
|
+
"policy-shape",
|
|
16739
|
+
"dataspace",
|
|
16740
|
+
"error",
|
|
16741
|
+
"normal",
|
|
16742
|
+
"TODO.primmel/10, MN 114 clause 19.2"
|
|
16743
|
+
),
|
|
16744
|
+
R(
|
|
16745
|
+
"C108",
|
|
16746
|
+
"correspondence-shape",
|
|
16747
|
+
"dataspace",
|
|
16748
|
+
"error",
|
|
16749
|
+
"normal",
|
|
16750
|
+
"TODO.primmel/10, MN 114 clause 19.4"
|
|
15862
16751
|
)
|
|
15863
16752
|
];
|
|
15864
16753
|
var byId = new Map(CHECK_RULES.map((r) => [r.id, r]));
|
|
@@ -19918,6 +20807,230 @@ function checkPackage(dir, options = {}) {
|
|
|
19918
20807
|
}
|
|
19919
20808
|
}
|
|
19920
20809
|
}
|
|
20810
|
+
{
|
|
20811
|
+
const dataspaces = standard.dataspaces ?? [];
|
|
20812
|
+
const policies = standard.policies ?? [];
|
|
20813
|
+
const policyIds = new Set(policies.map((p) => p.id));
|
|
20814
|
+
const dataspaceIds = new Set(dataspaces.map((d) => d.id));
|
|
20815
|
+
const artifactClassIds = /* @__PURE__ */ new Set();
|
|
20816
|
+
for (const d of dataspaces) {
|
|
20817
|
+
for (const ac of d.artifactClasses) {
|
|
20818
|
+
artifactClassIds.add(ac.id);
|
|
20819
|
+
}
|
|
20820
|
+
}
|
|
20821
|
+
const elementIds = /* @__PURE__ */ new Set([
|
|
20822
|
+
...(standard.artifactDefinitions ?? []).map((a) => a.id),
|
|
20823
|
+
...(standard.forms ?? []).map((f) => f.id),
|
|
20824
|
+
...(standard.dataclasses ?? []).map((c) => c.id)
|
|
20825
|
+
]);
|
|
20826
|
+
for (const d of dataspaces) {
|
|
20827
|
+
for (const pid of d.policies) {
|
|
20828
|
+
if (!policyIds.has(pid)) {
|
|
20829
|
+
err(
|
|
20830
|
+
"C104",
|
|
20831
|
+
`dataspace ${d.id}: policies entry "${pid}" declares no policy of that id \u2014 the dataspace's policy register references declared policy constructs (dataspace-references-resolve)`
|
|
20832
|
+
);
|
|
20833
|
+
}
|
|
20834
|
+
}
|
|
20835
|
+
if (d.defaultPolicy !== "") {
|
|
20836
|
+
if (!policyIds.has(d.defaultPolicy)) {
|
|
20837
|
+
err(
|
|
20838
|
+
"C104",
|
|
20839
|
+
`dataspace ${d.id}: default_policy "${d.defaultPolicy}" declares no policy of that id \u2014 the standing default is a declared policy (dataspace-references-resolve)`
|
|
20840
|
+
);
|
|
20841
|
+
} else if (!d.policies.includes(d.defaultPolicy)) {
|
|
20842
|
+
err(
|
|
20843
|
+
"C104",
|
|
20844
|
+
`dataspace ${d.id}: default_policy "${d.defaultPolicy}" is not in the dataspace's policies register \u2014 the default is one of the policy sets the dataspace carries (dataspace-references-resolve)`
|
|
20845
|
+
);
|
|
20846
|
+
}
|
|
20847
|
+
}
|
|
20848
|
+
for (const ac of d.artifactClasses) {
|
|
20849
|
+
if (ac.policy !== "") {
|
|
20850
|
+
if (!policyIds.has(ac.policy)) {
|
|
20851
|
+
err(
|
|
20852
|
+
"C104",
|
|
20853
|
+
`dataspace ${d.id}: artifact class "${ac.id}" overrides with policy "${ac.policy}", which declares no policy of that id (dataspace-references-resolve)`
|
|
20854
|
+
);
|
|
20855
|
+
} else if (!d.policies.includes(ac.policy)) {
|
|
20856
|
+
err(
|
|
20857
|
+
"C104",
|
|
20858
|
+
`dataspace ${d.id}: artifact class "${ac.id}" overrides with policy "${ac.policy}", which the dataspace's policies register does not carry \u2014 an override names a policy set the dataspace carries (dataspace-references-resolve)`
|
|
20859
|
+
);
|
|
20860
|
+
}
|
|
20861
|
+
}
|
|
20862
|
+
if (ac.element !== "" && !elementIds.has(ac.element)) {
|
|
20863
|
+
err(
|
|
20864
|
+
"C104",
|
|
20865
|
+
`dataspace ${d.id}: artifact class "${ac.id}" declares element "${ac.element}", which names no declared artifact definition, form, or data class \u2014 the class's content definition must resolve (dataspace-references-resolve)`
|
|
20866
|
+
);
|
|
20867
|
+
}
|
|
20868
|
+
}
|
|
20869
|
+
for (const compat of d.compatibleWith) {
|
|
20870
|
+
if (!dataspaceIds.has(compat)) {
|
|
20871
|
+
err(
|
|
20872
|
+
"C104",
|
|
20873
|
+
`dataspace ${d.id}: compatible_with entry "${compat}" declares no dataspace of that id \u2014 compatibility is explicit and resolved (dataspace-references-resolve)`
|
|
20874
|
+
);
|
|
20875
|
+
} else if (compat === d.id) {
|
|
20876
|
+
err(
|
|
20877
|
+
"C104",
|
|
20878
|
+
`dataspace ${d.id}: compatible_with names the dataspace itself \u2014 compatibility relates two dataspaces (dataspace-references-resolve)`
|
|
20879
|
+
);
|
|
20880
|
+
}
|
|
20881
|
+
}
|
|
20882
|
+
for (const ta of d.trustAnchors) {
|
|
20883
|
+
if (!ta.trustRef || ta.trustRef.org === "") {
|
|
20884
|
+
err(
|
|
20885
|
+
"C105",
|
|
20886
|
+
`dataspace ${d.id}: trust anchor "${ta.id}" declares no trust_ref with an organization identifier \u2014 an anchor without its trust reference anchors nothing (dataspace-trust-anchor-shape)`
|
|
20887
|
+
);
|
|
20888
|
+
}
|
|
20889
|
+
}
|
|
20890
|
+
const hasGovernance = (d.sourceRefs?.length ?? 0) > 0 || d.source && (d.source.doc || d.source.clause);
|
|
20891
|
+
if (!hasGovernance) {
|
|
20892
|
+
warn(
|
|
20893
|
+
"C106",
|
|
20894
|
+
`dataspace ${d.id}: the dataspace cites no governance clause \u2014 the definition's charter is its clause-cited provenance (ref derives-from); an orphan definition is a warning, never silent (dataspace-governance-provenance)`
|
|
20895
|
+
);
|
|
20896
|
+
}
|
|
20897
|
+
}
|
|
20898
|
+
for (const p of policies) {
|
|
20899
|
+
if (p.rules.length === 0) {
|
|
20900
|
+
err(
|
|
20901
|
+
"C107",
|
|
20902
|
+
`policy ${p.id}: a policy declares at least one rule \u2014 a rule-less set says nothing (policy-shape)`
|
|
20903
|
+
);
|
|
20904
|
+
}
|
|
20905
|
+
for (const g of p.governs) {
|
|
20906
|
+
if (!artifactClassIds.has(g)) {
|
|
20907
|
+
err(
|
|
20908
|
+
"C107",
|
|
20909
|
+
`policy ${p.id}: governs entry "${g}" names no artifact class declared by the merged model's dataspaces \u2014 the governed classes resolve (policy-shape)`
|
|
20910
|
+
);
|
|
20911
|
+
}
|
|
20912
|
+
}
|
|
20913
|
+
for (const r of p.rules) {
|
|
20914
|
+
if (r.action === "") {
|
|
20915
|
+
err(
|
|
20916
|
+
"C107",
|
|
20917
|
+
`policy ${p.id}: rule "${r.id}" declares no action \u2014 a rule without its action says nothing (policy-shape)`
|
|
20918
|
+
);
|
|
20919
|
+
}
|
|
20920
|
+
if (r.artifact !== "") {
|
|
20921
|
+
if (p.governs.length > 0 && !p.governs.includes(r.artifact)) {
|
|
20922
|
+
err(
|
|
20923
|
+
"C107",
|
|
20924
|
+
`policy ${p.id}: rule "${r.id}" constrains artifact class "${r.artifact}", which is not in the policy's governs register \u2014 a rule stays inside the register, or drops the facet to cover every governed class (policy-shape)`
|
|
20925
|
+
);
|
|
20926
|
+
}
|
|
20927
|
+
if (!artifactClassIds.has(r.artifact)) {
|
|
20928
|
+
err(
|
|
20929
|
+
"C107",
|
|
20930
|
+
`policy ${p.id}: rule "${r.id}" constrains artifact class "${r.artifact}", which no dataspace of the merged model declares (policy-shape)`
|
|
20931
|
+
);
|
|
20932
|
+
}
|
|
20933
|
+
}
|
|
20934
|
+
}
|
|
20935
|
+
}
|
|
20936
|
+
const postureByClass = /* @__PURE__ */ new Map();
|
|
20937
|
+
for (const p of policies) {
|
|
20938
|
+
if (p.defaultPosture !== true) {
|
|
20939
|
+
continue;
|
|
20940
|
+
}
|
|
20941
|
+
for (const g of p.governs) {
|
|
20942
|
+
postureByClass.set(g, [...postureByClass.get(g) ?? [], p.id]);
|
|
20943
|
+
}
|
|
20944
|
+
}
|
|
20945
|
+
for (const [cls, ids] of postureByClass) {
|
|
20946
|
+
if (ids.length > 1) {
|
|
20947
|
+
err(
|
|
20948
|
+
"C107",
|
|
20949
|
+
`artifact class "${cls}" is governed by ${ids.length} default-posture policies (${ids.join(", ")}) \u2014 the standing default is one policy per class; the rest attach by explicit reference (policy-shape)`
|
|
20950
|
+
);
|
|
20951
|
+
}
|
|
20952
|
+
}
|
|
20953
|
+
const corrElements = [];
|
|
20954
|
+
const collect = (kind, items) => {
|
|
20955
|
+
for (const it of items ?? []) {
|
|
20956
|
+
if (it.correspondences && it.correspondences.length > 0) {
|
|
20957
|
+
corrElements.push({ kind, id: it.id, corrs: it.correspondences });
|
|
20958
|
+
}
|
|
20959
|
+
}
|
|
20960
|
+
};
|
|
20961
|
+
collect("dataspace", dataspaces);
|
|
20962
|
+
collect("policy", policies);
|
|
20963
|
+
collect("instrument", standard.instruments ?? []);
|
|
20964
|
+
collect("attribute_definition", standard.attributeDefinitions ?? []);
|
|
20965
|
+
collect("capability", standard.capabilities ?? []);
|
|
20966
|
+
collect("behavior", standard.behaviors ?? []);
|
|
20967
|
+
collect("condition_set", standard.conditionSets ?? []);
|
|
20968
|
+
collect("requirement", standard.requirements ?? []);
|
|
20969
|
+
collect("conformance_test", standard.conformanceTests ?? []);
|
|
20970
|
+
collect("form", standard.forms ?? []);
|
|
20971
|
+
collect("table", standard.tables ?? []);
|
|
20972
|
+
collect("symbol", standard.symbols ?? []);
|
|
20973
|
+
collect("calculation", standard.calculations ?? []);
|
|
20974
|
+
collect("term", standard.terms ?? []);
|
|
20975
|
+
collect("artifact_definition", standard.artifactDefinitions ?? []);
|
|
20976
|
+
collect("verdict", standard.verdicts ?? []);
|
|
20977
|
+
collect("reference_material", standard.referenceMaterials ?? []);
|
|
20978
|
+
collect("test_point_set", standard.testPointSets ?? []);
|
|
20979
|
+
collect("competence_kind", standard.competenceKinds ?? []);
|
|
20980
|
+
collect("constraint", standard.constraints ?? []);
|
|
20981
|
+
collect("test_sequence", standard.testSequences ?? []);
|
|
20982
|
+
collect("formulas_used", standard.formulasUsed ?? []);
|
|
20983
|
+
collect("process", standard.processes ?? []);
|
|
20984
|
+
for (const f of standard.forms ?? []) {
|
|
20985
|
+
for (const fld of f.fields ?? []) {
|
|
20986
|
+
if (fld.correspondences && fld.correspondences.length > 0) {
|
|
20987
|
+
corrElements.push({
|
|
20988
|
+
kind: "field",
|
|
20989
|
+
id: `${f.id}.${fld.name}`,
|
|
20990
|
+
corrs: fld.correspondences
|
|
20991
|
+
});
|
|
20992
|
+
}
|
|
20993
|
+
}
|
|
20994
|
+
}
|
|
20995
|
+
if (standard.packageManifest?.correspondences?.length) {
|
|
20996
|
+
corrElements.push({
|
|
20997
|
+
kind: "package",
|
|
20998
|
+
id: standard.packageManifest.id,
|
|
20999
|
+
corrs: standard.packageManifest.correspondences
|
|
21000
|
+
});
|
|
21001
|
+
}
|
|
21002
|
+
for (const el of corrElements) {
|
|
21003
|
+
const byScheme = /* @__PURE__ */ new Map();
|
|
21004
|
+
for (const c of el.corrs) {
|
|
21005
|
+
byScheme.set(c.scheme, (byScheme.get(c.scheme) ?? 0) + 1);
|
|
21006
|
+
if (c.scheme === "" || c.concept === "") {
|
|
21007
|
+
err(
|
|
21008
|
+
"C108",
|
|
21009
|
+
`${el.kind} ${el.id}: a corresponds entry carries an empty scheme or concept \u2014 the entry names its scheme and the scheme's concept identifier (correspondence-shape)`
|
|
21010
|
+
);
|
|
21011
|
+
}
|
|
21012
|
+
}
|
|
21013
|
+
for (const [scheme, n] of byScheme) {
|
|
21014
|
+
if (n > 1) {
|
|
21015
|
+
err(
|
|
21016
|
+
"C108",
|
|
21017
|
+
`${el.kind} ${el.id}: ${n} corresponds entries name scheme "${scheme}" \u2014 one element has at most one correspondence per scheme, so every bridge reads an unambiguous mapping (correspondence-shape)`
|
|
21018
|
+
);
|
|
21019
|
+
}
|
|
21020
|
+
}
|
|
21021
|
+
}
|
|
21022
|
+
for (const a of standard.attributeDefinitions ?? []) {
|
|
21023
|
+
if (a.irdi && a.irdi !== "") {
|
|
21024
|
+
const cdd = (a.correspondences ?? []).find((c) => c.scheme === "iec-cdd");
|
|
21025
|
+
if (cdd && cdd.concept !== a.irdi) {
|
|
21026
|
+
warn(
|
|
21027
|
+
"C108",
|
|
21028
|
+
`attribute_definition ${a.id}: irdi "${a.irdi}" disagrees with corresponds iec-cdd "${cdd.concept}" \u2014 the legacy single-scheme spelling and the generalized annotation name the same concept, or the irdi facet retires (correspondence-shape)`
|
|
21029
|
+
);
|
|
21030
|
+
}
|
|
21031
|
+
}
|
|
21032
|
+
}
|
|
21033
|
+
}
|
|
19921
21034
|
const level = strictness === "audit" ? "audit" : "normal";
|
|
19922
21035
|
const { allowlist, issues: allowlistParseIssues } = loadAllowlist(dir);
|
|
19923
21036
|
issues.push(...allowlistParseIssues);
|