Skip to content

feat(web): select roles when creating a workbench/agent (CL-9780) - #1093

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-9780-select-roles-at-create
Oct 3, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-9780-select-roles-at-create

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Role selection is part of the create basics UI: both create surfaces offer the tenant's live platform roles as checkboxes (agent panel: the workbench's roles; new-workbench picker: the workspace's system roles, the portable set for a fresh tenant), so a new agent starts with the right grants.

  • Selections travel as role names into NewAgentInput and CreateWorkbenchInput, resolve to per-tenant ids against live platform roles (fail fast on unknown names, before anything installs/deploys), and assign to the agent's workflow principal via the stock assign route once the install lands.
  • Reads gate the submit on both surfaces: a roles fetch that hasn't resolved (loading/error/signed-out) blocks creating, with retry — a failed read never silent-fallbacks to role-less creation.
  • Fail-closed throughout: unknown name, missing principal (fresh agent, no first run yet), or refused write aborts with user-safe copy. A fresh create that selects roles lands in the created workbench/agent with guidance (open so the agent runs, then Settings or resubmit); the default empty selection is behavior-identical to before.
  • Tests: apps/web/src/agent-roles.test.ts (13 tests over a stubbed stock API: name resolution, principal matching incl. pagination/removed-skipping, ordered idempotent-safe assignment, no-op empties).

Known limitation (accepted for now): the platform mints an agent's workflow principal at its first run, not at deploy — a deployment's run principal is reserved on first delivery (see commitRunGrants), so there is nothing to assign roles to on a brand-new agent. Selecting roles on a fresh create therefore fails closed after the deploy lands (workbench/agent in place, honest error with the remedy: let the agent run once, then resubmit/retry or assign in Settings). Redeploys of agents that have already run assign cleanly. If we want roles to land on first run with no retry, that needs a platform mechanism (e.g. definition-level role requirements) — follow-up.

Verification: web typecheck clean, repo typecheck/lint/fmt:check green (lint: 0 errors; 3 pre-existing warnings in apps/sidecar), @workbench/web tests 98 pass / 0 fail, vite build clean. Full-repo test run has 7 failing packages in unrelated areas (hub/worker/workflows/deferred-tools/url-path/approvals/e2e) with environmental signatures (shared-DB sidecar leases, missing tmp module); none depends on apps/web.

Both create surfaces offer the tenant's live platform roles as
checkboxes. Selections travel as role names into NewAgentInput and
CreateWorkbenchInput, resolve to per-tenant ids against live roles
(fail fast on unknown names), and assign to the agent's workflow
principal via stock role routes once the install lands. Reads gate
the submit so a failed roles fetch never silent-fallbacks; a fresh
agent with no first run yet fails closed with its deploy in place.
@linear-code

linear-code Bot commented Oct 3, 2026

Copy link
Copy Markdown

CL-9780

@TheGreatAxios
TheGreatAxios merged commit bc7cc9c into main Oct 3, 2026
3 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-9780-select-roles-at-create branch October 3, 2026 17:07
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