@kitman-sh/software-engineering 0.50.0 → 0.51.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
@@ -20259,6 +20259,7 @@ var EvidenceCheck = Struct({
20259
20259
  outputTail: optionalKey2(String5),
20260
20260
  failedTests: optionalKey2(ArraySchema(String5)),
20261
20261
  suggested: optionalKey2(Boolean3),
20262
+ notStarted: optionalKey2(Boolean3),
20262
20263
  skippedSinceBaseline: optionalKey2(ArraySchema(String5)),
20263
20264
  newNotRun: optionalKey2(ArraySchema(String5)),
20264
20265
  environmentFailure: optionalKey2(Struct({
@@ -20273,7 +20274,12 @@ var VerifyResult = Struct({
20273
20274
  tree: String5,
20274
20275
  passed: Boolean3,
20275
20276
  unchanged: optionalKey2(Boolean3),
20276
- checks: ArraySchema(EvidenceCheck)
20277
+ checks: ArraySchema(EvidenceCheck),
20278
+ runnable: optionalKey2(ArraySchema(Struct({
20279
+ name: String5,
20280
+ command: String5,
20281
+ workingDirectory: optionalKey2(String5)
20282
+ })))
20277
20283
  });
20278
20284
  var verdict = (reasons) => reasons.length === 0 ? { settled: true } : { settled: false, reasons };
20279
20285
  var missing2 = (side) => `No verification evidence for the ${side}`;
@@ -23566,6 +23572,7 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
23566
23572
  step: launch.step,
23567
23573
  ...launch.revision === undefined ? undefined : { revision: launch.revision },
23568
23574
  ...launch.checks === undefined ? undefined : { checks: launch.checks },
23575
+ ...launch.suggested === undefined ? undefined : { suggested: launch.suggested },
23569
23576
  ...launch.extra === undefined ? undefined : { extra: launch.extra },
23570
23577
  ...launch.rerunFailed === undefined ? undefined : { rerunFailed: launch.rerunFailed }
23571
23578
  });
@@ -23574,7 +23581,11 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
23574
23581
  const flat = Array.from({ length: launch.measure.samples }, () => Object.fromEntries(launch.measure?.plan.metrics.map((metric) => [metric.name, 100]) ?? []));
23575
23582
  return resolve(measureDeferred(launch.step), launch.token, measured instanceof ScriptedFailure ? fail5(new StepFailed({ step: launch.step, reason: measured.reason })) : succeed4(measured ?? { base: flat, head: flat, ...launch.measure.calibrate ? { baseAgain: flat } : undefined }));
23576
23583
  }
23577
- return resolve(verifyDeferred(launch.step), launch.token, scripted instanceof ScriptedFailure ? fail5(new StepFailed({ step: launch.step, reason: scripted.reason })) : succeed4(scripted ?? {
23584
+ return resolve(verifyDeferred(launch.step), launch.token, scripted instanceof ScriptedFailure ? fail5(new StepFailed({
23585
+ step: launch.step,
23586
+ reason: scripted.reason,
23587
+ ...scripted.code === undefined ? undefined : { code: scripted.code }
23588
+ })) : succeed4(scripted ?? {
23578
23589
  revision: launch.revision ?? "head",
23579
23590
  tree: launch.revision ?? "head",
23580
23591
  passed: true,
@@ -24662,7 +24673,7 @@ var CriterionAnswer = Struct({
24662
24673
  detail: ShortStatement,
24663
24674
  ...outOfScopeCase
24664
24675
  });
24665
- var BuildOutput = Struct({
24676
+ var ChangeBuilt = Struct({
24666
24677
  changeRequest: ChangeRequestResult.annotate({ description: "The ChangeRequest the Build opened or fixed forward." }),
24667
24678
  revision: String5.annotate({ description: "The head commit the Build pushed." }),
24668
24679
  tree: String5.annotate({
@@ -24707,7 +24718,31 @@ var BuildOutput = Struct({
24707
24718
  description: "Where the Run's delivery landed and the layer it came from."
24708
24719
  })
24709
24720
  });
24710
- var Built = Struct(omit3(BuildOutput.fields, ["changeRequest", "landed", "next"]));
24721
+ var NothingToDo = Struct({
24722
+ status: Literal2("nothing_to_do").annotate({
24723
+ description: "Nothing needed changing: the implementer changed nothing, a fix reverted the change, or a rebuild found the ChangeRequest's change already on its target."
24724
+ }),
24725
+ summary: String5.annotate({
24726
+ description: "The implementer's summary, the evidence that nothing needed changing."
24727
+ }),
24728
+ claims: ArraySchema(String5).annotate({
24729
+ description: "The implementer's claims, which Kitman has not checked."
24730
+ }),
24731
+ criteria: ArraySchema(CriterionAnswer).annotate({
24732
+ description: "The implementer's answer to each Acceptance Criterion."
24733
+ }),
24734
+ revision: String5.annotate({ description: "The head, which is the base." }),
24735
+ tree: String5.annotate({ description: "The tree of that head." }),
24736
+ reverted: optionalKey2(Boolean3).annotate({
24737
+ description: "True when a fix after a review returned the head to the base, reverting the implementer's change."
24738
+ }),
24739
+ changeRequest: optionalKey2(ChangeRequestResult).annotate({
24740
+ description: "The open ChangeRequest a rebuild found with nothing left on it, for a person to close."
24741
+ })
24742
+ });
24743
+ var BuildOutput = Union2([ChangeBuilt, NothingToDo]);
24744
+ var isNothingToDo = (output) => ("status" in output);
24745
+ var Built = Struct(omit3(ChangeBuilt.fields, ["changeRequest", "landed", "next"]));
24711
24746
  var taskOf = (words) => words === undefined ? "the Task your brief describes." : `this: ${words}`;
24712
24747
 
24713
24748
  // src/agents.ts
@@ -24718,9 +24753,62 @@ var reviewer = agent("reviewer");
24718
24753
 
24719
24754
  // src/suggested-check.ts
24720
24755
  var SuggestedCheck = Struct({
24721
- name: CheckName,
24722
- command: String5,
24723
- workingDirectory: optionalKey2(String5)
24756
+ name: ApprovedCheck.fields.name,
24757
+ command: ApprovedCheck.fields.command,
24758
+ workingDirectory: ApprovedCheck.fields.workingDirectory
24759
+ });
24760
+ var checkRefusals = ["Already a check of this repository with another command", "Two checks named", "Could not start"];
24761
+ var refusedCheck = (error) => error.code === "step_refused" && checkRefusals.some((refusal) => error.reason.startsWith(refusal));
24762
+ var sameCommand = (one, other) => one.command === other.command && one.workingDirectory === other.workingDirectory;
24763
+ var clashingChecks = (step, checks) => {
24764
+ const twice = [
24765
+ ...new Set(checks.flatMap((check, index) => checks.slice(0, index).some((other) => other.name === check.name && !sameCommand(other, check)) ? [check.name] : []))
24766
+ ];
24767
+ return twice.length === 0 ? undefined : new StepFailed({
24768
+ step,
24769
+ code: "step_refused",
24770
+ reason: `Two checks named with different commands: ${twice.join(", ")}; give each check its own name`
24771
+ });
24772
+ };
24773
+ var unstartedChecks = (result, named) => result.checks.filter((check) => check.notStarted === true && named.some((one) => one.name === check.name && one.command === check.command));
24774
+ var unstartedRefusal = (step, result, named) => {
24775
+ const unstarted = unstartedChecks(result, named);
24776
+ return unstarted.length === 0 ? undefined : new StepFailed({
24777
+ step,
24778
+ code: "step_refused",
24779
+ reason: [
24780
+ `Could not start: ${unstarted.map((check) => `${check.name}: \`${check.command}\` printed ${JSON.stringify(check.outputTail ?? "")}`).join("; ")}`,
24781
+ (result.runnable ?? []).length === 0 ? "The repository approves no checks" : `Its checks are ${(result.runnable ?? []).map(shownCheck).join("; ")}`
24782
+ ].join(". ")
24783
+ });
24784
+ };
24785
+ var Renamed = Struct({
24786
+ renamed: Record(String5, CheckName),
24787
+ commands: optional2(Record(String5, Struct({
24788
+ command: SuggestedCheck.fields.command,
24789
+ workingDirectory: SuggestedCheck.fields.workingDirectory
24790
+ })))
24791
+ });
24792
+ var shownCheck = (check) => `${check.name}: \`${check.command}\`${check.workingDirectory === undefined ? "" : ` in ${check.workingDirectory}`}`;
24793
+ var numbered = (check, index) => `${index + 1}. ${shownCheck(check)}`;
24794
+ var renamePrompt = (reason, named, kept = []) => [
24795
+ `Kitman will not run the checks you named: ${reason}`,
24796
+ ["You named:", ...named.map(numbered)].join(`
24797
+ `),
24798
+ ...kept.length === 0 ? [] : [["These keep their names:", ...kept.map((check) => `- ${shownCheck(check)}`)].join(`
24799
+ `)],
24800
+ "Give in `renamed`, keyed by each one's number, a new name of letters, digits, `.`, `_`, `:` and `-` that no other check has, for each you rename. Kitman keeps each command and runs it under its new name, except one that could not start: give it, in `commands` under its number, a command that runs in this repository, or one of its checks exactly with that check's name. Change nothing in the workspace."
24801
+ ].join(`
24802
+
24803
+ `);
24804
+ var renamedChecks = (named, renamed) => named.map((check, index) => {
24805
+ const key = String(index + 1);
24806
+ const run = renamed.commands?.[key] ?? check;
24807
+ return {
24808
+ name: renamed.renamed[key] ?? check.name,
24809
+ command: run.command,
24810
+ ...run.workingDirectory === undefined ? undefined : { workingDirectory: run.workingDirectory }
24811
+ };
24724
24812
  });
24725
24813
 
24726
24814
  // src/implemented.ts
@@ -24728,19 +24816,20 @@ var Change = Struct({
24728
24816
  title: String5,
24729
24817
  summary: ChangeRequestSummary,
24730
24818
  claims: ArraySchema(ShortStatement),
24731
- documented: optional2(ArraySchema(String5)),
24732
- rollback: optional2(String5),
24819
+ documented: optional2(ArraySchema(SuggestedCheck)),
24820
+ rollback: optional2(SuggestedCheck),
24733
24821
  criteria: optional2(ArraySchema(CriterionAnswer)),
24734
24822
  checks: optional2(ArraySchema(SuggestedCheck))
24735
24823
  });
24736
24824
  var Criteria = Struct({ criteria: ArraySchema(CriterionAnswer) });
24825
+ var proofGuidance = "Give each the command itself, with a `name` of letters, digits, `.`, `_`, `:` and `-` that no check of the repository has, unless it is exactly an approved check's name, command and directory. Kitman runs them on every head; a narrower command than an approved check is its own check.";
24737
24826
  var outcomeGuidance = {
24738
24827
  feature: "Deliver the whole scope; review checks it was met.",
24739
24828
  bug: "Your failing test is already in place: make it pass.",
24740
24829
  refactor: "Keep behaviour exactly as it is; the approved verifications must pass before and after.",
24741
24830
  investigation: "Investigate and report what you found, with its sources.",
24742
- docs: "Name, in `documented`, the approved checks that run the commands you documented.",
24743
- migration: "Name, in `rollback`, the approved check that rolls the migration back.",
24831
+ docs: `Name, in \`documented\`, a check for each command you documented that runs exactly it. ${proofGuidance}`,
24832
+ migration: `Name, in \`rollback\`, the check that rolls the migration back. ${proofGuidance}`,
24744
24833
  performance: "Make it faster without changing behaviour."
24745
24834
  };
24746
24835
  var criteriaGuidance = "If your brief has a Task, answer each of its acceptance criteria in `criteria`: met, with the test or file that shows it; after_merge, with why it can only be seen once merged; or not_met, with why. Give an empty `criteria` when the Task has none.";
@@ -24774,6 +24863,40 @@ var criteriaPrompt = (unanswered, unmet, cases) => [
24774
24863
  ].join(`
24775
24864
 
24776
24865
  `);
24866
+ var proofsOf = (outcome, change) => {
24867
+ if (outcome === "docs")
24868
+ return change.documented ?? [];
24869
+ return outcome === "migration" && change.rollback !== undefined ? [change.rollback] : [];
24870
+ };
24871
+ var runnableProofs = (outcome, change, reproducing) => gen2(function* () {
24872
+ const kept = reproducing === undefined ? [] : [reproducing];
24873
+ const checked = ({
24874
+ checks,
24875
+ proofs
24876
+ }, verified) => proofs.length === 0 ? suspend2(() => {
24877
+ const clash = clashingChecks("implemented", [...kept, ...checks]);
24878
+ return clash === undefined ? void_3 : fail7(clash);
24879
+ }) : verified({ checks: [], ...checks.length === 0 ? undefined : { suggested: checks }, extra: proofs }).pipe(flatMap3((result) => {
24880
+ const refusal = unstartedRefusal("implemented", result, proofs);
24881
+ return refusal === undefined ? void_3 : fail7(refusal);
24882
+ }));
24883
+ const named = { checks: change.checks ?? [], proofs: proofsOf(outcome, change) };
24884
+ const { checks, proofs } = yield* checked(named, (launch) => verify("proofs", launch)).pipe(as2(named), catchTag2("StepFailed", (error) => refusedCheck(error) ? gen2(function* () {
24885
+ const all = [...named.checks, ...named.proofs];
24886
+ const renamed = renamedChecks(all, yield* implementer("rename", { prompt: renamePrompt(error.reason, all, kept), output: Renamed }));
24887
+ const again = {
24888
+ checks: renamed.slice(0, named.checks.length),
24889
+ proofs: renamed.slice(named.checks.length)
24890
+ };
24891
+ yield* checked(again, (launch) => verify("proofs-renamed", launch));
24892
+ return again;
24893
+ }) : fail7(error)));
24894
+ return {
24895
+ ...change.checks === undefined ? undefined : { checks },
24896
+ ...outcome === "docs" && change.documented !== undefined ? { documented: proofs } : undefined,
24897
+ ...outcome === "migration" && change.rollback !== undefined ? { rollback: proofs[0] } : undefined
24898
+ };
24899
+ });
24777
24900
 
24778
24901
  class Implemented extends TaggedClass2()("Implemented", {
24779
24902
  ...Change.fields,
@@ -24793,12 +24916,15 @@ var implemented = step2("implemented", {
24793
24916
  cases: optional2(ArraySchema(String5)).annotate({
24794
24917
  description: "The Task's Out of scope list, which the implementer does not build."
24795
24918
  }),
24919
+ reproducing: optional2(SuggestedCheck).annotate({
24920
+ description: "The bug's reproducing check, whose name the implementer's checks may not take for another command."
24921
+ }),
24796
24922
  planReviewed: optional2(Boolean3).annotate({
24797
24923
  description: "Plan review passed the Task and this is its first implementation: the `planned-implementer` makes it."
24798
24924
  })
24799
24925
  },
24800
24926
  success: Implemented,
24801
- run: ({ words, taskId, outcome, continuing, cases = [], planReviewed }) => gen2(function* () {
24927
+ run: ({ words, taskId, outcome, continuing, cases = [], reproducing, planReviewed }) => gen2(function* () {
24802
24928
  const work = {
24803
24929
  skill: "implement",
24804
24930
  prompt: implementPrompt(taskOf(words), outcome, continuing, cases),
@@ -24807,13 +24933,8 @@ var implemented = step2("implemented", {
24807
24933
  const change = yield* planReviewed === true ? plannedImplementer("implement", work) : implementer("implement", work);
24808
24934
  const unanswered = taskId !== undefined && change.criteria === undefined;
24809
24935
  const unmet = (change.criteria ?? []).filter((answer) => answer.status === "not_met" && caseOf(cases, answer) === undefined);
24810
- if (!unanswered && unmet.length === 0)
24811
- return new Implemented({ ...change, criteria: change.criteria ?? [] });
24812
- const { criteria } = yield* implementer("criteria", {
24813
- prompt: criteriaPrompt(unanswered, unmet, cases),
24814
- output: Criteria
24815
- });
24816
- return new Implemented({ ...change, criteria });
24936
+ const { criteria } = !unanswered && unmet.length === 0 ? { criteria: change.criteria ?? [] } : yield* implementer("criteria", { prompt: criteriaPrompt(unanswered, unmet, cases), output: Criteria });
24937
+ return new Implemented({ ...change, ...yield* runnableProofs(outcome, change, reproducing), criteria });
24817
24938
  })
24818
24939
  });
24819
24940
 
@@ -28687,6 +28808,12 @@ class Reviewed extends TaggedClass2()("Reviewed", {
28687
28808
  }) {
28688
28809
  }
28689
28810
 
28811
+ class Unchanged extends TaggedClass2()("Unchanged", {
28812
+ head: VerifyResult,
28813
+ reverted: Boolean3
28814
+ }) {
28815
+ }
28816
+
28690
28817
  class SameEvidence extends TaggedClass2()("SameEvidence", headRead) {
28691
28818
  }
28692
28819
  var ShownFailure = Struct({ id: String5, detail: String5 });
@@ -28708,7 +28835,7 @@ var reviewed = step2("reviewed", {
28708
28835
  description: "A head already reviewed, and what the fixer was told of its failing checks; a head with its tree and evidence, and no failure the fixer was not told of, is not reviewed again."
28709
28836
  })
28710
28837
  },
28711
- success: Union2([Reviewed, SameEvidence]),
28838
+ success: Union2([Reviewed, SameEvidence, Unchanged]),
28712
28839
  error: BaseUnpinned,
28713
28840
  run: (payload) => gen2(function* () {
28714
28841
  const {
@@ -28736,6 +28863,8 @@ var reviewed = step2("reviewed", {
28736
28863
  message: verified === undefined ? `The Runner did not report which commit of ${target ?? "the default branch"} it merged in round ${payload.round}, so there is no base to review against; update the Runner` : "A head the caller verified is reviewed with no target merged in, so it needs a base to review against"
28737
28864
  });
28738
28865
  const head = verified ?? (yield* verify("verify", { suggested, ...extra === undefined ? undefined : { extra } }));
28866
+ if (head.revision === reviewBase)
28867
+ return new Unchanged({ head, reverted: payload.round > 1 });
28739
28868
  const found = {
28740
28869
  head,
28741
28870
  ...synced?.status === "conflict" ? { conflict: { files: synced.files, reason: synced.reason } } : undefined
@@ -28815,7 +28944,7 @@ var rallied = step2("rallied", {
28815
28944
  description: "An Effect to run after each fix, before the round that reviews it. A head it gives, having verified it, is reviewed as `verified` is. Failing with `Halted` ends the rally. The journal holds null for it."
28816
28945
  })
28817
28946
  },
28818
- success: Union2([Settled, DisputeStands, FindingsReturned, RoundCap]),
28947
+ success: Union2([Settled, DisputeStands, FindingsReturned, RoundCap, Unchanged]),
28819
28948
  error: Union2([BaseUnpinned, Halted]),
28820
28949
  run: ({ maxRounds, guidance, fixes = "open", afterFix, ...payload }) => gen2(function* () {
28821
28950
  const fixesOpen = fixes === "open";
@@ -28842,6 +28971,8 @@ var rallied = step2("rallied", {
28842
28971
  scope: last === undefined ? payload.scope : last.scope,
28843
28972
  known: fixesOpen && last !== undefined && rebuttals.length === 0 && onlyChecksBlock(last.settled) ? { head: last.head, shown: [...shown] } : undefined
28844
28973
  });
28974
+ if (found._tag === "Unchanged")
28975
+ return new Unchanged({ head: withoutOutput(found.head), reverted: found.reverted });
28845
28976
  const { head, conflict } = found;
28846
28977
  if (conflict !== undefined)
28847
28978
  conflicts.push(`Could not merge the target branch in round ${round}: ${conflict.files.join(", ")} (${conflict.reason})`);
@@ -28969,8 +29100,18 @@ var reproduced = step2("reproduced", {
28969
29100
  prompt: continuing === undefined ? reproducePrompt(task) : reproducedOnBranchPrompt(task),
28970
29101
  output: ReproducingTest
28971
29102
  });
28972
- const base = yield* verify("verify", { ...revision === undefined ? undefined : { revision }, extra: [check] });
28973
- return new Reproduced({ check, base: withoutOutput(base) });
29103
+ const verifyAt = (name, reproducing) => verify(name, { ...revision === undefined ? undefined : { revision }, extra: [reproducing] }).pipe(flatMap3((base) => {
29104
+ const refusal = unstartedRefusal(name, base, [reproducing]);
29105
+ return refusal === undefined ? succeed7(new Reproduced({ check: reproducing, base: withoutOutput(base) })) : fail7(refusal);
29106
+ }));
29107
+ return yield* verifyAt("verify", check).pipe(catchTag2("StepFailed", (error) => refusedCheck(error) ? gen2(function* () {
29108
+ const renamed = yield* implementer("rename", {
29109
+ prompt: renamePrompt(error.reason, [check]),
29110
+ output: Renamed
29111
+ });
29112
+ const [reproducing = check] = renamedChecks([check], renamed);
29113
+ return yield* verifyAt("verify-renamed", reproducing);
29114
+ }) : fail7(error)));
28974
29115
  })
28975
29116
  });
28976
29117
 
@@ -28995,6 +29136,11 @@ class TakenOver extends TaggedClass2()("TakenOver", {}) {
28995
29136
  class Rebuilt extends TaggedClass2()("Rebuilt", { built: Built }) {
28996
29137
  }
28997
29138
 
29139
+ class RebuildUnchanged extends TaggedClass2()("RebuildUnchanged", {
29140
+ built: NothingToDo
29141
+ }) {
29142
+ }
29143
+
28998
29144
  class BuildBlocked extends TaggedError3()("BuildBlocked", {
28999
29145
  message: String5
29000
29146
  }) {
@@ -29019,7 +29165,7 @@ var standing = step2("standing", {
29019
29165
  }),
29020
29166
  build: Struct(pick(BuildInput.fields, ["words", "taskId", "repoBindingId", "outcome", "maxRounds", "deliversTo"])).annotate({ description: "The Build's own Input, which a rebuild is given too." })
29021
29167
  },
29022
- success: Union2([TakenOver, Rebuilt]),
29168
+ success: Union2([TakenOver, Rebuilt, RebuildUnchanged]),
29023
29169
  error: BuildBlocked,
29024
29170
  run: ({
29025
29171
  changeRequest,
@@ -29087,6 +29233,8 @@ var standing = step2("standing", {
29087
29233
  ...scope === undefined ? undefined : { scope },
29088
29234
  ...ownDeliveryTarget(build)
29089
29235
  }, { constraints: unsettled.map(standingConstraint) });
29236
+ if (isNothingToDo(rebuilt))
29237
+ return new RebuildUnchanged({ built: { ...rebuilt, changeRequest } });
29090
29238
  return new Rebuilt({ built: omit3(rebuilt, ["changeRequest", "landed", "next"]) });
29091
29239
  })
29092
29240
  });
@@ -29163,8 +29311,8 @@ var gated = ({
29163
29311
  ...before._tag === "NotNeeded" ? undefined : { base: before.base },
29164
29312
  ...last.scope === undefined ? undefined : { review: last.scope },
29165
29313
  ...before._tag === "Reproduced" ? { reproducing: before.check.name } : undefined,
29166
- ...change.documented === undefined ? undefined : { documented: change.documented },
29167
- ...change.rollback === undefined ? undefined : { rollback: change.rollback }
29314
+ ...change.documented === undefined ? undefined : { documented: change.documented.map((check) => check.name) },
29315
+ ...change.rollback === undefined ? undefined : { rollback: change.rollback.name }
29168
29316
  });
29169
29317
  const stopped = stoppedAs[last._tag];
29170
29318
  const findings = codeFindings(last.settled);
@@ -29220,7 +29368,7 @@ var outputOf2 = (input, changeRequest, built) => ({
29220
29368
  });
29221
29369
  var build2 = defineLoop({
29222
29370
  id: "build",
29223
- version: "3.1.0",
29371
+ version: "4.0.0",
29224
29372
  title: "Build",
29225
29373
  description: "Implements a Task or words, reviews and fixes the change, and opens a ChangeRequest with its evidence.",
29226
29374
  input: BuildInput,
@@ -29253,8 +29401,10 @@ var build2 = defineLoop({
29253
29401
  outcome,
29254
29402
  continuing,
29255
29403
  ...cases.length === 0 ? undefined : { cases },
29404
+ ...before._tag === "Reproduced" ? { reproducing: before.check } : undefined,
29256
29405
  ...input.planReviewed === true ? { planReviewed: true } : undefined
29257
29406
  });
29407
+ const proven = [...before._tag === "Reproduced" ? [before.check] : [], ...proofsOf(outcome, change)];
29258
29408
  const last = yield* rallied({
29259
29409
  fixer: "implementer",
29260
29410
  maxRounds: input.maxRounds ?? 3,
@@ -29262,7 +29412,7 @@ var build2 = defineLoop({
29262
29412
  outcome,
29263
29413
  claims: [...change.claims, ...change.criteria.map((answer) => `Criterion ${answerLine(answer, cases)}`)],
29264
29414
  suggested: change.checks ?? [],
29265
- extra: before._tag === "Reproduced" ? [before.check] : undefined,
29415
+ extra: proven.length === 0 ? undefined : proven,
29266
29416
  reviewed: input.reviewed,
29267
29417
  earlier: input.earlier,
29268
29418
  deliveredBy: input.changeRequestId,
@@ -29272,6 +29422,22 @@ var build2 = defineLoop({
29272
29422
  afterMergeCriteria: answeredAs(change.criteria, cases, "after_merge"),
29273
29423
  scope: input.scope
29274
29424
  });
29425
+ if (last._tag === "Unchanged") {
29426
+ const { summary, claims, criteria } = change;
29427
+ const { revision, tree } = last.head;
29428
+ return {
29429
+ status: "nothing_to_do",
29430
+ output: {
29431
+ status: "nothing_to_do",
29432
+ summary,
29433
+ claims,
29434
+ criteria,
29435
+ revision,
29436
+ tree,
29437
+ ...last.reverted ? { reverted: true } : undefined
29438
+ }
29439
+ };
29440
+ }
29275
29441
  const gate = gated({ outcome, before, change, last, cases });
29276
29442
  const { changeRequest, approval } = yield* opened({
29277
29443
  title: change.title,
@@ -29297,6 +29463,8 @@ var build2 = defineLoop({
29297
29463
  });
29298
29464
  if (decided._tag === "TakenOver")
29299
29465
  return { status: "taken_over", output: outputOf2(input, changeRequest, built) };
29466
+ if (decided._tag === "RebuildUnchanged")
29467
+ return { status: "nothing_to_do", output: decided.built };
29300
29468
  built = decided.built;
29301
29469
  }
29302
29470
  const shepherded = yield* landed3({
@@ -30033,6 +30201,7 @@ ${followUps.map((entry) => `- \`${entry.id}\` ${entry.status.replace("_", " ")}`
30033
30201
 
30034
30202
  `);
30035
30203
  };
30204
+ var nothingNeeded = (built) => built.changeRequest === undefined ? `Nothing needed changing: ${built.summary}` : `Nothing needed changing, so close ${built.changeRequest.url}: ${built.summary}`;
30036
30205
  var fixBrief = (changeRequestId, findings, unmet) => [
30037
30206
  `Fix what a review of ChangeRequest ${changeRequestId} found, on its branch:`,
30038
30207
  ...findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`),
@@ -30261,7 +30430,7 @@ What next?`,
30261
30430
  ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings },
30262
30431
  ...scope === undefined ? undefined : { scope },
30263
30432
  ...ownDeliveryTarget(input)
30264
- }).pipe(map8((fixed) => new Fixed2({
30433
+ }).pipe(map8((fixed) => isNothingToDo(fixed) ? new Done3({ choice, detail: nothingNeeded(fixed) }) : new Fixed2({
30265
30434
  choice,
30266
30435
  detail: fixed.settled ? "Fixed and pushed" : `Pushed; left: ${fixed.unsettled.join("; ")}`
30267
30436
  })), catchTag2("ChildFailed", (failed) => succeed7(new Done3({ choice, detail: failed.reason }))));
@@ -30269,7 +30438,7 @@ What next?`,
30269
30438
  return yield* call("build", buildLoop(), {
30270
30439
  words: fixBrief(changeRequestId, findings, scope?.unmet ?? []),
30271
30440
  ...ownDeliveryTarget(input)
30272
- }).pipe(map8((built) => new Built2({ choice, detail: built.changeRequest.url })), catchTag2("ChildFailed", (failed) => succeed7(new Done3({ choice, detail: failed.reason }))));
30441
+ }).pipe(map8((built) => isNothingToDo(built) ? new Done3({ choice, detail: nothingNeeded(built) }) : new Built2({ choice, detail: built.changeRequest.url })), catchTag2("ChildFailed", (failed) => succeed7(new Done3({ choice, detail: failed.reason }))));
30273
30442
  return new Done3({ choice, detail: "The review is kept as an artifact" });
30274
30443
  })
30275
30444
  });
@@ -30530,7 +30699,7 @@ var Output4 = Struct({
30530
30699
  }),
30531
30700
  summary: String5.annotate({ description: "What the Errand did, in a line." }),
30532
30701
  changeRequest: optional2(ChangeRequestResult).annotate({
30533
- description: "The ChangeRequest it opened, when it opened one."
30702
+ description: "The ChangeRequest it opened, or one a Build found nothing left on, for a person to close."
30534
30703
  })
30535
30704
  });
30536
30705
  var prompt3 = (words) => [
@@ -30637,6 +30806,12 @@ var errand_default = defineLoop({
30637
30806
  ...input.taskId === undefined ? undefined : { taskId: input.taskId },
30638
30807
  ...input.branch === undefined ? undefined : { branch: input.branch }
30639
30808
  });
30809
+ if (isNothingToDo(built))
30810
+ return {
30811
+ status: "done",
30812
+ summary: built.summary,
30813
+ ...built.changeRequest === undefined ? undefined : { changeRequest: built.changeRequest }
30814
+ };
30640
30815
  return { status: "handed_to_build", summary: errand.summary, changeRequest: built.changeRequest };
30641
30816
  }
30642
30817
  const { changeRequest } = yield* opened({
@@ -31353,6 +31528,8 @@ var hillclimb_default = defineLoop({
31353
31528
  }).pipe(catchTag2("Halted", (halt) => succeed7(halt)));
31354
31529
  if (rally._tag === "Halted")
31355
31530
  return yield* halted(rally, findings);
31531
+ if (rally._tag === "Unchanged")
31532
+ return yield* ending2("no_gain", "The reviewed head is the base, so it changes nothing", findings);
31356
31533
  const shipped = provenAt(rally.head, improvements) ?? (yield* measured({ ...gain, revision: rally.head.revision }));
31357
31534
  if (shipped._tag !== "Improved")
31358
31535
  return yield* unproven(shipped, findings);
@@ -31404,11 +31581,11 @@ var Output7 = Struct({
31404
31581
  description: "The Artifact holding the investigation's conclusion."
31405
31582
  }),
31406
31583
  resolvedDuring: Boolean3.annotate({ description: "It resolved on its own while it was being investigated." }),
31407
- fix: Literals(["none", "declined", "started", "failed"]).annotate({
31408
- description: "Whether a fix was started: none was offered, a person declined it, it started, or starting it failed."
31584
+ fix: Literals(["none", "declined", "started", "failed", "unneeded"]).annotate({
31585
+ description: "Whether a fix was started: none was offered, a person declined it, it started, starting it failed, or its Build found nothing needed changing."
31409
31586
  }),
31410
31587
  changeRequestUrl: optional2(String5).annotate({
31411
- description: "The fix's ChangeRequest, when a fix opened one."
31588
+ description: "The fix's ChangeRequest, when a fix opened one; with an unneeded fix, the one left open for a person to close."
31412
31589
  }),
31413
31590
  fixRequest: optional2(FixRequest).annotate({
31414
31591
  description: "The fix a person can still start from the Run's offer."
@@ -31528,6 +31705,11 @@ class FixStarted extends TaggedClass2()("FixStarted", { changeRequestUrl: String
31528
31705
 
31529
31706
  class FixFailed extends TaggedClass2()("FixFailed", {}) {
31530
31707
  }
31708
+
31709
+ class FixUnneeded extends TaggedClass2()("FixUnneeded", {
31710
+ changeRequestUrl: optionalKey2(String5)
31711
+ }) {
31712
+ }
31531
31713
  var fixOffered = step2("fixOffered", {
31532
31714
  payload: {
31533
31715
  summary: String5,
@@ -31539,7 +31721,7 @@ var fixOffered = step2("fixOffered", {
31539
31721
  taskId: optional2(String5),
31540
31722
  repoBindingId: optional2(String5)
31541
31723
  },
31542
- success: Union2([FixDeclined, FixStarted, FixFailed]),
31724
+ success: Union2([FixDeclined, FixStarted, FixFailed, FixUnneeded]),
31543
31725
  run: ({ summary, fix, fixRequest, confident, resolvedDuring, autoFix, taskId, repoBindingId }) => gen2(function* () {
31544
31726
  const answer = yield* ask("start-fix", {
31545
31727
  prompt: `${summary}
@@ -31560,12 +31742,12 @@ Start a Build that fixes it as a bug: ${fix}?`,
31560
31742
  ...fixRequest,
31561
31743
  ...taskId === undefined ? undefined : { taskId },
31562
31744
  ...repoBindingId === undefined ? undefined : { repoBindingId }
31563
- }).pipe(map8((fixed) => new FixStarted({ changeRequestUrl: fixed.changeRequest.url })), catchTag2("ChildFailed", () => succeed7(new FixFailed)));
31745
+ }).pipe(map8((fixed) => isNothingToDo(fixed) ? new FixUnneeded(fixed.changeRequest === undefined ? {} : { changeRequestUrl: fixed.changeRequest.url }) : new FixStarted({ changeRequestUrl: fixed.changeRequest.url })), catchTag2("ChildFailed", () => succeed7(new FixFailed)));
31564
31746
  })
31565
31747
  });
31566
31748
  var firewatch_default = defineLoop({
31567
31749
  id: "firewatch",
31568
- version: "2.0.0",
31750
+ version: "2.1.0",
31569
31751
  title: "Firewatch",
31570
31752
  description: "Investigates an alert and writes its cited cause on a Bug Task, offering a fix.",
31571
31753
  input: Input7,
@@ -31626,6 +31808,12 @@ ${conclusionText(conclusion, resolvedDuring)}`,
31626
31808
  return { ...ended, fix: "started", changeRequestUrl: offered.changeRequestUrl };
31627
31809
  if (offered._tag === "FixFailed")
31628
31810
  return { ...ended, fix: "failed", fixRequest };
31811
+ if (offered._tag === "FixUnneeded")
31812
+ return {
31813
+ ...ended,
31814
+ fix: "unneeded",
31815
+ ...offered.changeRequestUrl === undefined ? undefined : { changeRequestUrl: offered.changeRequestUrl }
31816
+ };
31629
31817
  return { ...ended, fix: "declined", fixRequest };
31630
31818
  })
31631
31819
  });
@@ -32080,7 +32268,8 @@ var unmerged = {
32080
32268
 
32081
32269
  class Merged2 extends TaggedClass2()("Merged", {
32082
32270
  repoBindingId: String5,
32083
- changeRequest: ChangeRequestResult
32271
+ changeRequest: optionalKey2(ChangeRequestResult),
32272
+ reason: optionalKey2(String5)
32084
32273
  }) {
32085
32274
  }
32086
32275
 
@@ -32113,7 +32302,8 @@ var resultOf = ({ key, title }, outcome) => {
32113
32302
  title,
32114
32303
  status: "merged",
32115
32304
  repoBindingId: outcome.repoBindingId,
32116
- changeRequest: outcome.changeRequest
32305
+ ...outcome.changeRequest === undefined ? undefined : { changeRequest: outcome.changeRequest },
32306
+ ...outcome.reason === undefined ? undefined : { reason: outcome.reason }
32117
32307
  };
32118
32308
  return {
32119
32309
  key,
@@ -32138,7 +32328,7 @@ var buildOf = {
32138
32328
  };
32139
32329
  var buildTried = step2("buildTried", {
32140
32330
  payload: buildOf,
32141
- success: Union2([Built3, Failed, Skipped]),
32331
+ success: Union2([Built3, Merged2, Failed, Skipped]),
32142
32332
  run: ({ ticket, head, taskId, steer }) => gen2(function* () {
32143
32333
  const words = steer === undefined ? taskId === undefined ? { words: buildWords(ticket) } : undefined : { words: `${buildWords(ticket)}
32144
32334
 
@@ -32156,6 +32346,8 @@ An earlier Build of this failed. ${steer}` };
32156
32346
  }));
32157
32347
  if (built instanceof ChildFailed)
32158
32348
  return new Failed({ repoBindingId: head.repoBindingId, reason: built.reason });
32349
+ if (isNothingToDo(built))
32350
+ return new Merged2({ repoBindingId: head.repoBindingId, reason: `Nothing needed changing: ${built.summary}` });
32159
32351
  if (built.notRun !== undefined && built.notRun.length > 0) {
32160
32352
  const unverified = yield* ask("unverified", {
32161
32353
  prompt: `Verify never ran some tests of the ChangeRequest for ${ticket.key} (${built.changeRequest.url}):
@@ -33226,7 +33418,7 @@ var improved = step2("improved", {
33226
33418
  key: ({ key }) => key,
33227
33419
  run: ({ key, size, words, taskId }) => {
33228
33420
  const on = { words, taskId };
33229
- const started = size === "errand" ? map8(call("improve", errand_default, on), (done) => done.status) : map8(call("improve", build_default, on), (built) => built.stopped);
33421
+ const started = size === "errand" ? map8(call("improve", errand_default, on), (done) => done.status) : map8(call("improve", build_default, on), (built) => isNothingToDo(built) ? built.changeRequest === undefined ? built.status : `${built.status}: close ${built.changeRequest.url}` : built.stopped);
33230
33422
  return started.pipe(catchTag2("ChildFailed", (failed) => succeed7(`failed: ${failed.reason}`)), map8((outcome) => ({ key, loop: size, outcome })));
33231
33423
  }
33232
33424
  });
@@ -40096,4 +40288,4 @@ var runKit = (config, identity, packages) => {
40096
40288
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
40097
40289
  };
40098
40290
  // .kitman-build-entry.ts
40099
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.50.0" }, []);
40291
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.51.0" }, []);