@kitman-sh/software-engineering 0.10.81 → 0.10.83

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
@@ -19378,6 +19378,7 @@ var PipelineStatus = Struct({
19378
19378
  runnerChecks: optionalKey2(ArraySchema(String5)),
19379
19379
  approved: optionalKey2(String5),
19380
19380
  repository: optionalKey2(String5),
19381
+ targetBranch: optionalKey2(String5),
19381
19382
  conflicts: optionalKey2(Boolean3),
19382
19383
  needsRebase: optionalKey2(Boolean3),
19383
19384
  target: optionalKey2(Struct({ branch: String5, head: String5, jobs: ArraySchema(PipelineJob) }))
@@ -20068,6 +20069,12 @@ var MeasureEvidence = Struct({
20068
20069
  head: MeasureSamples,
20069
20070
  baseAgain: optionalKey2(MeasureSamples)
20070
20071
  });
20072
+ var ResolveSpec = Struct({
20073
+ revisions: ArraySchema(String5.check(isMinLength(1), isMaxLength(240))).check(isMinLength(1), isMaxLength(10))
20074
+ });
20075
+ var ResolvedRevisions = Struct({
20076
+ commits: ArraySchema(String5.check(isPattern2(new RegExp("^[0-9a-f]{40}([0-9a-f]{24})?$", "u"))))
20077
+ });
20071
20078
  var VerificationWorkUnit = Struct({
20072
20079
  kind: Literal2("verification"),
20073
20080
  id: Id,
@@ -20080,6 +20087,7 @@ var VerificationWorkUnit = Struct({
20080
20087
  baseline: optionalKey2(String5.check(isMinLength(1), isMaxLength(300))),
20081
20088
  checks: ArraySchema(RepositoryCheck).check(isMaxLength(50)),
20082
20089
  measure: optionalKey2(MeasureSpec),
20090
+ resolve: optionalKey2(ResolveSpec),
20083
20091
  hosts: optionalKey2(ArraySchema(NetworkHost)),
20084
20092
  storageOrigin: StorageOrigin
20085
20093
  });
@@ -20128,7 +20136,8 @@ var TreeEvidence = Struct({
20128
20136
  var VerificationEvidence = Struct({
20129
20137
  head: TreeEvidence,
20130
20138
  baseline: optionalKey2(TreeEvidence),
20131
- measurement: optionalKey2(MeasureEvidence)
20139
+ measurement: optionalKey2(MeasureEvidence),
20140
+ resolved: optionalKey2(ResolvedRevisions)
20132
20141
  });
20133
20142
  var BoundaryChange = Struct({
20134
20143
  kind: Literal2("change"),
@@ -20171,6 +20180,7 @@ var WorkUnitOutcome = Struct({
20171
20180
  evidence: optionalKey2(VerificationEvidence),
20172
20181
  boundary: optionalKey2(BoundaryChange),
20173
20182
  catchUp: optionalKey2(CatchUp),
20183
+ syncedTarget: optionalKey2(Revision),
20174
20184
  harnessHold: optionalKey2(HarnessHold),
20175
20185
  restart: optionalKey2(StepRestart),
20176
20186
  failureSummary: optionalKey2(String5.check(isMinLength(1), isMaxLength(4000)))
@@ -20301,6 +20311,14 @@ var measure = (name, request) => takeStep(name, "measure", "measure", gen2(funct
20301
20311
  });
20302
20312
  }));
20303
20313
 
20314
+ // ../../packages/sdk/src/loop/resolve.ts
20315
+ var resolveDeferred = (step) => make14(`resolve/${step}`, { success: ResolvedRevisions, error: StepFailed });
20316
+ var resolveRevisions = (name, revisions) => takeStep(name, "verify", "verify", gen2(function* () {
20317
+ const deferred = resolveDeferred(name);
20318
+ yield* launch(deferred, (host, token) => host.startVerification({ step: name, resolve: { revisions }, token }));
20319
+ return (yield* await_2(deferred)).commits;
20320
+ }));
20321
+
20304
20322
  // ../../packages/sdk/src/loop/test-loop.ts
20305
20323
  var LoopJournal = Struct({
20306
20324
  activities: Record(String5, Json2),
@@ -20345,7 +20363,7 @@ var defaultActivities = {
20345
20363
  },
20346
20364
  transcripts: { run: () => succeed7({ runs: [] }) },
20347
20365
  changeRequestRead: {
20348
- pipeline: () => succeed7({ head: "head", status: "success", source: "forge", jobs: [] }),
20366
+ pipeline: () => succeed7({ head: "head", status: "success", source: "forge", jobs: [], targetBranch: "main" }),
20349
20367
  reviewThreads: () => succeed7({ threads: [] }),
20350
20368
  opened: () => succeed7({ changeRequests: [] }),
20351
20369
  own: () => succeed7({ changeRequests: [] })
@@ -20392,6 +20410,7 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
20392
20410
  step: launch.step,
20393
20411
  agent: launch.agent,
20394
20412
  prompt: launch.prompt,
20413
+ output: launch.output,
20395
20414
  ...launch.skill === undefined ? undefined : { skill: launch.skill },
20396
20415
  ...launch.secrets === undefined ? undefined : { secrets: launch.secrets },
20397
20416
  ...launch.mergeTarget === undefined ? undefined : { mergeTarget: launch.mergeTarget }
@@ -20422,6 +20441,14 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
20422
20441
  claimResource: (launch) => flatMap3(script.claimed?.({ step: launch.step, resource: launch.resource, action: launch.action }) ?? undefined_2, (settled) => launch.action === "let_go" ? resolve(letGoDeferred(launch.step), launch.token, succeed4(null)) : resolve(claimDeferred(launch.step), launch.token, succeed4(settled ?? script.claims?.[launch.step] ?? { status: "granted", resource: launch.resource }))),
20423
20442
  startVerification: (launch) => {
20424
20443
  const scripted = script.verifications?.[launch.step];
20444
+ if (launch.resolve !== undefined) {
20445
+ const commits = launch.resolve.revisions.map((revision) => {
20446
+ const scriptedCommit = script.commits?.[revision];
20447
+ return scriptedCommit === undefined ? madeUpCommit(revision) : scriptedCommit;
20448
+ });
20449
+ const unnamed = launch.resolve.revisions.filter((_, index) => commits[index] === null);
20450
+ return resolve(resolveDeferred(launch.step), launch.token, unnamed.length > 0 ? fail5(new StepFailed({ step: launch.step, reason: `No commit named ${unnamed.join(", ")}` })) : succeed4({ commits: commits.filter((commit) => commit !== null) }));
20451
+ }
20425
20452
  if (launch.measure === undefined)
20426
20453
  verifyLaunches.push({
20427
20454
  step: launch.step,
@@ -20451,6 +20478,18 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
20451
20478
  }
20452
20479
  };
20453
20480
  };
20481
+ var fullSha = /^[0-9a-f]{40}$/u;
20482
+ var madeUpCommit = (revision) => {
20483
+ if (fullSha.test(revision))
20484
+ return revision;
20485
+ const word = (seed) => {
20486
+ let hash = seed;
20487
+ for (const char of revision)
20488
+ hash = Math.imul(hash ^ char.charCodeAt(0), 16777619) >>> 0;
20489
+ return hash.toString(16).padStart(8, "0");
20490
+ };
20491
+ return [2166136261, 16777619, 1540483477, 668265263, 374761393].map(word).join("");
20492
+ };
20454
20493
  var loopWorkflow = (loop) => make13(`kitman-loop/${loop.id}`, {
20455
20494
  payload: { input: Json2 },
20456
20495
  idempotencyKey: () => loop.id,
@@ -20653,10 +20692,11 @@ var merged = {
20653
20692
  settled: ArraySchema(String5)
20654
20693
  };
20655
20694
  var SyncAnswer = Union2([UpToDate, Struct(merged), Conflict]);
20695
+ var reported = { base: optionalKey2(String5) };
20656
20696
  var BaseSync = Union2([
20657
- UpToDate,
20658
- Struct({ ...merged, catchUp: optionalKey2(CatchUp) }),
20659
- Conflict
20697
+ Struct({ ...UpToDate.fields, ...reported }),
20698
+ Struct({ ...merged, catchUp: optionalKey2(CatchUp), ...reported }),
20699
+ Struct({ ...Conflict.fields, ...reported })
20660
20700
  ]);
20661
20701
  var afterMerge = "One thing comes before any answer of merged, a clean merge included, and stopping above means stopping after it: before you answer merged, do what the repository's agent instructions say to do once the target branch is merged in, such as regenerating this branch's database migrations on top of the target's. Leave what that changes in the workspace: Kitman commits it.";
20662
20702
  var prompt = (target) => [
@@ -20786,6 +20826,14 @@ var changeRequestBody = (build) => [
20786
20826
 
20787
20827
  `);
20788
20828
 
20829
+ // src/text-limits.ts
20830
+ var bounded2 = (maxLength, description) => String5.check(isMaxLength(maxLength)).annotate({ description });
20831
+ var OneSentence = bounded2(300, "One sentence, at most 300 characters.");
20832
+ var ChangeRequestSummary = bounded2(3000, "At most 3,000 characters.");
20833
+ var FindingDetail = bounded2(1200, "At most 1,200 characters.");
20834
+ var ShortStatement = bounded2(400, "One or two sentences, at most 400 characters.");
20835
+ var Reason = bounded2(600, "At most 600 characters.");
20836
+
20789
20837
  // src/review.ts
20790
20838
  var buildLoop = () => ({ id: "build", input: BuildInput, output: BuildOutput });
20791
20839
  var seats = {
@@ -20820,10 +20868,11 @@ var FollowUpStatus = Literals(["fixed", "changed", "still_there"]);
20820
20868
  var FollowUp = Struct({ id: String5, status: FollowUpStatus });
20821
20869
  var SeatFinding = Struct({
20822
20870
  ...Finding.fields,
20871
+ detail: FindingDetail,
20823
20872
  approvedCode: optional2(Boolean3)
20824
20873
  });
20825
20874
  var SeatOutput = Struct({
20826
- summary: String5,
20875
+ summary: OneSentence,
20827
20876
  findings: ArraySchema(SeatFinding),
20828
20877
  verdicts: optional2(ArraySchema(RebuttalVerdict)),
20829
20878
  scope: optional2(ScopeJudgement),
@@ -20846,25 +20895,48 @@ class ReviewTargetMissing extends TaggedError3()("ReviewTargetMissing", {
20846
20895
  message: String5
20847
20896
  }) {
20848
20897
  }
20849
- var targetOf = (input, head) => {
20898
+
20899
+ class ReviewDiffEmpty extends TaggedError3()("ReviewDiffEmpty", {
20900
+ message: String5
20901
+ }) {
20902
+ }
20903
+
20904
+ class ReviewBaseUnpinned extends TaggedError3()("ReviewBaseUnpinned", {
20905
+ message: String5
20906
+ }) {
20907
+ }
20908
+ var targetOf = (input, { base, head }) => {
20850
20909
  if (input.changeRequestId !== undefined)
20851
- return `ChangeRequest ${input.changeRequestId} at revision ${head}. Read it with \`kitman.changeRequests.get("${input.changeRequestId}")\` through Kitman's MCP, fetch its source branch, and review the diff of revision ${head} against its target branch, even if the branch has moved since. If the Runner cannot fetch that revision (a fork, say), report exactly that as your only finding, a blocker, and stop.`;
20852
- if (input.base !== undefined && input.head !== undefined && input.files === undefined && input.approved !== undefined)
20910
+ return `ChangeRequest ${input.changeRequestId} at revision ${head}: \`git diff ${base}...${head}\`, its change against its target branch as that stood when this review started. Read it with \`kitman.changeRequests.get("${input.changeRequestId}")\` through Kitman's MCP and fetch its source branch; diff exactly those commits even if either branch has moved since. If the Runner cannot fetch that revision (a fork, say), report exactly that as your only finding, a blocker, and stop.`;
20911
+ if (input.files === undefined && input.approved !== undefined)
20853
20912
  return [
20854
- `only what the change gained or lost since it was approved at ${input.approved}: compare \`git diff ${input.base}...${input.approved}\`, the change as approved, with \`git diff ${input.base}...${input.head}\`, the change now, in your checkout. The rest was reviewed and approved before.`,
20913
+ `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.`,
20855
20914
  "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."
20856
20915
  ].join(`
20857
20916
 
20858
20917
  `);
20859
- if (input.base !== undefined && input.head !== undefined)
20860
- return input.files === undefined ? `the change \`git diff ${input.base}...${input.head}\` in your checkout.` : [
20861
- `only these files of the change \`git diff ${input.base}...${input.head}\` in your checkout; the rest of it was reviewed and approved before:`,
20862
- ...input.files.map((file) => `- ${file}`),
20863
- ...input.since === undefined ? [] : [`Also review all of \`git diff ${input.since}..${input.head}\`, whichever files it touches.`]
20864
- ].join(`
20918
+ return input.files === undefined ? `the change \`git diff ${base}...${head}\` in your checkout.` : [
20919
+ `only these files of the change \`git diff ${base}...${head}\` in your checkout; the rest of it was reviewed and approved before:`,
20920
+ ...input.files.map((file) => `- ${file}`),
20921
+ ...input.since === undefined ? [] : [`Also review all of \`git diff ${input.since}..${head}\`, whichever files it touches.`]
20922
+ ].join(`
20865
20923
  `);
20866
- return;
20867
20924
  };
20925
+ var pinnedRange = (input) => gen2(function* () {
20926
+ if (input.changeRequestId !== undefined) {
20927
+ const status = yield* pipelineStatus("head", { changeRequestId: input.changeRequestId });
20928
+ if (status.targetBranch === undefined)
20929
+ return yield* new ReviewBaseUnpinned({
20930
+ message: `Kitman did not say which branch ChangeRequest ${input.changeRequestId} merges into, so there is no base to review against; update Kitman`
20931
+ });
20932
+ const [base = ""] = yield* resolveRevisions("pin", [`origin/${status.targetBranch}`]);
20933
+ return { base, head: status.head.toLowerCase() };
20934
+ }
20935
+ if (input.base === undefined || input.head === undefined)
20936
+ return yield* new ReviewTargetMissing({ message: "Name a ChangeRequest, or both base and head revisions" });
20937
+ const [base = "", head = ""] = yield* resolveRevisions("pin", [input.base, input.head]);
20938
+ return { base, head };
20939
+ });
20868
20940
  var wholeChange = (input) => input.files === undefined && input.approved === undefined;
20869
20941
  var scopePrompt = (input) => [
20870
20942
  "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? Set `met` to true only if it does all of it, and list in `unmet` one line for each criterion or part of the description that is not done. If your brief has no Task, leave `scope` out.",
@@ -20939,7 +21011,7 @@ var fixBrief = (changeRequestId, findings) => [
20939
21011
  `);
20940
21012
  var review_default = defineLoop({
20941
21013
  id: "review",
20942
- version: "3.5.0",
21014
+ version: "3.6.0",
20943
21015
  title: "Review",
20944
21016
  input: Input,
20945
21017
  output: Output,
@@ -20963,10 +21035,13 @@ var review_default = defineLoop({
20963
21035
  { id: "review", title: "Review again", loop: "review" }
20964
21036
  ],
20965
21037
  run: (input) => gen2(function* () {
20966
- const head = input.changeRequestId === undefined ? undefined : (yield* pipelineStatus("head", { changeRequestId: input.changeRequestId })).head;
20967
- const target = targetOf(input, head);
20968
- if (target === undefined)
20969
- return yield* new ReviewTargetMissing({ message: "Name a ChangeRequest, or both base and head revisions" });
21038
+ const range = yield* pinnedRange(input);
21039
+ const head = input.changeRequestId === undefined ? undefined : range.head;
21040
+ if (range.base === range.head)
21041
+ return yield* new ReviewDiffEmpty({
21042
+ message: `Base and head are both commit ${range.head}, so the diff is empty: give the base the change is to merge into`
21043
+ });
21044
+ const target = targetOf(input, range);
20970
21045
  const verified = head === undefined ? { failing: [], notRun: [] } : yield* verifyHead("verify", head);
20971
21046
  const failing = [...new Set([...input.failing ?? [], ...verified.failing])];
20972
21047
  const notRun = [...new Set([...input.notRun ?? [], ...verified.notRun])];
@@ -21080,7 +21155,7 @@ var Drafted = Struct({
21080
21155
  });
21081
21156
  var Deployed = Struct({
21082
21157
  status: Literals(["deployed", "failed", "rolled_back", "rollback_failed", "none"]),
21083
- detail: String5
21158
+ detail: FindingDetail
21084
21159
  });
21085
21160
  var deployPrompt = (tag, previousTag) => [
21086
21161
  `Deploy the release ${tag}, which Kitman has just tagged and pushed.`,
@@ -21444,7 +21519,7 @@ var Input3 = Struct({
21444
21519
  var Output3 = ShepherdOutput;
21445
21520
  var CiFix = Struct({
21446
21521
  verdict: Literals(["fixed", "pre_existing", "flaky"]),
21447
- summary: String5
21522
+ summary: OneSentence
21448
21523
  });
21449
21524
  var Replies = Struct({
21450
21525
  replies: ArraySchema(Struct({
@@ -21484,7 +21559,7 @@ var threadLine = (thread) => [
21484
21559
  ].join(`
21485
21560
  `);
21486
21561
  var ReviewFix = Struct({
21487
- summary: String5,
21562
+ summary: OneSentence,
21488
21563
  changed: Boolean3
21489
21564
  });
21490
21565
  var findingLines2 = (findings) => findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`).join(`
@@ -22182,7 +22257,7 @@ var BuildInput = Struct({
22182
22257
  var CriterionAnswer = Struct({
22183
22258
  criterion: String5,
22184
22259
  status: Literals(["met", "after_merge", "not_met"]),
22185
- detail: String5
22260
+ detail: ShortStatement
22186
22261
  });
22187
22262
  var Criteria = Struct({ criteria: ArraySchema(CriterionAnswer) });
22188
22263
  var SuggestedCheck = Struct({
@@ -22192,8 +22267,8 @@ var SuggestedCheck = Struct({
22192
22267
  });
22193
22268
  var Implemented = Struct({
22194
22269
  title: String5,
22195
- summary: String5,
22196
- claims: ArraySchema(String5),
22270
+ summary: ChangeRequestSummary,
22271
+ claims: ArraySchema(ShortStatement),
22197
22272
  documented: optional2(ArraySchema(String5)),
22198
22273
  rollback: optional2(String5),
22199
22274
  criteria: optional2(ArraySchema(CriterionAnswer)),
@@ -22201,16 +22276,17 @@ var Implemented = Struct({
22201
22276
  });
22202
22277
  var Reproduced = Struct({
22203
22278
  check: String5,
22204
- summary: String5
22279
+ summary: ChangeRequestSummary
22205
22280
  });
22206
22281
  var ReproducedOnBranch = Struct({
22207
22282
  ...Reproduced.fields,
22208
22283
  revision: optional2(String5)
22209
22284
  });
22285
+ var FixRebuttal = Struct({ ...Rebuttal.fields, reason: Reason });
22210
22286
  var Fixed = Struct({
22211
- summary: String5,
22212
- claims: ArraySchema(String5),
22213
- rebuttals: ArraySchema(Rebuttal)
22287
+ summary: ChangeRequestSummary,
22288
+ claims: ArraySchema(ShortStatement),
22289
+ rebuttals: ArraySchema(FixRebuttal)
22214
22290
  });
22215
22291
  var BuildOutput = Struct({
22216
22292
  changeRequest: ChangeRequestResult,
@@ -22232,6 +22308,11 @@ class BuildBlocked extends TaggedError3()("BuildBlocked", {
22232
22308
  }) {
22233
22309
  }
22234
22310
 
22311
+ class BuildBaseUnpinned extends TaggedError3()("BuildBaseUnpinned", {
22312
+ message: String5
22313
+ }) {
22314
+ }
22315
+
22235
22316
  class BuildTargetMissing extends TaggedError3()("BuildTargetMissing", {
22236
22317
  message: String5
22237
22318
  }) {
@@ -22328,6 +22409,11 @@ var rally = (input) => gen2(function* () {
22328
22409
  });
22329
22410
  if (synced.status === "conflict")
22330
22411
  conflicts.push(`Could not merge the target branch in round ${round}: ${synced.files.join(", ")} (${synced.reason})`);
22412
+ const base = synced.base;
22413
+ if (base === undefined)
22414
+ return yield* new BuildBaseUnpinned({
22415
+ message: `The Runner did not report which commit of ${input.target ?? "the default branch"} it merged in round ${round}, so there is no base to review against; update the Runner`
22416
+ });
22331
22417
  const head = yield* verify(`verify:${round}`, { suggested: input.suggested });
22332
22418
  if (last !== undefined && last.head.tree === head.tree && rebuttals.length === 0 && onlyChecksBlock(last.settled))
22333
22419
  return {
@@ -22341,7 +22427,7 @@ var rally = (input) => gen2(function* () {
22341
22427
  const failing = brokenChecks(head).map((check) => check.name);
22342
22428
  const notRun = testsNotRunReasons(head);
22343
22429
  const reviewed = yield* call(`review:${round}`, review_default, {
22344
- base: input.base,
22430
+ base,
22345
22431
  head: head.revision,
22346
22432
  ...rebuttals.length === 0 ? undefined : { rebuttals },
22347
22433
  ...earlier.length === 0 ? undefined : { earlier },
@@ -22385,7 +22471,7 @@ var rally = (input) => gen2(function* () {
22385
22471
  });
22386
22472
  var build2 = defineLoop({
22387
22473
  id: "build",
22388
- version: "2.4.0",
22474
+ version: "2.5.0",
22389
22475
  title: "Build",
22390
22476
  input: BuildInput,
22391
22477
  output: BuildOutput,
@@ -22409,7 +22495,7 @@ var build2 = defineLoop({
22409
22495
  yield* writeBack("write-back:started", { milestone: "started" });
22410
22496
  const task = input.words === undefined ? "the Task your brief describes." : `this: ${input.words}`;
22411
22497
  const outcome = input.outcome;
22412
- const target = input.branch ?? input.continuing?.targetBranch;
22498
+ const target = input.continuing?.targetBranch ?? input.branch;
22413
22499
  if (input.changeRequestId !== undefined && input.continuing?.changeRequestId !== input.changeRequestId)
22414
22500
  return yield* new BuildTargetMissing({
22415
22501
  message: `Kitman did not put this Run on ChangeRequest ${input.changeRequestId}'s branch`
@@ -22435,7 +22521,6 @@ var build2 = defineLoop({
22435
22521
  })).criteria : implemented.criteria ?? [];
22436
22522
  const last = yield* rally({
22437
22523
  maxRounds: input.maxRounds ?? 3,
22438
- base: `origin/${target ?? "HEAD"}`,
22439
22524
  target,
22440
22525
  outcome,
22441
22526
  claims: [...implemented.claims, ...criteria.map((answer) => `Criterion ${answerLine(answer)}`)],
@@ -22571,7 +22656,7 @@ var Input4 = Struct({
22571
22656
  });
22572
22657
  var Done3 = Struct({
22573
22658
  status: Literals(["done", "blocked", "too_big"]),
22574
- summary: String5,
22659
+ summary: ChangeRequestSummary,
22575
22660
  changed: Boolean3,
22576
22661
  title: optional2(String5),
22577
22662
  checks: optional2(ArraySchema(SuggestedCheck))
@@ -22700,7 +22785,7 @@ var Input5 = Struct({
22700
22785
  });
22701
22786
  var Opportunity = Struct({
22702
22787
  title: String5,
22703
- detail: String5,
22788
+ detail: FindingDetail,
22704
22789
  evidence: Literals(["measured", "telemetry", "hypothesis"]),
22705
22790
  external: optional2(Boolean3)
22706
22791
  });
@@ -22711,12 +22796,12 @@ var Discovery = Struct({
22711
22796
  opportunities: ArraySchema(Opportunity)
22712
22797
  });
22713
22798
  var Harness = Struct({
22714
- summary: String5,
22799
+ summary: OneSentence,
22715
22800
  plan: MeasurePlan
22716
22801
  });
22717
22802
  var Change = Struct({
22718
22803
  status: Literals(["changed", "exhausted", "unsafe"]),
22719
- summary: String5
22804
+ summary: OneSentence
22720
22805
  });
22721
22806
  var Kept = Struct({ summary: String5, verdict: String5, reason: String5 });
22722
22807
  var Output6 = Struct({
@@ -22952,7 +23037,7 @@ var hillclimb_default = defineLoop({
22952
23037
  yield* agentWork(`fix:${round}`, {
22953
23038
  agent: "implementer",
22954
23039
  prompt: fixPrompt2(blocking),
22955
- output: Struct({ summary: String5 })
23040
+ output: Struct({ summary: OneSentence })
22956
23041
  });
22957
23042
  const fixed = yield* verify(`verify:fix:${round}`, {});
22958
23043
  if (!fixed.passed) {
@@ -23019,7 +23104,7 @@ var Input6 = Struct({
23019
23104
  autoFix: optional2(Boolean3)
23020
23105
  });
23021
23106
  var Conclusion = Struct({
23022
- summary: String5,
23107
+ summary: OneSentence,
23023
23108
  cause: String5,
23024
23109
  confidence: Literals(["high", "medium", "low"]),
23025
23110
  sources: NonEmptyArray(String5),
@@ -23689,7 +23774,7 @@ var Fix = Struct({
23689
23774
  var NextSteps = Struct({ tickets: PlanTickets });
23690
23775
  var Report = Struct({
23691
23776
  title: String5,
23692
- summary: String5,
23777
+ summary: OneSentence,
23693
23778
  findings: ArraySchema(Struct({
23694
23779
  finding: String5,
23695
23780
  basis: Literals(["observed", "read", "inferred"]),
@@ -23862,7 +23947,7 @@ var Finding2 = Struct({
23862
23947
  category: Category,
23863
23948
  kind: Literals(["memory", "task"]),
23864
23949
  lesson: String5,
23865
- detail: optional2(String5),
23950
+ detail: optional2(FindingDetail),
23866
23951
  fix: optional2(Struct({ size: Literals(["errand", "build"]), words: String5 })),
23867
23952
  citations: ArraySchema(TranscriptPoint)
23868
23953
  });
@@ -23876,9 +23961,9 @@ var Proposal2 = Struct({
23876
23961
  runIds: ArraySchema(String5)
23877
23962
  });
23878
23963
  var Output11 = Struct({
23879
- summary: String5,
23964
+ summary: OneSentence,
23880
23965
  proposals: ArraySchema(Proposal2),
23881
- leftOut: ArraySchema(Struct({ key: String5, reason: String5 })),
23966
+ leftOut: ArraySchema(Struct({ key: String5, reason: Reason })),
23882
23967
  improvements: ArraySchema(Struct({ key: String5, loop: Literals(["errand", "build"]), outcome: String5 }))
23883
23968
  });
23884
23969
  var prompt4 = (runs, days) => [
@@ -23997,7 +24082,7 @@ var Assessed = Struct({
23997
24082
  var Batched = Struct({
23998
24083
  applied: ArraySchema(String5),
23999
24084
  dropped: ArraySchema(Struct({ number: String5, reason: String5 })),
24000
- summary: String5
24085
+ summary: OneSentence
24001
24086
  });
24002
24087
  var Placed = Struct({ number: String5, title: String5, url: String5, reason: String5 });
24003
24088
  var Output12 = Struct({
@@ -24250,8 +24335,8 @@ var Tidied = Struct({
24250
24335
  improved: Boolean3,
24251
24336
  hint: optional2(Hint),
24252
24337
  title: optional2(String5),
24253
- summary: String5,
24254
- claims: ArraySchema(String5)
24338
+ summary: OneSentence,
24339
+ claims: ArraySchema(ShortStatement)
24255
24340
  });
24256
24341
  var Output13 = Struct({
24257
24342
  status: Literals(["nothing_worth_it", "reported", "planned", "opened"]),
@@ -24431,7 +24516,11 @@ What next?`,
24431
24516
 
24432
24517
  // kitman.config.ts
24433
24518
  var fallbacks = [{ harness: "pi" }];
24434
- var reviewer = { harness: "pi", model: "openai-codex/gpt-6.1-sol", fallbacks: [{ harness: "claude" }] };
24519
+ var reviewer = {
24520
+ harness: "pi",
24521
+ model: "openai-codex/gpt-6.1-sol",
24522
+ fallbacks: [{ harness: "claude", model: "opus", effort: "high" }]
24523
+ };
24435
24524
  var kitman_config_default = defineKit({
24436
24525
  loops: [
24437
24526
  build_default,
@@ -27143,7 +27232,8 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
27143
27232
  plan: MeasurePlan,
27144
27233
  samples: Int,
27145
27234
  calibrate: Boolean3
27146
- }))
27235
+ })),
27236
+ resolve: optionalKey2(ResolveSpec)
27147
27237
  },
27148
27238
  success: Struct({ verificationId: String5 }),
27149
27239
  error: RunnerRpcError
@@ -27284,6 +27374,7 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
27284
27374
  runnerChecks: optionalKey2(ArraySchema(String5)),
27285
27375
  approved: optionalKey2(String5),
27286
27376
  repository: optionalKey2(String5),
27377
+ targetBranch: optionalKey2(String5),
27287
27378
  conflicts: optionalKey2(Boolean3),
27288
27379
  needsRebase: optionalKey2(Boolean3),
27289
27380
  target: optionalKey2(Struct({
@@ -27642,12 +27733,13 @@ var runnerHost = (capabilities) => ({
27642
27733
  })).pipe(asVoid2),
27643
27734
  startVerification: (launch) => requested(launch.step, capabilities.startVerification({
27644
27735
  step: launch.step,
27645
- deferredName: (launch.measure === undefined ? verifyDeferred : measureDeferred)(launch.step).name,
27736
+ deferredName: (launch.resolve !== undefined ? resolveDeferred : launch.measure === undefined ? verifyDeferred : measureDeferred)(launch.step).name,
27646
27737
  ...launch.revision === undefined ? undefined : { revision: launch.revision },
27647
27738
  ...launch.checks === undefined ? undefined : { checks: launch.checks },
27648
27739
  ...launch.suggested === undefined ? undefined : { suggested: launch.suggested },
27649
27740
  ...launch.rerunFailed === undefined ? undefined : { rerunFailed: launch.rerunFailed },
27650
- ...launch.measure === undefined ? undefined : { measure: launch.measure }
27741
+ ...launch.measure === undefined ? undefined : { measure: launch.measure },
27742
+ ...launch.resolve === undefined ? undefined : { resolve: launch.resolve }
27651
27743
  })).pipe(asVoid2),
27652
27744
  startAgentWork: (launch) => requested(launch.step, capabilities.startAgentStep({
27653
27745
  step: launch.step,
@@ -27873,7 +27965,8 @@ var rpcProgramPorts = (rpc, work) => {
27873
27965
  ...verification.checks === undefined ? undefined : { checks: [...verification.checks] },
27874
27966
  ...verification.suggested === undefined ? undefined : { suggested: [...verification.suggested] },
27875
27967
  ...verification.rerunFailed === undefined ? undefined : { rerunFailed: verification.rerunFailed },
27876
- ...verification.measure === undefined ? undefined : { measure: verification.measure }
27968
+ ...verification.measure === undefined ? undefined : { measure: verification.measure },
27969
+ ...verification.resolve === undefined ? undefined : { resolve: { revisions: [...verification.resolve.revisions] } }
27877
27970
  }),
27878
27971
  startAgentStep: ({ secrets, ...step }) => rpc.startAgentStep({ lease, ...step, ...secrets === undefined ? undefined : { secrets: [...secrets] } }),
27879
27972
  awaitEvent: (wait) => rpc.awaitEvent({ lease, ...wait }),
@@ -30169,4 +30262,4 @@ var runKit = (config, identity, packages) => {
30169
30262
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
30170
30263
  };
30171
30264
  // .kitman-build-entry.ts
30172
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.81" }, []);
30265
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.83" }, []);
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "id": "build",
5
5
  "title": "Build",
6
- "version": "2.4.0",
6
+ "version": "2.5.0",
7
7
  "input": {
8
8
  "type": "object",
9
9
  "properties": {
@@ -268,7 +268,9 @@
268
268
  ]
269
269
  },
270
270
  "detail": {
271
- "type": "string"
271
+ "type": "string",
272
+ "maxLength": 400,
273
+ "description": "One or two sentences, at most 400 characters."
272
274
  }
273
275
  },
274
276
  "required": [
@@ -1948,7 +1950,9 @@
1948
1950
  "type": "object",
1949
1951
  "properties": {
1950
1952
  "summary": {
1951
- "type": "string"
1953
+ "type": "string",
1954
+ "maxLength": 300,
1955
+ "description": "One sentence, at most 300 characters."
1952
1956
  },
1953
1957
  "proposals": {
1954
1958
  "type": "array",
@@ -2011,7 +2015,9 @@
2011
2015
  "type": "string"
2012
2016
  },
2013
2017
  "reason": {
2014
- "type": "string"
2018
+ "type": "string",
2019
+ "maxLength": 600,
2020
+ "description": "At most 600 characters."
2015
2021
  }
2016
2022
  },
2017
2023
  "required": [
@@ -2096,7 +2102,7 @@
2096
2102
  {
2097
2103
  "id": "review",
2098
2104
  "title": "Review",
2099
- "version": "3.5.0",
2105
+ "version": "3.6.0",
2100
2106
  "input": {
2101
2107
  "type": "object",
2102
2108
  "properties": {
@@ -3299,7 +3305,9 @@
3299
3305
  "effort": "high",
3300
3306
  "fallbacks": [
3301
3307
  {
3302
- "harness": "claude"
3308
+ "harness": "claude",
3309
+ "model": "opus",
3310
+ "effort": "high"
3303
3311
  }
3304
3312
  ]
3305
3313
  },
@@ -3409,7 +3417,7 @@
3409
3417
  "carried": [
3410
3418
  {
3411
3419
  "name": "@kitman-sh/software-engineering",
3412
- "version": "0.10.81",
3420
+ "version": "0.10.83",
3413
3421
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
3414
3422
  "loops": [
3415
3423
  "build",
package/kitman.config.ts CHANGED
@@ -24,9 +24,14 @@ const fallbacks = [{ harness: 'pi' }]
24
24
 
25
25
  /**
26
26
  * Reviews run on Pi, off the Claude subscription, with another model family checking Opus's work; pi's `--model` is a
27
- * fuzzy pattern with no alias for the latest Sol, so it is pinned and bumped here.
27
+ * fuzzy pattern with no alias for the latest Sol, so it is pinned and bumped here. When Codex is out of quota, Opus at
28
+ * high effort reviews instead.
28
29
  */
29
- const reviewer = { harness: 'pi', model: 'openai-codex/gpt-6.1-sol', fallbacks: [{ harness: 'claude' }] }
30
+ const reviewer = {
31
+ harness: 'pi',
32
+ model: 'openai-codex/gpt-6.1-sol',
33
+ fallbacks: [{ harness: 'claude', model: 'opus', effort: 'high' as const }]
34
+ }
30
35
 
31
36
  /** Kitman's Kit for building software: its Loops, the Agents they run, and the skills those use. */
32
37
  export default defineKit({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/software-engineering",
3
- "version": "0.10.81",
3
+ "version": "0.10.83",
4
4
  "description": "Everything for building software: Loops, their Agents, the skills they use and the Ponytail plugin.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -17,12 +17,12 @@
17
17
  "tsconfig.json"
18
18
  ],
19
19
  "dependencies": {
20
- "@kitman-sh/sdk": "0.10.81",
21
- "effect": "4.1.2"
20
+ "@kitman-sh/sdk": "0.10.83",
21
+ "effect": "^4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "8b38eb9071e521d41da1abdfb4579ddbaed942e423430be8211817fafaad6280",
25
+ "digest": "2ebc1034e681c6f84e977ff6d45fa9612edfcbe582157648d7c7247bb441bfae",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
package/src/build.ts CHANGED
@@ -45,6 +45,7 @@ import {
45
45
  import review from './review'
46
46
  import shepherd from './shepherd'
47
47
  import { ShepherdOutput } from './shepherd-output'
48
+ import { ChangeRequestSummary, Reason, ShortStatement } from './text-limits'
48
49
 
49
50
  export const BuildInput = Schema.Struct({
50
51
  /** What to build, when no Task says it. */
@@ -79,7 +80,7 @@ const CriterionAnswer = Schema.Struct({
79
80
  criterion: Schema.String,
80
81
  status: Schema.Literals(['met', 'after_merge', 'not_met']),
81
82
  /** The test or file that shows it met, or why it is after merge or not met. */
82
- detail: Schema.String
83
+ detail: ShortStatement
83
84
  })
84
85
 
85
86
  type CriterionAnswer = typeof CriterionAnswer.Type
@@ -95,8 +96,8 @@ export const SuggestedCheck = Schema.Struct({
95
96
  const Implemented = Schema.Struct({
96
97
  /** The ChangeRequest's title. */
97
98
  title: Schema.String,
98
- summary: Schema.String,
99
- claims: Schema.Array(Schema.String),
99
+ summary: ChangeRequestSummary,
100
+ claims: Schema.Array(ShortStatement),
100
101
  /** The approved checks that run the documented commands, for a docs Outcome. */
101
102
  documented: Schema.optional(Schema.Array(Schema.String)),
102
103
  /** The approved check that rolls a migration back. */
@@ -110,7 +111,7 @@ const Implemented = Schema.Struct({
110
111
  const Reproduced = Schema.Struct({
111
112
  /** The approved check that reproduces the bug. */
112
113
  check: Schema.String,
113
- summary: Schema.String
114
+ summary: ChangeRequestSummary
114
115
  })
115
116
 
116
117
  /** A bug's proof; a continued Build recovers it from the branch an earlier Run left. */
@@ -120,10 +121,12 @@ const ReproducedOnBranch = Schema.Struct({
120
121
  revision: Schema.optional(Schema.String)
121
122
  })
122
123
 
124
+ const FixRebuttal = Schema.Struct({ ...Rebuttal.fields, reason: Reason })
125
+
123
126
  const Fixed = Schema.Struct({
124
- summary: Schema.String,
125
- claims: Schema.Array(Schema.String),
126
- rebuttals: Schema.Array(Rebuttal)
127
+ summary: ChangeRequestSummary,
128
+ claims: Schema.Array(ShortStatement),
129
+ rebuttals: Schema.Array(FixRebuttal)
127
130
  })
128
131
 
129
132
  export const BuildOutput = Schema.Struct({
@@ -150,6 +153,11 @@ export class BuildBlocked extends Schema.TaggedError<BuildBlocked>()('BuildBlock
150
153
  message: Schema.String
151
154
  }) {}
152
155
 
156
+ /** The base sync did not say which target commit it merged, so a review would have no fixed base to diff against. */
157
+ export class BuildBaseUnpinned extends Schema.TaggedError<BuildBaseUnpinned>()('BuildBaseUnpinned', {
158
+ message: Schema.String
159
+ }) {}
160
+
153
161
  export class BuildTargetMissing extends Schema.TaggedError<BuildTargetMissing>()('BuildTargetMissing', {
154
162
  message: Schema.String
155
163
  }) {}
@@ -275,7 +283,6 @@ type Round = {
275
283
  */
276
284
  const rally = (input: {
277
285
  readonly maxRounds: number
278
- readonly base: string
279
286
  readonly target: string | undefined
280
287
  readonly outcome: LoopOutcome | undefined
281
288
  readonly claims: readonly string[]
@@ -302,6 +309,14 @@ const rally = (input: {
302
309
  `Could not merge the target branch in round ${round}: ${synced.files.join(', ')} (${synced.reason})`
303
310
  )
304
311
 
312
+ // Pinned, so a target that moves during the round does not move what is reviewed.
313
+ const base = synced.base
314
+
315
+ if (base === undefined)
316
+ return yield* new BuildBaseUnpinned({
317
+ message: `The Runner did not report which commit of ${input.target ?? 'the default branch'} it merged in round ${round}, so there is no base to review against; update the Runner`
318
+ })
319
+
305
320
  const head = yield* verify(`verify:${round}`, { suggested: input.suggested })
306
321
 
307
322
  // Evidence is held per tree, so the same checks would fail again and a review would judge the same change.
@@ -319,7 +334,7 @@ const rally = (input: {
319
334
  const notRun = testsNotRunReasons(head)
320
335
 
321
336
  const reviewed = yield* call(`review:${round}`, review, {
322
- base: input.base,
337
+ base,
323
338
  head: head.revision,
324
339
  ...(rebuttals.length === 0 ? undefined : { rebuttals }),
325
340
  ...(earlier.length === 0 ? undefined : { earlier }),
@@ -393,7 +408,7 @@ const rally = (input: {
393
408
  */
394
409
  const build = defineLoop({
395
410
  id: 'build',
396
- version: '2.4.0',
411
+ version: '2.5.0',
397
412
  title: 'Build',
398
413
  input: BuildInput,
399
414
  output: BuildOutput,
@@ -422,7 +437,8 @@ const build = defineLoop({
422
437
 
423
438
  const task = input.words === undefined ? 'the Task your brief describes.' : `this: ${input.words}`
424
439
  const outcome = input.outcome
425
- const target = input.branch ?? input.continuing?.targetBranch
440
+ // A retry carries the Run's own branch as `branch`; the ChangeRequest it continues says what it merges into.
441
+ const target = input.continuing?.targetBranch ?? input.branch
426
442
 
427
443
  if (input.changeRequestId !== undefined && input.continuing?.changeRequestId !== input.changeRequestId)
428
444
  return yield* new BuildTargetMissing({
@@ -472,8 +488,6 @@ const build = defineLoop({
472
488
 
473
489
  const last = yield* rally({
474
490
  maxRounds: input.maxRounds ?? 3,
475
- // Against the target, not `revision`: a Build handed a revision, such as an Errand's head, reviews that change too.
476
- base: `origin/${target ?? 'HEAD'}`,
477
491
  target,
478
492
  outcome,
479
493
  claims: [...implemented.claims, ...criteria.map(answer => `Criterion ${answerLine(answer)}`)],
package/src/errand.ts CHANGED
@@ -13,6 +13,7 @@ import * as Effect from 'effect/Effect'
13
13
  import * as Schema from 'effect/Schema'
14
14
  import build, { implementAdaptation, SuggestedCheck } from './build'
15
15
  import { evidenceTable } from './change-request-body'
16
+ import { ChangeRequestSummary } from './text-limits'
16
17
 
17
18
  const Input = Schema.Struct({
18
19
  /** What to just do. */
@@ -27,7 +28,7 @@ const Done = Schema.Struct({
27
28
  /** done: finished; blocked: something stopped it; too_big: it is a feature, not an errand, and nothing changed. */
28
29
  status: Schema.Literals(['done', 'blocked', 'too_big']),
29
30
  /** What it did or found, or what stopped it, for the person who asked. */
30
- summary: Schema.String,
31
+ summary: ChangeRequestSummary,
31
32
  /** Whether it changed any file. */
32
33
  changed: Schema.Boolean,
33
34
  /** The ChangeRequest's title, when it changed files. */
package/src/firewatch.ts CHANGED
@@ -3,6 +3,7 @@ import * as Effect from 'effect/Effect'
3
3
  import * as Predicate from 'effect/Predicate'
4
4
  import * as Schema from 'effect/Schema'
5
5
  import build from './build'
6
+ import { OneSentence } from './text-limits'
6
7
 
7
8
  const Input = Schema.Struct({
8
9
  /** The alert as the monitoring Connection received it. */
@@ -21,7 +22,7 @@ const Input = Schema.Struct({
21
22
  type Alert = (typeof Input.Type)['alert']
22
23
 
23
24
  const Conclusion = Schema.Struct({
24
- summary: Schema.String,
25
+ summary: OneSentence,
25
26
  cause: Schema.String,
26
27
  /** high: the evidence shows it; medium: it fits but something is unchecked; low: a best guess. */
27
28
  confidence: Schema.Literals(['high', 'medium', 'low']),
package/src/hillclimb.ts CHANGED
@@ -22,6 +22,7 @@ import * as Effect from 'effect/Effect'
22
22
  import * as Schema from 'effect/Schema'
23
23
  import { notVerifiedSection, scopeFindings } from './change-request-body'
24
24
  import review from './review'
25
+ import { FindingDetail, OneSentence } from './text-limits'
25
26
 
26
27
  const Input = Schema.Struct({
27
28
  /** What to make faster, in words; the journeys that matter most when left out. */
@@ -40,7 +41,7 @@ const Input = Schema.Struct({
40
41
 
41
42
  const Opportunity = Schema.Struct({
42
43
  title: Schema.String,
43
- detail: Schema.String,
44
+ detail: FindingDetail,
44
45
  /** measured: a number shows it; telemetry: production data shows it; hypothesis: reading the code suggests it. */
45
46
  evidence: Schema.Literals(['measured', 'telemetry', 'hypothesis']),
46
47
  /** Only another repository can make it; offered as a Task at the end, never made here. */
@@ -59,14 +60,14 @@ const Discovery = Schema.Struct({
59
60
 
60
61
  const Harness = Schema.Struct({
61
62
  /** What the benchmark exercises and why it stands for the journeys. */
62
- summary: Schema.String,
63
+ summary: OneSentence,
63
64
  plan: MeasurePlan
64
65
  })
65
66
 
66
67
  const Change = Schema.Struct({
67
68
  /** changed: one change is committed; exhausted: nothing left worth trying; unsafe: the gain would cost correctness. */
68
69
  status: Schema.Literals(['changed', 'exhausted', 'unsafe']),
69
- summary: Schema.String
70
+ summary: OneSentence
70
71
  })
71
72
 
72
73
  const Kept = Schema.Struct({ summary: Schema.String, verdict: Schema.String, reason: Schema.String })
@@ -362,7 +363,7 @@ export default defineLoop({
362
363
  yield* agentWork(`fix:${round}`, {
363
364
  agent: 'implementer',
364
365
  prompt: fixPrompt(blocking),
365
- output: Schema.Struct({ summary: Schema.String })
366
+ output: Schema.Struct({ summary: OneSentence })
366
367
  })
367
368
 
368
369
  const fixed = yield* verify(`verify:fix:${round}`, {})
package/src/hindsight.ts CHANGED
@@ -12,6 +12,7 @@ import * as Effect from 'effect/Effect'
12
12
  import * as Schema from 'effect/Schema'
13
13
  import build from './build'
14
14
  import errand from './errand'
15
+ import { FindingDetail, OneSentence, Reason } from './text-limits'
15
16
 
16
17
  const Input = Schema.Struct({
17
18
  /** How many days back to read; a week when left out. */
@@ -44,7 +45,7 @@ const Finding = Schema.Struct({
44
45
  /** The Memory's words, or the Task's title. */
45
46
  lesson: Schema.String,
46
47
  /** The Task's description. */
47
- detail: Schema.optional(Schema.String),
48
+ detail: Schema.optional(FindingDetail),
48
49
  /** How to fix the cause when a Run may start on it: an errand for a small change, a build for a feature. */
49
50
  fix: Schema.optional(Schema.Struct({ size: Schema.Literals(['errand', 'build']), words: Schema.String })),
50
51
  citations: Schema.Array(TranscriptPoint)
@@ -66,10 +67,10 @@ const Proposal = Schema.Struct({
66
67
 
67
68
  const Output = Schema.Struct({
68
69
  /** One line on what the Run found. */
69
- summary: Schema.String,
70
+ summary: OneSentence,
70
71
  proposals: Schema.Array(Proposal),
71
72
  /** Findings left out, and why. */
72
- leftOut: Schema.Array(Schema.Struct({ key: Schema.String, reason: Schema.String })),
73
+ leftOut: Schema.Array(Schema.Struct({ key: Schema.String, reason: Reason })),
73
74
  improvements: Schema.Array(
74
75
  Schema.Struct({ key: Schema.String, loop: Schema.Literals(['errand', 'build']), outcome: Schema.String })
75
76
  )
package/src/release.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  } from '@kitman-sh/sdk/loop'
15
15
  import * as Effect from 'effect/Effect'
16
16
  import * as Schema from 'effect/Schema'
17
+ import { FindingDetail } from './text-limits'
17
18
 
18
19
  const Input = Schema.Struct({
19
20
  /** The tag to release; the drafting agent proposes one when left out. */
@@ -47,7 +48,7 @@ type Drafted = typeof Drafted.Type
47
48
  const Deployed = Schema.Struct({
48
49
  /** none: the repository has no `.kitman/deploy`, so the deploy is left to whatever sends the deploy Event. */
49
50
  status: Schema.Literals(['deployed', 'failed', 'rolled_back', 'rollback_failed', 'none']),
50
- detail: Schema.String
51
+ detail: FindingDetail
51
52
  })
52
53
 
53
54
  const deployPrompt = (tag: string, previousTag: string | undefined) =>
package/src/research.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { agentWork, artifact, defineLoop, LoopOutcome, note, PlanTickets } from '@kitman-sh/sdk/loop'
2
2
  import * as Effect from 'effect/Effect'
3
3
  import * as Schema from 'effect/Schema'
4
+ import { OneSentence } from './text-limits'
4
5
 
5
6
  export class ResearchQuestionMissing extends Schema.TaggedError<ResearchQuestionMissing>()('ResearchQuestionMissing', {
6
7
  message: Schema.String
@@ -28,7 +29,7 @@ const NextSteps = Schema.Struct({ tickets: PlanTickets })
28
29
  const Report = Schema.Struct({
29
30
  /** The Task's title, or a short title for the question. */
30
31
  title: Schema.String,
31
- summary: Schema.String,
32
+ summary: OneSentence,
32
33
  findings: Schema.Array(
33
34
  Schema.Struct({
34
35
  finding: Schema.String,
package/src/review.ts CHANGED
@@ -15,12 +15,14 @@ import {
15
15
  Rebuttal,
16
16
  RebuttalVerdict,
17
17
  pipelineStatus,
18
+ resolveRevisions,
18
19
  ScopeJudgement
19
20
  } from '@kitman-sh/sdk/loop'
20
21
  import * as Effect from 'effect/Effect'
21
22
  import * as Schema from 'effect/Schema'
22
23
  import build, { BuildInput, BuildOutput } from './build'
23
24
  import { verifyHead } from './change-request-body'
25
+ import { FindingDetail, OneSentence } from './text-limits'
24
26
 
25
27
  /** Build, by its schemas: the module imports this one, so its definition is not ready when this one loads. */
26
28
  const buildLoop = () => ({ id: 'build', input: BuildInput, output: BuildOutput })
@@ -85,13 +87,14 @@ const FollowUp = Schema.Struct({ id: Schema.String, status: FollowUpStatus })
85
87
 
86
88
  const SeatFinding = Schema.Struct({
87
89
  ...Finding.fields,
90
+ detail: FindingDetail,
88
91
  /** In a review since an approved head: the problem is in code the change already had there. */
89
92
  approvedCode: Schema.optional(Schema.Boolean)
90
93
  })
91
94
 
92
95
  const SeatOutput = Schema.Struct({
93
96
  /** One sentence: can it merge, and what matters most. */
94
- summary: Schema.String,
97
+ summary: OneSentence,
95
98
  findings: Schema.Array(SeatFinding),
96
99
  verdicts: Schema.optional(Schema.Array(RebuttalVerdict)),
97
100
  scope: Schema.optional(ScopeJudgement),
@@ -123,30 +126,67 @@ export class ReviewTargetMissing extends Schema.TaggedError<ReviewTargetMissing>
123
126
  message: Schema.String
124
127
  }) {}
125
128
 
126
- const targetOf = (input: typeof Input.Type, head?: string) => {
129
+ /** The base and head are one commit, so there is no change to review. */
130
+ export class ReviewDiffEmpty extends Schema.TaggedError<ReviewDiffEmpty>()('ReviewDiffEmpty', {
131
+ message: Schema.String
132
+ }) {}
133
+
134
+ /** A ChangeRequest's target branch is not known, so the review has no base to pin. */
135
+ export class ReviewBaseUnpinned extends Schema.TaggedError<ReviewBaseUnpinned>()('ReviewBaseUnpinned', {
136
+ message: Schema.String
137
+ }) {}
138
+
139
+ /** The commits a review diffs, `git diff base...head`, resolved once so every seat reads the same diff. */
140
+ type Range = { readonly base: string; readonly head: string }
141
+
142
+ const targetOf = (input: typeof Input.Type, { base, head }: Range) => {
127
143
  if (input.changeRequestId !== undefined)
128
- return `ChangeRequest ${input.changeRequestId} at revision ${head}. Read it with \`kitman.changeRequests.get("${input.changeRequestId}")\` through Kitman's MCP, fetch its source branch, and review the diff of revision ${head} against its target branch, even if the branch has moved since. If the Runner cannot fetch that revision (a fork, say), report exactly that as your only finding, a blocker, and stop.`
144
+ return `ChangeRequest ${input.changeRequestId} at revision ${head}: \`git diff ${base}...${head}\`, its change against its target branch as that stood when this review started. Read it with \`kitman.changeRequests.get("${input.changeRequestId}")\` through Kitman's MCP and fetch its source branch; diff exactly those commits even if either branch has moved since. If the Runner cannot fetch that revision (a fork, say), report exactly that as your only finding, a blocker, and stop.`
129
145
 
130
- if (input.base !== undefined && input.head !== undefined && input.files === undefined && input.approved !== undefined)
146
+ if (input.files === undefined && input.approved !== undefined)
131
147
  return [
132
- `only what the change gained or lost since it was approved at ${input.approved}: compare \`git diff ${input.base}...${input.approved}\`, the change as approved, with \`git diff ${input.base}...${input.head}\`, the change now, in your checkout. The rest was reviewed and approved before.`,
148
+ `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.`,
133
149
  '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.'
134
150
  ].join('\n\n')
135
151
 
136
- if (input.base !== undefined && input.head !== undefined)
137
- return input.files === undefined
138
- ? `the change \`git diff ${input.base}...${input.head}\` in your checkout.`
139
- : [
140
- `only these files of the change \`git diff ${input.base}...${input.head}\` in your checkout; the rest of it was reviewed and approved before:`,
141
- ...input.files.map(file => `- ${file}`),
142
- ...(input.since === undefined
143
- ? []
144
- : [`Also review all of \`git diff ${input.since}..${input.head}\`, whichever files it touches.`])
145
- ].join('\n')
146
-
147
- return undefined
152
+ return input.files === undefined
153
+ ? `the change \`git diff ${base}...${head}\` in your checkout.`
154
+ : [
155
+ `only these files of the change \`git diff ${base}...${head}\` in your checkout; the rest of it was reviewed and approved before:`,
156
+ ...input.files.map(file => `- ${file}`),
157
+ ...(input.since === undefined
158
+ ? []
159
+ : [`Also review all of \`git diff ${input.since}..${head}\`, whichever files it touches.`])
160
+ ].join('\n')
148
161
  }
149
162
 
163
+ /**
164
+ * The commits the review diffs, read on a Runner when it starts: a ChangeRequest's head against its target branch,
165
+ * else `base` against `head`. A branch that moves later does not move the diff.
166
+ */
167
+ const pinnedRange = (input: typeof Input.Type) =>
168
+ Effect.gen(function* () {
169
+ if (input.changeRequestId !== undefined) {
170
+ const status = yield* pipelineStatus('head', { changeRequestId: input.changeRequestId })
171
+
172
+ if (status.targetBranch === undefined)
173
+ return yield* new ReviewBaseUnpinned({
174
+ message: `Kitman did not say which branch ChangeRequest ${input.changeRequestId} merges into, so there is no base to review against; update Kitman`
175
+ })
176
+
177
+ const [base = ''] = yield* resolveRevisions('pin', [`origin/${status.targetBranch}`])
178
+
179
+ return { base, head: status.head.toLowerCase() }
180
+ }
181
+
182
+ if (input.base === undefined || input.head === undefined)
183
+ return yield* new ReviewTargetMissing({ message: 'Name a ChangeRequest, or both base and head revisions' })
184
+
185
+ const [base = '', head = ''] = yield* resolveRevisions('pin', [input.base, input.head])
186
+
187
+ return { base, head }
188
+ })
189
+
150
190
  /** A review of the whole change judges its scope; one of some files or of a change since an approval does not. */
151
191
  const wholeChange = (input: typeof Input.Type) => input.files === undefined && input.approved === undefined
152
192
 
@@ -256,15 +296,16 @@ const fixBrief = (changeRequestId: string, findings: readonly MergedFinding[]) =
256
296
 
257
297
  /**
258
298
  * Reviews a ChangeRequest or a revision range with two reviewer Agents, one following the `code-review` skill and one
259
- * `code-review-and-quality`, and writes one review from their findings, each said once. Given an earlier review's
260
- * findings it follows them up, keeping their ids. On a ChangeRequest it verifies the head it reviews against the
299
+ * `code-review-and-quality`, and writes one review from their findings, each said once. It first resolves the base and
300
+ * head to commits on a Runner, so every reviewer reads one diff, and fails when they are one commit. Given an earlier
301
+ * review's findings it follows them up, keeping their ids. On a ChangeRequest it verifies the head it reviews against the
261
302
  * ChangeRequest's target and approves it when nothing blocks it, none of its checks broke and verify ran all of its
262
303
  * tests, unless it wrote the change, then asks what next and posts only when told to, as one summary comment it edits
263
304
  * on later reviews.
264
305
  */
265
306
  export default defineLoop({
266
307
  id: 'review',
267
- version: '3.5.0',
308
+ version: '3.6.0',
268
309
  title: 'Review',
269
310
  input: Input,
270
311
  output: Output,
@@ -291,15 +332,15 @@ export default defineLoop({
291
332
  run: input =>
292
333
  Effect.gen(function* () {
293
334
  // The head is read first, so an approval approves the commit the reviewers read.
294
- const head =
295
- input.changeRequestId === undefined
296
- ? undefined
297
- : (yield* pipelineStatus('head', { changeRequestId: input.changeRequestId })).head
335
+ const range = yield* pinnedRange(input)
336
+ const head = input.changeRequestId === undefined ? undefined : range.head
298
337
 
299
- const target = targetOf(input, head)
338
+ if (range.base === range.head)
339
+ return yield* new ReviewDiffEmpty({
340
+ message: `Base and head are both commit ${range.head}, so the diff is empty: give the base the change is to merge into`
341
+ })
300
342
 
301
- if (target === undefined)
302
- return yield* new ReviewTargetMissing({ message: 'Name a ChangeRequest, or both base and head revisions' })
343
+ const target = targetOf(input, range)
303
344
 
304
345
  // Evidence Kitman holds for the head's tree is reused.
305
346
  const verified = head === undefined ? { failing: [], notRun: [] } : yield* verifyHead('verify', head)
package/src/shepherd.ts CHANGED
@@ -34,6 +34,7 @@ import release from './release'
34
34
  import { verifyHead } from './change-request-body'
35
35
  import review, { ReviewInput, ReviewOutput } from './review'
36
36
  import { ShepherdOutput } from './shepherd-output'
37
+ import { OneSentence } from './text-limits'
37
38
 
38
39
  /** Review, by its schemas: Build calls this Loop and Review calls Build, so Review's definition may not be ready yet. */
39
40
  const reviewLoop = () => ({ id: 'review', input: ReviewInput, output: ReviewOutput })
@@ -73,7 +74,7 @@ type Output = typeof Output.Type
73
74
  const CiFix = Schema.Struct({
74
75
  /** fixed: a commit fixes the branch's own failure; pre_existing: it fails on the target branch too; flaky: it passed on its rerun. */
75
76
  verdict: Schema.Literals(['fixed', 'pre_existing', 'flaky']),
76
- summary: Schema.String
77
+ summary: OneSentence
77
78
  })
78
79
 
79
80
  const Replies = Schema.Struct({
@@ -143,7 +144,7 @@ const threadLine = (thread: ReviewThreads['threads'][number]) =>
143
144
  ].join('\n')
144
145
 
145
146
  const ReviewFix = Schema.Struct({
146
- summary: Schema.String,
147
+ summary: OneSentence,
147
148
  /** Whether it left a change for Kitman to push. */
148
149
  changed: Schema.Boolean
149
150
  })
package/src/sweep.ts CHANGED
@@ -18,6 +18,7 @@ import * as Effect from 'effect/Effect'
18
18
  import * as Schema from 'effect/Schema'
19
19
  import { notVerifiedSection, verifyHead } from './change-request-body'
20
20
  import shepherd from './shepherd'
21
+ import { OneSentence } from './text-limits'
21
22
 
22
23
  const Input = Schema.Struct({
23
24
  /** The dependency bots' logins; Renovate's and Dependabot's on GitHub when left out. */
@@ -49,7 +50,7 @@ const Batched = Schema.Struct({
49
50
  applied: Schema.Array(Schema.String),
50
51
  /** The updates taken out, each with why. */
51
52
  dropped: Schema.Array(Schema.Struct({ number: Schema.String, reason: Schema.String })),
52
- summary: Schema.String
53
+ summary: OneSentence
53
54
  })
54
55
 
55
56
  type Batched = typeof Batched.Type
@@ -0,0 +1,17 @@
1
+ import * as Schema from 'effect/Schema'
2
+
3
+ /** Text an agent writes into an Output, bounded so its brief shows the limit and Kitman refuses a longer one. */
4
+ const bounded = (maxLength: number, description: string) =>
5
+ Schema.String.check(Schema.isMaxLength(maxLength)).annotate({ description })
6
+
7
+ export const OneSentence = bounded(300, 'One sentence, at most 300 characters.')
8
+
9
+ /** A summary that becomes a ChangeRequest's description. */
10
+ export const ChangeRequestSummary = bounded(3000, 'At most 3,000 characters.')
11
+
12
+ export const FindingDetail = bounded(1200, 'At most 1,200 characters.')
13
+
14
+ /** A claim, or a criterion's answer. */
15
+ export const ShortStatement = bounded(400, 'One or two sentences, at most 400 characters.')
16
+
17
+ export const Reason = bounded(600, 'At most 600 characters.')
package/src/tidy.ts CHANGED
@@ -19,6 +19,7 @@ import * as Schema from 'effect/Schema'
19
19
  import { changeRequestBody, unsettledItems } from './change-request-body'
20
20
  import plan from './plan'
21
21
  import review from './review'
22
+ import { OneSentence, ShortStatement } from './text-limits'
22
23
 
23
24
  const Input = Schema.Struct({
24
25
  /**
@@ -68,8 +69,8 @@ const Tidied = Schema.Struct({
68
69
  improved: Schema.Boolean,
69
70
  hint: Schema.optional(Hint),
70
71
  title: Schema.optional(Schema.String),
71
- summary: Schema.String,
72
- claims: Schema.Array(Schema.String)
72
+ summary: OneSentence,
73
+ claims: Schema.Array(ShortStatement)
73
74
  })
74
75
 
75
76
  const Output = Schema.Struct({