@kitman-sh/software-engineering 0.10.68 → 0.10.70
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.
- package/dist/bundle.js +377 -95
- package/dist/declarations.json +164 -19
- package/package.json +3 -3
- package/src/release.ts +46 -8
- package/src/review.ts +59 -23
- package/src/shepherd-output.ts +12 -1
- package/src/shepherd.ts +416 -89
package/dist/declarations.json
CHANGED
|
@@ -322,7 +322,8 @@
|
|
|
322
322
|
"enum": [
|
|
323
323
|
"merged",
|
|
324
324
|
"ready",
|
|
325
|
-
"needs_you"
|
|
325
|
+
"needs_you",
|
|
326
|
+
"handed_back"
|
|
326
327
|
]
|
|
327
328
|
},
|
|
328
329
|
"reason": {
|
|
@@ -370,6 +371,49 @@
|
|
|
370
371
|
"type": "null"
|
|
371
372
|
}
|
|
372
373
|
]
|
|
374
|
+
},
|
|
375
|
+
"handBack": {
|
|
376
|
+
"anyOf": [
|
|
377
|
+
{
|
|
378
|
+
"type": "object",
|
|
379
|
+
"properties": {
|
|
380
|
+
"changeRequestId": {
|
|
381
|
+
"type": "string"
|
|
382
|
+
},
|
|
383
|
+
"words": {
|
|
384
|
+
"type": "string"
|
|
385
|
+
},
|
|
386
|
+
"taskId": {
|
|
387
|
+
"anyOf": [
|
|
388
|
+
{
|
|
389
|
+
"type": "string"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"type": "null"
|
|
393
|
+
}
|
|
394
|
+
]
|
|
395
|
+
},
|
|
396
|
+
"branch": {
|
|
397
|
+
"anyOf": [
|
|
398
|
+
{
|
|
399
|
+
"type": "string"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"type": "null"
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
"required": [
|
|
408
|
+
"changeRequestId",
|
|
409
|
+
"words"
|
|
410
|
+
],
|
|
411
|
+
"additionalProperties": true
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"type": "null"
|
|
415
|
+
}
|
|
416
|
+
]
|
|
373
417
|
}
|
|
374
418
|
},
|
|
375
419
|
"required": [
|
|
@@ -2014,7 +2058,7 @@
|
|
|
2014
2058
|
{
|
|
2015
2059
|
"id": "review",
|
|
2016
2060
|
"title": "Review",
|
|
2017
|
-
"version": "3.
|
|
2061
|
+
"version": "3.4.0",
|
|
2018
2062
|
"input": {
|
|
2019
2063
|
"type": "object",
|
|
2020
2064
|
"properties": {
|
|
@@ -2071,6 +2115,16 @@
|
|
|
2071
2115
|
}
|
|
2072
2116
|
]
|
|
2073
2117
|
},
|
|
2118
|
+
"approved": {
|
|
2119
|
+
"anyOf": [
|
|
2120
|
+
{
|
|
2121
|
+
"type": "string"
|
|
2122
|
+
},
|
|
2123
|
+
{
|
|
2124
|
+
"type": "null"
|
|
2125
|
+
}
|
|
2126
|
+
]
|
|
2127
|
+
},
|
|
2074
2128
|
"rebuttals": {
|
|
2075
2129
|
"anyOf": [
|
|
2076
2130
|
{
|
|
@@ -2265,6 +2319,58 @@
|
|
|
2265
2319
|
"additionalProperties": true
|
|
2266
2320
|
}
|
|
2267
2321
|
},
|
|
2322
|
+
"approvedFindings": {
|
|
2323
|
+
"anyOf": [
|
|
2324
|
+
{
|
|
2325
|
+
"type": "array",
|
|
2326
|
+
"items": {
|
|
2327
|
+
"type": "object",
|
|
2328
|
+
"properties": {
|
|
2329
|
+
"id": {
|
|
2330
|
+
"type": "string"
|
|
2331
|
+
},
|
|
2332
|
+
"severity": {
|
|
2333
|
+
"type": "string",
|
|
2334
|
+
"enum": [
|
|
2335
|
+
"blocker",
|
|
2336
|
+
"major",
|
|
2337
|
+
"minor"
|
|
2338
|
+
]
|
|
2339
|
+
},
|
|
2340
|
+
"file": {
|
|
2341
|
+
"type": "string"
|
|
2342
|
+
},
|
|
2343
|
+
"line": {
|
|
2344
|
+
"type": "integer",
|
|
2345
|
+
"minimum": -9007199254740991,
|
|
2346
|
+
"maximum": 9007199254740991
|
|
2347
|
+
},
|
|
2348
|
+
"detail": {
|
|
2349
|
+
"type": "string"
|
|
2350
|
+
},
|
|
2351
|
+
"seats": {
|
|
2352
|
+
"type": "array",
|
|
2353
|
+
"items": {
|
|
2354
|
+
"type": "string"
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
},
|
|
2358
|
+
"required": [
|
|
2359
|
+
"id",
|
|
2360
|
+
"severity",
|
|
2361
|
+
"file",
|
|
2362
|
+
"line",
|
|
2363
|
+
"detail",
|
|
2364
|
+
"seats"
|
|
2365
|
+
],
|
|
2366
|
+
"additionalProperties": true
|
|
2367
|
+
}
|
|
2368
|
+
},
|
|
2369
|
+
{
|
|
2370
|
+
"type": "null"
|
|
2371
|
+
}
|
|
2372
|
+
]
|
|
2373
|
+
},
|
|
2268
2374
|
"followUps": {
|
|
2269
2375
|
"type": "array",
|
|
2270
2376
|
"items": {
|
|
@@ -2456,7 +2562,7 @@
|
|
|
2456
2562
|
{
|
|
2457
2563
|
"id": "shepherd",
|
|
2458
2564
|
"title": "Shepherd",
|
|
2459
|
-
"version": "1.
|
|
2565
|
+
"version": "1.2.0",
|
|
2460
2566
|
"input": {
|
|
2461
2567
|
"type": "object",
|
|
2462
2568
|
"properties": {
|
|
@@ -2568,18 +2674,6 @@
|
|
|
2568
2674
|
}
|
|
2569
2675
|
]
|
|
2570
2676
|
},
|
|
2571
|
-
"maxFixRounds": {
|
|
2572
|
-
"anyOf": [
|
|
2573
|
-
{
|
|
2574
|
-
"type": "integer",
|
|
2575
|
-
"minimum": -9007199254740991,
|
|
2576
|
-
"maximum": 9007199254740991
|
|
2577
|
-
},
|
|
2578
|
-
{
|
|
2579
|
-
"type": "null"
|
|
2580
|
-
}
|
|
2581
|
-
]
|
|
2582
|
-
},
|
|
2583
2677
|
"maxCycles": {
|
|
2584
2678
|
"anyOf": [
|
|
2585
2679
|
{
|
|
@@ -2607,7 +2701,8 @@
|
|
|
2607
2701
|
"enum": [
|
|
2608
2702
|
"merged",
|
|
2609
2703
|
"ready",
|
|
2610
|
-
"needs_you"
|
|
2704
|
+
"needs_you",
|
|
2705
|
+
"handed_back"
|
|
2611
2706
|
]
|
|
2612
2707
|
},
|
|
2613
2708
|
"reason": {
|
|
@@ -2655,6 +2750,49 @@
|
|
|
2655
2750
|
"type": "null"
|
|
2656
2751
|
}
|
|
2657
2752
|
]
|
|
2753
|
+
},
|
|
2754
|
+
"handBack": {
|
|
2755
|
+
"anyOf": [
|
|
2756
|
+
{
|
|
2757
|
+
"type": "object",
|
|
2758
|
+
"properties": {
|
|
2759
|
+
"changeRequestId": {
|
|
2760
|
+
"type": "string"
|
|
2761
|
+
},
|
|
2762
|
+
"words": {
|
|
2763
|
+
"type": "string"
|
|
2764
|
+
},
|
|
2765
|
+
"taskId": {
|
|
2766
|
+
"anyOf": [
|
|
2767
|
+
{
|
|
2768
|
+
"type": "string"
|
|
2769
|
+
},
|
|
2770
|
+
{
|
|
2771
|
+
"type": "null"
|
|
2772
|
+
}
|
|
2773
|
+
]
|
|
2774
|
+
},
|
|
2775
|
+
"branch": {
|
|
2776
|
+
"anyOf": [
|
|
2777
|
+
{
|
|
2778
|
+
"type": "string"
|
|
2779
|
+
},
|
|
2780
|
+
{
|
|
2781
|
+
"type": "null"
|
|
2782
|
+
}
|
|
2783
|
+
]
|
|
2784
|
+
}
|
|
2785
|
+
},
|
|
2786
|
+
"required": [
|
|
2787
|
+
"changeRequestId",
|
|
2788
|
+
"words"
|
|
2789
|
+
],
|
|
2790
|
+
"additionalProperties": true
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
"type": "null"
|
|
2794
|
+
}
|
|
2795
|
+
]
|
|
2658
2796
|
}
|
|
2659
2797
|
},
|
|
2660
2798
|
"required": [
|
|
@@ -2671,7 +2809,14 @@
|
|
|
2671
2809
|
},
|
|
2672
2810
|
"checkout": "write",
|
|
2673
2811
|
"when": [],
|
|
2674
|
-
"offers": [
|
|
2812
|
+
"offers": [
|
|
2813
|
+
{
|
|
2814
|
+
"id": "build",
|
|
2815
|
+
"title": "Hand back to Build",
|
|
2816
|
+
"loop": "build",
|
|
2817
|
+
"from": "handBack"
|
|
2818
|
+
}
|
|
2819
|
+
],
|
|
2675
2820
|
"capabilities": [
|
|
2676
2821
|
"agent_work",
|
|
2677
2822
|
"read_change_request",
|
|
@@ -2682,8 +2827,8 @@
|
|
|
2682
2827
|
"write_back",
|
|
2683
2828
|
"ask",
|
|
2684
2829
|
"verify",
|
|
2685
|
-
"change_request",
|
|
2686
2830
|
"claim",
|
|
2831
|
+
"change_request",
|
|
2687
2832
|
"publish_release"
|
|
2688
2833
|
]
|
|
2689
2834
|
},
|
|
@@ -3187,7 +3332,7 @@
|
|
|
3187
3332
|
"carried": [
|
|
3188
3333
|
{
|
|
3189
3334
|
"name": "@kitman-sh/software-engineering",
|
|
3190
|
-
"version": "0.10.
|
|
3335
|
+
"version": "0.10.70",
|
|
3191
3336
|
"setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
|
|
3192
3337
|
"loops": [
|
|
3193
3338
|
"build",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitman-sh/software-engineering",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.70",
|
|
4
4
|
"description": "Everything for building software: Loops, their Agents, the skills they use and the Ponytail plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"tsconfig.json"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@kitman-sh/sdk": "0.10.
|
|
20
|
+
"@kitman-sh/sdk": "0.10.70",
|
|
21
21
|
"effect": "4.1.2"
|
|
22
22
|
},
|
|
23
23
|
"kitman": {
|
|
24
24
|
"bundle": "dist/bundle.js",
|
|
25
|
-
"digest": "
|
|
25
|
+
"digest": "f4c65f62a3f9c7699a096c7c508729a86836aa61b132f5273586356c441f8eab",
|
|
26
26
|
"protocolVersion": 5,
|
|
27
27
|
"declarations": "dist/declarations.json",
|
|
28
28
|
"setup": {
|
package/src/release.ts
CHANGED
|
@@ -194,7 +194,8 @@ const recovery = (previous: string | undefined) =>
|
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
* Proves the release before anyone is asked: the approved checks pass on the revision to tag, or a release
|
|
197
|
-
* ChangeRequest is green, approved and mergeable.
|
|
197
|
+
* ChangeRequest is green, approved and mergeable. A failed check runs once more in a fresh checkout; one that passes
|
|
198
|
+
* there is recorded as an environment failure. It then asks once, with no default, whether to release the drafted
|
|
198
199
|
* notes, which can be edited in place. On approval it merges the ChangeRequest when there is one, tags and publishes
|
|
199
200
|
* once (a tag already released at the same revision counts as done; one at another is never moved), holds the deploy
|
|
200
201
|
* target so two Releases never deploy over each other, and waits for the deploy. A failed or late deploy asks whether
|
|
@@ -225,16 +226,53 @@ export default defineLoop({
|
|
|
225
226
|
let gated: string
|
|
226
227
|
|
|
227
228
|
if (changeRequestId === undefined) {
|
|
228
|
-
|
|
229
|
+
// A failure an earlier Release recorded at this tree may be its checkout's, so it is run again.
|
|
230
|
+
const gate = yield* verify('gate', {
|
|
231
|
+
...(input.revision === undefined ? undefined : { revision: input.revision }),
|
|
232
|
+
rerunFailed: true
|
|
233
|
+
})
|
|
229
234
|
|
|
230
235
|
if (!gate.passed) {
|
|
231
|
-
const
|
|
236
|
+
const failed = gate.checks.filter(check => check.status !== 'passed' && !check.preExisting)
|
|
232
237
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
// Once more in a fresh checkout of the same commit: a check that passes there failed on its environment.
|
|
239
|
+
const retry = yield* verify('gate:retry', {
|
|
240
|
+
revision: gate.revision,
|
|
241
|
+
...(failed.length === 0 ? undefined : { checks: failed.map(check => check.name) }),
|
|
242
|
+
rerunFailed: true
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
const environmental = failed.filter(check =>
|
|
246
|
+
retry.checks.some(again => again.name === check.name && again.status === 'passed')
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
const names = environmental.map(check => check.name).join(', ')
|
|
250
|
+
|
|
251
|
+
if (environmental.length > 0)
|
|
252
|
+
yield* artifact('environment-failure', {
|
|
253
|
+
kind: 'gate_environment_failure',
|
|
254
|
+
title: `${names} failed on the gate's checkout at ${gate.revision}`,
|
|
255
|
+
text: `These checks failed at ${gate.revision} and passed in a fresh checkout of it, so the first checkout's environment failed them, not the code: ${names}.`,
|
|
256
|
+
data: {
|
|
257
|
+
revision: gate.revision,
|
|
258
|
+
checks: environmental.map(check => ({
|
|
259
|
+
name: check.name,
|
|
260
|
+
failedEvidenceId: check.evidenceId,
|
|
261
|
+
...(check.outputTail === undefined ? undefined : { outputTail: check.outputTail })
|
|
262
|
+
}))
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
// A retry passes only when its checks passed: one failing again may read as pre-existing against a moved target.
|
|
267
|
+
const failing = retry.checks.filter(check => check.status !== 'passed').map(check => check.name)
|
|
268
|
+
|
|
269
|
+
if (!retry.passed || retry.checks.length === 0 || failing.length > 0) {
|
|
270
|
+
return {
|
|
271
|
+
status: 'gate_failed',
|
|
272
|
+
reason: `The checks fail at ${retry.revision}, and again in a fresh checkout: ${(failing.length > 0 ? failing : failed.map(check => check.name)).join(', ')}`,
|
|
273
|
+
revision: retry.revision
|
|
274
|
+
} satisfies Output
|
|
275
|
+
}
|
|
238
276
|
}
|
|
239
277
|
|
|
240
278
|
gated = gate.revision
|
package/src/review.ts
CHANGED
|
@@ -57,6 +57,11 @@ const Input = Schema.Struct({
|
|
|
57
57
|
files: Schema.optional(Schema.Array(Schema.String)),
|
|
58
58
|
/** With `files`, also reviews everything in `git diff since..head`, such as a fix made after the files' review. */
|
|
59
59
|
since: Schema.optional(Schema.String),
|
|
60
|
+
/**
|
|
61
|
+
* With `base` and `head`, the last approved head: reviews only what the change gained or lost since then, judges no
|
|
62
|
+
* scope, and keeps findings about code that head already had apart, where they do not block.
|
|
63
|
+
*/
|
|
64
|
+
approved: Schema.optional(Schema.String),
|
|
60
65
|
/** The implementer's rebuttals of the last round's findings, for the panel to judge. */
|
|
61
66
|
rebuttals: Schema.optional(Schema.Array(Rebuttal)),
|
|
62
67
|
/** The Outcome the change must prove. */
|
|
@@ -75,10 +80,16 @@ const FollowUpStatus = Schema.Literals(['fixed', 'changed', 'still_there'])
|
|
|
75
80
|
|
|
76
81
|
const FollowUp = Schema.Struct({ id: Schema.String, status: FollowUpStatus })
|
|
77
82
|
|
|
83
|
+
const SeatFinding = Schema.Struct({
|
|
84
|
+
...Finding.fields,
|
|
85
|
+
/** In a review since an approved head: the problem is in code the change already had there. */
|
|
86
|
+
approvedCode: Schema.optional(Schema.Boolean)
|
|
87
|
+
})
|
|
88
|
+
|
|
78
89
|
const SeatOutput = Schema.Struct({
|
|
79
90
|
/** One sentence: can it merge, and what matters most. */
|
|
80
91
|
summary: Schema.String,
|
|
81
|
-
findings: Schema.Array(
|
|
92
|
+
findings: Schema.Array(SeatFinding),
|
|
82
93
|
verdicts: Schema.optional(Schema.Array(RebuttalVerdict)),
|
|
83
94
|
scope: Schema.optional(ScopeJudgement),
|
|
84
95
|
followUps: Schema.optional(Schema.Array(FollowUp))
|
|
@@ -88,6 +99,8 @@ const Output = Schema.Struct({
|
|
|
88
99
|
/** What the review leads with: each reviewer's one sentence. */
|
|
89
100
|
summary: Schema.String,
|
|
90
101
|
findings: Schema.Array(MergedFinding),
|
|
102
|
+
/** In a review since an approved head, the findings about code that head already had; they never block. */
|
|
103
|
+
approvedFindings: Schema.optional(Schema.Array(MergedFinding)),
|
|
91
104
|
/** Each earlier finding, as fixed, changed but not fixed, or still there. */
|
|
92
105
|
followUps: Schema.Array(FollowUp),
|
|
93
106
|
verdicts: Schema.Array(RebuttalVerdict),
|
|
@@ -111,6 +124,12 @@ const targetOf = (input: typeof Input.Type, head?: string) => {
|
|
|
111
124
|
if (input.changeRequestId !== undefined)
|
|
112
125
|
return `ChangeRequest ${input.changeRequestId} at revision ${head}. Read it with \`kitman.changeRequests.get("${input.changeRequestId}")\` through Kitman's MCP, fetch its source branch, and review the diff of revision ${head} against its target branch, even if the branch has moved since. If the Runner cannot fetch that revision (a fork, say), report exactly that as your only finding, a blocker, and stop.`
|
|
113
126
|
|
|
127
|
+
if (input.base !== undefined && input.head !== undefined && input.files === undefined && input.approved !== undefined)
|
|
128
|
+
return [
|
|
129
|
+
`only what the change gained or lost since it was approved at ${input.approved}: compare \`git diff ${input.base}...${input.approved}\`, the change as approved, with \`git diff ${input.base}...${input.head}\`, the change now, in your checkout. The rest was reviewed and approved before.`,
|
|
130
|
+
'Report a problem in code the change already had at the approved head only if it matters, with `approvedCode` set to true: such findings are kept apart and do not block.'
|
|
131
|
+
].join('\n\n')
|
|
132
|
+
|
|
114
133
|
if (input.base !== undefined && input.head !== undefined)
|
|
115
134
|
return input.files === undefined
|
|
116
135
|
? `the change \`git diff ${input.base}...${input.head}\` in your checkout.`
|
|
@@ -125,6 +144,9 @@ const targetOf = (input: typeof Input.Type, head?: string) => {
|
|
|
125
144
|
return undefined
|
|
126
145
|
}
|
|
127
146
|
|
|
147
|
+
/** A review of the whole change judges its scope; one of some files or of a change since an approval does not. */
|
|
148
|
+
const wholeChange = (input: typeof Input.Type) => input.files === undefined && input.approved === undefined
|
|
149
|
+
|
|
128
150
|
const scopePrompt = (input: typeof Input.Type) =>
|
|
129
151
|
[
|
|
130
152
|
"If your brief has a Task, judge its scope and give it as `scope`: does the change do what the Task's description and each of its Acceptance Criteria ask? Set `met` to true only if it does all of it, and list in `unmet` one line for each criterion or part of the description that is not done. If your brief has no Task, leave `scope` out.",
|
|
@@ -150,7 +172,7 @@ const promptFor = (seat: keyof typeof seats, target: string, input: typeof Input
|
|
|
150
172
|
'Give `summary`: one sentence on whether it can merge and what matters most.',
|
|
151
173
|
'Report each problem as a finding: severity blocker (must not ship), major (fix before merge) or minor (optional); the file path from the repository root; the line; and the detail. When it is one instance of a class of bug, name every other instance in the diff in its detail. Report nothing you have not checked in the code.',
|
|
152
174
|
'If the diff is too big to review in one go, review it directory by directory and say so in a finding on the first file you skipped.',
|
|
153
|
-
...(seat === scopeSeat && input
|
|
175
|
+
...(seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : []),
|
|
154
176
|
...(input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)]),
|
|
155
177
|
...(input.failing === undefined || input.failing.length === 0
|
|
156
178
|
? []
|
|
@@ -181,22 +203,23 @@ const followUpsOf = (earlier: readonly MergedFinding[], answers: readonly (typeo
|
|
|
181
203
|
}
|
|
182
204
|
})
|
|
183
205
|
|
|
206
|
+
const findingLines = (findings: readonly MergedFinding[]) =>
|
|
207
|
+
findings
|
|
208
|
+
.map(finding => `- **${finding.severity}** \`${finding.id}\` ${finding.detail} _(${finding.seats.join(', ')})_`)
|
|
209
|
+
.join('\n')
|
|
210
|
+
|
|
184
211
|
const reviewText = (
|
|
185
212
|
summary: string,
|
|
186
213
|
findings: readonly MergedFinding[],
|
|
187
|
-
followUps: readonly (typeof FollowUp.Type)[]
|
|
214
|
+
followUps: readonly (typeof FollowUp.Type)[],
|
|
215
|
+
approvedFindings: readonly MergedFinding[]
|
|
188
216
|
) =>
|
|
189
217
|
[
|
|
190
218
|
`**Kitman review.** ${summary}`,
|
|
191
|
-
...(findings.length === 0
|
|
219
|
+
...(findings.length === 0 ? [] : [findingLines(findings)]),
|
|
220
|
+
...(approvedFindings.length === 0
|
|
192
221
|
? []
|
|
193
|
-
: [
|
|
194
|
-
findings
|
|
195
|
-
.map(
|
|
196
|
-
finding => `- **${finding.severity}** \`${finding.id}\` ${finding.detail} _(${finding.seats.join(', ')})_`
|
|
197
|
-
)
|
|
198
|
-
.join('\n')
|
|
199
|
-
]),
|
|
222
|
+
: [`In code approved before, not blocking:\n${findingLines(approvedFindings)}`]),
|
|
200
223
|
...(followUps.length === 0
|
|
201
224
|
? []
|
|
202
225
|
: [
|
|
@@ -219,7 +242,7 @@ const fixBrief = (changeRequestId: string, findings: readonly MergedFinding[]) =
|
|
|
219
242
|
*/
|
|
220
243
|
export default defineLoop({
|
|
221
244
|
id: 'review',
|
|
222
|
-
version: '3.
|
|
245
|
+
version: '3.4.0',
|
|
223
246
|
title: 'Review',
|
|
224
247
|
input: Input,
|
|
225
248
|
output: Output,
|
|
@@ -290,19 +313,29 @@ export default defineLoop({
|
|
|
290
313
|
const carried = earlier.filter(finding => standing.has(finding.id) && !withdrawn(finding.id))
|
|
291
314
|
const followUps = answered.filter(entry => !withdrawn(entry.id))
|
|
292
315
|
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
316
|
+
const sinceApproval = input.approved !== undefined && input.files === undefined
|
|
317
|
+
|
|
318
|
+
const merged = (approvedCode: boolean) =>
|
|
319
|
+
mergeFindings(
|
|
320
|
+
Object.fromEntries(
|
|
321
|
+
outputs.map(([seat, output]) => [
|
|
322
|
+
seat,
|
|
323
|
+
output.findings.filter(
|
|
324
|
+
finding =>
|
|
325
|
+
!earlierIds.has(`${finding.file}:${finding.line}`) &&
|
|
326
|
+
(sinceApproval && finding.approvedCode === true) === approvedCode
|
|
327
|
+
)
|
|
328
|
+
])
|
|
329
|
+
)
|
|
299
330
|
)
|
|
300
|
-
|
|
331
|
+
|
|
332
|
+
const fresh = merged(false)
|
|
333
|
+
const approvedFindings = sinceApproval ? merged(true) : []
|
|
301
334
|
|
|
302
335
|
const findings = [...carried, ...fresh]
|
|
303
336
|
|
|
304
337
|
const blockers = findings.filter(isBlocking)
|
|
305
|
-
const scope = input
|
|
338
|
+
const scope = wholeChange(input) ? outputs.find(([seat]) => seat === scopeSeat)?.[1].scope : undefined
|
|
306
339
|
const failing = input.failing ?? []
|
|
307
340
|
|
|
308
341
|
// A seat's own summary is kept only when nothing blocks, so it cannot contradict the verdict.
|
|
@@ -314,17 +347,19 @@ export default defineLoop({
|
|
|
314
347
|
: failing.length > 0
|
|
315
348
|
? `Not ready: ${failing.join(', ')} fails on this head.`
|
|
316
349
|
: findings.length === 0
|
|
317
|
-
?
|
|
350
|
+
? sinceApproval
|
|
351
|
+
? `No findings in what changed since ${input.approved}: nothing stands in the way of merging.`
|
|
352
|
+
: 'No findings: nothing stands in the way of merging.'
|
|
318
353
|
: ['Can merge: nothing blocks it.', ...outputs.map(([, output]) => output.summary)].join(' ')
|
|
319
354
|
|
|
320
355
|
const freshIds = new Set(fresh.map(finding => finding.id))
|
|
321
|
-
const text = reviewText(summary, findings, followUps)
|
|
356
|
+
const text = reviewText(summary, findings, followUps, approvedFindings)
|
|
322
357
|
|
|
323
358
|
const stored = yield* artifact('findings', {
|
|
324
359
|
kind: 'review-findings',
|
|
325
360
|
title: 'Review findings',
|
|
326
361
|
text,
|
|
327
|
-
data: { findings, followUps }
|
|
362
|
+
data: { findings, followUps, ...(approvedFindings.length === 0 ? undefined : { approvedFindings }) }
|
|
328
363
|
})
|
|
329
364
|
|
|
330
365
|
const reviewed = {
|
|
@@ -334,6 +369,7 @@ export default defineLoop({
|
|
|
334
369
|
verdicts,
|
|
335
370
|
blocking: findings.some(isBlocking),
|
|
336
371
|
artifactId: stored.artifactId,
|
|
372
|
+
...(approvedFindings.length === 0 ? undefined : { approvedFindings }),
|
|
337
373
|
...(scope === undefined ? undefined : { scope })
|
|
338
374
|
}
|
|
339
375
|
|
package/src/shepherd-output.ts
CHANGED
|
@@ -2,7 +2,8 @@ import * as Schema from 'effect/Schema'
|
|
|
2
2
|
|
|
3
3
|
/** Shepherd's Output, outside shepherd.ts so Build can import it without the review → build → shepherd cycle. */
|
|
4
4
|
export const ShepherdOutput = Schema.Struct({
|
|
5
|
-
|
|
5
|
+
/** handed_back: its fix rounds ran out, and the ChangeRequest goes back to Build with what is still open. */
|
|
6
|
+
status: Schema.Literals(['merged', 'ready', 'needs_you', 'handed_back']),
|
|
6
7
|
/** Why it stopped, in a line a person can act on. */
|
|
7
8
|
reason: Schema.String,
|
|
8
9
|
fixRounds: Schema.Int,
|
|
@@ -10,5 +11,15 @@ export const ShepherdOutput = Schema.Struct({
|
|
|
10
11
|
/** The Release it started after merging, when it was told to release. */
|
|
11
12
|
release: Schema.optional(
|
|
12
13
|
Schema.Struct({ runStatus: Schema.String, reason: Schema.String, tag: Schema.optional(Schema.String) })
|
|
14
|
+
),
|
|
15
|
+
/** The Build its offer starts when it hands the ChangeRequest back: that ChangeRequest, and what is still open. */
|
|
16
|
+
handBack: Schema.optional(
|
|
17
|
+
Schema.Struct({
|
|
18
|
+
changeRequestId: Schema.String,
|
|
19
|
+
words: Schema.String,
|
|
20
|
+
taskId: Schema.optional(Schema.String),
|
|
21
|
+
/** The ChangeRequest's target, which Build merges into. */
|
|
22
|
+
branch: Schema.optional(Schema.String)
|
|
23
|
+
})
|
|
13
24
|
)
|
|
14
25
|
})
|