Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): surface a degraded grant where the operator will see it
Andy Pavia6a48924079ff
diff --git a/control-ui/components/HookInstallForm/index.tsx b/control-ui/components/HookInstallForm/index.tsxindex c91bf78af..fc14937a9 100644--- a/control-ui/components/HookInstallForm/index.tsx+++ b/control-ui/components/HookInstallForm/index.tsx@@ -66,6 +66,38 @@ function describeHookInstallError(err: unknown): string {return reason ? `${message} (${reason})` : message}+/**+ * What the author declared and the install will not get. Rendered at step 0,+ * where the operator can still act on it, and again in the review, which is the+ * last thing they see before Install.+ */+function DegradedGrantNotices({+ enforced,+ unenforced,+}: {+ enforced: HookCapability[]+ unenforced: HookCapability[]+}) {+ return (+ <>+ {enforced.length > 0 ? (+ <div className="cu-banner cu-banner--warning">+ This hook needs {enforced.join(', ')} to function. Without{' '}+ {enforced.length > 1 ? 'them' : 'it'}, it installs and reports Ready, but the actions it+ takes are discarded.+ </div>+ ) : null}+ {unenforced.length > 0 ? (+ <div className="cu-banner cu-banner--info">+ {enforced.length > 0 ? 'The author also lists' : 'The author lists'}{' '}+ {unenforced.join(', ')}, which the runtime does not enforce today: the hook behaves the+ same whether or not {unenforced.length > 1 ? 'they are' : 'it is'} granted.+ </div>+ ) : null}+ </>+ )+}+export function HookInstallForm({ entry, onCancel, onInstalled }: HookInstallFormProps) {const { showToast } = useToast()const [step, setStep] = useState(0)@@ -123,6 +155,7 @@ export function HookInstallForm({ entry, onCancel, onInstalled }: HookInstallForsetError('')setCredValues({})setAdvancedOpen(false)+ autoOpenedRef.current = false// Seed from the author's declaration so the default install is the working// one. The ceiling effect below narrows this once an agent is selected, and// the operator can still untick anything.@@ -199,6 +232,21 @@ export function HookInstallForm({ entry, onCancel, onInstalled }: HookInstallForconst missingEnforced = missingDeclared.filter(c => ENFORCED_HOOK_CAPABILITIES.includes(c))const missingUnenforced = missingDeclared.filter(c => !ENFORCED_HOOK_CAPABILITIES.includes(c))+ // The capability grant lives behind a disclosure that ships closed, so an+ // operator can reach Install having never seen it. Open it the first time the+ // grant falls short of what the author declared — which is only knowable once+ // the agent's ceiling has loaded, so it cannot be a static default. Once per+ // entry: an operator who closes it again has answered the question.+ //+ // Not while loading: the seed is applied by an effect, so the first render+ // sees an empty selection and every declared capability as missing.+ const autoOpenedRef = useRef(false)+ useEffect(() => {+ if (loading || missingDeclared.length === 0 || autoOpenedRef.current) return+ autoOpenedRef.current = true+ setAdvancedOpen(true)+ }, [loading, missingDeclared])+// 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@@ -453,21 +501,15 @@ export function HookInstallForm({ entry, onCancel, onInstalled }: HookInstallFor/>)})}- {missingEnforced.length > 0 ? (- <div className="cu-banner cu-banner--warning" role="status">- 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}+ {/* Always mounted, so ticking a box announces the change. A+ live region added to the DOM already populated announces+ nothing. */}+ <div role="status">+ <DegradedGrantNotices+ enforced={missingEnforced}+ unenforced={missingUnenforced}+ />+ </div></fieldset><Field@@ -515,15 +557,18 @@ export function HookInstallForm({ entry, onCancel, onInstalled }: HookInstallFor) : null}{step === 1 ? (- <div className="cu-agent-review">- Guardrail hook <b>{entry.name}</b> v{entry.version} will be installed on agent{' '}- <b>{hostRef || '-'}</b> with{' '}- <b>- {capabilities.size > 0 ? [...capabilities].join(', ') : 'no extra capabilities'}- </b>- , order <b>{order.trim() === '' ? DEFAULT_HOOK_ORDER : order}</b>, fail mode{' '}- <b>{effectiveFailMode}</b>.- </div>+ <>+ <div className="cu-agent-review">+ Guardrail hook <b>{entry.name}</b> v{entry.version} will be installed on agent{' '}+ <b>{hostRef || '-'}</b> with{' '}+ <b>+ {capabilities.size > 0 ? [...capabilities].join(', ') : 'no extra capabilities'}+ </b>+ , order <b>{order.trim() === '' ? DEFAULT_HOOK_ORDER : order}</b>, fail mode{' '}+ <b>{effectiveFailMode}</b>.+ </div>+ <DegradedGrantNotices enforced={missingEnforced} unenforced={missingUnenforced} />+ </>) : null}{error ? (diff --git a/control-ui/components/__tests__/HookInstallForm.test.tsx b/control-ui/components/__tests__/HookInstallForm.test.tsxindex 89325f17e..6a6e1348f 100644--- a/control-ui/components/__tests__/HookInstallForm.test.tsx+++ b/control-ui/components/__tests__/HookInstallForm.test.tsx@@ -266,6 +266,69 @@ describe('HookInstallForm — step navigation', () => {})})+describe('HookInstallForm — a degraded grant is visible without hunting for it', () => {+ it('opens Advanced details when the grant falls short of the declaration', async () => {+ // Whether the grant falls short is only knowable once the agent's ceiling+ // has loaded, so this cannot be a static default.+ vi.mocked(api.getHosts).mockResolvedValue({ items: [host('agent-a', null)] } as never)+ render(+ <HookInstallForm+ entry={entryWith({ requiredCapabilities: ['may_deny'] })}+ onCancel={noop}+ onInstalled={noop}+ />+ )+ const toggle = await screen.findByRole('button', { name: /advanced details/i })+ await waitFor(() => expect(toggle).toHaveAttribute('aria-expanded', 'true'))+ expect(screen.getByText(/needs may_deny to function/i)).toBeInTheDocument()+ })++ it('stays closed when the install gets everything the author asked for', async () => {+ render(+ <HookInstallForm+ entry={entryWith({ requiredCapabilities: ['may_rewrite'] })}+ onCancel={noop}+ onInstalled={noop}+ />+ )+ const toggle = await screen.findByRole('button', { name: /advanced details/i })+ await waitFor(() => expect(screen.getByRole('button', { name: /continue/i })).toBeEnabled())+ expect(toggle).toHaveAttribute('aria-expanded', 'false')+ })++ it('does not reopen itself after the operator closes it', async () => {+ vi.mocked(api.getHosts).mockResolvedValue({ items: [host('agent-a', null)] } as never)+ render(+ <HookInstallForm+ entry={entryWith({ requiredCapabilities: ['may_deny'] })}+ onCancel={noop}+ onInstalled={noop}+ />+ )+ const toggle = await screen.findByRole('button', { name: /advanced details/i })+ await waitFor(() => expect(toggle).toHaveAttribute('aria-expanded', 'true'))+ fireEvent.click(toggle)+ await waitFor(() => expect(toggle).toHaveAttribute('aria-expanded', 'false'))+ expect(screen.queryByText(/needs may_deny to function/i)).toBeNull()+ })++ it('names the dropped capabilities in the review step', async () => {+ // The review is the last thing before Install; stating only what was+ // granted let a silently degraded install through unremarked.+ vi.mocked(api.getHosts).mockResolvedValue({ items: [host('agent-a', null)] } as never)+ render(+ <HookInstallForm+ entry={entryWith({ requiredCapabilities: ['may_deny'] })}+ onCancel={noop}+ onInstalled={noop}+ />+ )+ fireEvent.click(await screen.findByRole('button', { name: /continue/i }))+ expect(await screen.findByText(/will be installed on agent/i)).toBeInTheDocument()+ expect(screen.getByText(/needs may_deny to function/i)).toBeInTheDocument()+ })+})+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 capabilitydiff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex fe4130736..17c73022c 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.455",+ "version": "0.1.456","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.455",+ "version": "0.1.456","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.jsonindex f717e25df..baf02e9fd 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.455",+ "version": "0.1.456","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",