@kitman-sh/software-engineering 0.13.15 → 0.13.17

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
@@ -13431,6 +13431,8 @@ var ClaimRanks = ["in_progress", "finishing", "new"];
13431
13431
  var TokenCount = Int.check(isGreaterThanOrEqualTo2(0));
13432
13432
  var TokenUsage = Struct({ input: TokenCount, output: TokenCount, cached: TokenCount });
13433
13433
  var AttemptTokens = Union2([TokenUsage, Literal2("none")]);
13434
+ var TokenTotalCount = String5.check(isPattern2(/^(?:0|[1-9][0-9]*)$/));
13435
+ var TokenTotal = Struct({ input: TokenTotalCount, output: TokenTotalCount, cached: TokenTotalCount });
13434
13436
 
13435
13437
  // ../../packages/core/src/loop.ts
13436
13438
  var LoopStatuses = ["draft", "active", "disabled", "archived"];
@@ -14196,6 +14198,12 @@ var SkippedChoice = Struct({
14196
14198
  reason: Literals(SkippedChoiceReasons),
14197
14199
  until: optionalKey2(Timestamp)
14198
14200
  });
14201
+ var StepFallback = Struct({
14202
+ harness: String5,
14203
+ model: optionalKey2(String5),
14204
+ effort: optionalKey2(Literals(AgentEfforts)),
14205
+ firstChoice: SkippedChoice
14206
+ });
14199
14207
  var StepAttempt = Struct({
14200
14208
  id: Id,
14201
14209
  workspaceId: Id,
@@ -14336,7 +14344,8 @@ var RunStepSummary = Struct({
14336
14344
  model: optionalKey2(String5),
14337
14345
  tokens: optionalKey2(AttemptTokens)
14338
14346
  })),
14339
- tokens: optionalKey2(TokenUsage)
14347
+ tokens: optionalKey2(TokenUsage),
14348
+ fallback: optionalKey2(StepFallback)
14340
14349
  });
14341
14350
  var RunSteerDeliveries = ["queued", "delivered", "failed"];
14342
14351
  var RunSteer = Struct({
@@ -14399,6 +14408,7 @@ var RunGraphNode = Struct({
14399
14408
  model: optionalKey2(String5),
14400
14409
  runner: optionalKey2(Struct({ id: Id, name: String5 }))
14401
14410
  })),
14411
+ fallback: optionalKey2(StepFallback),
14402
14412
  child: optionalKey2(Struct({
14403
14413
  runId: Id,
14404
14414
  loopTitle: String5,
@@ -14431,6 +14441,7 @@ var RunShow = Struct({
14431
14441
  steps: ArraySchema(RunStepSummary),
14432
14442
  questions: ArraySchema(Question),
14433
14443
  questionsBelow: optionalKey2(ArraySchema(QuestionBelow)),
14444
+ runsBelow: optionalKey2(ArraySchema(Struct({ runId: Id, parentRunId: Id }))),
14434
14445
  children: ArraySchema(Struct({
14435
14446
  runId: Id,
14436
14447
  name: String5,
@@ -14451,7 +14462,8 @@ var RunShow = Struct({
14451
14462
  steers: ArraySchema(RunSteer),
14452
14463
  waiting: ArraySchema(RunWaiting),
14453
14464
  closures: ArraySchema(RunClosure),
14454
- tokens: optionalKey2(TokenUsage)
14465
+ tokens: optionalKey2(TokenUsage),
14466
+ tokensWithChildRuns: optionalKey2(TokenTotal)
14455
14467
  });
14456
14468
  var RunStartPreview = Struct({
14457
14469
  loop: Struct({ id: String5, title: String5, outcome: optionalKey2(String5) }),
@@ -20345,6 +20357,7 @@ var WorkUnitHeartbeatInput = Struct({
20345
20357
  workUnitId: Id,
20346
20358
  lease: WorkUnitLeaseInput,
20347
20359
  leaseDurationSeconds: optionalKey2(Int.check(isGreaterThanOrEqualTo2(1), isLessThanOrEqualTo3(3600))),
20360
+ harnessStarted: optionalKey2(Literal2(true)),
20348
20361
  secrets: optionalKey2(ArraySchema(Struct({ name: SecretName, version: String5.check(isMinLength(1), isMaxLength(128)) })).check(isMaxLength(256)))
20349
20362
  });
20350
20363
  var WorkUnitHeartbeatResult = Struct({
@@ -20358,7 +20371,8 @@ var WorkUnitReleaseInput = Struct({
20358
20371
  workUnitId: Id,
20359
20372
  lease: WorkUnitLeaseInput,
20360
20373
  crashed: optionalKey2(Struct({ reason: String5.check(isMinLength(1), isMaxLength(500)) })),
20361
- tokens: optionalKey2(AttemptTokens)
20374
+ tokens: optionalKey2(AttemptTokens),
20375
+ ranModel: optionalKey2(String5.check(isMinLength(1), isMaxLength(200)))
20362
20376
  });
20363
20377
  var CheckEvidence = Struct({
20364
20378
  name: String5.check(isMinLength(1), isMaxLength(120)),
@@ -20429,6 +20443,7 @@ var WorkUnitOutcome = Struct({
20429
20443
  harnessHold: optionalKey2(HarnessHold),
20430
20444
  restart: optionalKey2(StepRestart),
20431
20445
  tokens: optionalKey2(AttemptTokens),
20446
+ ranModel: optionalKey2(String5.check(isMinLength(1), isMaxLength(200))),
20432
20447
  failureSummary: optionalKey2(String5.check(isMinLength(1), isMaxLength(4000)))
20433
20448
  });
20434
20449
  var WorkUnitCompletion = Struct({
@@ -21086,6 +21101,25 @@ var readPlanReview = (answer, revision, markdown) => {
21086
21101
  return { revision, comments: [{ id: "words", body: answer.trim() }] };
21087
21102
  return { revision, comments: decoded.value.planReview.comments.map((comment) => placed(comment, markdown)) };
21088
21103
  };
21104
+ // src/out-of-scope.ts
21105
+ var outOfScopeCase = { outOfScope: optional2(Int) };
21106
+ var listedCases = (cases) => (cases ?? []).filter((item) => item.trim() !== "");
21107
+ var caseOf = (cases, marked) => marked.outOfScope === undefined ? undefined : cases[marked.outOfScope - 1];
21108
+ var numberedCases = (cases) => cases.map((item, index) => `${index + 1}. ${item}`);
21109
+ var inCase = (text, item) => `${text} (Out of scope: ${item})`;
21110
+ var OutOfScopeFinding = Struct({
21111
+ ...MergedFinding.fields,
21112
+ severity: Literals(["major", "minor"]),
21113
+ item: String5,
21114
+ problem: optionalKey2(String5)
21115
+ });
21116
+ var outOfScopeLines = (findings, scope) => [
21117
+ ...findings.map((finding) => `${finding.id} (${finding.severity}): ${inCase(finding.detail, finding.item)}`),
21118
+ ...(scope?.outOfScope ?? []).map(({ part, item }) => inCase(part, item))
21119
+ ];
21120
+ var outOfScopeSection = (lines) => lines.length === 0 ? [] : ["## Out of scope", lines.map((line) => `- ${line}`).join(`
21121
+ `)];
21122
+
21089
21123
  // src/change-request-body.ts
21090
21124
  var scopeFindings = (scope) => (scope?.unmet ?? []).map((item) => ({
21091
21125
  id: `scope: ${item}`,
@@ -21170,6 +21204,7 @@ var changeRequestBody = (build) => [
21170
21204
  "## Unsettled",
21171
21205
  ...unsettledLines(build.unsettled, build.head),
21172
21206
  ...build.later === undefined || build.later.length === 0 ? [] : ["## Left for later", ...build.later.map((item) => `- ${item}`)],
21207
+ ...outOfScopeSection(build.outOfScope ?? []),
21173
21208
  "## Review",
21174
21209
  `${build.rounds} review round${build.rounds === 1 ? "" : "s"}; the rally stopped: ${build.stopped.replaceAll("_", " ")}.`
21175
21210
  ].join(`
@@ -21206,9 +21241,16 @@ var deliveryLayerWords = {
21206
21241
  };
21207
21242
 
21208
21243
  // src/reviewed-scope.ts
21244
+ var CriterionDisposition = Struct({
21245
+ criterion: String5,
21246
+ status: Literals(["met", "open", "out_of_scope", "reported"]),
21247
+ item: optionalKey2(String5)
21248
+ });
21209
21249
  var ReviewedScope = Struct({
21210
21250
  ...ScopeJudgement.fields,
21211
- reported: optional2(ArraySchema(String5))
21251
+ reported: optional2(ArraySchema(String5)),
21252
+ outOfScope: optional2(ArraySchema(Struct({ part: String5, item: String5 }))),
21253
+ criteria: optional2(ArraySchema(CriterionDisposition))
21212
21254
  });
21213
21255
 
21214
21256
  // src/text-limits.ts
@@ -21236,6 +21278,7 @@ var scopeSeat = "code-review";
21236
21278
  var choices = ["Post to the ChangeRequest", "Fix here", "Build from it", "Done"];
21237
21279
  var Input = Struct({
21238
21280
  changeRequestId: optional2(String5),
21281
+ deliveredBy: optional2(String5),
21239
21282
  base: optional2(String5),
21240
21283
  head: optional2(String5),
21241
21284
  files: optional2(ArraySchema(String5)),
@@ -21249,38 +21292,144 @@ var Input = Struct({
21249
21292
  scope: optional2(ReviewedScope),
21250
21293
  failing: optional2(ArraySchema(String5)),
21251
21294
  notRun: optional2(ArraySchema(String5)),
21295
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
21296
+ unmetCriteria: optional2(ArraySchema(String5)),
21297
+ metCriteria: optional2(ArraySchema(String5)),
21298
+ afterMergeCriteria: optional2(ArraySchema(String5)),
21299
+ taskOutOfScope: optional2(ArraySchema(String5)),
21252
21300
  next: optional2(Literals(choices)),
21253
21301
  ...DeliveryFields
21254
21302
  });
21255
21303
  var FollowUpStatus = Literals(["fixed", "changed", "still_there"]);
21256
21304
  var FollowUp = Struct({ id: String5, status: FollowUpStatus });
21305
+ var SeatFollowUp = Struct({
21306
+ ...FollowUp.fields,
21307
+ severity: optional2(Finding.fields.severity),
21308
+ ...outOfScopeCase
21309
+ });
21257
21310
  var SeatFinding = Struct({
21258
21311
  ...Finding.fields,
21259
21312
  detail: FindingDetail,
21260
21313
  approvedCode: optional2(Boolean3),
21261
21314
  rule: optional2(OneSentence),
21262
21315
  checked: optional2(ArraySchema(ShortStatement)),
21263
- outsideFix: optional2(Boolean3)
21316
+ outsideFix: optional2(Boolean3),
21317
+ ...outOfScopeCase
21318
+ });
21319
+ var isText = is2(String5);
21320
+ var SeatUnmet = Union2([
21321
+ String5,
21322
+ Struct({
21323
+ part: String5,
21324
+ criterion: optional2(Int),
21325
+ ...outOfScopeCase
21326
+ })
21327
+ ]);
21328
+ var SeatScope = Struct({
21329
+ ...ScopeJudgement.fields,
21330
+ unmet: ArraySchema(SeatUnmet),
21331
+ reported: optional2(ArraySchema(String5)),
21332
+ criteria: optional2(ArraySchema(Struct({
21333
+ criterion: Int,
21334
+ met: optional2(Boolean3),
21335
+ reported: optional2(Boolean3),
21336
+ ...outOfScopeCase
21337
+ })))
21264
21338
  });
21265
- var agreedScope = (scope) => scope.unmet.length === 0 && (scope.reported ?? []).length > 0 ? { ...scope, met: true } : scope;
21266
- var carriedScope = (judged, earlier) => {
21267
- if (judged === undefined)
21268
- return earlier;
21269
- const scope = agreedScope(judged);
21270
- const reported = [...new Set([...earlier?.reported ?? [], ...scope.reported ?? []])].filter((item) => !scope.unmet.includes(item));
21271
- return earlier === undefined || reported.length === 0 ? scope : { ...scope, reported };
21339
+ var dispositionsOf = (judged, cases, unmetCriteria, reportedByAnswer) => {
21340
+ const byCriterion = new Map;
21341
+ for (const entry of judged) {
21342
+ const criterion = unmetCriteria[entry.criterion - 1];
21343
+ if (criterion === undefined)
21344
+ continue;
21345
+ const item = caseOf(cases, entry);
21346
+ const disposition = entry.met === true ? { criterion, status: "met" } : entry.reported === true || item === undefined && reportedByAnswer.includes(criterion) ? { criterion, status: "reported" } : item === undefined ? { criterion, status: "open" } : { criterion, status: "out_of_scope", item };
21347
+ const known = byCriterion.get(criterion);
21348
+ byCriterion.set(criterion, known === undefined || JSON.stringify(known) === JSON.stringify(disposition) ? disposition : { criterion, status: "open" });
21349
+ }
21350
+ return [...byCriterion.values()];
21351
+ };
21352
+ var agreedScope = ({ unmet, criteria = [], reported: seatReported = [], ...scope }, cases, numberedCriteria, earlier) => {
21353
+ const given = unmet.map((entry) => isText(entry) ? { part: entry, item: undefined } : {
21354
+ part: (entry.criterion === undefined ? undefined : numberedCriteria[entry.criterion - 1]) ?? entry.part,
21355
+ item: caseOf(cases, entry)
21356
+ });
21357
+ const numbered = new Set(numberedCriteria);
21358
+ const parts = given.filter(({ part }) => !numbered.has(part));
21359
+ const judgedByNumber = dispositionsOf(criteria, cases, numberedCriteria, seatReported);
21360
+ const named = given.filter(({ part }) => numbered.has(part));
21361
+ const dispositions = [
21362
+ ...judgedByNumber.map((entry) => entry.status === "met" && named.some(({ part }) => part === entry.criterion) ? { criterion: entry.criterion, status: "open" } : entry),
21363
+ ...named.flatMap(({ part, item }, index) => judgedByNumber.some((entry) => entry.criterion === part) || named.findIndex((other) => other.part === part) !== index ? [] : named.filter((other) => other.part === part).every((other) => other.item === item) && item !== undefined ? [{ criterion: part, status: "out_of_scope", item }] : [{ criterion: part, status: "open" }])
21364
+ ];
21365
+ const criteriaApart = dispositions.flatMap(({ criterion, item }) => item === undefined ? [] : [{ part: criterion, item }]);
21366
+ const marked = [...parts.flatMap(({ part, item }) => item === undefined ? [] : [{ part, item }]), ...criteriaApart];
21367
+ const waivedParts = new Set(marked.map((entry) => entry.part));
21368
+ const left = [
21369
+ ...new Set([
21370
+ ...parts.flatMap(({ part }) => waivedParts.has(part) ? [] : [part]),
21371
+ ...dispositions.flatMap((entry) => entry.status === "open" ? [entry.criterion] : [])
21372
+ ])
21373
+ ];
21374
+ const judgedAgain = new Set([...waivedParts, ...left, ...dispositions.map((entry) => entry.criterion)]);
21375
+ const kept = earlier.filter(({ part }) => !judgedAgain.has(part));
21376
+ const outOfScope = [...kept, ...marked];
21377
+ const byAnswer = dispositions.flatMap((entry) => entry.status === "reported" ? [entry.criterion] : []);
21378
+ const judgedOtherwise = new Set(dispositions.flatMap((entry) => entry.status === "reported" ? [] : [entry.criterion]));
21379
+ const reported = [...new Set([...seatReported, ...byAnswer])].filter((part) => !left.includes(part) && !judgedOtherwise.has(part));
21380
+ const waived = reported.length + marked.length;
21381
+ const strict = cases.length > 0 || unmet.some((entry) => !isText(entry));
21382
+ return {
21383
+ ...scope,
21384
+ ...reported.length === 0 ? undefined : { reported },
21385
+ unmet: left,
21386
+ met: left.length === 0 ? scope.met || waived > 0 : scope.met && !strict,
21387
+ ...outOfScope.length === 0 ? undefined : { outOfScope },
21388
+ ...dispositions.length === 0 ? undefined : { criteria: dispositions }
21389
+ };
21390
+ };
21391
+ var withUnjudged = (scope, unmetCriteria) => {
21392
+ const settled = new Set([
21393
+ ...(scope?.criteria ?? []).map((entry) => entry.criterion),
21394
+ ...(scope?.outOfScope ?? []).map((entry) => entry.part),
21395
+ ...scope?.reported ?? [],
21396
+ ...scope?.unmet ?? []
21397
+ ]);
21398
+ const unjudged = unmetCriteria.filter((criterion) => !settled.has(criterion));
21399
+ return unjudged.length === 0 ? scope : { ...scope, met: false, unmet: [...scope?.unmet ?? [], ...unjudged] };
21400
+ };
21401
+ var carriedScope = (judged, earlier, cases, numberedCriteria) => {
21402
+ if (judged === undefined) {
21403
+ if (earlier === undefined)
21404
+ return;
21405
+ const { criteria: _, ...carried } = earlier;
21406
+ return carried;
21407
+ }
21408
+ const scope = agreedScope(judged, cases, numberedCriteria, earlier?.outOfScope ?? []);
21409
+ const judgedOtherwise = new Set((scope.criteria ?? []).flatMap((entry) => entry.status === "reported" ? [] : [entry.criterion]));
21410
+ const reported = [...new Set([...earlier?.reported ?? [], ...scope.reported ?? []])].filter((item) => !scope.unmet.includes(item) && !judgedOtherwise.has(item));
21411
+ if (earlier === undefined)
21412
+ return scope;
21413
+ const { reported: _, ...rest } = scope;
21414
+ return reported.length === 0 ? rest : { ...rest, reported };
21272
21415
  };
21273
21416
  var SeatOutput = Struct({
21274
21417
  summary: OneSentence,
21275
21418
  findings: ArraySchema(SeatFinding),
21276
21419
  verdicts: optional2(ArraySchema(RebuttalVerdict)),
21277
- scope: optional2(ReviewedScope),
21278
- followUps: optional2(ArraySchema(FollowUp))
21420
+ scope: optional2(SeatScope),
21421
+ followUps: optional2(ArraySchema(SeatFollowUp))
21422
+ });
21423
+ var ApprovedFinding = Struct({
21424
+ ...MergedFinding.fields,
21425
+ item: optionalKey2(String5),
21426
+ problem: OutOfScopeFinding.fields.problem
21279
21427
  });
21280
21428
  var Output = Struct({
21281
21429
  summary: String5,
21282
21430
  findings: ArraySchema(MergedFinding),
21283
- approvedFindings: optional2(ArraySchema(MergedFinding)),
21431
+ approvedFindings: optional2(ArraySchema(ApprovedFinding)),
21432
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
21284
21433
  followUps: ArraySchema(FollowUp),
21285
21434
  verdicts: ArraySchema(RebuttalVerdict),
21286
21435
  blocking: Boolean3,
@@ -21318,7 +21467,7 @@ var targetOf = (input, { base, head, branches, epic }) => {
21318
21467
  if (input.files === undefined && input.approved !== undefined)
21319
21468
  return [
21320
21469
  `only what the change gained or lost since it was approved at ${input.approved}: compare \`git diff ${base}...${input.approved}\`, the change as approved, with \`git diff ${base}...${head}\`, the change now, in your checkout. The rest was reviewed and approved before.`,
21321
- "Report a problem in code the change already had at the approved head only if it matters, with `approvedCode` set to true: such findings are kept apart and do not block."
21470
+ "Report a problem in code the change already had at the approved head only if it matters, with `approvedCode` set to true: such findings are kept apart and do not block, unless one is a blocker in one of the Task's numbered out-of-scope cases."
21322
21471
  ].join(`
21323
21472
 
21324
21473
  `);
@@ -21354,26 +21503,102 @@ var pinnedRange = (input) => gen2(function* () {
21354
21503
  return { base, head };
21355
21504
  });
21356
21505
  var wholeChange = (input) => input.files === undefined && input.approved === undefined;
21357
- 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.";
21358
- var rejudgedScopePrompt = (unmet) => [
21359
- [
21360
- "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.",
21361
- ...unmet.length === 0 ? ["It found nothing unmet."] : [
21362
- "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:",
21363
- ...unmet.map((item) => `- ${item}`)
21364
- ]
21365
- ].join(`
21366
- `),
21367
- "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."
21506
+ var casesOf = (input) => listedCases(input.taskOutOfScope);
21507
+ var unmetCriteriaOf = (input) => casesOf(input).length === 0 ? [] : input.unmetCriteria ?? [];
21508
+ var afterMergeCriteriaOf = (input) => casesOf(input).length === 0 ? [] : input.afterMergeCriteria ?? [];
21509
+ var criteriaOf = (input) => casesOf(input).length === 0 ? [] : [...new Set([...unmetCriteriaOf(input), ...input.metCriteria ?? [], ...afterMergeCriteriaOf(input)])];
21510
+ var outOfScopePrompt = (cases) => [
21511
+ "The Task's Out of scope list is these numbered cases, and no other list in your brief is. The change need not handle them, so a case it does not handle is not missing scope:",
21512
+ ...numberedCases(cases),
21513
+ "Report a problem in one of them at its real severity, with `outOfScope` set to the case's number: a major or minor is kept apart and does not block. A blocker there, such as a security hole or lost data, still blocks."
21368
21514
  ].join(`
21515
+ `);
21516
+ var wholeScopePrompt = "If your brief has a Task, judge its scope and give it as `scope`: does the change make the Task's Promise true, if it has one, and 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, unless it is a numbered criterion your brief asks you to judge in `criteria`, 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 the Promise and each other criterion or part of the description that is not done, except a numbered criterion, which you judge in `criteria` alone. If your brief has no Task, leave `scope` out.";
21517
+ var rejudgedScopePrompt = ({ unmet, outOfScope = [] }, numbered) => {
21518
+ const shown = unmet.filter((item) => !numbered.includes(item));
21519
+ return [
21520
+ [
21521
+ "If your brief has a Task, judge its scope again and give it as `scope`. An earlier round judged what the Task's Promise, if it has one, its description and Acceptance Criteria ask, and that stands, so do not judge all of it again.",
21522
+ ...unmet.length === 0 ? ["It found nothing unmet."] : shown.length === 0 ? ["What it found unmet is among the numbered criteria below, which you judge by number."] : [
21523
+ `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${numbered.length === 0 ? "" : ", unless it is one of the numbered criteria below: judge that one by its number alone, which wins over any line naming it"}:`,
21524
+ ...shown.map((item) => `- ${item}`)
21525
+ ]
21526
+ ].join(`
21527
+ `),
21528
+ ...outOfScope.length === 0 ? [] : [
21529
+ [
21530
+ "It found these not done only because of one of the Task's numbered out-of-scope cases. They stay reported apart, so leave them out of `unmet`:",
21531
+ ...outOfScope.map(({ part, item }) => `- ${inCase(part, item)}`)
21532
+ ].join(`
21533
+ `)
21534
+ ],
21535
+ "Also list in `unmet`, one line each, the Promise and any criterion or part the fix undoes, except a numbered criterion, which you judge in `criteria` alone. 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, unless it is a numbered criterion. Set `met` to true only if `unmet` is empty. If your brief has no Task, leave `scope` out."
21536
+ ].join(`
21369
21537
 
21370
21538
  `);
21539
+ };
21371
21540
  var fixRound = (input) => (input.earlier?.length ?? 0) > 0 || input.reviewed !== undefined;
21372
- var scopeToRejudge = (input) => fixRound(input) && (input.scope?.met === true || (input.scope?.unmet.length ?? 0) > 0) ? input.scope : undefined;
21541
+ var earlierScope = (input) => {
21542
+ if (!fixRound(input) || input.scope === undefined)
21543
+ return;
21544
+ const { outOfScope = [], ...scope } = input.scope;
21545
+ const listed = outOfScope.filter(({ item }) => casesOf(input).includes(item));
21546
+ const unlisted = outOfScope.flatMap((entry) => listed.includes(entry) ? [] : [entry.part]);
21547
+ return {
21548
+ ...scope,
21549
+ ...unlisted.length === 0 ? undefined : { met: false, unmet: [...new Set([...scope.unmet, ...unlisted])] },
21550
+ ...listed.length === 0 ? undefined : { outOfScope: listed }
21551
+ };
21552
+ };
21553
+ var scopeToRejudge = (input) => {
21554
+ const scope = earlierScope(input);
21555
+ return scope?.met === true || (scope?.unmet.length ?? 0) > 0 ? scope : undefined;
21556
+ };
21557
+ var earlierOpenCriteriaOf = (input) => {
21558
+ const scope = earlierScope(input);
21559
+ const open = new Set([
21560
+ ...scope?.unmet ?? [],
21561
+ ...(scope?.criteria ?? []).flatMap((entry) => entry.status === "open" ? [entry.criterion] : [])
21562
+ ]);
21563
+ return criteriaOf(input).filter((criterion) => open.has(criterion));
21564
+ };
21565
+ var requiredCriteriaOf = (input) => [
21566
+ ...new Set([...unmetCriteriaOf(input), ...earlierOpenCriteriaOf(input)])
21567
+ ];
21568
+ var numbersOf = (input, criteria) => criteriaOf(input).flatMap((criterion, index) => criteria.includes(criterion) ? [index + 1] : []);
21569
+ var answeredPrompt = (input) => {
21570
+ const notMet = numbersOf(input, unmetCriteriaOf(input));
21571
+ const afterMerge = numbersOf(input, afterMergeCriteriaOf(input));
21572
+ const reopened = numbersOf(input, earlierOpenCriteriaOf(input)).filter((number) => !notMet.includes(number));
21573
+ const required = [...notMet, ...reopened].toSorted((left, right) => left - right);
21574
+ return [
21575
+ notMet.length === 0 && afterMerge.length === 0 ? "The implementer answered each of them met." : `The implementer answered ${[
21576
+ ...notMet.length === 0 ? [] : [`${notMet.join(", ")} not met`],
21577
+ ...afterMerge.length === 0 ? [] : [
21578
+ `${afterMerge.join(", ")} after merge, as their result shows only once the change is merged; judge those by the code, never as not done only because that result cannot be seen yet`
21579
+ ]
21580
+ ].join(", and ")}, and the rest met.`,
21581
+ ...reopened.length === 0 ? [] : [`An earlier round found ${reopened.join(", ")} not done.`],
21582
+ required.length === 0 ? "Give one only if the change does not do it." : `Judge ${required.join(", ")} every time, and any other only if the change does not do it.`
21583
+ ].join(" ");
21584
+ };
21373
21585
  var scopePrompt = (input) => {
21374
21586
  const earlier = scopeToRejudge(input);
21375
21587
  return [
21376
- earlier === undefined ? wholeScopePrompt : rejudgedScopePrompt(earlier.unmet),
21588
+ earlier === undefined ? wholeScopePrompt : rejudgedScopePrompt(earlier, criteriaOf(input)),
21589
+ ...casesOf(input).length === 0 ? [] : [
21590
+ `A part that is not done only because it falls in one of the Task's numbered out-of-scope cases is never unmet, even where the Promise, the description or a criterion covers it. Give it in \`unmet\` as \`{ part, outOfScope }\`, with the case's number; Kitman reports it apart. Give each part once${criteriaOf(input).length === 0 ? "" : ", and a numbered criterion only by its number"}.`
21591
+ ],
21592
+ ...criteriaOf(input).length === 0 ? [] : [
21593
+ [
21594
+ [
21595
+ "The Task's acceptance criteria are numbered below, in the implementer's words. Judge a numbered criterion in `criteria` alone, by its number, as `{ criterion, met }`: `met` true only if the change does it. For one not done only because of a numbered out-of-scope case, also set `outOfScope` to the case's number; for one an answer under your brief's Answers so far put out of scope, set `reported` to true instead. Leave them out of `unmet` and `reported`, even one an answer put out of scope or one you would word as the Task does: Kitman lists them there itself, and a criterion's number wins over any line there that names it. If you still give a line in `unmet` about one, give it as `{ part, criterion }` with the criterion's number.",
21596
+ answeredPrompt(input)
21597
+ ].join(" "),
21598
+ ...numberedCases(criteriaOf(input))
21599
+ ].join(`
21600
+ `)
21601
+ ],
21377
21602
  ...input.outcome === undefined ? [] : [`The Outcome to prove is ${input.outcome}.`],
21378
21603
  ...input.claims === undefined || input.claims.length === 0 ? [] : [
21379
21604
  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:",
@@ -21387,12 +21612,24 @@ var exhaustivePrompt = (subject) => [
21387
21612
  `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.`,
21388
21613
  "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."
21389
21614
  ].join(" ");
21390
- var earlierPrompt = (earlier) => [
21391
- "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.",
21615
+ var earlierPrompt = (earlier, cases) => [
21616
+ [
21617
+ "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.",
21618
+ ...cases.length === 0 ? [] : [
21619
+ "If one that is not fixed is in one of the Task's numbered out-of-scope cases, set `outOfScope` on its entry to the case's number.",
21620
+ "If one that is not fixed now has another severity, worse or less bad, set `severity` on its entry to its severity now: a blocker always blocks.",
21621
+ "Report a different problem on the same line as a finding."
21622
+ ]
21623
+ ].join(" "),
21392
21624
  ...earlier.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
21393
21625
  ].join(`
21394
21626
  `);
21395
- 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.";
21627
+ var outsideFixPrompt = (cases) => [
21628
+ "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.",
21629
+ ...cases.length === 0 ? [] : [
21630
+ "A problem in one of the Task's numbered out-of-scope cases is the exception: report it at its real severity, with `outOfScope` set."
21631
+ ]
21632
+ ].join(" ");
21396
21633
  var fixTargetOf = (input, { head, branches, epic }) => {
21397
21634
  const from = input.reviewed ?? (input.files === undefined ? undefined : input.since);
21398
21635
  const branch = branches === undefined ? epic?.branch : branches.source ?? head;
@@ -21400,7 +21637,7 @@ var fixTargetOf = (input, { head, branches, epic }) => {
21400
21637
  `${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.`,
21401
21638
  "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.",
21402
21639
  ...input.files === undefined ? input.approved === undefined ? [] : [
21403
- `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.`
21640
+ `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, unless one is a blocker in one of the Task's numbered out-of-scope cases.`
21404
21641
  ] : [
21405
21642
  [
21406
21643
  "Whatever changed in these files since then, even by merging the target branch, counts as the fix:",
@@ -21415,17 +21652,18 @@ var fixTargetOf = (input, { head, branches, epic }) => {
21415
21652
 
21416
21653
  `);
21417
21654
  };
21418
- var promptFor = (seat, target, input, failing, notRun) => [
21655
+ var promptFor = (seat, target, input, earlier, failing, notRun) => [
21419
21656
  `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}`,
21420
21657
  `Review ${target}`,
21421
21658
  "Give `summary`: one sentence on whether it can merge and what matters most.",
21422
21659
  "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.",
21423
21660
  exhaustivePrompt(fixRound(input) ? "the fix" : "the change"),
21424
21661
  "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.",
21662
+ ...casesOf(input).length === 0 ? [] : [outOfScopePrompt(casesOf(input))],
21425
21663
  "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.",
21426
21664
  ...seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : [],
21427
- ...input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)],
21428
- ...fixRound(input) ? [outsideFixPrompt] : [],
21665
+ ...earlier.length === 0 ? [] : [earlierPrompt(earlier, casesOf(input))],
21666
+ ...fixRound(input) ? [outsideFixPrompt(casesOf(input))] : [],
21429
21667
  ...failing.length === 0 ? [] : [
21430
21668
  `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.`
21431
21669
  ],
@@ -21445,26 +21683,67 @@ var promptFor = (seat, target, input, failing, notRun) => [
21445
21683
  `);
21446
21684
  var rank2 = { still_there: 0, changed: 1, fixed: 2 };
21447
21685
  var outsideFixAsMinor = (finding) => finding.outsideFix === true && finding.severity === "major" ? { ...finding, severity: "minor" } : finding;
21686
+ var earlierOf = (input) => {
21687
+ const followed = new Map((input.earlier ?? []).map((finding) => [finding.id, finding]));
21688
+ for (const { item, problem: _, ...finding } of input.outOfScopeFindings ?? []) {
21689
+ if (casesOf(input).includes(item))
21690
+ continue;
21691
+ const taken = new Set(followed.keys());
21692
+ const id = taken.has(finding.id) ? ownId(inCase(finding.id, item), taken) : finding.id;
21693
+ followed.set(id, { ...finding, id });
21694
+ }
21695
+ return [...followed.values()];
21696
+ };
21697
+ var keptApart = (finding, item) => finding.severity === "blocker" ? [] : [{ ...finding, severity: finding.severity, item }];
21448
21698
  var detailOf = (detail, rule, checked) => [
21449
21699
  ...rule === undefined ? [] : [`[${rule}]`],
21450
21700
  detail,
21451
21701
  ...checked.length === 0 ? [] : [`Checked and fine: ${checked.join("; ")}.`]
21452
21702
  ].join(" ");
21453
21703
  var severityRank = { blocker: 0, major: 1, minor: 2 };
21704
+ var ownId = (id, taken) => {
21705
+ if (!taken.has(id))
21706
+ return id;
21707
+ let number = 2;
21708
+ while (taken.has(`${id} (${number})`))
21709
+ number++;
21710
+ return `${id} (${number})`;
21711
+ };
21712
+ var wordingsOf = ({ detail, problem }) => problem === undefined ? [detail] : [detail, problem];
21713
+ var distinctApart = (findings, taken = new Set) => {
21714
+ const kept = [];
21715
+ for (const finding of findings) {
21716
+ const index = kept.findIndex((known) => known.file === finding.file && known.line === finding.line && known.item === finding.item && wordingsOf(known).some((wording) => wordingsOf(finding).includes(wording)));
21717
+ const same = kept[index];
21718
+ if (same === undefined) {
21719
+ kept.push({ ...finding, id: ownId(finding.id, new Set([...taken, ...kept.map((known) => known.id)])) });
21720
+ continue;
21721
+ }
21722
+ kept[index] = {
21723
+ ...same,
21724
+ ...same.problem !== undefined || finding.problem === undefined ? undefined : { problem: finding.problem },
21725
+ severity: severityRank[finding.severity] < severityRank[same.severity] ? finding.severity : same.severity,
21726
+ seats: [...new Set([...same.seats, ...finding.seats])]
21727
+ };
21728
+ }
21729
+ return kept;
21730
+ };
21454
21731
  var blockingSeatsOf = (finding) => isBlocking(finding) ? finding.blockingSeats ?? finding.seats : [];
21732
+ var stillOpen = " Still open on this line: ";
21733
+ var problemsOf = (detail) => detail.split(stillOpen).map((problem) => problem.trim());
21455
21734
  var withEarlier = (worse, earlier) => {
21456
21735
  const { blockingSeats: _, ...finding } = worse;
21457
21736
  const seats = [...new Set([...earlier.seats, ...worse.seats])];
21458
21737
  const blockingSeats = [...new Set([...blockingSeatsOf(earlier), ...blockingSeatsOf(worse)])];
21459
21738
  return {
21460
21739
  ...finding,
21461
- detail: `${finding.detail} Still open on this line: ${earlier.detail}`,
21740
+ detail: `${finding.detail}${stillOpen}${earlier.detail}`,
21462
21741
  seats,
21463
21742
  ...blockingSeats.length === seats.length ? undefined : { blockingSeats }
21464
21743
  };
21465
21744
  };
21466
21745
  var idOf = (finding) => `${finding.file}:${finding.line}`;
21467
- var groupedByRule = (bySeat) => {
21746
+ var groupedByRule = (bySeat, cases, taken) => {
21468
21747
  const rules = new Map;
21469
21748
  const checked = new Map;
21470
21749
  for (const finding of Object.values(bySeat).flat()) {
@@ -21473,18 +21752,55 @@ var groupedByRule = (bySeat) => {
21473
21752
  rules.set(id, finding.rule);
21474
21753
  checked.set(id, new Set([...checked.get(id) ?? [], ...finding.checked ?? []]));
21475
21754
  }
21476
- const findings = mergeFindings(Object.fromEntries(Object.entries(bySeat).map(([seat, seatFindings]) => [
21755
+ const detailed = (finding) => detailOf(finding.detail, rules.get(idOf(finding)), [...checked.get(idOf(finding)) ?? []]);
21756
+ const distinct = [];
21757
+ const blockers = Object.entries(bySeat).flatMap(([seat, seatFindings]) => seatFindings.flatMap((finding) => finding.severity === "blocker" ? [{ seat, finding }] : []));
21758
+ const firstOn = new Map;
21759
+ for (const { finding } of blockers)
21760
+ if (!firstOn.has(idOf(finding)))
21761
+ firstOn.set(idOf(finding), finding);
21762
+ const merges = new Set(Object.keys(bySeat).flatMap((seat) => [...firstOn].flatMap(([id, first]) => {
21763
+ const own = blockers.filter((entry) => entry.seat === seat && idOf(entry.finding) === id).map((entry) => entry.finding);
21764
+ return own.find((finding) => finding.detail === first.detail) ?? own[0] ?? [];
21765
+ })));
21766
+ const merging = Object.entries(bySeat).map(([seat, seatFindings]) => [
21767
+ seat,
21768
+ seatFindings.flatMap((finding) => {
21769
+ const id = idOf(finding);
21770
+ const first = firstOn.get(id);
21771
+ const marked = caseOf(cases, finding);
21772
+ const another = finding.severity === "blocker" && cases.length > 0 && finding.detail !== first?.detail && (!merges.has(finding) || marked !== undefined && marked !== (first && caseOf(cases, first)));
21773
+ if (!another)
21774
+ return [finding];
21775
+ const index = distinct.findIndex((known) => known.id === id && known.problem === finding.detail);
21776
+ const known = distinct[index];
21777
+ if (known === undefined)
21778
+ distinct.push({ ...finding, id, detail: detailed(finding), seats: [seat], problem: finding.detail });
21779
+ else
21780
+ distinct[index] = { ...known, seats: [...new Set([...known.seats, seat])] };
21781
+ return [];
21782
+ })
21783
+ ]);
21784
+ const findings = mergeFindings(Object.fromEntries(merging.map(([seat, seatFindings]) => [
21477
21785
  seat,
21478
21786
  seatFindings.map((finding) => ({
21479
21787
  severity: finding.severity,
21480
21788
  file: finding.file,
21481
21789
  line: finding.line,
21482
- detail: detailOf(finding.detail, rules.get(idOf(finding)), [...checked.get(idOf(finding)) ?? []])
21790
+ detail: detailed(finding)
21483
21791
  }))
21484
21792
  ])));
21485
- const groupOf = (finding) => rules.get(finding.id) ?? finding.id;
21486
- const order = [...new Set(findings.map(groupOf))];
21487
- return findings.toSorted((left, right) => order.indexOf(groupOf(left)) - order.indexOf(groupOf(right)));
21793
+ for (const finding of findings)
21794
+ taken.add(finding.id);
21795
+ const apart = distinct.map(({ file, line, severity, detail, seats, id }) => {
21796
+ const own = ownId(id, taken);
21797
+ taken.add(own);
21798
+ return { id: own, severity, file, line, detail, seats };
21799
+ });
21800
+ const groupOf = (finding) => rules.get(`${finding.file}:${finding.line}`) ?? finding.id;
21801
+ const all = [...findings, ...apart];
21802
+ const order = [...new Set(all.map(groupOf))];
21803
+ return all.toSorted((left, right) => order.indexOf(groupOf(left)) - order.indexOf(groupOf(right)));
21488
21804
  };
21489
21805
  var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21490
21806
  const statuses = answers.flatMap((answer) => answer.id === finding.id ? [answer.status] : []);
@@ -21493,27 +21809,65 @@ var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21493
21809
  status: statuses.length === 0 ? "still_there" : statuses.reduce((worst, status) => rank2[status] < rank2[worst] ? status : worst)
21494
21810
  };
21495
21811
  });
21812
+ var currentOf = (finding, answers) => {
21813
+ const judging = answers.flatMap(({ id, status, severity, seat }) => id === finding.id && status !== "fixed" && severity !== undefined ? [{ seat, severity }] : []);
21814
+ const now = judging.reduce((worst, { severity }) => worst === undefined || severityRank[severity] < severityRank[worst] ? severity : worst, undefined);
21815
+ if (now === undefined || now === finding.severity)
21816
+ return finding;
21817
+ const { blockingSeats: _, ...current } = finding;
21818
+ const seats = [...new Set([...finding.seats, ...judging.map(({ seat }) => seat)])];
21819
+ const blockingSeats = isBlocking({ severity: now }) ? [
21820
+ ...new Set([
21821
+ ...blockingSeatsOf(finding),
21822
+ ...judging.flatMap(({ seat, severity }) => isBlocking({ severity }) ? [seat] : [])
21823
+ ])
21824
+ ] : [];
21825
+ return {
21826
+ ...current,
21827
+ severity: now,
21828
+ seats,
21829
+ ...blockingSeats.length === 0 || blockingSeats.length === seats.length ? undefined : { blockingSeats }
21830
+ };
21831
+ };
21832
+ var earlierCaseOf = (finding, answers, cases) => {
21833
+ const items = answers.flatMap((answer) => answer.id === finding.id && answer.status !== "fixed" ? [caseOf(cases, answer)] : []);
21834
+ return finding.severity === "blocker" || items.includes(undefined) ? undefined : items[0];
21835
+ };
21496
21836
  var findingLines = (findings) => findings.map((finding) => `- **${finding.severity}** \`${finding.id}\` ${finding.detail} _(${finding.seats.join(", ")})_`).join(`
21497
21837
  `);
21498
- var reviewText = (summary, findings, followUps, approvedFindings, notRun, reported) => [
21499
- `**Kitman review.** ${summary}`,
21500
- ...reported.length === 0 ? [] : [`Out of scope by an answer, so reported, not blocking:
21838
+ var reviewText = (summary, findings, followUps, approvedFindings, outOfScopeFindings, notRun, scope) => {
21839
+ const reported = scope?.reported ?? [];
21840
+ const outOfScope = scope?.outOfScope ?? [];
21841
+ return [
21842
+ `**Kitman review.** ${summary}`,
21843
+ ...reported.length === 0 ? [] : [`Out of scope by an answer, so reported, not blocking:
21501
21844
  ${reported.map((item) => `- ${item}`).join(`
21502
21845
  `)}`],
21503
- ...notRun.length === 0 ? [] : [`Verify never ran these tests, so they are unverified:
21846
+ ...notRun.length === 0 ? [] : [`Verify never ran these tests, so they are unverified:
21504
21847
  ${notRun.map((item) => `- ${item}`).join(`
21505
21848
  `)}`],
21506
- ...findings.length === 0 ? [] : [findingLines(findings)],
21507
- ...approvedFindings.length === 0 ? [] : [`In code approved before, not blocking:
21508
- ${findingLines(approvedFindings)}`],
21509
- ...followUps.length === 0 ? [] : [
21510
- `Earlier findings:
21849
+ ...findings.length === 0 ? [] : [findingLines(findings)],
21850
+ ...approvedFindings.length === 0 ? [] : [
21851
+ `In code approved before, not blocking:
21852
+ ${findingLines(approvedFindings.map(({ item, ...finding }) => item === undefined ? finding : { ...finding, detail: inCase(finding.detail, item) }))}`
21853
+ ],
21854
+ ...outOfScope.length + outOfScopeFindings.length === 0 ? [] : [
21855
+ [
21856
+ "In a case the Task lists as Out of scope, so reported, not blocking:",
21857
+ ...outOfScope.map(({ part, item }) => `- ${inCase(part, item)}`),
21858
+ ...outOfScopeFindings.length === 0 ? [] : [findingLines(outOfScopeFindings)]
21859
+ ].join(`
21860
+ `)
21861
+ ],
21862
+ ...followUps.length === 0 ? [] : [
21863
+ `Earlier findings:
21511
21864
  ${followUps.map((entry) => `- \`${entry.id}\` ${entry.status.replace("_", " ")}`).join(`
21512
21865
  `)}`
21513
- ]
21514
- ].join(`
21866
+ ]
21867
+ ].join(`
21515
21868
 
21516
21869
  `);
21870
+ };
21517
21871
  var fixBrief = (changeRequestId, findings, unmet) => [
21518
21872
  `Fix what a review of ChangeRequest ${changeRequestId} found, on its branch:`,
21519
21873
  ...findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`),
@@ -21522,7 +21876,7 @@ var fixBrief = (changeRequestId, findings, unmet) => [
21522
21876
  `);
21523
21877
  var review_default = defineLoop({
21524
21878
  id: "review",
21525
- version: "3.10.0",
21879
+ version: "3.11.0",
21526
21880
  title: "Review",
21527
21881
  input: Input,
21528
21882
  output: Output,
@@ -21556,47 +21910,119 @@ var review_default = defineLoop({
21556
21910
  const verified = head === undefined ? { failing: [], notRun: [] } : yield* verifyHead("verify", head);
21557
21911
  const failing = [...new Set([...input.failing ?? [], ...verified.failing])];
21558
21912
  const notRun = [...new Set([...input.notRun ?? [], ...verified.notRun])];
21913
+ const earlier = earlierOf(input);
21559
21914
  const outputs = yield* forEach2(fixRound(input) ? [scopeSeat] : seatNames, (seat) => agentWork(`review:${seat}`, {
21560
21915
  agent: seat,
21561
- prompt: promptFor(seat, target, input, failing, notRun),
21916
+ prompt: promptFor(seat, target, input, earlier, failing, notRun),
21562
21917
  output: SeatOutput
21563
21918
  }).pipe(map8((output) => [seat, output])), { concurrency: "unbounded" });
21564
- const earlier = input.earlier ?? [];
21919
+ const cases = casesOf(input);
21565
21920
  const earlierById = new Map(earlier.map((finding) => [finding.id, finding]));
21566
- const answered = followUpsOf(earlier, outputs.flatMap(([, output]) => output.followUps ?? []));
21921
+ const answers = outputs.flatMap(([seat, output]) => (output.followUps ?? []).map((answer) => ({ ...answer, seat })));
21922
+ const answered = followUpsOf(earlier, answers);
21567
21923
  const standing = new Set(answered.flatMap((entry) => entry.status === "fixed" ? [] : [entry.id]));
21568
21924
  const given = outputs.flatMap(([, output]) => output.verdicts ?? []);
21569
21925
  const settled = settleRound({ findings: earlier, rebuttals: input.rebuttals ?? [], verdicts: given });
21570
21926
  const withdrawn = new Set(settled.withdrawn.map((entry) => entry.finding.id));
21571
- const open = new Map([...earlierById].filter(([id]) => standing.has(id) && !withdrawn.has(id)));
21927
+ const open = new Map([...earlierById].flatMap(([id, finding]) => standing.has(id) && !withdrawn.has(id) ? [[id, currentOf(finding, answers)]] : []));
21928
+ const movedApart = new Map;
21929
+ for (const [id, finding] of open) {
21930
+ const item = earlierCaseOf(finding, answers, cases);
21931
+ if (item === undefined)
21932
+ continue;
21933
+ open.delete(id);
21934
+ for (const apart of keptApart(finding, item))
21935
+ movedApart.set(id, apart);
21936
+ }
21572
21937
  const followUps = answered.filter((entry) => !withdrawn.has(entry.id));
21573
21938
  const sinceApproval = input.approved !== undefined && input.files === undefined;
21574
- const isNew = (finding) => {
21939
+ const groupOf = (finding) => {
21940
+ const approved = sinceApproval && finding.approvedCode === true;
21941
+ if (caseOf(cases, finding) !== undefined)
21942
+ return finding.severity === "blocker" ? "fresh" : approved ? "approvedApart" : "outOfScope";
21943
+ return approved ? "approvedCode" : "fresh";
21944
+ };
21945
+ const keepsSeverity = (finding) => {
21946
+ const group = groupOf(finding);
21947
+ return group === "outOfScope" || group === "approvedApart";
21948
+ };
21949
+ const listedApart = [
21950
+ ...(input.outOfScopeFindings ?? []).filter((finding) => cases.includes(finding.item)),
21951
+ ...movedApart.values()
21952
+ ];
21953
+ const unfixedOn = (finding) => {
21575
21954
  const before = earlierById.get(idOf(finding));
21576
- return before === undefined || severityRank[finding.severity] < severityRank[before.severity] || !standing.has(before.id) && !withdrawn.has(before.id);
21955
+ return before !== undefined && (standing.has(before.id) || withdrawn.has(before.id)) ? before : undefined;
21956
+ };
21957
+ const saysAgain = (before, finding) => [finding.detail, detailOf(finding.detail, finding.rule, finding.checked ?? [])].some((text) => problemsOf(before.detail).includes(text.trim()));
21958
+ const isNew = (finding) => {
21959
+ const before = unfixedOn(finding);
21960
+ return before === undefined || movedApart.has(before.id) || severityRank[finding.severity] < severityRank[before.severity] || finding.severity === "blocker" && (withdrawn.has(before.id) || caseOf(cases, finding) !== undefined) && !saysAgain(before, finding);
21961
+ };
21962
+ const isNewApart = (finding) => {
21963
+ const before = unfixedOn(finding);
21964
+ return before === undefined || movedApart.has(before.id) || severityRank[finding.severity] < severityRank[before.severity] || !saysAgain(before, finding);
21577
21965
  };
21578
- const merged = (approvedCode) => groupedByRule(Object.fromEntries(outputs.map(([seat, output]) => [
21966
+ const seatFindings = (holds) => Object.fromEntries(outputs.map(([seat, output]) => [
21579
21967
  seat,
21580
- output.findings.map((finding) => fixRound(input) ? outsideFixAsMinor(finding) : finding).filter((finding) => isNew(finding) && (sinceApproval && finding.approvedCode === true) === approvedCode)
21581
- ])));
21582
- const fresh = merged(false).map((finding) => {
21968
+ output.findings.map((finding) => fixRound(input) && !keepsSeverity(finding) ? outsideFixAsMinor(finding) : finding).filter(holds)
21969
+ ]));
21970
+ const takenIds = new Set(earlierById.keys());
21971
+ const merged = (holds) => groupedByRule(seatFindings((finding) => isNew(finding) && holds(finding)), cases, takenIds);
21972
+ const ownFinding = (finding) => {
21973
+ const id = ownId(finding.id, takenIds);
21974
+ takenIds.add(id);
21975
+ return { ...finding, id };
21976
+ };
21977
+ const fresh = merged((finding) => groupOf(finding) === "fresh").map((finding) => {
21583
21978
  const before = open.get(finding.id);
21584
- return before === undefined ? finding : withEarlier(finding, before);
21979
+ const rebutted = earlierById.get(finding.id);
21980
+ const worse = (than) => severityRank[finding.severity] < severityRank[than.severity];
21981
+ if (before !== undefined)
21982
+ return worse(before) ? withEarlier(finding, before) : ownFinding(finding);
21983
+ return rebutted !== undefined && withdrawn.has(rebutted.id) && !worse(rebutted) ? ownFinding(finding) : finding;
21585
21984
  });
21586
21985
  const freshIds = new Set(fresh.map((finding) => finding.id));
21587
- const approvedFindings = sinceApproval ? merged(true) : [];
21986
+ const apartOf = (group) => Object.entries(seatFindings((finding) => groupOf(finding) === group && isNewApart(finding))).flatMap(([seat, found]) => found.flatMap((finding) => keptApart({
21987
+ id: idOf(finding),
21988
+ severity: finding.severity,
21989
+ file: finding.file,
21990
+ line: finding.line,
21991
+ detail: detailOf(finding.detail, finding.rule, finding.checked ?? []),
21992
+ seats: [seat],
21993
+ problem: finding.detail
21994
+ }, caseOf(cases, finding) ?? "")));
21995
+ const approvedInScope = merged((finding) => groupOf(finding) === "approvedCode");
21996
+ const approvedFindings = [
21997
+ ...approvedInScope,
21998
+ ...distinctApart(apartOf("approvedApart"), new Set(approvedInScope.map((finding) => finding.id)))
21999
+ ];
22000
+ const outOfScopeFindings = distinctApart([...listedApart, ...apartOf("outOfScope")]);
21588
22001
  const findings = [...[...open.values()].filter((finding) => !freshIds.has(finding.id)), ...fresh];
21589
22002
  const verdicts = given.map((verdict) => freshIds.has(verdict.findingId) ? { ...verdict, accepted: false } : verdict);
21590
22003
  const blockers = findings.filter(isBlocking);
21591
22004
  const judged = outputs.find(([seat]) => seat === scopeSeat)?.[1].scope;
21592
- const scope = wholeChange(input) ? carriedScope(judged, fixRound(input) ? input.scope : undefined) : undefined;
21593
- 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(" ");
21594
- const text = reviewText(summary, findings, followUps, approvedFindings, notRun, scope?.reported ?? []);
22005
+ const scope = wholeChange(input) ? withUnjudged(carriedScope(judged, earlierScope(input), cases, criteriaOf(input)), requiredCriteriaOf(input)) : undefined;
22006
+ 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.` : outOfScopeFindings.length > 0 ? "No findings in scope: 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(" ");
22007
+ const shownOutOfScope = outOfScopeFindings.map((finding) => ({
22008
+ ...finding,
22009
+ detail: inCase(finding.detail, finding.item)
22010
+ }));
22011
+ const text = reviewText(summary, findings, followUps, approvedFindings, shownOutOfScope, notRun, scope);
22012
+ const apart = {
22013
+ ...approvedFindings.length === 0 ? undefined : { approvedFindings },
22014
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings }
22015
+ };
21595
22016
  const stored = yield* artifact("findings", {
21596
22017
  kind: "review-findings",
21597
22018
  title: "Review findings",
21598
22019
  text,
21599
- data: { findings, followUps, ...approvedFindings.length === 0 ? undefined : { approvedFindings } }
22020
+ data: {
22021
+ findings,
22022
+ followUps,
22023
+ ...apart,
22024
+ ...scope === undefined ? undefined : { scope: { outOfScope: scope.outOfScope ?? [] } }
22025
+ }
21600
22026
  });
21601
22027
  const reviewed = {
21602
22028
  summary,
@@ -21605,7 +22031,7 @@ var review_default = defineLoop({
21605
22031
  verdicts,
21606
22032
  blocking: findings.some(isBlocking),
21607
22033
  artifactId: stored.artifactId,
21608
- ...approvedFindings.length === 0 ? undefined : { approvedFindings },
22034
+ ...apart,
21609
22035
  ...scope === undefined ? undefined : { scope },
21610
22036
  ...failing.length === 0 ? undefined : { failing },
21611
22037
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
@@ -21645,6 +22071,7 @@ What next?`,
21645
22071
  maxRounds: 2,
21646
22072
  reviewed: range.head,
21647
22073
  ...findings.length === 0 ? undefined : { earlier: findings },
22074
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings },
21648
22075
  ...scope === undefined ? undefined : { scope },
21649
22076
  ...ownDeliveryTarget(input)
21650
22077
  });
@@ -22209,6 +22636,7 @@ var ShepherdOutput = Struct({
22209
22636
  branch: optional2(String5),
22210
22637
  reviewed: optional2(String5),
22211
22638
  earlier: optional2(ArraySchema(MergedFinding)),
22639
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
22212
22640
  scope: optional2(ReviewedScope)
22213
22641
  }))
22214
22642
  });
@@ -22399,7 +22827,7 @@ var repliesPrompt = (threads) => [
22399
22827
  var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
22400
22828
  var shepherd_default = defineLoop({
22401
22829
  id: "shepherd",
22402
- version: "1.10.0",
22830
+ version: "1.11.0",
22403
22831
  title: "Shepherd",
22404
22832
  input: Input3,
22405
22833
  output: Output3,
@@ -22436,6 +22864,7 @@ var shepherd_default = defineLoop({
22436
22864
  const leftToPerson = new Set;
22437
22865
  let headFindings = [];
22438
22866
  let headFindingsAt;
22867
+ let outOfScopeFindings = [];
22439
22868
  let headScope;
22440
22869
  const unranAt = new Map;
22441
22870
  const rounds = { "ci-fix": 0, "head-fix": 0 };
@@ -22511,7 +22940,8 @@ var shepherd_default = defineLoop({
22511
22940
  ${open}`,
22512
22941
  ...input.taskId === undefined ? undefined : { taskId: input.taskId },
22513
22942
  ...target === "HEAD" ? undefined : { branch: target },
22514
- ...review
22943
+ ...review,
22944
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings }
22515
22945
  }
22516
22946
  });
22517
22947
  const takeTurn = () => gen2(function* () {
@@ -22745,11 +23175,14 @@ ${open}`,
22745
23175
  const reviewed = yield* call(`review:${cycle}`, reviewLoop(), {
22746
23176
  base: `origin/${target}`,
22747
23177
  head,
23178
+ deliveredBy: changeRequestId,
22748
23179
  files: files.files,
22749
23180
  ...head === files.synced ? undefined : { since: files.synced },
22750
23181
  ...files.earlier.length === 0 ? undefined : { earlier: files.earlier },
22751
- ...files.reviewed === undefined ? undefined : { reviewed: files.reviewed }
23182
+ ...files.reviewed === undefined ? undefined : { reviewed: files.reviewed },
23183
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings }
22752
23184
  });
23185
+ outOfScopeFindings = reviewed.outOfScopeFindings ?? [];
22753
23186
  if (reviewed.blocking) {
22754
23187
  const blocking = reviewed.findings.filter(isBlocking);
22755
23188
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
@@ -22810,12 +23243,15 @@ ${open}`,
22810
23243
  const reviewed = yield* call(`head-review:${cycle}`, reviewLoop(), {
22811
23244
  base: `origin/${target}`,
22812
23245
  head,
23246
+ deliveredBy: changeRequestId,
22813
23247
  ...notRun.length === 0 ? undefined : { notRun },
22814
23248
  ...since === undefined ? undefined : { approved: since },
22815
23249
  ...headFindings.length === 0 ? undefined : { earlier: headFindings },
22816
23250
  ...headFindingsAt === undefined ? undefined : { reviewed: headFindingsAt },
23251
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings },
22817
23252
  ...headScope === undefined ? undefined : { scope: headScope }
22818
23253
  });
23254
+ outOfScopeFindings = reviewed.outOfScopeFindings ?? [];
22819
23255
  if (reviewed.blocking) {
22820
23256
  const blocking = reviewed.findings.filter(isBlocking);
22821
23257
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
@@ -23298,6 +23734,8 @@ var BuildInput = Struct({
23298
23734
  maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0))),
23299
23735
  reviewed: optional2(String5),
23300
23736
  earlier: optional2(ArraySchema(MergedFinding)),
23737
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
23738
+ taskOutOfScope: optional2(ArraySchema(String5)),
23301
23739
  scope: optional2(ReviewedScope),
23302
23740
  planReviewed: optional2(Boolean3),
23303
23741
  ...DeliveryFields
@@ -23305,7 +23743,8 @@ var BuildInput = Struct({
23305
23743
  var CriterionAnswer = Struct({
23306
23744
  criterion: String5,
23307
23745
  status: Literals(["met", "after_merge", "not_met"]),
23308
- detail: ShortStatement
23746
+ detail: ShortStatement,
23747
+ ...outOfScopeCase
23309
23748
  });
23310
23749
  var Criteria = Struct({ criteria: ArraySchema(CriterionAnswer) });
23311
23750
  var SuggestedCheck = Struct({
@@ -23347,6 +23786,7 @@ var BuildOutput = Struct({
23347
23786
  criteria: ArraySchema(CriterionAnswer),
23348
23787
  notRun: optional2(ArraySchema(String5)),
23349
23788
  findings: optional2(ArraySchema(MergedFinding)),
23789
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
23350
23790
  scope: optional2(ReviewedScope),
23351
23791
  blockingCounts: optional2(ArraySchema(Int)),
23352
23792
  approval: optional2(ApproveChangeRequestResult),
@@ -23384,27 +23824,67 @@ class BuildOutcomeRefused extends TaggedError3()("BuildOutcomeRefused", {
23384
23824
  }) {
23385
23825
  }
23386
23826
  var criteriaGuidance = "If your brief has a Task, answer each of its acceptance criteria in `criteria`: met, with the test or file that shows it; after_merge, with why it can only be seen once merged; or not_met, with why. Give an empty `criteria` when the Task has none.";
23827
+ var outOfScopeGuidance = (cases) => cases.length === 0 ? [] : [
23828
+ [
23829
+ "The Task's Out of scope list is these numbered cases. Do not build them: Review reports a problem in one without holding the change for it, unless it is a blocker, such as a security hole or lost data.",
23830
+ ...numberedCases(cases),
23831
+ "A criterion that is not met only because it falls in one of these is not_met, with `outOfScope` set to the case's number; Review says whether it agrees."
23832
+ ].join(`
23833
+ `)
23834
+ ];
23387
23835
  var checksGuidance = "If your brief lists no approved verifications for this repository, name in `checks` the commands from its package scripts or CI config that test, lint and typecheck it, each with a `name` of letters, digits, `.`, `_`, `:` and `-` only, such as `unit-tests`; Kitman runs them and labels them as suggested by you.";
23388
23836
  var implementAdaptation = "You run the implement skill as a Kitman Step. The work is in this prompt and your brief, so fetch no ticket. Leave your changes uncommitted: the Run owns the branch. Skip its final code-review: a Review run or a person reviews the change.";
23389
- var implementPrompt = (task, outcome, continuing) => [
23837
+ var implementPrompt = (task, outcome, continuing, cases) => [
23390
23838
  ...continuing === undefined ? [] : [continuingBrief(continuing), "Fix forward from there."],
23391
23839
  `Build ${task}`,
23392
23840
  implementAdaptation,
23393
23841
  ...outcome === undefined ? [] : [outcomeGuidance[outcome]],
23394
23842
  'Commit nothing yourself: Kitman pushes what you leave in the workspace. Give the ChangeRequest a title and a summary, and list as claims what you believe but Kitman has not checked, such as "the tests pass".',
23843
+ ...outOfScopeGuidance(cases),
23395
23844
  criteriaGuidance,
23396
23845
  checksGuidance
23397
23846
  ].join(`
23398
23847
 
23399
23848
  `);
23400
- var criteriaPrompt = (unanswered, unmet) => [
23849
+ var criteriaPrompt = (unanswered, unmet, cases) => [
23401
23850
  unanswered ? "You did not answer the Task's acceptance criteria. Answer each one before anyone reviews the change." : "These acceptance criteria are not met yet. Meet them, or say why they cannot be met here, such as an answer under Answers so far that put them out of scope; do not ask that Question again:",
23402
23851
  ...unmet.map((answer) => `- ${answer.criterion}: ${answer.detail}`),
23852
+ ...outOfScopeGuidance(cases),
23403
23853
  criteriaGuidance
23404
23854
  ].join(`
23405
23855
 
23406
23856
  `);
23407
- var answerLine = (answer) => `${answer.criterion}: ${answer.status.replaceAll("_", " ")}, ${answer.detail}`;
23857
+ var answerLine = (answer, cases) => {
23858
+ const line = `${answer.criterion}: ${answer.status.replaceAll("_", " ")}, ${answer.detail}`;
23859
+ const item = answer.status === "not_met" ? caseOf(cases, answer) : undefined;
23860
+ return item === undefined ? line : `${line} (proposed Out of scope: ${item})`;
23861
+ };
23862
+ var reviewedAs = (criterion, cases, scope) => {
23863
+ if (cases.length === 0 || scope === undefined)
23864
+ return;
23865
+ const judged = scope.criteria?.find((entry) => entry.criterion === criterion);
23866
+ if (judged?.status === "open" || scope.unmet.includes(criterion))
23867
+ return { status: "open" };
23868
+ if (judged?.status === "met")
23869
+ return { status: "met" };
23870
+ if (judged?.status === "reported" || scope.reported?.includes(criterion))
23871
+ return { status: "reported" };
23872
+ const item = judged?.item ?? scope.outOfScope?.find((entry) => entry.part === criterion)?.item;
23873
+ return item !== undefined && cases.includes(item) ? { status: "out_of_scope", item } : undefined;
23874
+ };
23875
+ var criterionLine = (answer, cases, scope) => {
23876
+ const final = reviewedAs(answer.criterion, cases, scope);
23877
+ const answered = `answered ${answer.status.replaceAll("_", " ")}: ${answer.detail}`;
23878
+ if (final === undefined || final.status === "met" && answer.status === "met")
23879
+ return answerLine(answer, cases);
23880
+ if (final.status === "open")
23881
+ return answer.status === "not_met" ? answerLine(answer, cases) : `${answer.criterion}: not met, as Review judged it (${answered})`;
23882
+ if (final.status === "met")
23883
+ return `${answer.criterion}: met, as Review judged it (${answered})`;
23884
+ if (final.status === "reported")
23885
+ return `${answer.criterion}: out of scope by an answer (${answered})`;
23886
+ return answer.status === "not_met" ? inCase(`${answer.criterion}: not met, ${answer.detail}`, final.item) : inCase(`${answer.criterion}: not done, as Review judged it (${answered})`, final.item);
23887
+ };
23408
23888
  var reproducingCheckGuidance = "Give in `check` the command that runs only that test, with a `name` of letters, digits, `.`, `_`, `:` and `-` that no approved verification of the repository has, unless it is exactly that approved check. Kitman runs it before the fix, where it must fail, and on every head after, where it must pass.";
23409
23889
  var reproducePrompt = (task) => [
23410
23890
  `Reproduce the bug in ${task} before anyone fixes it.`,
@@ -23456,6 +23936,7 @@ var rally = (input) => gen2(function* () {
23456
23936
  const blockingCounts = [];
23457
23937
  let rebuttals = [];
23458
23938
  let earlier = input.earlier;
23939
+ let outOfScope = input.outOfScope;
23459
23940
  let previous;
23460
23941
  let last;
23461
23942
  const shown = new Set;
@@ -23484,6 +23965,7 @@ var rally = (input) => gen2(function* () {
23484
23965
  head,
23485
23966
  decision: { stop: true, reason: "findings_returned", unsettled: blockingIds(last.settled) },
23486
23967
  claims,
23968
+ outOfScope,
23487
23969
  conflicts,
23488
23970
  earlier,
23489
23971
  blockingCounts
@@ -23494,15 +23976,21 @@ var rally = (input) => gen2(function* () {
23494
23976
  const reviewed = yield* call(`review:${round}`, review_default, {
23495
23977
  base,
23496
23978
  head: head.revision,
23979
+ ...input.deliveredBy === undefined ? undefined : { deliveredBy: input.deliveredBy },
23497
23980
  ...rebuttals.length === 0 ? undefined : { rebuttals },
23498
23981
  ...earlier.length === 0 ? undefined : { earlier },
23499
23982
  ...last === undefined ? input.reviewed === undefined ? undefined : { reviewed: input.reviewed } : { reviewed: last.head.revision },
23983
+ ...outOfScope.length === 0 ? undefined : { outOfScopeFindings: outOfScope },
23984
+ ...input.unmetCriteria.length === 0 ? undefined : { unmetCriteria: input.unmetCriteria },
23985
+ ...input.metCriteria.length === 0 ? undefined : { metCriteria: input.metCriteria },
23986
+ ...input.afterMergeCriteria.length === 0 ? undefined : { afterMergeCriteria: input.afterMergeCriteria },
23500
23987
  ...scope === undefined ? undefined : { scope },
23501
23988
  ...input.outcome === undefined ? undefined : { outcome: input.outcome },
23502
23989
  ...failing.length === 0 ? undefined : { failing },
23503
23990
  ...notRun.length === 0 ? undefined : { notRun },
23504
23991
  claims: [...claims]
23505
23992
  });
23993
+ outOfScope = reviewed.outOfScopeFindings ?? [];
23506
23994
  const checks = checkFindings(head);
23507
23995
  const settled = settleRound({
23508
23996
  findings: [...reviewed.findings, ...scopeFindings(reviewed.scope), ...checks],
@@ -23526,6 +24014,7 @@ var rally = (input) => gen2(function* () {
23526
24014
  decision,
23527
24015
  claims,
23528
24016
  scope: reviewed.scope,
24017
+ outOfScope,
23529
24018
  conflicts,
23530
24019
  earlier,
23531
24020
  blockingCounts
@@ -23549,7 +24038,7 @@ var rally = (input) => gen2(function* () {
23549
24038
  });
23550
24039
  var build2 = defineLoop({
23551
24040
  id: "build",
23552
- version: "2.12.0",
24041
+ version: "2.13.0",
23553
24042
  title: "Build",
23554
24043
  input: BuildInput,
23555
24044
  output: BuildOutput,
@@ -23573,6 +24062,7 @@ var build2 = defineLoop({
23573
24062
  yield* writeBack("write-back:started", { milestone: "started" });
23574
24063
  const task = input.words === undefined ? "the Task your brief describes." : `this: ${input.words}`;
23575
24064
  const outcome = input.outcome;
24065
+ const cases = listedCases(input.taskOutOfScope);
23576
24066
  const epic = epicOf(input);
23577
24067
  const target = input.continuing?.targetBranch ?? input.branch ?? epic?.branch;
23578
24068
  if (epic !== undefined && input.continuing === undefined && input.branch === undefined)
@@ -23593,25 +24083,30 @@ var build2 = defineLoop({
23593
24083
  const implemented = yield* agentWorkOnce("implement", {
23594
24084
  agent: input.planReviewed === true ? "planned-implementer" : "implementer",
23595
24085
  skill: "implement",
23596
- prompt: implementPrompt(task, outcome, input.continuing),
24086
+ prompt: implementPrompt(task, outcome, input.continuing, cases),
23597
24087
  output: Implemented
23598
24088
  });
23599
24089
  const unanswered = input.taskId !== undefined && implemented.criteria === undefined;
23600
- const unmet = (implemented.criteria ?? []).filter((answer) => answer.status === "not_met");
24090
+ const unmet = (implemented.criteria ?? []).filter((answer) => answer.status === "not_met" && caseOf(cases, answer) === undefined);
23601
24091
  const criteria = unanswered || unmet.length > 0 ? (yield* agentWorkOnce("criteria", {
23602
24092
  agent: "implementer",
23603
- prompt: criteriaPrompt(unanswered, unmet),
24093
+ prompt: criteriaPrompt(unanswered, unmet, cases),
23604
24094
  output: Criteria
23605
24095
  })).criteria : implemented.criteria ?? [];
23606
24096
  const last = yield* rally({
23607
24097
  maxRounds: input.maxRounds ?? 3,
23608
24098
  target,
23609
24099
  outcome,
23610
- claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer)}`)],
24100
+ claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer, cases)}`)],
23611
24101
  suggested: implemented.checks ?? [],
23612
24102
  reproducing: reproduced?.check,
23613
24103
  reviewed: input.reviewed,
24104
+ deliveredBy: input.changeRequestId,
23614
24105
  earlier: input.earlier ?? [],
24106
+ outOfScope: input.outOfScopeFindings ?? [],
24107
+ unmetCriteria: cases.length === 0 ? [] : criteria.flatMap((answer) => answer.status === "not_met" ? [answer.criterion] : []),
24108
+ metCriteria: cases.length === 0 ? [] : criteria.flatMap((answer) => answer.status === "met" ? [answer.criterion] : []),
24109
+ afterMergeCriteria: cases.length === 0 ? [] : criteria.flatMap((answer) => answer.status === "after_merge" ? [answer.criterion] : []),
23615
24110
  scope: input.scope
23616
24111
  });
23617
24112
  const verdict = evidenceGate({
@@ -23630,7 +24125,7 @@ var build2 = defineLoop({
23630
24125
  ...brokenChecks(last.head).map((check) => failsOn("head", check, last.head.tree)),
23631
24126
  ...unsettledItems(last.settled, last.decision),
23632
24127
  ...last.conflicts,
23633
- ...criteria.flatMap((answer) => answer.status === "not_met" ? [`Criterion not met: ${answer.criterion} (${answer.detail})`] : [])
24128
+ ...criteria.flatMap((answer) => answer.status === "not_met" && (reviewedAs(answer.criterion, cases, last.scope)?.status ?? "open") === "open" ? [`Criterion not met: ${answer.criterion} (${answer.detail})`] : [])
23634
24129
  ])
23635
24130
  ];
23636
24131
  const body = changeRequestBody({
@@ -23638,8 +24133,9 @@ var build2 = defineLoop({
23638
24133
  head: last.head,
23639
24134
  claims: last.claims,
23640
24135
  unsettled,
23641
- criteria: criteria.map(answerLine),
24136
+ criteria: criteria.map((answer) => criterionLine(answer, cases, last.scope)),
23642
24137
  later: last.settled.open.filter((finding) => !isBlocking(finding)).map((finding) => `${finding.id}: ${finding.detail}`),
24138
+ outOfScope: outOfScopeLines(last.outOfScope, last.scope),
23643
24139
  rounds: last.round,
23644
24140
  stopped: last.decision.reason
23645
24141
  });
@@ -23663,6 +24159,7 @@ var build2 = defineLoop({
23663
24159
  criteria,
23664
24160
  ...lastNotRun.length === 0 ? undefined : { notRun: lastNotRun },
23665
24161
  ...last.earlier.length === 0 ? undefined : { findings: last.earlier },
24162
+ ...last.outOfScope.length === 0 ? undefined : { outOfScopeFindings: last.outOfScope },
23666
24163
  ...last.scope === undefined ? undefined : { scope: last.scope },
23667
24164
  blockingCounts: last.blockingCounts,
23668
24165
  ...approval === undefined ? undefined : { approval }
@@ -23728,6 +24225,7 @@ var build2 = defineLoop({
23728
24225
  land: false,
23729
24226
  reviewed: settledAs.revision,
23730
24227
  ...settledAs.findings === undefined ? undefined : { earlier: settledAs.findings },
24228
+ ...settledAs.outOfScopeFindings === undefined ? undefined : { outOfScopeFindings: settledAs.outOfScopeFindings },
23731
24229
  ...settledAs.scope === undefined ? undefined : { scope: settledAs.scope },
23732
24230
  ...ownDeliveryTarget(input)
23733
24231
  }, { constraints: standing.map(standingConstraint) });
@@ -24143,7 +24641,7 @@ var steadier = (plan) => {
24143
24641
  };
24144
24642
  var hillclimb_default = defineLoop({
24145
24643
  id: "hillclimb",
24146
- version: "1.5.0",
24644
+ version: "1.6.0",
24147
24645
  title: "Hillclimb",
24148
24646
  outcome: "performance",
24149
24647
  input: Input5,
@@ -24298,6 +24796,7 @@ var hillclimb_default = defineLoop({
24298
24796
  claims,
24299
24797
  earlier: reviewed.findings,
24300
24798
  reviewed: fixedFrom,
24799
+ ...reviewed.outOfScopeFindings === undefined ? undefined : { outOfScopeFindings: reviewed.outOfScopeFindings },
24301
24800
  ...reviewed.scope === undefined ? undefined : { scope: reviewed.scope }
24302
24801
  });
24303
24802
  }
@@ -24326,7 +24825,8 @@ ${harness.summary}
24326
24825
  ...unsettled.length + caveats.length === 0 ? [] : [`## Unsettled
24327
24826
 
24328
24827
  ${[...unsettled, ...caveats].map((entry) => `- ${entry}`).join(`
24329
- `)}`]
24828
+ `)}`],
24829
+ ...outOfScopeSection(outOfScopeLines(reviewed.outOfScopeFindings ?? [], reviewed.scope))
24330
24830
  ].join(`
24331
24831
 
24332
24832
  `)
@@ -25841,7 +26341,7 @@ var tidyPrompt = (scope, words) => [
25841
26341
  var areaOf = (revision, branch) => `in the area of the change at ${revision}: only the files that \`git diff $(git merge-base origin/${branch ?? "HEAD"} ${revision}) ${revision}\` touches, and the files that change with them`;
25842
26342
  var tidy_default = defineLoop({
25843
26343
  id: "tidy",
25844
- version: "1.0.0",
26344
+ version: "1.1.0",
25845
26345
  title: "Tidy",
25846
26346
  input: Input12,
25847
26347
  output: Output13,
@@ -25883,6 +26383,7 @@ var tidy_default = defineLoop({
25883
26383
  head,
25884
26384
  claims: improvement.claims,
25885
26385
  unsettled,
26386
+ outOfScope: outOfScopeLines(reviewed.outOfScopeFindings ?? [], reviewed.scope),
25886
26387
  rounds: 1,
25887
26388
  stopped: decision.stop ? decision.reason : "round_cap"
25888
26389
  })
@@ -31825,4 +32326,4 @@ var runKit = (config, identity, packages) => {
31825
32326
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31826
32327
  };
31827
32328
  // .kitman-build-entry.ts
31828
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.15" }, []);
32329
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.17" }, []);