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: reconcile reviewer settings after overlapping bridge writes (#12569)
[._.]/ Adam Eivy7c0ef4a3cdb0
diff --git a/server/services/codeReview.diskSettings.test.js b/server/services/codeReview.diskSettings.test.jsindex 3f8031b8b1..9ca57f9ba4 100644--- a/server/services/codeReview.diskSettings.test.js+++ b/server/services/codeReview.diskSettings.test.js@@ -3,16 +3,25 @@ import { mkdtemp, writeFile, rm, utimes } from 'node:fs/promises';import { join } from 'node:path';import { tmpdir } from 'node:os';-const context = vi.hoisted(() => ({ data: '' }));+const context = vi.hoisted(() => ({ data: '', afterHydrate: null }));vi.mock('../lib/paths.js', async importActual => {const actual = await importActual();return { ...actual, PATHS: { ...actual.PATHS, get data() { return context.data; } } };});+vi.mock('./privateKeyStore.js', async importActual => {+ const actual = await importActual();+ return { ...actual, hydratePrivateKeys: async (...args) => {+ const hydrated = await actual.hydratePrivateKeys(...args);+ await context.afterHydrate?.(hydrated);+ return hydrated;+ } };+});vi.mock('./userActions.js', () => ({ recordUserAction: vi.fn() }));let settings;let getCodeReviewDefaults;let file;beforeEach(async () => {+ context.afterHydrate = null;context.data = await mkdtemp(join(tmpdir(), 'review-settings-'));file = join(context.data, 'settings.json');vi.resetModules();@@ -78,3 +87,17 @@ it('invalidates corrupt settings without broadcasting an empty update, then obseawait writeFile(file, JSON.stringify({ codeReview: { reviewers: ['claude'] } }));expect((await getCodeReviewDefaults()).reviewers).toEqual(['claude']);});++it('observes a bridge write landing after local persistence but before save completes', async () => {+ const config = { reviewerFallbackGroups: [['codex'], ['claude']] };+ await settings.updateSettings({ codeReview: config }, { skipUserAction: true });+ expect((await getCodeReviewDefaults()).reviewers).toEqual(['codex']);+ const health = { codex: { pausedUntil: Date.now() + 60_000, reason: 'quota', lastFailureAt: Date.now() } };+ context.afterHydrate = async current => {+ if (!current.localSave) return;+ context.afterHydrate = null;+ await writeFile(file, JSON.stringify({ ...current, codeReview: { ...config, reviewerHealth: health } }));+ };+ await settings.updateSettings({ localSave: true }, { skipUserAction: true });+ expect(await getCodeReviewDefaults()).toMatchObject({ reviewers: ['claude'], reviewerHealth: health });+});diff --git a/server/services/settings.js b/server/services/settings.jsindex c6b180d443..b90316ab78 100644--- a/server/services/settings.js+++ b/server/services/settings.js@@ -311,7 +311,10 @@ const save = async (settings, { actor = 'system', skipUserAction = false } = {},// newline; atomicWrite's own JSON.stringify omits it.await atomicWrite(SETTINGS_FILE, JSON.stringify(await persistPrivateKeys(cleaned, PATHS.data, { previousSettings: prev }), null, 2) + '\n');await hydratePrivateKeys(cleaned, PATHS.data);- settingsSignature = await readSettingsSignature();+ // Another process can replace the file between our write and a stat. Never+ // label this in-memory save with metadata that might belong to that writer;+ // the next reviewer-selection read reconciles the persisted snapshot once.+ settingsSignature = undefined;// Warn AFTER the successful write so a thrown write never produces// a misleading "stripped" log line for a write that didn't happen.if (isPlainObject(settings)) {