@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
package/esm/profile/manifest.js
CHANGED
|
@@ -26,6 +26,7 @@ export const ALLOWED_PROFILE_KEYS = new Set([
|
|
|
26
26
|
"conventions",
|
|
27
27
|
"types",
|
|
28
28
|
"documents",
|
|
29
|
+
"delivers",
|
|
29
30
|
"kinds",
|
|
30
31
|
"prose",
|
|
31
32
|
"discipline-mode",
|
|
@@ -43,6 +44,7 @@ export const ALLOWED_TYPE_KEYS = new Set([
|
|
|
43
44
|
]);
|
|
44
45
|
export const ALLOWED_DOC_TYPE_KEYS = new Set(["id", "contains", "description"]);
|
|
45
46
|
export const ALLOWED_DOCUMENTS_KEYS = new Set(["types", "frontMatter"]);
|
|
47
|
+
export const ALLOWED_DELIVERS_KEYS = new Set(["path", "corpus", "description"]);
|
|
46
48
|
export const ALLOWED_ATTR_KEYS = new Set([
|
|
47
49
|
"name",
|
|
48
50
|
"type",
|
|
@@ -1094,6 +1096,106 @@ function parseDocumentsSection(raw, sourcePath, diagnostics) {
|
|
|
1094
1096
|
const frontMatter = parseAttrList(r.frontMatter, "profile.documents.frontMatter", sourcePath, diagnostics);
|
|
1095
1097
|
return { types, frontMatter };
|
|
1096
1098
|
}
|
|
1099
|
+
function parseDeliversSection(raw, sourcePath, diagnostics) {
|
|
1100
|
+
if (raw === undefined)
|
|
1101
|
+
return [];
|
|
1102
|
+
const loc = { file: sourcePath, line: 1, column: 1 };
|
|
1103
|
+
if (!Array.isArray(raw)) {
|
|
1104
|
+
diagnostics.push({
|
|
1105
|
+
code: "PROFILE-LOAD-003",
|
|
1106
|
+
severity: "error",
|
|
1107
|
+
message: `profile.delivers: must be a list`,
|
|
1108
|
+
location: loc,
|
|
1109
|
+
});
|
|
1110
|
+
return [];
|
|
1111
|
+
}
|
|
1112
|
+
const out = [];
|
|
1113
|
+
const seenPaths = new Set();
|
|
1114
|
+
for (const item of raw) {
|
|
1115
|
+
if (item == null || typeof item !== "object" || Array.isArray(item)) {
|
|
1116
|
+
diagnostics.push({
|
|
1117
|
+
code: "PROFILE-LOAD-003",
|
|
1118
|
+
severity: "error",
|
|
1119
|
+
message: `profile.delivers: each item must be a mapping`,
|
|
1120
|
+
location: loc,
|
|
1121
|
+
});
|
|
1122
|
+
continue;
|
|
1123
|
+
}
|
|
1124
|
+
const r = item;
|
|
1125
|
+
for (const key of Object.keys(r)) {
|
|
1126
|
+
if (!ALLOWED_DELIVERS_KEYS.has(key)) {
|
|
1127
|
+
diagnostics.push({
|
|
1128
|
+
code: "PROFILE-LOAD-003",
|
|
1129
|
+
severity: "error",
|
|
1130
|
+
message: `profile.delivers: unknown key '${key}'`,
|
|
1131
|
+
location: loc,
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
const path = r.path;
|
|
1136
|
+
if (typeof path !== "string" || path.trim().length === 0) {
|
|
1137
|
+
diagnostics.push({
|
|
1138
|
+
code: "PROFILE-LOAD-003",
|
|
1139
|
+
severity: "error",
|
|
1140
|
+
message: `profile.delivers: item missing required 'path' (string)`,
|
|
1141
|
+
location: loc,
|
|
1142
|
+
});
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
// PROFILE-DELIVERS-003 — the path must stay inside the profile
|
|
1146
|
+
// directory: no absolute paths (POSIX or drive-letter), no `..`.
|
|
1147
|
+
const normalized = path.replaceAll("\\", "/");
|
|
1148
|
+
if (normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized) ||
|
|
1149
|
+
normalized.split("/").includes("..")) {
|
|
1150
|
+
diagnostics.push({
|
|
1151
|
+
code: "PROFILE-DELIVERS-003",
|
|
1152
|
+
severity: "error",
|
|
1153
|
+
message: `profile.delivers: path '${path}' escapes the profile ` +
|
|
1154
|
+
`directory (absolute paths and '..' segments are not allowed)`,
|
|
1155
|
+
location: loc,
|
|
1156
|
+
});
|
|
1157
|
+
continue;
|
|
1158
|
+
}
|
|
1159
|
+
if (r.corpus !== undefined && typeof r.corpus !== "boolean") {
|
|
1160
|
+
diagnostics.push({
|
|
1161
|
+
code: "PROFILE-LOAD-003",
|
|
1162
|
+
severity: "error",
|
|
1163
|
+
message: `profile.delivers: 'corpus' must be a boolean`,
|
|
1164
|
+
location: loc,
|
|
1165
|
+
});
|
|
1166
|
+
continue;
|
|
1167
|
+
}
|
|
1168
|
+
const corpus = r.corpus === true;
|
|
1169
|
+
if (corpus && !normalized.toLowerCase().endsWith(".md")) {
|
|
1170
|
+
diagnostics.push({
|
|
1171
|
+
code: "PROFILE-DELIVERS-004",
|
|
1172
|
+
severity: "error",
|
|
1173
|
+
message: `profile.delivers: 'corpus: true' requires a Markdown ` +
|
|
1174
|
+
`(.md) file, got '${path}'`,
|
|
1175
|
+
location: loc,
|
|
1176
|
+
});
|
|
1177
|
+
continue;
|
|
1178
|
+
}
|
|
1179
|
+
if (seenPaths.has(normalized)) {
|
|
1180
|
+
diagnostics.push({
|
|
1181
|
+
code: "PROFILE-LOAD-003",
|
|
1182
|
+
severity: "error",
|
|
1183
|
+
message: `profile.delivers: duplicate path '${path}'`,
|
|
1184
|
+
location: loc,
|
|
1185
|
+
});
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
seenPaths.add(normalized);
|
|
1189
|
+
out.push({
|
|
1190
|
+
path: normalized,
|
|
1191
|
+
corpus,
|
|
1192
|
+
description: typeof r.description === "string"
|
|
1193
|
+
? r.description
|
|
1194
|
+
: undefined,
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
return out;
|
|
1198
|
+
}
|
|
1097
1199
|
/**
|
|
1098
1200
|
* Parse and validate a raw markspec.yaml string.
|
|
1099
1201
|
*
|
|
@@ -1207,6 +1309,10 @@ export function parseManifest(rawYaml, sourcePath = "<markspec.yaml>") {
|
|
|
1207
1309
|
if (diagnostics.some((d) => d.severity === "error")) {
|
|
1208
1310
|
return { manifest: null, diagnostics };
|
|
1209
1311
|
}
|
|
1312
|
+
const delivers = parseDeliversSection(profileSection.delivers, sourcePath, diagnostics);
|
|
1313
|
+
if (diagnostics.some((d) => d.severity === "error")) {
|
|
1314
|
+
return { manifest: null, diagnostics };
|
|
1315
|
+
}
|
|
1210
1316
|
const prose = parseProse(profileSection.prose, sourcePath, diagnostics);
|
|
1211
1317
|
if (diagnostics.some((d) => d.severity === "error")) {
|
|
1212
1318
|
return { manifest: null, diagnostics };
|
|
@@ -1236,6 +1342,7 @@ export function parseManifest(rawYaml, sourcePath = "<markspec.yaml>") {
|
|
|
1236
1342
|
colors,
|
|
1237
1343
|
types: types,
|
|
1238
1344
|
documents: documents,
|
|
1345
|
+
delivers,
|
|
1239
1346
|
kinds,
|
|
1240
1347
|
prose,
|
|
1241
1348
|
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/esm/profile/merge.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Merge happens once at load. Callers should not call `mergeChain` lazily.
|
|
9
9
|
*/
|
|
10
|
+
import { join } from "@std/path";
|
|
10
11
|
import { CORE_KINDS } from "../model/mod.js";
|
|
11
12
|
import { resolveDisciplineMode } from "./discipline_mode.js";
|
|
12
13
|
/**
|
|
@@ -140,6 +141,13 @@ function foldTier(base, tier, diagnostics) {
|
|
|
140
141
|
// Overlap handling deferred.
|
|
141
142
|
}
|
|
142
143
|
const frontMatter = unionAttrMap(base.documents.frontMatter, m.documents.frontMatter, origin, diagnostics);
|
|
144
|
+
// Delivered documents — additive union keyed by (profileId, path).
|
|
145
|
+
const delivers = [...base.delivers];
|
|
146
|
+
for (const d of deliveredFromTier(tier)) {
|
|
147
|
+
if (!delivers.some((e) => e.profileId === d.profileId && e.path === d.path)) {
|
|
148
|
+
delivers.push(d);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
143
151
|
// Prose lexicons: list-additive across tiers (profile-schema §5.1).
|
|
144
152
|
const capAllow = unionList(base.prose.lexicons["capitalized-allow"], m.prose.lexicons["capitalized-allow"], origin);
|
|
145
153
|
const sentAbbrev = unionList(base.prose.lexicons["sentence-abbrev"], m.prose.lexicons["sentence-abbrev"], origin);
|
|
@@ -153,6 +161,7 @@ function foldTier(base, tier, diagnostics) {
|
|
|
153
161
|
types: docTypes,
|
|
154
162
|
frontMatter,
|
|
155
163
|
},
|
|
164
|
+
delivers,
|
|
156
165
|
kinds,
|
|
157
166
|
prose: {
|
|
158
167
|
lexicons: {
|
|
@@ -516,6 +525,17 @@ function stringifyMatcher(m) {
|
|
|
516
525
|
// ---------------------------------------------------------------------------
|
|
517
526
|
// Helpers: construct an EffectiveProfile from a single tier's manifest.
|
|
518
527
|
// ---------------------------------------------------------------------------
|
|
528
|
+
/** Resolve a tier's `delivers:` declarations against its baseDir (ADR-030). */
|
|
529
|
+
function deliveredFromTier(tier) {
|
|
530
|
+
return tier.manifest.delivers.map((d) => ({
|
|
531
|
+
profileId: tier.id,
|
|
532
|
+
profileVersion: tier.version,
|
|
533
|
+
path: d.path,
|
|
534
|
+
absPath: join(tier.baseDir, d.path),
|
|
535
|
+
corpus: d.corpus,
|
|
536
|
+
description: d.description,
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
519
539
|
function seedFromTier(tier) {
|
|
520
540
|
const origin = tier.id;
|
|
521
541
|
const m = tier.manifest;
|
|
@@ -529,6 +549,7 @@ function seedFromTier(tier) {
|
|
|
529
549
|
types: mapFromDocTypes(m.documents.types, origin),
|
|
530
550
|
frontMatter: mapFromAttrList(m.documents.frontMatter, origin),
|
|
531
551
|
},
|
|
552
|
+
delivers: deliveredFromTier(tier),
|
|
532
553
|
kinds: mapFromKinds(m.kinds, origin),
|
|
533
554
|
prose: {
|
|
534
555
|
lexicons: {
|
package/esm/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/esm/refs/mod.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* it (WASM-migration purity guard, AGENTS.md).
|
|
13
13
|
*/
|
|
14
14
|
import { CORE_RELATIONS, DISPLAY_ID_RE, LOCK_EXTRA_INVERSE_KEYS, ULID_RE, } from "../model/mod.js";
|
|
15
|
+
import { FENCE_RE } from "../util/fence.js";
|
|
15
16
|
/**
|
|
16
17
|
* Trace-attribute keys whose values are canonicalised/healed: the core
|
|
17
18
|
* relations plus `Verified-by`. Derived from {@linkcode CORE_RELATIONS} so new
|
|
@@ -84,12 +85,25 @@ export function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
84
85
|
};
|
|
85
86
|
const lines = content.split("\n");
|
|
86
87
|
let changed = false;
|
|
88
|
+
// Track fenced-code regions so illustrative trailers inside ``` / ~~~
|
|
89
|
+
// blocks (e.g. `Realizes: 01HGW...` in a ```markdown example) are never
|
|
90
|
+
// "healed" against the real ref index — the same verbatim-region rule
|
|
91
|
+
// every other fmt pass honors (§5.1; cf. `collapseBlankLines`). Without
|
|
92
|
+
// this, `markspec fmt` rewrites example IDs in spec/ADR docs on every run
|
|
93
|
+
// (#668). The parser/validator already treat fenced content as inert.
|
|
94
|
+
let inFence = false;
|
|
87
95
|
for (let i = 0; i < lines.length; i++) {
|
|
88
96
|
// Strip a trailing CR before matching so CRLF files are handled (the
|
|
89
97
|
// trailer regex ends in `$`, which `\r` would block) and re-append it on
|
|
90
98
|
// rewrite so line endings stay byte-for-byte lossless.
|
|
91
99
|
const cr = lines[i].endsWith("\r");
|
|
92
100
|
const bare = cr ? lines[i].slice(0, -1) : lines[i];
|
|
101
|
+
if (FENCE_RE.test(bare)) {
|
|
102
|
+
inFence = !inFence;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (inFence)
|
|
106
|
+
continue;
|
|
93
107
|
const m = TRACE_TRAILER_RE.exec(bare);
|
|
94
108
|
if (!m)
|
|
95
109
|
continue;
|
|
@@ -116,6 +130,14 @@ export function canonicalizeRefs(content, entries, index, ledger) {
|
|
|
116
130
|
j++;
|
|
117
131
|
const crj = lines[j].endsWith("\r");
|
|
118
132
|
const barej = crj ? lines[j].slice(0, -1) : lines[j];
|
|
133
|
+
// A fence marker is never continuation text. An indented one (e.g.
|
|
134
|
+
// ` ```md`) would otherwise match CONTINUATION_LINE_RE and be
|
|
135
|
+
// swallowed here without toggling `inFence`, desyncing fence tracking
|
|
136
|
+
// for the rest of the file. Back out and let the outer loop toggle it.
|
|
137
|
+
if (FENCE_RE.test(barej)) {
|
|
138
|
+
j--;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
119
141
|
const cm = CONTINUATION_LINE_RE.exec(barej);
|
|
120
142
|
if (!cm) {
|
|
121
143
|
j--; // not a continuation line — leave it for the outer loop
|
package/esm/reporter/mod.js
CHANGED
|
@@ -42,6 +42,17 @@ function filterEntries(result, scope, label) {
|
|
|
42
42
|
}
|
|
43
43
|
return entries;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Render an entry's provenance cell (ADR-030): `<profileId>@<profileVersion>`
|
|
47
|
+
* for an entry injected from a profile-delivered corpus, `"project"` for a
|
|
48
|
+
* project-authored entry. Shared by the traceability matrix builder so CSV,
|
|
49
|
+
* Markdown, and JSON rows all agree on the same value.
|
|
50
|
+
*/
|
|
51
|
+
function originCell(entry) {
|
|
52
|
+
return entry.origin
|
|
53
|
+
? `${entry.origin.profileId}@${entry.origin.profileVersion}`
|
|
54
|
+
: "project";
|
|
55
|
+
}
|
|
45
56
|
function buildTraceRows(result, entries) {
|
|
46
57
|
return entries.map((entry) => {
|
|
47
58
|
const fwd = result.forward.get(entry.displayId) ?? [];
|
|
@@ -50,6 +61,7 @@ function buildTraceRows(result, entries) {
|
|
|
50
61
|
id: entry.displayId,
|
|
51
62
|
title: entry.title,
|
|
52
63
|
entryType: entry.type ?? "",
|
|
64
|
+
origin: originCell(entry),
|
|
53
65
|
satisfies: fwd
|
|
54
66
|
.filter((l) => l.kind === "satisfies")
|
|
55
67
|
.map((l) => l.to)
|
|
@@ -67,20 +79,21 @@ function formatTraceability(result, entries, format) {
|
|
|
67
79
|
return JSON.stringify(rows, null, 2);
|
|
68
80
|
}
|
|
69
81
|
if (format === "csv") {
|
|
70
|
-
const header = "ID,Title,Type,Satisfies,Satisfied-by";
|
|
82
|
+
const header = "ID,Title,Type,Origin,Satisfies,Satisfied-by";
|
|
71
83
|
const lines = rows.map((r) => [
|
|
72
84
|
r.id,
|
|
73
85
|
csvEscape(r.title),
|
|
74
86
|
r.entryType,
|
|
87
|
+
csvEscape(r.origin),
|
|
75
88
|
csvEscape(r.satisfies),
|
|
76
89
|
csvEscape(r.satisfiedBy),
|
|
77
90
|
].join(","));
|
|
78
91
|
return [header, ...lines].join("\n");
|
|
79
92
|
}
|
|
80
93
|
// Markdown table
|
|
81
|
-
const header = "| ID | Title | Type | Satisfies | Satisfied-by |";
|
|
82
|
-
const sep = "| -- | ----- | ---- | --------- | ------------ |";
|
|
83
|
-
const lines = rows.map((r) => `| ${r.id} | ${r.title} | ${r.entryType} | ${r.satisfies || "\u2014"} | ${r.satisfiedBy || "\u2014"} |`);
|
|
94
|
+
const header = "| ID | Title | Type | Origin | Satisfies | Satisfied-by |";
|
|
95
|
+
const sep = "| -- | ----- | ---- | ------ | --------- | ------------ |";
|
|
96
|
+
const lines = rows.map((r) => `| ${r.id} | ${r.title} | ${r.entryType} | ${r.origin} | ${r.satisfies || "\u2014"} | ${r.satisfiedBy || "\u2014"} |`);
|
|
84
97
|
return [header, sep, ...lines].join("\n");
|
|
85
98
|
}
|
|
86
99
|
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,138 @@
|
|
|
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
|
+
/** Generic duplicate detectors superseded by MSL-R014 for corpus collisions. */
|
|
17
|
+
const GENERIC_DUP_CODES = new Set([
|
|
18
|
+
"MSL-R005",
|
|
19
|
+
"MSL-R006",
|
|
20
|
+
"MSL-I007",
|
|
21
|
+
"MSL-I008",
|
|
22
|
+
]);
|
|
23
|
+
export function detectCorpusCollisions(allEntries) {
|
|
24
|
+
const corpusByDisplayId = new Map();
|
|
25
|
+
const corpusById = new Map();
|
|
26
|
+
for (const e of allEntries) {
|
|
27
|
+
if (!e.origin)
|
|
28
|
+
continue;
|
|
29
|
+
if (!corpusByDisplayId.has(e.displayId)) {
|
|
30
|
+
corpusByDisplayId.set(e.displayId, e);
|
|
31
|
+
}
|
|
32
|
+
if (e.id && !corpusById.has(e.id))
|
|
33
|
+
corpusById.set(e.id, e);
|
|
34
|
+
}
|
|
35
|
+
if (corpusByDisplayId.size === 0 && corpusById.size === 0) {
|
|
36
|
+
return { diagnostics: [], collidedTokens: new Set() };
|
|
37
|
+
}
|
|
38
|
+
const diagnostics = [];
|
|
39
|
+
const collided = new Set();
|
|
40
|
+
for (const e of allEntries) {
|
|
41
|
+
if (!e.origin) {
|
|
42
|
+
const displayOwner = corpusByDisplayId.get(e.displayId);
|
|
43
|
+
if (displayOwner) {
|
|
44
|
+
collided.add(e.displayId);
|
|
45
|
+
diagnostics.push({
|
|
46
|
+
code: "MSL-R014",
|
|
47
|
+
severity: "error",
|
|
48
|
+
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
49
|
+
`${displayOwner.origin.profileId}@` +
|
|
50
|
+
`${displayOwner.origin.profileVersion}; rename this entry — ` +
|
|
51
|
+
`delivered corpus entries are read-only`,
|
|
52
|
+
location: e.location,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (e.id) {
|
|
56
|
+
const idOwner = corpusById.get(e.id);
|
|
57
|
+
if (idOwner) {
|
|
58
|
+
collided.add(e.id);
|
|
59
|
+
diagnostics.push({
|
|
60
|
+
code: "MSL-R014",
|
|
61
|
+
severity: "error",
|
|
62
|
+
message: `Id '${e.id}' is already delivered by ` +
|
|
63
|
+
`${idOwner.origin.profileId}@` +
|
|
64
|
+
`${idOwner.origin.profileVersion}; rename this entry — ` +
|
|
65
|
+
`delivered corpus entries are read-only`,
|
|
66
|
+
location: e.location,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// Corpus↔corpus inter-tier collision: a later delivered entry from a
|
|
73
|
+
// DIFFERENT profile claims a display ID (or Id) the first-registered
|
|
74
|
+
// profile already owns. Same-profile duplicates are excluded — that's
|
|
75
|
+
// the delivering profile's own authoring bug, not a read-only-boundary
|
|
76
|
+
// violation, and stays on the generic duplicate codes.
|
|
77
|
+
const displayOwner = corpusByDisplayId.get(e.displayId);
|
|
78
|
+
if (displayOwner !== e && displayOwner &&
|
|
79
|
+
displayOwner.origin.profileId !== e.origin.profileId) {
|
|
80
|
+
collided.add(e.displayId);
|
|
81
|
+
diagnostics.push({
|
|
82
|
+
code: "MSL-R014",
|
|
83
|
+
severity: "error",
|
|
84
|
+
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
85
|
+
`${displayOwner.origin.profileId}@` +
|
|
86
|
+
`${displayOwner.origin.profileVersion}; delivered corpus ` +
|
|
87
|
+
`entries are read-only`,
|
|
88
|
+
location: e.location,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (e.id) {
|
|
92
|
+
const idOwner = corpusById.get(e.id);
|
|
93
|
+
if (idOwner !== e && idOwner &&
|
|
94
|
+
idOwner.origin.profileId !== e.origin.profileId) {
|
|
95
|
+
collided.add(e.id);
|
|
96
|
+
diagnostics.push({
|
|
97
|
+
code: "MSL-R014",
|
|
98
|
+
severity: "error",
|
|
99
|
+
message: `Id '${e.id}' is already delivered by ` +
|
|
100
|
+
`${idOwner.origin.profileId}@` +
|
|
101
|
+
`${idOwner.origin.profileVersion}; delivered corpus entries ` +
|
|
102
|
+
`are read-only`,
|
|
103
|
+
location: e.location,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { diagnostics, collidedTokens: collided };
|
|
109
|
+
}
|
|
110
|
+
export function attributeCorpusDiagnostics(diagnostics, allEntries, collidedTokens) {
|
|
111
|
+
const corpusFiles = new Map();
|
|
112
|
+
for (const e of allEntries) {
|
|
113
|
+
if (e.origin) {
|
|
114
|
+
corpusFiles.set(e.location.file, `${e.origin.profileId}@${e.origin.profileVersion}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const out = [];
|
|
118
|
+
for (const d of diagnostics) {
|
|
119
|
+
// Suppress the generic duplicate codes for corpus collisions; the
|
|
120
|
+
// validator embeds the offending token in single quotes, which is what
|
|
121
|
+
// this containment check keys on.
|
|
122
|
+
if (GENERIC_DUP_CODES.has(d.code) &&
|
|
123
|
+
[...collidedTokens].some((t) => d.message.includes(`'${t}'`))) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const label = d.location ? corpusFiles.get(d.location.file) : undefined;
|
|
127
|
+
if (label !== undefined) {
|
|
128
|
+
out.push({
|
|
129
|
+
...d,
|
|
130
|
+
severity: d.severity === "error" ? "warning" : d.severity,
|
|
131
|
+
message: `delivered by ${label}: ${d.message}`,
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
out.push(d);
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
package/esm/validator/mod.d.ts
CHANGED
|
@@ -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,C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AC;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/esm/validator/mod.js
CHANGED
|
@@ -474,3 +474,4 @@ export { effectiveScope, validateAttributesForEntry } from "./attributes.js";
|
|
|
474
474
|
export { validateValue } from "./value_types.js";
|
|
475
475
|
export { normalizeListValues } from "./normalize.js";
|
|
476
476
|
export { effectiveTraceRules, matchesAnyTarget, validateTraceabilityForEntry, } from "./traceability.js";
|
|
477
|
+
export { attributeCorpusDiagnostics, detectCorpusCollisions, } from "./corpus.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driftsys/markspec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Markdown flavor and toolchain for traceable industrial documentation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"scripts": {},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@dprint/formatter": "0.5.1",
|
|
33
|
+
"@dprint/markdown": "0.20.0",
|
|
32
34
|
"@types/mdast": "^4",
|
|
33
35
|
"remark-gfm": "^4",
|
|
34
36
|
"remark-parse": "^11",
|
package/script/compiler/mod.d.ts
CHANGED
|
@@ -43,6 +43,13 @@ export interface CompileOptions {
|
|
|
43
43
|
* list is deduplicated and sorted for deterministic output.
|
|
44
44
|
*/
|
|
45
45
|
readonly withContributors?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Profile-delivered corpus entries (ADR-030), pre-loaded and
|
|
48
|
+
* origin-stamped by `loadDeliveredCorpus`. Injected AHEAD of project
|
|
49
|
+
* entries so first-entry-wins graph slots resolve to the corpus
|
|
50
|
+
* deterministically. Optional — absent means no corpus.
|
|
51
|
+
*/
|
|
52
|
+
readonly corpusEntries?: readonly Entry[];
|
|
46
53
|
}
|
|
47
54
|
/** Compiled project output with resolved traceability graph. */
|
|
48
55
|
export interface CompileResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/compiler/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,KAAK,EAEL,IAAI,EAEL,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/compiler/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,KAAK,EAEL,IAAI,EAEL,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAOjE,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,qGAAqG;IACrG,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAClB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACjD;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CACjB,IAAI,EAAE,MAAM,KACT,OAAO,CACV;QACE,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,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M,eAAe,CAAC"}
|
package/script/compiler/mod.js
CHANGED
|
@@ -114,7 +114,7 @@ class Semaphore {
|
|
|
114
114
|
*/
|
|
115
115
|
async function compile(paths, options) {
|
|
116
116
|
const read = options.readFile;
|
|
117
|
-
const allEntries = [];
|
|
117
|
+
const allEntries = [...(options.corpusEntries ?? [])];
|
|
118
118
|
const parseDiagnostics = [];
|
|
119
119
|
const documents = new Map();
|
|
120
120
|
// Phase 1: Read and parse all files with bounded concurrency (16 slots).
|
|
@@ -242,11 +242,25 @@ async function compile(paths, options) {
|
|
|
242
242
|
// diagnostics are already included in validationDiagnostics, so we discard
|
|
243
243
|
// them to avoid duplicates in the output.
|
|
244
244
|
const { registry: typeRegistry } = (0, mod_js_4.validateTypl)([...entries.values()]);
|
|
245
|
-
|
|
245
|
+
let diagnostics = [
|
|
246
246
|
...parseDiagnostics,
|
|
247
247
|
...validationDiagnostics,
|
|
248
248
|
...linkTargetDiags,
|
|
249
249
|
];
|
|
250
|
+
// Phase 5: Corpus-aware diagnostic post-pass (ADR-030). A project entry
|
|
251
|
+
// that reuses a display ID or Id already delivered by a corpus is
|
|
252
|
+
// MSL-R014, not the generic MSL-R005/R006/I007/I008 duplicate codes —
|
|
253
|
+
// and findings located inside a corpus file are downgraded to
|
|
254
|
+
// attributed warnings so consumer builds don't go red over upstream
|
|
255
|
+
// bugs they cannot fix. No-op (and zero allocation beyond the spread
|
|
256
|
+
// above) when no corpus was injected.
|
|
257
|
+
if (options.corpusEntries && options.corpusEntries.length > 0) {
|
|
258
|
+
const collisions = (0, mod_js_3.detectCorpusCollisions)(allEntries);
|
|
259
|
+
diagnostics = [
|
|
260
|
+
...(0, mod_js_3.attributeCorpusDiagnostics)(diagnostics, allEntries, collisions.collidedTokens),
|
|
261
|
+
...collisions.diagnostics,
|
|
262
|
+
];
|
|
263
|
+
}
|
|
250
264
|
return {
|
|
251
265
|
entries,
|
|
252
266
|
links,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* interchange.
|
|
7
7
|
*/
|
|
8
8
|
import type { CompileResult } from "./mod.js";
|
|
9
|
-
import type { Diagnostic, Entry, Link } from "../model/mod.js";
|
|
9
|
+
import type { Diagnostic, Entry, EntryOrigin, Link } from "../model/mod.js";
|
|
10
10
|
import type { RegistryBinding, RegistryTypedef } from "../typl/mod.js";
|
|
11
11
|
/**
|
|
12
12
|
* JSON-serializable form of {@linkcode Entry}.
|
|
@@ -14,9 +14,16 @@ import type { RegistryBinding, RegistryTypedef } from "../typl/mod.js";
|
|
|
14
14
|
* Identical to `Entry` except `typedAttributes` is a plain
|
|
15
15
|
* `Record<string, readonly string[]>` instead of a `ReadonlyMap` — Maps are
|
|
16
16
|
* not JSON-serializable. All other fields are passed through unchanged.
|
|
17
|
+
*
|
|
18
|
+
* `origin` (ADR-030) is restated explicitly here — rather than relying on
|
|
19
|
+
* the `Omit<Entry, ...>` passthrough — so the field-presence contract is
|
|
20
|
+
* documented at the serialization boundary: present verbatim on entries
|
|
21
|
+
* injected from a profile-delivered corpus, absent (not `null`) on
|
|
22
|
+
* project-authored entries.
|
|
17
23
|
*/
|
|
18
24
|
export type SerializedEntry = Omit<Entry, "typedAttributes"> & {
|
|
19
25
|
readonly typedAttributes?: Record<string, readonly string[]>;
|
|
26
|
+
readonly origin?: EntryOrigin;
|
|
20
27
|
};
|
|
21
28
|
/**
|
|
22
29
|
* Serialized form of the {@linkcode TypeRegistry}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/compiler/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/compiler/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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,YAAY,EAAE,sBAAsB,CAAC;CAC/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,GACpB,uBAAuB,CAazB;AAgBD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CA4B5D"}
|
|
@@ -61,9 +61,16 @@ function serializeEntry(entry) {
|
|
|
61
61
|
const { sync: _sync, ...rest } = properties;
|
|
62
62
|
properties = Object.keys(rest).length > 0 ? rest : undefined;
|
|
63
63
|
}
|
|
64
|
+
// Pull `origin` (ADR-030) out of the spread so the key is entirely
|
|
65
|
+
// absent — not `origin: undefined` — on entries that did not come
|
|
66
|
+
// from a delivered corpus, matching the serialized-field-presence
|
|
67
|
+
// contract. Object rest destructuring drops the named key regardless
|
|
68
|
+
// of its value, unlike `...entry` alone.
|
|
69
|
+
const { origin, ...rest } = entry;
|
|
64
70
|
return {
|
|
65
|
-
...
|
|
71
|
+
...rest,
|
|
66
72
|
typedAttributes,
|
|
67
73
|
properties,
|
|
74
|
+
...(origin ? { origin } : {}),
|
|
68
75
|
};
|
|
69
76
|
}
|