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: use Git null paths for Windows archive verification

Adam Eivy30aec7bb64e7
diff --git a/server/services/heldCheckoutRecovery.js b/server/services/heldCheckoutRecovery.js
index ece4601f3f..cbff29c23b 100644
--- a/server/services/heldCheckoutRecovery.js
+++ b/server/services/heldCheckoutRecovery.js
@@ -21,7 +21,7 @@
import { findGoneInventoryRows } from './branchReconcileInventoryPrune.js';
import { createReadStream, realpathSync } from 'node:fs';
import { lstat, stat, readlink, readdir, readFile, chmod, open, mkdtemp } from 'node:fs/promises';
-import { devNull, tmpdir } from 'node:os';
+import { tmpdir } from 'node:os';
import { createHash, randomUUID } from 'node:crypto';
import { basename, dirname, isAbsolute, join, resolve, relative, sep } from 'node:path';
import { sameRetirementCheckout, unresolvedRetirements } from '../lib/reconcileRetirementEvidence.js';
@@ -129,9 +129,11 @@ async function verifyHeldArchive(repoPath, dir, release) {
// Bundle verify/list-heads validate headers, not packed object integrity. Prove
// the complete closure without borrowing any object from the live repository.
const scratch = await mkdtemp(join(tmpdir(), 'portos-retirement-proof-'));
+ // Git's null path also works on Windows; Node's device-namespace spelling
+ // (\\.\nul) is not the Git configuration-file contract.
const env = { ...Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.toUpperCase().startsWith('GIT_'))),
- GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: devNull, GIT_NO_REPLACE_OBJECTS: '1', GIT_NO_LAZY_FETCH: '1', GIT_TERMINAL_PROMPT: '0' };
- const prove = args => execGit(['--no-optional-locks', '-c', `core.hooksPath=${devNull}`, '-c', 'core.fsmonitor=false', ...args], scratch,
+ GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null', GIT_NO_REPLACE_OBJECTS: '1', GIT_NO_LAZY_FETCH: '1', GIT_TERMINAL_PROMPT: '0' };
+ const prove = args => execGit(['--no-optional-locks', '-c', 'core.hooksPath=/dev/null', '-c', 'core.fsmonitor=false', ...args], scratch,
{ env, maxBuffer: GIT_OUTPUT_BYTES });
try {
await prove(['init', '--bare', `--object-format=${release.head.length === 64 ? 'sha256' : 'sha1'}`, '.']);
diff --git a/server/services/heldCheckoutRecovery.test.js b/server/services/heldCheckoutRecovery.test.js
index d074c15406..65b0a71c36 100644
--- a/server/services/heldCheckoutRecovery.test.js
+++ b/server/services/heldCheckoutRecovery.test.js
@@ -21,7 +21,7 @@ afterAll(cleanupTempDataRoots);
const SYMLINKS = process.platform !== 'win32';
const retirementFaults = vi.hoisted(() => ({ onRemove: null, onBranchDelete: null, scheduleWrites: 0, failScheduleWrite: null }));
-const injected = vi.hoisted(() => ({ policies: [], schedule: null, app: null, fetchRemote: null, fetches: [], onBundle: null, onEvidence: null }));
+const injected = vi.hoisted(() => ({ policies: [], schedule: null, app: null, fetchRemote: null, fetches: [], onBundle: null, onEvidence: null, proofFailures: [] }));
vi.mock('../lib/execGit.js', async importOriginal => {
const actual = await importOriginal();
@@ -35,7 +35,19 @@ vi.mock('../lib/execGit.js', async importOriginal => {
injected.fetches.push({ args, options });
if (injected.fetchRemote) args = args.map(arg => arg === 'https://github.com/example/repo.git' ? injected.fetchRemote : arg);
}
- return actual.execGit(args, cwd, options);
+ try { return await actual.execGit(args, cwd, options); }
+ catch (error) {
+ const phase = args.includes('unbundle') ? 'unbundle' : args.includes('fsck') ? 'fsck' : args.includes('--bare') ? 'init' : null;
+ if (phase && options?.env?.GIT_NO_REPLACE_OBJECTS === '1') {
+ // Persisted evidence hides child stderr; retain bounded fixture-only diagnostics.
+ let message = String(error.message);
+ for (const root of [cwd, tmpdir(), realpathSync(tmpdir())]) {
+ message = message.split(root).join('<temp>').split(root.replaceAll('\\', '/')).join('<temp>');
+ }
+ injected.proofFailures.push({ phase, message: message.replace(/\s+/g, ' ').slice(0, 500) });
+ }
+ throw error;
+ }
} };
});
vi.mock('./forgeExecOptions.js', () => ({ resolveForgeExecOptions: async () => ({ env: { ...process.env, GH_TOKEN: 'synthetic-account-token' } }) }));
@@ -69,7 +81,7 @@ describe.skipIf(SKIP_HEAVY_INTEGRATION)('held checkout recovery (real git)', ()
beforeEach(async () => {
Object.assign(retirementFaults, { onRemove: null, onBranchDelete: null, scheduleWrites: 0, failScheduleWrite: null });
- Object.assign(injected, { policies: [], schedule: { tasks: {}, executions: {} }, app: { id: 'app-1', repoPath: null }, fetchRemote: null, fetches: [], onBundle: null, onEvidence: null });
+ Object.assign(injected, { policies: [], schedule: { tasks: {}, executions: {} }, app: { id: 'app-1', repoPath: null }, fetchRemote: null, fetches: [], onBundle: null, onEvidence: null, proofFailures: [] });
scratch = realpathSync(await mkdtemp(join(tmpdir(), 'portos-held-checkout-')));
const safeRepo = join(scratch, 'repo');
await mkdir(safeRepo);
@@ -291,7 +303,7 @@ describe.skipIf(SKIP_HEAVY_INTEGRATION)('held checkout recovery (real git)', ()
const { release, saved } = await historicalArchive();
const before = (await execGit(['show-ref'], repo)).stdout;
const outcome = await recordBranchReconcileOutcome('app-1', { status: 'incomplete', remaining: [] });
- expect(outcome.retirementObligations).toEqual([]);
+ expect(outcome.retirementObligations, `Standalone archive proof failures: ${JSON.stringify(injected.proofFailures)}`).toEqual([]);
expect(outcome.remaining).toEqual([]);
expect(outcome.recoveredPreservations).toEqual([expect.objectContaining({ path: release.path, branch: release.branch, head: release.head,
archiveDir: saved.archiveDir, verified: true,