From 3d8be54ba52a67c4f2b55d776afc12dfe11f7658 Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Thu, 1 Oct 2026 10:19:18 -0400 Subject: [PATCH 1/2] feat(#6966): make the review role's repo read-only in agent new The fleet's review harness sets readonly_repo, so the checked-out repository is read-only in the sandbox and a reviewer cannot modify the code it reviews. A review agent generated by `fullsend agent new` did not set it. Add ReadonlyRepo to the role table, set it for review only, and carry it into the generated harness. Tests pin the role table and the emitted harness YAML; docs/cli/agent.md notes it under the role table. The triage and validation-loop goldens are unaffected. Assisted-by: Claude (fix), Claude (review) Signed-off-by: Wayne Sun --- docs/cli/agent.md | 2 ++ internal/agentnew/render.go | 1 + internal/agentnew/render_test.go | 6 ++++++ internal/agentnew/roles.go | 11 ++++++++--- internal/agentnew/roles_test.go | 12 ++++++++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/cli/agent.md b/docs/cli/agent.md index e413df7220..18a304981d 100644 --- a/docs/cli/agent.md +++ b/docs/cli/agent.md @@ -146,6 +146,8 @@ command refuses an unknown one up front. The hosted mint serves these: | `retro` | `actions:read`, `contents:read`, `pull_requests:write`, `issues:write`, `metadata:read` | vertex-ai, github-ro, github-artifacts | | `prioritize` | `contents:read`, `issues:write`, `organization_projects:write`, `metadata:read` | vertex-ai, github-ro | +A `review` agent also gets `readonly_repo: true`: the checked-out repository is made read-only in the sandbox, so a reviewer cannot modify the code it reviews. That matches `harness/review.yaml` in fullsend-ai/agents. + Pick the role whose permissions fit what the agent does. An unknown role fails immediately with this table, rather than returning `403` from the mint the first time the agent runs. To use a role the hosted mint does not serve, you diff --git a/internal/agentnew/render.go b/internal/agentnew/render.go index 5e917bc0d8..ca0ed2935d 100644 --- a/internal/agentnew/render.go +++ b/internal/agentnew/render.go @@ -105,6 +105,7 @@ func buildHarness(opts Options, role Role) (*harness.Harness, error) { Effort: opts.Effort, PostScript: "scripts/post-" + opts.Name + ".sh", TimeoutMinutes: opts.TimeoutMinutes, + ReadonlyRepo: role.ReadonlyRepo, Trigger: opts.Trigger, Env: &harness.EnvConfig{ Runner: map[string]string{ diff --git a/internal/agentnew/render_test.go b/internal/agentnew/render_test.go index 64515f25be..0baf6b8302 100644 --- a/internal/agentnew/render_test.go +++ b/internal/agentnew/render_test.go @@ -375,6 +375,12 @@ func TestRoleImageReachesTheHarness(t *testing.T) { if h.OpenShell == nil || !reflect.DeepEqual(h.OpenShell.Profiles, role.Profiles) { t.Errorf("role %q: profiles = %v, want %v", name, h.OpenShell, role.Profiles) } + // readonly_repo must survive into the emitted YAML, not only sit on + // the Role struct: a generated review harness that ships writable + // lets the reviewer modify the code it reviews. + if h.ReadonlyRepo != role.ReadonlyRepo || h.ReadonlyRepo != (name == "review") { + t.Errorf("role %q: readonly_repo = %v, want %v", name, h.ReadonlyRepo, name == "review") + } seen[role.Image] = true } // Both image constants must be reachable, or one is dead configuration. diff --git a/internal/agentnew/roles.go b/internal/agentnew/roles.go index 461672b81b..70cb78e882 100644 --- a/internal/agentnew/roles.go +++ b/internal/agentnew/roles.go @@ -38,6 +38,10 @@ type Role struct { Profiles []string // Image is the sandbox image this role's agents run under. Image string + // ReadonlyRepo mirrors the fleet: the review harness makes the checked-out + // repository read-only in the sandbox, so a reviewer cannot modify the + // code it reviews. Set for roles whose fleet harness sets `readonly_repo`. + ReadonlyRepo bool } // roleTable is the set of roles `agent new` will generate for. Excluded on @@ -60,9 +64,10 @@ var roleTable = map[string]Role{ "contents": "read", "pull_requests": "write", "issues": "write", "checks": "read", "metadata": "read", }, - Providers: []string{"providers/vertex-ai.yaml", "providers/github-ro.yaml"}, - Profiles: []string{"profiles/fullsend-vertex-ai.yaml", "profiles/fullsend-github-ro.yaml"}, - Image: config.DefaultCodeImage, + Providers: []string{"providers/vertex-ai.yaml", "providers/github-ro.yaml"}, + Profiles: []string{"profiles/fullsend-vertex-ai.yaml", "profiles/fullsend-github-ro.yaml"}, + Image: config.DefaultCodeImage, + ReadonlyRepo: true, }, "coder": { Name: "coder", diff --git a/internal/agentnew/roles_test.go b/internal/agentnew/roles_test.go index 0208526ac0..50a18ed7af 100644 --- a/internal/agentnew/roles_test.go +++ b/internal/agentnew/roles_test.go @@ -126,3 +126,15 @@ func TestCoderUsesEmbeddedGithubProvider(t *testing.T) { t.Errorf("coder should use providers/github.yaml, got %v", role.Providers) } } + +// TestReviewRoleMountsTheRepositoryReadOnly pins fleet parity: the review +// harness in fullsend-ai/agents sets readonly_repo, and only the review role +// does. +func TestReviewRoleMountsTheRepositoryReadOnly(t *testing.T) { + for _, r := range roleTable { + want := r.Name == "review" + if r.ReadonlyRepo != want { + t.Errorf("role %s: ReadonlyRepo = %v, want %v", r.Name, r.ReadonlyRepo, want) + } + } +} From 6fb93c3975c6b51f7ce7d81f9beea301b7bf547c Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Thu, 1 Oct 2026 11:42:11 -0400 Subject: [PATCH 2/2] test(#6966): iterate the role table in name order in the readonly test Use RoleNames() for a deterministic order and %q for the role name, like the other role-table tests. Assisted-by: Claude (fix), Claude (review) Signed-off-by: Wayne Sun --- internal/agentnew/roles_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/agentnew/roles_test.go b/internal/agentnew/roles_test.go index 50a18ed7af..2cc3fea0db 100644 --- a/internal/agentnew/roles_test.go +++ b/internal/agentnew/roles_test.go @@ -131,10 +131,10 @@ func TestCoderUsesEmbeddedGithubProvider(t *testing.T) { // harness in fullsend-ai/agents sets readonly_repo, and only the review role // does. func TestReviewRoleMountsTheRepositoryReadOnly(t *testing.T) { - for _, r := range roleTable { - want := r.Name == "review" - if r.ReadonlyRepo != want { - t.Errorf("role %s: ReadonlyRepo = %v, want %v", r.Name, r.ReadonlyRepo, want) + for _, name := range RoleNames() { + want := name == "review" + if got := roleTable[name].ReadonlyRepo; got != want { + t.Errorf("role %q: ReadonlyRepo = %v, want %v", name, got, want) } } }