@driftsys/markspec 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/ast/build.d.ts.map +1 -1
- package/esm/ast/build.js +19 -5
- package/esm/ast/equivalence.js +14 -2
- package/esm/ast/nodes.d.ts +15 -3
- package/esm/ast/nodes.d.ts.map +1 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +18 -3
- package/esm/compiler/mod.d.ts +34 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +112 -48
- package/esm/compiler/schema.d.ts +3 -2
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +6 -3
- package/esm/criteria/scenarios.d.ts +55 -0
- package/esm/criteria/scenarios.d.ts.map +1 -0
- package/esm/criteria/scenarios.js +133 -0
- package/esm/discovery/mod.d.ts +20 -1
- package/esm/discovery/mod.d.ts.map +1 -1
- package/esm/discovery/mod.js +105 -17
- package/esm/formatter/entry_body.d.ts +8 -5
- package/esm/formatter/entry_body.d.ts.map +1 -1
- package/esm/formatter/entry_body.js +12 -8
- package/esm/formatter/feature_file.d.ts +40 -0
- package/esm/formatter/feature_file.d.ts.map +1 -0
- package/esm/formatter/feature_file.js +88 -0
- package/esm/formatter/mod.d.ts +21 -2
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +64 -22
- package/esm/gates/mod.d.ts +2 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +17 -2
- package/esm/gherkin/load.d.ts +35 -0
- package/esm/gherkin/load.d.ts.map +1 -0
- package/esm/gherkin/load.js +39 -0
- package/esm/gherkin/parse.d.ts +11 -0
- package/esm/gherkin/parse.d.ts.map +1 -0
- package/esm/gherkin/parse.js +311 -0
- package/esm/gherkin/position.d.ts +23 -0
- package/esm/gherkin/position.d.ts.map +1 -0
- package/esm/gherkin/position.js +21 -0
- package/esm/gherkin/procedure.d.ts +76 -0
- package/esm/gherkin/procedure.d.ts.map +1 -0
- package/esm/gherkin/procedure.js +164 -0
- package/esm/gherkin/project.d.ts +35 -0
- package/esm/gherkin/project.d.ts.map +1 -0
- package/esm/gherkin/project.js +64 -0
- package/esm/gherkin/role.d.ts +23 -0
- package/esm/gherkin/role.d.ts.map +1 -0
- package/esm/gherkin/role.js +28 -0
- package/esm/gherkin/types.d.ts +118 -0
- package/esm/gherkin/types.d.ts.map +1 -0
- package/esm/gherkin/types.js +12 -0
- package/esm/lock/acquire_compile.d.ts +12 -4
- package/esm/lock/acquire_compile.d.ts.map +1 -1
- package/esm/lock/acquire_compile.js +15 -5
- package/esm/lock/canonical_edges.d.ts +6 -2
- package/esm/lock/canonical_edges.d.ts.map +1 -1
- package/esm/lock/canonical_edges.js +10 -3
- package/esm/lock/model.d.ts +5 -0
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +2 -0
- package/esm/lock/resolve.d.ts +6 -2
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +36 -4
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +7 -1
- package/esm/mod.d.ts +23 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +18 -5
- package/esm/model/mod.d.ts +42 -1
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +1 -1
- package/esm/model/relations.d.ts +9 -0
- package/esm/model/relations.d.ts.map +1 -1
- package/esm/model/relations.js +16 -1
- package/esm/parser/attributes.d.ts +82 -3
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +199 -32
- package/esm/parser/body_tokens.d.ts +1 -1
- package/esm/parser/body_tokens.d.ts.map +1 -1
- package/esm/parser/body_tokens.js +49 -35
- package/esm/parser/feature_file.d.ts +116 -0
- package/esm/parser/feature_file.d.ts.map +1 -0
- package/esm/parser/feature_file.js +540 -0
- package/esm/parser/markdown.d.ts +7 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +129 -40
- package/esm/parser/mod.d.ts +18 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +51 -0
- package/esm/parser/translate.d.ts.map +1 -1
- package/esm/parser/translate.js +5 -0
- package/esm/refs/mod.d.ts +2 -1
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +12 -4
- package/esm/refs/split.d.ts +58 -0
- package/esm/refs/split.d.ts.map +1 -0
- package/esm/refs/split.js +137 -0
- package/esm/reporter/mod.d.ts +7 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +113 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +4 -1
- package/esm/validator/block_role.d.ts +40 -0
- package/esm/validator/block_role.d.ts.map +1 -0
- package/esm/validator/block_role.js +109 -0
- package/esm/validator/feature_ac.d.ts.map +1 -1
- package/esm/validator/feature_ac.js +6 -1
- package/esm/validator/feature_parse.d.ts +35 -0
- package/esm/validator/feature_parse.d.ts.map +1 -0
- package/esm/validator/feature_parse.js +69 -0
- package/esm/validator/locators.d.ts +36 -0
- package/esm/validator/locators.d.ts.map +1 -0
- package/esm/validator/locators.js +184 -0
- package/esm/validator/mod.d.ts +10 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +38 -14
- package/esm/validator/normalize.d.ts.map +1 -1
- package/esm/validator/normalize.js +8 -3
- package/esm/validator/per_type_attrs.d.ts +3 -3
- package/esm/validator/per_type_attrs.js +3 -3
- package/esm/validator/pipeline.d.ts +4 -12
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +24 -5
- package/esm/validator/procedure.d.ts +22 -0
- package/esm/validator/procedure.d.ts.map +1 -0
- package/esm/validator/procedure.js +58 -0
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +4 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +4 -1
- package/esm/validator/type_resolution.d.ts +5 -3
- package/esm/validator/type_resolution.d.ts.map +1 -1
- package/esm/validator/type_resolution.js +14 -2
- package/esm/validator/types.d.ts +11 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +26 -4
- package/esm/validator/uxil_family.d.ts +1 -1
- package/package.json +3 -1
- package/script/ast/build.d.ts.map +1 -1
- package/script/ast/build.js +19 -5
- package/script/ast/equivalence.js +14 -2
- package/script/ast/nodes.d.ts +15 -3
- package/script/ast/nodes.d.ts.map +1 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +18 -3
- package/script/compiler/mod.d.ts +34 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +110 -46
- package/script/compiler/schema.d.ts +3 -2
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +6 -3
- package/script/criteria/scenarios.d.ts +55 -0
- package/script/criteria/scenarios.d.ts.map +1 -0
- package/script/criteria/scenarios.js +139 -0
- package/script/discovery/mod.d.ts +20 -1
- package/script/discovery/mod.d.ts.map +1 -1
- package/script/discovery/mod.js +106 -17
- package/script/formatter/entry_body.d.ts +8 -5
- package/script/formatter/entry_body.d.ts.map +1 -1
- package/script/formatter/entry_body.js +12 -8
- package/script/formatter/feature_file.d.ts +40 -0
- package/script/formatter/feature_file.d.ts.map +1 -0
- package/script/formatter/feature_file.js +92 -0
- package/script/formatter/mod.d.ts +21 -2
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +63 -21
- package/script/gates/mod.d.ts +2 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +17 -2
- package/script/gherkin/load.d.ts +35 -0
- package/script/gherkin/load.d.ts.map +1 -0
- package/script/gherkin/load.js +76 -0
- package/script/gherkin/parse.d.ts +11 -0
- package/script/gherkin/parse.d.ts.map +1 -0
- package/script/gherkin/parse.js +314 -0
- package/script/gherkin/position.d.ts +23 -0
- package/script/gherkin/position.d.ts.map +1 -0
- package/script/gherkin/position.js +24 -0
- package/script/gherkin/procedure.d.ts +76 -0
- package/script/gherkin/procedure.d.ts.map +1 -0
- package/script/gherkin/procedure.js +169 -0
- package/script/gherkin/project.d.ts +35 -0
- package/script/gherkin/project.d.ts.map +1 -0
- package/script/gherkin/project.js +67 -0
- package/script/gherkin/role.d.ts +23 -0
- package/script/gherkin/role.d.ts.map +1 -0
- package/script/gherkin/role.js +31 -0
- package/script/gherkin/types.d.ts +118 -0
- package/script/gherkin/types.d.ts.map +1 -0
- package/script/gherkin/types.js +13 -0
- package/script/lock/acquire_compile.d.ts +12 -4
- package/script/lock/acquire_compile.d.ts.map +1 -1
- package/script/lock/acquire_compile.js +15 -5
- package/script/lock/canonical_edges.d.ts +6 -2
- package/script/lock/canonical_edges.d.ts.map +1 -1
- package/script/lock/canonical_edges.js +10 -3
- package/script/lock/model.d.ts +5 -0
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +2 -0
- package/script/lock/resolve.d.ts +6 -2
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +36 -4
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +7 -1
- package/script/mod.d.ts +23 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +45 -6
- package/script/model/mod.d.ts +42 -1
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +2 -1
- package/script/model/relations.d.ts +9 -0
- package/script/model/relations.d.ts.map +1 -1
- package/script/model/relations.js +17 -1
- package/script/parser/attributes.d.ts +82 -3
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +205 -33
- package/script/parser/body_tokens.d.ts +1 -1
- package/script/parser/body_tokens.d.ts.map +1 -1
- package/script/parser/body_tokens.js +49 -35
- package/script/parser/feature_file.d.ts +116 -0
- package/script/parser/feature_file.d.ts.map +1 -0
- package/script/parser/feature_file.js +548 -0
- package/script/parser/markdown.d.ts +7 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +128 -39
- package/script/parser/mod.d.ts +18 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +52 -1
- package/script/parser/translate.d.ts.map +1 -1
- package/script/parser/translate.js +5 -0
- package/script/refs/mod.d.ts +2 -1
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +12 -4
- package/script/refs/split.d.ts +58 -0
- package/script/refs/split.d.ts.map +1 -0
- package/script/refs/split.js +145 -0
- package/script/reporter/mod.d.ts +7 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +113 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +4 -1
- package/script/validator/block_role.d.ts +40 -0
- package/script/validator/block_role.d.ts.map +1 -0
- package/script/validator/block_role.js +112 -0
- package/script/validator/feature_ac.d.ts.map +1 -1
- package/script/validator/feature_ac.js +6 -1
- package/script/validator/feature_parse.d.ts +35 -0
- package/script/validator/feature_parse.d.ts.map +1 -0
- package/script/validator/feature_parse.js +73 -0
- package/script/validator/locators.d.ts +36 -0
- package/script/validator/locators.d.ts.map +1 -0
- package/script/validator/locators.js +188 -0
- package/script/validator/mod.d.ts +10 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +38 -14
- package/script/validator/normalize.d.ts.map +1 -1
- package/script/validator/normalize.js +8 -3
- package/script/validator/per_type_attrs.d.ts +3 -3
- package/script/validator/per_type_attrs.js +3 -3
- package/script/validator/pipeline.d.ts +4 -12
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +23 -5
- package/script/validator/procedure.d.ts +22 -0
- package/script/validator/procedure.d.ts.map +1 -0
- package/script/validator/procedure.js +61 -0
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +4 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +4 -1
- package/script/validator/type_resolution.d.ts +5 -3
- package/script/validator/type_resolution.d.ts.map +1 -1
- package/script/validator/type_resolution.js +14 -2
- package/script/validator/types.d.ts +11 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +27 -4
- package/script/validator/uxil_family.d.ts +1 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/locators
|
|
3
|
+
*
|
|
4
|
+
* Locator and scenario-name diagnostics (epic #915, scenario-locator
|
|
5
|
+
* slice):
|
|
6
|
+
*
|
|
7
|
+
* - `MSL-L007` (warning): a locator on a `"criterion"` relation
|
|
8
|
+
* (`Satisfies`, `Verifies`) names no addressable scenario of a resolved,
|
|
9
|
+
* criteria-bearing target. The edge to the target is kept.
|
|
10
|
+
* - `MSL-L008` (warning): a locator on a trace relation that does not
|
|
11
|
+
* accept one (every relation without a locator mode, including
|
|
12
|
+
* profile-declared relations and a hand-written `Verified-by`). The
|
|
13
|
+
* edge to the target is kept.
|
|
14
|
+
* - `MSL-L009` (warning): a trace value has a `[` after whitespace that
|
|
15
|
+
* no `]` closes. The value has no locator and is read as it was before
|
|
16
|
+
* scenario locators existed.
|
|
17
|
+
* - `MSL-B060` (warning): a scenario name occurs more than once in one
|
|
18
|
+
* entry; reported on the second and later occurrences.
|
|
19
|
+
* - `MSL-B061` (info): a scenario has an empty name.
|
|
20
|
+
*
|
|
21
|
+
* A locator on an unresolved target raises only `MSL-L006`, and a locator
|
|
22
|
+
* on a target that carries no criteria (not a Requirement or Contract, or a
|
|
23
|
+
* Reference entry) is free text: neither raises `MSL-L007`.
|
|
24
|
+
*/
|
|
25
|
+
import { ATTRIBUTE_CATALOG, CORE_RELATIONS, emittableEntries, isUpstreamEntry, relationLocatorMode, } from "../model/mod.js";
|
|
26
|
+
import { buildCriteria, isCriteriaBearing } from "../criteria/scenarios.js";
|
|
27
|
+
import { isUnterminatedLocator, parseTraceValue, splitTraceValues, } from "../refs/split.js";
|
|
28
|
+
import { classifyEntry, featureFileCoreType } from "./types.js";
|
|
29
|
+
/** Value types whose values reference other entries. */
|
|
30
|
+
const REFERENCE_VALUE_TYPES = new Set([
|
|
31
|
+
"id",
|
|
32
|
+
"id-list",
|
|
33
|
+
"citation",
|
|
34
|
+
]);
|
|
35
|
+
/** Core relations that accept a locator, for the MSL-L008 message. */
|
|
36
|
+
const LOCATOR_RELATIONS = (() => {
|
|
37
|
+
const names = CORE_RELATIONS.filter((r) => r.locator !== undefined).map((r) => r.attr);
|
|
38
|
+
return `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
39
|
+
})();
|
|
40
|
+
/**
|
|
41
|
+
* Report the locator and scenario-name diagnostics for `entries`.
|
|
42
|
+
* Targets resolve against every entry (upstream entries included);
|
|
43
|
+
* diagnostics are emitted for emittable entries only. When `profile` is
|
|
44
|
+
* given, an entry without a `type` is classified against it first.
|
|
45
|
+
*/
|
|
46
|
+
export function validateLocators(entries, profile) {
|
|
47
|
+
const typed = entries.map((e) => withType(e, profile));
|
|
48
|
+
const byKey = new Map();
|
|
49
|
+
for (const e of typed) {
|
|
50
|
+
if (!byKey.has(e.displayId))
|
|
51
|
+
byKey.set(e.displayId, e);
|
|
52
|
+
if (e.id && !byKey.has(e.id))
|
|
53
|
+
byKey.set(e.id, e);
|
|
54
|
+
}
|
|
55
|
+
const relations = relationKeys(profile);
|
|
56
|
+
const diagnostics = [];
|
|
57
|
+
for (const entry of emittableEntries(typed)) {
|
|
58
|
+
if (isCriteriaBearing(entry, profile)) {
|
|
59
|
+
diagnostics.push(...scenarioNameDiagnostics(entry));
|
|
60
|
+
}
|
|
61
|
+
entry.rawAttributes.forEach((attr, index) => {
|
|
62
|
+
if (!relations.has(attr.key))
|
|
63
|
+
return;
|
|
64
|
+
const location = attributeLocation(entry, index);
|
|
65
|
+
for (const part of splitTraceValues(attr.value)) {
|
|
66
|
+
if (isUnterminatedLocator(part)) {
|
|
67
|
+
diagnostics.push({
|
|
68
|
+
code: "MSL-L009",
|
|
69
|
+
severity: "warning",
|
|
70
|
+
message: `${entry.displayId}: '${attr.key}' value '${part}' has ` +
|
|
71
|
+
"a '[' with no closing ']'. Add the closing ']'",
|
|
72
|
+
location,
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const parsed = parseTraceValue(part);
|
|
77
|
+
if (parsed.locator === undefined)
|
|
78
|
+
continue;
|
|
79
|
+
const mode = relationLocatorMode(attr.key);
|
|
80
|
+
if (mode === undefined) {
|
|
81
|
+
diagnostics.push({
|
|
82
|
+
code: "MSL-L008",
|
|
83
|
+
severity: "warning",
|
|
84
|
+
message: `${entry.displayId}: '${attr.key}' does not accept a ` +
|
|
85
|
+
`locator ('${parsed.locator}'); only ${LOCATOR_RELATIONS} do. ` +
|
|
86
|
+
`The link to ${parsed.target} is kept`,
|
|
87
|
+
location,
|
|
88
|
+
});
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (mode !== "criterion")
|
|
92
|
+
continue;
|
|
93
|
+
const target = byKey.get(parsed.target);
|
|
94
|
+
// An upstream target carries no criteria (as in the compiler).
|
|
95
|
+
if (!target || isUpstreamEntry(target))
|
|
96
|
+
continue;
|
|
97
|
+
if (!isCriteriaBearing(target, profile))
|
|
98
|
+
continue;
|
|
99
|
+
const resolved = buildCriteria(target).some((c) => c.addressable && c.name === parsed.locator);
|
|
100
|
+
if (resolved)
|
|
101
|
+
continue;
|
|
102
|
+
diagnostics.push({
|
|
103
|
+
code: "MSL-L007",
|
|
104
|
+
severity: "warning",
|
|
105
|
+
message: `${entry.displayId}: locator '${parsed.locator}' matches ` +
|
|
106
|
+
`no scenario of ${target.displayId}`,
|
|
107
|
+
location,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return diagnostics;
|
|
113
|
+
}
|
|
114
|
+
/** MSL-B060 and MSL-B061 for the scenarios of one entry. */
|
|
115
|
+
function scenarioNameDiagnostics(entry) {
|
|
116
|
+
const diagnostics = [];
|
|
117
|
+
const seen = new Set();
|
|
118
|
+
for (const criterion of buildCriteria(entry)) {
|
|
119
|
+
if (criterion.name === "") {
|
|
120
|
+
diagnostics.push({
|
|
121
|
+
code: "MSL-B061",
|
|
122
|
+
severity: "info",
|
|
123
|
+
message: `${entry.displayId}: scenario has no name; ` +
|
|
124
|
+
"a locator cannot address it",
|
|
125
|
+
location: criterion.location,
|
|
126
|
+
});
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (seen.has(criterion.name)) {
|
|
130
|
+
diagnostics.push({
|
|
131
|
+
code: "MSL-B060",
|
|
132
|
+
severity: "warning",
|
|
133
|
+
message: `${entry.displayId}: scenario name '${criterion.name}' ` +
|
|
134
|
+
"is used more than once; a locator cannot address it",
|
|
135
|
+
location: criterion.location,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
seen.add(criterion.name);
|
|
139
|
+
}
|
|
140
|
+
return diagnostics;
|
|
141
|
+
}
|
|
142
|
+
/** `entry` with its type classified against `profile` when unset. Without a
|
|
143
|
+
* profile, a `.feature` header entry still gets its step-6a core type. */
|
|
144
|
+
export function withType(entry, profile) {
|
|
145
|
+
if (entry.type !== undefined)
|
|
146
|
+
return entry;
|
|
147
|
+
// Without a profile only step 6a (a `.feature` header entry) can type it.
|
|
148
|
+
const type = profile === null
|
|
149
|
+
? featureFileCoreType(entry)
|
|
150
|
+
: classifyEntry(entry, profile).type;
|
|
151
|
+
return type === undefined ? entry : { ...entry, type };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Trailer keys that are trace relations: the core relations, core
|
|
155
|
+
* attributes whose values reference entries (such as `Verified-by`), and
|
|
156
|
+
* the profile's reference-valued attributes and traceability links.
|
|
157
|
+
*/
|
|
158
|
+
function relationKeys(profile) {
|
|
159
|
+
const keys = new Set(CORE_RELATIONS.map((r) => r.attr));
|
|
160
|
+
const isRelation = (key, type) => type !== undefined && REFERENCE_VALUE_TYPES.has(type) && keys.add(key);
|
|
161
|
+
for (const spec of ATTRIBUTE_CATALOG)
|
|
162
|
+
isRelation(spec.key, spec.type);
|
|
163
|
+
if (profile === null)
|
|
164
|
+
return keys;
|
|
165
|
+
for (const [, a] of profile.attributes) {
|
|
166
|
+
isRelation(a.value.name, a.value.type);
|
|
167
|
+
}
|
|
168
|
+
for (const [, t] of profile.types) {
|
|
169
|
+
for (const [, a] of t.value.attributes) {
|
|
170
|
+
isRelation(a.value.name, a.value.type);
|
|
171
|
+
}
|
|
172
|
+
for (const name of t.value.traceability.keys())
|
|
173
|
+
keys.add(name);
|
|
174
|
+
}
|
|
175
|
+
return keys;
|
|
176
|
+
}
|
|
177
|
+
/** The location of the trailer line of `entry.rawAttributes[index]`. */
|
|
178
|
+
function attributeLocation(entry, index) {
|
|
179
|
+
const lines = entry.attributeLines;
|
|
180
|
+
if (!lines || lines.length !== entry.rawAttributes.length) {
|
|
181
|
+
return entry.location;
|
|
182
|
+
}
|
|
183
|
+
return { file: entry.location.file, line: lines[index], column: 1 };
|
|
184
|
+
}
|
package/esm/validator/mod.d.ts
CHANGED
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
* a profile-aware validator layer (not in the core).
|
|
15
15
|
*/
|
|
16
16
|
import type { Attribute, Diagnostic, Entry } from "../model/mod.js";
|
|
17
|
+
/**
|
|
18
|
+
* The values of a repeatable attribute (id-list, tag-list, citation or
|
|
19
|
+
* external-id) after trimming and splitting, by the value type's rule: a
|
|
20
|
+
* citation is not split, an id-list uses `splitTraceValues`, the other types
|
|
21
|
+
* split on commas. Empty values are dropped. `undefined` when `key` is not a
|
|
22
|
+
* repeatable attribute. MSL-A012 fires when the list is empty; the LSP quick
|
|
23
|
+
* fix for it uses the same function.
|
|
24
|
+
*/
|
|
25
|
+
export declare function repeatableAttributeValues(key: string, raw: string): string[] | undefined;
|
|
17
26
|
/** Result of a validation pass. */
|
|
18
27
|
export interface ValidateResult {
|
|
19
28
|
/** Diagnostics found during validation. */
|
|
@@ -30,7 +39,7 @@ export interface ValidateResult {
|
|
|
30
39
|
export declare function validate(entries: readonly Entry[]): ValidateResult;
|
|
31
40
|
export declare function indexByDisplayId(entries: readonly Entry[]): ReadonlyMap<string, Entry>;
|
|
32
41
|
export declare function findAttr(attrs: readonly Attribute[], key: string): Attribute | undefined;
|
|
33
|
-
export { runPipeline
|
|
42
|
+
export { runPipeline } from "./pipeline.js";
|
|
34
43
|
export type { PipelineOptions, PipelineResult } from "./pipeline.js";
|
|
35
44
|
export { validateListingDocuments } from "./listing.js";
|
|
36
45
|
export type { ListingFileContext, ListingKind } from "./listing.js";
|
|
@@ -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;AAsCpE,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,CAuBlE;
|
|
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;AAsCpE;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,MAAM,EAAE,GAAG,SAAS,CAMtB;AAUD,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,CAuBlE;AAkbD,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,MAAM,eAAe,CAAC;AAC5C,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,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
package/esm/validator/mod.js
CHANGED
|
@@ -13,11 +13,15 @@
|
|
|
13
13
|
* constraints, enum vocabularies) are profile-declared and evaluated by
|
|
14
14
|
* a profile-aware validator layer (not in the core).
|
|
15
15
|
*/
|
|
16
|
-
import { attributeSpec, CORE_TYPE_SCOPED_ATTRS, CSV_SPLITTABLE_TYPES, emittableEntries, IDENTITY_KEY, ULID_RE, UNIVERSAL_ATTRIBUTE_KEYS, URI_SCHEME_RE, } from "../model/mod.js";
|
|
16
|
+
import { attributeSpec, CORE_RELATIONS, CORE_TYPE_SCOPED_ATTRS, CSV_SPLITTABLE_TYPES, emittableEntries, IDENTITY_KEY, ULID_RE, UNIVERSAL_ATTRIBUTE_KEYS, URI_SCHEME_RE, } from "../model/mod.js";
|
|
17
17
|
import { HTTP_URL_RE } from "./value_types.js";
|
|
18
|
+
import { splitTraceValues } from "../refs/split.js";
|
|
18
19
|
import { validateTypl } from "../typl/mod.js";
|
|
19
20
|
/** Universal attribute keys the core recognizes. */
|
|
20
21
|
const UNIVERSAL_KEYS = new Set(UNIVERSAL_ATTRIBUTE_KEYS);
|
|
22
|
+
/** Trailer keys of the core relations. Core recognizes them without a
|
|
23
|
+
* profile, so MSL-R010 never applies to them. */
|
|
24
|
+
const CORE_RELATION_KEYS = new Set(CORE_RELATIONS.map((r) => r.attr));
|
|
21
25
|
/**
|
|
22
26
|
* Value-type set that's repeatable per spec §1.8 — these attributes
|
|
23
27
|
* accept multiple lines for distinct values, so multiple trailers with
|
|
@@ -30,6 +34,24 @@ const REPEATABLE_VALUE_TYPES = new Set([
|
|
|
30
34
|
"citation",
|
|
31
35
|
"external-id",
|
|
32
36
|
]);
|
|
37
|
+
/**
|
|
38
|
+
* The values of a repeatable attribute (id-list, tag-list, citation or
|
|
39
|
+
* external-id) after trimming and splitting, by the value type's rule: a
|
|
40
|
+
* citation is not split, an id-list uses `splitTraceValues`, the other types
|
|
41
|
+
* split on commas. Empty values are dropped. `undefined` when `key` is not a
|
|
42
|
+
* repeatable attribute. MSL-A012 fires when the list is empty; the LSP quick
|
|
43
|
+
* fix for it uses the same function.
|
|
44
|
+
*/
|
|
45
|
+
export function repeatableAttributeValues(key, raw) {
|
|
46
|
+
const spec = attributeSpec(key);
|
|
47
|
+
if (!spec || !REPEATABLE_VALUE_TYPES.has(spec.type))
|
|
48
|
+
return undefined;
|
|
49
|
+
if (spec.type === "citation")
|
|
50
|
+
return [raw.trim()].filter((v) => v.length > 0);
|
|
51
|
+
if (spec.type === "id-list")
|
|
52
|
+
return splitTraceValues(raw);
|
|
53
|
+
return raw.split(",").map((v) => v.trim()).filter((v) => v.length > 0);
|
|
54
|
+
}
|
|
33
55
|
/**
|
|
34
56
|
* Slug pattern for Reference-shape display IDs (spec §1.7, ADR-002 §Part 3).
|
|
35
57
|
* Pandoc/BibTeX cite-key convention, restricted to a portable character
|
|
@@ -241,8 +263,13 @@ function checkStructural(emittable, diagnostics) {
|
|
|
241
263
|
continue;
|
|
242
264
|
let depth = 0;
|
|
243
265
|
let sawTopLevelComma = false;
|
|
244
|
-
|
|
245
|
-
|
|
266
|
+
const value = attr.value;
|
|
267
|
+
for (let i = 0; i < value.length; i++) {
|
|
268
|
+
const ch = value[i];
|
|
269
|
+
// Inside a locator, `\]` and `\\` are escapes (#915).
|
|
270
|
+
if (ch === "\\" && depth > 0)
|
|
271
|
+
i++;
|
|
272
|
+
else if (ch === "[")
|
|
246
273
|
depth++;
|
|
247
274
|
else if (ch === "]" && depth > 0)
|
|
248
275
|
depth--;
|
|
@@ -273,11 +300,7 @@ function checkStructural(emittable, diagnostics) {
|
|
|
273
300
|
continue;
|
|
274
301
|
if (!REPEATABLE_VALUE_TYPES.has(spec.type))
|
|
275
302
|
continue;
|
|
276
|
-
const
|
|
277
|
-
const isCitation = spec.type === "citation";
|
|
278
|
-
const values = isCitation
|
|
279
|
-
? [raw.trim()].filter((s) => s.length > 0)
|
|
280
|
-
: raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
303
|
+
const values = repeatableAttributeValues(attr.key, attr.value) ?? [];
|
|
281
304
|
if (values.length === 0) {
|
|
282
305
|
diagnostics.push({
|
|
283
306
|
code: "MSL-A012",
|
|
@@ -365,17 +388,18 @@ function checkStructural(emittable, diagnostics) {
|
|
|
365
388
|
}
|
|
366
389
|
// MSL-R010: Unknown attributes are warnings in the core. A
|
|
367
390
|
// profile-aware validator widens this check to include profile-declared
|
|
368
|
-
// attributes; until then, anything outside the universal set
|
|
369
|
-
// unrecognized. Core-typed attributes (per
|
|
370
|
-
// suppressed here — the per-type validator emits
|
|
371
|
-
// MSL-T022 when they appear on the "wrong" type.
|
|
391
|
+
// attributes; until then, anything outside the universal set and the
|
|
392
|
+
// core relation keys is unrecognized. Core-typed attributes (per
|
|
393
|
+
// ADR-003 §Part 2) are suppressed here — the per-type validator emits
|
|
394
|
+
// a more specific MSL-T022 when they appear on the "wrong" type.
|
|
372
395
|
if (!UNIVERSAL_KEYS.has(attr.key) &&
|
|
396
|
+
!CORE_RELATION_KEYS.has(attr.key) &&
|
|
373
397
|
attr.key !== "Type" &&
|
|
374
398
|
!CORE_TYPE_SCOPED_ATTRS.has(attr.key)) {
|
|
375
399
|
diagnostics.push({
|
|
376
400
|
code: "MSL-R010",
|
|
377
401
|
severity: "warning",
|
|
378
|
-
message: `${entry.displayId}: unknown attribute '${attr.key}' (not in core universal set; profile-declared attributes are permitted when a profile is loaded)`,
|
|
402
|
+
message: `${entry.displayId}: unknown attribute '${attr.key}' (not in core universal set or core relation keys; profile-declared attributes are permitted when a profile is loaded)`,
|
|
379
403
|
location: entry.location,
|
|
380
404
|
});
|
|
381
405
|
}
|
|
@@ -479,7 +503,7 @@ export function indexByDisplayId(entries) {
|
|
|
479
503
|
export function findAttr(attrs, key) {
|
|
480
504
|
return attrs.find((a) => a.key === key);
|
|
481
505
|
}
|
|
482
|
-
export { runPipeline
|
|
506
|
+
export { runPipeline } from "./pipeline.js";
|
|
483
507
|
export { validateListingDocuments } from "./listing.js";
|
|
484
508
|
export { classifyEntriesStage, classifyEntry } from "./types.js";
|
|
485
509
|
export { compileDisplayIdPattern } from "./pattern.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/validator/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/validator/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAa,MAAM,iBAAiB,CAAC;AAM1E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,KAAK,CAoBP"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* whitespace is trimmed.
|
|
14
14
|
*/
|
|
15
15
|
import { effectiveScope } from "./attributes.js";
|
|
16
|
+
import { splitTraceValues } from "../refs/split.js";
|
|
16
17
|
const LIST_TYPES = new Set(["id-list", "tag-list"]);
|
|
17
18
|
/**
|
|
18
19
|
* Return a new Entry with list-typed attribute values split on commas. If no
|
|
@@ -25,7 +26,7 @@ export function normalizeListValues(entry, profile) {
|
|
|
25
26
|
for (const [name, values] of entry.typedAttributes) {
|
|
26
27
|
const decl = scope.attributes.get(name);
|
|
27
28
|
if (decl !== undefined && LIST_TYPES.has(decl.type)) {
|
|
28
|
-
const split = splitListValues(values);
|
|
29
|
+
const split = splitListValues(values, decl.type === "id-list");
|
|
29
30
|
if (!arraysEqual(split, values)) {
|
|
30
31
|
rewritten.set(name, split);
|
|
31
32
|
anyChange = true;
|
|
@@ -38,10 +39,14 @@ export function normalizeListValues(entry, profile) {
|
|
|
38
39
|
return entry;
|
|
39
40
|
return { ...entry, typedAttributes: rewritten };
|
|
40
41
|
}
|
|
41
|
-
function splitListValues(values) {
|
|
42
|
+
function splitListValues(values, isTraceList) {
|
|
42
43
|
const out = [];
|
|
43
44
|
for (const v of values) {
|
|
44
|
-
|
|
45
|
+
// In a trace list, commas inside a bracket locator (`A [x, y]`) do not
|
|
46
|
+
// split. Other lists (tag-list) split on every comma.
|
|
47
|
+
const parts = isTraceList
|
|
48
|
+
? splitTraceValues(v)
|
|
49
|
+
: v.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
45
50
|
if (parts.length === 0)
|
|
46
51
|
continue;
|
|
47
52
|
out.push(...parts);
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* `Type:`, profile classification, or URI-scheme inference for
|
|
7
7
|
* Reference-shape entries — any attribute that's known to the core
|
|
8
8
|
* hierarchy but not allowed on that type fires MSL-T022 as a warning.
|
|
9
|
-
* Unknown attributes (neither universal
|
|
10
|
-
* to the existing MSL-R010 unknown-attribute
|
|
11
|
-
* `validator/mod.ts`.
|
|
9
|
+
* Unknown attributes (neither universal, core relation keys, nor
|
|
10
|
+
* core-typed) fall through to the existing MSL-R010 unknown-attribute
|
|
11
|
+
* warning in `validator/mod.ts`.
|
|
12
12
|
*/
|
|
13
13
|
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
14
14
|
/**
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* `Type:`, profile classification, or URI-scheme inference for
|
|
7
7
|
* Reference-shape entries — any attribute that's known to the core
|
|
8
8
|
* hierarchy but not allowed on that type fires MSL-T022 as a warning.
|
|
9
|
-
* Unknown attributes (neither universal
|
|
10
|
-
* to the existing MSL-R010 unknown-attribute
|
|
11
|
-
* `validator/mod.ts`.
|
|
9
|
+
* Unknown attributes (neither universal, core relation keys, nor
|
|
10
|
+
* core-typed) fall through to the existing MSL-R010 unknown-attribute
|
|
11
|
+
* warning in `validator/mod.ts`.
|
|
12
12
|
*/
|
|
13
13
|
import { attributesForType, CORE_TYPE_SCOPED_ATTRS, UNIVERSAL_ATTRIBUTE_KEYS, } from "../model/mod.js";
|
|
14
14
|
import { resolvedCoreType } from "./type_resolution.js";
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
* Stage 2 (type classification — {@linkcode classifyEntriesStage}),
|
|
6
6
|
* Stage 2.5 (list-value normalization — {@linkcode normalizeListValues}),
|
|
7
7
|
* Stage 3 (typed attribute validation — {@linkcode validateAttributesForEntry}),
|
|
8
|
-
*
|
|
8
|
+
* Stage 4 (traceability rules — {@linkcode validateTraceabilityForEntry}),
|
|
9
|
+
* then the Gherkin checks: Stage 4.4 (MSL-B062), Stage 4.5 (scenario
|
|
10
|
+
* locators), Stage 4.6 (procedure steps, MSL-B063) and Stage 4.7 (block
|
|
11
|
+
* roles, MSL-B064 to MSL-B068).
|
|
9
12
|
*/
|
|
10
13
|
import type { CaptionConventions, Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
11
14
|
/** Result of running the full validator pipeline. */
|
|
@@ -58,15 +61,4 @@ export interface PipelineOptions {
|
|
|
58
61
|
* validating a file-local subset to suppress cross-entry diagnostics.
|
|
59
62
|
*/
|
|
60
63
|
export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions, opts?: PipelineOptions): PipelineResult;
|
|
61
|
-
/**
|
|
62
|
-
* Drop core Stage 1 `MSL-R010` ("unknown attribute") warnings for attributes
|
|
63
|
-
* the loaded profile declares — Stage 3 validates those directly, so the
|
|
64
|
-
* core-only check would be noise. Returns `diagnostics` unchanged when no
|
|
65
|
-
* profile is loaded.
|
|
66
|
-
*
|
|
67
|
-
* Exported so callers that run only Stage 1 (e.g. the compiler's diagnostic
|
|
68
|
-
* pass) suppress the same false positives the full {@linkcode runPipeline}
|
|
69
|
-
* does, keeping LSP/MCP diagnostics consistent with the `validate` command.
|
|
70
|
-
*/
|
|
71
|
-
export declare function suppressDeclaredAttrR010(diagnostics: readonly Diagnostic[], entries: readonly Entry[], profile: EffectiveProfile | null): readonly Diagnostic[];
|
|
72
64
|
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,KAAK,EACN,MAAM,iBAAiB,CAAC;AA6CzB,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;;;;;;;;;OASG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;;;;OAOG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;GAiBG;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,CA4KhB"}
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
* Stage 2 (type classification — {@linkcode classifyEntriesStage}),
|
|
6
6
|
* Stage 2.5 (list-value normalization — {@linkcode normalizeListValues}),
|
|
7
7
|
* Stage 3 (typed attribute validation — {@linkcode validateAttributesForEntry}),
|
|
8
|
-
*
|
|
8
|
+
* Stage 4 (traceability rules — {@linkcode validateTraceabilityForEntry}),
|
|
9
|
+
* then the Gherkin checks: Stage 4.4 (MSL-B062), Stage 4.5 (scenario
|
|
10
|
+
* locators), Stage 4.6 (procedure steps, MSL-B063) and Stage 4.7 (block
|
|
11
|
+
* roles, MSL-B064 to MSL-B068).
|
|
9
12
|
*/
|
|
10
13
|
import { CORE_DISCIPLINE_REGISTRY, emittableEntries, makeDisplayId, } from "../model/mod.js";
|
|
11
14
|
import { validate } from "./mod.js";
|
|
@@ -23,6 +26,10 @@ import { validateCaptionConvention } from "./caption_convention.js";
|
|
|
23
26
|
import { validateDiscipline } from "./discipline.js";
|
|
24
27
|
import { buildEffectiveDisciplineRegistry } from "../profile/discipline_registry.js";
|
|
25
28
|
import { validateUxilFamily } from "./uxil_family.js";
|
|
29
|
+
import { validateLocators } from "./locators.js";
|
|
30
|
+
import { checkBlockRoles } from "./block_role.js";
|
|
31
|
+
import { checkProcedureSteps } from "./procedure.js";
|
|
32
|
+
import { checkFeatureParse } from "./feature_parse.js";
|
|
26
33
|
/** Cross-entry DSL codes suppressed under file-local scope: a
|
|
27
34
|
* subset registry cannot distinguish a dangling reference from an
|
|
28
35
|
* unchecked file — the same false-positive class the MSL-L006 filter
|
|
@@ -168,6 +175,20 @@ export function runPipeline(entries, profile, captionConventions = {}, opts = {}
|
|
|
168
175
|
: stage4.filter((d) => d.code !== "MSL-L006" && d.code !== "MSL-T014"));
|
|
169
176
|
}
|
|
170
177
|
}
|
|
178
|
+
// Stage 4.4 — Gherkin blocks that do not parse (MSL-B062, epic #915).
|
|
179
|
+
diagnostics.push(...checkFeatureParse(entries));
|
|
180
|
+
// Stage 4.5 — scenario locators and scenario names (epic #915). Runs
|
|
181
|
+
// on the classified entries so criteria-bearing types resolve; targets
|
|
182
|
+
// resolve against the full list, diagnostics come from the emittable
|
|
183
|
+
// entries only. An unresolved target raises MSL-L006 (Stage 4), never
|
|
184
|
+
// MSL-L007, so no file-local filter is needed here.
|
|
185
|
+
diagnostics.push(...validateLocators(finalEntries, profile));
|
|
186
|
+
// Stage 4.6 — Gherkin procedure steps with no expected result (MSL-B063).
|
|
187
|
+
// Only Test entries are checked; unclassified entries are classified first.
|
|
188
|
+
diagnostics.push(...checkProcedureSteps(finalEntries, profile));
|
|
189
|
+
// Stage 4.7 — Gherkin block roles (MSL-B064 warning, MSL-B065..B068 info).
|
|
190
|
+
// Unclassified entries are classified first, as in Stage 4.6.
|
|
191
|
+
diagnostics.push(...checkBlockRoles(finalEntries, profile));
|
|
171
192
|
// Stage 5 — uxil diagnostics family (S9 #727). Inert unless some profile
|
|
172
193
|
// tier designates a declaring type (`declares: ux-surface`). Receives the
|
|
173
194
|
// FULL classified list on purpose: the family derives its own #771
|
|
@@ -186,11 +207,9 @@ export function runPipeline(entries, profile, captionConventions = {}, opts = {}
|
|
|
186
207
|
* core-only check would be noise. Returns `diagnostics` unchanged when no
|
|
187
208
|
* profile is loaded.
|
|
188
209
|
*
|
|
189
|
-
*
|
|
190
|
-
* pass) suppress the same false positives the full {@linkcode runPipeline}
|
|
191
|
-
* does, keeping LSP/MCP diagnostics consistent with the `validate` command.
|
|
210
|
+
* Used by {@linkcode runPipeline} Stage 1 only.
|
|
192
211
|
*/
|
|
193
|
-
|
|
212
|
+
function suppressDeclaredAttrR010(diagnostics, entries, profile) {
|
|
194
213
|
if (profile === null)
|
|
195
214
|
return diagnostics;
|
|
196
215
|
const declared = collectAllProfileAttributes(entries, profile);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/procedure
|
|
3
|
+
*
|
|
4
|
+
* `MSL-B063` (warning): a step of a Gherkin procedure has actions and no
|
|
5
|
+
* expected result (epic #915). Only entries whose type is, or extends, core
|
|
6
|
+
* `Test` are checked, because the procedure view belongs to Test entries.
|
|
7
|
+
* In a Requirement the block is a criterion, which is another check.
|
|
8
|
+
*
|
|
9
|
+
* Each `feature` or `gherkin` block is checked in a top-level block or in a
|
|
10
|
+
* list item at any depth, as for `MSL-B062`. A block that has a
|
|
11
|
+
* `parseError` or no `feature` is skipped: `MSL-B062` reports the first, and
|
|
12
|
+
* the second means the Gherkin parser was not loaded. Upstream entries are
|
|
13
|
+
* not checked (`emittableEntries`).
|
|
14
|
+
*
|
|
15
|
+
* The warning is reported at the file line of the last action of the step,
|
|
16
|
+
* in column 1. An entry without `entry.type` is classified with the profile
|
|
17
|
+
* first, so callers may pass classified or unclassified entries.
|
|
18
|
+
*/
|
|
19
|
+
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
20
|
+
/** Report one MSL-B063 warning per procedure step with no expected result. */
|
|
21
|
+
export declare function checkProcedureSteps(entries: readonly Entry[], profile: EffectiveProfile | null): Diagnostic[];
|
|
22
|
+
//# sourceMappingURL=procedure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/validator/procedure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAQ3E,8EAA8E;AAC9E,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,UAAU,EAAE,CA6Bd"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/procedure
|
|
3
|
+
*
|
|
4
|
+
* `MSL-B063` (warning): a step of a Gherkin procedure has actions and no
|
|
5
|
+
* expected result (epic #915). Only entries whose type is, or extends, core
|
|
6
|
+
* `Test` are checked, because the procedure view belongs to Test entries.
|
|
7
|
+
* In a Requirement the block is a criterion, which is another check.
|
|
8
|
+
*
|
|
9
|
+
* Each `feature` or `gherkin` block is checked in a top-level block or in a
|
|
10
|
+
* list item at any depth, as for `MSL-B062`. A block that has a
|
|
11
|
+
* `parseError` or no `feature` is skipped: `MSL-B062` reports the first, and
|
|
12
|
+
* the second means the Gherkin parser was not loaded. Upstream entries are
|
|
13
|
+
* not checked (`emittableEntries`).
|
|
14
|
+
*
|
|
15
|
+
* The warning is reported at the file line of the last action of the step,
|
|
16
|
+
* in column 1. An entry without `entry.type` is classified with the profile
|
|
17
|
+
* first, so callers may pass classified or unclassified entries.
|
|
18
|
+
*/
|
|
19
|
+
import { emittableEntries } from "../model/mod.js";
|
|
20
|
+
import { isTestEntry } from "../criteria/scenarios.js";
|
|
21
|
+
import { scenarioProcedure } from "../gherkin/procedure.js";
|
|
22
|
+
import { featureFileLine } from "../gherkin/position.js";
|
|
23
|
+
import { featureNodes } from "./feature_parse.js";
|
|
24
|
+
import { withType } from "./locators.js";
|
|
25
|
+
/** Report one MSL-B063 warning per procedure step with no expected result. */
|
|
26
|
+
export function checkProcedureSteps(entries, profile) {
|
|
27
|
+
const diagnostics = [];
|
|
28
|
+
for (const candidate of emittableEntries(entries)) {
|
|
29
|
+
// Classify an unclassified entry, as `validateLocators` does.
|
|
30
|
+
const entry = withType(candidate, profile);
|
|
31
|
+
if (!isTestEntry(entry, profile))
|
|
32
|
+
continue;
|
|
33
|
+
for (const node of featureNodes(entry.bodyAst ?? [])) {
|
|
34
|
+
if (node.parseError !== undefined || node.feature === undefined)
|
|
35
|
+
continue;
|
|
36
|
+
for (const scenario of node.feature.scenarios) {
|
|
37
|
+
for (const step of scenarioProcedure(scenario).steps) {
|
|
38
|
+
const last = step.actions.at(-1);
|
|
39
|
+
if (last === undefined || step.expected.length > 0)
|
|
40
|
+
continue;
|
|
41
|
+
diagnostics.push({
|
|
42
|
+
code: "MSL-B063",
|
|
43
|
+
severity: "warning",
|
|
44
|
+
message: `${entry.displayId}: step ${step.n} of scenario ` +
|
|
45
|
+
`"${scenario.name}" has no expected result (no Then step); ` +
|
|
46
|
+
"add a Then step after the last action",
|
|
47
|
+
location: {
|
|
48
|
+
file: entry.location.file,
|
|
49
|
+
line: featureFileLine(entry, node, last.step.range.start.line),
|
|
50
|
+
column: 1,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return diagnostics;
|
|
58
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace_types.d.ts","sourceRoot":"","sources":["../../src/validator/trace_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"trace_types.d.ts","sourceRoot":"","sources":["../../src/validator/trace_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAyFzD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,SAAS,KAAK,EAAE,EAC3B,GAAG,EAAE,SAAS,KAAK,EAAE,GACpB,SAAS,UAAU,EAAE,CA8HvB"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { CORE_RELATIONS, CORE_TYPE_HIERARCHY, isUpstreamEntry, } from "../model/mod.js";
|
|
15
15
|
import { resolvedCoreType } from "./type_resolution.js";
|
|
16
|
+
import { traceTarget } from "../refs/split.js";
|
|
16
17
|
const TRACE_RULES = CORE_RELATIONS
|
|
17
18
|
.filter((r) => r.targetTypes)
|
|
18
19
|
.map((r) => ({ attr: r.attr, allowedTargetTypes: r.targetTypes }));
|
|
@@ -107,7 +108,7 @@ export function validateTraceTargetTypes(emittable, all) {
|
|
|
107
108
|
for (const attr of entry.rawAttributes) {
|
|
108
109
|
if (attr.key !== "Supersedes")
|
|
109
110
|
continue;
|
|
110
|
-
const target = attr.value
|
|
111
|
+
const target = traceTarget(attr.value);
|
|
111
112
|
const resolved = byId.get(target) ?? byDisplayId.get(target);
|
|
112
113
|
if (!resolved)
|
|
113
114
|
continue;
|
|
@@ -126,7 +127,7 @@ export function validateTraceTargetTypes(emittable, all) {
|
|
|
126
127
|
for (const attr of entry.rawAttributes) {
|
|
127
128
|
if (attr.key !== rule.attr)
|
|
128
129
|
continue;
|
|
129
|
-
const target = attr.value
|
|
130
|
+
const target = traceTarget(attr.value);
|
|
130
131
|
const resolved = byId.get(target) ?? byDisplayId.get(target);
|
|
131
132
|
if (!resolved)
|
|
132
133
|
continue;
|
|
@@ -166,7 +167,7 @@ export function validateTraceTargetTypes(emittable, all) {
|
|
|
166
167
|
for (const attr of entry.rawAttributes) {
|
|
167
168
|
if (attr.key !== "Caused-by")
|
|
168
169
|
continue;
|
|
169
|
-
const target = attr.value
|
|
170
|
+
const target = traceTarget(attr.value);
|
|
170
171
|
const resolved = byId.get(target) ?? byDisplayId.get(target);
|
|
171
172
|
if (!resolved)
|
|
172
173
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,KAAK,EAEV,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,KAAK,EAEV,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,iBAAiB,CAAC;AAGzB;;;;;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;;;;;;;;;;;;;;;;;;;GAmBG;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,EACnD,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,UAAU,EAAE,CAiHd"}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* never have declared outgoing links.
|
|
22
22
|
*/
|
|
23
23
|
import { isUpstreamEntry, URI_SCHEME_RE, } from "../model/mod.js";
|
|
24
|
+
import { traceTarget } from "../refs/split.js";
|
|
24
25
|
/**
|
|
25
26
|
* Effective trace rules for an entry: type-scope rules only.
|
|
26
27
|
* Type-scope rules are applied only when the entry is classified.
|
|
@@ -127,7 +128,9 @@ export function validateTraceabilityForEntry(entry, profile, graph, byDisplayId
|
|
|
127
128
|
// MSL-L004 target match + MSL-L006 existence, for each resolved value.
|
|
128
129
|
// Resolve by ULID (graph) first, then by display ID (byDisplayId) — the
|
|
129
130
|
// dual-resolution spine (issue #593).
|
|
130
|
-
|
|
131
|
+
// A bracket locator (`A [x]`) addresses part of the target; the
|
|
132
|
+
// existence check uses the target only (epic #915).
|
|
133
|
+
for (const v of values.map(traceTarget)) {
|
|
131
134
|
const target = graph.get(v) ?? byDisplayId.get(v);
|
|
132
135
|
if (!target) {
|
|
133
136
|
// Scheme-qualified URIs are intentionally external — never local
|