@driftsys/markspec 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/esm/ast/build.d.ts.map +1 -1
  2. package/esm/ast/build.js +19 -5
  3. package/esm/ast/equivalence.js +14 -2
  4. package/esm/ast/nodes.d.ts +15 -3
  5. package/esm/ast/nodes.d.ts.map +1 -1
  6. package/esm/compiler/inverses.d.ts.map +1 -1
  7. package/esm/compiler/inverses.js +18 -3
  8. package/esm/compiler/mod.d.ts +34 -1
  9. package/esm/compiler/mod.d.ts.map +1 -1
  10. package/esm/compiler/mod.js +112 -48
  11. package/esm/compiler/schema.d.ts +3 -2
  12. package/esm/compiler/schema.d.ts.map +1 -1
  13. package/esm/compiler/schema.js +6 -3
  14. package/esm/criteria/scenarios.d.ts +55 -0
  15. package/esm/criteria/scenarios.d.ts.map +1 -0
  16. package/esm/criteria/scenarios.js +133 -0
  17. package/esm/discovery/mod.d.ts +20 -1
  18. package/esm/discovery/mod.d.ts.map +1 -1
  19. package/esm/discovery/mod.js +105 -17
  20. package/esm/formatter/entry_body.d.ts +8 -5
  21. package/esm/formatter/entry_body.d.ts.map +1 -1
  22. package/esm/formatter/entry_body.js +12 -8
  23. package/esm/formatter/feature_file.d.ts +40 -0
  24. package/esm/formatter/feature_file.d.ts.map +1 -0
  25. package/esm/formatter/feature_file.js +88 -0
  26. package/esm/formatter/mod.d.ts +21 -2
  27. package/esm/formatter/mod.d.ts.map +1 -1
  28. package/esm/formatter/mod.js +64 -22
  29. package/esm/gates/mod.d.ts +2 -2
  30. package/esm/gates/mod.d.ts.map +1 -1
  31. package/esm/gates/mod.js +17 -2
  32. package/esm/gherkin/load.d.ts +35 -0
  33. package/esm/gherkin/load.d.ts.map +1 -0
  34. package/esm/gherkin/load.js +39 -0
  35. package/esm/gherkin/parse.d.ts +11 -0
  36. package/esm/gherkin/parse.d.ts.map +1 -0
  37. package/esm/gherkin/parse.js +311 -0
  38. package/esm/gherkin/position.d.ts +23 -0
  39. package/esm/gherkin/position.d.ts.map +1 -0
  40. package/esm/gherkin/position.js +21 -0
  41. package/esm/gherkin/procedure.d.ts +76 -0
  42. package/esm/gherkin/procedure.d.ts.map +1 -0
  43. package/esm/gherkin/procedure.js +164 -0
  44. package/esm/gherkin/project.d.ts +35 -0
  45. package/esm/gherkin/project.d.ts.map +1 -0
  46. package/esm/gherkin/project.js +64 -0
  47. package/esm/gherkin/role.d.ts +23 -0
  48. package/esm/gherkin/role.d.ts.map +1 -0
  49. package/esm/gherkin/role.js +28 -0
  50. package/esm/gherkin/types.d.ts +118 -0
  51. package/esm/gherkin/types.d.ts.map +1 -0
  52. package/esm/gherkin/types.js +12 -0
  53. package/esm/lock/acquire_compile.d.ts +12 -4
  54. package/esm/lock/acquire_compile.d.ts.map +1 -1
  55. package/esm/lock/acquire_compile.js +15 -5
  56. package/esm/lock/canonical_edges.d.ts +6 -2
  57. package/esm/lock/canonical_edges.d.ts.map +1 -1
  58. package/esm/lock/canonical_edges.js +10 -3
  59. package/esm/lock/model.d.ts +5 -0
  60. package/esm/lock/model.d.ts.map +1 -1
  61. package/esm/lock/parser.d.ts.map +1 -1
  62. package/esm/lock/parser.js +2 -0
  63. package/esm/lock/resolve.d.ts +6 -2
  64. package/esm/lock/resolve.d.ts.map +1 -1
  65. package/esm/lock/resolve.js +36 -4
  66. package/esm/lock/serializer.d.ts.map +1 -1
  67. package/esm/lock/serializer.js +7 -1
  68. package/esm/mod.d.ts +23 -6
  69. package/esm/mod.d.ts.map +1 -1
  70. package/esm/mod.js +18 -5
  71. package/esm/model/mod.d.ts +42 -1
  72. package/esm/model/mod.d.ts.map +1 -1
  73. package/esm/model/mod.js +1 -1
  74. package/esm/model/relations.d.ts +9 -0
  75. package/esm/model/relations.d.ts.map +1 -1
  76. package/esm/model/relations.js +16 -1
  77. package/esm/parser/attributes.d.ts +82 -3
  78. package/esm/parser/attributes.d.ts.map +1 -1
  79. package/esm/parser/attributes.js +199 -32
  80. package/esm/parser/body_tokens.d.ts +1 -1
  81. package/esm/parser/body_tokens.d.ts.map +1 -1
  82. package/esm/parser/body_tokens.js +49 -35
  83. package/esm/parser/feature_file.d.ts +116 -0
  84. package/esm/parser/feature_file.d.ts.map +1 -0
  85. package/esm/parser/feature_file.js +540 -0
  86. package/esm/parser/markdown.d.ts +7 -0
  87. package/esm/parser/markdown.d.ts.map +1 -1
  88. package/esm/parser/markdown.js +129 -40
  89. package/esm/parser/mod.d.ts +18 -0
  90. package/esm/parser/mod.d.ts.map +1 -1
  91. package/esm/parser/mod.js +51 -0
  92. package/esm/parser/translate.d.ts.map +1 -1
  93. package/esm/parser/translate.js +5 -0
  94. package/esm/refs/mod.d.ts +2 -1
  95. package/esm/refs/mod.d.ts.map +1 -1
  96. package/esm/refs/mod.js +12 -4
  97. package/esm/refs/split.d.ts +58 -0
  98. package/esm/refs/split.d.ts.map +1 -0
  99. package/esm/refs/split.js +137 -0
  100. package/esm/reporter/mod.d.ts +7 -0
  101. package/esm/reporter/mod.d.ts.map +1 -1
  102. package/esm/reporter/mod.js +113 -3
  103. package/esm/validator/attributes.d.ts.map +1 -1
  104. package/esm/validator/attributes.js +4 -1
  105. package/esm/validator/block_role.d.ts +40 -0
  106. package/esm/validator/block_role.d.ts.map +1 -0
  107. package/esm/validator/block_role.js +109 -0
  108. package/esm/validator/feature_ac.d.ts.map +1 -1
  109. package/esm/validator/feature_ac.js +6 -1
  110. package/esm/validator/feature_parse.d.ts +35 -0
  111. package/esm/validator/feature_parse.d.ts.map +1 -0
  112. package/esm/validator/feature_parse.js +69 -0
  113. package/esm/validator/locators.d.ts +36 -0
  114. package/esm/validator/locators.d.ts.map +1 -0
  115. package/esm/validator/locators.js +184 -0
  116. package/esm/validator/mod.d.ts +10 -1
  117. package/esm/validator/mod.d.ts.map +1 -1
  118. package/esm/validator/mod.js +38 -14
  119. package/esm/validator/normalize.d.ts.map +1 -1
  120. package/esm/validator/normalize.js +8 -3
  121. package/esm/validator/per_type_attrs.d.ts +3 -3
  122. package/esm/validator/per_type_attrs.js +3 -3
  123. package/esm/validator/pipeline.d.ts +4 -12
  124. package/esm/validator/pipeline.d.ts.map +1 -1
  125. package/esm/validator/pipeline.js +24 -5
  126. package/esm/validator/procedure.d.ts +22 -0
  127. package/esm/validator/procedure.d.ts.map +1 -0
  128. package/esm/validator/procedure.js +58 -0
  129. package/esm/validator/trace_types.d.ts.map +1 -1
  130. package/esm/validator/trace_types.js +4 -3
  131. package/esm/validator/traceability.d.ts.map +1 -1
  132. package/esm/validator/traceability.js +4 -1
  133. package/esm/validator/type_resolution.d.ts +5 -3
  134. package/esm/validator/type_resolution.d.ts.map +1 -1
  135. package/esm/validator/type_resolution.js +14 -2
  136. package/esm/validator/types.d.ts +11 -0
  137. package/esm/validator/types.d.ts.map +1 -1
  138. package/esm/validator/types.js +26 -4
  139. package/esm/validator/uxil_family.d.ts +1 -1
  140. package/package.json +3 -1
  141. package/script/ast/build.d.ts.map +1 -1
  142. package/script/ast/build.js +19 -5
  143. package/script/ast/equivalence.js +14 -2
  144. package/script/ast/nodes.d.ts +15 -3
  145. package/script/ast/nodes.d.ts.map +1 -1
  146. package/script/compiler/inverses.d.ts.map +1 -1
  147. package/script/compiler/inverses.js +18 -3
  148. package/script/compiler/mod.d.ts +34 -1
  149. package/script/compiler/mod.d.ts.map +1 -1
  150. package/script/compiler/mod.js +110 -46
  151. package/script/compiler/schema.d.ts +3 -2
  152. package/script/compiler/schema.d.ts.map +1 -1
  153. package/script/compiler/schema.js +6 -3
  154. package/script/criteria/scenarios.d.ts +55 -0
  155. package/script/criteria/scenarios.d.ts.map +1 -0
  156. package/script/criteria/scenarios.js +139 -0
  157. package/script/discovery/mod.d.ts +20 -1
  158. package/script/discovery/mod.d.ts.map +1 -1
  159. package/script/discovery/mod.js +106 -17
  160. package/script/formatter/entry_body.d.ts +8 -5
  161. package/script/formatter/entry_body.d.ts.map +1 -1
  162. package/script/formatter/entry_body.js +12 -8
  163. package/script/formatter/feature_file.d.ts +40 -0
  164. package/script/formatter/feature_file.d.ts.map +1 -0
  165. package/script/formatter/feature_file.js +92 -0
  166. package/script/formatter/mod.d.ts +21 -2
  167. package/script/formatter/mod.d.ts.map +1 -1
  168. package/script/formatter/mod.js +63 -21
  169. package/script/gates/mod.d.ts +2 -2
  170. package/script/gates/mod.d.ts.map +1 -1
  171. package/script/gates/mod.js +17 -2
  172. package/script/gherkin/load.d.ts +35 -0
  173. package/script/gherkin/load.d.ts.map +1 -0
  174. package/script/gherkin/load.js +76 -0
  175. package/script/gherkin/parse.d.ts +11 -0
  176. package/script/gherkin/parse.d.ts.map +1 -0
  177. package/script/gherkin/parse.js +314 -0
  178. package/script/gherkin/position.d.ts +23 -0
  179. package/script/gherkin/position.d.ts.map +1 -0
  180. package/script/gherkin/position.js +24 -0
  181. package/script/gherkin/procedure.d.ts +76 -0
  182. package/script/gherkin/procedure.d.ts.map +1 -0
  183. package/script/gherkin/procedure.js +169 -0
  184. package/script/gherkin/project.d.ts +35 -0
  185. package/script/gherkin/project.d.ts.map +1 -0
  186. package/script/gherkin/project.js +67 -0
  187. package/script/gherkin/role.d.ts +23 -0
  188. package/script/gherkin/role.d.ts.map +1 -0
  189. package/script/gherkin/role.js +31 -0
  190. package/script/gherkin/types.d.ts +118 -0
  191. package/script/gherkin/types.d.ts.map +1 -0
  192. package/script/gherkin/types.js +13 -0
  193. package/script/lock/acquire_compile.d.ts +12 -4
  194. package/script/lock/acquire_compile.d.ts.map +1 -1
  195. package/script/lock/acquire_compile.js +15 -5
  196. package/script/lock/canonical_edges.d.ts +6 -2
  197. package/script/lock/canonical_edges.d.ts.map +1 -1
  198. package/script/lock/canonical_edges.js +10 -3
  199. package/script/lock/model.d.ts +5 -0
  200. package/script/lock/model.d.ts.map +1 -1
  201. package/script/lock/parser.d.ts.map +1 -1
  202. package/script/lock/parser.js +2 -0
  203. package/script/lock/resolve.d.ts +6 -2
  204. package/script/lock/resolve.d.ts.map +1 -1
  205. package/script/lock/resolve.js +36 -4
  206. package/script/lock/serializer.d.ts.map +1 -1
  207. package/script/lock/serializer.js +7 -1
  208. package/script/mod.d.ts +23 -6
  209. package/script/mod.d.ts.map +1 -1
  210. package/script/mod.js +45 -6
  211. package/script/model/mod.d.ts +42 -1
  212. package/script/model/mod.d.ts.map +1 -1
  213. package/script/model/mod.js +2 -1
  214. package/script/model/relations.d.ts +9 -0
  215. package/script/model/relations.d.ts.map +1 -1
  216. package/script/model/relations.js +17 -1
  217. package/script/parser/attributes.d.ts +82 -3
  218. package/script/parser/attributes.d.ts.map +1 -1
  219. package/script/parser/attributes.js +205 -33
  220. package/script/parser/body_tokens.d.ts +1 -1
  221. package/script/parser/body_tokens.d.ts.map +1 -1
  222. package/script/parser/body_tokens.js +49 -35
  223. package/script/parser/feature_file.d.ts +116 -0
  224. package/script/parser/feature_file.d.ts.map +1 -0
  225. package/script/parser/feature_file.js +548 -0
  226. package/script/parser/markdown.d.ts +7 -0
  227. package/script/parser/markdown.d.ts.map +1 -1
  228. package/script/parser/markdown.js +128 -39
  229. package/script/parser/mod.d.ts +18 -0
  230. package/script/parser/mod.d.ts.map +1 -1
  231. package/script/parser/mod.js +52 -1
  232. package/script/parser/translate.d.ts.map +1 -1
  233. package/script/parser/translate.js +5 -0
  234. package/script/refs/mod.d.ts +2 -1
  235. package/script/refs/mod.d.ts.map +1 -1
  236. package/script/refs/mod.js +12 -4
  237. package/script/refs/split.d.ts +58 -0
  238. package/script/refs/split.d.ts.map +1 -0
  239. package/script/refs/split.js +145 -0
  240. package/script/reporter/mod.d.ts +7 -0
  241. package/script/reporter/mod.d.ts.map +1 -1
  242. package/script/reporter/mod.js +113 -3
  243. package/script/validator/attributes.d.ts.map +1 -1
  244. package/script/validator/attributes.js +4 -1
  245. package/script/validator/block_role.d.ts +40 -0
  246. package/script/validator/block_role.d.ts.map +1 -0
  247. package/script/validator/block_role.js +112 -0
  248. package/script/validator/feature_ac.d.ts.map +1 -1
  249. package/script/validator/feature_ac.js +6 -1
  250. package/script/validator/feature_parse.d.ts +35 -0
  251. package/script/validator/feature_parse.d.ts.map +1 -0
  252. package/script/validator/feature_parse.js +73 -0
  253. package/script/validator/locators.d.ts +36 -0
  254. package/script/validator/locators.d.ts.map +1 -0
  255. package/script/validator/locators.js +188 -0
  256. package/script/validator/mod.d.ts +10 -1
  257. package/script/validator/mod.d.ts.map +1 -1
  258. package/script/validator/mod.js +38 -14
  259. package/script/validator/normalize.d.ts.map +1 -1
  260. package/script/validator/normalize.js +8 -3
  261. package/script/validator/per_type_attrs.d.ts +3 -3
  262. package/script/validator/per_type_attrs.js +3 -3
  263. package/script/validator/pipeline.d.ts +4 -12
  264. package/script/validator/pipeline.d.ts.map +1 -1
  265. package/script/validator/pipeline.js +23 -5
  266. package/script/validator/procedure.d.ts +22 -0
  267. package/script/validator/procedure.d.ts.map +1 -0
  268. package/script/validator/procedure.js +61 -0
  269. package/script/validator/trace_types.d.ts.map +1 -1
  270. package/script/validator/trace_types.js +4 -3
  271. package/script/validator/traceability.d.ts.map +1 -1
  272. package/script/validator/traceability.js +4 -1
  273. package/script/validator/type_resolution.d.ts +5 -3
  274. package/script/validator/type_resolution.d.ts.map +1 -1
  275. package/script/validator/type_resolution.js +14 -2
  276. package/script/validator/types.d.ts +11 -0
  277. package/script/validator/types.d.ts.map +1 -1
  278. package/script/validator/types.js +27 -4
  279. package/script/validator/uxil_family.d.ts +1 -1
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @module core/gherkin/procedure
3
+ *
4
+ * Procedure view of a Gherkin scenario. This module resolves the role of each
5
+ * step (precondition, action or outcome). It is a pure function of the
6
+ * normalized AST; nothing is stored on the AST.
7
+ */
8
+ import type { FeatureAst, GherkinComment, ScenarioAst, StepAst } from "./types.js";
9
+ /** What a step does in a procedure. */
10
+ export type StepRole = "precondition" | "action" | "outcome";
11
+ /**
12
+ * Resolve the role of each step, in order.
13
+ *
14
+ * `Given` is a precondition, `When` is an action, `Then` is an outcome, and a
15
+ * `*` step is always an action. `And` and `But` take the role of the step
16
+ * before them; a first `And` or `But` is an action.
17
+ */
18
+ export declare function stepRoles(steps: readonly StepAst[]): StepRole[];
19
+ /** A step of the scenario, with its resolved role and where it came from. */
20
+ export interface ProcedureStepRef {
21
+ readonly step: StepAst;
22
+ readonly role: StepRole;
23
+ readonly origin: "background" | "scenario";
24
+ }
25
+ /** One numbered step of a procedure: its setup, actions and expected results. */
26
+ export interface ProcedureStep {
27
+ /** 1-based position in the scenario. */
28
+ readonly n: number;
29
+ /**
30
+ * The `# Step` label above the step's first line, without the `#`
31
+ * (for example `Step 1`). Absent when the step has no label. It never
32
+ * changes `n`.
33
+ */
34
+ readonly label?: string;
35
+ /** Preconditions that follow the first non-precondition step. */
36
+ readonly setup: readonly ProcedureStepRef[];
37
+ readonly actions: readonly ProcedureStepRef[];
38
+ readonly expected: readonly ProcedureStepRef[];
39
+ }
40
+ /** The procedure view of one scenario. */
41
+ export interface ScenarioProcedure {
42
+ /** Background steps, then the leading precondition steps of the scenario. */
43
+ readonly preconditions: readonly ProcedureStepRef[];
44
+ readonly steps: readonly ProcedureStep[];
45
+ /**
46
+ * `# Step` labels inside the scenario's range that do not label a step: one
47
+ * before a leading precondition or a step that does not open a procedure
48
+ * step, one with a description line between it and the step, one with no
49
+ * step after it (including one before `Examples:`), or a
50
+ * second label above the same step. Labels outside every scenario are
51
+ * reported by {@linkcode unplacedStepLabels}.
52
+ */
53
+ readonly unplacedLabels: readonly GherkinComment[];
54
+ }
55
+ /**
56
+ * Derive the procedure view of a scenario.
57
+ *
58
+ * Preconditions are the scenario's background steps followed by its leading
59
+ * precondition steps. The remaining steps are paired in order: an action after
60
+ * an expected result, or a precondition after an action or expected result,
61
+ * opens a new step. Examples of an outline are not expanded.
62
+ *
63
+ * `comments` are the block's comments. A `# Step` comment inside the
64
+ * scenario's range labels the procedure step that starts at the next step
65
+ * line; any other label is returned in `unplacedLabels`.
66
+ */
67
+ export declare function scenarioProcedure(scenario: ScenarioAst, comments?: readonly GherkinComment[]): ScenarioProcedure;
68
+ /**
69
+ * Every `# Step` label of a feature block that labels no step, each once, in
70
+ * document order. A label inside a scenario's range is unplaced when
71
+ * {@linkcode scenarioProcedure} leaves it unplaced; a label outside every
72
+ * scenario (in a Background, a Rule header, after a scenario's last step, or
73
+ * between scenarios) is always unplaced.
74
+ */
75
+ export declare function unplacedStepLabels(feature: FeatureAst): GherkinComment[];
76
+ //# sourceMappingURL=procedure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/gherkin/procedure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,OAAO,EACR,MAAM,YAAY,CAAC;AAEpB,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,QAAQ,EAAE,CAyB/D;AAED,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAAC;CAC5C;AAED,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAChD;AAED,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,cAAc,EAAE,CAAC;CACpD;AASD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,WAAW,EACrB,QAAQ,GAAE,SAAS,cAAc,EAAO,GACvC,iBAAiB,CAgFnB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,EAAE,CAiBxE"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @module core/gherkin/procedure
3
+ *
4
+ * Procedure view of a Gherkin scenario. This module resolves the role of each
5
+ * step (precondition, action or outcome). It is a pure function of the
6
+ * normalized AST; nothing is stored on the AST.
7
+ */
8
+ /**
9
+ * Resolve the role of each step, in order.
10
+ *
11
+ * `Given` is a precondition, `When` is an action, `Then` is an outcome, and a
12
+ * `*` step is always an action. `And` and `But` take the role of the step
13
+ * before them; a first `And` or `But` is an action.
14
+ */
15
+ export function stepRoles(steps) {
16
+ const roles = [];
17
+ for (const step of steps) {
18
+ switch (step.normalized) {
19
+ case "given":
20
+ roles.push("precondition");
21
+ break;
22
+ case "then":
23
+ roles.push("outcome");
24
+ break;
25
+ case "when":
26
+ case "step":
27
+ roles.push("action");
28
+ break;
29
+ case "and":
30
+ case "but":
31
+ roles.push(roles.at(-1) ?? "action");
32
+ break;
33
+ default: {
34
+ const unhandled = step.normalized;
35
+ throw new Error(`unhandled step keyword: ${unhandled}`);
36
+ }
37
+ }
38
+ }
39
+ return roles;
40
+ }
41
+ /**
42
+ * A step label comment: `#`, optional spaces, the fixed word `Step`, then
43
+ * whitespace or the end of the line. `# Step`, `# Step 2` and `#Step 2` are
44
+ * labels; `# Step-by-step`, `# Step: 1` and `# Steps 1` are not.
45
+ */
46
+ const STEP_LABEL_RE = /^#\s*Step(?:\s|$)/;
47
+ /**
48
+ * Derive the procedure view of a scenario.
49
+ *
50
+ * Preconditions are the scenario's background steps followed by its leading
51
+ * precondition steps. The remaining steps are paired in order: an action after
52
+ * an expected result, or a precondition after an action or expected result,
53
+ * opens a new step. Examples of an outline are not expanded.
54
+ *
55
+ * `comments` are the block's comments. A `# Step` comment inside the
56
+ * scenario's range labels the procedure step that starts at the next step
57
+ * line; any other label is returned in `unplacedLabels`.
58
+ */
59
+ export function scenarioProcedure(scenario, comments = []) {
60
+ // Guards a call through `Array.prototype.map`, which passes the index.
61
+ if (!Array.isArray(comments))
62
+ comments = [];
63
+ const preconditions = scenario.background.map((step) => ({
64
+ step,
65
+ role: "precondition",
66
+ origin: "background",
67
+ }));
68
+ const roles = stepRoles(scenario.steps);
69
+ let first = 0;
70
+ while (first < roles.length && roles[first] === "precondition") {
71
+ preconditions.push({
72
+ step: scenario.steps[first],
73
+ role: "precondition",
74
+ origin: "scenario",
75
+ });
76
+ first++;
77
+ }
78
+ const steps = [];
79
+ let setup = [];
80
+ let actions = [];
81
+ let expected = [];
82
+ let startIndex = first;
83
+ // Scenario step index that opens each procedure step.
84
+ const startIndexes = [];
85
+ const close = (next) => {
86
+ if (setup.length + actions.length + expected.length === 0)
87
+ return;
88
+ steps.push({ n: steps.length + 1, setup, actions, expected });
89
+ startIndexes.push(startIndex);
90
+ startIndex = next;
91
+ setup = [];
92
+ actions = [];
93
+ expected = [];
94
+ };
95
+ for (let i = first; i < roles.length; i++) {
96
+ const ref = {
97
+ step: scenario.steps[i],
98
+ role: roles[i],
99
+ origin: "scenario",
100
+ };
101
+ if (ref.role === "precondition") {
102
+ if (actions.length > 0 || expected.length > 0)
103
+ close(i);
104
+ setup.push(ref);
105
+ }
106
+ else if (ref.role === "action") {
107
+ if (expected.length > 0)
108
+ close(i);
109
+ actions.push(ref);
110
+ }
111
+ else {
112
+ expected.push(ref);
113
+ }
114
+ }
115
+ close(roles.length);
116
+ const labels = new Map();
117
+ const unplacedLabels = [];
118
+ for (const comment of comments) {
119
+ if (!STEP_LABEL_RE.test(comment.text))
120
+ continue;
121
+ if (comment.line < scenario.range.start.line ||
122
+ comment.line > scenario.range.end.line)
123
+ continue;
124
+ const next = scenario.steps.findIndex((s) => s.range.start.line > comment.line);
125
+ // Only comments and blank lines may lie between a label and its step: a
126
+ // description line after the label makes the label unplaced.
127
+ const afterDescription = comment.line > (scenario.descriptionEndLine ?? 0);
128
+ const target = next < 0 || !afterDescription
129
+ ? -1
130
+ : startIndexes.indexOf(next);
131
+ if (target < 0 || labels.has(target))
132
+ unplacedLabels.push(comment);
133
+ else
134
+ labels.set(target, comment.text.slice(1).trim());
135
+ }
136
+ return {
137
+ preconditions,
138
+ steps: steps.map((step, i) => labels.has(i) ? { ...step, label: labels.get(i) } : step),
139
+ unplacedLabels,
140
+ };
141
+ }
142
+ /**
143
+ * Every `# Step` label of a feature block that labels no step, each once, in
144
+ * document order. A label inside a scenario's range is unplaced when
145
+ * {@linkcode scenarioProcedure} leaves it unplaced; a label outside every
146
+ * scenario (in a Background, a Rule header, after a scenario's last step, or
147
+ * between scenarios) is always unplaced.
148
+ */
149
+ export function unplacedStepLabels(feature) {
150
+ const perScenario = feature.scenarios.map((scenario) => ({
151
+ scenario,
152
+ unplaced: new Set(scenarioProcedure(scenario, feature.comments).unplacedLabels),
153
+ }));
154
+ const out = [];
155
+ for (const comment of feature.comments) {
156
+ if (!STEP_LABEL_RE.test(comment.text))
157
+ continue;
158
+ const owner = perScenario.find(({ scenario }) => comment.line >= scenario.range.start.line &&
159
+ comment.line <= scenario.range.end.line);
160
+ if (!owner || owner.unplaced.has(comment))
161
+ out.push(comment);
162
+ }
163
+ return out;
164
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @module core/gherkin/project
3
+ *
4
+ * Projects the {@linkcode FeatureAst} of a whole `.feature` file onto one
5
+ * entry (epic #915 Case B, ADR-038). The entry keeps only the scenarios it
6
+ * owns, and its ranges are rebased so that line 1 is the first line of the
7
+ * owning node's span.
8
+ */
9
+ import type { FeatureAst } from "./types.js";
10
+ /** A span of file lines, 1-based and inclusive. */
11
+ export interface LineSpan {
12
+ readonly startLine: number;
13
+ readonly endLine: number;
14
+ }
15
+ /**
16
+ * Return the part of `ast` that one entry owns.
17
+ *
18
+ * - `scenarios` holds the scenarios at `scenarioIndexes`, in that order.
19
+ * - Every range is rebased: file line `span.startLine` becomes line 1.
20
+ * Inherited Background steps lie above the span and keep rebased lines
21
+ * that can be 0 or less.
22
+ * - `backgrounds` holds the Background steps that apply to the kept
23
+ * scenarios, each once, in document order.
24
+ * - `sections` and `comments` keep only the ones inside the span and
25
+ * outside every `exclude` span (the header and span of a nested node
26
+ * that is its own entry).
27
+ *
28
+ * @param ast - The normalized AST of the whole file; ranges are file lines.
29
+ * @param scenarioIndexes - Indexes into `ast.scenarios` of the owned ones.
30
+ * @param span - The file lines of the owning node.
31
+ * @param exclude - File line spans inside `span` that belong to other
32
+ * entries.
33
+ */
34
+ export declare function projectFeature(ast: FeatureAst, scenarioIndexes: readonly number[], span: LineSpan, exclude?: readonly LineSpan[]): FeatureAst;
35
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/gherkin/project.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAEV,UAAU,EAIX,MAAM,YAAY,CAAC;AAEpB,mDAAmD;AACnD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,UAAU,EACf,eAAe,EAAE,SAAS,MAAM,EAAE,EAClC,IAAI,EAAE,QAAQ,EACd,OAAO,GAAE,SAAS,QAAQ,EAAO,GAChC,UAAU,CAuCZ"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @module core/gherkin/project
3
+ *
4
+ * Projects the {@linkcode FeatureAst} of a whole `.feature` file onto one
5
+ * entry (epic #915 Case B, ADR-038). The entry keeps only the scenarios it
6
+ * owns, and its ranges are rebased so that line 1 is the first line of the
7
+ * owning node's span.
8
+ */
9
+ /**
10
+ * Return the part of `ast` that one entry owns.
11
+ *
12
+ * - `scenarios` holds the scenarios at `scenarioIndexes`, in that order.
13
+ * - Every range is rebased: file line `span.startLine` becomes line 1.
14
+ * Inherited Background steps lie above the span and keep rebased lines
15
+ * that can be 0 or less.
16
+ * - `backgrounds` holds the Background steps that apply to the kept
17
+ * scenarios, each once, in document order.
18
+ * - `sections` and `comments` keep only the ones inside the span and
19
+ * outside every `exclude` span (the header and span of a nested node
20
+ * that is its own entry).
21
+ *
22
+ * @param ast - The normalized AST of the whole file; ranges are file lines.
23
+ * @param scenarioIndexes - Indexes into `ast.scenarios` of the owned ones.
24
+ * @param span - The file lines of the owning node.
25
+ * @param exclude - File line spans inside `span` that belong to other
26
+ * entries.
27
+ */
28
+ export function projectFeature(ast, scenarioIndexes, span, exclude = []) {
29
+ const offset = span.startLine - 1;
30
+ const range = (r) => ({
31
+ start: { line: r.start.line - offset, column: r.start.column },
32
+ end: { line: r.end.line - offset, column: r.end.column },
33
+ });
34
+ const step = (s) => ({ ...s, range: range(s.range) });
35
+ const examples = (e) => ({
36
+ ...e,
37
+ range: range(e.range),
38
+ });
39
+ const scenario = (s) => ({
40
+ ...s,
41
+ ...(s.descriptionEndLine !== undefined
42
+ ? { descriptionEndLine: s.descriptionEndLine - offset }
43
+ : {}),
44
+ background: s.background.map(step),
45
+ steps: s.steps.map(step),
46
+ examples: s.examples.map(examples),
47
+ range: range(s.range),
48
+ });
49
+ const kept = scenarioIndexes.map((i) => ast.scenarios[i]);
50
+ const visible = (line) => line >= span.startLine && line <= span.endLine &&
51
+ !exclude.some((x) => line >= x.startLine && line <= x.endLine);
52
+ const background = new Set(kept.flatMap((s) => s.background));
53
+ return {
54
+ ...ast,
55
+ scenarios: kept.map(scenario),
56
+ backgrounds: ast.backgrounds.filter((s) => background.has(s)).map(step),
57
+ sections: ast.sections
58
+ .filter((s) => visible(s.range.start.line))
59
+ .map((s) => ({ ...s, range: range(s.range) })),
60
+ comments: ast.comments
61
+ .filter((c) => visible(c.line))
62
+ .map((c) => ({ ...c, line: c.line - offset })),
63
+ };
64
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @module core/gherkin/role
3
+ *
4
+ * The role of a Gherkin block follows the type of the entry that holds it
5
+ * (epic #915, ADR-038). The role is derived on demand and is not stored on
6
+ * the entry.
7
+ *
8
+ * - `criteria`: the entry is, or extends, a Requirement or a Contract. Each
9
+ * scenario is an acceptance criterion.
10
+ * - `procedure`: the entry is, or extends, Test. The block is a test
11
+ * procedure.
12
+ * - `illustration`: any other typed entry. The block is an example.
13
+ */
14
+ import type { EffectiveProfile, Entry } from "../model/mod.js";
15
+ /** What a Gherkin block means in its entry. */
16
+ export type BlockRole = "criteria" | "procedure" | "illustration";
17
+ /**
18
+ * Return the role of the Gherkin blocks of `entry`, or `undefined` when the
19
+ * entry has no resolved type. The entry is not classified here: callers
20
+ * classify it first (for example with the profile's display-ID patterns).
21
+ */
22
+ export declare function blockRole(entry: Entry, profile: EffectiveProfile | null): BlockRole | undefined;
23
+ //# sourceMappingURL=role.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.d.ts","sourceRoot":"","sources":["../../src/gherkin/role.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG/D,+CAA+C;AAC/C,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,cAAc,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,GAAG,SAAS,CAKvB"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @module core/gherkin/role
3
+ *
4
+ * The role of a Gherkin block follows the type of the entry that holds it
5
+ * (epic #915, ADR-038). The role is derived on demand and is not stored on
6
+ * the entry.
7
+ *
8
+ * - `criteria`: the entry is, or extends, a Requirement or a Contract. Each
9
+ * scenario is an acceptance criterion.
10
+ * - `procedure`: the entry is, or extends, Test. The block is a test
11
+ * procedure.
12
+ * - `illustration`: any other typed entry. The block is an example.
13
+ */
14
+ import { isCriteriaBearing, isTestEntry } from "../criteria/scenarios.js";
15
+ /**
16
+ * Return the role of the Gherkin blocks of `entry`, or `undefined` when the
17
+ * entry has no resolved type. The entry is not classified here: callers
18
+ * classify it first (for example with the profile's display-ID patterns).
19
+ */
20
+ export function blockRole(entry, profile) {
21
+ if (entry.type === undefined)
22
+ return undefined;
23
+ if (isCriteriaBearing(entry, profile))
24
+ return "criteria";
25
+ if (isTestEntry(entry, profile))
26
+ return "procedure";
27
+ return "illustration";
28
+ }
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @module core/gherkin/types
3
+ *
4
+ * Normalized AST of one Gherkin block. It is built from the parser's
5
+ * `GherkinDocument` by {@linkcode parseFeature}. Ranges are relative to the
6
+ * authored block text: line 1 is the first line of the source, and a
7
+ * synthetic `Feature:` line is not counted. Lines and columns are 1-based.
8
+ * The end column is exclusive (one past the last character). A step with a
9
+ * doc string or data table ends after its last line; a scenario ends after
10
+ * its last step or Examples row; a section covers its keyword and colon.
11
+ */
12
+ /**
13
+ * A span inside a Gherkin block, with the same shape as the body-AST
14
+ * `SourceRange` (`core/ast/nodes.ts`). It is declared here so that
15
+ * `gherkin/` does not import from `ast/`, which imports this module.
16
+ */
17
+ export interface GherkinRange {
18
+ readonly start: {
19
+ readonly line: number;
20
+ readonly column: number;
21
+ };
22
+ readonly end: {
23
+ readonly line: number;
24
+ readonly column: number;
25
+ };
26
+ }
27
+ /** Role-independent step keyword, taken from the parser's `keywordType`. */
28
+ export type StepKeyword = "given" | "when" | "then" | "and" | "but" | "step";
29
+ /** One Gherkin step. */
30
+ export interface StepAst {
31
+ /** The keyword as authored, with the trailing space removed. */
32
+ readonly keyword: string;
33
+ readonly normalized: StepKeyword;
34
+ readonly text: string;
35
+ readonly docString?: {
36
+ mediaType?: string;
37
+ content: string;
38
+ };
39
+ readonly dataTable?: readonly (readonly string[])[];
40
+ readonly range: GherkinRange;
41
+ }
42
+ /** One `Examples` table of a `Scenario Outline`. It is not expanded. */
43
+ export interface ExamplesAst {
44
+ readonly name: string;
45
+ readonly keyword: string;
46
+ readonly tags: readonly string[];
47
+ readonly header: readonly string[];
48
+ readonly rows: readonly (readonly string[])[];
49
+ readonly range: GherkinRange;
50
+ }
51
+ /** One scenario or scenario outline, with the Rules flattened away. */
52
+ export interface ScenarioAst {
53
+ /** The parser name, trimmed. It is not normalized as a locator. */
54
+ readonly name: string;
55
+ readonly keyword: string;
56
+ /** The scenario's own tags, not inherited ones. */
57
+ readonly tags: readonly string[];
58
+ readonly ruleName?: string;
59
+ readonly description: string;
60
+ /**
61
+ * 1-based block line of the last description text line. Absent when the
62
+ * scenario has no description.
63
+ */
64
+ readonly descriptionEndLine?: number;
65
+ readonly isOutline: boolean;
66
+ /** Feature background steps, then Rule background steps, in order. */
67
+ readonly background: readonly StepAst[];
68
+ readonly steps: readonly StepAst[];
69
+ readonly examples: readonly ExamplesAst[];
70
+ readonly range: GherkinRange;
71
+ }
72
+ /** A Feature, Background, Rule, Scenario or Examples keyword. */
73
+ export interface SectionAst {
74
+ readonly keyword: string;
75
+ readonly range: GherkinRange;
76
+ }
77
+ /**
78
+ * One comment line of a Gherkin block. Comments inside a doc string are part
79
+ * of its content and are not reported.
80
+ */
81
+ export interface GherkinComment {
82
+ /** 1-based block line; the synthetic `Feature:` line is not counted. */
83
+ readonly line: number;
84
+ /** The comment line trimmed, including the leading `#`. */
85
+ readonly text: string;
86
+ }
87
+ /** The normalized document of one Gherkin block. */
88
+ export interface FeatureAst {
89
+ /** Empty when the Feature line is synthetic. */
90
+ readonly name: string;
91
+ readonly keyword: string;
92
+ /** `true` when MarkSpec added the Feature line before parsing. */
93
+ readonly synthetic: boolean;
94
+ readonly language: string;
95
+ readonly description: string;
96
+ readonly tags: readonly string[];
97
+ readonly scenarios: readonly ScenarioAst[];
98
+ /**
99
+ * The steps of every Background (Feature and Rule), each once, in document
100
+ * order. A scenario's `background` repeats the ones that apply to it.
101
+ */
102
+ readonly backgrounds: readonly StepAst[];
103
+ /** Every structural keyword in document order, without the synthetic line. */
104
+ readonly sections: readonly SectionAst[];
105
+ /** Every comment line in document order, including `# language:`. */
106
+ readonly comments: readonly GherkinComment[];
107
+ }
108
+ /** Result of {@linkcode parseFeature}. */
109
+ export type FeatureParse = {
110
+ ok: true;
111
+ feature: FeatureAst;
112
+ } | {
113
+ ok: false;
114
+ line: number;
115
+ column: number;
116
+ message: string;
117
+ };
118
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/gherkin/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module core/gherkin/types
3
+ *
4
+ * Normalized AST of one Gherkin block. It is built from the parser's
5
+ * `GherkinDocument` by {@linkcode parseFeature}. Ranges are relative to the
6
+ * authored block text: line 1 is the first line of the source, and a
7
+ * synthetic `Feature:` line is not counted. Lines and columns are 1-based.
8
+ * The end column is exclusive (one past the last character). A step with a
9
+ * doc string or data table ends after its last line; a scenario ends after
10
+ * its last step or Examples row; a section covers its keyword and colon.
11
+ */
12
+ export {};
@@ -3,10 +3,11 @@
3
3
  *
4
4
  * Deterministic in-process compile of an acquired dependency tree
5
5
  * (design §4.3). Produces the same `manifest.json` + `compiled.json` layout
6
- * a published `references:` site serves, so `loadUpstreamCorpus` /
7
- * `probeCacheSnapshot` read a dependency snapshot identically to a reference
8
- * snapshot. The output is byte-reproducible from (tree, markspec version):
9
- * files are compiled in sorted, tree-relative order with no stat/git IO, so
6
+ * a published `references:` site serves, except that `compiled.json` omits
7
+ * `diagnostics` (#963). `loadUpstreamCorpus` / `probeCacheSnapshot` read a
8
+ * dependency snapshot identically to a reference snapshot, because they read
9
+ * only the entries. The output is byte-reproducible from (tree, markspec
10
+ * version): files are compiled in sorted, tree-relative order with no stat/git IO, so
10
11
  * `entry.location.file`, `properties.file.path`, and entry ordering are all
11
12
  * stable. Pure — every file touch flows through {@linkcode AcquireCompileIO}.
12
13
  */
@@ -25,6 +26,13 @@ export interface CompiledSnapshot {
25
26
  readonly compiledBytes: Uint8Array;
26
27
  readonly snapshot: string;
27
28
  }
29
+ /**
30
+ * Compile a fetched dependency tree into its upstream snapshot. The
31
+ * snapshot covers the entries, links and registry only. Validator
32
+ * diagnostics are neither hashed nor stored, so a validator change never
33
+ * moves a pin (#963). Every reader of the stored snapshot takes only its
34
+ * entries.
35
+ */
28
36
  export declare function compileAcquiredTree(treeRoot: string, io: AcquireCompileIO, release: string): Promise<CompiledSnapshot | {
29
37
  error: string;
30
38
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"acquire_compile.d.ts","sourceRoot":"","sources":["../../src/lock/acquire_compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK3E,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtE,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjE,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,gBAAgB,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA0E/C"}
1
+ {"version":3,"file":"acquire_compile.d.ts","sourceRoot":"","sources":["../../src/lock/acquire_compile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK3E,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtE,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjE,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,gBAAgB,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA8E/C"}
@@ -3,10 +3,11 @@
3
3
  *
4
4
  * Deterministic in-process compile of an acquired dependency tree
5
5
  * (design §4.3). Produces the same `manifest.json` + `compiled.json` layout
6
- * a published `references:` site serves, so `loadUpstreamCorpus` /
7
- * `probeCacheSnapshot` read a dependency snapshot identically to a reference
8
- * snapshot. The output is byte-reproducible from (tree, markspec version):
9
- * files are compiled in sorted, tree-relative order with no stat/git IO, so
6
+ * a published `references:` site serves, except that `compiled.json` omits
7
+ * `diagnostics` (#963). `loadUpstreamCorpus` / `probeCacheSnapshot` read a
8
+ * dependency snapshot identically to a reference snapshot, because they read
9
+ * only the entries. The output is byte-reproducible from (tree, markspec
10
+ * version): files are compiled in sorted, tree-relative order with no stat/git IO, so
10
11
  * `entry.location.file`, `properties.file.path`, and entry ordering are all
11
12
  * stable. Pure — every file touch flows through {@linkcode AcquireCompileIO}.
12
13
  */
@@ -19,6 +20,13 @@ import { loadToolConfig } from "../config/markspec.js";
19
20
  import { loadProfileForCommand } from "../profile/load.js";
20
21
  import { discoverFiles } from "../discovery/mod.js";
21
22
  import { sha256Bytes } from "./hash.js";
23
+ /**
24
+ * Compile a fetched dependency tree into its upstream snapshot. The
25
+ * snapshot covers the entries, links and registry only. Validator
26
+ * diagnostics are neither hashed nor stored, so a validator change never
27
+ * moves a pin (#963). Every reader of the stored snapshot takes only its
28
+ * entries.
29
+ */
22
30
  export async function compileAcquiredTree(treeRoot, io, release) {
23
31
  // Memoize by path: loadConfig, loadProfileForCommand, and loadToolConfig
24
32
  // each walk + read the same project.yaml/.markspec.yaml, so cache the
@@ -73,7 +81,9 @@ export async function compileAcquiredTree(treeRoot, io, release) {
73
81
  // probeCacheSnapshot JSON.parse it), and compact output keeps
74
82
  // `entry.location.file`'s tree-relative path adjacent to its `"file":`
75
83
  // key with no formatting-introduced variance to reason about.
76
- const compiled = serializeCompileResult(result);
84
+ // Dropping `diagnostics` here is intentional: they are neither hashed nor
85
+ // stored, so a validator change cannot move a pin (#963).
86
+ const { diagnostics: _diagnostics, ...compiled } = serializeCompileResult(result);
77
87
  const compiledBytes = new TextEncoder().encode(JSON.stringify(compiled));
78
88
  return {
79
89
  manifestJson,
@@ -13,6 +13,8 @@ export interface EdgeQuad {
13
13
  readonly source: string;
14
14
  readonly relation: string;
15
15
  readonly target: string;
16
+ /** Normalized scenario locator (#915). Absent when the value has none. */
17
+ readonly locator?: string;
16
18
  readonly provenance: "local" | "external" | "generated";
17
19
  }
18
20
  /**
@@ -21,8 +23,10 @@ export interface EdgeQuad {
21
23
  * Rules:
22
24
  * 1. Object keys sorted alphabetically.
23
25
  * 2. No insignificant whitespace.
24
- * 3. Top-level array sorted by (source, relation, target, provenance)
25
- * so input order doesn't affect output.
26
+ * 3. Top-level array sorted by (source, relation, target, locator,
27
+ * provenance) so input order doesn't affect output.
28
+ * 5. `locator` is emitted only when present, so a graph without
29
+ * locators serializes exactly as before locators existed.
26
30
  * 4. Strings JSON-escaped per RFC 8259.
27
31
  */
28
32
  export declare function canonicalEdgeJson(edges: readonly EdgeQuad[]): string;
@@ -1 +1 @@
1
- {"version":3,"file":"canonical_edges.d.ts","sourceRoot":"","sources":["../../src/lock/canonical_edges.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,+CAA+C;AAC/C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC;CACzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CASpE;AAED,iEAAiE;AACjE,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,SAAS,QAAQ,EAAE,GACzB,OAAO,CAAC,MAAM,CAAC,CAEjB"}
1
+ {"version":3,"file":"canonical_edges.d.ts","sourceRoot":"","sources":["../../src/lock/canonical_edges.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,+CAA+C;AAC/C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,GAAG,WAAW,CAAC;CACzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CASpE;AAED,iEAAiE;AACjE,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,SAAS,QAAQ,EAAE,GACzB,OAAO,CAAC,MAAM,CAAC,CAEjB"}