@kitman-sh/software-engineering 0.14.8 → 0.15.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.
- package/CHANGELOG.md +118 -0
- package/agents/releaser.md +3 -3
- package/dist/bundle.js +12562 -5360
- package/dist/declarations.json +139340 -4561
- package/kitman.config.ts +163 -2
- package/package.json +4 -3
- package/src/agents.ts +10 -0
- package/src/approved.ts +219 -0
- package/src/backport-schemas.ts +46 -0
- package/src/backport.ts +110 -0
- package/src/build-schemas.ts +135 -0
- package/src/build.ts +202 -739
- package/src/change-request-body.ts +22 -3
- package/src/delivery.ts +26 -6
- package/src/deploy.ts +661 -0
- package/src/errand.ts +124 -76
- package/src/file-tasks.ts +17 -10
- package/src/firewatch.ts +191 -82
- package/src/hillclimb.ts +563 -273
- package/src/hindsight.ts +154 -100
- package/src/implemented.ts +143 -0
- package/src/index.ts +511 -12
- package/src/land-epic.ts +30 -19
- package/src/land.ts +293 -0
- package/src/landed.ts +30 -0
- package/src/opened.ts +79 -0
- package/src/plan-review.ts +7 -8
- package/src/plan.ts +717 -432
- package/src/project-update.ts +50 -11
- package/src/rallied.ts +535 -0
- package/src/release-set.ts +370 -0
- package/src/release.ts +1402 -573
- package/src/reproduced.ts +82 -0
- package/src/research.ts +53 -37
- package/src/revert.ts +331 -0
- package/src/review.ts +466 -250
- package/src/shepherd-output.ts +81 -35
- package/src/shepherd.ts +2109 -1304
- package/src/standing.ts +165 -0
- package/src/suggested-check.ts +8 -0
- package/src/sweep.ts +432 -253
- package/src/tidy.ts +239 -156
package/src/standing.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { ask, call, ChangeRequestResult, MergedFinding, note, step } from '@kitman-sh/sdk/loop'
|
|
2
|
+
import * as Effect from 'effect/Effect'
|
|
3
|
+
import * as Schema from 'effect/Schema'
|
|
4
|
+
import * as SchemaTransformation from 'effect/SchemaTransformation'
|
|
5
|
+
import * as Struct from 'effect/Struct'
|
|
6
|
+
import { BuildInput, BuildOutput, Built } from './build-schemas'
|
|
7
|
+
import { rebuildRefusal } from './convergence'
|
|
8
|
+
import { ownDeliveryTarget } from './delivery'
|
|
9
|
+
import { OutOfScopeFinding } from './out-of-scope'
|
|
10
|
+
import { ReviewedScope } from './reviewed-scope'
|
|
11
|
+
|
|
12
|
+
const takenOverAnswer = 'Taken over'
|
|
13
|
+
|
|
14
|
+
const buildAgainAnswer = 'Build again'
|
|
15
|
+
|
|
16
|
+
const blockedAnswer = 'Mark blocked'
|
|
17
|
+
|
|
18
|
+
const standingConstraint = (item: string) => `Settle what an earlier Build left standing: ${item}`
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A list the journal holds null for: what stands before a rebuild beside what stands after it can pass the 256 KiB of one
|
|
22
|
+
* entry.
|
|
23
|
+
*/
|
|
24
|
+
const unjournaled = <Item extends Schema.Codec<unknown, unknown>>(item: Item, description: string) => {
|
|
25
|
+
const list = Schema.Array(item)
|
|
26
|
+
|
|
27
|
+
return Schema.declare(Schema.is(list), {
|
|
28
|
+
toCodecJson: () =>
|
|
29
|
+
Schema.link<typeof list.Type>()(
|
|
30
|
+
Schema.NullOr(list).annotate({ description: `${description} The journal holds null for it.` }),
|
|
31
|
+
SchemaTransformation.transform({
|
|
32
|
+
decode: (held: typeof list.Type | null) => held ?? [],
|
|
33
|
+
encode: (): typeof list.Type | null => null
|
|
34
|
+
})
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A person takes the ChangeRequest from here. */
|
|
40
|
+
export class TakenOver extends Schema.TaggedClass<TakenOver>()('TakenOver', {}) {}
|
|
41
|
+
|
|
42
|
+
/** Another Build ran on the ChangeRequest; `built` is what it made. */
|
|
43
|
+
export class Rebuilt extends Schema.TaggedClass<Rebuilt>()('Rebuilt', { built: Built }) {}
|
|
44
|
+
|
|
45
|
+
/** Build was marked blocked on findings that still stand, so the Task waits on its owner. */
|
|
46
|
+
export class BuildBlocked extends Schema.TaggedError<BuildBlocked>()('BuildBlocked', {
|
|
47
|
+
message: Schema.String
|
|
48
|
+
}) {}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Asks what to do about what a Build left standing on its open ChangeRequest: leave it to a person, build again on the
|
|
52
|
+
* same branch, or mark the Build blocked, which records what stands as a blocker on its Task. Full auto builds again
|
|
53
|
+
* while it may, then marks it blocked rather than wait on a Question nobody answers. The calling Loop lists Build in
|
|
54
|
+
* `calls`.
|
|
55
|
+
*/
|
|
56
|
+
export const standing = step('standing', {
|
|
57
|
+
payload: {
|
|
58
|
+
changeRequest: ChangeRequestResult.annotate({ description: 'The open ChangeRequest.' }),
|
|
59
|
+
unsettled: unjournaled(Schema.String, 'What still stands on it, one line each.'),
|
|
60
|
+
revision: Schema.String.annotate({
|
|
61
|
+
description: "The head the last review read, whose fix a rebuild's first review reviews."
|
|
62
|
+
}),
|
|
63
|
+
findings: Schema.optional(unjournaled(MergedFinding, "That review's open findings, which a rebuild fixes.")),
|
|
64
|
+
outOfScopeFindings: Schema.optional(
|
|
65
|
+
unjournaled(OutOfScopeFinding, "That review's findings kept apart as out of scope.")
|
|
66
|
+
),
|
|
67
|
+
scope: Schema.optional(ReviewedScope).annotate({
|
|
68
|
+
description: "That review's scope judgement, which a rebuild's first review judges again."
|
|
69
|
+
}),
|
|
70
|
+
blockingCounts: Schema.optional(Schema.Array(Schema.Int)).annotate({
|
|
71
|
+
description: "Each Review round's blocking count, first to last: none builds again when they are not converging."
|
|
72
|
+
}),
|
|
73
|
+
again: Schema.Boolean.annotate({
|
|
74
|
+
description:
|
|
75
|
+
'Whether it may build again, unless its Review rounds were not converging; when not, it may be marked blocked instead.'
|
|
76
|
+
}),
|
|
77
|
+
build: Schema.Struct(
|
|
78
|
+
Struct.pick(BuildInput.fields, ['words', 'taskId', 'repoBindingId', 'outcome', 'maxRounds', 'deliversTo'])
|
|
79
|
+
).annotate({ description: "The Build's own Input, which a rebuild is given too." })
|
|
80
|
+
},
|
|
81
|
+
success: Schema.Union([TakenOver, Rebuilt]),
|
|
82
|
+
error: BuildBlocked,
|
|
83
|
+
run: ({
|
|
84
|
+
changeRequest,
|
|
85
|
+
unsettled,
|
|
86
|
+
revision,
|
|
87
|
+
findings,
|
|
88
|
+
outOfScopeFindings,
|
|
89
|
+
scope,
|
|
90
|
+
blockingCounts = [],
|
|
91
|
+
build,
|
|
92
|
+
...given
|
|
93
|
+
}) =>
|
|
94
|
+
Effect.gen(function* () {
|
|
95
|
+
const refusal = rebuildRefusal(blockingCounts)
|
|
96
|
+
const again = given.again && refusal === undefined
|
|
97
|
+
const refused = refusal === undefined ? [] : [`Another Build is not offered: ${refusal}.`]
|
|
98
|
+
|
|
99
|
+
const answer = yield* ask('unsettled', {
|
|
100
|
+
prompt: [
|
|
101
|
+
`The ChangeRequest ${changeRequest.url} is open, but these still stand: ${unsettled.join('; ')}. Build will not land it.`,
|
|
102
|
+
...refused
|
|
103
|
+
].join(' '),
|
|
104
|
+
options: [
|
|
105
|
+
{ value: takenOverAnswer, description: 'A person fixes, rebuts or steers it from here.' },
|
|
106
|
+
again
|
|
107
|
+
? {
|
|
108
|
+
value: buildAgainAnswer,
|
|
109
|
+
description: 'Starts one more Build on this branch, with each of these as a constraint.'
|
|
110
|
+
}
|
|
111
|
+
: {
|
|
112
|
+
value: blockedAnswer,
|
|
113
|
+
description: 'Fails this Build, recording these as a blocker on its Task, and tells its owner.'
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
recommended: takenOverAnswer,
|
|
117
|
+
recommendationReason: 'Build stopped with these unsettled, so the next step is a person’s.',
|
|
118
|
+
// No default: an unattended Run would take it at once even in a gated Team, and finish as partial.
|
|
119
|
+
default: null,
|
|
120
|
+
unattendedAuto: again ? buildAgainAnswer : blockedAnswer
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
if (answer === takenOverAnswer) return new TakenOver()
|
|
124
|
+
|
|
125
|
+
if (answer === blockedAnswer) {
|
|
126
|
+
if (build.taskId !== undefined)
|
|
127
|
+
yield* note('blocked', {
|
|
128
|
+
kind: 'blocker',
|
|
129
|
+
text: [
|
|
130
|
+
`Build stopped without landing ${changeRequest.url}, marked blocked on what still stands:`,
|
|
131
|
+
'',
|
|
132
|
+
...unsettled.map(item => `- ${item}`),
|
|
133
|
+
...(refused.length === 0 ? [] : ['', ...refused])
|
|
134
|
+
].join('\n')
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
return yield* new BuildBlocked({
|
|
138
|
+
message: `The ChangeRequest ${changeRequest.url} is open, and Build was marked blocked on what still stands: ${unsettled.join('; ')}`
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const rebuilt = yield* call(
|
|
143
|
+
'rebuild',
|
|
144
|
+
{ id: 'build', input: BuildInput, output: BuildOutput },
|
|
145
|
+
{
|
|
146
|
+
...(build.words === undefined ? undefined : { words: build.words }),
|
|
147
|
+
...(build.taskId === undefined ? undefined : { taskId: build.taskId }),
|
|
148
|
+
...(build.repoBindingId === undefined ? undefined : { repoBindingId: build.repoBindingId }),
|
|
149
|
+
...(build.outcome === undefined ? undefined : { outcome: build.outcome }),
|
|
150
|
+
...(build.maxRounds === undefined ? undefined : { maxRounds: build.maxRounds }),
|
|
151
|
+
changeRequestId: changeRequest.id,
|
|
152
|
+
land: false,
|
|
153
|
+
// Its first review reviews the fix of what the last review read.
|
|
154
|
+
reviewed: revision,
|
|
155
|
+
...(findings === undefined ? undefined : { earlier: findings }),
|
|
156
|
+
...(outOfScopeFindings === undefined || outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings }),
|
|
157
|
+
...(scope === undefined ? undefined : { scope }),
|
|
158
|
+
...ownDeliveryTarget(build)
|
|
159
|
+
},
|
|
160
|
+
{ constraints: unsettled.map(standingConstraint) }
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return new Rebuilt({ built: Struct.omit(rebuilt, ['changeRequest', 'landed', 'next']) })
|
|
164
|
+
})
|
|
165
|
+
})
|