pr-shepherd 2.2.9 → 2.2.10
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 -1
- package/bin/checks/classify.mjs +4 -2
- package/bin/commands/iterate/index.mjs +77 -55
- package/bin/github/batch-parser-helpers.mjs +4 -1
- 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/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Take pull requests from scratch to merge-ready with a coding agent, as a [Code M
|
|
|
4
4
|
|
|
5
5
|
## Benefits
|
|
6
6
|
|
|
7
|
-
- **Better decisions:** across
|
|
7
|
+
- **Better decisions:** across 59 PR states, it scores 0.94 with the plugin vs. 0.46 with `gh` + the GitHub MCP server ([outcome evals](evals/README.md), 2026-11-19).
|
|
8
8
|
- **Lower cost:** modeled cost per PR session is about 36% lower than `gh` and 76% lower than the GitHub MCP server, with 20% / 69% fewer turns ([token bench](evals/tokens/README.md); assumes a warm prompt cache).
|
|
9
9
|
- **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
10
|
- **72 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)).
|
package/bin/checks/classify.mjs
CHANGED
|
@@ -76,8 +76,10 @@ function classify(check, relevantEvents) {
|
|
|
76
76
|
return { ...check, category: "filtered" };
|
|
77
77
|
}
|
|
78
78
|
const { status, conclusion } = check;
|
|
79
|
-
// Not yet finished.
|
|
80
|
-
|
|
79
|
+
// Not yet finished. A recorded conclusion means finished whatever `status` says, so a check can
|
|
80
|
+
// never be both non-completed and carry a SUCCESS conclusion (which would hide it from the
|
|
81
|
+
// failing list while still counting as failing).
|
|
82
|
+
if (status !== "COMPLETED" && conclusion == null) {
|
|
81
83
|
// The enclosing suite finished while this run did not: nothing will update it again, so
|
|
82
84
|
// waiting would only end in the stall timeout. Surface it as failing work (rerun the
|
|
83
85
|
// workflow) with the raw status and suite status shown.
|
|
@@ -317,8 +317,8 @@ async function runIterateCore(opts, tick) {
|
|
|
317
317
|
if (markReadyResult)
|
|
318
318
|
return markReadyResult;
|
|
319
319
|
if (readyState.shouldCancel && !report.mergeStatus.isDraft) {
|
|
320
|
-
const
|
|
321
|
-
? "written"
|
|
320
|
+
const outcome = receiptCurrent
|
|
321
|
+
? { status: "written" }
|
|
322
322
|
: await recordReadyReceipt(receiptKey, report, checkContext);
|
|
323
323
|
// Aggregate `stack` routing trusts only a layer's receipt, so an unwritten
|
|
324
324
|
// one keeps the elapsed marker and retries next tick. A one-PR receipt
|
|
@@ -327,14 +327,13 @@ async function runIterateCore(opts, tick) {
|
|
|
327
327
|
// still holds it, but without --merge its one-PR session ends like a
|
|
328
328
|
// single PR's instead of waiting for a stall-timeout.
|
|
329
329
|
const stackLayer = report.mergeStatus.mergeRequirements?.stack !== undefined;
|
|
330
|
-
if (stackLayer &&
|
|
330
|
+
if (stackLayer &&
|
|
331
|
+
(outcome.status === "failed" || (outcome.status === "blocked" && opts.merge))) {
|
|
331
332
|
const receiptWait = {
|
|
332
333
|
...base,
|
|
333
334
|
action: "wait",
|
|
334
335
|
shouldCancel: false,
|
|
335
|
-
log:
|
|
336
|
-
? `WAIT: PR #${base.pr} reached ready-delay but GitHub reports BLOCKED, so its stack readiness receipt was not certified`
|
|
337
|
-
: `WAIT: PR #${base.pr} reached ready-delay but its stack readiness receipt could not be persisted`,
|
|
336
|
+
log: receiptWaitLog(base.pr, outcome),
|
|
338
337
|
};
|
|
339
338
|
return annotateBlockedWait(await applyStallGuard(stallKey, stallTimeoutSeconds, headSha, base, prNumber, receiptWait, reportForWork, reviewSummaryIds, opts.stallDeadlineSink, opts.persistSeen !== false), blockerGate);
|
|
340
339
|
}
|
|
@@ -373,55 +372,81 @@ async function runIterateCore(opts, tick) {
|
|
|
373
372
|
};
|
|
374
373
|
return annotateBlockedWait(await applyStallGuard(stallKey, stallTimeoutSeconds, headSha, base, prNumber, wait, reportForWork, reviewSummaryIds, opts.stallDeadlineSink, opts.persistSeen !== false), blockerGate);
|
|
375
374
|
}
|
|
375
|
+
const short = (oid) => oid.slice(0, 7);
|
|
376
|
+
const failed = (reason) => ({ status: "failed", reason });
|
|
377
|
+
const errMessage = (e) => (e instanceof Error ? e.message : String(e));
|
|
378
|
+
function receiptWaitLog(pr, outcome) {
|
|
379
|
+
const head = `WAIT: PR #${pr} reached ready-delay but`;
|
|
380
|
+
if (outcome.status === "blocked")
|
|
381
|
+
return `${head} GitHub reports BLOCKED, so its stack readiness receipt was not certified`;
|
|
382
|
+
if (outcome.persistFailure)
|
|
383
|
+
return `${head} its stack readiness receipt could not be persisted: ${outcome.reason}`;
|
|
384
|
+
return `${head} its stack readiness receipt was not certified: ${outcome.reason}`;
|
|
385
|
+
}
|
|
376
386
|
/**
|
|
377
387
|
* Persist a READY receipt from a fresh compact snapshot. `blocked` means the
|
|
378
|
-
* snapshot is ready except for GitHub's BLOCKED state; `failed`
|
|
379
|
-
* stale, or not-ready evidence
|
|
388
|
+
* snapshot is ready except for GitHub's BLOCKED state; `failed` carries the
|
|
389
|
+
* reason the receipt was not certified (missing, stale, or not-ready evidence,
|
|
390
|
+
* or a write error flagged `persistFailure`).
|
|
380
391
|
*/
|
|
381
392
|
async function recordReadyReceipt(key, report, context) {
|
|
382
|
-
if (report.status !== "READY"
|
|
383
|
-
report.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
393
|
+
if (report.status !== "READY")
|
|
394
|
+
return failed(`report status is ${report.status}, not READY`);
|
|
395
|
+
if (!report.headSha)
|
|
396
|
+
return failed("report has no head SHA");
|
|
397
|
+
if (!report.baseRefOid)
|
|
398
|
+
return failed("report has no base SHA");
|
|
399
|
+
let raw;
|
|
400
|
+
let fingerprint;
|
|
401
|
+
let summary;
|
|
389
402
|
try {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
return
|
|
403
|
+
raw = await receiptSummaryForReport(key, report, context);
|
|
404
|
+
const fresh = fingerprintRawSummaryPr(raw);
|
|
405
|
+
if (fresh === null)
|
|
406
|
+
return failed("fresh summary has no fingerprint");
|
|
407
|
+
fingerprint = fresh;
|
|
408
|
+
if (raw.state !== "OPEN")
|
|
409
|
+
return failed(`fresh summary shows PR ${raw.state}, not OPEN`);
|
|
410
|
+
if (raw.isDraft)
|
|
411
|
+
return failed("fresh summary shows PR as a draft");
|
|
412
|
+
if (raw.headRefOid !== report.headSha)
|
|
413
|
+
return failed(`head moved (report ${short(report.headSha)}, fresh ${short(raw.headRefOid)})`);
|
|
414
|
+
if (raw.baseRefOid !== report.baseRefOid)
|
|
415
|
+
return failed(`base moved (report ${short(report.baseRefOid)}, fresh ${short(raw.baseRefOid)})`);
|
|
397
416
|
// Summarize hydrates annotation totals onto the snapshot before the stored hash.
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
417
|
+
summary = await summarizePollSummaryPr(raw, { owner: key.owner, name: key.repo }, { stackPrNumber: report.pr });
|
|
418
|
+
}
|
|
419
|
+
catch (e) {
|
|
420
|
+
// The receipt is supplementary evidence. A transient summary fetch failure
|
|
421
|
+
// must not turn a completed one-PR poll into a different Shepherd action.
|
|
422
|
+
return failed(`fresh summary unavailable: ${errMessage(e)}`);
|
|
423
|
+
}
|
|
424
|
+
if (annotationProbeUnavailable(raw))
|
|
425
|
+
return failed("annotation probe unavailable");
|
|
426
|
+
const checks = summary.checks ?? {};
|
|
427
|
+
const review = summary.review ?? {};
|
|
428
|
+
if (!isCurrentSummaryReady(raw, checks, review)) {
|
|
429
|
+
const onlyBlocked = raw.mergeStateStatus === "BLOCKED" &&
|
|
430
|
+
!raw.isInMergeQueue &&
|
|
431
|
+
isCurrentSummaryReady(raw, checks, review, { allowBlocked: true });
|
|
432
|
+
return onlyBlocked
|
|
433
|
+
? { status: "blocked" }
|
|
434
|
+
: failed("fresh summary is not ready (checks, review, or merge state changed)");
|
|
435
|
+
}
|
|
436
|
+
const removalEvent = currentQueueRemovalEvent(raw);
|
|
437
|
+
// Bind recovery to the exact evidence the one-PR check accepted. A new ejection
|
|
438
|
+
// between that check and this fresh snapshot must get its own acknowledgment.
|
|
439
|
+
if (report.mergeQueue?.removalAcknowledged) {
|
|
440
|
+
const accepted = report.mergeQueue.latestRemoval;
|
|
441
|
+
if (raw.isInMergeQueue ||
|
|
442
|
+
!accepted ||
|
|
443
|
+
!removalEvent ||
|
|
444
|
+
removalEvent.beforeCommit?.oid !== accepted.beforeCommitOid ||
|
|
445
|
+
Math.floor(Date.parse(removalEvent.createdAt) / 1000) !== accepted.createdAtUnix ||
|
|
446
|
+
removalEvent.reason !== accepted.reason)
|
|
447
|
+
return failed("merge-queue removal evidence changed since the one-PR check");
|
|
448
|
+
}
|
|
449
|
+
try {
|
|
425
450
|
await writeReadyReceipt({
|
|
426
451
|
version: 1,
|
|
427
452
|
...key,
|
|
@@ -435,13 +460,10 @@ async function recordReadyReceipt(key, report, context) {
|
|
|
435
460
|
}),
|
|
436
461
|
recordedAtUnix: Math.floor(Date.now() / 1000),
|
|
437
462
|
});
|
|
438
|
-
return "written";
|
|
463
|
+
return { status: "written" };
|
|
439
464
|
}
|
|
440
|
-
catch {
|
|
441
|
-
|
|
442
|
-
// state-directory failure must not turn a completed one-PR poll into a
|
|
443
|
-
// different Shepherd action.
|
|
444
|
-
return "failed";
|
|
465
|
+
catch (e) {
|
|
466
|
+
return { status: "failed", reason: errMessage(e), persistFailure: true };
|
|
445
467
|
}
|
|
446
468
|
}
|
|
447
469
|
/** Clear a stale READY receipt; return whether a current receipt remains. */
|
|
@@ -36,7 +36,10 @@ export function mapCheckRunNode(node) {
|
|
|
36
36
|
return {
|
|
37
37
|
id: node.id,
|
|
38
38
|
name: node.name,
|
|
39
|
-
|
|
39
|
+
// GitHub can report a finished run (conclusion and/or completed_at set) with a stale
|
|
40
|
+
// status such as IN_PROGRESS. A recorded outcome means the run is completed; keep the
|
|
41
|
+
// reported conclusion as-is and invent nothing.
|
|
42
|
+
status: (node.conclusion ? "COMPLETED" : node.status),
|
|
40
43
|
conclusion: node.conclusion,
|
|
41
44
|
source: "check_run",
|
|
42
45
|
detailsUrl: node.detailsUrl ?? "",
|
package/package.json
CHANGED