@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
@@ -0,0 +1,135 @@
1
+ /**
2
+ * @module core/profile/introspect
3
+ *
4
+ * Unified introspection API for profile chains. All discovery surfaces
5
+ * (CLI, MCP, LSP) consume this module instead of re-walking EffectiveProfile.
6
+ *
7
+ * Node-safe: no Deno.* APIs.
8
+ */
9
+ import type { LabelConcernKind, ProfileChain } from "../model/mod.js";
10
+ /** Discriminant for the five kinds of profile elements. */
11
+ export type ProfileElementKind = "type" | "attribute" | "relation" | "label-concern" | "convention";
12
+ /**
13
+ * A human-readable description with provenance: which profile tier contributed
14
+ * it and which tiers it overrides.
15
+ */
16
+ export interface ProvenancedDescription {
17
+ readonly text?: string;
18
+ readonly origin?: string;
19
+ readonly overrides?: string[];
20
+ }
21
+ /**
22
+ * A lightweight reference to a profile element, used in overview lists and
23
+ * resolve results. `ref` is `"<kind>/<name>"`, e.g. `"type/software-requirement"`.
24
+ */
25
+ export interface ProfileElementRef {
26
+ readonly kind: ProfileElementKind;
27
+ readonly name: string;
28
+ readonly summary: string;
29
+ /** `"<kind>/<name>"`, e.g. `"type/software-requirement"`. */
30
+ readonly ref: string;
31
+ }
32
+ /**
33
+ * High-level snapshot of the active profile chain: chain tiers and all
34
+ * declared elements as lightweight refs.
35
+ */
36
+ export interface ProfileOverview {
37
+ readonly tiers: readonly {
38
+ id: string;
39
+ version: string;
40
+ summary: string;
41
+ }[];
42
+ readonly elements: readonly ProfileElementRef[];
43
+ }
44
+ /** Detailed description of a profile-declared entry type. */
45
+ export interface TypeDetail {
46
+ readonly kind: "type";
47
+ readonly name: string;
48
+ readonly description: ProvenancedDescription;
49
+ readonly extendsTarget: string;
50
+ readonly shape: string;
51
+ readonly displayIdPattern?: string;
52
+ readonly color?: string;
53
+ readonly requiredAttributes: readonly ProfileElementRef[];
54
+ readonly allowedAttributes: readonly ProfileElementRef[];
55
+ readonly outgoingRelations: readonly ProfileElementRef[];
56
+ readonly incomingRelations: readonly ProfileElementRef[];
57
+ }
58
+ /** Detailed description of a universal or type-scoped attribute declaration. */
59
+ export interface AttributeDetail {
60
+ readonly kind: "attribute";
61
+ readonly name: string;
62
+ readonly description: ProvenancedDescription;
63
+ readonly valueType: string;
64
+ readonly cardinality: string;
65
+ readonly required: boolean;
66
+ readonly enumValues?: readonly string[];
67
+ readonly inverse?: {
68
+ name: string;
69
+ category: string;
70
+ };
71
+ readonly declaredBy: readonly string[];
72
+ }
73
+ /**
74
+ * Detailed description of a traceability relation, aggregated across all types
75
+ * that declare it.
76
+ */
77
+ export interface RelationDetail {
78
+ readonly kind: "relation";
79
+ readonly name: string;
80
+ readonly description: ProvenancedDescription;
81
+ readonly targets: readonly string[];
82
+ readonly cardinality?: string;
83
+ readonly required: boolean;
84
+ readonly declaredBy: readonly string[];
85
+ }
86
+ /** Detailed description of a label concern (enum, set, or flag). */
87
+ export interface LabelConcernDetail {
88
+ readonly kind: "label-concern";
89
+ readonly name: string;
90
+ readonly description: ProvenancedDescription;
91
+ readonly concernKind: LabelConcernKind;
92
+ readonly values: readonly {
93
+ name: string;
94
+ description?: string;
95
+ }[];
96
+ }
97
+ /**
98
+ * Detailed description of a named profile convention (e.g. `modal-keywords`).
99
+ */
100
+ export interface ConventionDetail {
101
+ readonly kind: "convention";
102
+ readonly name: string;
103
+ readonly description: ProvenancedDescription;
104
+ readonly settings: Readonly<Record<string, string>>;
105
+ }
106
+ /**
107
+ * Discriminated union of all per-element detail types returned by
108
+ * `ProfileIntrospection.describe`.
109
+ */
110
+ export type ProfileElementDetail = TypeDetail | AttributeDetail | RelationDetail | LabelConcernDetail | ConventionDetail;
111
+ /**
112
+ * Unified read-only view of a profile chain. Consumed by CLI, MCP, and LSP
113
+ * instead of walking `EffectiveProfile` directly.
114
+ */
115
+ export interface ProfileIntrospection {
116
+ /** Return a lazily computed, cached overview of all profile elements. */
117
+ overview(): ProfileOverview;
118
+ /**
119
+ * Return full detail for the named element, or `undefined` if not found.
120
+ */
121
+ describe(kind: ProfileElementKind, name: string): ProfileElementDetail | undefined;
122
+ /**
123
+ * Return elements whose kind/name/summary contain all whitespace-separated
124
+ * query tokens (case-insensitive).
125
+ */
126
+ resolve(query: string): ProfileElementRef[];
127
+ }
128
+ /**
129
+ * Build a `ProfileIntrospection` from a profile chain (or `null` when
130
+ * no profile is configured for the project).
131
+ *
132
+ * The returned object is lazy — `overview()` caches after the first call.
133
+ */
134
+ export declare function buildProfileIntrospection(chain: ProfileChain | null): ProfileIntrospection;
135
+ //# sourceMappingURL=introspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../../src/profile/introspect.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/profile/introspect
4
+ *
5
+ * Unified introspection API for profile chains. All discovery surfaces
6
+ * (CLI, MCP, LSP) consume this module instead of re-walking EffectiveProfile.
7
+ *
8
+ * Node-safe: no Deno.* APIs.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.buildProfileIntrospection = buildProfileIntrospection;
12
+ // ---------------------------------------------------------------------------
13
+ // Factory
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * Build a `ProfileIntrospection` from a profile chain (or `null` when
17
+ * no profile is configured for the project).
18
+ *
19
+ * The returned object is lazy — `overview()` caches after the first call.
20
+ */
21
+ function buildProfileIntrospection(chain) {
22
+ if (!chain) {
23
+ return {
24
+ overview: () => ({
25
+ tiers: [
26
+ { id: "(none)", version: "", summary: "No profile configured" },
27
+ ],
28
+ elements: [],
29
+ }),
30
+ describe: () => undefined,
31
+ resolve: () => [],
32
+ };
33
+ }
34
+ // Capture non-null references so inner closures type-check.
35
+ const nonNullChain = chain;
36
+ const effective = nonNullChain.effective;
37
+ let cachedOverview;
38
+ function getOverview() {
39
+ if (cachedOverview)
40
+ return cachedOverview;
41
+ const tiers = nonNullChain.tiers.map((tier) => ({
42
+ id: tier.id,
43
+ version: tier.version,
44
+ summary: tier.manifest.description ?? tier.id,
45
+ }));
46
+ const elements = [];
47
+ // Types
48
+ for (const [name, entry] of effective.types) {
49
+ const tdef = entry.value;
50
+ const summary = tdef.description.value ?? tdef.extends;
51
+ elements.push({
52
+ kind: "type",
53
+ name,
54
+ summary,
55
+ ref: `type/${name}`,
56
+ });
57
+ }
58
+ // Universal attributes
59
+ for (const [name, entry] of effective.attributes) {
60
+ const decl = entry.value;
61
+ const summary = decl.description ??
62
+ `${decl.type}, ${formatCardinality(decl.cardinality)}`;
63
+ elements.push({
64
+ kind: "attribute",
65
+ name,
66
+ summary,
67
+ ref: `attribute/${name}`,
68
+ });
69
+ }
70
+ // Relations (deduplicated across types)
71
+ const seenRelations = new Map();
72
+ for (const [, typeEntry] of effective.types) {
73
+ const tdef = typeEntry.value;
74
+ for (const [relName, ruleEntry] of tdef.traceability) {
75
+ const existing = seenRelations.get(relName);
76
+ const desc = tdef.relationDescriptions.get(relName);
77
+ if (!existing) {
78
+ seenRelations.set(relName, {
79
+ targets: new Set(ruleEntry.value.target.map(targetToString)),
80
+ description: desc?.value,
81
+ });
82
+ }
83
+ else {
84
+ for (const t of ruleEntry.value.target.map(targetToString)) {
85
+ existing.targets.add(t);
86
+ }
87
+ if (desc?.value !== undefined && existing.description === undefined) {
88
+ existing.description = desc.value;
89
+ }
90
+ }
91
+ }
92
+ }
93
+ for (const [name, info] of seenRelations) {
94
+ const summary = info.description ??
95
+ `targets: ${[...info.targets].join(", ")}`;
96
+ elements.push({
97
+ kind: "relation",
98
+ name,
99
+ summary,
100
+ ref: `relation/${name}`,
101
+ });
102
+ }
103
+ // Label concerns
104
+ for (const [name, entry] of effective.labels) {
105
+ const concern = entry.value;
106
+ const summary = concern.description ??
107
+ `${concern.kind}, ${concern.values.length} values`;
108
+ elements.push({
109
+ kind: "label-concern",
110
+ name,
111
+ summary,
112
+ ref: `label/${name}`,
113
+ });
114
+ }
115
+ // Conventions
116
+ for (const [name, entry] of effective.conventions) {
117
+ const conv = entry.value;
118
+ const summary = conv.description ??
119
+ Object.entries(conv.settings).map(([k, v]) => `${k}=${v}`).join(" ");
120
+ elements.push({
121
+ kind: "convention",
122
+ name,
123
+ summary,
124
+ ref: `convention/${name}`,
125
+ });
126
+ }
127
+ // Sort by kind order, then name within kind.
128
+ const KIND_ORDER = {
129
+ "type": 0,
130
+ "attribute": 1,
131
+ "relation": 2,
132
+ "label-concern": 3,
133
+ "convention": 4,
134
+ };
135
+ elements.sort((a, b) => {
136
+ const kDiff = KIND_ORDER[a.kind] - KIND_ORDER[b.kind];
137
+ return kDiff !== 0 ? kDiff : a.name.localeCompare(b.name);
138
+ });
139
+ cachedOverview = { tiers, elements };
140
+ return cachedOverview;
141
+ }
142
+ function describe(kind, name) {
143
+ switch (kind) {
144
+ case "type":
145
+ return describeType(name, effective);
146
+ case "attribute":
147
+ return describeAttribute(name, effective);
148
+ case "relation":
149
+ return describeRelation(name, effective);
150
+ case "label-concern":
151
+ return describeLabelConcern(name, effective);
152
+ case "convention":
153
+ return describeConvention(name, effective);
154
+ }
155
+ }
156
+ function resolve(query) {
157
+ const tokens = query.toLowerCase().split(/\s+/).filter(Boolean);
158
+ if (tokens.length === 0)
159
+ return [];
160
+ const overview = getOverview();
161
+ return overview.elements.filter((ref) => {
162
+ const haystack = `${ref.kind} ${ref.name} ${ref.summary}`.toLowerCase();
163
+ return tokens.every((t) => haystack.includes(t));
164
+ });
165
+ }
166
+ return { overview: getOverview, describe, resolve };
167
+ }
168
+ // ---------------------------------------------------------------------------
169
+ // Per-element describe helpers
170
+ // ---------------------------------------------------------------------------
171
+ function describeType(name, effective) {
172
+ const entry = effective.types.get(name);
173
+ if (!entry)
174
+ return undefined;
175
+ const tdef = entry.value;
176
+ const description = provenancedFromValue(tdef.description);
177
+ // Required attributes: those listed in tdef.required
178
+ const requiredAttributes = tdef.required.value
179
+ .map((attrName) => attrRef(attrName, effective, tdef));
180
+ // Allowed attributes: all declared attrs minus required
181
+ const requiredSet = new Set(tdef.required.value);
182
+ const allAttrNames = [
183
+ ...tdef.attributes.keys(),
184
+ ...effective.attributes.keys(),
185
+ ].filter((attrName, i, arr) => arr.indexOf(attrName) === i); // dedupe
186
+ const allowedAttributes = allAttrNames
187
+ .filter((attrName) => !requiredSet.has(attrName))
188
+ .map((attrName) => attrRef(attrName, effective, tdef));
189
+ // Outgoing relations
190
+ const outgoingRelations = [
191
+ ...tdef.traceability.keys(),
192
+ ].map((relName) => {
193
+ const descEntry = tdef.relationDescriptions.get(relName);
194
+ const rule = tdef.traceability.get(relName);
195
+ const summary = descEntry?.value ??
196
+ `targets: ${rule.value.target.map(targetToString).join(", ")}`;
197
+ return {
198
+ kind: "relation",
199
+ name: relName,
200
+ summary,
201
+ ref: `relation/${relName}`,
202
+ };
203
+ });
204
+ // Incoming relations: types whose traceability targets this type by name
205
+ const incomingRelations = [];
206
+ const seenIn = new Set();
207
+ for (const [otherTypeName, otherEntry] of effective.types) {
208
+ if (otherTypeName === name)
209
+ continue;
210
+ for (const [relName, ruleEntry] of otherEntry.value.traceability) {
211
+ if (seenIn.has(relName))
212
+ continue;
213
+ const targets = ruleEntry.value.target;
214
+ const matches = targets.some((t) => typeof t === "string" ? t === name : false);
215
+ if (matches) {
216
+ seenIn.add(relName);
217
+ const relDesc = otherEntry.value.relationDescriptions.get(relName);
218
+ const summary = relDesc?.value ?? `from ${otherTypeName}`;
219
+ incomingRelations.push({
220
+ kind: "relation",
221
+ name: relName,
222
+ summary,
223
+ ref: `relation/${relName}`,
224
+ });
225
+ }
226
+ }
227
+ }
228
+ return {
229
+ kind: "type",
230
+ name,
231
+ description,
232
+ extendsTarget: tdef.extends,
233
+ shape: tdef.extends,
234
+ displayIdPattern: tdef.displayIdPattern.value,
235
+ color: tdef.color.value,
236
+ requiredAttributes,
237
+ allowedAttributes,
238
+ outgoingRelations,
239
+ incomingRelations,
240
+ };
241
+ }
242
+ function attrRef(attrName, effective, tdef) {
243
+ // Look in type-specific scope first, then universal.
244
+ const typeAttr = tdef.attributes.get(attrName)?.value;
245
+ const universalAttr = effective.attributes.get(attrName)?.value;
246
+ const attrDecl = typeAttr ?? universalAttr;
247
+ const attrDesc = tdef.attrDescriptions.get(attrName);
248
+ const summary = attrDesc?.value ??
249
+ attrDecl?.description ??
250
+ (attrDecl
251
+ ? `${attrDecl.type}, ${formatCardinality(attrDecl.cardinality)}`
252
+ : attrName);
253
+ return {
254
+ kind: "attribute",
255
+ name: attrName,
256
+ summary,
257
+ ref: `attribute/${attrName}`,
258
+ };
259
+ }
260
+ function describeAttribute(name, effective) {
261
+ const entry = effective.attributes.get(name);
262
+ if (!entry)
263
+ return undefined;
264
+ const decl = entry.value;
265
+ // Find which types also declare this attribute.
266
+ const declaredBy = ["universal"];
267
+ for (const [typeName, typeEntry] of effective.types) {
268
+ if (typeEntry.value.attributes.has(name)) {
269
+ declaredBy.push(typeName);
270
+ }
271
+ }
272
+ const description = {
273
+ text: decl.description,
274
+ origin: decl.description !== undefined ? entry.origin : undefined,
275
+ };
276
+ return {
277
+ kind: "attribute",
278
+ name,
279
+ description,
280
+ valueType: decl.type,
281
+ cardinality: formatCardinality(decl.cardinality),
282
+ required: decl.required,
283
+ enumValues: decl.values,
284
+ inverse: decl.inverse,
285
+ declaredBy,
286
+ };
287
+ }
288
+ function describeRelation(name, effective) {
289
+ const declaredBy = [];
290
+ let bestDesc = {};
291
+ const targets = [];
292
+ let required = false;
293
+ let cardinality;
294
+ for (const [typeName, typeEntry] of effective.types) {
295
+ const tdef = typeEntry.value;
296
+ const ruleEntry = tdef.traceability.get(name);
297
+ if (!ruleEntry)
298
+ continue;
299
+ declaredBy.push(typeName);
300
+ const rule = ruleEntry.value;
301
+ for (const t of rule.target.map(targetToString)) {
302
+ if (!targets.includes(t))
303
+ targets.push(t);
304
+ }
305
+ if (rule.required)
306
+ required = true;
307
+ if (rule.cardinality) {
308
+ cardinality = formatCardinality(rule.cardinality);
309
+ }
310
+ const descEntry = tdef.relationDescriptions.get(name);
311
+ if (descEntry?.value !== undefined && bestDesc.text === undefined) {
312
+ bestDesc = {
313
+ text: descEntry.value,
314
+ origin: descEntry.origin,
315
+ overrides: descEntry.overrides ? [...descEntry.overrides] : undefined,
316
+ };
317
+ }
318
+ }
319
+ if (declaredBy.length === 0)
320
+ return undefined;
321
+ return {
322
+ kind: "relation",
323
+ name,
324
+ description: bestDesc,
325
+ targets,
326
+ cardinality,
327
+ required,
328
+ declaredBy,
329
+ };
330
+ }
331
+ function describeLabelConcern(name, effective) {
332
+ const entry = effective.labels.get(name);
333
+ if (!entry)
334
+ return undefined;
335
+ const concern = entry.value;
336
+ const description = {
337
+ text: concern.description,
338
+ origin: concern.description !== undefined ? entry.origin : undefined,
339
+ overrides: entry.overrides ? [...entry.overrides] : undefined,
340
+ };
341
+ return {
342
+ kind: "label-concern",
343
+ name,
344
+ description,
345
+ concernKind: concern.kind,
346
+ values: concern.values,
347
+ };
348
+ }
349
+ function describeConvention(name, effective) {
350
+ const entry = effective.conventions.get(name);
351
+ if (!entry)
352
+ return undefined;
353
+ const conv = entry.value;
354
+ const description = {
355
+ text: conv.description,
356
+ origin: conv.description !== undefined ? entry.origin : undefined,
357
+ overrides: entry.overrides ? [...entry.overrides] : undefined,
358
+ };
359
+ return {
360
+ kind: "convention",
361
+ name,
362
+ description,
363
+ settings: conv.settings,
364
+ };
365
+ }
366
+ // ---------------------------------------------------------------------------
367
+ // Helpers
368
+ // ---------------------------------------------------------------------------
369
+ function provenancedFromValue(pv) {
370
+ return {
371
+ text: pv.value,
372
+ origin: pv.value !== undefined ? pv.origin : undefined,
373
+ };
374
+ }
375
+ function formatCardinality(card) {
376
+ const upper = card.upper === Infinity ? "N" : String(card.upper);
377
+ return `${card.lower}..${upper}`;
378
+ }
379
+ function targetToString(t) {
380
+ return typeof t === "string" ? t : `{shape:${t.shape}}`;
381
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/profile/load.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGhE,yCAAyC;AACzC,MAAM,WAAW,2BAA2B;IAC1C,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,2BAA2B,CAAC,CAuCtC"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/profile/load.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIhE,yCAAyC;AACzC,MAAM,WAAW,2BAA2B;IAC1C,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,2BAA2B,CAAC,CA4CtC"}
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.loadProfileForCommand = loadProfileForCommand;
12
12
  const path_1 = require("@std/path");
13
13
  const markspec_js_1 = require("../config/markspec.js");
14
+ const mod_js_1 = require("../model/mod.js");
14
15
  const chain_js_1 = require("./chain.js");
15
16
  /**
16
17
  * Load the active profile chain for the project at `projectRoot`.
@@ -49,5 +50,71 @@ async function loadProfileForCommand(projectRoot, readFile) {
49
50
  }
50
51
  const chainResult = await (0, chain_js_1.loadChain)(profiles[0], projectRoot, projectRoot, readFile);
51
52
  diagnostics.push(...chainResult.diagnostics);
53
+ // MSL-A040 — profile must not redefine reserved core keys / types.
54
+ if (chainResult.chain) {
55
+ diagnostics.push(...checkReservedRedefinitions(chainResult.chain));
56
+ }
52
57
  return { chain: chainResult.chain, diagnostics };
53
58
  }
59
+ /**
60
+ * Reserved attribute names a profile must never declare. Per spec
61
+ * §4.4 MSL-A040 and ADR-009 §6: the identity slot (`Id`) and the
62
+ * type attribute (`Type`) are the absolutely reserved keys; their
63
+ * meaning is fixed by the core and any profile redefinition would
64
+ * silently break shape discrimination or type resolution.
65
+ */
66
+ const RESERVED_ATTRIBUTE_KEYS = new Set([
67
+ "Id",
68
+ "Type",
69
+ ]);
70
+ /**
71
+ * Scan the loaded profile chain for declarations that shadow core
72
+ * reserved names and emit MSL-A040 diagnostics. The check inspects:
73
+ *
74
+ * - universal `attributes:` scope,
75
+ * - per-shape `identified.attributes:` and `referenced.attributes:`,
76
+ * - every per-type `attributes:` map under `types:`,
77
+ * - each declared type name itself (must not match a core type).
78
+ */
79
+ function checkReservedRedefinitions(chain) {
80
+ const diagnostics = [];
81
+ const effective = chain.effective;
82
+ // Build origin → sourcePath index from the chain's tiers so diagnostics
83
+ // can point at the manifest file that introduced each declaration.
84
+ const originToPath = new Map();
85
+ for (const tier of chain.tiers) {
86
+ originToPath.set(tier.id, tier.sourcePath);
87
+ }
88
+ // Fallback file when an origin somehow isn't in the tier list.
89
+ const fallbackPath = chain.tiers[0]?.sourcePath ?? "<profile>";
90
+ function pathFor(origin) {
91
+ return originToPath.get(origin) ?? fallbackPath;
92
+ }
93
+ function checkAttrMap(map, scope) {
94
+ for (const [key, entry] of map) {
95
+ if (RESERVED_ATTRIBUTE_KEYS.has(key)) {
96
+ diagnostics.push({
97
+ code: "MSL-A040",
98
+ severity: "error",
99
+ message: `profile ${scope} attribute '${key}' shadows a core ` +
100
+ `reserved key (spec §4.4, ADR-009 §6); choose a different name`,
101
+ location: { file: pathFor(entry.origin), line: 1, column: 1 },
102
+ });
103
+ }
104
+ }
105
+ }
106
+ checkAttrMap(effective.attributes, "universal");
107
+ for (const [typeName, typeEntry] of effective.types) {
108
+ checkAttrMap(typeEntry.value.attributes, `type '${typeName}'`);
109
+ if (mod_js_1.CORE_TYPES.has(typeName)) {
110
+ diagnostics.push({
111
+ code: "MSL-A040",
112
+ severity: "error",
113
+ message: `profile type '${typeName}' shadows a core type name ` +
114
+ `(spec §4.4); the 15-type core vocabulary is reserved`,
115
+ location: { file: pathFor(typeEntry.origin), line: 1, column: 1 },
116
+ });
117
+ }
118
+ }
119
+ return diagnostics;
120
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/profile/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAwHnE,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AA4tBD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,UAAU,SAAoB,GAC7B,mBAAmB,CAkNrB"}
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/profile/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AA4EnE,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAo9BD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,UAAU,SAAoB,GAC7B,mBAAmB,CA6KrB"}