@kitman-sh/software-engineering 0.10.80 → 0.10.81

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
@@ -21417,6 +21417,7 @@ var ShepherdOutput = Struct({
21417
21417
  reason: String5,
21418
21418
  fixRounds: Int,
21419
21419
  replies: Int,
21420
+ unsettled: optional2(ArraySchema(String5)),
21420
21421
  release: optional2(Struct({ runStatus: String5, reason: String5, tag: optional2(String5) })),
21421
21422
  handBack: optional2(Struct({
21422
21423
  changeRequestId: String5,
@@ -21554,6 +21555,7 @@ var shepherd_default = defineLoop({
21554
21555
  const syncedFor = new Set;
21555
21556
  const syncedKey = (head, targetHead) => `${head}@${targetHead}`;
21556
21557
  const blockerSynced = new Set;
21558
+ const blockerRechecks = new Map;
21557
21559
  let turn;
21558
21560
  let turns = 0;
21559
21561
  let passes = 0;
@@ -21564,7 +21566,8 @@ var shepherd_default = defineLoop({
21564
21566
  status,
21565
21567
  reason,
21566
21568
  fixRounds: fixRounds(),
21567
- replies
21569
+ replies,
21570
+ ...status === "needs_you" || status === "handed_back" ? { unsettled: [reason] } : undefined
21568
21571
  });
21569
21572
  const handBack = (reason, open) => ({
21570
21573
  ...done("handed_back", reason),
@@ -21777,8 +21780,20 @@ ${open}`,
21777
21780
  const blocker = pipeline.conflicts === true ? `conflicts with ${target}` : `needs ${target} merged in`;
21778
21781
  const targetHead = pipeline.target?.head;
21779
21782
  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.`);
21783
+ if (syncedAlready) {
21784
+ const rechecks = (blockerRechecks.get(pipeline.head) ?? 0) + 1;
21785
+ blockerRechecks.set(pipeline.head, rechecks);
21786
+ if (rechecks <= 3) {
21787
+ yield* waitFor(`recheck:${cycle}`, {
21788
+ event: "change_request.mergeable",
21789
+ filter: { changeRequestId, head: pipeline.head },
21790
+ timeout: "2 minutes",
21791
+ ...pipeline.readAt === undefined ? undefined : { since: pipeline.readAt }
21792
+ }).pipe(catchTag2("WaitTimedOut", () => void_3));
21793
+ continue;
21794
+ }
21795
+ 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.`);
21796
+ }
21782
21797
  if (targetHead !== undefined)
21783
21798
  syncedFor.add(syncedKey(pipeline.head, targetHead));
21784
21799
  blockerSynced.add(pipeline.head);
@@ -30154,4 +30169,4 @@ var runKit = (config, identity, packages) => {
30154
30169
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
30155
30170
  };
30156
30171
  // .kitman-build-entry.ts
30157
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.80" }, []);
30172
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.81" }, []);
@@ -364,6 +364,19 @@
364
364
  "minimum": -9007199254740991,
365
365
  "maximum": 9007199254740991
366
366
  },
367
+ "unsettled": {
368
+ "anyOf": [
369
+ {
370
+ "type": "array",
371
+ "items": {
372
+ "type": "string"
373
+ }
374
+ },
375
+ {
376
+ "type": "null"
377
+ }
378
+ ]
379
+ },
367
380
  "release": {
368
381
  "anyOf": [
369
382
  {
@@ -2769,6 +2782,19 @@
2769
2782
  "minimum": -9007199254740991,
2770
2783
  "maximum": 9007199254740991
2771
2784
  },
2785
+ "unsettled": {
2786
+ "anyOf": [
2787
+ {
2788
+ "type": "array",
2789
+ "items": {
2790
+ "type": "string"
2791
+ }
2792
+ },
2793
+ {
2794
+ "type": "null"
2795
+ }
2796
+ ]
2797
+ },
2772
2798
  "release": {
2773
2799
  "anyOf": [
2774
2800
  {
@@ -3383,7 +3409,7 @@
3383
3409
  "carried": [
3384
3410
  {
3385
3411
  "name": "@kitman-sh/software-engineering",
3386
- "version": "0.10.80",
3412
+ "version": "0.10.81",
3387
3413
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
3388
3414
  "loops": [
3389
3415
  "build",
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.81",
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",
20
+ "@kitman-sh/sdk": "0.10.81",
21
21
  "effect": "4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "b208051317bf879ed8e8b55c9d44f2f97ec316402747e639fa131e2e9579dcd9",
25
+ "digest": "8b38eb9071e521d41da1abdfb4579ddbaed942e423430be8211817fafaad6280",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
@@ -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
@@ -273,6 +273,8 @@ export default defineLoop({
273
273
  const syncedKey = (head: string, targetHead: string) => `${head}@${targetHead}`
274
274
  /** The heads a sync for the forge's blocker started from or pushed, judged by when the target's head is unknown. */
275
275
  const blockerSynced = new Set<string>()
276
+ /** How often the forge's blocker has been looked at again at a head a sync settled it for. */
277
+ const blockerRechecks = new Map<string, number>()
276
278
 
277
279
  /** The target's turn: held from the sync before the merge until the merge, so one ChangeRequest merges at a time. */
278
280
  let turn: Claim | undefined
@@ -292,7 +294,8 @@ export default defineLoop({
292
294
  status,
293
295
  reason,
294
296
  fixRounds: fixRounds(),
295
- replies
297
+ replies,
298
+ ...(status === 'needs_you' || status === 'handed_back' ? { unsettled: [reason] } : undefined)
296
299
  })
297
300
 
298
301
  const handBack = (reason: string, open: string): Output => ({
@@ -623,11 +626,29 @@ export default defineLoop({
623
626
  ? blockerSynced.has(pipeline.head)
624
627
  : syncedFor.has(syncedKey(pipeline.head, targetHead))
625
628
 
626
- if (syncedAlready)
629
+ if (syncedAlready) {
630
+ // This head already took the target in, so the blocker is most likely the forge's answer for an older head:
631
+ // GitLab works mergeability out after a push and shows the last answer meanwhile. Look again before giving up.
632
+ const rechecks = (blockerRechecks.get(pipeline.head) ?? 0) + 1
633
+
634
+ blockerRechecks.set(pipeline.head, rechecks)
635
+
636
+ if (rechecks <= 3) {
637
+ yield* waitFor(`recheck:${cycle}`, {
638
+ event: 'change_request.mergeable',
639
+ filter: { changeRequestId, head: pipeline.head },
640
+ timeout: '2 minutes',
641
+ ...(pipeline.readAt === undefined ? undefined : { since: pipeline.readAt })
642
+ }).pipe(Effect.catchTag('WaitTimedOut', () => Effect.void))
643
+
644
+ continue
645
+ }
646
+
627
647
  return handBack(
628
- `The forge still says ${pipeline.head} ${blocker} after merging it in`,
648
+ `The forge still says ${pipeline.head} ${blocker} after merging it in, and three more looks said the same`,
629
649
  `Merge ${target} into the branch and settle what conflicts.`
630
650
  )
651
+ }
631
652
 
632
653
  if (targetHead !== undefined) syncedFor.add(syncedKey(pipeline.head, targetHead))
633
654
  blockerSynced.add(pipeline.head)