@kitman-sh/software-engineering 0.13.7 → 0.13.8

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
@@ -21174,6 +21174,12 @@ var deliveryLayerWords = {
21174
21174
  workspace: "the Workspace"
21175
21175
  };
21176
21176
 
21177
+ // src/reviewed-scope.ts
21178
+ var ReviewedScope = Struct({
21179
+ ...ScopeJudgement.fields,
21180
+ reported: optional2(ArraySchema(String5))
21181
+ });
21182
+
21177
21183
  // src/text-limits.ts
21178
21184
  var bounded2 = (maxLength, description) => String5.check(isMaxLength(maxLength)).annotate({ description });
21179
21185
  var OneSentence = bounded2(300, "One sentence, at most 300 characters.");
@@ -21209,6 +21215,7 @@ var Input = Struct({
21209
21215
  claims: optional2(ArraySchema(String5)),
21210
21216
  earlier: optional2(ArraySchema(MergedFinding)),
21211
21217
  reviewed: optional2(String5),
21218
+ scope: optional2(ReviewedScope),
21212
21219
  failing: optional2(ArraySchema(String5)),
21213
21220
  notRun: optional2(ArraySchema(String5)),
21214
21221
  next: optional2(Literals(choices)),
@@ -21224,11 +21231,14 @@ var SeatFinding = Struct({
21224
21231
  checked: optional2(ArraySchema(ShortStatement)),
21225
21232
  outsideFix: optional2(Boolean3)
21226
21233
  });
21227
- var ReviewedScope = Struct({
21228
- ...ScopeJudgement.fields,
21229
- reported: optional2(ArraySchema(String5))
21230
- });
21231
21234
  var agreedScope = (scope) => scope.unmet.length === 0 && (scope.reported ?? []).length > 0 ? { ...scope, met: true } : scope;
21235
+ var carriedScope = (judged, earlier) => {
21236
+ if (judged === undefined)
21237
+ return earlier;
21238
+ const scope = agreedScope(judged);
21239
+ const reported = [...new Set([...earlier?.reported ?? [], ...scope.reported ?? []])].filter((item) => !scope.unmet.includes(item));
21240
+ return earlier === undefined || reported.length === 0 ? scope : { ...scope, reported };
21241
+ };
21232
21242
  var SeatOutput = Struct({
21233
21243
  summary: OneSentence,
21234
21244
  findings: ArraySchema(SeatFinding),
@@ -21265,13 +21275,14 @@ class ReviewBaseUnpinned extends TaggedError3()("ReviewBaseUnpinned", {
21265
21275
  message: String5
21266
21276
  }) {
21267
21277
  }
21278
+ var unfetchable = (head) => `If the Runner cannot fetch revision ${head} (a fork, say), report exactly that as your only finding, a blocker, and stop.`;
21268
21279
  var targetOf = (input, { base, head, branches, epic }) => {
21269
21280
  if (epic !== undefined)
21270
21281
  return `the epic's whole change \`git diff ${base}...${head}\` in your checkout: epic branch \`${epic.branch}\` against default branch \`${epic.defaultBranch}\`, as they stood when this review started. Fetch both from \`origin\` and diff exactly those commits, even if either branch has moved since.`;
21271
21282
  if (input.changeRequestId !== undefined && branches !== undefined) {
21272
21283
  const { source, target } = branches;
21273
21284
  const from = source === undefined ? "" : ` from source branch \`${source}\``;
21274
- return `ChangeRequest ${input.changeRequestId} at revision ${head}: \`git diff ${base}...${head}\`, its change${from} into target branch \`${target}\` as that stood when this review started. This names all you need of the ChangeRequest, so look nothing up: fetch \`${source ?? head}\` and \`${target}\` from \`origin\`, and diff exactly those commits even if either branch has moved since. If the Runner cannot fetch revision ${head} (a fork, say), report exactly that as your only finding, a blocker, and stop.`;
21285
+ return `ChangeRequest ${input.changeRequestId} at revision ${head}: \`git diff ${base}...${head}\`, its change${from} into target branch \`${target}\` as that stood when this review started. This names all you need of the ChangeRequest, so look nothing up: fetch \`${source ?? head}\` and \`${target}\` from \`origin\`, and diff exactly those commits even if either branch has moved since. ${unfetchable(head)}`;
21275
21286
  }
21276
21287
  if (input.files === undefined && input.approved !== undefined)
21277
21288
  return [
@@ -21312,39 +21323,78 @@ var pinnedRange = (input) => gen2(function* () {
21312
21323
  return { base, head };
21313
21324
  });
21314
21325
  var wholeChange = (input) => input.files === undefined && input.approved === undefined;
21315
- var scopePrompt = (input) => [
21316
- "If your brief has a Task, judge its scope and give it as `scope`: does the change do what the Task's description and each of its Acceptance Criteria ask? Judge it against what is still agreed: a criterion or part an answer under your brief's Answers so far put out of scope is reported, not unmet; list each in `reported`, one line each, and leave it out of `unmet`. Set `met` to true only if the change does all the rest, and list in `unmet` one line for each other criterion or part of the description that is not done. If your brief has no Task, leave `scope` out.",
21317
- ...input.outcome === undefined ? [] : [`The Outcome to prove is ${input.outcome}.`],
21318
- ...input.claims === undefined || input.claims.length === 0 ? [] : [
21319
- "The implementer claims it built these. Check them against the code rather than taking them on trust:",
21320
- ...input.claims.map((claim) => `- ${claim}`)
21321
- ]
21326
+ var wholeScopePrompt = "If your brief has a Task, judge its scope and give it as `scope`: does the change do what the Task's description and each of its Acceptance Criteria ask? Judge it against what is still agreed: a criterion or part an answer under your brief's Answers so far put out of scope is reported, not unmet; list each in `reported`, one line each, and leave it out of `unmet`. Set `met` to true only if the change does all the rest, and list in `unmet` one line for each other criterion or part of the description that is not done. If your brief has no Task, leave `scope` out.";
21327
+ var rejudgedScopePrompt = (unmet) => [
21328
+ [
21329
+ "If your brief has a Task, judge its scope again and give it as `scope`. An earlier round judged what the Task's description and Acceptance Criteria ask, and that stands, so do not judge all of it again.",
21330
+ ...unmet.length === 0 ? ["It found nothing unmet."] : [
21331
+ "It found these unmet. Judge each of these again, against the code at the head, and list each that is still not done in `unmet`, in the same words:",
21332
+ ...unmet.map((item) => `- ${item}`)
21333
+ ]
21334
+ ].join(`
21335
+ `),
21336
+ "Also list in `unmet`, one line each, any criterion or part the fix undoes. What an answer under your brief's Answers so far put out of scope is reported, not unmet: list each of these in `reported` instead. Set `met` to true only if `unmet` is empty. If your brief has no Task, leave `scope` out."
21322
21337
  ].join(`
21323
21338
 
21324
21339
  `);
21325
- var exhaustivePrompt = [
21326
- "Review exhaustively, in this one pass. For each rule or check the change adds or alters, such as who may read or change what, a validation, a limit or a state transition, trace it through every caller and every input it can get before you report: each kind of actor, each visibility, Team and Project scope, and ids the caller gives.",
21340
+ var fixRound = (input) => (input.earlier?.length ?? 0) > 0 || input.reviewed !== undefined;
21341
+ var scopeToRejudge = (input) => fixRound(input) && (input.scope?.met === true || (input.scope?.unmet.length ?? 0) > 0) ? input.scope : undefined;
21342
+ var scopePrompt = (input) => {
21343
+ const earlier = scopeToRejudge(input);
21344
+ return [
21345
+ earlier === undefined ? wholeScopePrompt : rejudgedScopePrompt(earlier.unmet),
21346
+ ...input.outcome === undefined ? [] : [`The Outcome to prove is ${input.outcome}.`],
21347
+ ...input.claims === undefined || input.claims.length === 0 ? [] : [
21348
+ earlier === undefined ? "The implementer claims it built these. Check them against the code rather than taking them on trust:" : "The implementer claims these. Check those about the fix or an unmet item against the code rather than taking them on trust:",
21349
+ ...input.claims.map((claim) => `- ${claim}`)
21350
+ ]
21351
+ ].join(`
21352
+
21353
+ `);
21354
+ };
21355
+ var exhaustivePrompt = (subject) => [
21356
+ `Review exhaustively, in this one pass. For each rule or check ${subject} adds or alters, such as who may read or change what, a validation, a limit or a state transition, trace it through every caller and every input it can get before you report: each kind of actor, each visibility, Team and Project scope, and ids the caller gives.`,
21327
21357
  "Report every finding of every severity in this one pass, grouped by the rule it breaks: do not stop at the first serious one in an area, and hold none back for a later round. Give each its `rule`, worded alike for every finding that breaks the same rule, and its `checked`: the sibling cases of that rule you checked and found fine, so the next round need not explore them again."
21328
21358
  ].join(" ");
21329
21359
  var earlierPrompt = (earlier) => [
21330
- "An earlier review found these. Give each as a `followUps` entry with its id: fixed, changed (the code moved but the problem stands) or still_there. Do not report them again as findings.",
21360
+ "Earlier rounds, by both reviewers, left these findings open. Give each as a `followUps` entry with its id: fixed, changed (the code moved but the problem stands) or still_there. Do not report them again as findings.",
21331
21361
  ...earlier.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
21332
21362
  ].join(`
21333
21363
  `);
21334
- var fixRound = (input) => (input.earlier?.length ?? 0) > 0 || input.reviewed !== undefined;
21335
- var fixPrompt = (fix) => `This round reviews ${fix} and the code it touches, exhaustively as above. Raise a new problem outside the fix and the code it touches only if it is a blocker; report one that is not as a minor with \`outsideFix\` set to true, which does not block landing.`;
21336
- var fixOf = (input, head) => input.reviewed === undefined ? "the fix since the earlier review" : `the fix, \`git diff ${input.reviewed}..${head}\` (the target branch merged into it is not the fix),`;
21337
- var promptFor = (seat, target, head, input, failing, notRun) => [
21338
- `You are one of two reviewers. Follow your \`${seats[seat].skill}\` skill; if you do not have it: ${seats[seat].focus}`,
21364
+ var outsideFixPrompt = "Raise a new problem outside the fix and the code it touches only if it is a blocker; report one that is not as a minor with `outsideFix` set to true, which does not block landing.";
21365
+ var fixTargetOf = (input, { head, branches, epic }) => {
21366
+ const from = input.reviewed ?? (input.files === undefined ? undefined : input.since);
21367
+ const branch = branches === undefined ? epic?.branch : branches.source ?? head;
21368
+ return [
21369
+ `${from === undefined ? `the fix made since the earlier review, up to revision ${head}, which you find from the open findings and \`git log\`,` : `the fix, \`git diff ${from}..${head}\`,`} and the code it touches. An empty fix means nothing was changed, so judge only what is asked below. An earlier round reviewed the rest of the change, so do not review that again. You may read any other code you need.`,
21370
+ "The commits merging the target branch brought in are not the fix; what such a merge changed in this change, such as a settled conflict, is.",
21371
+ ...input.files === undefined ? input.approved === undefined ? [] : [
21372
+ `The change was approved at ${input.approved}. Report a problem in code it already had there only if it matters, with \`approvedCode\` set to true: such findings are kept apart and do not block.`
21373
+ ] : [
21374
+ [
21375
+ "Whatever changed in these files since then, even by merging the target branch, counts as the fix:",
21376
+ ...input.files.map((file) => `- ${file}`)
21377
+ ].join(`
21378
+ `)
21379
+ ],
21380
+ ...branch === undefined ? [] : [
21381
+ `Look nothing up: fetch \`${branch}\` from \`origin\`, and read exactly revision ${head} even if it has moved since. ${unfetchable(head)}`
21382
+ ]
21383
+ ].join(`
21384
+
21385
+ `);
21386
+ };
21387
+ var promptFor = (seat, target, input, failing, notRun) => [
21388
+ `You are ${fixRound(input) ? "the only reviewer of this round" : "one of two reviewers"}. Follow your \`${seats[seat].skill}\` skill; if you do not have it: ${seats[seat].focus}`,
21339
21389
  `Review ${target}`,
21340
21390
  "Give `summary`: one sentence on whether it can merge and what matters most.",
21341
21391
  "Report each problem as a finding: severity blocker (must not ship), major (fix before merge) or minor (optional); the file path from the repository root; the line; and the detail. When it is one instance of a class of bug, name every other instance in the diff in its detail. Report nothing you have not checked in the code.",
21342
- exhaustivePrompt,
21392
+ exhaustivePrompt(fixRound(input) ? "the fix" : "the change"),
21343
21393
  "What an answer under your brief's Answers so far put out of scope is reported, not missing: do not report it as a finding.",
21344
21394
  "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.",
21345
21395
  ...seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : [],
21346
21396
  ...input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)],
21347
- ...fixRound(input) ? [fixPrompt(fixOf(input, head))] : [],
21397
+ ...fixRound(input) ? [outsideFixPrompt] : [],
21348
21398
  ...failing.length === 0 ? [] : [
21349
21399
  `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.`
21350
21400
  ],
@@ -21369,6 +21419,19 @@ var detailOf = (detail, rule, checked) => [
21369
21419
  detail,
21370
21420
  ...checked.length === 0 ? [] : [`Checked and fine: ${checked.join("; ")}.`]
21371
21421
  ].join(" ");
21422
+ var severityRank = { blocker: 0, major: 1, minor: 2 };
21423
+ var blockingSeatsOf = (finding) => isBlocking(finding) ? finding.blockingSeats ?? finding.seats : [];
21424
+ var withEarlier = (worse, earlier) => {
21425
+ const { blockingSeats: _, ...finding } = worse;
21426
+ const seats = [...new Set([...earlier.seats, ...worse.seats])];
21427
+ const blockingSeats = [...new Set([...blockingSeatsOf(earlier), ...blockingSeatsOf(worse)])];
21428
+ return {
21429
+ ...finding,
21430
+ detail: `${finding.detail} Still open on this line: ${earlier.detail}`,
21431
+ seats,
21432
+ ...blockingSeats.length === seats.length ? undefined : { blockingSeats }
21433
+ };
21434
+ };
21372
21435
  var idOf = (finding) => `${finding.file}:${finding.line}`;
21373
21436
  var groupedByRule = (bySeat) => {
21374
21437
  const rules = new Map;
@@ -21420,14 +21483,15 @@ ${followUps.map((entry) => `- \`${entry.id}\` ${entry.status.replace("_", " ")}`
21420
21483
  ].join(`
21421
21484
 
21422
21485
  `);
21423
- var fixBrief = (changeRequestId, findings) => [
21486
+ var fixBrief = (changeRequestId, findings, unmet) => [
21424
21487
  `Fix what a review of ChangeRequest ${changeRequestId} found, on its branch:`,
21425
- ...findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
21488
+ ...findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`),
21489
+ ...unmet.length === 0 ? [] : ["Do what it found unmet:", ...unmet.map((item) => `- ${item}`)]
21426
21490
  ].join(`
21427
21491
  `);
21428
21492
  var review_default = defineLoop({
21429
21493
  id: "review",
21430
- version: "3.9.0",
21494
+ version: "3.10.0",
21431
21495
  title: "Review",
21432
21496
  input: Input,
21433
21497
  output: Output,
@@ -21457,37 +21521,45 @@ var review_default = defineLoop({
21457
21521
  return yield* new ReviewDiffEmpty({
21458
21522
  message: `Base and head are both commit ${range.head}, so the diff is empty: give the base the change is to merge into`
21459
21523
  });
21460
- const target = targetOf(input, range);
21524
+ const target = fixRound(input) ? fixTargetOf(input, range) : targetOf(input, range);
21461
21525
  const verified = head === undefined ? { failing: [], notRun: [] } : yield* verifyHead("verify", head);
21462
21526
  const failing = [...new Set([...input.failing ?? [], ...verified.failing])];
21463
21527
  const notRun = [...new Set([...input.notRun ?? [], ...verified.notRun])];
21464
- const outputs = yield* forEach2(seatNames, (seat) => agentWork(`review:${seat}`, {
21528
+ const outputs = yield* forEach2(fixRound(input) ? [scopeSeat] : seatNames, (seat) => agentWork(`review:${seat}`, {
21465
21529
  agent: seat,
21466
- prompt: promptFor(seat, target, range.head, input, failing, notRun),
21530
+ prompt: promptFor(seat, target, input, failing, notRun),
21467
21531
  output: SeatOutput
21468
21532
  }).pipe(map8((output) => [seat, output])), { concurrency: "unbounded" });
21469
21533
  const earlier = input.earlier ?? [];
21470
- const earlierIds = new Set(earlier.map((finding) => finding.id));
21534
+ const earlierById = new Map(earlier.map((finding) => [finding.id, finding]));
21471
21535
  const answered = followUpsOf(earlier, outputs.flatMap(([, output]) => output.followUps ?? []));
21472
21536
  const standing = new Set(answered.flatMap((entry) => entry.status === "fixed" ? [] : [entry.id]));
21473
- const verdicts = outputs.flatMap(([, output]) => output.verdicts ?? []);
21474
- const settled = settleRound({ findings: earlier, rebuttals: input.rebuttals ?? [], verdicts });
21537
+ const given = outputs.flatMap(([, output]) => output.verdicts ?? []);
21538
+ const settled = settleRound({ findings: earlier, rebuttals: input.rebuttals ?? [], verdicts: given });
21475
21539
  const withdrawn = new Set(settled.withdrawn.map((entry) => entry.finding.id));
21476
- const carried = earlier.filter((finding) => standing.has(finding.id) && !withdrawn.has(finding.id));
21540
+ const open = new Map([...earlierById].filter(([id]) => standing.has(id) && !withdrawn.has(id)));
21477
21541
  const followUps = answered.filter((entry) => !withdrawn.has(entry.id));
21478
21542
  const sinceApproval = input.approved !== undefined && input.files === undefined;
21543
+ const isNew = (finding) => {
21544
+ const before = earlierById.get(idOf(finding));
21545
+ return before === undefined || severityRank[finding.severity] < severityRank[before.severity] || !standing.has(before.id) && !withdrawn.has(before.id);
21546
+ };
21479
21547
  const merged = (approvedCode) => groupedByRule(Object.fromEntries(outputs.map(([seat, output]) => [
21480
21548
  seat,
21481
- output.findings.filter((finding) => !earlierIds.has(`${finding.file}:${finding.line}`) && (sinceApproval && finding.approvedCode === true) === approvedCode).map((finding) => fixRound(input) ? outsideFixAsMinor(finding) : finding)
21549
+ output.findings.map((finding) => fixRound(input) ? outsideFixAsMinor(finding) : finding).filter((finding) => isNew(finding) && (sinceApproval && finding.approvedCode === true) === approvedCode)
21482
21550
  ])));
21483
- const fresh = merged(false);
21551
+ const fresh = merged(false).map((finding) => {
21552
+ const before = open.get(finding.id);
21553
+ return before === undefined ? finding : withEarlier(finding, before);
21554
+ });
21555
+ const freshIds = new Set(fresh.map((finding) => finding.id));
21484
21556
  const approvedFindings = sinceApproval ? merged(true) : [];
21485
- const findings = [...carried, ...fresh];
21557
+ const findings = [...[...open.values()].filter((finding) => !freshIds.has(finding.id)), ...fresh];
21558
+ const verdicts = given.map((verdict) => freshIds.has(verdict.findingId) ? { ...verdict, accepted: false } : verdict);
21486
21559
  const blockers = findings.filter(isBlocking);
21487
- const judged = wholeChange(input) ? outputs.find(([seat]) => seat === scopeSeat)?.[1].scope : undefined;
21488
- const scope = judged === undefined ? undefined : agreedScope(judged);
21560
+ const judged = outputs.find(([seat]) => seat === scopeSeat)?.[1].scope;
21561
+ const scope = wholeChange(input) ? carriedScope(judged, fixRound(input) ? input.scope : undefined) : undefined;
21489
21562
  const summary = blockers.length > 0 ? `Blocking: fix ${blockers.map((finding) => finding.id).join(", ")} before merging.` : scope?.met === false ? "Not ready: the change does not yet do what was asked." : failing.length > 0 ? `Not ready: ${failing.join(", ")} fails on this head.` : notRun.length > 0 ? "Not ready: verify never ran some of its tests, so they are unverified." : findings.length === 0 ? sinceApproval ? `No findings in what changed since ${input.approved}: nothing stands in the way of merging.` : "No findings: nothing stands in the way of merging." : ["Can merge: nothing blocks it.", ...outputs.map(([, output]) => output.summary)].join(" ");
21490
- const freshIds = new Set(fresh.map((finding) => finding.id));
21491
21563
  const text = reviewText(summary, findings, followUps, approvedFindings, notRun, scope?.reported ?? []);
21492
21564
  const stored = yield* artifact("findings", {
21493
21565
  kind: "review-findings",
@@ -21537,18 +21609,19 @@ What next?`,
21537
21609
  }
21538
21610
  if (choice === "Fix here") {
21539
21611
  const fixed = yield* call("fix", buildLoop(), {
21540
- words: fixBrief(changeRequestId, findings),
21612
+ words: fixBrief(changeRequestId, findings, scope?.unmet ?? []),
21541
21613
  changeRequestId,
21542
21614
  maxRounds: 2,
21543
21615
  reviewed: range.head,
21544
21616
  ...findings.length === 0 ? undefined : { earlier: findings },
21617
+ ...scope === undefined ? undefined : { scope },
21545
21618
  ...ownDeliveryTarget(input)
21546
21619
  });
21547
21620
  return { choice, detail: fixed.settled ? "Fixed and pushed" : `Pushed; left: ${fixed.unsettled.join("; ")}` };
21548
21621
  }
21549
21622
  if (choice === "Build from it") {
21550
21623
  const built = yield* call("build", buildLoop(), {
21551
- words: fixBrief(changeRequestId, findings),
21624
+ words: fixBrief(changeRequestId, findings, scope?.unmet ?? []),
21552
21625
  ...ownDeliveryTarget(input)
21553
21626
  });
21554
21627
  return { choice, detail: built.changeRequest.url };
@@ -22104,7 +22177,8 @@ var ShepherdOutput = Struct({
22104
22177
  taskId: optional2(String5),
22105
22178
  branch: optional2(String5),
22106
22179
  reviewed: optional2(String5),
22107
- earlier: optional2(ArraySchema(MergedFinding))
22180
+ earlier: optional2(ArraySchema(MergedFinding)),
22181
+ scope: optional2(ReviewedScope)
22108
22182
  }))
22109
22183
  });
22110
22184
 
@@ -22294,7 +22368,7 @@ var repliesPrompt = (threads) => [
22294
22368
  var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
22295
22369
  var shepherd_default = defineLoop({
22296
22370
  id: "shepherd",
22297
- version: "1.9.0",
22371
+ version: "1.10.0",
22298
22372
  title: "Shepherd",
22299
22373
  input: Input3,
22300
22374
  output: Output3,
@@ -22331,6 +22405,7 @@ var shepherd_default = defineLoop({
22331
22405
  const leftToPerson = new Set;
22332
22406
  let headFindings = [];
22333
22407
  let headFindingsAt;
22408
+ let headScope;
22334
22409
  const unranAt = new Map;
22335
22410
  const rounds = { "ci-fix": 0, "head-fix": 0 };
22336
22411
  const allowed = { "ci-fix": 0, "head-fix": 0 };
@@ -22544,7 +22619,13 @@ ${open}`,
22544
22619
  unreviewed = caught.from === unreviewed.synced ? { ...unreviewed, files, synced: caught.head } : { ...unreviewed, files };
22545
22620
  } else if (caught !== undefined && verdict.kind === "review") {
22546
22621
  notCarried = undefined;
22547
- unreviewed = { files: verdict.files, synced: caught.head, sync: `sync:${cycle}`, earlier: [] };
22622
+ unreviewed = {
22623
+ files: verdict.files,
22624
+ synced: caught.head,
22625
+ sync: `sync:${cycle}`,
22626
+ from: caught.from,
22627
+ earlier: []
22628
+ };
22548
22629
  } else if (caught !== undefined) {
22549
22630
  notCarried = undefined;
22550
22631
  const carried = yield* approveChangeRequest(`carry:${cycle}`, {
@@ -22627,7 +22708,8 @@ ${open}`,
22627
22708
  }
22628
22709
  return stop(ready);
22629
22710
  });
22630
- const reviewMergedFiles = (cycle, head, files) => gen2(function* () {
22711
+ const reviewMergedFiles = (cycle, pipeline, files) => gen2(function* () {
22712
+ const { head } = pipeline;
22631
22713
  yield* passTurn();
22632
22714
  const reviewed = yield* call(`review:${cycle}`, reviewLoop(), {
22633
22715
  base: `origin/${target}`,
@@ -22640,7 +22722,7 @@ ${open}`,
22640
22722
  if (reviewed.blocking) {
22641
22723
  const blocking = reviewed.findings.filter(isBlocking);
22642
22724
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
22643
- return stop(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), { reviewed: head, earlier: reviewed.findings }));
22725
+ return stop(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), pipeline.approved === files.from ? { reviewed: head, earlier: reviewed.findings } : undefined));
22644
22726
  rounds["head-fix"]++;
22645
22727
  const fix = yield* agentWork(`review-fix:${cycle}`, {
22646
22728
  agent: "implementer",
@@ -22700,12 +22782,18 @@ ${open}`,
22700
22782
  ...notRun.length === 0 ? undefined : { notRun },
22701
22783
  ...since === undefined ? undefined : { approved: since },
22702
22784
  ...headFindings.length === 0 ? undefined : { earlier: headFindings },
22703
- ...headFindingsAt === undefined ? undefined : { reviewed: headFindingsAt }
22785
+ ...headFindingsAt === undefined ? undefined : { reviewed: headFindingsAt },
22786
+ ...headScope === undefined ? undefined : { scope: headScope }
22704
22787
  });
22705
22788
  if (reviewed.blocking) {
22706
22789
  const blocking = reviewed.findings.filter(isBlocking);
22707
22790
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
22708
- return stop(handBack(`The review of ${head} still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking), { reviewed: head, earlier: reviewed.findings }));
22791
+ return stop(handBack(`The review of ${head} still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, [findingLines2(blocking), ...(reviewed.scope?.unmet ?? []).map((item) => `- Not done: ${item}`)].join(`
22792
+ `), {
22793
+ reviewed: head,
22794
+ earlier: reviewed.findings,
22795
+ ...reviewed.scope === undefined ? undefined : { scope: reviewed.scope }
22796
+ }));
22709
22797
  rounds["head-fix"]++;
22710
22798
  const fix = yield* agentWork(`head-fix:${cycle}`, {
22711
22799
  agent: "implementer",
@@ -22715,11 +22803,13 @@ ${open}`,
22715
22803
  });
22716
22804
  headFindings = reviewed.findings;
22717
22805
  headFindingsAt = head;
22806
+ headScope = reviewed.scope;
22718
22807
  fixedFrom = { head, changed: fix.changed, looks: 0 };
22719
22808
  return { kind: "fixing" };
22720
22809
  }
22721
22810
  headFindings = [];
22722
22811
  headFindingsAt = undefined;
22812
+ headScope = undefined;
22723
22813
  if (notRun.length > 0)
22724
22814
  unranAt.set(head, { notRun, review: `head-review:${cycle}` });
22725
22815
  else {
@@ -22765,7 +22855,7 @@ ${open}`,
22765
22855
  if (head !== pipeline.head)
22766
22856
  return;
22767
22857
  if (unreviewed !== undefined)
22768
- return yield* reviewMergedFiles(cycle, head, unreviewed);
22858
+ return yield* reviewMergedFiles(cycle, pipeline, unreviewed);
22769
22859
  if (notCarried !== undefined && pipeline.approved !== head)
22770
22860
  return yield* reviewHead(cycle, pipeline, "the head its catch-up merge pushed");
22771
22861
  return;
@@ -22990,7 +23080,7 @@ ${open}`,
22990
23080
  }
22991
23081
  let reviewedHere = reviewedHeads.has(pipeline.head) && (pipeline.approved === pipeline.head || unranAt.has(pipeline.head));
22992
23082
  if (unreviewed !== undefined) {
22993
- const reviewing = yield* reviewMergedFiles(cycle, pipeline.head, unreviewed);
23083
+ const reviewing = yield* reviewMergedFiles(cycle, pipeline, unreviewed);
22994
23084
  if (reviewing.kind === "stop")
22995
23085
  return reviewing.output;
22996
23086
  if (reviewing.kind === "fixing")
@@ -23177,6 +23267,7 @@ var BuildInput = Struct({
23177
23267
  maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0))),
23178
23268
  reviewed: optional2(String5),
23179
23269
  earlier: optional2(ArraySchema(MergedFinding)),
23270
+ scope: optional2(ReviewedScope),
23180
23271
  ...DeliveryFields
23181
23272
  });
23182
23273
  var CriterionAnswer = Struct({
@@ -23224,6 +23315,7 @@ var BuildOutput = Struct({
23224
23315
  criteria: ArraySchema(CriterionAnswer),
23225
23316
  notRun: optional2(ArraySchema(String5)),
23226
23317
  findings: optional2(ArraySchema(MergedFinding)),
23318
+ scope: optional2(ReviewedScope),
23227
23319
  blockingCounts: optional2(ArraySchema(Int)),
23228
23320
  approval: optional2(ApproveChangeRequestResult),
23229
23321
  landed: optional2(ShepherdOutput),
@@ -23300,7 +23392,7 @@ var reproducedOnBranchPrompt = (task) => [
23300
23392
  var findingLine = (finding) => `- **${finding.severity}** \`${finding.id}\` ${finding.detail}`;
23301
23393
  var disputeLine = ({ finding, rebuttal }) => `${findingLine(finding)}
23302
23394
  You rebutted: ${rebuttal.reason}`;
23303
- var fixPrompt2 = (settled) => {
23395
+ var fixPrompt = (settled) => {
23304
23396
  const checks = settled.open.filter((finding) => isCheckFinding(finding.id));
23305
23397
  const findings = settled.open.filter((finding) => !isCheckFinding(finding.id));
23306
23398
  return [
@@ -23365,12 +23457,14 @@ var rally = (input) => gen2(function* () {
23365
23457
  };
23366
23458
  const failing = brokenChecks(head).map((check) => check.name);
23367
23459
  const notRun = testsNotRunReasons(head);
23460
+ const scope = last === undefined ? input.scope : last.scope;
23368
23461
  const reviewed = yield* call(`review:${round}`, review_default, {
23369
23462
  base,
23370
23463
  head: head.revision,
23371
23464
  ...rebuttals.length === 0 ? undefined : { rebuttals },
23372
23465
  ...earlier.length === 0 ? undefined : { earlier },
23373
23466
  ...last === undefined ? input.reviewed === undefined ? undefined : { reviewed: input.reviewed } : { reviewed: last.head.revision },
23467
+ ...scope === undefined ? undefined : { scope },
23374
23468
  ...input.outcome === undefined ? undefined : { outcome: input.outcome },
23375
23469
  ...failing.length === 0 ? undefined : { failing },
23376
23470
  ...notRun.length === 0 ? undefined : { notRun },
@@ -23407,7 +23501,7 @@ var rally = (input) => gen2(function* () {
23407
23501
  shown.add(finding.detail);
23408
23502
  const fixed = yield* agentWork(`fix:${round}`, {
23409
23503
  agent: "implementer",
23410
- prompt: fixPrompt2(settled),
23504
+ prompt: fixPrompt(settled),
23411
23505
  output: Fixed
23412
23506
  });
23413
23507
  claims.push(...fixed.claims, ...fixed.rebuttals.flatMap((rebuttal) => isCheckFinding(rebuttal.findingId) ? [`Rebutted ${rebuttal.findingId}: ${rebuttal.reason}`] : []));
@@ -23422,7 +23516,7 @@ var rally = (input) => gen2(function* () {
23422
23516
  });
23423
23517
  var build2 = defineLoop({
23424
23518
  id: "build",
23425
- version: "2.10.0",
23519
+ version: "2.11.0",
23426
23520
  title: "Build",
23427
23521
  input: BuildInput,
23428
23522
  output: BuildOutput,
@@ -23484,7 +23578,8 @@ var build2 = defineLoop({
23484
23578
  suggested: implemented.checks ?? [],
23485
23579
  reproducing: reproduced?.check,
23486
23580
  reviewed: input.reviewed,
23487
- earlier: input.earlier ?? []
23581
+ earlier: input.earlier ?? [],
23582
+ scope: input.scope
23488
23583
  });
23489
23584
  const verdict = evidenceGate({
23490
23585
  ...outcome === undefined ? undefined : { outcome },
@@ -23535,6 +23630,7 @@ var build2 = defineLoop({
23535
23630
  criteria,
23536
23631
  ...lastNotRun.length === 0 ? undefined : { notRun: lastNotRun },
23537
23632
  ...last.earlier.length === 0 ? undefined : { findings: last.earlier },
23633
+ ...last.scope === undefined ? undefined : { scope: last.scope },
23538
23634
  blockingCounts: last.blockingCounts,
23539
23635
  ...approval === undefined ? undefined : { approval }
23540
23636
  };
@@ -23599,6 +23695,7 @@ var build2 = defineLoop({
23599
23695
  land: false,
23600
23696
  reviewed: settledAs.revision,
23601
23697
  ...settledAs.findings === undefined ? undefined : { earlier: settledAs.findings },
23698
+ ...settledAs.scope === undefined ? undefined : { scope: settledAs.scope },
23602
23699
  ...ownDeliveryTarget(input)
23603
23700
  }, { constraints: standing.map(standingConstraint) });
23604
23701
  settledAs = rebuilt;
@@ -23813,7 +23910,7 @@ var changePrompt = (discovery, plan, tried, cycle) => [
23813
23910
 
23814
23911
  `);
23815
23912
  var revertPrompt = (start, cycle) => `Cycle ${cycle}'s change did not prove faster. Revert its commits, and only those: run \`git revert --no-edit ${start}..HEAD\`. Touch no commit at or before ${start}, never reset or force-push, and change nothing else.`;
23816
- var fixPrompt3 = (findings) => [
23913
+ var fixPrompt2 = (findings) => [
23817
23914
  "The review of the climb found these. Fix each, keep behaviour exactly as it is and keep the gain, and commit. Kitman verifies and measures again; a fix that costs the gain ends the climb.",
23818
23915
  ...findings.map((finding) => `- ${finding.id}: ${finding.detail}`)
23819
23916
  ].join(`
@@ -23876,7 +23973,7 @@ var steadier = (plan) => {
23876
23973
  };
23877
23974
  var hillclimb_default = defineLoop({
23878
23975
  id: "hillclimb",
23879
- version: "1.4.0",
23976
+ version: "1.5.0",
23880
23977
  title: "Hillclimb",
23881
23978
  outcome: "performance",
23882
23979
  input: Input5,
@@ -24010,7 +24107,7 @@ var hillclimb_default = defineLoop({
24010
24107
  const blocking = reviewed.findings.filter(isBlocking);
24011
24108
  yield* agentWork(`fix:${round}`, {
24012
24109
  agent: "implementer",
24013
- prompt: fixPrompt3(blocking),
24110
+ prompt: fixPrompt2(blocking),
24014
24111
  output: Struct({ summary: OneSentence })
24015
24112
  });
24016
24113
  const fixed = yield* verify(`verify:fix:${round}`, {});
@@ -24029,8 +24126,9 @@ var hillclimb_default = defineLoop({
24029
24126
  outcome: "performance",
24030
24127
  ...notRunOf(fixed),
24031
24128
  claims,
24032
- earlier: blocking,
24033
- reviewed: fixedFrom
24129
+ earlier: reviewed.findings,
24130
+ reviewed: fixedFrom,
24131
+ ...reviewed.scope === undefined ? undefined : { scope: reviewed.scope }
24034
24132
  });
24035
24133
  }
24036
24134
  const notRun = testsNotRunReasons(head);
@@ -25277,7 +25375,7 @@ var batchPrompt = (requests, target) => [
25277
25375
  ].join(`
25278
25376
 
25279
25377
  `);
25280
- var fixPrompt4 = (failed, applied) => [
25378
+ var fixPrompt3 = (failed, applied) => [
25281
25379
  `The batch of ${applied.map((number) => `!${number}`).join(", ")} fails these checks:`,
25282
25380
  ...failed.checks.filter((check) => check.status === "failed").map((check) => `- ${check.name}: \`${check.command}\``),
25283
25381
  "Fix what an update broke, the way its changelog says to. If an update cannot be fixed in a small change, take it back out and drop it with the reason. Commit nothing yourself."
@@ -25410,7 +25508,7 @@ var sweep_default = defineLoop({
25410
25508
  for (let round = 1;!checked.passed && round <= maxFixRounds && batched.applied.length > 0; round++) {
25411
25509
  batched = yield* agentWork(`fix:${round}`, {
25412
25510
  agent: "implementer",
25413
- prompt: fixPrompt4(checked, batched.applied),
25511
+ prompt: fixPrompt3(checked, batched.applied),
25414
25512
  output: Batched
25415
25513
  });
25416
25514
  for (const drop of batched.dropped)
@@ -31520,4 +31618,4 @@ var runKit = (config, identity, packages) => {
31520
31618
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31521
31619
  };
31522
31620
  // .kitman-build-entry.ts
31523
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.7" }, []);
31621
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.8" }, []);