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([issue-1947]): mirror worktree migration-skip in update-status pending check
[._.]/ Adam Eivy499a5d5f43fe
diff --git a/server/services/installState.js b/server/services/installState.jsindex 5e2f06dcac..87bd41f71b 100644--- a/server/services/installState.js+++ b/server/services/installState.js@@ -31,6 +31,7 @@ import { stat, readdir } from 'fs/promises';import { PATHS } from '../lib/fileUtils.js';import { execGit } from '../lib/execGit.js';import { listPendingMigrations } from '../../scripts/run-migrations.js';+import { isWorktreeRoot } from '../lib/dataRoot.js';// The commit the running process was launched at. Captured once at boot (see// captureBootCommit, called from server/index.js). null when not yet captured@@ -197,7 +198,14 @@ export async function getInstallState({isAncestor = (a, b) => gitIsAncestor(a, b, rootDir),statMtime = statMtimeMs,clientSourceNewer = (buildMs) => isClientSourceNewer(rootDir, buildMs, { statMtime }),- listPending = () => listPendingMigrations({ rootDir: migrationRootDir }),+ // Mirror the boot backstop (#1947): when the data root is a CoS agent worktree+ // checkout, boot SKIPS migrations and never writes data/migrations.applied.json+ // there — so scanning against that ledger-less tree would report every+ // migration as pending and flag the install outOfSync on every worktree boot.+ // Short-circuit to zero pending instead, matching what boot actually did.+ listPending = () => isWorktreeRoot(migrationRootDir)+ ? Promise.resolve([])+ : listPendingMigrations({ rootDir: migrationRootDir }),} = {}) {const currentCommit = await getCurrentCommit().catch(() => null);diff --git a/server/services/installState.test.js b/server/services/installState.test.jsindex c2c74abccb..842f84e393 100644--- a/server/services/installState.test.js+++ b/server/services/installState.test.js@@ -214,6 +214,31 @@ describe('getInstallState — pending migrations', () => {await getInstallState({ ...optsWithoutInjectedPending, migrationRootDir: '/pinned/install' });expect(listPendingMigrations).toHaveBeenCalledWith({ rootDir: '/pinned/install' });});++ // #1947: boot SKIPS migrations for a worktree data root (no ledger written),+ // so the status path must not scan the ledger-less worktree and falsely report+ // every migration pending / outOfSync on every worktree boot.+ it('reports zero pending on a worktree data root without scanning the ledger', async () => {+ listPendingMigrations.mockClear();+ const { listPending, ...optsWithoutInjectedPending } = syncedOpts();+ const worktreeRoot = join(ROOT, 'data', 'cos', 'worktrees', 'agent-abc');+ const state = await getInstallState({ ...optsWithoutInjectedPending, migrationRootDir: worktreeRoot });+ expect(state.pendingMigrations.count).toBe(0);+ expect(state.outOfSync).toBe(false);+ // short-circuited — never scanned the worktree's absent ledger+ expect(listPendingMigrations).not.toHaveBeenCalled();+ });++ it('still reports pending migrations for a normal (non-worktree) data root', async () => {+ listPendingMigrations.mockClear();+ listPendingMigrations.mockResolvedValueOnce(['099-foo.js']);+ const { listPending, ...optsWithoutInjectedPending } = syncedOpts();+ const state = await getInstallState({ ...optsWithoutInjectedPending, migrationRootDir: ROOT });+ expect(state.pendingMigrations.count).toBe(1);+ expect(state.pendingMigrations.files).toEqual(['099-foo.js']);+ expect(state.outOfSync).toBe(true);+ expect(listPendingMigrations).toHaveBeenCalledWith({ rootDir: ROOT });+ });});describe('getInstallState — resilience', () => {