@driftsys/markspec 0.7.1 → 0.7.3
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/config/markspec.d.ts +17 -0
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +30 -1
- package/esm/lock/mod.d.ts +2 -2
- package/esm/lock/mod.d.ts.map +1 -1
- package/esm/lock/mod.js +1 -1
- package/esm/lock/model.d.ts +25 -0
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +20 -0
- package/esm/lock/resolve.d.ts +19 -1
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +47 -1
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +31 -0
- package/esm/mod.d.ts +9 -7
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +6 -4
- package/esm/model/mod.d.ts +16 -0
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +16 -0
- package/esm/profile/display_id.d.ts +78 -25
- package/esm/profile/display_id.d.ts.map +1 -1
- package/esm/profile/display_id.js +164 -26
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +19 -0
- package/esm/profile/mod.d.ts +2 -2
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +1 -1
- package/esm/refs/mod.d.ts +43 -0
- package/esm/refs/mod.d.ts.map +1 -0
- package/esm/refs/mod.js +128 -0
- package/esm/validator/mod.d.ts +1 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/pattern.d.ts +47 -13
- package/esm/validator/pattern.d.ts.map +1 -1
- package/esm/validator/pattern.js +91 -41
- package/esm/validator/pipeline.d.ts +15 -1
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +16 -7
- package/esm/validator/traceability.d.ts +6 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +23 -5
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +10 -4
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +4 -2
- package/package.json +1 -1
- package/script/config/markspec.d.ts +17 -0
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +30 -0
- package/script/lock/mod.d.ts +2 -2
- package/script/lock/mod.d.ts.map +1 -1
- package/script/lock/mod.js +2 -1
- package/script/lock/model.d.ts +25 -0
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +20 -0
- package/script/lock/resolve.d.ts +19 -1
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +47 -0
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +31 -0
- package/script/mod.d.ts +9 -7
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +30 -22
- package/script/model/mod.d.ts +16 -0
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +17 -1
- package/script/profile/display_id.d.ts +78 -25
- package/script/profile/display_id.d.ts.map +1 -1
- package/script/profile/display_id.js +166 -26
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +19 -0
- package/script/profile/mod.d.ts +2 -2
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +2 -1
- package/script/refs/mod.d.ts +43 -0
- package/script/refs/mod.d.ts.map +1 -0
- package/script/refs/mod.js +133 -0
- package/script/validator/mod.d.ts +1 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/pattern.d.ts +47 -13
- package/script/validator/pattern.d.ts.map +1 -1
- package/script/validator/pattern.js +92 -41
- package/script/validator/pipeline.d.ts +15 -1
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +16 -7
- package/script/validator/traceability.d.ts +6 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +23 -5
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +9 -3
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +3 -1
|
@@ -1,30 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module core/validator/pattern
|
|
3
3
|
*
|
|
4
|
-
* Display-ID pattern template → anchored RegExp
|
|
4
|
+
* Display-ID pattern template → anchored RegExp (the classification half of
|
|
5
|
+
* the grammar). The tokenizer and well-formedness oracle live in
|
|
6
|
+
* `core/profile/display_id.ts` — {@linkcode tokenizePattern} and
|
|
7
|
+
* {@linkcode validateDisplayIdPattern} — and are shared with the
|
|
8
|
+
* minting/scaffold parser so the two never disagree about which forms are
|
|
9
|
+
* valid (#596). This module only builds the recognizer regex.
|
|
5
10
|
*
|
|
6
|
-
*
|
|
7
|
-
* pattern := segment+ (exactly one counter)
|
|
8
|
-
* segment := literal | counter | named
|
|
9
|
-
* counter := "{n}" | "{n:" PADDING "d}"
|
|
10
|
-
* named := "{" identifier "}" (e.g. {scope}, {feature})
|
|
11
|
-
* PADDING := "0" digits
|
|
11
|
+
* A pattern is one of two kinds, selected by whether it contains a counter:
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* numbered := segment+ (exactly one counter) — mintable + classifying
|
|
14
|
+
* named := segment+ (literal anchor, ≥1 named, no counter) — classifying
|
|
15
|
+
*
|
|
16
|
+
* segment := literal | counter | named
|
|
17
|
+
* counter := "{n}" | "{n:" digits "d}" (e.g. {n}, {n:4d}, {n:04d})
|
|
18
|
+
* named := "{" identifier "}" (e.g. {scope}, {name})
|
|
19
|
+
*
|
|
20
|
+
* **Numbered patterns** carry exactly one counter — the numeric running
|
|
21
|
+
* index used both for classification (a recognizer regex) and for minting the
|
|
22
|
+
* next ID. A medial named placeholder such as `{scope}` matches a single free
|
|
23
|
+
* alphanumeric segment, so one pattern serves every feature scope.
|
|
24
|
+
*
|
|
25
|
+
* **Named patterns** (ADR-025, issue #594) carry no counter — they classify
|
|
26
|
+
* types whose IDs are *named, not numbered* (e.g. components `SWC_LIGHT_CTRL`,
|
|
27
|
+
* `HWC_PIU`). They require a non-empty literal anchor plus at least one named
|
|
28
|
+
* placeholder; the trailing named placeholder captures the rest of the
|
|
29
|
+
* display ID (underscores, dots, slashes, hyphens included). A bare `{name}`
|
|
30
|
+
* with no literal anchor is rejected — it would match every ID and collide
|
|
31
|
+
* with every type. Named patterns are not mintable (no counter to increment);
|
|
32
|
+
* `parseDisplayIdPattern` skips them so the scaffold/next-id paths fall back
|
|
33
|
+
* to author-typed IDs.
|
|
17
34
|
*
|
|
18
35
|
* Examples:
|
|
19
36
|
* REQ-{n} → ^REQ-(\d+)$
|
|
20
37
|
* REQ-{n:04d} → ^REQ-(\d{4})$
|
|
38
|
+
* STK_{n:4d} → ^STK_(\d{4})$
|
|
21
39
|
* XREQ_{scope}_{n:04d} → ^XREQ_(?<scope>[A-Za-z0-9]+)_(\d{4})$
|
|
40
|
+
* SWC_{name} → ^SWC_(?<name>[A-Za-z0-9._/-]+)$
|
|
22
41
|
*/
|
|
23
42
|
/**
|
|
24
43
|
* Compile a display-ID pattern template into an anchored RegExp.
|
|
25
44
|
*
|
|
26
|
-
* Throws
|
|
27
|
-
*
|
|
45
|
+
* Throws the {@linkcode validateDisplayIdPattern} reason when the template is
|
|
46
|
+
* malformed (more than one counter, a malformed/zero-width padding specifier,
|
|
47
|
+
* no variable part, a counter-less pattern without a literal anchor, or a
|
|
48
|
+
* duplicate named placeholder). Validating first guarantees `new RegExp`
|
|
49
|
+
* below never sees a duplicate capture name.
|
|
28
50
|
*/
|
|
29
51
|
export declare function compileDisplayIdPattern(template: string): RegExp;
|
|
52
|
+
/**
|
|
53
|
+
* Compile a display-ID pattern, returning `undefined` instead of throwing when
|
|
54
|
+
* the template is malformed.
|
|
55
|
+
*
|
|
56
|
+
* Defensive guard for the classification stage: the canonical fix rejects a
|
|
57
|
+
* malformed `display-id-pattern` at profile-load (`PROFILE-TYPE-008`, #597),
|
|
58
|
+
* but until that fix is on the same branch a bad pattern reaching
|
|
59
|
+
* classification must not crash `markspec check` with an uncaught throw
|
|
60
|
+
* (clig.dev: never surface a raw stack trace). A skipped type simply does not
|
|
61
|
+
* classify — the entry surfaces as `MSL-T003` rather than a crash.
|
|
62
|
+
*/
|
|
63
|
+
export declare function tryCompileDisplayIdPattern(template: string): RegExp | undefined;
|
|
30
64
|
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/validator/pattern.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/validator/pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAuBH;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA+BhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAMpB"}
|
|
@@ -2,68 +2,119 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @module core/validator/pattern
|
|
4
4
|
*
|
|
5
|
-
* Display-ID pattern template → anchored RegExp
|
|
5
|
+
* Display-ID pattern template → anchored RegExp (the classification half of
|
|
6
|
+
* the grammar). The tokenizer and well-formedness oracle live in
|
|
7
|
+
* `core/profile/display_id.ts` — {@linkcode tokenizePattern} and
|
|
8
|
+
* {@linkcode validateDisplayIdPattern} — and are shared with the
|
|
9
|
+
* minting/scaffold parser so the two never disagree about which forms are
|
|
10
|
+
* valid (#596). This module only builds the recognizer regex.
|
|
6
11
|
*
|
|
7
|
-
*
|
|
8
|
-
* pattern := segment+ (exactly one counter)
|
|
9
|
-
* segment := literal | counter | named
|
|
10
|
-
* counter := "{n}" | "{n:" PADDING "d}"
|
|
11
|
-
* named := "{" identifier "}" (e.g. {scope}, {feature})
|
|
12
|
-
* PADDING := "0" digits
|
|
12
|
+
* A pattern is one of two kinds, selected by whether it contains a counter:
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* numbered := segment+ (exactly one counter) — mintable + classifying
|
|
15
|
+
* named := segment+ (literal anchor, ≥1 named, no counter) — classifying
|
|
16
|
+
*
|
|
17
|
+
* segment := literal | counter | named
|
|
18
|
+
* counter := "{n}" | "{n:" digits "d}" (e.g. {n}, {n:4d}, {n:04d})
|
|
19
|
+
* named := "{" identifier "}" (e.g. {scope}, {name})
|
|
20
|
+
*
|
|
21
|
+
* **Numbered patterns** carry exactly one counter — the numeric running
|
|
22
|
+
* index used both for classification (a recognizer regex) and for minting the
|
|
23
|
+
* next ID. A medial named placeholder such as `{scope}` matches a single free
|
|
24
|
+
* alphanumeric segment, so one pattern serves every feature scope.
|
|
25
|
+
*
|
|
26
|
+
* **Named patterns** (ADR-025, issue #594) carry no counter — they classify
|
|
27
|
+
* types whose IDs are *named, not numbered* (e.g. components `SWC_LIGHT_CTRL`,
|
|
28
|
+
* `HWC_PIU`). They require a non-empty literal anchor plus at least one named
|
|
29
|
+
* placeholder; the trailing named placeholder captures the rest of the
|
|
30
|
+
* display ID (underscores, dots, slashes, hyphens included). A bare `{name}`
|
|
31
|
+
* with no literal anchor is rejected — it would match every ID and collide
|
|
32
|
+
* with every type. Named patterns are not mintable (no counter to increment);
|
|
33
|
+
* `parseDisplayIdPattern` skips them so the scaffold/next-id paths fall back
|
|
34
|
+
* to author-typed IDs.
|
|
18
35
|
*
|
|
19
36
|
* Examples:
|
|
20
37
|
* REQ-{n} → ^REQ-(\d+)$
|
|
21
38
|
* REQ-{n:04d} → ^REQ-(\d{4})$
|
|
39
|
+
* STK_{n:4d} → ^STK_(\d{4})$
|
|
22
40
|
* XREQ_{scope}_{n:04d} → ^XREQ_(?<scope>[A-Za-z0-9]+)_(\d{4})$
|
|
41
|
+
* SWC_{name} → ^SWC_(?<name>[A-Za-z0-9._/-]+)$
|
|
23
42
|
*/
|
|
24
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
44
|
exports.compileDisplayIdPattern = compileDisplayIdPattern;
|
|
26
|
-
|
|
27
|
-
const
|
|
45
|
+
exports.tryCompileDisplayIdPattern = tryCompileDisplayIdPattern;
|
|
46
|
+
const display_id_js_1 = require("../profile/display_id.js");
|
|
47
|
+
/**
|
|
48
|
+
* Character class for the trailing named placeholder of a *named* pattern —
|
|
49
|
+
* the established display-ID token set (letters, digits, underscore, dot,
|
|
50
|
+
* slash, hyphen). Wider than the medial-segment class so `SWC_{name}` matches
|
|
51
|
+
* underscore-bearing IDs like `SWC_LIGHT_CTRL`.
|
|
52
|
+
*/
|
|
53
|
+
const REST_OF_ID_CLASS = "[A-Za-z0-9._/-]+";
|
|
54
|
+
/**
|
|
55
|
+
* Character class for a medial named placeholder (e.g. `{scope}` between two
|
|
56
|
+
* literal segments). A single free alphanumeric run that stops at the next
|
|
57
|
+
* literal — never swallows an adjacent counter or separator.
|
|
58
|
+
*/
|
|
59
|
+
const SEGMENT_CLASS = "[A-Za-z0-9]+";
|
|
28
60
|
/**
|
|
29
61
|
* Compile a display-ID pattern template into an anchored RegExp.
|
|
30
62
|
*
|
|
31
|
-
* Throws
|
|
32
|
-
*
|
|
63
|
+
* Throws the {@linkcode validateDisplayIdPattern} reason when the template is
|
|
64
|
+
* malformed (more than one counter, a malformed/zero-width padding specifier,
|
|
65
|
+
* no variable part, a counter-less pattern without a literal anchor, or a
|
|
66
|
+
* duplicate named placeholder). Validating first guarantees `new RegExp`
|
|
67
|
+
* below never sees a duplicate capture name.
|
|
33
68
|
*/
|
|
34
69
|
function compileDisplayIdPattern(template) {
|
|
70
|
+
const validation = (0, display_id_js_1.validateDisplayIdPattern)(template);
|
|
71
|
+
if (!validation.ok)
|
|
72
|
+
throw new Error(validation.message);
|
|
73
|
+
const tokens = (0, display_id_js_1.tokenizePattern)(template);
|
|
74
|
+
const counters = tokens.filter((t) => t.kind === "counter").length;
|
|
75
|
+
// In a named (counter-less) pattern the trailing named placeholder matches
|
|
76
|
+
// the rest of the display ID; every other named placeholder — and every
|
|
77
|
+
// named placeholder in a numbered pattern — stays a single segment.
|
|
78
|
+
const restOfIdNamedIndex = counters === 0
|
|
79
|
+
? tokens.reduce((acc, t, i) => (t.kind === "named" ? i : acc), -1)
|
|
80
|
+
: -1;
|
|
35
81
|
let regexSource = "^";
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
let match;
|
|
40
|
-
while ((match = re.exec(template)) !== null) {
|
|
41
|
-
regexSource += escapeRegex(template.slice(lastIndex, match.index));
|
|
42
|
-
const named = match[2];
|
|
43
|
-
if (named === undefined) {
|
|
44
|
-
// {n} / {n:0Nd} counter
|
|
45
|
-
const padding = match[1];
|
|
46
|
-
regexSource += "(" + (padding ? `\\d{${Number(padding)}}` : `\\d+`) + ")";
|
|
47
|
-
counters++;
|
|
82
|
+
tokens.forEach((t, i) => {
|
|
83
|
+
if (t.kind === "literal") {
|
|
84
|
+
regexSource += escapeRegex(t.text);
|
|
48
85
|
}
|
|
49
|
-
else {
|
|
50
|
-
|
|
51
|
-
|
|
86
|
+
else if (t.kind === "counter") {
|
|
87
|
+
regexSource += "(" +
|
|
88
|
+
(t.padding ? `\\d{${Number(t.padding)}}` : `\\d+`) + ")";
|
|
52
89
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw new Error(`display-id-pattern '${template}': invalid padding specifier ` +
|
|
59
|
-
`(expected {n} or {n:NNd})`);
|
|
90
|
+
else {
|
|
91
|
+
const charClass = i === restOfIdNamedIndex
|
|
92
|
+
? REST_OF_ID_CLASS
|
|
93
|
+
: SEGMENT_CLASS;
|
|
94
|
+
regexSource += `(?<${t.name}>${charClass})`;
|
|
60
95
|
}
|
|
61
|
-
|
|
96
|
+
});
|
|
97
|
+
regexSource += "$";
|
|
98
|
+
return new RegExp(regexSource);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Compile a display-ID pattern, returning `undefined` instead of throwing when
|
|
102
|
+
* the template is malformed.
|
|
103
|
+
*
|
|
104
|
+
* Defensive guard for the classification stage: the canonical fix rejects a
|
|
105
|
+
* malformed `display-id-pattern` at profile-load (`PROFILE-TYPE-008`, #597),
|
|
106
|
+
* but until that fix is on the same branch a bad pattern reaching
|
|
107
|
+
* classification must not crash `markspec check` with an uncaught throw
|
|
108
|
+
* (clig.dev: never surface a raw stack trace). A skipped type simply does not
|
|
109
|
+
* classify — the entry surfaces as `MSL-T003` rather than a crash.
|
|
110
|
+
*/
|
|
111
|
+
function tryCompileDisplayIdPattern(template) {
|
|
112
|
+
try {
|
|
113
|
+
return compileDisplayIdPattern(template);
|
|
62
114
|
}
|
|
63
|
-
|
|
64
|
-
|
|
115
|
+
catch {
|
|
116
|
+
return undefined;
|
|
65
117
|
}
|
|
66
|
-
return new RegExp(regexSource);
|
|
67
118
|
}
|
|
68
119
|
function escapeRegex(s) {
|
|
69
120
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -16,6 +16,18 @@ export interface PipelineResult {
|
|
|
16
16
|
/** `true` when no error-severity diagnostics were emitted. */
|
|
17
17
|
readonly valid: boolean;
|
|
18
18
|
}
|
|
19
|
+
/** Options for {@linkcode runPipeline}. */
|
|
20
|
+
export interface PipelineOptions {
|
|
21
|
+
/**
|
|
22
|
+
* When `false`, suppress MSL-L006 ("link target does not resolve") from
|
|
23
|
+
* Stage 4 output. Use this when the validator is running against a subset
|
|
24
|
+
* of the project's files (e.g. `markspec check <file>`): file-local scope
|
|
25
|
+
* cannot distinguish a typo from a valid cross-file target. MSL-L006 is
|
|
26
|
+
* only meaningful when the full entry set is available (LSP, `compile`).
|
|
27
|
+
* Defaults to `true` (full-project scope — emit MSL-L006 normally).
|
|
28
|
+
*/
|
|
29
|
+
readonly projectWide?: boolean;
|
|
30
|
+
}
|
|
19
31
|
/**
|
|
20
32
|
* Run the validator pipeline.
|
|
21
33
|
*
|
|
@@ -30,8 +42,10 @@ export interface PipelineResult {
|
|
|
30
42
|
* conventions (from `ProjectConfig.captionConventions`). When supplied
|
|
31
43
|
* and non-empty, MSL-C072 is checked for each entry. Defaults to no
|
|
32
44
|
* conventions (rule inactive).
|
|
45
|
+
* @param opts - Pipeline options. Pass `{ projectWide: false }` when
|
|
46
|
+
* validating a file-local subset so MSL-L006 is suppressed.
|
|
33
47
|
*/
|
|
34
|
-
export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions): PipelineResult;
|
|
48
|
+
export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions, opts?: PipelineOptions): PipelineResult;
|
|
35
49
|
/**
|
|
36
50
|
* Drop core Stage 1 `MSL-R010` ("unknown attribute") warnings for attributes
|
|
37
51
|
* the loaded profile declares — Stage 3 validates those directly, so the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;AAsBzB,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;AAsBzB,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,EAChC,kBAAkB,GAAE,kBAAuB,EAC3C,IAAI,GAAE,eAAoB,GACzB,cAAc,CA0GhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CASvB"}
|
|
@@ -40,8 +40,10 @@ const discipline_registry_js_1 = require("../profile/discipline_registry.js");
|
|
|
40
40
|
* conventions (from `ProjectConfig.captionConventions`). When supplied
|
|
41
41
|
* and non-empty, MSL-C072 is checked for each entry. Defaults to no
|
|
42
42
|
* conventions (rule inactive).
|
|
43
|
+
* @param opts - Pipeline options. Pass `{ projectWide: false }` when
|
|
44
|
+
* validating a file-local subset so MSL-L006 is suppressed.
|
|
43
45
|
*/
|
|
44
|
-
function runPipeline(entries, profile, captionConventions = {}) {
|
|
46
|
+
function runPipeline(entries, profile, captionConventions = {}, opts = {}) {
|
|
45
47
|
const diagnostics = [];
|
|
46
48
|
// Stage 1 — core hygiene. When a profile is loaded, suppress MSL-R010
|
|
47
49
|
// warnings for attributes the profile actually declares (Stage 3's scope
|
|
@@ -103,18 +105,25 @@ function runPipeline(entries, profile, captionConventions = {}) {
|
|
|
103
105
|
diagnostics.push(...stage3);
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
|
-
// Stage 4 — traceability rules (only when a profile is loaded). Builds
|
|
107
|
-
//
|
|
108
|
-
//
|
|
108
|
+
// Stage 4 — traceability rules (only when a profile is loaded). Builds two
|
|
109
|
+
// indexes: by `entry.id` (ULID) and by `entry.displayId`, so trace values
|
|
110
|
+
// resolve in either form (issue #593).
|
|
109
111
|
if (profile !== null) {
|
|
110
112
|
const graph = new Map();
|
|
113
|
+
const byDisplayId = new Map();
|
|
111
114
|
for (const e of finalEntries) {
|
|
112
|
-
if (e.id)
|
|
115
|
+
if (e.id && !graph.has(e.id))
|
|
113
116
|
graph.set(e.id, e);
|
|
117
|
+
if (!byDisplayId.has(e.displayId))
|
|
118
|
+
byDisplayId.set(e.displayId, e);
|
|
114
119
|
}
|
|
120
|
+
const projectWide = opts.projectWide !== false;
|
|
115
121
|
for (const entry of finalEntries) {
|
|
116
|
-
const stage4 = (0, traceability_js_1.validateTraceabilityForEntry)(entry, profile, graph);
|
|
117
|
-
|
|
122
|
+
const stage4 = (0, traceability_js_1.validateTraceabilityForEntry)(entry, profile, graph, byDisplayId);
|
|
123
|
+
// Suppress MSL-L006 ("link target does not resolve") when running
|
|
124
|
+
// file-locally: the checked subset cannot distinguish a typo from a
|
|
125
|
+
// valid cross-file target. Only emit when the full entry set is present.
|
|
126
|
+
diagnostics.push(...projectWide ? stage4 : stage4.filter((d) => d.code !== "MSL-L006"));
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
129
|
const valid = !diagnostics.some((d) => d.severity === "error");
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
* - Required (MSL-L001)
|
|
10
10
|
* - Cardinality bounds (MSL-L002 upper / MSL-L003 lower)
|
|
11
11
|
* - Target match against the rule's target matchers (MSL-L004)
|
|
12
|
+
* - Target existence (MSL-L006, warning; scheme-qualified URIs exempt)
|
|
12
13
|
*
|
|
13
14
|
* Referenced entries are skipped entirely — the profile manifest parser
|
|
14
15
|
* rejects `referenced.traceability` at load time, so referenced entries
|
|
15
16
|
* never have declared outgoing links.
|
|
16
17
|
*/
|
|
17
|
-
import type
|
|
18
|
+
import { type Diagnostic, type EffectiveProfile, type Entry, type TargetMatcher, type TraceRule } from "../model/mod.js";
|
|
18
19
|
/**
|
|
19
20
|
* Effective trace rules for an entry: type-scope rules only.
|
|
20
21
|
* Type-scope rules are applied only when the entry is classified.
|
|
@@ -41,7 +42,9 @@ export declare function matchesAnyTarget(target: Entry, matchers: readonly Targe
|
|
|
41
42
|
* @param entry - The entry to validate (after Stage 2 classification +
|
|
42
43
|
* Stage 2.5 normalization)
|
|
43
44
|
* @param profile - The effective profile (null → never called)
|
|
44
|
-
* @param graph - Index keyed by entry.id for target lookup
|
|
45
|
+
* @param graph - Index keyed by entry.id (ULID) for target lookup
|
|
46
|
+
* @param byDisplayId - Index keyed by entry.displayId for target lookup
|
|
47
|
+
* (issue #593 — display-ID targets). Defaults to empty.
|
|
45
48
|
*/
|
|
46
|
-
export declare function validateTraceabilityForEntry(entry: Entry, profile: EffectiveProfile, graph: ReadonlyMap<string, Entry>): Diagnostic[];
|
|
49
|
+
export declare function validateTraceabilityForEntry(entry: Entry, profile: EffectiveProfile, graph: ReadonlyMap<string, Entry>, byDisplayId?: ReadonlyMap<string, Entry>): Diagnostic[];
|
|
47
50
|
//# sourceMappingURL=traceability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAehC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,OAAO,CAST;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,EACjC,WAAW,GAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAa,GAClD,UAAU,EAAE,CAsFd"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - Required (MSL-L001)
|
|
11
11
|
* - Cardinality bounds (MSL-L002 upper / MSL-L003 lower)
|
|
12
12
|
* - Target match against the rule's target matchers (MSL-L004)
|
|
13
|
+
* - Target existence (MSL-L006, warning; scheme-qualified URIs exempt)
|
|
13
14
|
*
|
|
14
15
|
* Referenced entries are skipped entirely — the profile manifest parser
|
|
15
16
|
* rejects `referenced.traceability` at load time, so referenced entries
|
|
@@ -19,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
20
|
exports.effectiveTraceRules = effectiveTraceRules;
|
|
20
21
|
exports.matchesAnyTarget = matchesAnyTarget;
|
|
21
22
|
exports.validateTraceabilityForEntry = validateTraceabilityForEntry;
|
|
23
|
+
const mod_js_1 = require("../model/mod.js");
|
|
22
24
|
/**
|
|
23
25
|
* Effective trace rules for an entry: type-scope rules only.
|
|
24
26
|
* Type-scope rules are applied only when the entry is classified.
|
|
@@ -71,9 +73,11 @@ function matchesAnyTarget(target, matchers) {
|
|
|
71
73
|
* @param entry - The entry to validate (after Stage 2 classification +
|
|
72
74
|
* Stage 2.5 normalization)
|
|
73
75
|
* @param profile - The effective profile (null → never called)
|
|
74
|
-
* @param graph - Index keyed by entry.id for target lookup
|
|
76
|
+
* @param graph - Index keyed by entry.id (ULID) for target lookup
|
|
77
|
+
* @param byDisplayId - Index keyed by entry.displayId for target lookup
|
|
78
|
+
* (issue #593 — display-ID targets). Defaults to empty.
|
|
75
79
|
*/
|
|
76
|
-
function validateTraceabilityForEntry(entry, profile, graph) {
|
|
80
|
+
function validateTraceabilityForEntry(entry, profile, graph, byDisplayId = new Map()) {
|
|
77
81
|
const diagnostics = [];
|
|
78
82
|
if (entry.shape !== "Authored")
|
|
79
83
|
return diagnostics;
|
|
@@ -113,11 +117,25 @@ function validateTraceabilityForEntry(entry, profile, graph) {
|
|
|
113
117
|
location: entry.location,
|
|
114
118
|
});
|
|
115
119
|
}
|
|
116
|
-
// MSL-L004
|
|
120
|
+
// MSL-L004 target match + MSL-L006 existence, for each resolved value.
|
|
121
|
+
// Resolve by ULID (graph) first, then by display ID (byDisplayId) — the
|
|
122
|
+
// dual-resolution spine (issue #593).
|
|
117
123
|
for (const v of values) {
|
|
118
|
-
const target = graph.get(v);
|
|
119
|
-
if (!target)
|
|
124
|
+
const target = graph.get(v) ?? byDisplayId.get(v);
|
|
125
|
+
if (!target) {
|
|
126
|
+
// Scheme-qualified URIs are intentionally external — never local
|
|
127
|
+
// graph targets, so they are not "broken references".
|
|
128
|
+
if (mod_js_1.URI_SCHEME_RE.test(v))
|
|
129
|
+
continue;
|
|
130
|
+
diagnostics.push({
|
|
131
|
+
code: "MSL-L006",
|
|
132
|
+
severity: "warning",
|
|
133
|
+
message: `${entry.displayId}: link '${linkName}' target '${v}' does not ` +
|
|
134
|
+
`resolve to any entry`,
|
|
135
|
+
location: entry.location,
|
|
136
|
+
});
|
|
120
137
|
continue;
|
|
138
|
+
}
|
|
121
139
|
if (!matchesAnyTarget(target, rule.target)) {
|
|
122
140
|
diagnostics.push({
|
|
123
141
|
code: "MSL-L004",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,KAAK,EAEN,MAAM,iBAAiB,CAAC;AAwBzB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAWvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAiBvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CAwBvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,KAAK,EAEN,MAAM,iBAAiB,CAAC;AAwBzB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAWvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAiBvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CAwBvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,cAAc,CAiEhB;AAED,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GACxB,mBAAmB,CAuBrB"}
|
|
@@ -174,7 +174,11 @@ function classifyEntry(entry, profile) {
|
|
|
174
174
|
const pattern = typeEntry.value.displayIdPattern.value;
|
|
175
175
|
if (pattern === undefined)
|
|
176
176
|
continue;
|
|
177
|
-
|
|
177
|
+
// A malformed pattern must not crash classification — skip it (canonical
|
|
178
|
+
// fix: load-time PROFILE-TYPE-008, #597).
|
|
179
|
+
const regex = (0, pattern_js_1.tryCompileDisplayIdPattern)(pattern);
|
|
180
|
+
if (regex === undefined)
|
|
181
|
+
continue;
|
|
178
182
|
if (regex.test(entry.displayId)) {
|
|
179
183
|
matches.push(typeName);
|
|
180
184
|
}
|
|
@@ -246,8 +250,10 @@ function checkEnforcement(entry, typeEntry) {
|
|
|
246
250
|
const level = typeEntry.value.displayIdPatternEnforcement.value;
|
|
247
251
|
if (level === "off")
|
|
248
252
|
return undefined;
|
|
249
|
-
|
|
250
|
-
|
|
253
|
+
// A malformed pattern cannot enforce anything — skip rather than crash
|
|
254
|
+
// (canonical fix: load-time PROFILE-TYPE-008, #597).
|
|
255
|
+
const regex = (0, pattern_js_1.tryCompileDisplayIdPattern)(pattern);
|
|
256
|
+
if (regex === undefined || regex.test(entry.displayId))
|
|
251
257
|
return undefined;
|
|
252
258
|
return {
|
|
253
259
|
code: "MSL-T004",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AA+C9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
|
|
@@ -59,7 +59,9 @@ const validateId = (value, _decl) => {
|
|
|
59
59
|
return null;
|
|
60
60
|
if (mod_js_1.URI_SCHEME_RE.test(value))
|
|
61
61
|
return null;
|
|
62
|
-
|
|
62
|
+
if (mod_js_1.DISPLAY_ID_RE.test(value))
|
|
63
|
+
return null;
|
|
64
|
+
return `not a valid id: '${value}' (expected a display ID, 26-char ULID, or scheme-qualified URI)`;
|
|
63
65
|
};
|
|
64
66
|
/**
|
|
65
67
|
* HTTP(S) URL prefix used by the `url` value type (spec §1.8). The
|