@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.
Files changed (331) hide show
  1. package/esm/ast/build.d.ts +70 -0
  2. package/esm/ast/build.d.ts.map +1 -0
  3. package/esm/ast/build.js +605 -0
  4. package/esm/ast/equivalence.d.ts +18 -0
  5. package/esm/ast/equivalence.d.ts.map +1 -0
  6. package/esm/ast/equivalence.js +56 -0
  7. package/esm/ast/nodes.d.ts +221 -0
  8. package/esm/ast/nodes.d.ts.map +1 -0
  9. package/esm/ast/nodes.js +12 -0
  10. package/esm/ast/normalize.d.ts +67 -0
  11. package/esm/ast/normalize.d.ts.map +1 -0
  12. package/esm/ast/normalize.js +255 -0
  13. package/esm/ast/render.d.ts +34 -0
  14. package/esm/ast/render.d.ts.map +1 -0
  15. package/esm/ast/render.js +215 -0
  16. package/esm/compiler/inverses.d.ts +2 -8
  17. package/esm/compiler/inverses.d.ts.map +1 -1
  18. package/esm/compiler/inverses.js +50 -14
  19. package/esm/compiler/manifest.d.ts +59 -0
  20. package/esm/compiler/manifest.d.ts.map +1 -0
  21. package/esm/compiler/manifest.js +48 -0
  22. package/esm/compiler/mod.d.ts +9 -1
  23. package/esm/compiler/mod.d.ts.map +1 -1
  24. package/esm/compiler/mod.js +21 -2
  25. package/esm/compiler/ndjson_writer.d.ts +50 -0
  26. package/esm/compiler/ndjson_writer.d.ts.map +1 -0
  27. package/esm/compiler/ndjson_writer.js +73 -0
  28. package/esm/compiler/schema.d.ts +18 -1
  29. package/esm/compiler/schema.d.ts.map +1 -1
  30. package/esm/compiler/schema.js +18 -9
  31. package/esm/config/mod.d.ts.map +1 -1
  32. package/esm/config/mod.js +54 -0
  33. package/esm/formatter/mod.d.ts +56 -6
  34. package/esm/formatter/mod.d.ts.map +1 -1
  35. package/esm/formatter/mod.js +372 -41
  36. package/esm/formatter/synth_ulid.d.ts +21 -0
  37. package/esm/formatter/synth_ulid.d.ts.map +1 -0
  38. package/esm/formatter/synth_ulid.js +64 -0
  39. package/esm/lint/mod.d.ts +10 -0
  40. package/esm/lint/mod.d.ts.map +1 -0
  41. package/esm/lint/mod.js +7 -0
  42. package/esm/lint/rules/lexicon.d.ts +24 -0
  43. package/esm/lint/rules/lexicon.d.ts.map +1 -0
  44. package/esm/lint/rules/lexicon.js +236 -0
  45. package/esm/lint/rules/struct.d.ts +17 -0
  46. package/esm/lint/rules/struct.d.ts.map +1 -0
  47. package/esm/lint/rules/struct.js +55 -0
  48. package/esm/lint/rules/suppression.d.ts +19 -0
  49. package/esm/lint/rules/suppression.d.ts.map +1 -0
  50. package/esm/lint/rules/suppression.js +75 -0
  51. package/esm/lint/runner.d.ts +39 -0
  52. package/esm/lint/runner.d.ts.map +1 -0
  53. package/esm/lint/runner.js +112 -0
  54. package/esm/lint/types.d.ts +19 -0
  55. package/esm/lint/types.d.ts.map +1 -0
  56. package/esm/lint/types.js +9 -0
  57. package/esm/mod.d.ts +21 -8
  58. package/esm/mod.d.ts.map +1 -1
  59. package/esm/mod.js +16 -5
  60. package/esm/model/attributes.d.ts.map +1 -1
  61. package/esm/model/attributes.js +163 -2
  62. package/esm/model/discriminating_attr.d.ts +33 -0
  63. package/esm/model/discriminating_attr.d.ts.map +1 -0
  64. package/esm/model/discriminating_attr.js +74 -0
  65. package/esm/model/mod.d.ts +100 -3
  66. package/esm/model/mod.d.ts.map +1 -1
  67. package/esm/model/mod.js +58 -2
  68. package/esm/model/palette.d.ts +18 -0
  69. package/esm/model/palette.d.ts.map +1 -0
  70. package/esm/model/palette.js +23 -0
  71. package/esm/model/profile.d.ts +33 -27
  72. package/esm/model/profile.d.ts.map +1 -1
  73. package/esm/model/source_introspection.d.ts +26 -0
  74. package/esm/model/source_introspection.d.ts.map +1 -0
  75. package/esm/model/source_introspection.js +77 -0
  76. package/esm/model/type_hierarchy.d.ts +51 -0
  77. package/esm/model/type_hierarchy.d.ts.map +1 -0
  78. package/esm/model/type_hierarchy.js +126 -0
  79. package/esm/model/uri_scheme_map.d.ts +21 -0
  80. package/esm/model/uri_scheme_map.d.ts.map +1 -0
  81. package/esm/model/uri_scheme_map.js +66 -0
  82. package/esm/parser/attributes.d.ts.map +1 -1
  83. package/esm/parser/attributes.js +9 -6
  84. package/esm/parser/entity_refs.d.ts +53 -0
  85. package/esm/parser/entity_refs.d.ts.map +1 -0
  86. package/esm/parser/entity_refs.js +151 -0
  87. package/esm/parser/glossary.d.ts +43 -0
  88. package/esm/parser/glossary.d.ts.map +1 -0
  89. package/esm/parser/glossary.js +217 -0
  90. package/esm/parser/markdown.d.ts +10 -3
  91. package/esm/parser/markdown.d.ts.map +1 -1
  92. package/esm/parser/markdown.js +241 -11
  93. package/esm/parser/mod.d.ts +1 -0
  94. package/esm/parser/mod.d.ts.map +1 -1
  95. package/esm/parser/mod.js +4 -3
  96. package/esm/parser/source.d.ts +20 -0
  97. package/esm/parser/source.d.ts.map +1 -1
  98. package/esm/parser/source.js +4 -4
  99. package/esm/profile/chain.js +3 -13
  100. package/esm/profile/colors.d.ts +26 -0
  101. package/esm/profile/colors.d.ts.map +1 -0
  102. package/esm/profile/colors.js +46 -0
  103. package/esm/profile/introspect.d.ts +135 -0
  104. package/esm/profile/introspect.d.ts.map +1 -0
  105. package/esm/profile/introspect.js +378 -0
  106. package/esm/profile/load.d.ts.map +1 -1
  107. package/esm/profile/load.js +67 -0
  108. package/esm/profile/manifest.d.ts.map +1 -1
  109. package/esm/profile/manifest.js +278 -104
  110. package/esm/profile/merge.js +139 -39
  111. package/esm/profile/mod.d.ts +3 -4
  112. package/esm/profile/mod.d.ts.map +1 -1
  113. package/esm/profile/mod.js +6 -2
  114. package/esm/reporter/mod.js +4 -4
  115. package/esm/util/fence.d.ts +30 -0
  116. package/esm/util/fence.d.ts.map +1 -0
  117. package/esm/util/fence.js +40 -0
  118. package/esm/validator/attributes.d.ts +3 -3
  119. package/esm/validator/attributes.d.ts.map +1 -1
  120. package/esm/validator/attributes.js +1 -18
  121. package/esm/validator/body_blocks.d.ts +38 -0
  122. package/esm/validator/body_blocks.d.ts.map +1 -0
  123. package/esm/validator/body_blocks.js +218 -0
  124. package/esm/validator/caption_convention.d.ts +29 -0
  125. package/esm/validator/caption_convention.d.ts.map +1 -0
  126. package/esm/validator/caption_convention.js +58 -0
  127. package/esm/validator/captions.d.ts +22 -0
  128. package/esm/validator/captions.d.ts.map +1 -0
  129. package/esm/validator/captions.js +137 -0
  130. package/esm/validator/component_schemes.d.ts +73 -0
  131. package/esm/validator/component_schemes.d.ts.map +1 -0
  132. package/esm/validator/component_schemes.js +375 -0
  133. package/esm/validator/feature_ac.d.ts +28 -0
  134. package/esm/validator/feature_ac.d.ts.map +1 -0
  135. package/esm/validator/feature_ac.js +102 -0
  136. package/esm/validator/listing.d.ts +42 -0
  137. package/esm/validator/listing.d.ts.map +1 -0
  138. package/esm/validator/listing.js +295 -0
  139. package/esm/validator/mod.d.ts +2 -0
  140. package/esm/validator/mod.d.ts.map +1 -1
  141. package/esm/validator/mod.js +253 -12
  142. package/esm/validator/modal_keywords.d.ts +23 -0
  143. package/esm/validator/modal_keywords.d.ts.map +1 -0
  144. package/esm/validator/modal_keywords.js +137 -0
  145. package/esm/validator/per_type_attrs.d.ts +29 -0
  146. package/esm/validator/per_type_attrs.d.ts.map +1 -0
  147. package/esm/validator/per_type_attrs.js +75 -0
  148. package/esm/validator/pipeline.d.ts +7 -2
  149. package/esm/validator/pipeline.d.ts.map +1 -1
  150. package/esm/validator/pipeline.js +40 -7
  151. package/esm/validator/trace_types.d.ts +26 -0
  152. package/esm/validator/trace_types.d.ts.map +1 -0
  153. package/esm/validator/trace_types.js +232 -0
  154. package/esm/validator/traceability.d.ts +3 -4
  155. package/esm/validator/traceability.d.ts.map +1 -1
  156. package/esm/validator/traceability.js +5 -10
  157. package/esm/validator/type_resolution.d.ts +67 -0
  158. package/esm/validator/type_resolution.d.ts.map +1 -0
  159. package/esm/validator/type_resolution.js +140 -0
  160. package/esm/validator/types.d.ts +45 -0
  161. package/esm/validator/types.d.ts.map +1 -1
  162. package/esm/validator/types.js +128 -16
  163. package/esm/validator/value_types.d.ts +8 -0
  164. package/esm/validator/value_types.d.ts.map +1 -1
  165. package/esm/validator/value_types.js +8 -1
  166. package/package.json +1 -1
  167. package/script/ast/build.d.ts +70 -0
  168. package/script/ast/build.d.ts.map +1 -0
  169. package/script/ast/build.js +610 -0
  170. package/script/ast/equivalence.d.ts +18 -0
  171. package/script/ast/equivalence.d.ts.map +1 -0
  172. package/script/ast/equivalence.js +59 -0
  173. package/script/ast/nodes.d.ts +221 -0
  174. package/script/ast/nodes.d.ts.map +1 -0
  175. package/script/ast/nodes.js +13 -0
  176. package/script/ast/normalize.d.ts +67 -0
  177. package/script/ast/normalize.d.ts.map +1 -0
  178. package/script/ast/normalize.js +258 -0
  179. package/script/ast/render.d.ts +34 -0
  180. package/script/ast/render.d.ts.map +1 -0
  181. package/script/ast/render.js +218 -0
  182. package/script/compiler/inverses.d.ts +2 -8
  183. package/script/compiler/inverses.d.ts.map +1 -1
  184. package/script/compiler/inverses.js +50 -14
  185. package/script/compiler/manifest.d.ts +59 -0
  186. package/script/compiler/manifest.d.ts.map +1 -0
  187. package/script/compiler/manifest.js +51 -0
  188. package/script/compiler/mod.d.ts +9 -1
  189. package/script/compiler/mod.d.ts.map +1 -1
  190. package/script/compiler/mod.js +21 -2
  191. package/script/compiler/ndjson_writer.d.ts +50 -0
  192. package/script/compiler/ndjson_writer.d.ts.map +1 -0
  193. package/script/compiler/ndjson_writer.js +78 -0
  194. package/script/compiler/schema.d.ts +18 -1
  195. package/script/compiler/schema.d.ts.map +1 -1
  196. package/script/compiler/schema.js +18 -8
  197. package/script/config/mod.d.ts.map +1 -1
  198. package/script/config/mod.js +54 -0
  199. package/script/formatter/mod.d.ts +56 -6
  200. package/script/formatter/mod.d.ts.map +1 -1
  201. package/script/formatter/mod.js +375 -41
  202. package/script/formatter/synth_ulid.d.ts +21 -0
  203. package/script/formatter/synth_ulid.d.ts.map +1 -0
  204. package/script/formatter/synth_ulid.js +67 -0
  205. package/script/lint/mod.d.ts +10 -0
  206. package/script/lint/mod.d.ts.map +1 -0
  207. package/script/lint/mod.js +12 -0
  208. package/script/lint/rules/lexicon.d.ts +24 -0
  209. package/script/lint/rules/lexicon.d.ts.map +1 -0
  210. package/script/lint/rules/lexicon.js +240 -0
  211. package/script/lint/rules/struct.d.ts +17 -0
  212. package/script/lint/rules/struct.d.ts.map +1 -0
  213. package/script/lint/rules/struct.js +59 -0
  214. package/script/lint/rules/suppression.d.ts +19 -0
  215. package/script/lint/rules/suppression.d.ts.map +1 -0
  216. package/script/lint/rules/suppression.js +80 -0
  217. package/script/lint/runner.d.ts +39 -0
  218. package/script/lint/runner.d.ts.map +1 -0
  219. package/script/lint/runner.js +116 -0
  220. package/script/lint/types.d.ts +19 -0
  221. package/script/lint/types.d.ts.map +1 -0
  222. package/script/lint/types.js +10 -0
  223. package/script/mod.d.ts +21 -8
  224. package/script/mod.d.ts.map +1 -1
  225. package/script/mod.js +58 -32
  226. package/script/model/attributes.d.ts.map +1 -1
  227. package/script/model/attributes.js +163 -2
  228. package/script/model/discriminating_attr.d.ts +33 -0
  229. package/script/model/discriminating_attr.d.ts.map +1 -0
  230. package/script/model/discriminating_attr.js +77 -0
  231. package/script/model/mod.d.ts +100 -3
  232. package/script/model/mod.d.ts.map +1 -1
  233. package/script/model/mod.js +67 -3
  234. package/script/model/palette.d.ts +18 -0
  235. package/script/model/palette.d.ts.map +1 -0
  236. package/script/model/palette.js +26 -0
  237. package/script/model/profile.d.ts +33 -27
  238. package/script/model/profile.d.ts.map +1 -1
  239. package/script/model/source_introspection.d.ts +26 -0
  240. package/script/model/source_introspection.d.ts.map +1 -0
  241. package/script/model/source_introspection.js +80 -0
  242. package/script/model/type_hierarchy.d.ts +51 -0
  243. package/script/model/type_hierarchy.d.ts.map +1 -0
  244. package/script/model/type_hierarchy.js +130 -0
  245. package/script/model/uri_scheme_map.d.ts +21 -0
  246. package/script/model/uri_scheme_map.d.ts.map +1 -0
  247. package/script/model/uri_scheme_map.js +69 -0
  248. package/script/parser/attributes.d.ts.map +1 -1
  249. package/script/parser/attributes.js +9 -6
  250. package/script/parser/entity_refs.d.ts +53 -0
  251. package/script/parser/entity_refs.d.ts.map +1 -0
  252. package/script/parser/entity_refs.js +155 -0
  253. package/script/parser/glossary.d.ts +43 -0
  254. package/script/parser/glossary.d.ts.map +1 -0
  255. package/script/parser/glossary.js +221 -0
  256. package/script/parser/markdown.d.ts +10 -3
  257. package/script/parser/markdown.d.ts.map +1 -1
  258. package/script/parser/markdown.js +240 -10
  259. package/script/parser/mod.d.ts +1 -0
  260. package/script/parser/mod.d.ts.map +1 -1
  261. package/script/parser/mod.js +8 -4
  262. package/script/parser/source.d.ts +20 -0
  263. package/script/parser/source.d.ts.map +1 -1
  264. package/script/parser/source.js +4 -1
  265. package/script/profile/chain.js +3 -13
  266. package/script/profile/colors.d.ts +26 -0
  267. package/script/profile/colors.d.ts.map +1 -0
  268. package/script/profile/colors.js +49 -0
  269. package/script/profile/introspect.d.ts +135 -0
  270. package/script/profile/introspect.d.ts.map +1 -0
  271. package/script/profile/introspect.js +381 -0
  272. package/script/profile/load.d.ts.map +1 -1
  273. package/script/profile/load.js +67 -0
  274. package/script/profile/manifest.d.ts.map +1 -1
  275. package/script/profile/manifest.js +280 -106
  276. package/script/profile/merge.js +139 -39
  277. package/script/profile/mod.d.ts +3 -4
  278. package/script/profile/mod.d.ts.map +1 -1
  279. package/script/profile/mod.js +9 -6
  280. package/script/reporter/mod.js +4 -4
  281. package/script/util/fence.d.ts +30 -0
  282. package/script/util/fence.d.ts.map +1 -0
  283. package/script/util/fence.js +44 -0
  284. package/script/validator/attributes.d.ts +3 -3
  285. package/script/validator/attributes.d.ts.map +1 -1
  286. package/script/validator/attributes.js +1 -18
  287. package/script/validator/body_blocks.d.ts +38 -0
  288. package/script/validator/body_blocks.d.ts.map +1 -0
  289. package/script/validator/body_blocks.js +221 -0
  290. package/script/validator/caption_convention.d.ts +29 -0
  291. package/script/validator/caption_convention.d.ts.map +1 -0
  292. package/script/validator/caption_convention.js +61 -0
  293. package/script/validator/captions.d.ts +22 -0
  294. package/script/validator/captions.d.ts.map +1 -0
  295. package/script/validator/captions.js +140 -0
  296. package/script/validator/component_schemes.d.ts +73 -0
  297. package/script/validator/component_schemes.d.ts.map +1 -0
  298. package/script/validator/component_schemes.js +384 -0
  299. package/script/validator/feature_ac.d.ts +28 -0
  300. package/script/validator/feature_ac.d.ts.map +1 -0
  301. package/script/validator/feature_ac.js +105 -0
  302. package/script/validator/listing.d.ts +42 -0
  303. package/script/validator/listing.d.ts.map +1 -0
  304. package/script/validator/listing.js +298 -0
  305. package/script/validator/mod.d.ts +2 -0
  306. package/script/validator/mod.d.ts.map +1 -1
  307. package/script/validator/mod.js +256 -14
  308. package/script/validator/modal_keywords.d.ts +23 -0
  309. package/script/validator/modal_keywords.d.ts.map +1 -0
  310. package/script/validator/modal_keywords.js +140 -0
  311. package/script/validator/per_type_attrs.d.ts +29 -0
  312. package/script/validator/per_type_attrs.d.ts.map +1 -0
  313. package/script/validator/per_type_attrs.js +78 -0
  314. package/script/validator/pipeline.d.ts +7 -2
  315. package/script/validator/pipeline.d.ts.map +1 -1
  316. package/script/validator/pipeline.js +39 -6
  317. package/script/validator/trace_types.d.ts +26 -0
  318. package/script/validator/trace_types.d.ts.map +1 -0
  319. package/script/validator/trace_types.js +235 -0
  320. package/script/validator/traceability.d.ts +3 -4
  321. package/script/validator/traceability.d.ts.map +1 -1
  322. package/script/validator/traceability.js +5 -10
  323. package/script/validator/type_resolution.d.ts +67 -0
  324. package/script/validator/type_resolution.d.ts.map +1 -0
  325. package/script/validator/type_resolution.js +146 -0
  326. package/script/validator/types.d.ts +45 -0
  327. package/script/validator/types.d.ts.map +1 -1
  328. package/script/validator/types.js +131 -16
  329. package/script/validator/value_types.d.ts +8 -0
  330. package/script/validator/value_types.d.ts.map +1 -1
  331. package/script/validator/value_types.js +10 -2
@@ -15,13 +15,33 @@
15
15
  * a profile-aware validator layer (not in the core).
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.validateTraceabilityForEntry = exports.matchesAnyTarget = exports.effectiveTraceRules = exports.normalizeListValues = exports.validateValue = exports.validateAttributesForEntry = exports.effectiveScope = exports.compileDisplayIdPattern = exports.classifyEntry = exports.classifyEntriesStage = exports.runPipeline = void 0;
18
+ exports.validateTraceabilityForEntry = exports.matchesAnyTarget = exports.effectiveTraceRules = exports.normalizeListValues = exports.validateValue = exports.validateAttributesForEntry = exports.effectiveScope = exports.compileDisplayIdPattern = exports.classifyEntry = exports.classifyEntriesStage = exports.validateListingDocuments = exports.runPipeline = void 0;
19
19
  exports.validate = validate;
20
20
  exports.indexByDisplayId = indexByDisplayId;
21
21
  exports.findAttr = findAttr;
22
22
  const mod_js_1 = require("../model/mod.js");
23
+ const value_types_js_1 = require("./value_types.js");
23
24
  /** Universal attribute keys the core recognizes. */
24
25
  const UNIVERSAL_KEYS = new Set(mod_js_1.UNIVERSAL_ATTRIBUTE_KEYS);
26
+ /**
27
+ * Value-type set that's repeatable per spec §1.8 — these attributes
28
+ * accept multiple lines for distinct values, so multiple trailers with
29
+ * the same key are legal. Single-cardinality attributes are anything
30
+ * not in this set.
31
+ */
32
+ const REPEATABLE_VALUE_TYPES = new Set([
33
+ "id-list",
34
+ "tag-list",
35
+ "citation",
36
+ "external-id",
37
+ ]);
38
+ /**
39
+ * Slug pattern for Reference-shape display IDs (spec §1.7, ADR-002 §Part 3).
40
+ * Pandoc/BibTeX cite-key convention, restricted to a portable character
41
+ * set: starts with a letter, body alphanumeric + `.` / `/` / `-` / `_`,
42
+ * ends with an alphanumeric.
43
+ */
44
+ const REFERENCE_SLUG_RE = /^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$/;
25
45
  /**
26
46
  * Validate a set of parsed entries for structural correctness and
27
47
  * cross-reference integrity.
@@ -41,6 +61,8 @@ function checkStructural(entries, diagnostics) {
41
61
  const ids = new Map();
42
62
  for (const entry of entries) {
43
63
  // MSL-R003: exactly one `Id:` attribute per entry.
64
+ // Dual-emit: MSL-I002 (Reference missing Id), MSL-I003 (Authored missing
65
+ // Id), MSL-I004 (multiple Id) — nextgen §4.2 codes alongside legacy.
44
66
  const idAttrs = entry.rawAttributes.filter((a) => a.key === mod_js_1.IDENTITY_KEY);
45
67
  if (idAttrs.length === 0) {
46
68
  diagnostics.push({
@@ -49,6 +71,25 @@ function checkStructural(entries, diagnostics) {
49
71
  message: `${entry.displayId}: missing Id: attribute`,
50
72
  location: entry.location,
51
73
  });
74
+ // Dual-emit: shape-specific nextgen code
75
+ if (entry.shape === "Reference") {
76
+ diagnostics.push({
77
+ code: "MSL-I002",
78
+ severity: "error",
79
+ message: `${entry.displayId}: Reference-shape entry without Id: ` +
80
+ `fmt cannot mint URIs (spec section 4.2)`,
81
+ location: entry.location,
82
+ });
83
+ }
84
+ else {
85
+ diagnostics.push({
86
+ code: "MSL-I003",
87
+ severity: "error",
88
+ message: `${entry.displayId}: Authored-shape entry without Id: ` +
89
+ `run fmt to mint a ULID (spec section 4.2)`,
90
+ location: entry.location,
91
+ });
92
+ }
52
93
  }
53
94
  else if (idAttrs.length > 1) {
54
95
  diagnostics.push({
@@ -57,8 +98,17 @@ function checkStructural(entries, diagnostics) {
57
98
  message: `${entry.displayId}: multiple Id: attributes (${idAttrs.length}) — exactly one is required`,
58
99
  location: entry.location,
59
100
  });
101
+ // Dual-emit: MSL-I004
102
+ diagnostics.push({
103
+ code: "MSL-I004",
104
+ severity: "error",
105
+ message: `${entry.displayId}: multiple Id: trailers ` +
106
+ `(${idAttrs.length}) on the same entry (spec section 4.2)`,
107
+ location: entry.location,
108
+ });
60
109
  }
61
110
  // MSL-R004: `Id:` value must be a ULID or a scheme-qualified URI.
111
+ // Dual-emit: MSL-I001 — nextgen §4.2 code alongside legacy.
62
112
  if (idAttrs.length > 0) {
63
113
  const value = idAttrs[0].value;
64
114
  const isUlid = mod_js_1.ULID_RE.test(value);
@@ -70,9 +120,16 @@ function checkStructural(entries, diagnostics) {
70
120
  message: `${entry.displayId}: Id: value '${value}' is neither a bare ULID nor a scheme-qualified URI`,
71
121
  location: entry.location,
72
122
  });
123
+ diagnostics.push({
124
+ code: "MSL-I001",
125
+ severity: "error",
126
+ message: `${entry.displayId}: Id: value '${value}' is neither a ULID ` +
127
+ `(^[0-9A-HJKMNP-TV-Z]{26}$) nor an RFC 3986 URI (spec section 4.2)`,
128
+ location: entry.location,
129
+ });
73
130
  }
74
131
  // Shape consistency: ULID ↔ identified, URI ↔ referenced.
75
- if (isUlid && entry.shape !== "identified") {
132
+ if (isUlid && entry.shape !== "Authored") {
76
133
  diagnostics.push({
77
134
  code: "MSL-R004",
78
135
  severity: "error",
@@ -80,7 +137,7 @@ function checkStructural(entries, diagnostics) {
80
137
  location: entry.location,
81
138
  });
82
139
  }
83
- else if (isUri && entry.shape !== "referenced") {
140
+ else if (isUri && entry.shape !== "Reference") {
84
141
  diagnostics.push({
85
142
  code: "MSL-R004",
86
143
  severity: "error",
@@ -89,7 +146,21 @@ function checkStructural(entries, diagnostics) {
89
146
  });
90
147
  }
91
148
  }
149
+ // MSL-I006: Reference-shape display ID must match the slug pattern
150
+ // (spec §1.7, ADR-002 §Part 3). Authored entries have a free-form
151
+ // display ID at core level (tightened by profile patterns).
152
+ if (entry.shape === "Reference" && !REFERENCE_SLUG_RE.test(entry.displayId)) {
153
+ diagnostics.push({
154
+ code: "MSL-I006",
155
+ severity: "error",
156
+ message: `${entry.displayId}: Reference-shape display ID does not ` +
157
+ `match the slug pattern (spec §1.7); expected ` +
158
+ `^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$`,
159
+ location: entry.location,
160
+ });
161
+ }
92
162
  // MSL-R006: Display ID unique across all entries.
163
+ // Dual-emit: MSL-I008 (warning) — nextgen §4.2.
93
164
  const existingDisplay = displayIds.get(entry.displayId);
94
165
  if (existingDisplay) {
95
166
  diagnostics.push({
@@ -98,11 +169,21 @@ function checkStructural(entries, diagnostics) {
98
169
  message: `duplicate display ID '${entry.displayId}' (also at ${existingDisplay.location.file}:${existingDisplay.location.line})`,
99
170
  location: entry.location,
100
171
  });
172
+ diagnostics.push({
173
+ code: "MSL-I008",
174
+ severity: "warning",
175
+ message: `duplicate display ID '${entry.displayId}' within the same ` +
176
+ `shape (also at ${existingDisplay.location.file}:` +
177
+ `${existingDisplay.location.line}) -- cross-references resolve ` +
178
+ `by Id:, so this is style-only (spec section 4.2)`,
179
+ location: entry.location,
180
+ });
101
181
  }
102
182
  else {
103
183
  displayIds.set(entry.displayId, entry);
104
184
  }
105
185
  // MSL-R005: identity value unique across all entries.
186
+ // Dual-emit: MSL-I007 — nextgen §4.2.
106
187
  if (entry.id) {
107
188
  const existingId = ids.get(entry.id);
108
189
  if (existingId) {
@@ -112,17 +193,174 @@ function checkStructural(entries, diagnostics) {
112
193
  message: `duplicate Id '${entry.id}' (also at ${existingId.location.file}:${existingId.location.line})`,
113
194
  location: entry.location,
114
195
  });
196
+ diagnostics.push({
197
+ code: "MSL-I007",
198
+ severity: "error",
199
+ message: `duplicate Id: value '${entry.id}' across the project (also ` +
200
+ `at ${existingId.location.file}:${existingId.location.line}) ` +
201
+ `(spec section 4.2)`,
202
+ location: entry.location,
203
+ });
115
204
  }
116
205
  else {
117
206
  ids.set(entry.id, entry);
118
207
  }
119
208
  }
120
- // MSL-R010: Unknown attributes are warnings in the core. A
121
- // profile-aware validator widens this check to include profile-declared
122
- // attributes; until then, anything outside the universal set is
123
- // unrecognized.
209
+ // MSL-P010 — entry title is empty after trimming. The parser
210
+ // accepts an empty title for shape stability (`[REQ-001]` with
211
+ // nothing after) but the canonical form per spec §4.2 requires a
212
+ // non-empty human-readable title. Fires regardless of shape.
213
+ if (entry.title.trim().length === 0) {
214
+ diagnostics.push({
215
+ code: "MSL-P010",
216
+ severity: "error",
217
+ message: `${entry.displayId}: title is empty after trimming ` +
218
+ `(spec §4.2); add a non-empty human-readable title after ']'`,
219
+ location: entry.location,
220
+ });
221
+ }
222
+ // MSL-A011 — `citation`-typed attribute (References:) used CSV
223
+ // form. The canonical form is multi-line per spec §2.3.2: locators
224
+ // may contain commas (e.g. `[@iso26262, p. 42]`), so the parser
225
+ // never CSV-splits citation values. Detection scans for a `,` at
226
+ // bracket-depth zero — commas inside `[…]` are locators and OK.
227
+ for (const attr of entry.rawAttributes) {
228
+ const spec = (0, mod_js_1.attributeSpec)(attr.key);
229
+ if (spec?.type !== "citation")
230
+ continue;
231
+ let depth = 0;
232
+ let sawTopLevelComma = false;
233
+ for (const ch of attr.value) {
234
+ if (ch === "[")
235
+ depth++;
236
+ else if (ch === "]" && depth > 0)
237
+ depth--;
238
+ else if (ch === "," && depth === 0) {
239
+ sawTopLevelComma = true;
240
+ break;
241
+ }
242
+ }
243
+ if (sawTopLevelComma) {
244
+ diagnostics.push({
245
+ code: "MSL-A011",
246
+ severity: "error",
247
+ message: `${entry.displayId}: '${attr.key}' is citation-typed and ` +
248
+ `must use multi-line form (spec §2.3.2); CSV is rejected because ` +
249
+ `Pandoc locators may contain commas`,
250
+ location: entry.location,
251
+ });
252
+ }
253
+ }
254
+ // MSL-A012 — repeatable attribute value list is empty (spec §1.8).
255
+ // Fires when an authored repeatable attribute (id-list, tag-list,
256
+ // citation, external-id) carries no non-empty values after trimming
257
+ // and CSV splitting. `citation` is not CSV-splittable, so its check
258
+ // is a plain trim-and-empty test.
259
+ for (const attr of entry.rawAttributes) {
260
+ const spec = (0, mod_js_1.attributeSpec)(attr.key);
261
+ if (!spec)
262
+ continue;
263
+ if (!REPEATABLE_VALUE_TYPES.has(spec.type))
264
+ continue;
265
+ const raw = attr.value;
266
+ const isCitation = spec.type === "citation";
267
+ const values = isCitation
268
+ ? [raw.trim()].filter((s) => s.length > 0)
269
+ : raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
270
+ if (values.length === 0) {
271
+ diagnostics.push({
272
+ code: "MSL-A012",
273
+ severity: "error",
274
+ message: `${entry.displayId}: '${attr.key}' is a repeatable ` +
275
+ `attribute but the value list is empty (spec §1.8)`,
276
+ location: entry.location,
277
+ });
278
+ }
279
+ }
280
+ // MSL-A013 — single-cardinality core attribute used more than once.
281
+ // `Id:` is excluded because MSL-R003 (above) reports its duplicates
282
+ // with a more specific message. Profile-declared attribute
283
+ // cardinality is enforced by the profile-aware Stage 3 (MSL-A002).
284
+ const seenSingleKeys = new Set();
285
+ const reportedA013 = new Set();
124
286
  for (const attr of entry.rawAttributes) {
125
- if (!UNIVERSAL_KEYS.has(attr.key) && attr.key !== "Type") {
287
+ if (attr.key === mod_js_1.IDENTITY_KEY)
288
+ continue;
289
+ const spec = (0, mod_js_1.attributeSpec)(attr.key);
290
+ if (!spec)
291
+ continue;
292
+ if (REPEATABLE_VALUE_TYPES.has(spec.type))
293
+ continue;
294
+ if (seenSingleKeys.has(attr.key)) {
295
+ if (!reportedA013.has(attr.key)) {
296
+ diagnostics.push({
297
+ code: "MSL-A013",
298
+ severity: "error",
299
+ message: `${entry.displayId}: '${attr.key}' is single-cardinality ` +
300
+ `but appears more than once (spec §1.8)`,
301
+ location: entry.location,
302
+ });
303
+ reportedA013.add(attr.key);
304
+ }
305
+ }
306
+ else {
307
+ seenSingleKeys.add(attr.key);
308
+ }
309
+ }
310
+ // MSL-A030 / MSL-A050 / MSL-R010 checks per attribute
311
+ // (§4.4 / §4.8 / spec §1.5).
312
+ for (const attr of entry.rawAttributes) {
313
+ // MSL-A030: generated-origin attributes must not appear in source.
314
+ const spec = (0, mod_js_1.attributeSpec)(attr.key);
315
+ if (spec?.origin === "generated") {
316
+ diagnostics.push({
317
+ code: "MSL-A030",
318
+ severity: "error",
319
+ message: `${entry.displayId}: '${attr.key}' has generated origin and must not appear in source (computed at build time per ADR-003 §Part 3)`,
320
+ location: entry.location,
321
+ });
322
+ continue;
323
+ }
324
+ // MSL-A050: value does not parse against the declared value type
325
+ // (§4.4). The core knows the value type for the promoted Reference
326
+ // attributes (spec §1.5) and the universal enum attributes;
327
+ // profile-declared attribute types are validated by the
328
+ // profile-aware Stage 3 instead.
329
+ if (attr.key === "Reference-url") {
330
+ if (!value_types_js_1.HTTP_URL_RE.test(attr.value.trim())) {
331
+ diagnostics.push({
332
+ code: "MSL-A050",
333
+ severity: "error",
334
+ message: `${entry.displayId}: Reference-url value ` +
335
+ `'${attr.value.trim()}' is not an http(s) URL (spec §1.5)`,
336
+ location: entry.location,
337
+ });
338
+ continue;
339
+ }
340
+ }
341
+ if (spec?.type === "enum" && spec.enumValues) {
342
+ const trimmed = attr.value.trim();
343
+ if (trimmed.length > 0 && !spec.enumValues.includes(trimmed)) {
344
+ diagnostics.push({
345
+ code: "MSL-A050",
346
+ severity: "error",
347
+ message: `${entry.displayId}: ${attr.key} value '${trimmed}' ` +
348
+ `is not in the allowed set ` +
349
+ `{${spec.enumValues.join(", ")}} (spec §1.8 enum)`,
350
+ location: entry.location,
351
+ });
352
+ continue;
353
+ }
354
+ }
355
+ // MSL-R010: Unknown attributes are warnings in the core. A
356
+ // profile-aware validator widens this check to include profile-declared
357
+ // attributes; until then, anything outside the universal set is
358
+ // unrecognized. Core-typed attributes (per ADR-003 §Part 2) are
359
+ // suppressed here — the per-type validator emits a more specific
360
+ // MSL-T022 when they appear on the "wrong" type.
361
+ if (!UNIVERSAL_KEYS.has(attr.key) &&
362
+ attr.key !== "Type" &&
363
+ !mod_js_1.CORE_TYPE_SCOPED_ATTRS.has(attr.key)) {
126
364
  diagnostics.push({
127
365
  code: "MSL-R010",
128
366
  severity: "warning",
@@ -186,11 +424,13 @@ function checkReferences(entries, diagnostics) {
186
424
  });
187
425
  continue;
188
426
  }
189
- if (resolved.shape !== "referenced") {
427
+ if (resolved.shape !== "Reference") {
190
428
  diagnostics.push({
191
- code: "MSL-T005",
192
- severity: "error",
193
- message: `${entry.displayId}: References: target '${slug}' is shape '${resolved.shape}', expected 'referenced'`,
429
+ code: "MSL-R085",
430
+ severity: "warning",
431
+ message: `${entry.displayId}: References: target '${slug}' resolves to a ` +
432
+ `'${resolved.shape}' entry but References must cite a ` +
433
+ `Reference-shape entry (spec §4.8)`,
194
434
  location: entry.location,
195
435
  });
196
436
  }
@@ -213,6 +453,8 @@ function findAttr(attrs, key) {
213
453
  }
214
454
  var pipeline_js_1 = require("./pipeline.js");
215
455
  Object.defineProperty(exports, "runPipeline", { enumerable: true, get: function () { return pipeline_js_1.runPipeline; } });
456
+ var listing_js_1 = require("./listing.js");
457
+ Object.defineProperty(exports, "validateListingDocuments", { enumerable: true, get: function () { return listing_js_1.validateListingDocuments; } });
216
458
  var types_js_1 = require("./types.js");
217
459
  Object.defineProperty(exports, "classifyEntriesStage", { enumerable: true, get: function () { return types_js_1.classifyEntriesStage; } });
218
460
  Object.defineProperty(exports, "classifyEntry", { enumerable: true, get: function () { return types_js_1.classifyEntry; } });
@@ -221,8 +463,8 @@ Object.defineProperty(exports, "compileDisplayIdPattern", { enumerable: true, ge
221
463
  var attributes_js_1 = require("./attributes.js");
222
464
  Object.defineProperty(exports, "effectiveScope", { enumerable: true, get: function () { return attributes_js_1.effectiveScope; } });
223
465
  Object.defineProperty(exports, "validateAttributesForEntry", { enumerable: true, get: function () { return attributes_js_1.validateAttributesForEntry; } });
224
- var value_types_js_1 = require("./value_types.js");
225
- Object.defineProperty(exports, "validateValue", { enumerable: true, get: function () { return value_types_js_1.validateValue; } });
466
+ var value_types_js_2 = require("./value_types.js");
467
+ Object.defineProperty(exports, "validateValue", { enumerable: true, get: function () { return value_types_js_2.validateValue; } });
226
468
  var normalize_js_1 = require("./normalize.js");
227
469
  Object.defineProperty(exports, "normalizeListValues", { enumerable: true, get: function () { return normalize_js_1.normalizeListValues; } });
228
470
  var traceability_js_1 = require("./traceability.js");
@@ -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,140 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/validator/modal_keywords
4
+ *
5
+ * MSL-M060 validator — uppercase RFC 2119 modal keyword (`SHALL`,
6
+ * `SHOULD`, `MAY`, `MUST`, optionally `… NOT`) in entry-body prose.
7
+ * The formatter normalises these to lowercase per spec §3.4.1; this
8
+ * validator surfaces the deviation in a lint-only flow. Profiles may
9
+ * promote the severity. Each prose-bearing node's `InlineContent.markers`
10
+ * carries pre-extracted `ModalMarker` objects from the builder; an
11
+ * uppercase match is detected where `marker.raw` differs from
12
+ * `marker.canonical`. EARS markers are not flagged — MSL-M060 targets
13
+ * RFC 2119 only. Code, Feature, and Math blocks are automatically
14
+ * excluded because the builder does not extract markers from verbatim
15
+ * content.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.validateModalKeywords = validateModalKeywords;
19
+ const type_resolution_js_1 = require("./type_resolution.js");
20
+ // ---------------------------------------------------------------------------
21
+ // Marker collection from bodyAst
22
+ // ---------------------------------------------------------------------------
23
+ /** Collect all modal markers from an InlineContent object. */
24
+ function modalsFromInline(content) {
25
+ return content.markers.filter((m) => m.kind === "modal");
26
+ }
27
+ /** Recursively collect modal markers from a list item's blocks. */
28
+ function modalsFromListItem(item) {
29
+ const out = [];
30
+ for (const block of item.blocks) {
31
+ out.push(...modalsFromBlock(block));
32
+ }
33
+ return out;
34
+ }
35
+ /** Collect all modal markers from a single BodyBlock (recursively). */
36
+ function modalsFromBlock(block) {
37
+ const out = [];
38
+ switch (block.kind) {
39
+ case "paragraph":
40
+ out.push(...modalsFromInline(block.content));
41
+ break;
42
+ case "list":
43
+ for (const item of block.items) {
44
+ out.push(...modalsFromListItem(item));
45
+ }
46
+ break;
47
+ case "table":
48
+ for (const cell of block.header) {
49
+ out.push(...modalsFromInline(cell));
50
+ }
51
+ for (const row of block.rows) {
52
+ for (const cell of row) {
53
+ out.push(...modalsFromInline(cell));
54
+ }
55
+ }
56
+ break;
57
+ case "note":
58
+ out.push(...modalsFromInline(block.content));
59
+ break;
60
+ case "blockquote":
61
+ out.push(...modalsFromInline(block.content));
62
+ break;
63
+ case "definition-list":
64
+ for (const item of block.items) {
65
+ out.push(...modalsFromInline(item.term));
66
+ out.push(...modalsFromInline(item.definition));
67
+ }
68
+ break;
69
+ case "code":
70
+ case "feature":
71
+ case "math":
72
+ case "figure":
73
+ case "caption":
74
+ case "unknown":
75
+ // Verbatim / structural nodes: no modal markers.
76
+ break;
77
+ default:
78
+ break;
79
+ }
80
+ return out;
81
+ }
82
+ // ---------------------------------------------------------------------------
83
+ // Public API
84
+ // ---------------------------------------------------------------------------
85
+ /**
86
+ * Scan an entry's body for uppercase modal keywords and emit MSL-M060
87
+ * for each occurrence. Severity is `warning`; the formatter rewrites
88
+ * them on the next run.
89
+ */
90
+ function validateModalKeywords(entry) {
91
+ const diagnostics = [];
92
+ let anyModalSeen = false;
93
+ const blocks = entry.bodyAst ?? [];
94
+ for (const block of blocks) {
95
+ for (const marker of modalsFromBlock(block)) {
96
+ anyModalSeen = true;
97
+ // MSL-M060: RFC 2119 keywords in non-canonical (uppercase) form.
98
+ // `marker.raw` is the original source text; `marker.canonical` is
99
+ // always lowercase. When they differ, the keyword is uppercase.
100
+ // EARS markers (cls = "ears") are always case-preserved and
101
+ // are not subject to MSL-M060.
102
+ if (marker.cls !== "rfc2119")
103
+ continue;
104
+ const raw = marker.raw ?? marker.canonical;
105
+ if (raw === marker.canonical)
106
+ continue; // already lowercase — OK
107
+ diagnostics.push({
108
+ code: "MSL-M060",
109
+ severity: "warning",
110
+ message: `${entry.displayId}: modal keyword '${raw}' in body ` +
111
+ `prose is uppercase (spec §3.4.1 canonical form is lowercase; ` +
112
+ `'markspec format' will rewrite it)`,
113
+ location: {
114
+ file: entry.location.file,
115
+ // marker.range.start.line is body-relative 1-based.
116
+ // entry.location.line is the title line (0-based offset 0).
117
+ // Body line 1 → file line entry.location.line + 0, etc.
118
+ line: entry.location.line + (marker.range.start.line - 1),
119
+ column: marker.range.start.column,
120
+ },
121
+ });
122
+ }
123
+ }
124
+ // MSL-M061 — Requirement-type entry contains no modal keyword
125
+ // (info; style hint). Gated on the resolved core type being
126
+ // `Requirement` so non-requirement entries (Tests, Contracts, etc.)
127
+ // are not flagged. The hint stays at info severity so it doesn't
128
+ // affect exit codes; profiles may promote.
129
+ if (!anyModalSeen && (0, type_resolution_js_1.resolvedCoreType)(entry) === "Requirement") {
130
+ diagnostics.push({
131
+ code: "MSL-M061",
132
+ severity: "info",
133
+ message: `${entry.displayId}: Requirement entry contains no modal ` +
134
+ `keyword (shall / should / may / must) — consider declaring one ` +
135
+ `to make the obligation explicit (spec §3.4.1 "Modal keywords")`,
136
+ location: entry.location,
137
+ });
138
+ }
139
+ return diagnostics;
140
+ }
@@ -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,78 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/validator/per_type_attrs
4
+ *
5
+ * Per-type attribute compatibility check (spec §4.3 — MSL-T022). When
6
+ * an entry's effective type resolves to a core type — via explicit
7
+ * `Type:`, profile classification, or URI-scheme inference for
8
+ * Reference-shape entries — any attribute that's known to the core
9
+ * hierarchy but not allowed on that type fires MSL-T022 as a warning.
10
+ * Unknown attributes (neither universal nor core-typed) fall through
11
+ * to the existing MSL-R010 unknown-attribute warning in
12
+ * `validator/mod.ts`.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.validatePerTypeAttributes = validatePerTypeAttributes;
16
+ const mod_js_1 = require("../model/mod.js");
17
+ const type_resolution_js_1 = require("./type_resolution.js");
18
+ /**
19
+ * Attribute keys that are universal to every entry regardless of type
20
+ * (spec §1.4 + §1.5). Sourced entirely from {@linkcode UNIVERSAL_ATTRIBUTE_KEYS}
21
+ * — `Type`, `Source`, `Origin`, `Reference-url`, and `Reference-document`
22
+ * are now first-class catalogue entries, so the previous hand-maintained
23
+ * extension list is no longer needed.
24
+ */
25
+ const UNIVERSAL_KEYS = new Set(mod_js_1.UNIVERSAL_ATTRIBUTE_KEYS);
26
+ /**
27
+ * Emit per-type attribute diagnostics:
28
+ *
29
+ * - **MSL-T022** (warning) — an attribute is core-known but not
30
+ * valid on the entry's *resolved* type.
31
+ * - **MSL-T024** (warning) — the entry's core type could not be
32
+ * resolved (no explicit `Type:`, no profile classification, no
33
+ * inferable signal — display-ID prefix / URI scheme /
34
+ * discriminating attribute) yet it carries a core-type-scoped
35
+ * attribute, so that attribute cannot be validated. Without this,
36
+ * such attributes slipped through silently (e.g. `Manufacturer:`
37
+ * on a `jira:`-scheme reference). Universal and entirely unknown
38
+ * attributes are exempt — those go through MSL-R010.
39
+ */
40
+ function validatePerTypeAttributes(entry) {
41
+ const type = (0, type_resolution_js_1.resolvedCoreType)(entry);
42
+ if (type === undefined) {
43
+ const diagnostics = [];
44
+ for (const attr of entry.rawAttributes) {
45
+ if (UNIVERSAL_KEYS.has(attr.key))
46
+ continue;
47
+ if (!mod_js_1.CORE_TYPE_SCOPED_ATTRS.has(attr.key))
48
+ continue;
49
+ diagnostics.push({
50
+ code: "MSL-T024",
51
+ severity: "warning",
52
+ message: `${entry.displayId}: attribute '${attr.key}' is type-specific but ` +
53
+ `the entry's core type could not be resolved; it cannot be ` +
54
+ `validated (spec §8.3)`,
55
+ location: entry.location,
56
+ });
57
+ }
58
+ return diagnostics;
59
+ }
60
+ const allowed = (0, mod_js_1.attributesForType)(type);
61
+ const diagnostics = [];
62
+ for (const attr of entry.rawAttributes) {
63
+ if (UNIVERSAL_KEYS.has(attr.key))
64
+ continue;
65
+ if (allowed.has(attr.key))
66
+ continue;
67
+ if (!mod_js_1.CORE_TYPE_SCOPED_ATTRS.has(attr.key))
68
+ continue;
69
+ diagnostics.push({
70
+ code: "MSL-T022",
71
+ severity: "warning",
72
+ message: `${entry.displayId}: attribute '${attr.key}' is not valid on Type: ${type} ` +
73
+ `(spec §1.6, ADR-003 §Part 2)`,
74
+ location: entry.location,
75
+ });
76
+ }
77
+ return diagnostics;
78
+ }