@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB
|
|
1
|
+
{"version":3,"file":"traceability.d.ts","sourceRoot":"","sources":["../../src/validator/traceability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,KAAK,EACL,aAAa,EACb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAehC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,EAAE,SAAS,aAAa,EAAE,GACjC,OAAO,CAST;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAChC,UAAU,EAAE,CAuEd"}
|
|
@@ -15,20 +15,15 @@
|
|
|
15
15
|
* never have declared outgoing links.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
|
-
* Effective trace rules for an entry:
|
|
19
|
-
*
|
|
20
|
-
* link-attribute-name collision.
|
|
18
|
+
* Effective trace rules for an entry: type-scope rules only.
|
|
19
|
+
* Type-scope rules are applied only when the entry is classified.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
21
|
+
* Reference entries (shape !== "Authored") always return an empty map.
|
|
23
22
|
*/
|
|
24
23
|
export function effectiveTraceRules(entry, profile) {
|
|
25
24
|
const out = new Map();
|
|
26
|
-
if (entry.shape !== "
|
|
25
|
+
if (entry.shape !== "Authored")
|
|
27
26
|
return out;
|
|
28
|
-
// Shape scope.
|
|
29
|
-
for (const [name, ruleEntry] of profile.identified.traceability) {
|
|
30
|
-
out.set(name, ruleEntry.value);
|
|
31
|
-
}
|
|
32
27
|
// Type scope (only when classified AND type is declared in the profile).
|
|
33
28
|
if (entry.type !== undefined) {
|
|
34
29
|
const typeEntry = profile.types.get(entry.type);
|
|
@@ -75,7 +70,7 @@ export function matchesAnyTarget(target, matchers) {
|
|
|
75
70
|
*/
|
|
76
71
|
export function validateTraceabilityForEntry(entry, profile, graph) {
|
|
77
72
|
const diagnostics = [];
|
|
78
|
-
if (entry.shape !== "
|
|
73
|
+
if (entry.shape !== "Authored")
|
|
79
74
|
return diagnostics;
|
|
80
75
|
const rules = effectiveTraceRules(entry, profile);
|
|
81
76
|
const present = entry.typedAttributes;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/type_resolution
|
|
3
|
+
*
|
|
4
|
+
* Shared helper for resolving an entry's effective core type. Walks
|
|
5
|
+
* the spec §1.3.1 type-resolution chain at the level needed for
|
|
6
|
+
* validator passes:
|
|
7
|
+
*
|
|
8
|
+
* 1. Explicit `Type:` attribute.
|
|
9
|
+
* 2. Profile-classified `entry.type` (set upstream).
|
|
10
|
+
* 3. `Source:` introspection (Cargo.toml → SoftwareComponent,
|
|
11
|
+
* *.rs → SoftwareUnit, *.proto → SoftwareInterface, …).
|
|
12
|
+
* 4. Authored display-ID prefix (`REQ` / `TST` / `ICD` / `REC` /
|
|
13
|
+
* `RSK`) → corresponding core Specification subtype.
|
|
14
|
+
* 5. Reference-shape URI scheme inference (ADR-003 §Part 6).
|
|
15
|
+
* 6. Discriminating-attribute presence (Verifies → Test,
|
|
16
|
+
* Schema-language → Contract, …).
|
|
17
|
+
*
|
|
18
|
+
* Step 7 (document directive) is not consulted here; step 8
|
|
19
|
+
* (display-ID shape) has its own warning-emitting stage in
|
|
20
|
+
* `validator/types.ts` (`inferTypeFromDisplayIdShape`).
|
|
21
|
+
*/
|
|
22
|
+
import type { Entry } from "../model/mod.js";
|
|
23
|
+
/**
|
|
24
|
+
* Infer a core type from an Authored entry's display-ID prefix.
|
|
25
|
+
* Returns the type when the display ID starts with one of the
|
|
26
|
+
* recognised prefixes followed by `-` or `_`. Returns `undefined`
|
|
27
|
+
* otherwise.
|
|
28
|
+
*
|
|
29
|
+
* Per spec §1.3.1 this is step 4 of the resolution chain — earlier
|
|
30
|
+
* than late-stage inference at step 8, so a matching prefix does
|
|
31
|
+
* not produce an MSL-T021 warning.
|
|
32
|
+
*/
|
|
33
|
+
export declare function inferTypeFromDisplayIdPrefix(displayId: string): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Read an entry's explicit `Type:` attribute, trimmed. Returns
|
|
36
|
+
* `undefined` when the attribute is absent OR when the trimmed value
|
|
37
|
+
* is empty — a whitespace-only `Type:` value is treated as "no type
|
|
38
|
+
* given" so downstream diagnostics don't surface empty-quoted values.
|
|
39
|
+
*/
|
|
40
|
+
export declare function explicitType(entry: Entry): string | undefined;
|
|
41
|
+
/** Which step of the §1.3.1 chain resolved a type. Steps 7 and 8 are
|
|
42
|
+
* not reported here; step 8 has its own warning-emitting stage. */
|
|
43
|
+
export type TypeResolutionStep = 1 | 2 | 3 | 4 | 5 | 6;
|
|
44
|
+
/** A type together with the step of the §1.3.1 chain that resolved it. */
|
|
45
|
+
export interface ResolvedTypeWithProvenance {
|
|
46
|
+
readonly type: string;
|
|
47
|
+
readonly step: TypeResolutionStep;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve an entry's effective core type and report which step of the
|
|
51
|
+
* spec §1.3.1 chain matched. First match wins. Returns `undefined` when
|
|
52
|
+
* no step in {1..6} resolves to a known core type — callers may then
|
|
53
|
+
* consult late-stage step-8 inference (`inferTypeFromDisplayIdShape`)
|
|
54
|
+
* or treat the entry as unclassified (fallback to `Item`).
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolvedCoreTypeWithProvenance(entry: Entry): ResolvedTypeWithProvenance | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve an entry's effective core type without provenance. Convenience
|
|
59
|
+
* wrapper around {@linkcode resolvedCoreTypeWithProvenance} for callers
|
|
60
|
+
* that don't need to know which step matched.
|
|
61
|
+
*
|
|
62
|
+
* Returns `undefined` when no step in {1..6} resolves to a known core
|
|
63
|
+
* type. The caller decides whether to skip validation, fall back to a
|
|
64
|
+
* less specific check, or report on the unclassified state.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolvedCoreType(entry: Entry): string | undefined;
|
|
67
|
+
//# sourceMappingURL=type_resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type_resolution.d.ts","sourceRoot":"","sources":["../../src/validator/type_resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAuB7C;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAO7D;AAYD;mEACmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEvD,0EAA0E;AAC1E,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,KAAK,GACX,0BAA0B,GAAG,SAAS,CAuCxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAEjE"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/validator/type_resolution
|
|
3
|
+
*
|
|
4
|
+
* Shared helper for resolving an entry's effective core type. Walks
|
|
5
|
+
* the spec §1.3.1 type-resolution chain at the level needed for
|
|
6
|
+
* validator passes:
|
|
7
|
+
*
|
|
8
|
+
* 1. Explicit `Type:` attribute.
|
|
9
|
+
* 2. Profile-classified `entry.type` (set upstream).
|
|
10
|
+
* 3. `Source:` introspection (Cargo.toml → SoftwareComponent,
|
|
11
|
+
* *.rs → SoftwareUnit, *.proto → SoftwareInterface, …).
|
|
12
|
+
* 4. Authored display-ID prefix (`REQ` / `TST` / `ICD` / `REC` /
|
|
13
|
+
* `RSK`) → corresponding core Specification subtype.
|
|
14
|
+
* 5. Reference-shape URI scheme inference (ADR-003 §Part 6).
|
|
15
|
+
* 6. Discriminating-attribute presence (Verifies → Test,
|
|
16
|
+
* Schema-language → Contract, …).
|
|
17
|
+
*
|
|
18
|
+
* Step 7 (document directive) is not consulted here; step 8
|
|
19
|
+
* (display-ID shape) has its own warning-emitting stage in
|
|
20
|
+
* `validator/types.ts` (`inferTypeFromDisplayIdShape`).
|
|
21
|
+
*/
|
|
22
|
+
import { CORE_TYPE_HIERARCHY, inferTypeFromDiscriminatingAttr, inferTypeFromSource, inferTypeFromUriScheme, } from "../model/mod.js";
|
|
23
|
+
/**
|
|
24
|
+
* Map from Authored display-ID prefix to the core type the prefix
|
|
25
|
+
* implies (spec §1.3.1 step 4, ADR-003 §Part 1 "Display-ID prefixes").
|
|
26
|
+
* Matched as `<PREFIX><sep><rest>` where `<sep>` is `-` or `_` — the
|
|
27
|
+
* two conventions in widespread use. Case-sensitive: the prefix is
|
|
28
|
+
* part of the canonical-style ID, not a free-form alias.
|
|
29
|
+
*/
|
|
30
|
+
const DISPLAY_ID_PREFIX_TYPE = new Map([
|
|
31
|
+
["REQ", "Requirement"],
|
|
32
|
+
["TST", "Test"],
|
|
33
|
+
["ICD", "Contract"],
|
|
34
|
+
["REC", "Record"],
|
|
35
|
+
["RSK", "Risk"],
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Infer a core type from an Authored entry's display-ID prefix.
|
|
39
|
+
* Returns the type when the display ID starts with one of the
|
|
40
|
+
* recognised prefixes followed by `-` or `_`. Returns `undefined`
|
|
41
|
+
* otherwise.
|
|
42
|
+
*
|
|
43
|
+
* Per spec §1.3.1 this is step 4 of the resolution chain — earlier
|
|
44
|
+
* than late-stage inference at step 8, so a matching prefix does
|
|
45
|
+
* not produce an MSL-T021 warning.
|
|
46
|
+
*/
|
|
47
|
+
export function inferTypeFromDisplayIdPrefix(displayId) {
|
|
48
|
+
for (const [prefix, type] of DISPLAY_ID_PREFIX_TYPE) {
|
|
49
|
+
if (displayId.startsWith(prefix) &&
|
|
50
|
+
displayId.length > prefix.length &&
|
|
51
|
+
(displayId[prefix.length] === "-" || displayId[prefix.length] === "_")) {
|
|
52
|
+
return type;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Read an entry's explicit `Type:` attribute, trimmed. Returns
|
|
59
|
+
* `undefined` when the attribute is absent OR when the trimmed value
|
|
60
|
+
* is empty — a whitespace-only `Type:` value is treated as "no type
|
|
61
|
+
* given" so downstream diagnostics don't surface empty-quoted values.
|
|
62
|
+
*/
|
|
63
|
+
export function explicitType(entry) {
|
|
64
|
+
for (const attr of entry.rawAttributes) {
|
|
65
|
+
if (attr.key !== "Type")
|
|
66
|
+
continue;
|
|
67
|
+
const trimmed = attr.value.trim();
|
|
68
|
+
return trimmed.length === 0 ? undefined : trimmed;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
/** Read an entry's `Source:` attribute, trimmed; empty values yield `undefined`. */
|
|
73
|
+
function sourceValue(entry) {
|
|
74
|
+
for (const attr of entry.rawAttributes) {
|
|
75
|
+
if (attr.key !== "Source")
|
|
76
|
+
continue;
|
|
77
|
+
const trimmed = attr.value.trim();
|
|
78
|
+
return trimmed.length === 0 ? undefined : trimmed;
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve an entry's effective core type and report which step of the
|
|
84
|
+
* spec §1.3.1 chain matched. First match wins. Returns `undefined` when
|
|
85
|
+
* no step in {1..6} resolves to a known core type — callers may then
|
|
86
|
+
* consult late-stage step-8 inference (`inferTypeFromDisplayIdShape`)
|
|
87
|
+
* or treat the entry as unclassified (fallback to `Item`).
|
|
88
|
+
*/
|
|
89
|
+
export function resolvedCoreTypeWithProvenance(entry) {
|
|
90
|
+
// Step 1: explicit Type:
|
|
91
|
+
const explicit = explicitType(entry);
|
|
92
|
+
if (explicit && CORE_TYPE_HIERARCHY[explicit]) {
|
|
93
|
+
return { type: explicit, step: 1 };
|
|
94
|
+
}
|
|
95
|
+
// Step 2: profile-classified entry.type
|
|
96
|
+
if (entry.type && CORE_TYPE_HIERARCHY[entry.type]) {
|
|
97
|
+
return { type: entry.type, step: 2 };
|
|
98
|
+
}
|
|
99
|
+
// Step 3: Source: introspection
|
|
100
|
+
const source = sourceValue(entry);
|
|
101
|
+
if (source !== undefined) {
|
|
102
|
+
const inferred = inferTypeFromSource(source);
|
|
103
|
+
if (inferred && CORE_TYPE_HIERARCHY[inferred]) {
|
|
104
|
+
return { type: inferred, step: 3 };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Step 4: Authored display-ID prefix
|
|
108
|
+
if (entry.shape === "Authored") {
|
|
109
|
+
const inferred = inferTypeFromDisplayIdPrefix(entry.displayId);
|
|
110
|
+
if (inferred && CORE_TYPE_HIERARCHY[inferred]) {
|
|
111
|
+
return { type: inferred, step: 4 };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Step 5: Reference-shape URI scheme
|
|
115
|
+
if (entry.shape === "Reference" && entry.id) {
|
|
116
|
+
const inferred = inferTypeFromUriScheme(entry.id);
|
|
117
|
+
if (inferred && CORE_TYPE_HIERARCHY[inferred]) {
|
|
118
|
+
return { type: inferred, step: 5 };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Step 6: Discriminating attribute presence — first matching key wins.
|
|
122
|
+
const attrKeys = entry.rawAttributes.map((a) => a.key);
|
|
123
|
+
const fromDiscriminator = inferTypeFromDiscriminatingAttr(attrKeys);
|
|
124
|
+
if (fromDiscriminator && CORE_TYPE_HIERARCHY[fromDiscriminator]) {
|
|
125
|
+
return { type: fromDiscriminator, step: 6 };
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Resolve an entry's effective core type without provenance. Convenience
|
|
131
|
+
* wrapper around {@linkcode resolvedCoreTypeWithProvenance} for callers
|
|
132
|
+
* that don't need to know which step matched.
|
|
133
|
+
*
|
|
134
|
+
* Returns `undefined` when no step in {1..6} resolves to a known core
|
|
135
|
+
* type. The caller decides whether to skip validation, fall back to a
|
|
136
|
+
* less specific check, or report on the unclassified state.
|
|
137
|
+
*/
|
|
138
|
+
export function resolvedCoreType(entry) {
|
|
139
|
+
return resolvedCoreTypeWithProvenance(entry)?.type;
|
|
140
|
+
}
|
package/esm/validator/types.d.ts
CHANGED
|
@@ -8,6 +8,51 @@
|
|
|
8
8
|
* entries in a strict profile (types declared) produce MSL-T003.
|
|
9
9
|
*/
|
|
10
10
|
import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
|
|
11
|
+
/**
|
|
12
|
+
* Late-stage type inference per spec §1.3.1 step 8 (Authored shape).
|
|
13
|
+
*
|
|
14
|
+
* When no upstream signal has resolved the entry's type and the display
|
|
15
|
+
* ID carries a path-like separator, infer `Unit` and emit MSL-T021 as a
|
|
16
|
+
* warning so the author can promote the inferred type to an explicit
|
|
17
|
+
* declaration.
|
|
18
|
+
*
|
|
19
|
+
* The "no upstream signal" check consults `resolvedCoreType()` so a
|
|
20
|
+
* profile-classified `entry.type` or any earlier inference branch
|
|
21
|
+
* suppresses the warning — previously only an explicit `Type:`
|
|
22
|
+
* attribute did. Step 8 (this function) is the genuinely-late
|
|
23
|
+
* fallback; firing it on already-classified entries was a false
|
|
24
|
+
* positive.
|
|
25
|
+
*/
|
|
26
|
+
export declare function inferTypeFromDisplayIdShape(entry: Entry): readonly Diagnostic[];
|
|
27
|
+
/**
|
|
28
|
+
* Late-stage type-inference warning for steps 5 and 6 of the §1.3.1
|
|
29
|
+
* resolution chain (URI scheme inference; discriminating-attribute
|
|
30
|
+
* presence). Per spec §1.3.2, MSL-T021 fires for any inference at
|
|
31
|
+
* step ≥ 5 — step 8 (display-ID shape) is covered by
|
|
32
|
+
* {@linkcode inferTypeFromDisplayIdShape} above, this function covers
|
|
33
|
+
* steps 5 and 6. Step 7 (document directive) is not yet wired through.
|
|
34
|
+
*
|
|
35
|
+
* Suppressed when the entry already carries a profile-classified
|
|
36
|
+
* `entry.type` — even if that profile type is not itself in the core
|
|
37
|
+
* hierarchy (e.g., `test` rather than `Test`). The author has already
|
|
38
|
+
* provided a type signal through the profile's display-ID-pattern
|
|
39
|
+
* mechanism; a late-stage warning about a different core type that
|
|
40
|
+
* happens to also resolve would be noise.
|
|
41
|
+
*/
|
|
42
|
+
export declare function inferTypeFromLateStageChain(entry: Entry): readonly Diagnostic[];
|
|
43
|
+
/**
|
|
44
|
+
* Validate the `Type:` attribute value against the core type taxonomy plus
|
|
45
|
+
* any profile-declared types. Runs in every mode (with or without a loaded
|
|
46
|
+
* profile) — see spec §1.3 and ADR-003 §Part 1.
|
|
47
|
+
*
|
|
48
|
+
* Emits:
|
|
49
|
+
* - `MSL-T020` when `Type:` is present but the value is neither a core
|
|
50
|
+
* abstract/concrete type nor a profile-declared type.
|
|
51
|
+
* - `MSL-T023` when `Type:` matches the profile-declared naming convention
|
|
52
|
+
* (lowercase-with-hyphens) but no profile is loaded — i.e., the value
|
|
53
|
+
* is plausibly a profile type, just unreachable in core-only mode.
|
|
54
|
+
*/
|
|
55
|
+
export declare function validateCoreTypeAttribute(entry: Entry, profile: EffectiveProfile | null): readonly Diagnostic[];
|
|
11
56
|
/** Result of classifying a single entry. */
|
|
12
57
|
export interface ClassifyResult {
|
|
13
58
|
/** The assigned type name, or `undefined` if un-classified. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,KAAK,EAEN,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAEhB,KAAK,EAEN,MAAM,iBAAiB,CAAC;AAwBzB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAWvB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,KAAK,GACX,SAAS,UAAU,EAAE,CAiBvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CAwBvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GACxB,cAAc,CA8DhB;AAED,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GACxB,mBAAmB,CAuBrB"}
|
package/esm/validator/types.js
CHANGED
|
@@ -7,7 +7,125 @@
|
|
|
7
7
|
* `Type:` trailer attribute or by display-ID pattern matching. Un-classified
|
|
8
8
|
* entries in a strict profile (types declared) produce MSL-T003.
|
|
9
9
|
*/
|
|
10
|
+
import { CORE_TYPES } from "../model/mod.js";
|
|
10
11
|
import { compileDisplayIdPattern } from "./pattern.js";
|
|
12
|
+
import { explicitType, resolvedCoreType, resolvedCoreTypeWithProvenance, } from "./type_resolution.js";
|
|
13
|
+
/**
|
|
14
|
+
* Profile-declared concrete-type naming convention (spec §1.3): lowercase
|
|
15
|
+
* alphanumeric with hyphens, starting with a letter. Used to distinguish a
|
|
16
|
+
* "looks like a profile type but no profile is loaded" diagnostic
|
|
17
|
+
* (MSL-T023) from a generic "unknown type" diagnostic (MSL-T020).
|
|
18
|
+
*/
|
|
19
|
+
const PROFILE_TYPE_NAME_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
20
|
+
/**
|
|
21
|
+
* Display-ID shape that infers Unit at chain step 8 (spec §1.3.1).
|
|
22
|
+
* Matches when the display ID carries a path-like separator (`::` for
|
|
23
|
+
* Rust/C++ symbol paths, `/` for filesystem-style hierarchies).
|
|
24
|
+
*/
|
|
25
|
+
const UNIT_DISPLAY_ID_RE = /(::|\/)/;
|
|
26
|
+
/**
|
|
27
|
+
* Late-stage type inference per spec §1.3.1 step 8 (Authored shape).
|
|
28
|
+
*
|
|
29
|
+
* When no upstream signal has resolved the entry's type and the display
|
|
30
|
+
* ID carries a path-like separator, infer `Unit` and emit MSL-T021 as a
|
|
31
|
+
* warning so the author can promote the inferred type to an explicit
|
|
32
|
+
* declaration.
|
|
33
|
+
*
|
|
34
|
+
* The "no upstream signal" check consults `resolvedCoreType()` so a
|
|
35
|
+
* profile-classified `entry.type` or any earlier inference branch
|
|
36
|
+
* suppresses the warning — previously only an explicit `Type:`
|
|
37
|
+
* attribute did. Step 8 (this function) is the genuinely-late
|
|
38
|
+
* fallback; firing it on already-classified entries was a false
|
|
39
|
+
* positive.
|
|
40
|
+
*/
|
|
41
|
+
export function inferTypeFromDisplayIdShape(entry) {
|
|
42
|
+
if (entry.shape !== "Authored")
|
|
43
|
+
return [];
|
|
44
|
+
if (resolvedCoreType(entry) !== undefined)
|
|
45
|
+
return [];
|
|
46
|
+
if (!UNIT_DISPLAY_ID_RE.test(entry.displayId))
|
|
47
|
+
return [];
|
|
48
|
+
return [{
|
|
49
|
+
code: "MSL-T021",
|
|
50
|
+
severity: "warning",
|
|
51
|
+
message: `${entry.displayId}: Type inferred as 'Unit' from display-ID ` +
|
|
52
|
+
`shape (late-stage inference); declare 'Type:' explicitly to silence`,
|
|
53
|
+
location: entry.location,
|
|
54
|
+
}];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Late-stage type-inference warning for steps 5 and 6 of the §1.3.1
|
|
58
|
+
* resolution chain (URI scheme inference; discriminating-attribute
|
|
59
|
+
* presence). Per spec §1.3.2, MSL-T021 fires for any inference at
|
|
60
|
+
* step ≥ 5 — step 8 (display-ID shape) is covered by
|
|
61
|
+
* {@linkcode inferTypeFromDisplayIdShape} above, this function covers
|
|
62
|
+
* steps 5 and 6. Step 7 (document directive) is not yet wired through.
|
|
63
|
+
*
|
|
64
|
+
* Suppressed when the entry already carries a profile-classified
|
|
65
|
+
* `entry.type` — even if that profile type is not itself in the core
|
|
66
|
+
* hierarchy (e.g., `test` rather than `Test`). The author has already
|
|
67
|
+
* provided a type signal through the profile's display-ID-pattern
|
|
68
|
+
* mechanism; a late-stage warning about a different core type that
|
|
69
|
+
* happens to also resolve would be noise.
|
|
70
|
+
*/
|
|
71
|
+
export function inferTypeFromLateStageChain(entry) {
|
|
72
|
+
if (entry.type !== undefined)
|
|
73
|
+
return [];
|
|
74
|
+
const resolved = resolvedCoreTypeWithProvenance(entry);
|
|
75
|
+
if (!resolved)
|
|
76
|
+
return [];
|
|
77
|
+
if (resolved.step < 5)
|
|
78
|
+
return [];
|
|
79
|
+
const source = resolved.step === 5
|
|
80
|
+
? "URI scheme"
|
|
81
|
+
: "discriminating attribute";
|
|
82
|
+
return [{
|
|
83
|
+
code: "MSL-T021",
|
|
84
|
+
severity: "warning",
|
|
85
|
+
message: `${entry.displayId}: Type inferred as '${resolved.type}' from ${source} ` +
|
|
86
|
+
`(late-stage inference, step ${resolved.step}); declare 'Type:' ` +
|
|
87
|
+
`explicitly to silence`,
|
|
88
|
+
location: entry.location,
|
|
89
|
+
}];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Validate the `Type:` attribute value against the core type taxonomy plus
|
|
93
|
+
* any profile-declared types. Runs in every mode (with or without a loaded
|
|
94
|
+
* profile) — see spec §1.3 and ADR-003 §Part 1.
|
|
95
|
+
*
|
|
96
|
+
* Emits:
|
|
97
|
+
* - `MSL-T020` when `Type:` is present but the value is neither a core
|
|
98
|
+
* abstract/concrete type nor a profile-declared type.
|
|
99
|
+
* - `MSL-T023` when `Type:` matches the profile-declared naming convention
|
|
100
|
+
* (lowercase-with-hyphens) but no profile is loaded — i.e., the value
|
|
101
|
+
* is plausibly a profile type, just unreachable in core-only mode.
|
|
102
|
+
*/
|
|
103
|
+
export function validateCoreTypeAttribute(entry, profile) {
|
|
104
|
+
const value = explicitType(entry);
|
|
105
|
+
if (value === undefined)
|
|
106
|
+
return [];
|
|
107
|
+
if (CORE_TYPES.has(value))
|
|
108
|
+
return [];
|
|
109
|
+
if (profile !== null && profile.types.has(value))
|
|
110
|
+
return [];
|
|
111
|
+
// Core-only mode: distinguish "profile-only type" (T023) from "unknown" (T020).
|
|
112
|
+
if (profile === null && PROFILE_TYPE_NAME_RE.test(value)) {
|
|
113
|
+
return [{
|
|
114
|
+
code: "MSL-T023",
|
|
115
|
+
severity: "error",
|
|
116
|
+
message: `${entry.displayId}: Type: '${value}' looks like a ` +
|
|
117
|
+
`profile-declared type but no profile is loaded (core-only mode)`,
|
|
118
|
+
location: entry.location,
|
|
119
|
+
}];
|
|
120
|
+
}
|
|
121
|
+
return [{
|
|
122
|
+
code: "MSL-T020",
|
|
123
|
+
severity: "error",
|
|
124
|
+
message: `${entry.displayId}: Type: '${value}' is not a core type ` +
|
|
125
|
+
`or a profile-declared type`,
|
|
126
|
+
location: entry.location,
|
|
127
|
+
}];
|
|
128
|
+
}
|
|
11
129
|
/**
|
|
12
130
|
* Classify one {@linkcode Entry} against the profile's type vocabulary.
|
|
13
131
|
*
|
|
@@ -26,24 +144,26 @@ import { compileDisplayIdPattern } from "./pattern.js";
|
|
|
26
144
|
export function classifyEntry(entry, profile) {
|
|
27
145
|
const diagnostics = [];
|
|
28
146
|
// 1. Explicit Type: trailer?
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
if (profile.types.has(
|
|
32
|
-
return { type:
|
|
147
|
+
const explicit = explicitType(entry);
|
|
148
|
+
if (explicit !== undefined) {
|
|
149
|
+
if (profile.types.has(explicit)) {
|
|
150
|
+
return { type: explicit, diagnostics };
|
|
33
151
|
}
|
|
34
152
|
diagnostics.push({
|
|
35
153
|
code: "MSL-T001",
|
|
36
154
|
severity: "error",
|
|
37
|
-
message: `${entry.displayId}: explicit Type: '${
|
|
155
|
+
message: `${entry.displayId}: explicit Type: '${explicit}' is not a declared type`,
|
|
38
156
|
location: entry.location,
|
|
39
157
|
});
|
|
40
158
|
return { type: undefined, diagnostics };
|
|
41
159
|
}
|
|
42
|
-
// 2. Display-ID pattern match across same-shape types.
|
|
160
|
+
// 2. Display-ID pattern match across same-shape types (Authored only).
|
|
161
|
+
// Reference entries use URI scheme or explicit Type: for classification;
|
|
162
|
+
// matching display-id-patterns against their slug-style IDs is incorrect.
|
|
163
|
+
if (entry.shape !== "Authored")
|
|
164
|
+
return { type: undefined, diagnostics };
|
|
43
165
|
const matches = [];
|
|
44
166
|
for (const [typeName, typeEntry] of profile.types) {
|
|
45
|
-
if (typeEntry.value.shape !== entry.shape)
|
|
46
|
-
continue;
|
|
47
167
|
const pattern = typeEntry.value.displayIdPattern.value;
|
|
48
168
|
if (pattern === undefined)
|
|
49
169
|
continue;
|
|
@@ -77,14 +197,6 @@ export function classifyEntry(entry, profile) {
|
|
|
77
197
|
}
|
|
78
198
|
return { type: undefined, diagnostics };
|
|
79
199
|
}
|
|
80
|
-
function findExplicitTypeAttribute(entry) {
|
|
81
|
-
for (const attr of entry.rawAttributes) {
|
|
82
|
-
if (attr.key === "Type") {
|
|
83
|
-
return attr.value.trim();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
200
|
/**
|
|
89
201
|
* Run classification across all entries. Produces new {@linkcode Entry}
|
|
90
202
|
* objects with `type` set when classification succeeds; un-classified
|
|
@@ -17,4 +17,12 @@ import type { AttrDecl } from "../model/mod.js";
|
|
|
17
17
|
export declare function validateValue(value: string, decl: AttrDecl): string | null;
|
|
18
18
|
/** Signature for a single value-type validator. */
|
|
19
19
|
export type ValueValidator = (value: string, decl: AttrDecl) => string | null;
|
|
20
|
+
/**
|
|
21
|
+
* HTTP(S) URL prefix used by the `url` value type (spec §1.8). The
|
|
22
|
+
* spec specifies HTTPS but `http://` is accepted for compatibility
|
|
23
|
+
* with existing fixtures; tightening to HTTPS-only is a future
|
|
24
|
+
* config-driven slice. Exported so other validator passes (e.g.,
|
|
25
|
+
* file-local `Reference-url` checks) can share one regex.
|
|
26
|
+
*/
|
|
27
|
+
export declare const HTTP_URL_RE: RegExp;
|
|
20
28
|
//# sourceMappingURL=value_types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AA8C9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
|
|
@@ -57,7 +57,14 @@ const validateId = (value, _decl) => {
|
|
|
57
57
|
return null;
|
|
58
58
|
return `not a valid id: '${value}' (expected 26-char ULID or scheme-qualified URI)`;
|
|
59
59
|
};
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* HTTP(S) URL prefix used by the `url` value type (spec §1.8). The
|
|
62
|
+
* spec specifies HTTPS but `http://` is accepted for compatibility
|
|
63
|
+
* with existing fixtures; tightening to HTTPS-only is a future
|
|
64
|
+
* config-driven slice. Exported so other validator passes (e.g.,
|
|
65
|
+
* file-local `Reference-url` checks) can share one regex.
|
|
66
|
+
*/
|
|
67
|
+
export const HTTP_URL_RE = /^https?:\/\//;
|
|
61
68
|
const validateUrl = (value, _decl) => {
|
|
62
69
|
return HTTP_URL_RE.test(value) ? null : `not a valid http(s) URL: '${value}'`;
|
|
63
70
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/ast/build
|
|
3
|
+
*
|
|
4
|
+
* Body-string → BodyBlock[] builder. Parses the entry body string
|
|
5
|
+
* (post-`splitBodyAndAttributes`) with the shared remark processor and
|
|
6
|
+
* maps each mdast block child to the §2.4-2.6 node taxonomy.
|
|
7
|
+
*
|
|
8
|
+
* Inline markers (modal + $Identifier) are extracted for prose-bearing
|
|
9
|
+
* nodes: Paragraph, List items, Table cells, Note bodies, Blockquotes,
|
|
10
|
+
* and DefinitionList term/definitions. They are NOT extracted inside
|
|
11
|
+
* Code, Feature, or Math blocks (spec §2.5).
|
|
12
|
+
*
|
|
13
|
+
* This module is pure library code: no `Deno.*` APIs.
|
|
14
|
+
*/
|
|
15
|
+
import type { BodyBlock, InlineMarker, SourceRange } from "./nodes.js";
|
|
16
|
+
/**
|
|
17
|
+
* Extract all inline markers from a prose text string.
|
|
18
|
+
* `lineOffset` is the 0-based line index of the text within the body
|
|
19
|
+
* (used for SourceRange line numbers).
|
|
20
|
+
*
|
|
21
|
+
* For multi-line text the SourceRange carries the first line's 1-based
|
|
22
|
+
* column; this is best-effort for PR 2 (noted as DONE_WITH_CONCERNS:
|
|
23
|
+
* multi-line paragraph ranges are approximated to the starting line).
|
|
24
|
+
*
|
|
25
|
+
* Exported so the AST-native §3.4.1 normalisation pass
|
|
26
|
+
* (`core/ast/normalize.ts`) re-derives `InlineContent.markers` from the
|
|
27
|
+
* normalised text with the SAME extraction the builder uses — no regex
|
|
28
|
+
* duplication.
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractMarkersFromText(text: string, startRange: SourceRange): readonly InlineMarker[];
|
|
31
|
+
/**
|
|
32
|
+
* Return the exact source substring for an mdast node `position`, with
|
|
33
|
+
* list-continuation indentation normalised to column 0 so the slice is a
|
|
34
|
+
* self-contained, column-0-anchored string. This is the load-bearing
|
|
35
|
+
* mechanism for §5.1 faithful capture (ADR-014; spec §5.1): remark
|
|
36
|
+
* populates byte `offset` when a string is passed to `.parse()`; a
|
|
37
|
+
* line/column reconstruction is the defensive fallback. Extracted from
|
|
38
|
+
* the original inline `TableNode` logic — behaviour is identical.
|
|
39
|
+
*/
|
|
40
|
+
export declare function verbatimSlice(body: string, pos: {
|
|
41
|
+
start: {
|
|
42
|
+
line: number;
|
|
43
|
+
column: number;
|
|
44
|
+
offset?: number;
|
|
45
|
+
};
|
|
46
|
+
end: {
|
|
47
|
+
line: number;
|
|
48
|
+
column: number;
|
|
49
|
+
offset?: number;
|
|
50
|
+
};
|
|
51
|
+
} | undefined): string;
|
|
52
|
+
/**
|
|
53
|
+
* Build the canonical body AST from an entry body string.
|
|
54
|
+
*
|
|
55
|
+
* Re-parses `body` via the shared remark processor (CommonMark+GFM) and
|
|
56
|
+
* maps each block-level mdast node to a `BodyBlock`. SourceRange positions
|
|
57
|
+
* are body-relative (1-based line/column) matching the mdast output directly.
|
|
58
|
+
*
|
|
59
|
+
* DONE_WITH_CONCERNS notes:
|
|
60
|
+
* - DefinitionList: single-item best-effort. `Term\n: def` patterns in
|
|
61
|
+
* multi-item lists are parsed as one DefinitionListNode per paragraph
|
|
62
|
+
* block; the validator would need to coalesce them (deferred).
|
|
63
|
+
* - Caption position: assigned by adjacent-block heuristic (post-pass).
|
|
64
|
+
* `block` (resolved owner) is `undefined` for PR 2 per spec.
|
|
65
|
+
* - Multi-line paragraph marker ranges: SourceRange is approximated to
|
|
66
|
+
* the paragraph start line; intra-paragraph column tracking is correct
|
|
67
|
+
* only for single-line paragraphs.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildBodyAst(body: string): BodyBlock[];
|
|
70
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/ast/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAGV,SAAS,EAQT,YAAY,EAQZ,WAAW,EAGZ,MAAM,YAAY,CAAC;AAmBpB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,WAAW,GACtB,SAAS,YAAY,EAAE,CAyEzB;AAyCD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE;IACH,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxD,GAAG,SAAS,GACZ,MAAM,CAgCR;AA4cD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAUtD"}
|