Skip to content

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

fix: report unverified quality snapshot cleanup when git listing fails

[._.]/ Adam Eivyb230e8d2b712
diff --git a/server/services/appQualitySnapshotFile.js b/server/services/appQualitySnapshotFile.js
index f6f32de72e..16910575c0 100644
--- a/server/services/appQualitySnapshotFile.js
+++ b/server/services/appQualitySnapshotFile.js
@@ -408,10 +408,12 @@ async function cleanupSnapshotWorktree(app, git, worktreePath, removeTemp) {
const listing = await git.execGit(['worktree', 'list', '--porcelain'], app.repoPath, { ignoreExitCode: true })
.catch(() => null);
const name = basename(worktreePath);
+ const verificationFailed = !listing || listing.exitCode !== 0 || typeof listing.stdout !== 'string';
const stillRegistered = String(listing?.stdout || '').split('\n')
.some(line => line.startsWith('worktree ') && basename(line.slice(9).trim()) === name);
- if (!stillRegistered && !rmError) return;
+ if (!verificationFailed && !stillRegistered && !rmError) return;
const reasons = [
+ verificationFailed && 'registration verification unavailable',
stillRegistered && `registration remains (${redact(gitError) || 'no error reported'})`,
rmError && `directory removal failed (${redact(rmError)})`,
].filter(Boolean).join('; ');
diff --git a/server/services/appQualitySnapshotFile.test.js b/server/services/appQualitySnapshotFile.test.js
index 10d27b7d1d..e1adbb2a35 100644
--- a/server/services/appQualitySnapshotFile.test.js
+++ b/server/services/appQualitySnapshotFile.test.js
@@ -563,7 +563,7 @@ it('serializes worktree cleanup, retries a failed Git removal, and reports stale
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
const order = [];
let removals = 0;
- const run = async ({ retrySucceeds }) => {
+ const run = async ({ retrySucceeds, listingFails = false }) => {
removals = 0;
order.length = 0;
__resetQualitySnapshotPublishState();
@@ -579,6 +579,7 @@ it('serializes worktree cleanup, retries a failed Git removal, and reports stale
return { exitCode: 0, stdout: '', stderr: '' };
}
if (args[0] === 'worktree' && args[1] === 'list') {
+ if (listingFails) return { exitCode: 128, stdout: '', stderr: 'Git listing failed' };
const stale = retrySucceeds ? '' : `worktree /private${worktreePath}\ndetached\n\n`;
return { exitCode: 0, stdout: `worktree /repo/example-app\nbranch refs/heads/main\n\n${stale}worktree /repo/other\n`, stderr: '' };
}
@@ -600,5 +601,8 @@ it('serializes worktree cleanup, retries a failed Git removal, and reports stale
expect(message).toContain('registration remains');
expect(message).toContain('<snapshot-worktree>');
expect(message).not.toContain(worktreePath);
+ warn.mockClear();
+ expect((await run({ retrySucceeds: false, listingFails: true })).published).toBe(true);
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('registration verification unavailable'));
warn.mockRestore();
});