Skip to content

fix(pr-management): post code reviews through the REST reviews endpoint - #2353

Closed
potiuk wants to merge 1 commit into
apache:mainfrom
potiuk:fix/review-post-rest
Closed

potiuk wants to merge 1 commit into
apache:mainfrom
potiuk:fix/review-post-rest

Conversation

@potiuk

@potiuk potiuk commented Nov 26, 2026

Copy link
Copy Markdown
Member

Summary

  • pr-management code-review render posted every review with inline threads as a GraphQL addPullRequestReview mutation (gh api graphql --input …).
    The public-surface scrub hook in magpie-security can only set the framework's own tool names aside on a command that provably targets apache/magpie, and a GraphQL mutation addresses a node id, so it never can (by design since fix(security-guard): trust the directory for framework identifiers only when it names the repository #2143).
    Result: any review on a Magpie PR whose text names the Vulnogram adapter's directory under tools/ is blocked as an embargo-term disclosure, even though the same review sent to repos/apache/magpie/pulls/<N>/reviews passes.
  • render now writes one REST payload for every review (body-only or with threads) and prints gh api repos/<repo>/pulls/<N>/reviews -X POST --input <payload>.
    The payload carries event, body, comments[{path, line, side, body}], and commit_id pinned to the head the review was drafted against.
  • posting.md and the pr-management spec describe the REST post; the "empty output means success" note (true of gh pr review, not of the REST call) becomes "never re-run the post, count the viewer's reviews".
    The renamed heading's one inbound link (stack-review/SKILL.md) is updated; both skills are restamped.
  • The scrub hook itself is unchanged: refusing to trust a GraphQL mutation's target is right; the posting path was the part to change.

Found while reviewing #2194, whose review was blocked by the scrub until it was re-sent over REST.

Type of change

  • Python package (tools/pr-management, plugin mirror synced)
  • Skill change (code-review/posting.md, link fix in stack-review/SKILL.md)
  • Other: spec (tools/spec-loop/specs/pr-management-family.md)

Test plan

  • uv run --project tools/pr-management pytest tools/pr-management/tests: all pass except the two test_policy_grants tests, which read .apache-magpie-overrides/tools/vetted-ops/config.toml and fail only because the sandboxed scratch checkout cannot contain that path (unchanged by this PR).
  • Updated tests: the render test asserts the REST command (repository in the path) and the payload shape; test_body asserts the full payload with commit_id and a body-only payload without comments.
  • prek run --files <changed> passes (lychee, skill-surface-hash, skill-and-tool-validate, ruff, mypy).
  • No eval step extracts posting.md.

Generative AI disclosure

Drafted with Claude Code (Opus 5); I reviewed the diff and the test run.

🤖 Generated with Claude Code

`code-review render` posted a review with inline threads as a GraphQL
`addPullRequestReview` mutation. A GraphQL mutation addresses a node
id, so the public-surface scrub cannot tell which repository it goes
to and never sets the framework's own tool names aside for it: every
review of a Magpie PR that names `tools/cve-tool-vulnogram/` was
blocked, while the same review sent to the REST endpoint passes.

`render` now writes one payload for every review, body-only or with
threads, and prints `gh api repos/<repo>/pulls/<N>/reviews -X POST
--input <payload>`. The payload also pins the review to the head it
was drafted against (`commit_id`).

Generated-by: Claude Opus 5
@potiuk potiuk added family:pr-management pr-management-* skills capability:review Deep per-item code review or contributor mentoring labels Nov 26, 2026
@potiuk
potiuk enabled auto-merge (squash) November 26, 2026 09:55
@github-actions github-actions Bot added family:tools tools/* substrate:analytics Tool substrate: read-only metrics / dashboards / renderers family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json labels Nov 26, 2026
@potiuk

potiuk commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

Superseded: this change landed on main as part of #2355 (0d808e0), which was stacked on this branch. Closing.

@potiuk potiuk closed this Nov 26, 2026
auto-merge was automatically disabled November 26, 2026 11:26

Pull request was closed

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

Labels

capability:review Deep per-item code review or contributor mentoring family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json family:pr-management pr-management-* skills family:tools tools/* substrate:analytics Tool substrate: read-only metrics / dashboards / renderers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant