pr-shepherd 2.6.1 → 2.7.0

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.
Files changed (131) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/classify/standard/coderabbit-walkthrough.d.mts +10 -0
  3. package/bin/classify/standard/coderabbit-walkthrough.mjs +21 -0
  4. package/bin/classify/standard/devin-no-issues.d.mts +7 -0
  5. package/bin/classify/standard/devin-no-issues.mjs +18 -0
  6. package/bin/classify/standard/index.d.mts +2 -1
  7. package/bin/classify/standard/index.mjs +6 -1
  8. package/bin/cli/apply-merge-handler.mjs +2 -0
  9. package/bin/cli/body-truncate.d.mts +7 -0
  10. package/bin/cli/body-truncate.mjs +8 -4
  11. package/bin/cli/help-command-pages.d.mts +4 -2
  12. package/bin/cli/help-command-pages.mjs +4 -1
  13. package/bin/cli/help-iterate-poll-pages.d.mts +1 -1
  14. package/bin/cli/help-iterate-poll-pages.mjs +1 -1
  15. package/bin/cli/help-top-page.d.mts +1 -1
  16. package/bin/cli/help-top-page.mjs +3 -1
  17. package/bin/cli/help-watch-status-page.d.mts +1 -0
  18. package/bin/cli/help-watch-status-page.mjs +21 -0
  19. package/bin/cli/help.d.mts +5 -3
  20. package/bin/cli/help.mjs +2 -0
  21. package/bin/cli/iterate-lean.d.mts +0 -5
  22. package/bin/cli/iterate-lean.mjs +9 -2
  23. package/bin/cli/poll-summary-formatter.mjs +2 -1
  24. package/bin/cli/review-body-cap.d.mts +10 -0
  25. package/bin/cli/review-body-cap.mjs +84 -0
  26. package/bin/cli/stack-layer-view.d.mts +2 -0
  27. package/bin/cli/stack-layer-view.mjs +8 -0
  28. package/bin/cli/stack-overview.mjs +4 -5
  29. package/bin/cli/triage-formatter.mjs +4 -1
  30. package/bin/cli/watch-status-handler.d.mts +2 -0
  31. package/bin/cli/watch-status-handler.mjs +56 -0
  32. package/bin/cli-parser.mjs +7 -0
  33. package/bin/commands/apply-merge-default-route.d.mts +56 -0
  34. package/bin/commands/apply-merge-default-route.mjs +149 -0
  35. package/bin/commands/apply-merge-output.d.mts +2 -0
  36. package/bin/commands/apply-merge-output.mjs +8 -0
  37. package/bin/commands/apply-merge-pull.d.mts +3 -0
  38. package/bin/commands/apply-merge-resume.d.mts +2 -3
  39. package/bin/commands/apply-merge-resume.mjs +74 -32
  40. package/bin/commands/apply-merge-stack-membership.d.mts +27 -0
  41. package/bin/commands/apply-merge-stack-membership.mjs +85 -0
  42. package/bin/commands/apply-merge-submit.d.mts +20 -0
  43. package/bin/commands/apply-merge-submit.mjs +47 -0
  44. package/bin/commands/apply-merge-supersede.d.mts +17 -0
  45. package/bin/commands/apply-merge-supersede.mjs +30 -0
  46. package/bin/commands/apply-merge-sync-fallback.d.mts +16 -0
  47. package/bin/commands/apply-merge-sync-fallback.mjs +55 -0
  48. package/bin/commands/apply-merge.d.mts +2 -0
  49. package/bin/commands/apply-merge.mjs +65 -41
  50. package/bin/commands/check-review-budget.mjs +12 -1
  51. package/bin/commands/check.d.mts +2 -0
  52. package/bin/commands/check.mjs +9 -1
  53. package/bin/commands/iterate/escalate.mjs +5 -0
  54. package/bin/commands/iterate/index.mjs +34 -4
  55. package/bin/commands/iterate/merge-plan.d.mts +2 -0
  56. package/bin/commands/iterate/merge-plan.mjs +1 -1
  57. package/bin/commands/iterate/merge.mjs +7 -3
  58. package/bin/commands/iterate/stack-boundary.mjs +6 -6
  59. package/bin/commands/iterate/triage.mjs +19 -6
  60. package/bin/commands/poll-events.d.mts +1 -1
  61. package/bin/commands/poll-events.mjs +8 -3
  62. package/bin/commands/poll-seen-options.d.mts +7 -0
  63. package/bin/commands/poll-seen-options.mjs +9 -0
  64. package/bin/commands/poll-summary-instructions.d.mts +1 -0
  65. package/bin/commands/poll-summary-instructions.mjs +17 -7
  66. package/bin/commands/poll-summary.mjs +8 -4
  67. package/bin/commands/poll.mjs +2 -2
  68. package/bin/commands/rest-stack-merge-readiness.d.mts +6 -2
  69. package/bin/commands/rest-stack-merge-readiness.mjs +59 -7
  70. package/bin/commands/stack-drain.d.mts +7 -1
  71. package/bin/commands/stack-drain.mjs +30 -6
  72. package/bin/commands/stack-lower-heads.d.mts +32 -0
  73. package/bin/commands/stack-lower-heads.mjs +53 -0
  74. package/bin/commands/stack-merge-escalations.d.mts +2 -1
  75. package/bin/commands/stack-merge-plan.mjs +35 -41
  76. package/bin/commands/stack-merge-trunk-check.d.mts +0 -2
  77. package/bin/commands/stack-merge-trunk-check.mjs +0 -2
  78. package/bin/commands/stack-ownership.mjs +3 -3
  79. package/bin/commands/stack-stall.d.mts +1 -0
  80. package/bin/commands/stack-stall.mjs +6 -2
  81. package/bin/commands/stack-trunk-behind.d.mts +1 -1
  82. package/bin/commands/stack-trunk-behind.mjs +1 -1
  83. package/bin/commands/stack-work.mjs +1 -1
  84. package/bin/config/merge-command-args.d.mts +2 -0
  85. package/bin/config/merge-command-args.mjs +13 -0
  86. package/bin/config/merge-method.d.mts +0 -5
  87. package/bin/config/merge-method.mjs +0 -6
  88. package/bin/config/schema.d.mts +2 -0
  89. package/bin/config/schema.mjs +2 -13
  90. package/bin/github/batch-parser-helpers.d.mts +5 -0
  91. package/bin/github/batch-parser-helpers.mjs +7 -2
  92. package/bin/github/batch-parsers.mjs +6 -2
  93. package/bin/github/errors.d.mts +2 -0
  94. package/bin/github/errors.mjs +1 -1
  95. package/bin/github/poll-summary-annotation-probe.d.mts +1 -1
  96. package/bin/github/poll-summary-annotation-probe.mjs +2 -2
  97. package/bin/github/poll-summary-command.d.mts +3 -2
  98. package/bin/github/poll-summary-command.mjs +6 -4
  99. package/bin/github/poll-summary-projector.mjs +16 -14
  100. package/bin/github/poll-summary-readiness.d.mts +4 -0
  101. package/bin/github/poll-summary-readiness.mjs +22 -0
  102. package/bin/github/poll-summary-rest-queue.d.mts +13 -0
  103. package/bin/github/poll-summary-rest-queue.mjs +21 -0
  104. package/bin/github/poll-summary-review-helpers.mjs +8 -4
  105. package/bin/state/merge-method-cache.d.mts +19 -0
  106. package/bin/state/merge-method-cache.mjs +27 -0
  107. package/bin/state/merge-request-claim.d.mts +23 -0
  108. package/bin/state/merge-request-claim.mjs +44 -0
  109. package/bin/state/merge-request-clear.d.mts +24 -0
  110. package/bin/state/merge-request-clear.mjs +36 -0
  111. package/bin/state/merge-request-lock.d.mts +13 -0
  112. package/bin/state/merge-request-lock.mjs +136 -0
  113. package/bin/state/merge-request-stack-heads.d.mts +2 -0
  114. package/bin/state/merge-request-stack-heads.mjs +8 -0
  115. package/bin/state/merge-request.d.mts +23 -6
  116. package/bin/state/merge-request.mjs +29 -29
  117. package/bin/state/ready-receipts.d.mts +11 -0
  118. package/bin/state/ready-receipts.mjs +7 -0
  119. package/bin/state/watch-lock.d.mts +10 -0
  120. package/bin/state/watch-lock.mjs +38 -3
  121. package/bin/types/poll-summary.d.mts +2 -0
  122. package/package.json +12 -5
  123. package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
  124. package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
  125. package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +1 -1
  126. package/plugins/pr-shepherd/skills/pr-shepherd/references/create-a-pr.md +2 -2
  127. package/plugins/pr-shepherd/skills/pr-shepherd/references/waiting.md +1 -1
  128. package/plugins/pr-shepherd/skills/setup-pr-shepherd/references/classifiers.md +1 -1
  129. package/pr-shepherd.schema.json +8 -0
  130. package/bin/commands/stack-merge-flag.d.mts +0 -7
  131. package/bin/commands/stack-merge-flag.mjs +0 -6
@@ -1,9 +1,7 @@
1
- import { getGithubTransport } from "../github/transport.mjs";
2
1
  import { buildMergeCommandPlan, renderMergeCommand } from "./iterate/merge.mjs";
3
2
  import { appendAutonomousInstructions, idleWaitPlan, appendHumanHandoffInstructions, findHumanHandoffs, hasListedOwnership, } from "./stack-drain.mjs";
4
3
  import { isStackLayerReady, aboveThroughTarget, closedInScope, mergeScopeLayers, openLayers, readyPrefix, stackPosition, } from "./stack-merge-scope.mjs";
5
- import { stackMergeFlag } from "./stack-merge-flag.mjs";
6
- import { MERGE_CONFLICT_NOTE, trunkPreCheck } from "./stack-merge-trunk-check.mjs";
4
+ import { trunkPreCheck } from "./stack-merge-trunk-check.mjs";
7
5
  import { addedLayersEscalation, escalation, list, scopeDone, unlistedAboveStep, unlistedEscalation, } from "./stack-merge-escalations.mjs";
8
6
  import { splitStackWork, stackRerunTarget } from "./stack-work.mjs";
9
7
  const NO_PER_LAYER = "One command lands every listed layer. Do not merge the layers one at a time with `gh pr merge`, and do not rebase or push between layers; GitHub retargets the remaining layers itself.";
@@ -66,7 +64,7 @@ function mergePlan(result, top, scope, rerunCommand, approve) {
66
64
  const landing = lands.length === 1 ? `PR #${top.pr} alone` : `PRs ${list(lands)}`;
67
65
  const partial = result.selection.kind === "stack" && result.selection.owned !== undefined;
68
66
  const ownership = partial
69
- ? ` (${above.every((item) => item.owned) ? "owned" : above.some((item) => item.owned) ? "owned and unowned" : "not owned"})`
67
+ ? ` (${above.every((item) => item.owned) ? "listed" : above.some((item) => item.owned) ? "listed and unlisted" : "not listed"})`
70
68
  : "";
71
69
  const left = above.length > 0
72
70
  ? ` ${list(above)} stay${above.length === 1 ? "s" : ""} open above it${ownership}; GitHub retargets ${above.length === 1 ? "it" : "them"} onto \`${stack.baseRefName}\`.`
@@ -84,7 +82,7 @@ function mergePlan(result, top, scope, rerunCommand, approve) {
84
82
  first.text,
85
83
  ].filter((step) => step !== undefined);
86
84
  const instructions = steps.map((step, index) => `${index + 1}. ${step}`);
87
- appendAutonomousInstructions(instructions, work.sessions, hasListedOwnership(result));
85
+ appendAutonomousInstructions(instructions, work.sessions, hasListedOwnership(result), approve, true);
88
86
  const handoffs = findHumanHandoffs(result);
89
87
  if (handoffs)
90
88
  appendHumanHandoffInstructions(instructions, handoffs, false);
@@ -97,42 +95,38 @@ function mergePlan(result, top, scope, rerunCommand, approve) {
97
95
  }
98
96
  function mergeStep(result, top, landing, left) {
99
97
  const stack = top.stack;
100
- if (getGithubTransport() === "rest" || top.transport === "rest") {
101
- // Upper layers target their parent; the prefix merges into the stack trunk.
102
- const trunk = result.prs.find((item) => item.baseRefName === stack.baseRefName);
103
- const plan = buildMergeCommandPlan({
104
- transport: "rest",
105
- pr: top.pr,
106
- repo: result.repo,
107
- nodeId: "",
108
- headSha: top.headRefOid,
109
- queue: trunk?.requiresMergeQueue === true,
110
- queueKnown: trunk?.requiresMergeQueue !== undefined,
111
- allowedMergeMethods: result.allowedMergeMethods,
112
- expectedStack: {
113
- number: stack.number,
114
- baseRefName: stack.baseRefName,
115
- prefix: [...result.prs]
116
- .sort((left, right) => stackPosition(left) - stackPosition(right))
117
- .filter((item) => stackPosition(item) <= stackPosition(top))
118
- .map((item) => ({
119
- pr: item.pr,
120
- headRefName: item.headRefName,
121
- headRefOid: item.headRefOid,
122
- baseRefName: item.baseRefName,
123
- })),
124
- },
125
- });
126
- if ("unavailable" in plan)
127
- return { unavailable: plan.unavailable, ...(plan.refresh && { refresh: true }) };
128
- return {
129
- text: `Run \`${renderMergeCommand(plan.command)}\` to request merging ${landing} of native stack #${stack.number}.${left} ${NO_PER_LAYER} If status is \`pending\`, rerun that command at the configured cadence to resume its UUID. \`enqueued\` is not merged. Shepherd revalidates every open lower layer's READY receipt before submission.`,
130
- };
131
- }
132
- const method = stackMergeFlag(result.allowedMergeMethods);
133
- if ("unavailable" in method)
134
- return { unavailable: method.unavailable };
98
+ // Upper layers target their parent; the prefix merges into the stack trunk.
99
+ const trunk = result.prs.find((item) => item.baseRefName === stack.baseRefName);
100
+ const plan = buildMergeCommandPlan({
101
+ transport: "rest",
102
+ pr: top.pr,
103
+ repo: result.repo,
104
+ nodeId: "",
105
+ headSha: top.headRefOid,
106
+ queue: trunk?.requiresMergeQueue === true,
107
+ queueKnown: trunk?.requiresMergeQueue !== undefined,
108
+ allowedMergeMethods: result.allowedMergeMethods,
109
+ linearHistory: trunk?.requiresLinearHistory === true,
110
+ // A stack prefers squash: it lands on a trunk that requires linear history, and a merge
111
+ // commit is kept only when the repository or `merge.method` selects it.
112
+ fallbackMethod: "squash",
113
+ expectedStack: {
114
+ number: stack.number,
115
+ baseRefName: stack.baseRefName,
116
+ prefix: [...result.prs]
117
+ .sort((left, right) => stackPosition(left) - stackPosition(right))
118
+ .filter((item) => stackPosition(item) <= stackPosition(top))
119
+ .map((item) => ({
120
+ pr: item.pr,
121
+ headRefName: item.headRefName,
122
+ headRefOid: item.headRefOid,
123
+ baseRefName: item.baseRefName,
124
+ })),
125
+ },
126
+ });
127
+ if ("unavailable" in plan)
128
+ return { unavailable: plan.unavailable, ...(plan.refresh && { refresh: true }) };
135
129
  return {
136
- text: `Run \`GH_REPO=${result.repo} gh stack merge ${top.pr} --yes ${method.flag}\` in \`${result.repo}\` to merge ${landing} of stack #${stack.number}.${left} ${NO_PER_LAYER} If \`gh stack\` is an unknown command, run \`gh extension install github/gh-stack\`, then rerun that merge command. ${MERGE_CONFLICT_NOTE}`,
130
+ text: `Run \`${renderMergeCommand(plan.command)}\` to request merging ${landing} of native stack #${stack.number}.${left} ${NO_PER_LAYER} If status is \`pending\`, rerun that command at the configured cadence to resume its UUID. \`enqueued\` is not merged. Shepherd revalidates every open lower layer's READY receipt before submission.`,
137
131
  };
138
132
  }
@@ -8,5 +8,3 @@ import type { PollSummaryItem, PollSummaryResult } from "../types.mts";
8
8
  * (`trunkBehindUnknown`); otherwise the merge step stays as it was.
9
9
  */
10
10
  export declare function trunkPreCheck(result: PollSummaryResult, top: PollSummaryItem): string | undefined;
11
- /** Appended to the `gh stack merge` step: that merge is atomic, so a conflict merges nothing. */
12
- export declare const MERGE_CONFLICT_NOTE = "If `gh stack merge` reports `Merge conflict detected`, nothing was merged. Do not rerun the merge; update the stack from its bottom layer onto trunk with `gh stack rebase`, then `gh stack push`, following the Branch update playbook, and rerun the stack command.";
@@ -22,5 +22,3 @@ export function trunkPreCheck(result, top) {
22
22
  });
23
23
  return `Before merging, check the top layer against trunk, because GitHub's \`mergeable\` compares an upper layer only with its parent layer. ${why}. From a checkout of \`${result.repo}\`, run \`git fetch <remote> ${trunk}\` (\`<remote>\` is the remote that points at \`${result.repo}\`), then \`git merge-tree --write-tree FETCH_HEAD ${top.headRefOid}\`. This writes no files and no refs. If it exits 0, continue with the next step. If it exits 1, it lists the conflicts: do not merge, and do not merge layer by layer. Update the whole stack from its bottom layer onto \`${trunk}\`, then push it. ${rebase} Then rerun the stack command.`;
24
24
  }
25
- /** Appended to the `gh stack merge` step: that merge is atomic, so a conflict merges nothing. */
26
- export const MERGE_CONFLICT_NOTE = "If `gh stack merge` reports `Merge conflict detected`, nothing was merged. Do not rerun the merge; update the stack from its bottom layer onto trunk with `gh stack rebase`, then `gh stack push`, following the Branch update playbook, and rerun the stack command.";
@@ -19,12 +19,12 @@ export function ownershipBoundaryStep(result) {
19
19
  const names = unowned.map((item) => `#${item.pr}`).join(", ");
20
20
  const below = open.filter((item) => item.owned && stackPosition(item) < stackPosition(boundary));
21
21
  const top = below.at(-1);
22
- const head = `Branch updates: unowned ${unowned.length === 1 ? "layer" : "layers"} ${names} ${unowned.length === 1 ? "sits" : "sit"} in this stack and must not be rebased or pushed. A \`gh stack rebase\` or \`gh stack push\` printed by a one-PR session covers the whole stack, so do not run it as printed.`;
22
+ const head = `Branch updates: ${names} ${unowned.length === 1 ? "is" : "are"} not listed after \`stack\`, so this command must not rebase or push ${unowned.length === 1 ? "it" : "them"}. A \`gh stack rebase\` or \`gh stack push\` printed by a one-PR session covers the whole stack, so do not run it as printed.`;
23
23
  if (!top) {
24
- return `${head} No owned layer sits below the first unowned layer (#${boundary.pr}), so no owned branch can be restacked without rewriting it. Do not rebase or push; report that the owned layers wait on #${boundary.pr}'s owner.`;
24
+ return `${head} No listed layer sits below the first unlisted layer (#${boundary.pr}), so no listed branch can be restacked without rewriting it. Do not rebase or push; report that the listed layers wait on #${boundary.pr}, which this command does not list.`;
25
25
  }
26
26
  const branches = below.map((item) => `\`${item.headRefName}\``).join(", ");
27
- return `${head} Instead, stop at the first unowned layer (#${boundary.pr}): check out \`${top.headRefName}\` (PR #${top.pr}), run \`gh stack rebase --downstack\`, then push only the owned branches (${branches}) with \`git push --force-with-lease <push-remote> <branch>\` (substitute this repository's push remote for \`<push-remote>\`, the remote \`gh stack push\` uses). Owned layers above #${boundary.pr} cannot be restacked this way. After the update, ${names} (and anything above) will be stale: tell the user their owner must restack ${unowned.length === 1 ? "it" : "them"}.`;
27
+ return `${head} Instead, stop at the first unlisted layer (#${boundary.pr}): check out \`${top.headRefName}\` (PR #${top.pr}), run \`gh stack rebase --downstack\`, then push only the listed branches (${branches}) with \`git push --force-with-lease <push-remote> <branch>\` (substitute this repository's push remote for \`<push-remote>\`, the remote \`gh stack push\` uses). Listed layers above #${boundary.pr} cannot be restacked this way. After the update, ${names} (and anything above) will be stale: tell the user ${unowned.length === 1 ? "it needs" : "they need"} a restack by whoever shepherds ${unowned.length === 1 ? "it" : "them"}.`;
28
28
  }
29
29
  /** Listed PRs that are no longer layers of the stack (a teammate ran `gh stack unstack` or `modify`). */
30
30
  export function missingListedLayers(prs, listed) {
@@ -8,6 +8,7 @@ import type { PollSummaryItem, PollSummaryResult } from "../types.mts";
8
8
  export declare function applyStackStallGuard(planned: {
9
9
  result: PollSummaryResult;
10
10
  idle?: PollSummaryItem[];
11
+ claims?: string[];
11
12
  }, repo: {
12
13
  owner: string;
13
14
  name: string;
@@ -11,7 +11,7 @@ import { describeIdleLayers } from "./stack-drain.mjs";
11
11
  * timer cannot be read or written, escalate `stall-state-unavailable` instead of restarting it.
12
12
  */
13
13
  export async function applyStackStallGuard(planned, repo, stallTimeoutSeconds) {
14
- const { result, idle } = planned;
14
+ const { result, idle, claims = [] } = planned;
15
15
  if (result.selection.kind !== "stack")
16
16
  return result;
17
17
  const key = { owner: repo.owner, repo: repo.name, stack: result.selection.stackNumber };
@@ -34,13 +34,17 @@ export async function applyStackStallGuard(planned, repo, stallTimeoutSeconds) {
34
34
  const ageSeconds = nowSeconds - stored.firstSeenAt;
35
35
  if (ageSeconds < stallTimeoutSeconds)
36
36
  return result;
37
+ const lead = claims.map((step, i) => step.replace(/^\d+\. /, `${i + 1}. `));
38
+ // A claim step is for a caller that owns the layer, so the handoff comes last and yields to it.
39
+ const handoff = lead.length > 0 ? "If no step above applies to you, stop and ask" : "Stop and ask";
37
40
  return {
38
41
  ...result,
39
42
  reason: "actionable",
40
43
  nextAction: "escalate",
41
44
  stackMergeable: false,
42
45
  instructions: [
43
- `1. \`stall-timeout\`: the stack has not changed for ${formatDurationApprox(ageSeconds)} while no one-PR session could advance it: ${describeIdleLayers(idle)}. Stop and ask a human to unblock the waiting layers.`,
46
+ ...lead,
47
+ `${lead.length + 1}. \`stall-timeout\`: the stack has not changed for ${formatDurationApprox(ageSeconds)} while no one-PR session could advance it: ${describeIdleLayers(idle)}. ${handoff} a human to unblock the waiting layers.`,
44
48
  ],
45
49
  };
46
50
  }
@@ -1,7 +1,7 @@
1
1
  import type { PollSummaryResult, StackMergeScope } from "../types.mts";
2
2
  /**
3
3
  * GitHub compares an upper layer's `mergeable` only with its parent layer, so a conflict with
4
- * trunk stays invisible until `gh stack merge` fails. Compare trunk with the top landing layer's
4
+ * trunk stays invisible until the stack merge fails. Compare trunk with the top landing layer's
5
5
  * head once and record the result on that row: `trunkBehindBy` when trunk has commits the head
6
6
  * lacks, `trunkBehindUnknown` when the compare failed. A failure never blocks the merge; the
7
7
  * printed pre-check still runs, because a missed conflict costs a failed atomic merge.
@@ -18,7 +18,7 @@ function stackMergeTop(result, scope) {
18
18
  }
19
19
  /**
20
20
  * GitHub compares an upper layer's `mergeable` only with its parent layer, so a conflict with
21
- * trunk stays invisible until `gh stack merge` fails. Compare trunk with the top landing layer's
21
+ * trunk stays invisible until the stack merge fails. Compare trunk with the top landing layer's
22
22
  * head once and record the result on that row: `trunkBehindBy` when trunk has commits the head
23
23
  * lacks, `trunkBehindUnknown` when the compare failed. A failure never blocks the merge; the
24
24
  * printed pre-check still runs, because a missed conflict costs a failed atomic merge.
@@ -38,7 +38,7 @@ function onlyUnownedWork(layers) {
38
38
  /** The turn must outlive every non-terminal layer; a one-PR session ending does not end the stack. */
39
39
  const STACK_KEEP_WATCHING = "Keep watching until every layer is terminal.";
40
40
  /** Work remains, but only on other authors' layers. The stack stall timer escalates if it never moves. */
41
- const NO_OWNED_SESSION = "No owned layer needs a session. The remaining work belongs to other authors. Recheck at the configured polling cadence; Shepherd escalates `stall-timeout` if the stack does not change.";
41
+ const NO_OWNED_SESSION = "No listed layer needs a session. The remaining work is on layers this command does not list. Recheck at the configured polling cadence; Shepherd escalates `stall-timeout` if the stack does not change.";
42
42
  /** The literal stack command to rerun, or the generic name when the caller's command is unknown. */
43
43
  export function stackRerunTarget(command) {
44
44
  return command ? `\`${command}\`` : "this same `stack` command";
@@ -1,2 +1,4 @@
1
+ /** `gh pr merge` flags Shepherd sets itself, so `merge.command-args` may not pass them. */
2
+ export declare const SHEPHERD_OWNED_MERGE_FLAGS: string[];
1
3
  /** Return active merge strategies while validating compound strategy syntax. */
2
4
  export declare function findMergeStrategies(args: string[]): string[];
@@ -1,3 +1,16 @@
1
+ /** `gh pr merge` flags Shepherd sets itself, so `merge.command-args` may not pass them. */
2
+ export const SHEPHERD_OWNED_MERGE_FLAGS = [
3
+ "--repo",
4
+ "-R",
5
+ "--auto",
6
+ "--disable-auto",
7
+ "--match-head-commit",
8
+ "--admin",
9
+ "--body-file",
10
+ "-F",
11
+ "--help",
12
+ "-h",
13
+ ];
1
14
  const MERGE_STRATEGY_FLAGS = new Map([
2
15
  ["--merge", "merge"],
3
16
  ["-m", "merge"],
@@ -21,8 +21,3 @@ export declare function chooseMergeMethod(input: {
21
21
  } | {
22
22
  unavailable: string;
23
23
  };
24
- export declare function mergeMethodFlag(allowed: readonly MergeMethod[] | undefined, fallback: MergeMethod, configured: MergeMethod | null): {
25
- flag: string;
26
- } | {
27
- unavailable: string;
28
- };
@@ -58,9 +58,3 @@ export function chooseMergeMethod(input) {
58
58
  unavailable: "This repository allows no merge method (merge commits, squash, and rebase are all disabled).",
59
59
  };
60
60
  }
61
- export function mergeMethodFlag(allowed, fallback, configured) {
62
- const decision = chooseMergeMethod({ allowed, configured, fallback });
63
- if ("unavailable" in decision)
64
- return decision;
65
- return { flag: `--${decision.method}` };
66
- }
@@ -36,6 +36,7 @@ export declare const configSchema: z.ZodObject<{
36
36
  rebase: "rebase";
37
37
  }>>;
38
38
  "review-output-max-chars": z.ZodDefault<z.ZodNumber>;
39
+ "changes-requested-review-max-chars": z.ZodDefault<z.ZodNumber>;
39
40
  "resolve-other-human-threads": z.ZodDefault<z.ZodEnum<{
40
41
  always: "always";
41
42
  none: "none";
@@ -131,6 +132,7 @@ export declare const configFileSchema: z.ZodObject<{
131
132
  rebase: "rebase";
132
133
  }>>;
133
134
  "review-output-max-chars": z.ZodDefault<z.ZodNumber>;
135
+ "changes-requested-review-max-chars": z.ZodDefault<z.ZodNumber>;
134
136
  "resolve-other-human-threads": z.ZodDefault<z.ZodEnum<{
135
137
  always: "always";
136
138
  none: "none";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { STANDARD_RULE_NAMES } from "../classify/standard/index.mjs";
3
3
  import { DEFAULT_BOT_USERNAMES } from "./default-bot-usernames.mjs";
4
- import { findMergeStrategies } from "./merge-command-args.mjs";
4
+ import { findMergeStrategies, SHEPHERD_OWNED_MERGE_FLAGS } from "./merge-command-args.mjs";
5
5
  /**
6
6
  * The strict v1 `.pr-shepherdrc.yml` schema. Keys are kebab-case, durations carry their unit in
7
7
  * the key name, and unknown keys or invalid values are hard errors. The defaults declared here
@@ -12,18 +12,6 @@ const DEFAULT_QUOTA_WARNINGS = [
12
12
  { "remaining-percent": 20, "interval-factor": 5 },
13
13
  { "remaining-percent": 10, "interval-factor": 10 },
14
14
  ];
15
- const SHEPHERD_OWNED_MERGE_FLAGS = [
16
- "--repo",
17
- "-R",
18
- "--auto",
19
- "--disable-auto",
20
- "--match-head-commit",
21
- "--admin",
22
- "--body-file",
23
- "-F",
24
- "--help",
25
- "-h",
26
- ];
27
15
  const strings = () => z.array(z.string());
28
16
  const positive = () => z.number().positive();
29
17
  const nonNegative = () => z.number().nonnegative();
@@ -122,6 +110,7 @@ export const configSchema = z.strictObject({
122
110
  "behind-base-hint": z.string().default(""),
123
111
  "branch-update": z.enum(["rebase", "merge"]).default("rebase"),
124
112
  "review-output-max-chars": z.number().int().nonnegative().default(50000),
113
+ "changes-requested-review-max-chars": z.number().int().nonnegative().default(10000),
125
114
  "resolve-other-human-threads": z.enum(["none", "outdated", "always"]).default("none"),
126
115
  instructions: z.enum(["inline", "playbook"]).default("inline"),
127
116
  })
@@ -6,6 +6,11 @@ export declare function parseCreatedAt(iso: string): number;
6
6
  export declare function mapCheckRunNode(node: Extract<RawContextNode, {
7
7
  __typename: "CheckRun";
8
8
  }>): CheckRun;
9
+ /**
10
+ * Lowercased logins whose latest review is APPROVED or DISMISSED, which settles their older
11
+ * CHANGES_REQUESTED reviews. GitHub logins are case-insensitive, so callers look up a lowercased
12
+ * login. Callers pass only reviews that have an author: a missing author settles nothing.
13
+ */
9
14
  export declare function latestApprovedLogins(latest: Array<{
10
15
  login: string;
11
16
  state: string;
@@ -106,10 +106,15 @@ function extractCheckRunSummary(title, summary) {
106
106
  ?.trim();
107
107
  return firstLine || undefined;
108
108
  }
109
+ /**
110
+ * Lowercased logins whose latest review is APPROVED or DISMISSED, which settles their older
111
+ * CHANGES_REQUESTED reviews. GitHub logins are case-insensitive, so callers look up a lowercased
112
+ * login. Callers pass only reviews that have an author: a missing author settles nothing.
113
+ */
109
114
  export function latestApprovedLogins(latest) {
110
115
  return new Set(latest
111
- .filter((r) => r.login !== "unknown" && (r.state === "APPROVED" || r.state === "DISMISSED"))
112
- .map((r) => r.login));
116
+ .filter((r) => r.state === "APPROVED" || r.state === "DISMISSED")
117
+ .map((r) => r.login.toLowerCase()));
113
118
  }
114
119
  /**
115
120
  * A CR review is stale when its commit.oid differs from the PR head AND every
@@ -40,7 +40,8 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
40
40
  login: n.author?.login ?? "unknown",
41
41
  state: n.state,
42
42
  }));
43
- const crDone = latestApprovedLogins(latestReviews);
43
+ // Only real logins settle a review: a missing author is not the login "unknown".
44
+ const crDone = latestApprovedLogins((raw.latestReviews?.nodes ?? []).flatMap((n) => n.author ? [{ login: n.author.login, state: n.state }] : []));
44
45
  const reviewThreads = rawThreadPages.map((t) => {
45
46
  const comment = t.comments.nodes[0];
46
47
  const comments = t.comments.nodes.map((c) => ({
@@ -99,7 +100,10 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
99
100
  }
100
101
  return review;
101
102
  });
102
- const changesRequestedReviews = allChangesRequestedReviews.filter((r) => !crDone.has(r.author));
103
+ const changesRequestedReviews = allChangesRequestedReviews.filter((_, index) => {
104
+ const login = rawReviewNodes[index]?.author?.login;
105
+ return !login || !crDone.has(login.toLowerCase());
106
+ });
103
107
  const reviewSummaries = rawReviewSummaryNodes
104
108
  .filter((r) => !r.isMinimized && r.body.trim() !== "")
105
109
  .map((r) => parseReviewNode(r));
@@ -43,5 +43,7 @@ export declare class GitHubRequestError extends ShepherdError {
43
43
  * an availability or permission problem).
44
44
  */
45
45
  exitCodeOverride?: number;
46
+ /** The error this one wraps. */
47
+ cause?: unknown;
46
48
  });
47
49
  }
@@ -85,7 +85,7 @@ export class GitHubRequestError extends ShepherdError {
85
85
  responseMessage;
86
86
  constructor(message, opts) {
87
87
  super(message, opts.exitCodeOverride ??
88
- classifyStatus(opts.status, message, opts.responseMessage, opts.rateLimit, opts.retryAfterSeconds, opts.graphqlErrors));
88
+ classifyStatus(opts.status, message, opts.responseMessage, opts.rateLimit, opts.retryAfterSeconds, opts.graphqlErrors), opts.cause === undefined ? undefined : { cause: opts.cause });
89
89
  this.name = "GitHubRequestError";
90
90
  this.status = opts.status;
91
91
  this.rateLimit = opts.rateLimit;
@@ -18,7 +18,7 @@ export declare function readyFingerprint(raw: RawSummaryPr, stored: string | nul
18
18
  export declare function hydrateReadyAnnotationProbe(pr: RawSummaryPr, repo: RepoInfo, review: {
19
19
  actionable?: number;
20
20
  incomplete?: true;
21
- }): Promise<void>;
21
+ }, olderThreadsSettled?: boolean): Promise<void>;
22
22
  /**
23
23
  * Load annotation totals once per summary row, from the same probe the READY receipt
24
24
  * hash uses. False when a page could not be read, so no total is trustworthy.
@@ -32,11 +32,11 @@ export function readyFingerprint(raw, stored) {
32
32
  * otherwise looks ready loads them once so a READY receipt still changes when
33
33
  * a check gains an annotation.
34
34
  */
35
- export async function hydrateReadyAnnotationProbe(pr, repo, review) {
35
+ export async function hydrateReadyAnnotationProbe(pr, repo, review, olderThreadsSettled = false) {
36
36
  if (COMPLETE_FROM_BATCH.has(pr))
37
37
  return;
38
38
  const checks = summarizePollSummaryChecks(pr);
39
- if (!isCurrentSummaryReady(pr, checks, review))
39
+ if (!isCurrentSummaryReady(pr, checks, review, { olderThreadsSettled }))
40
40
  return;
41
41
  await hydrateAnnotationTotals(pr, repo);
42
42
  }
@@ -8,9 +8,10 @@ export declare function pollCommandFields(repo: string, pr: number, isDraft: boo
8
8
  export declare function aggregateRerunCommand(repo: string, selection: PollSummarySelection, opts: PollSummaryCommandOptions, refs?: string[]): string;
9
9
  /**
10
10
  * The two commands that approve unlisted layers: the same request listing them as well, and the
11
- * same request naming the stack number, which owns every layer.
11
+ * same request naming the stack number, which owns every layer. With `shepherdOnly`, both drop
12
+ * the merge flag: listing a layer to shepherd it must never also merge it.
12
13
  */
13
- export declare function stackApprovalCommands(repo: string, selection: PollSummarySelection, opts: PollSummaryCommandOptions, extra: number[]): {
14
+ export declare function stackApprovalCommands(repo: string, selection: PollSummarySelection, opts: PollSummaryCommandOptions, extra: number[], shepherdOnly?: boolean): {
14
15
  listed: string;
15
16
  whole: string;
16
17
  };
@@ -67,15 +67,17 @@ export function aggregateRerunCommand(repo, selection, opts, refs) {
67
67
  }
68
68
  /**
69
69
  * The two commands that approve unlisted layers: the same request listing them as well, and the
70
- * same request naming the stack number, which owns every layer.
70
+ * same request naming the stack number, which owns every layer. With `shepherdOnly`, both drop
71
+ * the merge flag: listing a layer to shepherd it must never also merge it.
71
72
  */
72
- export function stackApprovalCommands(repo, selection, opts, extra) {
73
+ export function stackApprovalCommands(repo, selection, opts, extra, shepherdOnly = false) {
73
74
  if (selection.kind !== "stack")
74
75
  return { listed: "", whole: "" };
75
76
  const listed = [...new Set([...(selection.owned ?? []), ...extra])].sort((a, b) => a - b);
77
+ const used = shepherdOnly ? { ...opts, merge: false, stackMerge: undefined } : opts;
76
78
  return {
77
- listed: aggregateRerunCommand(repo, { ...selection, owned: listed }, opts),
78
- whole: aggregateRerunCommand(repo, selection, opts, [`${repo}#${selection.stackNumber}`]),
79
+ listed: aggregateRerunCommand(repo, { ...selection, owned: listed }, used),
80
+ whole: aggregateRerunCommand(repo, selection, used, [`${repo}#${selection.stackNumber}`]),
79
81
  };
80
82
  }
81
83
  /**
@@ -3,7 +3,7 @@ import { loadConfig } from "../config/load.mjs";
3
3
  import { updateReadyDelay } from "../commands/ready-delay.mjs";
4
4
  import { formatPrUrl } from "../pr-reference.mjs";
5
5
  import { loadSeenMap } from "../state/seen-comments.mjs";
6
- import { isReadyReceiptCurrent, readReadyReceipt } from "../state/ready-receipts.mjs";
6
+ import * as receipts from "../state/ready-receipts.mjs";
7
7
  import { summarizePollSummaryChecks } from "./poll-summary-checks.mjs";
8
8
  import { evaluatePollSummaryReview } from "./poll-summary-review.mjs";
9
9
  import { currentQueueRemovalEvent, projectQueueRemoval } from "./poll-summary-queue-removal.mjs";
@@ -11,10 +11,10 @@ import { applyUnseenCheckAnnotations } from "./poll-summary-annotations.mjs";
11
11
  import { isCurrentSummaryReady } from "./poll-summary-readiness.mjs";
12
12
  import { applyOpenCheckBlockers } from "./poll-summary-check-blockers.mjs";
13
13
  import { normalizePollSummaryState, routePollSummary } from "./poll-summary-route.mjs";
14
- import { hydrateReadyAnnotationProbe, readyFingerprint } from "./poll-summary-annotation-probe.mjs";
14
+ import * as probe from "./poll-summary-annotation-probe.mjs";
15
15
  import { applyPendingWorkflowSuites, applyUnreportedRequiredChecks, summaryRequiredContexts, } from "./poll-summary-unreported.mjs";
16
16
  import { aliasThreadSeenMarkers } from "./rest-identities.mjs";
17
- import { restQueueRequirement } from "./poll-summary-rest-queue.mjs";
17
+ import { graphqlStackQueueRequirement, restQueueRequirement, stackLinearHistoryRequirement, } from "./poll-summary-rest-queue.mjs";
18
18
  import { detectBlockingReviewer } from "./poll-summary-blocking-reviewer.mjs";
19
19
  export async function summarizePollSummaryPr(raw, repo, opts, viewerCanAdminister = undefined, mergeTargetContexts,
20
20
  /** Aggregate polls only: apply rule-driven auto-resolve. Receipt and merge validation reads never mutate. */
@@ -60,23 +60,23 @@ applyRuleAutoResolve = false) {
60
60
  baseRefName: raw.stack.baseRefName,
61
61
  }
62
62
  : undefined;
63
- if (opts.stackPrNumber !== undefined)
64
- await hydrateReadyAnnotationProbe(raw, repo, review);
65
63
  const receipt = opts.stackPrNumber === undefined
66
64
  ? null
67
- : await readReadyReceipt({ owner: repo.owner, repo: repo.name, pr: raw.number });
68
- const fingerprint = opts.stackPrNumber === undefined
69
- ? null
70
- : readyFingerprint(raw, receipt?.readinessFingerprint ?? null);
65
+ : await receipts.readReadyReceipt({ owner: repo.owner, repo: repo.name, pr: raw.number });
66
+ // Queued layers skip BLOCKED, so they get no exception; others cost no extra probe.
67
+ const olderThreadsSettled = !raw.isInMergeQueue && receipts.receiptResolvedAllThreads(receipt, raw);
68
+ if (opts.stackPrNumber !== undefined)
69
+ await probe.hydrateReadyAnnotationProbe(raw, repo, review, olderThreadsSettled);
71
70
  // A queued PR's base can advance. Keep the receipt base while the probe is complete.
72
- const receiptFingerprint = raw.isInMergeQueue && receipt
73
- ? readyFingerprint({ ...raw, baseRefOid: receipt.baseRefOid }, receipt.readinessFingerprint)
74
- : fingerprint;
71
+ const receiptFingerprint = opts.stackPrNumber === undefined
72
+ ? null
73
+ : probe.readyFingerprint(raw.isInMergeQueue && receipt ? { ...raw, baseRefOid: receipt.baseRefOid } : raw, receipt?.readinessFingerprint ?? null);
75
74
  const currentReady = isCurrentSummaryReady(raw, checks, review, {
76
75
  allowQueuedProgress: opts.stackPrNumber !== undefined && raw.isInMergeQueue,
76
+ olderThreadsSettled: olderThreadsSettled && !probe.annotationProbeUnavailable(raw),
77
77
  });
78
78
  const readyReceipt = receiptFingerprint !== null &&
79
- isReadyReceiptCurrent(receipt, {
79
+ receipts.isReadyReceiptCurrent(receipt, {
80
80
  headRefOid: raw.headRefOid,
81
81
  baseRefOid: raw.isInMergeQueue && receipt ? receipt.baseRefOid : raw.baseRefOid,
82
82
  readinessFingerprint: receiptFingerprint,
@@ -91,7 +91,8 @@ applyRuleAutoResolve = false) {
91
91
  const blocked = await applyOpenCheckBlockers(raw, repo, { action, reasons }, checks, review, opts.stackPrNumber !== undefined, required);
92
92
  action = blocked.action;
93
93
  reasons = blocked.reasons;
94
- const requiresMergeQueue = raw.transport === "rest" ? restQueueRequirement(raw) : undefined;
94
+ const requiresMergeQueue = raw.transport === "rest" ? restQueueRequirement(raw) : graphqlStackQueueRequirement(raw);
95
+ const requiresLinearHistory = stackLinearHistoryRequirement(raw);
95
96
  return {
96
97
  pr: raw.number,
97
98
  repo: repoName,
@@ -112,6 +113,7 @@ applyRuleAutoResolve = false) {
112
113
  ...(raw.isDraft && { isDraft: true }),
113
114
  ...(raw.isInMergeQueue && { isInMergeQueue: true }),
114
115
  ...(requiresMergeQueue !== undefined && { requiresMergeQueue }),
116
+ ...(requiresLinearHistory && { requiresLinearHistory }),
115
117
  ...(queueRemoval && { queueRemoval }),
116
118
  ...(blockingReviewerInProgress && { blockingReviewerInProgress: true }),
117
119
  ...(remainingSeconds !== undefined && { remainingSeconds }),
@@ -4,8 +4,12 @@ import type { RawSummaryPr } from "./poll-summary-raw.mts";
4
4
  * Fresh compact evidence required before a READY receipt can be used.
5
5
  * `allowBlocked` asks whether GitHub's BLOCKED state is the only gap, so a
6
6
  * caller can tell a blocker it cannot clear from missing or stale evidence.
7
+ * `olderThreadsSettled` says a full one-PR check at this head found every review thread
8
+ * resolved; it then covers threads older than the compact summary's window (see
9
+ * `olderThreadsOnlyGap`).
7
10
  */
8
11
  export declare function isCurrentSummaryReady(raw: RawSummaryPr, checks: PollSummaryChecks, review: PollSummaryReview, options?: {
9
12
  allowQueuedProgress?: boolean;
10
13
  allowBlocked?: boolean;
14
+ olderThreadsSettled?: boolean;
11
15
  }): boolean;
@@ -7,6 +7,9 @@ import { isKnownMergeStateStatus, transportReadinessGaps } from "./transport-evi
7
7
  * Fresh compact evidence required before a READY receipt can be used.
8
8
  * `allowBlocked` asks whether GitHub's BLOCKED state is the only gap, so a
9
9
  * caller can tell a blocker it cannot clear from missing or stale evidence.
10
+ * `olderThreadsSettled` says a full one-PR check at this head found every review thread
11
+ * resolved; it then covers threads older than the compact summary's window (see
12
+ * `olderThreadsOnlyGap`).
10
13
  */
11
14
  export function isCurrentSummaryReady(raw, checks, review, options = {}) {
12
15
  const blockedStates = options.allowBlocked
@@ -33,6 +36,7 @@ export function isCurrentSummaryReady(raw, checks, review, options = {}) {
33
36
  checks.incomplete !== true &&
34
37
  sourceChecks.incomplete !== true &&
35
38
  (review.incomplete !== true ||
39
+ (options.olderThreadsSettled === true && olderThreadsOnlyGap(raw)) ||
36
40
  raw.mergeStateStatus === "CLEAN" ||
37
41
  (rulesComplete(raw.baseRef) && !requiresConversationResolution)) &&
38
42
  raw.state === "OPEN" &&
@@ -49,3 +53,21 @@ export function isCurrentSummaryReady(raw, checks, review, options = {}) {
49
53
  !(checks.actionsWorkflowInProgress === true && hasNoRelevantChecks(checks)) &&
50
54
  (review.actionable ?? 0) === 0);
51
55
  }
56
+ /**
57
+ * The compact review sample is short only because older review threads fell outside its
58
+ * window: comments, reviews, and each sampled thread's replies are all present.
59
+ *
60
+ * Best effort: a full one-PR check that found every thread resolved vouches for the older
61
+ * threads. An older thread unresolved after that check is not caught here, because the
62
+ * fingerprint records the sampled threads and the PR's `updatedAt`, not each older thread's
63
+ * resolution. It can stay undetected until the next full one-PR check, which reads every thread
64
+ * and routes it back to triage; a repository that requires conversation resolution has GitHub
65
+ * refuse the merge meanwhile.
66
+ */
67
+ function olderThreadsOnlyGap(raw) {
68
+ return (raw.reviewThreads.pageInfo.hasPreviousPage &&
69
+ raw.unreadNodes?.feedback !== true &&
70
+ !raw.comments.pageInfo.hasPreviousPage &&
71
+ !raw.reviews.pageInfo.hasPreviousPage &&
72
+ raw.reviewThreads.nodes.every((thread) => !thread.comments.pageInfo.hasPreviousPage));
73
+ }
@@ -1,3 +1,16 @@
1
1
  import type { RawSummaryPr } from "./poll-summary-raw.mts";
2
2
  /** Positive rules remain authoritative even when other branch policy is unavailable. */
3
3
  export declare function restQueueRequirement(raw: Pick<RawSummaryPr, "baseRef" | "transportUnavailable">): boolean | undefined;
4
+ /**
5
+ * A trunk that requires linear history excludes merge commits from a stack's direct merge. Only
6
+ * a positive rule is surfaced: a negative or unreadable policy stays omitted so a row never
7
+ * claims a requirement it did not see. Non-stack GraphQL rows omit it too, since a one-PR merge
8
+ * reads linear history itself.
9
+ */
10
+ export declare function stackLinearHistoryRequirement(raw: Pick<RawSummaryPr, "baseRef" | "stack" | "transport">): true | undefined;
11
+ /**
12
+ * GraphQL reads the complete rules and the queue flag, so a native-stack row states its trunk's
13
+ * queue requirement and the printed stack merge picks the queue or direct route without a guess.
14
+ * Other rows omit it: a one-PR merge reads queue policy itself.
15
+ */
16
+ export declare function graphqlStackQueueRequirement(raw: Pick<RawSummaryPr, "baseRef" | "isMergeQueueEnabled" | "stack">): boolean | undefined;
@@ -10,3 +10,24 @@ export function restQueueRequirement(raw) {
10
10
  return undefined;
11
11
  return false;
12
12
  }
13
+ /**
14
+ * A trunk that requires linear history excludes merge commits from a stack's direct merge. Only
15
+ * a positive rule is surfaced: a negative or unreadable policy stays omitted so a row never
16
+ * claims a requirement it did not see. Non-stack GraphQL rows omit it too, since a one-PR merge
17
+ * reads linear history itself.
18
+ */
19
+ export function stackLinearHistoryRequirement(raw) {
20
+ if (raw.transport !== "rest" && !raw.stack)
21
+ return undefined;
22
+ return parseBranchRules(raw.baseRef).requiresLinearHistory ? true : undefined;
23
+ }
24
+ /**
25
+ * GraphQL reads the complete rules and the queue flag, so a native-stack row states its trunk's
26
+ * queue requirement and the printed stack merge picks the queue or direct route without a guess.
27
+ * Other rows omit it: a one-PR merge reads queue policy itself.
28
+ */
29
+ export function graphqlStackQueueRequirement(raw) {
30
+ if (!raw.stack || !raw.baseRef)
31
+ return undefined;
32
+ return parseBranchRules(raw.baseRef).requiresMergeQueue || raw.isMergeQueueEnabled === true;
33
+ }