Skip to content

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

TypeScript

fix(control-ui): stop claiming discarded actions for may_add_context

Andy Pavia6bbbb9918f94
diff --git a/control-ui/components/HookInstallForm/constants.ts b/control-ui/components/HookInstallForm/constants.ts
index 74d87f184..835d9bc0b 100644
--- a/control-ui/components/HookInstallForm/constants.ts
+++ b/control-ui/components/HookInstallForm/constants.ts
@@ -31,6 +31,20 @@ export const HOOK_CAPABILITY_OPTIONS: Array<{
export const ALL_HOOK_CAPABILITIES: HookCapability[] = HOOK_CAPABILITY_OPTIONS.map(o => o.value)
+// The capabilities mcp-host neutralizes when they are not granted, per
+// `enforceCapabilities` (core/guardrails/capabilities.ts): an ungranted `deny`
+// downgrades to `no_decision`, an ungranted `rewrite`/`substitute` is dropped.
+//
+// `may_add_context` has no such branch — a hook adds context whether or not it
+// was granted — so telling an operator its actions are discarded would be
+// untrue for that one, and would spend the warning's credibility on a case
+// where nothing is wrong.
+export const ENFORCED_HOOK_CAPABILITIES: HookCapability[] = [
+ 'may_deny',
+ 'may_rewrite',
+ 'may_substitute_result',
+]
+
// Default installation order applied by the backend when none is supplied.
export const DEFAULT_HOOK_ORDER = 100
diff --git a/control-ui/components/HookInstallForm/index.tsx b/control-ui/components/HookInstallForm/index.tsx
index 3c807ae19..10b5b995e 100644
--- a/control-ui/components/HookInstallForm/index.tsx
+++ b/control-ui/components/HookInstallForm/index.tsx
@@ -11,6 +11,7 @@ import { getEmbeddedHookCredentialSchema } from '../registryInstallHelpers'
import {
ALL_HOOK_CAPABILITIES,
DEFAULT_HOOK_ORDER,
+ ENFORCED_HOOK_CAPABILITIES,
HOOK_CAPABILITY_OPTIONS,
HOOK_INSTALL_ERROR_LABELS,
ORDER_HINT_LABELS,
@@ -187,6 +188,12 @@ export function HookInstallForm({ entry, onCancel, onInstalled }: HookInstallFor
[declaredCapabilities, capabilities]
)
+ // Split by whether mcp-host actually withholds the action. The two cases
+ // deserve different words: one silently breaks the hook, the other changes
+ // nothing about how it runs today.
+ const missingEnforced = missingDeclared.filter(c => ENFORCED_HOOK_CAPABILITIES.includes(c))
+ const missingUnenforced = missingDeclared.filter(c => !ENFORCED_HOOK_CAPABILITIES.includes(c))
+
// may_deny ⇒ fail-closed, matching the backend deny_requires_fail_closed rule.
const mustFailClosed = capabilities.has('may_deny')
const effectiveFailMode: 'open' | 'closed' = mustFailClosed ? 'closed' : failMode
@@ -436,13 +443,21 @@ export function HookInstallForm({ entry, onCancel, onInstalled }: HookInstallFor
/>
)
})}
- {missingDeclared.length > 0 ? (
+ {missingEnforced.length > 0 ? (
<div className="cu-banner cu-banner--warning" role="status">
- This hook needs {missingDeclared.join(', ')} to function. Without{' '}
- {missingDeclared.length > 1 ? 'them' : 'it'}, it installs and reports Ready,
+ This hook needs {missingEnforced.join(', ')} to function. Without{' '}
+ {missingEnforced.length > 1 ? 'them' : 'it'}, it installs and reports Ready,
but the actions it takes are discarded.
</div>
) : null}
+ {missingUnenforced.length > 0 ? (
+ <div className="cu-banner cu-banner--info">
+ {missingEnforced.length > 0 ? 'The author also lists' : 'The author lists'}{' '}
+ {missingUnenforced.join(', ')}, which the runtime does not enforce today: the
+ hook behaves the same whether or not{' '}
+ {missingUnenforced.length > 1 ? 'they are' : 'it is'} granted.
+ </div>
+ ) : null}
</fieldset>
<Field
diff --git a/control-ui/components/__tests__/HookInstallForm.test.tsx b/control-ui/components/__tests__/HookInstallForm.test.tsx
index 882cafe10..0e1fc5986 100644
--- a/control-ui/components/__tests__/HookInstallForm.test.tsx
+++ b/control-ui/components/__tests__/HookInstallForm.test.tsx
@@ -226,3 +226,41 @@ describe('HookInstallForm — declaration never escapes the ceiling', () => {
expect(select).toBeDisabled()
})
})
+
+describe('HookInstallForm — ungranted-capability warning', () => {
+ // `enforceCapabilities` neutralizes deny/rewrite/substitute and nothing else,
+ // so the "actions are discarded" warning must not be shown for a capability
+ // the runtime never withholds.
+ it('does not claim discarded actions for an unenforced capability', async () => {
+ vi.mocked(api.getHosts).mockResolvedValue({ items: [host('agent-a', null)] } as never)
+ render(
+ <HookInstallForm
+ entry={entryWith({ requiredCapabilities: ['may_add_context'] })}
+ onCancel={noop}
+ onInstalled={noop}
+ />
+ )
+ await openAdvanced()
+ await waitFor(() =>
+ expect(screen.getByText(/the author lists may_add_context/i)).toBeInTheDocument()
+ )
+ expect(screen.getByText(/does not enforce today/i)).toBeInTheDocument()
+ expect(screen.queryByText(/the actions it takes are discarded/i)).toBeNull()
+ })
+
+ it('warns about the enforced capability and notes the unenforced one apart', async () => {
+ vi.mocked(api.getHosts).mockResolvedValue({ items: [host('agent-a', null)] } as never)
+ render(
+ <HookInstallForm
+ entry={entryWith({ requiredCapabilities: ['may_deny', 'may_add_context'] })}
+ onCancel={noop}
+ onInstalled={noop}
+ />
+ )
+ await openAdvanced()
+ // The strong warning names only the capability the runtime withholds.
+ await waitFor(() => expect(screen.getByText(/needs may_deny to function/i)).toBeInTheDocument())
+ expect(screen.queryByText(/needs may_deny, may_add_context to function/i)).toBeNull()
+ expect(screen.getByText(/the author also lists may_add_context/i)).toBeInTheDocument()
+ })
+})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 2c6910463..6a2c37b1d 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.452",
+ "version": "0.1.453",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.452",
+ "version": "0.1.453",
"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 24b4ddf96..5d0f54fc2 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.452",
+ "version": "0.1.453",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",