Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): make admin delete, budget, and hook-install copy accurate
Jose Gabriel Ramirez Encinasc693d4157447
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 86e53095b..092d6afee 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.737",+ "version": "0.1.738","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.737",+ "version": "0.1.738","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex d584b970e..2b01bf382 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.737",+ "version": "0.1.738","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/routes/admin/registry.ts b/control-api/src/routes/admin/registry.tsindex 8ec9e9f5f..3fb72180c 100644--- a/control-api/src/routes/admin/registry.ts+++ b/control-api/src/routes/admin/registry.ts@@ -354,8 +354,7 @@ function assertHookAdmissible(status: 400,body: {error: 'content_access_conflict',- reason:- 'contentAccess: metadata is not allowed for a hook using moderate/postCallSuccess/onError (§8.4)',+ reason: `contentAccess: metadata is not allowed for a hook using ${[...INHERENTLY_CONTENT_POINTS].join('/')} (§8.4)`,},}}diff --git a/control-api/src/routes/admin/teams.ts b/control-api/src/routes/admin/teams.tsindex 92f03de6e..a9331809d 100644--- a/control-api/src/routes/admin/teams.ts+++ b/control-api/src/routes/admin/teams.ts@@ -152,8 +152,10 @@ export function createAdminTeamsRouter(gateway: K8sGateway): Router {})/**- * Hard-delete team and all memberships, invitations, team context/agent links (DB CASCADE).- * Audit history is retained, so teams referenced by workflow audit rows cannot be deleted.+ * Hard-delete an empty team plus its invitations, inactive memberships, and team+ * context/agent links (DB CASCADE). Active members block deletion (409 team_not_empty).+ * Audit history is retained, so teams referenced by workflow audit rows cannot be deleted+ * (409 team_has_audit_history).*/router.delete('/admin/teams/:teamId', async (req, res, next) => {try {diff --git a/control-api/test/routes.registryInstall.test.ts b/control-api/test/routes.registryInstall.test.tsindex 80521a759..a5fc333dd 100644--- a/control-api/test/routes.registryInstall.test.ts+++ b/control-api/test/routes.registryInstall.test.ts@@ -6511,6 +6511,44 @@ describe('POST /admin/registry/upgrade-hook — gates are not bypassed', () => {expect(() => assertValidSecretConstraints(secretRequest, secretOptions)).not.toThrow()})+ it('names the tool-lane points in the content_access_conflict reason', async () => {+ const gw = new MockGateway()+ await gw.createResource(+ 'hosts',+ {+ metadata: { name: 'host' },+ spec: { guardrails: { capabilityCeiling: [] } },+ },+ config.hostsNamespace+ )+ vi.mocked(resolvePublishScope).mockResolvedValue(clusterScope)+ vi.mocked(getEntryVersion).mockResolvedValueOnce(+ hookEntry({+ trust_level: 'high',+ hook_meta: {+ target: { image: { ref: IMG_A, port: 8080 } },+ lifecyclePoints: ['preToolUse'],+ contentAccess: 'metadata',+ },+ }) as any+ )++ const res = await request(makeApp(gw))+ .post('/admin/registry/install-hook')+ .send({+ hostRef: 'host',+ hookName: 'tool-lane-hook',+ registryEntryName: '@acme/hook',+ registryEntryVersion: '2.0.0',+ })+ .expect(400)++ expect(res.body.error).toBe('content_access_conflict')+ expect(res.body.reason).toBe(+ 'contentAccess: metadata is not allowed for a hook using moderate/postCallSuccess/onError/preToolUse/postToolUse (§8.4)'+ )+ })+it('preserves an ambiguous hook dependency', async () => {const gw = new MockGateway()await gw.createResource(diff --git a/control-ui/components/HookInstallForm/constants.ts b/control-ui/components/HookInstallForm/constants.tsindex 2bc529877..517332bd4 100644--- a/control-ui/components/HookInstallForm/constants.ts+++ b/control-ui/components/HookInstallForm/constants.ts@@ -80,4 +80,8 @@ export const HOOK_INSTALL_ERROR_LABELS: Record<string, string> = {deny_requires_fail_closed: 'A hook that may deny must run in fail-closed mode.',image_not_allowlisted: "This hook's image is not allow-listed for installation.",unknown_credential_keys: 'One or more credential keys are not recognized by this hook.',+ hook_requires_org_scope: 'Only organization-scoped registry hooks can be installed.',+ content_access_conflict:+ 'This hook declares metadata-only access at a lifecycle point that always receives content.',+ image_ref_not_digest_pinned: "This hook's image must be pinned by digest (@sha256:…).",}diff --git a/control-ui/components/ProfileAdminHome.tsx b/control-ui/components/ProfileAdminHome.tsxindex 2131e18cb..d74477f2f 100644--- a/control-ui/components/ProfileAdminHome.tsx+++ b/control-ui/components/ProfileAdminHome.tsx@@ -26,7 +26,11 @@ import {revokeAdminTeamInvitation,} from '../lib/api'import type { DeleteCandidateTeam } from '../lib/profileAdminDelete'-import { formatTeamNames, getSoloMemberTeamsForUser } from '../lib/profileAdminDelete'+import {+ describeDeleteTeamError,+ formatTeamNames,+ getSoloMemberTeamsForUser,+} from '../lib/profileAdminDelete'import { formatTeamRole } from '../lib/teamRoles'import { ControlAdminsPanel } from './ControlAdminsPanel'import type { ProfileAdminHomeProps, ProfileAdminTab } from './ProfileAdminHome.types'@@ -345,7 +349,7 @@ export function ProfileAdminHome({ activeTab, highlightedAdminId = '' }: ProfilesetTeamToDelete(null)await loadData()} catch (e) {- setDeleteDialogError(e instanceof Error ? e.message : 'Failed to delete team')+ setDeleteDialogError(describeDeleteTeamError(e))} finally {setDeleteSubmitting(false)}@@ -1021,8 +1025,9 @@ export function ProfileAdminHome({ activeTab, highlightedAdminId = '' }: Profile</button></div><p className="cu-muted" style={{ fontSize: '0.875rem', margin: '0 0 1rem' }}>- Permanently delete <strong>{teamToDelete.name}</strong> and all memberships, pending- invitations, and team context/agent mappings. This cannot be undone.+ Permanently delete <strong>{teamToDelete.name}</strong> with its pending invitations+ and team context/agent mappings. This cannot be undone. Only a team with no active+ members can be deleted, and a team referenced by workflow audit history is kept.</p>{deleteDialogError ? (<div className="cu-banner cu-banner--error" style={{ marginBottom: '0.75rem' }}>diff --git a/control-ui/components/TokenBudgetForm/index.tsx b/control-ui/components/TokenBudgetForm/index.tsxindex fe29a345a..7a6adb06d 100644--- a/control-ui/components/TokenBudgetForm/index.tsx+++ b/control-ui/components/TokenBudgetForm/index.tsx@@ -358,7 +358,7 @@ export function TokenBudgetForm({<FormSectiontitle="Thresholds"- description="Guardrails applied per task (enforcement arrives in a later phase)."+ description="Guardrails applied per task. With Block enforcement, a task cannot start below the minimum remaining and is stopped once it exceeds the per-task cap. With Warn, neither stops a task."><div className="cu-form-grid cu-form-grid--2"><Fielddiff --git a/control-ui/components/__tests__/HookInstallForm.test.tsx b/control-ui/components/__tests__/HookInstallForm.test.tsxindex 7af9cf4a4..a3fcc7586 100644--- a/control-ui/components/__tests__/HookInstallForm.test.tsx+++ b/control-ui/components/__tests__/HookInstallForm.test.tsx@@ -442,3 +442,25 @@ describe('HookInstallForm — what actually reaches the install route', () => {expect(payload.failMode).toBe('open')})})++describe('HookInstallForm — install rejections render friendly copy', () => {+ it.each([+ ['hook_requires_org_scope', 'Only organization-scoped registry hooks can be installed.'],+ [+ 'content_access_conflict',+ 'This hook declares metadata-only access at a lifecycle point that always receives content.',+ ],+ ['image_ref_not_digest_pinned', "This hook's image must be pinned by digest (@sha256:…)."],+ ])('labels %s instead of rendering the raw code', async (code, label) => {+ vi.mocked(api.installHookFromRegistry).mockRejectedValue(+ Object.assign(new Error(`400 Bad Request - ${code}`), { code, body: { error: code } })+ )+ render(<HookInstallForm entry={entryWith({})} onCancel={noop} onInstalled={noop} />)+ fireEvent.click(await screen.findByRole('button', { name: /continue/i }))+ fireEvent.click(await screen.findByRole('button', { name: /^install$/i }))++ const alert = await screen.findByRole('alert')+ expect(alert).toHaveTextContent(label)+ expect(alert).not.toHaveTextContent(code)+ })+})diff --git a/control-ui/components/__tests__/ProfileAdminHome.test.tsx b/control-ui/components/__tests__/ProfileAdminHome.test.tsxindex 8a718e222..36607ac3b 100644--- a/control-ui/components/__tests__/ProfileAdminHome.test.tsx+++ b/control-ui/components/__tests__/ProfileAdminHome.test.tsx@@ -3,6 +3,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/reimport {deleteAdminTeam,deleteAdminUser,+ formatApiError,getAdminTeams,getAdminUserTeams,getProfileAdminOverview,@@ -389,4 +390,47 @@ describe('ProfileAdminHome — members invitations', () => {vi.mocked(deleteAdminUser).mock.calls[0]?.[1])})++ async function openDeleteTeamDialog() {+ renderProfileAdminHome('teams')+ await screen.findByLabelText('Open team Marketing')+ fireEvent.click(screen.getByRole('button', { name: 'Actions for team Marketing' }))+ fireEvent.click(screen.getByRole('menuitem', { name: 'Delete' }))+ return screen.findByRole('alertdialog')+ }++ function conflictError(code: string) {+ return formatApiError(+ new Response(null, { status: 409, statusText: 'Conflict' }),+ JSON.stringify({ error: code })+ )+ }++ it('does not promise to delete active memberships in the delete-team dialog', async () => {+ const dialog = await openDeleteTeamDialog()++ expect(dialog).not.toHaveTextContent(/all memberships/i)+ expect(dialog).toHaveTextContent('Only a team with no active members can be deleted')+ expect(dialog).toHaveTextContent('a team referenced by workflow audit history is kept')+ })++ it.each([+ [+ 'team_not_empty',+ 'This team still has active members. Remove every member from the team, then delete it.',+ ],+ [+ 'team_has_audit_history',+ 'This team cannot be deleted because workflow audit history references it, and audit history is retained.',+ ],+ ])('explains a %s 409 in the delete-team dialog', async (code, message) => {+ vi.mocked(deleteAdminTeam).mockRejectedValueOnce(conflictError(code))+ const dialog = await openDeleteTeamDialog()++ fireEvent.click(screen.getByRole('button', { name: 'Delete team' }))++ await waitFor(() => expect(dialog).toHaveTextContent(message))+ expect(dialog).not.toHaveTextContent(code)+ expect(deleteAdminTeam).toHaveBeenCalledWith('team-1')+ })})diff --git a/control-ui/components/__tests__/TokenBudgetForm.test.tsx b/control-ui/components/__tests__/TokenBudgetForm.test.tsxnew file mode 100644index 000000000..4adcf2e14--- /dev/null+++ b/control-ui/components/__tests__/TokenBudgetForm.test.tsx@@ -0,0 +1,48 @@+import { afterEach, describe, expect, it, vi } from 'vitest'+import { cleanup, render, screen } from '@testing-library/react'+import { TokenBudgetForm } from '../TokenBudgetForm'++vi.mock('@lib/hooks/useSubscriptionCapabilities', () => ({+ useSubscriptionCapabilities: () => ({+ capabilities: { providers: {} },+ loading: false,+ error: null,+ retry: vi.fn(),+ }),+}))++vi.mock('@lib/hooks/useLlmAllowedModels', () => ({+ useLlmAllowedModels: () => ({ models: [], loading: false, error: '' }),+}))++vi.mock('@lib/api', async importOriginal => {+ const actual = await importOriginal<typeof import('@lib/api')>()+ return {+ ...actual,+ getAdminTeams: vi.fn().mockResolvedValue({ items: [] }),+ getAdminUsers: vi.fn().mockResolvedValue({ items: [] }),+ getHosts: vi.fn().mockResolvedValue({ items: [] }),+ getRecipeSecrets: vi.fn().mockResolvedValue({ items: [] }),+ getLlmPrices: vi.fn().mockResolvedValue({ rows: [] }),+ }+})++const noop = () => undefined++afterEach(cleanup)++describe('TokenBudgetForm — thresholds copy', () => {+ it('describes per-task guardrails as enforced today, not deferred', () => {+ render(<TokenBudgetForm mode="create" saving={false} onSubmit={noop} onCancel={noop} />)++ // control-api's budget check denies below min-start and mcp-host's task+ // brake aborts over max-per-task for block budgets, so the copy must not+ // promise enforcement in a later phase.+ expect(screen.queryByText(/later phase/i)).not.toBeInTheDocument()+ expect(+ screen.getByText(+ /With Block enforcement, a task cannot start below the minimum remaining and is stopped once it exceeds the per-task cap\./+ )+ ).toBeInTheDocument()+ })+})diff --git a/control-ui/lib/profileAdminDelete.ts b/control-ui/lib/profileAdminDelete.tsindex 914c1c613..64e33d8a2 100644--- a/control-ui/lib/profileAdminDelete.ts+++ b/control-ui/lib/profileAdminDelete.ts@@ -15,3 +15,18 @@ export function getSoloMemberTeamsForUser(export function formatTeamNames(teams: readonly DeleteCandidateTeam[]): string {return teams.map(team => team.name).join(', ')}++const DELETE_TEAM_ERROR_MESSAGES: Readonly<Record<string, string>> = {+ team_not_empty:+ 'This team still has active members. Remove every member from the team, then delete it.',+ team_has_audit_history:+ 'This team cannot be deleted because workflow audit history references it, and audit history is retained.',+}++/** Maps the delete-team route's 409 codes to actionable copy; falls back to the error message. */+export function describeDeleteTeamError(err: unknown): string {+ const code = (err as { code?: unknown } | null)?.code+ const known = typeof code === 'string' ? DELETE_TEAM_ERROR_MESSAGES[code] : undefined+ if (known) return known+ return err instanceof Error && err.message ? err.message : 'Failed to delete team'+}diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 131a17269..89df19642 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.728",+ "version": "0.1.729","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.728",+ "version": "0.1.729","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 6cda74840..a23f3ab42 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.728",+ "version": "0.1.729","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",