Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: gate tool-enabled capability tests while preserving inference (#8798)

[._.]/ Adam Eivy62debe97c160
diff --git a/server/lib/hostControlRoutes.js b/server/lib/hostControlRoutes.js
index 4368fab17c..bfc84f5837 100644
--- a/server/lib/hostControlRoutes.js
+++ b/server/lib/hostControlRoutes.js
@@ -45,11 +45,12 @@
* (including cancel/remove), mtplx models/pull/remove and slotstream
* models/download (including cancel) manage model data, not executables.
* download-preflight only reads. switch selects a built-in backend and
- * registers its fixed provider. unload and jev/unload release weights;
+ * enables its existing fixed provider. unload and jev/unload release weights;
* security-guard/install/cancel and jev/install/cancel cancel work.
* laya-mlx/score, jev/score, test (including stream), compare,
- * assessments/run/sweep (including sweep/cancel), capability-tests/run
- * use configured runtimes for inference, not tool-enabled agent work;
+ * assessments/run/sweep (including sweep/cancel) and capability-tests/run
+ * except sandbox-repair use configured runtimes for inference; sandbox-repair
+ * runs a tool-enabled agent and is gated by testId after body parsing.
* assessments/delete and capability-tests/delete remove result records.
* In contrast, installers, explicit service lifecycle/startup persistence,
* persistent-mind setup, agent-benchmark and JEV policy/head mutations
@@ -342,10 +343,11 @@ const COMPILED_ROUTES = HOST_CONTROL_ROUTES.map(compileRoute);
const bodyKeys = (body) => (body && typeof body === 'object' && !Array.isArray(body) ? Object.keys(body) : []);
-// The two polymorphic policy stores, gated per body key rather than per route.
+// Polymorphic policy stores and the capability runner, gated per body rather than per route.
// `hostControlBodyGate` in services/authGate.js applies these after the body
// parser, since `hostControlRouteGate` runs before it.
const COMPILED_BODY_ROUTES = [
+ ['POST /api/local-llm/capability-tests/run', (body) => body?.testId === 'sandbox-repair' ? ['testId'] : []],
['PUT /api/settings', (body) => bodyKeys(body).filter((key) => HOST_CONTROL_SETTINGS_SLICES.includes(key))],
['PUT /api/cos/config', (body) => bodyKeys(body).filter((key) => !HOST_CONTROL_OPEN_COS_CONFIG_KEYS.includes(key))],
].map(([route, pick]) => ({ ...compileRoute(route), pick }));
diff --git a/server/lib/hostControlRoutes.test.js b/server/lib/hostControlRoutes.test.js
index efe07b0e5a..eeeb712d4c 100644
--- a/server/lib/hostControlRoutes.test.js
+++ b/server/lib/hostControlRoutes.test.js
@@ -43,6 +43,7 @@ describe('browser/runtime mutation inventory (#8798)', () => {
'download-preflight', 'install', 'delete', 'switch', 'migrate', 'unload',
'test', 'test/stream', 'compare',
'assessments/run', 'assessments/sweep', 'assessments/sweep/cancel', 'assessments/delete',
+ // /run is body-gated for sandbox-repair; ordinary inference stays open.
'capability-tests/run', 'capability-tests/delete',
'llama-server/download-model', 'llama-server/download-model/cancel', 'llama-server/download-model/remove',
'mtplx/models/pull', 'mtplx/models/remove',
diff --git a/server/routes/hostControlRuntimeFamilies.test.js b/server/routes/hostControlRuntimeFamilies.test.js
index c6b358bee1..781c612a94 100644
--- a/server/routes/hostControlRuntimeFamilies.test.js
+++ b/server/routes/hostControlRuntimeFamilies.test.js
@@ -172,7 +172,7 @@ vi.mock('../services/lmStudioManager.js', () => ({
getLoadedModels: vi.fn(),
}));
-import { authGate, hostControlRouteGate } from '../services/authGate.js';
+import { authGate, hostControlBodyGate, hostControlRouteGate } from '../services/authGate.js';
import browserRoutes from './browser.js';
import harnessRoutes from './harnesses.js';
import localLlmRoutes from './localLlm.js';
@@ -182,6 +182,7 @@ import { installBackend, getStatus, listModels, installModel } from '../services
import { runOpenCodeAgentBenchmark } from '../services/localModelAgentBenchmark.js';
import { updateSettingsWith } from '../services/settings.js';
import { runLocalLlmTest } from '../services/localLlmPlayground.js';
+import { runCapabilityTest } from '../services/modelCapabilityTests.js';
import { getMeasuredFits } from '../services/localModelAssessmentStore.js';
const buildApp = (address = '192.0.2.10') => {
@@ -190,7 +191,7 @@ const buildApp = (address = '192.0.2.10') => {
Object.defineProperty(req.socket, 'remoteAddress', { value: address });
next();
});
- app.use(authGate, hostControlRouteGate, express.json());
+ app.use(authGate, hostControlBodyGate, hostControlRouteGate, express.json(), hostControlBodyGate);
app.use('/api/browser', browserRoutes);
app.use('/api/harnesses', harnessRoutes);
app.use('/api/local-llm', localLlmRoutes);
@@ -199,6 +200,7 @@ const buildApp = (address = '192.0.2.10') => {
};
const writes = [
+ ['post', '/api/local-llm/capability-tests/run', { backend: 'ollama', modelId: 'example-model', testId: 'sandbox-repair' }, runCapabilityTest],
['put', '/api/browser/config', { chromePath: '/opt/example/bin/chrome', headless: true }, updateConfig],
['post', '/api/browser/launch', {}, launchBrowser],
['post', '/api/harnesses/action?runtime=codex&action=uninstall', {}, streamHarnessAction],
@@ -219,6 +221,7 @@ describe('operator authority for browser, harness and local-runtime management (
auth.isAuthEnabled.mockResolvedValue(false);
installBackend.mockResolvedValue({ success: true });
runOpenCodeAgentBenchmark.mockResolvedValue({ completed: true });
+ runCapabilityTest.mockResolvedValue({ passed: true });
getStatus.mockResolvedValue({ available: true });
listModels.mockResolvedValue([]);
getMeasuredFits.mockResolvedValue({});
@@ -277,6 +280,8 @@ describe('operator authority for browser, harness and local-runtime management (
}
expect((await call(app, ['post', '/api/local-llm/install', { backend: 'ollama', modelId: 'example-model' }])).status).toBe(200);
expect((await call(app, ['post', '/api/local-llm/test', { backend: 'ollama', modelId: 'example-model', prompt: 'Example' }])).status).toBe(200);
+ expect((await call(app, ['post', '/api/local-llm/capability-tests/run', { backend: 'ollama', modelId: 'example-model', testId: 'story-outline' }])).status).toBe(200);
+ expect(runCapabilityTest).toHaveBeenCalledTimes(1);
expect(installModel).toHaveBeenCalledTimes(1);
expect(runLocalLlmTest).toHaveBeenCalledTimes(1);
});