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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: fold the database routes into the audited mutation inventory (#8897)
[._.]/ Adam Eivy1e3964b0a466
diff --git a/server/lib/hostControlRoutes.test.js b/server/lib/hostControlRoutes.test.jsindex 8130ca86f6..ea3ebb60ad 100644--- a/server/lib/hostControlRoutes.test.js+++ b/server/lib/hostControlRoutes.test.js@@ -31,7 +31,7 @@ describe('HOST_CONTROL_ROUTES (#8716)', () => {// Every mutation in these audited routers must be gated or explicitly reviewed// as a data/inference operation. A new route fails closed at review time instead// of silently falling through the inventory's one-way "listed routes exist" check.-describe('browser/runtime mutation inventory (#8798)', () => {+describe('browser/runtime/database mutation inventory (#8798, #8897)', () => {const dataOrInference = ['POST /api/browser/navigate','DELETE /api/browser/downloads/:name',@@ -49,32 +49,17 @@ describe('browser/runtime mutation inventory (#8798)', () => {'mtplx/models/pull', 'mtplx/models/remove','slotstream/models/download', 'slotstream/models/download/cancel',].map(path => `POST /api/local-llm/${path}`),+ // Advisory and read-only: validates cutover preconditions, runs nothing (#8897).+ 'POST /api/database/maintenance/preflight',];it('classifies every mounted mutation and keeps reviewed data/inference operations open', () => {const mutations = getApiRouteCatalog().routes.filter(({ method, path }) =>/^(POST|PUT|PATCH|DELETE)$/.test(method)- && /^\/api\/(browser|harnesses|local-llm)(\/|$)/.test(path));+ && /^\/api\/(browser|database|harnesses|local-llm)(\/|$)/.test(path));const open = mutations.filter(({ method, path }) => !isHostControlRoute(method, path)).map(({ method, path }) => `${method} ${path}`);expect([...new Set(open)].sort()).toEqual([...dataOrInference].sort());});});-// Database mutation inventory (#8897): every /api/database/* mutation must be gated-// as host control or explicitly reviewed as data-only. New mutations fail closed.-describe('database mutation inventory (#8897)', () => {- const reviewedOpen = [- // POST /maintenance/preflight is advisory only — validates preconditions without side effects.- 'POST /api/database/maintenance/preflight',- ];-- it('classifies every mounted mutation and keeps reviewed data-only operations open', () => {- const mutations = getApiRouteCatalog().routes.filter(({ method, path }) =>- /^(POST|PUT|PATCH|DELETE)$/.test(method)- && /^\/api\/database(\/|$)/.test(path));- const open = mutations.filter(({ method, path }) => !isHostControlRoute(method, path))- .map(({ method, path }) => `${method} ${path}`);- expect([...new Set(open)].sort()).toEqual([...reviewedOpen].sort());- });-});diff --git a/server/routes/database.test.js b/server/routes/database.test.jsindex 875e088a88..44a8bf4063 100644--- a/server/routes/database.test.js+++ b/server/routes/database.test.js@@ -73,6 +73,7 @@ import databaseRoutes from './database.js';import { PATHS } from '../lib/paths.js';import { createDatabaseMaintenanceJournal } from '../lib/databaseMaintenanceJournal.js';import { cleanupTempDataRoots } from '../lib/mockPathsDataRoot.js';+import { hostControlRouteGate } from '../services/authGate.js';afterAll(cleanupTempDataRoots);import { isPg17OnlyDirective, importDumpFile } from '../services/dbAdmin.js';@@ -769,8 +770,14 @@ describe('POST /api/database/sync endpoint safety', () => {});});-// Host-control gating (#8897): database admin routes require operator authority.+// Every host-executing database route requires operator authority (#8897).describe('database admin routes host-control gating', () => {+ const gated = express();+ gated.use((req, _res, next) => { req.portosAuthContext = { enabled: true, authenticated: false }; next(); });+ gated.use(hostControlRouteGate);+ gated.use(express.json());+ gated.use('/api/database', databaseRoutes);+it.each([['start', { backend: 'docker' }],['stop', { backend: 'native' }],@@ -780,16 +787,7 @@ describe('database admin routes host-control gating', () => {['sync', {}],['fix', {}],['switch', { target: 'docker', migrate: false }],- ])('requires host-control authority for POST /api/database/%s', async (route, body) => {- const gated = express();- gated.use((req, _res, next) => {- req.portosAuthContext = { enabled: true, authenticated: false };- next();- });- const { hostControlRouteGate } = await import('../services/authGate.js');- gated.use(hostControlRouteGate);- gated.use(express.json());- gated.use('/api/database', databaseRoutes);+ ])('refuses POST /api/database/%s without host control and runs nothing', async (route, body) => {const res = await request(gated).post(`/api/database/${route}`).send(body);expect(res.status).toBe(403);expect(res.body.code).toBe('HOST_CONTROL_FORBIDDEN');@@ -797,20 +795,4 @@ describe('database admin routes host-control gating', () => {expect(spawn).not.toHaveBeenCalled();expect(query).not.toHaveBeenCalled();});-- it('allows preflight without host-control authority (advisory only)', async () => {- const gated = express();- gated.use((req, _res, next) => {- req.portosAuthContext = { enabled: true, authenticated: false };- next();- });- const { hostControlRouteGate } = await import('../services/authGate.js');- gated.use(hostControlRouteGate);- gated.use(express.json());- gated.use('/api/database', databaseRoutes);- const res = await request(gated).post('/api/database/maintenance/preflight').send({ source: 'native', target: 'docker' });- // preflight is read-only advisory, but returns 400 for this test input- // (no actual system idle) rather than 403.- expect(res.status).not.toBe(403);- });});