@kitman-sh/software-engineering 0.10.80 → 0.10.82

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
@@ -20392,6 +20392,7 @@ var scriptedHost = (script, engine, agentLaunches, childLaunches, waits, verifyL
20392
20392
  step: launch.step,
20393
20393
  agent: launch.agent,
20394
20394
  prompt: launch.prompt,
20395
+ output: launch.output,
20395
20396
  ...launch.skill === undefined ? undefined : { skill: launch.skill },
20396
20397
  ...launch.secrets === undefined ? undefined : { secrets: launch.secrets },
20397
20398
  ...launch.mergeTarget === undefined ? undefined : { mergeTarget: launch.mergeTarget }
@@ -20786,6 +20787,14 @@ var changeRequestBody = (build) => [
20786
20787
 
20787
20788
  `);
20788
20789
 
20790
+ // src/text-limits.ts
20791
+ var bounded2 = (maxLength, description) => String5.check(isMaxLength(maxLength)).annotate({ description });
20792
+ var OneSentence = bounded2(300, "One sentence, at most 300 characters.");
20793
+ var ChangeRequestSummary = bounded2(3000, "At most 3,000 characters.");
20794
+ var FindingDetail = bounded2(1200, "At most 1,200 characters.");
20795
+ var ShortStatement = bounded2(400, "One or two sentences, at most 400 characters.");
20796
+ var Reason = bounded2(600, "At most 600 characters.");
20797
+
20789
20798
  // src/review.ts
20790
20799
  var buildLoop = () => ({ id: "build", input: BuildInput, output: BuildOutput });
20791
20800
  var seats = {
@@ -20820,10 +20829,11 @@ var FollowUpStatus = Literals(["fixed", "changed", "still_there"]);
20820
20829
  var FollowUp = Struct({ id: String5, status: FollowUpStatus });
20821
20830
  var SeatFinding = Struct({
20822
20831
  ...Finding.fields,
20832
+ detail: FindingDetail,
20823
20833
  approvedCode: optional2(Boolean3)
20824
20834
  });
20825
20835
  var SeatOutput = Struct({
20826
- summary: String5,
20836
+ summary: OneSentence,
20827
20837
  findings: ArraySchema(SeatFinding),
20828
20838
  verdicts: optional2(ArraySchema(RebuttalVerdict)),
20829
20839
  scope: optional2(ScopeJudgement),
@@ -21080,7 +21090,7 @@ var Drafted = Struct({
21080
21090
  });
21081
21091
  var Deployed = Struct({
21082
21092
  status: Literals(["deployed", "failed", "rolled_back", "rollback_failed", "none"]),
21083
- detail: String5
21093
+ detail: FindingDetail
21084
21094
  });
21085
21095
  var deployPrompt = (tag, previousTag) => [
21086
21096
  `Deploy the release ${tag}, which Kitman has just tagged and pushed.`,
@@ -21417,6 +21427,7 @@ var ShepherdOutput = Struct({
21417
21427
  reason: String5,
21418
21428
  fixRounds: Int,
21419
21429
  replies: Int,
21430
+ unsettled: optional2(ArraySchema(String5)),
21420
21431
  release: optional2(Struct({ runStatus: String5, reason: String5, tag: optional2(String5) })),
21421
21432
  handBack: optional2(Struct({
21422
21433
  changeRequestId: String5,
@@ -21443,7 +21454,7 @@ var Input3 = Struct({
21443
21454
  var Output3 = ShepherdOutput;
21444
21455
  var CiFix = Struct({
21445
21456
  verdict: Literals(["fixed", "pre_existing", "flaky"]),
21446
- summary: String5
21457
+ summary: OneSentence
21447
21458
  });
21448
21459
  var Replies = Struct({
21449
21460
  replies: ArraySchema(Struct({
@@ -21483,7 +21494,7 @@ var threadLine = (thread) => [
21483
21494
  ].join(`
21484
21495
  `);
21485
21496
  var ReviewFix = Struct({
21486
- summary: String5,
21497
+ summary: OneSentence,
21487
21498
  changed: Boolean3
21488
21499
  });
21489
21500
  var findingLines2 = (findings) => findings.map((finding) => `- ${finding.id} (${finding.severity}): ${finding.detail}`).join(`
@@ -21554,6 +21565,7 @@ var shepherd_default = defineLoop({
21554
21565
  const syncedFor = new Set;
21555
21566
  const syncedKey = (head, targetHead) => `${head}@${targetHead}`;
21556
21567
  const blockerSynced = new Set;
21568
+ const blockerRechecks = new Map;
21557
21569
  let turn;
21558
21570
  let turns = 0;
21559
21571
  let passes = 0;
@@ -21564,7 +21576,8 @@ var shepherd_default = defineLoop({
21564
21576
  status,
21565
21577
  reason,
21566
21578
  fixRounds: fixRounds(),
21567
- replies
21579
+ replies,
21580
+ ...status === "needs_you" || status === "handed_back" ? { unsettled: [reason] } : undefined
21568
21581
  });
21569
21582
  const handBack = (reason, open) => ({
21570
21583
  ...done("handed_back", reason),
@@ -21777,8 +21790,20 @@ ${open}`,
21777
21790
  const blocker = pipeline.conflicts === true ? `conflicts with ${target}` : `needs ${target} merged in`;
21778
21791
  const targetHead = pipeline.target?.head;
21779
21792
  const syncedAlready = targetHead === undefined ? blockerSynced.has(pipeline.head) : syncedFor.has(syncedKey(pipeline.head, targetHead));
21780
- if (syncedAlready)
21781
- return handBack(`The forge still says ${pipeline.head} ${blocker} after merging it in`, `Merge ${target} into the branch and settle what conflicts.`);
21793
+ if (syncedAlready) {
21794
+ const rechecks = (blockerRechecks.get(pipeline.head) ?? 0) + 1;
21795
+ blockerRechecks.set(pipeline.head, rechecks);
21796
+ if (rechecks <= 3) {
21797
+ yield* waitFor(`recheck:${cycle}`, {
21798
+ event: "change_request.mergeable",
21799
+ filter: { changeRequestId, head: pipeline.head },
21800
+ timeout: "2 minutes",
21801
+ ...pipeline.readAt === undefined ? undefined : { since: pipeline.readAt }
21802
+ }).pipe(catchTag2("WaitTimedOut", () => void_3));
21803
+ continue;
21804
+ }
21805
+ return handBack(`The forge still says ${pipeline.head} ${blocker} after merging it in, and three more looks said the same`, `Merge ${target} into the branch and settle what conflicts.`);
21806
+ }
21782
21807
  if (targetHead !== undefined)
21783
21808
  syncedFor.add(syncedKey(pipeline.head, targetHead));
21784
21809
  blockerSynced.add(pipeline.head);
@@ -22167,7 +22192,7 @@ var BuildInput = Struct({
22167
22192
  var CriterionAnswer = Struct({
22168
22193
  criterion: String5,
22169
22194
  status: Literals(["met", "after_merge", "not_met"]),
22170
- detail: String5
22195
+ detail: ShortStatement
22171
22196
  });
22172
22197
  var Criteria = Struct({ criteria: ArraySchema(CriterionAnswer) });
22173
22198
  var SuggestedCheck = Struct({
@@ -22177,8 +22202,8 @@ var SuggestedCheck = Struct({
22177
22202
  });
22178
22203
  var Implemented = Struct({
22179
22204
  title: String5,
22180
- summary: String5,
22181
- claims: ArraySchema(String5),
22205
+ summary: ChangeRequestSummary,
22206
+ claims: ArraySchema(ShortStatement),
22182
22207
  documented: optional2(ArraySchema(String5)),
22183
22208
  rollback: optional2(String5),
22184
22209
  criteria: optional2(ArraySchema(CriterionAnswer)),
@@ -22186,16 +22211,17 @@ var Implemented = Struct({
22186
22211
  });
22187
22212
  var Reproduced = Struct({
22188
22213
  check: String5,
22189
- summary: String5
22214
+ summary: ChangeRequestSummary
22190
22215
  });
22191
22216
  var ReproducedOnBranch = Struct({
22192
22217
  ...Reproduced.fields,
22193
22218
  revision: optional2(String5)
22194
22219
  });
22220
+ var FixRebuttal = Struct({ ...Rebuttal.fields, reason: Reason });
22195
22221
  var Fixed = Struct({
22196
- summary: String5,
22197
- claims: ArraySchema(String5),
22198
- rebuttals: ArraySchema(Rebuttal)
22222
+ summary: ChangeRequestSummary,
22223
+ claims: ArraySchema(ShortStatement),
22224
+ rebuttals: ArraySchema(FixRebuttal)
22199
22225
  });
22200
22226
  var BuildOutput = Struct({
22201
22227
  changeRequest: ChangeRequestResult,
@@ -22556,7 +22582,7 @@ var Input4 = Struct({
22556
22582
  });
22557
22583
  var Done3 = Struct({
22558
22584
  status: Literals(["done", "blocked", "too_big"]),
22559
- summary: String5,
22585
+ summary: ChangeRequestSummary,
22560
22586
  changed: Boolean3,
22561
22587
  title: optional2(String5),
22562
22588
  checks: optional2(ArraySchema(SuggestedCheck))
@@ -22685,7 +22711,7 @@ var Input5 = Struct({
22685
22711
  });
22686
22712
  var Opportunity = Struct({
22687
22713
  title: String5,
22688
- detail: String5,
22714
+ detail: FindingDetail,
22689
22715
  evidence: Literals(["measured", "telemetry", "hypothesis"]),
22690
22716
  external: optional2(Boolean3)
22691
22717
  });
@@ -22696,12 +22722,12 @@ var Discovery = Struct({
22696
22722
  opportunities: ArraySchema(Opportunity)
22697
22723
  });
22698
22724
  var Harness = Struct({
22699
- summary: String5,
22725
+ summary: OneSentence,
22700
22726
  plan: MeasurePlan
22701
22727
  });
22702
22728
  var Change = Struct({
22703
22729
  status: Literals(["changed", "exhausted", "unsafe"]),
22704
- summary: String5
22730
+ summary: OneSentence
22705
22731
  });
22706
22732
  var Kept = Struct({ summary: String5, verdict: String5, reason: String5 });
22707
22733
  var Output6 = Struct({
@@ -22937,7 +22963,7 @@ var hillclimb_default = defineLoop({
22937
22963
  yield* agentWork(`fix:${round}`, {
22938
22964
  agent: "implementer",
22939
22965
  prompt: fixPrompt2(blocking),
22940
- output: Struct({ summary: String5 })
22966
+ output: Struct({ summary: OneSentence })
22941
22967
  });
22942
22968
  const fixed = yield* verify(`verify:fix:${round}`, {});
22943
22969
  if (!fixed.passed) {
@@ -23004,7 +23030,7 @@ var Input6 = Struct({
23004
23030
  autoFix: optional2(Boolean3)
23005
23031
  });
23006
23032
  var Conclusion = Struct({
23007
- summary: String5,
23033
+ summary: OneSentence,
23008
23034
  cause: String5,
23009
23035
  confidence: Literals(["high", "medium", "low"]),
23010
23036
  sources: NonEmptyArray(String5),
@@ -23674,7 +23700,7 @@ var Fix = Struct({
23674
23700
  var NextSteps = Struct({ tickets: PlanTickets });
23675
23701
  var Report = Struct({
23676
23702
  title: String5,
23677
- summary: String5,
23703
+ summary: OneSentence,
23678
23704
  findings: ArraySchema(Struct({
23679
23705
  finding: String5,
23680
23706
  basis: Literals(["observed", "read", "inferred"]),
@@ -23847,7 +23873,7 @@ var Finding2 = Struct({
23847
23873
  category: Category,
23848
23874
  kind: Literals(["memory", "task"]),
23849
23875
  lesson: String5,
23850
- detail: optional2(String5),
23876
+ detail: optional2(FindingDetail),
23851
23877
  fix: optional2(Struct({ size: Literals(["errand", "build"]), words: String5 })),
23852
23878
  citations: ArraySchema(TranscriptPoint)
23853
23879
  });
@@ -23861,9 +23887,9 @@ var Proposal2 = Struct({
23861
23887
  runIds: ArraySchema(String5)
23862
23888
  });
23863
23889
  var Output11 = Struct({
23864
- summary: String5,
23890
+ summary: OneSentence,
23865
23891
  proposals: ArraySchema(Proposal2),
23866
- leftOut: ArraySchema(Struct({ key: String5, reason: String5 })),
23892
+ leftOut: ArraySchema(Struct({ key: String5, reason: Reason })),
23867
23893
  improvements: ArraySchema(Struct({ key: String5, loop: Literals(["errand", "build"]), outcome: String5 }))
23868
23894
  });
23869
23895
  var prompt4 = (runs, days) => [
@@ -23982,7 +24008,7 @@ var Assessed = Struct({
23982
24008
  var Batched = Struct({
23983
24009
  applied: ArraySchema(String5),
23984
24010
  dropped: ArraySchema(Struct({ number: String5, reason: String5 })),
23985
- summary: String5
24011
+ summary: OneSentence
23986
24012
  });
23987
24013
  var Placed = Struct({ number: String5, title: String5, url: String5, reason: String5 });
23988
24014
  var Output12 = Struct({
@@ -24235,8 +24261,8 @@ var Tidied = Struct({
24235
24261
  improved: Boolean3,
24236
24262
  hint: optional2(Hint),
24237
24263
  title: optional2(String5),
24238
- summary: String5,
24239
- claims: ArraySchema(String5)
24264
+ summary: OneSentence,
24265
+ claims: ArraySchema(ShortStatement)
24240
24266
  });
24241
24267
  var Output13 = Struct({
24242
24268
  status: Literals(["nothing_worth_it", "reported", "planned", "opened"]),
@@ -24416,7 +24442,11 @@ What next?`,
24416
24442
 
24417
24443
  // kitman.config.ts
24418
24444
  var fallbacks = [{ harness: "pi" }];
24419
- var reviewer = { harness: "pi", model: "openai-codex/gpt-6.1-sol", fallbacks: [{ harness: "claude" }] };
24445
+ var reviewer = {
24446
+ harness: "pi",
24447
+ model: "openai-codex/gpt-6.1-sol",
24448
+ fallbacks: [{ harness: "claude", model: "opus", effort: "high" }]
24449
+ };
24420
24450
  var kitman_config_default = defineKit({
24421
24451
  loops: [
24422
24452
  build_default,
@@ -30154,4 +30184,4 @@ var runKit = (config, identity, packages) => {
30154
30184
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
30155
30185
  };
30156
30186
  // .kitman-build-entry.ts
30157
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.80" }, []);
30187
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.82" }, []);
@@ -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": [
@@ -364,6 +366,19 @@
364
366
  "minimum": -9007199254740991,
365
367
  "maximum": 9007199254740991
366
368
  },
369
+ "unsettled": {
370
+ "anyOf": [
371
+ {
372
+ "type": "array",
373
+ "items": {
374
+ "type": "string"
375
+ }
376
+ },
377
+ {
378
+ "type": "null"
379
+ }
380
+ ]
381
+ },
367
382
  "release": {
368
383
  "anyOf": [
369
384
  {
@@ -1935,7 +1950,9 @@
1935
1950
  "type": "object",
1936
1951
  "properties": {
1937
1952
  "summary": {
1938
- "type": "string"
1953
+ "type": "string",
1954
+ "maxLength": 300,
1955
+ "description": "One sentence, at most 300 characters."
1939
1956
  },
1940
1957
  "proposals": {
1941
1958
  "type": "array",
@@ -1998,7 +2015,9 @@
1998
2015
  "type": "string"
1999
2016
  },
2000
2017
  "reason": {
2001
- "type": "string"
2018
+ "type": "string",
2019
+ "maxLength": 600,
2020
+ "description": "At most 600 characters."
2002
2021
  }
2003
2022
  },
2004
2023
  "required": [
@@ -2769,6 +2788,19 @@
2769
2788
  "minimum": -9007199254740991,
2770
2789
  "maximum": 9007199254740991
2771
2790
  },
2791
+ "unsettled": {
2792
+ "anyOf": [
2793
+ {
2794
+ "type": "array",
2795
+ "items": {
2796
+ "type": "string"
2797
+ }
2798
+ },
2799
+ {
2800
+ "type": "null"
2801
+ }
2802
+ ]
2803
+ },
2772
2804
  "release": {
2773
2805
  "anyOf": [
2774
2806
  {
@@ -3273,7 +3305,9 @@
3273
3305
  "effort": "high",
3274
3306
  "fallbacks": [
3275
3307
  {
3276
- "harness": "claude"
3308
+ "harness": "claude",
3309
+ "model": "opus",
3310
+ "effort": "high"
3277
3311
  }
3278
3312
  ]
3279
3313
  },
@@ -3383,7 +3417,7 @@
3383
3417
  "carried": [
3384
3418
  {
3385
3419
  "name": "@kitman-sh/software-engineering",
3386
- "version": "0.10.80",
3420
+ "version": "0.10.82",
3387
3421
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
3388
3422
  "loops": [
3389
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.80",
3
+ "version": "0.10.82",
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.80",
21
- "effect": "4.1.2"
20
+ "@kitman-sh/sdk": "0.10.82",
21
+ "effect": "^4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "b208051317bf879ed8e8b55c9d44f2f97ec316402747e639fa131e2e9579dcd9",
25
+ "digest": "828c128c0e8d48d9b8612e9fc73aca0cedaa37a4a28d319ffec70eabd5d1fe84",
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({
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
@@ -21,6 +21,7 @@ import * as Effect from 'effect/Effect'
21
21
  import * as Schema from 'effect/Schema'
22
22
  import build, { BuildInput, BuildOutput } from './build'
23
23
  import { verifyHead } from './change-request-body'
24
+ import { FindingDetail, OneSentence } from './text-limits'
24
25
 
25
26
  /** Build, by its schemas: the module imports this one, so its definition is not ready when this one loads. */
26
27
  const buildLoop = () => ({ id: 'build', input: BuildInput, output: BuildOutput })
@@ -85,13 +86,14 @@ const FollowUp = Schema.Struct({ id: Schema.String, status: FollowUpStatus })
85
86
 
86
87
  const SeatFinding = Schema.Struct({
87
88
  ...Finding.fields,
89
+ detail: FindingDetail,
88
90
  /** In a review since an approved head: the problem is in code the change already had there. */
89
91
  approvedCode: Schema.optional(Schema.Boolean)
90
92
  })
91
93
 
92
94
  const SeatOutput = Schema.Struct({
93
95
  /** One sentence: can it merge, and what matters most. */
94
- summary: Schema.String,
96
+ summary: OneSentence,
95
97
  findings: Schema.Array(SeatFinding),
96
98
  verdicts: Schema.optional(Schema.Array(RebuttalVerdict)),
97
99
  scope: Schema.optional(ScopeJudgement),
@@ -8,6 +8,8 @@ export const ShepherdOutput = Schema.Struct({
8
8
  reason: Schema.String,
9
9
  fixRounds: Schema.Int,
10
10
  replies: Schema.Int,
11
+ /** What still stands when it stopped without landing (needs_you, handed_back), so the Run and a Build above it read partial. */
12
+ unsettled: Schema.optional(Schema.Array(Schema.String)),
11
13
  /** The Release it started after merging, when it was told to release. */
12
14
  release: Schema.optional(
13
15
  Schema.Struct({ runStatus: Schema.String, reason: Schema.String, tag: Schema.optional(Schema.String) })
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
  })
@@ -273,6 +274,8 @@ export default defineLoop({
273
274
  const syncedKey = (head: string, targetHead: string) => `${head}@${targetHead}`
274
275
  /** The heads a sync for the forge's blocker started from or pushed, judged by when the target's head is unknown. */
275
276
  const blockerSynced = new Set<string>()
277
+ /** How often the forge's blocker has been looked at again at a head a sync settled it for. */
278
+ const blockerRechecks = new Map<string, number>()
276
279
 
277
280
  /** The target's turn: held from the sync before the merge until the merge, so one ChangeRequest merges at a time. */
278
281
  let turn: Claim | undefined
@@ -292,7 +295,8 @@ export default defineLoop({
292
295
  status,
293
296
  reason,
294
297
  fixRounds: fixRounds(),
295
- replies
298
+ replies,
299
+ ...(status === 'needs_you' || status === 'handed_back' ? { unsettled: [reason] } : undefined)
296
300
  })
297
301
 
298
302
  const handBack = (reason: string, open: string): Output => ({
@@ -623,11 +627,29 @@ export default defineLoop({
623
627
  ? blockerSynced.has(pipeline.head)
624
628
  : syncedFor.has(syncedKey(pipeline.head, targetHead))
625
629
 
626
- if (syncedAlready)
630
+ if (syncedAlready) {
631
+ // This head already took the target in, so the blocker is most likely the forge's answer for an older head:
632
+ // GitLab works mergeability out after a push and shows the last answer meanwhile. Look again before giving up.
633
+ const rechecks = (blockerRechecks.get(pipeline.head) ?? 0) + 1
634
+
635
+ blockerRechecks.set(pipeline.head, rechecks)
636
+
637
+ if (rechecks <= 3) {
638
+ yield* waitFor(`recheck:${cycle}`, {
639
+ event: 'change_request.mergeable',
640
+ filter: { changeRequestId, head: pipeline.head },
641
+ timeout: '2 minutes',
642
+ ...(pipeline.readAt === undefined ? undefined : { since: pipeline.readAt })
643
+ }).pipe(Effect.catchTag('WaitTimedOut', () => Effect.void))
644
+
645
+ continue
646
+ }
647
+
627
648
  return handBack(
628
- `The forge still says ${pipeline.head} ${blocker} after merging it in`,
649
+ `The forge still says ${pipeline.head} ${blocker} after merging it in, and three more looks said the same`,
629
650
  `Merge ${target} into the branch and settle what conflicts.`
630
651
  )
652
+ }
631
653
 
632
654
  if (targetHead !== undefined) syncedFor.add(syncedKey(pipeline.head, targetHead))
633
655
  blockerSynced.add(pipeline.head)
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({