pr-shepherd 2.2.18 → 2.4.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 +1 -0
- package/bin/api.d.mts +10 -0
- package/bin/api.mjs +21 -1
- package/bin/cli/iterate-formatter.mjs +3 -1
- package/bin/cli/triage-formatter.mjs +2 -0
- package/bin/cli/workflow-elsewhere-format.d.mts +3 -0
- package/bin/cli/workflow-elsewhere-format.mjs +112 -0
- package/bin/commands/iterate/base.mjs +1 -0
- package/bin/commands/iterate/helpers.mjs +1 -0
- package/bin/commands/iterate/index.mjs +11 -3
- package/bin/commands/iterate/queue-recovery-instructions.d.mts +1 -1
- package/bin/commands/iterate/queue-recovery-instructions.mjs +7 -4
- package/bin/commands/iterate/render.mjs +2 -1
- package/bin/commands/iterate/triage.mjs +24 -7
- package/bin/commands/iterate/workflow-elsewhere.d.mts +19 -0
- package/bin/commands/iterate/workflow-elsewhere.mjs +144 -0
- package/bin/commands/ready-delay.mjs +24 -1
- package/bin/comments/rest-reply.mjs +2 -1
- package/bin/comments/uncertain-replies.mjs +2 -1
- package/bin/comments/uncertain-reply-guards.mjs +2 -1
- package/bin/config/schema.d.mts +6 -0
- package/bin/config/schema.mjs +3 -0
- package/bin/execution-context.d.mts +7 -0
- package/bin/execution-context.mjs +13 -1
- package/bin/github/gql/default-branch-workflow-runs.gql +71 -0
- package/bin/github/graphql-http.mjs +2 -0
- package/bin/github/graphql-internal-retry.mjs +2 -1
- package/bin/github/queries.d.mts +2 -0
- package/bin/github/queries.mjs +2 -0
- package/bin/github/read-only-guard.d.mts +4 -0
- package/bin/github/read-only-guard.mjs +25 -0
- package/bin/github/rest-http.mjs +2 -0
- package/bin/github/rest-identities.mjs +16 -2
- package/bin/github/workflow-elsewhere-parse.d.mts +19 -0
- package/bin/github/workflow-elsewhere-parse.mjs +172 -0
- package/bin/github/workflow-elsewhere-queue.d.mts +28 -0
- package/bin/github/workflow-elsewhere-queue.mjs +137 -0
- package/bin/github/workflow-elsewhere-read.d.mts +26 -0
- package/bin/github/workflow-elsewhere-read.mjs +120 -0
- package/bin/github/workflow-elsewhere-rest-runs.d.mts +20 -0
- package/bin/github/workflow-elsewhere-rest-runs.mjs +54 -0
- package/bin/github/workflow-elsewhere-rest.d.mts +3 -0
- package/bin/github/workflow-elsewhere-rest.mjs +126 -0
- package/bin/log/log-file.mjs +1 -1
- package/bin/state/base.mjs +30 -12
- package/bin/state/check-blockers.mjs +2 -1
- package/bin/state/check-follow-up.mjs +2 -1
- package/bin/state/ci-retrigger.mjs +2 -1
- package/bin/state/conflicting-head-seen.mjs +2 -1
- package/bin/state/fix-attempts.mjs +2 -1
- package/bin/state/graphql-quota-claims.mjs +6 -1
- package/bin/state/graphql-quota-warnings.mjs +2 -1
- package/bin/state/guarded-fs.d.mts +16 -0
- package/bin/state/guarded-fs.mjs +49 -0
- package/bin/state/merge-request.mjs +2 -1
- package/bin/state/pr-fingerprint.mjs +2 -1
- package/bin/state/queue-removal-ack.mjs +2 -1
- package/bin/state/ready-receipts.mjs +2 -1
- package/bin/state/rest-cache.mjs +2 -1
- package/bin/state/rest-snapshot-report.mjs +2 -1
- package/bin/state/seen-comments.mjs +2 -1
- package/bin/state/signature-marker.mjs +2 -1
- package/bin/state/stack-merge-approval.mjs +2 -1
- package/bin/state/stall-repair.mjs +2 -1
- package/bin/state/stall-state-store.mjs +2 -1
- package/bin/types/iterate.d.mts +2 -0
- package/bin/types/report.d.mts +7 -0
- package/bin/types/workflow-elsewhere-raw.d.mts +108 -0
- package/bin/types/workflow-elsewhere-raw.mjs +1 -0
- package/bin/types/workflow-elsewhere.d.mts +55 -0
- package/bin/types/workflow-elsewhere.mjs +1 -0
- package/bin/types.d.mts +1 -0
- package/bin/types.mjs +1 -0
- package/package.json +1 -1
- package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/references/merge-queue-ejection.md +1 -1
- package/pr-shepherd.schema.json +13 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** A one-field marker file in the PR state directory: "this exact situation was already presented". */
|
|
2
|
-
import {
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { mkdir, writeFile } from "./guarded-fs.mjs";
|
|
3
4
|
import { dirname } from "node:path";
|
|
4
5
|
import { resolvePrStatePath } from "./base.mjs";
|
|
5
6
|
/** True when the marker file holds exactly this signature. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { mkdir, unlink, writeFile } from "./guarded-fs.mjs";
|
|
2
3
|
import { dirname } from "node:path";
|
|
3
4
|
import { resolveStackStatePath } from "./base.mjs";
|
|
4
5
|
/** How long one request's approval lasts; a request outliving it is approved afresh. */
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* When even the temp directory is unusable the marker cannot bound the repair tick, so the failure escalates at once.
|
|
10
10
|
*/
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
|
-
import { readFile
|
|
12
|
+
import { readFile } from "node:fs/promises";
|
|
13
|
+
import { writeFile } from "./guarded-fs.mjs";
|
|
13
14
|
import { tmpdir } from "node:os";
|
|
14
15
|
import { join } from "node:path";
|
|
15
16
|
import { resolveStateBase } from "./base.mjs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { readFile
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { writeFile, rename, unlink, mkdir } from "./guarded-fs.mjs";
|
|
2
3
|
import { randomUUID } from "node:crypto";
|
|
3
4
|
import { dirname } from "node:path";
|
|
4
5
|
/**
|
package/bin/types/iterate.d.mts
CHANGED
|
@@ -27,6 +27,8 @@ export interface IterateResultBase {
|
|
|
27
27
|
}>;
|
|
28
28
|
pr: number;
|
|
29
29
|
repo: string;
|
|
30
|
+
/** The PR head commit this tick evaluated. Omitted when GitHub did not report it. */
|
|
31
|
+
headSha?: string;
|
|
30
32
|
status: ShepherdStatus;
|
|
31
33
|
state: "OPEN" | "CLOSED" | "MERGED" | "UNKNOWN";
|
|
32
34
|
mergeStateStatus: MergeStateStatus;
|
package/bin/types/report.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AuthorType, ReviewThread, PrComment, Review, MergeStatusResult, Vi
|
|
|
2
2
|
import type { ClassifiedCheck, RelatedFailedJob, TriagedCheck } from "./check-classification.mts";
|
|
3
3
|
import type { AgentThreadComment } from "./agent-thread.mts";
|
|
4
4
|
import type { CheckAnnotation } from "./check-annotations.mts";
|
|
5
|
+
import type { ElsewhereRun } from "./workflow-elsewhere.mts";
|
|
5
6
|
import type { PrActivitySummary } from "./activity.mts";
|
|
6
7
|
import type { MergeQueueReport } from "./merge-queue.mts";
|
|
7
8
|
export interface AutoMinimizedItem {
|
|
@@ -230,6 +231,12 @@ export interface AgentCheck {
|
|
|
230
231
|
annotationOnly?: true;
|
|
231
232
|
scope?: "merge_group";
|
|
232
233
|
commitOid?: string;
|
|
234
|
+
/** Recent completed runs of the same workflow on the default branch and other merge-queue entries. */
|
|
235
|
+
elsewhere?: ElsewhereRun[];
|
|
236
|
+
/** Bounded-read scope metadata (workflow, window start, items checked, matched vs shown), present alongside `elsewhere`. */
|
|
237
|
+
elsewhereScope?: import("./workflow-elsewhere.mts").ElsewhereScope;
|
|
238
|
+
/** Why `elsewhere` could not be read or was incomplete; omitted when `elsewhere` is present. */
|
|
239
|
+
elsewhereUnread?: string;
|
|
233
240
|
}
|
|
234
241
|
/**
|
|
235
242
|
* A single CI check that is relevant to PR readiness — triggered by a PR event
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ElsewhereRun } from "./workflow-elsewhere.mts";
|
|
2
|
+
/** Raw GitHub GraphQL and REST shapes for merge-queue workflow-elsewhere comparisons. */
|
|
3
|
+
export interface ParsedDefaultBranchRuns {
|
|
4
|
+
runs: ElsewhereRun[];
|
|
5
|
+
incomplete: boolean;
|
|
6
|
+
unavailable?: string;
|
|
7
|
+
branch?: string;
|
|
8
|
+
commitsRead: number;
|
|
9
|
+
matched: number;
|
|
10
|
+
matchedComplete: boolean;
|
|
11
|
+
workflowName?: string;
|
|
12
|
+
workflowPath?: string;
|
|
13
|
+
}
|
|
14
|
+
interface RawElsewhereAnnotation {
|
|
15
|
+
path?: string | null;
|
|
16
|
+
location?: {
|
|
17
|
+
start?: {
|
|
18
|
+
line?: number | null;
|
|
19
|
+
} | null;
|
|
20
|
+
} | null;
|
|
21
|
+
message?: string | null;
|
|
22
|
+
}
|
|
23
|
+
interface RawElsewhereCheckRun {
|
|
24
|
+
name: string;
|
|
25
|
+
conclusion: string | null;
|
|
26
|
+
annotations?: {
|
|
27
|
+
totalCount?: number;
|
|
28
|
+
nodes?: Array<RawElsewhereAnnotation | null>;
|
|
29
|
+
} | null;
|
|
30
|
+
}
|
|
31
|
+
interface RawPageInfo {
|
|
32
|
+
hasNextPage?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface RawElsewhereSuite {
|
|
35
|
+
status?: string | null;
|
|
36
|
+
conclusion?: string | null;
|
|
37
|
+
updatedAt?: string | null;
|
|
38
|
+
branch?: {
|
|
39
|
+
name?: string | null;
|
|
40
|
+
} | null;
|
|
41
|
+
workflowRun?: {
|
|
42
|
+
databaseId?: number | null;
|
|
43
|
+
event?: string | null;
|
|
44
|
+
updatedAt?: string | null;
|
|
45
|
+
file?: {
|
|
46
|
+
path?: string | null;
|
|
47
|
+
} | null;
|
|
48
|
+
workflow?: {
|
|
49
|
+
databaseId?: number | null;
|
|
50
|
+
name?: string | null;
|
|
51
|
+
} | null;
|
|
52
|
+
} | null;
|
|
53
|
+
checkRuns?: {
|
|
54
|
+
nodes?: Array<RawElsewhereCheckRun | null>;
|
|
55
|
+
} | null;
|
|
56
|
+
}
|
|
57
|
+
export interface RawDefaultBranchRunsResponse {
|
|
58
|
+
repository?: {
|
|
59
|
+
defaultBranchRef?: {
|
|
60
|
+
name?: string | null;
|
|
61
|
+
target?: {
|
|
62
|
+
history?: {
|
|
63
|
+
pageInfo?: RawPageInfo | null;
|
|
64
|
+
nodes?: Array<{
|
|
65
|
+
oid: string;
|
|
66
|
+
committedDate: string;
|
|
67
|
+
checkSuites?: {
|
|
68
|
+
pageInfo?: RawPageInfo | null;
|
|
69
|
+
nodes?: Array<RawElsewhereSuite | null>;
|
|
70
|
+
} | null;
|
|
71
|
+
} | null>;
|
|
72
|
+
} | null;
|
|
73
|
+
} | null;
|
|
74
|
+
} | null;
|
|
75
|
+
} | null;
|
|
76
|
+
}
|
|
77
|
+
export interface RawQueueCommitsResponse {
|
|
78
|
+
repository?: Record<string, {
|
|
79
|
+
oid?: string;
|
|
80
|
+
checkSuites?: {
|
|
81
|
+
pageInfo?: RawPageInfo | null;
|
|
82
|
+
nodes?: Array<RawElsewhereSuite | null>;
|
|
83
|
+
} | null;
|
|
84
|
+
} | null> | null;
|
|
85
|
+
}
|
|
86
|
+
export interface RestWorkflowRunItem {
|
|
87
|
+
id: number;
|
|
88
|
+
name?: string | null;
|
|
89
|
+
path?: string | null;
|
|
90
|
+
head_sha: string;
|
|
91
|
+
head_branch?: string | null;
|
|
92
|
+
event?: string | null;
|
|
93
|
+
status: string | null;
|
|
94
|
+
conclusion: string | null;
|
|
95
|
+
run_attempt?: number | null;
|
|
96
|
+
created_at: string;
|
|
97
|
+
updated_at?: string | null;
|
|
98
|
+
}
|
|
99
|
+
export interface RestRunCandidate {
|
|
100
|
+
runId: string;
|
|
101
|
+
headSha: string;
|
|
102
|
+
pr?: number;
|
|
103
|
+
branch?: string;
|
|
104
|
+
runAttempt?: number;
|
|
105
|
+
conclusion: string;
|
|
106
|
+
completedAt: string;
|
|
107
|
+
}
|
|
108
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** One inline annotation on a failed job in another run of the same workflow. */
|
|
2
|
+
export interface ElsewhereAnnotation {
|
|
3
|
+
path: string;
|
|
4
|
+
line: number | null;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
/** One failed or timed-out job in another run of the same workflow. */
|
|
8
|
+
export interface ElsewhereFailedJob {
|
|
9
|
+
name: string;
|
|
10
|
+
conclusion: string;
|
|
11
|
+
/** True when this job's exact name matches the failing merge-group check's name. */
|
|
12
|
+
sameJob?: true;
|
|
13
|
+
annotations: ElsewhereAnnotation[];
|
|
14
|
+
/** Count of additional annotations beyond the shown cap; omitted when zero or unknown. */
|
|
15
|
+
moreAnnotations?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Bounded-read scope for `Same workflow elsewhere` so callers see exactly what was inspected. */
|
|
18
|
+
export interface ElsewhereScope {
|
|
19
|
+
workflowName?: string;
|
|
20
|
+
workflowPath?: string;
|
|
21
|
+
/** ISO 8601 UTC start of the comparison window. */
|
|
22
|
+
since: string;
|
|
23
|
+
defaultBranch: {
|
|
24
|
+
branch: string;
|
|
25
|
+
/** Default-branch commits read (GraphQL transport). */
|
|
26
|
+
commitsRead?: number;
|
|
27
|
+
/** Default-branch workflow runs read (REST transport). */
|
|
28
|
+
runsRead?: number;
|
|
29
|
+
matched: number;
|
|
30
|
+
/** False when the read stopped before reaching the window start, so `matched` is a lower bound. */
|
|
31
|
+
matchedComplete: boolean;
|
|
32
|
+
shown: number;
|
|
33
|
+
};
|
|
34
|
+
mergeQueue: {
|
|
35
|
+
runsRead: number;
|
|
36
|
+
matched: number;
|
|
37
|
+
/** False when the read stopped before reaching the window start, so `matched` is a lower bound. */
|
|
38
|
+
matchedComplete: boolean;
|
|
39
|
+
shown: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** One completed run of the same workflow on the default branch or another merge-queue entry. */
|
|
43
|
+
export interface ElsewhereRun {
|
|
44
|
+
source: "default-branch" | "merge-queue";
|
|
45
|
+
/** Default branch name (e.g. `"main"`), set when `source === "default-branch"`. */
|
|
46
|
+
branch?: string;
|
|
47
|
+
/** Other PR number parsed from `gh-readonly-queue/<base>/pr-<N>-<sha>`, when known. */
|
|
48
|
+
pr?: number;
|
|
49
|
+
/** 7-character head commit SHA. */
|
|
50
|
+
headSha: string;
|
|
51
|
+
runId: string;
|
|
52
|
+
conclusion: string;
|
|
53
|
+
completedAt: string;
|
|
54
|
+
failedJobs: ElsewhereFailedJob[];
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/bin/types.d.mts
CHANGED
package/bin/types.mjs
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Apply when a step says `Playbook: "Merge queue ejection"`. The `**queue removal**` header names the queue commit. That commit combined the PR head with the base and any entries queued ahead of it, so a failure there may come from this PR, the base, another entry, or a flake. Do not requeue without triage. After triage, continue with the remaining numbered steps; iterate only at the final step.
|
|
4
4
|
|
|
5
|
-
1. If the step names a failed queue-commit check, update the PR head from the latest base following the repository's branch-update convention
|
|
5
|
+
1. If the step names a failed queue-commit check, inspect any `Same workflow elsewhere` runs under `## Failing checks` first; if the failure is already failing on the base branch itself, follow step 4 instead of updating the head. Otherwise, update the PR head from the latest base following the repository's branch-update convention (on a native stack, use the printed stack update route instead) and reproduce the failing step on the updated head.
|
|
6
6
|
2. If the failure belongs to this PR, fix it. The printed push step commits and pushes the fix.
|
|
7
7
|
3. If the failure does not reproduce and the update changed the head, the printed push step pushes it (`gh stack push` on a native stack). Never run a printed `requeue:` or `acknowledge queue removal:` command after a push. Shepherd prints a fresh queue command once the new head is READY.
|
|
8
8
|
4. If the failure comes from the base itself, do not requeue or acknowledge it. Make no change. The unchanged failure escalates through the stall timeout.
|
package/pr-shepherd.schema.json
CHANGED
|
@@ -331,6 +331,19 @@
|
|
|
331
331
|
},
|
|
332
332
|
"additionalProperties": false
|
|
333
333
|
},
|
|
334
|
+
"merge-queue": {
|
|
335
|
+
"default": {},
|
|
336
|
+
"type": "object",
|
|
337
|
+
"properties": {
|
|
338
|
+
"compare-window-hours": {
|
|
339
|
+
"default": 6,
|
|
340
|
+
"type": "number",
|
|
341
|
+
"minimum": 0,
|
|
342
|
+
"maximum": 720
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
"additionalProperties": false
|
|
346
|
+
},
|
|
334
347
|
"actions": {
|
|
335
348
|
"default": {},
|
|
336
349
|
"type": "object",
|