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

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
@@ -12624,7 +12624,11 @@ function inSecretReference(text, start, end) {
12624
12624
  var placeholderTokenName = new RegExp(`^<?(?:ghp_|github_pat_|glpat-|ksa1\\.|sk-|xox[baprs]-)${placeholderNamePart}(?:[_.-]${placeholderNamePart})*>?$`, "u");
12625
12625
  var bearerValue = /[0-9]|[._~+/:-][A-Za-z0-9]|[<{]/u;
12626
12626
  var VALUE_RULES = [
12627
- { classification: "secret", name: "private-key", pattern: /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u },
12627
+ {
12628
+ classification: "secret",
12629
+ name: "private-key",
12630
+ pattern: /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY-----(?:[\s\S]*?-----END (?:[A-Z0-9]+ )*PRIVATE KEY-----|[\s\S]*)/u
12631
+ },
12628
12632
  {
12629
12633
  classification: "credential",
12630
12634
  name: "bearer-token",
@@ -19418,7 +19422,9 @@ var NoteRequest = Struct({
19418
19422
  });
19419
19423
  var CreateTasksRequest = Struct({
19420
19424
  tickets: ArraySchema(PlanTicket),
19421
- projectId: optionalKey2(String5)
19425
+ projectId: optionalKey2(String5),
19426
+ builds: optionalKey2(Boolean3),
19427
+ releases: optionalKey2(Boolean3)
19422
19428
  });
19423
19429
  var CreateTasksResult = Struct({
19424
19430
  tasks: ArraySchema(Struct({ key: String5, taskId: String5 }))
@@ -19463,7 +19469,8 @@ var ApproveChangeRequestRequest = Struct({
19463
19469
  head: String5,
19464
19470
  summary: String5,
19465
19471
  review: optionalKey2(String5),
19466
- carries: optionalKey2(String5)
19472
+ carries: optionalKey2(String5),
19473
+ reuses: optionalKey2(String5)
19467
19474
  });
19468
19475
  var ApproveChangeRequestResult = Union2([
19469
19476
  Struct({ approved: Literal2(true), reviewId: String5 }),
@@ -19522,6 +19529,7 @@ var PipelineStatus = Struct({
19522
19529
  runnerChecks: optionalKey2(ArraySchema(String5)),
19523
19530
  targetChecks: optionalKey2(ArraySchema(String5)),
19524
19531
  approved: optionalKey2(String5),
19532
+ reviewed: optionalKey2(Struct({ review: String5, notRun: optionalKey2(ArraySchema(String5)) })),
19525
19533
  repository: optionalKey2(String5),
19526
19534
  sourceBranch: optionalKey2(String5),
19527
19535
  targetBranch: optionalKey2(String5),
@@ -21114,6 +21122,7 @@ var Input = Struct({
21114
21122
  outcome: optional2(LoopOutcome),
21115
21123
  claims: optional2(ArraySchema(String5)),
21116
21124
  earlier: optional2(ArraySchema(MergedFinding)),
21125
+ reviewed: optional2(String5),
21117
21126
  failing: optional2(ArraySchema(String5)),
21118
21127
  notRun: optional2(ArraySchema(String5)),
21119
21128
  next: optional2(Literals(choices)),
@@ -21124,7 +21133,10 @@ var FollowUp = Struct({ id: String5, status: FollowUpStatus });
21124
21133
  var SeatFinding = Struct({
21125
21134
  ...Finding.fields,
21126
21135
  detail: FindingDetail,
21127
- approvedCode: optional2(Boolean3)
21136
+ approvedCode: optional2(Boolean3),
21137
+ rule: optional2(OneSentence),
21138
+ checked: optional2(ArraySchema(ShortStatement)),
21139
+ outsideFix: optional2(Boolean3)
21128
21140
  });
21129
21141
  var ReviewedScope = Struct({
21130
21142
  ...ScopeJudgement.fields,
@@ -21147,6 +21159,7 @@ var Output = Struct({
21147
21159
  blocking: Boolean3,
21148
21160
  artifactId: String5,
21149
21161
  scope: optional2(ReviewedScope),
21162
+ failing: optional2(ArraySchema(String5)),
21150
21163
  approval: optional2(Struct({ head: String5, approved: Boolean3, reason: optional2(String5) })),
21151
21164
  next: optional2(Struct({ choice: Literals(choices), detail: optional2(String5) })),
21152
21165
  deliversTo: optional2(ResolvedDeliveryTarget)
@@ -21216,20 +21229,29 @@ var scopePrompt = (input) => [
21216
21229
  ].join(`
21217
21230
 
21218
21231
  `);
21232
+ var exhaustivePrompt = [
21233
+ "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.",
21234
+ "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."
21235
+ ].join(" ");
21219
21236
  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.",
21237
+ "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
21238
  ...earlier.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
21222
21239
  ].join(`
21223
21240
  `);
21224
- var promptFor = (seat, target, input, failing, notRun) => [
21241
+ var fixRound = (input) => (input.earlier?.length ?? 0) > 0 || input.reviewed !== undefined;
21242
+ 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.`;
21243
+ 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),`;
21244
+ var promptFor = (seat, target, head, input, failing, notRun) => [
21225
21245
  `You are one of two reviewers. Follow your \`${seats[seat].skill}\` skill; if you do not have it: ${seats[seat].focus}`,
21226
21246
  `Review ${target}`,
21227
21247
  "Give `summary`: one sentence on whether it can merge and what matters most.",
21228
21248
  "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.",
21249
+ exhaustivePrompt,
21229
21250
  "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
21251
  "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
21252
  ...seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : [],
21232
21253
  ...input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)],
21254
+ ...fixRound(input) ? [fixPrompt(fixOf(input, head))] : [],
21233
21255
  ...failing.length === 0 ? [] : [
21234
21256
  `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
21257
  ],
@@ -21248,6 +21270,35 @@ var promptFor = (seat, target, input, failing, notRun) => [
21248
21270
 
21249
21271
  `);
21250
21272
  var rank2 = { still_there: 0, changed: 1, fixed: 2 };
21273
+ var outsideFixAsMinor = (finding) => finding.outsideFix === true && finding.severity === "major" ? { ...finding, severity: "minor" } : finding;
21274
+ var detailOf = (detail, rule, checked) => [
21275
+ ...rule === undefined ? [] : [`[${rule}]`],
21276
+ detail,
21277
+ ...checked.length === 0 ? [] : [`Checked and fine: ${checked.join("; ")}.`]
21278
+ ].join(" ");
21279
+ var idOf = (finding) => `${finding.file}:${finding.line}`;
21280
+ var groupedByRule = (bySeat) => {
21281
+ const rules = new Map;
21282
+ const checked = new Map;
21283
+ for (const finding of Object.values(bySeat).flat()) {
21284
+ const id = idOf(finding);
21285
+ if (finding.rule !== undefined && !rules.has(id))
21286
+ rules.set(id, finding.rule);
21287
+ checked.set(id, new Set([...checked.get(id) ?? [], ...finding.checked ?? []]));
21288
+ }
21289
+ const findings = mergeFindings(Object.fromEntries(Object.entries(bySeat).map(([seat, seatFindings]) => [
21290
+ seat,
21291
+ seatFindings.map((finding) => ({
21292
+ severity: finding.severity,
21293
+ file: finding.file,
21294
+ line: finding.line,
21295
+ detail: detailOf(finding.detail, rules.get(idOf(finding)), [...checked.get(idOf(finding)) ?? []])
21296
+ }))
21297
+ ])));
21298
+ const groupOf = (finding) => rules.get(finding.id) ?? finding.id;
21299
+ const order = [...new Set(findings.map(groupOf))];
21300
+ return findings.toSorted((left, right) => order.indexOf(groupOf(left)) - order.indexOf(groupOf(right)));
21301
+ };
21251
21302
  var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21252
21303
  const statuses = answers.flatMap((answer) => answer.id === finding.id ? [answer.status] : []);
21253
21304
  return {
@@ -21283,7 +21334,7 @@ var fixBrief = (changeRequestId, findings) => [
21283
21334
  `);
21284
21335
  var review_default = defineLoop({
21285
21336
  id: "review",
21286
- version: "3.8.0",
21337
+ version: "3.9.0",
21287
21338
  title: "Review",
21288
21339
  input: Input,
21289
21340
  output: Output,
@@ -21319,7 +21370,7 @@ var review_default = defineLoop({
21319
21370
  const notRun = [...new Set([...input.notRun ?? [], ...verified.notRun])];
21320
21371
  const outputs = yield* forEach2(seatNames, (seat) => agentWork(`review:${seat}`, {
21321
21372
  agent: seat,
21322
- prompt: promptFor(seat, target, input, failing, notRun),
21373
+ prompt: promptFor(seat, target, range.head, input, failing, notRun),
21323
21374
  output: SeatOutput
21324
21375
  }).pipe(map8((output) => [seat, output])), { concurrency: "unbounded" });
21325
21376
  const earlier = input.earlier ?? [];
@@ -21332,9 +21383,9 @@ var review_default = defineLoop({
21332
21383
  const carried = earlier.filter((finding) => standing.has(finding.id) && !withdrawn.has(finding.id));
21333
21384
  const followUps = answered.filter((entry) => !withdrawn.has(entry.id));
21334
21385
  const sinceApproval = input.approved !== undefined && input.files === undefined;
21335
- const merged = (approvedCode) => mergeFindings(Object.fromEntries(outputs.map(([seat, output]) => [
21386
+ const merged = (approvedCode) => groupedByRule(Object.fromEntries(outputs.map(([seat, output]) => [
21336
21387
  seat,
21337
- output.findings.filter((finding) => !earlierIds.has(`${finding.file}:${finding.line}`) && (sinceApproval && finding.approvedCode === true) === approvedCode)
21388
+ output.findings.filter((finding) => !earlierIds.has(`${finding.file}:${finding.line}`) && (sinceApproval && finding.approvedCode === true) === approvedCode).map((finding) => fixRound(input) ? outsideFixAsMinor(finding) : finding)
21338
21389
  ])));
21339
21390
  const fresh = merged(false);
21340
21391
  const approvedFindings = sinceApproval ? merged(true) : [];
@@ -21360,6 +21411,7 @@ var review_default = defineLoop({
21360
21411
  artifactId: stored.artifactId,
21361
21412
  ...approvedFindings.length === 0 ? undefined : { approvedFindings },
21362
21413
  ...scope === undefined ? undefined : { scope },
21414
+ ...failing.length === 0 ? undefined : { failing },
21363
21415
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
21364
21416
  };
21365
21417
  const changeRequestId = input.changeRequestId;
@@ -21395,6 +21447,8 @@ What next?`,
21395
21447
  words: fixBrief(changeRequestId, findings),
21396
21448
  changeRequestId,
21397
21449
  maxRounds: 2,
21450
+ reviewed: range.head,
21451
+ ...findings.length === 0 ? undefined : { earlier: findings },
21398
21452
  ...ownDeliveryTarget(input)
21399
21453
  });
21400
21454
  return { choice, detail: fixed.settled ? "Fixed and pushed" : `Pushed; left: ${fixed.unsettled.join("; ")}` };
@@ -21943,6 +21997,7 @@ var ShepherdOutput = Struct({
21943
21997
  reason: String5,
21944
21998
  fixRounds: Int,
21945
21999
  replies: Int,
22000
+ reused: optional2(ArraySchema(Struct({ review: String5, head: String5 }))),
21946
22001
  unsettled: optional2(ArraySchema(String5)),
21947
22002
  release: optional2(Struct({ runStatus: String5, reason: String5, tag: optional2(String5) })),
21948
22003
  releaseWhen: optional2(ResolvedReleaseTrigger),
@@ -21952,7 +22007,9 @@ var ShepherdOutput = Struct({
21952
22007
  changeRequestId: String5,
21953
22008
  words: String5,
21954
22009
  taskId: optional2(String5),
21955
- branch: optional2(String5)
22010
+ branch: optional2(String5),
22011
+ reviewed: optional2(String5),
22012
+ earlier: optional2(ArraySchema(MergedFinding))
21956
22013
  }))
21957
22014
  });
21958
22015
 
@@ -22142,7 +22199,7 @@ var repliesPrompt = (threads) => [
22142
22199
  var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
22143
22200
  var shepherd_default = defineLoop({
22144
22201
  id: "shepherd",
22145
- version: "1.8.0",
22202
+ version: "1.9.0",
22146
22203
  title: "Shepherd",
22147
22204
  input: Input3,
22148
22205
  output: Output3,
@@ -22178,6 +22235,7 @@ var shepherd_default = defineLoop({
22178
22235
  const ranOnRunner = new Set;
22179
22236
  const leftToPerson = new Set;
22180
22237
  let headFindings = [];
22238
+ let headFindingsAt;
22181
22239
  const unranAt = new Map;
22182
22240
  const rounds = { "ci-fix": 0, "head-fix": 0 };
22183
22241
  const allowed = { "ci-fix": 0, "head-fix": 0 };
@@ -22188,6 +22246,8 @@ var shepherd_default = defineLoop({
22188
22246
  let reviewOnceShown;
22189
22247
  let pipelineFirst;
22190
22248
  const reviewedHeads = new Set;
22249
+ const reused = [];
22250
+ const reuseTried = new Set;
22191
22251
  const approvalOf = new Map;
22192
22252
  let notCarried;
22193
22253
  let behind = false;
@@ -22210,6 +22270,7 @@ var shepherd_default = defineLoop({
22210
22270
  reason,
22211
22271
  fixRounds: fixRounds(),
22212
22272
  replies,
22273
+ ...reused.length === 0 ? undefined : { reused },
22213
22274
  ...input.releaseWhen === undefined ? undefined : { releaseWhen: input.releaseWhen },
22214
22275
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo },
22215
22276
  ...status === "needs_you" || status === "handed_back" ? { unsettled: [reason] } : undefined
@@ -22241,14 +22302,15 @@ var shepherd_default = defineLoop({
22241
22302
  }).pipe(catchTag2("WaitTimedOut", () => void_3));
22242
22303
  }
22243
22304
  });
22244
- const handBack = (reason, open) => ({
22305
+ const handBack = (reason, open, review) => ({
22245
22306
  ...done("handed_back", reason),
22246
22307
  handBack: {
22247
22308
  changeRequestId,
22248
22309
  words: `Shepherd handed ChangeRequest ${changeRequestId} back: ${reason}. Fix it forward on its branch:
22249
22310
  ${open}`,
22250
22311
  ...input.taskId === undefined ? undefined : { taskId: input.taskId },
22251
- ...target === "HEAD" ? undefined : { branch: target }
22312
+ ...target === "HEAD" ? undefined : { branch: target },
22313
+ ...review
22252
22314
  }
22253
22315
  });
22254
22316
  const takeTurn = () => gen2(function* () {
@@ -22477,12 +22539,13 @@ ${open}`,
22477
22539
  head,
22478
22540
  files: files.files,
22479
22541
  ...head === files.synced ? undefined : { since: files.synced },
22480
- ...files.earlier.length === 0 ? undefined : { earlier: files.earlier }
22542
+ ...files.earlier.length === 0 ? undefined : { earlier: files.earlier },
22543
+ ...files.reviewed === undefined ? undefined : { reviewed: files.reviewed }
22481
22544
  });
22482
22545
  if (reviewed.blocking) {
22483
22546
  const blocking = reviewed.findings.filter(isBlocking);
22484
22547
  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)));
22548
+ 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
22549
  rounds["head-fix"]++;
22487
22550
  const fix = yield* agentWork(`review-fix:${cycle}`, {
22488
22551
  agent: "implementer",
@@ -22490,7 +22553,7 @@ ${open}`,
22490
22553
  output: ReviewFix,
22491
22554
  timeout: stepBudget
22492
22555
  });
22493
- unreviewed = { ...files, earlier: reviewed.findings };
22556
+ unreviewed = { ...files, earlier: reviewed.findings, reviewed: head };
22494
22557
  fixedFrom = { head, changed: fix.changed, looks: 0 };
22495
22558
  return { kind: "fixing" };
22496
22559
  }
@@ -22541,12 +22604,13 @@ ${open}`,
22541
22604
  head,
22542
22605
  ...notRun.length === 0 ? undefined : { notRun },
22543
22606
  ...since === undefined ? undefined : { approved: since },
22544
- ...headFindings.length === 0 ? undefined : { earlier: headFindings }
22607
+ ...headFindings.length === 0 ? undefined : { earlier: headFindings },
22608
+ ...headFindingsAt === undefined ? undefined : { reviewed: headFindingsAt }
22545
22609
  });
22546
22610
  if (reviewed.blocking) {
22547
22611
  const blocking = reviewed.findings.filter(isBlocking);
22548
22612
  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)));
22613
+ 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
22614
  rounds["head-fix"]++;
22551
22615
  const fix = yield* agentWork(`head-fix:${cycle}`, {
22552
22616
  agent: "implementer",
@@ -22555,10 +22619,12 @@ ${open}`,
22555
22619
  timeout: stepBudget
22556
22620
  });
22557
22621
  headFindings = reviewed.findings;
22622
+ headFindingsAt = head;
22558
22623
  fixedFrom = { head, changed: fix.changed, looks: 0 };
22559
22624
  return { kind: "fixing" };
22560
22625
  }
22561
22626
  headFindings = [];
22627
+ headFindingsAt = undefined;
22562
22628
  if (notRun.length > 0)
22563
22629
  unranAt.set(head, { notRun, review: `head-review:${cycle}` });
22564
22630
  else {
@@ -22575,6 +22641,29 @@ ${open}`,
22575
22641
  reviewedHeads.add(head);
22576
22642
  return { kind: "reviewed" };
22577
22643
  });
22644
+ const reuseReview = (cycle, pipeline, reviewed) => gen2(function* () {
22645
+ const { head } = pipeline;
22646
+ reuseTried.add(head);
22647
+ const notRun = [...new Set([...input.notRun ?? [], ...reviewed.notRun ?? []])];
22648
+ if (notRun.length > 0) {
22649
+ unranAt.set(head, { notRun, reuses: reviewed.review });
22650
+ reviewedHeads.add(head);
22651
+ reused.push({ review: reviewed.review, head });
22652
+ return true;
22653
+ }
22654
+ const recorded = yield* approveChangeRequest(`reuse:${cycle}`, {
22655
+ changeRequestId,
22656
+ head,
22657
+ summary: `Review ${reviewed.review} passed the whole change at ${head}, so Shepherd approves it without reviewing it again.`,
22658
+ reuses: reviewed.review
22659
+ }).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
22660
+ if (!recorded.approved)
22661
+ return false;
22662
+ approvalOf.set(head, recorded.reviewId);
22663
+ reviewedHeads.add(head);
22664
+ reused.push({ review: reviewed.review, head });
22665
+ return true;
22666
+ });
22578
22667
  const reviewCaughtUp = (cycle, pipeline) => gen2(function* () {
22579
22668
  const head = reviewOnceShown;
22580
22669
  reviewOnceShown = undefined;
@@ -22630,6 +22719,9 @@ ${open}`,
22630
22719
  else
22631
22720
  return found;
22632
22721
  }
22722
+ const reviewedElsewhere = pipeline.approved === pipeline.head || reviewedHeads.has(pipeline.head) || reuseTried.has(pipeline.head) ? undefined : pipeline.reviewed;
22723
+ if (reviewedElsewhere !== undefined && (yield* reuseReview(cycle, pipeline, reviewedElsewhere)))
22724
+ continue;
22633
22725
  const pipelineFailed = pipeline.status === "failed" || pipeline.status === "canceled";
22634
22726
  const blocked = pipeline.conflicts === true || pipeline.needsRebase === true && pipelineFailed;
22635
22727
  const caughtUpHead = pipeline.head === pipelineFirst;
@@ -22879,7 +22971,7 @@ Merge now?`,
22879
22971
  changeRequestId,
22880
22972
  head: pipeline.head,
22881
22973
  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
22974
+ ..."reuses" in unapproved ? { reuses: unapproved.reuses } : { review: unapproved.review }
22883
22975
  }).pipe(catchTag2("StepFailed", (error) => succeed7({ approved: false, reason: error.reason })));
22884
22976
  if (!recorded.approved)
22885
22977
  return done("needs_you", `The review of ${pipeline.head} passed, but did not approve it: ${recorded.reason}`);
@@ -22988,6 +23080,8 @@ var BuildInput = Struct({
22988
23080
  land: optional2(Boolean3),
22989
23081
  changeRequestId: optional2(String5),
22990
23082
  maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0))),
23083
+ reviewed: optional2(String5),
23084
+ earlier: optional2(ArraySchema(MergedFinding)),
22991
23085
  ...DeliveryFields
22992
23086
  });
22993
23087
  var CriterionAnswer = Struct({
@@ -23034,6 +23128,7 @@ var BuildOutput = Struct({
23034
23128
  stopped: Literals(["settled", "dispute_stands", "findings_returned", "round_cap"]),
23035
23129
  criteria: ArraySchema(CriterionAnswer),
23036
23130
  notRun: optional2(ArraySchema(String5)),
23131
+ findings: optional2(ArraySchema(MergedFinding)),
23037
23132
  approval: optional2(ApproveChangeRequestResult),
23038
23133
  landed: optional2(ShepherdOutput),
23039
23134
  next: Struct({ changeRequestId: String5 }),
@@ -23106,7 +23201,7 @@ var reproducedOnBranchPrompt = (task) => [
23106
23201
  var findingLine = (finding) => `- **${finding.severity}** \`${finding.id}\` ${finding.detail}`;
23107
23202
  var disputeLine = ({ finding, rebuttal }) => `${findingLine(finding)}
23108
23203
  You rebutted: ${rebuttal.reason}`;
23109
- var fixPrompt = (settled) => {
23204
+ var fixPrompt2 = (settled) => {
23110
23205
  const checks = settled.open.filter((finding) => isCheckFinding(finding.id));
23111
23206
  const findings = settled.open.filter((finding) => !isCheckFinding(finding.id));
23112
23207
  return [
@@ -23135,7 +23230,7 @@ var rally = (input) => gen2(function* () {
23135
23230
  const claims = [...input.claims];
23136
23231
  const conflicts = [];
23137
23232
  let rebuttals = [];
23138
- let earlier = [];
23233
+ let earlier = input.earlier;
23139
23234
  let previous;
23140
23235
  let last;
23141
23236
  const shown = new Set;
@@ -23161,7 +23256,8 @@ var rally = (input) => gen2(function* () {
23161
23256
  head,
23162
23257
  decision: { stop: true, reason: "findings_returned", unsettled: blockingIds(last.settled) },
23163
23258
  claims,
23164
- conflicts
23259
+ conflicts,
23260
+ earlier
23165
23261
  };
23166
23262
  const failing = brokenChecks(head).map((check) => check.name);
23167
23263
  const notRun = testsNotRunReasons(head);
@@ -23170,6 +23266,7 @@ var rally = (input) => gen2(function* () {
23170
23266
  head: head.revision,
23171
23267
  ...rebuttals.length === 0 ? undefined : { rebuttals },
23172
23268
  ...earlier.length === 0 ? undefined : { earlier },
23269
+ ...last === undefined ? input.reviewed === undefined ? undefined : { reviewed: input.reviewed } : { reviewed: last.head.revision },
23173
23270
  ...input.outcome === undefined ? undefined : { outcome: input.outcome },
23174
23271
  ...failing.length === 0 ? undefined : { failing },
23175
23272
  ...notRun.length === 0 ? undefined : { notRun },
@@ -23190,12 +23287,12 @@ var rally = (input) => gen2(function* () {
23190
23287
  ...previous === undefined || unseen ? undefined : { previous }
23191
23288
  });
23192
23289
  if (decision.stop && (!unseen || round >= input.maxRounds))
23193
- return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts };
23290
+ return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts, earlier };
23194
23291
  for (const finding of checks)
23195
23292
  shown.add(finding.detail);
23196
23293
  const fixed = yield* agentWork(`fix:${round}`, {
23197
23294
  agent: "implementer",
23198
- prompt: fixPrompt(settled),
23295
+ prompt: fixPrompt2(settled),
23199
23296
  output: Fixed
23200
23297
  });
23201
23298
  claims.push(...fixed.claims, ...fixed.rebuttals.flatMap((rebuttal) => isCheckFinding(rebuttal.findingId) ? [`Rebutted ${rebuttal.findingId}: ${rebuttal.reason}`] : []));
@@ -23210,7 +23307,7 @@ var rally = (input) => gen2(function* () {
23210
23307
  });
23211
23308
  var build2 = defineLoop({
23212
23309
  id: "build",
23213
- version: "2.7.0",
23310
+ version: "2.8.0",
23214
23311
  title: "Build",
23215
23312
  input: BuildInput,
23216
23313
  output: BuildOutput,
@@ -23266,7 +23363,9 @@ var build2 = defineLoop({
23266
23363
  target,
23267
23364
  outcome,
23268
23365
  claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer)}`)],
23269
- suggested: implemented.checks ?? []
23366
+ suggested: implemented.checks ?? [],
23367
+ reviewed: input.reviewed,
23368
+ earlier: input.earlier ?? []
23270
23369
  });
23271
23370
  const verdict = evidenceGate({
23272
23371
  ...outcome === undefined ? undefined : { outcome },
@@ -23316,6 +23415,7 @@ var build2 = defineLoop({
23316
23415
  stopped: last.decision.reason,
23317
23416
  criteria,
23318
23417
  ...lastNotRun.length === 0 ? undefined : { notRun: lastNotRun },
23418
+ ...last.earlier.length === 0 ? undefined : { findings: last.earlier },
23319
23419
  ...approval === undefined ? undefined : { approval }
23320
23420
  };
23321
23421
  const maxRebuilds = input.maxRebuilds ?? 1;
@@ -23371,6 +23471,8 @@ var build2 = defineLoop({
23371
23471
  ...input.maxRounds === undefined ? undefined : { maxRounds: input.maxRounds },
23372
23472
  changeRequestId: opened.id,
23373
23473
  land: false,
23474
+ reviewed: settledAs.revision,
23475
+ ...settledAs.findings === undefined ? undefined : { earlier: settledAs.findings },
23374
23476
  ...ownDeliveryTarget(input)
23375
23477
  }, { constraints: standing.map(standingConstraint) });
23376
23478
  settledAs = rebuilt;
@@ -23585,7 +23687,7 @@ var changePrompt = (discovery, plan, tried, cycle) => [
23585
23687
 
23586
23688
  `);
23587
23689
  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) => [
23690
+ var fixPrompt3 = (findings) => [
23589
23691
  "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
23692
  ...findings.map((finding) => `- ${finding.id}: ${finding.detail}`)
23591
23693
  ].join(`
@@ -23648,7 +23750,7 @@ var steadier = (plan) => {
23648
23750
  };
23649
23751
  var hillclimb_default = defineLoop({
23650
23752
  id: "hillclimb",
23651
- version: "1.3.0",
23753
+ version: "1.4.0",
23652
23754
  title: "Hillclimb",
23653
23755
  outcome: "performance",
23654
23756
  input: Input5,
@@ -23782,7 +23884,7 @@ var hillclimb_default = defineLoop({
23782
23884
  const blocking = reviewed.findings.filter(isBlocking);
23783
23885
  yield* agentWork(`fix:${round}`, {
23784
23886
  agent: "implementer",
23785
- prompt: fixPrompt2(blocking),
23887
+ prompt: fixPrompt3(blocking),
23786
23888
  output: Struct({ summary: OneSentence })
23787
23889
  });
23788
23890
  const fixed = yield* verify(`verify:fix:${round}`, {});
@@ -23793,6 +23895,7 @@ var hillclimb_default = defineLoop({
23793
23895
  final = yield* measure(`measure:fix:${round}`, { plan, base: baseline, head: fixed.revision, ...limits });
23794
23896
  if (final.verdict !== "gain")
23795
23897
  return yield* ending("gain_gone", `The review's fixes cost the gain: ${final.reason}`, final);
23898
+ const fixedFrom = head.revision;
23796
23899
  head = fixed;
23797
23900
  reviewed = yield* call(`review:${round + 1}`, review_default, {
23798
23901
  base: baseline,
@@ -23800,7 +23903,8 @@ var hillclimb_default = defineLoop({
23800
23903
  outcome: "performance",
23801
23904
  ...notRunOf(fixed),
23802
23905
  claims,
23803
- earlier: blocking
23906
+ earlier: blocking,
23907
+ reviewed: fixedFrom
23804
23908
  });
23805
23909
  }
23806
23910
  const notRun = testsNotRunReasons(head);
@@ -24180,7 +24284,10 @@ An earlier Build of this failed. ${retry.steer}` };
24180
24284
  branch: head.branch,
24181
24285
  revision: head.revision,
24182
24286
  land: false
24183
- }).pipe(catchTag2("ChildFailed", (failure) => succeed7(failure)));
24287
+ }).pipe(catchTags2({
24288
+ ChildFailed: (failure) => succeed7(failure),
24289
+ StepFailed: (refused) => refused.code === "task_run_unsettled" ? succeed7(new ChildFailed({ step: refused.step, loop: build_default.id, reason: refused.reason })) : fail7(refused)
24290
+ }));
24184
24291
  if (built instanceof ChildFailed)
24185
24292
  return settled(ticket, { status: "failed", repoBindingId: head.repoBindingId, reason: built.reason });
24186
24293
  const delivered = { repoBindingId: head.repoBindingId, changeRequest: built.changeRequest };
@@ -24276,6 +24383,7 @@ var deliveryBody = (plan, results) => {
24276
24383
  var implement = (input, plan, revision, filed) => gen2(function* () {
24277
24384
  const tasks = filed?.revision === revision ? filed.tasks : (yield* createTasks("tasks", {
24278
24385
  tickets: plan.tickets,
24386
+ builds: true,
24279
24387
  ...input.projectId === undefined ? undefined : { projectId: input.projectId }
24280
24388
  })).tasks;
24281
24389
  const taskOf = new Map(tasks.map((task) => [task.key, task.taskId]));
@@ -24380,6 +24488,19 @@ var plan_default = defineLoop({
24380
24488
  let opinions = 0;
24381
24489
  yield* storePlan(plan, "");
24382
24490
  const project = input.projectId === undefined ? undefined : { projectId: input.projectId };
24491
+ const held = new Map;
24492
+ let implementing = false;
24493
+ const file = (step) => gen2(function* () {
24494
+ const made = yield* createTasks(step, { tickets: plan.tickets, builds: true, ...project });
24495
+ for (const ticket of plan.tickets)
24496
+ held.set(ticket.key, ticket);
24497
+ filed = { revision, tasks: made.tasks };
24498
+ });
24499
+ const release = (building = []) => {
24500
+ const tickets = [...held.values()].filter((ticket) => !building.some((built) => built.key === ticket.key));
24501
+ held.clear();
24502
+ return tickets.length === 0 ? void_3 : asVoid2(createTasks("release-tasks", { tickets, releases: true, ...project }));
24503
+ };
24383
24504
  const ended = (rest) => ({
24384
24505
  title: plan.title,
24385
24506
  outOfScope: plan.outOfScope,
@@ -24391,81 +24512,83 @@ var plan_default = defineLoop({
24391
24512
  ...docs === undefined ? undefined : { docs },
24392
24513
  ...rest
24393
24514
  });
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(`
24515
+ const decide = gen2(function* () {
24516
+ for (let round = 1;round <= maxRounds; round++) {
24517
+ const isFiled = filed?.revision === revision;
24518
+ const options = menu.filter((option) => !(option === "File as Tasks" && isFiled) && !(option === "Second opinion" && opinions >= maxOpinionsPerPlan));
24519
+ const fallback = input.implement === true ? "Implement now" : isFiled ? "Finish" : "File as Tasks";
24520
+ const answer = yield* ask(`next:${round}`, {
24521
+ prompt: `What next for the plan "${plan.title}"?`,
24522
+ options: options.map((option) => ({ value: option, description: menuDescriptions[option] })),
24523
+ recommended: fallback,
24524
+ 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.",
24525
+ default: fallback,
24526
+ timeout: "1 hour"
24527
+ });
24528
+ const choice = menu.find((option) => option === answer) ?? fallback;
24529
+ switch (choice) {
24530
+ case "Finish":
24531
+ yield* release();
24532
+ return ended({ implemented: false });
24533
+ case "Implement now": {
24534
+ implementing = true;
24535
+ yield* release(plan.tickets);
24536
+ const delivered = yield* implement(input, plan, revision, filed);
24537
+ return { ...ended({ implemented: true }), ...delivered };
24538
+ }
24539
+ case "File as Tasks":
24540
+ yield* file(`file-tasks:${round}`);
24541
+ break;
24542
+ case "Second opinion": {
24543
+ opinions++;
24544
+ const opinion = yield* agentWork(`second-opinion:${round}`, {
24545
+ agent: "reviewer",
24546
+ prompt: opinionPrompt(plan),
24547
+ output: Opinion
24548
+ });
24549
+ yield* artifact(`opinion:${round}`, {
24550
+ kind: "plan_review",
24551
+ title: `Second opinion on ${plan.title}`,
24552
+ text: [opinion.summary, ...opinion.concerns.map((concern) => `- ${concern}`)].join(`
24430
24553
 
24431
24554
  `)
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;
24555
+ });
24556
+ break;
24557
+ }
24558
+ case "Refine": {
24559
+ const words = yield* ask(`refine:${round}`, {
24560
+ prompt: "What should change in the plan?",
24561
+ freeText: true,
24562
+ informationOnly: true,
24563
+ recommendationReason: "You chose to refine it, so only you know what should change."
24564
+ });
24565
+ const refined = yield* agentWorkOnce(`refine-plan:${round}`, {
24566
+ agent: "planner",
24567
+ prompt: refinePrompt(plan, words),
24568
+ output: Plan
24569
+ });
24570
+ const before = plan;
24571
+ revision++;
24572
+ ({ plan, rejected } = yield* checked(refined, revision));
24573
+ yield* storePlan(plan, `:${round}`);
24574
+ yield* artifact(`changes:${round}`, {
24575
+ kind: "plan_changes",
24576
+ title: `Revision ${revision} of ${plan.title}`,
24577
+ text: changelog(before, plan, words)
24578
+ });
24579
+ break;
24580
+ }
24457
24581
  }
24458
24582
  }
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`
24583
+ if (filed?.revision !== revision)
24584
+ yield* file("file-tasks:last");
24585
+ yield* release();
24586
+ return ended({
24587
+ implemented: false,
24588
+ stopped: `No decision after ${maxRounds} rounds, so the tickets are filed as Tasks for a person to pick up`
24589
+ });
24468
24590
  });
24591
+ return yield* decide.pipe(tapError2(() => implementing ? void_3 : ignore2(release())));
24469
24592
  })
24470
24593
  });
24471
24594
 
@@ -24952,7 +25075,7 @@ var batchPrompt = (requests, target) => [
24952
25075
  ].join(`
24953
25076
 
24954
25077
  `);
24955
- var fixPrompt3 = (failed, applied) => [
25078
+ var fixPrompt4 = (failed, applied) => [
24956
25079
  `The batch of ${applied.map((number) => `!${number}`).join(", ")} fails these checks:`,
24957
25080
  ...failed.checks.filter((check) => check.status === "failed").map((check) => `- ${check.name}: \`${check.command}\``),
24958
25081
  "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 +25208,7 @@ var sweep_default = defineLoop({
25085
25208
  for (let round = 1;!checked.passed && round <= maxFixRounds && batched.applied.length > 0; round++) {
25086
25209
  batched = yield* agentWork(`fix:${round}`, {
25087
25210
  agent: "implementer",
25088
- prompt: fixPrompt3(checked, batched.applied),
25211
+ prompt: fixPrompt4(checked, batched.applied),
25089
25212
  output: Batched
25090
25213
  });
25091
25214
  for (const drop of batched.dropped)
@@ -28230,6 +28353,7 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28230
28353
  runnerChecks: optionalKey2(ArraySchema(String5)),
28231
28354
  targetChecks: optionalKey2(ArraySchema(String5)),
28232
28355
  approved: optionalKey2(String5),
28356
+ reviewed: optionalKey2(Struct({ review: String5, notRun: optionalKey2(ArraySchema(String5)) })),
28233
28357
  repository: optionalKey2(String5),
28234
28358
  sourceBranch: optionalKey2(String5),
28235
28359
  targetBranch: optionalKey2(String5),
@@ -28361,13 +28485,16 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28361
28485
  payload: {
28362
28486
  lease: ProgramLease,
28363
28487
  projectId: optionalKey2(String5),
28488
+ builds: optionalKey2(Boolean3),
28489
+ releases: optionalKey2(Boolean3),
28364
28490
  tickets: ArraySchema(Struct({
28365
28491
  key: String5,
28366
28492
  title: String5,
28367
28493
  body: String5,
28368
28494
  acceptanceCriteria: ArraySchema(String5),
28369
28495
  blockedBy: ArraySchema(String5),
28370
- outcome: optionalKey2(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"]))
28496
+ outcome: optionalKey2(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"])),
28497
+ repoBindingId: optionalKey2(String5)
28371
28498
  }))
28372
28499
  },
28373
28500
  success: ArraySchema(Struct({ key: String5, taskId: String5 })),
@@ -28406,7 +28533,8 @@ class RunnerCapabilityRpcs extends make31(make30("PutQuestion", {
28406
28533
  head: String5,
28407
28534
  summary: String5,
28408
28535
  review: optionalKey2(String5),
28409
- carries: optionalKey2(String5)
28536
+ carries: optionalKey2(String5),
28537
+ reuses: optionalKey2(String5)
28410
28538
  },
28411
28539
  success: Union2([
28412
28540
  Struct({ approved: Literal2(true), reviewId: String5 }),
@@ -28760,7 +28888,10 @@ var runnerActivities = (capabilities, services) => ({
28760
28888
  file: { run: (request, step) => keepFile(capabilities, step, request).pipe(provideContext2(services)) },
28761
28889
  note: { run: (request, step) => requested(step, capabilities.recordNote({ step, ...request })) },
28762
28890
  createTasks: {
28763
- run: (request, step) => requested(step, map8(capabilities.createPlanTasks(request.tickets, request.projectId), (tasks) => ({ tasks })))
28891
+ run: (request, step) => requested(step, map8(capabilities.createPlanTasks(request.tickets, request.projectId, {
28892
+ ...request.builds === undefined ? undefined : { builds: request.builds },
28893
+ ...request.releases === undefined ? undefined : { releases: request.releases }
28894
+ }), (tasks) => ({ tasks })))
28764
28895
  },
28765
28896
  alertTask: { run: (request, step) => requested(step, capabilities.alertTask({ step, ...request })) },
28766
28897
  integrationBranch: {
@@ -28892,16 +29023,18 @@ var rpcProgramPorts = (rpc, work) => {
28892
29023
  ...rpcRunFiles(rpc, lease),
28893
29024
  recordNote: (note) => rpc.recordNote({ lease, ...note }),
28894
29025
  performHostEffect: (request) => rpc.performHostEffect({ lease, ...request, waitsWhenUnconfirmed: true }),
28895
- createPlanTasks: (tickets, projectId) => rpc.createPlanTasks({
29026
+ createPlanTasks: (tickets, projectId, pickup) => rpc.createPlanTasks({
28896
29027
  lease,
28897
29028
  ...projectId === undefined ? undefined : { projectId },
29029
+ ...pickup,
28898
29030
  tickets: tickets.map((ticket) => ({
28899
29031
  key: ticket.key,
28900
29032
  title: ticket.title,
28901
29033
  body: ticket.body,
28902
29034
  acceptanceCriteria: ticket.acceptanceCriteria,
28903
29035
  blockedBy: ticket.blockedBy,
28904
- ...ticket.outcome === undefined ? undefined : { outcome: ticket.outcome }
29036
+ ...ticket.outcome === undefined ? undefined : { outcome: ticket.outcome },
29037
+ ...ticket.repoBindingId === undefined ? undefined : { repoBindingId: ticket.repoBindingId }
28905
29038
  }))
28906
29039
  }),
28907
29040
  integrationBranch: (repoBindingId, base) => base === true ? rpc.deliveryBase({ lease }) : rpc.integrationBranch({ lease, ...repoBindingId === undefined ? undefined : { repoBindingId } }),
@@ -31176,4 +31309,4 @@ var runKit = (config, identity, packages) => {
31176
31309
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31177
31310
  };
31178
31311
  // .kitman-build-entry.ts
31179
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.0-rc.2" }, []);
31312
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.12.0-rc.4" }, []);