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
fix: require operator authority for generic voice replacement
atomantic7f041e283189
diff --git a/docs/features/voice.md b/docs/features/voice.mdindex a23f87b5ab..faf35451a2 100644--- a/docs/features/voice.md+++ b/docs/features/voice.md@@ -309,6 +309,11 @@ MODEL_NAME=ggml-small.en.bin bash scripts/setup-voice.shAll options live in `data/settings.json` under `voice` (Settings UI patches this file).+Replacing the entire `voice` root through `PUT /api/settings` requires operator+authority, including empty or null replacements that reset voice policy. The+dedicated `PUT /api/voice/config` endpoint continues to check changes to protected+instructions, tools, and the STT endpoint while allowing ordinary voice preferences.+| Option | Default | Notes ||--------|---------|-------|| `enabled` | `false` | Master toggle. Triggers reconcile on change. |diff --git a/server/lib/hostControlRoutes.js b/server/lib/hostControlRoutes.jsindex 9368c6d7f0..3b1931c84a 100644--- a/server/lib/hostControlRoutes.js+++ b/server/lib/hostControlRoutes.js@@ -153,7 +153,9 @@* `stt.endpoint` receives microphone audio and returns the transcript* the agent acts on. `PUT /api/voice/config` is gated only when one of those values would* change (`HOST_CONTROL_VOICE_CONFIG_PATHS`); a whole-config resend and- * every other voice setting stay open.+ * every other voice setting stay open on that dedicated endpoint.+ * Generic settings replaces the entire voice root, so even an empty+ * replacement can reset protected policy and requires operator authority.** Patterns are `METHOD /path`, with Express-style `:param` (one segment) and* `*name` (the rest of the path). Matching is case-insensitive and ignores one@@ -880,7 +882,8 @@ export const HOST_CONTROL_ROUTES = Object.freeze([* harness enablement and wrapper CLIs, the Code Animation worker tools, the* code-review chain, the untrusted content screen in front of agent work,* scheduled self-update, scheduled series autopilots, and backup destination/- * recovery policy. The store is polymorphic, so its other slices stay open.+ * recovery policy, and whole-root voice policy replacement. The store is+ * polymorphic, so its other slices stay open.*/export const HOST_CONTROL_SETTINGS_SLICES = Object.freeze(['autoUpdate',@@ -893,6 +896,7 @@ export const HOST_CONTROL_SETTINGS_SLICES = Object.freeze(['harnesses','seriesAutopilot','untrustedContent',+ 'voice',]);/**diff --git a/server/routes/settings.test.js b/server/routes/settings.test.jsindex 5f5a011c3a..527dcb37ad 100644--- a/server/routes/settings.test.js+++ b/server/routes/settings.test.js@@ -1622,30 +1622,32 @@ describe('Settings routes — atomic partial saves (#11045)', () => {});});+const guardedSettingsApp = (authority) => {+ const app = express();+ app.use(express.json());+ app.use((req, _res, next) => {+ Object.defineProperty(req.socket, 'remoteAddress', { value: authority === 'local' ? '127.0.0.1' : '192.0.2.10', configurable: true });+ // authGate supplies this verified context for both human and agent sessions.+ req.portosAuthContext = authority === 'session'+ ? { enabled: true, authenticated: true, method: 'session' }+ : { enabled: false, authenticated: false, method: null };+ next();+ });+ app.use(hostControlBodyGate);+ app.use('/api/settings', settingsRoutes);+ return app;+};+// Regression: generic settings writes must not let a remote caller repoint,// disable or prune the backups that hold the install's private records.describe('backup settings operator authority', () => {beforeEach(() => { store = { backup: { destPath: '/example-backups', enabled: true } }; vi.clearAllMocks(); });- const guardedApp = (authority) => {- const app = express();- app.use(express.json());- app.use((req, _res, next) => {- Object.defineProperty(req.socket, 'remoteAddress', { value: authority === 'local' ? '127.0.0.1' : '192.0.2.10', configurable: true });- // authGate supplies this verified context for both human and agent sessions.- req.portosAuthContext = authority === 'session'- ? { enabled: true, authenticated: true, method: 'session' }- : { enabled: false, authenticated: false, method: null };- next();- });- app.use(hostControlBodyGate);- app.use('/api/settings', settingsRoutes);- return app;- };+it.each([{ destPath: '/example-other-backups' }, { enabled: false }, { retentionCount: 1 }, null])('refuses unauthorized backup policy changes before persistence: %j', async (backup) => {const previous = structuredClone(store);- const res = await request(guardedApp('remote')).put('/api/settings').send({ backup });+ const res = await request(guardedSettingsApp('remote')).put('/api/settings').send({ backup });expect(res.status).toBe(403);expect(res.body.code).toBe('HOST_CONTROL_FORBIDDEN');expect(updateSettingsWith).not.toHaveBeenCalled();@@ -1654,8 +1656,41 @@ describe('backup settings operator authority', () => {);it.each(['local', 'session'])('preserves authorized backup configuration: %s', async (authority) => {- const res = await request(guardedApp(authority)).put('/api/settings').send({ backup: { destPath: '/example-other-backups' } });+ const res = await request(guardedSettingsApp(authority)).put('/api/settings').send({ backup: { destPath: '/example-other-backups' } });expect(res.status).toBe(200);expect(store.backup.destPath).toBe('/example-other-backups');});});++// A generic settings PUT replaces the whole voice root. Even an empty or null+// value can reset protected instructions; it is not the dedicated deep-merge API.+describe('generic voice settings operator authority', () => {+ const original = { stt: { endpoint: 'https://example.com/trusted-stt' }, llm: { systemPrompt: 'Synthetic trusted instructions', tools: { enabled: false } }, tts: { rate: 1 } };+ beforeEach(() => { store = { voice: structuredClone(original) }; vi.clearAllMocks(); });++ it.each([+ { stt: { endpoint: 'https://example.com/other-stt' } },+ { llm: { systemPrompt: 'Synthetic replacement', tools: { enabled: true } } },+ {},+ null,+ ])('refuses an unauthorized root replacement or reset before persistence: %j', async voice => {+ const res = await request(guardedSettingsApp('remote')).put('/api/settings').send({ voice });+ expect(res.status).toBe(403);+ expect(res.body.code).toBe('HOST_CONTROL_FORBIDDEN');+ expect(updateSettingsWith).not.toHaveBeenCalled();+ expect(store.voice).toEqual(original);+ });++ it.each(['local', 'session'])('preserves authorized voice replacement: %s', async authority => {+ const voice = { ...original, stt: { endpoint: 'https://example.com/other-stt' } };+ const res = await request(guardedSettingsApp(authority)).put('/api/settings').send({ voice });+ expect(res.status).toBe(200);+ expect(store.voice).toEqual(voice);+ });++ it('keeps unrelated generic settings writes open without changing voice policy', async () => {+ const res = await request(guardedSettingsApp('remote')).put('/api/settings').send({ theme: 'dark' });+ expect(res.status).toBe(200);+ expect(store.voice).toEqual(original);+ });+});