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: track missing directories still registered with Git (#13271)

Adam Eivya4c6d3fb53e8
diff --git a/server/services/branchReconcileInventoryPrune.js b/server/services/branchReconcileInventoryPrune.js
index f467debaf3..e48f88aaab 100644
--- a/server/services/branchReconcileInventoryPrune.js
+++ b/server/services/branchReconcileInventoryPrune.js
@@ -3,18 +3,12 @@
* can offer per-row actions. Disappearance establishes missing source, never
* preservation. Callers must retain it as an obligation without an exact receipt.
*/
-import { execGit } from '../lib/execGit.js';
import { readCheckoutPathPresence, readLocalBranchPresence } from './repoCleanupObservation.js';
// Rows that bind a retirement-receipt obligation are evidence, not display data.
export const isObligationRow = row => ['retirement-review-pending', 'retirement-receipt-unverified',
'retirement-provenance-unverified'].includes(row?.reason);
-async function registeredPaths(repoPath) {
- const { stdout } = await execGit(['worktree', 'list', '--porcelain'], repoPath);
- return new Set(stdout.split(/\r?\n/).filter(line => line.startsWith('worktree ')).map(line => line.slice(9)));
-}
-
/**
* Stored inventory rows whose checkout (or, for a branch-only row, local branch)
* is gone from the repository. A row whose branch survives but whose checkout is
@@ -28,7 +22,6 @@ async function registeredPaths(repoPath) {
*/
export async function findGoneInventoryRows(repoPath, rows, { includeObligations = false } = {}) {
if (!Array.isArray(rows) || !rows.length) return [];
- const registered = await registeredPaths(repoPath);
const gone = [];
for (const row of rows) {
// A remote-only hold has no local ref by definition. Only a new forge scan
@@ -36,7 +29,6 @@ export async function findGoneInventoryRows(repoPath, rows, { includeObligations
if (row?.reason === 'remote-branch-held') continue;
if (!includeObligations && (isObligationRow(row) || row?.reason === 'claim-reservation-owner-unverified')) continue;
if (typeof row?.path === 'string' && row.path) {
- if (registered.has(row.path)) continue;
const present = await readCheckoutPathPresence(row.path);
if (present === null) throw new Error('checkout-presence-unavailable');
if (present === false) gone.push(row);
diff --git a/server/services/heldCheckoutRecovery.test.js b/server/services/heldCheckoutRecovery.test.js
index 2be512d126..6de1ed06de 100644
--- a/server/services/heldCheckoutRecovery.test.js
+++ b/server/services/heldCheckoutRecovery.test.js
@@ -470,15 +470,18 @@ describe.skipIf(SKIP_HEAVY_INTEGRATION)('held checkout recovery (real git)', ()
const { path, release } = await heldCheckout('gone-between-scans', { branch: 'feature/missing' });
const marker = { branch: 'claim/issue-99', issue: 99, reason: 'claim-reservation-owner-unverified' };
await recordBranchReconcileOutcome('app-1', { status: 'running', remaining: [{ ...release, reason: 'worktree-locked' }, marker] });
- await execGit(['worktree', 'unlock', path], repo);
- // Model an external actor; the retirement service never receives this deletion.
- await execGit(['worktree', 'remove', '--force', path], repo);
+ // Model an external directory deletion that leaves Git's registration intact.
+ const gitDir = (await execGit(['rev-parse', '--absolute-git-dir'], path)).stdout.trim();
+ await writeFile(join(gitDir, 'portos-review-status'), 'recoverable private evidence');
+ await rm(path, { recursive: true, force: true });
+ expect(await registered(path)).toBe(true);
await recordBranchReconcileOutcome('app-1', { status: 'drained', remaining: [] });
const pending = await getBranchReconcileOutcome('app-1');
expect(pending).toMatchObject({ status: 'incomplete', reason: 'retirement-provenance-unverified',
retirementObligations: [{ ...release, reason: 'retirement-provenance-unverified' }],
});
expect(pending.remaining).toHaveLength(1);
+ expect(await readFile(join(gitDir, 'portos-review-status'), 'utf8')).toBe('recoverable private evidence');
const createdAt = pending.retirementObligations[0].createdAt;
// A receipt for another head cannot explain the original disappearance.
await recordHeldCheckoutRetirement('app-1', { ...release, head: 'f'.repeat(40), branchDeleted: true, archiveDir: '/example/other-archive' });