@kitman-sh/software-engineering 0.13.16 → 0.13.18

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
@@ -13434,6 +13434,50 @@ var AttemptTokens = Union2([TokenUsage, Literal2("none")]);
13434
13434
  var TokenTotalCount = String5.check(isPattern2(/^(?:0|[1-9][0-9]*)$/));
13435
13435
  var TokenTotal = Struct({ input: TokenTotalCount, output: TokenTotalCount, cached: TokenTotalCount });
13436
13436
 
13437
+ // ../../packages/core/src/test-report.ts
13438
+ var maxSkippedTests = 1e4;
13439
+ var maxRanDigests = 1e5;
13440
+ var TestId = String5.check(isMinLength(1), isMaxLength(1000));
13441
+ var maxFailedTests = 50;
13442
+ var maxFailedTestLength = 300;
13443
+ var FailedTests = ArraySchema(String5.check(isMinLength(1), isMaxLength(maxFailedTestLength))).check(isMaxLength(maxFailedTests));
13444
+ var EnvironmentFailure = Struct({
13445
+ failedTests: optionalKey2(FailedTests),
13446
+ exitCode: optionalKey2(Int),
13447
+ outputTail: optionalKey2(String5.check(isMaxLength(8000))),
13448
+ retryFailedTests: optionalKey2(FailedTests)
13449
+ });
13450
+ var CheckTests = Struct({
13451
+ reports: Int.check(isGreaterThanOrEqualTo2(0)),
13452
+ passed: Int.check(isGreaterThanOrEqualTo2(0)),
13453
+ failed: Int.check(isGreaterThanOrEqualTo2(0)),
13454
+ skipped: Int.check(isGreaterThanOrEqualTo2(0)),
13455
+ skippedTests: ArraySchema(TestId).check(isMaxLength(maxSkippedTests)),
13456
+ ranDigests: ArraySchema(String5.check(isMaxLength(16))).check(isMaxLength(maxRanDigests)),
13457
+ failedTests: optionalKey2(FailedTests),
13458
+ environmentFailure: optionalKey2(EnvironmentFailure),
13459
+ environmentJudged: optionalKey2(Boolean3)
13460
+ });
13461
+ var entities = new Map([
13462
+ ["amp", "&"],
13463
+ ["lt", "<"],
13464
+ ["gt", ">"],
13465
+ ["quot", '"'],
13466
+ ["apos", "'"]
13467
+ ]);
13468
+ var failedFileStart = String.raw`FAIL +(?:\|[^|]+\| *)?(?! )(?!\S*:\/\/)`;
13469
+ var afterPath = String.raw` > | \[ `;
13470
+ var failedFilePaths = [
13471
+ String.raw`\S*\.[A-Za-z]\w*(?=[\s:]|$)`,
13472
+ String.raw`(?=\S*[A-Za-z])(?=\S*\/)\S+(?=${afterPath}|$)`,
13473
+ String.raw`(?:(?!${afterPath}).)*\.[A-Za-z]\w*(?=${afterPath})`,
13474
+ String.raw`(?=\S*\/)(?:(?!${afterPath}).)*\.[A-Za-z]\w*$`,
13475
+ String.raw`(?=.*(?:\.(?:test|spec)\.|\b__tests__\/))(?:(?!${afterPath}).)*\.[cm]?[jt]sx?$`
13476
+ ];
13477
+ var failedFileLine = new RegExp(`^${failedFileStart}((?:${failedFilePaths.join("|")}).*)$`, "su");
13478
+ var attempt = String.raw`(?:\d+ times in )?(?:initial run|\d+[a-z]{2} (?:retry(?: of \d+[a-z]{2} repeat)?|repeat))`;
13479
+ var vitestAttempts = new RegExp(String.raw` \(${attempt}(?:, ${attempt})*\)$`, "u");
13480
+
13437
13481
  // ../../packages/core/src/loop.ts
13438
13482
  var LoopStatuses = ["draft", "active", "disabled", "archived"];
13439
13483
  var LoopStepImplementationKinds = [
@@ -14006,6 +14050,7 @@ var RunEvidence = Struct({
14006
14050
  failedTests: optionalKey2(ArraySchema(String5)),
14007
14051
  skippedSinceBaseline: optionalKey2(ArraySchema(String5)),
14008
14052
  newNotRun: optionalKey2(ArraySchema(String5)),
14053
+ environmentFailure: optionalKey2(EnvironmentFailure),
14009
14054
  recordedAt: Timestamp
14010
14055
  });
14011
14056
  var ApprovedVerification = Struct({
@@ -19051,7 +19096,13 @@ var EvidenceCheck = Struct({
19051
19096
  failedTests: optionalKey2(ArraySchema(String5)),
19052
19097
  suggested: optionalKey2(Boolean3),
19053
19098
  skippedSinceBaseline: optionalKey2(ArraySchema(String5)),
19054
- newNotRun: optionalKey2(ArraySchema(String5))
19099
+ newNotRun: optionalKey2(ArraySchema(String5)),
19100
+ environmentFailure: optionalKey2(Struct({
19101
+ failedTests: optionalKey2(ArraySchema(String5)),
19102
+ exitCode: optionalKey2(Int),
19103
+ outputTail: optionalKey2(String5),
19104
+ retryFailedTests: optionalKey2(ArraySchema(String5))
19105
+ }))
19055
19106
  });
19056
19107
  var VerifyResult = Struct({
19057
19108
  revision: String5,
@@ -20136,41 +20187,6 @@ var NetworkHostQuery = Struct({
20136
20187
  repoBindingId: optionalKey2(Id)
20137
20188
  });
20138
20189
 
20139
- // ../../packages/core/src/test-report.ts
20140
- var maxSkippedTests = 1e4;
20141
- var maxRanDigests = 1e5;
20142
- var TestId = String5.check(isMinLength(1), isMaxLength(1000));
20143
- var maxFailedTests = 50;
20144
- var maxFailedTestLength = 300;
20145
- var CheckTests = Struct({
20146
- reports: Int.check(isGreaterThanOrEqualTo2(0)),
20147
- passed: Int.check(isGreaterThanOrEqualTo2(0)),
20148
- failed: Int.check(isGreaterThanOrEqualTo2(0)),
20149
- skipped: Int.check(isGreaterThanOrEqualTo2(0)),
20150
- skippedTests: ArraySchema(TestId).check(isMaxLength(maxSkippedTests)),
20151
- ranDigests: ArraySchema(String5.check(isMaxLength(16))).check(isMaxLength(maxRanDigests)),
20152
- failedTests: optionalKey2(ArraySchema(String5.check(isMinLength(1), isMaxLength(maxFailedTestLength))).check(isMaxLength(maxFailedTests)))
20153
- });
20154
- var entities = new Map([
20155
- ["amp", "&"],
20156
- ["lt", "<"],
20157
- ["gt", ">"],
20158
- ["quot", '"'],
20159
- ["apos", "'"]
20160
- ]);
20161
- var failedFileStart = String.raw`FAIL +(?:\|[^|]+\| *)?(?! )(?!\S*:\/\/)`;
20162
- var afterPath = String.raw` > | \[ `;
20163
- var failedFilePaths = [
20164
- String.raw`\S*\.[A-Za-z]\w*(?=[\s:]|$)`,
20165
- String.raw`(?=\S*[A-Za-z])(?=\S*\/)\S+(?=${afterPath}|$)`,
20166
- String.raw`(?:(?!${afterPath}).)*\.[A-Za-z]\w*(?=${afterPath})`,
20167
- String.raw`(?=\S*\/)(?:(?!${afterPath}).)*\.[A-Za-z]\w*$`,
20168
- String.raw`(?=.*(?:\.(?:test|spec)\.|\b__tests__\/))(?:(?!${afterPath}).)*\.[cm]?[jt]sx?$`
20169
- ];
20170
- var failedFileLine = new RegExp(`^${failedFileStart}((?:${failedFilePaths.join("|")}).*)$`, "su");
20171
- var attempt = String.raw`(?:\d+ times in )?(?:initial run|\d+[a-z]{2} (?:retry(?: of \d+[a-z]{2} repeat)?|repeat))`;
20172
- var vitestAttempts = new RegExp(String.raw` \(${attempt}(?:, ${attempt})*\)$`, "u");
20173
-
20174
20190
  // ../../packages/core/src/work-unit.ts
20175
20191
  var WorkUnitLease = Struct({
20176
20192
  leaseOwnerId: Id,
@@ -21101,6 +21117,25 @@ var readPlanReview = (answer, revision, markdown) => {
21101
21117
  return { revision, comments: [{ id: "words", body: answer.trim() }] };
21102
21118
  return { revision, comments: decoded.value.planReview.comments.map((comment) => placed(comment, markdown)) };
21103
21119
  };
21120
+ // src/out-of-scope.ts
21121
+ var outOfScopeCase = { outOfScope: optional2(Int) };
21122
+ var listedCases = (cases) => (cases ?? []).filter((item) => item.trim() !== "");
21123
+ var caseOf = (cases, marked) => marked.outOfScope === undefined ? undefined : cases[marked.outOfScope - 1];
21124
+ var numberedCases = (cases) => cases.map((item, index) => `${index + 1}. ${item}`);
21125
+ var inCase = (text, item) => `${text} (Out of scope: ${item})`;
21126
+ var OutOfScopeFinding = Struct({
21127
+ ...MergedFinding.fields,
21128
+ severity: Literals(["major", "minor"]),
21129
+ item: String5,
21130
+ problem: optionalKey2(String5)
21131
+ });
21132
+ var outOfScopeLines = (findings, scope) => [
21133
+ ...findings.map((finding) => `${finding.id} (${finding.severity}): ${inCase(finding.detail, finding.item)}`),
21134
+ ...(scope?.outOfScope ?? []).map(({ part, item }) => inCase(part, item))
21135
+ ];
21136
+ var outOfScopeSection = (lines) => lines.length === 0 ? [] : ["## Out of scope", lines.map((line) => `- ${line}`).join(`
21137
+ `)];
21138
+
21104
21139
  // src/change-request-body.ts
21105
21140
  var scopeFindings = (scope) => (scope?.unmet ?? []).map((item) => ({
21106
21141
  id: `scope: ${item}`,
@@ -21185,6 +21220,7 @@ var changeRequestBody = (build) => [
21185
21220
  "## Unsettled",
21186
21221
  ...unsettledLines(build.unsettled, build.head),
21187
21222
  ...build.later === undefined || build.later.length === 0 ? [] : ["## Left for later", ...build.later.map((item) => `- ${item}`)],
21223
+ ...outOfScopeSection(build.outOfScope ?? []),
21188
21224
  "## Review",
21189
21225
  `${build.rounds} review round${build.rounds === 1 ? "" : "s"}; the rally stopped: ${build.stopped.replaceAll("_", " ")}.`
21190
21226
  ].join(`
@@ -21221,9 +21257,16 @@ var deliveryLayerWords = {
21221
21257
  };
21222
21258
 
21223
21259
  // src/reviewed-scope.ts
21260
+ var CriterionDisposition = Struct({
21261
+ criterion: String5,
21262
+ status: Literals(["met", "open", "out_of_scope", "reported"]),
21263
+ item: optionalKey2(String5)
21264
+ });
21224
21265
  var ReviewedScope = Struct({
21225
21266
  ...ScopeJudgement.fields,
21226
- reported: optional2(ArraySchema(String5))
21267
+ reported: optional2(ArraySchema(String5)),
21268
+ outOfScope: optional2(ArraySchema(Struct({ part: String5, item: String5 }))),
21269
+ criteria: optional2(ArraySchema(CriterionDisposition))
21227
21270
  });
21228
21271
 
21229
21272
  // src/text-limits.ts
@@ -21251,6 +21294,7 @@ var scopeSeat = "code-review";
21251
21294
  var choices = ["Post to the ChangeRequest", "Fix here", "Build from it", "Done"];
21252
21295
  var Input = Struct({
21253
21296
  changeRequestId: optional2(String5),
21297
+ deliveredBy: optional2(String5),
21254
21298
  base: optional2(String5),
21255
21299
  head: optional2(String5),
21256
21300
  files: optional2(ArraySchema(String5)),
@@ -21264,38 +21308,144 @@ var Input = Struct({
21264
21308
  scope: optional2(ReviewedScope),
21265
21309
  failing: optional2(ArraySchema(String5)),
21266
21310
  notRun: optional2(ArraySchema(String5)),
21311
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
21312
+ unmetCriteria: optional2(ArraySchema(String5)),
21313
+ metCriteria: optional2(ArraySchema(String5)),
21314
+ afterMergeCriteria: optional2(ArraySchema(String5)),
21315
+ taskOutOfScope: optional2(ArraySchema(String5)),
21267
21316
  next: optional2(Literals(choices)),
21268
21317
  ...DeliveryFields
21269
21318
  });
21270
21319
  var FollowUpStatus = Literals(["fixed", "changed", "still_there"]);
21271
21320
  var FollowUp = Struct({ id: String5, status: FollowUpStatus });
21321
+ var SeatFollowUp = Struct({
21322
+ ...FollowUp.fields,
21323
+ severity: optional2(Finding.fields.severity),
21324
+ ...outOfScopeCase
21325
+ });
21272
21326
  var SeatFinding = Struct({
21273
21327
  ...Finding.fields,
21274
21328
  detail: FindingDetail,
21275
21329
  approvedCode: optional2(Boolean3),
21276
21330
  rule: optional2(OneSentence),
21277
21331
  checked: optional2(ArraySchema(ShortStatement)),
21278
- outsideFix: optional2(Boolean3)
21332
+ outsideFix: optional2(Boolean3),
21333
+ ...outOfScopeCase
21279
21334
  });
21280
- var agreedScope = (scope) => scope.unmet.length === 0 && (scope.reported ?? []).length > 0 ? { ...scope, met: true } : scope;
21281
- var carriedScope = (judged, earlier) => {
21282
- if (judged === undefined)
21283
- return earlier;
21284
- const scope = agreedScope(judged);
21285
- const reported = [...new Set([...earlier?.reported ?? [], ...scope.reported ?? []])].filter((item) => !scope.unmet.includes(item));
21286
- return earlier === undefined || reported.length === 0 ? scope : { ...scope, reported };
21335
+ var isText = is2(String5);
21336
+ var SeatUnmet = Union2([
21337
+ String5,
21338
+ Struct({
21339
+ part: String5,
21340
+ criterion: optional2(Int),
21341
+ ...outOfScopeCase
21342
+ })
21343
+ ]);
21344
+ var SeatScope = Struct({
21345
+ ...ScopeJudgement.fields,
21346
+ unmet: ArraySchema(SeatUnmet),
21347
+ reported: optional2(ArraySchema(String5)),
21348
+ criteria: optional2(ArraySchema(Struct({
21349
+ criterion: Int,
21350
+ met: optional2(Boolean3),
21351
+ reported: optional2(Boolean3),
21352
+ ...outOfScopeCase
21353
+ })))
21354
+ });
21355
+ var dispositionsOf = (judged, cases, unmetCriteria, reportedByAnswer) => {
21356
+ const byCriterion = new Map;
21357
+ for (const entry of judged) {
21358
+ const criterion = unmetCriteria[entry.criterion - 1];
21359
+ if (criterion === undefined)
21360
+ continue;
21361
+ const item = caseOf(cases, entry);
21362
+ 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 };
21363
+ const known = byCriterion.get(criterion);
21364
+ byCriterion.set(criterion, known === undefined || JSON.stringify(known) === JSON.stringify(disposition) ? disposition : { criterion, status: "open" });
21365
+ }
21366
+ return [...byCriterion.values()];
21367
+ };
21368
+ var agreedScope = ({ unmet, criteria = [], reported: seatReported = [], ...scope }, cases, numberedCriteria, earlier) => {
21369
+ const given = unmet.map((entry) => isText(entry) ? { part: entry, item: undefined } : {
21370
+ part: (entry.criterion === undefined ? undefined : numberedCriteria[entry.criterion - 1]) ?? entry.part,
21371
+ item: caseOf(cases, entry)
21372
+ });
21373
+ const numbered = new Set(numberedCriteria);
21374
+ const parts = given.filter(({ part }) => !numbered.has(part));
21375
+ const judgedByNumber = dispositionsOf(criteria, cases, numberedCriteria, seatReported);
21376
+ const named = given.filter(({ part }) => numbered.has(part));
21377
+ const dispositions = [
21378
+ ...judgedByNumber.map((entry) => entry.status === "met" && named.some(({ part }) => part === entry.criterion) ? { criterion: entry.criterion, status: "open" } : entry),
21379
+ ...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" }])
21380
+ ];
21381
+ const criteriaApart = dispositions.flatMap(({ criterion, item }) => item === undefined ? [] : [{ part: criterion, item }]);
21382
+ const marked = [...parts.flatMap(({ part, item }) => item === undefined ? [] : [{ part, item }]), ...criteriaApart];
21383
+ const waivedParts = new Set(marked.map((entry) => entry.part));
21384
+ const left = [
21385
+ ...new Set([
21386
+ ...parts.flatMap(({ part }) => waivedParts.has(part) ? [] : [part]),
21387
+ ...dispositions.flatMap((entry) => entry.status === "open" ? [entry.criterion] : [])
21388
+ ])
21389
+ ];
21390
+ const judgedAgain = new Set([...waivedParts, ...left, ...dispositions.map((entry) => entry.criterion)]);
21391
+ const kept = earlier.filter(({ part }) => !judgedAgain.has(part));
21392
+ const outOfScope = [...kept, ...marked];
21393
+ const byAnswer = dispositions.flatMap((entry) => entry.status === "reported" ? [entry.criterion] : []);
21394
+ const judgedOtherwise = new Set(dispositions.flatMap((entry) => entry.status === "reported" ? [] : [entry.criterion]));
21395
+ const reported = [...new Set([...seatReported, ...byAnswer])].filter((part) => !left.includes(part) && !judgedOtherwise.has(part));
21396
+ const waived = reported.length + marked.length;
21397
+ const strict = cases.length > 0 || unmet.some((entry) => !isText(entry));
21398
+ return {
21399
+ ...scope,
21400
+ ...reported.length === 0 ? undefined : { reported },
21401
+ unmet: left,
21402
+ met: left.length === 0 ? scope.met || waived > 0 : scope.met && !strict,
21403
+ ...outOfScope.length === 0 ? undefined : { outOfScope },
21404
+ ...dispositions.length === 0 ? undefined : { criteria: dispositions }
21405
+ };
21406
+ };
21407
+ var withUnjudged = (scope, unmetCriteria) => {
21408
+ const settled = new Set([
21409
+ ...(scope?.criteria ?? []).map((entry) => entry.criterion),
21410
+ ...(scope?.outOfScope ?? []).map((entry) => entry.part),
21411
+ ...scope?.reported ?? [],
21412
+ ...scope?.unmet ?? []
21413
+ ]);
21414
+ const unjudged = unmetCriteria.filter((criterion) => !settled.has(criterion));
21415
+ return unjudged.length === 0 ? scope : { ...scope, met: false, unmet: [...scope?.unmet ?? [], ...unjudged] };
21416
+ };
21417
+ var carriedScope = (judged, earlier, cases, numberedCriteria) => {
21418
+ if (judged === undefined) {
21419
+ if (earlier === undefined)
21420
+ return;
21421
+ const { criteria: _, ...carried } = earlier;
21422
+ return carried;
21423
+ }
21424
+ const scope = agreedScope(judged, cases, numberedCriteria, earlier?.outOfScope ?? []);
21425
+ const judgedOtherwise = new Set((scope.criteria ?? []).flatMap((entry) => entry.status === "reported" ? [] : [entry.criterion]));
21426
+ const reported = [...new Set([...earlier?.reported ?? [], ...scope.reported ?? []])].filter((item) => !scope.unmet.includes(item) && !judgedOtherwise.has(item));
21427
+ if (earlier === undefined)
21428
+ return scope;
21429
+ const { reported: _, ...rest } = scope;
21430
+ return reported.length === 0 ? rest : { ...rest, reported };
21287
21431
  };
21288
21432
  var SeatOutput = Struct({
21289
21433
  summary: OneSentence,
21290
21434
  findings: ArraySchema(SeatFinding),
21291
21435
  verdicts: optional2(ArraySchema(RebuttalVerdict)),
21292
- scope: optional2(ReviewedScope),
21293
- followUps: optional2(ArraySchema(FollowUp))
21436
+ scope: optional2(SeatScope),
21437
+ followUps: optional2(ArraySchema(SeatFollowUp))
21438
+ });
21439
+ var ApprovedFinding = Struct({
21440
+ ...MergedFinding.fields,
21441
+ item: optionalKey2(String5),
21442
+ problem: OutOfScopeFinding.fields.problem
21294
21443
  });
21295
21444
  var Output = Struct({
21296
21445
  summary: String5,
21297
21446
  findings: ArraySchema(MergedFinding),
21298
- approvedFindings: optional2(ArraySchema(MergedFinding)),
21447
+ approvedFindings: optional2(ArraySchema(ApprovedFinding)),
21448
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
21299
21449
  followUps: ArraySchema(FollowUp),
21300
21450
  verdicts: ArraySchema(RebuttalVerdict),
21301
21451
  blocking: Boolean3,
@@ -21333,7 +21483,7 @@ var targetOf = (input, { base, head, branches, epic }) => {
21333
21483
  if (input.files === undefined && input.approved !== undefined)
21334
21484
  return [
21335
21485
  `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.`,
21336
- "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."
21486
+ "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."
21337
21487
  ].join(`
21338
21488
 
21339
21489
  `);
@@ -21369,26 +21519,102 @@ var pinnedRange = (input) => gen2(function* () {
21369
21519
  return { base, head };
21370
21520
  });
21371
21521
  var wholeChange = (input) => input.files === undefined && input.approved === undefined;
21372
- 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.";
21373
- var rejudgedScopePrompt = (unmet) => [
21374
- [
21375
- "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.",
21376
- ...unmet.length === 0 ? ["It found nothing unmet."] : [
21377
- "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:",
21378
- ...unmet.map((item) => `- ${item}`)
21379
- ]
21380
- ].join(`
21381
- `),
21382
- "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."
21522
+ var casesOf = (input) => listedCases(input.taskOutOfScope);
21523
+ var unmetCriteriaOf = (input) => casesOf(input).length === 0 ? [] : input.unmetCriteria ?? [];
21524
+ var afterMergeCriteriaOf = (input) => casesOf(input).length === 0 ? [] : input.afterMergeCriteria ?? [];
21525
+ var criteriaOf = (input) => casesOf(input).length === 0 ? [] : [...new Set([...unmetCriteriaOf(input), ...input.metCriteria ?? [], ...afterMergeCriteriaOf(input)])];
21526
+ var outOfScopePrompt = (cases) => [
21527
+ "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:",
21528
+ ...numberedCases(cases),
21529
+ "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."
21383
21530
  ].join(`
21531
+ `);
21532
+ 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.";
21533
+ var rejudgedScopePrompt = ({ unmet, outOfScope = [] }, numbered) => {
21534
+ const shown = unmet.filter((item) => !numbered.includes(item));
21535
+ return [
21536
+ [
21537
+ "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.",
21538
+ ...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."] : [
21539
+ `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"}:`,
21540
+ ...shown.map((item) => `- ${item}`)
21541
+ ]
21542
+ ].join(`
21543
+ `),
21544
+ ...outOfScope.length === 0 ? [] : [
21545
+ [
21546
+ "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`:",
21547
+ ...outOfScope.map(({ part, item }) => `- ${inCase(part, item)}`)
21548
+ ].join(`
21549
+ `)
21550
+ ],
21551
+ "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."
21552
+ ].join(`
21384
21553
 
21385
21554
  `);
21555
+ };
21386
21556
  var fixRound = (input) => (input.earlier?.length ?? 0) > 0 || input.reviewed !== undefined;
21387
- var scopeToRejudge = (input) => fixRound(input) && (input.scope?.met === true || (input.scope?.unmet.length ?? 0) > 0) ? input.scope : undefined;
21557
+ var earlierScope = (input) => {
21558
+ if (!fixRound(input) || input.scope === undefined)
21559
+ return;
21560
+ const { outOfScope = [], ...scope } = input.scope;
21561
+ const listed = outOfScope.filter(({ item }) => casesOf(input).includes(item));
21562
+ const unlisted = outOfScope.flatMap((entry) => listed.includes(entry) ? [] : [entry.part]);
21563
+ return {
21564
+ ...scope,
21565
+ ...unlisted.length === 0 ? undefined : { met: false, unmet: [...new Set([...scope.unmet, ...unlisted])] },
21566
+ ...listed.length === 0 ? undefined : { outOfScope: listed }
21567
+ };
21568
+ };
21569
+ var scopeToRejudge = (input) => {
21570
+ const scope = earlierScope(input);
21571
+ return scope?.met === true || (scope?.unmet.length ?? 0) > 0 ? scope : undefined;
21572
+ };
21573
+ var earlierOpenCriteriaOf = (input) => {
21574
+ const scope = earlierScope(input);
21575
+ const open = new Set([
21576
+ ...scope?.unmet ?? [],
21577
+ ...(scope?.criteria ?? []).flatMap((entry) => entry.status === "open" ? [entry.criterion] : [])
21578
+ ]);
21579
+ return criteriaOf(input).filter((criterion) => open.has(criterion));
21580
+ };
21581
+ var requiredCriteriaOf = (input) => [
21582
+ ...new Set([...unmetCriteriaOf(input), ...earlierOpenCriteriaOf(input)])
21583
+ ];
21584
+ var numbersOf = (input, criteria) => criteriaOf(input).flatMap((criterion, index) => criteria.includes(criterion) ? [index + 1] : []);
21585
+ var answeredPrompt = (input) => {
21586
+ const notMet = numbersOf(input, unmetCriteriaOf(input));
21587
+ const afterMerge = numbersOf(input, afterMergeCriteriaOf(input));
21588
+ const reopened = numbersOf(input, earlierOpenCriteriaOf(input)).filter((number) => !notMet.includes(number));
21589
+ const required = [...notMet, ...reopened].toSorted((left, right) => left - right);
21590
+ return [
21591
+ notMet.length === 0 && afterMerge.length === 0 ? "The implementer answered each of them met." : `The implementer answered ${[
21592
+ ...notMet.length === 0 ? [] : [`${notMet.join(", ")} not met`],
21593
+ ...afterMerge.length === 0 ? [] : [
21594
+ `${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`
21595
+ ]
21596
+ ].join(", and ")}, and the rest met.`,
21597
+ ...reopened.length === 0 ? [] : [`An earlier round found ${reopened.join(", ")} not done.`],
21598
+ 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.`
21599
+ ].join(" ");
21600
+ };
21388
21601
  var scopePrompt = (input) => {
21389
21602
  const earlier = scopeToRejudge(input);
21390
21603
  return [
21391
- earlier === undefined ? wholeScopePrompt : rejudgedScopePrompt(earlier.unmet),
21604
+ earlier === undefined ? wholeScopePrompt : rejudgedScopePrompt(earlier, criteriaOf(input)),
21605
+ ...casesOf(input).length === 0 ? [] : [
21606
+ `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"}.`
21607
+ ],
21608
+ ...criteriaOf(input).length === 0 ? [] : [
21609
+ [
21610
+ [
21611
+ "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.",
21612
+ answeredPrompt(input)
21613
+ ].join(" "),
21614
+ ...numberedCases(criteriaOf(input))
21615
+ ].join(`
21616
+ `)
21617
+ ],
21392
21618
  ...input.outcome === undefined ? [] : [`The Outcome to prove is ${input.outcome}.`],
21393
21619
  ...input.claims === undefined || input.claims.length === 0 ? [] : [
21394
21620
  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:",
@@ -21402,12 +21628,24 @@ var exhaustivePrompt = (subject) => [
21402
21628
  `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.`,
21403
21629
  "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."
21404
21630
  ].join(" ");
21405
- var earlierPrompt = (earlier) => [
21406
- "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.",
21631
+ var earlierPrompt = (earlier, cases) => [
21632
+ [
21633
+ "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.",
21634
+ ...cases.length === 0 ? [] : [
21635
+ "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.",
21636
+ "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.",
21637
+ "Report a different problem on the same line as a finding."
21638
+ ]
21639
+ ].join(" "),
21407
21640
  ...earlier.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`)
21408
21641
  ].join(`
21409
21642
  `);
21410
- 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.";
21643
+ var outsideFixPrompt = (cases) => [
21644
+ "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.",
21645
+ ...cases.length === 0 ? [] : [
21646
+ "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."
21647
+ ]
21648
+ ].join(" ");
21411
21649
  var fixTargetOf = (input, { head, branches, epic }) => {
21412
21650
  const from = input.reviewed ?? (input.files === undefined ? undefined : input.since);
21413
21651
  const branch = branches === undefined ? epic?.branch : branches.source ?? head;
@@ -21415,7 +21653,7 @@ var fixTargetOf = (input, { head, branches, epic }) => {
21415
21653
  `${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.`,
21416
21654
  "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.",
21417
21655
  ...input.files === undefined ? input.approved === undefined ? [] : [
21418
- `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.`
21656
+ `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.`
21419
21657
  ] : [
21420
21658
  [
21421
21659
  "Whatever changed in these files since then, even by merging the target branch, counts as the fix:",
@@ -21430,17 +21668,18 @@ var fixTargetOf = (input, { head, branches, epic }) => {
21430
21668
 
21431
21669
  `);
21432
21670
  };
21433
- var promptFor = (seat, target, input, failing, notRun) => [
21671
+ var promptFor = (seat, target, input, earlier, failing, notRun) => [
21434
21672
  `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}`,
21435
21673
  `Review ${target}`,
21436
21674
  "Give `summary`: one sentence on whether it can merge and what matters most.",
21437
21675
  "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.",
21438
21676
  exhaustivePrompt(fixRound(input) ? "the fix" : "the change"),
21439
21677
  "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.",
21678
+ ...casesOf(input).length === 0 ? [] : [outOfScopePrompt(casesOf(input))],
21440
21679
  "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.",
21441
21680
  ...seat === scopeSeat && wholeChange(input) ? [scopePrompt(input)] : [],
21442
- ...input.earlier === undefined || input.earlier.length === 0 ? [] : [earlierPrompt(input.earlier)],
21443
- ...fixRound(input) ? [outsideFixPrompt] : [],
21681
+ ...earlier.length === 0 ? [] : [earlierPrompt(earlier, casesOf(input))],
21682
+ ...fixRound(input) ? [outsideFixPrompt(casesOf(input))] : [],
21444
21683
  ...failing.length === 0 ? [] : [
21445
21684
  `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.`
21446
21685
  ],
@@ -21460,26 +21699,67 @@ var promptFor = (seat, target, input, failing, notRun) => [
21460
21699
  `);
21461
21700
  var rank2 = { still_there: 0, changed: 1, fixed: 2 };
21462
21701
  var outsideFixAsMinor = (finding) => finding.outsideFix === true && finding.severity === "major" ? { ...finding, severity: "minor" } : finding;
21702
+ var earlierOf = (input) => {
21703
+ const followed = new Map((input.earlier ?? []).map((finding) => [finding.id, finding]));
21704
+ for (const { item, problem: _, ...finding } of input.outOfScopeFindings ?? []) {
21705
+ if (casesOf(input).includes(item))
21706
+ continue;
21707
+ const taken = new Set(followed.keys());
21708
+ const id = taken.has(finding.id) ? ownId(inCase(finding.id, item), taken) : finding.id;
21709
+ followed.set(id, { ...finding, id });
21710
+ }
21711
+ return [...followed.values()];
21712
+ };
21713
+ var keptApart = (finding, item) => finding.severity === "blocker" ? [] : [{ ...finding, severity: finding.severity, item }];
21463
21714
  var detailOf = (detail, rule, checked) => [
21464
21715
  ...rule === undefined ? [] : [`[${rule}]`],
21465
21716
  detail,
21466
21717
  ...checked.length === 0 ? [] : [`Checked and fine: ${checked.join("; ")}.`]
21467
21718
  ].join(" ");
21468
21719
  var severityRank = { blocker: 0, major: 1, minor: 2 };
21720
+ var ownId = (id, taken) => {
21721
+ if (!taken.has(id))
21722
+ return id;
21723
+ let number = 2;
21724
+ while (taken.has(`${id} (${number})`))
21725
+ number++;
21726
+ return `${id} (${number})`;
21727
+ };
21728
+ var wordingsOf = ({ detail, problem }) => problem === undefined ? [detail] : [detail, problem];
21729
+ var distinctApart = (findings, taken = new Set) => {
21730
+ const kept = [];
21731
+ for (const finding of findings) {
21732
+ 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)));
21733
+ const same = kept[index];
21734
+ if (same === undefined) {
21735
+ kept.push({ ...finding, id: ownId(finding.id, new Set([...taken, ...kept.map((known) => known.id)])) });
21736
+ continue;
21737
+ }
21738
+ kept[index] = {
21739
+ ...same,
21740
+ ...same.problem !== undefined || finding.problem === undefined ? undefined : { problem: finding.problem },
21741
+ severity: severityRank[finding.severity] < severityRank[same.severity] ? finding.severity : same.severity,
21742
+ seats: [...new Set([...same.seats, ...finding.seats])]
21743
+ };
21744
+ }
21745
+ return kept;
21746
+ };
21469
21747
  var blockingSeatsOf = (finding) => isBlocking(finding) ? finding.blockingSeats ?? finding.seats : [];
21748
+ var stillOpen = " Still open on this line: ";
21749
+ var problemsOf = (detail) => detail.split(stillOpen).map((problem) => problem.trim());
21470
21750
  var withEarlier = (worse, earlier) => {
21471
21751
  const { blockingSeats: _, ...finding } = worse;
21472
21752
  const seats = [...new Set([...earlier.seats, ...worse.seats])];
21473
21753
  const blockingSeats = [...new Set([...blockingSeatsOf(earlier), ...blockingSeatsOf(worse)])];
21474
21754
  return {
21475
21755
  ...finding,
21476
- detail: `${finding.detail} Still open on this line: ${earlier.detail}`,
21756
+ detail: `${finding.detail}${stillOpen}${earlier.detail}`,
21477
21757
  seats,
21478
21758
  ...blockingSeats.length === seats.length ? undefined : { blockingSeats }
21479
21759
  };
21480
21760
  };
21481
21761
  var idOf = (finding) => `${finding.file}:${finding.line}`;
21482
- var groupedByRule = (bySeat) => {
21762
+ var groupedByRule = (bySeat, cases, taken) => {
21483
21763
  const rules = new Map;
21484
21764
  const checked = new Map;
21485
21765
  for (const finding of Object.values(bySeat).flat()) {
@@ -21488,18 +21768,55 @@ var groupedByRule = (bySeat) => {
21488
21768
  rules.set(id, finding.rule);
21489
21769
  checked.set(id, new Set([...checked.get(id) ?? [], ...finding.checked ?? []]));
21490
21770
  }
21491
- const findings = mergeFindings(Object.fromEntries(Object.entries(bySeat).map(([seat, seatFindings]) => [
21771
+ const detailed = (finding) => detailOf(finding.detail, rules.get(idOf(finding)), [...checked.get(idOf(finding)) ?? []]);
21772
+ const distinct = [];
21773
+ const blockers = Object.entries(bySeat).flatMap(([seat, seatFindings]) => seatFindings.flatMap((finding) => finding.severity === "blocker" ? [{ seat, finding }] : []));
21774
+ const firstOn = new Map;
21775
+ for (const { finding } of blockers)
21776
+ if (!firstOn.has(idOf(finding)))
21777
+ firstOn.set(idOf(finding), finding);
21778
+ const merges = new Set(Object.keys(bySeat).flatMap((seat) => [...firstOn].flatMap(([id, first]) => {
21779
+ const own = blockers.filter((entry) => entry.seat === seat && idOf(entry.finding) === id).map((entry) => entry.finding);
21780
+ return own.find((finding) => finding.detail === first.detail) ?? own[0] ?? [];
21781
+ })));
21782
+ const merging = Object.entries(bySeat).map(([seat, seatFindings]) => [
21783
+ seat,
21784
+ seatFindings.flatMap((finding) => {
21785
+ const id = idOf(finding);
21786
+ const first = firstOn.get(id);
21787
+ const marked = caseOf(cases, finding);
21788
+ const another = finding.severity === "blocker" && cases.length > 0 && finding.detail !== first?.detail && (!merges.has(finding) || marked !== undefined && marked !== (first && caseOf(cases, first)));
21789
+ if (!another)
21790
+ return [finding];
21791
+ const index = distinct.findIndex((known) => known.id === id && known.problem === finding.detail);
21792
+ const known = distinct[index];
21793
+ if (known === undefined)
21794
+ distinct.push({ ...finding, id, detail: detailed(finding), seats: [seat], problem: finding.detail });
21795
+ else
21796
+ distinct[index] = { ...known, seats: [...new Set([...known.seats, seat])] };
21797
+ return [];
21798
+ })
21799
+ ]);
21800
+ const findings = mergeFindings(Object.fromEntries(merging.map(([seat, seatFindings]) => [
21492
21801
  seat,
21493
21802
  seatFindings.map((finding) => ({
21494
21803
  severity: finding.severity,
21495
21804
  file: finding.file,
21496
21805
  line: finding.line,
21497
- detail: detailOf(finding.detail, rules.get(idOf(finding)), [...checked.get(idOf(finding)) ?? []])
21806
+ detail: detailed(finding)
21498
21807
  }))
21499
21808
  ])));
21500
- const groupOf = (finding) => rules.get(finding.id) ?? finding.id;
21501
- const order = [...new Set(findings.map(groupOf))];
21502
- return findings.toSorted((left, right) => order.indexOf(groupOf(left)) - order.indexOf(groupOf(right)));
21809
+ for (const finding of findings)
21810
+ taken.add(finding.id);
21811
+ const apart = distinct.map(({ file, line, severity, detail, seats, id }) => {
21812
+ const own = ownId(id, taken);
21813
+ taken.add(own);
21814
+ return { id: own, severity, file, line, detail, seats };
21815
+ });
21816
+ const groupOf = (finding) => rules.get(`${finding.file}:${finding.line}`) ?? finding.id;
21817
+ const all = [...findings, ...apart];
21818
+ const order = [...new Set(all.map(groupOf))];
21819
+ return all.toSorted((left, right) => order.indexOf(groupOf(left)) - order.indexOf(groupOf(right)));
21503
21820
  };
21504
21821
  var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21505
21822
  const statuses = answers.flatMap((answer) => answer.id === finding.id ? [answer.status] : []);
@@ -21508,27 +21825,65 @@ var followUpsOf = (earlier, answers) => earlier.map((finding) => {
21508
21825
  status: statuses.length === 0 ? "still_there" : statuses.reduce((worst, status) => rank2[status] < rank2[worst] ? status : worst)
21509
21826
  };
21510
21827
  });
21828
+ var currentOf = (finding, answers) => {
21829
+ const judging = answers.flatMap(({ id, status, severity, seat }) => id === finding.id && status !== "fixed" && severity !== undefined ? [{ seat, severity }] : []);
21830
+ const now = judging.reduce((worst, { severity }) => worst === undefined || severityRank[severity] < severityRank[worst] ? severity : worst, undefined);
21831
+ if (now === undefined || now === finding.severity)
21832
+ return finding;
21833
+ const { blockingSeats: _, ...current } = finding;
21834
+ const seats = [...new Set([...finding.seats, ...judging.map(({ seat }) => seat)])];
21835
+ const blockingSeats = isBlocking({ severity: now }) ? [
21836
+ ...new Set([
21837
+ ...blockingSeatsOf(finding),
21838
+ ...judging.flatMap(({ seat, severity }) => isBlocking({ severity }) ? [seat] : [])
21839
+ ])
21840
+ ] : [];
21841
+ return {
21842
+ ...current,
21843
+ severity: now,
21844
+ seats,
21845
+ ...blockingSeats.length === 0 || blockingSeats.length === seats.length ? undefined : { blockingSeats }
21846
+ };
21847
+ };
21848
+ var earlierCaseOf = (finding, answers, cases) => {
21849
+ const items = answers.flatMap((answer) => answer.id === finding.id && answer.status !== "fixed" ? [caseOf(cases, answer)] : []);
21850
+ return finding.severity === "blocker" || items.includes(undefined) ? undefined : items[0];
21851
+ };
21511
21852
  var findingLines = (findings) => findings.map((finding) => `- **${finding.severity}** \`${finding.id}\` ${finding.detail} _(${finding.seats.join(", ")})_`).join(`
21512
21853
  `);
21513
- var reviewText = (summary, findings, followUps, approvedFindings, notRun, reported) => [
21514
- `**Kitman review.** ${summary}`,
21515
- ...reported.length === 0 ? [] : [`Out of scope by an answer, so reported, not blocking:
21854
+ var reviewText = (summary, findings, followUps, approvedFindings, outOfScopeFindings, notRun, scope) => {
21855
+ const reported = scope?.reported ?? [];
21856
+ const outOfScope = scope?.outOfScope ?? [];
21857
+ return [
21858
+ `**Kitman review.** ${summary}`,
21859
+ ...reported.length === 0 ? [] : [`Out of scope by an answer, so reported, not blocking:
21516
21860
  ${reported.map((item) => `- ${item}`).join(`
21517
21861
  `)}`],
21518
- ...notRun.length === 0 ? [] : [`Verify never ran these tests, so they are unverified:
21862
+ ...notRun.length === 0 ? [] : [`Verify never ran these tests, so they are unverified:
21519
21863
  ${notRun.map((item) => `- ${item}`).join(`
21520
21864
  `)}`],
21521
- ...findings.length === 0 ? [] : [findingLines(findings)],
21522
- ...approvedFindings.length === 0 ? [] : [`In code approved before, not blocking:
21523
- ${findingLines(approvedFindings)}`],
21524
- ...followUps.length === 0 ? [] : [
21525
- `Earlier findings:
21865
+ ...findings.length === 0 ? [] : [findingLines(findings)],
21866
+ ...approvedFindings.length === 0 ? [] : [
21867
+ `In code approved before, not blocking:
21868
+ ${findingLines(approvedFindings.map(({ item, ...finding }) => item === undefined ? finding : { ...finding, detail: inCase(finding.detail, item) }))}`
21869
+ ],
21870
+ ...outOfScope.length + outOfScopeFindings.length === 0 ? [] : [
21871
+ [
21872
+ "In a case the Task lists as Out of scope, so reported, not blocking:",
21873
+ ...outOfScope.map(({ part, item }) => `- ${inCase(part, item)}`),
21874
+ ...outOfScopeFindings.length === 0 ? [] : [findingLines(outOfScopeFindings)]
21875
+ ].join(`
21876
+ `)
21877
+ ],
21878
+ ...followUps.length === 0 ? [] : [
21879
+ `Earlier findings:
21526
21880
  ${followUps.map((entry) => `- \`${entry.id}\` ${entry.status.replace("_", " ")}`).join(`
21527
21881
  `)}`
21528
- ]
21529
- ].join(`
21882
+ ]
21883
+ ].join(`
21530
21884
 
21531
21885
  `);
21886
+ };
21532
21887
  var fixBrief = (changeRequestId, findings, unmet) => [
21533
21888
  `Fix what a review of ChangeRequest ${changeRequestId} found, on its branch:`,
21534
21889
  ...findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`),
@@ -21537,7 +21892,7 @@ var fixBrief = (changeRequestId, findings, unmet) => [
21537
21892
  `);
21538
21893
  var review_default = defineLoop({
21539
21894
  id: "review",
21540
- version: "3.10.0",
21895
+ version: "3.11.0",
21541
21896
  title: "Review",
21542
21897
  input: Input,
21543
21898
  output: Output,
@@ -21571,47 +21926,119 @@ var review_default = defineLoop({
21571
21926
  const verified = head === undefined ? { failing: [], notRun: [] } : yield* verifyHead("verify", head);
21572
21927
  const failing = [...new Set([...input.failing ?? [], ...verified.failing])];
21573
21928
  const notRun = [...new Set([...input.notRun ?? [], ...verified.notRun])];
21929
+ const earlier = earlierOf(input);
21574
21930
  const outputs = yield* forEach2(fixRound(input) ? [scopeSeat] : seatNames, (seat) => agentWork(`review:${seat}`, {
21575
21931
  agent: seat,
21576
- prompt: promptFor(seat, target, input, failing, notRun),
21932
+ prompt: promptFor(seat, target, input, earlier, failing, notRun),
21577
21933
  output: SeatOutput
21578
21934
  }).pipe(map8((output) => [seat, output])), { concurrency: "unbounded" });
21579
- const earlier = input.earlier ?? [];
21935
+ const cases = casesOf(input);
21580
21936
  const earlierById = new Map(earlier.map((finding) => [finding.id, finding]));
21581
- const answered = followUpsOf(earlier, outputs.flatMap(([, output]) => output.followUps ?? []));
21937
+ const answers = outputs.flatMap(([seat, output]) => (output.followUps ?? []).map((answer) => ({ ...answer, seat })));
21938
+ const answered = followUpsOf(earlier, answers);
21582
21939
  const standing = new Set(answered.flatMap((entry) => entry.status === "fixed" ? [] : [entry.id]));
21583
21940
  const given = outputs.flatMap(([, output]) => output.verdicts ?? []);
21584
21941
  const settled = settleRound({ findings: earlier, rebuttals: input.rebuttals ?? [], verdicts: given });
21585
21942
  const withdrawn = new Set(settled.withdrawn.map((entry) => entry.finding.id));
21586
- const open = new Map([...earlierById].filter(([id]) => standing.has(id) && !withdrawn.has(id)));
21943
+ const open = new Map([...earlierById].flatMap(([id, finding]) => standing.has(id) && !withdrawn.has(id) ? [[id, currentOf(finding, answers)]] : []));
21944
+ const movedApart = new Map;
21945
+ for (const [id, finding] of open) {
21946
+ const item = earlierCaseOf(finding, answers, cases);
21947
+ if (item === undefined)
21948
+ continue;
21949
+ open.delete(id);
21950
+ for (const apart of keptApart(finding, item))
21951
+ movedApart.set(id, apart);
21952
+ }
21587
21953
  const followUps = answered.filter((entry) => !withdrawn.has(entry.id));
21588
21954
  const sinceApproval = input.approved !== undefined && input.files === undefined;
21589
- const isNew = (finding) => {
21955
+ const groupOf = (finding) => {
21956
+ const approved = sinceApproval && finding.approvedCode === true;
21957
+ if (caseOf(cases, finding) !== undefined)
21958
+ return finding.severity === "blocker" ? "fresh" : approved ? "approvedApart" : "outOfScope";
21959
+ return approved ? "approvedCode" : "fresh";
21960
+ };
21961
+ const keepsSeverity = (finding) => {
21962
+ const group = groupOf(finding);
21963
+ return group === "outOfScope" || group === "approvedApart";
21964
+ };
21965
+ const listedApart = [
21966
+ ...(input.outOfScopeFindings ?? []).filter((finding) => cases.includes(finding.item)),
21967
+ ...movedApart.values()
21968
+ ];
21969
+ const unfixedOn = (finding) => {
21590
21970
  const before = earlierById.get(idOf(finding));
21591
- return before === undefined || severityRank[finding.severity] < severityRank[before.severity] || !standing.has(before.id) && !withdrawn.has(before.id);
21971
+ return before !== undefined && (standing.has(before.id) || withdrawn.has(before.id)) ? before : undefined;
21972
+ };
21973
+ const saysAgain = (before, finding) => [finding.detail, detailOf(finding.detail, finding.rule, finding.checked ?? [])].some((text) => problemsOf(before.detail).includes(text.trim()));
21974
+ const isNew = (finding) => {
21975
+ const before = unfixedOn(finding);
21976
+ 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);
21977
+ };
21978
+ const isNewApart = (finding) => {
21979
+ const before = unfixedOn(finding);
21980
+ return before === undefined || movedApart.has(before.id) || severityRank[finding.severity] < severityRank[before.severity] || !saysAgain(before, finding);
21592
21981
  };
21593
- const merged = (approvedCode) => groupedByRule(Object.fromEntries(outputs.map(([seat, output]) => [
21982
+ const seatFindings = (holds) => Object.fromEntries(outputs.map(([seat, output]) => [
21594
21983
  seat,
21595
- output.findings.map((finding) => fixRound(input) ? outsideFixAsMinor(finding) : finding).filter((finding) => isNew(finding) && (sinceApproval && finding.approvedCode === true) === approvedCode)
21596
- ])));
21597
- const fresh = merged(false).map((finding) => {
21984
+ output.findings.map((finding) => fixRound(input) && !keepsSeverity(finding) ? outsideFixAsMinor(finding) : finding).filter(holds)
21985
+ ]));
21986
+ const takenIds = new Set(earlierById.keys());
21987
+ const merged = (holds) => groupedByRule(seatFindings((finding) => isNew(finding) && holds(finding)), cases, takenIds);
21988
+ const ownFinding = (finding) => {
21989
+ const id = ownId(finding.id, takenIds);
21990
+ takenIds.add(id);
21991
+ return { ...finding, id };
21992
+ };
21993
+ const fresh = merged((finding) => groupOf(finding) === "fresh").map((finding) => {
21598
21994
  const before = open.get(finding.id);
21599
- return before === undefined ? finding : withEarlier(finding, before);
21995
+ const rebutted = earlierById.get(finding.id);
21996
+ const worse = (than) => severityRank[finding.severity] < severityRank[than.severity];
21997
+ if (before !== undefined)
21998
+ return worse(before) ? withEarlier(finding, before) : ownFinding(finding);
21999
+ return rebutted !== undefined && withdrawn.has(rebutted.id) && !worse(rebutted) ? ownFinding(finding) : finding;
21600
22000
  });
21601
22001
  const freshIds = new Set(fresh.map((finding) => finding.id));
21602
- const approvedFindings = sinceApproval ? merged(true) : [];
22002
+ const apartOf = (group) => Object.entries(seatFindings((finding) => groupOf(finding) === group && isNewApart(finding))).flatMap(([seat, found]) => found.flatMap((finding) => keptApart({
22003
+ id: idOf(finding),
22004
+ severity: finding.severity,
22005
+ file: finding.file,
22006
+ line: finding.line,
22007
+ detail: detailOf(finding.detail, finding.rule, finding.checked ?? []),
22008
+ seats: [seat],
22009
+ problem: finding.detail
22010
+ }, caseOf(cases, finding) ?? "")));
22011
+ const approvedInScope = merged((finding) => groupOf(finding) === "approvedCode");
22012
+ const approvedFindings = [
22013
+ ...approvedInScope,
22014
+ ...distinctApart(apartOf("approvedApart"), new Set(approvedInScope.map((finding) => finding.id)))
22015
+ ];
22016
+ const outOfScopeFindings = distinctApart([...listedApart, ...apartOf("outOfScope")]);
21603
22017
  const findings = [...[...open.values()].filter((finding) => !freshIds.has(finding.id)), ...fresh];
21604
22018
  const verdicts = given.map((verdict) => freshIds.has(verdict.findingId) ? { ...verdict, accepted: false } : verdict);
21605
22019
  const blockers = findings.filter(isBlocking);
21606
22020
  const judged = outputs.find(([seat]) => seat === scopeSeat)?.[1].scope;
21607
- const scope = wholeChange(input) ? carriedScope(judged, fixRound(input) ? input.scope : undefined) : undefined;
21608
- 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(" ");
21609
- const text = reviewText(summary, findings, followUps, approvedFindings, notRun, scope?.reported ?? []);
22021
+ const scope = wholeChange(input) ? withUnjudged(carriedScope(judged, earlierScope(input), cases, criteriaOf(input)), requiredCriteriaOf(input)) : undefined;
22022
+ 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(" ");
22023
+ const shownOutOfScope = outOfScopeFindings.map((finding) => ({
22024
+ ...finding,
22025
+ detail: inCase(finding.detail, finding.item)
22026
+ }));
22027
+ const text = reviewText(summary, findings, followUps, approvedFindings, shownOutOfScope, notRun, scope);
22028
+ const apart = {
22029
+ ...approvedFindings.length === 0 ? undefined : { approvedFindings },
22030
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings }
22031
+ };
21610
22032
  const stored = yield* artifact("findings", {
21611
22033
  kind: "review-findings",
21612
22034
  title: "Review findings",
21613
22035
  text,
21614
- data: { findings, followUps, ...approvedFindings.length === 0 ? undefined : { approvedFindings } }
22036
+ data: {
22037
+ findings,
22038
+ followUps,
22039
+ ...apart,
22040
+ ...scope === undefined ? undefined : { scope: { outOfScope: scope.outOfScope ?? [] } }
22041
+ }
21615
22042
  });
21616
22043
  const reviewed = {
21617
22044
  summary,
@@ -21620,7 +22047,7 @@ var review_default = defineLoop({
21620
22047
  verdicts,
21621
22048
  blocking: findings.some(isBlocking),
21622
22049
  artifactId: stored.artifactId,
21623
- ...approvedFindings.length === 0 ? undefined : { approvedFindings },
22050
+ ...apart,
21624
22051
  ...scope === undefined ? undefined : { scope },
21625
22052
  ...failing.length === 0 ? undefined : { failing },
21626
22053
  ...input.deliversTo === undefined ? undefined : { deliversTo: input.deliversTo }
@@ -21660,6 +22087,7 @@ What next?`,
21660
22087
  maxRounds: 2,
21661
22088
  reviewed: range.head,
21662
22089
  ...findings.length === 0 ? undefined : { earlier: findings },
22090
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings },
21663
22091
  ...scope === undefined ? undefined : { scope },
21664
22092
  ...ownDeliveryTarget(input)
21665
22093
  });
@@ -22224,6 +22652,7 @@ var ShepherdOutput = Struct({
22224
22652
  branch: optional2(String5),
22225
22653
  reviewed: optional2(String5),
22226
22654
  earlier: optional2(ArraySchema(MergedFinding)),
22655
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
22227
22656
  scope: optional2(ReviewedScope)
22228
22657
  }))
22229
22658
  });
@@ -22414,7 +22843,7 @@ var repliesPrompt = (threads) => [
22414
22843
  var threadKey = (thread) => `${thread.id}:${thread.comments.length}`;
22415
22844
  var shepherd_default = defineLoop({
22416
22845
  id: "shepherd",
22417
- version: "1.10.0",
22846
+ version: "1.11.0",
22418
22847
  title: "Shepherd",
22419
22848
  input: Input3,
22420
22849
  output: Output3,
@@ -22451,6 +22880,7 @@ var shepherd_default = defineLoop({
22451
22880
  const leftToPerson = new Set;
22452
22881
  let headFindings = [];
22453
22882
  let headFindingsAt;
22883
+ let outOfScopeFindings = [];
22454
22884
  let headScope;
22455
22885
  const unranAt = new Map;
22456
22886
  const rounds = { "ci-fix": 0, "head-fix": 0 };
@@ -22526,7 +22956,8 @@ var shepherd_default = defineLoop({
22526
22956
  ${open}`,
22527
22957
  ...input.taskId === undefined ? undefined : { taskId: input.taskId },
22528
22958
  ...target === "HEAD" ? undefined : { branch: target },
22529
- ...review
22959
+ ...review,
22960
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings }
22530
22961
  }
22531
22962
  });
22532
22963
  const takeTurn = () => gen2(function* () {
@@ -22760,11 +23191,14 @@ ${open}`,
22760
23191
  const reviewed = yield* call(`review:${cycle}`, reviewLoop(), {
22761
23192
  base: `origin/${target}`,
22762
23193
  head,
23194
+ deliveredBy: changeRequestId,
22763
23195
  files: files.files,
22764
23196
  ...head === files.synced ? undefined : { since: files.synced },
22765
23197
  ...files.earlier.length === 0 ? undefined : { earlier: files.earlier },
22766
- ...files.reviewed === undefined ? undefined : { reviewed: files.reviewed }
23198
+ ...files.reviewed === undefined ? undefined : { reviewed: files.reviewed },
23199
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings }
22767
23200
  });
23201
+ outOfScopeFindings = reviewed.outOfScopeFindings ?? [];
22768
23202
  if (reviewed.blocking) {
22769
23203
  const blocking = reviewed.findings.filter(isBlocking);
22770
23204
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
@@ -22825,12 +23259,15 @@ ${open}`,
22825
23259
  const reviewed = yield* call(`head-review:${cycle}`, reviewLoop(), {
22826
23260
  base: `origin/${target}`,
22827
23261
  head,
23262
+ deliveredBy: changeRequestId,
22828
23263
  ...notRun.length === 0 ? undefined : { notRun },
22829
23264
  ...since === undefined ? undefined : { approved: since },
22830
23265
  ...headFindings.length === 0 ? undefined : { earlier: headFindings },
22831
23266
  ...headFindingsAt === undefined ? undefined : { reviewed: headFindingsAt },
23267
+ ...outOfScopeFindings.length === 0 ? undefined : { outOfScopeFindings },
22832
23268
  ...headScope === undefined ? undefined : { scope: headScope }
22833
23269
  });
23270
+ outOfScopeFindings = reviewed.outOfScopeFindings ?? [];
22834
23271
  if (reviewed.blocking) {
22835
23272
  const blocking = reviewed.findings.filter(isBlocking);
22836
23273
  if (!(yield* mayFix("head-fix", cycle, blocking.map((finding) => finding.id).join(", "))))
@@ -23313,6 +23750,8 @@ var BuildInput = Struct({
23313
23750
  maxRebuilds: optional2(Int.check(isGreaterThanOrEqualTo2(0))),
23314
23751
  reviewed: optional2(String5),
23315
23752
  earlier: optional2(ArraySchema(MergedFinding)),
23753
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
23754
+ taskOutOfScope: optional2(ArraySchema(String5)),
23316
23755
  scope: optional2(ReviewedScope),
23317
23756
  planReviewed: optional2(Boolean3),
23318
23757
  ...DeliveryFields
@@ -23320,7 +23759,8 @@ var BuildInput = Struct({
23320
23759
  var CriterionAnswer = Struct({
23321
23760
  criterion: String5,
23322
23761
  status: Literals(["met", "after_merge", "not_met"]),
23323
- detail: ShortStatement
23762
+ detail: ShortStatement,
23763
+ ...outOfScopeCase
23324
23764
  });
23325
23765
  var Criteria = Struct({ criteria: ArraySchema(CriterionAnswer) });
23326
23766
  var SuggestedCheck = Struct({
@@ -23362,6 +23802,7 @@ var BuildOutput = Struct({
23362
23802
  criteria: ArraySchema(CriterionAnswer),
23363
23803
  notRun: optional2(ArraySchema(String5)),
23364
23804
  findings: optional2(ArraySchema(MergedFinding)),
23805
+ outOfScopeFindings: optional2(ArraySchema(OutOfScopeFinding)),
23365
23806
  scope: optional2(ReviewedScope),
23366
23807
  blockingCounts: optional2(ArraySchema(Int)),
23367
23808
  approval: optional2(ApproveChangeRequestResult),
@@ -23399,27 +23840,67 @@ class BuildOutcomeRefused extends TaggedError3()("BuildOutcomeRefused", {
23399
23840
  }) {
23400
23841
  }
23401
23842
  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.";
23843
+ var outOfScopeGuidance = (cases) => cases.length === 0 ? [] : [
23844
+ [
23845
+ "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.",
23846
+ ...numberedCases(cases),
23847
+ "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."
23848
+ ].join(`
23849
+ `)
23850
+ ];
23402
23851
  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.";
23403
23852
  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.";
23404
- var implementPrompt = (task, outcome, continuing) => [
23853
+ var implementPrompt = (task, outcome, continuing, cases) => [
23405
23854
  ...continuing === undefined ? [] : [continuingBrief(continuing), "Fix forward from there."],
23406
23855
  `Build ${task}`,
23407
23856
  implementAdaptation,
23408
23857
  ...outcome === undefined ? [] : [outcomeGuidance[outcome]],
23409
23858
  '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".',
23859
+ ...outOfScopeGuidance(cases),
23410
23860
  criteriaGuidance,
23411
23861
  checksGuidance
23412
23862
  ].join(`
23413
23863
 
23414
23864
  `);
23415
- var criteriaPrompt = (unanswered, unmet) => [
23865
+ var criteriaPrompt = (unanswered, unmet, cases) => [
23416
23866
  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:",
23417
23867
  ...unmet.map((answer) => `- ${answer.criterion}: ${answer.detail}`),
23868
+ ...outOfScopeGuidance(cases),
23418
23869
  criteriaGuidance
23419
23870
  ].join(`
23420
23871
 
23421
23872
  `);
23422
- var answerLine = (answer) => `${answer.criterion}: ${answer.status.replaceAll("_", " ")}, ${answer.detail}`;
23873
+ var answerLine = (answer, cases) => {
23874
+ const line = `${answer.criterion}: ${answer.status.replaceAll("_", " ")}, ${answer.detail}`;
23875
+ const item = answer.status === "not_met" ? caseOf(cases, answer) : undefined;
23876
+ return item === undefined ? line : `${line} (proposed Out of scope: ${item})`;
23877
+ };
23878
+ var reviewedAs = (criterion, cases, scope) => {
23879
+ if (cases.length === 0 || scope === undefined)
23880
+ return;
23881
+ const judged = scope.criteria?.find((entry) => entry.criterion === criterion);
23882
+ if (judged?.status === "open" || scope.unmet.includes(criterion))
23883
+ return { status: "open" };
23884
+ if (judged?.status === "met")
23885
+ return { status: "met" };
23886
+ if (judged?.status === "reported" || scope.reported?.includes(criterion))
23887
+ return { status: "reported" };
23888
+ const item = judged?.item ?? scope.outOfScope?.find((entry) => entry.part === criterion)?.item;
23889
+ return item !== undefined && cases.includes(item) ? { status: "out_of_scope", item } : undefined;
23890
+ };
23891
+ var criterionLine = (answer, cases, scope) => {
23892
+ const final = reviewedAs(answer.criterion, cases, scope);
23893
+ const answered = `answered ${answer.status.replaceAll("_", " ")}: ${answer.detail}`;
23894
+ if (final === undefined || final.status === "met" && answer.status === "met")
23895
+ return answerLine(answer, cases);
23896
+ if (final.status === "open")
23897
+ return answer.status === "not_met" ? answerLine(answer, cases) : `${answer.criterion}: not met, as Review judged it (${answered})`;
23898
+ if (final.status === "met")
23899
+ return `${answer.criterion}: met, as Review judged it (${answered})`;
23900
+ if (final.status === "reported")
23901
+ return `${answer.criterion}: out of scope by an answer (${answered})`;
23902
+ 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);
23903
+ };
23423
23904
  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.";
23424
23905
  var reproducePrompt = (task) => [
23425
23906
  `Reproduce the bug in ${task} before anyone fixes it.`,
@@ -23471,6 +23952,7 @@ var rally = (input) => gen2(function* () {
23471
23952
  const blockingCounts = [];
23472
23953
  let rebuttals = [];
23473
23954
  let earlier = input.earlier;
23955
+ let outOfScope = input.outOfScope;
23474
23956
  let previous;
23475
23957
  let last;
23476
23958
  const shown = new Set;
@@ -23499,6 +23981,7 @@ var rally = (input) => gen2(function* () {
23499
23981
  head,
23500
23982
  decision: { stop: true, reason: "findings_returned", unsettled: blockingIds(last.settled) },
23501
23983
  claims,
23984
+ outOfScope,
23502
23985
  conflicts,
23503
23986
  earlier,
23504
23987
  blockingCounts
@@ -23509,15 +23992,21 @@ var rally = (input) => gen2(function* () {
23509
23992
  const reviewed = yield* call(`review:${round}`, review_default, {
23510
23993
  base,
23511
23994
  head: head.revision,
23995
+ ...input.deliveredBy === undefined ? undefined : { deliveredBy: input.deliveredBy },
23512
23996
  ...rebuttals.length === 0 ? undefined : { rebuttals },
23513
23997
  ...earlier.length === 0 ? undefined : { earlier },
23514
23998
  ...last === undefined ? input.reviewed === undefined ? undefined : { reviewed: input.reviewed } : { reviewed: last.head.revision },
23999
+ ...outOfScope.length === 0 ? undefined : { outOfScopeFindings: outOfScope },
24000
+ ...input.unmetCriteria.length === 0 ? undefined : { unmetCriteria: input.unmetCriteria },
24001
+ ...input.metCriteria.length === 0 ? undefined : { metCriteria: input.metCriteria },
24002
+ ...input.afterMergeCriteria.length === 0 ? undefined : { afterMergeCriteria: input.afterMergeCriteria },
23515
24003
  ...scope === undefined ? undefined : { scope },
23516
24004
  ...input.outcome === undefined ? undefined : { outcome: input.outcome },
23517
24005
  ...failing.length === 0 ? undefined : { failing },
23518
24006
  ...notRun.length === 0 ? undefined : { notRun },
23519
24007
  claims: [...claims]
23520
24008
  });
24009
+ outOfScope = reviewed.outOfScopeFindings ?? [];
23521
24010
  const checks = checkFindings(head);
23522
24011
  const settled = settleRound({
23523
24012
  findings: [...reviewed.findings, ...scopeFindings(reviewed.scope), ...checks],
@@ -23541,6 +24030,7 @@ var rally = (input) => gen2(function* () {
23541
24030
  decision,
23542
24031
  claims,
23543
24032
  scope: reviewed.scope,
24033
+ outOfScope,
23544
24034
  conflicts,
23545
24035
  earlier,
23546
24036
  blockingCounts
@@ -23564,7 +24054,7 @@ var rally = (input) => gen2(function* () {
23564
24054
  });
23565
24055
  var build2 = defineLoop({
23566
24056
  id: "build",
23567
- version: "2.12.0",
24057
+ version: "2.13.0",
23568
24058
  title: "Build",
23569
24059
  input: BuildInput,
23570
24060
  output: BuildOutput,
@@ -23588,6 +24078,7 @@ var build2 = defineLoop({
23588
24078
  yield* writeBack("write-back:started", { milestone: "started" });
23589
24079
  const task = input.words === undefined ? "the Task your brief describes." : `this: ${input.words}`;
23590
24080
  const outcome = input.outcome;
24081
+ const cases = listedCases(input.taskOutOfScope);
23591
24082
  const epic = epicOf(input);
23592
24083
  const target = input.continuing?.targetBranch ?? input.branch ?? epic?.branch;
23593
24084
  if (epic !== undefined && input.continuing === undefined && input.branch === undefined)
@@ -23608,25 +24099,30 @@ var build2 = defineLoop({
23608
24099
  const implemented = yield* agentWorkOnce("implement", {
23609
24100
  agent: input.planReviewed === true ? "planned-implementer" : "implementer",
23610
24101
  skill: "implement",
23611
- prompt: implementPrompt(task, outcome, input.continuing),
24102
+ prompt: implementPrompt(task, outcome, input.continuing, cases),
23612
24103
  output: Implemented
23613
24104
  });
23614
24105
  const unanswered = input.taskId !== undefined && implemented.criteria === undefined;
23615
- const unmet = (implemented.criteria ?? []).filter((answer) => answer.status === "not_met");
24106
+ const unmet = (implemented.criteria ?? []).filter((answer) => answer.status === "not_met" && caseOf(cases, answer) === undefined);
23616
24107
  const criteria = unanswered || unmet.length > 0 ? (yield* agentWorkOnce("criteria", {
23617
24108
  agent: "implementer",
23618
- prompt: criteriaPrompt(unanswered, unmet),
24109
+ prompt: criteriaPrompt(unanswered, unmet, cases),
23619
24110
  output: Criteria
23620
24111
  })).criteria : implemented.criteria ?? [];
23621
24112
  const last = yield* rally({
23622
24113
  maxRounds: input.maxRounds ?? 3,
23623
24114
  target,
23624
24115
  outcome,
23625
- claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer)}`)],
24116
+ claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer, cases)}`)],
23626
24117
  suggested: implemented.checks ?? [],
23627
24118
  reproducing: reproduced?.check,
23628
24119
  reviewed: input.reviewed,
24120
+ deliveredBy: input.changeRequestId,
23629
24121
  earlier: input.earlier ?? [],
24122
+ outOfScope: input.outOfScopeFindings ?? [],
24123
+ unmetCriteria: cases.length === 0 ? [] : criteria.flatMap((answer) => answer.status === "not_met" ? [answer.criterion] : []),
24124
+ metCriteria: cases.length === 0 ? [] : criteria.flatMap((answer) => answer.status === "met" ? [answer.criterion] : []),
24125
+ afterMergeCriteria: cases.length === 0 ? [] : criteria.flatMap((answer) => answer.status === "after_merge" ? [answer.criterion] : []),
23630
24126
  scope: input.scope
23631
24127
  });
23632
24128
  const verdict = evidenceGate({
@@ -23645,7 +24141,7 @@ var build2 = defineLoop({
23645
24141
  ...brokenChecks(last.head).map((check) => failsOn("head", check, last.head.tree)),
23646
24142
  ...unsettledItems(last.settled, last.decision),
23647
24143
  ...last.conflicts,
23648
- ...criteria.flatMap((answer) => answer.status === "not_met" ? [`Criterion not met: ${answer.criterion} (${answer.detail})`] : [])
24144
+ ...criteria.flatMap((answer) => answer.status === "not_met" && (reviewedAs(answer.criterion, cases, last.scope)?.status ?? "open") === "open" ? [`Criterion not met: ${answer.criterion} (${answer.detail})`] : [])
23649
24145
  ])
23650
24146
  ];
23651
24147
  const body = changeRequestBody({
@@ -23653,8 +24149,9 @@ var build2 = defineLoop({
23653
24149
  head: last.head,
23654
24150
  claims: last.claims,
23655
24151
  unsettled,
23656
- criteria: criteria.map(answerLine),
24152
+ criteria: criteria.map((answer) => criterionLine(answer, cases, last.scope)),
23657
24153
  later: last.settled.open.filter((finding) => !isBlocking(finding)).map((finding) => `${finding.id}: ${finding.detail}`),
24154
+ outOfScope: outOfScopeLines(last.outOfScope, last.scope),
23658
24155
  rounds: last.round,
23659
24156
  stopped: last.decision.reason
23660
24157
  });
@@ -23678,6 +24175,7 @@ var build2 = defineLoop({
23678
24175
  criteria,
23679
24176
  ...lastNotRun.length === 0 ? undefined : { notRun: lastNotRun },
23680
24177
  ...last.earlier.length === 0 ? undefined : { findings: last.earlier },
24178
+ ...last.outOfScope.length === 0 ? undefined : { outOfScopeFindings: last.outOfScope },
23681
24179
  ...last.scope === undefined ? undefined : { scope: last.scope },
23682
24180
  blockingCounts: last.blockingCounts,
23683
24181
  ...approval === undefined ? undefined : { approval }
@@ -23743,6 +24241,7 @@ var build2 = defineLoop({
23743
24241
  land: false,
23744
24242
  reviewed: settledAs.revision,
23745
24243
  ...settledAs.findings === undefined ? undefined : { earlier: settledAs.findings },
24244
+ ...settledAs.outOfScopeFindings === undefined ? undefined : { outOfScopeFindings: settledAs.outOfScopeFindings },
23746
24245
  ...settledAs.scope === undefined ? undefined : { scope: settledAs.scope },
23747
24246
  ...ownDeliveryTarget(input)
23748
24247
  }, { constraints: standing.map(standingConstraint) });
@@ -24158,7 +24657,7 @@ var steadier = (plan) => {
24158
24657
  };
24159
24658
  var hillclimb_default = defineLoop({
24160
24659
  id: "hillclimb",
24161
- version: "1.5.0",
24660
+ version: "1.6.0",
24162
24661
  title: "Hillclimb",
24163
24662
  outcome: "performance",
24164
24663
  input: Input5,
@@ -24313,6 +24812,7 @@ var hillclimb_default = defineLoop({
24313
24812
  claims,
24314
24813
  earlier: reviewed.findings,
24315
24814
  reviewed: fixedFrom,
24815
+ ...reviewed.outOfScopeFindings === undefined ? undefined : { outOfScopeFindings: reviewed.outOfScopeFindings },
24316
24816
  ...reviewed.scope === undefined ? undefined : { scope: reviewed.scope }
24317
24817
  });
24318
24818
  }
@@ -24341,7 +24841,8 @@ ${harness.summary}
24341
24841
  ...unsettled.length + caveats.length === 0 ? [] : [`## Unsettled
24342
24842
 
24343
24843
  ${[...unsettled, ...caveats].map((entry) => `- ${entry}`).join(`
24344
- `)}`]
24844
+ `)}`],
24845
+ ...outOfScopeSection(outOfScopeLines(reviewed.outOfScopeFindings ?? [], reviewed.scope))
24345
24846
  ].join(`
24346
24847
 
24347
24848
  `)
@@ -25856,7 +26357,7 @@ var tidyPrompt = (scope, words) => [
25856
26357
  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`;
25857
26358
  var tidy_default = defineLoop({
25858
26359
  id: "tidy",
25859
- version: "1.0.0",
26360
+ version: "1.1.0",
25860
26361
  title: "Tidy",
25861
26362
  input: Input12,
25862
26363
  output: Output13,
@@ -25898,6 +26399,7 @@ var tidy_default = defineLoop({
25898
26399
  head,
25899
26400
  claims: improvement.claims,
25900
26401
  unsettled,
26402
+ outOfScope: outOfScopeLines(reviewed.outOfScopeFindings ?? [], reviewed.scope),
25901
26403
  rounds: 1,
25902
26404
  stopped: decision.stop ? decision.reason : "round_cap"
25903
26405
  })
@@ -28648,7 +29150,12 @@ class RunnerReplicaRpcs extends make31(make30("Claim", {
28648
29150
  error: RunnerRpcError
28649
29151
  }), make30("KnownEvidence", {
28650
29152
  payload: { lease: ProgramLease, trees: ArraySchema(String5) },
28651
- success: ArraySchema(Struct({ tree: String5, name: String5, command: String5 })),
29153
+ success: ArraySchema(Struct({
29154
+ tree: String5,
29155
+ name: String5,
29156
+ command: String5,
29157
+ unjudgedFailure: optionalKey2(Boolean3)
29158
+ })),
28652
29159
  error: RunnerRpcError
28653
29160
  })).middleware(RunnerAuthentication) {
28654
29161
  }
@@ -31840,4 +32347,4 @@ var runKit = (config, identity, packages) => {
31840
32347
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31841
32348
  };
31842
32349
  // .kitman-build-entry.ts
31843
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.16" }, []);
32350
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.18" }, []);