@kitman-sh/software-engineering 0.10.70 → 0.10.72

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.
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "id": "build",
5
5
  "title": "Build",
6
- "version": "2.2.0",
6
+ "version": "2.3.0",
7
7
  "input": {
8
8
  "type": "object",
9
9
  "properties": {
@@ -267,6 +267,19 @@
267
267
  "additionalProperties": true
268
268
  }
269
269
  },
270
+ "notRun": {
271
+ "anyOf": [
272
+ {
273
+ "type": "array",
274
+ "items": {
275
+ "type": "string"
276
+ }
277
+ },
278
+ {
279
+ "type": "null"
280
+ }
281
+ ]
282
+ },
270
283
  "approval": {
271
284
  "anyOf": [
272
285
  {
@@ -1159,7 +1172,7 @@
1159
1172
  {
1160
1173
  "id": "plan",
1161
1174
  "title": "Plan",
1162
- "version": "2.0.0",
1175
+ "version": "2.1.0",
1163
1176
  "input": {
1164
1177
  "type": "object",
1165
1178
  "properties": {
@@ -2058,7 +2071,7 @@
2058
2071
  {
2059
2072
  "id": "review",
2060
2073
  "title": "Review",
2061
- "version": "3.4.0",
2074
+ "version": "3.5.0",
2062
2075
  "input": {
2063
2076
  "type": "object",
2064
2077
  "properties": {
@@ -2248,6 +2261,19 @@
2248
2261
  }
2249
2262
  ]
2250
2263
  },
2264
+ "notRun": {
2265
+ "anyOf": [
2266
+ {
2267
+ "type": "array",
2268
+ "items": {
2269
+ "type": "string"
2270
+ }
2271
+ },
2272
+ {
2273
+ "type": "null"
2274
+ }
2275
+ ]
2276
+ },
2251
2277
  "next": {
2252
2278
  "anyOf": [
2253
2279
  {
@@ -2562,7 +2588,7 @@
2562
2588
  {
2563
2589
  "id": "shepherd",
2564
2590
  "title": "Shepherd",
2565
- "version": "1.2.0",
2591
+ "version": "1.3.0",
2566
2592
  "input": {
2567
2593
  "type": "object",
2568
2594
  "properties": {
@@ -2589,6 +2615,19 @@
2589
2615
  }
2590
2616
  ]
2591
2617
  },
2618
+ "notRun": {
2619
+ "anyOf": [
2620
+ {
2621
+ "type": "array",
2622
+ "items": {
2623
+ "type": "string"
2624
+ }
2625
+ },
2626
+ {
2627
+ "type": "null"
2628
+ }
2629
+ ]
2630
+ },
2592
2631
  "branch": {
2593
2632
  "anyOf": [
2594
2633
  {
@@ -2835,7 +2874,7 @@
2835
2874
  {
2836
2875
  "id": "sweep",
2837
2876
  "title": "Sweep",
2838
- "version": "1.0.0",
2877
+ "version": "1.1.0",
2839
2878
  "input": {
2840
2879
  "type": "object",
2841
2880
  "properties": {
@@ -3332,7 +3371,7 @@
3332
3371
  "carried": [
3333
3372
  {
3334
3373
  "name": "@kitman-sh/software-engineering",
3335
- "version": "0.10.70",
3374
+ "version": "0.10.72",
3336
3375
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
3337
3376
  "loops": [
3338
3377
  "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/software-engineering",
3
- "version": "0.10.70",
3
+ "version": "0.10.72",
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.70",
20
+ "@kitman-sh/sdk": "0.10.72",
21
21
  "effect": "4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "f4c65f62a3f9c7699a096c7c508729a86836aa61b132f5273586356c441f8eab",
25
+ "digest": "8a10261d484efa7c46223466bec9a57205bdc6fe0395d65ddbe2759de1763cc3",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
package/src/build.ts CHANGED
@@ -21,6 +21,7 @@ import {
21
21
  rallyStop,
22
22
  Rebuttal,
23
23
  settleRound,
24
+ testsNotRunReasons,
24
25
  verify,
25
26
  writeBack,
26
27
  type Disputed,
@@ -128,6 +129,8 @@ export const BuildOutput = Schema.Struct({
128
129
  rounds: Schema.Int,
129
130
  stopped: Schema.Literals(['settled', 'dispute_stands', 'findings_returned', 'round_cap']),
130
131
  criteria: Schema.Array(CriterionAnswer),
132
+ /** Why each head test verify never ran is unverified; absent when it ran them all. */
133
+ notRun: Schema.optional(Schema.Array(Schema.String)),
131
134
  /** Whether the last Review's approval was recorded, or why not, when nothing was left unsettled. */
132
135
  approval: Schema.optional(ApproveChangeRequestResult),
133
136
  /** What Shepherd did with the ChangeRequest, when the Build was told to land it. */
@@ -294,6 +297,7 @@ const rally = (input: {
294
297
  } satisfies Round
295
298
 
296
299
  const failing = brokenChecks(head).map(check => check.name)
300
+ const notRun = testsNotRunReasons(head)
297
301
 
298
302
  const reviewed = yield* call(`review:${round}`, review, {
299
303
  base: input.base,
@@ -302,6 +306,7 @@ const rally = (input: {
302
306
  ...(earlier.length === 0 ? undefined : { earlier }),
303
307
  ...(input.outcome === undefined ? undefined : { outcome: input.outcome }),
304
308
  ...(failing.length === 0 ? undefined : { failing }),
309
+ ...(notRun.length === 0 ? undefined : { notRun }),
305
310
  claims: [...claims]
306
311
  })
307
312
 
@@ -368,7 +373,7 @@ const rally = (input: {
368
373
  */
369
374
  export default defineLoop({
370
375
  id: 'build',
371
- version: '2.2.0',
376
+ version: '2.3.0',
372
377
  title: 'Build',
373
378
  input: BuildInput,
374
379
  output: BuildOutput,
@@ -465,6 +470,8 @@ export default defineLoop({
465
470
  ...(implemented.rollback === undefined ? undefined : { rollback: implemented.rollback })
466
471
  })
467
472
 
473
+ const lastNotRun = testsNotRunReasons(last.head)
474
+
468
475
  // An Outcome's gate may not read every check, so a failing one is reported here too, once.
469
476
  const unsettled = [
470
477
  ...new Set([
@@ -522,6 +529,7 @@ export default defineLoop({
522
529
  input.land !== false && unsettled.length === 0
523
530
  ? yield* call('land', shepherd, {
524
531
  changeRequestId: opened.id,
532
+ ...(lastNotRun.length === 0 ? undefined : { notRun: lastNotRun }),
525
533
  ...(input.taskId === undefined ? undefined : { taskId: input.taskId }),
526
534
  ...(input.branch === undefined ? undefined : { branch: input.branch })
527
535
  })
@@ -546,6 +554,7 @@ export default defineLoop({
546
554
  rounds: last.round,
547
555
  stopped: last.decision.reason,
548
556
  criteria,
557
+ ...(lastNotRun.length === 0 ? undefined : { notRun: lastNotRun }),
549
558
  ...(approval === undefined ? undefined : { approval }),
550
559
  ...(landed === undefined ? undefined : { landed }),
551
560
  next: { changeRequestId: opened.id }
@@ -1,4 +1,13 @@
1
- import type { MergedFinding, RallyDecision, ScopeJudgement, SettledRound, VerifyResult } from '@kitman-sh/sdk/loop'
1
+ import {
2
+ testsNotRunReasons,
3
+ verify,
4
+ type MergedFinding,
5
+ type RallyDecision,
6
+ type ScopeJudgement,
7
+ type SettledRound,
8
+ type VerifyResult
9
+ } from '@kitman-sh/sdk/loop'
10
+ import * as Effect from 'effect/Effect'
2
11
 
3
12
  /** Each part of the Task the reviewer found not done, as a blocker the implementer fixes or rebuts like any other. */
4
13
  export const scopeFindings = (scope: ScopeJudgement | undefined): readonly MergedFinding[] =>
@@ -15,6 +24,27 @@ export const scopeFindings = (scope: ScopeJudgement | undefined): readonly Merge
15
24
  export const brokenChecks = (head: VerifyResult) =>
16
25
  head.unchanged === true ? [] : head.checks.filter(check => check.status === 'failed' && !check.preExisting)
17
26
 
27
+ /** Kitman's refusals of a verify that has no check of its own to run, such as one whose approved checks are all pipeline checks. */
28
+ const nothingToVerify = (reason: string) =>
29
+ reason.includes('has no approved verifications') || reason.includes('approved verifications are all pipeline checks')
30
+
31
+ /**
32
+ * Verify at a ChangeRequest's head: the checks it broke and the tests it never ran. A repository with nothing for verify
33
+ * to run has no skips to compare; a head Kitman otherwise could not verify ran none.
34
+ */
35
+ export const verifyHead = (name: string, revision: string) =>
36
+ verify(name, { revision }).pipe(
37
+ Effect.map(head => ({ failing: brokenChecks(head).map(check => check.name), notRun: testsNotRunReasons(head) })),
38
+ Effect.catchTag('StepFailed', failed =>
39
+ Effect.succeed({
40
+ failing: [],
41
+ notRun: nothingToVerify(failed.reason)
42
+ ? []
43
+ : [`Kitman could not verify the head, so none of its tests count as run: ${failed.reason}`]
44
+ })
45
+ )
46
+ )
47
+
18
48
  export const isCheckFinding = (id: string) => id.startsWith('check: ')
19
49
 
20
50
  /** Each check the change broke, as a blocker with its output, which only the check passing closes. */
@@ -44,8 +74,41 @@ export const unsettledItems = (settled: SettledRound, decision: RallyDecision &
44
74
  return `Unresolved ${settled.open.find(finding => finding.id === id)?.severity ?? 'blocker'} at ${id}: ${settled.open.find(finding => finding.id === id)?.detail ?? ''}`
45
75
  })
46
76
 
47
- export const evidenceTable = (head: VerifyResult) =>
48
- [
77
+ /** The tests the checks skipped on the head where the baseline ran them or did not have them. */
78
+ export const notVerifiedSection = (head: VerifyResult) => {
79
+ const listed = head.checks.flatMap(entry => [
80
+ ...(entry.newNotRun ?? []).map(test => `- ${entry.name}: \`${test}\` is new and was skipped`),
81
+ ...(entry.skippedSinceBaseline ?? []).map(
82
+ test => `- ${entry.name}: \`${test}\` was skipped, and ran on the base branch`
83
+ )
84
+ ])
85
+
86
+ return listed.length === 0
87
+ ? undefined
88
+ : [
89
+ '**Not verified.** Verify never ran these tests, so their checks passing says nothing about them. Run them where they can run before trusting them:',
90
+ '',
91
+ ...listed
92
+ ].join('\n')
93
+ }
94
+
95
+ const unsettledLines = (unsettled: readonly string[], head: VerifyResult) => {
96
+ const listed = new Set(testsNotRunReasons(head))
97
+ const left = unsettled.filter(item => !listed.has(item))
98
+
99
+ if (left.length > 0) return left.map(item => `- ${item}`)
100
+
101
+ return [
102
+ left.length === unsettled.length
103
+ ? 'Nothing is unsettled.'
104
+ : 'Only the tests verify never ran, listed under Evidence.'
105
+ ]
106
+ }
107
+
108
+ export const evidenceTable = (head: VerifyResult) => {
109
+ const notVerified = notVerifiedSection(head)
110
+
111
+ return [
49
112
  `Collected by a Runner for revision \`${head.revision}\`, tree \`${head.tree}\`; it holds for any revision with this tree.`,
50
113
  '',
51
114
  '| Check | Command | Result |',
@@ -54,6 +117,7 @@ export const evidenceTable = (head: VerifyResult) =>
54
117
  entry =>
55
118
  `| ${entry.name}${entry.suggested === true ? ' (suggested by the agent)' : ''} | \`${entry.command}\` | ${entry.status}${entry.status === 'failed' && (entry.preExisting || head.unchanged === true) ? ' (also fails on the base branch)' : ''} |`
56
119
  ),
120
+ ...(notVerified === undefined ? [] : ['', notVerified]),
57
121
  ...(head.checks.some(entry => entry.suggested === true)
58
122
  ? [
59
123
  '',
@@ -61,8 +125,12 @@ export const evidenceTable = (head: VerifyResult) =>
61
125
  ]
62
126
  : [])
63
127
  ].join('\n')
128
+ }
64
129
 
65
- /** A ChangeRequest's description: the summary, the head's evidence, the claims and what was left unsettled. */
130
+ /**
131
+ * A ChangeRequest's description: the summary, the head's evidence, the claims and what was left unsettled, less the
132
+ * tests verify never ran, which the evidence lists.
133
+ */
66
134
  export const changeRequestBody = (build: {
67
135
  readonly summary: string
68
136
  readonly head: VerifyResult
@@ -86,7 +154,7 @@ export const changeRequestBody = (build: {
86
154
  'What the agent says and Kitman has not checked.',
87
155
  ...(build.claims.length === 0 ? ['None.'] : build.claims.map(claim => `- ${claim}`)),
88
156
  '## Unsettled',
89
- ...(build.unsettled.length === 0 ? ['Nothing is unsettled.'] : build.unsettled.map(item => `- ${item}`)),
157
+ ...unsettledLines(build.unsettled, build.head),
90
158
  ...(build.later === undefined || build.later.length === 0
91
159
  ? []
92
160
  : ['## Left for later', ...build.later.map(item => `- ${item}`)]),
package/src/errand.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  changeRequest,
6
6
  ChangeRequestResult,
7
7
  defineLoop,
8
+ testsNotRunReasons,
8
9
  verify,
9
10
  writeBack
10
11
  } from '@kitman-sh/sdk/loop'
@@ -97,17 +98,28 @@ export default defineLoop({
97
98
 
98
99
  const head = yield* verify('verify', { suggested: done.checks ?? [] })
99
100
 
101
+ const notRun = testsNotRunReasons(head)
102
+ const trusted = head.passed && notRun.length === 0
103
+
104
+ const checksSay = !head.passed
105
+ ? 'The checks fail.'
106
+ : notRun.length === 0
107
+ ? 'The checks pass.'
108
+ : `The checks pass, but verify never ran some tests:\n${notRun.map(item => `- ${item}`).join('\n')}`
109
+
100
110
  const answer = yield* ask('next', {
101
- prompt: `${done.summary}\n\nThe checks ${head.passed ? 'pass' : 'fail'}. What next?`,
111
+ prompt: `${done.summary}\n\n${checksSay}\n\nWhat next?`,
102
112
  options: [
103
113
  { value: 'Open a ChangeRequest', description: 'Deliver it as it is, unreviewed.' },
104
114
  { value: 'Hand to Build for a full review', description: 'Build reviews and verifies it before delivering.' },
105
115
  { value: 'Discard', description: 'Drop the change.' }
106
116
  ] satisfies { readonly value: (typeof choices)[number]; readonly description: string }[],
107
- recommended: head.passed ? 'Open a ChangeRequest' : 'Hand to Build for a full review',
108
- recommendationReason: head.passed
117
+ recommended: trusted ? 'Open a ChangeRequest' : 'Hand to Build for a full review',
118
+ recommendationReason: trusted
109
119
  ? 'The checks pass, and an errand is small enough to review on the ChangeRequest.'
110
- : 'The checks fail, so it needs the fixes and review a Build gives before anyone merges it.',
120
+ : head.passed
121
+ ? 'Verify skipped tests it should have run, so it needs the review a Build gives before anyone merges it.'
122
+ : 'The checks fail, so it needs the fixes and review a Build gives before anyone merges it.',
111
123
  default: 'Open a ChangeRequest',
112
124
  timeout: '1 hour'
113
125
  })
package/src/hillclimb.ts CHANGED
@@ -12,13 +12,15 @@ import {
12
12
  measure,
13
13
  MeasurePlan,
14
14
  syncBase,
15
+ testsNotRunReasons,
15
16
  verify,
16
17
  writeBack,
17
- type Measurement
18
+ type Measurement,
19
+ type VerifyResult
18
20
  } from '@kitman-sh/sdk/loop'
19
21
  import * as Effect from 'effect/Effect'
20
22
  import * as Schema from 'effect/Schema'
21
- import { scopeFindings } from './change-request-body'
23
+ import { notVerifiedSection, scopeFindings } from './change-request-body'
22
24
  import review from './review'
23
25
 
24
26
  const Input = Schema.Struct({
@@ -151,6 +153,13 @@ const report = (input: {
151
153
  `## Opportunities\n\n${input.discovery.opportunities.map(entry => `- ${entry.title} (${entry.evidence}${entry.external === true ? ', external' : ''}): ${entry.detail}`).join('\n')}`
152
154
  ].join('\n\n')
153
155
 
156
+ /** Review's `notRun` for a head, left out when verify ran every test. */
157
+ const notRunOf = (head: VerifyResult) => {
158
+ const notRun = testsNotRunReasons(head)
159
+
160
+ return notRun.length === 0 ? undefined : { notRun }
161
+ }
162
+
154
163
  /** Makes the plan's low-variance counter its primary metric, the old primary a guardrail. */
155
164
  const steadier = (plan: MeasurePlan): MeasurePlan | undefined => {
156
165
  const counter = plan.metrics.find(metric => metric.lowVariance === true && metric.role !== 'primary')
@@ -337,10 +346,13 @@ export default defineLoop({
337
346
  ...kept.map(entry => entry.summary)
338
347
  ]
339
348
 
349
+ let head = checked
350
+
340
351
  let reviewed = yield* call('review', review, {
341
352
  base: baseline,
342
353
  head: checked.revision,
343
354
  outcome: 'performance',
355
+ ...notRunOf(checked),
344
356
  claims
345
357
  })
346
358
 
@@ -366,15 +378,21 @@ export default defineLoop({
366
378
  if (final.verdict !== 'gain')
367
379
  return yield* ending('gain_gone', `The review's fixes cost the gain: ${final.reason}`, final)
368
380
 
381
+ head = fixed
382
+
369
383
  reviewed = yield* call(`review:${round + 1}`, review, {
370
384
  base: baseline,
371
385
  head: fixed.revision,
372
386
  outcome: 'performance',
387
+ ...notRunOf(fixed),
373
388
  claims,
374
389
  earlier: blocking
375
390
  })
376
391
  }
377
392
 
393
+ const notRun = testsNotRunReasons(head)
394
+ const notVerified = notVerifiedSection(head)
395
+
378
396
  const unsettled = [
379
397
  ...[...reviewed.findings, ...scopeFindings(reviewed.scope)].flatMap(finding =>
380
398
  isBlocking(finding) ? [`${finding.id}: ${finding.detail}`] : []
@@ -394,6 +412,7 @@ export default defineLoop({
394
412
  numbers(final),
395
413
  `## Kept\n\n${kept.map(entry => `- ${entry.summary}: ${entry.reason}`).join('\n')}`,
396
414
  `## Benchmark\n\n${harness.summary}\n\n\`${plan.command}\``,
415
+ ...(notVerified === undefined ? [] : [notVerified]),
397
416
  ...(unsettled.length + caveats.length === 0
398
417
  ? []
399
418
  : [`## Unsettled\n\n${[...unsettled, ...caveats].map(entry => `- ${entry}`).join('\n')}`])
@@ -402,6 +421,10 @@ export default defineLoop({
402
421
 
403
422
  yield* writeBack('write-back', { milestone: 'change_request_opened', changeRequestUrl: opened.url })
404
423
 
405
- return { ...(yield* ending('improved', final.reason, final)), changeRequest: opened, unsettled }
424
+ return {
425
+ ...(yield* ending('improved', final.reason, final)),
426
+ changeRequest: opened,
427
+ unsettled: [...unsettled, ...notRun]
428
+ }
406
429
  })
407
430
  })
package/src/plan.ts CHANGED
@@ -106,6 +106,8 @@ const menuDescriptions: Record<Choice, string> = {
106
106
 
107
107
  const onConflict = ['Rebuild on the integration branch', 'Skip'] as const
108
108
 
109
+ const onUnverified = ['Skip', 'Merge'] as const
110
+
109
111
  const onFailure = ['Retry with a steer', 'Skip it and its dependents', 'Stop here'] as const
110
112
 
111
113
  const ticketRules = [
@@ -256,9 +258,10 @@ const settled = (ticket: PlanTicket, result: Omit<TicketResult, 'key' | 'title'>
256
258
  })
257
259
 
258
260
  /**
259
- * Builds a ticket from the integration head, then merges its ChangeRequest into the integration branch. On a
260
- * conflict the user chooses to rebuild from the head as it is now, or to give the ticket up. `steer` is a person's
261
- * words for a retry; `label` names its Steps apart from the first try's.
261
+ * Builds a ticket from the integration head, then merges its ChangeRequest into the integration branch. When verify
262
+ * never ran some of its tests, the user chooses to merge it or skip it. On a conflict the user chooses to rebuild from
263
+ * the head as it is now, or to give the ticket up. `steer` is a person's words for a retry; `label` names its Steps
264
+ * apart from the first try's.
262
265
  */
263
266
  const buildTicket = (
264
267
  ticket: PlanTicket,
@@ -293,14 +296,31 @@ const buildTicket = (
293
296
  if (built instanceof ChildFailed)
294
297
  return settled(ticket, { status: 'failed', repoBindingId: head.repoBindingId, reason: built.reason })
295
298
 
299
+ const delivered = { repoBindingId: head.repoBindingId, changeRequest: built.changeRequest }
300
+
301
+ if (built.notRun !== undefined && built.notRun.length > 0) {
302
+ const unverified = yield* ask(`unverified:${name}${suffix}`, {
303
+ prompt: `Verify never ran some tests of the ChangeRequest for ${ticket.key} (${built.changeRequest.url}):\n${built.notRun.map(item => `- ${item}`).join('\n')}\n\nMerge it once they pass by hand, or skip it and the tickets it blocks?`,
304
+ options: [
305
+ { value: 'Skip', description: 'Leaves it and the tickets it blocks unmerged.' },
306
+ { value: 'Merge', description: 'Merges it into the integration branch, for when the tests pass by hand.' }
307
+ ] satisfies { readonly value: (typeof onUnverified)[number]; readonly description: string }[],
308
+ recommended: 'Skip',
309
+ recommendationReason: 'Nobody has seen these tests pass, so merging would land them as if they had.',
310
+ default: 'Skip',
311
+ timeout: '1 day'
312
+ })
313
+
314
+ if (unverified === 'Skip')
315
+ return settled(ticket, { status: 'skipped', ...delivered, reason: 'Verify never ran some of its tests' })
316
+ }
317
+
296
318
  // Only what the Build verified merges; a commit pushed to its branch since is rebuilt or skipped like a conflict.
297
319
  const merged = yield* mergeChangeRequest(`merge:${name}${suffix}`, {
298
320
  changeRequestId: built.changeRequest.id,
299
321
  head: built.revision
300
322
  })
301
323
 
302
- const delivered = { repoBindingId: head.repoBindingId, changeRequest: built.changeRequest }
303
-
304
324
  if (merged.status === 'merged') return settled(ticket, { status: 'merged', ...delivered })
305
325
 
306
326
  const choice = yield* ask(`conflict:${name}${suffix}`, {
@@ -478,7 +498,7 @@ const implement = (input: typeof Input.Type, plan: Plan, revision: number, filed
478
498
  */
479
499
  export default defineLoop({
480
500
  id: 'plan',
481
- version: '2.0.0',
501
+ version: '2.1.0',
482
502
  title: 'Plan',
483
503
  input: Input,
484
504
  output: Output,
package/src/review.ts CHANGED
@@ -20,6 +20,7 @@ import {
20
20
  import * as Effect from 'effect/Effect'
21
21
  import * as Schema from 'effect/Schema'
22
22
  import build, { BuildInput, BuildOutput } from './build'
23
+ import { verifyHead } from './change-request-body'
23
24
 
24
25
  /** Build, by its schemas: the module imports this one, so its definition is not ready when this one loads. */
25
26
  const buildLoop = () => ({ id: 'build', input: BuildInput, output: BuildOutput })
@@ -72,6 +73,8 @@ const Input = Schema.Struct({
72
73
  earlier: Schema.optional(Schema.Array(MergedFinding)),
73
74
  /** The checks that fail on the head and pass on the base, which the implementer is already told. */
74
75
  failing: Schema.optional(Schema.Array(Schema.String)),
76
+ /** Why each head test verify never ran is unverified; a ChangeRequest's head is verified here too. */
77
+ notRun: Schema.optional(Schema.Array(Schema.String)),
75
78
  /** What to do after a ChangeRequest's review without asking; Done when nobody answers. */
76
79
  next: Schema.optional(Schema.Literals(choices))
77
80
  })
@@ -165,7 +168,13 @@ const earlierPrompt = (earlier: readonly MergedFinding[]) =>
165
168
  ...earlier.map(finding => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
166
169
  ].join('\n')
167
170
 
168
- const promptFor = (seat: keyof typeof seats, target: string, input: typeof Input.Type) =>
171
+ const promptFor = (
172
+ seat: keyof typeof seats,
173
+ target: string,
174
+ input: typeof Input.Type,
175
+ failing: readonly string[],
176
+ notRun: readonly string[]
177
+ ) =>
169
178
  [
170
179
  `You are one of two reviewers. Follow your \`${seats[seat].skill}\` skill; if you do not have it: ${seats[seat].focus}`,
171
180
  `Review ${target}`,
@@ -174,10 +183,18 @@ const promptFor = (seat: keyof typeof seats, target: string, input: typeof Input
174
183
  '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.',
175
184
  ...(seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : []),
176
185
  ...(input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)]),
177
- ...(input.failing === undefined || input.failing.length === 0
186
+ ...(failing.length === 0
187
+ ? []
188
+ : [
189
+ `These checks fail on this head and pass on the base: ${failing.join(', ')}. The implementer has their output, so do not report them as findings, and do not say it can merge while they fail.`
190
+ ]),
191
+ ...(notRun.length === 0
178
192
  ? []
179
193
  : [
180
- `These checks fail on this head and pass on the base: ${input.failing.join(', ')}. The implementer has their output, so do not report them as findings, and do not say it can merge while they fail.`
194
+ [
195
+ 'Verify never ran these tests: its checks passed with them skipped. Treat what they test as unverified, not as passing; read each in the code, report one that looks wrong as a finding, and do not say it can merge on their strength.',
196
+ ...notRun.map(item => `- ${item}`)
197
+ ].join('\n')
181
198
  ]),
182
199
  ...(input.rebuttals === undefined || input.rebuttals.length === 0
183
200
  ? []
@@ -212,10 +229,14 @@ const reviewText = (
212
229
  summary: string,
213
230
  findings: readonly MergedFinding[],
214
231
  followUps: readonly (typeof FollowUp.Type)[],
215
- approvedFindings: readonly MergedFinding[]
232
+ approvedFindings: readonly MergedFinding[],
233
+ notRun: readonly string[]
216
234
  ) =>
217
235
  [
218
236
  `**Kitman review.** ${summary}`,
237
+ ...(notRun.length === 0
238
+ ? []
239
+ : [`Verify never ran these tests, so they are unverified:\n${notRun.map(item => `- ${item}`).join('\n')}`]),
219
240
  ...(findings.length === 0 ? [] : [findingLines(findings)]),
220
241
  ...(approvedFindings.length === 0
221
242
  ? []
@@ -236,13 +257,14 @@ const fixBrief = (changeRequestId: string, findings: readonly MergedFinding[]) =
236
257
  /**
237
258
  * Reviews a ChangeRequest or a revision range with two reviewer Agents, one following the `code-review` skill and one
238
259
  * `code-review-and-quality`, and writes one review from their findings, each said once. Given an earlier review's
239
- * findings it follows them up, keeping their ids. On a ChangeRequest it approves the head it reviewed when nothing
240
- * blocks it, unless it wrote the change, then asks what next and posts only when told to, as one summary
241
- * comment it edits on later reviews.
260
+ * findings it follows them up, keeping their ids. On a ChangeRequest it verifies the head it reviews against the
261
+ * ChangeRequest's target and approves it when nothing blocks it, none of its checks broke and verify ran all of its
262
+ * tests, unless it wrote the change, then asks what next and posts only when told to, as one summary comment it edits
263
+ * on later reviews.
242
264
  */
243
265
  export default defineLoop({
244
266
  id: 'review',
245
- version: '3.4.0',
267
+ version: '3.5.0',
246
268
  title: 'Review',
247
269
  input: Input,
248
270
  output: Output,
@@ -279,12 +301,18 @@ export default defineLoop({
279
301
  if (target === undefined)
280
302
  return yield* new ReviewTargetMissing({ message: 'Name a ChangeRequest, or both base and head revisions' })
281
303
 
304
+ // Evidence Kitman holds for the head's tree is reused.
305
+ const verified = head === undefined ? { failing: [], notRun: [] } : yield* verifyHead('verify', head)
306
+
307
+ const failing = [...new Set([...(input.failing ?? []), ...verified.failing])]
308
+ const notRun = [...new Set([...(input.notRun ?? []), ...verified.notRun])]
309
+
282
310
  const outputs = yield* Effect.forEach(
283
311
  seatNames,
284
312
  seat =>
285
313
  agentWork(`review:${seat}`, {
286
314
  agent: seat,
287
- prompt: promptFor(seat, target, input),
315
+ prompt: promptFor(seat, target, input, failing, notRun),
288
316
  output: SeatOutput
289
317
  }).pipe(Effect.map(output => [seat, output] as const)),
290
318
  { concurrency: 'unbounded' }
@@ -336,7 +364,6 @@ export default defineLoop({
336
364
 
337
365
  const blockers = findings.filter(isBlocking)
338
366
  const scope = wholeChange(input) ? outputs.find(([seat]) => seat === scopeSeat)?.[1].scope : undefined
339
- const failing = input.failing ?? []
340
367
 
341
368
  // A seat's own summary is kept only when nothing blocks, so it cannot contradict the verdict.
342
369
  const summary =
@@ -346,14 +373,16 @@ export default defineLoop({
346
373
  ? 'Not ready: the change does not yet do what was asked.'
347
374
  : failing.length > 0
348
375
  ? `Not ready: ${failing.join(', ')} fails on this head.`
349
- : findings.length === 0
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.'
353
- : ['Can merge: nothing blocks it.', ...outputs.map(([, output]) => output.summary)].join(' ')
376
+ : notRun.length > 0
377
+ ? 'Not ready: verify never ran some of its tests, so they are unverified.'
378
+ : findings.length === 0
379
+ ? sinceApproval
380
+ ? `No findings in what changed since ${input.approved}: nothing stands in the way of merging.`
381
+ : 'No findings: nothing stands in the way of merging.'
382
+ : ['Can merge: nothing blocks it.', ...outputs.map(([, output]) => output.summary)].join(' ')
354
383
 
355
384
  const freshIds = new Set(fresh.map(finding => finding.id))
356
- const text = reviewText(summary, findings, followUps, approvedFindings)
385
+ const text = reviewText(summary, findings, followUps, approvedFindings, notRun)
357
386
 
358
387
  const stored = yield* artifact('findings', {
359
388
  kind: 'review-findings',
@@ -378,7 +407,7 @@ export default defineLoop({
378
407
  if (changeRequestId === undefined || head === undefined) return reviewed
379
408
 
380
409
  const approval =
381
- reviewed.blocking || scope?.met === false || failing.length > 0
410
+ reviewed.blocking || scope?.met === false || failing.length > 0 || notRun.length > 0
382
411
  ? undefined
383
412
  : yield* approveChangeRequest('approve', { changeRequestId, head, summary }).pipe(
384
413
  Effect.map(result =>
@@ -396,10 +425,12 @@ export default defineLoop({
396
425
  { value: 'Build from it', description: 'A Build fixes them in a new ChangeRequest.' },
397
426
  { value: 'Done', description: 'Keeps the review as an artifact and stops.' }
398
427
  ] satisfies { readonly value: (typeof choices)[number]; readonly description: string }[],
399
- recommended: reviewed.blocking ? 'Fix here' : 'Done',
428
+ recommended: reviewed.blocking ? 'Fix here' : notRun.length > 0 ? 'Post to the ChangeRequest' : 'Done',
400
429
  recommendationReason: reviewed.blocking
401
430
  ? 'A blocking finding stops the merge, and fixing it here is the shortest way through.'
402
- : 'Nothing blocks the merge, so the findings can wait in the Run.',
431
+ : notRun.length > 0
432
+ ? 'Verify never ran some of its tests, so whoever merges it needs to know to run them first.'
433
+ : 'Nothing blocks the merge, so the findings can wait in the Run.',
403
434
  default: 'Done',
404
435
  timeout: '1 hour'
405
436
  }))