@kitman-sh/software-engineering 0.48.0 → 0.49.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/dist/bundle.js CHANGED
@@ -26793,6 +26793,7 @@ var steered = { event: "run.steered" };
26793
26793
  var watchLook = "6 hours";
26794
26794
  var watchLooks = 28;
26795
26795
  var roundLimits = { "ci-fix": 1, "head-fix": 2 };
26796
+ var ciFixRunLimit = 3;
26796
26797
  var handBackAnswer = "Hand back to Build";
26797
26798
  var Input3 = Struct({
26798
26799
  changeRequestId: String5.annotate({
@@ -26842,7 +26843,8 @@ var releaseWhenWords = {
26842
26843
  var Output2 = ShepherdOutput;
26843
26844
  var CiFix = Struct({
26844
26845
  verdict: Literals(["fixed", "pre_existing", "flaky"]),
26845
- summary: OneSentence
26846
+ summary: OneSentence,
26847
+ reran: optionalKey2(Struct({ revision: String5, passed: ArraySchema(String5) }))
26846
26848
  });
26847
26849
  var Replies = Struct({
26848
26850
  replies: ArraySchema(Struct({
@@ -26855,6 +26857,12 @@ var failedJobs = (pipeline) => pipeline.jobs.flatMap((job) => job.status === "fa
26855
26857
 
26856
26858
  ${job.logTail ?? "No log was served."}`] : []);
26857
26859
  var failingJobs = (pipeline) => pipeline.jobs.flatMap((job) => job.status === "failed" ? [job.name] : []);
26860
+ var passedWhenRerun = (passed, pipeline) => {
26861
+ if (pipeline.source !== "reported" || pipeline.runnerChecks !== undefined || pipeline.status !== "failed")
26862
+ return false;
26863
+ const failing = failingJobs(pipeline);
26864
+ return failing.length > 0 && (passed ?? []).some((rerun) => rerun.head === pipeline.head && failing.every((job) => rerun.jobs.includes(job)));
26865
+ };
26858
26866
  var OnTarget = Struct({
26859
26867
  failed: ArraySchema(String5),
26860
26868
  passed: ArraySchema(String5),
@@ -26907,7 +26915,7 @@ var ciFixPrompt = (pipeline, target, onTarget) => {
26907
26915
  return [
26908
26916
  `The pipeline at ${pipeline.head} failed. These jobs failed, with the end of each log:`,
26909
26917
  ...failedJobs(pipeline),
26910
- "Run the failing job once more here to rule out a flake; if it passes, change nothing and answer flaky.",
26918
+ `Run each failing job once more here to rule out a flake. If every one passes, change nothing, answer flaky and give in reran the commit \`git rev-parse HEAD\` names and the name of each job that passed; Shepherd lands on that only at ${pipeline.head}.`,
26911
26919
  ...onTarget.passed.length === 0 ? [] : [
26912
26920
  `Kitman ran ${onTarget.passed.join(", ")} at the head of \`origin/${target}\` and they passed there, so do not run them on the target branch.`
26913
26921
  ],
@@ -27012,6 +27020,7 @@ var Shepherding = Struct({
27012
27020
  targetChecked: optional2(Struct({ head: String5, targetHead: String5 })),
27013
27021
  turn: optional2(Turn),
27014
27022
  caughtUpFrom: optionalKey2(ArraySchema(String5)),
27023
+ passedOnRerun: optionalKey2(ArraySchema(Struct({ head: String5, jobs: ArraySchema(String5) }))),
27015
27024
  redTarget: optional2(Struct({ head: String5, targetHead: optional2(String5), moved: Boolean3 }))
27016
27025
  });
27017
27026
  var unshepherded = {
@@ -27503,13 +27512,29 @@ var ciFixed = step2("ciFixed", {
27503
27512
  run: ({ target, pipeline, onTarget }) => implementer("ci-fix", { prompt: ciFixPrompt(pipeline, target, onTarget), output: CiFix, timeout: stepBudget })
27504
27513
  });
27505
27514
  var reran = step2("reran", {
27506
- payload: { charge: Charge, at: Shepherding, pipeline: PipelineStatus, summary: String5 },
27515
+ payload: {
27516
+ charge: Charge,
27517
+ at: Shepherding,
27518
+ pipeline: PipelineStatus,
27519
+ summary: String5,
27520
+ rerun: CiFix.fields.reran
27521
+ },
27507
27522
  success: Union2([Again, ...Ended]),
27508
- run: ({ charge, at, pipeline, summary }) => gen2(function* () {
27523
+ run: ({ charge, at, pipeline, summary, rerun: ranAgain }) => gen2(function* () {
27509
27524
  const { changeRequestId } = charge;
27510
27525
  if (pipeline.source === "reported") {
27511
- if (pipeline.runnerChecks === undefined)
27512
- return new NeedsYou({ at, reason: `The failing job passed when run again, outside the forge: ${summary}` });
27526
+ if (pipeline.runnerChecks === undefined) {
27527
+ const passed = [
27528
+ ...at.passedOnRerun ?? [],
27529
+ ...ranAgain?.revision === pipeline.head ? [{ head: pipeline.head, jobs: ranAgain.passed }] : []
27530
+ ];
27531
+ if (!passedWhenRerun(passed, pipeline))
27532
+ return new NeedsYou({
27533
+ at,
27534
+ reason: `The ci-fix did not show every failing job of the pipeline at ${pipeline.head} passing there when run again: ${summary}`
27535
+ });
27536
+ return new Again({ at: { ...at, reranHeads: [...at.reranHeads, pipeline.head], passedOnRerun: passed } });
27537
+ }
27513
27538
  if (at.reranHeads.includes(pipeline.head))
27514
27539
  return new NeedsYou({ at, reason: `The failing job failed again when run again on the Runner: ${summary}` });
27515
27540
  const ran = yield* runOnRunner(changeRequestId, "rerun", pipeline.head, pipeline.runnerChecks);
@@ -28081,7 +28106,7 @@ var mergedOnTurn = step2("mergedOnTurn", {
28081
28106
  agent: "implementer",
28082
28107
  approve: () => void_3,
28083
28108
  ...target === "HEAD" ? undefined : { target },
28084
- read: pipeline,
28109
+ read: passedWhenRerun(turn.at.passedOnRerun, pipeline) ? { ...pipeline, status: "success" } : pipeline,
28085
28110
  catchUp: false,
28086
28111
  ...turn.at.repository === undefined ? undefined : { repository: turn.at.repository }
28087
28112
  }).pipe(catchTag2("MergeRefused", (refused) => succeed7(refused)));
@@ -28137,7 +28162,7 @@ var looked = step2("looked", {
28137
28162
  const reusing = reviewedElsewhere === undefined ? seen : yield* reviewReused({ charge, at: seen.at, pipeline, reviewed: reviewedElsewhere }).pipe(endedOn(charge, seen.at));
28138
28163
  if (reusing._tag !== "Onward")
28139
28164
  return reusing;
28140
- const pipelineFailed = pipeline.status === "failed" || pipeline.status === "canceled";
28165
+ const pipelineFailed = (pipeline.status === "failed" || pipeline.status === "canceled") && !passedWhenRerun(reusing.at.passedOnRerun, pipeline);
28141
28166
  const heldBehind = hold && (pipeline.needsRebase === true || pipeline.behind === true);
28142
28167
  const blocked = pipeline.conflicts === true || pipeline.needsRebase === true && pipelineFailed || heldBehind;
28143
28168
  const caughtUpHead = head === reusing.at.pipelineFirst;
@@ -28324,6 +28349,7 @@ var shepherd_default = defineLoop({
28324
28349
  };
28325
28350
  let rounds = noRounds;
28326
28351
  let limits = roundLimits;
28352
+ let ciFixRuns = 0;
28327
28353
  let next = new Again({ at: unshepherded });
28328
28354
  for (let cycle = 1;next._tag === "Again"; cycle++) {
28329
28355
  const look = yield* looked({
@@ -28337,7 +28363,8 @@ var shepherd_default = defineLoop({
28337
28363
  continue;
28338
28364
  }
28339
28365
  const kind = look._tag === "CiFixDue" ? "ci-fix" : "head-fix";
28340
- const round = yield* roundAllowed({
28366
+ const ciFixesSpent = look._tag === "CiFixDue" && ciFixRuns >= ciFixRunLimit;
28367
+ const round = ciFixesSpent ? new RoundsSpent : yield* roundAllowed({
28341
28368
  kind,
28342
28369
  taken: rounds[kind],
28343
28370
  limit: limits[kind],
@@ -28348,7 +28375,7 @@ var shepherd_default = defineLoop({
28348
28375
  charge,
28349
28376
  at: look.at,
28350
28377
  ...look.handBack,
28351
- reason: `${look.handBack.reason} after ${rounds[kind]} ${kind} rounds`
28378
+ reason: `${look.handBack.reason} after ${ciFixesSpent ? ciFixRuns : rounds[kind]} ${kind} rounds`
28352
28379
  });
28353
28380
  continue;
28354
28381
  }
@@ -28363,6 +28390,7 @@ var shepherd_default = defineLoop({
28363
28390
  continue;
28364
28391
  }
28365
28392
  const { at, pipeline, onTarget } = look;
28393
+ ciFixRuns++;
28366
28394
  const fixed = yield* ciFixed({ target: charge.target, pipeline, onTarget }).pipe(endedOn(charge, at));
28367
28395
  if (!("verdict" in fixed)) {
28368
28396
  next = fixed;
@@ -28378,7 +28406,13 @@ var shepherd_default = defineLoop({
28378
28406
  at,
28379
28407
  pipeline,
28380
28408
  why: `the failure is pre-existing on the target branch: ${fixed.summary}`
28381
- }).pipe(endedOn(charge, at)) : yield* reran({ charge, at, pipeline, summary: fixed.summary }).pipe(endedOn(charge, at));
28409
+ }).pipe(endedOn(charge, at)) : yield* reran({
28410
+ charge,
28411
+ at,
28412
+ pipeline,
28413
+ summary: fixed.summary,
28414
+ ...fixed.reran === undefined ? undefined : { rerun: fixed.reran }
28415
+ }).pipe(endedOn(charge, at));
28382
28416
  }
28383
28417
  const fixRounds = rounds["ci-fix"] + rounds["head-fix"];
28384
28418
  const { target } = charge;
@@ -40056,4 +40090,4 @@ var runKit = (config, identity, packages) => {
40056
40090
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
40057
40091
  };
40058
40092
  // .kitman-build-entry.ts
40059
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.48.0" }, []);
40093
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.49.0" }, []);