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: drain checkout probes before refusing pending merges
[._.]/ Adam Eivy9351dd79b856
diff --git a/.changelog/v2.102.0.md b/.changelog/v2.102.0.mdindex 605b5a3a80..3ccb553174 100644--- a/.changelog/v2.102.0.md+++ b/.changelog/v2.102.0.md@@ -68,6 +68,7 @@ Released: 2026-10-23- Calendar names reach sync agents as untrusted data, scheduled Brain summaries run without host tools, and browser destinations and media prompts stay out of operational logs.- Review Hub distinguishes stored pending work from an all-clear queue, commission cards show current render outcomes, and Wiki health reports display their complete formatted content.- Managed merges validate structural compatibility with their actual target, preserve ownership holds, and recover deferred validation checkouts without discarding work.+- Managed merge checkout checks wait for every Git probe before refusing a checkout, preventing cleanup from racing a still-running process.## Full Changelogdiff --git a/server/services/pendingMergeGuard.js b/server/services/pendingMergeGuard.jsindex 266c977975..4c20347c91 100644--- a/server/services/pendingMergeGuard.js+++ b/server/services/pendingMergeGuard.js@@ -31,15 +31,17 @@ async function supportsPendingMergeGuard(repoPath) {export async function verifyPendingMergeCheckout(repoPath, worktreePath, branch, headSha) {if (!worktreePath || resolve(repoPath) === resolve(worktreePath)) return false;const read = async (args, cwd = worktreePath) => (await execGit(args, cwd)).stdout.trim();- const checked = await Promise.all([+ // A refused probe must still drain its siblings: a live Git process can+ // retain the checkout cwd while the caller handles that refusal.+ const checked = await Promise.allSettled([read(['rev-parse', '--path-format=absolute', '--git-common-dir']),read(['rev-parse', '--path-format=absolute', '--git-common-dir'], repoPath),read(['rev-parse', '--verify', 'HEAD^{commit}']),read(['symbolic-ref', '--quiet', '--short', 'HEAD']),read(['status', '--porcelain=v1', '--untracked-files=all']),- ]).catch(() => null);- if (!checked) return false;- const [common, primaryCommon, head, ref, status] = checked;+ ]);+ if (checked.some(result => result.status === 'rejected')) return false;+ const [common, primaryCommon, head, ref, status] = checked.map(result => result.value);return common === primaryCommon && head === headSha && ref === branch && !status;}diff --git a/server/services/pendingMergeGuard.test.js b/server/services/pendingMergeGuard.test.jsindex eace4114cf..f5c1c7346a 100644--- a/server/services/pendingMergeGuard.test.js+++ b/server/services/pendingMergeGuard.test.js@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';import { tmpdir } from 'node:os';import { join } from 'node:path';+import * as childProcess from '../lib/childProcess.js';import { execGit } from '../lib/execGit.js';import { preparePendingMergeGuard, pendingMergeGuardCurrent } from './pendingMergeGuard.js';@@ -101,6 +102,44 @@ describe('pending merged-tree validation', () => {expect(await preparePendingMergeGuard(input)).toEqual({ ok: false, reason: 'merged-tree-checkout-unverified' });});+ it('drains sibling checkout probes before refusing a detached checkout', async () => {+ const { input, git, repoPath, worktreePath, headSha } = await fixture();+ await git(['checkout', '--detach', headSha], worktreePath);+ const spawn = childProcess.spawn;+ const closes = [];+ let heldChild;+ let detachedProbeClosed;+ const detachedClosed = new Promise(resolve => { detachedProbeClosed = resolve; });+ const spy = vi.spyOn(childProcess, 'spawn').mockImplementation((command, args, options) => {+ // A live sibling owns the primary repo as its cwd, just as a slow Git+ // probe does on Windows. Release it explicitly rather than sleeping.+ const held = command === 'git' && options.cwd === repoPath && args.includes('--git-common-dir');+ const child = held+ ? spawn(process.execPath, ['-e', 'process.stdin.resume()'], options)+ : spawn(command, args, options);+ closes.push(new Promise(resolve => child.once('close', resolve)));+ if (held) heldChild = child;+ if (command === 'git' && args[0] === 'symbolic-ref') child.once('close', detachedProbeClosed);+ return child;+ });+ let settled = false;+ const checking = preparePendingMergeGuard(input).then(result => {+ settled = true;+ return result;+ });+ try {+ await detachedClosed;+ await new Promise(resolve => setImmediate(resolve));+ expect(heldChild.exitCode).toBeNull();+ expect(settled).toBe(false);+ } finally {+ heldChild?.stdin.end();+ await Promise.allSettled([...closes, checking]);+ spy.mockRestore();+ }+ expect(await checking).toEqual({ ok: false, reason: 'merged-tree-checkout-unverified' });+ });+it('leaves an ordinary managed app without the supported command unchanged', async () => {const repoPath = await mkdtemp(join(tmpdir(), 'ordinary-managed-app-'));roots.push(repoPath);