@driftsys/markspec 0.3.0 → 0.5.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 +70 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +605 -0
- package/esm/ast/equivalence.d.ts +18 -0
- package/esm/ast/equivalence.d.ts.map +1 -0
- package/esm/ast/equivalence.js +56 -0
- package/esm/ast/nodes.d.ts +221 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +12 -0
- package/esm/ast/normalize.d.ts +67 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +255 -0
- package/esm/ast/render.d.ts +34 -0
- package/esm/ast/render.d.ts.map +1 -0
- package/esm/ast/render.js +215 -0
- package/esm/compiler/inverses.d.ts +2 -8
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +50 -14
- package/esm/compiler/manifest.d.ts +59 -0
- package/esm/compiler/manifest.d.ts.map +1 -0
- package/esm/compiler/manifest.js +48 -0
- package/esm/compiler/mod.d.ts +9 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +21 -2
- package/esm/compiler/ndjson_writer.d.ts +50 -0
- package/esm/compiler/ndjson_writer.d.ts.map +1 -0
- package/esm/compiler/ndjson_writer.js +73 -0
- package/esm/compiler/schema.d.ts +18 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +18 -9
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +56 -6
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +372 -41
- package/esm/formatter/synth_ulid.d.ts +21 -0
- package/esm/formatter/synth_ulid.d.ts.map +1 -0
- package/esm/formatter/synth_ulid.js +64 -0
- package/esm/lint/mod.d.ts +10 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +7 -0
- package/esm/lint/rules/lexicon.d.ts +24 -0
- package/esm/lint/rules/lexicon.d.ts.map +1 -0
- package/esm/lint/rules/lexicon.js +236 -0
- package/esm/lint/rules/struct.d.ts +17 -0
- package/esm/lint/rules/struct.d.ts.map +1 -0
- package/esm/lint/rules/struct.js +55 -0
- package/esm/lint/rules/suppression.d.ts +19 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +75 -0
- package/esm/lint/runner.d.ts +39 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +112 -0
- package/esm/lint/types.d.ts +19 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/mod.d.ts +21 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +16 -5
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +163 -2
- package/esm/model/discriminating_attr.d.ts +33 -0
- package/esm/model/discriminating_attr.d.ts.map +1 -0
- package/esm/model/discriminating_attr.js +74 -0
- package/esm/model/mod.d.ts +100 -3
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +58 -2
- package/esm/model/palette.d.ts +18 -0
- package/esm/model/palette.d.ts.map +1 -0
- package/esm/model/palette.js +23 -0
- package/esm/model/profile.d.ts +33 -27
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/model/source_introspection.d.ts +26 -0
- package/esm/model/source_introspection.d.ts.map +1 -0
- package/esm/model/source_introspection.js +77 -0
- package/esm/model/type_hierarchy.d.ts +51 -0
- package/esm/model/type_hierarchy.d.ts.map +1 -0
- package/esm/model/type_hierarchy.js +126 -0
- package/esm/model/uri_scheme_map.d.ts +21 -0
- package/esm/model/uri_scheme_map.d.ts.map +1 -0
- package/esm/model/uri_scheme_map.js +66 -0
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +9 -6
- package/esm/parser/entity_refs.d.ts +53 -0
- package/esm/parser/entity_refs.d.ts.map +1 -0
- package/esm/parser/entity_refs.js +151 -0
- package/esm/parser/glossary.d.ts +43 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +217 -0
- package/esm/parser/markdown.d.ts +10 -3
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +241 -11
- package/esm/parser/mod.d.ts +1 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +4 -3
- package/esm/parser/source.d.ts +20 -0
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +4 -4
- package/esm/profile/chain.js +3 -13
- package/esm/profile/colors.d.ts +26 -0
- package/esm/profile/colors.d.ts.map +1 -0
- package/esm/profile/colors.js +46 -0
- package/esm/profile/introspect.d.ts +135 -0
- package/esm/profile/introspect.d.ts.map +1 -0
- package/esm/profile/introspect.js +378 -0
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +67 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +278 -104
- package/esm/profile/merge.js +139 -39
- package/esm/profile/mod.d.ts +3 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +6 -2
- package/esm/reporter/mod.js +4 -4
- package/esm/util/fence.d.ts +30 -0
- package/esm/util/fence.d.ts.map +1 -0
- package/esm/util/fence.js +40 -0
- package/esm/validator/attributes.d.ts +3 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +1 -18
- package/esm/validator/body_blocks.d.ts +38 -0
- package/esm/validator/body_blocks.d.ts.map +1 -0
- package/esm/validator/body_blocks.js +218 -0
- package/esm/validator/caption_convention.d.ts +29 -0
- package/esm/validator/caption_convention.d.ts.map +1 -0
- package/esm/validator/caption_convention.js +58 -0
- package/esm/validator/captions.d.ts +22 -0
- package/esm/validator/captions.d.ts.map +1 -0
- package/esm/validator/captions.js +137 -0
- package/esm/validator/component_schemes.d.ts +73 -0
- package/esm/validator/component_schemes.d.ts.map +1 -0
- package/esm/validator/component_schemes.js +375 -0
- package/esm/validator/feature_ac.d.ts +28 -0
- package/esm/validator/feature_ac.d.ts.map +1 -0
- package/esm/validator/feature_ac.js +102 -0
- package/esm/validator/listing.d.ts +42 -0
- package/esm/validator/listing.d.ts.map +1 -0
- package/esm/validator/listing.js +295 -0
- package/esm/validator/mod.d.ts +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +253 -12
- package/esm/validator/modal_keywords.d.ts +23 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +137 -0
- package/esm/validator/per_type_attrs.d.ts +29 -0
- package/esm/validator/per_type_attrs.d.ts.map +1 -0
- package/esm/validator/per_type_attrs.js +75 -0
- package/esm/validator/pipeline.d.ts +7 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +40 -7
- package/esm/validator/trace_types.d.ts +26 -0
- package/esm/validator/trace_types.d.ts.map +1 -0
- package/esm/validator/trace_types.js +232 -0
- package/esm/validator/traceability.d.ts +3 -4
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +5 -10
- package/esm/validator/type_resolution.d.ts +67 -0
- package/esm/validator/type_resolution.d.ts.map +1 -0
- package/esm/validator/type_resolution.js +140 -0
- package/esm/validator/types.d.ts +45 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +128 -16
- package/esm/validator/value_types.d.ts +8 -0
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +8 -1
- package/package.json +1 -1
- package/script/ast/build.d.ts +70 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +610 -0
- package/script/ast/equivalence.d.ts +18 -0
- package/script/ast/equivalence.d.ts.map +1 -0
- package/script/ast/equivalence.js +59 -0
- package/script/ast/nodes.d.ts +221 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +13 -0
- package/script/ast/normalize.d.ts +67 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +258 -0
- package/script/ast/render.d.ts +34 -0
- package/script/ast/render.d.ts.map +1 -0
- package/script/ast/render.js +218 -0
- package/script/compiler/inverses.d.ts +2 -8
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +50 -14
- package/script/compiler/manifest.d.ts +59 -0
- package/script/compiler/manifest.d.ts.map +1 -0
- package/script/compiler/manifest.js +51 -0
- package/script/compiler/mod.d.ts +9 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +21 -2
- package/script/compiler/ndjson_writer.d.ts +50 -0
- package/script/compiler/ndjson_writer.d.ts.map +1 -0
- package/script/compiler/ndjson_writer.js +78 -0
- package/script/compiler/schema.d.ts +18 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +18 -8
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +56 -6
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +375 -41
- package/script/formatter/synth_ulid.d.ts +21 -0
- package/script/formatter/synth_ulid.d.ts.map +1 -0
- package/script/formatter/synth_ulid.js +67 -0
- package/script/lint/mod.d.ts +10 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +12 -0
- package/script/lint/rules/lexicon.d.ts +24 -0
- package/script/lint/rules/lexicon.d.ts.map +1 -0
- package/script/lint/rules/lexicon.js +240 -0
- package/script/lint/rules/struct.d.ts +17 -0
- package/script/lint/rules/struct.d.ts.map +1 -0
- package/script/lint/rules/struct.js +59 -0
- package/script/lint/rules/suppression.d.ts +19 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +80 -0
- package/script/lint/runner.d.ts +39 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +116 -0
- package/script/lint/types.d.ts +19 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/mod.d.ts +21 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +58 -32
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +163 -2
- package/script/model/discriminating_attr.d.ts +33 -0
- package/script/model/discriminating_attr.d.ts.map +1 -0
- package/script/model/discriminating_attr.js +77 -0
- package/script/model/mod.d.ts +100 -3
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +67 -3
- package/script/model/palette.d.ts +18 -0
- package/script/model/palette.d.ts.map +1 -0
- package/script/model/palette.js +26 -0
- package/script/model/profile.d.ts +33 -27
- package/script/model/profile.d.ts.map +1 -1
- package/script/model/source_introspection.d.ts +26 -0
- package/script/model/source_introspection.d.ts.map +1 -0
- package/script/model/source_introspection.js +80 -0
- package/script/model/type_hierarchy.d.ts +51 -0
- package/script/model/type_hierarchy.d.ts.map +1 -0
- package/script/model/type_hierarchy.js +130 -0
- package/script/model/uri_scheme_map.d.ts +21 -0
- package/script/model/uri_scheme_map.d.ts.map +1 -0
- package/script/model/uri_scheme_map.js +69 -0
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +9 -6
- package/script/parser/entity_refs.d.ts +53 -0
- package/script/parser/entity_refs.d.ts.map +1 -0
- package/script/parser/entity_refs.js +155 -0
- package/script/parser/glossary.d.ts +43 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +221 -0
- package/script/parser/markdown.d.ts +10 -3
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +240 -10
- package/script/parser/mod.d.ts +1 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +8 -4
- package/script/parser/source.d.ts +20 -0
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +4 -1
- package/script/profile/chain.js +3 -13
- package/script/profile/colors.d.ts +26 -0
- package/script/profile/colors.d.ts.map +1 -0
- package/script/profile/colors.js +49 -0
- package/script/profile/introspect.d.ts +135 -0
- package/script/profile/introspect.d.ts.map +1 -0
- package/script/profile/introspect.js +381 -0
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +67 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +280 -106
- package/script/profile/merge.js +139 -39
- package/script/profile/mod.d.ts +3 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +9 -6
- package/script/reporter/mod.js +4 -4
- package/script/util/fence.d.ts +30 -0
- package/script/util/fence.d.ts.map +1 -0
- package/script/util/fence.js +44 -0
- package/script/validator/attributes.d.ts +3 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +1 -18
- package/script/validator/body_blocks.d.ts +38 -0
- package/script/validator/body_blocks.d.ts.map +1 -0
- package/script/validator/body_blocks.js +221 -0
- package/script/validator/caption_convention.d.ts +29 -0
- package/script/validator/caption_convention.d.ts.map +1 -0
- package/script/validator/caption_convention.js +61 -0
- package/script/validator/captions.d.ts +22 -0
- package/script/validator/captions.d.ts.map +1 -0
- package/script/validator/captions.js +140 -0
- package/script/validator/component_schemes.d.ts +73 -0
- package/script/validator/component_schemes.d.ts.map +1 -0
- package/script/validator/component_schemes.js +384 -0
- package/script/validator/feature_ac.d.ts +28 -0
- package/script/validator/feature_ac.d.ts.map +1 -0
- package/script/validator/feature_ac.js +105 -0
- package/script/validator/listing.d.ts +42 -0
- package/script/validator/listing.d.ts.map +1 -0
- package/script/validator/listing.js +298 -0
- package/script/validator/mod.d.ts +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +256 -14
- package/script/validator/modal_keywords.d.ts +23 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +140 -0
- package/script/validator/per_type_attrs.d.ts +29 -0
- package/script/validator/per_type_attrs.d.ts.map +1 -0
- package/script/validator/per_type_attrs.js +78 -0
- package/script/validator/pipeline.d.ts +7 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +39 -6
- package/script/validator/trace_types.d.ts +26 -0
- package/script/validator/trace_types.d.ts.map +1 -0
- package/script/validator/trace_types.js +235 -0
- package/script/validator/traceability.d.ts +3 -4
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +5 -10
- package/script/validator/type_resolution.d.ts +67 -0
- package/script/validator/type_resolution.d.ts.map +1 -0
- package/script/validator/type_resolution.js +146 -0
- package/script/validator/types.d.ts +45 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +131 -16
- package/script/validator/value_types.d.ts +8 -0
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +10 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/modal_keywords
|
|
3
|
+
*
|
|
4
|
+
* MSL-M060 validator — uppercase RFC 2119 modal keyword (`SHALL`,
|
|
5
|
+
* `SHOULD`, `MAY`, `MUST`, optionally `… NOT`) in entry-body prose.
|
|
6
|
+
* The formatter normalises these to lowercase per spec §3.4.1; this
|
|
7
|
+
* validator surfaces the deviation in a lint-only flow. Profiles may
|
|
8
|
+
* promote the severity. Each prose-bearing node's `InlineContent.markers`
|
|
9
|
+
* carries pre-extracted `ModalMarker` objects from the builder; an
|
|
10
|
+
* uppercase match is detected where `marker.raw` differs from
|
|
11
|
+
* `marker.canonical`. EARS markers are not flagged — MSL-M060 targets
|
|
12
|
+
* RFC 2119 only. Code, Feature, and Math blocks are automatically
|
|
13
|
+
* excluded because the builder does not extract markers from verbatim
|
|
14
|
+
* content.
|
|
15
|
+
*/
|
|
16
|
+
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
17
|
+
/**
|
|
18
|
+
* Scan an entry's body for uppercase modal keywords and emit MSL-M060
|
|
19
|
+
* for each occurrence. Severity is `warning`; the formatter rewrites
|
|
20
|
+
* them on the next run.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateModalKeywords(entry: Entry): readonly Diagnostic[];
|
|
23
|
+
//# sourceMappingURL=modal_keywords.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal_keywords.d.ts","sourceRoot":"","sources":["../../src/validator/modal_keywords.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAiFzD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,UAAU,EAAE,CAkDzE"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/modal_keywords
|
|
3
|
+
*
|
|
4
|
+
* MSL-M060 validator — uppercase RFC 2119 modal keyword (`SHALL`,
|
|
5
|
+
* `SHOULD`, `MAY`, `MUST`, optionally `… NOT`) in entry-body prose.
|
|
6
|
+
* The formatter normalises these to lowercase per spec §3.4.1; this
|
|
7
|
+
* validator surfaces the deviation in a lint-only flow. Profiles may
|
|
8
|
+
* promote the severity. Each prose-bearing node's `InlineContent.markers`
|
|
9
|
+
* carries pre-extracted `ModalMarker` objects from the builder; an
|
|
10
|
+
* uppercase match is detected where `marker.raw` differs from
|
|
11
|
+
* `marker.canonical`. EARS markers are not flagged — MSL-M060 targets
|
|
12
|
+
* RFC 2119 only. Code, Feature, and Math blocks are automatically
|
|
13
|
+
* excluded because the builder does not extract markers from verbatim
|
|
14
|
+
* content.
|
|
15
|
+
*/
|
|
16
|
+
import { resolvedCoreType } from "./type_resolution.js";
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Marker collection from bodyAst
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
/** Collect all modal markers from an InlineContent object. */
|
|
21
|
+
function modalsFromInline(content) {
|
|
22
|
+
return content.markers.filter((m) => m.kind === "modal");
|
|
23
|
+
}
|
|
24
|
+
/** Recursively collect modal markers from a list item's blocks. */
|
|
25
|
+
function modalsFromListItem(item) {
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const block of item.blocks) {
|
|
28
|
+
out.push(...modalsFromBlock(block));
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/** Collect all modal markers from a single BodyBlock (recursively). */
|
|
33
|
+
function modalsFromBlock(block) {
|
|
34
|
+
const out = [];
|
|
35
|
+
switch (block.kind) {
|
|
36
|
+
case "paragraph":
|
|
37
|
+
out.push(...modalsFromInline(block.content));
|
|
38
|
+
break;
|
|
39
|
+
case "list":
|
|
40
|
+
for (const item of block.items) {
|
|
41
|
+
out.push(...modalsFromListItem(item));
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
case "table":
|
|
45
|
+
for (const cell of block.header) {
|
|
46
|
+
out.push(...modalsFromInline(cell));
|
|
47
|
+
}
|
|
48
|
+
for (const row of block.rows) {
|
|
49
|
+
for (const cell of row) {
|
|
50
|
+
out.push(...modalsFromInline(cell));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case "note":
|
|
55
|
+
out.push(...modalsFromInline(block.content));
|
|
56
|
+
break;
|
|
57
|
+
case "blockquote":
|
|
58
|
+
out.push(...modalsFromInline(block.content));
|
|
59
|
+
break;
|
|
60
|
+
case "definition-list":
|
|
61
|
+
for (const item of block.items) {
|
|
62
|
+
out.push(...modalsFromInline(item.term));
|
|
63
|
+
out.push(...modalsFromInline(item.definition));
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case "code":
|
|
67
|
+
case "feature":
|
|
68
|
+
case "math":
|
|
69
|
+
case "figure":
|
|
70
|
+
case "caption":
|
|
71
|
+
case "unknown":
|
|
72
|
+
// Verbatim / structural nodes: no modal markers.
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
// Public API
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
/**
|
|
83
|
+
* Scan an entry's body for uppercase modal keywords and emit MSL-M060
|
|
84
|
+
* for each occurrence. Severity is `warning`; the formatter rewrites
|
|
85
|
+
* them on the next run.
|
|
86
|
+
*/
|
|
87
|
+
export function validateModalKeywords(entry) {
|
|
88
|
+
const diagnostics = [];
|
|
89
|
+
let anyModalSeen = false;
|
|
90
|
+
const blocks = entry.bodyAst ?? [];
|
|
91
|
+
for (const block of blocks) {
|
|
92
|
+
for (const marker of modalsFromBlock(block)) {
|
|
93
|
+
anyModalSeen = true;
|
|
94
|
+
// MSL-M060: RFC 2119 keywords in non-canonical (uppercase) form.
|
|
95
|
+
// `marker.raw` is the original source text; `marker.canonical` is
|
|
96
|
+
// always lowercase. When they differ, the keyword is uppercase.
|
|
97
|
+
// EARS markers (cls = "ears") are always case-preserved and
|
|
98
|
+
// are not subject to MSL-M060.
|
|
99
|
+
if (marker.cls !== "rfc2119")
|
|
100
|
+
continue;
|
|
101
|
+
const raw = marker.raw ?? marker.canonical;
|
|
102
|
+
if (raw === marker.canonical)
|
|
103
|
+
continue; // already lowercase — OK
|
|
104
|
+
diagnostics.push({
|
|
105
|
+
code: "MSL-M060",
|
|
106
|
+
severity: "warning",
|
|
107
|
+
message: `${entry.displayId}: modal keyword '${raw}' in body ` +
|
|
108
|
+
`prose is uppercase (spec §3.4.1 canonical form is lowercase; ` +
|
|
109
|
+
`'markspec format' will rewrite it)`,
|
|
110
|
+
location: {
|
|
111
|
+
file: entry.location.file,
|
|
112
|
+
// marker.range.start.line is body-relative 1-based.
|
|
113
|
+
// entry.location.line is the title line (0-based offset 0).
|
|
114
|
+
// Body line 1 → file line entry.location.line + 0, etc.
|
|
115
|
+
line: entry.location.line + (marker.range.start.line - 1),
|
|
116
|
+
column: marker.range.start.column,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// MSL-M061 — Requirement-type entry contains no modal keyword
|
|
122
|
+
// (info; style hint). Gated on the resolved core type being
|
|
123
|
+
// `Requirement` so non-requirement entries (Tests, Contracts, etc.)
|
|
124
|
+
// are not flagged. The hint stays at info severity so it doesn't
|
|
125
|
+
// affect exit codes; profiles may promote.
|
|
126
|
+
if (!anyModalSeen && resolvedCoreType(entry) === "Requirement") {
|
|
127
|
+
diagnostics.push({
|
|
128
|
+
code: "MSL-M061",
|
|
129
|
+
severity: "info",
|
|
130
|
+
message: `${entry.displayId}: Requirement entry contains no modal ` +
|
|
131
|
+
`keyword (shall / should / may / must) — consider declaring one ` +
|
|
132
|
+
`to make the obligation explicit (spec §3.4.1 "Modal keywords")`,
|
|
133
|
+
location: entry.location,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return diagnostics;
|
|
137
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/per_type_attrs
|
|
3
|
+
*
|
|
4
|
+
* Per-type attribute compatibility check (spec §4.3 — MSL-T022). When
|
|
5
|
+
* an entry's effective type resolves to a core type — via explicit
|
|
6
|
+
* `Type:`, profile classification, or URI-scheme inference for
|
|
7
|
+
* Reference-shape entries — any attribute that's known to the core
|
|
8
|
+
* hierarchy but not allowed on that type fires MSL-T022 as a warning.
|
|
9
|
+
* Unknown attributes (neither universal nor core-typed) fall through
|
|
10
|
+
* to the existing MSL-R010 unknown-attribute warning in
|
|
11
|
+
* `validator/mod.ts`.
|
|
12
|
+
*/
|
|
13
|
+
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
14
|
+
/**
|
|
15
|
+
* Emit per-type attribute diagnostics:
|
|
16
|
+
*
|
|
17
|
+
* - **MSL-T022** (warning) — an attribute is core-known but not
|
|
18
|
+
* valid on the entry's *resolved* type.
|
|
19
|
+
* - **MSL-T024** (warning) — the entry's core type could not be
|
|
20
|
+
* resolved (no explicit `Type:`, no profile classification, no
|
|
21
|
+
* inferable signal — display-ID prefix / URI scheme /
|
|
22
|
+
* discriminating attribute) yet it carries a core-type-scoped
|
|
23
|
+
* attribute, so that attribute cannot be validated. Without this,
|
|
24
|
+
* such attributes slipped through silently (e.g. `Manufacturer:`
|
|
25
|
+
* on a `jira:`-scheme reference). Universal and entirely unknown
|
|
26
|
+
* attributes are exempt — those go through MSL-R010.
|
|
27
|
+
*/
|
|
28
|
+
export declare function validatePerTypeAttributes(entry: Entry): readonly Diagnostic[];
|
|
29
|
+
//# sourceMappingURL=per_type_attrs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"per_type_attrs.d.ts","sourceRoot":"","sources":["../../src/validator/per_type_attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAmBzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAsCvB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/per_type_attrs
|
|
3
|
+
*
|
|
4
|
+
* Per-type attribute compatibility check (spec §4.3 — MSL-T022). When
|
|
5
|
+
* an entry's effective type resolves to a core type — via explicit
|
|
6
|
+
* `Type:`, profile classification, or URI-scheme inference for
|
|
7
|
+
* Reference-shape entries — any attribute that's known to the core
|
|
8
|
+
* hierarchy but not allowed on that type fires MSL-T022 as a warning.
|
|
9
|
+
* Unknown attributes (neither universal nor core-typed) fall through
|
|
10
|
+
* to the existing MSL-R010 unknown-attribute warning in
|
|
11
|
+
* `validator/mod.ts`.
|
|
12
|
+
*/
|
|
13
|
+
import { attributesForType, CORE_TYPE_SCOPED_ATTRS, UNIVERSAL_ATTRIBUTE_KEYS, } from "../model/mod.js";
|
|
14
|
+
import { resolvedCoreType } from "./type_resolution.js";
|
|
15
|
+
/**
|
|
16
|
+
* Attribute keys that are universal to every entry regardless of type
|
|
17
|
+
* (spec §1.4 + §1.5). Sourced entirely from {@linkcode UNIVERSAL_ATTRIBUTE_KEYS}
|
|
18
|
+
* — `Type`, `Source`, `Origin`, `Reference-url`, and `Reference-document`
|
|
19
|
+
* are now first-class catalogue entries, so the previous hand-maintained
|
|
20
|
+
* extension list is no longer needed.
|
|
21
|
+
*/
|
|
22
|
+
const UNIVERSAL_KEYS = new Set(UNIVERSAL_ATTRIBUTE_KEYS);
|
|
23
|
+
/**
|
|
24
|
+
* Emit per-type attribute diagnostics:
|
|
25
|
+
*
|
|
26
|
+
* - **MSL-T022** (warning) — an attribute is core-known but not
|
|
27
|
+
* valid on the entry's *resolved* type.
|
|
28
|
+
* - **MSL-T024** (warning) — the entry's core type could not be
|
|
29
|
+
* resolved (no explicit `Type:`, no profile classification, no
|
|
30
|
+
* inferable signal — display-ID prefix / URI scheme /
|
|
31
|
+
* discriminating attribute) yet it carries a core-type-scoped
|
|
32
|
+
* attribute, so that attribute cannot be validated. Without this,
|
|
33
|
+
* such attributes slipped through silently (e.g. `Manufacturer:`
|
|
34
|
+
* on a `jira:`-scheme reference). Universal and entirely unknown
|
|
35
|
+
* attributes are exempt — those go through MSL-R010.
|
|
36
|
+
*/
|
|
37
|
+
export function validatePerTypeAttributes(entry) {
|
|
38
|
+
const type = resolvedCoreType(entry);
|
|
39
|
+
if (type === undefined) {
|
|
40
|
+
const diagnostics = [];
|
|
41
|
+
for (const attr of entry.rawAttributes) {
|
|
42
|
+
if (UNIVERSAL_KEYS.has(attr.key))
|
|
43
|
+
continue;
|
|
44
|
+
if (!CORE_TYPE_SCOPED_ATTRS.has(attr.key))
|
|
45
|
+
continue;
|
|
46
|
+
diagnostics.push({
|
|
47
|
+
code: "MSL-T024",
|
|
48
|
+
severity: "warning",
|
|
49
|
+
message: `${entry.displayId}: attribute '${attr.key}' is type-specific but ` +
|
|
50
|
+
`the entry's core type could not be resolved; it cannot be ` +
|
|
51
|
+
`validated (spec §8.3)`,
|
|
52
|
+
location: entry.location,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return diagnostics;
|
|
56
|
+
}
|
|
57
|
+
const allowed = attributesForType(type);
|
|
58
|
+
const diagnostics = [];
|
|
59
|
+
for (const attr of entry.rawAttributes) {
|
|
60
|
+
if (UNIVERSAL_KEYS.has(attr.key))
|
|
61
|
+
continue;
|
|
62
|
+
if (allowed.has(attr.key))
|
|
63
|
+
continue;
|
|
64
|
+
if (!CORE_TYPE_SCOPED_ATTRS.has(attr.key))
|
|
65
|
+
continue;
|
|
66
|
+
diagnostics.push({
|
|
67
|
+
code: "MSL-T022",
|
|
68
|
+
severity: "warning",
|
|
69
|
+
message: `${entry.displayId}: attribute '${attr.key}' is not valid on Type: ${type} ` +
|
|
70
|
+
`(spec §1.6, ADR-003 §Part 2)`,
|
|
71
|
+
location: entry.location,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return diagnostics;
|
|
75
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Stage 3 (typed attribute validation — {@linkcode validateAttributesForEntry}),
|
|
8
8
|
* and Stage 4 (traceability rules — {@linkcode validateTraceabilityForEntry}).
|
|
9
9
|
*/
|
|
10
|
-
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
10
|
+
import type { CaptionConventions, Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
11
11
|
/** Result of running the full validator pipeline. */
|
|
12
12
|
export interface PipelineResult {
|
|
13
13
|
/** Entries after classification — `type` set on those that classified. */
|
|
@@ -25,6 +25,11 @@ export interface PipelineResult {
|
|
|
25
25
|
*
|
|
26
26
|
* When `profile` is `null`, entries pass through unchanged (no `type`
|
|
27
27
|
* assignments).
|
|
28
|
+
*
|
|
29
|
+
* @param captionConventions - Optional project-configured caption-position
|
|
30
|
+
* conventions (from `ProjectConfig.captionConventions`). When supplied
|
|
31
|
+
* and non-empty, MSL-C072 is checked for each entry. Defaults to no
|
|
32
|
+
* conventions (rule inactive).
|
|
28
33
|
*/
|
|
29
|
-
export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null): PipelineResult;
|
|
34
|
+
export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions): PipelineResult;
|
|
30
35
|
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,
|
|
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;AAmBzB,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;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,EAChC,kBAAkB,GAAE,kBAAuB,GAC1C,cAAc,CAwFhB"}
|
|
@@ -8,10 +8,17 @@
|
|
|
8
8
|
* and Stage 4 (traceability rules — {@linkcode validateTraceabilityForEntry}).
|
|
9
9
|
*/
|
|
10
10
|
import { validate } from "./mod.js";
|
|
11
|
-
import { classifyEntriesStage } from "./types.js";
|
|
11
|
+
import { classifyEntriesStage, inferTypeFromDisplayIdShape, inferTypeFromLateStageChain, validateCoreTypeAttribute, } from "./types.js";
|
|
12
|
+
import { validateBodyBlocks } from "./body_blocks.js";
|
|
13
|
+
import { validateCaptions } from "./captions.js";
|
|
14
|
+
import { validateModalKeywords } from "./modal_keywords.js";
|
|
15
|
+
import { validatePerTypeAttributes } from "./per_type_attrs.js";
|
|
16
|
+
import { validateTraceTargetTypes } from "./trace_types.js";
|
|
12
17
|
import { effectiveScope, validateAttributesForEntry } from "./attributes.js";
|
|
13
18
|
import { normalizeListValues } from "./normalize.js";
|
|
14
19
|
import { validateTraceabilityForEntry } from "./traceability.js";
|
|
20
|
+
import { validateFeatureAc } from "./feature_ac.js";
|
|
21
|
+
import { validateCaptionConvention } from "./caption_convention.js";
|
|
15
22
|
/**
|
|
16
23
|
* Run the validator pipeline.
|
|
17
24
|
*
|
|
@@ -21,8 +28,13 @@ import { validateTraceabilityForEntry } from "./traceability.js";
|
|
|
21
28
|
*
|
|
22
29
|
* When `profile` is `null`, entries pass through unchanged (no `type`
|
|
23
30
|
* assignments).
|
|
31
|
+
*
|
|
32
|
+
* @param captionConventions - Optional project-configured caption-position
|
|
33
|
+
* conventions (from `ProjectConfig.captionConventions`). When supplied
|
|
34
|
+
* and non-empty, MSL-C072 is checked for each entry. Defaults to no
|
|
35
|
+
* conventions (rule inactive).
|
|
24
36
|
*/
|
|
25
|
-
export function runPipeline(entries, profile) {
|
|
37
|
+
export function runPipeline(entries, profile, captionConventions = {}) {
|
|
26
38
|
const diagnostics = [];
|
|
27
39
|
// Stage 1 — core hygiene. When a profile is loaded, suppress MSL-R010
|
|
28
40
|
// warnings for attributes the profile actually declares (Stage 3's scope
|
|
@@ -42,6 +54,24 @@ export function runPipeline(entries, profile) {
|
|
|
42
54
|
return !profileDeclaredAttrs.has(match[1]);
|
|
43
55
|
});
|
|
44
56
|
diagnostics.push(...filteredStage1);
|
|
57
|
+
// Stage 1.5 — core type-attribute check. Runs always (core-only mode
|
|
58
|
+
// included) so unknown `Type:` values fail fast regardless of profile.
|
|
59
|
+
// Also covers late-stage display-ID-shape inference (step 8 → MSL-T021)
|
|
60
|
+
// and caption-adjacency rules (§2.6 → MSL-C070).
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
diagnostics.push(...validateCoreTypeAttribute(entry, profile));
|
|
63
|
+
diagnostics.push(...inferTypeFromDisplayIdShape(entry));
|
|
64
|
+
diagnostics.push(...validateCaptions(entry));
|
|
65
|
+
diagnostics.push(...validateCaptionConvention(entry, captionConventions));
|
|
66
|
+
diagnostics.push(...validateBodyBlocks(entry));
|
|
67
|
+
diagnostics.push(...validateFeatureAc(entry));
|
|
68
|
+
diagnostics.push(...validatePerTypeAttributes(entry));
|
|
69
|
+
diagnostics.push(...validateModalKeywords(entry));
|
|
70
|
+
}
|
|
71
|
+
// Stage 1.6 — cross-file trace target-type compatibility (MSL-R083).
|
|
72
|
+
// Runs project-wide because targets may live in any entry; needs the
|
|
73
|
+
// whole batch indexed.
|
|
74
|
+
diagnostics.push(...validateTraceTargetTypes(entries));
|
|
45
75
|
// Stage 2 — classification (only when a profile is loaded).
|
|
46
76
|
let finalEntries = entries;
|
|
47
77
|
if (profile !== null) {
|
|
@@ -49,6 +79,14 @@ export function runPipeline(entries, profile) {
|
|
|
49
79
|
finalEntries = stage2.entries;
|
|
50
80
|
diagnostics.push(...stage2.diagnostics);
|
|
51
81
|
}
|
|
82
|
+
// Stage 2.4 — late-stage inference warnings (MSL-T021 for steps 5/6).
|
|
83
|
+
// Runs after Stage 2 so that profile-classified `entry.type` suppresses
|
|
84
|
+
// the warning correctly. In core-only mode `finalEntries === entries`
|
|
85
|
+
// and `entry.type` is always undefined, so this stage produces the same
|
|
86
|
+
// diagnostics regardless of mode.
|
|
87
|
+
for (const entry of finalEntries) {
|
|
88
|
+
diagnostics.push(...inferTypeFromLateStageChain(entry));
|
|
89
|
+
}
|
|
52
90
|
// Stage 2.5 — normalize profile-declared list-value attributes. Splits
|
|
53
91
|
// comma-separated values for `id-list`/`tag-list` attributes the core parser
|
|
54
92
|
// didn't see so that Stage 3 sees already-split values.
|
|
@@ -106,10 +144,5 @@ function collectAllProfileAttributes(entries, profile) {
|
|
|
106
144
|
for (const name of typeEntry.value.traceability.keys())
|
|
107
145
|
out.add(name);
|
|
108
146
|
}
|
|
109
|
-
// Shape-level trace rule link names too.
|
|
110
|
-
for (const name of profile.identified.traceability.keys())
|
|
111
|
-
out.add(name);
|
|
112
|
-
for (const name of profile.referenced.traceability.keys())
|
|
113
|
-
out.add(name);
|
|
114
147
|
return out;
|
|
115
148
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/trace_types
|
|
3
|
+
*
|
|
4
|
+
* Cross-file trace target-type compatibility check (spec §4.8 — MSL-R083).
|
|
5
|
+
*
|
|
6
|
+
* For each authored trace attribute on each entry, the target must
|
|
7
|
+
* resolve to an entry whose type is allowed by ADR-003 §Part 2 (taking
|
|
8
|
+
* inheritance into account — e.g., a Requirement target is valid where
|
|
9
|
+
* the rule allows Specification).
|
|
10
|
+
*
|
|
11
|
+
* Unresolved targets are intentionally not flagged here — that is the
|
|
12
|
+
* job of MSL-R080 / MSL-T012 / MSL-T005 in other passes.
|
|
13
|
+
*/
|
|
14
|
+
import type { Diagnostic, Entry } from "../model/mod.js";
|
|
15
|
+
/**
|
|
16
|
+
* Validate that every authored trace attribute targets an entry of an
|
|
17
|
+
* allowed type. Emits MSL-R083 for each type mismatch and MSL-R084
|
|
18
|
+
* when `Supersedes` crosses the Authored↔Reference shape boundary
|
|
19
|
+
* (ADR-002 §Part 1 — "Supersedes operates within a shape").
|
|
20
|
+
*
|
|
21
|
+
* Unresolved targets are silently skipped — they're caught elsewhere
|
|
22
|
+
* (MSL-R080 / MSL-T012 / MSL-T005). Targets without a resolvable core
|
|
23
|
+
* type are also skipped (no compat call to make).
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateTraceTargetTypes(entries: readonly Entry[]): readonly Diagnostic[];
|
|
26
|
+
//# sourceMappingURL=trace_types.d.ts.map
|
|
@@ -0,0 +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;AA0GzD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,KAAK,EAAE,GACxB,SAAS,UAAU,EAAE,CAuHvB"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/trace_types
|
|
3
|
+
*
|
|
4
|
+
* Cross-file trace target-type compatibility check (spec §4.8 — MSL-R083).
|
|
5
|
+
*
|
|
6
|
+
* For each authored trace attribute on each entry, the target must
|
|
7
|
+
* resolve to an entry whose type is allowed by ADR-003 §Part 2 (taking
|
|
8
|
+
* inheritance into account — e.g., a Requirement target is valid where
|
|
9
|
+
* the rule allows Specification).
|
|
10
|
+
*
|
|
11
|
+
* Unresolved targets are intentionally not flagged here — that is the
|
|
12
|
+
* job of MSL-R080 / MSL-T012 / MSL-T005 in other passes.
|
|
13
|
+
*/
|
|
14
|
+
import { CORE_TYPE_HIERARCHY } from "../model/mod.js";
|
|
15
|
+
import { resolvedCoreType } from "./type_resolution.js";
|
|
16
|
+
const TRACE_RULES = [
|
|
17
|
+
// Specification family
|
|
18
|
+
{ attr: "Satisfies", allowedTargetTypes: ["Specification"] },
|
|
19
|
+
{ attr: "Derived-from", allowedTargetTypes: ["Specification"] },
|
|
20
|
+
{ attr: "Allocated-to", allowedTargetTypes: ["Component"] },
|
|
21
|
+
// Test (extends Specification)
|
|
22
|
+
{ attr: "Verifies", allowedTargetTypes: ["Requirement", "Contract"] },
|
|
23
|
+
{ attr: "Tests", allowedTargetTypes: ["Component", "Unit"] },
|
|
24
|
+
// Component / Unit
|
|
25
|
+
{ attr: "Realizes", allowedTargetTypes: ["Specification"] },
|
|
26
|
+
{
|
|
27
|
+
attr: "Provides",
|
|
28
|
+
allowedTargetTypes: ["SoftwareInterface", "HardwareInterface"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
attr: "Requires",
|
|
32
|
+
allowedTargetTypes: ["SoftwareInterface", "HardwareInterface"],
|
|
33
|
+
},
|
|
34
|
+
{ attr: "Depends-on", allowedTargetTypes: ["Component", "Unit"] },
|
|
35
|
+
{ attr: "Part-of", allowedTargetTypes: ["Component"] },
|
|
36
|
+
// Risk
|
|
37
|
+
{ attr: "Mitigated-by", allowedTargetTypes: ["Specification"] },
|
|
38
|
+
// Record
|
|
39
|
+
{ attr: "Affects", allowedTargetTypes: ["Component", "Unit"] },
|
|
40
|
+
// `Caused-by` is polymorphic between Record (cause = Requirement/Risk/
|
|
41
|
+
// Contract/Record) and Risk (cause = Component/Unit/Specification).
|
|
42
|
+
// The simplest correct rule is the union — handled by the loop below.
|
|
43
|
+
];
|
|
44
|
+
/** Polymorphic relations where the source type's role widens the targets. */
|
|
45
|
+
const POLYMORPHIC_CAUSED_BY = [
|
|
46
|
+
{
|
|
47
|
+
source: "Record",
|
|
48
|
+
allowed: ["Requirement", "Risk", "Contract", "Record"],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
source: "Risk",
|
|
52
|
+
allowed: ["Component", "Unit", "Specification"],
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
/** True when the entry carries a non-empty `Deprecated:` attribute. */
|
|
56
|
+
function isRetired(entry) {
|
|
57
|
+
for (const a of entry.rawAttributes) {
|
|
58
|
+
if (a.key === "Deprecated" && a.value.trim().length > 0)
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
/** True when the entry's `Labels:` set contains `DRAFT`. */
|
|
64
|
+
function isDraft(entry) {
|
|
65
|
+
for (const a of entry.rawAttributes) {
|
|
66
|
+
if (a.key !== "Labels")
|
|
67
|
+
continue;
|
|
68
|
+
const values = a.value.split(/[,\s]+/).map((s) => s.trim());
|
|
69
|
+
if (values.includes("DRAFT"))
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Trace attribute keys subject to link-target severity diagnostics
|
|
76
|
+
* (MSL-R081 / MSL-R082). `Supersedes` is intentionally excluded: its
|
|
77
|
+
* target IS the predecessor, expected to be retired, so flagging a
|
|
78
|
+
* Deprecated predecessor would be noise.
|
|
79
|
+
*/
|
|
80
|
+
const SEVERITY_TRACKED_ATTRS = [
|
|
81
|
+
...new Set(TRACE_RULES.map((r) => r.attr)),
|
|
82
|
+
"Caused-by",
|
|
83
|
+
"References",
|
|
84
|
+
];
|
|
85
|
+
/**
|
|
86
|
+
* Check whether `targetType` is compatible with any type in
|
|
87
|
+
* `allowedTypes` by walking the parent chain (inheritance-aware).
|
|
88
|
+
*/
|
|
89
|
+
function isTargetTypeCompatible(targetType, allowedTypes) {
|
|
90
|
+
if (allowedTypes.length === 0)
|
|
91
|
+
return true;
|
|
92
|
+
let cursor = targetType;
|
|
93
|
+
while (cursor !== null && CORE_TYPE_HIERARCHY[cursor]) {
|
|
94
|
+
if (allowedTypes.includes(cursor))
|
|
95
|
+
return true;
|
|
96
|
+
cursor = CORE_TYPE_HIERARCHY[cursor].parent;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Validate that every authored trace attribute targets an entry of an
|
|
102
|
+
* allowed type. Emits MSL-R083 for each type mismatch and MSL-R084
|
|
103
|
+
* when `Supersedes` crosses the Authored↔Reference shape boundary
|
|
104
|
+
* (ADR-002 §Part 1 — "Supersedes operates within a shape").
|
|
105
|
+
*
|
|
106
|
+
* Unresolved targets are silently skipped — they're caught elsewhere
|
|
107
|
+
* (MSL-R080 / MSL-T012 / MSL-T005). Targets without a resolvable core
|
|
108
|
+
* type are also skipped (no compat call to make).
|
|
109
|
+
*/
|
|
110
|
+
export function validateTraceTargetTypes(entries) {
|
|
111
|
+
const byDisplayId = new Map();
|
|
112
|
+
const byId = new Map();
|
|
113
|
+
for (const e of entries) {
|
|
114
|
+
if (!byDisplayId.has(e.displayId))
|
|
115
|
+
byDisplayId.set(e.displayId, e);
|
|
116
|
+
if (e.id && !byId.has(e.id))
|
|
117
|
+
byId.set(e.id, e);
|
|
118
|
+
}
|
|
119
|
+
const diagnostics = [];
|
|
120
|
+
for (const entry of entries) {
|
|
121
|
+
// MSL-R084: Supersedes target must be the same shape as the source.
|
|
122
|
+
for (const attr of entry.rawAttributes) {
|
|
123
|
+
if (attr.key !== "Supersedes")
|
|
124
|
+
continue;
|
|
125
|
+
const target = attr.value.trim();
|
|
126
|
+
const resolved = byId.get(target) ?? byDisplayId.get(target);
|
|
127
|
+
if (!resolved)
|
|
128
|
+
continue;
|
|
129
|
+
if (resolved.shape === entry.shape)
|
|
130
|
+
continue;
|
|
131
|
+
diagnostics.push({
|
|
132
|
+
code: "MSL-R084",
|
|
133
|
+
severity: "error",
|
|
134
|
+
message: `${entry.displayId}: Supersedes: target '${target}' is ` +
|
|
135
|
+
`shape '${resolved.shape}' but source is '${entry.shape}' — ` +
|
|
136
|
+
`Supersedes operates within a shape (ADR-002 §Part 1)`,
|
|
137
|
+
location: entry.location,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
for (const rule of TRACE_RULES) {
|
|
141
|
+
for (const attr of entry.rawAttributes) {
|
|
142
|
+
if (attr.key !== rule.attr)
|
|
143
|
+
continue;
|
|
144
|
+
const target = attr.value.trim();
|
|
145
|
+
const resolved = byId.get(target) ?? byDisplayId.get(target);
|
|
146
|
+
if (!resolved)
|
|
147
|
+
continue;
|
|
148
|
+
const targetType = resolvedCoreType(resolved);
|
|
149
|
+
if (!targetType)
|
|
150
|
+
continue;
|
|
151
|
+
if (isTargetTypeCompatible(targetType, rule.allowedTargetTypes)) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
diagnostics.push({
|
|
155
|
+
code: "MSL-R083",
|
|
156
|
+
severity: "error",
|
|
157
|
+
message: `${entry.displayId}: ${rule.attr}: target '${target}' is ` +
|
|
158
|
+
`of type '${targetType}' — expected one of [${rule.allowedTargetTypes.join(", ")}]`,
|
|
159
|
+
location: entry.location,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Polymorphic Caused-by: ADR-003 §Part 2 lists distinct allowed
|
|
164
|
+
// target sets for `Caused-by` on Record vs Risk. If we can't
|
|
165
|
+
// classify the source as one of those two, we can't pick an
|
|
166
|
+
// applicable rule — emitting MSL-R083 with the union of both sets
|
|
167
|
+
// produces a useless "expected one of seven types" message, so we
|
|
168
|
+
// skip the check entirely. Record/Risk subtype classification
|
|
169
|
+
// walks the type hierarchy so subtypes (e.g., Hazard extends Risk)
|
|
170
|
+
// inherit the rule.
|
|
171
|
+
const sourceType = resolvedCoreType(entry);
|
|
172
|
+
const sourceRole = sourceType
|
|
173
|
+
? POLYMORPHIC_CAUSED_BY.find((r) => isTargetTypeCompatible(sourceType, [r.source]))
|
|
174
|
+
: undefined;
|
|
175
|
+
if (sourceRole) {
|
|
176
|
+
for (const attr of entry.rawAttributes) {
|
|
177
|
+
if (attr.key !== "Caused-by")
|
|
178
|
+
continue;
|
|
179
|
+
const target = attr.value.trim();
|
|
180
|
+
const resolved = byId.get(target) ?? byDisplayId.get(target);
|
|
181
|
+
if (!resolved)
|
|
182
|
+
continue;
|
|
183
|
+
const targetType = resolvedCoreType(resolved);
|
|
184
|
+
if (!targetType)
|
|
185
|
+
continue;
|
|
186
|
+
if (isTargetTypeCompatible(targetType, sourceRole.allowed))
|
|
187
|
+
continue;
|
|
188
|
+
diagnostics.push({
|
|
189
|
+
code: "MSL-R083",
|
|
190
|
+
severity: "error",
|
|
191
|
+
message: `${entry.displayId}: Caused-by: target '${target}' is ` +
|
|
192
|
+
`of type '${targetType}' — expected one of [${sourceRole.allowed.join(", ")}] for a ${sourceRole.source} source`,
|
|
193
|
+
location: entry.location,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Link-target severity diagnostics (MSL-R081 / MSL-R082) for all
|
|
198
|
+
// forward-pointing trace attributes. Supersedes is excluded — its
|
|
199
|
+
// predecessor target is meant to be retired.
|
|
200
|
+
for (const attr of entry.rawAttributes) {
|
|
201
|
+
if (!SEVERITY_TRACKED_ATTRS.includes(attr.key))
|
|
202
|
+
continue;
|
|
203
|
+
// Citations may carry a free-text locator after the slug — take
|
|
204
|
+
// the first whitespace-separated token as the target.
|
|
205
|
+
const target = attr.value.trim().split(/\s+/)[0];
|
|
206
|
+
if (!target)
|
|
207
|
+
continue;
|
|
208
|
+
const resolved = byId.get(target) ?? byDisplayId.get(target);
|
|
209
|
+
if (!resolved)
|
|
210
|
+
continue;
|
|
211
|
+
if (isRetired(resolved)) {
|
|
212
|
+
diagnostics.push({
|
|
213
|
+
code: "MSL-R081",
|
|
214
|
+
severity: "warning",
|
|
215
|
+
message: `${entry.displayId}: ${attr.key}: target '${target}' is ` +
|
|
216
|
+
`retired (Deprecated set on the target entry)`,
|
|
217
|
+
location: entry.location,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (isDraft(resolved)) {
|
|
221
|
+
diagnostics.push({
|
|
222
|
+
code: "MSL-R082",
|
|
223
|
+
severity: "info",
|
|
224
|
+
message: `${entry.displayId}: ${attr.key}: target '${target}' ` +
|
|
225
|
+
`carries Labels: DRAFT`,
|
|
226
|
+
location: entry.location,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return diagnostics;
|
|
232
|
+
}
|
|
@@ -16,11 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { Diagnostic, EffectiveProfile, Entry, TargetMatcher, TraceRule } from "../model/mod.js";
|
|
18
18
|
/**
|
|
19
|
-
* Effective trace rules for an entry:
|
|
20
|
-
*
|
|
21
|
-
* link-attribute-name collision.
|
|
19
|
+
* Effective trace rules for an entry: type-scope rules only.
|
|
20
|
+
* Type-scope rules are applied only when the entry is classified.
|
|
22
21
|
*
|
|
23
|
-
*
|
|
22
|
+
* Reference entries (shape !== "Authored") always return an empty map.
|
|
24
23
|
*/
|
|
25
24
|
export declare function effectiveTraceRules(entry: Entry, profile: EffectiveProfile): ReadonlyMap<string, TraceRule>;
|
|
26
25
|
/**
|