Skip to content

feat(skills): review GitHub PRs from pinned snapshots - #2038

Draft
lizhengfeng101 wants to merge 4 commits into
mainfrom
design/2025-native-pr-snapshots
Draft

lizhengfeng101 wants to merge 4 commits into
mainfrom
design/2025-native-pr-snapshots

Conversation

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Description

The native open-code-review skill can review a GitHub PR by number: 42 selects PR 42 in the GitHub CLI's default repository for the checkout, including an upstream default when working in a fork. The report identifies the resolved PR. pr 42, a full PR URL, and 42 --repo OWNER/REPO also work. This is a skill entry point, not a new ocr CLI flag. Local workspace, commit, and branch reviews keep their existing workflow.

Both installation layouts ship the same helper. It verifies GitHub's advertised commits, reviews the merge-base-to-head range once in a private detached worktree, and releases clean temporary resources without changing the caller's checkout. Before returning, it reports whether the snapshot is current, stale, or unverifiable. The native OCR result and run manifest remain available after cleanup.

Before merge

  • Isolate local MCP startup from the untrusted PR checkout.
  • Source the review policy independently of the proposed changes so the PR cannot narrow its own review coverage.

Validation

  • Ran make check, make test, the installed-helper contract suite, and the plugin manifest and link checks.
  • Exercised both installation layouts with real local Git histories: a non-default target, a dirty checkout, concurrent runs and interruption, moving revisions, a stale or unavailable freshness check, and cleanup failures.
  • Smoke-tested PR feat(skills): include behavior and impact in native and delegated reviews #2029 with real GitHub metadata and native OCR. The snapshot was current at the final check and cleanup completed. Line review skipped the Markdown-only diff; behavior analysis completed.

AI Disclosure

OpenAI Codex (gpt-6.2-astra) assisted with implementation, tests, and PR preparation. The pre-commit review used Open Code Review (configured model: claude-opus-4-6).

Refs #2025 and #2023.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 4 issue(s) in this PR.

  • ✅ Successfully posted inline: 4 comment(s)

Comment thread .github/workflows/plugin-contract.yml Outdated
Comment on lines +81 to +82
- name: Test installed PR review helpers
run: python3 scripts/github-actions/test_review_pr.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other · medium
Fragile runtime dependency: This job runs inside a node:24.22.1 container, which only includes Python 3 incidentally (via the Debian base image). This is not a guaranteed part of the Node.js image contract — a future image update or switch to a slimmer variant could remove Python and break this step.

Consider either:

  1. Running this step in a separate job with a python:3.x container, or
  2. Adding an explicit apt-get install -y python3 step before this, or
  3. Using actions/setup-python (though this may not work inside a container job).

This makes the dependency intentional and resilient to base image changes.

Comment on lines +72 to +73
command("git", "clone", "--bare", "--shared", "--single-branch", "--no-tags", "--template=",
"--", source, store, cwd=folder, env=dict(offline, GIT_ALLOW_PROTOCOL="file"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
Using --shared creates a bare clone whose object store references the source repository's objects via alternates. If the source repository undergoes garbage collection (git gc, git prune) while the review is in progress, objects needed for merge-base, rev-parse, or worktree operations can disappear, causing mid-review failures.

Consider using --dissociate alongside --shared to copy the necessary objects locally and sever the alternates link, or drop --shared entirely and accept the cost of a full local copy. This would make the review isolated from concurrent operations on the source repo.

if result.is_file():
summary["result"] = str(result)
try:
release(folder, summary.get("snapshot", {}).get("head"), offline)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · low
When lookup fails before setting snapshot in summary, this call passes head=None to release. While the current control flow makes it unlikely for the worktree to exist in that case, release compares git rev-parse HEAD output (a string) against None on line 96, which always evaluates as unequal and raises a misleading "worktree changed; retained" error. Adding an early guard would make the function robust against future refactoring:

def release(folder, head, env):
    store, tree = folder / "objects.git", folder / "worktree"
    if tree.exists():
        if head is None:
            raise ValueError("cannot verify worktree integrity: head revision unknown")
        ...

Comment on lines +35 to +38
def command(*args, cwd=None, env=None):
result = subprocess.run(args, cwd=cwd, env=env, text=True, stdout=subprocess.PIPE)
if result.returncode:
raise ValueError(f"{args[0]} {args[1]} exited {result.returncode} (see stderr)")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maintainability · medium
The error message says "(see stderr)" but stderr is not captured or included in the exception. Since subprocess.run here only captures stdout=subprocess.PIPE, stderr goes directly to the parent process's stderr stream and is not available in the exception. When this exception is caught and serialized into the manifest JSON (line 160), the user only sees the exit code with no diagnostic detail.

Consider capturing stderr and including it in the error message, e.g.:

result = subprocess.run(args, cwd=cwd, env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode:
    raise ValueError(f"{args[0]} {args[1]} exited {result.returncode}: {result.stderr.strip()}")

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant