@driftsys/markspec 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/compiler/mod.d.ts +7 -0
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +17 -3
- package/esm/compiler/schema.d.ts +8 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +8 -1
- package/esm/formatter/dprint.d.ts +62 -0
- package/esm/formatter/dprint.d.ts.map +1 -0
- package/esm/formatter/dprint.js +83 -0
- package/esm/formatter/md_equiv.d.ts +24 -0
- package/esm/formatter/md_equiv.d.ts.map +1 -0
- package/esm/formatter/md_equiv.js +81 -0
- package/esm/formatter/mod.d.ts +25 -0
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +106 -6
- package/esm/formatter/prose.d.ts +48 -0
- package/esm/formatter/prose.d.ts.map +1 -0
- package/esm/formatter/prose.js +85 -0
- package/esm/mod.d.ts +8 -4
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +5 -2
- package/esm/model/mod.d.ts +19 -1
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/profile.d.ts +34 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/profile/chain.js +1 -0
- package/esm/profile/delivered.d.ts +27 -0
- package/esm/profile/delivered.d.ts.map +1 -0
- package/esm/profile/delivered.js +60 -0
- package/esm/profile/manifest.d.ts +1 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +107 -0
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +21 -0
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +22 -0
- package/esm/reporter/mod.js +17 -4
- package/esm/validator/corpus.d.ts +25 -0
- package/esm/validator/corpus.d.ts.map +1 -0
- package/esm/validator/corpus.js +138 -0
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +1 -0
- package/package.json +3 -1
- package/script/compiler/mod.d.ts +7 -0
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +16 -2
- package/script/compiler/schema.d.ts +8 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +8 -1
- package/script/formatter/dprint.d.ts +62 -0
- package/script/formatter/dprint.d.ts.map +1 -0
- package/script/formatter/dprint.js +120 -0
- package/script/formatter/md_equiv.d.ts +24 -0
- package/script/formatter/md_equiv.d.ts.map +1 -0
- package/script/formatter/md_equiv.js +87 -0
- package/script/formatter/mod.d.ts +25 -0
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +106 -5
- package/script/formatter/prose.d.ts +48 -0
- package/script/formatter/prose.d.ts.map +1 -0
- package/script/formatter/prose.js +88 -0
- package/script/mod.d.ts +8 -4
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +14 -3
- package/script/model/mod.d.ts +19 -1
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/profile.d.ts +34 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/profile/chain.js +1 -0
- package/script/profile/delivered.d.ts +27 -0
- package/script/profile/delivered.d.ts.map +1 -0
- package/script/profile/delivered.js +65 -0
- package/script/profile/manifest.d.ts +1 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +108 -1
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +21 -0
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +22 -0
- package/script/reporter/mod.js +17 -4
- package/script/validator/corpus.d.ts +25 -0
- package/script/validator/corpus.d.ts.map +1 -0
- package/script/validator/corpus.js +142 -0
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +4 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* schema violations.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.ALLOWED_TRACE_RULE_KEYS = exports.ALLOWED_INVERSE_KEYS = exports.ALLOWED_ATTR_KEYS = exports.ALLOWED_DOCUMENTS_KEYS = exports.ALLOWED_DOC_TYPE_KEYS = exports.ALLOWED_TYPE_KEYS = exports.ALLOWED_PROFILE_KEYS = exports.ALLOWED_ROOT_KEYS = void 0;
|
|
10
|
+
exports.ALLOWED_TRACE_RULE_KEYS = exports.ALLOWED_INVERSE_KEYS = exports.ALLOWED_ATTR_KEYS = exports.ALLOWED_DELIVERS_KEYS = exports.ALLOWED_DOCUMENTS_KEYS = exports.ALLOWED_DOC_TYPE_KEYS = exports.ALLOWED_TYPE_KEYS = exports.ALLOWED_PROFILE_KEYS = exports.ALLOWED_ROOT_KEYS = void 0;
|
|
11
11
|
exports.parseManifest = parseManifest;
|
|
12
12
|
const yaml_1 = require("@std/yaml");
|
|
13
13
|
const mod_js_1 = require("../model/mod.js");
|
|
@@ -30,6 +30,7 @@ exports.ALLOWED_PROFILE_KEYS = new Set([
|
|
|
30
30
|
"conventions",
|
|
31
31
|
"types",
|
|
32
32
|
"documents",
|
|
33
|
+
"delivers",
|
|
33
34
|
"kinds",
|
|
34
35
|
"prose",
|
|
35
36
|
"discipline-mode",
|
|
@@ -47,6 +48,7 @@ exports.ALLOWED_TYPE_KEYS = new Set([
|
|
|
47
48
|
]);
|
|
48
49
|
exports.ALLOWED_DOC_TYPE_KEYS = new Set(["id", "contains", "description"]);
|
|
49
50
|
exports.ALLOWED_DOCUMENTS_KEYS = new Set(["types", "frontMatter"]);
|
|
51
|
+
exports.ALLOWED_DELIVERS_KEYS = new Set(["path", "corpus", "description"]);
|
|
50
52
|
exports.ALLOWED_ATTR_KEYS = new Set([
|
|
51
53
|
"name",
|
|
52
54
|
"type",
|
|
@@ -1098,6 +1100,106 @@ function parseDocumentsSection(raw, sourcePath, diagnostics) {
|
|
|
1098
1100
|
const frontMatter = parseAttrList(r.frontMatter, "profile.documents.frontMatter", sourcePath, diagnostics);
|
|
1099
1101
|
return { types, frontMatter };
|
|
1100
1102
|
}
|
|
1103
|
+
function parseDeliversSection(raw, sourcePath, diagnostics) {
|
|
1104
|
+
if (raw === undefined)
|
|
1105
|
+
return [];
|
|
1106
|
+
const loc = { file: sourcePath, line: 1, column: 1 };
|
|
1107
|
+
if (!Array.isArray(raw)) {
|
|
1108
|
+
diagnostics.push({
|
|
1109
|
+
code: "PROFILE-LOAD-003",
|
|
1110
|
+
severity: "error",
|
|
1111
|
+
message: `profile.delivers: must be a list`,
|
|
1112
|
+
location: loc,
|
|
1113
|
+
});
|
|
1114
|
+
return [];
|
|
1115
|
+
}
|
|
1116
|
+
const out = [];
|
|
1117
|
+
const seenPaths = new Set();
|
|
1118
|
+
for (const item of raw) {
|
|
1119
|
+
if (item == null || typeof item !== "object" || Array.isArray(item)) {
|
|
1120
|
+
diagnostics.push({
|
|
1121
|
+
code: "PROFILE-LOAD-003",
|
|
1122
|
+
severity: "error",
|
|
1123
|
+
message: `profile.delivers: each item must be a mapping`,
|
|
1124
|
+
location: loc,
|
|
1125
|
+
});
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
const r = item;
|
|
1129
|
+
for (const key of Object.keys(r)) {
|
|
1130
|
+
if (!exports.ALLOWED_DELIVERS_KEYS.has(key)) {
|
|
1131
|
+
diagnostics.push({
|
|
1132
|
+
code: "PROFILE-LOAD-003",
|
|
1133
|
+
severity: "error",
|
|
1134
|
+
message: `profile.delivers: unknown key '${key}'`,
|
|
1135
|
+
location: loc,
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
const path = r.path;
|
|
1140
|
+
if (typeof path !== "string" || path.trim().length === 0) {
|
|
1141
|
+
diagnostics.push({
|
|
1142
|
+
code: "PROFILE-LOAD-003",
|
|
1143
|
+
severity: "error",
|
|
1144
|
+
message: `profile.delivers: item missing required 'path' (string)`,
|
|
1145
|
+
location: loc,
|
|
1146
|
+
});
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
// PROFILE-DELIVERS-003 — the path must stay inside the profile
|
|
1150
|
+
// directory: no absolute paths (POSIX or drive-letter), no `..`.
|
|
1151
|
+
const normalized = path.replaceAll("\\", "/");
|
|
1152
|
+
if (normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized) ||
|
|
1153
|
+
normalized.split("/").includes("..")) {
|
|
1154
|
+
diagnostics.push({
|
|
1155
|
+
code: "PROFILE-DELIVERS-003",
|
|
1156
|
+
severity: "error",
|
|
1157
|
+
message: `profile.delivers: path '${path}' escapes the profile ` +
|
|
1158
|
+
`directory (absolute paths and '..' segments are not allowed)`,
|
|
1159
|
+
location: loc,
|
|
1160
|
+
});
|
|
1161
|
+
continue;
|
|
1162
|
+
}
|
|
1163
|
+
if (r.corpus !== undefined && typeof r.corpus !== "boolean") {
|
|
1164
|
+
diagnostics.push({
|
|
1165
|
+
code: "PROFILE-LOAD-003",
|
|
1166
|
+
severity: "error",
|
|
1167
|
+
message: `profile.delivers: 'corpus' must be a boolean`,
|
|
1168
|
+
location: loc,
|
|
1169
|
+
});
|
|
1170
|
+
continue;
|
|
1171
|
+
}
|
|
1172
|
+
const corpus = r.corpus === true;
|
|
1173
|
+
if (corpus && !normalized.toLowerCase().endsWith(".md")) {
|
|
1174
|
+
diagnostics.push({
|
|
1175
|
+
code: "PROFILE-DELIVERS-004",
|
|
1176
|
+
severity: "error",
|
|
1177
|
+
message: `profile.delivers: 'corpus: true' requires a Markdown ` +
|
|
1178
|
+
`(.md) file, got '${path}'`,
|
|
1179
|
+
location: loc,
|
|
1180
|
+
});
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
if (seenPaths.has(normalized)) {
|
|
1184
|
+
diagnostics.push({
|
|
1185
|
+
code: "PROFILE-LOAD-003",
|
|
1186
|
+
severity: "error",
|
|
1187
|
+
message: `profile.delivers: duplicate path '${path}'`,
|
|
1188
|
+
location: loc,
|
|
1189
|
+
});
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
seenPaths.add(normalized);
|
|
1193
|
+
out.push({
|
|
1194
|
+
path: normalized,
|
|
1195
|
+
corpus,
|
|
1196
|
+
description: typeof r.description === "string"
|
|
1197
|
+
? r.description
|
|
1198
|
+
: undefined,
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
return out;
|
|
1202
|
+
}
|
|
1101
1203
|
/**
|
|
1102
1204
|
* Parse and validate a raw markspec.yaml string.
|
|
1103
1205
|
*
|
|
@@ -1211,6 +1313,10 @@ function parseManifest(rawYaml, sourcePath = "<markspec.yaml>") {
|
|
|
1211
1313
|
if (diagnostics.some((d) => d.severity === "error")) {
|
|
1212
1314
|
return { manifest: null, diagnostics };
|
|
1213
1315
|
}
|
|
1316
|
+
const delivers = parseDeliversSection(profileSection.delivers, sourcePath, diagnostics);
|
|
1317
|
+
if (diagnostics.some((d) => d.severity === "error")) {
|
|
1318
|
+
return { manifest: null, diagnostics };
|
|
1319
|
+
}
|
|
1214
1320
|
const prose = parseProse(profileSection.prose, sourcePath, diagnostics);
|
|
1215
1321
|
if (diagnostics.some((d) => d.severity === "error")) {
|
|
1216
1322
|
return { manifest: null, diagnostics };
|
|
@@ -1240,6 +1346,7 @@ function parseManifest(rawYaml, sourcePath = "<markspec.yaml>") {
|
|
|
1240
1346
|
colors,
|
|
1241
1347
|
types: types,
|
|
1242
1348
|
documents: documents,
|
|
1349
|
+
delivers,
|
|
1243
1350
|
kinds,
|
|
1244
1351
|
prose,
|
|
1245
1352
|
disciplineMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/profile/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/profile/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAGV,UAAU,EAGV,gBAAgB,EAKhB,YAAY,EASb,MAAM,iBAAiB,CAAC;AAGzB,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAiF3D"}
|
package/script/profile/merge.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.mergeChain = mergeChain;
|
|
13
|
+
const path_1 = require("@std/path");
|
|
13
14
|
const mod_js_1 = require("../model/mod.js");
|
|
14
15
|
const discipline_mode_js_1 = require("./discipline_mode.js");
|
|
15
16
|
/**
|
|
@@ -143,6 +144,13 @@ function foldTier(base, tier, diagnostics) {
|
|
|
143
144
|
// Overlap handling deferred.
|
|
144
145
|
}
|
|
145
146
|
const frontMatter = unionAttrMap(base.documents.frontMatter, m.documents.frontMatter, origin, diagnostics);
|
|
147
|
+
// Delivered documents — additive union keyed by (profileId, path).
|
|
148
|
+
const delivers = [...base.delivers];
|
|
149
|
+
for (const d of deliveredFromTier(tier)) {
|
|
150
|
+
if (!delivers.some((e) => e.profileId === d.profileId && e.path === d.path)) {
|
|
151
|
+
delivers.push(d);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
146
154
|
// Prose lexicons: list-additive across tiers (profile-schema §5.1).
|
|
147
155
|
const capAllow = unionList(base.prose.lexicons["capitalized-allow"], m.prose.lexicons["capitalized-allow"], origin);
|
|
148
156
|
const sentAbbrev = unionList(base.prose.lexicons["sentence-abbrev"], m.prose.lexicons["sentence-abbrev"], origin);
|
|
@@ -156,6 +164,7 @@ function foldTier(base, tier, diagnostics) {
|
|
|
156
164
|
types: docTypes,
|
|
157
165
|
frontMatter,
|
|
158
166
|
},
|
|
167
|
+
delivers,
|
|
159
168
|
kinds,
|
|
160
169
|
prose: {
|
|
161
170
|
lexicons: {
|
|
@@ -519,6 +528,17 @@ function stringifyMatcher(m) {
|
|
|
519
528
|
// ---------------------------------------------------------------------------
|
|
520
529
|
// Helpers: construct an EffectiveProfile from a single tier's manifest.
|
|
521
530
|
// ---------------------------------------------------------------------------
|
|
531
|
+
/** Resolve a tier's `delivers:` declarations against its baseDir (ADR-030). */
|
|
532
|
+
function deliveredFromTier(tier) {
|
|
533
|
+
return tier.manifest.delivers.map((d) => ({
|
|
534
|
+
profileId: tier.id,
|
|
535
|
+
profileVersion: tier.version,
|
|
536
|
+
path: d.path,
|
|
537
|
+
absPath: (0, path_1.join)(tier.baseDir, d.path),
|
|
538
|
+
corpus: d.corpus,
|
|
539
|
+
description: d.description,
|
|
540
|
+
}));
|
|
541
|
+
}
|
|
522
542
|
function seedFromTier(tier) {
|
|
523
543
|
const origin = tier.id;
|
|
524
544
|
const m = tier.manifest;
|
|
@@ -532,6 +552,7 @@ function seedFromTier(tier) {
|
|
|
532
552
|
types: mapFromDocTypes(m.documents.types, origin),
|
|
533
553
|
frontMatter: mapFromAttrList(m.documents.frontMatter, origin),
|
|
534
554
|
},
|
|
555
|
+
delivers: deliveredFromTier(tier),
|
|
535
556
|
kinds: mapFromKinds(m.kinds, origin),
|
|
536
557
|
prose: {
|
|
537
558
|
lexicons: {
|
package/script/refs/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAcD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAgHtC"}
|
package/script/refs/mod.js
CHANGED
|
@@ -17,6 +17,7 @@ exports.TRACE_ATTRIBUTE_KEYS = void 0;
|
|
|
17
17
|
exports.buildRefIndex = buildRefIndex;
|
|
18
18
|
exports.canonicalizeRefs = canonicalizeRefs;
|
|
19
19
|
const mod_js_1 = require("../model/mod.js");
|
|
20
|
+
const fence_js_1 = require("../util/fence.js");
|
|
20
21
|
/**
|
|
21
22
|
* Trace-attribute keys whose values are canonicalised/healed: the core
|
|
22
23
|
* relations plus `Verified-by`. Derived from {@linkcode CORE_RELATIONS} so new
|
|
@@ -89,12 +90,25 @@ function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
89
90
|
};
|
|
90
91
|
const lines = content.split("\n");
|
|
91
92
|
let changed = false;
|
|
93
|
+
// Track fenced-code regions so illustrative trailers inside ``` / ~~~
|
|
94
|
+
// blocks (e.g. `Realizes: 01HGW...` in a ```markdown example) are never
|
|
95
|
+
// "healed" against the real ref index — the same verbatim-region rule
|
|
96
|
+
// every other fmt pass honors (§5.1; cf. `collapseBlankLines`). Without
|
|
97
|
+
// this, `markspec fmt` rewrites example IDs in spec/ADR docs on every run
|
|
98
|
+
// (#668). The parser/validator already treat fenced content as inert.
|
|
99
|
+
let inFence = false;
|
|
92
100
|
for (let i = 0; i < lines.length; i++) {
|
|
93
101
|
// Strip a trailing CR before matching so CRLF files are handled (the
|
|
94
102
|
// trailer regex ends in `$`, which `\r` would block) and re-append it on
|
|
95
103
|
// rewrite so line endings stay byte-for-byte lossless.
|
|
96
104
|
const cr = lines[i].endsWith("\r");
|
|
97
105
|
const bare = cr ? lines[i].slice(0, -1) : lines[i];
|
|
106
|
+
if (fence_js_1.FENCE_RE.test(bare)) {
|
|
107
|
+
inFence = !inFence;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (inFence)
|
|
111
|
+
continue;
|
|
98
112
|
const m = TRACE_TRAILER_RE.exec(bare);
|
|
99
113
|
if (!m)
|
|
100
114
|
continue;
|
|
@@ -121,6 +135,14 @@ function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
121
135
|
j++;
|
|
122
136
|
const crj = lines[j].endsWith("\r");
|
|
123
137
|
const barej = crj ? lines[j].slice(0, -1) : lines[j];
|
|
138
|
+
// A fence marker is never continuation text. An indented one (e.g.
|
|
139
|
+
// ` ```md`) would otherwise match CONTINUATION_LINE_RE and be
|
|
140
|
+
// swallowed here without toggling `inFence`, desyncing fence tracking
|
|
141
|
+
// for the rest of the file. Back out and let the outer loop toggle it.
|
|
142
|
+
if (fence_js_1.FENCE_RE.test(barej)) {
|
|
143
|
+
j--;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
124
146
|
const cm = CONTINUATION_LINE_RE.exec(barej);
|
|
125
147
|
if (!cm) {
|
|
126
148
|
j--; // not a continuation line — leave it for the outer loop
|
package/script/reporter/mod.js
CHANGED
|
@@ -45,6 +45,17 @@ function filterEntries(result, scope, label) {
|
|
|
45
45
|
}
|
|
46
46
|
return entries;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Render an entry's provenance cell (ADR-030): `<profileId>@<profileVersion>`
|
|
50
|
+
* for an entry injected from a profile-delivered corpus, `"project"` for a
|
|
51
|
+
* project-authored entry. Shared by the traceability matrix builder so CSV,
|
|
52
|
+
* Markdown, and JSON rows all agree on the same value.
|
|
53
|
+
*/
|
|
54
|
+
function originCell(entry) {
|
|
55
|
+
return entry.origin
|
|
56
|
+
? `${entry.origin.profileId}@${entry.origin.profileVersion}`
|
|
57
|
+
: "project";
|
|
58
|
+
}
|
|
48
59
|
function buildTraceRows(result, entries) {
|
|
49
60
|
return entries.map((entry) => {
|
|
50
61
|
const fwd = result.forward.get(entry.displayId) ?? [];
|
|
@@ -53,6 +64,7 @@ function buildTraceRows(result, entries) {
|
|
|
53
64
|
id: entry.displayId,
|
|
54
65
|
title: entry.title,
|
|
55
66
|
entryType: entry.type ?? "",
|
|
67
|
+
origin: originCell(entry),
|
|
56
68
|
satisfies: fwd
|
|
57
69
|
.filter((l) => l.kind === "satisfies")
|
|
58
70
|
.map((l) => l.to)
|
|
@@ -70,20 +82,21 @@ function formatTraceability(result, entries, format) {
|
|
|
70
82
|
return JSON.stringify(rows, null, 2);
|
|
71
83
|
}
|
|
72
84
|
if (format === "csv") {
|
|
73
|
-
const header = "ID,Title,Type,Satisfies,Satisfied-by";
|
|
85
|
+
const header = "ID,Title,Type,Origin,Satisfies,Satisfied-by";
|
|
74
86
|
const lines = rows.map((r) => [
|
|
75
87
|
r.id,
|
|
76
88
|
csvEscape(r.title),
|
|
77
89
|
r.entryType,
|
|
90
|
+
csvEscape(r.origin),
|
|
78
91
|
csvEscape(r.satisfies),
|
|
79
92
|
csvEscape(r.satisfiedBy),
|
|
80
93
|
].join(","));
|
|
81
94
|
return [header, ...lines].join("\n");
|
|
82
95
|
}
|
|
83
96
|
// Markdown table
|
|
84
|
-
const header = "| ID | Title | Type | Satisfies | Satisfied-by |";
|
|
85
|
-
const sep = "| -- | ----- | ---- | --------- | ------------ |";
|
|
86
|
-
const lines = rows.map((r) => `| ${r.id} | ${r.title} | ${r.entryType} | ${r.satisfies || "\u2014"} | ${r.satisfiedBy || "\u2014"} |`);
|
|
97
|
+
const header = "| ID | Title | Type | Origin | Satisfies | Satisfied-by |";
|
|
98
|
+
const sep = "| -- | ----- | ---- | ------ | --------- | ------------ |";
|
|
99
|
+
const lines = rows.map((r) => `| ${r.id} | ${r.title} | ${r.entryType} | ${r.origin} | ${r.satisfies || "\u2014"} | ${r.satisfiedBy || "\u2014"} |`);
|
|
87
100
|
return [header, sep, ...lines].join("\n");
|
|
88
101
|
}
|
|
89
102
|
function computeCoverage(result, entries) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/corpus
|
|
3
|
+
*
|
|
4
|
+
* Corpus-aware diagnostic post-pass (ADR-030). Two responsibilities:
|
|
5
|
+
*
|
|
6
|
+
* 1. {@linkcode detectCorpusCollisions} — a project entry re-declaring a
|
|
7
|
+
* display ID (or Id) owned by a delivered corpus entry is MSL-R014, a
|
|
8
|
+
* distinct code from MSL-R006 because the fix is different: rename the
|
|
9
|
+
* project entry; the corpus entry is not yours to change.
|
|
10
|
+
* 2. {@linkcode attributeCorpusDiagnostics} — consumer builds must not go
|
|
11
|
+
* red from upstream bugs they cannot fix: findings located inside a
|
|
12
|
+
* corpus file are downgraded to warnings and attributed to the
|
|
13
|
+
* delivering profile; generic duplicate codes are suppressed for
|
|
14
|
+
* collided tokens (MSL-R014 replaces them).
|
|
15
|
+
*/
|
|
16
|
+
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
17
|
+
/** Result of {@linkcode detectCorpusCollisions}. */
|
|
18
|
+
export interface CorpusCollisionResult {
|
|
19
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
20
|
+
/** Display-ID / Id tokens involved in a project↔corpus collision. */
|
|
21
|
+
readonly collidedTokens: ReadonlySet<string>;
|
|
22
|
+
}
|
|
23
|
+
export declare function detectCorpusCollisions(allEntries: readonly Entry[]): CorpusCollisionResult;
|
|
24
|
+
export declare function attributeCorpusDiagnostics(diagnostics: readonly Diagnostic[], allEntries: readonly Entry[], collidedTokens: ReadonlySet<string>): Diagnostic[];
|
|
25
|
+
//# sourceMappingURL=corpus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/validator/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAUzD,oDAAoD;AACpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,SAAS,KAAK,EAAE,GAC3B,qBAAqB,CAwFvB;AAED,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,UAAU,EAAE,SAAS,KAAK,EAAE,EAC5B,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAClC,UAAU,EAAE,CAiCd"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/validator/corpus
|
|
4
|
+
*
|
|
5
|
+
* Corpus-aware diagnostic post-pass (ADR-030). Two responsibilities:
|
|
6
|
+
*
|
|
7
|
+
* 1. {@linkcode detectCorpusCollisions} — a project entry re-declaring a
|
|
8
|
+
* display ID (or Id) owned by a delivered corpus entry is MSL-R014, a
|
|
9
|
+
* distinct code from MSL-R006 because the fix is different: rename the
|
|
10
|
+
* project entry; the corpus entry is not yours to change.
|
|
11
|
+
* 2. {@linkcode attributeCorpusDiagnostics} — consumer builds must not go
|
|
12
|
+
* red from upstream bugs they cannot fix: findings located inside a
|
|
13
|
+
* corpus file are downgraded to warnings and attributed to the
|
|
14
|
+
* delivering profile; generic duplicate codes are suppressed for
|
|
15
|
+
* collided tokens (MSL-R014 replaces them).
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.detectCorpusCollisions = detectCorpusCollisions;
|
|
19
|
+
exports.attributeCorpusDiagnostics = attributeCorpusDiagnostics;
|
|
20
|
+
/** Generic duplicate detectors superseded by MSL-R014 for corpus collisions. */
|
|
21
|
+
const GENERIC_DUP_CODES = new Set([
|
|
22
|
+
"MSL-R005",
|
|
23
|
+
"MSL-R006",
|
|
24
|
+
"MSL-I007",
|
|
25
|
+
"MSL-I008",
|
|
26
|
+
]);
|
|
27
|
+
function detectCorpusCollisions(allEntries) {
|
|
28
|
+
const corpusByDisplayId = new Map();
|
|
29
|
+
const corpusById = new Map();
|
|
30
|
+
for (const e of allEntries) {
|
|
31
|
+
if (!e.origin)
|
|
32
|
+
continue;
|
|
33
|
+
if (!corpusByDisplayId.has(e.displayId)) {
|
|
34
|
+
corpusByDisplayId.set(e.displayId, e);
|
|
35
|
+
}
|
|
36
|
+
if (e.id && !corpusById.has(e.id))
|
|
37
|
+
corpusById.set(e.id, e);
|
|
38
|
+
}
|
|
39
|
+
if (corpusByDisplayId.size === 0 && corpusById.size === 0) {
|
|
40
|
+
return { diagnostics: [], collidedTokens: new Set() };
|
|
41
|
+
}
|
|
42
|
+
const diagnostics = [];
|
|
43
|
+
const collided = new Set();
|
|
44
|
+
for (const e of allEntries) {
|
|
45
|
+
if (!e.origin) {
|
|
46
|
+
const displayOwner = corpusByDisplayId.get(e.displayId);
|
|
47
|
+
if (displayOwner) {
|
|
48
|
+
collided.add(e.displayId);
|
|
49
|
+
diagnostics.push({
|
|
50
|
+
code: "MSL-R014",
|
|
51
|
+
severity: "error",
|
|
52
|
+
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
53
|
+
`${displayOwner.origin.profileId}@` +
|
|
54
|
+
`${displayOwner.origin.profileVersion}; rename this entry — ` +
|
|
55
|
+
`delivered corpus entries are read-only`,
|
|
56
|
+
location: e.location,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (e.id) {
|
|
60
|
+
const idOwner = corpusById.get(e.id);
|
|
61
|
+
if (idOwner) {
|
|
62
|
+
collided.add(e.id);
|
|
63
|
+
diagnostics.push({
|
|
64
|
+
code: "MSL-R014",
|
|
65
|
+
severity: "error",
|
|
66
|
+
message: `Id '${e.id}' is already delivered by ` +
|
|
67
|
+
`${idOwner.origin.profileId}@` +
|
|
68
|
+
`${idOwner.origin.profileVersion}; rename this entry — ` +
|
|
69
|
+
`delivered corpus entries are read-only`,
|
|
70
|
+
location: e.location,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
// Corpus↔corpus inter-tier collision: a later delivered entry from a
|
|
77
|
+
// DIFFERENT profile claims a display ID (or Id) the first-registered
|
|
78
|
+
// profile already owns. Same-profile duplicates are excluded — that's
|
|
79
|
+
// the delivering profile's own authoring bug, not a read-only-boundary
|
|
80
|
+
// violation, and stays on the generic duplicate codes.
|
|
81
|
+
const displayOwner = corpusByDisplayId.get(e.displayId);
|
|
82
|
+
if (displayOwner !== e && displayOwner &&
|
|
83
|
+
displayOwner.origin.profileId !== e.origin.profileId) {
|
|
84
|
+
collided.add(e.displayId);
|
|
85
|
+
diagnostics.push({
|
|
86
|
+
code: "MSL-R014",
|
|
87
|
+
severity: "error",
|
|
88
|
+
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
89
|
+
`${displayOwner.origin.profileId}@` +
|
|
90
|
+
`${displayOwner.origin.profileVersion}; delivered corpus ` +
|
|
91
|
+
`entries are read-only`,
|
|
92
|
+
location: e.location,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (e.id) {
|
|
96
|
+
const idOwner = corpusById.get(e.id);
|
|
97
|
+
if (idOwner !== e && idOwner &&
|
|
98
|
+
idOwner.origin.profileId !== e.origin.profileId) {
|
|
99
|
+
collided.add(e.id);
|
|
100
|
+
diagnostics.push({
|
|
101
|
+
code: "MSL-R014",
|
|
102
|
+
severity: "error",
|
|
103
|
+
message: `Id '${e.id}' is already delivered by ` +
|
|
104
|
+
`${idOwner.origin.profileId}@` +
|
|
105
|
+
`${idOwner.origin.profileVersion}; delivered corpus entries ` +
|
|
106
|
+
`are read-only`,
|
|
107
|
+
location: e.location,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { diagnostics, collidedTokens: collided };
|
|
113
|
+
}
|
|
114
|
+
function attributeCorpusDiagnostics(diagnostics, allEntries, collidedTokens) {
|
|
115
|
+
const corpusFiles = new Map();
|
|
116
|
+
for (const e of allEntries) {
|
|
117
|
+
if (e.origin) {
|
|
118
|
+
corpusFiles.set(e.location.file, `${e.origin.profileId}@${e.origin.profileVersion}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const out = [];
|
|
122
|
+
for (const d of diagnostics) {
|
|
123
|
+
// Suppress the generic duplicate codes for corpus collisions; the
|
|
124
|
+
// validator embeds the offending token in single quotes, which is what
|
|
125
|
+
// this containment check keys on.
|
|
126
|
+
if (GENERIC_DUP_CODES.has(d.code) &&
|
|
127
|
+
[...collidedTokens].some((t) => d.message.includes(`'${t}'`))) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const label = d.location ? corpusFiles.get(d.location.file) : undefined;
|
|
131
|
+
if (label !== undefined) {
|
|
132
|
+
out.push({
|
|
133
|
+
...d,
|
|
134
|
+
severity: d.severity === "error" ? "warning" : d.severity,
|
|
135
|
+
message: `delivered by ${label}: ${d.message}`,
|
|
136
|
+
});
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
out.push(d);
|
|
140
|
+
}
|
|
141
|
+
return out;
|
|
142
|
+
}
|
|
@@ -43,4 +43,6 @@ export { validateValue } from "./value_types.js";
|
|
|
43
43
|
export type { ValueValidator } from "./value_types.js";
|
|
44
44
|
export { normalizeListValues } from "./normalize.js";
|
|
45
45
|
export { effectiveTraceRules, matchesAnyTarget, validateTraceabilityForEntry, } from "./traceability.js";
|
|
46
|
+
export { attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|
|
47
|
+
export type { CorpusCollisionResult } from "./corpus.js";
|
|
46
48
|
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAqCpE,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,cAAc,CAclE;AA2aD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAM5B;AAGD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS,CAEvB;AAED,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/validator/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAqCpE,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,cAAc,CAclE;AA2aD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAM5B;AAGD,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS,CAEvB;AAED,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
package/script/validator/mod.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* a profile-aware validator layer (not in the core).
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.validateTraceabilityForEntry = exports.matchesAnyTarget = exports.effectiveTraceRules = exports.normalizeListValues = exports.validateValue = exports.validateAttributesForEntry = exports.effectiveScope = exports.compileDisplayIdPattern = exports.classifyEntry = exports.classifyEntriesStage = exports.validateListingDocuments = exports.suppressDeclaredAttrR010 = exports.runPipeline = void 0;
|
|
18
|
+
exports.detectCorpusCollisions = exports.attributeCorpusDiagnostics = exports.validateTraceabilityForEntry = exports.matchesAnyTarget = exports.effectiveTraceRules = exports.normalizeListValues = exports.validateValue = exports.validateAttributesForEntry = exports.effectiveScope = exports.compileDisplayIdPattern = exports.classifyEntry = exports.classifyEntriesStage = exports.validateListingDocuments = exports.suppressDeclaredAttrR010 = exports.runPipeline = void 0;
|
|
19
19
|
exports.validate = validate;
|
|
20
20
|
exports.indexByDisplayId = indexByDisplayId;
|
|
21
21
|
exports.findAttr = findAttr;
|
|
@@ -493,3 +493,6 @@ var traceability_js_1 = require("./traceability.js");
|
|
|
493
493
|
Object.defineProperty(exports, "effectiveTraceRules", { enumerable: true, get: function () { return traceability_js_1.effectiveTraceRules; } });
|
|
494
494
|
Object.defineProperty(exports, "matchesAnyTarget", { enumerable: true, get: function () { return traceability_js_1.matchesAnyTarget; } });
|
|
495
495
|
Object.defineProperty(exports, "validateTraceabilityForEntry", { enumerable: true, get: function () { return traceability_js_1.validateTraceabilityForEntry; } });
|
|
496
|
+
var corpus_js_1 = require("./corpus.js");
|
|
497
|
+
Object.defineProperty(exports, "attributeCorpusDiagnostics", { enumerable: true, get: function () { return corpus_js_1.attributeCorpusDiagnostics; } });
|
|
498
|
+
Object.defineProperty(exports, "detectCorpusCollisions", { enumerable: true, get: function () { return corpus_js_1.detectCorpusCollisions; } });
|