@kitman-sh/software-engineering 0.10.100 → 0.10.102

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
@@ -13864,7 +13864,9 @@ var RunWaiting = Union2([
13864
13864
  kind: Literal2("event"),
13865
13865
  name: String5.check(isMinLength(1)),
13866
13866
  event: String5.check(isMinLength(1)),
13867
- timesOutAt: Timestamp
13867
+ timesOutAt: Timestamp,
13868
+ changeRequestId: optionalKey2(Id),
13869
+ head: optionalKey2(String5)
13868
13870
  }),
13869
13871
  Struct({ kind: Literal2("step"), name: String5.check(isMinLength(1)), stepAttemptId: Id }),
13870
13872
  Struct({ kind: Literal2("child"), name: String5.check(isMinLength(1)), runId: Id }),
@@ -19310,11 +19312,15 @@ var IntegrationBranch = Struct({
19310
19312
  });
19311
19313
  var MergeChangeRequestRequest = Struct({
19312
19314
  changeRequestId: String5,
19313
- head: optionalKey2(String5)
19315
+ head: optionalKey2(String5),
19316
+ rebase: optionalKey2(Boolean3)
19314
19317
  });
19315
19318
  var MergeResult = Union2([
19316
19319
  Struct({ status: Literal2("merged"), revision: String5 }),
19317
- Struct({ status: Literal2("conflict") }),
19320
+ Struct({
19321
+ status: Literal2("conflict"),
19322
+ reason: optionalKey2(Literals(["conflicts", "behind", "not_ready"]))
19323
+ }),
19318
19324
  Struct({ status: Literal2("moved"), head: String5 })
19319
19325
  ]);
19320
19326
  var ApproveChangeRequestRequest = Struct({
@@ -23392,6 +23398,8 @@ var menuDescriptions = {
23392
23398
  Refine: "You say what to change and the planner rewrites it.",
23393
23399
  Finish: "Ends the Run with the plan as it is."
23394
23400
  };
23401
+ var onConflict = ["Rebuild on the integration branch", "Skip"];
23402
+ var onHeld = ["Merge again", ...onConflict];
23395
23403
  var onFailure = ["Retry with a steer", "Skip it and its dependents", "Stop here"];
23396
23404
  var ticketRules = [
23397
23405
  "Each ticket is one Build: a vertical slice an agent can implement, review and deliver as one ChangeRequest. Give it a short unique key, and list in blockedBy the keys of the tickets whose code it needs; tickets never block each other in a cycle. Set repoBindingId only when it changes another repository than the plan, keep one repository per ticket, and no cycle across repositories. Set outcome to the kind of change: feature, bug, refactor, docs, migration, investigation or performance.",
@@ -23544,28 +23552,55 @@ Merge it once they pass by hand, or skip it and the tickets it blocks?`,
23544
23552
  if (unverified === "Skip")
23545
23553
  return settled(ticket, { status: "skipped", ...delivered, reason: "Verify never ran some of its tests" });
23546
23554
  }
23547
- const merged = yield* mergeChangeRequest(`merge:${name}${suffix}`, {
23548
- changeRequestId: built.changeRequest.id,
23549
- head: built.revision
23550
- });
23551
- if (merged.status === "merged")
23552
- return settled(ticket, { status: "merged", ...delivered });
23553
- const choice = yield* ask(`conflict:${name}${suffix}`, {
23554
- prompt: `The ChangeRequest for ${ticket.key} (${built.changeRequest.url}) ${merged.status === "moved" ? "changed after it was built" : `conflicts with ${head.branch}`}. Rebuild ${ticket.key} on the integration branch as it is now, or skip it and the tickets it blocks?`,
23555
- options: [
23556
- {
23557
- value: "Rebuild on the integration branch",
23558
- description: "Builds the ticket again from the branch as it is now."
23559
- },
23560
- { value: "Skip", description: "Leaves it and the tickets it blocks undelivered." }
23561
- ],
23562
- recommended: "Rebuild on the integration branch",
23563
- recommendationReason: "A rebuild on the current branch usually resolves a conflict, and skipping also drops every ticket it blocks.",
23564
- default: "Skip",
23565
- timeout: "1 hour"
23566
- });
23555
+ const rebuild = {
23556
+ value: "Rebuild on the integration branch",
23557
+ description: "Builds the ticket again from the branch as it is now."
23558
+ };
23559
+ const skip = { value: "Skip", description: "Leaves it and the tickets it blocks undelivered." };
23560
+ let choice = "Merge again";
23561
+ let refusal = `It conflicted with ${head.branch}`;
23562
+ for (let again = 0;choice === "Merge again"; again++) {
23563
+ const label = again === 0 ? suffix : `${suffix}:again:${again}`;
23564
+ const merged = yield* mergeChangeRequest(`merge:${name}${label}`, {
23565
+ changeRequestId: built.changeRequest.id,
23566
+ head: built.revision,
23567
+ rebase: true
23568
+ });
23569
+ if (merged.status === "merged")
23570
+ return settled(ticket, { status: "merged", ...delivered });
23571
+ const request = `The ChangeRequest for ${ticket.key} (${built.changeRequest.url})`;
23572
+ if (merged.status === "conflict" && merged.reason === "not_ready") {
23573
+ refusal = `The forge held it back from ${head.branch}`;
23574
+ choice = yield* ask(`conflict:${name}${label}`, {
23575
+ prompt: `${request} cannot merge into ${head.branch} yet: the forge holds it back, as for approvals, unresolved discussions, a draft or a pipeline that must pass first. Merge it again once that is settled, rebuild ${ticket.key} on the integration branch as it is now, or skip it and the tickets it blocks?`,
23576
+ options: [
23577
+ {
23578
+ value: "Merge again",
23579
+ description: "Tries the merge again, for once whatever holds it back is settled."
23580
+ },
23581
+ rebuild,
23582
+ skip
23583
+ ],
23584
+ recommended: "Merge again",
23585
+ recommendationReason: "Nothing conflicts, so a rebuild meets the same hold, and skipping also drops every ticket it blocks.",
23586
+ default: "Skip",
23587
+ timeout: "1 hour"
23588
+ });
23589
+ } else {
23590
+ const behind = merged.status === "conflict" && merged.reason === "behind";
23591
+ refusal = `${behind ? "It stayed behind" : "It conflicted with"} ${head.branch}`;
23592
+ choice = yield* ask(`conflict:${name}${label}`, {
23593
+ prompt: `${request} ${merged.status === "moved" ? "changed after it was built" : `${behind ? "is behind" : "conflicts with"} ${head.branch}`}. Rebuild ${ticket.key} on the integration branch as it is now, or skip it and the tickets it blocks?`,
23594
+ options: [rebuild, skip],
23595
+ recommended: "Rebuild on the integration branch",
23596
+ recommendationReason: "A rebuild on the current branch usually resolves a conflict, and skipping also drops every ticket it blocks.",
23597
+ default: "Skip",
23598
+ timeout: "1 hour"
23599
+ });
23600
+ }
23601
+ }
23567
23602
  if (choice === "Skip")
23568
- return settled(ticket, { status: "failed", ...delivered, reason: `It conflicted with ${head.branch}` });
23603
+ return settled(ticket, { status: "failed", ...delivered, reason: refusal });
23569
23604
  head = yield* integrationBranch(`rebuild-from:${name}:${attempt + 1}`, {
23570
23605
  repoBindingId: head.repoBindingId
23571
23606
  });
@@ -27671,11 +27706,15 @@ class RunnerCapabilityRpcs extends make30(make29("PutQuestion", {
27671
27706
  lease: ProgramLease,
27672
27707
  step: String5,
27673
27708
  changeRequestId: String5,
27674
- head: optionalKey2(String5)
27709
+ head: optionalKey2(String5),
27710
+ rebase: optionalKey2(Boolean3)
27675
27711
  },
27676
27712
  success: Union2([
27677
27713
  Struct({ status: Literal2("merged"), revision: String5 }),
27678
- Struct({ status: Literal2("conflict") }),
27714
+ Struct({
27715
+ status: Literal2("conflict"),
27716
+ reason: optionalKey2(Literals(["conflicts", "behind", "not_ready"]))
27717
+ }),
27679
27718
  Struct({ status: Literal2("moved"), head: String5 })
27680
27719
  ]),
27681
27720
  error: RunnerRpcError
@@ -30412,4 +30451,4 @@ var runKit = (config, identity, packages) => {
30412
30451
  runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
30413
30452
  };
30414
30453
  // .kitman-build-entry.ts
30415
- runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.100" }, []);
30454
+ runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.10.102" }, []);
@@ -3528,7 +3528,7 @@
3528
3528
  "carried": [
3529
3529
  {
3530
3530
  "name": "@kitman-sh/software-engineering",
3531
- "version": "0.10.100",
3531
+ "version": "0.10.102",
3532
3532
  "setup": "2a237548a69b0cd53ec3be7f687cfa8c2128335b3a655d34e185f2abce6a3c37",
3533
3533
  "loops": [
3534
3534
  "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitman-sh/software-engineering",
3
- "version": "0.10.100",
3
+ "version": "0.10.102",
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.100",
20
+ "@kitman-sh/sdk": "0.10.102",
21
21
  "effect": "^4.1.2"
22
22
  },
23
23
  "kitman": {
24
24
  "bundle": "dist/bundle.js",
25
- "digest": "c1553b8d74ae9535bcf917cd88ab24d71a8fd8d15903ca6d50505e2e310e611f",
25
+ "digest": "790e075dcc25cd2cd6a0d0228fc1ac568b5920efcddb5622dcefe2cccc7102fe",
26
26
  "protocolVersion": 5,
27
27
  "declarations": "dist/declarations.json",
28
28
  "setup": {
package/src/plan.ts CHANGED
@@ -106,6 +106,8 @@ const menuDescriptions: Record<Choice, string> = {
106
106
 
107
107
  const onConflict = ['Rebuild on the integration branch', 'Skip'] as const
108
108
 
109
+ const onHeld = ['Merge again', ...onConflict] as const
110
+
109
111
  const onUnverified = ['Skip', 'Merge'] as const
110
112
 
111
113
  const onFailure = ['Retry with a steer', 'Skip it and its dependents', 'Stop here'] as const
@@ -260,8 +262,8 @@ const settled = (ticket: PlanTicket, result: Omit<TicketResult, 'key' | 'title'>
260
262
  /**
261
263
  * Builds a ticket from the integration head, then merges its ChangeRequest into the integration branch. When verify
262
264
  * never ran some of its tests, the user chooses to merge it or skip it. On a conflict the user chooses to rebuild from
263
- * the head as it is now, or to give the ticket up. `steer` is a person's words for a retry; `label` names its Steps
264
- * apart from the first try's.
265
+ * the head as it is now, or to give the ticket up; on a merge the forge only holds back, also to merge it again.
266
+ * `steer` is a person's words for a retry; `label` names its Steps apart from the first try's.
265
267
  */
266
268
  const buildTicket = (
267
269
  ticket: PlanTicket,
@@ -315,32 +317,68 @@ const buildTicket = (
315
317
  return settled(ticket, { status: 'skipped', ...delivered, reason: 'Verify never ran some of its tests' })
316
318
  }
317
319
 
318
- // Only what the Build verified merges; a commit pushed to its branch since is rebuilt or skipped like a conflict.
319
- const merged = yield* mergeChangeRequest(`merge:${name}${suffix}`, {
320
- changeRequestId: built.changeRequest.id,
321
- head: built.revision
322
- })
320
+ const rebuild = {
321
+ value: 'Rebuild on the integration branch',
322
+ description: 'Builds the ticket again from the branch as it is now.'
323
+ } as const
323
324
 
324
- if (merged.status === 'merged') return settled(ticket, { status: 'merged', ...delivered })
325
+ const skip = { value: 'Skip', description: 'Leaves it and the tickets it blocks undelivered.' } as const
326
+ let choice: (typeof onHeld)[number] = 'Merge again'
327
+ let refusal = `It conflicted with ${head.branch}`
325
328
 
326
- const choice = yield* ask(`conflict:${name}${suffix}`, {
327
- prompt: `The ChangeRequest for ${ticket.key} (${built.changeRequest.url}) ${merged.status === 'moved' ? 'changed after it was built' : `conflicts with ${head.branch}`}. Rebuild ${ticket.key} on the integration branch as it is now, or skip it and the tickets it blocks?`,
328
- options: [
329
- {
330
- value: 'Rebuild on the integration branch',
331
- description: 'Builds the ticket again from the branch as it is now.'
332
- },
333
- { value: 'Skip', description: 'Leaves it and the tickets it blocks undelivered.' }
334
- ] satisfies { readonly value: (typeof onConflict)[number]; readonly description: string }[],
335
- recommended: 'Rebuild on the integration branch',
336
- recommendationReason:
337
- 'A rebuild on the current branch usually resolves a conflict, and skipping also drops every ticket it blocks.',
338
- default: 'Skip',
339
- timeout: '1 hour'
340
- })
329
+ for (let again = 0; choice === 'Merge again'; again++) {
330
+ const label = again === 0 ? suffix : `${suffix}:again:${again}`
331
+
332
+ // Only what the Build verified merges; a commit pushed to its branch since is rebuilt or skipped like a
333
+ // conflict. The integration branch's own ChangeRequest is verified again, so one behind it is rebased onto it.
334
+ const merged = yield* mergeChangeRequest(`merge:${name}${label}`, {
335
+ changeRequestId: built.changeRequest.id,
336
+ head: built.revision,
337
+ rebase: true
338
+ })
339
+
340
+ if (merged.status === 'merged') return settled(ticket, { status: 'merged', ...delivered })
341
+ const request = `The ChangeRequest for ${ticket.key} (${built.changeRequest.url})`
342
+
343
+ if (merged.status === 'conflict' && merged.reason === 'not_ready') {
344
+ refusal = `The forge held it back from ${head.branch}`
345
+
346
+ choice = yield* ask(`conflict:${name}${label}`, {
347
+ prompt: `${request} cannot merge into ${head.branch} yet: the forge holds it back, as for approvals, unresolved discussions, a draft or a pipeline that must pass first. Merge it again once that is settled, rebuild ${ticket.key} on the integration branch as it is now, or skip it and the tickets it blocks?`,
348
+ options: [
349
+ {
350
+ value: 'Merge again',
351
+ description: 'Tries the merge again, for once whatever holds it back is settled.'
352
+ },
353
+ rebuild,
354
+ skip
355
+ ] satisfies { readonly value: (typeof onHeld)[number]; readonly description: string }[],
356
+ recommended: 'Merge again',
357
+ recommendationReason:
358
+ 'Nothing conflicts, so a rebuild meets the same hold, and skipping also drops every ticket it blocks.',
359
+ default: 'Skip',
360
+ timeout: '1 hour'
361
+ })
362
+ } else {
363
+ const behind = merged.status === 'conflict' && merged.reason === 'behind'
364
+ refusal = `${behind ? 'It stayed behind' : 'It conflicted with'} ${head.branch}`
365
+
366
+ choice = yield* ask(`conflict:${name}${label}`, {
367
+ prompt: `${request} ${merged.status === 'moved' ? 'changed after it was built' : `${behind ? 'is behind' : 'conflicts with'} ${head.branch}`}. Rebuild ${ticket.key} on the integration branch as it is now, or skip it and the tickets it blocks?`,
368
+ options: [rebuild, skip] satisfies {
369
+ readonly value: (typeof onConflict)[number]
370
+ readonly description: string
371
+ }[],
372
+ recommended: 'Rebuild on the integration branch',
373
+ recommendationReason:
374
+ 'A rebuild on the current branch usually resolves a conflict, and skipping also drops every ticket it blocks.',
375
+ default: 'Skip',
376
+ timeout: '1 hour'
377
+ })
378
+ }
379
+ }
341
380
 
342
- if (choice === 'Skip')
343
- return settled(ticket, { status: 'failed', ...delivered, reason: `It conflicted with ${head.branch}` })
381
+ if (choice === 'Skip') return settled(ticket, { status: 'failed', ...delivered, reason: refusal })
344
382
 
345
383
  head = yield* integrationBranch(`rebuild-from:${name}:${attempt + 1}`, {
346
384
  repoBindingId: head.repoBindingId