pr-shepherd 2.0.0 → 2.2.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +41 -32
- package/bin/api.d.mts +10 -2
- package/bin/api.mjs +30 -6
- package/bin/checks/pending-deployments.d.mts +10 -0
- package/bin/checks/pending-deployments.mjs +66 -0
- package/bin/checks/run-workflow-paths.d.mts +7 -0
- package/bin/checks/run-workflow-paths.mjs +19 -0
- package/bin/checks/triage.mjs +3 -2
- package/bin/checks/unreported-required.d.mts +11 -1
- package/bin/checks/unreported-required.mjs +8 -3
- package/bin/checks/workflow-concurrency.d.mts +9 -0
- package/bin/checks/workflow-concurrency.mjs +84 -0
- package/bin/checks/workflow-path.d.mts +2 -0
- package/bin/checks/workflow-path.mjs +4 -0
- package/bin/classify/standard/dependency-review-no-issues.d.mts +4 -0
- package/bin/classify/standard/dependency-review-no-issues.mjs +16 -0
- package/bin/classify/standard/index.mjs +8 -0
- package/bin/classify/standard/snyk-no-issues.d.mts +7 -0
- package/bin/classify/standard/snyk-no-issues.mjs +27 -0
- package/bin/classify/standard/socket-reports.d.mts +4 -0
- package/bin/classify/standard/socket-reports.mjs +18 -0
- package/bin/classify/standard/sonarqube-gate-passed.d.mts +7 -0
- package/bin/classify/standard/sonarqube-gate-passed.mjs +41 -0
- package/bin/cli/arg-flags.mjs +3 -0
- package/bin/cli/clean-handler.mjs +1 -1
- package/bin/cli/default-poll.mjs +1 -0
- package/bin/cli/handlers.mjs +2 -0
- package/bin/cli/help-command-pages.d.mts +5 -4
- package/bin/cli/help-command-pages.mjs +2 -1
- package/bin/cli/help-iterate-poll-pages.d.mts +3 -3
- package/bin/cli/help-iterate-poll-pages.mjs +10 -2
- package/bin/cli/help-top-page.d.mts +1 -1
- package/bin/cli/help-top-page.mjs +2 -2
- package/bin/cli/help.d.mts +6 -5
- package/bin/cli/in-progress-run-format.d.mts +3 -0
- package/bin/cli/in-progress-run-format.mjs +14 -0
- package/bin/cli/iterate-activity-formatter.d.mts +2 -0
- package/bin/cli/iterate-activity-formatter.mjs +11 -0
- package/bin/cli/iterate-flags.d.mts +3 -0
- package/bin/cli/iterate-flags.mjs +18 -1
- package/bin/cli/iterate-formatter.mjs +2 -1
- package/bin/cli/iterate-lean.mjs +2 -0
- package/bin/cli/pending-deployments-format.d.mts +5 -0
- package/bin/cli/pending-deployments-format.mjs +19 -0
- package/bin/cli/poll-handler.d.mts +1 -1
- package/bin/cli/poll-handler.mjs +33 -10
- package/bin/cli/poll-targets.mjs +2 -0
- package/bin/cli/stack-merge-args.d.mts +10 -0
- package/bin/cli/stack-merge-args.mjs +27 -0
- package/bin/cli/stack-overview.d.mts +1 -0
- package/bin/cli/stack-overview.mjs +5 -1
- package/bin/cli/stalled-check-format.d.mts +3 -0
- package/bin/cli/stalled-check-format.mjs +23 -0
- package/bin/cli/suggestion-renderer.mjs +6 -0
- package/bin/cli/triage-formatter.mjs +14 -0
- package/bin/commands/check.mjs +7 -2
- package/bin/commands/clean.d.mts +1 -1
- package/bin/commands/clean.mjs +7 -0
- package/bin/commands/iterate/check-follow-up.d.mts +9 -0
- package/bin/commands/iterate/check-follow-up.mjs +34 -0
- package/bin/commands/iterate/ci-start-stall.d.mts +23 -0
- package/bin/commands/iterate/ci-start-stall.mjs +33 -0
- package/bin/commands/iterate/duration-approx.d.mts +2 -0
- package/bin/commands/iterate/duration-approx.mjs +8 -0
- package/bin/commands/iterate/escalate.d.mts +8 -17
- package/bin/commands/iterate/escalate.mjs +19 -48
- package/bin/commands/iterate/helpers.mjs +1 -0
- package/bin/commands/iterate/in-progress-runs.d.mts +10 -0
- package/bin/commands/iterate/in-progress-runs.mjs +120 -0
- package/bin/commands/iterate/index.mjs +12 -6
- package/bin/commands/iterate/merge-plan.d.mts +2 -0
- package/bin/commands/iterate/merge-plan.mjs +2 -1
- package/bin/commands/iterate/merge-state.d.mts +2 -0
- package/bin/commands/iterate/merge-state.mjs +8 -21
- package/bin/commands/iterate/native-stack-rebase.d.mts +3 -2
- package/bin/commands/iterate/native-stack-rebase.mjs +32 -11
- package/bin/commands/iterate/queue-removal.d.mts +19 -0
- package/bin/commands/iterate/queue-removal.mjs +64 -0
- package/bin/commands/iterate/render.d.mts +2 -1
- package/bin/commands/iterate/render.mjs +4 -1
- package/bin/commands/iterate/stack-boundary.d.mts +17 -0
- package/bin/commands/iterate/stack-boundary.mjs +95 -0
- package/bin/commands/iterate/stall-repair.d.mts +17 -0
- package/bin/commands/iterate/stall-repair.mjs +25 -0
- package/bin/commands/iterate/stall.d.mts +1 -1
- package/bin/commands/iterate/stall.mjs +27 -18
- package/bin/commands/iterate/state-unavailable.d.mts +8 -0
- package/bin/commands/iterate/state-unavailable.mjs +23 -0
- package/bin/commands/iterate/triage-loop-instruction.mjs +1 -1
- package/bin/commands/iterate/triage.mjs +41 -74
- package/bin/commands/iterate/unreported-required.d.mts +5 -2
- package/bin/commands/iterate/unreported-required.mjs +13 -8
- package/bin/commands/iterate/workflow-files.d.mts +27 -0
- package/bin/commands/iterate/workflow-files.mjs +85 -0
- package/bin/commands/poll-summary-explicit-instructions.mjs +15 -1
- package/bin/commands/poll-summary-instructions.d.mts +4 -3
- package/bin/commands/poll-summary-instructions.mjs +60 -22
- package/bin/commands/poll-summary.mjs +38 -10
- package/bin/commands/poll.mjs +4 -2
- package/bin/commands/stack-drain.d.mts +4 -4
- package/bin/commands/stack-drain.mjs +19 -113
- package/bin/commands/stack-handoffs.d.mts +3 -3
- package/bin/commands/stack-handoffs.mjs +8 -8
- package/bin/commands/stack-lower-ready-note.d.mts +6 -0
- package/bin/commands/stack-lower-ready-note.mjs +35 -0
- package/bin/commands/stack-merge-escalations.d.mts +17 -0
- package/bin/commands/stack-merge-escalations.mjs +57 -0
- package/bin/commands/stack-merge-plan.d.mts +10 -0
- package/bin/commands/stack-merge-plan.mjs +132 -0
- package/bin/commands/stack-merge-scope.d.mts +42 -0
- package/bin/commands/stack-merge-scope.mjs +113 -0
- package/bin/commands/stack-ownership.d.mts +25 -0
- package/bin/commands/stack-ownership.mjs +85 -0
- package/bin/commands/stack-stall.d.mts +2 -0
- package/bin/commands/stack-stall.mjs +25 -3
- package/bin/commands/stack-targets-error.d.mts +16 -0
- package/bin/commands/stack-targets-error.mjs +44 -0
- package/bin/commands/stack-targets.d.mts +30 -0
- package/bin/commands/stack-targets.mjs +121 -0
- package/bin/commands/stack-work.d.mts +4 -3
- package/bin/commands/stack-work.mjs +7 -4
- package/bin/commands/tick.mjs +14 -2
- package/bin/config/renames.mjs +1 -1
- package/bin/config/schema.d.mts +4 -0
- package/bin/config/schema.mjs +2 -0
- package/bin/github/batch-parse-suites.d.mts +4 -1
- package/bin/github/batch-parse-suites.mjs +15 -3
- package/bin/github/batch-raw-types.d.mts +6 -0
- package/bin/github/gql/commit-check-suites.gql +6 -0
- package/bin/github/gql/poll-summary-fragment.gql +6 -0
- package/bin/github/poll-summary-command.d.mts +15 -1
- package/bin/github/poll-summary-command.mjs +39 -3
- package/bin/github/poll-summary-projector.d.mts +1 -1
- package/bin/github/poll-summary-projector.mjs +1 -4
- package/bin/github/poll-summary-raw.d.mts +6 -0
- package/bin/github/poll-summary-route.mjs +4 -1
- package/bin/github/poll-summary.mjs +10 -3
- package/bin/github/rest-batch-read.mjs +17 -6
- package/bin/github/rest-batch-snapshot.d.mts +2 -2
- package/bin/github/rest-batch-snapshot.mjs +3 -0
- package/bin/github/rest-check-read.d.mts +1 -18
- package/bin/github/rest-check-read.mjs +1 -2
- package/bin/github/rest-stack-read.d.mts +9 -0
- package/bin/github/rest-stack-read.mjs +40 -0
- package/bin/github/rest-suite-types.d.mts +23 -0
- package/bin/github/rest-suite-types.mjs +1 -0
- package/bin/github/rest-summary-read.mjs +2 -0
- package/bin/mcp/server.mjs +29 -3
- package/bin/pr-reference.d.mts +2 -0
- package/bin/pr-reference.mjs +1 -1
- package/bin/reporters/agent.mjs +3 -0
- package/bin/state/check-follow-up.d.mts +30 -0
- package/bin/state/check-follow-up.mjs +51 -0
- package/bin/state/ci-start-follow-up.d.mts +14 -0
- package/bin/state/ci-start-follow-up.mjs +21 -0
- package/bin/state/queue-removal-follow-up.d.mts +20 -0
- package/bin/state/queue-removal-follow-up.mjs +23 -0
- package/bin/state/signature-marker.d.mts +10 -0
- package/bin/state/signature-marker.mjs +28 -0
- package/bin/state/stack-merge-approval.d.mts +26 -0
- package/bin/state/stack-merge-approval.mjs +39 -0
- package/bin/state/stall-repair.d.mts +16 -0
- package/bin/state/stall-repair.mjs +47 -0
- package/bin/types/activity.d.mts +2 -1
- package/bin/types/escalate.d.mts +9 -2
- package/bin/types/github.d.mts +18 -0
- package/bin/types/in-progress-run.d.mts +20 -0
- package/bin/types/in-progress-run.mjs +1 -0
- package/bin/types/iterate.d.mts +22 -1
- package/bin/types/poll-summary.d.mts +18 -1
- package/bin/types/report.d.mts +5 -1
- package/bin/types.d.mts +1 -0
- package/bin/types.mjs +1 -0
- package/package.json +2 -2
- package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex.mcp.json +1 -1
- package/plugins/pr-shepherd/.mcp.json +1 -1
- package/plugins/pr-shepherd/hooks/poll-guard-args.mjs +49 -0
- package/plugins/pr-shepherd/hooks/poll-guard-detect.mjs +134 -26
- package/plugins/pr-shepherd/hooks/poll-guard-shell.mjs +192 -0
- package/plugins/pr-shepherd/package-lock.json +7 -7
- package/plugins/pr-shepherd/package.json +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +8 -7
- package/plugins/pr-shepherd/skills/pr-shepherd/references/check-follow-up.md +14 -0
- package/plugins/pr-shepherd/skills/pr-shepherd/references/ci-failure-triage.md +6 -5
- package/plugins/pr-shepherd/skills/pr-shepherd/references/ci-start-stall.md +15 -0
- package/plugins/pr-shepherd/skills/pr-shepherd/references/create-a-pr.md +4 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/references/mcp-fallback.md +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/references/merge-queue-ejection.md +6 -5
- package/plugins/pr-shepherd/skills/pr-shepherd/references/required-checks-unreported.md +16 -0
- package/plugins/pr-shepherd/skills/reduce-pr-noise/references/classifiers.md +1 -1
- package/pr-shepherd.schema.json +15 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { formatPrUrl } from "../pr-reference.mjs";
|
|
2
|
+
import { buildPrShepherdCommand } from "../cli/runner.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* The error for refs that span several stacks: it names each stack, the refs that belong to it,
|
|
5
|
+
* and the exact command to run for it, so the caller can run them as written. `tool` names the
|
|
6
|
+
* `stack` tool call (MCP or library) instead of the CLI command.
|
|
7
|
+
*/
|
|
8
|
+
export function multiStackError(repo, groups, merge, through, tool = false) {
|
|
9
|
+
const lines = groups.map((group) => {
|
|
10
|
+
const refs = [
|
|
11
|
+
...group.stackRefs.map((n) => `stack #${n}`),
|
|
12
|
+
...group.prs.map((n) => `#${n}`),
|
|
13
|
+
].join(", ");
|
|
14
|
+
const targets = [
|
|
15
|
+
...group.stackRefs.map((n) => `${repo}#${n}`),
|
|
16
|
+
...group.prs.map((n) => formatPrUrl(repo, n)),
|
|
17
|
+
];
|
|
18
|
+
const flags = merge === "through"
|
|
19
|
+
? through !== undefined && group.members?.includes(through)
|
|
20
|
+
? ["--merge-through", formatPrUrl(repo, through)]
|
|
21
|
+
: []
|
|
22
|
+
: merge === "ready"
|
|
23
|
+
? ["--merge-ready"]
|
|
24
|
+
: merge === "merge"
|
|
25
|
+
? ["--merge"]
|
|
26
|
+
: [];
|
|
27
|
+
const command = tool
|
|
28
|
+
? toolCall(targets, merge, through !== undefined && group.members?.includes(through) ? through : undefined, repo)
|
|
29
|
+
: buildPrShepherdCommand(["stack", ...targets, "--until-terminal", ...flags]).text;
|
|
30
|
+
return `- stack #${group.stack} (${refs}): \`${command}\``;
|
|
31
|
+
});
|
|
32
|
+
return [`These refs span ${groups.length} stacks. Run one command per stack:`, ...lines].join("\n");
|
|
33
|
+
}
|
|
34
|
+
/** The `stack` tool call for one group, in the tool's own argument names. */
|
|
35
|
+
function toolCall(refs, merge, through, repo) {
|
|
36
|
+
const args = {
|
|
37
|
+
refs,
|
|
38
|
+
...(merge === "merge" && { merge: true }),
|
|
39
|
+
...(merge === "ready" && { mergeReady: true }),
|
|
40
|
+
...(merge === "through" &&
|
|
41
|
+
through !== undefined && { mergeThrough: formatPrUrl(repo, through) }),
|
|
42
|
+
};
|
|
43
|
+
return `stack ${JSON.stringify(args)}`;
|
|
44
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type RepoInfo } from "../github/client.mts";
|
|
2
|
+
import { type ParsedPrReference } from "../pr-reference.mts";
|
|
3
|
+
import type { StackMergeScope } from "../types.mts";
|
|
4
|
+
export type StackMergeFlag = "merge" | "ready" | "through";
|
|
5
|
+
export declare function stackMergeScope(flag: StackMergeFlag | undefined, through: number | undefined): StackMergeScope | undefined;
|
|
6
|
+
export interface StackTargetInput {
|
|
7
|
+
/** One stack number, or one or more PRs from one native stack. */
|
|
8
|
+
refs: ParsedPrReference[];
|
|
9
|
+
/** `--merge-through`: a PR of the selected stack. */
|
|
10
|
+
through?: ParsedPrReference;
|
|
11
|
+
/** Which merge flag the caller passed, so a multi-stack error can repeat it. */
|
|
12
|
+
merge?: StackMergeFlag;
|
|
13
|
+
/** The caller is the library or MCP `stack` tool: errors name tool calls, not CLI commands. */
|
|
14
|
+
tool?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface StackTarget {
|
|
17
|
+
/** A PR of the selected stack, used to read it. */
|
|
18
|
+
anchor: number;
|
|
19
|
+
/** The PRs the caller listed, and so owns; omitted only for a stack number, which owns every layer. */
|
|
20
|
+
owned?: number[];
|
|
21
|
+
through?: number;
|
|
22
|
+
targetRepository?: RepoInfo;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve `stack` refs to one native stack and the layers the caller owns. A number is a PR when
|
|
26
|
+
* GitHub has one, else a stack number (the two share a sequence). Ownership is declared: a stack
|
|
27
|
+
* number selects and owns every layer, and listed PRs own only themselves, so one PR does not
|
|
28
|
+
* claim the layers around it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveStackTarget(input: StackTargetInput): Promise<StackTarget>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { EXIT, ShepherdError } from "../exit-codes.mjs";
|
|
2
|
+
import { getRepoInfo } from "../github/client.mjs";
|
|
3
|
+
import { readRestStackByNumber, restPullExists, restRepoReachable, } from "../github/rest-stack-read.mjs";
|
|
4
|
+
import { GitHubRequestError } from "../github/errors.mjs";
|
|
5
|
+
import { readStackTopology } from "../github/stack-read.mjs";
|
|
6
|
+
import { normalizeRepositoryIdentity, resolveParsedPrTarget, } from "../pr-reference.mjs";
|
|
7
|
+
import { multiStackError } from "./stack-targets-error.mjs";
|
|
8
|
+
export function stackMergeScope(flag, through) {
|
|
9
|
+
if (flag === "through")
|
|
10
|
+
return { kind: "through", pr: through };
|
|
11
|
+
if (flag === "ready")
|
|
12
|
+
return { kind: "ready" };
|
|
13
|
+
return flag ? { kind: "all" } : undefined;
|
|
14
|
+
}
|
|
15
|
+
function usage(message) {
|
|
16
|
+
throw new ShepherdError(message, EXIT.USAGE);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve `stack` refs to one native stack and the layers the caller owns. A number is a PR when
|
|
20
|
+
* GitHub has one, else a stack number (the two share a sequence). Ownership is declared: a stack
|
|
21
|
+
* number selects and owns every layer, and listed PRs own only themselves, so one PR does not
|
|
22
|
+
* claim the layers around it.
|
|
23
|
+
*/
|
|
24
|
+
export async function resolveStackTarget(input) {
|
|
25
|
+
const all = [...input.refs, ...(input.through ? [input.through] : [])];
|
|
26
|
+
const repos = all.flatMap((ref) => resolveParsedPrTarget(ref).targetRepository ?? []);
|
|
27
|
+
const named = repos[0];
|
|
28
|
+
if (repos.some((r) => normalizeRepositoryIdentity(`${r.owner}/${r.name}`) !==
|
|
29
|
+
normalizeRepositoryIdentity(`${named.owner}/${named.name}`))) {
|
|
30
|
+
usage("stack refs must all name one repository.");
|
|
31
|
+
}
|
|
32
|
+
const [only] = input.refs;
|
|
33
|
+
// One PR URL needs no resolution: it selects its stack and owns only itself.
|
|
34
|
+
if (input.refs.length === 1 && only.url === true && !input.through) {
|
|
35
|
+
return {
|
|
36
|
+
anchor: only.number,
|
|
37
|
+
owned: [only.number],
|
|
38
|
+
...(named && { targetRepository: named }),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const repo = named ?? (await getRepoInfo());
|
|
42
|
+
const slug = `${repo.owner}/${repo.name}`;
|
|
43
|
+
const numbers = [...new Set(input.refs.map((ref) => ref.number))];
|
|
44
|
+
const refByNumber = new Map(input.refs.map((ref) => [ref.number, ref]));
|
|
45
|
+
const groups = new Map();
|
|
46
|
+
for (const number of numbers) {
|
|
47
|
+
// A number already in a read stack is one of its PRs; PR and stack numbers never collide.
|
|
48
|
+
const member = [...groups.values()].find((group) => group.members.includes(number));
|
|
49
|
+
if (member) {
|
|
50
|
+
member.prs.push(number);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const found = await readRef(number, refByNumber.get(number), repo, slug);
|
|
54
|
+
const isPr = found.isPr;
|
|
55
|
+
const group = groups.get(found.number) ?? { stack: found.number, prs: [], stackRefs: [] };
|
|
56
|
+
(isPr ? group.prs : group.stackRefs).push(number);
|
|
57
|
+
groups.set(found.number, group);
|
|
58
|
+
group.members = found.members;
|
|
59
|
+
}
|
|
60
|
+
if (groups.size > 1) {
|
|
61
|
+
usage(multiStackError(slug, [...groups.values()], input.merge, input.through?.number, input.tool));
|
|
62
|
+
}
|
|
63
|
+
const group = [...groups.values()][0];
|
|
64
|
+
if (group.stackRefs.length > 0 && numbers.length > 1) {
|
|
65
|
+
usage(`stack #${group.stack} is named together with other refs. A stack number already selects every layer; pass either that one stack number or PRs of the stack.`);
|
|
66
|
+
}
|
|
67
|
+
const owned = group.prs.length > 0 ? group.prs : undefined;
|
|
68
|
+
const through = input.through?.number;
|
|
69
|
+
if (through !== undefined) {
|
|
70
|
+
if (!group.members.includes(through)) {
|
|
71
|
+
usage(`--merge-through PR #${through} is not a layer of native stack #${group.stack}.`);
|
|
72
|
+
}
|
|
73
|
+
if (owned && !owned.includes(through)) {
|
|
74
|
+
usage(`--merge-through PR #${through} is not one of the PRs listed as yours.`);
|
|
75
|
+
}
|
|
76
|
+
if (input.through.url !== true &&
|
|
77
|
+
!(await readOrDenied(() => restPullExists(through, repo), slug))) {
|
|
78
|
+
usage(`--merge-through takes a pull request; #${through} is a stack number.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
anchor: group.prs[0] ?? group.members[0],
|
|
83
|
+
...(owned && { owned }),
|
|
84
|
+
...(through !== undefined && { through }),
|
|
85
|
+
...(named && { targetRepository: repo }),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** A GitHub 401/403 is an access problem, not a missing PR or stack. */
|
|
89
|
+
async function readOrDenied(read, slug) {
|
|
90
|
+
try {
|
|
91
|
+
return await read();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error instanceof GitHubRequestError && (error.status === 401 || error.status === 403)) {
|
|
95
|
+
throw new ShepherdError(`GitHub denied access to ${slug} (HTTP ${error.status}). Check that the token can read pull requests and stacks in that repository; the refs were not resolved.`, EXIT.NOPERM, { cause: error });
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function readRef(number, ref, repo, slug) {
|
|
101
|
+
const isPr = ref.url === true || (await readOrDenied(() => restPullExists(number, repo), slug));
|
|
102
|
+
const found = isPr
|
|
103
|
+
? await readOrDenied(() => readPrStack(number, repo), slug)
|
|
104
|
+
: await readStack(number, repo, slug);
|
|
105
|
+
return { ...found, isPr };
|
|
106
|
+
}
|
|
107
|
+
async function readPrStack(pr, repo) {
|
|
108
|
+
const read = await readStackTopology(pr, repo);
|
|
109
|
+
return { number: read.stackNumber, members: read.ordered.map((member) => member.number) };
|
|
110
|
+
}
|
|
111
|
+
async function readStack(number, repo, slug) {
|
|
112
|
+
const stack = await readOrDenied(() => readRestStackByNumber(number, repo), slug);
|
|
113
|
+
if (!stack) {
|
|
114
|
+
// GitHub answers 404 for a repository the token cannot see, too.
|
|
115
|
+
if (!(await readOrDenied(() => restRepoReachable(repo), slug))) {
|
|
116
|
+
throw new ShepherdError(`#${number} could not be resolved: ${slug} is not accessible with the current GitHub credentials (or does not exist). Check the repository and token access.`, EXIT.NOPERM);
|
|
117
|
+
}
|
|
118
|
+
usage(`#${number} is neither a pull request nor a native stack in ${slug}.`);
|
|
119
|
+
}
|
|
120
|
+
return { number: stack.number, members: stack.members };
|
|
121
|
+
}
|
|
@@ -20,8 +20,9 @@ export declare function splitStackWork(candidates: PollSummaryItem[], staleChild
|
|
|
20
20
|
/** The literal stack command to rerun, or the generic name when the caller's command is unknown. */
|
|
21
21
|
export declare function stackRerunTarget(command?: string): string;
|
|
22
22
|
/**
|
|
23
|
-
* The closing step after routed sessions: rerun the stack command, or
|
|
24
|
-
* Returns the plan action:
|
|
23
|
+
* The closing step after routed sessions: rerun the stack command, or wait when nothing is owned.
|
|
24
|
+
* Returns the plan action: other authors' layers are not an intervention, so the plan waits under
|
|
25
|
+
* the stack stall timer, with no rerun, quota cadence, or wake-up step.
|
|
25
26
|
* `keepWatching` is false when a human handoff may end the run before every layer is terminal.
|
|
26
27
|
*/
|
|
27
|
-
export declare function appendStackRerunInstruction(instructions: string[], layers: PollSummaryItem[], rerun: string, keepWatching?: boolean): "shepherd" | "
|
|
28
|
+
export declare function appendStackRerunInstruction(instructions: string[], layers: PollSummaryItem[], rerun: string, keepWatching?: boolean): "shepherd" | "wait";
|
|
@@ -37,18 +37,21 @@ function onlyUnownedWork(layers) {
|
|
|
37
37
|
}
|
|
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
|
+
/** 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.";
|
|
40
42
|
/** The literal stack command to rerun, or the generic name when the caller's command is unknown. */
|
|
41
43
|
export function stackRerunTarget(command) {
|
|
42
44
|
return command ? `\`${command}\`` : "this same `stack` command";
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
|
-
* The closing step after routed sessions: rerun the stack command, or
|
|
46
|
-
* Returns the plan action:
|
|
47
|
+
* The closing step after routed sessions: rerun the stack command, or wait when nothing is owned.
|
|
48
|
+
* Returns the plan action: other authors' layers are not an intervention, so the plan waits under
|
|
49
|
+
* the stack stall timer, with no rerun, quota cadence, or wake-up step.
|
|
47
50
|
* `keepWatching` is false when a human handoff may end the run before every layer is terminal.
|
|
48
51
|
*/
|
|
49
52
|
export function appendStackRerunInstruction(instructions, layers, rerun, keepWatching = true) {
|
|
50
53
|
const stop = onlyUnownedWork(layers);
|
|
51
54
|
const step = keepWatching ? `${rerun} ${STACK_KEEP_WATCHING}` : rerun;
|
|
52
|
-
instructions.push(`${instructions.length + 1}. ${stop ?
|
|
53
|
-
return stop ? "
|
|
55
|
+
instructions.push(`${instructions.length + 1}. ${stop ? NO_OWNED_SESSION : step}`);
|
|
56
|
+
return stop ? "wait" : "shepherd";
|
|
54
57
|
}
|
package/bin/commands/tick.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { isHandedOffSelection, onlyDraftVerificationSelection, } from "./poll-su
|
|
|
5
5
|
import { runIterate } from "./iterate/index.mjs";
|
|
6
6
|
import { earliestDeadline, readStallDeadline } from "./stall-deadline.mjs";
|
|
7
7
|
import { runsSingleTick } from "./single-tick.mjs";
|
|
8
|
+
import { isDraftReadinessVerification } from "./stack-work.mjs";
|
|
8
9
|
import { readStackStallDeadline } from "./stack-stall.mjs";
|
|
9
10
|
import { runPoll } from "./poll.mjs";
|
|
10
11
|
import { runAggregatePoll, runPollSummary, } from "./poll-summary.mjs";
|
|
@@ -70,14 +71,25 @@ async function withAggregateNextCheck(result, opts) {
|
|
|
70
71
|
/** The appended tick step owns timing, including pending stack merges. */
|
|
71
72
|
function withoutPollingCadence(step) {
|
|
72
73
|
return step
|
|
73
|
-
.replace(/ Recheck(?: them)? at the configured polling cadence
|
|
74
|
+
.replace(/ Recheck(?: them)? at the configured polling cadence[.;]/g, "")
|
|
74
75
|
.replace(" If a background exit wakes you, end the turn and continue then.", "")
|
|
75
76
|
.replace(/Do not end the turn while any selected row is non-terminal: /g, "Keep watching every non-terminal selected row through the wake-up below: ")
|
|
76
77
|
.replace("rerun that command at the configured cadence to resume its UUID", "rerun that command after the wake-up below to resume its UUID");
|
|
77
78
|
}
|
|
79
|
+
/** A stack layer no one-PR probe can advance: unreadable, or another author's draft. */
|
|
80
|
+
function hasUnrunnableLayer(result) {
|
|
81
|
+
const { selection } = result;
|
|
82
|
+
if (selection.kind !== "stack")
|
|
83
|
+
return false;
|
|
84
|
+
// A whole-stack selection omits row ownership: every layer is the caller's.
|
|
85
|
+
const listed = selection.owned !== undefined;
|
|
86
|
+
return result.prs.some((item) => item.state === "UNKNOWN" || (listed && isDraftReadinessVerification(item) && !item.owned));
|
|
87
|
+
}
|
|
78
88
|
function aggregateNextCheck(result, stallDeadlineSeconds) {
|
|
79
89
|
if (isHandedOffSelection(result) ||
|
|
80
|
-
(onlyDraftVerificationSelection(result) &&
|
|
90
|
+
(onlyDraftVerificationSelection(result) &&
|
|
91
|
+
!hasUnrunnableLayer(result) &&
|
|
92
|
+
result.nextAction !== "merge") ||
|
|
81
93
|
result.reason === "all_terminal" ||
|
|
82
94
|
result.nextAction === "cancel" ||
|
|
83
95
|
result.nextAction === "escalate") {
|
package/bin/config/renames.mjs
CHANGED
|
@@ -6,7 +6,7 @@ const RENAMED_KEYS = {
|
|
|
6
6
|
cliCommand: "cli-command",
|
|
7
7
|
botUsernames: "bot-usernames",
|
|
8
8
|
ignoreChecks: "checks.ignore",
|
|
9
|
-
"actions.neverCancelRuns": "checks.never-
|
|
9
|
+
"actions.neverCancelRuns": "checks.never-cancel",
|
|
10
10
|
"checks.ciTriggerEvents": "checks.ci-trigger-events",
|
|
11
11
|
"checks.ignoreLogLines": "checks.ignore-log-lines",
|
|
12
12
|
"iterate.fixAttemptsPerThread": "iterate.triage-attempts-per-thread",
|
package/bin/config/schema.d.mts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
15
15
|
checks: z.ZodPrefault<z.ZodObject<{
|
|
16
16
|
ignore: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
17
17
|
"never-ignore": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
"never-cancel": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
19
|
"ci-trigger-events": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
20
|
"ignore-log-lines": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
20
21
|
}, z.core.$strict>>;
|
|
@@ -79,6 +80,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
79
80
|
actions: z.ZodPrefault<z.ZodObject<{
|
|
80
81
|
"auto-minimize-suppressed": z.ZodDefault<z.ZodBoolean>;
|
|
81
82
|
"work-while-queued": z.ZodDefault<z.ZodBoolean>;
|
|
83
|
+
"cancel-runs-before-push": z.ZodDefault<z.ZodBoolean>;
|
|
82
84
|
}, z.core.$strict>>;
|
|
83
85
|
classify: z.ZodPrefault<z.ZodObject<{
|
|
84
86
|
standard: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
|
|
@@ -100,6 +102,7 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
100
102
|
checks: z.ZodPrefault<z.ZodObject<{
|
|
101
103
|
ignore: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
102
104
|
"never-ignore": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
105
|
+
"never-cancel": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
103
106
|
"ci-trigger-events": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
104
107
|
"ignore-log-lines": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
105
108
|
}, z.core.$strict>>;
|
|
@@ -164,6 +167,7 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
164
167
|
actions: z.ZodPrefault<z.ZodObject<{
|
|
165
168
|
"auto-minimize-suppressed": z.ZodDefault<z.ZodBoolean>;
|
|
166
169
|
"work-while-queued": z.ZodDefault<z.ZodBoolean>;
|
|
170
|
+
"cancel-runs-before-push": z.ZodDefault<z.ZodBoolean>;
|
|
167
171
|
}, z.core.$strict>>;
|
|
168
172
|
classify: z.ZodPrefault<z.ZodObject<{
|
|
169
173
|
standard: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
|
package/bin/config/schema.mjs
CHANGED
|
@@ -106,6 +106,7 @@ export const configSchema = z.strictObject({
|
|
|
106
106
|
.strictObject({
|
|
107
107
|
ignore: strings().default(() => []),
|
|
108
108
|
"never-ignore": strings().default(() => []),
|
|
109
|
+
"never-cancel": strings().default(() => []),
|
|
109
110
|
"ci-trigger-events": strings().default(() => ["pull_request", "pull_request_target"]),
|
|
110
111
|
"ignore-log-lines": z.array(regexPattern).default(() => []),
|
|
111
112
|
})
|
|
@@ -162,6 +163,7 @@ export const configSchema = z.strictObject({
|
|
|
162
163
|
.strictObject({
|
|
163
164
|
"auto-minimize-suppressed": z.boolean().default(true),
|
|
164
165
|
"work-while-queued": z.boolean().default(false),
|
|
166
|
+
"cancel-runs-before-push": z.boolean().default(true),
|
|
165
167
|
})
|
|
166
168
|
.prefault({}),
|
|
167
169
|
classify: z
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type WorkflowSuiteSnapshot } from "../checks/unreported-required.mts";
|
|
2
2
|
import type { CheckRun } from "../types.mts";
|
|
3
3
|
import type { RawPr } from "./batch-raw-types.mts";
|
|
4
4
|
export declare function parseCheckSuitesComplete(raw: RawPr): boolean;
|
|
@@ -16,6 +16,9 @@ export declare function startupFailureChecksFromSuites(suites: {
|
|
|
16
16
|
workflow?: {
|
|
17
17
|
name: string | null;
|
|
18
18
|
} | null;
|
|
19
|
+
file?: {
|
|
20
|
+
path: string | null;
|
|
21
|
+
} | null;
|
|
19
22
|
} | null;
|
|
20
23
|
}>;
|
|
21
24
|
} | null | undefined): CheckRun[];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { normalizeWorkflowPath } from "../checks/workflow-path.mjs";
|
|
2
|
+
import { ACTIONS_APP_SLUG } from "../checks/unreported-required.mjs";
|
|
1
3
|
export function parseCheckSuitesComplete(raw) {
|
|
2
4
|
return raw.commits.nodes[0]?.commit.checkSuites?.pageInfo.hasNextPage === false;
|
|
3
5
|
}
|
|
@@ -10,13 +12,21 @@ export function parseHeadCheckSuitesEmpty(raw) {
|
|
|
10
12
|
function parseHeadWorkflowSuites(raw) {
|
|
11
13
|
const nodes = raw.commits.nodes[0]?.commit.checkSuites?.nodes ?? [];
|
|
12
14
|
return nodes.flatMap((node) => {
|
|
13
|
-
if (!node.workflowRun)
|
|
14
|
-
|
|
15
|
+
if (!node.workflowRun) {
|
|
16
|
+
// Actions creates its suites before their runs; keep those so a starting workflow is visible.
|
|
17
|
+
if (node.app?.slug !== ACTIONS_APP_SLUG)
|
|
18
|
+
return [];
|
|
19
|
+
return [{ status: node.status ?? null, conclusion: node.conclusion, app: node.app }];
|
|
20
|
+
}
|
|
15
21
|
return [
|
|
16
22
|
{
|
|
17
23
|
status: node.status ?? null,
|
|
18
24
|
conclusion: node.conclusion,
|
|
19
|
-
workflowRun: {
|
|
25
|
+
workflowRun: {
|
|
26
|
+
event: node.workflowRun.event,
|
|
27
|
+
databaseId: node.workflowRun.databaseId,
|
|
28
|
+
path: normalizeWorkflowPath(node.workflowRun.file?.path) ?? null,
|
|
29
|
+
},
|
|
20
30
|
},
|
|
21
31
|
];
|
|
22
32
|
});
|
|
@@ -33,6 +43,7 @@ export function startupFailureChecksFromSuites(suites) {
|
|
|
33
43
|
return [];
|
|
34
44
|
const runId = node.workflowRun.databaseId != null ? String(node.workflowRun.databaseId) : null;
|
|
35
45
|
const name = node.workflowRun.workflow?.name?.trim() || (runId ? `workflow run ${runId}` : "workflow run");
|
|
46
|
+
const workflowPath = normalizeWorkflowPath(node.workflowRun.file?.path);
|
|
36
47
|
return [
|
|
37
48
|
{
|
|
38
49
|
name,
|
|
@@ -42,6 +53,7 @@ export function startupFailureChecksFromSuites(suites) {
|
|
|
42
53
|
detailsUrl: node.workflowRun.url ?? "",
|
|
43
54
|
event: node.workflowRun.event,
|
|
44
55
|
runId,
|
|
56
|
+
...(workflowPath !== undefined && { workflowPath }),
|
|
45
57
|
},
|
|
46
58
|
];
|
|
47
59
|
});
|
|
@@ -125,6 +125,9 @@ interface RawCheckSuites {
|
|
|
125
125
|
id?: string;
|
|
126
126
|
status?: string | null;
|
|
127
127
|
conclusion: string | null;
|
|
128
|
+
app?: {
|
|
129
|
+
slug: string | null;
|
|
130
|
+
} | null;
|
|
128
131
|
workflowRun: {
|
|
129
132
|
databaseId: number | null;
|
|
130
133
|
event: string | null;
|
|
@@ -132,6 +135,9 @@ interface RawCheckSuites {
|
|
|
132
135
|
workflow: {
|
|
133
136
|
name: string | null;
|
|
134
137
|
} | null;
|
|
138
|
+
file?: {
|
|
139
|
+
path: string | null;
|
|
140
|
+
} | null;
|
|
135
141
|
} | null;
|
|
136
142
|
}>;
|
|
137
143
|
}
|
|
@@ -7,6 +7,9 @@ fragment CommitCheckSuites on Commit {
|
|
|
7
7
|
id
|
|
8
8
|
status
|
|
9
9
|
conclusion
|
|
10
|
+
app {
|
|
11
|
+
slug
|
|
12
|
+
}
|
|
10
13
|
workflowRun {
|
|
11
14
|
databaseId
|
|
12
15
|
event
|
|
@@ -14,6 +17,9 @@ fragment CommitCheckSuites on Commit {
|
|
|
14
17
|
workflow {
|
|
15
18
|
name
|
|
16
19
|
}
|
|
20
|
+
file {
|
|
21
|
+
path
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
24
|
}
|
|
19
25
|
}
|
|
@@ -247,6 +247,9 @@ fragment PollSummaryPr on PullRequest {
|
|
|
247
247
|
id
|
|
248
248
|
status
|
|
249
249
|
conclusion
|
|
250
|
+
app {
|
|
251
|
+
slug
|
|
252
|
+
}
|
|
250
253
|
workflowRun {
|
|
251
254
|
databaseId
|
|
252
255
|
event
|
|
@@ -254,6 +257,9 @@ fragment PollSummaryPr on PullRequest {
|
|
|
254
257
|
workflow {
|
|
255
258
|
name
|
|
256
259
|
}
|
|
260
|
+
file {
|
|
261
|
+
path
|
|
262
|
+
}
|
|
257
263
|
}
|
|
258
264
|
}
|
|
259
265
|
}
|
|
@@ -5,4 +5,18 @@ export declare function pollCommandFields(repo: string, pr: number, isDraft: boo
|
|
|
5
5
|
* Intervals and timeouts are omitted: they are loop cadence, not selection. Options equal to the
|
|
6
6
|
* configured defaults are omitted too, since the parser fills them from config.
|
|
7
7
|
*/
|
|
8
|
-
export declare function aggregateRerunCommand(repo: string, selection: PollSummarySelection, opts: PollSummaryCommandOptions): string;
|
|
8
|
+
export declare function aggregateRerunCommand(repo: string, selection: PollSummarySelection, opts: PollSummaryCommandOptions, refs?: string[]): string;
|
|
9
|
+
/**
|
|
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.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stackApprovalCommands(repo: string, selection: PollSummarySelection, opts: PollSummaryCommandOptions, extra: number[]): {
|
|
14
|
+
listed: string;
|
|
15
|
+
whole: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The same stack command, merging whichever owned prefix is ready instead of the whole scope.
|
|
19
|
+
* `scoped` replaces the listed refs, so a stack number or a listed PR above a `--merge-through`
|
|
20
|
+
* target cannot widen ownership past what the original request approved.
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeReadyCommand(command: string, scoped?: string[]): string;
|
|
@@ -29,15 +29,27 @@ export function pollCommandFields(repo, pr, isDraft, opts) {
|
|
|
29
29
|
* Intervals and timeouts are omitted: they are loop cadence, not selection. Options equal to the
|
|
30
30
|
* configured defaults are omitted too, since the parser fills them from config.
|
|
31
31
|
*/
|
|
32
|
-
export function aggregateRerunCommand(repo, selection, opts) {
|
|
32
|
+
export function aggregateRerunCommand(repo, selection, opts, refs) {
|
|
33
33
|
const args = selection.kind === "stack"
|
|
34
|
-
? [
|
|
34
|
+
? [
|
|
35
|
+
"stack",
|
|
36
|
+
// Listed PRs name the caller's own layers; otherwise the stack number selects them all.
|
|
37
|
+
...(refs ??
|
|
38
|
+
(selection.owned
|
|
39
|
+
? selection.owned.map((pr) => formatPrUrl(repo, pr))
|
|
40
|
+
: [`${repo}#${selection.stackNumber}`])),
|
|
41
|
+
opts.tick ? "--once" : "--until-terminal",
|
|
42
|
+
]
|
|
35
43
|
: [
|
|
36
44
|
...(opts.tick ? ["iterate"] : []),
|
|
37
45
|
...selection.requested.map((pr) => formatPrUrl(repo, pr)),
|
|
38
46
|
...(opts.tick ? [] : ["--until-terminal"]),
|
|
39
47
|
];
|
|
40
|
-
if (opts.
|
|
48
|
+
if (opts.stackMerge?.kind === "ready")
|
|
49
|
+
args.push("--merge-ready");
|
|
50
|
+
else if (opts.stackMerge?.kind === "through")
|
|
51
|
+
args.push("--merge-through", formatPrUrl(repo, opts.stackMerge.pr));
|
|
52
|
+
else if (opts.merge)
|
|
41
53
|
args.push("--merge");
|
|
42
54
|
// The parser always fills these from config, so a default value adds nothing to the command.
|
|
43
55
|
const iterate = loadConfig().iterate;
|
|
@@ -53,3 +65,27 @@ export function aggregateRerunCommand(repo, selection, opts) {
|
|
|
53
65
|
args.push("--no-auto-mark-ready");
|
|
54
66
|
return buildPrShepherdCommand(args).text;
|
|
55
67
|
}
|
|
68
|
+
/**
|
|
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.
|
|
71
|
+
*/
|
|
72
|
+
export function stackApprovalCommands(repo, selection, opts, extra) {
|
|
73
|
+
if (selection.kind !== "stack")
|
|
74
|
+
return { listed: "", whole: "" };
|
|
75
|
+
const listed = [...new Set([...(selection.owned ?? []), ...extra])].sort((a, b) => a - b);
|
|
76
|
+
return {
|
|
77
|
+
listed: aggregateRerunCommand(repo, { ...selection, owned: listed }, opts),
|
|
78
|
+
whole: aggregateRerunCommand(repo, selection, opts, [`${repo}#${selection.stackNumber}`]),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The same stack command, merging whichever owned prefix is ready instead of the whole scope.
|
|
83
|
+
* `scoped` replaces the listed refs, so a stack number or a listed PR above a `--merge-through`
|
|
84
|
+
* target cannot widen ownership past what the original request approved.
|
|
85
|
+
*/
|
|
86
|
+
export function mergeReadyCommand(command, scoped) {
|
|
87
|
+
const swapped = command.replace(/ --merge(?:-through \S+)?(?= |$)/, " --merge-ready");
|
|
88
|
+
return scoped
|
|
89
|
+
? swapped.replace(/ stack (?:[^-\s]\S* )+(?=--)/, ` stack ${scoped.join(" ")} `)
|
|
90
|
+
: swapped;
|
|
91
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PollSummaryCommandOptions, PollSummaryItem } from "../types.mts";
|
|
2
2
|
import type { RepoInfo } from "./client.mts";
|
|
3
3
|
import type { RawSummaryPr } from "./poll-summary-raw.mts";
|
|
4
|
-
export declare function summarizePollSummaryPr(raw: RawSummaryPr, repo: RepoInfo, opts: PollSummaryCommandOptions, viewerCanAdminister?: boolean | undefined, mergeTargetContexts?: readonly string[],
|
|
4
|
+
export declare function summarizePollSummaryPr(raw: RawSummaryPr, repo: RepoInfo, opts: PollSummaryCommandOptions, viewerCanAdminister?: boolean | undefined, mergeTargetContexts?: readonly string[],
|
|
5
5
|
/** Aggregate polls only: apply rule-driven auto-resolve. Receipt and merge validation reads never mutate. */
|
|
6
6
|
applyRuleAutoResolve?: boolean): Promise<PollSummaryItem>;
|
|
@@ -16,7 +16,7 @@ import { applyPendingWorkflowSuites, applyUnreportedRequiredChecks, summaryRequi
|
|
|
16
16
|
import { aliasThreadSeenMarkers } from "./rest-identities.mjs";
|
|
17
17
|
import { restQueueRequirement } from "./poll-summary-rest-queue.mjs";
|
|
18
18
|
import { detectBlockingReviewer } from "./poll-summary-blocking-reviewer.mjs";
|
|
19
|
-
export async function summarizePollSummaryPr(raw, repo, opts, viewerCanAdminister = undefined, mergeTargetContexts,
|
|
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. */
|
|
21
21
|
applyRuleAutoResolve = false) {
|
|
22
22
|
const repoName = `${repo.owner}/${repo.name}`;
|
|
@@ -100,9 +100,6 @@ applyRuleAutoResolve = false) {
|
|
|
100
100
|
title: raw.title,
|
|
101
101
|
url: raw.url || formatPrUrl(repoName, raw.number),
|
|
102
102
|
...(raw.author?.login && { authorLogin: raw.author.login }),
|
|
103
|
-
...(raw.author?.login &&
|
|
104
|
-
viewerLogin !== null &&
|
|
105
|
-
raw.author.login.toLowerCase() === viewerLogin.toLowerCase() && { owned: true }),
|
|
106
103
|
action,
|
|
107
104
|
reasons,
|
|
108
105
|
state: normalizePollSummaryState(raw.state),
|
|
@@ -94,6 +94,9 @@ export interface RawSummaryCommit {
|
|
|
94
94
|
id?: string;
|
|
95
95
|
status?: string | null;
|
|
96
96
|
conclusion: string | null;
|
|
97
|
+
app?: {
|
|
98
|
+
slug: string | null;
|
|
99
|
+
} | null;
|
|
97
100
|
workflowRun: {
|
|
98
101
|
databaseId?: number | null;
|
|
99
102
|
event: string | null;
|
|
@@ -101,6 +104,9 @@ export interface RawSummaryCommit {
|
|
|
101
104
|
workflow?: {
|
|
102
105
|
name: string | null;
|
|
103
106
|
} | null;
|
|
107
|
+
file?: {
|
|
108
|
+
path: string | null;
|
|
109
|
+
} | null;
|
|
104
110
|
} | null;
|
|
105
111
|
}>;
|
|
106
112
|
} | null;
|
|
@@ -50,7 +50,10 @@ export function routePollSummary(raw, checks, review, opts) {
|
|
|
50
50
|
const unsupported = getGithubTransport() === "rest" && raw.viewerCanUpdate !== false && !isCcrTransport();
|
|
51
51
|
if (unsupported)
|
|
52
52
|
return { action: "escalate", reasons: ["transport-unsupported"] };
|
|
53
|
-
return {
|
|
53
|
+
return {
|
|
54
|
+
action: "escalate",
|
|
55
|
+
reasons: ["mark-ready-authorization-required"],
|
|
56
|
+
};
|
|
54
57
|
}
|
|
55
58
|
return { action: "mark_ready", reasons: ["draft-appears-ready"] };
|
|
56
59
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readRestStackSummary } from "./rest-stack-summary.mjs";
|
|
2
|
+
import { requestedMergeScope } from "../commands/stack-merge-scope.mjs";
|
|
2
3
|
import { githubOperation, getGithubTransport, runWithGithubTransport } from "./transport.mjs";
|
|
3
4
|
import { readRestExplicitSummary } from "./rest-explicit-summary-read.mjs";
|
|
4
5
|
import { withRestConditionalScope } from "./rest-conditional-scope.mjs";
|
|
@@ -38,7 +39,7 @@ async function fetchSelectedPollSummary(opts, repo) {
|
|
|
38
39
|
return {
|
|
39
40
|
selection: { kind: "prs", requested },
|
|
40
41
|
// One explicit PR's failed read becomes a row; stack selections stay fail-closed.
|
|
41
|
-
prs: await summarizeRowsIsolated(raw, failures, repo, opts, (pr) => summarizePollSummaryPr(pr, repo, opts, viewerCanAdminister, undefined,
|
|
42
|
+
prs: await summarizeRowsIsolated(raw, failures, repo, opts, (pr) => summarizePollSummaryPr(pr, repo, opts, viewerCanAdminister, undefined, true)),
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
/** Fresh, read-only snapshot used to bind a one-PR READY receipt to stack routing. */
|
|
@@ -96,7 +97,7 @@ async function fetchStackSummary(opts, repo) {
|
|
|
96
97
|
const hint = graphql ? await loadStackSizeHint(stateKey) : 0;
|
|
97
98
|
const sizeHint = hint || UNSIZED_STACK_SUMMARY_FIRST;
|
|
98
99
|
const read = await readStackSummary(anchor, repo, sizeHint);
|
|
99
|
-
const { stackNumber, stackSize,
|
|
100
|
+
const { stackNumber, stackSize, viewerCanAdminister, ordered, allowedMergeMethods } = read;
|
|
100
101
|
if (graphql && stackSize !== hint)
|
|
101
102
|
await storeStackSizeHint(stateKey, stackSize);
|
|
102
103
|
for (const pr of ordered) {
|
|
@@ -106,7 +107,13 @@ async function fetchStackSummary(opts, repo) {
|
|
|
106
107
|
const handoffSource = getGithubTransport() === "rest" ? undefined : stackHandoffSource(read);
|
|
107
108
|
const stackAncestry = stackAncestryGaps(ordered);
|
|
108
109
|
const required = await trunkRequiredContexts(ordered, repo);
|
|
109
|
-
|
|
110
|
+
// Rule-driven auto-resolve mutates review state, so it runs only on layers the caller owns
|
|
111
|
+
// and, for --merge-through, only through the target: other layers are read, never written.
|
|
112
|
+
const scope = requestedMergeScope(opts);
|
|
113
|
+
const throughIndex = scope?.kind === "through" ? ordered.findIndex((pr) => pr.number === scope.pr) : -1;
|
|
114
|
+
const mayMutate = (pr, index) => (!opts.stackOwned || opts.stackOwned.includes(pr.number)) &&
|
|
115
|
+
(throughIndex < 0 || index <= throughIndex);
|
|
116
|
+
const prs = await Promise.all(ordered.map((pr, index) => summarizePollSummaryPr(pr, repo, opts, viewerCanAdminister, required, mayMutate(pr, index))));
|
|
110
117
|
if (handoffSource)
|
|
111
118
|
patchHandoffLayers(handoffSource.layers, prs);
|
|
112
119
|
return {
|