@kitman-sh/software-engineering 0.12.0-rc.2 → 0.12.0-rc.3

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
@@ -19418,7 +19418,9 @@ var NoteRequest = Struct({
19418
19418
  });
19419
19419
  var CreateTasksRequest = Struct({
19420
19420
  tickets: ArraySchema(PlanTicket),
19421
- projectId: optionalKey2(String5)
19421
+ projectId: optionalKey2(String5),
19422
+ builds: optionalKey2(Boolean3),
19423
+ releases: optionalKey2(Boolean3)
19422
19424
  });
19423
19425
  var CreateTasksResult = Struct({
19424
19426
  tasks: ArraySchema(Struct({ key: String5, taskId: String5 }))
@@ -19463,7 +19465,8 @@ var ApproveChangeRequestRequest = Struct({
19463
19465
  head: String5,
19464
19466
  summary: String5,
19465
19467
  review: optionalKey2(String5),
19466
- carries: optionalKey2(String5)
19468
+ carries: optionalKey2(String5),
19469
+ reuses: optionalKey2(String5)
19467
19470
  });
19468
19471
  var ApproveChangeRequestResult = Union2([
19469
19472
  Struct({ approved: Literal2(true), reviewId: String5 }),
@@ -19522,6 +19525,7 @@ var PipelineStatus = Struct({
19522
19525
  runnerChecks: optionalKey2(ArraySchema(String5)),
19523
19526
  targetChecks: optionalKey2(ArraySchema(String5)),
19524
19527
  approved: optionalKey2(String5),
19528
+ reviewed: optionalKey2(Struct({ review: String5, notRun: optionalKey2(ArraySchema(String5)) })),
19525
19529
  repository: optionalKey2(String5),
19526
19530
  sourceBranch: optionalKey2(String5),
19527
19531
  targetBranch: optionalKey2(String5),
@@ -21114,6 +21118,7 @@ var Input = Struct({
21114
21118
  outcome: optional2(LoopOutcome),
21115
21119
  claims: optional2(ArraySchema(String5)),
21116
21120
  earlier: optional2(ArraySchema(MergedFinding)),
21121
+ reviewed: optional2(String5),
21117
21122
  failing: optional2(ArraySchema(String5)),
21118
21123
  notRun: optional2(ArraySchema(String5)),
21119
21124
  next: optional2(Literals(choices)),
@@ -21124,7 +21129,10 @@ var FollowUp = Struct({ id: String5, status: FollowUpStatus });
21124
21129
  var SeatFinding = Struct({
21125
21130
  ...Finding.fields,
21126
21131
  detail: FindingDetail,
21127
- approvedCode: optional2(Boolean3)
21132
+ approvedCode: optional2(Boolean3),
21133
+ rule: optional2(OneSentence),
21134
+ checked: optional2(ArraySchema(ShortStatement)),
21135
+ outsideFix: optional2(Boolean3)
21128
21136
  });
21129
21137
  var ReviewedScope = Struct({
21130
21138
  ...ScopeJudgement.fields,
@@ -21147,6 +21155,7 @@ var Output = Struct({
21147
21155
  blocking: Boolean3,
21148
21156
  artifactId: String5,
21149
21157
  scope: optional2(ReviewedScope),
21158
+ failing: optional2(ArraySchema(String5)),
21150
21159
  approval: optional2(Struct({ head: String5, approved: Boolean3, reason: optional2(String5) })),
21151
21160
  next: optional2(Struct({ choice: Literals(choices), detail: optional2(String5) })),
21152
21161
  deliversTo: optional2(ResolvedDeliveryTarget)
@@ -21216,20 +21225,29 @@ var scopePrompt = (input) => [
21216
21225
  ].join(`
21217
21226
 
21218
21227
  `);
21228
+ var exhaustivePrompt = [
21229
+ "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.",
21230
+ "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."
21231
+ ].join(" ");
21219
21232
  var earlierPrompt = (earlier) => [
21220
- "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; review only what changed since, for new problems.",
21233
+ "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.",
21221
21234
  ...earlier.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
21222
21235
  ].join(`
21223
21236
  `);
21224
- var promptFor = (seat, target, input, failing, notRun) => [
21237
+ var fixRound = (input) => (input.earlier?.length ?? 0) > 0 || input.reviewed !== undefined;
21238
+ 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.`;
21239
+ 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),`;
21240
+ var promptFor = (seat, target, head, input, failing, notRun) => [
21225
21241
  `You are one of two reviewers. Follow your \`${seats[seat].skill}\` skill; if you do not have it: ${seats[seat].focus}`,
21226
21242
  `Review ${target}`,
21227
21243
  "Give `summary`: one sentence on whether it can merge and what matters most.",
21228
21244
  "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.",
21245
+ exhaustivePrompt,
21229
21246
  "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.",
21230
21247
  "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.",
21231
21248
  ...seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : [],
21232
21249
  ...input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)],
21250
+ ...fixRound(input) ? [fixPrompt(fixOf(input, head))] : [],
21233
21251
  ...failing.length === 0 ? [] : [
21234
21252
  `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.`
21235
21253
  ],
@@ -21248,6 +21266,35 @@ var promptFor = (seat, target, input, failing, notRun) => [
21248
21266
 
21249
21267
  `);
21250
21268
  var rank2 = { still_there: 0, changed: 1, fixed: 2 };
21269
+ var outsideFixAsMinor = (finding) => finding.outsideFix === true && finding.severity === "major" ? { ...finding, severity: "minor" } : finding;
21270
+ var detailOf = (detail, rule, checked) => [
21271
+ ...rule === undefined ? [] : [`[${rule}]`],
21272
+ detail,
21273
+ ...checked.length === 0 ? [] : [`Checked and fine: ${checked.join("; ")}.`]
21274
+ ].join(" ");
21275
+ var idOf = (finding) => `${finding.file}:${finding.line}`;
21276
+ var groupedByRule = (bySeat) => {
21277
+ const rules = new Map;
21278
+ const checked = new Map;
21279
+ for (const finding of Object.values(bySeat).flat()) {
21280
+ const id = idOf(finding);
21281
+ if (finding.rule !== undefined && !rules.has(id))
21282
+ rules.set(id, finding.rule);
21283
+ checked.set(id, new Set([...checked.get(id) ?? [], ...finding.checked ?? []]));
21284
+ }
21285
+ const findings = mergeFindings(Object.fromEntries(Object.entries(bySeat).map(([seat, seatFindings]) => [
21286
+ seat,
21287
+ seatFindings.map((finding) => ({
21288
+ severity: finding.severity,
21289
+ file: finding.file,
21290
+ line: finding.line,
21291
+ detail: detailOf(finding.detail, rules.get(idOf(finding)), [...checked.get(idOf(finding)) ?? []])
21292
+ }))
21293
+ ])));
21294
+ const groupOf = (finding) => rules.get(finding.id) ?? finding.id;
21295
+ const order = [...new Set(findings.map(groupOf))];
21296
+ return findings.toSorted((left, right) => order.indexOf(groupOf(left)) - order.indexOf(groupOf(right)));
21297
+ };
21251
21298
  var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21252
21299
  const statuses = answers.flatMap((answer) => answer.id === finding.id ? [answer.status] : []);
21253
21300
  return {
@@ -21283,7 +21330,7 @@ var fixBrief = (changeRequestId, findings) => [
21283
21330
  `);
21284
21331
  var review_default = defineLoop({
21285
21332
  id: "review",
21286
- version: "3.8.0",
21333
+ version: "3.9.0",
21287
21334
  title: "Review",
21288
21335
  input: Input,
21289
21336
  output: Output,
@@ -21319,7 +21366,7 @@ var review_default = defineLoop({
21319
21366
  const notRun = [...new Set([...input.notRun ?? [], ...verified.notRun])];
21320
21367
  const outputs = yield* forEach2(seatNames, (seat) => agentWork(`review:${seat}`, {
21321
21368
  agent: seat,
21322
- prompt: promptFor(seat, target, input, failing, notRun),
21369
+ prompt: promptFor(seat, target, range.head, input, failing, notRun),
21323
21370
  output: SeatOutput
21324
21371
  }).pipe(map8((output) => [seat, output])), { concurrency: "unbounded" });
21325
21372
  const earlier = input.earlier ?? [];
@@ -21332,9 +21379,9 @@ var review_default = defineLoop({
21332
21379
  const carried = earlier.filter((finding) => standing.has(finding.id) && !withdrawn.has(finding.id));
21333
21380
  const followUps = answered.filter((entry) => !withdrawn.has(entry.id));
21334
21381
  const sinceApproval = input.approved !== undefined && input.files === undefined;
21335
- const merged = (approvedCode) => mergeFindings(Object.fromEntries(outputs.map(([seat, output]) => [
21382
+ const merged = (approvedCode) => groupedByRule(Object.fromEntries(outputs.map(([seat, output]) => [
21336
21383
  seat,
21337
- output.findings.filter((finding) => !earlierIds.has(`${finding.file}:${finding.line}`) && (sinceApproval && finding.approvedCode === true) === approvedCode)
21384
+ output.findings.filter((finding) => !earlierIds.has(`${finding.file}:${finding.line}`) && (sinceApproval && finding.approvedCode === true) === approvedCode).map((finding) => fixRound(input) ? outsideFixAsMinor(finding) : finding)
21338
21385
  ])));
21339
21386
  const fresh = merged(false);
21340
21387
  const approvedFindings = sinceApproval ? merged(true) : [];
@@ -21360,6 +21407,7 @@ var review_default = defineLoop({
21360
21407
  artifactId: stored.artifactId,
21361
21408
  ...approvedFindings.length === 0 ? undefined : { approvedFindings },
21362
21409
  ...scope === undefined ? undefined : { scope },
21410
+ ...failing.length === 0 ? undefined : { failing },
21363
21411
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
21364
21412
  };
21365
21413
  const changeRequestId = input.changeRequestId;
@@ -21395,6 +21443,8 @@ What next?`,
21395
21443
  words: fixBrief(changeRequestId, findings),
21396
21444
  changeRequestId,
21397
21445
  maxRounds: 2,
21446
+ reviewed: range.head,
21447
+ ...findings.length === 0 ? undefined : { earlier: findings },
21398
21448
  ...ownDeliveryTarget(input)
21399
21449
  });
21400
21450
  return { choice, detail: fixed.settled ? "Fixed and pushed" : `Pushed; left: ${fixed.unsettled.join("; ")}` };
@@ -21943,6 +21993,7 @@ var ShepherdOutput = Struct({
21943
21993
  reason: String5,
21944
21994
  fixRounds: Int,
21945
21995
  replies: Int,
21996
+ reused: optional2(ArraySchema(Struct({ review: String5, head: String5 }))),
21946
21997
  unsettled: optional2(ArraySchema(String5)),
21947
21998
  release: optional2(Struct({ runStatus: String5, reason: String5, tag: optional2(String5) })),
21948
21999
  releaseWhen: optional2(ResolvedReleaseTrigger),
@@ -21952,7 +22003,9 @@ var ShepherdOutput = Struct({
21952
22003
  changeRequestId: String5,
21953
22004
  words: String5,
21954
22005
  taskId: optional2(String5),
21955
- branch: optional2(String5)
22006
+ branch: optional2(String5),
22007
+ reviewed: optional2(String5),
22008
+ earlier: optional2(ArraySchema(MergedFinding))
21956
22009
  }))
21957
22010
  });
21958
22011
 
@@ -22142,7 +22195,7 @@ var repliesPrompt = (threads) => [
22142
22195
  var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
22143
22196
  var shepherd_default = defineLoop({
22144
22197
  id: "shepherd",
22145
- version: "1.8.0",
22198
+ version: "1.9.0",
22146
22199
  title: "Shepherd",
22147
22200
  input: Input3,
22148
22201
  output: Output3,
@@ -22178,6 +22231,7 @@ var shepherd_default = defineLoop({
22178
22231
  const ranOnRunner = new Set;
22179
22232
  const leftToPerson = new Set;
22180
22233
  let headFindings = [];
22234
+ let headFindingsAt;
22181
22235
  const unranAt = new Map;
22182
22236
  const rounds = { "ci-fix": 0, "head-fix": 0 };
22183
22237
  const allowed = { "ci-fix": 0, "head-fix": 0 };
@@ -22188,6 +22242,8 @@ var shepherd_default = defineLoop({
22188
22242
  let reviewOnceShown;
22189
22243
  let pipelineFirst;
22190
22244
  const reviewedHeads = new Set;
22245
+ const reused = [];
22246
+ const reuseTried = new Set;
22191
22247
  const approvalOf = new Map;
22192
22248
  let notCarried;
22193
22249
  let behind = false;
@@ -22210,6 +22266,7 @@ var shepherd_default = defineLoop({
22210
22266
  reason,
22211
22267
  fixRounds: fixRounds(),
22212
22268
  replies,
22269
+ ...reused.length === 0 ? undefined : { reused },
22213
22270
  ...input.releaseWhen === undefined ? undefined : { releaseWhen: input.releaseWhen },
22214
22271
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo },
22215
22272
  ...status === "needs_you" || status === "handed_back" ? { unsettled: [reason] } : undefined
@@ -22241,14 +22298,15 @@ var shepherd_default = defineLoop({
22241
22298
  }).pipe(catchTag2("WaitTimedOut", () => void_3));
22242
22299
  }
22243
22300
  });
22244
- const handBack = (reason, open) => ({
22301
+ const handBack = (reason, open, review) => ({
22245
22302
  ...done("handed_back", reason),
22246
22303
  handBack: {
22247
22304
  changeRequestId,
22248
22305
  words: `Shepherd handed ChangeRequest ${changeRequestId} back: ${reason}. Fix it forward on its branch:
22249
22306
  ${open}`,
22250
22307
  ...input.taskId === undefined ? undefined : { taskId: input.taskId },
22251
- ...target === "HEAD" ? undefined : { branch: target }
22308
+ ...target === "HEAD" ? undefined : { branch: target },
22309
+ ...review
22252
22310
  }
22253
22311
  });
22254
22312
  const takeTurn = () => gen2(function* () {
@@ -22477,12 +22535,13 @@ ${open}`,
22477
22535
  head,
22478
22536
  files: files.files,
22479
22537
  ...head === files.synced ? undefined : { since: files.synced },
22480
- ...files.earlier.length === 0 ? undefined : { earlier: files.earlier }
22538
+ ...files.earlier.length === 0 ? undefined : { earlier: files.earlier },
22539
+ ...files.reviewed === undefined ? undefined : { reviewed: files.reviewed }
22481
22540
  });
22482
22541
  if (reviewed.blocking) {
22483
22542
  const blocking = reviewed.findings.filter(isBlocking);
22484
22543
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
22485
- 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)));
22544
+ 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 }));
22486
22545
  rounds["head-fix"]++;
22487
22546
  const fix = yield* agentWork(`review-fix:${cycle}`, {
22488
22547
  agent: "implementer",
@@ -22490,7 +22549,7 @@ ${open}`,
22490
22549
  output: ReviewFix,
22491
22550
  timeout: stepBudget
22492
22551
  });
22493
- unreviewed = { ...files, earlier: reviewed.findings };
22552
+ unreviewed = { ...files, earlier: reviewed.findings, reviewed: head };
22494
22553
  fixedFrom = { head, changed: fix.changed, looks: 0 };
22495
22554
  return { kind: "fixing" };
22496
22555
  }
@@ -22541,12 +22600,13 @@ ${open}`,
22541
22600
  head,
22542
22601
  ...notRun.length === 0 ? undefined : { notRun },
22543
22602
  ...since === undefined ? undefined : { approved: since },
22544
- ...headFindings.length === 0 ? undefined : { earlier: headFindings }
22603
+ ...headFindings.length === 0 ? undefined : { earlier: headFindings },
22604
+ ...headFindingsAt === undefined ? undefined : { reviewed: headFindingsAt }
22545
22605
  });
22546
22606
  if (reviewed.blocking) {
22547
22607
  const blocking = reviewed.findings.filter(isBlocking);
22548
22608
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
22549
- return stop(handBack(`The review of ${head} still finds ${blocking.map((finding) => finding.id).join(", ")} after ${rounds["head-fix"]} head-fix rounds`, findingLines2(blocking)));
22609
+ 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 }));
22550
22610
  rounds["head-fix"]++;
22551
22611
  const fix = yield* agentWork(`head-fix:${cycle}`, {
22552
22612
  agent: "implementer",
@@ -22555,10 +22615,12 @@ ${open}`,
22555
22615
  timeout: stepBudget
22556
22616
  });
22557
22617
  headFindings = reviewed.findings;
22618
+ headFindingsAt = head;
22558
22619
  fixedFrom = { head, changed: fix.changed, looks: 0 };
22559
22620
  return { kind: "fixing" };
22560
22621
  }
22561
22622
  headFindings = [];
22623
+ headFindingsAt = undefined;
22562
22624
  if (notRun.length > 0)
22563
22625
  unranAt.set(head, { notRun, review: `head-review:${cycle}` });
22564
22626
  else {
@@ -22575,6 +22637,29 @@ ${open}`,
22575
22637
  reviewedHeads.add(head);
22576
22638
  return { kind: "reviewed" };
22577
22639
  });
22640
+ const reuseReview = (cycle, pipeline, reviewed) => gen2(function* () {
22641
+ const { head } = pipeline;
22642
+ reuseTried.add(head);
22643
+ const notRun = [...new Set([...input.notRun ?? [], ...reviewed.notRun ?? []])];
22644
+ if (notRun.length > 0) {
22645
+ unranAt.set(head, { notRun, reuses: reviewed.review });
22646
+ reviewedHeads.add(head);
22647
+ reused.push({ review: reviewed.review, head });
22648
+ return true;
22649
+ }
22650
+ const recorded = yield* approveChangeRequest(`reuse:${cycle}`, {
22651
+ changeRequestId,
22652
+ head,
22653
+ summary: `Review ${reviewed.review} passed the whole change at ${head}, so Shepherd approves it without reviewing it again.`,
22654
+ reuses: reviewed.review
22655
+ }).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
22656
+ if (!recorded.approved)
22657
+ return false;
22658
+ approvalOf.set(head, recorded.reviewId);
22659
+ reviewedHeads.add(head);
22660
+ reused.push({ review: reviewed.review, head });
22661
+ return true;
22662
+ });
22578
22663
  const reviewCaughtUp = (cycle, pipeline) => gen2(function* () {
22579
22664
  const head = reviewOnceShown;
22580
22665
  reviewOnceShown = undefined;
@@ -22630,6 +22715,9 @@ ${open}`,
22630
22715
  else
22631
22716
  return found;
22632
22717
  }
22718
+ const reviewedElsewhere = pipeline.approved === pipeline.head || reviewedHeads.has(pipeline.head) || reuseTried.has(pipeline.head) ? undefined : pipeline.reviewed;
22719
+ if (reviewedElsewhere !== undefined && (yield* reuseReview(cycle, pipeline, reviewedElsewhere)))
22720
+ continue;
22633
22721
  const pipelineFailed = pipeline.status === "failed" || pipeline.status === "canceled";
22634
22722
  const blocked = pipeline.conflicts === true || pipeline.needsRebase === true && pipelineFailed;
22635
22723
  const caughtUpHead = pipeline.head === pipelineFirst;
@@ -22879,7 +22967,7 @@ Merge now?`,
22879
22967
  changeRequestId,
22880
22968
  head: pipeline.head,
22881
22969
  summary: `A review of ${pipeline.head} passed with nothing blocking; a person chose to merge it though verify never ran some of its tests.`,
22882
- review: unapproved.review
22970
+ ..."reuses" in unapproved ? { reuses: unapproved.reuses } : { review: unapproved.review }
22883
22971
  }).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
22884
22972
  if (!recorded.approved)
22885
22973
  return done("needs_you", `The review of ${pipeline.head} passed, but did not approve it: ${recorded.reason}`);
@@ -22988,6 +23076,8 @@ var BuildInput = Struct({
22988
23076
  land: optional2(Boolean3),
22989
23077
  changeRequestId: optional2(String5),
22990
23078
  maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0))),
23079
+ reviewed: optional2(String5),
23080
+ earlier: optional2(ArraySchema(MergedFinding)),
22991
23081
  ...DeliveryFields
22992
23082
  });
22993
23083
  var CriterionAnswer = Struct({
@@ -23034,6 +23124,7 @@ var BuildOutput = Struct({
23034
23124
  stopped: Literals(["settled", "dispute_stands", "findings_returned", "round_cap"]),
23035
23125
  criteria: ArraySchema(CriterionAnswer),
23036
23126
  notRun: optional2(ArraySchema(String5)),
23127
+ findings: optional2(ArraySchema(MergedFinding)),
23037
23128
  approval: optional2(ApproveChangeRequestResult),
23038
23129
  landed: optional2(ShepherdOutput),
23039
23130
  next: Struct({ changeRequestId: String5 }),
@@ -23106,7 +23197,7 @@ var reproducedOnBranchPrompt = (task) => [
23106
23197
  var findingLine = (finding) => `- **${finding.severity}** \`${finding.id}\` ${finding.detail}`;
23107
23198
  var disputeLine = ({ finding, rebuttal }) => `${findingLine(finding)}
23108
23199
  You rebutted: ${rebuttal.reason}`;
23109
- var fixPrompt = (settled) => {
23200
+ var fixPrompt2 = (settled) => {
23110
23201
  const checks = settled.open.filter((finding) => isCheckFinding(finding.id));
23111
23202
  const findings = settled.open.filter((finding) => !isCheckFinding(finding.id));
23112
23203
  return [
@@ -23135,7 +23226,7 @@ var rally = (input) => gen2(function* () {
23135
23226
  const claims = [...input.claims];
23136
23227
  const conflicts = [];
23137
23228
  let rebuttals = [];
23138
- let earlier = [];
23229
+ let earlier = input.earlier;
23139
23230
  let previous;
23140
23231
  let last;
23141
23232
  const shown = new Set;
@@ -23161,7 +23252,8 @@ var rally = (input) => gen2(function* () {
23161
23252
  head,
23162
23253
  decision: { stop: true, reason: "findings_returned", unsettled: blockingIds(last.settled) },
23163
23254
  claims,
23164
- conflicts
23255
+ conflicts,
23256
+ earlier
23165
23257
  };
23166
23258
  const failing = brokenChecks(head).map((check) => check.name);
23167
23259
  const notRun = testsNotRunReasons(head);
@@ -23170,6 +23262,7 @@ var rally = (input) => gen2(function* () {
23170
23262
  head: head.revision,
23171
23263
  ...rebuttals.length === 0 ? undefined : { rebuttals },
23172
23264
  ...earlier.length === 0 ? undefined : { earlier },
23265
+ ...last === undefined ? input.reviewed === undefined ? undefined : { reviewed: input.reviewed } : { reviewed: last.head.revision },
23173
23266
  ...input.outcome === undefined ? undefined : { outcome: input.outcome },
23174
23267
  ...failing.length === 0 ? undefined : { failing },
23175
23268
  ...notRun.length === 0 ? undefined : { notRun },
@@ -23190,12 +23283,12 @@ var rally = (input) => gen2(function* () {
23190
23283
  ...previous === undefined || unseen ? undefined : { previous }
23191
23284
  });
23192
23285
  if (decision.stop && (!unseen || round >= input.maxRounds))
23193
- return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts };
23286
+ return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts, earlier };
23194
23287
  for (const finding of checks)
23195
23288
  shown.add(finding.detail);
23196
23289
  const fixed = yield* agentWork(`fix:${round}`, {
23197
23290
  agent: "implementer",
23198
- prompt: fixPrompt(settled),
23291
+ prompt: fixPrompt2(settled),
23199
23292
  output: Fixed
23200
23293
  });
23201
23294
  claims.push(...fixed.claims, ...fixed.rebuttals.flatMap((rebuttal) => isCheckFinding(rebuttal.findingId) ? [`Rebutted ${rebuttal.findingId}: ${rebuttal.reason}`] : []));
@@ -23210,7 +23303,7 @@ var rally = (input) => gen2(function* () {
23210
23303
  });
23211
23304
  var build2 = defineLoop({
23212
23305
  id: "build",
23213
- version: "2.7.0",
23306
+ version: "2.8.0",
23214
23307
  title: "Build",
23215
23308
  input: BuildInput,
23216
23309
  output: BuildOutput,
@@ -23266,7 +23359,9 @@ var build2 = defineLoop({
23266
23359
  target,
23267
23360
  outcome,
23268
23361
  claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer)}`)],
23269
- suggested: implemented.checks ?? []
23362
+ suggested: implemented.checks ?? [],
23363
+ reviewed: input.reviewed,
23364
+ earlier: input.earlier ?? []
23270
23365
  });
23271
23366
  const verdict = evidenceGate({
23272
23367
  ...outcome === undefined ? undefined : { outcome },
@@ -23316,6 +23411,7 @@ var build2 = defineLoop({
23316
23411
  stopped: last.decision.reason,
23317
23412
  criteria,
23318
23413
  ...lastNotRun.length === 0 ? undefined : { notRun: lastNotRun },
23414
+ ...last.earlier.length === 0 ? undefined : { findings: last.earlier },
23319
23415
  ...approval === undefined ? undefined : { approval }
23320
23416
  };
23321
23417
  const maxRebuilds = input.maxRebuilds ?? 1;
@@ -23371,6 +23467,8 @@ var build2 = defineLoop({
23371
23467
  ...input.maxRounds === undefined ? undefined : { maxRounds: input.maxRounds },
23372
23468
  changeRequestId: opened.id,
23373
23469
  land: false,
23470
+ reviewed: settledAs.revision,
23471
+ ...settledAs.findings === undefined ? undefined : { earlier: settledAs.findings },
23374
23472
  ...ownDeliveryTarget(input)
23375
23473
  }, { constraints: standing.map(standingConstraint) });
23376
23474
  settledAs = rebuilt;
@@ -23585,7 +23683,7 @@ var changePrompt = (discovery, plan, tried, cycle) => [
23585
23683
 
23586
23684
  `);
23587
23685
  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.`;
23588
- var fixPrompt2 = (findings) => [
23686
+ var fixPrompt3 = (findings) => [
23589
23687
  "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.",
23590
23688
  ...findings.map((finding) => `- ${finding.id}: ${finding.detail}`)
23591
23689
  ].join(`
@@ -23648,7 +23746,7 @@ var steadier = (plan) => {
23648
23746
  };
23649
23747
  var hillclimb_default = defineLoop({
23650
23748
  id: "hillclimb",
23651
- version: "1.3.0",
23749
+ version: "1.4.0",
23652
23750
  title: "Hillclimb",
23653
23751
  outcome: "performance",
23654
23752
  input: Input5,
@@ -23782,7 +23880,7 @@ var hillclimb_default = defineLoop({
23782
23880
  const blocking = reviewed.findings.filter(isBlocking);
23783
23881
  yield* agentWork(`fix:${round}`, {
23784
23882
  agent: "implementer",
23785
- prompt: fixPrompt2(blocking),
23883
+ prompt: fixPrompt3(blocking),
23786
23884
  output: Struct({ summary: OneSentence })
23787
23885
  });
23788
23886
  const fixed = yield* verify(`verify:fix:${round}`, {});
@@ -23793,6 +23891,7 @@ var hillclimb_default = defineLoop({
23793
23891
  final = yield* measure(`measure:fix:${round}`, { plan, base: baseline, head: fixed.revision, ...limits });
23794
23892
  if (final.verdict !== "gain")
23795
23893
  return yield* ending("gain_gone", `The review's fixes cost the gain: ${final.reason}`, final);
23894
+ const fixedFrom = head.revision;
23796
23895
  head = fixed;
23797
23896
  reviewed = yield* call(`review:${round + 1}`, review_default, {
23798
23897
  base: baseline,
@@ -23800,7 +23899,8 @@ var hillclimb_default = defineLoop({
23800
23899
  outcome: "performance",
23801
23900
  ...notRunOf(fixed),
23802
23901
  claims,
23803
- earlier: blocking
23902
+ earlier: blocking,
23903
+ reviewed: fixedFrom
23804
23904
  });
23805
23905
  }
23806
23906
  const notRun = testsNotRunReasons(head);
@@ -24180,7 +24280,10 @@ An earlier Build of this failed. ${retry.steer}` };
24180
24280
  branch: head.branch,
24181
24281
  revision: head.revision,
24182
24282
  land: false
24183
- }).pipe(catchTag2("ChildFailed", (failure) => succeed7(failure)));
24283
+ }).pipe(catchTags2({
24284
+ ChildFailed: (failure) => succeed7(failure),
24285
+ StepFailed: (refused) => refused.code === "task_run_unsettled" ? succeed7(new ChildFailed({ step: refused.step, loop: build_default.id, reason: refused.reason })) : fail7(refused)
24286
+ }));
24184
24287
  if (built instanceof ChildFailed)
24185
24288
  return settled(ticket, { status: "failed", repoBindingId: head.repoBindingId, reason: built.reason });
24186
24289
  const delivered = { repoBindingId: head.repoBindingId, changeRequest: built.changeRequest };
@@ -24276,6 +24379,7 @@ var deliveryBody = (plan, results) => {
24276
24379
  var implement = (input, plan, revision, filed) => gen2(function* () {
24277
24380
  const tasks = filed?.revision === revision ? filed.tasks : (yield* createTasks("tasks", {
24278
24381
  tickets: plan.tickets,
24382
+ builds: true,
24279
24383
  ...input.projectId === undefined ? undefined : { projectId: input.projectId }
24280
24384
  })).tasks;
24281
24385
  const taskOf = new Map(tasks.map((task) => [task.key, task.taskId]));
@@ -24380,6 +24484,19 @@ var plan_default = defineLoop({
24380
24484
  let opinions = 0;
24381
24485
  yield* storePlan(plan, "");
24382
24486
  const project = input.projectId === undefined ? undefined : { projectId: input.projectId };
24487
+ const held = new Map;
24488
+ let implementing = false;
24489
+ const file = (step) => gen2(function* () {
24490
+ const made = yield* createTasks(step, { tickets: plan.tickets, builds: true, ...project });
24491
+ for (const ticket of plan.tickets)
24492
+ held.set(ticket.key, ticket);
24493
+ filed = { revision, tasks: made.tasks };
24494
+ });
24495
+ const release = (building = []) => {
24496
+ const tickets = [...held.values()].filter((ticket) => !building.some((built) => built.key === ticket.key));
24497
+ held.clear();
24498
+ return tickets.length === 0 ? void_3 : asVoid2(createTasks("release-tasks", { tickets, releases: true, ...project }));
24499
+ };
24383
24500
  const ended = (rest) => ({
24384
24501
  title: plan.title,
24385
24502
  outOfScope: plan.outOfScope,
@@ -24391,81 +24508,83 @@ var plan_default = defineLoop({
24391
24508
  ...docs === undefined ? undefined : { docs },
24392
24509
  ...rest
24393
24510
  });
24394
- for (let round = 1;round <= maxRounds; round++) {
24395
- const isFiled = filed?.revision === revision;
24396
- const options = menu.filter((option) => !(option === "File as Tasks" && isFiled) && !(option === "Second opinion" && opinions >= maxOpinionsPerPlan));
24397
- const fallback = input.implement === true ? "Implement now" : isFiled ? "Finish" : "File as Tasks";
24398
- const answer = yield* ask(`next:${round}`, {
24399
- prompt: `What next for the plan "${plan.title}"?`,
24400
- options: options.map((option) => ({ value: option, description: menuDescriptions[option] })),
24401
- recommended: fallback,
24402
- recommendationReason: fallback === "Implement now" ? "You asked for the plan to be implemented." : fallback === "Finish" ? "The plan is filed as Tasks, so nothing is lost by finishing." : "Filing keeps the plan as Tasks a person or a Build can pick up later.",
24403
- default: fallback,
24404
- timeout: "1 hour"
24405
- });
24406
- const choice = menu.find((option) => option === answer) ?? fallback;
24407
- switch (choice) {
24408
- case "Finish":
24409
- return ended({ implemented: false });
24410
- case "Implement now": {
24411
- const delivered = yield* implement(input, plan, revision, filed);
24412
- return { ...ended({ implemented: true }), ...delivered };
24413
- }
24414
- case "File as Tasks": {
24415
- const made = yield* createTasks(`file-tasks:${round}`, { tickets: plan.tickets, ...project });
24416
- filed = { revision, tasks: made.tasks };
24417
- break;
24418
- }
24419
- case "Second opinion": {
24420
- opinions++;
24421
- const opinion = yield* agentWork(`second-opinion:${round}`, {
24422
- agent: "reviewer",
24423
- prompt: opinionPrompt(plan),
24424
- output: Opinion
24425
- });
24426
- yield* artifact(`opinion:${round}`, {
24427
- kind: "plan_review",
24428
- title: `Second opinion on ${plan.title}`,
24429
- text: [opinion.summary, ...opinion.concerns.map((concern) => `- ${concern}`)].join(`
24511
+ const decide = gen2(function* () {
24512
+ for (let round = 1;round <= maxRounds; round++) {
24513
+ const isFiled = filed?.revision === revision;
24514
+ const options = menu.filter((option) => !(option === "File as Tasks" && isFiled) && !(option === "Second opinion" && opinions >= maxOpinionsPerPlan));
24515
+ const fallback = input.implement === true ? "Implement now" : isFiled ? "Finish" : "File as Tasks";
24516
+ const answer = yield* ask(`next:${round}`, {
24517
+ prompt: `What next for the plan "${plan.title}"?`,
24518
+ options: options.map((option) => ({ value: option, description: menuDescriptions[option] })),
24519
+ recommended: fallback,
24520
+ recommendationReason: fallback === "Implement now" ? "You asked for the plan to be implemented." : fallback === "Finish" ? "The plan is filed as Tasks, so nothing is lost by finishing." : "Filing keeps the plan as Tasks a person or a Build can pick up later.",
24521
+ default: fallback,
24522
+ timeout: "1 hour"
24523
+ });
24524
+ const choice = menu.find((option) => option === answer) ?? fallback;
24525
+ switch (choice) {
24526
+ case "Finish":
24527
+ yield* release();
24528
+ return ended({ implemented: false });
24529
+ case "Implement now": {
24530
+ implementing = true;
24531
+ yield* release(plan.tickets);
24532
+ const delivered = yield* implement(input, plan, revision, filed);
24533
+ return { ...ended({ implemented: true }), ...delivered };
24534
+ }
24535
+ case "File as Tasks":
24536
+ yield* file(`file-tasks:${round}`);
24537
+ break;
24538
+ case "Second opinion": {
24539
+ opinions++;
24540
+ const opinion = yield* agentWork(`second-opinion:${round}`, {
24541
+ agent: "reviewer",
24542
+ prompt: opinionPrompt(plan),
24543
+ output: Opinion
24544
+ });
24545
+ yield* artifact(`opinion:${round}`, {
24546
+ kind: "plan_review",
24547
+ title: `Second opinion on ${plan.title}`,
24548
+ text: [opinion.summary, ...opinion.concerns.map((concern) => `- ${concern}`)].join(`
24430
24549
 
24431
24550
  `)
24432
- });
24433
- break;
24434
- }
24435
- case "Refine": {
24436
- const words = yield* ask(`refine:${round}`, {
24437
- prompt: "What should change in the plan?",
24438
- freeText: true,
24439
- informationOnly: true,
24440
- recommendationReason: "You chose to refine it, so only you know what should change."
24441
- });
24442
- const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
24443
- agent: "planner",
24444
- prompt: refinePrompt(plan, words),
24445
- output: Plan
24446
- });
24447
- const before = plan;
24448
- revision++;
24449
- ({ plan, rejected } = yield* checked(refined, revision));
24450
- yield* storePlan(plan, `:${round}`);
24451
- yield* artifact(`changes:${round}`, {
24452
- kind: "plan_changes",
24453
- title: `Revision ${revision} of ${plan.title}`,
24454
- text: changelog(before, plan, words)
24455
- });
24456
- break;
24551
+ });
24552
+ break;
24553
+ }
24554
+ case "Refine": {
24555
+ const words = yield* ask(`refine:${round}`, {
24556
+ prompt: "What should change in the plan?",
24557
+ freeText: true,
24558
+ informationOnly: true,
24559
+ recommendationReason: "You chose to refine it, so only you know what should change."
24560
+ });
24561
+ const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
24562
+ agent: "planner",
24563
+ prompt: refinePrompt(plan, words),
24564
+ output: Plan
24565
+ });
24566
+ const before = plan;
24567
+ revision++;
24568
+ ({ plan, rejected } = yield* checked(refined, revision));
24569
+ yield* storePlan(plan, `:${round}`);
24570
+ yield* artifact(`changes:${round}`, {
24571
+ kind: "plan_changes",
24572
+ title: `Revision ${revision} of ${plan.title}`,
24573
+ text: changelog(before, plan, words)
24574
+ });
24575
+ break;
24576
+ }
24457
24577
  }
24458
24578
  }
24459
- }
24460
- if (filed?.revision !== revision)
24461
- filed = {
24462
- revision,
24463
- tasks: (yield* createTasks("file-tasks:last", { tickets: plan.tickets, ...project })).tasks
24464
- };
24465
- return ended({
24466
- implemented: false,
24467
- stopped: `No decision after ${maxRounds} rounds, so the tickets are filed as Tasks for a person to pick up`
24579
+ if (filed?.revision !== revision)
24580
+ yield* file("file-tasks:last");
24581
+ yield* release();
24582
+ return ended({
24583
+ implemented: false,
24584
+ stopped: `No decision after ${maxRounds} rounds, so the tickets are filed as Tasks for a person to pick up`
24585
+ });
24468
24586
  });
24587
+ return yield* decide.pipe(tapError2(() => implementing ? void_3 : ignore2(release())));
24469
24588
  })
24470
24589
  });
24471
24590
 
@@ -24952,7 +25071,7 @@ var batchPrompt = (requests, target) => [
24952
25071
  ].join(`
24953
25072
 
24954
25073
  `);
24955
- var fixPrompt3 = (failed, applied) => [
25074
+ var fixPrompt4 = (failed, applied) => [
24956
25075
  `The batch of ${applied.map((number) => `!${number}`).join(", ")} fails these checks:`,
24957
25076
  ...failed.checks.filter((check) => check.status === "failed").map((check) => `- ${check.name}: \`${check.command}\``),
24958
25077
  "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."
@@ -25085,7 +25204,7 @@ var sweep_default = defineLoop({
25085
25204
  for (let round = 1;!checked.passed && round <= maxFixRounds && batched.applied.length > 0; round++) {
25086
25205
  batched = yield* agentWork(`fix:${round}`, {
25087
25206
  agent: "implementer",
25088
- prompt: fixPrompt3(checked, batched.applied),
25207
+ prompt: fixPrompt4(checked, batched.applied),
25089
25208
  output: Batched
25090
25209
  });
25091
25210
  for (const drop of batched.dropped)
@@ -28230,6 +28349,7 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28230
28349
  runnerChecks: optionalKey2(ArraySchema(String5)),
28231
28350
  targetChecks: optionalKey2(ArraySchema(String5)),
28232
28351
  approved: optionalKey2(String5),
28352
+ reviewed: optionalKey2(Struct({ review: String5, notRun: optionalKey2(ArraySchema(String5)) })),
28233
28353
  repository: optionalKey2(String5),
28234
28354
  sourceBranch: optionalKey2(String5),
28235
28355
  targetBranch: optionalKey2(String5),
@@ -28361,13 +28481,16 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28361
28481
  payload: {
28362
28482
  lease: ProgramLease,
28363
28483
  projectId: optionalKey2(String5),
28484
+ builds: optionalKey2(Boolean3),
28485
+ releases: optionalKey2(Boolean3),
28364
28486
  tickets: ArraySchema(Struct({
28365
28487
  key: String5,
28366
28488
  title: String5,
28367
28489
  body: String5,
28368
28490
  acceptanceCriteria: ArraySchema(String5),
28369
28491
  blockedBy: ArraySchema(String5),
28370
- outcome: optionalKey2(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"]))
28492
+ outcome: optionalKey2(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"])),
28493
+ repoBindingId: optionalKey2(String5)
28371
28494
  }))
28372
28495
  },
28373
28496
  success: ArraySchema(Struct({ key: String5, taskId: String5 })),
@@ -28406,7 +28529,8 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28406
28529
  head: String5,
28407
28530
  summary: String5,
28408
28531
  review: optionalKey2(String5),
28409
- carries: optionalKey2(String5)
28532
+ carries: optionalKey2(String5),
28533
+ reuses: optionalKey2(String5)
28410
28534
  },
28411
28535
  success: Union2([
28412
28536
  Struct({ approved: Literal2(true), reviewId: String5 }),
@@ -28760,7 +28884,10 @@ var runnerActivities = (capabilities, services) => ({
28760
28884
  file: { run: (request, step) => keepFile(capabilities, step, request).pipe(provideContext2(services)) },
28761
28885
  note: { run: (request, step) => requested(step, capabilities.recordNote({ step, ...request })) },
28762
28886
  createTasks: {
28763
- run: (request, step) => requested(step, map8(capabilities.createPlanTasks(request.tickets, request.projectId), (tasks) => ({ tasks })))
28887
+ run: (request, step) => requested(step, map8(capabilities.createPlanTasks(request.tickets, request.projectId, {
28888
+ ...request.builds === undefined ? undefined : { builds: request.builds },
28889
+ ...request.releases === undefined ? undefined : { releases: request.releases }
28890
+ }), (tasks) => ({ tasks })))
28764
28891
  },
28765
28892
  alertTask: { run: (request, step) => requested(step, capabilities.alertTask({ step, ...request })) },
28766
28893
  integrationBranch: {
@@ -28892,16 +29019,18 @@ var rpcProgramPorts = (rpc, work) => {
28892
29019
  ...rpcRunFiles(rpc, lease),
28893
29020
  recordNote: (note) => rpc.recordNote({ lease, ...note }),
28894
29021
  performHostEffect: (request) => rpc.performHostEffect({ lease, ...request, waitsWhenUnconfirmed: true }),
28895
- createPlanTasks: (tickets, projectId) => rpc.createPlanTasks({
29022
+ createPlanTasks: (tickets, projectId, pickup) => rpc.createPlanTasks({
28896
29023
  lease,
28897
29024
  ...projectId === undefined ? undefined : { projectId },
29025
+ ...pickup,
28898
29026
  tickets: tickets.map((ticket) => ({
28899
29027
  key: ticket.key,
28900
29028
  title: ticket.title,
28901
29029
  body: ticket.body,
28902
29030
  acceptanceCriteria: ticket.acceptanceCriteria,
28903
29031
  blockedBy: ticket.blockedBy,
28904
- ...ticket.outcome === undefined ? undefined : { outcome: ticket.outcome }
29032
+ ...ticket.outcome === undefined ? undefined : { outcome: ticket.outcome },
29033
+ ...ticket.repoBindingId === undefined ? undefined : { repoBindingId: ticket.repoBindingId }
28905
29034
  }))
28906
29035
  }),
28907
29036
  integrationBranch: (repoBindingId, base) => base === true ? rpc.deliveryBase({ lease }) : rpc.integrationBranch({ lease, ...repoBindingId === undefined ? undefined : { repoBindingId } }),
@@ -31176,4 +31305,4 @@ var runKit = (config, identity, packages) => {
31176
31305
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31177
31306
  };
31178
31307
  // .kitman-build-entry.ts
31179
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.0-rc.2" }, []);
31308
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.0-rc.3" }, []);