Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(control-ui): derive connector access teams/users from agent grants

Miguelon Peluchon983acb95f7b1
diff --git a/control-ui/app/mcp-servers/[name]/edit/page.tsx b/control-ui/app/mcp-servers/[name]/edit/page.tsx
index b3f88e80a..47f7adfd0 100644
--- a/control-ui/app/mcp-servers/[name]/edit/page.tsx
+++ b/control-ui/app/mcp-servers/[name]/edit/page.tsx
@@ -21,8 +21,8 @@ import {
import { CONTROL_ROUTES } from '@constants/routes'
import { getAgentDisplayName } from '@lib/agentName'
import {
- getContextTeams,
- getContextUsers,
+ getAgentTeams,
+ getAgentUsers,
getContexts,
getHosts,
getMcpServer,
@@ -200,31 +200,45 @@ export default function EditMcpServerPage() {
setContextAccessError('')
void (async () => {
- const [hostsResults, contextResults] = await Promise.all([
- Promise.allSettled([getHosts()]),
- Promise.all(
- contextNames.map(async contextName => {
- const [usersResult, teamsResult] = await Promise.allSettled([
- getContextUsers(contextName),
- getContextTeams(contextName),
- ])
- return { contextName, usersResult, teamsResult }
- })
+ // Resolve the AGENTS whose scopes carry this connector, then read their
+ // user/team grants — the same mappings operators manage in Users &
+ // Teams — instead of the legacy scope-centric context sub-resources.
+ const hostsResult = await Promise.allSettled([getHosts()])
+ if (cancelled) return
+
+ const hosts = hostsResult[0].status === 'fulfilled' ? (hostsResult[0].value.items ?? []) : []
+ const contextNameSet = new Set(contextNames)
+ const owningAgents = [
+ ...new Set(
+ hosts
+ .map(host => {
+ const ref = String(host.spec?.contextRef ?? '').trim()
+ return contextNameSet.has(ref) ? String(host.metadata?.name ?? '') : ''
+ })
+ .filter(Boolean)
),
- ])
+ ]
+
+ const agentResults = await Promise.all(
+ owningAgents.map(async agentName => {
+ const [usersResult, teamsResult] = await Promise.allSettled([
+ getAgentUsers(agentName),
+ getAgentTeams(agentName),
+ ])
+ return { agentName, usersResult, teamsResult }
+ })
+ )
if (cancelled) return
- const hostsResult = hostsResults[0]
const failed =
- hostsResult.status === 'rejected' ||
- contextResults.some(
+ hostsResult[0].status === 'rejected' ||
+ agentResults.some(
result =>
result.usersResult.status === 'rejected' || result.teamsResult.status === 'rejected'
)
- const hosts = hostsResult.status === 'fulfilled' ? (hostsResult.value.items ?? []) : []
setContextAccess(
mergeAccessSummaries(
- contextResults.map(({ contextName, usersResult, teamsResult }) => ({
+ agentResults.map(({ agentName, usersResult, teamsResult }) => ({
users:
usersResult.status === 'fulfilled'
? sortAccessPrincipals(
@@ -243,14 +257,12 @@ export default function EditMcpServerPage() {
}))
)
: [],
- agents: sortAccessPrincipals(
- hosts
- .filter(host => String(host.spec?.contextRef ?? '').trim() === contextName)
- .map(host => {
- const agentName = host.metadata?.name || 'unknown'
- return { id: agentName, label: getAgentDisplayName(agentName) || agentName }
- })
- ),
+ agents: [
+ {
+ id: agentName,
+ label: getAgentDisplayName(agentName) || agentName,
+ },
+ ],
}))
)
)
diff --git a/control-ui/app/mcp-servers/page.tsx b/control-ui/app/mcp-servers/page.tsx
index 75e8618ed..b0bf380eb 100644
--- a/control-ui/app/mcp-servers/page.tsx
+++ b/control-ui/app/mcp-servers/page.tsx
@@ -16,8 +16,8 @@ import type {
import { useToast } from '../../components/Toast'
import {
apiSend,
- getContextTeams,
- getContextUsers,
+ getAgentTeams,
+ getAgentUsers,
getContexts,
getHosts,
getMcpServers,
@@ -107,21 +107,22 @@ function bindingsByConnectorFromContexts(
return bindings
}
-// User/team access summaries stay context-derived (read-only groups in the
-// table); the agents group itself comes from the bindings above.
-async function loadContextAccess(
- contextRef: string
+// User/team access summaries ride the AGENTS that carry the connector (the
+// same grants operators make in Users & Teams ▸ Access/Agents tabs), not the
+// legacy scope-centric context mappings. Read-only groups in the table.
+async function loadAgentAccess(
+ agentName: string
): Promise<readonly [ConnectorAccessSummary, boolean]> {
const [usersResult, teamsResult] = await Promise.allSettled([
- getContextUsers(contextRef),
- getContextTeams(contextRef),
+ getAgentUsers(agentName),
+ getAgentTeams(agentName),
])
const accessLoadFailed = usersResult.status === 'rejected' || teamsResult.status === 'rejected'
if (usersResult.status === 'rejected') {
- console.warn(`Failed to load users for context ${contextRef}:`, usersResult.reason)
+ console.warn(`Failed to load users for agent ${agentName}:`, usersResult.reason)
}
if (teamsResult.status === 'rejected') {
- console.warn(`Failed to load teams for context ${contextRef}:`, teamsResult.reason)
+ console.warn(`Failed to load teams for agent ${agentName}:`, teamsResult.reason)
}
const users =
usersResult.status === 'fulfilled'
@@ -200,23 +201,23 @@ export default function McpServersPage() {
const nextAgentTargets = agentTargetsFromHosts(hosts)
const nextBindings = bindingsByConnectorFromContexts(nextContexts, nextAgentTargets)
- // Read-only user/team summaries are merged across the agent-owned
- // scopes that carry each connector (bindings), so the visible access
- // grid never depends on invisible orphan contexts.
- const managedContextRefs = [
+ // Read-only user/team summaries are merged across the AGENTS that
+ // carry each connector (bindings), matching the grants operators see
+ // in Users & Teams — never the legacy scope-centric mappings.
+ const managedAgentNames = [
...new Set(
Object.values(nextBindings)
.flat()
- .map(binding => binding.contextRef)
+ .flatMap(binding => binding.agents.map(agent => agent.id))
),
]
const accessResults = await Promise.all(
- managedContextRefs.map(
- async contextRef => [contextRef, await loadContextAccess(contextRef)] as const
+ managedAgentNames.map(
+ async agentName => [agentName, await loadAgentAccess(agentName)] as const
)
)
- const accessByContext = new Map(
- accessResults.map(([contextRef, [summary]]) => [contextRef, summary] as const)
+ const accessByAgent = new Map(
+ accessResults.map(([agentName, [summary]]) => [agentName, summary] as const)
)
const accessLoadFailed = accessResults.some(([, [, failed]]) => failed)
if (accessLoadFailed) {
@@ -228,12 +229,13 @@ export default function McpServersPage() {
(acc, connector) => {
const connectorName = resourceName(connector)
const connectorBindings = nextBindings[connectorName] ?? []
- const bindingRefs = connectorBindings.map(binding => binding.contextRef)
- if (bindingRefs.length > 0) {
+ const bindingAgentNames = connectorBindings.flatMap(binding =>
+ binding.agents.map(agent => agent.id)
+ )
+ if (bindingAgentNames.length > 0) {
const merged = mergeAccessSummaries(
- bindingRefs.map(
- contextRef =>
- accessByContext.get(contextRef) ?? { agents: [], users: [], teams: [] }
+ bindingAgentNames.map(
+ agentName => accessByAgent.get(agentName) ?? { agents: [], users: [], teams: [] }
)
)
// The agents group must reflect the bindings (the write model) so
diff --git a/control-ui/e2e/qa-recorder-recipe-scope-copy.spec.ts b/control-ui/e2e/qa-recorder-recipe-scope-copy.spec.ts
index 997e8bcc9..4a513fedf 100644
--- a/control-ui/e2e/qa-recorder-recipe-scope-copy.spec.ts
+++ b/control-ui/e2e/qa-recorder-recipe-scope-copy.spec.ts
@@ -157,17 +157,21 @@ test.describe('optional QA recorder: Control UI recipe connector-scope copy', ()
const primaryAction = page.locator('.cu-create-actions button')
await primaryAction.filter({ hasText: 'Review manifest' }).click()
-
- // The L1 policy blocks the review itself: the review findings show a
- // blocking error carrying the connector-scope wording (the deploy-path
- // "Cannot deploy" banner appears at the Access step, which the pinned
- // error prevents reaching).
- await expect(page.getByText(/Manifest review failed/)).toBeVisible({ timeout: 20_000 })
- const findings = page.getByRole('region', { name: 'Review findings' })
- await expect(findings).toBeVisible()
- await expect(findings).toContainText('shared connector scope')
- await expect(findings).toContainText('WRC will auto-create a private connector scope')
- await expect(findings).not.toContainText('private Context')
+ await expect(page.getByText(/Manifest review passed/)).toBeVisible()
+ await screenshotAndLog(page, testInfo, 'control-ui-recipe-agentic-manifest-review')
+
+ // L1 is a live deploy-time check (not part of the review findings), so
+ // the walk proceeds to the Access & deploy step where the policy banner
+ // fires with the connector-scope wording.
+ await primaryAction.filter({ hasText: 'Apply defaults' }).click()
+ await primaryAction.filter({ hasText: 'Continue to access' }).click()
+
+ const banner = page.locator('.cu-recipe-status-panel--error[role="alert"]')
+ await expect(banner).toBeVisible({ timeout: 20_000 })
+ await expect(banner).toContainText('Cannot deploy: policy violation')
+ await expect(banner).toContainText('shared connector scope')
+ await expect(banner).toContainText('WRC will auto-create a private connector scope')
+ await expect(banner).not.toContainText('private Context')
await screenshotAndLog(page, testInfo, 'control-ui-recipe-agentic-scope-banner')
// (b) Transport workload, no spec.contextRef — the INFO note about the
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 7e0f771e7..a48c0df04 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.469",
+ "version": "0.1.470",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.469",
+ "version": "0.1.470",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-ui/package.json b/control-ui/package.json
index d21d4c8db..523b5475e 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.469",
+ "version": "0.1.470",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/docs/features/control-ui-context-removal.md b/docs/features/control-ui-context-removal.md
index 78b7a0ac2..873738521 100644
--- a/docs/features/control-ui-context-removal.md
+++ b/docs/features/control-ui-context-removal.md
@@ -80,6 +80,7 @@ Old `/contexts/*` bookmarks are redirected (see §6.3), not 404'd. For the full
| D4 | Access model naming | Users/teams "Contexts" tabs → **"Access"** tabs; rows labeled with resolved agent names; writes unchanged |
| D5 | Context deletion guardrail | Moot: after Category A removal there is **no user-facing context-delete path** left in the UI |
| D6 | Multi-agent GFS mounts via context detail | **Accepted loss** of that surface (was the only multi-agent mount UI). Single-agent GFS access continues via existing GFS grant surfaces; documented for product follow-up |
+| D7 | Connector access-grid people | The connectors list + connector-edit Access tab derive Teams/Users from the **agent-centric grants** (`/admin/agents/:name/{users,teams}`) merged across the connector's agents — NOT from the legacy scope-centric `/admin/contexts/:id/{users,teams}`. The operator's chain: connector → agent (scope allowlist) → user/team (Access/Agents tabs). Connector↔user/team direct grants remain out of scope (would need backend) |
**Backend changes required:** none. (Explicitly verified per phase; any backend need would be listed here.)
@@ -110,12 +111,12 @@ Tests updated in the same commit: `HostTable.test.tsx` (hover card now asserts a
- Contexts with **no owning agent** (e.g. per-install or workflow-recipe private contexts) are intentionally invisible here — they are not user-managed scopes.
- "Add contexts" → **"Add agents"** modal: multi-select of *agents* (by display name) that don't already have the connector; submit writes the connector into each selected agent's private context.
- Subtitle "Browse connector deployments and context bindings." → "Browse connector deployments and agent access."
-- The Agents/Teams/Users read-only summary groups stay exactly as they are (they were already context-free).
+- The read-only **Teams/Users** groups now ride the **agent grants** (`GET /admin/agents/:name/users|teams`, merged across the connector's agents) instead of the legacy scope-centric `GET /contexts/:id/users|teams` — they show exactly the people/teams an operator granted in Users & Teams, matching the "connectors ride agents; people ride scopes/agents" model (decision D7).
### 5.2 Connector edit page (`/connectors/<name>/edit`)
- Tab `context`/"Context" → tab `access`/"Access" (redirect added for old `/connectors/<name>/edit/context`).
-- Section "Context access" → **"Agent access"**: read-only Agents/Teams/Users groups (same data calls: `getContexts` + `getContextUsers/Teams` per binding + hosts join). The `Contexts: <names>` line is gone; agents are the resolved truth.
+- Section "Context access" → **"Agent access"**: read-only Agents/Teams/Users groups. Data path: `getContexts` (find scopes carrying the connector) → hosts join (owning agents) → per-AGENT `getAgentUsers/getAgentTeams` grants (D7). The `Contexts: <names>` line is gone; agents are the resolved truth.
- Page subtitle no longer mentions "context access".
### 5.3 Create connector (`/connectors/new`)
@@ -281,6 +282,7 @@ Tests updated in the same commit: `HostTable.test.tsx` (hover card now asserts a
| 2026-08-27 | e2e | Video-format answer + MP4 pipeline: Playwright/Chromium records **WebM** natively (not MP4) — `qa:recorder:convert-mp4` added (`scripts/qa-recorder/convert-videos-mp4.sh`, ffmpeg H.264 + faststart, `--replace` to drop originals; round-trip verified against a synthetic clip). Recorder doc + §9 updated. **No video evidence exists yet anywhere in `.local-notes/` — zero journeys have been executed in this lane; videos are produced only when a journey runs against a live cluster.** |
| 2026-08-28 | e2e | **Execution campaign (mock-backed).** Full T2 bootstrap was ruled out on this host (7 GB RAM, ~3 available → OOM risk; both minikube profiles Stopped, stale branch.mk ownership → fail-closed per repo rules). Instead: built `scripts/qa-recorder/mock-control-api.mjs` — an in-memory control-api implementing the audited wire contract (auth cookie, resourceVersion/409 semantics, users/teams contexts mappings with deleted-history, hosts/contexts/mcp-servers CRUD, registry entries + install, budgets, recipes, rotation `DeploymentReady` simulation) — and ran the REAL control-ui dev server against it. Environment fights solved along the way: mock must bind dual-stack (`localhost` → `::1` first for Playwright's request context); Next dev daemon ignores env/port and grabs its own port (verify + set `CONTROL_UI_URL` per run); each playwright invocation wipes the outputDir (run batches in ONE invocation, copy evidence out after). Spec fixes found by real rendering: connectors rows use `role="button"` (kills `row` role; target `Expand/Collapse connector <name>`), team Access rows are `listitem`s, sort headers expose `Sort by access …` aria-names, tombstone rows persist after removal (assert actionability, not absence), toasts stack (`.last()`), 10s auto-refresh detaches click targets (retry), journeys must re-navigate after seeding (login pre-seed landing makes sidebar clicks no-ops). |
| 2026-08-28 | e2e | **Two REAL production bugs found by the journeys, fixed in `f2eebbc8a`:** (1) member detail page crashed wholesale — `accessLabeler` useMemo was declared after its consumer in `availableContextOptions` (TDZ ReferenceError; no unit tests covered those pages); (2) connectors-page search-by-agent silently broke in the Phase-1 rework (`summary.agents` emptied while the search haystack still reads it). Both fixed; search-by-agent locked with a new unit regression test (`McpServerTable.test.tsx`); unit suite now **1701/1701**, `tsc` clean. |
+| 2026-08-28 | D7 | **Connector access grid now rides agent grants** (operator decision after flow review): connectors list + connector-edit Access tab fetch Teams/Users via `GET /admin/agents/:name/{users,teams}` merged across each connector's agents, replacing the legacy scope-centric `GET /admin/contexts/:id/{users,teams}` reads. Wire untouched (both endpoints already existed); `getContextUsers/getContextTeams` no longer called from the connectors surfaces. Mock control-api gained the agent-grant endpoints (reverse of the Users & Teams mappings). Verified: `tsc` clean, unit suite 1701/1701 (one unrelated 5s-timeout flake re-run green), and the affected recorder journeys re-executed green against the live mock stack (connectors-agent-access, connector-edit ×2 incl. the rotation journey). Canonical chain documented as: connector → agent (scope allowlist) → user/team (grants). |
| 2026-08-28 | ops | Operator stopped the machine mid-run (commit `3daf915d8` preserved the in-flight spec fixes — thank you). The interrupted final invocation still produced **37 passing journeys / 51 WebM videos + 132 PNG proofs**, preserved in `.local-notes/qa-recorder/evidence-final/`. Two core journeys (marketplace-install, recipe-scope-copy) were environment-killed mid-flight and re-queued; their root causes were fixed (recipe fixture needed `spec.triggers`; the L1 banner fires at the deploy step, not review — verified via validator probe: `validateRecipe` excludes the L1 check by design). Pre-existing journeys needing real cluster depth (rotation-demo, cost-usage/governance, llm-lifecycle/price, invitations, gfs) fail against the mock by design — they belong to the cluster/T2 lane. |
## 11. Post-implementation audit (2026-08-27)
diff --git a/scripts/qa-recorder/mock-control-api.mjs b/scripts/qa-recorder/mock-control-api.mjs
index da3c9bf21..470ace535 100644
--- a/scripts/qa-recorder/mock-control-api.mjs
+++ b/scripts/qa-recorder/mock-control-api.mjs
@@ -319,6 +319,28 @@ const server = createServer(async (req, res) => {
contexts.set(name, context)
return json(res, 201, context)
}
+ if (/^agents\/[^/]+\/users$/.test(rest) && M === 'GET') {
+ const name = decodeURIComponent(nameFrom(rest.replace('/users', '')))
+ const items = []
+ for (const [userId, agents] of userAgents) {
+ if ((agents ?? []).includes(name)) {
+ const u = users.find(candidate => candidate.id === userId)
+ if (u) items.push({ id: u.id, email: u.email, name: u.name, displayName: u.displayName })
+ }
+ }
+ return json(res, 200, { items })
+ }
+ if (/^agents\/[^/]+\/teams$/.test(rest) && M === 'GET') {
+ const name = decodeURIComponent(nameFrom(rest.replace('/teams', '')))
+ const items = []
+ for (const [teamId, agents] of teamAgents) {
+ if ((agents ?? []).includes(name)) {
+ const t = teams.find(candidate => candidate.id === teamId)
+ if (t) items.push({ id: t.id, name: t.name })
+ }
+ }
+ return json(res, 200, { items })
+ }
if (/^contexts\/[^/]+\/users$/.test(rest) && M === 'GET') return json(res, 200, contextUsers(nameFrom(rest.replace('/users', ''))))
if (/^contexts\/[^/]+\/teams$/.test(rest) && M === 'GET') return json(res, 200, contextTeams(nameFrom(rest.replace('/teams', ''))))
if (/^contexts\/[^/]+$/.test(rest) && M === 'GET') {