@kitman-sh/software-engineering 0.13.4 → 0.13.6

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
@@ -14283,6 +14283,7 @@ var QuestionAnswerCreate = Struct({
14283
14283
  idempotencyKey: String5.check(isMinLength(1), isMaxLength(240))
14284
14284
  });
14285
14285
  var QuestionList = Struct({ items: ArraySchema(Question) });
14286
+ var QuestionBelow = Struct({ name: String5, question: Question });
14286
14287
  var RunLaunchContext = Struct({
14287
14288
  teamId: optionalKey2(Id),
14288
14289
  remoteUrl: optionalKey2(String5.check(isMinLength(1), isMaxLength(2000))),
@@ -14425,6 +14426,7 @@ var RunShow = Struct({
14425
14426
  graph: RunGraph,
14426
14427
  steps: ArraySchema(RunStepSummary),
14427
14428
  questions: ArraySchema(Question),
14429
+ questionsBelow: optionalKey2(ArraySchema(QuestionBelow)),
14428
14430
  children: ArraySchema(Struct({
14429
14431
  runId: Id,
14430
14432
  name: String5,
@@ -20823,7 +20825,8 @@ var Finding = Struct({
20823
20825
  var MergedFinding = Struct({
20824
20826
  id: String5,
20825
20827
  ...Finding.fields,
20826
- seats: ArraySchema(String5)
20828
+ seats: ArraySchema(String5),
20829
+ blockingSeats: optionalKey2(ArraySchema(String5))
20827
20830
  });
20828
20831
  var Rebuttal = Struct({ findingId: String5, reason: String5 });
20829
20832
  var RebuttalVerdict = Struct({ findingId: String5, accepted: Boolean3 });
@@ -20832,6 +20835,7 @@ var rank = { blocker: 0, major: 1, minor: 2 };
20832
20835
  var isBlocking = (finding) => finding.severity !== "minor";
20833
20836
  var mergeFindings = (bySeat) => {
20834
20837
  const merged = new Map;
20838
+ const blocking = new Map;
20835
20839
  for (const [seat, findings] of Object.entries(bySeat))
20836
20840
  for (const finding of findings) {
20837
20841
  const id = `${finding.file}:${finding.line}`;
@@ -20839,8 +20843,13 @@ var mergeFindings = (bySeat) => {
20839
20843
  const seats = [...new Set([...known?.seats ?? [], seat])];
20840
20844
  const worst = known === undefined || rank[finding.severity] < rank[known.severity] ? finding : known;
20841
20845
  merged.set(id, { id, severity: worst.severity, file: worst.file, line: worst.line, detail: worst.detail, seats });
20846
+ if (isBlocking(finding))
20847
+ blocking.set(id, new Set([...blocking.get(id) ?? [], seat]));
20842
20848
  }
20843
- return [...merged.values()].toSorted((left, right) => rank[left.severity] - rank[right.severity]);
20849
+ return [...merged.values()].map((finding) => {
20850
+ const blockingSeats = [...blocking.get(finding.id) ?? []];
20851
+ return blockingSeats.length === 0 || blockingSeats.length === finding.seats.length ? finding : { ...finding, blockingSeats };
20852
+ }).toSorted((left, right) => rank[left.severity] - rank[right.severity]);
20844
20853
  };
20845
20854
  var splitDisputed = (findings, rebuttals) => {
20846
20855
  const disputed = [];
@@ -21134,6 +21143,20 @@ var changeRequestBody = (build) => [
21134
21143
 
21135
21144
  `);
21136
21145
 
21146
+ // src/convergence.ts
21147
+ var everyRoundSeat = "code-review";
21148
+ var levelLimit = 3;
21149
+ var raisedAsBlocking = (finding) => isBlocking(finding) && (finding.blockingSeats ?? finding.seats).includes(everyRoundSeat);
21150
+ var blockingCount = (settled) => [...settled.open, ...settled.standing.map((entry) => entry.finding)].filter(raisedAsBlocking).length;
21151
+ var rebuildRefusal = (counts) => {
21152
+ const previous = counts.at(-2);
21153
+ const latest = counts.at(-1);
21154
+ if (previous === undefined || latest === undefined)
21155
+ return;
21156
+ const change = latest > previous ? `rose from ${previous} to ${latest}` : latest === previous && latest >= levelLimit ? `stayed level at ${latest}` : undefined;
21157
+ return change === undefined ? undefined : `its Review rounds are not converging: the ${everyRoundSeat} reviewer's blockers and majors ${change} in the last Review round (${counts.join(", ")})`;
21158
+ };
21159
+
21137
21160
  // src/delivery.ts
21138
21161
  var DeliveryFields = {
21139
21162
  deliveryTarget: optional2(DeliveryTarget),
@@ -23199,6 +23222,7 @@ var BuildOutput = Struct({
23199
23222
  criteria: ArraySchema(CriterionAnswer),
23200
23223
  notRun: optional2(ArraySchema(String5)),
23201
23224
  findings: optional2(ArraySchema(MergedFinding)),
23225
+ blockingCounts: optional2(ArraySchema(Int)),
23202
23226
  approval: optional2(ApproveChangeRequestResult),
23203
23227
  landed: optional2(ShepherdOutput),
23204
23228
  next: Struct({ changeRequestId: String5 }),
@@ -23302,6 +23326,7 @@ var onlyChecksBlock = (settled) => blockingIds(settled).every(isCheckFinding) &&
23302
23326
  var rally = (input) => gen2(function* () {
23303
23327
  const claims = [...input.claims];
23304
23328
  const conflicts = [];
23329
+ const blockingCounts = [];
23305
23330
  let rebuttals = [];
23306
23331
  let earlier = input.earlier;
23307
23332
  let previous;
@@ -23333,7 +23358,8 @@ var rally = (input) => gen2(function* () {
23333
23358
  decision: { stop: true, reason: "findings_returned", unsettled: blockingIds(last.settled) },
23334
23359
  claims,
23335
23360
  conflicts,
23336
- earlier
23361
+ earlier,
23362
+ blockingCounts
23337
23363
  };
23338
23364
  const failing = brokenChecks(head).map((check) => check.name);
23339
23365
  const notRun = testsNotRunReasons(head);
@@ -23354,6 +23380,7 @@ var rally = (input) => gen2(function* () {
23354
23380
  rebuttals,
23355
23381
  verdicts: reviewed.verdicts
23356
23382
  });
23383
+ blockingCounts.push(blockingCount(settled));
23357
23384
  earlier = [...settled.open, ...settled.standing.map((entry) => entry.finding)].filter((finding) => !finding.id.startsWith("scope: ") && !isCheckFinding(finding.id));
23358
23385
  const unseen = checks.some((finding) => !shown.has(finding.detail));
23359
23386
  const decision = rallyStop({
@@ -23363,7 +23390,17 @@ var rally = (input) => gen2(function* () {
23363
23390
  ...previous === undefined || unseen ? undefined : { previous }
23364
23391
  });
23365
23392
  if (decision.stop && (!unseen || round >= input.maxRounds))
23366
- return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts, earlier };
23393
+ return {
23394
+ round,
23395
+ head,
23396
+ settled,
23397
+ decision,
23398
+ claims,
23399
+ scope: reviewed.scope,
23400
+ conflicts,
23401
+ earlier,
23402
+ blockingCounts
23403
+ };
23367
23404
  for (const finding of checks)
23368
23405
  shown.add(finding.detail);
23369
23406
  const fixed = yield* agentWork(`fix:${round}`, {
@@ -23383,7 +23420,7 @@ var rally = (input) => gen2(function* () {
23383
23420
  });
23384
23421
  var build2 = defineLoop({
23385
23422
  id: "build",
23386
- version: "2.9.0",
23423
+ version: "2.10.0",
23387
23424
  title: "Build",
23388
23425
  input: BuildInput,
23389
23426
  output: BuildOutput,
@@ -23496,14 +23533,20 @@ var build2 = defineLoop({
23496
23533
  criteria,
23497
23534
  ...lastNotRun.length === 0 ? undefined : { notRun: lastNotRun },
23498
23535
  ...last.earlier.length === 0 ? undefined : { findings: last.earlier },
23536
+ blockingCounts: last.blockingCounts,
23499
23537
  ...approval === undefined ? undefined : { approval }
23500
23538
  };
23501
23539
  const maxRebuilds = input.maxRebuilds ?? 1;
23502
23540
  for (let rebuilds = 0;input.land !== false && settledAs.unsettled.length > 0; ) {
23503
23541
  const standing = settledAs.unsettled;
23504
- const again = rebuilds < maxRebuilds;
23542
+ const refusal = rebuildRefusal(settledAs.blockingCounts ?? []);
23543
+ const again = rebuilds < maxRebuilds && refusal === undefined;
23544
+ const refused = refusal === undefined ? [] : [`Another Build is not offered: ${refusal}.`];
23505
23545
  const answer = yield* ask(rebuilds === 0 ? "unsettled" : `unsettled:${rebuilds + 1}`, {
23506
- prompt: `The ChangeRequest ${opened.url} is open, but these still stand: ${standing.join("; ")}. Build will not land it.`,
23546
+ prompt: [
23547
+ `The ChangeRequest ${opened.url} is open, but these still stand: ${standing.join("; ")}. Build will not land it.`,
23548
+ ...refused
23549
+ ].join(" "),
23507
23550
  options: [
23508
23551
  { value: takenOverAnswer, description: "A person fixes, rebuts or steers it from here." },
23509
23552
  again ? {
@@ -23528,7 +23571,8 @@ var build2 = defineLoop({
23528
23571
  text: [
23529
23572
  `Build stopped without landing ${opened.url}, marked blocked on what still stands:`,
23530
23573
  "",
23531
- ...standing.map((item) => `- ${item}`)
23574
+ ...standing.map((item) => `- ${item}`),
23575
+ ...refused.length === 0 ? [] : ["", ...refused]
23532
23576
  ].join(`
23533
23577
  `)
23534
23578
  });
@@ -31461,4 +31505,4 @@ var runKit = (config, identity, packages) => {
31461
31505
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
31462
31506
  };
31463
31507
  // .kitman-build-entry.ts
31464
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.4" }, []);
31508
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.13.6" }, []);
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "id": "build",
5
5
  "title": "Build",
6
- "version": "2.9.0",
6
+ "version": "2.10.0",
7
7
  "input": {
8
8
  "type": "object",
9
9
  "properties": {
@@ -249,6 +249,12 @@
249
249
  "items": {
250
250
  "type": "string"
251
251
  }
252
+ },
253
+ "blockingSeats": {
254
+ "type": "array",
255
+ "items": {
256
+ "type": "string"
257
+ }
252
258
  }
253
259
  },
254
260
  "required": [
@@ -496,6 +502,12 @@
496
502
  "items": {
497
503
  "type": "string"
498
504
  }
505
+ },
506
+ "blockingSeats": {
507
+ "type": "array",
508
+ "items": {
509
+ "type": "string"
510
+ }
499
511
  }
500
512
  },
501
513
  "required": [
@@ -514,6 +526,21 @@
514
526
  }
515
527
  ]
516
528
  },
529
+ "blockingCounts": {
530
+ "anyOf": [
531
+ {
532
+ "type": "array",
533
+ "items": {
534
+ "type": "integer",
535
+ "minimum": -9007199254740991,
536
+ "maximum": 9007199254740991
537
+ }
538
+ },
539
+ {
540
+ "type": "null"
541
+ }
542
+ ]
543
+ },
517
544
  "approval": {
518
545
  "anyOf": [
519
546
  {
@@ -823,6 +850,12 @@
823
850
  "items": {
824
851
  "type": "string"
825
852
  }
853
+ },
854
+ "blockingSeats": {
855
+ "type": "array",
856
+ "items": {
857
+ "type": "string"
858
+ }
826
859
  }
827
860
  },
828
861
  "required": [
@@ -3546,6 +3579,12 @@
3546
3579
  "items": {
3547
3580
  "type": "string"
3548
3581
  }
3582
+ },
3583
+ "blockingSeats": {
3584
+ "type": "array",
3585
+ "items": {
3586
+ "type": "string"
3587
+ }
3549
3588
  }
3550
3589
  },
3551
3590
  "required": [
@@ -3827,6 +3866,12 @@
3827
3866
  "items": {
3828
3867
  "type": "string"
3829
3868
  }
3869
+ },
3870
+ "blockingSeats": {
3871
+ "type": "array",
3872
+ "items": {
3873
+ "type": "string"
3874
+ }
3830
3875
  }
3831
3876
  },
3832
3877
  "required": [
@@ -4035,6 +4080,12 @@
4035
4080
  "items": {
4036
4081
  "type": "string"
4037
4082
  }
4083
+ },
4084
+ "blockingSeats": {
4085
+ "type": "array",
4086
+ "items": {
4087
+ "type": "string"
4088
+ }
4038
4089
  }
4039
4090
  },
4040
4091
  "required": [
@@ -4082,6 +4133,12 @@
4082
4133
  "items": {
4083
4134
  "type": "string"
4084
4135
  }
4136
+ },
4137
+ "blockingSeats": {
4138
+ "type": "array",
4139
+ "items": {
4140
+ "type": "string"
4141
+ }
4085
4142
  }
4086
4143
  },
4087
4144
  "required": [
@@ -4923,6 +4980,12 @@
4923
4980
  "items": {
4924
4981
  "type": "string"
4925
4982
  }
4983
+ },
4984
+ "blockingSeats": {
4985
+ "type": "array",
4986
+ "items": {
4987
+ "type": "string"
4988
+ }
4926
4989
  }
4927
4990
  },
4928
4991
  "required": [
@@ -5523,7 +5586,7 @@
5523
5586
  "carried": [
5524
5587
  {
5525
5588
  "name": "@kitman-sh/software-engineering",
5526
- "version": "0.13.4",
5589
+ "version": "0.13.6",
5527
5590
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
5528
5591
  "loops": [
5529
5592
  "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/software-engineering",
3
- "version": "0.13.4",
3
+ "version": "0.13.6",
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.13.4",
20
+ "@kitman-sh/sdk": "0.13.6",
21
21
  "effect": "^4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "bf8099ff83c3bee101dfc08f7b8da22954880dbafe7e9e244eb0b88dbd40d7b2",
25
+ "digest": "c8106e7dc49453ceeb6d0376da3266d2d2a82b3d21b1e1611c587a0f2160ce1e",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
package/src/build.ts CHANGED
@@ -44,6 +44,7 @@ import {
44
44
  scopeFindings,
45
45
  unsettledItems
46
46
  } from './change-request-body'
47
+ import { blockingCount, rebuildRefusal } from './convergence'
47
48
  import review from './review'
48
49
  import shepherd from './shepherd'
49
50
  import { ShepherdOutput } from './shepherd-output'
@@ -76,7 +77,7 @@ export const BuildInput = Schema.Struct({
76
77
  changeRequestId: Schema.optional(Schema.String),
77
78
  /**
78
79
  * How many more Builds an unattended full-auto Run starts on its ChangeRequest while review findings still stand,
79
- * before it fails with them; 1 when left out.
80
+ * before it fails with them; 1 when left out. None starts after Review rounds that were not converging.
80
81
  */
81
82
  maxRebuilds: Schema.optional(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
82
83
  /** The head an earlier review read, whose `earlier` findings this Build fixes: its first review reviews the fix. */
@@ -152,6 +153,8 @@ export const BuildOutput = Schema.Struct({
152
153
  notRun: Schema.optional(Schema.Array(Schema.String)),
153
154
  /** The last review's code findings still open or disputed, which a Build fixing them takes as `earlier`. */
154
155
  findings: Schema.optional(Schema.Array(MergedFinding)),
156
+ /** Each Review round's blocking count, first to last, which decides whether a Rebuild may follow. */
157
+ blockingCounts: Schema.optional(Schema.Array(Schema.Int)),
155
158
  /** Whether the last Review's approval was recorded, or why not, when nothing was left unsettled. */
156
159
  approval: Schema.optional(ApproveChangeRequestResult),
157
160
  /** What Shepherd did with the ChangeRequest, when the Build was told to land it. */
@@ -295,6 +298,7 @@ type Round = {
295
298
  readonly scope: ScopeJudgement | undefined
296
299
  readonly conflicts: readonly string[]
297
300
  readonly earlier: readonly MergedFinding[]
301
+ readonly blockingCounts: readonly number[]
298
302
  }
299
303
 
300
304
  /**
@@ -315,6 +319,7 @@ const rally = (input: {
315
319
  Effect.gen(function* () {
316
320
  const claims = [...input.claims]
317
321
  const conflicts: string[] = []
322
+ const blockingCounts: number[] = []
318
323
  let rebuttals: readonly Rebuttal[] = []
319
324
  let earlier = input.earlier
320
325
  let previous: readonly string[] | undefined
@@ -357,7 +362,8 @@ const rally = (input: {
357
362
  decision: { stop: true, reason: 'findings_returned', unsettled: blockingIds(last.settled) },
358
363
  claims,
359
364
  conflicts,
360
- earlier
365
+ earlier,
366
+ blockingCounts
361
367
  } satisfies Round
362
368
 
363
369
  const failing = brokenChecks(head).map(check => check.name)
@@ -387,6 +393,8 @@ const rally = (input: {
387
393
  verdicts: reviewed.verdicts
388
394
  })
389
395
 
396
+ blockingCounts.push(blockingCount(settled))
397
+
390
398
  // A dispute that stands stays in front of the reviewers when a broken check carries the rally on past it.
391
399
  earlier = [...settled.open, ...settled.standing.map(entry => entry.finding)].filter(
392
400
  finding => !finding.id.startsWith('scope: ') && !isCheckFinding(finding.id)
@@ -403,7 +411,17 @@ const rally = (input: {
403
411
  })
404
412
 
405
413
  if (decision.stop && (!unseen || round >= input.maxRounds))
406
- return { round, head, settled, decision, claims, scope: reviewed.scope, conflicts, earlier } satisfies Round
414
+ return {
415
+ round,
416
+ head,
417
+ settled,
418
+ decision,
419
+ claims,
420
+ scope: reviewed.scope,
421
+ conflicts,
422
+ earlier,
423
+ blockingCounts
424
+ } satisfies Round
407
425
 
408
426
  for (const finding of checks) shown.add(finding.detail)
409
427
 
@@ -439,11 +457,12 @@ const rally = (input: {
439
457
  * Implements a Task or words, reviews and fixes until the rally stops, gates on the evidence for the head, and opens
440
458
  * the Run's ChangeRequest with the evidence, the claims and whatever it could not settle (ADR-0051). It writes the
441
459
  * Run's milestones to its Task: started, ChangeRequest opened, and failed, or blocked instead of failed when findings
442
- * still stand once full auto's rebuilds run out; those findings go on the Task as a blocker before the Run fails.
460
+ * still stand once full auto's rebuilds run out or its Review rounds are not converging; those findings go on the Task as a blocker
461
+ * before the Run fails.
443
462
  */
444
463
  const build = defineLoop({
445
464
  id: 'build',
446
- version: '2.9.0',
465
+ version: '2.10.0',
447
466
  title: 'Build',
448
467
  input: BuildInput,
449
468
  output: BuildOutput,
@@ -611,19 +630,26 @@ const build = defineLoop({
611
630
  criteria,
612
631
  ...(lastNotRun.length === 0 ? undefined : { notRun: lastNotRun }),
613
632
  ...(last.earlier.length === 0 ? undefined : { findings: last.earlier }),
633
+ blockingCounts: last.blockingCounts,
614
634
  ...(approval === undefined ? undefined : { approval })
615
635
  }
616
636
 
617
637
  const maxRebuilds = input.maxRebuilds ?? 1
618
638
 
619
639
  // Anything left unsettled stops here with the findings for a person, not in Shepherd. Full auto builds again on
620
- // the same branch up to the cap, then fails with them rather than wait on a Question nobody answers.
640
+ // the same branch up to the cap while its Review rounds converge, then fails with them rather than wait on a
641
+ // Question nobody answers.
621
642
  for (let rebuilds = 0; input.land !== false && settledAs.unsettled.length > 0;) {
622
643
  const standing = settledAs.unsettled
623
- const again = rebuilds < maxRebuilds
644
+ const refusal = rebuildRefusal(settledAs.blockingCounts ?? [])
645
+ const again = rebuilds < maxRebuilds && refusal === undefined
646
+ const refused = refusal === undefined ? [] : [`Another Build is not offered: ${refusal}.`]
624
647
 
625
648
  const answer = yield* ask(rebuilds === 0 ? 'unsettled' : `unsettled:${rebuilds + 1}`, {
626
- prompt: `The ChangeRequest ${opened.url} is open, but these still stand: ${standing.join('; ')}. Build will not land it.`,
649
+ prompt: [
650
+ `The ChangeRequest ${opened.url} is open, but these still stand: ${standing.join('; ')}. Build will not land it.`,
651
+ ...refused
652
+ ].join(' '),
627
653
  options: [
628
654
  { value: takenOverAnswer, description: 'A person fixes, rebuts or steers it from here.' },
629
655
  again
@@ -652,7 +678,8 @@ const build = defineLoop({
652
678
  text: [
653
679
  `Build stopped without landing ${opened.url}, marked blocked on what still stands:`,
654
680
  '',
655
- ...standing.map(item => `- ${item}`)
681
+ ...standing.map(item => `- ${item}`),
682
+ ...(refused.length === 0 ? [] : ['', ...refused])
656
683
  ].join('\n')
657
684
  })
658
685
 
@@ -0,0 +1,36 @@
1
+ import { isBlocking, type MergedFinding, type SettledRound } from '@kitman-sh/sdk/loop'
2
+
3
+ /** The reviewer seat that runs in every Review round, so its counts compare from one round to the next. */
4
+ const everyRoundSeat = 'code-review'
5
+
6
+ /** From this many blockers and majors, a count that only stays level is not converging. */
7
+ const levelLimit = 3
8
+
9
+ const raisedAsBlocking = (finding: MergedFinding) =>
10
+ isBlocking(finding) && (finding.blockingSeats ?? finding.seats).includes(everyRoundSeat)
11
+
12
+ /** The blockers and majors of the seat that runs in every round, still open or disputed after a Review round. */
13
+ export const blockingCount = (settled: SettledRound) =>
14
+ [...settled.open, ...settled.standing.map(entry => entry.finding)].filter(raisedAsBlocking).length
15
+
16
+ /**
17
+ * Why a Build whose Review rounds had these blocking counts, first to last, may not start a Rebuild; undefined when it
18
+ * may.
19
+ */
20
+ export const rebuildRefusal = (counts: readonly number[]) => {
21
+ const previous = counts.at(-2)
22
+ const latest = counts.at(-1)
23
+
24
+ if (previous === undefined || latest === undefined) return undefined
25
+
26
+ const change =
27
+ latest > previous
28
+ ? `rose from ${previous} to ${latest}`
29
+ : latest === previous && latest >= levelLimit
30
+ ? `stayed level at ${latest}`
31
+ : undefined
32
+
33
+ return change === undefined
34
+ ? undefined
35
+ : `its Review rounds are not converging: the ${everyRoundSeat} reviewer's blockers and majors ${change} in the last Review round (${counts.join(', ')})`
36
+ }