@intentius/chant 0.124.61 → 0.124.63

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 (234) hide show
  1. package/dist/cli/handlers/approve.d.ts +18 -0
  2. package/dist/cli/handlers/approve.d.ts.map +1 -1
  3. package/dist/cli/handlers/approve.js +142 -16
  4. package/dist/cli/handlers/plan.d.ts +10 -0
  5. package/dist/cli/handlers/plan.d.ts.map +1 -0
  6. package/dist/cli/handlers/plan.js +71 -0
  7. package/dist/cli/handlers/release.d.ts +6 -4
  8. package/dist/cli/handlers/release.d.ts.map +1 -1
  9. package/dist/cli/handlers/release.js +13 -7
  10. package/dist/cli/main.d.ts.map +1 -1
  11. package/dist/cli/main.js +34 -5
  12. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  13. package/dist/cli/mcp/workspace-tools.js +2 -1
  14. package/dist/cli/parse-args.d.ts.map +1 -1
  15. package/dist/cli/parse-args.js +31 -0
  16. package/dist/cli/registry.d.ts +13 -1
  17. package/dist/cli/registry.d.ts.map +1 -1
  18. package/dist/config.d.ts +32 -0
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/gate-decision.d.ts +1 -1
  21. package/dist/gate-decision.d.ts.map +1 -1
  22. package/dist/gate-decision.js +4 -2
  23. package/dist/gate-statement.schema.json +44 -0
  24. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
  25. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
  26. package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
  27. package/dist/lifecycle/gate-ledger.d.ts +17 -3
  28. package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
  29. package/dist/lifecycle/gate-seal.d.ts +39 -3
  30. package/dist/lifecycle/gate-seal.d.ts.map +1 -1
  31. package/dist/lifecycle/gate-seal.js +50 -10
  32. package/dist/lifecycle/gate-statement.d.ts +70 -0
  33. package/dist/lifecycle/gate-statement.d.ts.map +1 -0
  34. package/dist/lifecycle/gate-statement.js +74 -0
  35. package/dist/lifecycle/gate-webauthn.d.ts +79 -0
  36. package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
  37. package/dist/lifecycle/gate-webauthn.js +105 -0
  38. package/dist/lifecycle/git.d.ts +1 -1
  39. package/dist/lifecycle/git.d.ts.map +1 -1
  40. package/dist/lifecycle/git.js +24 -19
  41. package/dist/lifecycle/ledger-remote.d.ts +37 -0
  42. package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
  43. package/dist/lifecycle/ledger-remote.js +42 -0
  44. package/dist/lifecycle/plan-stale.d.ts +76 -0
  45. package/dist/lifecycle/plan-stale.d.ts.map +1 -0
  46. package/dist/lifecycle/plan-stale.js +121 -0
  47. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  48. package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
  49. package/dist/lifecycle/publish-credentials.js +2 -0
  50. package/dist/lifecycle/publish-declaration.d.ts +87 -0
  51. package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
  52. package/dist/lifecycle/publish-declaration.js +87 -1
  53. package/dist/lifecycle/publish-forge.d.ts +5 -1
  54. package/dist/lifecycle/publish-forge.d.ts.map +1 -1
  55. package/dist/lifecycle/publish-forge.js +14 -4
  56. package/dist/lifecycle/publish-github.d.ts +69 -0
  57. package/dist/lifecycle/publish-github.d.ts.map +1 -0
  58. package/dist/lifecycle/publish-github.js +153 -0
  59. package/dist/lifecycle/publish-homebrew.d.ts +66 -0
  60. package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
  61. package/dist/lifecycle/publish-homebrew.js +173 -0
  62. package/dist/lifecycle/publish-marketplace.d.ts +51 -0
  63. package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
  64. package/dist/lifecycle/publish-marketplace.js +254 -0
  65. package/dist/lifecycle/publish-targets.d.ts +6 -0
  66. package/dist/lifecycle/publish-targets.d.ts.map +1 -1
  67. package/dist/lifecycle/publish-targets.js +15 -0
  68. package/dist/lifecycle/publish-tauri.d.ts +61 -0
  69. package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
  70. package/dist/lifecycle/publish-tauri.js +182 -0
  71. package/dist/lifecycle/release-publish.d.ts +5 -2
  72. package/dist/lifecycle/release-publish.d.ts.map +1 -1
  73. package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
  74. package/dist/lifecycle/snapshot-store.js +17 -9
  75. package/dist/lifecycle/test-passkey.d.ts +25 -0
  76. package/dist/lifecycle/test-passkey.d.ts.map +1 -0
  77. package/dist/lifecycle/test-passkey.js +39 -0
  78. package/dist/notify.d.ts +23 -3
  79. package/dist/notify.d.ts.map +1 -1
  80. package/dist/notify.js +8 -2
  81. package/dist/notify.schema.json +12 -3
  82. package/dist/op/activities/activity-contracts.d.ts +4 -4
  83. package/dist/pr-forge.d.ts +20 -0
  84. package/dist/pr-forge.d.ts.map +1 -1
  85. package/dist/pr-forge.js +61 -2
  86. package/dist/release-floors.d.ts +1 -1
  87. package/dist/release-floors.js +1 -1
  88. package/dist/wave-runtime.mjs +331 -330
  89. package/dist/workspace/ci-builds.d.ts +21 -0
  90. package/dist/workspace/ci-builds.d.ts.map +1 -1
  91. package/dist/workspace/ci-builds.js +14 -0
  92. package/dist/workspace/ci-green-workflow.d.ts +2 -0
  93. package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
  94. package/dist/workspace/ci-green-workflow.js +9 -0
  95. package/dist/workspace/ci-green.d.ts +45 -2
  96. package/dist/workspace/ci-green.d.ts.map +1 -1
  97. package/dist/workspace/ci-green.js +127 -9
  98. package/dist/workspace/ci-quarantine-report.d.ts +80 -0
  99. package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
  100. package/dist/workspace/ci-quarantine-report.js +205 -0
  101. package/dist/workspace/ci-quarantine.d.ts +73 -0
  102. package/dist/workspace/ci-quarantine.d.ts.map +1 -0
  103. package/dist/workspace/ci-quarantine.js +171 -0
  104. package/dist/workspace/ci-serve.d.ts.map +1 -1
  105. package/dist/workspace/ci-serve.js +7 -4
  106. package/dist/workspace/class-data.d.ts +3 -1
  107. package/dist/workspace/class-data.d.ts.map +1 -1
  108. package/dist/workspace/class-data.js +4 -1
  109. package/dist/workspace/declaration.d.ts +45 -2
  110. package/dist/workspace/declaration.d.ts.map +1 -1
  111. package/dist/workspace/declaration.js +45 -2
  112. package/dist/workspace/declaration.schema.json +51 -3
  113. package/dist/workspace/forge-work.d.ts +76 -0
  114. package/dist/workspace/forge-work.d.ts.map +1 -0
  115. package/dist/workspace/forge-work.js +160 -0
  116. package/dist/workspace/identity-gate-rule.d.ts +3 -2
  117. package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
  118. package/dist/workspace/identity-gate-rule.js +5 -7
  119. package/dist/workspace/identity.d.ts +3 -2
  120. package/dist/workspace/identity.d.ts.map +1 -1
  121. package/dist/workspace/identity.js +6 -3
  122. package/dist/workspace/intent-cli.d.ts +3 -2
  123. package/dist/workspace/intent-cli.d.ts.map +1 -1
  124. package/dist/workspace/intent-cli.js +26 -5
  125. package/dist/workspace/intent-record.d.ts +3 -0
  126. package/dist/workspace/intent-record.d.ts.map +1 -1
  127. package/dist/workspace/intent-record.schema.json +32 -0
  128. package/dist/workspace/intent.d.ts +9 -0
  129. package/dist/workspace/intent.d.ts.map +1 -1
  130. package/dist/workspace/intent.js +3 -0
  131. package/dist/workspace/intent.schema.json +32 -0
  132. package/dist/workspace/kind-readers.d.ts.map +1 -1
  133. package/dist/workspace/kind-readers.js +2 -1
  134. package/dist/workspace/kinds.d.ts +6 -1
  135. package/dist/workspace/kinds.d.ts.map +1 -1
  136. package/dist/workspace/kinds.js +8 -3
  137. package/dist/workspace/plan-stale.schema.json +286 -0
  138. package/dist/workspace/release-candidates.d.ts +33 -6
  139. package/dist/workspace/release-candidates.d.ts.map +1 -1
  140. package/dist/workspace/release-candidates.js +49 -20
  141. package/dist/workspace/release-candidates.schema.json +48 -2
  142. package/dist/workspace/trust/policy.d.ts +10 -0
  143. package/dist/workspace/trust/policy.d.ts.map +1 -1
  144. package/dist/workspace/trust/policy.js +19 -1
  145. package/dist/workspace/trust/run-commits.d.ts.map +1 -1
  146. package/dist/workspace/trust/run-commits.js +2 -1
  147. package/dist/workspace/trust/seal.d.ts.map +1 -1
  148. package/dist/workspace/trust/seal.js +34 -3
  149. package/dist/workspace/trust/trust-files.d.ts.map +1 -1
  150. package/dist/workspace/trust/trust-files.js +6 -1
  151. package/package.json +2 -1
  152. package/src/cli/handlers/approve-external-signature.test.ts +226 -0
  153. package/src/cli/handlers/approve.ts +174 -16
  154. package/src/cli/handlers/plan.ts +74 -0
  155. package/src/cli/handlers/release.ts +12 -7
  156. package/src/cli/main.ts +34 -5
  157. package/src/cli/mcp/workspace-tools.ts +2 -1
  158. package/src/cli/parse-args.ts +24 -0
  159. package/src/cli/registry.ts +13 -1
  160. package/src/gate-decision-bundle.test.ts +4 -2
  161. package/src/gate-decision.ts +11 -2
  162. package/src/gate-statement.schema.json +44 -0
  163. package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
  164. package/src/lifecycle/gate-ledger.ts +17 -3
  165. package/src/lifecycle/gate-seal.ts +62 -9
  166. package/src/lifecycle/gate-statement.ts +107 -0
  167. package/src/lifecycle/gate-webauthn.test.ts +77 -0
  168. package/src/lifecycle/gate-webauthn.ts +133 -0
  169. package/src/lifecycle/git.ts +23 -19
  170. package/src/lifecycle/ledger-remote.test.ts +183 -0
  171. package/src/lifecycle/ledger-remote.ts +46 -0
  172. package/src/lifecycle/plan-stale.test.ts +150 -0
  173. package/src/lifecycle/plan-stale.ts +173 -0
  174. package/src/lifecycle/publish-credentials.ts +2 -0
  175. package/src/lifecycle/publish-declaration.ts +93 -1
  176. package/src/lifecycle/publish-forge.ts +15 -4
  177. package/src/lifecycle/publish-github.ts +174 -0
  178. package/src/lifecycle/publish-homebrew.test.ts +179 -0
  179. package/src/lifecycle/publish-homebrew.ts +187 -0
  180. package/src/lifecycle/publish-marketplace.test.ts +254 -0
  181. package/src/lifecycle/publish-marketplace.ts +259 -0
  182. package/src/lifecycle/publish-target-context.test.ts +2 -2
  183. package/src/lifecycle/publish-targets.test.ts +23 -0
  184. package/src/lifecycle/publish-targets.ts +15 -0
  185. package/src/lifecycle/publish-tauri.test.ts +163 -0
  186. package/src/lifecycle/publish-tauri.ts +199 -0
  187. package/src/lifecycle/release-publish.ts +5 -3
  188. package/src/lifecycle/snapshot-store.ts +16 -9
  189. package/src/lifecycle/test-passkey.ts +55 -0
  190. package/src/notify-bundle.test.ts +3 -1
  191. package/src/notify.schema.json +12 -3
  192. package/src/notify.ts +20 -3
  193. package/src/override-gate-bundle.test.ts +2 -0
  194. package/src/pr-forge-bundle.test.ts +2 -2
  195. package/src/pr-forge.test.ts +38 -0
  196. package/src/pr-forge.ts +68 -5
  197. package/src/release-floors.ts +1 -1
  198. package/src/stage-hooks-bundle.test.ts +2 -0
  199. package/src/wave-runtime-bundle.test.ts +3 -2
  200. package/src/workspace/ci-builds.ts +27 -0
  201. package/src/workspace/ci-green-stale.test.ts +193 -0
  202. package/src/workspace/ci-green-workflow.test.ts +9 -0
  203. package/src/workspace/ci-green-workflow.ts +9 -0
  204. package/src/workspace/ci-green.ts +141 -10
  205. package/src/workspace/ci-quarantine-report.test.ts +146 -0
  206. package/src/workspace/ci-quarantine-report.ts +235 -0
  207. package/src/workspace/ci-quarantine.test.ts +161 -0
  208. package/src/workspace/ci-quarantine.ts +189 -0
  209. package/src/workspace/ci-serve.ts +7 -4
  210. package/src/workspace/class-data.ts +5 -1
  211. package/src/workspace/declaration.schema.json +51 -3
  212. package/src/workspace/declaration.test.ts +1 -0
  213. package/src/workspace/declaration.ts +88 -5
  214. package/src/workspace/forge-work.test.ts +143 -0
  215. package/src/workspace/forge-work.ts +195 -0
  216. package/src/workspace/identity-gate-rule.ts +6 -8
  217. package/src/workspace/identity.ts +6 -3
  218. package/src/workspace/intent-cli.ts +24 -5
  219. package/src/workspace/intent-record.schema.json +32 -0
  220. package/src/workspace/intent-record.ts +3 -0
  221. package/src/workspace/intent.schema.json +32 -0
  222. package/src/workspace/intent.ts +10 -0
  223. package/src/workspace/kind-readers.ts +2 -1
  224. package/src/workspace/kinds.test.ts +13 -0
  225. package/src/workspace/kinds.ts +12 -3
  226. package/src/workspace/plan-stale.schema.json +286 -0
  227. package/src/workspace/release-candidates.schema.json +48 -2
  228. package/src/workspace/release-candidates.test.ts +77 -4
  229. package/src/workspace/release-candidates.ts +62 -20
  230. package/src/workspace/trust/policy.ts +24 -1
  231. package/src/workspace/trust/run-commits.ts +2 -1
  232. package/src/workspace/trust/seal.ts +35 -3
  233. package/src/workspace/trust/trust-files.test.ts +5 -0
  234. package/src/workspace/trust/trust-files.ts +15 -1
@@ -0,0 +1,286 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://intentius.io/chant/schemas/workspace/plan-stale/v1/plan-stale.schema.json",
4
+ "title": "chant plan stale output",
5
+ "description": "What `chant plan stale <digest> --json` prints (#4648): whether anything applied to a plan's targets after the plan was recorded, and those applies. The plan is the pending gate facts that record the digest; it was recorded at the earliest. Its targets are each fact's member, op and environment (the fact's own, else the environment of the run that reached the gate). An apply under an approval of the same member and op for another plan, and a deploy record of the same member and environment, recorded after the plan, make it stale. It reads the local chant/lifecycle branch, never fetches and writes nothing. Version 1 of the read contract. Readers ignore fields they do not know; a field is only ever added within a version. The codes are a closed list, each in the one closed list of `reason-codes.ts`. Contract version 1 of this document is written by chant 0.124.63 and newer.",
6
+ "oneOf": [
7
+ {
8
+ "$ref": "#/$defs/result"
9
+ },
10
+ {
11
+ "$ref": "#/$defs/failure"
12
+ }
13
+ ],
14
+ "$defs": {
15
+ "result": {
16
+ "type": "object",
17
+ "description": "The ledger was read. Exit code 0 when the plan is current, 2 when it is stale, 1 when plan is null.",
18
+ "required": [
19
+ "$schema",
20
+ "contract",
21
+ "chant",
22
+ "digest",
23
+ "plan",
24
+ "stale",
25
+ "applies"
26
+ ],
27
+ "properties": {
28
+ "$schema": {
29
+ "const": "https://intentius.io/chant/schemas/workspace/plan-stale/v1/plan-stale.schema.json"
30
+ },
31
+ "contract": {
32
+ "const": 1
33
+ },
34
+ "chant": {
35
+ "type": "string"
36
+ },
37
+ "error": false,
38
+ "digest": {
39
+ "type": "string",
40
+ "description": "The digest asked for: a pending gate fact's planDigest."
41
+ },
42
+ "plan": {
43
+ "description": "The plan, or null when no pending gate fact on the local ledger records the digest.",
44
+ "oneOf": [
45
+ {
46
+ "type": "null"
47
+ },
48
+ {
49
+ "type": "object",
50
+ "required": [
51
+ "recordedAt",
52
+ "runId",
53
+ "gitSha",
54
+ "targets"
55
+ ],
56
+ "properties": {
57
+ "recordedAt": {
58
+ "type": "string",
59
+ "format": "date-time",
60
+ "description": "The timestamp of the earliest pending fact that records the digest."
61
+ },
62
+ "runId": {
63
+ "type": [
64
+ "string",
65
+ "null"
66
+ ],
67
+ "description": "The run that recorded that fact."
68
+ },
69
+ "gitSha": {
70
+ "type": [
71
+ "string",
72
+ "null"
73
+ ],
74
+ "description": "The commit that run reached the gate at."
75
+ },
76
+ "targets": {
77
+ "type": "array",
78
+ "minItems": 1,
79
+ "description": "Each gate the plan waits at, once.",
80
+ "items": {
81
+ "type": "object",
82
+ "required": [
83
+ "member",
84
+ "op",
85
+ "gate",
86
+ "environment"
87
+ ],
88
+ "properties": {
89
+ "member": {
90
+ "type": [
91
+ "string",
92
+ "null"
93
+ ],
94
+ "description": "The workspace member whose gate ledger holds the fact, or null outside a workspace."
95
+ },
96
+ "op": {
97
+ "type": "string"
98
+ },
99
+ "gate": {
100
+ "type": "string"
101
+ },
102
+ "environment": {
103
+ "type": [
104
+ "string",
105
+ "null"
106
+ ],
107
+ "description": "The fact's environment, else the env of the run that reached the gate, else null. A null environment matches no deploy record."
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ ]
115
+ },
116
+ "stale": {
117
+ "type": [
118
+ "boolean",
119
+ "null"
120
+ ],
121
+ "description": "True when applies is not empty. Null when plan is null."
122
+ },
123
+ "applies": {
124
+ "type": "array",
125
+ "description": "The applies that touched a target after the plan was recorded, oldest first. Empty when stale is false or null.",
126
+ "items": {
127
+ "type": "object",
128
+ "required": [
129
+ "source",
130
+ "member",
131
+ "op",
132
+ "gate",
133
+ "environment",
134
+ "component",
135
+ "planDigest",
136
+ "at",
137
+ "actor",
138
+ "approvedBy",
139
+ "runId",
140
+ "runUrl",
141
+ "gitSha",
142
+ "result"
143
+ ],
144
+ "properties": {
145
+ "source": {
146
+ "enum": [
147
+ "applies",
148
+ "deploys"
149
+ ],
150
+ "description": "applies: an apply under an approval, a line of _gates/<op>/applied.jsonl (chant ledger applies). deploys: a deploy record, a line of <env>/releases.jsonl (chant ledger deploys)."
151
+ },
152
+ "member": {
153
+ "type": [
154
+ "string",
155
+ "null"
156
+ ],
157
+ "description": "The workspace member whose ledger holds it, or null outside a workspace."
158
+ },
159
+ "op": {
160
+ "type": [
161
+ "string",
162
+ "null"
163
+ ],
164
+ "description": "The op it applied under. Null for a deploy record."
165
+ },
166
+ "gate": {
167
+ "type": [
168
+ "string",
169
+ "null"
170
+ ],
171
+ "description": "The gate whose approval it spent. Null for a deploy record."
172
+ },
173
+ "environment": {
174
+ "type": [
175
+ "string",
176
+ "null"
177
+ ],
178
+ "description": "The environment it deployed to. Null for an apply under an approval, whose line names none."
179
+ },
180
+ "component": {
181
+ "type": [
182
+ "string",
183
+ "null"
184
+ ],
185
+ "description": "The component a deploy record deployed. Null for an apply under an approval."
186
+ },
187
+ "planDigest": {
188
+ "type": [
189
+ "string",
190
+ "null"
191
+ ],
192
+ "description": "The plan it applied, always another plan than digest. Null for a deploy record."
193
+ },
194
+ "at": {
195
+ "type": "string",
196
+ "format": "date-time",
197
+ "description": "When it was recorded, after plan.recordedAt."
198
+ },
199
+ "actor": {
200
+ "type": [
201
+ "string",
202
+ "null"
203
+ ],
204
+ "description": "Who ran it: a deploy record's actor. Null for an apply under an approval, which names only its approver."
205
+ },
206
+ "approvedBy": {
207
+ "type": [
208
+ "string",
209
+ "null"
210
+ ],
211
+ "description": "Who approved it: an apply's approvedBy, a deploy record's approver."
212
+ },
213
+ "runId": {
214
+ "type": [
215
+ "string",
216
+ "null"
217
+ ],
218
+ "description": "The run that applied it."
219
+ },
220
+ "runUrl": {
221
+ "type": [
222
+ "string",
223
+ "null"
224
+ ],
225
+ "description": "A deploy record's link to its run. Null for an apply under an approval."
226
+ },
227
+ "gitSha": {
228
+ "type": [
229
+ "string",
230
+ "null"
231
+ ],
232
+ "description": "The commit it applied."
233
+ },
234
+ "result": {
235
+ "type": [
236
+ "string",
237
+ "null"
238
+ ],
239
+ "description": "How an apply under an approval ended: applied or failed, or null while it has no finished line. Null for a deploy record."
240
+ }
241
+ }
242
+ }
243
+ }
244
+ }
245
+ },
246
+ "failure": {
247
+ "type": "object",
248
+ "description": "Nothing was read. Exit code 1.",
249
+ "required": [
250
+ "$schema",
251
+ "contract",
252
+ "chant",
253
+ "error"
254
+ ],
255
+ "properties": {
256
+ "$schema": {
257
+ "const": "https://intentius.io/chant/schemas/workspace/plan-stale/v1/plan-stale.schema.json"
258
+ },
259
+ "contract": {
260
+ "const": 1
261
+ },
262
+ "chant": {
263
+ "type": "string"
264
+ },
265
+ "error": {
266
+ "type": "object",
267
+ "required": [
268
+ "code",
269
+ "message"
270
+ ],
271
+ "properties": {
272
+ "code": {
273
+ "enum": [
274
+ "not-a-git-repository",
275
+ "ledger-unreadable"
276
+ ]
277
+ },
278
+ "message": {
279
+ "type": "string"
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://intentius.io/chant/schemas/workspace/release-candidates/v1/release-candidates.schema.json",
4
4
  "title": "chant release candidates output",
5
- "description": "What `chant release candidates --json` prints (#4168 4.2): the green commits of trunk a release can be cut from, newest first, each with the commits, work items, pull requests, merge records and flags it would ship since the previous candidate, and what each environment of the member runs. It reads local refs and tags and never fetches. Version 1 of the read contract. Readers ignore fields they do not know; a field is only ever added within a version. The codes are a closed list, each in the one closed list of `reason-codes.ts`. Contract version 1 of this document is written by chant 0.124.33 and newer.",
5
+ "description": "What `chant release candidates --json` prints (#4168 4.2): the green commits of trunk a release can be cut from, newest first, each with the commits, work items, pull requests, merge records and flags it would ship since the previous candidate, and what each environment of the member runs. It reads local refs and tags and never fetches; with `--forge-issues` it also asks the forge, once per pull request, which issues each pull request closes (#4649). Version 1 of the read contract. Readers ignore fields they do not know; a field is only ever added within a version. The codes are a closed list, each in the one closed list of `reason-codes.ts`. Contract version 1 of this document is written by chant 0.124.33 and newer.",
6
6
  "oneOf": [
7
7
  {
8
8
  "$ref": "#/$defs/result"
@@ -251,7 +251,7 @@
251
251
  "items": {
252
252
  "$ref": "#/$defs/group"
253
253
  },
254
- "description": "The same changes by work item, then pull request, then commit (#4168 4.4). Work items come first, in the order the oldest change names them, then `work: null` for changes that name none. A change with two work items is under both."
254
+ "description": "The same changes by work item, then pull request, then commit (#4168 4.4). Work ids come first, in the order the oldest change names them, then the issues that changes with no work id close (`issue`, with `--forge-issues`), then `work: null` and `issue: null` for changes under neither. A change with two work items is under both."
255
255
  },
256
256
  "flags": {
257
257
  "type": "array",
@@ -276,6 +276,13 @@
276
276
  ],
277
277
  "description": "The work item id a `Chant-Record: work:<id>` trailer names, or null."
278
278
  },
279
+ "issue": {
280
+ "type": [
281
+ "integer",
282
+ "null"
283
+ ],
284
+ "description": "For changes with no work id: an issue their pull request closes, as `closes` says (#4649); null otherwise. Written by chant 0.124.63 and newer."
285
+ },
279
286
  "pullRequests": {
280
287
  "type": "array",
281
288
  "items": {
@@ -354,6 +361,17 @@
354
361
  "null"
355
362
  ],
356
363
  "description": "The merge record `_merges/<sha>.json` on chant/lifecycle (#4168 4.1), as stored, or null when there is none."
364
+ },
365
+ "closes": {
366
+ "anyOf": [
367
+ {
368
+ "$ref": "#/$defs/closes"
369
+ },
370
+ {
371
+ "type": "null"
372
+ }
373
+ ],
374
+ "description": "What the forge says `pr` closes (#4649), when the read was asked to (`--forge-issues`) and the change has a pull request; null otherwise. Written by chant 0.124.63 and newer."
357
375
  }
358
376
  },
359
377
  "description": "One first-parent commit."
@@ -399,6 +417,34 @@
399
417
  "description": "The value per environment, as the working tree's record writes it."
400
418
  }
401
419
  }
420
+ },
421
+ "closes": {
422
+ "type": "object",
423
+ "required": [
424
+ "resolved",
425
+ "issues",
426
+ "reason"
427
+ ],
428
+ "properties": {
429
+ "resolved": {
430
+ "type": "boolean",
431
+ "description": "Whether the forge answered. False without a forge chant reads, without a token, offline, or when the forge answered an error."
432
+ },
433
+ "issues": {
434
+ "type": "array",
435
+ "items": {
436
+ "type": "integer"
437
+ },
438
+ "description": "The issues of the repository the pull request closes, ascending. Empty when not resolved."
439
+ },
440
+ "reason": {
441
+ "type": [
442
+ "string",
443
+ "null"
444
+ ],
445
+ "description": "Why the forge was not read, or null when it was."
446
+ }
447
+ }
402
448
  }
403
449
  }
404
450
  }
@@ -15,6 +15,7 @@ import { groupChanges, mergeRecordPr, prFromSubject, recordTrailers, releaseCand
15
15
  import { appendCut, makeRelease, persistRelease } from "../lifecycle/release-store";
16
16
  import { appendReleaseRecord } from "../lifecycle/release-ledger";
17
17
  import { writeLedgerFiles } from "../lifecycle/git";
18
+ import type { ForgeFetch } from "../pr-forge";
18
19
 
19
20
  const { expectValid } = contract(candidatesSchema);
20
21
 
@@ -47,7 +48,16 @@ describe("recordTrailers and prFromSubject", () => {
47
48
  });
48
49
 
49
50
  describe("groupChanges (#4168 4.4)", () => {
50
- const change = (commit: string, work: string[], pr: number | null): CandidateChange => ({ commit, subject: commit, date: "", work, records: work.map((w) => `work:${w}`), pr, merge: null });
51
+ const change = (commit: string, work: string[], pr: number | null, issues?: number[]): CandidateChange => ({
52
+ commit,
53
+ subject: commit,
54
+ date: "",
55
+ work,
56
+ records: work.map((w) => `work:${w}`),
57
+ pr,
58
+ merge: null,
59
+ closes: issues ? { resolved: true, issues, reason: null } : null,
60
+ });
51
61
 
52
62
  test("groups by work item, then pull request, then commit, with the ungrouped last", () => {
53
63
  // Newest first, as a candidate's changes are.
@@ -60,9 +70,25 @@ describe("groupChanges (#4168 4.4)", () => {
60
70
  change("a", ["w-1"], 2),
61
71
  ]);
62
72
  expect(groups).toEqual([
63
- { work: "w-1", pullRequests: [{ pr: 2, commits: ["b", "a"] }, { pr: 4, commits: ["d"] }] },
64
- { work: "w-2", pullRequests: [{ pr: 2, commits: ["b"] }, { pr: null, commits: ["e"] }] },
65
- { work: null, pullRequests: [{ pr: 3, commits: ["c"] }, { pr: null, commits: ["f"] }] },
73
+ { work: "w-1", issue: null, pullRequests: [{ pr: 2, commits: ["b", "a"] }, { pr: 4, commits: ["d"] }] },
74
+ { work: "w-2", issue: null, pullRequests: [{ pr: 2, commits: ["b"] }, { pr: null, commits: ["e"] }] },
75
+ { work: null, issue: null, pullRequests: [{ pr: 3, commits: ["c"] }, { pr: null, commits: ["f"] }] },
76
+ ]);
77
+ });
78
+
79
+ test("a change with no work id lands under each issue its pull request closes (#4649)", () => {
80
+ const groups = groupChanges([
81
+ change("d", [], 9, []),
82
+ change("c", ["w-1"], 8, [70]),
83
+ change("b", [], 7, [71, 70]),
84
+ change("a", [], 6, [70]),
85
+ ]);
86
+ expect(groups).toEqual([
87
+ // A work id wins over the issues its pull request closes.
88
+ { work: "w-1", issue: null, pullRequests: [{ pr: 8, commits: ["c"] }] },
89
+ { work: null, issue: 70, pullRequests: [{ pr: 6, commits: ["a"] }, { pr: 7, commits: ["b"] }] },
90
+ { work: null, issue: 71, pullRequests: [{ pr: 7, commits: ["b"] }] },
91
+ { work: null, issue: null, pullRequests: [{ pr: 9, commits: ["d"] }] },
66
92
  ]);
67
93
  });
68
94
 
@@ -123,6 +149,53 @@ describe("releaseCandidatesDocument", () => {
123
149
  });
124
150
  });
125
151
 
152
+ test("with forgeIssues, each change carries what its pull request closes, and groups by those issues (#4649)", async () => {
153
+ await withTestDir(async (dir) => {
154
+ const [init, a, b, c, d] = repo(dir, ["a (#11)", "b (#12)\n\nChant-Record: work:w-1", "c (#11)", "d"]);
155
+ for (const sha of [init, d]) git(dir, "tag", `ci/green/${sha}`);
156
+ const asked: number[] = [];
157
+ const fetch: ForgeFetch = async (_url, init) => {
158
+ const pr = (JSON.parse(init.body!) as { variables: { pr: number } }).variables.pr;
159
+ asked.push(pr);
160
+ const nodes = (pr === 11 ? [70, 71] : [72]).map((number) => ({ number, repository: { nameWithOwner: "acme/app" } }));
161
+ return { ok: true, status: 200, text: async () => JSON.stringify({ data: { repository: { pullRequest: { closingIssuesReferences: { nodes } } } } }) };
162
+ };
163
+ const forgeIssues = { env: { GH_TOKEN: "t" }, remoteUrl: "https://github.com/acme/app.git", fetch };
164
+ const doc = await releaseCandidatesDocument({ cwd: dir, forgeIssues });
165
+ expectValid(doc);
166
+ if ("error" in doc) throw new Error(doc.error.message);
167
+ // One call per pull request, though #11 squashed two commits.
168
+ expect(asked.sort()).toEqual([11, 12]);
169
+ const changes = doc.candidates[0].changes;
170
+ expect(changes.map((x) => [x.commit, x.pr, x.closes])).toEqual([
171
+ [d, null, null],
172
+ [c, 11, { resolved: true, issues: [70, 71], reason: null }],
173
+ [b, 12, { resolved: true, issues: [72], reason: null }],
174
+ [a, 11, { resolved: true, issues: [70, 71], reason: null }],
175
+ ]);
176
+ expect(doc.candidates[0].groups).toEqual([
177
+ { work: "w-1", issue: null, pullRequests: [{ pr: 12, commits: [b] }] },
178
+ { work: null, issue: 70, pullRequests: [{ pr: 11, commits: [c, a] }] },
179
+ { work: null, issue: 71, pullRequests: [{ pr: 11, commits: [c, a] }] },
180
+ { work: null, issue: null, pullRequests: [{ pr: null, commits: [d] }] },
181
+ ]);
182
+
183
+ // Without a token the pull request stands alone, unresolved, and nothing is asked.
184
+ asked.length = 0;
185
+ const offline = await releaseCandidatesDocument({ cwd: dir, forgeIssues: { ...forgeIssues, env: {}, ghToken: () => undefined } });
186
+ expectValid(offline);
187
+ if ("error" in offline) throw new Error(offline.error.message);
188
+ expect(asked).toEqual([]);
189
+ expect(offline.candidates[0].changes[1]).toMatchObject({ pr: 11, closes: { resolved: false, issues: [] } });
190
+ expect(offline.candidates[0].groups.map((g) => [g.work, g.issue])).toEqual([["w-1", null], [null, null]]);
191
+
192
+ // Not asked, closes is null.
193
+ const plain = await releaseCandidatesDocument({ cwd: dir });
194
+ if ("error" in plain) throw new Error(plain.error.message);
195
+ expect(plain.candidates[0].changes.every((x) => x.closes === null)).toBe(true);
196
+ });
197
+ });
198
+
126
199
  test("outside git it is the failure not-a-git-repository", async () => {
127
200
  await withTestDir(async (dir) => {
128
201
  const doc = await releaseCandidatesDocument({ cwd: dir });
@@ -29,19 +29,30 @@
29
29
  * trailers name, or under no work item, and within that under its pull
30
30
  * request, or under none for a commit that landed without one.
31
31
  *
32
- * It reads local refs and tags only and never fetches. Git is read through a
33
- * local `git` subprocess.
32
+ * Asked to (`forgeIssues`, `--forge-issues`, #4649), it also asks the forge
33
+ * which issues each change's pull request closes (./forge-work.ts), once per
34
+ * pull request, and puts the answer in the change's `closes`. A change no
35
+ * `Chant-Record` trailer gives a work item then lands under each issue its
36
+ * pull request closes. Without a forge or a token the pull request number
37
+ * stands alone, `resolved: false`.
38
+ *
39
+ * Otherwise it reads local refs and tags only and never fetches. Git is read
40
+ * through a local `git` subprocess.
34
41
  */
35
42
 
36
43
  import { execFileSync } from "node:child_process";
37
44
  import { relative, resolve, sep } from "node:path";
45
+ import { NEXT_RELEASE } from "../release-floors";
38
46
  import { latestPerComponent, readReleaseLedger } from "../lifecycle/release-ledger";
39
47
  import { readAllReleases, readCuts } from "../lifecycle/release-store";
40
48
  import { resolveMemberLedger } from "../lifecycle/member-ledger";
41
49
  import { readBlobFromPath } from "../lifecycle/git";
42
50
  import { greenBranches, readerVersion } from "./declaration";
51
+ import type { ForgeWorkOptions, PullRequestCloses } from "./forge-work";
43
52
 
44
53
  export const RELEASE_CANDIDATES_CONTRACT_VERSION = 1;
54
+ /** The first chant whose candidates carry `changes[].closes` and `groups[].issue` (#4649). */
55
+ export const RELEASE_CANDIDATES_CLOSES_FLOOR = NEXT_RELEASE;
45
56
  export const RELEASE_CANDIDATES_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/release-candidates/v1/release-candidates.schema.json";
46
57
 
47
58
  /** Why the read stopped. Closed; each code is in `reason-codes.ts`. */
@@ -79,6 +90,12 @@ export interface CandidateChange {
79
90
  pr: number | null;
80
91
  /** The merge record `_merges/<sha>.json` (#4168 4.1), as stored, or null when there is none. */
81
92
  merge: Record<string, unknown> | null;
93
+ /**
94
+ * The issues the forge says `pr` closes (#4649), or null when the read was
95
+ * not asked to (`--forge-issues`) or the change has no pull request. Added
96
+ * within contract 1 by chant {@link RELEASE_CANDIDATES_CLOSES_FLOOR}.
97
+ */
98
+ closes: PullRequestCloses | null;
82
99
  }
83
100
 
84
101
  /** A candidate's changes under one pull request, or under none (`pr: null`) for commits that landed without one. */
@@ -88,9 +105,16 @@ export interface CandidatePullRequestGroup {
88
105
  commits: string[];
89
106
  }
90
107
 
91
- /** A candidate's changes under one work item, or under none (`work: null`). Work items come first, in the order the oldest change names them. */
108
+ /**
109
+ * A candidate's changes under one work item: a `Chant-Record` work id
110
+ * (`work`), or an issue the change's pull request closes (`issue`, #4649), or
111
+ * under none (both null). Work ids come first, then issues, each in the order
112
+ * the oldest change names them.
113
+ */
92
114
  export interface CandidateGroup {
93
115
  work: string | null;
116
+ /** The issue the forge says the changes' pull request closes, for changes with no work id; null otherwise. */
117
+ issue: number | null;
94
118
  /** Pull requests in the order their oldest commit landed, then `pr: null`. */
95
119
  pullRequests: CandidatePullRequestGroup[];
96
120
  }
@@ -147,6 +171,8 @@ export interface ReleaseCandidatesQuery {
147
171
  limit?: number;
148
172
  /** Walk this branch of `ci.green.branch` (#4325) instead of the first. */
149
173
  branch?: string;
174
+ /** Ask the forge which issues each pull request closes (#4649), with these options. Left out, the forge is not read. */
175
+ forgeIssues?: ForgeWorkOptions;
150
176
  }
151
177
 
152
178
  function git(top: string, args: string[]): string {
@@ -187,24 +213,34 @@ export function mergeRecordPr(merge: Record<string, unknown> | null): number | n
187
213
 
188
214
  /**
189
215
  * Group changes, given newest first, by work item, then pull request, then
190
- * commit. A change with work items lands in each one's group; the rest land
191
- * in the `work: null` group, last. Within a group, pull requests come in the
192
- * order their oldest commit landed, and commits without one last.
216
+ * commit. A change with work ids lands in each one's group; one without
217
+ * lands in the group of each issue its pull request closes (#4649); the rest
218
+ * land in the group of neither, last. Work ids come before issues. Within a
219
+ * group, pull requests come in the order their oldest commit landed, and
220
+ * commits without one last.
193
221
  */
194
222
  export function groupChanges(changes: readonly CandidateChange[]): CandidateGroup[] {
195
223
  const oldestFirst = [...changes].reverse();
196
- const groups = new Map<string | null, Map<number | null, string[]>>();
197
- const add = (work: string | null, pr: number | null, commit: string): void => {
198
- const byPr = groups.get(work) ?? new Map<number | null, string[]>();
199
- groups.set(work, byPr);
200
- byPr.set(pr, [commit, ...(byPr.get(pr) ?? [])]);
224
+ const groups = new Map<string, { work: string | null; issue: number | null; byPr: Map<number | null, string[]> }>();
225
+ const add = (work: string | null, issue: number | null, pr: number | null, commit: string): void => {
226
+ const key = work !== null ? `work:${work}` : issue !== null ? `issue:${issue}` : "";
227
+ const g = groups.get(key) ?? { work, issue, byPr: new Map<number | null, string[]>() };
228
+ groups.set(key, g);
229
+ g.byPr.set(pr, [commit, ...(g.byPr.get(pr) ?? [])]);
201
230
  };
202
- for (const c of oldestFirst) for (const work of c.work.length > 0 ? c.work : [null]) add(work, c.pr, c.commit);
231
+ for (const c of oldestFirst) {
232
+ const issues = c.closes?.issues ?? [];
233
+ if (c.work.length > 0) for (const work of c.work) add(work, null, c.pr, c.commit);
234
+ else if (issues.length > 0) for (const issue of issues) add(null, issue, c.pr, c.commit);
235
+ else add(null, null, c.pr, c.commit);
236
+ }
203
237
  const nullLast = <K>(keys: K[]): K[] => [...keys.filter((k) => k !== null), ...keys.filter((k) => k === null)];
204
- return nullLast([...groups.keys()]).map((work) => {
205
- const byPr = groups.get(work)!;
206
- return { work, pullRequests: nullLast([...byPr.keys()]).map((pr) => ({ pr, commits: byPr.get(pr)! })) };
207
- });
238
+ const all = [...groups.values()];
239
+ return [...all.filter((g) => g.work !== null), ...all.filter((g) => g.issue !== null), ...all.filter((g) => g.work === null && g.issue === null)].map((g) => ({
240
+ work: g.work,
241
+ issue: g.issue,
242
+ pullRequests: nullLast([...g.byPr.keys()]).map((pr) => ({ pr, commits: g.byPr.get(pr)! })),
243
+ }));
208
244
  }
209
245
 
210
246
  /** Read the release candidates of the member at `query.cwd`. */
@@ -290,14 +326,20 @@ export async function releaseCandidatesDocument(query: ReleaseCandidatesQuery):
290
326
  // A merge record that is not JSON is left out.
291
327
  }
292
328
  }
329
+ // The merge record names its pull request in `source` (../lifecycle/merge-record.ts).
330
+ const prOf = (sha: string): number | null => mergeRecordPr(merges.get(sha) ?? null) ?? prFromSubject(details.get(sha)?.subject ?? "");
331
+ // What each pull request closes, asked of the forge once each, when asked to (#4649).
332
+ let closed = new Map<number, PullRequestCloses>();
333
+ if (query.forgeIssues) {
334
+ const { forgeWorkReader } = await import("./forge-work");
335
+ closed = await forgeWorkReader(top, query.forgeIssues).closesAll(walk.map(prOf).filter((n): n is number => n !== null));
336
+ }
293
337
  const change = (sha: string): CandidateChange => {
294
338
  const d = details.get(sha);
295
339
  const { work, records } = recordTrailers(d?.trailers ?? {});
296
340
  const merge = merges.get(sha) ?? null;
297
- // The merge record names its pull request in `source` (../lifecycle/merge-record.ts).
298
- const mergePr = mergeRecordPr(merge);
299
- const subject = d?.subject ?? "";
300
- return { commit: sha, subject, date: d?.date ?? "", work, records, pr: mergePr ?? prFromSubject(subject), merge };
341
+ const pr = prOf(sha);
342
+ return { commit: sha, subject: d?.subject ?? "", date: d?.date ?? "", work, records, pr, merge, closes: pr !== null ? (closed.get(pr) ?? null) : null };
301
343
  };
302
344
 
303
345
  const flagReader = await flagsReader(top, source.rootOnDisk);