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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
3
  "description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
4
- "version": "2.2.9",
4
+ "version": "2.2.10",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
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 56 PR states, it scores 0.97 with the plugin vs. 0.47 with `gh` + the GitHub MCP server ([outcome evals](evals/README.md), 2026-11-15).
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)).
@@ -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
- if (status !== "COMPLETED") {
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 receipt = receiptCurrent
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 && (receipt === "failed" || (receipt === "blocked" && opts.merge))) {
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: receipt === "blocked"
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` covers missing,
379
- * stale, or not-ready evidence and write errors.
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.mergeStatus.state !== "OPEN" ||
384
- report.mergeStatus.isDraft ||
385
- !report.headSha ||
386
- !report.baseRefOid ||
387
- reportReadinessGaps(report).length > 0)
388
- return "failed";
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
- const raw = await receiptSummaryForReport(key, report, context);
391
- if (fingerprintRawSummaryPr(raw) === null ||
392
- raw.state !== "OPEN" ||
393
- raw.isDraft ||
394
- raw.headRefOid !== report.headSha ||
395
- raw.baseRefOid !== report.baseRefOid)
396
- return "failed";
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
- const summary = await summarizePollSummaryPr(raw, { owner: key.owner, name: key.repo }, { stackPrNumber: report.pr });
399
- if (annotationProbeUnavailable(raw))
400
- return "failed";
401
- const fingerprint = fingerprintRawSummaryPr(raw);
402
- if (fingerprint === null)
403
- return "failed";
404
- const checks = summary.checks ?? {};
405
- const review = summary.review ?? {};
406
- if (!isCurrentSummaryReady(raw, checks, review)) {
407
- const onlyBlocked = raw.mergeStateStatus === "BLOCKED" &&
408
- !raw.isInMergeQueue &&
409
- isCurrentSummaryReady(raw, checks, review, { allowBlocked: true });
410
- return onlyBlocked ? "blocked" : "failed";
411
- }
412
- const removalEvent = currentQueueRemovalEvent(raw);
413
- // Bind recovery to the exact evidence the one-PR check accepted. A new ejection
414
- // between that check and this fresh snapshot must get its own acknowledgment.
415
- if (report.mergeQueue?.removalAcknowledged) {
416
- const accepted = report.mergeQueue.latestRemoval;
417
- if (raw.isInMergeQueue ||
418
- !accepted ||
419
- !removalEvent ||
420
- removalEvent.beforeCommit?.oid !== accepted.beforeCommitOid ||
421
- Math.floor(Date.parse(removalEvent.createdAt) / 1000) !== accepted.createdAtUnix ||
422
- removalEvent.reason !== accepted.reason)
423
- return "failed";
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
- // The receipt is supplementary evidence. A transient summary fetch or
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
- status: node.status,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "2.2.9",
3
+ "version": "2.2.10",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
5
5
  "keywords": [
6
6
  "automation",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
3
  "description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
4
- "version": "2.2.9",
4
+ "version": "2.2.10",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "2.2.9",
3
+ "version": "2.2.10",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for Codex.",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",