@primmel/primmel 1.3.2 → 1.4.1

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 (423) hide show
  1. package/dist/index.d.ts +40 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +112 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/check-allowlist.d.ts +56 -0
  6. package/dist/src/check-allowlist.d.ts.map +1 -0
  7. package/dist/src/check-allowlist.js +307 -0
  8. package/dist/src/check-allowlist.js.map +1 -0
  9. package/dist/src/check-rules.d.ts +17 -0
  10. package/dist/src/check-rules.d.ts.map +1 -0
  11. package/dist/src/check-rules.js +351 -0
  12. package/dist/src/check-rules.js.map +1 -0
  13. package/dist/src/check.d.ts +115 -0
  14. package/dist/src/check.d.ts.map +1 -0
  15. package/dist/src/check.js +4164 -0
  16. package/dist/src/check.js.map +1 -0
  17. package/dist/src/export/rdf-competency-questions.d.ts +11 -0
  18. package/dist/src/export/rdf-competency-questions.d.ts.map +1 -0
  19. package/dist/src/export/rdf-competency-questions.js +99 -0
  20. package/dist/src/export/rdf-competency-questions.js.map +1 -0
  21. package/dist/src/export/rdf-shapes.d.ts +3 -0
  22. package/dist/src/export/rdf-shapes.d.ts.map +1 -0
  23. package/dist/src/export/rdf-shapes.js +225 -0
  24. package/dist/src/export/rdf-shapes.js.map +1 -0
  25. package/dist/src/export/rdf-vocabulary.d.ts +125 -0
  26. package/dist/src/export/rdf-vocabulary.d.ts.map +1 -0
  27. package/dist/src/export/rdf-vocabulary.js +230 -0
  28. package/dist/src/export/rdf-vocabulary.js.map +1 -0
  29. package/dist/src/export/rdf.d.ts +92 -0
  30. package/dist/src/export/rdf.d.ts.map +1 -0
  31. package/dist/src/export/rdf.js +707 -0
  32. package/dist/src/export/rdf.js.map +1 -0
  33. package/dist/src/export/reqif.d.ts +81 -0
  34. package/dist/src/export/reqif.d.ts.map +1 -0
  35. package/dist/src/export/reqif.js +703 -0
  36. package/dist/src/export/reqif.js.map +1 -0
  37. package/dist/src/instance-resolution.d.ts +68 -0
  38. package/dist/src/instance-resolution.d.ts.map +1 -0
  39. package/dist/src/instance-resolution.js +239 -0
  40. package/dist/src/instance-resolution.js.map +1 -0
  41. package/dist/src/mapping-coverage.d.ts +220 -0
  42. package/dist/src/mapping-coverage.d.ts.map +1 -0
  43. package/dist/src/mapping-coverage.js +528 -0
  44. package/dist/src/mapping-coverage.js.map +1 -0
  45. package/dist/src/model-diff.d.ts +198 -0
  46. package/dist/src/model-diff.d.ts.map +1 -0
  47. package/dist/src/model-diff.js +914 -0
  48. package/dist/src/model-diff.js.map +1 -0
  49. package/dist/src/operational-state.d.ts +112 -0
  50. package/dist/src/operational-state.d.ts.map +1 -0
  51. package/dist/src/operational-state.js +162 -0
  52. package/dist/src/operational-state.js.map +1 -0
  53. package/dist/src/package-diff.d.ts +36 -0
  54. package/dist/src/package-diff.d.ts.map +1 -0
  55. package/dist/src/package-diff.js +104 -0
  56. package/dist/src/package-diff.js.map +1 -0
  57. package/dist/src/ser-des/config/acceptance.d.ts +10 -0
  58. package/dist/src/ser-des/config/acceptance.d.ts.map +1 -0
  59. package/dist/src/ser-des/config/acceptance.js +163 -0
  60. package/dist/src/ser-des/config/acceptance.js.map +1 -0
  61. package/dist/src/ser-des/config/activityArchetype.d.ts +5 -0
  62. package/dist/src/ser-des/config/activityArchetype.d.ts.map +1 -0
  63. package/dist/src/ser-des/config/activityArchetype.js +78 -0
  64. package/dist/src/ser-des/config/activityArchetype.js.map +1 -0
  65. package/dist/src/ser-des/config/artifact.d.ts +16 -0
  66. package/dist/src/ser-des/config/artifact.d.ts.map +1 -0
  67. package/dist/src/ser-des/config/artifact.js +392 -0
  68. package/dist/src/ser-des/config/artifact.js.map +1 -0
  69. package/dist/src/ser-des/config/calculation.d.ts.map +1 -1
  70. package/dist/src/ser-des/config/calculation.js +214 -12
  71. package/dist/src/ser-des/config/calculation.js.map +1 -1
  72. package/dist/src/ser-des/config/comment.d.ts +34 -0
  73. package/dist/src/ser-des/config/comment.d.ts.map +1 -0
  74. package/dist/src/ser-des/config/comment.js +121 -0
  75. package/dist/src/ser-des/config/comment.js.map +1 -0
  76. package/dist/src/ser-des/config/competenceKind.d.ts +8 -0
  77. package/dist/src/ser-des/config/competenceKind.d.ts.map +1 -0
  78. package/dist/src/ser-des/config/competenceKind.js +266 -0
  79. package/dist/src/ser-des/config/competenceKind.js.map +1 -0
  80. package/dist/src/ser-des/config/composition.d.ts +6 -0
  81. package/dist/src/ser-des/config/composition.d.ts.map +1 -0
  82. package/dist/src/ser-des/config/composition.js +165 -0
  83. package/dist/src/ser-des/config/composition.js.map +1 -0
  84. package/dist/src/ser-des/config/conformanceClass.d.ts +9 -0
  85. package/dist/src/ser-des/config/conformanceClass.d.ts.map +1 -0
  86. package/dist/src/ser-des/config/conformanceClass.js +128 -0
  87. package/dist/src/ser-des/config/conformanceClass.js.map +1 -0
  88. package/dist/src/ser-des/config/conformanceTest.d.ts +6 -0
  89. package/dist/src/ser-des/config/conformanceTest.d.ts.map +1 -0
  90. package/dist/src/ser-des/config/conformanceTest.js +929 -0
  91. package/dist/src/ser-des/config/conformanceTest.js.map +1 -0
  92. package/dist/src/ser-des/config/constraint.d.ts +5 -0
  93. package/dist/src/ser-des/config/constraint.d.ts.map +1 -0
  94. package/dist/src/ser-des/config/constraint.js +108 -0
  95. package/dist/src/ser-des/config/constraint.js.map +1 -0
  96. package/dist/src/ser-des/config/data.d.ts.map +1 -1
  97. package/dist/src/ser-des/config/data.js +105 -12
  98. package/dist/src/ser-des/config/data.js.map +1 -1
  99. package/dist/src/ser-des/config/design.d.ts +9 -0
  100. package/dist/src/ser-des/config/design.d.ts.map +1 -0
  101. package/dist/src/ser-des/config/design.js +847 -0
  102. package/dist/src/ser-des/config/design.js.map +1 -0
  103. package/dist/src/ser-des/config/discrepancyRecord.d.ts +5 -0
  104. package/dist/src/ser-des/config/discrepancyRecord.d.ts.map +1 -0
  105. package/dist/src/ser-des/config/discrepancyRecord.js +109 -0
  106. package/dist/src/ser-des/config/discrepancyRecord.js.map +1 -0
  107. package/dist/src/ser-des/config/dual.d.ts +9 -0
  108. package/dist/src/ser-des/config/dual.d.ts.map +1 -0
  109. package/dist/src/ser-des/config/dual.js +84 -0
  110. package/dist/src/ser-des/config/dual.js.map +1 -0
  111. package/dist/src/ser-des/config/field-parser.d.ts +92 -7
  112. package/dist/src/ser-des/config/field-parser.d.ts.map +1 -1
  113. package/dist/src/ser-des/config/field-parser.js +844 -29
  114. package/dist/src/ser-des/config/field-parser.js.map +1 -1
  115. package/dist/src/ser-des/config/form.d.ts.map +1 -1
  116. package/dist/src/ser-des/config/form.js +356 -134
  117. package/dist/src/ser-des/config/form.js.map +1 -1
  118. package/dist/src/ser-des/config/formulasUsed.d.ts +9 -0
  119. package/dist/src/ser-des/config/formulasUsed.d.ts.map +1 -0
  120. package/dist/src/ser-des/config/formulasUsed.js +126 -0
  121. package/dist/src/ser-des/config/formulasUsed.js.map +1 -0
  122. package/dist/src/ser-des/config/index.d.ts.map +1 -1
  123. package/dist/src/ser-des/config/index.js +180 -1
  124. package/dist/src/ser-des/config/index.js.map +1 -1
  125. package/dist/src/ser-des/config/instance.d.ts +22 -0
  126. package/dist/src/ser-des/config/instance.d.ts.map +1 -0
  127. package/dist/src/ser-des/config/instance.js +266 -0
  128. package/dist/src/ser-des/config/instance.js.map +1 -0
  129. package/dist/src/ser-des/config/invariant.d.ts +9 -0
  130. package/dist/src/ser-des/config/invariant.d.ts.map +1 -0
  131. package/dist/src/ser-des/config/invariant.js +143 -0
  132. package/dist/src/ser-des/config/invariant.js.map +1 -0
  133. package/dist/src/ser-des/config/mapProfile.d.ts.map +1 -1
  134. package/dist/src/ser-des/config/mapProfile.js +199 -14
  135. package/dist/src/ser-des/config/mapProfile.js.map +1 -1
  136. package/dist/src/ser-des/config/metadata.js +6 -6
  137. package/dist/src/ser-des/config/metadata.js.map +1 -1
  138. package/dist/src/ser-des/config/monitor.d.ts +9 -0
  139. package/dist/src/ser-des/config/monitor.d.ts.map +1 -0
  140. package/dist/src/ser-des/config/monitor.js +322 -0
  141. package/dist/src/ser-des/config/monitor.js.map +1 -0
  142. package/dist/src/ser-des/config/note.d.ts.map +1 -1
  143. package/dist/src/ser-des/config/note.js +16 -1
  144. package/dist/src/ser-des/config/note.js.map +1 -1
  145. package/dist/src/ser-des/config/packageManifest.d.ts +5 -0
  146. package/dist/src/ser-des/config/packageManifest.d.ts.map +1 -0
  147. package/dist/src/ser-des/config/packageManifest.js +349 -0
  148. package/dist/src/ser-des/config/packageManifest.js.map +1 -0
  149. package/dist/src/ser-des/config/passport.d.ts +9 -0
  150. package/dist/src/ser-des/config/passport.d.ts.map +1 -0
  151. package/dist/src/ser-des/config/passport.js +191 -0
  152. package/dist/src/ser-des/config/passport.js.map +1 -0
  153. package/dist/src/ser-des/config/process.d.ts +5 -3
  154. package/dist/src/ser-des/config/process.d.ts.map +1 -1
  155. package/dist/src/ser-des/config/process.js +915 -8
  156. package/dist/src/ser-des/config/process.js.map +1 -1
  157. package/dist/src/ser-des/config/quantity.d.ts +21 -0
  158. package/dist/src/ser-des/config/quantity.d.ts.map +1 -0
  159. package/dist/src/ser-des/config/quantity.js +114 -0
  160. package/dist/src/ser-des/config/quantity.js.map +1 -0
  161. package/dist/src/ser-des/config/quantityRegister.d.ts +9 -0
  162. package/dist/src/ser-des/config/quantityRegister.d.ts.map +1 -0
  163. package/dist/src/ser-des/config/quantityRegister.js +202 -0
  164. package/dist/src/ser-des/config/quantityRegister.js.map +1 -0
  165. package/dist/src/ser-des/config/reference.d.ts.map +1 -1
  166. package/dist/src/ser-des/config/reference.js +6 -0
  167. package/dist/src/ser-des/config/reference.js.map +1 -1
  168. package/dist/src/ser-des/config/referenceMaterial.d.ts +5 -0
  169. package/dist/src/ser-des/config/referenceMaterial.d.ts.map +1 -0
  170. package/dist/src/ser-des/config/referenceMaterial.js +296 -0
  171. package/dist/src/ser-des/config/referenceMaterial.js.map +1 -0
  172. package/dist/src/ser-des/config/requirement.d.ts +16 -0
  173. package/dist/src/ser-des/config/requirement.d.ts.map +1 -0
  174. package/dist/src/ser-des/config/requirement.js +579 -0
  175. package/dist/src/ser-des/config/requirement.js.map +1 -0
  176. package/dist/src/ser-des/config/role.d.ts.map +1 -1
  177. package/dist/src/ser-des/config/role.js +12 -0
  178. package/dist/src/ser-des/config/role.js.map +1 -1
  179. package/dist/src/ser-des/config/series.d.ts +9 -0
  180. package/dist/src/ser-des/config/series.d.ts.map +1 -0
  181. package/dist/src/ser-des/config/series.js +121 -0
  182. package/dist/src/ser-des/config/series.js.map +1 -0
  183. package/dist/src/ser-des/config/sourceDiscrepancy.d.ts +11 -0
  184. package/dist/src/ser-des/config/sourceDiscrepancy.d.ts.map +1 -0
  185. package/dist/src/ser-des/config/sourceDiscrepancy.js +83 -0
  186. package/dist/src/ser-des/config/sourceDiscrepancy.js.map +1 -0
  187. package/dist/src/ser-des/config/stateMachine.d.ts.map +1 -1
  188. package/dist/src/ser-des/config/stateMachine.js +189 -38
  189. package/dist/src/ser-des/config/stateMachine.js.map +1 -1
  190. package/dist/src/ser-des/config/subform.d.ts.map +1 -1
  191. package/dist/src/ser-des/config/subform.js +25 -33
  192. package/dist/src/ser-des/config/subform.js.map +1 -1
  193. package/dist/src/ser-des/config/subject.d.ts +58 -0
  194. package/dist/src/ser-des/config/subject.d.ts.map +1 -0
  195. package/dist/src/ser-des/config/subject.js +2093 -0
  196. package/dist/src/ser-des/config/subject.js.map +1 -0
  197. package/dist/src/ser-des/config/symbol.d.ts.map +1 -1
  198. package/dist/src/ser-des/config/symbol.js +130 -6
  199. package/dist/src/ser-des/config/symbol.js.map +1 -1
  200. package/dist/src/ser-des/config/table.d.ts.map +1 -1
  201. package/dist/src/ser-des/config/table.js +373 -7
  202. package/dist/src/ser-des/config/table.js.map +1 -1
  203. package/dist/src/ser-des/config/term.d.ts.map +1 -1
  204. package/dist/src/ser-des/config/term.js +107 -0
  205. package/dist/src/ser-des/config/term.js.map +1 -1
  206. package/dist/src/ser-des/config/testPointSet.d.ts +5 -0
  207. package/dist/src/ser-des/config/testPointSet.d.ts.map +1 -0
  208. package/dist/src/ser-des/config/testPointSet.js +199 -0
  209. package/dist/src/ser-des/config/testPointSet.js.map +1 -0
  210. package/dist/src/ser-des/config/testSequence.d.ts +9 -0
  211. package/dist/src/ser-des/config/testSequence.d.ts.map +1 -0
  212. package/dist/src/ser-des/config/testSequence.js +206 -0
  213. package/dist/src/ser-des/config/testSequence.js.map +1 -0
  214. package/dist/src/ser-des/config/text.d.ts +5 -0
  215. package/dist/src/ser-des/config/text.d.ts.map +1 -0
  216. package/dist/src/ser-des/config/text.js +106 -0
  217. package/dist/src/ser-des/config/text.js.map +1 -0
  218. package/dist/src/ser-des/config/twin.d.ts +31 -0
  219. package/dist/src/ser-des/config/twin.d.ts.map +1 -0
  220. package/dist/src/ser-des/config/twin.js +362 -0
  221. package/dist/src/ser-des/config/twin.js.map +1 -0
  222. package/dist/src/ser-des/config/verdict.d.ts +5 -0
  223. package/dist/src/ser-des/config/verdict.d.ts.map +1 -0
  224. package/dist/src/ser-des/config/verdict.js +159 -0
  225. package/dist/src/ser-des/config/verdict.js.map +1 -0
  226. package/dist/src/ser-des/config/viewProfile.d.ts.map +1 -1
  227. package/dist/src/ser-des/config/viewProfile.js +7 -0
  228. package/dist/src/ser-des/config/viewProfile.js.map +1 -1
  229. package/dist/src/ser-des/includes.d.ts.map +1 -1
  230. package/dist/src/ser-des/includes.js +5 -2
  231. package/dist/src/ser-des/includes.js.map +1 -1
  232. package/dist/src/ser-des/index.d.ts +12 -0
  233. package/dist/src/ser-des/index.d.ts.map +1 -1
  234. package/dist/src/ser-des/index.js +42 -0
  235. package/dist/src/ser-des/index.js.map +1 -1
  236. package/dist/src/ser-des/package.d.ts +53 -0
  237. package/dist/src/ser-des/package.d.ts.map +1 -0
  238. package/dist/src/ser-des/package.js +404 -0
  239. package/dist/src/ser-des/package.js.map +1 -0
  240. package/dist/src/ser-des/parse-block.d.ts.map +1 -1
  241. package/dist/src/ser-des/parse-block.js +7 -1
  242. package/dist/src/ser-des/parse-block.js.map +1 -1
  243. package/dist/src/ser-des/parse.d.ts.map +1 -1
  244. package/dist/src/ser-des/parse.js +45 -0
  245. package/dist/src/ser-des/parse.js.map +1 -1
  246. package/dist/src/ser-des/prm.d.ts +53 -0
  247. package/dist/src/ser-des/prm.d.ts.map +1 -0
  248. package/dist/src/ser-des/prm.js +257 -0
  249. package/dist/src/ser-des/prm.js.map +1 -0
  250. package/dist/src/ser-des/resolve.d.ts.map +1 -1
  251. package/dist/src/ser-des/resolve.js +1 -0
  252. package/dist/src/ser-des/resolve.js.map +1 -1
  253. package/dist/src/ser-des/tokenize.d.ts +11 -0
  254. package/dist/src/ser-des/tokenize.d.ts.map +1 -1
  255. package/dist/src/ser-des/tokenize.js +28 -1
  256. package/dist/src/ser-des/tokenize.js.map +1 -1
  257. package/dist/src/ser-des/types.d.ts +56 -1
  258. package/dist/src/ser-des/types.d.ts.map +1 -1
  259. package/dist/src/spelling.d.ts +35 -0
  260. package/dist/src/spelling.d.ts.map +1 -0
  261. package/dist/src/spelling.js +140 -0
  262. package/dist/src/spelling.js.map +1 -0
  263. package/dist/src/text-coverage.d.ts +164 -0
  264. package/dist/src/text-coverage.d.ts.map +1 -0
  265. package/dist/src/text-coverage.js +679 -0
  266. package/dist/src/text-coverage.js.map +1 -0
  267. package/dist/src/time.d.ts +55 -0
  268. package/dist/src/time.d.ts.map +1 -0
  269. package/dist/src/time.js +223 -0
  270. package/dist/src/time.js.map +1 -0
  271. package/dist/src/type-expr.d.ts +31 -0
  272. package/dist/src/type-expr.d.ts.map +1 -0
  273. package/dist/src/type-expr.js +110 -0
  274. package/dist/src/type-expr.js.map +1 -0
  275. package/dist/src/types/Acceptance.d.ts +31 -0
  276. package/dist/src/types/Acceptance.d.ts.map +1 -0
  277. package/dist/src/types/Acceptance.js +12 -0
  278. package/dist/src/types/Acceptance.js.map +1 -0
  279. package/dist/src/types/ActivityArchetype.d.ts +14 -0
  280. package/dist/src/types/ActivityArchetype.d.ts.map +1 -0
  281. package/dist/src/types/ActivityArchetype.js +17 -0
  282. package/dist/src/types/ActivityArchetype.js.map +1 -0
  283. package/dist/src/types/Artifact.d.ts +117 -0
  284. package/dist/src/types/Artifact.d.ts.map +1 -0
  285. package/dist/src/types/Artifact.js +35 -0
  286. package/dist/src/types/Artifact.js.map +1 -0
  287. package/dist/src/types/Calculation.d.ts +49 -0
  288. package/dist/src/types/Calculation.d.ts.map +1 -1
  289. package/dist/src/types/Comment.d.ts +23 -0
  290. package/dist/src/types/Comment.d.ts.map +1 -0
  291. package/dist/src/types/Comment.js +3 -0
  292. package/dist/src/types/Comment.js.map +1 -0
  293. package/dist/src/types/CompetenceKind.d.ts +70 -0
  294. package/dist/src/types/CompetenceKind.d.ts.map +1 -0
  295. package/dist/src/types/CompetenceKind.js +3 -0
  296. package/dist/src/types/CompetenceKind.js.map +1 -0
  297. package/dist/src/types/Composition.d.ts +80 -0
  298. package/dist/src/types/Composition.d.ts.map +1 -0
  299. package/dist/src/types/Composition.js +44 -0
  300. package/dist/src/types/Composition.js.map +1 -0
  301. package/dist/src/types/ConformanceClass.d.ts +22 -0
  302. package/dist/src/types/ConformanceClass.d.ts.map +1 -0
  303. package/dist/src/types/ConformanceClass.js +7 -0
  304. package/dist/src/types/ConformanceClass.js.map +1 -0
  305. package/dist/src/types/ConformanceTest.d.ts +206 -0
  306. package/dist/src/types/ConformanceTest.d.ts.map +1 -0
  307. package/dist/src/types/ConformanceTest.js +3 -0
  308. package/dist/src/types/ConformanceTest.js.map +1 -0
  309. package/dist/src/types/Constraint.d.ts +34 -0
  310. package/dist/src/types/Constraint.d.ts.map +1 -0
  311. package/dist/src/types/Constraint.js +3 -0
  312. package/dist/src/types/Constraint.js.map +1 -0
  313. package/dist/src/types/Design.d.ts +147 -0
  314. package/dist/src/types/Design.d.ts.map +1 -0
  315. package/dist/src/types/Design.js +10 -0
  316. package/dist/src/types/Design.js.map +1 -0
  317. package/dist/src/types/DiscrepancyRecord.d.ts +42 -0
  318. package/dist/src/types/DiscrepancyRecord.d.ts.map +1 -0
  319. package/dist/src/types/DiscrepancyRecord.js +3 -0
  320. package/dist/src/types/DiscrepancyRecord.js.map +1 -0
  321. package/dist/src/types/Form.d.ts +132 -1
  322. package/dist/src/types/Form.d.ts.map +1 -1
  323. package/dist/src/types/FormulasUsed.d.ts +95 -0
  324. package/dist/src/types/FormulasUsed.d.ts.map +1 -0
  325. package/dist/src/types/FormulasUsed.js +64 -0
  326. package/dist/src/types/FormulasUsed.js.map +1 -0
  327. package/dist/src/types/Instance.d.ts +105 -0
  328. package/dist/src/types/Instance.d.ts.map +1 -0
  329. package/dist/src/types/Instance.js +40 -0
  330. package/dist/src/types/Instance.js.map +1 -0
  331. package/dist/src/types/Invariant.d.ts +82 -0
  332. package/dist/src/types/Invariant.d.ts.map +1 -0
  333. package/dist/src/types/Invariant.js +50 -0
  334. package/dist/src/types/Invariant.js.map +1 -0
  335. package/dist/src/types/MapProfile.d.ts +36 -1
  336. package/dist/src/types/MapProfile.d.ts.map +1 -1
  337. package/dist/src/types/Monitor.d.ts +144 -0
  338. package/dist/src/types/Monitor.d.ts.map +1 -0
  339. package/dist/src/types/Monitor.js +74 -0
  340. package/dist/src/types/Monitor.js.map +1 -0
  341. package/dist/src/types/Note.d.ts +4 -1
  342. package/dist/src/types/Note.d.ts.map +1 -1
  343. package/dist/src/types/Package.d.ts +161 -0
  344. package/dist/src/types/Package.d.ts.map +1 -0
  345. package/dist/src/types/Package.js +3 -0
  346. package/dist/src/types/Package.js.map +1 -0
  347. package/dist/src/types/Passport.d.ts +125 -0
  348. package/dist/src/types/Passport.d.ts.map +1 -0
  349. package/dist/src/types/Passport.js +84 -0
  350. package/dist/src/types/Passport.js.map +1 -0
  351. package/dist/src/types/Quantity.d.ts +99 -0
  352. package/dist/src/types/Quantity.d.ts.map +1 -0
  353. package/dist/src/types/Quantity.js +24 -0
  354. package/dist/src/types/Quantity.js.map +1 -0
  355. package/dist/src/types/Reference.d.ts +2 -0
  356. package/dist/src/types/Reference.d.ts.map +1 -1
  357. package/dist/src/types/ReferenceMaterial.d.ts +53 -0
  358. package/dist/src/types/ReferenceMaterial.d.ts.map +1 -0
  359. package/dist/src/types/ReferenceMaterial.js +14 -0
  360. package/dist/src/types/ReferenceMaterial.js.map +1 -0
  361. package/dist/src/types/Requirement.d.ts +111 -0
  362. package/dist/src/types/Requirement.d.ts.map +1 -0
  363. package/dist/src/types/Requirement.js +10 -0
  364. package/dist/src/types/Requirement.js.map +1 -0
  365. package/dist/src/types/Role.d.ts +4 -0
  366. package/dist/src/types/Role.d.ts.map +1 -1
  367. package/dist/src/types/Series.d.ts +31 -0
  368. package/dist/src/types/Series.d.ts.map +1 -0
  369. package/dist/src/types/Series.js +14 -0
  370. package/dist/src/types/Series.js.map +1 -0
  371. package/dist/src/types/SourceDiscrepancy.d.ts +21 -0
  372. package/dist/src/types/SourceDiscrepancy.d.ts.map +1 -0
  373. package/dist/src/types/SourceDiscrepancy.js +13 -0
  374. package/dist/src/types/SourceDiscrepancy.js.map +1 -0
  375. package/dist/src/types/Standard.d.ts +68 -0
  376. package/dist/src/types/Standard.d.ts.map +1 -1
  377. package/dist/src/types/StateMachine.d.ts +43 -0
  378. package/dist/src/types/StateMachine.d.ts.map +1 -1
  379. package/dist/src/types/StateMachine.js +7 -0
  380. package/dist/src/types/StateMachine.js.map +1 -1
  381. package/dist/src/types/Subject.d.ts +432 -0
  382. package/dist/src/types/Subject.d.ts.map +1 -0
  383. package/dist/src/types/Subject.js +13 -0
  384. package/dist/src/types/Subject.js.map +1 -0
  385. package/dist/src/types/Symbol.d.ts +31 -1
  386. package/dist/src/types/Symbol.d.ts.map +1 -1
  387. package/dist/src/types/Table.d.ts +43 -0
  388. package/dist/src/types/Table.d.ts.map +1 -1
  389. package/dist/src/types/Term.d.ts +29 -0
  390. package/dist/src/types/Term.d.ts.map +1 -1
  391. package/dist/src/types/TestPointSet.d.ts +33 -0
  392. package/dist/src/types/TestPointSet.d.ts.map +1 -0
  393. package/dist/src/types/TestPointSet.js +11 -0
  394. package/dist/src/types/TestPointSet.js.map +1 -0
  395. package/dist/src/types/TestSequence.d.ts +105 -0
  396. package/dist/src/types/TestSequence.d.ts.map +1 -0
  397. package/dist/src/types/TestSequence.js +65 -0
  398. package/dist/src/types/TestSequence.js.map +1 -0
  399. package/dist/src/types/Text.d.ts +21 -0
  400. package/dist/src/types/Text.d.ts.map +1 -0
  401. package/dist/src/types/Text.js +38 -0
  402. package/dist/src/types/Text.js.map +1 -0
  403. package/dist/src/types/Time.d.ts +43 -0
  404. package/dist/src/types/Time.d.ts.map +1 -0
  405. package/dist/src/types/Time.js +14 -0
  406. package/dist/src/types/Time.js.map +1 -0
  407. package/dist/src/types/Twin.d.ts +155 -0
  408. package/dist/src/types/Twin.d.ts.map +1 -0
  409. package/dist/src/types/Twin.js +102 -0
  410. package/dist/src/types/Twin.js.map +1 -0
  411. package/dist/src/types/Verdict.d.ts +40 -0
  412. package/dist/src/types/Verdict.d.ts.map +1 -0
  413. package/dist/src/types/Verdict.js +14 -0
  414. package/dist/src/types/Verdict.js.map +1 -0
  415. package/dist/src/types/ViewProfile.d.ts +6 -0
  416. package/dist/src/types/ViewProfile.d.ts.map +1 -1
  417. package/dist/src/types/data.d.ts +27 -0
  418. package/dist/src/types/data.d.ts.map +1 -1
  419. package/dist/src/types/process.d.ts +231 -0
  420. package/dist/src/types/process.d.ts.map +1 -1
  421. package/dist-browser/index.mjs +6699 -661
  422. package/dist-cli/primmel.mjs +21462 -0
  423. package/package.json +61 -5
@@ -0,0 +1,2093 @@
1
+ "use strict";
2
+ // ─────────────────────────────────────────────────────────────────────
3
+ // Subject-chain constructs (Primmel v2, gap G1):
4
+ // instrument, attribute_definition, capability, behavior, condition_set
5
+ //
6
+ // Grammar sketch:
7
+ // instrument LoadCell {
8
+ // extends MeasuringInstrumentModel
9
+ // definition "..."
10
+ // variant AnaloguePassiveLoadCell { definition "..." }
11
+ // dimension accuracy_class {
12
+ // label "Accuracy class" scope group description "..."
13
+ // reference { doc "urn:..." clause "5.1.1" }
14
+ // values { A { description "..." payload { n_lc_limits: "..." } } B C D }
15
+ // }
16
+ // family_criteria { "same material..." "same design..." }
17
+ // family_defaults { dimensions { construction technology } parameters { rated_output } }
18
+ // model_group {
19
+ // definition "..."
20
+ // identical_characteristics { metrological_class n_lc y z }
21
+ // identical_attributes { accuracy_class n_lc y z t_min t_max }
22
+ // }
23
+ // }
24
+ //
25
+ // attribute_definition e_max {
26
+ // symbol "E_max" name "Maximum capacity" definition "..."
27
+ // source { doc "urn:..." clause "3.5.5" }
28
+ // quantity_kind mass unit kg value_type QuantityValue
29
+ // origin design-fixed scope model category metrological
30
+ // is_dimension false enum humidity_class irdi "..." derived "ocl{...}"
31
+ // }
32
+ //
33
+ // capability digital {
34
+ // label "Digital" description "..." abstract false
35
+ // extends analogue-active requires strain-gauge
36
+ // has_parameters { output_signal software_identification }
37
+ // satisfies_requirements { /req/electronic/software }
38
+ // verified_by_tests { /conf/electronic-tests/software }
39
+ // }
40
+ //
41
+ // behavior creep {
42
+ // kind temporal stimulus force response "..."
43
+ // source { doc "..." clause "3.7.1" } verified_by { /conf/... }
44
+ // }
45
+ //
46
+ // condition_set load-cell-reference {
47
+ // role reference
48
+ // entries { temperature { value 20 unit degC tolerance 1 } }
49
+ // }
50
+ //
51
+ // Subject anatomy (Primmel v3, TODO.roadmap/01) — the `subject` construct
52
+ // organizes the aspect catalog by the three families is / has / does:
53
+ //
54
+ // subject LoadCell {
55
+ // extends MeasuringInstrumentModel
56
+ // is {
57
+ // metadata { name "Load cell" source "urn:oiml:pub:r:60-1:2021#clause-3.1.3" }
58
+ // provenance { manufacturer ACME }
59
+ // structure { }
60
+ // design_parameters { e_max : mass by design }
61
+ // designed_conditions { reference ref-conds rated rated-conds }
62
+ // promises {
63
+ // c6-envelope {
64
+ // target accuracy-class
65
+ // level symbolic C6
66
+ // conditions ocl{self.temperature >= rated.t_min and self.temperature <= rated.t_max}
67
+ // statement "Holds accuracy class C6 across the rated range −10…+40 °C."
68
+ // verified_by { /req/metrological/mpe /conf/metrological-tests/mpe-test }
69
+ // source { doc "urn:oiml:pub:r:60-1:2021" clause "5.1" }
70
+ // }
71
+ // "a statement-only claim (shorthand — linter C43 flags it unverifiable)"
72
+ // }
73
+ // artifacts { }
74
+ // }
75
+ // has {
76
+ // attributes { d_min : mass test_dependent }
77
+ // dimensions { accuracy_class in {A,B,C,D} }
78
+ // state OperationalStates
79
+ // characteristics { creep c_c = ocl{self.indication.delta / self.time.delta} }
80
+ // (block form, TODO.roadmap/10: creep { symbol "c_c" derivation ocl{…}
81
+ // behavior creep quantity_kind verification_interval unit "v"
82
+ // source { doc "…" clause "…" } })
83
+ // environmental_context { "logged 23.4 degC during run 7" }
84
+ // artifact_instances { }
85
+ // }
86
+ // does {
87
+ // behavior measure
88
+ // behavior creep
89
+ // }
90
+ // }
91
+ //
92
+ // Aspect blocks under the wrong family (or undeclared aspect kinds) are
93
+ // recorded on Subject.misplacedAspects for the linter (C6) — the parse
94
+ // itself stays lenient.
95
+ //
96
+ // `extends` merges at resolve time (resolveSubject): each subject merges
97
+ // with its parent per aspect-kind rules — maps merge by key (child
98
+ // wins), lists append (parent entries first), scalars override (child's
99
+ // non-empty value wins). Missing parents and cycle links stay unmerged
100
+ // (lint rule subject-extends-resolves reports the missing ones).
101
+ // ─────────────────────────────────────────────────────────────────────
102
+ Object.defineProperty(exports, "__esModule", { value: true });
103
+ exports.subjectConstruct = exports.conditionSetConstruct = exports.behaviorConstruct = exports.capabilityConstruct = exports.attributeDefinitionConstruct = exports.instrumentConstruct = void 0;
104
+ exports.resolveSubject = resolveSubject;
105
+ const tokenize_1 = require("../tokenize");
106
+ const tokenize_2 = require("../tokenize");
107
+ const field_parser_1 = require("./field-parser");
108
+ const field_parser_2 = require("./field-parser");
109
+ const twin_1 = require("./twin");
110
+ const composition_1 = require("./composition");
111
+ const quantity_1 = require("./quantity");
112
+ // ── shared little readers ────────────────────────────────────────────
113
+ function dumpSource(keyword, src, indent) {
114
+ if (!src || (!src.doc && !src.clause)) {
115
+ return '';
116
+ }
117
+ const frag = src.fragment ? ` fragment "${(0, tokenize_2.escapeString)(src.fragment)}"` : '';
118
+ return `${indent}${keyword} { doc "${(0, tokenize_2.escapeString)(src.doc)}" clause "${(0, tokenize_2.escapeString)(src.clause)}"${frag} }\n`;
119
+ }
120
+ function readIdList(block) {
121
+ // Wrap-tolerant: `{ a b }` block OR bare scalar — stripWrapping only strips
122
+ // when actually wrapped (unwrapBlock would mangle bare ids).
123
+ return (0, tokenize_1.default)((0, tokenize_2.stripWrapping)(block))
124
+ .map(field_parser_1.stripColon)
125
+ .map(tokenize_2.stripWrapping)
126
+ .filter(s => s.length > 0);
127
+ }
128
+ function dumpIdList(keyword, ids, indent) {
129
+ if (ids.length === 0) {
130
+ return '';
131
+ }
132
+ return `${indent}${keyword} { ${ids.join(' ')} }\n`;
133
+ }
134
+ function readReference(block) {
135
+ return (0, tokenize_1.default)((0, tokenize_2.stripWrapping)(block))
136
+ .map(tokenize_2.stripWrapping)
137
+ .filter(s => s.length > 0);
138
+ }
139
+ // ── instrument ───────────────────────────────────────────────────────
140
+ const parseInstrument = function (id, data) {
141
+ const result = {
142
+ id,
143
+ extends: '',
144
+ definition: '',
145
+ variants: [],
146
+ dimensions: [],
147
+ perChannel: '',
148
+ familyCriteria: [],
149
+ familyDefaultDimensions: [],
150
+ familyDefaultParameters: [],
151
+ modelGroup: null,
152
+ referenceIds: [],
153
+ measurand: null,
154
+ components: [],
155
+ structure: [],
156
+ };
157
+ const t = (0, tokenize_2.tokenizePackage)(data);
158
+ let i = 0;
159
+ while (i < t.length) {
160
+ const cmd = t[i++];
161
+ if (i >= t.length) {
162
+ break;
163
+ }
164
+ if (cmd === 'extends') {
165
+ result.extends = (0, tokenize_2.stripWrapping)(t[i++]);
166
+ }
167
+ else if (cmd === 'measurand_kind') {
168
+ result.measurandKind = (0, tokenize_2.stripWrapping)(t[i++]);
169
+ }
170
+ else if (cmd === 'measurand') {
171
+ result.measurand = parseMeasurand((0, tokenize_2.unwrapBlock)(t[i++]));
172
+ }
173
+ else if (cmd === 'component') {
174
+ result.components.push(parseComponent((0, tokenize_2.stripWrapping)(t[i++]), (0, tokenize_2.unwrapBlock)(t[i++])));
175
+ }
176
+ else if (cmd === 'structure') {
177
+ result.structure.push(parseStructure((0, tokenize_2.stripWrapping)(t[i++]), (0, tokenize_2.unwrapBlock)(t[i++])));
178
+ }
179
+ else if (cmd === 'definition') {
180
+ result.definition = (0, tokenize_2.stripWrapping)(t[i++]);
181
+ }
182
+ else if (cmd === 'note') {
183
+ result.note = (0, tokenize_2.stripWrapping)(t[i++]);
184
+ }
185
+ else if (cmd === 'source') {
186
+ result.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
187
+ }
188
+ else if (cmd === 'variant') {
189
+ const variantId = (0, tokenize_2.stripWrapping)(t[i++]);
190
+ const vblock = i < t.length ? (0, tokenize_2.unwrapBlock)(t[i++]) : '';
191
+ const v = { id: variantId, definition: '' };
192
+ const vt = (0, tokenize_1.default)(vblock);
193
+ let j = 0;
194
+ while (j < vt.length) {
195
+ const vc = vt[j++];
196
+ if (j >= vt.length) {
197
+ break;
198
+ }
199
+ if (vc === 'name') {
200
+ v.name = (0, tokenize_2.stripWrapping)(vt[j++]);
201
+ }
202
+ else if (vc === 'definition') {
203
+ v.definition = (0, tokenize_2.stripWrapping)(vt[j++]);
204
+ }
205
+ else if (vc === 'note') {
206
+ v.note = (0, tokenize_2.stripWrapping)(vt[j++]);
207
+ }
208
+ else if (vc === 'source') {
209
+ v.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(vt[j++]));
210
+ }
211
+ else {
212
+ (0, tokenize_2.unwrapBlock)(vt[j++]);
213
+ }
214
+ }
215
+ result.variants.push(v);
216
+ }
217
+ else if (cmd === 'dimension') {
218
+ result.dimensions.push(parseDimension((0, tokenize_2.stripWrapping)(t[i++]), (0, tokenize_2.unwrapBlock)(t[i++])));
219
+ }
220
+ else if (cmd === 'per_channel') {
221
+ result.perChannel = (0, tokenize_2.stripWrapping)(t[i++]);
222
+ }
223
+ else if (cmd === 'family_criteria') {
224
+ result.familyCriteria = readReference(t[i++]);
225
+ }
226
+ else if (cmd === 'family') {
227
+ // family { metamodel_class X definition "..." note "..." source { … } }
228
+ const fblk = (0, tokenize_2.unwrapBlock)(t[i++]);
229
+ const ft = (0, tokenize_1.default)(fblk);
230
+ let j = 0;
231
+ while (j < ft.length) {
232
+ const fc = ft[j++];
233
+ if (j >= ft.length) {
234
+ break;
235
+ }
236
+ if (fc === 'metamodel_class') {
237
+ result.familyMetamodelClass = (0, tokenize_2.stripWrapping)(ft[j++]);
238
+ }
239
+ else if (fc === 'definition') {
240
+ result.familyDefinition = (0, tokenize_2.stripWrapping)(ft[j++]);
241
+ }
242
+ else if (fc === 'note') {
243
+ result.familyNote = (0, tokenize_2.stripWrapping)(ft[j++]);
244
+ }
245
+ else if (fc === 'source') {
246
+ result.familySource = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(ft[j++]));
247
+ }
248
+ else {
249
+ (0, tokenize_2.unwrapBlock)(ft[j++]);
250
+ }
251
+ }
252
+ }
253
+ else if (cmd === 'family_defaults') {
254
+ const fblock = (0, tokenize_2.unwrapBlock)(t[i++]);
255
+ const ft = (0, tokenize_1.default)(fblock);
256
+ let j = 0;
257
+ while (j < ft.length) {
258
+ const fc = ft[j++];
259
+ if (j >= ft.length) {
260
+ break;
261
+ }
262
+ if (fc === 'dimensions') {
263
+ result.familyDefaultDimensions = readIdList(ft[j++]);
264
+ }
265
+ else if (fc === 'parameters') {
266
+ result.familyDefaultParameters = readIdList(ft[j++]);
267
+ }
268
+ else {
269
+ (0, tokenize_2.unwrapBlock)(ft[j++]);
270
+ }
271
+ }
272
+ }
273
+ else if (cmd === 'model_group') {
274
+ result.modelGroup = parseModelGroup((0, tokenize_2.unwrapBlock)(t[i++]));
275
+ }
276
+ else if (cmd === 'reference') {
277
+ result.referenceIds = readReference(t[i++]);
278
+ }
279
+ else {
280
+ (0, tokenize_2.unwrapBlock)(t[i++]);
281
+ }
282
+ }
283
+ return ctx => {
284
+ ctx.instruments[id] = result;
285
+ return ctx;
286
+ };
287
+ };
288
+ /** measurand { kind X description "..." context { … } source { … } } (TODO.roadmap/19, G8). */
289
+ function parseMeasurand(block) {
290
+ const m = {
291
+ kind: '',
292
+ description: '',
293
+ context: null,
294
+ source: null,
295
+ };
296
+ const t = (0, tokenize_1.default)(block);
297
+ let i = 0;
298
+ while (i < t.length) {
299
+ const cmd = t[i++];
300
+ if (i >= t.length) {
301
+ break;
302
+ }
303
+ if (cmd === 'kind') {
304
+ m.kind = (0, tokenize_2.stripWrapping)(t[i++]);
305
+ }
306
+ else if (cmd === 'description') {
307
+ m.description = (0, tokenize_2.stripWrapping)(t[i++]);
308
+ }
309
+ else if (cmd === 'context') {
310
+ const ctx = { targetObject: '', identificationMethod: '' };
311
+ const ct = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i++]));
312
+ let j = 0;
313
+ while (j < ct.length) {
314
+ const cc = ct[j++];
315
+ if (j >= ct.length) {
316
+ break;
317
+ }
318
+ if (cc === 'target_object') {
319
+ ctx.targetObject = (0, tokenize_2.stripWrapping)(ct[j++]);
320
+ }
321
+ else if (cc === 'identification_method') {
322
+ ctx.identificationMethod = (0, tokenize_2.stripWrapping)(ct[j++]);
323
+ }
324
+ else {
325
+ (0, tokenize_2.unwrapBlock)(ct[j++]);
326
+ }
327
+ }
328
+ m.context = ctx;
329
+ }
330
+ else if (cmd === 'source') {
331
+ m.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
332
+ }
333
+ else {
334
+ (0, tokenize_2.unwrapBlock)(t[i++]);
335
+ }
336
+ }
337
+ return m;
338
+ }
339
+ /** component <id> { class X definition "..." source { … } } (TODO.roadmap/19, G3). */
340
+ function parseComponent(id, block) {
341
+ const c = {
342
+ id,
343
+ classId: '',
344
+ definition: '',
345
+ source: null,
346
+ };
347
+ const t = (0, tokenize_1.default)(block);
348
+ let i = 0;
349
+ while (i < t.length) {
350
+ const cmd = t[i++];
351
+ if (i >= t.length) {
352
+ break;
353
+ }
354
+ if (cmd === 'class') {
355
+ c.classId = (0, tokenize_2.stripWrapping)(t[i++]);
356
+ }
357
+ else if (cmd === 'definition') {
358
+ c.definition = (0, tokenize_2.stripWrapping)(t[i++]);
359
+ }
360
+ else if (cmd === 'source') {
361
+ c.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
362
+ }
363
+ else {
364
+ (0, tokenize_2.unwrapBlock)(t[i++]);
365
+ }
366
+ }
367
+ return c;
368
+ }
369
+ /**
370
+ * structure <id> { predicate X subject Y target Z applicability { … }
371
+ * propagation { prop dir … } note "..." source { … } } (TODO.roadmap/19, G3).
372
+ */
373
+ function parseStructure(id, block) {
374
+ const s = {
375
+ id,
376
+ predicate: '',
377
+ subject: '',
378
+ target: '',
379
+ applicability: [],
380
+ propagation: [],
381
+ note: '',
382
+ source: null,
383
+ };
384
+ const t = (0, tokenize_1.default)(block);
385
+ let i = 0;
386
+ while (i < t.length) {
387
+ const cmd = t[i++];
388
+ if (i >= t.length) {
389
+ break;
390
+ }
391
+ if (cmd === 'predicate') {
392
+ s.predicate = (0, tokenize_2.stripWrapping)(t[i++]);
393
+ }
394
+ else if (cmd === 'subject') {
395
+ s.subject = (0, tokenize_2.stripWrapping)(t[i++]);
396
+ }
397
+ else if (cmd === 'target') {
398
+ s.target = (0, tokenize_2.stripWrapping)(t[i++]);
399
+ }
400
+ else if (cmd === 'applicability') {
401
+ s.applicability = (0, field_parser_2.parseApplicability)((0, tokenize_2.unwrapBlock)(t[i++]));
402
+ }
403
+ else if (cmd === 'propagation') {
404
+ const pt = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i++]));
405
+ for (let j = 0; j + 1 < pt.length; j += 2) {
406
+ s.propagation.push({
407
+ property: (0, tokenize_2.stripWrapping)(pt[j]),
408
+ direction: (0, tokenize_2.stripWrapping)(pt[j + 1]),
409
+ });
410
+ }
411
+ }
412
+ else if (cmd === 'note') {
413
+ s.note = (0, tokenize_2.stripWrapping)(t[i++]);
414
+ }
415
+ else if (cmd === 'source') {
416
+ s.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
417
+ }
418
+ else {
419
+ (0, tokenize_2.unwrapBlock)(t[i++]);
420
+ }
421
+ }
422
+ return s;
423
+ }
424
+ function parseDimension(id, block) {
425
+ const dim = {
426
+ id,
427
+ label: '',
428
+ scope: '',
429
+ cardinality: '',
430
+ labelSeparator: '',
431
+ description: '',
432
+ source: null,
433
+ values: [],
434
+ };
435
+ const t = (0, tokenize_1.default)(block);
436
+ let i = 0;
437
+ while (i < t.length) {
438
+ const cmd = t[i++];
439
+ if (i >= t.length) {
440
+ break;
441
+ }
442
+ if (cmd === 'label') {
443
+ dim.label = (0, tokenize_2.stripWrapping)(t[i++]);
444
+ }
445
+ else if (cmd === 'scope') {
446
+ dim.scope = (0, tokenize_2.stripWrapping)(t[i++]);
447
+ }
448
+ else if (cmd === 'cardinality') {
449
+ const c = (0, tokenize_2.stripWrapping)(t[i++]);
450
+ if (c !== 'single' && c !== 'set') {
451
+ throw new Error(`Parsing error: dimension. ID ${id}: Unknown cardinality ${c} (valid: single, set)`);
452
+ }
453
+ dim.cardinality = c;
454
+ }
455
+ else if (cmd === 'label_separator') {
456
+ dim.labelSeparator = (0, tokenize_2.stripWrapping)(t[i++]);
457
+ }
458
+ else if (cmd === 'description') {
459
+ dim.description = (0, tokenize_2.stripWrapping)(t[i++]);
460
+ }
461
+ else if (cmd === 'reference' || cmd === 'source') {
462
+ dim.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
463
+ }
464
+ else if (cmd === 'values') {
465
+ dim.values = parseDimensionValues((0, tokenize_2.unwrapBlock)(t[i++]));
466
+ }
467
+ else {
468
+ (0, tokenize_2.unwrapBlock)(t[i++]);
469
+ }
470
+ }
471
+ return dim;
472
+ }
473
+ function parseDimensionValues(block) {
474
+ const out = [];
475
+ const t = (0, tokenize_1.default)(block);
476
+ let i = 0;
477
+ while (i < t.length) {
478
+ const id = (0, field_parser_1.stripColon)(t[i++]);
479
+ if (!id) {
480
+ break;
481
+ }
482
+ const value = {
483
+ id,
484
+ label: '',
485
+ description: '',
486
+ payload: {},
487
+ implies: [],
488
+ };
489
+ if (i < t.length && t[i].startsWith('{')) {
490
+ const vblock = (0, tokenize_2.unwrapBlock)(t[i++]);
491
+ const vt = (0, tokenize_1.default)(vblock);
492
+ let j = 0;
493
+ while (j < vt.length) {
494
+ const cmd = vt[j++];
495
+ if (j >= vt.length) {
496
+ break;
497
+ }
498
+ if (cmd === 'label') {
499
+ value.label = (0, tokenize_2.stripWrapping)(vt[j++]);
500
+ }
501
+ else if (cmd === 'description') {
502
+ value.description = (0, tokenize_2.stripWrapping)(vt[j++]);
503
+ }
504
+ else if (cmd === 'implies') {
505
+ value.implies = readIdList(vt[j++]);
506
+ }
507
+ else if (cmd === 'term_ref') {
508
+ value.termRef = (0, tokenize_2.stripWrapping)(vt[j++]);
509
+ }
510
+ else if (cmd === 'payload') {
511
+ const pblock = (0, tokenize_2.unwrapBlock)(vt[j++]);
512
+ const pt = (0, tokenize_1.default)(pblock);
513
+ let k = 0;
514
+ while (k < pt.length) {
515
+ const key = (0, field_parser_1.stripColon)(pt[k++]);
516
+ if (k >= pt.length) {
517
+ break;
518
+ }
519
+ if (pt[k] === ':') {
520
+ k++;
521
+ }
522
+ if (k < pt.length && pt[k].startsWith('{')) {
523
+ // Nested payload block: n_lc_limits { lower: 50000 upper: unlimited }
524
+ const nt = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(pt[k++]));
525
+ const nested = {};
526
+ let n = 0;
527
+ while (n < nt.length) {
528
+ const nkey = (0, field_parser_1.stripColon)(nt[n++]);
529
+ if (n >= nt.length) {
530
+ break;
531
+ }
532
+ if (nt[n] === ':') {
533
+ n++;
534
+ }
535
+ if (n < nt.length) {
536
+ nested[nkey] = (0, tokenize_2.stripWrapping)(nt[n++]);
537
+ }
538
+ }
539
+ value.payload[key] = nested;
540
+ }
541
+ else if (k < pt.length) {
542
+ value.payload[key] = (0, tokenize_2.stripWrapping)(pt[k++]);
543
+ }
544
+ }
545
+ }
546
+ else {
547
+ (0, tokenize_2.unwrapBlock)(vt[j++]);
548
+ }
549
+ }
550
+ }
551
+ out.push(value);
552
+ }
553
+ return out;
554
+ }
555
+ function parseModelGroup(block) {
556
+ const mg = {
557
+ definition: '',
558
+ identicalCharacteristics: [],
559
+ identicalAttributes: [],
560
+ sources: [],
561
+ sampleSelection: [],
562
+ };
563
+ const t = (0, tokenize_1.default)(block);
564
+ let i = 0;
565
+ while (i < t.length) {
566
+ const cmd = t[i++];
567
+ if (i >= t.length) {
568
+ break;
569
+ }
570
+ if (cmd === 'definition') {
571
+ mg.definition = (0, tokenize_2.stripWrapping)(t[i++]);
572
+ }
573
+ else if (cmd === 'identical_characteristics') {
574
+ mg.identicalCharacteristics = readIdList(t[i++]);
575
+ }
576
+ else if (cmd === 'identical_attributes') {
577
+ mg.identicalAttributes = readIdList(t[i++]);
578
+ }
579
+ else if (cmd === 'group_by') {
580
+ mg.groupBy = (0, tokenize_2.stripWrapping)(t[i++]);
581
+ }
582
+ else if (cmd === 'note') {
583
+ mg.note = (0, tokenize_2.stripWrapping)(t[i++]);
584
+ }
585
+ else if (cmd === 'source') {
586
+ mg.sources.push((0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++])));
587
+ }
588
+ else if (cmd === 'sample_selection') {
589
+ mg.sampleSelection.push((0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++])));
590
+ }
591
+ else {
592
+ (0, tokenize_2.unwrapBlock)(t[i++]);
593
+ }
594
+ }
595
+ return mg;
596
+ }
597
+ const dumpInstrument = function (inst) {
598
+ let out = 'instrument ' + inst.id + ' {\n';
599
+ if (inst.extends) {
600
+ out += ' extends ' + inst.extends + '\n';
601
+ }
602
+ if (inst.perChannel) {
603
+ out += ' per_channel ' + inst.perChannel + '\n';
604
+ }
605
+ if (inst.measurandKind) {
606
+ out += ' measurand_kind ' + inst.measurandKind + '\n';
607
+ }
608
+ if (inst.measurand) {
609
+ const m = inst.measurand;
610
+ out += ' measurand {\n';
611
+ if (m.kind) {
612
+ out += ' kind ' + m.kind + '\n';
613
+ }
614
+ if (m.description) {
615
+ out += ' description "' + (0, tokenize_2.escapeString)(m.description) + '"\n';
616
+ }
617
+ if (m.context) {
618
+ out += ' context {';
619
+ if (m.context.targetObject) {
620
+ out += ' target_object "' + (0, tokenize_2.escapeString)(m.context.targetObject) + '"';
621
+ }
622
+ if (m.context.identificationMethod) {
623
+ out +=
624
+ ' identification_method "' +
625
+ (0, tokenize_2.escapeString)(m.context.identificationMethod) +
626
+ '"';
627
+ }
628
+ out += ' }\n';
629
+ }
630
+ out += dumpSource('source', m.source, ' ');
631
+ out += ' }\n';
632
+ }
633
+ for (const c of inst.components ?? []) {
634
+ let line = ' component ' + c.id + ' { ';
635
+ if (c.classId) {
636
+ line += 'class ' + c.classId + ' ';
637
+ }
638
+ if (c.definition) {
639
+ line += 'definition "' + (0, tokenize_2.escapeString)(c.definition) + '" ';
640
+ }
641
+ if (c.source && (c.source.doc || c.source.clause)) {
642
+ line +=
643
+ 'source { doc "' +
644
+ (0, tokenize_2.escapeString)(c.source.doc) +
645
+ '" clause "' +
646
+ (0, tokenize_2.escapeString)(c.source.clause) +
647
+ '" } ';
648
+ }
649
+ out += line + '}\n';
650
+ }
651
+ for (const s of inst.structure ?? []) {
652
+ out += ' structure ' + s.id + ' {\n';
653
+ if (s.predicate) {
654
+ out += ' predicate ' + s.predicate + '\n';
655
+ }
656
+ if (s.subject) {
657
+ out += ' subject ' + s.subject + '\n';
658
+ }
659
+ if (s.target) {
660
+ out += ' target ' + s.target + '\n';
661
+ }
662
+ if (s.applicability.length > 0) {
663
+ out +=
664
+ ' applicability { ' +
665
+ (0, field_parser_2.dumpApplicabilityEntries)(s.applicability).trim() +
666
+ ' }\n';
667
+ }
668
+ if (s.propagation.length > 0) {
669
+ out += ' propagation { ';
670
+ for (const p of s.propagation) {
671
+ out += p.property + ' ' + p.direction + ' ';
672
+ }
673
+ out += '}\n';
674
+ }
675
+ if (s.note) {
676
+ out += ' note "' + (0, tokenize_2.escapeString)(s.note) + '"\n';
677
+ }
678
+ out += dumpSource('source', s.source, ' ');
679
+ out += ' }\n';
680
+ }
681
+ if (inst.definition) {
682
+ out += ' definition "' + (0, tokenize_2.escapeString)(inst.definition) + '"\n';
683
+ }
684
+ if (inst.note) {
685
+ out += ' note "' + (0, tokenize_2.escapeString)(inst.note) + '"\n';
686
+ }
687
+ for (const v of inst.variants) {
688
+ let line = ' variant ' + v.id + ' { ';
689
+ if (v.name) {
690
+ line += 'name "' + (0, tokenize_2.escapeString)(v.name) + '" ';
691
+ }
692
+ line += 'definition "' + (0, tokenize_2.escapeString)(v.definition) + '" ';
693
+ if (v.note) {
694
+ line += 'note "' + (0, tokenize_2.escapeString)(v.note) + '" ';
695
+ }
696
+ if (v.source && (v.source.doc || v.source.clause)) {
697
+ line +=
698
+ 'source { doc "' +
699
+ (0, tokenize_2.escapeString)(v.source.doc) +
700
+ '" clause "' +
701
+ (0, tokenize_2.escapeString)(v.source.clause) +
702
+ '" } ';
703
+ }
704
+ out += line + '}\n';
705
+ }
706
+ for (const d of inst.dimensions) {
707
+ out += ' dimension ' + d.id + ' {\n';
708
+ if (d.label) {
709
+ out += ' label "' + (0, tokenize_2.escapeString)(d.label) + '"\n';
710
+ }
711
+ if (d.scope) {
712
+ out += ' scope ' + d.scope + '\n';
713
+ }
714
+ if (d.cardinality) {
715
+ out += ' cardinality ' + d.cardinality + '\n';
716
+ }
717
+ if (d.labelSeparator) {
718
+ out += ' label_separator "' + (0, tokenize_2.escapeString)(d.labelSeparator) + '"\n';
719
+ }
720
+ if (d.description) {
721
+ out += ' description "' + (0, tokenize_2.escapeString)(d.description) + '"\n';
722
+ }
723
+ out += dumpSource('reference', d.source, ' ');
724
+ if (d.values.length > 0) {
725
+ out += ' values {\n';
726
+ for (const v of d.values) {
727
+ let line = ' ' + v.id;
728
+ const hasProps = v.label ||
729
+ v.description ||
730
+ v.termRef ||
731
+ Object.keys(v.payload).length > 0 ||
732
+ v.implies.length > 0;
733
+ if (hasProps) {
734
+ line += ' { ';
735
+ if (v.label) {
736
+ line += 'label "' + (0, tokenize_2.escapeString)(v.label) + '" ';
737
+ }
738
+ if (v.description) {
739
+ line += 'description "' + (0, tokenize_2.escapeString)(v.description) + '" ';
740
+ }
741
+ if (v.termRef) {
742
+ line += 'term_ref ' + v.termRef + ' ';
743
+ }
744
+ if (v.implies.length > 0) {
745
+ line += 'implies { ' + v.implies.join(' ') + ' } ';
746
+ }
747
+ if (Object.keys(v.payload).length > 0) {
748
+ line += 'payload { ';
749
+ for (const [k, val] of Object.entries(v.payload)) {
750
+ if (typeof val === 'object' && val !== null) {
751
+ line += k + ' { ';
752
+ for (const [nk, nv] of Object.entries(val)) {
753
+ line += nk + ': "' + (0, tokenize_2.escapeString)(String(nv)) + '" ';
754
+ }
755
+ line += '} ';
756
+ }
757
+ else {
758
+ line += k + ': "' + (0, tokenize_2.escapeString)(String(val)) + '" ';
759
+ }
760
+ }
761
+ line += '} ';
762
+ }
763
+ line += '}';
764
+ }
765
+ out += line + '\n';
766
+ }
767
+ out += ' }\n';
768
+ }
769
+ out += ' }\n';
770
+ }
771
+ if (inst.familyMetamodelClass ||
772
+ inst.familyDefinition ||
773
+ inst.familyNote ||
774
+ (inst.familySource && (inst.familySource.doc || inst.familySource.clause))) {
775
+ out += ' family {\n';
776
+ if (inst.familyMetamodelClass) {
777
+ out += ' metamodel_class ' + inst.familyMetamodelClass + '\n';
778
+ }
779
+ if (inst.familyDefinition) {
780
+ out += ' definition "' + (0, tokenize_2.escapeString)(inst.familyDefinition) + '"\n';
781
+ }
782
+ if (inst.familyNote) {
783
+ out += ' note "' + (0, tokenize_2.escapeString)(inst.familyNote) + '"\n';
784
+ }
785
+ out += dumpSource('source', inst.familySource ?? null, ' ');
786
+ out += ' }\n';
787
+ }
788
+ if (inst.familyCriteria.length > 0) {
789
+ out += ' family_criteria {\n';
790
+ for (const c of inst.familyCriteria) {
791
+ out += ' "' + (0, tokenize_2.escapeString)(c) + '"\n';
792
+ }
793
+ out += ' }\n';
794
+ }
795
+ if (inst.familyDefaultDimensions.length > 0 ||
796
+ inst.familyDefaultParameters.length > 0) {
797
+ out += ' family_defaults {\n';
798
+ out += dumpIdList('dimensions', inst.familyDefaultDimensions, ' ');
799
+ out += dumpIdList('parameters', inst.familyDefaultParameters, ' ');
800
+ out += ' }\n';
801
+ }
802
+ if (inst.modelGroup) {
803
+ out += ' model_group {\n';
804
+ if (inst.modelGroup.definition) {
805
+ out +=
806
+ ' definition "' + (0, tokenize_2.escapeString)(inst.modelGroup.definition) + '"\n';
807
+ }
808
+ if (inst.modelGroup.groupBy) {
809
+ out += ' group_by ' + inst.modelGroup.groupBy + '\n';
810
+ }
811
+ if (inst.modelGroup.note) {
812
+ out += ' note "' + (0, tokenize_2.escapeString)(inst.modelGroup.note) + '"\n';
813
+ }
814
+ out += dumpIdList('identical_characteristics', inst.modelGroup.identicalCharacteristics, ' ');
815
+ out += dumpIdList('identical_attributes', inst.modelGroup.identicalAttributes, ' ');
816
+ for (const s of inst.modelGroup.sources ?? []) {
817
+ out += dumpSource('source', s, ' ');
818
+ }
819
+ for (const s of inst.modelGroup.sampleSelection ?? []) {
820
+ out += dumpSource('sample_selection', s, ' ');
821
+ }
822
+ out += ' }\n';
823
+ }
824
+ out += dumpSource('source', inst.source ?? null, ' ');
825
+ out += dumpIdList('reference', inst.referenceIds, ' ');
826
+ out += '}\n';
827
+ return out;
828
+ };
829
+ // ── attribute_definition ─────────────────────────────────────────────
830
+ const parseAttributeDefinition = function (id, data) {
831
+ const result = {
832
+ id,
833
+ symbol: '',
834
+ name: '',
835
+ definition: '',
836
+ source: null,
837
+ quantityKind: '',
838
+ unit: '',
839
+ valueType: '',
840
+ origin: '',
841
+ scope: '',
842
+ category: '',
843
+ isDimension: null,
844
+ enumRef: '',
845
+ irdi: '',
846
+ derived: '',
847
+ referenceIds: [],
848
+ };
849
+ const t = (0, tokenize_2.tokenizePackage)(data);
850
+ let i = 0;
851
+ while (i < t.length) {
852
+ const cmd = t[i++];
853
+ if (i >= t.length) {
854
+ break;
855
+ }
856
+ if (cmd === 'symbol') {
857
+ result.symbol = (0, tokenize_2.stripWrapping)(t[i++]);
858
+ }
859
+ else if (cmd === 'name') {
860
+ result.name = (0, tokenize_2.stripWrapping)(t[i++]);
861
+ }
862
+ else if (cmd === 'definition') {
863
+ result.definition = (0, tokenize_2.stripWrapping)(t[i++]);
864
+ }
865
+ else if (cmd === 'source' || cmd === 'reference') {
866
+ result.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
867
+ }
868
+ else if (cmd === 'quantity_kind') {
869
+ result.quantityKind = (0, tokenize_2.stripWrapping)(t[i++]);
870
+ }
871
+ else if (cmd === 'unit') {
872
+ result.unit = (0, tokenize_2.stripWrapping)(t[i++]);
873
+ }
874
+ else if (cmd === 'value_type') {
875
+ result.valueType = (0, tokenize_2.stripWrapping)(t[i++]);
876
+ }
877
+ else if (cmd === 'origin') {
878
+ result.origin = (0, tokenize_2.stripWrapping)(t[i++]);
879
+ }
880
+ else if (cmd === 'scope') {
881
+ result.scope = (0, tokenize_2.stripWrapping)(t[i++]);
882
+ }
883
+ else if (cmd === 'category') {
884
+ result.category = (0, tokenize_2.stripWrapping)(t[i++]);
885
+ }
886
+ else if (cmd === 'is_dimension') {
887
+ result.isDimension = (0, tokenize_2.stripWrapping)(t[i++]) === 'true';
888
+ }
889
+ else if (cmd === 'enum') {
890
+ result.enumRef = (0, tokenize_2.stripWrapping)(t[i++]);
891
+ }
892
+ else if (cmd === 'enum_values') {
893
+ result.enumValues = readIdList(t[i++]);
894
+ }
895
+ else if (cmd === 'note') {
896
+ result.note = (0, tokenize_2.stripWrapping)(t[i++]);
897
+ }
898
+ else if (cmd === 'irdi') {
899
+ result.irdi = (0, tokenize_2.stripWrapping)(t[i++]);
900
+ }
901
+ else if (cmd === 'derived') {
902
+ result.derived = (0, tokenize_2.stripWrapping)(t[i++]);
903
+ }
904
+ else {
905
+ (0, tokenize_2.unwrapBlock)(t[i++]);
906
+ }
907
+ }
908
+ return ctx => {
909
+ ctx.attributeDefinitions[id] = result;
910
+ return ctx;
911
+ };
912
+ };
913
+ const dumpAttributeDefinition = function (a) {
914
+ let out = 'attribute_definition ' + a.id + ' {\n';
915
+ if (a.symbol) {
916
+ out += ' symbol "' + (0, tokenize_2.escapeString)(a.symbol) + '"\n';
917
+ }
918
+ if (a.name) {
919
+ out += ' name "' + (0, tokenize_2.escapeString)(a.name) + '"\n';
920
+ }
921
+ if (a.definition) {
922
+ out += ' definition "' + (0, tokenize_2.escapeString)(a.definition) + '"\n';
923
+ }
924
+ out += dumpSource('source', a.source, ' ');
925
+ if (a.quantityKind) {
926
+ out += ' quantity_kind ' + a.quantityKind + '\n';
927
+ }
928
+ if (a.unit) {
929
+ out += ' unit "' + (0, tokenize_2.escapeString)(a.unit) + '"\n';
930
+ }
931
+ if (a.valueType) {
932
+ out += ' value_type ' + a.valueType + '\n';
933
+ }
934
+ if (a.origin) {
935
+ out += ' origin ' + a.origin + '\n';
936
+ }
937
+ if (a.scope) {
938
+ out += ' scope ' + a.scope + '\n';
939
+ }
940
+ if (a.category) {
941
+ out += ' category ' + a.category + '\n';
942
+ }
943
+ if (a.isDimension !== null && a.isDimension !== undefined) {
944
+ out += ' is_dimension ' + (a.isDimension ? 'true' : 'false') + '\n';
945
+ }
946
+ if (a.enumRef) {
947
+ out += ' enum ' + a.enumRef + '\n';
948
+ }
949
+ if (a.irdi) {
950
+ out += ' irdi "' + (0, tokenize_2.escapeString)(a.irdi) + '"\n';
951
+ }
952
+ if (a.derived) {
953
+ out += ' derived "' + (0, tokenize_2.escapeString)(a.derived) + '"\n';
954
+ }
955
+ out += '}\n';
956
+ return out;
957
+ };
958
+ // ── capability ───────────────────────────────────────────────────────
959
+ const parseCapability = function (id, data) {
960
+ const result = {
961
+ id,
962
+ label: '',
963
+ description: '',
964
+ abstract: false,
965
+ extends: [],
966
+ requires: [],
967
+ hasParameters: [],
968
+ satisfiesRequirements: [],
969
+ verifiedByTests: [],
970
+ referenceIds: [],
971
+ };
972
+ const t = (0, tokenize_2.tokenizePackage)(data);
973
+ let i = 0;
974
+ while (i < t.length) {
975
+ const cmd = t[i++];
976
+ if (i >= t.length) {
977
+ break;
978
+ }
979
+ if (cmd === 'label') {
980
+ result.label = (0, tokenize_2.stripWrapping)(t[i++]);
981
+ }
982
+ else if (cmd === 'description') {
983
+ result.description = (0, tokenize_2.stripWrapping)(t[i++]);
984
+ }
985
+ else if (cmd === 'abstract') {
986
+ result.abstract = (0, tokenize_2.stripWrapping)(t[i++]) === 'true';
987
+ }
988
+ else if (cmd === 'extends') {
989
+ result.extends = readIdList(t[i++]);
990
+ }
991
+ else if (cmd === 'requires') {
992
+ result.requires = readIdList(t[i++]);
993
+ }
994
+ else if (cmd === 'has_parameters') {
995
+ result.hasParameters = readIdList(t[i++]);
996
+ }
997
+ else if (cmd === 'satisfies_requirements') {
998
+ result.satisfiesRequirements = readReference(t[i++]);
999
+ }
1000
+ else if (cmd === 'verified_by_tests' || cmd === 'verified_by') {
1001
+ result.verifiedByTests = readReference(t[i++]);
1002
+ }
1003
+ else if (cmd === 'reference') {
1004
+ result.referenceIds = readReference(t[i++]);
1005
+ }
1006
+ else {
1007
+ (0, tokenize_2.unwrapBlock)(t[i++]);
1008
+ }
1009
+ }
1010
+ return ctx => {
1011
+ ctx.capabilities[id] = result;
1012
+ return ctx;
1013
+ };
1014
+ };
1015
+ const dumpCapability = function (c) {
1016
+ let out = 'capability ' + c.id + ' {\n';
1017
+ if (c.label) {
1018
+ out += ' label "' + (0, tokenize_2.escapeString)(c.label) + '"\n';
1019
+ }
1020
+ if (c.description) {
1021
+ out += ' description "' + (0, tokenize_2.escapeString)(c.description) + '"\n';
1022
+ }
1023
+ if (c.abstract) {
1024
+ out += ' abstract true\n';
1025
+ }
1026
+ out += dumpIdList('extends', c.extends, ' ');
1027
+ out += dumpIdList('requires', c.requires, ' ');
1028
+ out += dumpIdList('has_parameters', c.hasParameters, ' ');
1029
+ out += dumpIdList('satisfies_requirements', c.satisfiesRequirements, ' ');
1030
+ out += dumpIdList('verified_by_tests', c.verifiedByTests, ' ');
1031
+ out += dumpIdList('reference', c.referenceIds, ' ');
1032
+ out += '}\n';
1033
+ return out;
1034
+ };
1035
+ // ── behavior ─────────────────────────────────────────────────────────
1036
+ const parseBehavior = function (id, data) {
1037
+ const result = {
1038
+ id,
1039
+ kind: '',
1040
+ stimulus: '',
1041
+ response: '',
1042
+ source: null,
1043
+ verifiedBy: [],
1044
+ referenceIds: [],
1045
+ };
1046
+ const t = (0, tokenize_2.tokenizePackage)(data);
1047
+ let i = 0;
1048
+ while (i < t.length) {
1049
+ const cmd = t[i++];
1050
+ if (i >= t.length) {
1051
+ break;
1052
+ }
1053
+ if (cmd === 'kind') {
1054
+ result.kind = (0, tokenize_2.stripWrapping)(t[i++]);
1055
+ }
1056
+ else if (cmd === 'stimulus') {
1057
+ result.stimulus = (0, tokenize_2.stripWrapping)(t[i++]);
1058
+ }
1059
+ else if (cmd === 'response') {
1060
+ result.response = (0, tokenize_2.stripWrapping)(t[i++]);
1061
+ }
1062
+ else if (cmd === 'source' || cmd === 'reference') {
1063
+ result.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
1064
+ }
1065
+ else if (cmd === 'verified_by' || cmd === 'verified_by_tests') {
1066
+ result.verifiedBy = readReference(t[i++]);
1067
+ }
1068
+ else {
1069
+ (0, tokenize_2.unwrapBlock)(t[i++]);
1070
+ }
1071
+ }
1072
+ return ctx => {
1073
+ ctx.behaviors[id] = result;
1074
+ return ctx;
1075
+ };
1076
+ };
1077
+ const dumpBehavior = function (b) {
1078
+ let out = 'behavior ' + b.id + ' {\n';
1079
+ if (b.kind) {
1080
+ out += ' kind ' + b.kind + '\n';
1081
+ }
1082
+ if (b.stimulus) {
1083
+ out += ' stimulus ' + b.stimulus + '\n';
1084
+ }
1085
+ if (b.response) {
1086
+ out += ' response "' + (0, tokenize_2.escapeString)(b.response) + '"\n';
1087
+ }
1088
+ out += dumpSource('source', b.source, ' ');
1089
+ out += dumpIdList('verified_by', b.verifiedBy, ' ');
1090
+ out += '}\n';
1091
+ return out;
1092
+ };
1093
+ // ── condition_set ────────────────────────────────────────────────────
1094
+ const parseConditionSet = function (id, data) {
1095
+ const result = {
1096
+ id,
1097
+ role: '',
1098
+ entries: [],
1099
+ source: null,
1100
+ sources: [],
1101
+ referenceIds: [],
1102
+ };
1103
+ const t = (0, tokenize_2.tokenizePackage)(data);
1104
+ let i = 0;
1105
+ while (i < t.length) {
1106
+ const cmd = t[i++];
1107
+ if (i >= t.length) {
1108
+ break;
1109
+ }
1110
+ if (cmd === 'role') {
1111
+ result.role = (0, tokenize_2.stripWrapping)(t[i++]);
1112
+ }
1113
+ else if (cmd === 'subject') {
1114
+ result.subject = (0, tokenize_2.stripWrapping)(t[i++]);
1115
+ }
1116
+ else if (cmd === 'description') {
1117
+ result.description = (0, tokenize_2.stripWrapping)(t[i++]);
1118
+ }
1119
+ else if (cmd === 'entries') {
1120
+ result.entries = parseConditionEntries((0, tokenize_2.unwrapBlock)(t[i++]));
1121
+ }
1122
+ else if (cmd === 'source') {
1123
+ // Repeated source blocks accumulate; `source` stays the first entry.
1124
+ const src = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
1125
+ result.sources.push(src);
1126
+ if (!result.source) {
1127
+ result.source = src;
1128
+ }
1129
+ }
1130
+ else if (cmd === 'reference') {
1131
+ result.referenceIds = readReference(t[i++]);
1132
+ }
1133
+ else {
1134
+ (0, tokenize_2.unwrapBlock)(t[i++]);
1135
+ }
1136
+ }
1137
+ return ctx => {
1138
+ ctx.conditionSets[id] = result;
1139
+ return ctx;
1140
+ };
1141
+ };
1142
+ function parseConditionEntries(block) {
1143
+ const out = [];
1144
+ const t = (0, tokenize_1.default)(block);
1145
+ let i = 0;
1146
+ while (i < t.length) {
1147
+ const qk = (0, field_parser_1.stripColon)(t[i++]);
1148
+ if (!qk) {
1149
+ break;
1150
+ }
1151
+ const entry = {
1152
+ quantityKind: qk,
1153
+ value: '',
1154
+ unit: '',
1155
+ tolerance: '',
1156
+ };
1157
+ if (i < t.length && t[i].startsWith('{')) {
1158
+ const eblock = (0, tokenize_2.unwrapBlock)(t[i++]);
1159
+ const et = (0, tokenize_1.default)(eblock);
1160
+ let j = 0;
1161
+ while (j < et.length) {
1162
+ const cmd = et[j++];
1163
+ if (j >= et.length) {
1164
+ break;
1165
+ }
1166
+ if (cmd === 'value') {
1167
+ entry.value = (0, tokenize_2.stripWrapping)(et[j++]);
1168
+ }
1169
+ else if (cmd === 'unit') {
1170
+ entry.unit = (0, tokenize_2.stripWrapping)(et[j++]);
1171
+ }
1172
+ else if (cmd === 'tolerance') {
1173
+ entry.tolerance = (0, tokenize_2.stripWrapping)(et[j++]);
1174
+ }
1175
+ else if (cmd === 'note') {
1176
+ entry.note = (0, tokenize_2.stripWrapping)(et[j++]);
1177
+ }
1178
+ else {
1179
+ (0, tokenize_2.unwrapBlock)(et[j++]);
1180
+ }
1181
+ }
1182
+ }
1183
+ out.push(entry);
1184
+ }
1185
+ return out;
1186
+ }
1187
+ const dumpConditionSet = function (cs) {
1188
+ let out = 'condition_set ' + cs.id + ' {\n';
1189
+ if (cs.role) {
1190
+ out += ' role ' + cs.role + '\n';
1191
+ }
1192
+ if (cs.subject) {
1193
+ out += ' subject ' + cs.subject + '\n';
1194
+ }
1195
+ if (cs.description) {
1196
+ out += ' description "' + (0, tokenize_2.escapeString)(cs.description) + '"\n';
1197
+ }
1198
+ if (cs.entries.length > 0) {
1199
+ out += ' entries {\n';
1200
+ for (const e of cs.entries) {
1201
+ // Entry values may be free text ("nominal, per installation
1202
+ // conditions") — quote whenever not a single safe token.
1203
+ let line = ' ' + e.quantityKind + ' { value ' + (0, field_parser_1.dumpBareSafe)(e.value);
1204
+ if (e.unit) {
1205
+ line += ' unit "' + (0, tokenize_2.escapeString)(e.unit) + '"';
1206
+ }
1207
+ if (e.tolerance) {
1208
+ line += ' tolerance ' + (0, field_parser_1.dumpBareSafe)(e.tolerance);
1209
+ }
1210
+ if (e.note) {
1211
+ line += ' note "' + (0, tokenize_2.escapeString)(e.note) + '"';
1212
+ }
1213
+ out += line + ' }\n';
1214
+ }
1215
+ out += ' }\n';
1216
+ }
1217
+ const sources = cs.sources && cs.sources.length > 0
1218
+ ? cs.sources
1219
+ : cs.source
1220
+ ? [cs.source]
1221
+ : [];
1222
+ for (const s of sources) {
1223
+ out += dumpSource('source', s, ' ');
1224
+ }
1225
+ out += dumpIdList('reference', cs.referenceIds, ' ');
1226
+ out += '}\n';
1227
+ return out;
1228
+ };
1229
+ // ── subject (v3 anatomy: is / has / does) ────────────────────────────
1230
+ /** Read `key value` / `key: value` pairs into a string map. */
1231
+ function readStringMap(block) {
1232
+ const out = {};
1233
+ const t = (0, tokenize_1.default)(block);
1234
+ let i = 0;
1235
+ while (i < t.length) {
1236
+ const key = (0, field_parser_1.stripColon)(t[i++]);
1237
+ if (!key) {
1238
+ break;
1239
+ }
1240
+ if (t[i] === ':') {
1241
+ i++;
1242
+ }
1243
+ if (i < t.length) {
1244
+ out[key] = (0, tokenize_2.stripWrapping)(t[i++]);
1245
+ }
1246
+ }
1247
+ return out;
1248
+ }
1249
+ /**
1250
+ * Read `<id> : <qualifier tokens…>` entries (design_parameters / attributes).
1251
+ * The qualifier runs to the next `<id> :` head or the end of the block;
1252
+ * the stored value is the tokens joined with single spaces. The dump
1253
+ * re-emits the joined form, so the fixpoint holds.
1254
+ */
1255
+ function readValueMap(block) {
1256
+ const out = {};
1257
+ const t = (0, tokenize_1.default)(block);
1258
+ let i = 0;
1259
+ while (i < t.length) {
1260
+ const key = (0, field_parser_1.stripColon)(t[i++]);
1261
+ if (!key) {
1262
+ break;
1263
+ }
1264
+ if (t[i] === ':') {
1265
+ i++;
1266
+ }
1267
+ const parts = [];
1268
+ while (i < t.length && t[i + 1] !== ':') {
1269
+ parts.push((0, tokenize_2.stripWrapping)(t[i++]));
1270
+ }
1271
+ out[key] = parts.join(' ');
1272
+ }
1273
+ return out;
1274
+ }
1275
+ /** Read whitespace-separated entries (quoted phrases or bare ids). */
1276
+ function readStringEntries(block) {
1277
+ return (0, tokenize_1.default)(block)
1278
+ .map(tokenize_2.stripWrapping)
1279
+ .filter(s => s.length > 0);
1280
+ }
1281
+ /** Read `<id> in { A, B }` dimension-membership entries. */
1282
+ function readDimensionMap(block) {
1283
+ const out = {};
1284
+ const t = (0, tokenize_1.default)(block);
1285
+ let i = 0;
1286
+ while (i < t.length) {
1287
+ const key = (0, field_parser_1.stripColon)(t[i++]);
1288
+ if (!key) {
1289
+ break;
1290
+ }
1291
+ if (t[i] === ':') {
1292
+ i++;
1293
+ }
1294
+ if (t[i] === 'in') {
1295
+ i++;
1296
+ }
1297
+ if (i < t.length) {
1298
+ const raw = t[i++];
1299
+ const inner = raw.startsWith('{') ? (0, tokenize_2.unwrapBlock)(raw) : (0, tokenize_2.stripWrapping)(raw);
1300
+ out[key] = inner
1301
+ .split(/[,\s]+/)
1302
+ .map(s => s.trim())
1303
+ .filter(s => s.length > 0);
1304
+ }
1305
+ }
1306
+ return out;
1307
+ }
1308
+ /**
1309
+ * Read `name [symbol] = derivation` characteristic entries. The
1310
+ * derivation is an ocl{…} expression (reassembled across whitespace by
1311
+ * readValueToken) or a quoted phrase; an absent derivation parses as ''
1312
+ * and is flagged by the linter (C7).
1313
+ *
1314
+ * The `=` separator may arrive FUSED to the name or symbol token
1315
+ * (`creep c_c= ocl{…}`, `drift= ocl{…}`) — the tokenizer splits on
1316
+ * whitespace only, so a trailing `=` on either token is treated as the
1317
+ * separator and the derivation is read from the next token.
1318
+ *
1319
+ * Block form (TODO.roadmap/10): an entry whose name is followed by a
1320
+ * `{ … }` block carries the full register entry — symbol, derivation,
1321
+ * behavior (the behavior it quantifies), quantity_kind, unit, source:
1322
+ * mdlo_normalized {
1323
+ * symbol "C_M"
1324
+ * derivation ocl{abs(c_m * t_f / delta_t * (d_max - d_min) / (n * v_min))}
1325
+ * behavior temp-effect-min-dead-load
1326
+ * quantity_kind dimensionless
1327
+ * source { doc "urn:oiml:pub:r:60-3:2021" clause "2.1.4" }
1328
+ * }
1329
+ */
1330
+ function readCharacteristics(block) {
1331
+ const out = {};
1332
+ const t = (0, tokenize_1.default)(block);
1333
+ let i = 0;
1334
+ while (i < t.length) {
1335
+ let name = (0, field_parser_1.stripColon)(t[i++]);
1336
+ if (!name) {
1337
+ break;
1338
+ }
1339
+ if (i < t.length && t[i].startsWith('{')) {
1340
+ out[name] = readCharacteristicBlock((0, tokenize_2.unwrapBlock)(t[i++]));
1341
+ continue;
1342
+ }
1343
+ let symbol = '';
1344
+ let derivation = '';
1345
+ let fused = false;
1346
+ if (name.length > 1 && name.endsWith('=')) {
1347
+ name = name.slice(0, -1);
1348
+ fused = true;
1349
+ }
1350
+ if (!fused && i < t.length && t[i] !== '=') {
1351
+ // t[i] !== '=' here, so a trailing '=' on the symbol token is fused.
1352
+ fused = t[i].endsWith('=');
1353
+ symbol = fused ? t[i].slice(0, -1) : t[i];
1354
+ i++;
1355
+ }
1356
+ if (fused || t[i] === '=') {
1357
+ if (!fused) {
1358
+ i++;
1359
+ }
1360
+ const read = (0, field_parser_1.readValueToken)(t, i);
1361
+ derivation = (0, tokenize_2.stripWrapping)(read.text);
1362
+ i = read.next;
1363
+ }
1364
+ out[name] = { symbol, derivation };
1365
+ }
1366
+ return out;
1367
+ }
1368
+ /** Read one block-form characteristic entry (TODO.roadmap/10). */
1369
+ function readCharacteristicBlock(block) {
1370
+ const c = { symbol: '', derivation: '' };
1371
+ const t = (0, tokenize_1.default)(block);
1372
+ let i = 0;
1373
+ while (i < t.length) {
1374
+ const cmd = t[i++];
1375
+ if (i >= t.length) {
1376
+ break;
1377
+ }
1378
+ if (cmd === 'symbol') {
1379
+ c.symbol = (0, tokenize_2.stripWrapping)(t[i++]);
1380
+ }
1381
+ else if (cmd === 'derivation' || cmd === 'derive') {
1382
+ // ocl{…} expressions reassemble across whitespace (readValueToken).
1383
+ const read = (0, field_parser_1.readValueToken)(t, i);
1384
+ c.derivation = (0, tokenize_2.stripWrapping)(read.text);
1385
+ i = read.next;
1386
+ }
1387
+ else if (cmd === 'behavior') {
1388
+ c.behavior = (0, tokenize_2.stripWrapping)(t[i++]);
1389
+ }
1390
+ else if (cmd === 'quantity_kind') {
1391
+ c.quantityKind = (0, tokenize_2.stripWrapping)(t[i++]);
1392
+ }
1393
+ else if (cmd === 'unit') {
1394
+ c.unit = (0, tokenize_2.stripWrapping)(t[i++]);
1395
+ }
1396
+ else if (cmd === 'source' || cmd === 'reference') {
1397
+ c.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(t[i++]));
1398
+ }
1399
+ else {
1400
+ (0, tokenize_2.unwrapBlock)(t[i++]);
1401
+ }
1402
+ }
1403
+ return c;
1404
+ }
1405
+ /**
1406
+ * Aspects whose payload is a scalar (not a `{ … }` block). When such an
1407
+ * aspect is misplaced, its value token must be skipped together with the
1408
+ * keyword — otherwise the value is re-read as another (phantom) aspect.
1409
+ */
1410
+ const SCALAR_ASPECTS = new Set(['state', 'behavior']);
1411
+ /**
1412
+ * Misplaced-payload skipping for the twin aspects (TODO.roadmap/32):
1413
+ * endpoint <id> { … } — skip the id AND the block;
1414
+ * serve <aspect> via <op> [{ … }] — skip aspect/via/op + block.
1415
+ * Without the skip, a misplaced endpoint/serve cascades into phantom
1416
+ * aspects (the id, `via`, the operation name would each re-read as an
1417
+ * aspect keyword).
1418
+ */
1419
+ function skipMisplacedPayload(aspect, t, i) {
1420
+ if (aspect === 'endpoint') {
1421
+ if (i < t.length && !t[i].startsWith('{')) {
1422
+ i++; // the endpoint id
1423
+ }
1424
+ if (i < t.length && t[i].startsWith('{')) {
1425
+ i++; // the endpoint body
1426
+ }
1427
+ return i;
1428
+ }
1429
+ if (aspect === 'serve') {
1430
+ if (i < t.length) {
1431
+ i++; // the aspect path
1432
+ }
1433
+ if (t[i] === 'via') {
1434
+ i += 2; // `via` + the operation name
1435
+ }
1436
+ if (i < t.length && t[i].startsWith('{')) {
1437
+ i++; // the freshness block
1438
+ }
1439
+ return i;
1440
+ }
1441
+ return i;
1442
+ }
1443
+ /**
1444
+ * Record an aspect key found under the wrong family (or undeclared) for
1445
+ * the linter (C6), and skip its payload: one block token, or one scalar
1446
+ * value token for the known-scalar aspects.
1447
+ */
1448
+ function recordMisplaced(result, family, cmd, t, i) {
1449
+ const aspect = (0, field_parser_1.stripColon)(cmd);
1450
+ result.misplacedAspects.push({ family, aspect });
1451
+ if (i < t.length && t[i].startsWith('{')) {
1452
+ i++;
1453
+ }
1454
+ else if (SCALAR_ASPECTS.has(aspect)) {
1455
+ i++;
1456
+ }
1457
+ else {
1458
+ i = skipMisplacedPayload(aspect, t, i);
1459
+ }
1460
+ return i;
1461
+ }
1462
+ /**
1463
+ * Read one promise `level` value (TODO.roadmap/08). Three shapes:
1464
+ * level symbolic C6 → { kind: 'symbolic', symbolic }
1465
+ * level range { min -10 max 40 unit degC } → { kind: 'range', … }
1466
+ * level { value 0.7 unit v } → { kind: 'quantity', quantity }
1467
+ * Returns the level and the next unconsumed token index.
1468
+ */
1469
+ function readPromiseLevel(t, i) {
1470
+ const tok = t[i] ?? '';
1471
+ if (tok === 'symbolic') {
1472
+ return {
1473
+ level: { kind: 'symbolic', symbolic: (0, tokenize_2.stripWrapping)(t[i + 1] ?? '') },
1474
+ next: i + 2,
1475
+ };
1476
+ }
1477
+ if (tok === 'range') {
1478
+ const level = { kind: 'range' };
1479
+ const inner = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i + 1] ?? ''));
1480
+ let j = 0;
1481
+ while (j < inner.length) {
1482
+ const cmd = inner[j++];
1483
+ if (j > inner.length) {
1484
+ break;
1485
+ }
1486
+ if (cmd === 'min') {
1487
+ level.min = (0, quantity_1.coerceValueToken)(inner[j++]);
1488
+ }
1489
+ else if (cmd === 'max') {
1490
+ level.max = (0, quantity_1.coerceValueToken)(inner[j++]);
1491
+ }
1492
+ else if (cmd === 'unit') {
1493
+ level.unit = (0, tokenize_2.stripWrapping)(inner[j++]);
1494
+ }
1495
+ else {
1496
+ (0, tokenize_2.unwrapBlock)(inner[j++]);
1497
+ }
1498
+ }
1499
+ return { level, next: i + 2 };
1500
+ }
1501
+ // QuantityValue block form (the full INV-1 contract).
1502
+ return {
1503
+ level: { kind: 'quantity', quantity: (0, quantity_1.readQuantityBlock)((0, tokenize_2.unwrapBlock)(tok)) },
1504
+ next: i + 1,
1505
+ };
1506
+ }
1507
+ /**
1508
+ * Read is.promises entries (TODO.roadmap/08). Two entry forms:
1509
+ * - rich: `<id> { target … level … conditions … statement …
1510
+ * verified_by { … } source { … } }`
1511
+ * - shorthand: a quoted phrase or a bare token NOT followed by a block —
1512
+ * the legacy string-list form, parsed as a statement-only promise
1513
+ * (empty id/target/conditions; the linter's C43 flags it as
1514
+ * unverifiable at authoring).
1515
+ */
1516
+ function readPromises(block) {
1517
+ const out = [];
1518
+ const t = (0, tokenize_1.default)(block);
1519
+ let i = 0;
1520
+ while (i < t.length) {
1521
+ const tok = t[i++];
1522
+ if (!tok) {
1523
+ break;
1524
+ }
1525
+ if (tok.startsWith('"') || i >= t.length || !t[i].startsWith('{')) {
1526
+ out.push({
1527
+ id: '',
1528
+ target: '',
1529
+ level: null,
1530
+ conditions: '',
1531
+ statement: (0, tokenize_2.stripWrapping)(tok),
1532
+ verifiedBy: [],
1533
+ source: null,
1534
+ });
1535
+ continue;
1536
+ }
1537
+ const p = {
1538
+ id: (0, field_parser_1.stripColon)(tok),
1539
+ target: '',
1540
+ level: null,
1541
+ conditions: '',
1542
+ statement: '',
1543
+ verifiedBy: [],
1544
+ source: null,
1545
+ };
1546
+ const inner = (0, tokenize_1.default)((0, tokenize_2.unwrapBlock)(t[i++]));
1547
+ let j = 0;
1548
+ while (j < inner.length) {
1549
+ const cmd = inner[j++];
1550
+ if (j >= inner.length) {
1551
+ break;
1552
+ }
1553
+ if (cmd === 'target') {
1554
+ p.target = (0, tokenize_2.stripWrapping)(inner[j++]);
1555
+ }
1556
+ else if (cmd === 'level') {
1557
+ const read = readPromiseLevel(inner, j);
1558
+ p.level = read.level;
1559
+ j = read.next;
1560
+ }
1561
+ else if (cmd === 'conditions') {
1562
+ // ocl{…} expressions reassemble across whitespace (readValueToken).
1563
+ const read = (0, field_parser_1.readValueToken)(inner, j);
1564
+ p.conditions = (0, tokenize_2.stripWrapping)(read.text);
1565
+ j = read.next;
1566
+ }
1567
+ else if (cmd === 'statement') {
1568
+ p.statement = (0, tokenize_2.stripWrapping)(inner[j++]);
1569
+ }
1570
+ else if (cmd === 'verified_by') {
1571
+ p.verifiedBy = readIdList(inner[j++]);
1572
+ }
1573
+ else if (cmd === 'source') {
1574
+ p.source = (0, field_parser_1.readSource)((0, tokenize_2.unwrapBlock)(inner[j++]));
1575
+ }
1576
+ else {
1577
+ (0, tokenize_2.unwrapBlock)(inner[j++]);
1578
+ }
1579
+ }
1580
+ out.push(p);
1581
+ }
1582
+ return out;
1583
+ }
1584
+ /** A promise carrying nothing but its prose statement (the shorthand form). */
1585
+ function isStatementOnlyPromise(p) {
1586
+ return (p.id === '' &&
1587
+ !p.target &&
1588
+ !p.level &&
1589
+ !p.conditions &&
1590
+ p.verifiedBy.length === 0 &&
1591
+ !p.source);
1592
+ }
1593
+ function parseSubjectIs(block, result) {
1594
+ const t = (0, tokenize_1.default)(block);
1595
+ let i = 0;
1596
+ while (i < t.length) {
1597
+ const cmd = t[i++];
1598
+ if (i >= t.length) {
1599
+ break;
1600
+ }
1601
+ if (cmd === 'metadata') {
1602
+ result.is.metadata = readStringMap((0, tokenize_2.unwrapBlock)(t[i++]));
1603
+ }
1604
+ else if (cmd === 'provenance') {
1605
+ result.is.provenance = readStringMap((0, tokenize_2.unwrapBlock)(t[i++]));
1606
+ }
1607
+ else if (cmd === 'structure') {
1608
+ result.is.structure = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
1609
+ }
1610
+ else if (cmd === 'design_parameters') {
1611
+ result.is.designParameters = readValueMap((0, tokenize_2.unwrapBlock)(t[i++]));
1612
+ }
1613
+ else if (cmd === 'designed_conditions') {
1614
+ result.is.designedConditions = readStringMap((0, tokenize_2.unwrapBlock)(t[i++]));
1615
+ }
1616
+ else if (cmd === 'promises') {
1617
+ result.is.promises = readPromises((0, tokenize_2.unwrapBlock)(t[i++]));
1618
+ }
1619
+ else if (cmd === 'artifacts') {
1620
+ result.is.artifacts = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
1621
+ }
1622
+ else if (cmd === 'endpoint') {
1623
+ // endpoint <id> { … } (TODO.roadmap/32) — the declared API surface.
1624
+ const endpointId = (0, field_parser_1.stripColon)(t[i++] ?? '');
1625
+ const body = i < t.length ? (0, tokenize_2.unwrapBlock)(t[i++]) : '';
1626
+ if (endpointId) {
1627
+ result.is.endpoints.push((0, twin_1.parseEndpoint)(endpointId, body));
1628
+ }
1629
+ }
1630
+ else if (cmd === 'composed_of') {
1631
+ // composed_of { … } (TODO.integration/14) — the composition facet
1632
+ // of a composite subject.
1633
+ result.is.composedOf = (0, composition_1.parseComposedOf)((0, tokenize_2.unwrapBlock)(t[i++] ?? ''));
1634
+ }
1635
+ else {
1636
+ i = recordMisplaced(result, 'is', cmd, t, i);
1637
+ }
1638
+ }
1639
+ }
1640
+ function parseSubjectHas(block, result) {
1641
+ const t = (0, tokenize_1.default)(block);
1642
+ let i = 0;
1643
+ while (i < t.length) {
1644
+ const cmd = t[i++];
1645
+ if (i >= t.length) {
1646
+ break;
1647
+ }
1648
+ if (cmd === 'attributes') {
1649
+ result.has.attributes = readValueMap((0, tokenize_2.unwrapBlock)(t[i++]));
1650
+ }
1651
+ else if (cmd === 'dimensions') {
1652
+ result.has.dimensions = readDimensionMap((0, tokenize_2.unwrapBlock)(t[i++]));
1653
+ }
1654
+ else if (cmd === 'state') {
1655
+ result.has.state = (0, tokenize_2.stripWrapping)(t[i++]);
1656
+ }
1657
+ else if (cmd === 'characteristics') {
1658
+ result.has.characteristics = readCharacteristics((0, tokenize_2.unwrapBlock)(t[i++]));
1659
+ }
1660
+ else if (cmd === 'environmental_context') {
1661
+ result.has.environmentalContext = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
1662
+ }
1663
+ else if (cmd === 'artifact_instances') {
1664
+ result.has.artifactInstances = readStringEntries((0, tokenize_2.unwrapBlock)(t[i++]));
1665
+ }
1666
+ else if (cmd === 'serve') {
1667
+ // serve <aspect> via <operation> [{ fresh_within <duration> }]
1668
+ // (TODO.roadmap/32) — the HAS-level binding with freshness semantics.
1669
+ const read = (0, twin_1.parseServeEntry)(t, i);
1670
+ result.has.serves.push(read.binding);
1671
+ i = read.next;
1672
+ }
1673
+ else {
1674
+ i = recordMisplaced(result, 'has', cmd, t, i);
1675
+ }
1676
+ }
1677
+ }
1678
+ function parseSubjectDoes(block, result) {
1679
+ const t = (0, tokenize_1.default)(block);
1680
+ let i = 0;
1681
+ while (i < t.length) {
1682
+ const cmd = t[i++];
1683
+ if (i >= t.length) {
1684
+ break;
1685
+ }
1686
+ if (cmd === 'behavior') {
1687
+ result.does.behaviors.push((0, tokenize_2.stripWrapping)(t[i++]));
1688
+ }
1689
+ else {
1690
+ i = recordMisplaced(result, 'does', cmd, t, i);
1691
+ }
1692
+ }
1693
+ }
1694
+ const parseSubject = function (id, data) {
1695
+ const result = {
1696
+ id,
1697
+ extends: '',
1698
+ is: {
1699
+ metadata: {},
1700
+ provenance: {},
1701
+ structure: [],
1702
+ designParameters: {},
1703
+ designedConditions: {},
1704
+ promises: [],
1705
+ artifacts: [],
1706
+ endpoints: [],
1707
+ },
1708
+ has: {
1709
+ attributes: {},
1710
+ dimensions: {},
1711
+ state: '',
1712
+ characteristics: {},
1713
+ environmentalContext: [],
1714
+ artifactInstances: [],
1715
+ serves: [],
1716
+ },
1717
+ does: { behaviors: [] },
1718
+ referenceIds: [],
1719
+ misplacedAspects: [],
1720
+ };
1721
+ const t = (0, tokenize_2.tokenizePackage)(data);
1722
+ let i = 0;
1723
+ while (i < t.length) {
1724
+ const cmd = t[i++];
1725
+ if (i >= t.length) {
1726
+ break;
1727
+ }
1728
+ if (cmd === 'extends') {
1729
+ result.extends = (0, tokenize_2.stripWrapping)(t[i++]);
1730
+ }
1731
+ else if (cmd === 'is') {
1732
+ parseSubjectIs((0, tokenize_2.unwrapBlock)(t[i++]), result);
1733
+ }
1734
+ else if (cmd === 'has') {
1735
+ parseSubjectHas((0, tokenize_2.unwrapBlock)(t[i++]), result);
1736
+ }
1737
+ else if (cmd === 'does') {
1738
+ parseSubjectDoes((0, tokenize_2.unwrapBlock)(t[i++]), result);
1739
+ }
1740
+ else if (cmd === 'reference') {
1741
+ result.referenceIds = readReference(t[i++]);
1742
+ }
1743
+ else {
1744
+ (0, tokenize_2.unwrapBlock)(t[i++]);
1745
+ }
1746
+ }
1747
+ return ctx => {
1748
+ ctx.subjects[id] = result;
1749
+ return ctx;
1750
+ };
1751
+ };
1752
+ // ── subject extends resolution ───────────────────────────────────────
1753
+ /**
1754
+ * Merge PARENT into CHILD per aspect-kind rules (TODO.roadmap/01): maps
1755
+ * merge by key (child wins on conflict), lists append (parent entries
1756
+ * first, then child's), scalars override (child's non-empty value wins).
1757
+ * referenceIds and misplacedAspects are NOT merged: references stay the
1758
+ * declaring subject's own, and misplaced aspects are parse-time lint
1759
+ * capture the linter already sees on the parent itself.
1760
+ */
1761
+ function mergeSubject(parent, child) {
1762
+ return {
1763
+ id: child.id,
1764
+ // The extends link is consumed by the merge — the resolved subject is
1765
+ // self-contained, so a dump→load cycle can never re-merge (list
1766
+ // aspects would duplicate). Unmerged links keep `extends` (below).
1767
+ extends: '',
1768
+ is: {
1769
+ metadata: { ...parent.is.metadata, ...child.is.metadata },
1770
+ provenance: { ...parent.is.provenance, ...child.is.provenance },
1771
+ structure: [...parent.is.structure, ...child.is.structure],
1772
+ designParameters: {
1773
+ ...parent.is.designParameters,
1774
+ ...child.is.designParameters,
1775
+ },
1776
+ designedConditions: {
1777
+ ...parent.is.designedConditions,
1778
+ ...child.is.designedConditions,
1779
+ },
1780
+ promises: [...parent.is.promises, ...child.is.promises],
1781
+ artifacts: [...parent.is.artifacts, ...child.is.artifacts],
1782
+ endpoints: [...parent.is.endpoints, ...child.is.endpoints],
1783
+ // The composition facet: the child's declaration wins when present
1784
+ // (a composite refines its composition; the parent's carries
1785
+ // through unchanged otherwise).
1786
+ ...(child.is.composedOf
1787
+ ? { composedOf: child.is.composedOf }
1788
+ : parent.is.composedOf
1789
+ ? { composedOf: parent.is.composedOf }
1790
+ : {}),
1791
+ },
1792
+ has: {
1793
+ attributes: { ...parent.has.attributes, ...child.has.attributes },
1794
+ dimensions: { ...parent.has.dimensions, ...child.has.dimensions },
1795
+ state: child.has.state || parent.has.state,
1796
+ characteristics: {
1797
+ ...parent.has.characteristics,
1798
+ ...child.has.characteristics,
1799
+ },
1800
+ environmentalContext: [
1801
+ ...parent.has.environmentalContext,
1802
+ ...child.has.environmentalContext,
1803
+ ],
1804
+ artifactInstances: [
1805
+ ...parent.has.artifactInstances,
1806
+ ...child.has.artifactInstances,
1807
+ ],
1808
+ serves: [...parent.has.serves, ...child.has.serves],
1809
+ },
1810
+ does: { behaviors: [...parent.does.behaviors, ...child.does.behaviors] },
1811
+ referenceIds: child.referenceIds,
1812
+ misplacedAspects: child.misplacedAspects,
1813
+ };
1814
+ }
1815
+ /**
1816
+ * Resolve a subject's `extends` chain: merge each subject with its
1817
+ * parent from ctx.subjects, recursively when the parent itself extends.
1818
+ * Pure — parents are read from the raw parse table and never mutated
1819
+ * (several subjects may extend the same parent). Lenient links:
1820
+ * - missing parent → the subject is returned unmerged (the lint rule
1821
+ * subject-extends-resolves reports it);
1822
+ * - cycle → the visited set breaks the cyclic LINK (treated like a
1823
+ * missing parent); acyclic prefixes still merge, so resolution
1824
+ * always terminates.
1825
+ */
1826
+ function resolveSubject(ctx, item) {
1827
+ const chain = (s, visited) => {
1828
+ const parentId = s.extends;
1829
+ if (!parentId || visited.has(parentId)) {
1830
+ return s;
1831
+ }
1832
+ const parent = ctx.subjects[parentId];
1833
+ if (!parent) {
1834
+ return s;
1835
+ }
1836
+ visited.add(parentId);
1837
+ return mergeSubject(chain(parent, visited), s);
1838
+ };
1839
+ return chain(item, new Set([item.id]));
1840
+ }
1841
+ // ── subject dumpers ──────────────────────────────────────────────────
1842
+ function dumpSubjectStringMap(keyword, map) {
1843
+ const keys = Object.keys(map);
1844
+ if (keys.length === 0) {
1845
+ return '';
1846
+ }
1847
+ return (' ' +
1848
+ keyword +
1849
+ ' { ' +
1850
+ keys.map(k => k + ' ' + (0, field_parser_1.dumpBareSafe)(map[k])).join(' ') +
1851
+ ' }\n');
1852
+ }
1853
+ function dumpSubjectValueMap(keyword, map) {
1854
+ const keys = Object.keys(map);
1855
+ if (keys.length === 0) {
1856
+ return '';
1857
+ }
1858
+ return (' ' +
1859
+ keyword +
1860
+ ' { ' +
1861
+ // Values are free-form qualifiers — route through dumpBareSafe so
1862
+ // quotes/braces/whitespace can't break re-parse (same as
1863
+ // dumpSubjectStringMap).
1864
+ keys
1865
+ .map(k => k + ' :' + (map[k] ? ' ' + (0, field_parser_1.dumpBareSafe)(map[k]) : ''))
1866
+ .join(' ') +
1867
+ ' }\n');
1868
+ }
1869
+ function dumpSubjectEntries(keyword, entries) {
1870
+ if (entries.length === 0) {
1871
+ return '';
1872
+ }
1873
+ return (' ' + keyword + ' { ' + entries.map(field_parser_1.dumpBareSafe).join(' ') + ' }\n');
1874
+ }
1875
+ function dumpSubjectDimensions(map) {
1876
+ const keys = Object.keys(map);
1877
+ if (keys.length === 0) {
1878
+ return '';
1879
+ }
1880
+ return (' dimensions { ' +
1881
+ keys.map(k => k + ' in { ' + map[k].join(', ') + ' }').join(' ') +
1882
+ ' }\n');
1883
+ }
1884
+ /** Derivations emit bare when ocl{…}/single-token, quoted otherwise. */
1885
+ function dumpSubjectDerivation(d) {
1886
+ return /^ocl\{[\s\S]*\}$/.test(d) ? d : (0, field_parser_1.dumpBareSafe)(d);
1887
+ }
1888
+ /** Dump one promise level (TODO.roadmap/08) — the inverse of readPromiseLevel. */
1889
+ function dumpPromiseLevel(level) {
1890
+ if (level.kind === 'symbolic') {
1891
+ return 'symbolic ' + (0, field_parser_1.dumpBareSafe)(level.symbolic ?? '');
1892
+ }
1893
+ if (level.kind === 'range') {
1894
+ let inner = '';
1895
+ if (level.min !== undefined) {
1896
+ inner += 'min ' + (0, quantity_1.dumpScalarToken)(level.min) + ' ';
1897
+ }
1898
+ if (level.max !== undefined) {
1899
+ inner += 'max ' + (0, quantity_1.dumpScalarToken)(level.max) + ' ';
1900
+ }
1901
+ if (level.unit) {
1902
+ inner += 'unit "' + (0, tokenize_2.escapeString)(level.unit) + '"';
1903
+ }
1904
+ return 'range { ' + inner.trimEnd() + ' }';
1905
+ }
1906
+ return (0, quantity_1.dumpQuantityBlock)(level.quantity ?? { value: '' });
1907
+ }
1908
+ /**
1909
+ * Dump is.promises (TODO.roadmap/08). Byte-compat with the legacy string
1910
+ * list: a block of statement-only entries keeps the single-line form
1911
+ * (`promises { "a" "b" }`); any rich entry switches the block to the
1912
+ * multi-line form, one entry per `<id> { … }` block (statement-only
1913
+ * entries stay quoted strings on their own lines).
1914
+ */
1915
+ function dumpSubjectPromises(promises) {
1916
+ if (promises.length === 0) {
1917
+ return '';
1918
+ }
1919
+ if (promises.every(isStatementOnlyPromise)) {
1920
+ return (' promises { ' +
1921
+ promises.map(p => (0, field_parser_1.dumpBareSafe)(p.statement)).join(' ') +
1922
+ ' }\n');
1923
+ }
1924
+ let out = ' promises {\n';
1925
+ for (const p of promises) {
1926
+ if (isStatementOnlyPromise(p)) {
1927
+ out += ' ' + (0, field_parser_1.dumpBareSafe)(p.statement) + '\n';
1928
+ continue;
1929
+ }
1930
+ out += ' ' + (0, field_parser_1.dumpBareSafe)(p.id) + ' {\n';
1931
+ if (p.target) {
1932
+ out += ' target ' + (0, field_parser_1.dumpBareSafe)(p.target) + '\n';
1933
+ }
1934
+ if (p.level) {
1935
+ out += ' level ' + dumpPromiseLevel(p.level) + '\n';
1936
+ }
1937
+ if (p.conditions) {
1938
+ out += ' conditions ' + dumpSubjectDerivation(p.conditions) + '\n';
1939
+ }
1940
+ if (p.statement) {
1941
+ out += ' statement "' + (0, tokenize_2.escapeString)(p.statement) + '"\n';
1942
+ }
1943
+ out += dumpIdList('verified_by', p.verifiedBy, ' ');
1944
+ out += dumpSource('source', p.source ?? null, ' ');
1945
+ out += ' }\n';
1946
+ }
1947
+ out += ' }\n';
1948
+ return out;
1949
+ }
1950
+ function dumpSubjectCharacteristics(map) {
1951
+ const keys = Object.keys(map);
1952
+ if (keys.length === 0) {
1953
+ return '';
1954
+ }
1955
+ let out = ' characteristics {\n';
1956
+ for (const k of keys) {
1957
+ const c = map[k];
1958
+ const rich = c.behavior ||
1959
+ c.quantityKind ||
1960
+ c.unit ||
1961
+ (c.source && (c.source.doc || c.source.clause));
1962
+ if (rich) {
1963
+ // Block form (TODO.roadmap/10) — the full register entry.
1964
+ out += ' ' + k + ' {\n';
1965
+ if (c.symbol) {
1966
+ out += ' symbol "' + (0, tokenize_2.escapeString)(c.symbol) + '"\n';
1967
+ }
1968
+ if (c.derivation) {
1969
+ out +=
1970
+ ' derivation ' + dumpSubjectDerivation(c.derivation) + '\n';
1971
+ }
1972
+ if (c.behavior) {
1973
+ out += ' behavior ' + (0, field_parser_1.dumpBareSafe)(c.behavior) + '\n';
1974
+ }
1975
+ if (c.quantityKind) {
1976
+ out += ' quantity_kind ' + (0, field_parser_1.dumpBareSafe)(c.quantityKind) + '\n';
1977
+ }
1978
+ if (c.unit) {
1979
+ out += ' unit "' + (0, tokenize_2.escapeString)(c.unit) + '"\n';
1980
+ }
1981
+ out += dumpSource('source', c.source ?? null, ' ');
1982
+ out += ' }\n';
1983
+ continue;
1984
+ }
1985
+ out += ' ' + k + (c.symbol ? ' ' + c.symbol : '');
1986
+ if (c.derivation) {
1987
+ out += ' = ' + dumpSubjectDerivation(c.derivation);
1988
+ }
1989
+ out += '\n';
1990
+ }
1991
+ out += ' }\n';
1992
+ return out;
1993
+ }
1994
+ /** Dump is.endpoints (TODO.roadmap/32) — one `endpoint <id> { … }` block per
1995
+ * declared endpoint, after the other IS aspects. */
1996
+ function dumpSubjectEndpoints(endpoints) {
1997
+ let out = '';
1998
+ for (const e of endpoints) {
1999
+ out += (0, twin_1.dumpEndpoint)(e, ' ');
2000
+ }
2001
+ return out;
2002
+ }
2003
+ /** Dump has.serves (TODO.roadmap/32) — one `serve … via …` line per binding. */
2004
+ function dumpSubjectServes(serves) {
2005
+ let out = '';
2006
+ for (const b of serves) {
2007
+ out += (0, twin_1.dumpServe)(b, ' ');
2008
+ }
2009
+ return out;
2010
+ }
2011
+ const dumpSubject = function (s) {
2012
+ let out = 'subject ' + s.id + ' {\n';
2013
+ if (s.extends) {
2014
+ out += ' extends ' + s.extends + '\n';
2015
+ }
2016
+ const isBody = dumpSubjectStringMap('metadata', s.is.metadata) +
2017
+ dumpSubjectStringMap('provenance', s.is.provenance) +
2018
+ dumpSubjectEntries('structure', s.is.structure) +
2019
+ dumpSubjectValueMap('design_parameters', s.is.designParameters) +
2020
+ dumpSubjectStringMap('designed_conditions', s.is.designedConditions) +
2021
+ dumpSubjectPromises(s.is.promises) +
2022
+ dumpSubjectEntries('artifacts', s.is.artifacts) +
2023
+ dumpSubjectEndpoints(s.is.endpoints) +
2024
+ (s.is.composedOf ? (0, composition_1.dumpComposedOf)(s.is.composedOf, ' ') : '');
2025
+ if (isBody) {
2026
+ out += ' is {\n' + isBody + ' }\n';
2027
+ }
2028
+ const hasBody = dumpSubjectValueMap('attributes', s.has.attributes) +
2029
+ dumpSubjectDimensions(s.has.dimensions) +
2030
+ (s.has.state ? ' state ' + (0, field_parser_1.dumpBareSafe)(s.has.state) + '\n' : '') +
2031
+ dumpSubjectCharacteristics(s.has.characteristics) +
2032
+ dumpSubjectEntries('environmental_context', s.has.environmentalContext) +
2033
+ dumpSubjectEntries('artifact_instances', s.has.artifactInstances) +
2034
+ dumpSubjectServes(s.has.serves);
2035
+ if (hasBody) {
2036
+ out += ' has {\n' + hasBody + ' }\n';
2037
+ }
2038
+ let doesBody = '';
2039
+ for (const b of s.does.behaviors) {
2040
+ doesBody += ' behavior ' + (0, field_parser_1.dumpBareSafe)(b) + '\n';
2041
+ }
2042
+ if (doesBody) {
2043
+ out += ' does {\n' + doesBody + ' }\n';
2044
+ }
2045
+ out += dumpIdList('reference', s.referenceIds, ' ');
2046
+ out += '}\n';
2047
+ return out;
2048
+ };
2049
+ // ── construct registry entries ───────────────────────────────────────
2050
+ exports.instrumentConstruct = {
2051
+ keyword: 'instrument',
2052
+ field: 'instruments',
2053
+ takesID: true,
2054
+ parse: parseInstrument,
2055
+ dump: dumpInstrument,
2056
+ };
2057
+ exports.attributeDefinitionConstruct = {
2058
+ keyword: 'attribute_definition',
2059
+ field: 'attributeDefinitions',
2060
+ takesID: true,
2061
+ parse: parseAttributeDefinition,
2062
+ dump: dumpAttributeDefinition,
2063
+ };
2064
+ exports.capabilityConstruct = {
2065
+ keyword: 'capability',
2066
+ field: 'capabilities',
2067
+ takesID: true,
2068
+ parse: parseCapability,
2069
+ dump: dumpCapability,
2070
+ };
2071
+ exports.behaviorConstruct = {
2072
+ keyword: 'behavior',
2073
+ field: 'behaviors',
2074
+ takesID: true,
2075
+ parse: parseBehavior,
2076
+ dump: dumpBehavior,
2077
+ };
2078
+ exports.conditionSetConstruct = {
2079
+ keyword: 'condition_set',
2080
+ field: 'conditionSets',
2081
+ takesID: true,
2082
+ parse: parseConditionSet,
2083
+ dump: dumpConditionSet,
2084
+ };
2085
+ exports.subjectConstruct = {
2086
+ keyword: 'subject',
2087
+ field: 'subjects',
2088
+ takesID: true,
2089
+ parse: parseSubject,
2090
+ resolve: resolveSubject,
2091
+ dump: dumpSubject,
2092
+ };
2093
+ //# sourceMappingURL=subject.js.map