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
package/README.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Take pull requests from scratch to merge-ready with a coding agent, as a [Code Mode-style](https://code.claude.com/docs/en/code-mode) plugin. It works with Claude Code, Codex, and Grok.
|
|
4
4
|
|
|
5
|
+
A local CLI, harness-agnostic version of [PR Steward](https://code.claude.com/docs/en/pr-steward). See [comparisons](docs/comparison.md).
|
|
6
|
+
|
|
5
7
|
## Benefits
|
|
6
8
|
|
|
7
9
|
- **Better decisions:** across 71 PR states, it scores 0.95 with the plugin vs. 0.57 with `gh` + the GitHub MCP server ([outcome evals](evals/README.md), 2026-11-23).
|
|
8
10
|
- **Lower cost:** modeled cost per PR session is about 34% lower than `gh` and 75% lower than the GitHub MCP server, with 18% / 69% fewer turns ([token bench](evals/tokens/README.md); assumes a warm prompt cache).
|
|
9
11
|
- **More PRs on one GitHub quota:** 65% fewer GraphQL points than `gh` per PR session. While CI runs, a 5,000-point hourly budget covers about 80 waiting PRs, vs. about 13 with `gh pr checks --watch` ([GitHub API](docs/github-api.md), [GraphQL usage](docs/graphql-usage.md)). A [GitHub App](docs/github-app.md) and [webhook events](docs/hook-harness.md) cut it more.
|
|
10
|
-
- **
|
|
12
|
+
- **79 GitHub edge cases handled:** outdated or resolved threads are still shown once, edited comments come back, and conflicts that GraphQL reports as `CLEAN` are caught ([handled cases](docs/handled-cases.md)).
|
|
11
13
|
- **Tidy PRs, less context:** bot and outdated comments are triaged and resolved, human reviews get replies, and known bot noise is minimized and filtered out before it reaches the agent.
|
|
12
14
|
- **Review hygiene:** it never answers its own replies or minimizes human comments, skips a denied reply once, and hands a repeatedly rejected fix to a human ([comments and reviews](docs/handled-cases.md#comments-and-reviews)).
|
|
13
15
|
- **CI failures, pre-read:** each failing check comes with its failed step, summary, and log excerpt, so the agent rarely fetches logs. Superseded runs, unstarted required checks, and approval gates are recognized ([failing checks](docs/actions.md#failing-checks-and-reruns), [CI cases](docs/handled-cases.md#ci-checks)).
|
|
@@ -105,6 +107,7 @@ Requirements:
|
|
|
105
107
|
|
|
106
108
|
- Node.js >= 22.19.0, Bun, or Deno, and `git`
|
|
107
109
|
- A GitHub token or authenticated `gh` CLI with [the required access](docs/authentication.md)
|
|
110
|
+
- A repository where every check is expected to pass. Shepherd treats each failing check as work, required or not; list checks that may fail in [`checks.ignore`](docs/configuration.md#checksignore--default-) ([workflow assumptions](docs/features.md#workflow-assumptions))
|
|
108
111
|
|
|
109
112
|
## Documentation
|
|
110
113
|
|
|
@@ -7,6 +7,7 @@ import { numberInstructions } from "./iterate-instructions.mjs";
|
|
|
7
7
|
import { renderCheckAnnotation } from "./triage-formatter-extra.mjs";
|
|
8
8
|
import { renderRelatedJobLines } from "./related-jobs-format.mjs";
|
|
9
9
|
import { renderPendingDeploymentLines } from "./pending-deployments-format.mjs";
|
|
10
|
+
import { renderWorkflowElsewhereLines } from "./workflow-elsewhere-format.mjs";
|
|
10
11
|
import { renderStalledCheckLines } from "./stalled-check-format.mjs";
|
|
11
12
|
import { renderInProgressRun } from "./in-progress-run-format.mjs";
|
|
12
13
|
import { isFailingAgentCheck } from "../checks/conclusions.mjs";
|
|
@@ -111,6 +112,7 @@ export function formatTriageResult(header, result, opts = {}) {
|
|
|
111
112
|
lines.push(...renderRelatedJobLines(ch.relatedJobs));
|
|
112
113
|
}
|
|
113
114
|
lines.push(...renderPendingDeploymentLines(ch.pendingDeployments));
|
|
115
|
+
lines.push(...renderWorkflowElsewhereLines(ch));
|
|
114
116
|
if (ch.rerunCommand && ch.runId && !seenRerunRunIds.has(ch.runId)) {
|
|
115
117
|
seenRerunRunIds.add(ch.runId);
|
|
116
118
|
lines.push(` rerun: \`${ch.rerunCommand}\``);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** Format an ISO UTC timestamp as `HH:MMZ` for compact text output. */
|
|
2
|
+
function formatElsewhereShortTime(iso) {
|
|
3
|
+
if (!iso)
|
|
4
|
+
return "unknown";
|
|
5
|
+
const match = /T(\d{2}:\d{2}):\d{2}/.exec(iso);
|
|
6
|
+
return match?.[1] ? `${match[1]}Z` : iso;
|
|
7
|
+
}
|
|
8
|
+
function sanitizeInline(value) {
|
|
9
|
+
return value.replace(/[`\r\n]+/g, " ").trim();
|
|
10
|
+
}
|
|
11
|
+
function plural(n, singular, pluralForm) {
|
|
12
|
+
return `${n} ${n === 1 ? singular : pluralForm}`;
|
|
13
|
+
}
|
|
14
|
+
function formatAnnotation(ann) {
|
|
15
|
+
const path = sanitizeInline(ann.path);
|
|
16
|
+
const loc = path ? `\`${ann.line !== null ? `${path}:${ann.line}` : path}\`` : "";
|
|
17
|
+
const message = sanitizeInline(ann.message);
|
|
18
|
+
if (loc && message)
|
|
19
|
+
return `${loc} — ${message}`;
|
|
20
|
+
return loc || message;
|
|
21
|
+
}
|
|
22
|
+
function formatMoreAnnotations(count) {
|
|
23
|
+
if (!count || count <= 0)
|
|
24
|
+
return "";
|
|
25
|
+
return `(+${count} more ${count === 1 ? "annotation" : "annotations"})`;
|
|
26
|
+
}
|
|
27
|
+
function renderFailedJob(job, runConclusion, indent) {
|
|
28
|
+
const name = sanitizeInline(job.name);
|
|
29
|
+
const sameJob = job.sameJob ? " ← same job" : "";
|
|
30
|
+
const showConclusion = job.annotations.length === 0 || job.conclusion !== runConclusion;
|
|
31
|
+
const conclusionTag = showConclusion ? ` [conclusion: ${job.conclusion}]` : "";
|
|
32
|
+
const more = formatMoreAnnotations(job.moreAnnotations);
|
|
33
|
+
if (job.annotations.length === 0) {
|
|
34
|
+
return [`${indent}- ${name}${conclusionTag}${sameJob}${more ? ` ${more}` : ""}`];
|
|
35
|
+
}
|
|
36
|
+
if (job.annotations.length === 1) {
|
|
37
|
+
return [
|
|
38
|
+
`${indent}- ${name}${conclusionTag}${sameJob}: ${formatAnnotation(job.annotations[0])}${more ? ` ${more}` : ""}`,
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
const lines = [
|
|
42
|
+
`${indent}- ${name}${conclusionTag}${sameJob}:`,
|
|
43
|
+
...job.annotations.map((ann) => `${indent} - ${formatAnnotation(ann)}`),
|
|
44
|
+
];
|
|
45
|
+
if (more)
|
|
46
|
+
lines.push(`${indent} - ${more}`);
|
|
47
|
+
return lines;
|
|
48
|
+
}
|
|
49
|
+
function formatRunHeader(run) {
|
|
50
|
+
const target = run.source === "default-branch"
|
|
51
|
+
? `\`${sanitizeInline(run.branch ?? "default branch")}\``
|
|
52
|
+
: run.pr !== undefined
|
|
53
|
+
? `merge queue #${run.pr}`
|
|
54
|
+
: "merge queue";
|
|
55
|
+
return `${target} \`${run.headSha}\` run \`${run.runId}\` [conclusion: ${run.conclusion}]`;
|
|
56
|
+
}
|
|
57
|
+
function formatWorkflowLabel(scope) {
|
|
58
|
+
const name = scope?.workflowName ? sanitizeInline(scope.workflowName) : "";
|
|
59
|
+
const path = scope?.workflowPath ? sanitizeInline(scope.workflowPath) : "";
|
|
60
|
+
if (name && path)
|
|
61
|
+
return ` — \`${name}\` (${path})`;
|
|
62
|
+
if (name)
|
|
63
|
+
return ` — \`${name}\``;
|
|
64
|
+
if (path)
|
|
65
|
+
return ` — (${path})`;
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
function formatCheckedLine(scope, indent) {
|
|
69
|
+
const branch = `\`${sanitizeInline(scope.defaultBranch.branch)}\``;
|
|
70
|
+
const defaultPart = scope.defaultBranch.commitsRead !== undefined
|
|
71
|
+
? `${branch} last ${plural(scope.defaultBranch.commitsRead, "commit", "commits")}`
|
|
72
|
+
: `${branch} newest ${plural(scope.defaultBranch.runsRead ?? 0, "run", "runs")}`;
|
|
73
|
+
const queuePart = `merge queue newest ${plural(scope.mergeQueue.runsRead, "run", "runs")}`;
|
|
74
|
+
return `${indent} checked: ${defaultPart} · ${queuePart}`;
|
|
75
|
+
}
|
|
76
|
+
function formatShowingLine(scope, indent) {
|
|
77
|
+
const branch = `\`${sanitizeInline(scope.defaultBranch.branch)}\``;
|
|
78
|
+
const { defaultBranch: def, mergeQueue: mq } = scope;
|
|
79
|
+
const defMatched = `${def.matched}${def.matchedComplete ? "" : "+"}`;
|
|
80
|
+
const mqMatched = `${mq.matched}${mq.matchedComplete ? "" : "+"}`;
|
|
81
|
+
return `${indent} showing newest ${def.shown} of ${defMatched} on ${branch}, ${mq.shown} of ${mqMatched} in the merge queue`;
|
|
82
|
+
}
|
|
83
|
+
/** Render the `Same workflow elsewhere` sub-lines for a failing merge-group Actions check. */
|
|
84
|
+
export function renderWorkflowElsewhereLines(check, indent = " ") {
|
|
85
|
+
if (check.elsewhereUnread !== undefined) {
|
|
86
|
+
return [
|
|
87
|
+
`${indent}Same workflow elsewhere: not read (${sanitizeInline(check.elsewhereUnread)})`,
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (check.elsewhere === undefined)
|
|
91
|
+
return [];
|
|
92
|
+
const scope = check.elsewhereScope;
|
|
93
|
+
const since = formatElsewhereShortTime(scope?.since);
|
|
94
|
+
const wfLabel = formatWorkflowLabel(scope);
|
|
95
|
+
if (check.elsewhere.length === 0) {
|
|
96
|
+
const lines = [`${indent}Same workflow elsewhere${wfLabel}, since ${since}: none found`];
|
|
97
|
+
if (scope)
|
|
98
|
+
lines.push(formatCheckedLine(scope, indent));
|
|
99
|
+
return lines;
|
|
100
|
+
}
|
|
101
|
+
const lines = [`${indent}Same workflow elsewhere${wfLabel}, since ${since}:`];
|
|
102
|
+
if (scope) {
|
|
103
|
+
lines.push(formatCheckedLine(scope, indent), formatShowingLine(scope, indent));
|
|
104
|
+
}
|
|
105
|
+
for (const run of check.elsewhere) {
|
|
106
|
+
lines.push(`${indent}- ${formatRunHeader(run)}`);
|
|
107
|
+
for (const job of run.failedJobs) {
|
|
108
|
+
lines.push(...renderFailedJob(job, run.conclusion, `${indent} `));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return lines;
|
|
112
|
+
}
|
|
@@ -35,5 +35,7 @@ export declare function attachAndMergeCheckAnnotations(buckets: {
|
|
|
35
35
|
failing: TriagedCheck[];
|
|
36
36
|
skipped: ClassifiedCheck[];
|
|
37
37
|
filtered: ClassifiedCheck[];
|
|
38
|
+
/** A fetched annotation page held a null entry: CI is not fully known this tick. */
|
|
39
|
+
annotationsUnread?: true;
|
|
38
40
|
}>;
|
|
39
41
|
export declare function annotationMarkerBody(a: CheckAnnotation): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetchCheckRunAnnotationsBatch } from "../github/check-annotations-batch.mjs";
|
|
2
|
+
import { NullAnnotationNodeError } from "../github/check-annotation-pages.mjs";
|
|
2
3
|
import { pollRateLimitRetryAfterMs } from "./poll-quota.mjs";
|
|
3
4
|
function shouldFetchCheckAnnotations(check) {
|
|
4
5
|
return check.id != null && check.status === "COMPLETED" && check.hasAnnotations === true;
|
|
@@ -45,7 +46,7 @@ export async function attachAndMergeCheckAnnotations(buckets, seenMap, prNumber,
|
|
|
45
46
|
...buckets.filtered,
|
|
46
47
|
].filter(shouldFetchCheckAnnotations);
|
|
47
48
|
const expectedCounts = new Map(candidates.flatMap((c) => c.id != null && c.annotationCount ? [[c.id, c.annotationCount]] : []));
|
|
48
|
-
const annotated = await attachUnseenCheckAnnotations(candidates, seenMap, prNumber, cacheOpts && { ...cacheOpts, expectedCounts });
|
|
49
|
+
const { checks: annotated, unread } = await attachUnseenCheckAnnotations(candidates, seenMap, prNumber, cacheOpts && { ...cacheOpts, expectedCounts });
|
|
49
50
|
const byId = new Map(annotated.flatMap((c) => (c.id != null ? [[c.id, c]] : [])));
|
|
50
51
|
const apply = (list) => list.map((c) => {
|
|
51
52
|
const next = (c.id == null ? undefined : byId.get(c.id)) ?? c;
|
|
@@ -59,12 +60,14 @@ export async function attachAndMergeCheckAnnotations(buckets, seenMap, prNumber,
|
|
|
59
60
|
failing: apply(buckets.failing),
|
|
60
61
|
skipped: apply(buckets.skipped),
|
|
61
62
|
filtered: apply(buckets.filtered),
|
|
63
|
+
...(unread && { annotationsUnread: true }),
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
async function attachUnseenCheckAnnotations(checks, seenMap, prNumber, cacheOpts) {
|
|
65
67
|
if (checks.length === 0)
|
|
66
|
-
return checks;
|
|
68
|
+
return { checks, unread: false };
|
|
67
69
|
const annotations = new Map();
|
|
70
|
+
let unread = false;
|
|
68
71
|
for (const check of checks) {
|
|
69
72
|
if (check.id != null && check.inlineAnnotations)
|
|
70
73
|
annotations.set(check.id, check.inlineAnnotations);
|
|
@@ -79,16 +82,28 @@ async function attachUnseenCheckAnnotations(checks, seenMap, prNumber, cacheOpts
|
|
|
79
82
|
if (pollRateLimitRetryAfterMs(err) !== null)
|
|
80
83
|
throw err;
|
|
81
84
|
writeAnnotationFailureSummary(prNumber, ids.length, err);
|
|
82
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
checks: checks.map((check) => withUnseenAnnotations(check, annotations, seenMap)),
|
|
87
|
+
unread: false,
|
|
88
|
+
};
|
|
83
89
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const nullFailures = batch.failures.filter((f) => f.error instanceof NullAnnotationNodeError);
|
|
91
|
+
unread = nullFailures.length > 0;
|
|
92
|
+
// Entries read from a page that also held a null still surface; the run is held unread.
|
|
93
|
+
for (const failure of nullFailures) {
|
|
94
|
+
annotations.set(failure.checkRunId, failure.error.readable);
|
|
95
|
+
}
|
|
96
|
+
const otherFailures = batch.failures.filter((f) => !nullFailures.includes(f));
|
|
97
|
+
if (otherFailures[0] !== undefined) {
|
|
98
|
+
writeAnnotationFailureSummary(prNumber, otherFailures.length, otherFailures[0].error);
|
|
87
99
|
}
|
|
88
100
|
for (const [id, list] of batch.annotations)
|
|
89
101
|
annotations.set(id, list);
|
|
90
102
|
}
|
|
91
|
-
return
|
|
103
|
+
return {
|
|
104
|
+
checks: checks.map((check) => withUnseenAnnotations(check, annotations, seenMap)),
|
|
105
|
+
unread,
|
|
106
|
+
};
|
|
92
107
|
}
|
|
93
108
|
function withUnseenAnnotations(check, annotations, seenMap) {
|
|
94
109
|
const fetched = check.id == null ? undefined : annotations.get(check.id);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BatchPrData, ShepherdStatus } from "../types.mts";
|
|
2
|
+
/**
|
|
3
|
+
* A snapshot with unreadable (null) nodes cannot prove CI or feedback is clear, so it is never
|
|
4
|
+
* READY: the PR waits and the next tick re-reads it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function holdUnreadReadiness(status: ShepherdStatus, data: BatchPrData): ShepherdStatus;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A snapshot with unreadable (null) nodes cannot prove CI or feedback is clear, so it is never
|
|
3
|
+
* READY: the PR waits and the next tick re-reads it.
|
|
4
|
+
*/
|
|
5
|
+
export function holdUnreadReadiness(status, data) {
|
|
6
|
+
return status === "READY" && data.unreadNodes ? "PENDING" : status;
|
|
7
|
+
}
|
package/bin/commands/check.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import { loadConfig } from "../config/load.mjs";
|
|
|
21
21
|
import { classifyVisibleComments } from "../comments/visible-comments.mjs";
|
|
22
22
|
import { withHeadOid } from "./review-commit.mjs";
|
|
23
23
|
import { computeStatus } from "./check-status.mjs";
|
|
24
|
+
import { holdUnreadReadiness } from "./check-unread-readiness.mjs";
|
|
24
25
|
import { annotationMarkerBody, attachAndMergeCheckAnnotations, hasCheckDrivenActionableWork, isQueuedConflict, } from "./check-annotations.mjs";
|
|
25
26
|
import { buildTerminalReport } from "./check-terminal-report.mjs";
|
|
26
27
|
import { headStillSettling } from "./check-settle.mjs";
|
|
@@ -43,6 +44,7 @@ import { buildClassifyIndex, partitionBatch } from "../classify/apply.mjs";
|
|
|
43
44
|
import { EXIT, ShepherdError } from "../exit-codes.mjs";
|
|
44
45
|
import { getEffectiveCwd } from "../execution-context.mjs";
|
|
45
46
|
function enforceTransportReadiness(status, data) {
|
|
47
|
+
status = holdUnreadReadiness(status, data);
|
|
46
48
|
if (status !== "READY" || data.transport !== "rest")
|
|
47
49
|
return status;
|
|
48
50
|
const conversationsGated = data.branchRules?.requiresConversationResolution;
|
|
@@ -281,6 +283,9 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
|
|
|
281
283
|
settling;
|
|
282
284
|
let status = computeStatus(verdict, threadVisibility.activeThreads.length + threadVisibility.resolutionOnlyThreads.length, visibleCommentClassification.actionable.length, mergeStatus, changesRequestedReviewCount, awaitingChecks);
|
|
283
285
|
status = enforceTransportReadiness(status, batchData);
|
|
286
|
+
// A null annotation entry means CI is not fully known: wait a tick instead of READY.
|
|
287
|
+
if (merged.annotationsUnread && status === "READY")
|
|
288
|
+
status = "PENDING";
|
|
284
289
|
// Resolve any pending mergeability refresh (and the resulting MERGED/CLOSED short-circuit)
|
|
285
290
|
// before deciding what to persist below — deferWhileQueued must see the same final,
|
|
286
291
|
// possibly-refreshed mergeStatus that commands/iterate/index.mts acts on, not the pre-refresh
|
|
@@ -5,4 +5,4 @@ export type QueueEjectionRecovery = "requeue" | "acknowledge" | "none";
|
|
|
5
5
|
/** The removed queue commit whose failed checks this tick surfaces, if the removal is current. */
|
|
6
6
|
export declare function currentEjectionCommit(report: ShepherdReport, checks: AgentCheck[]): string | undefined;
|
|
7
7
|
/** The ejection step after failing-check triage; points at a stack route already printed. */
|
|
8
|
-
export declare function queueEjectionSteps(recovery: QueueEjectionRecovery | undefined, stackRebase: string | undefined, routePrinted: boolean): string[];
|
|
8
|
+
export declare function queueEjectionSteps(recovery: QueueEjectionRecovery | undefined, stackRebase: string | undefined, routePrinted: boolean, hasElsewhere?: boolean): string[];
|
|
@@ -11,20 +11,23 @@ export function currentEjectionCommit(report, checks) {
|
|
|
11
11
|
: undefined;
|
|
12
12
|
}
|
|
13
13
|
/** The ejection step after failing-check triage; points at a stack route already printed. */
|
|
14
|
-
export function queueEjectionSteps(recovery, stackRebase, routePrinted) {
|
|
14
|
+
export function queueEjectionSteps(recovery, stackRebase, routePrinted, hasElsewhere = false) {
|
|
15
15
|
if (!recovery)
|
|
16
16
|
return [];
|
|
17
17
|
const route = stackRebase && routePrinted ? "use the stack route printed above." : stackRebase;
|
|
18
|
-
return [buildQueueEjectionInstruction(recovery, route)];
|
|
18
|
+
return [buildQueueEjectionInstruction(recovery, route, hasElsewhere)];
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* The trigger, update route, and command guard; the fixed procedure lives in the playbook.
|
|
22
22
|
* A printed command implies a `failed_checks` removal. Without one, the agent reads the raw
|
|
23
23
|
* removal reason, since a person's dequeue must not be undone by a branch update.
|
|
24
24
|
*/
|
|
25
|
-
function buildQueueEjectionInstruction(recovery, stackRoute) {
|
|
25
|
+
function buildQueueEjectionInstruction(recovery, stackRoute, hasElsewhere = false) {
|
|
26
26
|
const target = stackRoute ? "the stack" : "the PR head";
|
|
27
27
|
const route = stackRoute ? `: ${stackRoute}` : ".";
|
|
28
|
+
const elsewhere = hasElsewhere
|
|
29
|
+
? " Check `Same workflow elsewhere` under `## Failing checks` for recent runs of this workflow on the default branch and other merge-queue entries."
|
|
30
|
+
: "";
|
|
28
31
|
const update = recovery === "none"
|
|
29
32
|
? `If the \`**queue removal**\` reason shows GitHub removed the entry itself, update ${target} from the latest base first${route} If a person may have dequeued the PR, skip that update unless a conflict step above requires it.`
|
|
30
33
|
: `Update ${target} from the latest base first${route}`;
|
|
@@ -34,5 +37,5 @@ function buildQueueEjectionInstruction(recovery, stackRoute) {
|
|
|
34
37
|
: recovery === "acknowledge"
|
|
35
38
|
? `Run \`acknowledge queue removal:\` ${reproduce}`
|
|
36
39
|
: "Shepherd printed no queue command for this session, so do not enqueue the PR.";
|
|
37
|
-
return `Triage the merge-queue ejection before any requeue
|
|
40
|
+
return `Triage the merge-queue ejection before any requeue.${elsewhere} ${update} ${guard} ${playbookPointer("Merge queue ejection")}`;
|
|
38
41
|
}
|
|
@@ -68,7 +68,8 @@ cancelRunsStep) {
|
|
|
68
68
|
instructions.push(pathA(buildCommitSuggestionInstruction(prReference, "## Review threads")));
|
|
69
69
|
if (resolutionOnlyThreads.length > 0)
|
|
70
70
|
instructions.push("Review the threads under `## Review threads to resolve` before running the generated mutations.");
|
|
71
|
-
|
|
71
|
+
const hasElsewhere = failingChecks.some((c) => c.elsewhere !== undefined || c.elsewhereUnread !== undefined);
|
|
72
|
+
instructions.push(...buildFailingCheckInstructions(failingChecks), ...repeatedWorkflowBranchRecoveryInstructions.map(pathA), ...queueEjectionSteps(queueEjection, stackRebase, branchRecovery, hasElsewhere));
|
|
72
73
|
if (hasAnnotations)
|
|
73
74
|
instructions.push(pathA("Inspect every referenced range under `## Check annotations` and apply any warranted change."));
|
|
74
75
|
// The first step already covers applying changes-requested bodies; only stale CRs add a step.
|
|
@@ -12,6 +12,7 @@ import { buildCheckFollowUpInstructions, buildEvidenceFollowUpInstruction, check
|
|
|
12
12
|
import { checkFollowUpKeys, readCheckFollowUp, readShownRunFailures, sameCheckFollowUp, writeCheckFollowUp, writeShownRunFailures, } from "../../state/check-follow-up.mjs";
|
|
13
13
|
import { activeRunFailures, buildRunFailureWait, runFailureKeys, runFailuresShown, } from "./run-failure-wait.mjs";
|
|
14
14
|
import { currentEjectionCommit, } from "./queue-recovery-instructions.mjs";
|
|
15
|
+
import { attachWorkflowElsewhere } from "./workflow-elsewhere.mjs";
|
|
15
16
|
import { buildReleasedBlockerInstruction, buildReviewSubsetInstruction, } from "./check-instructions.mjs";
|
|
16
17
|
import { buildNativeStackLayerRebase } from "./native-stack-rebase.mjs";
|
|
17
18
|
import { buildDequeueCommand } from "./merge-plan.mjs";
|
|
@@ -183,10 +184,11 @@ async function handleTriageTick(ctx) {
|
|
|
183
184
|
? { ...c, rerunCommand: `gh run rerun ${c.runId} -R ${report.repo}` }
|
|
184
185
|
: c;
|
|
185
186
|
});
|
|
186
|
-
const
|
|
187
|
-
...
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
const annotatedAgentChecks = toAgentChecks(annotatedExtra).map((c) => ({
|
|
188
|
+
...c,
|
|
189
|
+
annotationOnly: true,
|
|
190
|
+
}));
|
|
191
|
+
const checks = [...failingAgentChecks, ...annotatedAgentChecks];
|
|
190
192
|
const { changesRequestedReviews } = report;
|
|
191
193
|
const hasConflicts = report.mergeStatus.status === "CONFLICTS";
|
|
192
194
|
const queuedConflict = isQueuedConflict(report.mergeQueue?.inQueue, report.mergeStatus.status);
|
|
@@ -325,13 +327,28 @@ async function handleTriageTick(ctx) {
|
|
|
325
327
|
const queueRemovalAcknowledgment = acknowledgmentRecovery && !("unavailable" in acknowledgmentRecovery)
|
|
326
328
|
? acknowledgmentRecovery
|
|
327
329
|
: undefined;
|
|
328
|
-
const
|
|
330
|
+
const ejectionCommit = currentEjectionCommit(report, failingAgentChecks);
|
|
331
|
+
const queueEjection = !ejectionCommit
|
|
329
332
|
? undefined
|
|
330
333
|
: requeue
|
|
331
334
|
? "requeue"
|
|
332
335
|
: queueRemovalAcknowledgment
|
|
333
336
|
? "acknowledge"
|
|
334
337
|
: "none";
|
|
338
|
+
const triageChecks = ejectionCommit
|
|
339
|
+
? [
|
|
340
|
+
...(await attachWorkflowElsewhere({
|
|
341
|
+
checks: failingAgentChecks,
|
|
342
|
+
rawFailing: failingChecks,
|
|
343
|
+
report,
|
|
344
|
+
repo: { owner: repoOwner, name: repoName },
|
|
345
|
+
stateKey: stallKey,
|
|
346
|
+
ejectionCommit,
|
|
347
|
+
compareWindowHours: loadConfig()["merge-queue"]["compare-window-hours"],
|
|
348
|
+
})),
|
|
349
|
+
...annotatedAgentChecks,
|
|
350
|
+
]
|
|
351
|
+
: checks;
|
|
335
352
|
// Conflicts, a behind branch whose rerun already failed, and a queue ejection that may be
|
|
336
353
|
// reproduced on the latest base all print the branch update route.
|
|
337
354
|
const stackRebase = hasConflicts || (isBehind && exhaustedAttempts.length > 0) || queueEjection
|
|
@@ -341,7 +358,7 @@ async function handleTriageTick(ctx) {
|
|
|
341
358
|
? renderShellCommand(buildDequeueCommand(report.nodeId))
|
|
342
359
|
: undefined;
|
|
343
360
|
const inProgressRuns = await buildInProgressRuns(report, rerunAuthorized);
|
|
344
|
-
const instructions = buildFixInstructions(threads, actionableComments,
|
|
361
|
+
const instructions = buildFixInstructions(threads, actionableComments, triageChecks.filter((check) => !releasedCheckNames.has(check.name)), changesRequestedReviews, baseLookup.branch, resolveCommand, hasConflicts, prReference, firstLookThreads, firstLookComments, firstLookSummaries, editedSummaries, resolutionOnlyThreads, resolveOnlyCommand, behindBaseHint, isBehind, canGenerateGithubMutation(report.viewerAuthorization?.viewerCanUpdate, "ready"), exhaustedAttempts.length > 0, stackRebase, queueEjection, opts.instructions ?? configuredInstructions, dequeueCommand, buildCancelRunsInstruction(inProgressRuns));
|
|
345
362
|
if (investigate) {
|
|
346
363
|
// The failing-checks pointer is replaced: these checks have no excerpt for the CI playbook.
|
|
347
364
|
const triageStep = instructions.findIndex((step) => step.startsWith("Triage `## Failing checks`."));
|
|
@@ -426,7 +443,7 @@ async function handleTriageTick(ctx) {
|
|
|
426
443
|
firstLookSummaries,
|
|
427
444
|
editedSummaries,
|
|
428
445
|
surfacedApprovals,
|
|
429
|
-
checks,
|
|
446
|
+
checks: triageChecks,
|
|
430
447
|
...(inProgressRuns.length > 0 && { inProgressRuns }),
|
|
431
448
|
...(requeue && { requeue }),
|
|
432
449
|
...(queueRemovalAcknowledgment && { queueRemovalAcknowledgment }),
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RepoInfo } from "../../github/client.mts";
|
|
2
|
+
import { type StateKey } from "../../state/rest-cache.mts";
|
|
3
|
+
import type { AgentCheck, ShepherdReport, TriagedCheck } from "../../types.mts";
|
|
4
|
+
export interface AttachWorkflowElsewhereInput {
|
|
5
|
+
checks: AgentCheck[];
|
|
6
|
+
rawFailing: TriagedCheck[];
|
|
7
|
+
report: ShepherdReport;
|
|
8
|
+
repo: RepoInfo;
|
|
9
|
+
stateKey: StateKey;
|
|
10
|
+
ejectionCommit: string;
|
|
11
|
+
compareWindowHours: number;
|
|
12
|
+
nowMs?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Enrich failing `merge_group` Actions checks belonging to the current queue removal with recent
|
|
16
|
+
* runs of the same workflow on the default branch and other queue entries. Cached briefly per
|
|
17
|
+
* removal; incomplete or failed reads are never cached and surface `elsewhereUnread`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function attachWorkflowElsewhere(input: AttachWorkflowElsewhereInput): Promise<AgentCheck[]>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { readWorkflowElsewhere, resolveWorkflowId, summarizeElsewhereError, } from "../../github/workflow-elsewhere-read.mjs";
|
|
2
|
+
import { stampSameJob } from "../../github/workflow-elsewhere-parse.mjs";
|
|
3
|
+
import { queueRemovalSignature } from "../../state/queue-removal-follow-up.mjs";
|
|
4
|
+
import { loadDerived, storeDerived } from "../../state/rest-cache.mjs";
|
|
5
|
+
/** Cache TTL so later default-branch failures/recoveries appear on subsequent ticks. */
|
|
6
|
+
const ELSEWHERE_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
7
|
+
function isActionsProvenance(raw) {
|
|
8
|
+
return Boolean(raw &&
|
|
9
|
+
(raw.source === "startup_failure" ||
|
|
10
|
+
raw.workflowId !== undefined ||
|
|
11
|
+
raw.workflowName !== undefined));
|
|
12
|
+
}
|
|
13
|
+
function isFreshCached(value, nowMs) {
|
|
14
|
+
const e = value;
|
|
15
|
+
return Boolean(e &&
|
|
16
|
+
Array.isArray(e.runs) &&
|
|
17
|
+
typeof e.scope?.since === "string" &&
|
|
18
|
+
typeof e.scope?.defaultBranch?.branch === "string" &&
|
|
19
|
+
typeof e.scope?.defaultBranch?.matchedComplete === "boolean" &&
|
|
20
|
+
typeof e.scope?.mergeQueue?.runsRead === "number" &&
|
|
21
|
+
typeof e.scope?.mergeQueue?.matchedComplete === "boolean" &&
|
|
22
|
+
typeof e.cachedAtMs === "number" &&
|
|
23
|
+
nowMs - e.cachedAtMs >= 0 &&
|
|
24
|
+
nowMs - e.cachedAtMs < ELSEWHERE_CACHE_TTL_MS);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Enrich failing `merge_group` Actions checks belonging to the current queue removal with recent
|
|
28
|
+
* runs of the same workflow on the default branch and other queue entries. Cached briefly per
|
|
29
|
+
* removal; incomplete or failed reads are never cached and surface `elsewhereUnread`.
|
|
30
|
+
*/
|
|
31
|
+
export async function attachWorkflowElsewhere(input) {
|
|
32
|
+
const { checks, rawFailing, report, repo, stateKey, ejectionCommit, compareWindowHours } = input;
|
|
33
|
+
const nowMs = input.nowMs ?? Date.now();
|
|
34
|
+
const removal = report.mergeQueue?.latestRemoval;
|
|
35
|
+
if (compareWindowHours <= 0 || !removal)
|
|
36
|
+
return checks;
|
|
37
|
+
const windowStartMs = Math.floor((removal.createdAtUnix - compareWindowHours * 3600) * 1000);
|
|
38
|
+
const since = new Date(windowStartMs).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
39
|
+
const signature = queueRemovalSignature({
|
|
40
|
+
headSha: report.headSha ?? "unknown",
|
|
41
|
+
createdAtUnix: removal.createdAtUnix,
|
|
42
|
+
beforeCommitOid: ejectionCommit,
|
|
43
|
+
});
|
|
44
|
+
const rawByRunId = new Map();
|
|
45
|
+
for (const raw of rawFailing) {
|
|
46
|
+
if (raw.runId !== null &&
|
|
47
|
+
raw.scope === "merge_group" &&
|
|
48
|
+
raw.commitOid === ejectionCommit &&
|
|
49
|
+
(!rawByRunId.has(raw.runId) || raw.workflowId !== undefined)) {
|
|
50
|
+
rawByRunId.set(raw.runId, raw);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const workflowIdByRunId = new Map();
|
|
54
|
+
const outcomeByWorkflowId = new Map();
|
|
55
|
+
const resolveForRun = async (runId, raw) => {
|
|
56
|
+
const cached = workflowIdByRunId.get(runId);
|
|
57
|
+
if (cached)
|
|
58
|
+
return cached;
|
|
59
|
+
if (raw.workflowId && /^\d+$/.test(raw.workflowId)) {
|
|
60
|
+
const hit = { id: raw.workflowId };
|
|
61
|
+
workflowIdByRunId.set(runId, hit);
|
|
62
|
+
return hit;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const id = await resolveWorkflowId(repo, runId, stateKey);
|
|
66
|
+
const outcome = id ? { id } : { unread: "workflow ID unavailable" };
|
|
67
|
+
workflowIdByRunId.set(runId, outcome);
|
|
68
|
+
return outcome;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const outcome = { unread: summarizeElsewhereError(error) };
|
|
72
|
+
workflowIdByRunId.set(runId, outcome);
|
|
73
|
+
return outcome;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const fetchForWorkflow = async (workflowId, currentRunId, raw, check) => {
|
|
77
|
+
const memoized = outcomeByWorkflowId.get(workflowId);
|
|
78
|
+
if (memoized)
|
|
79
|
+
return memoized;
|
|
80
|
+
const cacheName = `workflow-elsewhere:${signature}:wf:${workflowId}:h=${compareWindowHours}`;
|
|
81
|
+
const stored = await loadDerived(stateKey, cacheName);
|
|
82
|
+
if (stored && isFreshCached(stored.value, nowMs)) {
|
|
83
|
+
const hit = {
|
|
84
|
+
runs: stored.value.runs,
|
|
85
|
+
scope: stored.value.scope,
|
|
86
|
+
};
|
|
87
|
+
outcomeByWorkflowId.set(workflowId, hit);
|
|
88
|
+
return hit;
|
|
89
|
+
}
|
|
90
|
+
const workflowName = raw.workflowName ?? check.workflowName;
|
|
91
|
+
const workflowPath = raw.workflowPath ?? check.workflowPath;
|
|
92
|
+
let outcome;
|
|
93
|
+
try {
|
|
94
|
+
outcome = await readWorkflowElsewhere({
|
|
95
|
+
repo,
|
|
96
|
+
prNumber: report.pr,
|
|
97
|
+
workflowId,
|
|
98
|
+
...(workflowName !== undefined && { workflowName }),
|
|
99
|
+
...(workflowPath !== undefined && { workflowPath }),
|
|
100
|
+
currentRunId,
|
|
101
|
+
currentCommitOid: ejectionCommit,
|
|
102
|
+
windowStartMs,
|
|
103
|
+
since,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
outcome = { unread: summarizeElsewhereError(error) };
|
|
108
|
+
}
|
|
109
|
+
outcomeByWorkflowId.set(workflowId, outcome);
|
|
110
|
+
if ("runs" in outcome) {
|
|
111
|
+
await storeDerived(stateKey, cacheName, { runs: outcome.runs, scope: outcome.scope, cachedAtMs: nowMs }, report.headSha);
|
|
112
|
+
}
|
|
113
|
+
return outcome;
|
|
114
|
+
};
|
|
115
|
+
const enriched = [];
|
|
116
|
+
for (const check of checks) {
|
|
117
|
+
const raw = check.scope === "merge_group" && check.commitOid === ejectionCommit && check.runId
|
|
118
|
+
? rawByRunId.get(check.runId)
|
|
119
|
+
: undefined;
|
|
120
|
+
if (!isActionsProvenance(raw)) {
|
|
121
|
+
enriched.push(check);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
// eslint-disable-next-line no-await-in-loop
|
|
125
|
+
const resolved = await resolveForRun(check.runId, raw);
|
|
126
|
+
if ("unread" in resolved) {
|
|
127
|
+
enriched.push({ ...check, elsewhereUnread: resolved.unread });
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
// eslint-disable-next-line no-await-in-loop
|
|
131
|
+
const outcome = await fetchForWorkflow(resolved.id, check.runId, raw, check);
|
|
132
|
+
if ("unread" in outcome) {
|
|
133
|
+
enriched.push({ ...check, elsewhereUnread: outcome.unread });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
enriched.push({
|
|
137
|
+
...check,
|
|
138
|
+
elsewhere: stampSameJob(outcome.runs, check.name),
|
|
139
|
+
elsewhereScope: outcome.scope,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return enriched;
|
|
144
|
+
}
|
package/bin/config/schema.d.mts
CHANGED
|
@@ -77,6 +77,9 @@ export declare const configSchema: z.ZodObject<{
|
|
|
77
77
|
}>>;
|
|
78
78
|
"command-args": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
79
79
|
}, z.core.$strict>>;
|
|
80
|
+
"merge-queue": z.ZodPrefault<z.ZodObject<{
|
|
81
|
+
"compare-window-hours": z.ZodDefault<z.ZodNumber>;
|
|
82
|
+
}, z.core.$strict>>;
|
|
80
83
|
actions: z.ZodPrefault<z.ZodObject<{
|
|
81
84
|
"auto-minimize-suppressed": z.ZodDefault<z.ZodBoolean>;
|
|
82
85
|
"work-while-queued": z.ZodDefault<z.ZodBoolean>;
|
|
@@ -164,6 +167,9 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
164
167
|
}>>;
|
|
165
168
|
"command-args": z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
166
169
|
}, z.core.$strict>>;
|
|
170
|
+
"merge-queue": z.ZodPrefault<z.ZodObject<{
|
|
171
|
+
"compare-window-hours": z.ZodDefault<z.ZodNumber>;
|
|
172
|
+
}, z.core.$strict>>;
|
|
167
173
|
actions: z.ZodPrefault<z.ZodObject<{
|
|
168
174
|
"auto-minimize-suppressed": z.ZodDefault<z.ZodBoolean>;
|
|
169
175
|
"work-while-queued": z.ZodDefault<z.ZodBoolean>;
|
package/bin/config/schema.mjs
CHANGED
|
@@ -159,6 +159,9 @@ export const configSchema = z.strictObject({
|
|
|
159
159
|
"command-args": mergeCommandArgs.default(() => []),
|
|
160
160
|
})
|
|
161
161
|
.prefault({}),
|
|
162
|
+
"merge-queue": z
|
|
163
|
+
.strictObject({ "compare-window-hours": nonNegative().max(720).default(6) })
|
|
164
|
+
.prefault({}),
|
|
162
165
|
actions: z
|
|
163
166
|
.strictObject({
|
|
164
167
|
"auto-minimize-suppressed": z.boolean().default(true),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type UnreadNodes } from "./null-nodes.mts";
|
|
1
2
|
import type { RawContextNode, RawComment, RawPr, RawReview, RawReviewSummary, RawThread } from "./batch-raw-types.mts";
|
|
2
3
|
export interface RawPageResponse {
|
|
3
4
|
repository: {
|
|
@@ -38,6 +39,8 @@ export interface PageAccumulator {
|
|
|
38
39
|
reviewSummaries: RawReviewSummary[];
|
|
39
40
|
approvedReviews: RawReviewSummary[];
|
|
40
41
|
checks: RawContextNode[];
|
|
42
|
+
/** What a page returned as null, dropped before it joined the lists above. */
|
|
43
|
+
unreadNodes?: UnreadNodes;
|
|
41
44
|
}
|
|
42
45
|
export declare function applyIncludedPage(dest: PageAccumulator, pr2: NonNullable<RawPageResponse["repository"]["pullRequest"]>, cursors: PageCursors, firstOid: string | undefined, pageCount: number, pr: number): {
|
|
43
46
|
cursors: PageCursors;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { contextNodes } from "./batch-response.mjs";
|
|
2
|
+
import { dropNullNodes, mergeUnread } from "./null-nodes.mjs";
|
|
2
3
|
export function backwardCursor(conn) {
|
|
3
4
|
if (conn?.pageInfo.hasPreviousPage === true && conn.pageInfo.startCursor) {
|
|
4
5
|
return conn.pageInfo.startCursor;
|
|
@@ -28,9 +29,11 @@ function takeCheckPage(pr2, firstOid, pageCount) {
|
|
|
28
29
|
if (!ctxs) {
|
|
29
30
|
return { pageInfo: { hasNextPage: false, endCursor: null }, nodes: [] };
|
|
30
31
|
}
|
|
31
|
-
return { ...ctxs, nodes:
|
|
32
|
+
return { ...ctxs, nodes: contextNodes(ctxs.nodes) };
|
|
32
33
|
}
|
|
33
34
|
export function applyIncludedPage(dest, pr2, cursors, firstOid, pageCount, pr) {
|
|
35
|
+
// A null in a page is dropped, never skipped silently: the caller learns the lists are partial.
|
|
36
|
+
dest.unreadNodes = mergeUnread(dest.unreadNodes, dropNullNodes(pr2));
|
|
34
37
|
const next = {};
|
|
35
38
|
let nextPageCount = pageCount;
|
|
36
39
|
if (cursors.threads !== undefined) {
|