Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): name the stranded pair on a gated rename, not the new one (spec 02 Pieza C)
Diego Zacariasf74e061a81ad
diff --git a/control-ui/app/llm-models/[id]/edit/page.tsx b/control-ui/app/llm-models/[id]/edit/page.tsxindex 38ce3e607..94fabe3f0 100644--- a/control-ui/app/llm-models/[id]/edit/page.tsx+++ b/control-ui/app/llm-models/[id]/edit/page.tsx@@ -64,9 +64,13 @@ export default function EditLlmModelPage() {await saveWithImpactGate(input, false)}- // Disabling a referenced model (enabled→false) is gated by control-api: without- // `?force` it answers 409 `model_in_use` with the impact. Show it and let the- // operator confirm a forced retry — never force automatically (spec Fase 3/5).+ // A write that pulls a still-referenced pair out of the runtime allowlist is+ // gated by control-api: without `?force` it answers 409 `model_in_use` with the+ // impact. TWO mutations trip it (spec Fase 3, gate widened by R1-H1): DISABLING+ // the model (enabled→false), and RENAMING an enabled pair — a rename strands the+ // OLD identity, whose references `impact.provider/impact.model` names. Show the+ // impact and let the operator confirm a forced retry — never force automatically+ // (spec Fase 3/5).async function saveWithImpactGate(input: CreateLlmModelInput, force: boolean) {setSaving(true)setSaveError('')@@ -95,19 +99,28 @@ export default function EditLlmModelPage() {setSaving(false)}- const forceDisable = await confirm({+ // control-api computes the impact over the pair that leaves the ConfigMap: the+ // CURRENT pair on a disable, the OLD pair on a rename. Name that pair from the+ // impact body (never `input`, which on a rename is the new, not-yet-referenced+ // identity) and match the verb to the mutation so the confirm states the real+ // consequence.+ const renamed = !!model && (input.provider !== model.provider || input.model !== model.model)+ const affectedPair = `${impact.provider}/${impact.model}`+ const forced = await confirm({title: 'Model still in use',- message: `${input.provider}/${input.model} is still referenced. Disabling it leaves these references pointing at a disabled model:`,+ message: renamed+ ? `${affectedPair} is still referenced. Renaming it to ${input.provider}/${input.model} strands these references, leaving them pointing at a model that no longer exists:`+ : `${affectedPair} is still referenced. Disabling it leaves these references pointing at a disabled model:`,details: (<ModelReferenceshostsAffected={impact.hostsAffected}grantsAffected={impact.grantsAffected}/>),- confirmLabel: 'Disable anyway',+ confirmLabel: renamed ? 'Rename anyway' : 'Disable anyway',tone: 'danger',})- if (forceDisable) await saveWithImpactGate(input, true)+ if (forced) await saveWithImpactGate(input, true)}return (diff --git a/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsx b/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsxindex 4c9cc379a..85fa65eea 100644--- a/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsx+++ b/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsx@@ -35,10 +35,19 @@ const SUBMIT_INPUT: CreateLlmModelInput = {model: 'claude-haiku-4-5',enabled: false,}+// A rename keeps the row enabled but changes the (provider, model) identity, so+// control-api gates it over the OLD pair (R1-H1). The `mock` prefix lets the+// hoisted vi.mock factory close over it; each test sets what the form emits.+let mockSubmitInput: CreateLlmModelInput = SUBMIT_INPUT+const RENAME_INPUT: CreateLlmModelInput = {+ provider: 'claude',+ model: 'claude-opus-4-8',+ enabled: true,+}const SUBMIT_LABEL = 'Submit model edit'vi.mock('@components/LlmModelForm', () => ({LlmModelForm: ({ onSubmit }: { onSubmit: (input: CreateLlmModelInput) => void }) => (- <button type="button" onClick={() => onSubmit(SUBMIT_INPUT)}>+ <button type="button" onClick={() => onSubmit(mockSubmitInput)}>{SUBMIT_LABEL}</button>),@@ -98,6 +107,7 @@ describe('edit page disable impact gate (409 model_in_use → force)', () => {beforeEach(() => {mockPush.mockClear()mockShowToast.mockClear()+ mockSubmitInput = SUBMIT_INPUTvi.mocked(getLlmModel).mockResolvedValue(model)})@@ -133,6 +143,43 @@ describe('edit page disable impact gate (409 model_in_use → force)', () => {await waitFor(() => expect(mockPush).toHaveBeenCalled())})+ // R1-H1 widened the gate: renaming an enabled pair also trips the 409, computed+ // over the OLD pair. The confirm must name that old pair (from the impact body,+ // not the freshly-typed new identity) and say "Rename", not "Disable".+ it('names the old pair and offers a rename override when a rename is gated', async () => {+ mockSubmitInput = RENAME_INPUT+ vi.mocked(updateLlmModel).mockRejectedValueOnce(inUseError()).mockResolvedValueOnce(model)++ render(<EditLlmModelPage />)++ fireEvent.click(await screen.findByRole('button', { name: SUBMIT_LABEL }))++ // The verb is "Rename", not "Disable" — nothing is being disabled here.+ expect(await screen.findByRole('button', { name: 'Rename anyway' })).toBeInTheDocument()+ expect(screen.queryByRole('button', { name: 'Disable anyway' })).not.toBeInTheDocument()+ // Names the OLD, still-referenced pair (impact body) and the new target — never+ // claims the new identity "is still referenced".+ expect(+ screen.getByText(+ /claude\/claude-haiku-4-5 is still referenced\. Renaming it to claude\/claude-opus-4-8/+ )+ ).toBeInTheDocument()+ expect(screen.getByText('mcp-host/agent-a')).toBeInTheDocument()++ fireEvent.click(screen.getByRole('button', { name: 'Rename anyway' }))++ await waitFor(() => {+ expect(vi.mocked(updateLlmModel)).toHaveBeenCalledTimes(2)+ })+ expect(vi.mocked(updateLlmModel).mock.calls[0]).toEqual(['model-1', RENAME_INPUT, {}])+ expect(vi.mocked(updateLlmModel).mock.calls[1]).toEqual([+ 'model-1',+ RENAME_INPUT,+ { force: true },+ ])+ await waitFor(() => expect(mockPush).toHaveBeenCalled())+ })+it('does not force when the operator cancels the impact confirm', async () => {vi.mocked(updateLlmModel).mockRejectedValueOnce(inUseError())diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 047434771..9791393c8 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.413",+ "version": "0.1.414","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.413",+ "version": "0.1.414","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --git a/control-ui/package.json b/control-ui/package.jsonindex d692775df..7505209d4 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.413",+ "version": "0.1.414","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",