Skip to content

feat(mr): expose viewer identity and permissions - #706

Merged
ImLunaHey merged 2 commits into
mainfrom
luna/dep-8717-viewer-permissions
Nov 18, 2026
Merged

ImLunaHey merged 2 commits into
mainfrom
luna/dep-8717-viewer-permissions

Conversation

@ImLunaHey

@ImLunaHey ImLunaHey commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Clients need the authenticated Depot user and the actions allowed on a merge request. Add depot mr viewer [--org] [--json], which works outside a checkout, and preserve the API's viewer and permission fields in depot mr view --json.

The command supports member agent-turn reads, validates the returned organization and identity, sanitizes text output, and reports a clear error when the server does not yet support viewer identity. Existing commands retain their behavior.

Validation: full go test ./..., CLI build, and focused golangci-lint passed. Tests cover viewer output, credential routing, mismatched identity, older APIs and permission JSON. Verified the unsupported-server error against the live API.

Rollout: deploy depot/api#7083 before releasing this CLI. Tracked in DEP-8717.

Created with GPT-6 Astra in Codex.

Catch up on this pull request in Depot


Note

Low Risk
Read-only CLI and proto additions with validation tests; behavior changes are additive and gated on new API fields.

Overview
Adds depot mr viewer to resolve the authenticated Depot user (and org) via a new GetViewer RPC—usable without a repo checkout, with --json, sanitized text output, graceful errors on older servers, and org mismatch checks.

Extends the merge-request API surface with MergeRequestActor.display_name, viewer and viewer_permissions on GetMergeRequestResponse, and the GetViewer / MergeRequestViewerPermissions messages; wires the Connect client and allows agent turn tokens for viewer alongside existing read-only view, list, and threads commands.

Reviewed by Cursor Bugbot for commit 52871bc. Bugbot is set up for automated code reviews on this repo. Configure here.

@linear-code

linear-code Bot commented Nov 18, 2026

Copy link
Copy Markdown

DEP-8717

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

🤖 Grok 4.6 responding on behalf of Cursor Approval Agent

Risk: medium. Approved. Cursor Bugbot completed successfully with no findings that need human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@claude claude Bot left a comment

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.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread pkg/cmd/mr/viewer.go Resolved

@claude claude Bot left a comment

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.

The latest commit fixes the earlier output nit: the text output now reads User: <id> (<name>) and leaves out the name when it is empty. I found no other bugs. A human should still look, because this adds a command to the list of commands an agent-turn token may run.

What was reviewed:

  • The turn-token allowlist in login (pkg/cmd/mr/mr.go). viewer goes through authenticateUser and then ResolveTurnReadAuth, the same path view, list and threads use, and sandbox_test.go covers it.
  • viewer.go: the check for older servers (Unimplemented, or Unknown with a "route not found" message), the response checks (missing org, missing user, non-USER actor, org mismatch), and text output sanitized through printable().
  • The proto additions are new field numbers and new messages only, so the wire format stays compatible. I did not compare the regenerated pb.go and connect code against a fresh buf generate run.
Extended reasoning...

The change adds a hidden, read-only depot mr viewer command, a GetViewer RPC, and new proto fields for viewer identity and permissions, mostly in generated code. The security-sensitive part is in pkg/cmd/mr/mr.go: the list of commands a Dispatch agent-turn token may run now includes viewer. That makes the read-only scope of turn tokens wider. The command only returns the caller's own identity and uses the read-only turn auth, so it looks intended, but widening a credential's scope is a decision a human should confirm. The PR also depends on an API rollout happening before this CLI is released.

@ImLunaHey
ImLunaHey merged commit 2f757a4 into main Nov 18, 2026
13 checks passed
@ImLunaHey
ImLunaHey deleted the luna/dep-8717-viewer-permissions branch November 18, 2026 13:03
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