Skip to content

🌱 narrow the reviewer token back to pull_requests: read now that the audited relay works #7487

Description

@clubanderson

Summary

#7472 gave the reviewer token tier pull_requests: write so an advisory reviewer could post its verdict. It merged before we established that hive already had a sanctioned route for this. Now that #7486 makes that route usable, the token grant should be narrowed back to pull_requests: read.

Why

Hive's pattern everywhere else is that the governor performs the write, not the agent: issue_request_watcher.go, pr_request_watcher.go, merge_request_watcher.go all take a request file from an agent and execute it with the App token. review_request_watcher.go is the review analogue, and its doc comment is explicit that this is the intended route:

An agent that wants to review a PR writes a request file here INSTEAD of running gh pr review from its own shell. The hive's watcher submits the review with the App token, so the review is authored by the App bot AND — unlike a direct agent-CLI review, which the hive never observes — it is recorded on the audit/activity trail.

With #7486 merged, an ADVISORY + converse: true reviewer can use that relay. The direct-token grant from #7472 is then redundant — and not neutral:

  • Attribution. A relay review is authored by the App bot. A direct-token review is authored by the agent's own identity, outside the App's activity trail.
  • Observability. The hive never sees a direct gh pr review. It is not on the audit trail, so it does not appear in activity counts or SLA accounting.
  • Canary / exfiltration. The relay runs review bodies through scanCanaryText with the fail-closed contract added in kubestellar/hive#4960. The direct path skips it.
  • Incentive. Leaving both routes open means the easier one wins, and the easier one is the one we cannot see.

Proposed change

  • Revert the pull_requests: write grant in the reviewer case of pkg/github/app.go back to read.
  • Keep the reviewer tier itself — it is still the right tier, and contents: read / metadata: read are correct.
  • Keep pkg/agentmode.TokenTierForRole and its tests; the role plumbing is independent of the permission level.
  • Confirm the reviewer's config carries converse: true before landing, so the relay route is live when the direct route closes.

Sequencing

Do not land this until a reviewer has actually posted through the relay on the projectbluefin spoke and it is observed on the audit trail. Narrowing the token first would leave the reviewer with no working route at all — which is the state #7485 described.

Verification note

The permission assertions from #7472 already exist in pkg/github/reviewer_tier_permissions_test.go and pin pull_requests presence, so this change is a one-line flip plus updating those expectations.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions