fix(pr-reviewer): read PR state from GitHub VFS instead of gh CLI

Merged
KH
5mo ago
+207-31

Problem

Every pr-reviewer run was failing with spawn gh ENOENT. The sandbox snapshot ships no gh binary, but two code paths shelled out to gh pr view:

  • verifyReadyForHumanReview (controls the Slack "ready" ping) — added in e981031 (READY-sentinel CI guard)
  • readMergeOnGreenState (controls auto-merge) — added in #57 (merge-on-green)

Before those commits pr-reviewer never used gh. The harness commits via the cloud writeback and is explicitly "no git/gh" — these calls violated that.

Fix

Rebuild the same PullRequestReadyState the gate evaluators consume from the GitHub adapter's VFS projection instead of gh:

NeedVFS source
state, draft, labels, head.shapulls/{n}/meta.json
CI check rolluppulls/{n}/checks/_summary.json ({total,passed,failed,pending})
latest review per authorpulls/{n}/reviews/*.json
  • The adapter does not project mergeability, so conflict detection is delegated to the merge API — mergePullRequest() returns merged:false on a dirty PR and mergePr throws, so a conflicting PR can never auto-merge.
  • Every read fails closed: a missing/empty projection yields a state the gates treat as not-ready / pending, never a green light.
  • The tested pure evaluators (evaluateMergeOnGreenState, prReadyStateAllowsHumanReview) are unchanged; only the data source moved.

Behavior note

The merge-on-green gate now drops the "wait for a requested bot reviewer to approve" check (the VFS doesn't project reviewRequests). It still blocks on any bot's explicit CHANGES_REQUESTED, the merge-on-green label, and all-checks-green.

Test

  • npm run typecheck clean
  • 37/37 review tests pass (added coverage for the VFS→gate mapping: rollupFromCheckSummary, deriveReviewDecision)
  • Deploy bundle verified to contain checks/_summary.json/listReviews and zero gh references

🤖 Generated with Claude Code


Summary by cubic

Read PR state from the GitHub adapter VFS instead of gh to fix sandbox failures and restore ready pings and merge-on-green. Also hardens review/check parsing so malformed VFS entries never make a PR appear green.

  • Bug Fixes
    • Build PullRequestReadyState from VFS: pulls/{n}/meta.json (state/draft/labels/head SHA), pulls/{n}/checks/_summary.json → statusCheckRollup, and pulls/{n}/reviews/*.json → latest review per author.
    • Harden VFS parsing: ignore malformed reviews/*.json entries and derive total from failed+pending+passed when missing so failing/pending checks still block.
    • Missing/empty projections default to “not ready”; conflicts are handled by the merge API (no auto-merge on conflicts).
    • Behavior: removed the “requested bot reviewer must approve” check (no reviewRequests in VFS). Still blocks on any bot CHANGES_REQUESTED, requires the merge-on-green label, and all checks green.