@kitman-sh/software-engineering 0.10.74 → 0.10.76

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 CHANGED
@@ -19835,6 +19835,11 @@ var SecretName2 = String5.check(isPattern2(new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"
19835
19835
  var SecretScope = Union2([Literal2("workspace"), Literal2("team")]);
19836
19836
  var SecretHost = String5.check(isPattern2(new RegExp("^(\\*\\.)?[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*(?::[0-9]{1,5})?$", "u")), isMaxLength(260));
19837
19837
  var SecretHosts = ArraySchema(SecretHost).check(isMaxLength(32));
19838
+ var referencePattern = /secret:\/\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+/;
19839
+ var placeholderMarker = "kitmanref";
19840
+ var tokenCharacter = "[A-Za-z0-9._~+/-]";
19841
+ var placeholderPattern = new RegExp(`(?<!${tokenCharacter})(?:proxy-ep=[A-Za-z0-9.-]+;)?${tokenCharacter}*${placeholderMarker}((?:[0-9a-f]{2})+)`);
19842
+ var anyReference = new RegExp(`${referencePattern.source}|${placeholderPattern.source}`, "g");
19838
19843
  var SecretSummary = Struct({
19839
19844
  name: SecretName2,
19840
19845
  scope: SecretScope,
@@ -21394,11 +21399,14 @@ var threadLine = (thread) => [
21394
21399
  ...thread.comments.map((entry) => `${entry.author ?? "someone"}: ${entry.body}`)
21395
21400
  ].join(`
21396
21401
  `);
21397
- var ReviewFix = Struct({ summary: String5 });
21402
+ var ReviewFix = Struct({
21403
+ summary: String5,
21404
+ changed: Boolean3
21405
+ });
21398
21406
  var findingLines2 = (findings) => findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`).join(`
21399
21407
  `);
21400
21408
  var reviewFixPrompt = (reviewed, findings) => [
21401
- `A review of ${reviewed} found these. Fix each blocker and major finding, with a test that shows it where one can. Kitman pushes what you leave.`,
21409
+ `A review of ${reviewed} found these. Fix each blocker and major finding, with a test that shows it where one can. Kitman pushes what you leave; answer changed with whether you left anything.`,
21402
21410
  findingLines2(findings)
21403
21411
  ].join(`
21404
21412
  `);
@@ -21421,7 +21429,7 @@ var repliesPrompt = (threads) => [
21421
21429
  var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
21422
21430
  var shepherd_default = defineLoop({
21423
21431
  id: "shepherd",
21424
- version: "1.3.0",
21432
+ version: "1.4.0",
21425
21433
  title: "Shepherd",
21426
21434
  input: Input3,
21427
21435
  output: Output3,
@@ -21459,6 +21467,7 @@ var shepherd_default = defineLoop({
21459
21467
  let notCarried;
21460
21468
  let behind = false;
21461
21469
  let pushed;
21470
+ let fixedFrom;
21462
21471
  let turn;
21463
21472
  let turns = 0;
21464
21473
  let passes = 0;
@@ -21518,15 +21527,36 @@ ${open}`,
21518
21527
  allowed[kind]++;
21519
21528
  return answer !== handBackAnswer;
21520
21529
  });
21530
+ const reportSteps = { run: "pipeline-report", rerun: "pipeline-rereport", fix: "pipeline-fix-report" };
21521
21531
  const runOnRunner = (step, cycle, head, checks) => gen2(function* () {
21522
21532
  const verification = `pipeline-${step}:${cycle}`;
21523
- const failed = yield* verify(verification, { revision: head, checks }).pipe(as2(undefined), catchTag2("StepFailed", (error) => succeed7(error.reason)));
21524
- if (failed === undefined)
21525
- yield* reportPipeline(`pipeline-${step === "run" ? "report" : "rereport"}:${cycle}`, {
21526
- changeRequestId,
21527
- verification
21528
- });
21529
- return failed;
21533
+ const ran = yield* verify(verification, {
21534
+ ...head === undefined ? undefined : { revision: head },
21535
+ checks
21536
+ }).pipe(map8((result) => ({ revision: result.revision })), catchTag2("StepFailed", (error) => succeed7({ failed: error.reason })));
21537
+ if ("revision" in ran)
21538
+ yield* reportPipeline(`${reportSteps[step]}:${cycle}`, { changeRequestId, verification });
21539
+ return ran;
21540
+ });
21541
+ const pushedByFix = (cycle, pipeline, changed) => gen2(function* () {
21542
+ if (pipeline.runnerChecks === undefined) {
21543
+ if (!changed)
21544
+ return "nothing";
21545
+ const woke = yield* pipelineMoved(`fix-pushed:${cycle}`, changeRequestId, pipeline, "5 minutes").pipe(catchTag2("WaitTimedOut", () => undefined_2));
21546
+ const head = woke?.payload.head;
21547
+ if (!is2(String5)(head) || head === pipeline.head)
21548
+ return "unknown";
21549
+ pushed = { head, stale: 0, by: "the fix" };
21550
+ return "pushed";
21551
+ }
21552
+ const ran = yield* runOnRunner("fix", cycle, undefined, pipeline.runnerChecks);
21553
+ if ("failed" in ran)
21554
+ return done("needs_you", `The pipeline could not run on the Runner: ${ran.failed}`);
21555
+ if (ran.revision === pipeline.head)
21556
+ return "nothing";
21557
+ ranOnRunner.add(ran.revision);
21558
+ pushed = { head: ran.revision, stale: 0, by: "the fix" };
21559
+ return "pushed";
21530
21560
  });
21531
21561
  const checkTarget = (cycle, pipeline) => gen2(function* () {
21532
21562
  const failing = failingJobs(pipeline);
@@ -21599,7 +21629,7 @@ ${open}`,
21599
21629
  notCarried = `the approval was not carried: ${carried.reason}`;
21600
21630
  }
21601
21631
  if (caught !== undefined) {
21602
- pushed = { head: caught.head, stale: 0 };
21632
+ pushed = { head: caught.head, stale: 0, by: "the catch-up" };
21603
21633
  yield* waitFor(`pushed:${cycle}`, {
21604
21634
  event: "change_request.mergeable",
21605
21635
  filter: { changeRequestId, head: caught.head },
@@ -21626,7 +21656,7 @@ ${open}`,
21626
21656
  repository = pipeline.repository ?? repository;
21627
21657
  if (pushed !== undefined && pipeline.head !== pushed.head) {
21628
21658
  if (++pushed.stale > 5)
21629
- return done("needs_you", `The forge still shows ${pipeline.head}, not ${pushed.head} that the catch-up pushed`);
21659
+ return done("needs_you", `The forge still shows ${pipeline.head}, not ${pushed.head} that ${pushed.by} pushed`);
21630
21660
  yield* waitFor(`pushed-again:${cycle}`, {
21631
21661
  event: "change_request.mergeable",
21632
21662
  filter: { changeRequestId, head: pushed.head },
@@ -21636,13 +21666,29 @@ ${open}`,
21636
21666
  continue;
21637
21667
  }
21638
21668
  pushed = undefined;
21669
+ if (fixedFrom !== undefined && pipeline.head !== fixedFrom.head)
21670
+ fixedFrom = undefined;
21671
+ if (fixedFrom !== undefined) {
21672
+ const found = yield* pushedByFix(cycle, pipeline, fixedFrom.changed);
21673
+ if (found === "unknown") {
21674
+ if (++fixedFrom.looks < 3)
21675
+ continue;
21676
+ return done("needs_you", `The fix from ${fixedFrom.head} left a change, but the forge showed no pipeline on a new head after three looks`);
21677
+ }
21678
+ if (found === "nothing")
21679
+ fixedFrom = undefined;
21680
+ else if (found === "pushed")
21681
+ continue;
21682
+ else
21683
+ return found;
21684
+ }
21639
21685
  if (pipeline.status === "none" && pipeline.runnerChecks !== undefined) {
21640
21686
  if (ranOnRunner.has(pipeline.head))
21641
21687
  return done("needs_you", `The pipeline ran on the Runner at ${pipeline.head}, but no result was recorded`);
21642
21688
  ranOnRunner.add(pipeline.head);
21643
- const failed = yield* runOnRunner("run", cycle, pipeline.head, pipeline.runnerChecks);
21644
- if (failed !== undefined)
21645
- return done("needs_you", `The pipeline could not run on the Runner: ${failed}`);
21689
+ const ran = yield* runOnRunner("run", cycle, pipeline.head, pipeline.runnerChecks);
21690
+ if ("failed" in ran)
21691
+ return done("needs_you", `The pipeline could not run on the Runner: ${ran.failed}`);
21646
21692
  continue;
21647
21693
  }
21648
21694
  if (pipeline.status === "none" || pipeline.status === "running") {
@@ -21697,8 +21743,10 @@ ${open}`,
21697
21743
  output: CiFix,
21698
21744
  timeout: stepBudget
21699
21745
  });
21700
- if (fixed.verdict === "fixed")
21746
+ if (fixed.verdict === "fixed") {
21701
21747
  rounds["ci-fix"]++;
21748
+ fixedFrom = { head: pipeline.head, changed: true, looks: 0 };
21749
+ }
21702
21750
  if (fixed.verdict === "pre_existing") {
21703
21751
  const stopped = yield* waitOutTarget(cycle, pipeline, `the failure is pre-existing on the target branch: ${fixed.summary}`);
21704
21752
  if (stopped !== undefined)
@@ -21712,9 +21760,9 @@ ${open}`,
21712
21760
  if (reranHeads.has(pipeline.head))
21713
21761
  return done("needs_you", `The failing job failed again when run again on the Runner: ${fixed.summary}`);
21714
21762
  reranHeads.add(pipeline.head);
21715
- const failed = yield* runOnRunner("rerun", cycle, pipeline.head, pipeline.runnerChecks);
21716
- if (failed !== undefined)
21717
- return done("needs_you", `The pipeline could not run on the Runner: ${failed}`);
21763
+ const ran = yield* runOnRunner("rerun", cycle, pipeline.head, pipeline.runnerChecks);
21764
+ if ("failed" in ran)
21765
+ return done("needs_you", `The pipeline could not run on the Runner: ${ran.failed}`);
21718
21766
  continue;
21719
21767
  }
21720
21768
  if (reranHeads.has(pipeline.head))
@@ -21785,13 +21833,14 @@ ${open}`,
21785
21833
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
21786
21834
  return handBack(`The review of the catch-up merge's files still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking));
21787
21835
  rounds["head-fix"]++;
21788
- yield* agentWork(`review-fix:${cycle}`, {
21836
+ const fix = yield* agentWork(`review-fix:${cycle}`, {
21789
21837
  agent: "implementer",
21790
21838
  prompt: reviewFixPrompt("the files the catch-up merge changed", blocking),
21791
21839
  output: ReviewFix,
21792
21840
  timeout: stepBudget
21793
21841
  });
21794
21842
  unreviewed = { ...files, earlier: reviewed.findings };
21843
+ fixedFrom = { head, changed: fix.changed, looks: 0 };
21795
21844
  continue;
21796
21845
  }
21797
21846
  const approval = yield* approveChangeRequest(`approve:${cycle}`, {
@@ -21865,13 +21914,14 @@ ${open}`,
21865
21914
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
21866
21915
  return handBack(`The review of ${head} still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking));
21867
21916
  rounds["head-fix"]++;
21868
- yield* agentWork(`head-fix:${cycle}`, {
21917
+ const fix = yield* agentWork(`head-fix:${cycle}`, {
21869
21918
  agent: "implementer",
21870
21919
  prompt: reviewFixPrompt(since === undefined ? `the change at ${head}` : `what changed between ${since} and ${head}`, blocking),
21871
21920
  output: ReviewFix,
21872
21921
  timeout: stepBudget
21873
21922
  });
21874
21923
  headFindings = reviewed.findings;
21924
+ fixedFrom = { head, changed: fix.changed, looks: 0 };
21875
21925
  continue;
21876
21926
  }
21877
21927
  headFindings = [];
@@ -29925,4 +29975,4 @@ var runKit = (config, identity, packages) => {
29925
29975
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
29926
29976
  };
29927
29977
  // .kitman-build-entry.ts
29928
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.74" }, []);
29978
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.76" }, []);
@@ -2588,7 +2588,7 @@
2588
2588
  {
2589
2589
  "id": "shepherd",
2590
2590
  "title": "Shepherd",
2591
- "version": "1.3.0",
2591
+ "version": "1.4.0",
2592
2592
  "input": {
2593
2593
  "type": "object",
2594
2594
  "properties": {
@@ -3371,7 +3371,7 @@
3371
3371
  "carried": [
3372
3372
  {
3373
3373
  "name": "@kitman-sh/software-engineering",
3374
- "version": "0.10.74",
3374
+ "version": "0.10.76",
3375
3375
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
3376
3376
  "loops": [
3377
3377
  "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/software-engineering",
3
- "version": "0.10.74",
3
+ "version": "0.10.76",
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.74",
20
+ "@kitman-sh/sdk": "0.10.76",
21
21
  "effect": "4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "43f17244831f3518094755134e8ab5904a3a68ad888d2b52995d0e3952f6c83d",
25
+ "digest": "b4e95b0c8f4903ce4470016ecfe7a3f4b2e06596609cad0c60bd5bd73690f661",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
package/src/shepherd.ts CHANGED
@@ -141,14 +141,18 @@ const threadLine = (thread: ReviewThreads['threads'][number]) =>
141
141
  ...thread.comments.map(entry => `${entry.author ?? 'someone'}: ${entry.body}`)
142
142
  ].join('\n')
143
143
 
144
- const ReviewFix = Schema.Struct({ summary: Schema.String })
144
+ const ReviewFix = Schema.Struct({
145
+ summary: Schema.String,
146
+ /** Whether it left a change for Kitman to push. */
147
+ changed: Schema.Boolean
148
+ })
145
149
 
146
150
  const findingLines = (findings: readonly MergedFinding[]) =>
147
151
  findings.map(finding => `- ${finding.id} (${finding.severity}): ${finding.detail}`).join('\n')
148
152
 
149
153
  const reviewFixPrompt = (reviewed: string, findings: readonly MergedFinding[]) =>
150
154
  [
151
- `A review of ${reviewed} found these. Fix each blocker and major finding, with a test that shows it where one can. Kitman pushes what you leave.`,
155
+ `A review of ${reviewed} found these. Fix each blocker and major finding, with a test that shows it where one can. Kitman pushes what you leave; answer changed with whether you left anything.`,
152
156
  findingLines(findings)
153
157
  ].join('\n')
154
158
 
@@ -189,12 +193,13 @@ const threadKey = (thread: ReviewThreads['threads'][number]) => `${thread.id}:${
189
193
  * each new review thread on the thread, merges the target branch in when it is behind, and merges once approved, green
190
194
  * and mergeable when told to or when a person says so. It merges the target in and merges only while it holds the
191
195
  * target's turn, so ChangeRequests for one target land one at a time, in order. A head nobody approved gets a review
192
- * of what changed since the last approved head. It runs one ci-fix and two head-fix rounds, then hands the
193
- * ChangeRequest back to Build, and stops as needs you, with why, instead of spinning.
196
+ * of what changed since the last approved head. It runs one ci-fix and two head-fix rounds, each judged by the
197
+ * pipeline at the head the last fix pushed, then hands the ChangeRequest back to Build, and stops as needs you, with
198
+ * why, instead of spinning.
194
199
  */
195
200
  export default defineLoop({
196
201
  id: 'shepherd',
197
- version: '1.3.0',
202
+ version: '1.4.0',
198
203
  title: 'Shepherd',
199
204
  input: Input,
200
205
  output: Output,
@@ -249,8 +254,14 @@ export default defineLoop({
249
254
  let notCarried: string | undefined
250
255
  // The last merge did not go in as the ChangeRequest is: its target moved on, or it conflicts.
251
256
  let behind = false
252
- /** The head a catch-up merge pushed, until the forge shows it, and how many reads showed another. */
253
- let pushed: { readonly head: string; stale: number } | undefined
257
+ /** The head a catch-up merge or a fix pushed, until the forge shows it, how many reads showed another, and who pushed it. */
258
+ let pushed: { readonly head: string; stale: number; readonly by: string } | undefined
259
+
260
+ /**
261
+ * The head the last fix round started from, until a read shows another or the round is known to have pushed
262
+ * nothing; whether the round says it left a change, and how many looks found no pipeline on its push.
263
+ */
264
+ let fixedFrom: { readonly head: string; readonly changed: boolean; looks: number } | undefined
254
265
 
255
266
  /** The target's turn: held from the sync before the merge until the merge, so one ChangeRequest merges at a time. */
256
267
  let turn: Claim | undefined
@@ -337,23 +348,66 @@ export default defineLoop({
337
348
  return answer !== handBackAnswer
338
349
  })
339
350
 
340
- /** Runs the repository's pipeline on a Runner at `head` and reports it; the reason when it could not run. */
341
- const runOnRunner = (step: 'run' | 'rerun', cycle: number, head: string, checks: readonly string[]) =>
351
+ const reportSteps = { run: 'pipeline-report', rerun: 'pipeline-rereport', fix: 'pipeline-fix-report' } as const
352
+
353
+ /**
354
+ * Runs the repository's pipeline on a Runner at `head`, the Run's own head when left out, and reports it: the
355
+ * revision it ran at, or the reason it could not run.
356
+ */
357
+ const runOnRunner = (
358
+ step: keyof typeof reportSteps,
359
+ cycle: number,
360
+ head: string | undefined,
361
+ checks: readonly string[]
362
+ ) =>
342
363
  Effect.gen(function* () {
343
364
  const verification = `pipeline-${step}:${cycle}`
344
365
 
345
- const failed = yield* verify(verification, { revision: head, checks }).pipe(
346
- Effect.as(undefined),
347
- Effect.catchTag('StepFailed', error => Effect.succeed(error.reason))
366
+ const ran = yield* verify(verification, {
367
+ ...(head === undefined ? undefined : { revision: head }),
368
+ checks
369
+ }).pipe(
370
+ Effect.map(result => ({ revision: result.revision })),
371
+ Effect.catchTag('StepFailed', error => Effect.succeed({ failed: error.reason }))
348
372
  )
349
373
 
350
- if (failed === undefined)
351
- yield* reportPipeline(`pipeline-${step === 'run' ? 'report' : 'rereport'}:${cycle}`, {
352
- changeRequestId,
353
- verification
354
- })
374
+ if ('revision' in ran) yield* reportPipeline(`${reportSteps[step]}:${cycle}`, { changeRequestId, verification })
375
+
376
+ return ran
377
+ })
378
+
379
+ /**
380
+ * What the last fix round pushed from `pipeline`, the head it started from, which the forge can show for a while
381
+ * after the push: on a Runner it runs the pipeline at the Run's own head, which is what the round pushed; otherwise
382
+ * the head of the forge's next pipeline says, and a round that left a change but has no such pipeline yet is
383
+ * `unknown`. The Output to stop with, when the pipeline cannot run.
384
+ */
385
+ const pushedByFix = (cycle: number, pipeline: PipelineStatus, changed: boolean) =>
386
+ Effect.gen(function* () {
387
+ if (pipeline.runnerChecks === undefined) {
388
+ if (!changed) return 'nothing' as const
389
+
390
+ const woke = yield* pipelineMoved(`fix-pushed:${cycle}`, changeRequestId, pipeline, '5 minutes').pipe(
391
+ Effect.catchTag('WaitTimedOut', () => Effect.undefined)
392
+ )
393
+
394
+ const head = woke?.payload.head
355
395
 
356
- return failed
396
+ if (!Schema.is(Schema.String)(head) || head === pipeline.head) return 'unknown' as const
397
+ pushed = { head, stale: 0, by: 'the fix' }
398
+
399
+ return 'pushed' as const
400
+ }
401
+
402
+ const ran = yield* runOnRunner('fix', cycle, undefined, pipeline.runnerChecks)
403
+
404
+ if ('failed' in ran) return done('needs_you', `The pipeline could not run on the Runner: ${ran.failed}`)
405
+
406
+ if (ran.revision === pipeline.head) return 'nothing' as const
407
+ ranOnRunner.add(ran.revision)
408
+ pushed = { head: ran.revision, stale: 0, by: 'the fix' }
409
+
410
+ return 'pushed' as const
357
411
  })
358
412
 
359
413
  /**
@@ -469,7 +523,7 @@ export default defineLoop({
469
523
 
470
524
  // The forge can show the old head for a moment after the push; the next look reads it once it shows this one.
471
525
  if (caught !== undefined) {
472
- pushed = { head: caught.head, stale: 0 }
526
+ pushed = { head: caught.head, stale: 0, by: 'the catch-up' }
473
527
 
474
528
  yield* waitFor(`pushed:${cycle}`, {
475
529
  event: 'change_request.mergeable',
@@ -506,7 +560,7 @@ export default defineLoop({
506
560
  if (++pushed.stale > 5)
507
561
  return done(
508
562
  'needs_you',
509
- `The forge still shows ${pipeline.head}, not ${pushed.head} that the catch-up pushed`
563
+ `The forge still shows ${pipeline.head}, not ${pushed.head} that ${pushed.by} pushed`
510
564
  )
511
565
 
512
566
  // Only an Event since this read settles it, so the one that settled the last wait does not end it at once.
@@ -522,15 +576,35 @@ export default defineLoop({
522
576
 
523
577
  pushed = undefined
524
578
 
579
+ // The round limit judges only the pipeline at the head the last fix left, so a push the read misses goes first.
580
+ if (fixedFrom !== undefined && pipeline.head !== fixedFrom.head) fixedFrom = undefined
581
+
582
+ if (fixedFrom !== undefined) {
583
+ const found = yield* pushedByFix(cycle, pipeline, fixedFrom.changed)
584
+
585
+ if (found === 'unknown') {
586
+ if (++fixedFrom.looks < 3) continue
587
+
588
+ return done(
589
+ 'needs_you',
590
+ `The fix from ${fixedFrom.head} left a change, but the forge showed no pipeline on a new head after three looks`
591
+ )
592
+ }
593
+
594
+ if (found === 'nothing') fixedFrom = undefined
595
+ else if (found === 'pushed') continue
596
+ else return found
597
+ }
598
+
525
599
  // The forge runs no pipeline for this repository: its pipeline runs on a Runner and is reported to Kitman.
526
600
  if (pipeline.status === 'none' && pipeline.runnerChecks !== undefined) {
527
601
  if (ranOnRunner.has(pipeline.head))
528
602
  return done('needs_you', `The pipeline ran on the Runner at ${pipeline.head}, but no result was recorded`)
529
603
  ranOnRunner.add(pipeline.head)
530
604
 
531
- const failed = yield* runOnRunner('run', cycle, pipeline.head, pipeline.runnerChecks)
605
+ const ran = yield* runOnRunner('run', cycle, pipeline.head, pipeline.runnerChecks)
532
606
 
533
- if (failed !== undefined) return done('needs_you', `The pipeline could not run on the Runner: ${failed}`)
607
+ if ('failed' in ran) return done('needs_you', `The pipeline could not run on the Runner: ${ran.failed}`)
534
608
 
535
609
  continue
536
610
  }
@@ -617,7 +691,10 @@ export default defineLoop({
617
691
  })
618
692
 
619
693
  // Only a round that fixed something counts: one that found the target's failure or a flake changed nothing.
620
- if (fixed.verdict === 'fixed') rounds['ci-fix']++
694
+ if (fixed.verdict === 'fixed') {
695
+ rounds['ci-fix']++
696
+ fixedFrom = { head: pipeline.head, changed: true, looks: 0 }
697
+ }
621
698
 
622
699
  if (fixed.verdict === 'pre_existing') {
623
700
  const stopped = yield* waitOutTarget(
@@ -641,9 +718,9 @@ export default defineLoop({
641
718
  return done('needs_you', `The failing job failed again when run again on the Runner: ${fixed.summary}`)
642
719
  reranHeads.add(pipeline.head)
643
720
 
644
- const failed = yield* runOnRunner('rerun', cycle, pipeline.head, pipeline.runnerChecks)
721
+ const ran = yield* runOnRunner('rerun', cycle, pipeline.head, pipeline.runnerChecks)
645
722
 
646
- if (failed !== undefined) return done('needs_you', `The pipeline could not run on the Runner: ${failed}`)
723
+ if ('failed' in ran) return done('needs_you', `The pipeline could not run on the Runner: ${ran.failed}`)
647
724
 
648
725
  continue
649
726
  }
@@ -743,13 +820,15 @@ export default defineLoop({
743
820
  )
744
821
  rounds['head-fix']++
745
822
 
746
- yield* agentWork(`review-fix:${cycle}`, {
823
+ const fix = yield* agentWork(`review-fix:${cycle}`, {
747
824
  agent: 'implementer',
748
825
  prompt: reviewFixPrompt('the files the catch-up merge changed', blocking),
749
826
  output: ReviewFix,
750
827
  timeout: stepBudget
751
828
  })
829
+
752
830
  unreviewed = { ...files, earlier: reviewed.findings }
831
+ fixedFrom = { head, changed: fix.changed, looks: 0 }
753
832
 
754
833
  continue
755
834
  }
@@ -869,7 +948,7 @@ export default defineLoop({
869
948
  )
870
949
  rounds['head-fix']++
871
950
 
872
- yield* agentWork(`head-fix:${cycle}`, {
951
+ const fix = yield* agentWork(`head-fix:${cycle}`, {
873
952
  agent: 'implementer',
874
953
  prompt: reviewFixPrompt(
875
954
  since === undefined ? `the change at ${head}` : `what changed between ${since} and ${head}`,
@@ -878,7 +957,9 @@ export default defineLoop({
878
957
  output: ReviewFix,
879
958
  timeout: stepBudget
880
959
  })
960
+
881
961
  headFindings = reviewed.findings
962
+ fixedFrom = { head, changed: fix.changed, looks: 0 }
882
963
 
883
964
  continue
884
965
  }