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

test: align reconcile inventory tests with presence reads and missing-obligation recording (#13271)

Adam Eivya301e400f0be
diff --git a/server/services/branchReconcileInventoryPrune.test.js b/server/services/branchReconcileInventoryPrune.test.js
index 241974502f..1922d280a3 100644
--- a/server/services/branchReconcileInventoryPrune.test.js
+++ b/server/services/branchReconcileInventoryPrune.test.js
@@ -1,9 +1,10 @@
import { describe, it, expect, vi } from 'vitest';
-vi.mock('../lib/execGit.js', () => ({ execGit: vi.fn(async () => ({ stdout: 'worktree /repo\nbranch refs/heads/main\n\n', exitCode: 0 })) }));
-vi.mock('../lib/fileCore.js', () => ({ pathExists: vi.fn(async () => false) }));
+vi.mock('./repoCleanupObservation.js', () => ({
+ readCheckoutPathPresence: vi.fn(async () => false),
+ readLocalBranchPresence: vi.fn(async () => false),
+}));
import { findGoneInventoryRows } from './branchReconcileInventoryPrune.js';
-import { execGit } from '../lib/execGit.js';
-import { pathExists } from '../lib/fileCore.js';
+import { readCheckoutPathPresence } from './repoCleanupObservation.js';
describe('historical checkout inventory', () => {
it('keeps remote-only holds when their local branch is absent, while pruning missing local branches', async () => {
@@ -16,14 +17,13 @@ describe('historical checkout inventory', () => {
});
it('reports missing obligation originals only for display, preserving the default pruning contract', async () => {
- const primary = { path: '/repo', branch: 'main' };
const obligation = { path: '/old', branch: 'fix/example', reason: 'retirement-receipt-unverified' };
- const rows = [primary, obligation];
+ const rows = [obligation];
expect(await findGoneInventoryRows('/repo', rows)).toEqual([]);
expect(await findGoneInventoryRows('/repo', rows, { includeObligations: true })).toEqual([obligation]);
- pathExists.mockResolvedValueOnce(true);
+ readCheckoutPathPresence.mockResolvedValueOnce(true);
+ expect(await findGoneInventoryRows('/repo', rows, { includeObligations: true })).toEqual([]);
+ readCheckoutPathPresence.mockResolvedValueOnce(null);
expect(await findGoneInventoryRows('/repo', rows, { includeObligations: true })).toEqual([]);
- execGit.mockRejectedValueOnce(new Error('git unavailable'));
- await expect(findGoneInventoryRows('/repo', rows, { includeObligations: true })).rejects.toThrow('git unavailable');
});
});
diff --git a/server/services/branchReconcileSweep.test.js b/server/services/branchReconcileSweep.test.js
index 0d1dc6c8fb..976a32c2dc 100644
--- a/server/services/branchReconcileSweep.test.js
+++ b/server/services/branchReconcileSweep.test.js
@@ -20,6 +20,7 @@ vi.mock('./branchReconcile.js', async (importOriginal) => ({
vi.mock('./cosClaimOwnership.js', () => ({ readClaimOwnershipAgents: vi.fn(async () => []) }));
vi.mock('./agentState.js', async (importOriginal) => ({ ...await importOriginal(), getActiveAgentIds: () => new Set() }));
vi.mock('./userTimezone.js', () => ({ getUserTimezone: async () => 'UTC' }));
+vi.mock('./apps.js', () => ({ getAppById: vi.fn(async () => null) }));
import { reconcile } from './branchReconcile.js';
import { readClaimOwnershipAgents } from './cosClaimOwnership.js';
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index 3adefc553e..c59b6994e2 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -78,7 +78,7 @@ vi.mock('./apps.js', () => ({
vi.mock('./taskInputGate.js', () => ({ inputsUnchangedSince: vi.fn().mockResolvedValue(false), readHead: vi.fn() }))
-vi.mock('./branchReconcileInventoryPrune.js', () => ({ findGoneInventoryRows: vi.fn().mockResolvedValue([]) }))
+vi.mock('./branchReconcileInventoryPrune.js', async importOriginal => ({ ...await importOriginal(), findGoneInventoryRows: vi.fn().mockResolvedValue([]) }))
vi.mock('./instanceFeatures.js', () => ({
isInstanceFeatureEnabled: vi.fn().mockResolvedValue(true),