pr-shepherd 2.2.17 → 2.3.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 +4 -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/check-annotations.d.mts +2 -0
- package/bin/commands/check-annotations.mjs +22 -7
- package/bin/commands/check-unread-readiness.d.mts +6 -0
- package/bin/commands/check-unread-readiness.mjs +7 -0
- package/bin/commands/check.mjs +5 -0
- 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/config/schema.d.mts +6 -0
- package/bin/config/schema.mjs +3 -0
- package/bin/github/batch-page-helpers.d.mts +3 -0
- package/bin/github/batch-page-helpers.mjs +5 -2
- package/bin/github/batch-page.mjs +2 -4
- package/bin/github/batch-parser-helpers.mjs +2 -0
- package/bin/github/batch-parsers.mjs +3 -3
- package/bin/github/batch-raw-types.d.mts +4 -2
- package/bin/github/batch-receipt-evidence.mjs +1 -0
- package/bin/github/batch-response.d.mts +2 -1
- package/bin/github/batch-response.mjs +8 -11
- package/bin/github/batch.mjs +8 -3
- package/bin/github/check-annotation-pages.d.mts +10 -1
- package/bin/github/check-annotation-pages.mjs +26 -2
- package/bin/github/gql/default-branch-workflow-runs.gql +71 -0
- package/bin/github/merge-queue-checks.mjs +8 -4
- package/bin/github/null-nodes.d.mts +19 -0
- package/bin/github/null-nodes.mjs +68 -0
- package/bin/github/poll-summary-annotation-probe.mjs +3 -1
- package/bin/github/poll-summary-check-hydration.mjs +8 -5
- package/bin/github/poll-summary-checks.mjs +2 -0
- package/bin/github/poll-summary-fingerprint.mjs +2 -0
- package/bin/github/poll-summary-raw.d.mts +2 -0
- package/bin/github/poll-summary-readiness.mjs +2 -0
- package/bin/github/poll-summary-review.mjs +2 -1
- package/bin/github/queries.d.mts +2 -0
- package/bin/github/queries.mjs +2 -0
- package/bin/github/stack-handoff-page.mjs +2 -2
- package/bin/github/stack-read.mjs +1 -1
- package/bin/github/thread-comments.d.mts +6 -2
- package/bin/github/thread-comments.mjs +12 -1
- 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/types/github.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
- package/bin/github/check-suite-nodes.d.mts +0 -17
- package/bin/github/check-suite-nodes.mjs +0 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { graphqlWithRateLimit } from "./client.mjs";
|
|
2
2
|
import { GitHubRequestError } from "./errors.mjs";
|
|
3
3
|
import { BATCH_PR_PAGE_DATA_QUERY, BATCH_PR_PAGE_QUERY } from "./queries.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { contextNodes } from "./batch-response.mjs";
|
|
5
5
|
import { applyIncludedPage, backwardCursor, forwardCursor, } from "./batch-page-helpers.mjs";
|
|
6
6
|
/**
|
|
7
7
|
* Fetch remaining connection pages with a slim `@include` query. Independent
|
|
@@ -14,9 +14,7 @@ export async function paginateBatchConnections(pr, repo, raw, opts, initialRateL
|
|
|
14
14
|
changesRequested: [...raw.changesRequestedReviews.nodes],
|
|
15
15
|
reviewSummaries: [...raw.reviewSummaries.nodes],
|
|
16
16
|
approvedReviews: [...raw.approvedReviews.nodes],
|
|
17
|
-
checks: [
|
|
18
|
-
...requireContextNodes(raw.commits.nodes[0]?.commit.statusCheckRollup?.contexts.nodes ?? []),
|
|
19
|
-
],
|
|
17
|
+
checks: [...contextNodes(raw.commits.nodes[0]?.commit.statusCheckRollup?.contexts.nodes ?? [])],
|
|
20
18
|
};
|
|
21
19
|
const firstOid = raw.commits.nodes[0]?.commit.oid;
|
|
22
20
|
let cursors = {
|
|
@@ -79,6 +79,8 @@ function inlineAnnotationsField(checkRunId, annotations) {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function fullRawAnnotation(node) {
|
|
82
|
+
if (node == null)
|
|
83
|
+
return null;
|
|
82
84
|
if (typeof node.path !== "string" || typeof node.annotationLevel !== "string")
|
|
83
85
|
return null;
|
|
84
86
|
if (node.location === undefined || node.fullDatabaseId === undefined)
|
|
@@ -2,7 +2,7 @@ import { mapAuthorType, parseCreatedAt, latestApprovedLogins, isReviewStale, } f
|
|
|
2
2
|
import { parseCheckNodes } from "./batch-parse-checks.mjs";
|
|
3
3
|
import { headFreshAtUnix } from "./head-freshness.mjs";
|
|
4
4
|
import { headPushUnixFromCheckNodes } from "./queue-removal-freshness.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { contextNodes } from "./batch-response.mjs";
|
|
6
6
|
import { buildPrActivitySummary } from "./activity.mjs";
|
|
7
7
|
import { parseBranchProtection } from "./branch-protection.mjs";
|
|
8
8
|
import { readAllowedMergeMethods } from "../config/merge-method.mjs";
|
|
@@ -111,7 +111,7 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
|
|
|
111
111
|
const queueHead = raw.mergeQueueEntry?.headCommit;
|
|
112
112
|
const removedQueueHead = raw.mergeQueueRemovals?.nodes[0]?.beforeCommit;
|
|
113
113
|
const mergeQueueChecks = parseCheckNodes(queueHead?.statusCheckRollup
|
|
114
|
-
?
|
|
114
|
+
? contextNodes(queueHead.statusCheckRollup.contexts.nodes)
|
|
115
115
|
: undefined, queueHead?.oid);
|
|
116
116
|
const headPushedAtUnix = headPushUnixFromCheckNodes(rawCheckNodes);
|
|
117
117
|
const headForcePushedAt = raw.headRefForcePushes?.nodes[0]?.createdAt;
|
|
@@ -122,7 +122,7 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
|
|
|
122
122
|
committedAt: raw.commits.nodes[0]?.commit.committedDate,
|
|
123
123
|
});
|
|
124
124
|
const removedMergeQueueChecks = parseCheckNodes(removedQueueHead?.statusCheckRollup
|
|
125
|
-
?
|
|
125
|
+
? contextNodes(removedQueueHead.statusCheckRollup.contexts.nodes)
|
|
126
126
|
: undefined, removedQueueHead?.oid);
|
|
127
127
|
const allowedMergeMethods = readAllowedMergeMethods(repository);
|
|
128
128
|
return {
|
|
@@ -16,6 +16,8 @@ export interface RawBatchResponse {
|
|
|
16
16
|
} | null;
|
|
17
17
|
}
|
|
18
18
|
export interface RawPr extends RawPrMergeFields {
|
|
19
|
+
/** Set when GitHub returned null connection nodes (dropped); see `null-nodes.mts`. */
|
|
20
|
+
unreadNodes?: import("./null-nodes.mts").UnreadNodes;
|
|
19
21
|
id: string;
|
|
20
22
|
number: number;
|
|
21
23
|
createdAt?: string;
|
|
@@ -245,9 +247,9 @@ export type RawContextNode = {
|
|
|
245
247
|
summary: string | null;
|
|
246
248
|
annotations?: {
|
|
247
249
|
totalCount?: number;
|
|
248
|
-
nodes: Array<Partial<RawCheckAnnotation> & {
|
|
250
|
+
nodes: Array<(Partial<RawCheckAnnotation> & {
|
|
249
251
|
message: string;
|
|
250
|
-
}>;
|
|
252
|
+
}) | null>;
|
|
251
253
|
};
|
|
252
254
|
checkSuite: {
|
|
253
255
|
status?: string | null;
|
|
@@ -3,6 +3,7 @@ import { markReadyAnnotationProbeComplete } from "./poll-summary-annotation-prob
|
|
|
3
3
|
/** Keep the exact PollSummaryPr shape used by v1 receipts; add only complete annotation totals. */
|
|
4
4
|
export async function prepareBatchReceiptEvidence(summary, batch, checks, repo) {
|
|
5
5
|
if (!summary ||
|
|
6
|
+
summary.unreadNodes ||
|
|
6
7
|
summary.number !== batch.number ||
|
|
7
8
|
summary.headRefOid !== batch.headRefOid ||
|
|
8
9
|
summary.baseRefOid !== batch.baseRefOid)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RepoInfo } from "./client.mts";
|
|
2
2
|
import type { RawBatchResponse, RawContextNode, RawPr } from "./batch-raw-types.mts";
|
|
3
3
|
export declare function requireRawPr(response: RawBatchResponse | null | undefined, pr: number, repo: RepoInfo): RawPr;
|
|
4
|
-
|
|
4
|
+
/** The context nodes of a page that `dropNullNodes` already cleaned. */
|
|
5
|
+
export declare function contextNodes(nodes: Array<RawContextNode | null>): RawContextNode[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EXIT, ShepherdError } from "../exit-codes.mjs";
|
|
2
2
|
import { GitHubRequestError } from "./errors.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { dropNullNodes } from "./null-nodes.mjs";
|
|
4
4
|
export function requireRawPr(response, pr, repo) {
|
|
5
5
|
if (!response?.repository) {
|
|
6
6
|
throw new GitHubRequestError(`GitHub GraphQL response did not include repository ${repo.owner}/${repo.name} (not found or access denied)`, { status: 200 });
|
|
@@ -9,16 +9,13 @@ export function requireRawPr(response, pr, repo) {
|
|
|
9
9
|
throw new ShepherdError(`PR #${pr} not found`, EXIT.UNAVAILABLE);
|
|
10
10
|
}
|
|
11
11
|
const raw = response.repository.pullRequest;
|
|
12
|
-
|
|
12
|
+
raw.unreadNodes = dropNullNodes(raw);
|
|
13
|
+
const receipt = response.repository.receiptSummary;
|
|
14
|
+
if (receipt)
|
|
15
|
+
receipt.unreadNodes = dropNullNodes(receipt);
|
|
13
16
|
return raw;
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// A null context node is an unexpected/malformed shape, not a precondition or
|
|
19
|
-
// permission problem — force EX_SOFTWARE rather than falling through to the
|
|
20
|
-
// (200-status-derived) EX_UNAVAILABLE default.
|
|
21
|
-
throw new GitHubRequestError(`Malformed GitHub GraphQL response: null check context at repository.pullRequest.commits.nodes.0.commit.statusCheckRollup.contexts.nodes.${nullIndex}`, { status: 200, exitCodeOverride: EXIT.SOFTWARE });
|
|
22
|
-
}
|
|
23
|
-
return nodes;
|
|
18
|
+
/** The context nodes of a page that `dropNullNodes` already cleaned. */
|
|
19
|
+
export function contextNodes(nodes) {
|
|
20
|
+
return nodes.filter((node) => node !== null);
|
|
24
21
|
}
|
package/bin/github/batch.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import { hydrateMergeQueueChecks } from "./merge-queue-checks.mjs";
|
|
|
15
15
|
import { fingerprintFromRaw } from "./fingerprint.mjs";
|
|
16
16
|
import { stackEvidenceFromRaw } from "./batch-stack-evidence.mjs";
|
|
17
17
|
import { takeStackHandoff } from "./stack-handoff.mjs";
|
|
18
|
+
import { mergeUnread } from "./null-nodes.mjs";
|
|
18
19
|
/**
|
|
19
20
|
* Fetch all PR data needed for a `shepherd check` in one (or a few, if paginating) GraphQL requests.
|
|
20
21
|
*/
|
|
@@ -29,7 +30,8 @@ async function fetchGraphqlPrBatch(pr, repo, opts = {}, reuse) {
|
|
|
29
30
|
// place of the viewer login: another token never matches a stored one.
|
|
30
31
|
const fingerprint = fingerprintFromRaw(raw, result.data.repository?.viewerPermission ?? null, result.data.viewer?.login ?? (split ? `token:${(await makeAuthHeaders()).fingerprint}` : null));
|
|
31
32
|
// Decide reuse from the first page alone, before any supplement is paid for.
|
|
32
|
-
|
|
33
|
+
// A page with an unreadable node cannot vouch for a stored report.
|
|
34
|
+
const reused = reuse && !raw.unreadNodes && (await reuse(fingerprint));
|
|
33
35
|
const baseTipOid = raw.baseRef?.target?.oid;
|
|
34
36
|
// A split read has no viewer fields yet, so a reused tick carries only the trunk rules.
|
|
35
37
|
let stackEvidence = stackEvidenceFromRaw(raw, result.data, split);
|
|
@@ -49,7 +51,7 @@ async function fetchGraphqlPrBatch(pr, repo, opts = {}, reuse) {
|
|
|
49
51
|
stackEvidence = stackEvidenceFromRaw(raw, { viewer, repository: viewer.repository });
|
|
50
52
|
}
|
|
51
53
|
let receiptSummary = null;
|
|
52
|
-
if (opts.includeReceiptSummary) {
|
|
54
|
+
if (opts.includeReceiptSummary && !raw.unreadNodes) {
|
|
53
55
|
try {
|
|
54
56
|
receiptSummary = await prepareBatchReceiptEvidence(result.data.repository?.receiptSummary, raw, paged.checks, repo);
|
|
55
57
|
}
|
|
@@ -63,14 +65,17 @@ async function fetchGraphqlPrBatch(pr, repo, opts = {}, reuse) {
|
|
|
63
65
|
if (numericId)
|
|
64
66
|
await recordThreadIdentity(repo, pr, thread.id, numericId);
|
|
65
67
|
}
|
|
68
|
+
const unreadNodes = mergeUnread(raw.unreadNodes, paged.unreadNodes, threadPages.unreadNodes);
|
|
66
69
|
const data = parseRawPr(raw, threadPages.threads, paged.comments, paged.changesRequested, paged.reviewSummaries, paged.approvedReviews, paged.checks, viewer ? { ...result.data.repository, ...viewer.repository } : result.data.repository);
|
|
67
70
|
const viewerLogin = viewer ? viewer.login : result.data.viewer?.login;
|
|
68
71
|
if (viewerLogin)
|
|
69
72
|
data.viewerLogin = viewerLogin;
|
|
73
|
+
if (unreadNodes)
|
|
74
|
+
data.unreadNodes = unreadNodes;
|
|
70
75
|
data.checks = mergeStartupFailureChecks(data.checks, parseSuiteStartupFailures(raw));
|
|
71
76
|
return {
|
|
72
77
|
data,
|
|
73
|
-
fingerprint,
|
|
78
|
+
...(!unreadNodes && { fingerprint }),
|
|
74
79
|
// A split read's other samples are the app's buckets; only the viewer read is the user's.
|
|
75
80
|
rateLimit: viewer
|
|
76
81
|
? viewer.rateLimit
|
|
@@ -5,7 +5,16 @@ export interface AnnotationPage {
|
|
|
5
5
|
hasNextPage: boolean;
|
|
6
6
|
endCursor: string | null;
|
|
7
7
|
};
|
|
8
|
-
nodes: RawCheckAnnotation
|
|
8
|
+
nodes: Array<RawCheckAnnotation | null>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A fetched page held a null annotation entry. `readable` is every annotation that was read, so a
|
|
12
|
+
* caller can still surface them while treating the run as unread (never cached, READY held).
|
|
13
|
+
*/
|
|
14
|
+
export declare class NullAnnotationNodeError extends Error {
|
|
15
|
+
readonly checkRunId: string;
|
|
16
|
+
readonly readable: CheckAnnotation[];
|
|
17
|
+
constructor(checkRunId: string, readable: CheckAnnotation[]);
|
|
9
18
|
}
|
|
10
19
|
/** Pages a single check run. `firstPage` skips the initial `node(id:)` request. */
|
|
11
20
|
export declare function collectAnnotations(checkRunId: string, firstPage?: AnnotationPage): Promise<CheckAnnotation[]>;
|
|
@@ -3,16 +3,37 @@ import { toCheckAnnotation } from "./check-annotation-shape.mjs";
|
|
|
3
3
|
import { CHECK_RUN_ANNOTATIONS_QUERY } from "./queries.mjs";
|
|
4
4
|
const ANNOTATIONS_PER_PAGE = 100;
|
|
5
5
|
const MAX_ANNOTATION_PAGES = 10;
|
|
6
|
+
/**
|
|
7
|
+
* A fetched page held a null annotation entry. `readable` is every annotation that was read, so a
|
|
8
|
+
* caller can still surface them while treating the run as unread (never cached, READY held).
|
|
9
|
+
*/
|
|
10
|
+
export class NullAnnotationNodeError extends Error {
|
|
11
|
+
checkRunId;
|
|
12
|
+
readable;
|
|
13
|
+
constructor(checkRunId, readable) {
|
|
14
|
+
super(`check run ${checkRunId} annotation page contains a null node`);
|
|
15
|
+
this.checkRunId = checkRunId;
|
|
16
|
+
this.readable = readable;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
6
19
|
/** Pages a single check run. `firstPage` skips the initial `node(id:)` request. */
|
|
7
20
|
export async function collectAnnotations(checkRunId, firstPage) {
|
|
8
21
|
const nodes = [];
|
|
22
|
+
let sawNull = false;
|
|
9
23
|
let cursor = null;
|
|
10
24
|
let seeded = firstPage;
|
|
11
25
|
for (let pageNumber = 1; pageNumber <= MAX_ANNOTATION_PAGES; pageNumber++) {
|
|
12
26
|
// eslint-disable-next-line no-await-in-loop
|
|
13
27
|
const current = seeded ?? (await fetchAnnotationPage(checkRunId, cursor));
|
|
14
28
|
seeded = undefined;
|
|
15
|
-
|
|
29
|
+
// A null entry is an annotation GitHub has not served yet. Keep reading, then fail with the
|
|
30
|
+
// readable entries so the caller holds READY and rereads next tick (never caches the run).
|
|
31
|
+
for (const node of current.nodes) {
|
|
32
|
+
if (node == null)
|
|
33
|
+
sawNull = true;
|
|
34
|
+
else
|
|
35
|
+
nodes.push(node);
|
|
36
|
+
}
|
|
16
37
|
if (!current.pageInfo.hasNextPage || !current.pageInfo.endCursor)
|
|
17
38
|
break;
|
|
18
39
|
if (pageNumber === MAX_ANNOTATION_PAGES) {
|
|
@@ -21,7 +42,10 @@ export async function collectAnnotations(checkRunId, firstPage) {
|
|
|
21
42
|
}
|
|
22
43
|
cursor = current.pageInfo.endCursor;
|
|
23
44
|
}
|
|
24
|
-
|
|
45
|
+
const annotations = nodes.map((node) => toCheckAnnotation(checkRunId, node));
|
|
46
|
+
if (sawNull)
|
|
47
|
+
throw new NullAnnotationNodeError(checkRunId, annotations);
|
|
48
|
+
return annotations;
|
|
25
49
|
}
|
|
26
50
|
async function fetchAnnotationPage(checkRunId, cursor) {
|
|
27
51
|
const res = await graphql(CHECK_RUN_ANNOTATIONS_QUERY, {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
query DefaultBranchWorkflowRuns($owner: String!, $repo: String!) {
|
|
2
|
+
_shepherdRateLimit: rateLimit {
|
|
3
|
+
cost
|
|
4
|
+
limit
|
|
5
|
+
nodeCount
|
|
6
|
+
remaining
|
|
7
|
+
resetAt
|
|
8
|
+
used
|
|
9
|
+
}
|
|
10
|
+
repository(owner: $owner, name: $repo) {
|
|
11
|
+
defaultBranchRef {
|
|
12
|
+
name
|
|
13
|
+
target {
|
|
14
|
+
... on Commit {
|
|
15
|
+
history(first: 20) {
|
|
16
|
+
pageInfo {
|
|
17
|
+
hasNextPage
|
|
18
|
+
}
|
|
19
|
+
nodes {
|
|
20
|
+
oid
|
|
21
|
+
committedDate
|
|
22
|
+
checkSuites(first: 20) {
|
|
23
|
+
pageInfo {
|
|
24
|
+
hasNextPage
|
|
25
|
+
}
|
|
26
|
+
nodes {
|
|
27
|
+
status
|
|
28
|
+
conclusion
|
|
29
|
+
updatedAt
|
|
30
|
+
branch {
|
|
31
|
+
name
|
|
32
|
+
}
|
|
33
|
+
workflowRun {
|
|
34
|
+
databaseId
|
|
35
|
+
event
|
|
36
|
+
updatedAt
|
|
37
|
+
file {
|
|
38
|
+
path
|
|
39
|
+
}
|
|
40
|
+
workflow {
|
|
41
|
+
databaseId
|
|
42
|
+
name
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
checkRuns(first: 15, filterBy: { conclusions: [FAILURE, TIMED_OUT] }) {
|
|
46
|
+
nodes {
|
|
47
|
+
name
|
|
48
|
+
conclusion
|
|
49
|
+
annotations(first: 3) {
|
|
50
|
+
totalCount
|
|
51
|
+
nodes {
|
|
52
|
+
path
|
|
53
|
+
location {
|
|
54
|
+
start {
|
|
55
|
+
line
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
message
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -2,7 +2,8 @@ import { parseCreatedAt } from "./batch-parser-helpers.mjs";
|
|
|
2
2
|
import { graphqlWithRateLimit } from "./client.mjs";
|
|
3
3
|
import { GitHubRequestError } from "./errors.mjs";
|
|
4
4
|
import { forcePushUnix, headPushUnixFromCheckNodes, queueRemovalAppliesToHead, } from "./queue-removal-freshness.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { contextNodes } from "./batch-response.mjs";
|
|
6
|
+
import { dropNullNodes, mergeUnread } from "./null-nodes.mjs";
|
|
6
7
|
import { COMMIT_CHECK_CONTEXTS_QUERY } from "./queries.mjs";
|
|
7
8
|
function omittedCursorError(oid) {
|
|
8
9
|
return new Error(`Merge queue check pagination interrupted: GitHub omitted the next cursor for ${oid}. Retry.`);
|
|
@@ -39,11 +40,13 @@ async function fetchQueuePage(oid, repo, cursor, gate) {
|
|
|
39
40
|
return null;
|
|
40
41
|
throw new Error(`Merge queue check pagination interrupted: commit ${oid} disappeared or changed. Retry.`);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
const contexts = object.statusCheckRollup?.contexts;
|
|
44
|
+
gate.unreadNodes = mergeUnread(gate.unreadNodes, dropNullNodes({ contexts }));
|
|
45
|
+
return contexts ?? null;
|
|
43
46
|
}
|
|
44
47
|
async function hydrateCommitContexts(commit, repo, gate) {
|
|
45
48
|
const existing = commit.statusCheckRollup?.contexts;
|
|
46
|
-
const nodes = existing ? [...
|
|
49
|
+
const nodes = existing ? [...contextNodes(existing.nodes)] : [];
|
|
47
50
|
let cursor = initialQueueCursor(existing, commit.oid);
|
|
48
51
|
while (cursor !== undefined) {
|
|
49
52
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -55,7 +58,7 @@ async function hydrateCommitContexts(commit, repo, gate) {
|
|
|
55
58
|
}
|
|
56
59
|
throw new Error(`Merge queue check pagination interrupted: statusCheckRollup disappeared for ${commit.oid}. Retry.`);
|
|
57
60
|
}
|
|
58
|
-
nodes.push(...
|
|
61
|
+
nodes.push(...contextNodes(next.nodes));
|
|
59
62
|
cursor = nextPageCursor(next, commit.oid);
|
|
60
63
|
}
|
|
61
64
|
commit.statusCheckRollup = {
|
|
@@ -95,5 +98,6 @@ export async function hydrateMergeQueueChecks(raw, repo, initialRateLimit) {
|
|
|
95
98
|
await hydrateCommitContexts(active, repo, gate);
|
|
96
99
|
if (removed && removed.oid !== active?.oid)
|
|
97
100
|
await hydrateCommitContexts(removed, repo, gate);
|
|
101
|
+
raw.unreadNodes = mergeUnread(raw.unreadNodes, gate.unreadNodes);
|
|
98
102
|
return gate.rateLimit;
|
|
99
103
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a read could not see because GitHub returned `null` in place of a connection node
|
|
3
|
+
* (seen right after a push, with no GraphQL error). Internal only: it gates readiness and
|
|
4
|
+
* reuse and is never printed.
|
|
5
|
+
*/
|
|
6
|
+
export interface UnreadNodes {
|
|
7
|
+
/** A check context, commit or queue entry was unreadable: CI state is not fully known. */
|
|
8
|
+
checks?: true;
|
|
9
|
+
/** A review thread, comment, review or rule was unreadable: feedback is not fully known. */
|
|
10
|
+
feedback?: true;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Remove `null` from every connection under `root`, in place, so no later reader dereferences
|
|
14
|
+
* one. Returns what was unreadable, or undefined when nothing was. Never use this on a root
|
|
15
|
+
* `nodes(ids: ...)` lookup, where null is the meaningful "not found" answer.
|
|
16
|
+
*/
|
|
17
|
+
export declare function dropNullNodes(root: object | null | undefined): UnreadNodes | undefined;
|
|
18
|
+
/** The union of several reads' unreadable parts. */
|
|
19
|
+
export declare function mergeUnread(...parts: Array<UnreadNodes | undefined>): UnreadNodes | undefined;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Connections whose nodes only describe history; a null there changes no decision. */
|
|
2
|
+
const INFORMATIONAL = new Set([
|
|
3
|
+
"parents",
|
|
4
|
+
"mergeQueueRemovalTimes",
|
|
5
|
+
"headRefForcePushes",
|
|
6
|
+
"prCommitOids",
|
|
7
|
+
]);
|
|
8
|
+
/** Keys that put the connections under them on the CI side of the split. */
|
|
9
|
+
const CHECK_KEYS = new Set(["commits", "statusCheckRollup", "contexts", "checkSuites"]);
|
|
10
|
+
function hasNullComment(thread) {
|
|
11
|
+
const comments = thread.comments?.nodes;
|
|
12
|
+
return comments?.includes(null) === true;
|
|
13
|
+
}
|
|
14
|
+
function tidyConnection(connection, key, inChecks, found) {
|
|
15
|
+
let kept = connection.nodes.filter((node) => node !== null);
|
|
16
|
+
// A thread missing one comment would hash a partial transcript and could point replies at the
|
|
17
|
+
// wrong root, so the whole thread counts as unread.
|
|
18
|
+
if (key === "reviewThreads")
|
|
19
|
+
kept = kept.filter((thread) => !hasNullComment(thread));
|
|
20
|
+
if (kept.length === connection.nodes.length)
|
|
21
|
+
return;
|
|
22
|
+
connection.nodes = kept;
|
|
23
|
+
// Consumers already treat an unread suite page as unverified.
|
|
24
|
+
if (key === "checkSuites")
|
|
25
|
+
connection.pageInfo = { ...connection.pageInfo, hasNextPage: true };
|
|
26
|
+
if (!INFORMATIONAL.has(key))
|
|
27
|
+
found[inChecks ? "checks" : "feedback"] = true;
|
|
28
|
+
}
|
|
29
|
+
function visit(value, key, inChecks, found) {
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
for (const item of value)
|
|
32
|
+
visit(item, key, inChecks, found);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Inline annotation nulls mean "read the annotations separately" and are handled there.
|
|
36
|
+
if (typeof value !== "object" || value === null || key === "annotations")
|
|
37
|
+
return;
|
|
38
|
+
const record = value;
|
|
39
|
+
const checks = inChecks || CHECK_KEYS.has(key);
|
|
40
|
+
if (Array.isArray(record["nodes"])) {
|
|
41
|
+
tidyConnection(record, key, checks, found);
|
|
42
|
+
}
|
|
43
|
+
for (const [child, node] of Object.entries(record))
|
|
44
|
+
visit(node, child, checks, found);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Remove `null` from every connection under `root`, in place, so no later reader dereferences
|
|
48
|
+
* one. Returns what was unreadable, or undefined when nothing was. Never use this on a root
|
|
49
|
+
* `nodes(ids: ...)` lookup, where null is the meaningful "not found" answer.
|
|
50
|
+
*/
|
|
51
|
+
export function dropNullNodes(root) {
|
|
52
|
+
if (!root)
|
|
53
|
+
return undefined;
|
|
54
|
+
const found = {};
|
|
55
|
+
visit(root, "", false, found);
|
|
56
|
+
return found.checks || found.feedback ? found : undefined;
|
|
57
|
+
}
|
|
58
|
+
/** The union of several reads' unreadable parts. */
|
|
59
|
+
export function mergeUnread(...parts) {
|
|
60
|
+
const merged = {};
|
|
61
|
+
for (const part of parts) {
|
|
62
|
+
if (part?.checks)
|
|
63
|
+
merged.checks = true;
|
|
64
|
+
if (part?.feedback)
|
|
65
|
+
merged.feedback = true;
|
|
66
|
+
}
|
|
67
|
+
return merged.checks || merged.feedback ? merged : undefined;
|
|
68
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dropNullNodes } from "./null-nodes.mjs";
|
|
1
2
|
import { githubOperation } from "./transport.mjs";
|
|
2
3
|
import { readRestAnnotationCounts } from "./rest-check-read.mjs";
|
|
3
4
|
import { graphqlWithRateLimit } from "./client.mjs";
|
|
@@ -79,7 +80,8 @@ async function collectProbePages(oid, repo) {
|
|
|
79
80
|
const seen = new Set();
|
|
80
81
|
for (;;) {
|
|
81
82
|
const contexts = await fetchProbePage(oid, repo, before);
|
|
82
|
-
|
|
83
|
+
// An unreadable context leaves its annotation total unknown: no total is trustworthy.
|
|
84
|
+
if (!contexts || dropNullNodes({ contexts }))
|
|
83
85
|
return null;
|
|
84
86
|
pages.push(...contexts.nodes);
|
|
85
87
|
const pageInfo = contexts.pageInfo;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { githubOperation } from "./transport.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { dropNullNodes, mergeUnread } from "./null-nodes.mjs";
|
|
3
3
|
import { readRestCommitChecks } from "./rest-check-read.mjs";
|
|
4
4
|
import { graphqlWithRateLimit } from "./client.mjs";
|
|
5
5
|
import { POLL_SUMMARY_CHECK_PAGE_QUERY } from "./queries.mjs";
|
|
@@ -14,14 +14,16 @@ import { POLL_SUMMARY_CHECK_PAGE_QUERY } from "./queries.mjs";
|
|
|
14
14
|
*/
|
|
15
15
|
export async function hydratePollSummaryChecks(raw, repo) {
|
|
16
16
|
const headCommit = raw.commits.nodes[0]?.commit;
|
|
17
|
-
|
|
17
|
+
raw.unreadNodes = mergeUnread(raw.unreadNodes, dropNullNodes(raw));
|
|
18
|
+
const pages = {};
|
|
18
19
|
if (headCommit)
|
|
19
|
-
await hydrateCommitContexts(headCommit, repo);
|
|
20
|
+
await hydrateCommitContexts(headCommit, repo, pages);
|
|
20
21
|
const queueCommit = raw.mergeQueueEntry?.headCommit;
|
|
21
22
|
if (queueCommit)
|
|
22
|
-
await hydrateCommitContexts(queueCommit, repo);
|
|
23
|
+
await hydrateCommitContexts(queueCommit, repo, pages);
|
|
24
|
+
raw.unreadNodes = mergeUnread(raw.unreadNodes, pages.unreadNodes);
|
|
23
25
|
}
|
|
24
|
-
async function hydrateCommitContexts(commit, repo) {
|
|
26
|
+
async function hydrateCommitContexts(commit, repo, pages) {
|
|
25
27
|
const contexts = commit.statusCheckRollup?.contexts;
|
|
26
28
|
if (!contexts)
|
|
27
29
|
return;
|
|
@@ -31,6 +33,7 @@ async function hydrateCommitContexts(commit, repo) {
|
|
|
31
33
|
const older = await fetchOlderContexts(commit.oid, pageInfo.startCursor, repo);
|
|
32
34
|
if (!older)
|
|
33
35
|
break;
|
|
36
|
+
pages.unreadNodes = mergeUnread(pages.unreadNodes, dropNullNodes({ contexts: older }));
|
|
34
37
|
if (older.fullSnapshot)
|
|
35
38
|
nodes.splice(0, nodes.length, ...older.nodes);
|
|
36
39
|
else
|
|
@@ -18,6 +18,8 @@ export function summarizePollSummaryChecks(raw, requiredContexts) {
|
|
|
18
18
|
counts[key] = (counts[key] ?? 0) + 1;
|
|
19
19
|
}
|
|
20
20
|
const summary = counts;
|
|
21
|
+
if (raw.unreadNodes?.checks)
|
|
22
|
+
summary.incomplete = true;
|
|
21
23
|
if (rollups.some(({ rollup }) => rollup.contexts.pageInfo.hasPreviousPage)) {
|
|
22
24
|
summary.incomplete = true;
|
|
23
25
|
}
|
|
@@ -14,6 +14,8 @@ import { withoutHandoffFields } from "./poll-summary-handoff-fields.mjs";
|
|
|
14
14
|
* to post-rule state unless the one-PR check hashes the same projection.
|
|
15
15
|
*/
|
|
16
16
|
export function fingerprintRawSummaryPr(summary) {
|
|
17
|
+
if (summary.unreadNodes)
|
|
18
|
+
return null;
|
|
17
19
|
const raw = withoutHandoffFields(summary);
|
|
18
20
|
if (!raw.updatedAt || !raw.headRefOid || !raw.baseRefOid)
|
|
19
21
|
return null;
|
|
@@ -112,6 +112,8 @@ export interface RawSummaryCommit {
|
|
|
112
112
|
} | null;
|
|
113
113
|
}
|
|
114
114
|
export interface RawSummaryPr {
|
|
115
|
+
/** Set when GitHub returned null connection nodes (dropped); see `null-nodes.mts`. */
|
|
116
|
+
unreadNodes?: import("./null-nodes.mts").UnreadNodes;
|
|
115
117
|
transport?: "rest";
|
|
116
118
|
transportUnavailable?: Array<{
|
|
117
119
|
field: string;
|
|
@@ -28,6 +28,8 @@ export function isCurrentSummaryReady(raw, checks, review, options = {}) {
|
|
|
28
28
|
return (isKnownMergeStateStatus(raw.mergeStateStatus) &&
|
|
29
29
|
transportReadinessGaps(raw, raw.mergeStateStatus, requiresConversationResolution).length ===
|
|
30
30
|
0 &&
|
|
31
|
+
// A null review node is unknown, never settled by CLEAN or branch rules: reread next tick.
|
|
32
|
+
raw.unreadNodes?.feedback !== true &&
|
|
31
33
|
checks.incomplete !== true &&
|
|
32
34
|
sourceChecks.incomplete !== true &&
|
|
33
35
|
(review.incomplete !== true ||
|
|
@@ -23,7 +23,8 @@ export async function evaluatePollSummaryReview(raw, seen, viewerCanAdminister,
|
|
|
23
23
|
const bots = normalizeBotUsernames(config["bot-usernames"]);
|
|
24
24
|
const rules = await loadClassifyRules(getEffectiveCwd(), config.standardRules);
|
|
25
25
|
let actionable = 0;
|
|
26
|
-
let incomplete = raw.
|
|
26
|
+
let incomplete = raw.unreadNodes?.feedback === true ||
|
|
27
|
+
raw.comments.pageInfo.hasPreviousPage ||
|
|
27
28
|
raw.reviews.pageInfo.hasPreviousPage ||
|
|
28
29
|
raw.reviewThreads.pageInfo.hasPreviousPage;
|
|
29
30
|
// A pre-minimized comment is a first-look acknowledgement, never readiness work.
|
package/bin/github/queries.d.mts
CHANGED
|
@@ -80,3 +80,5 @@ export declare const GET_PR_BODY_QUERY: string;
|
|
|
80
80
|
export declare const UPDATE_PR_BODY_MUTATION: string;
|
|
81
81
|
/** CheckRun titles, summaries, and first annotations for routed stack-layer handoffs. */
|
|
82
82
|
export declare const STACK_HANDOFF_CHECK_RUNS_QUERY: string;
|
|
83
|
+
/** Recent default-branch commits and workflow check suites for merge-queue ejection comparison. */
|
|
84
|
+
export declare const DEFAULT_BRANCH_WORKFLOW_RUNS_QUERY: string;
|
package/bin/github/queries.mjs
CHANGED
|
@@ -86,3 +86,5 @@ export const GET_PR_BODY_QUERY = gql("get-pr-body.gql");
|
|
|
86
86
|
export const UPDATE_PR_BODY_MUTATION = gql("update-pr-body.gql");
|
|
87
87
|
/** CheckRun titles, summaries, and first annotations for routed stack-layer handoffs. */
|
|
88
88
|
export const STACK_HANDOFF_CHECK_RUNS_QUERY = gql("stack-handoff-check-runs.gql");
|
|
89
|
+
/** Recent default-branch commits and workflow check suites for merge-queue ejection comparison. */
|
|
90
|
+
export const DEFAULT_BRANCH_WORKFLOW_RUNS_QUERY = gql("default-branch-workflow-runs.gql");
|
|
@@ -19,6 +19,8 @@ function reviewsIn(layer, state) {
|
|
|
19
19
|
/** True when every window `BatchPr`'s first page reads is complete in this summary. */
|
|
20
20
|
export function summaryComplete(layer, source) {
|
|
21
21
|
const { read } = source;
|
|
22
|
+
if (layer.unreadNodes)
|
|
23
|
+
return false;
|
|
22
24
|
if (!read.stack || read.viewerPermission === undefined || !read.mergeSettings)
|
|
23
25
|
return false;
|
|
24
26
|
if (source.layers.length > MAX_STACK_ENTRIES || !layer.stack || !layer.stackEntry)
|
|
@@ -42,8 +44,6 @@ export function summaryComplete(layer, source) {
|
|
|
42
44
|
const commit = headCommit(layer);
|
|
43
45
|
if (!commit || commit.oid !== layer.headRefOid || !commit.checkSuites?.pageInfo)
|
|
44
46
|
return false;
|
|
45
|
-
if (commit.checkSuites.nodes.includes(null))
|
|
46
|
-
return false;
|
|
47
47
|
const contexts = commit.statusCheckRollup?.contexts;
|
|
48
48
|
if (contexts &&
|
|
49
49
|
(contexts.pageInfo.hasPreviousPage ||
|
|
@@ -51,7 +51,7 @@ pageCeiling) {
|
|
|
51
51
|
stackNumber = stack.number;
|
|
52
52
|
stackSize = stack.size;
|
|
53
53
|
for (const entry of stack.entries.nodes) {
|
|
54
|
-
if (!entry
|
|
54
|
+
if (!entry?.pullRequest) {
|
|
55
55
|
throw new ShepherdError("GitHub returned an incomplete pull-request stack entry", EXIT.TEMPFAIL);
|
|
56
56
|
}
|
|
57
57
|
entries.push({ position: entry.position, pullRequest: entry.pullRequest });
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type RateLimitInfo } from "./client.mts";
|
|
2
|
+
import { type UnreadNodes } from "./null-nodes.mts";
|
|
2
3
|
import type { RawThread } from "./batch-raw-types.mts";
|
|
3
|
-
export
|
|
4
|
+
export interface ThreadPages {
|
|
4
5
|
threads: RawThread[];
|
|
5
6
|
rateLimit?: RateLimitInfo;
|
|
6
|
-
|
|
7
|
+
/** Set when a thread was withheld because one of its comments came back null. */
|
|
8
|
+
unreadNodes?: UnreadNodes;
|
|
9
|
+
}
|
|
10
|
+
export declare function hydrateThreadCommentPages(threads: RawThread[], initialRateLimit?: RateLimitInfo, viewerFree?: boolean): Promise<ThreadPages>;
|
|
@@ -5,6 +5,7 @@ import { GitHubRequestError } from "./errors.mjs";
|
|
|
5
5
|
import { paginateForward } from "./pagination.mjs";
|
|
6
6
|
import { REVIEW_THREAD_COMMENTS_DATA_QUERY, REVIEW_THREAD_COMMENTS_QUERY } from "./queries.mjs";
|
|
7
7
|
import { mapPool } from "../util/pool.mjs";
|
|
8
|
+
import { dropNullNodes } from "./null-nodes.mjs";
|
|
8
9
|
const THREAD_COMMENT_PAGE_CONCURRENCY = 4;
|
|
9
10
|
async function hydrateGraphqlThreadCommentPages(threads, initialRateLimit, viewerFree = false) {
|
|
10
11
|
const gate = {
|
|
@@ -24,9 +25,16 @@ async function hydrateGraphqlThreadCommentPages(threads, initialRateLimit, viewe
|
|
|
24
25
|
});
|
|
25
26
|
if (gate.error !== undefined)
|
|
26
27
|
throw gate.error;
|
|
27
|
-
|
|
28
|
+
// A thread with an unreadable comment is withheld whole: a partial transcript is not its own.
|
|
29
|
+
const threadsRead = hydrated.filter((thread) => thread !== null);
|
|
30
|
+
return {
|
|
31
|
+
threads: threadsRead,
|
|
32
|
+
rateLimit: gate.rateLimit,
|
|
33
|
+
...(threadsRead.length < hydrated.length && { unreadNodes: { feedback: true } }),
|
|
34
|
+
};
|
|
28
35
|
}
|
|
29
36
|
async function hydrateThreadCommentPage(thread, gate, viewerFree) {
|
|
37
|
+
let unread = false;
|
|
30
38
|
const pageInfo = thread.comments.pageInfo;
|
|
31
39
|
if (!pageInfo?.hasNextPage || !pageInfo.endCursor)
|
|
32
40
|
return thread;
|
|
@@ -52,8 +60,11 @@ async function hydrateThreadCommentPage(thread, gate, viewerFree) {
|
|
|
52
60
|
const nodeType = node?.__typename ?? "null";
|
|
53
61
|
throw new Error(`Review thread ${thread.id} did not resolve to PullRequestReviewThread while paginating comments (node type: ${nodeType})`);
|
|
54
62
|
}
|
|
63
|
+
unread ||= dropNullNodes(node) !== undefined;
|
|
55
64
|
return node.comments;
|
|
56
65
|
}, pageInfo.endCursor);
|
|
66
|
+
if (unread)
|
|
67
|
+
return null;
|
|
57
68
|
return {
|
|
58
69
|
...thread,
|
|
59
70
|
comments: {
|