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: keep autofixer's isGitRepo/createDisposableWorktree contracts intact under the new cwd guard (#4554)
[._.]/ Adam Eivy09d3ceba147b
diff --git a/autofixer/sandbox.git.test.js b/autofixer/sandbox.git.test.jsindex 16b991d933..3235c9d455 100644--- a/autofixer/sandbox.git.test.js+++ b/autofixer/sandbox.git.test.js@@ -55,6 +55,10 @@ describe('git worktree isolation (integration)', () => {const nonRepo = join(scratch, 'plain');await mkdir(nonRepo, { recursive: true });expect(await isGitRepo(nonRepo)).toBe(false);+ // A missing path answers false rather than asking git about process.cwd(),+ // which for this suite is the PortOS checkout itself (#4554).+ expect(await isGitRepo(undefined)).toBe(false);+ expect(await isGitRepo('')).toBe(false);});it('runs an edit in the worktree, collects a diff, and promotes it to live', async () => {diff --git a/autofixer/sandbox.js b/autofixer/sandbox.jsindex 0b027c117d..674e270e4a 100644--- a/autofixer/sandbox.js+++ b/autofixer/sandbox.js@@ -368,8 +368,10 @@ export function execGit(gitArgs, cwd) {});}-/** True when repoPath is inside a git work tree. */+/** True when repoPath is inside a git work tree. A missing path is a definite+ * no — never a reason to ask git about the autofixer's own cwd (#4554). */export async function isGitRepo(repoPath) {+ if (typeof repoPath !== 'string' || repoPath.trim() === '') return false;const { code, stdout } = await execGit(['rev-parse', '--is-inside-work-tree'], repoPath);return code === 0 && stdout.trim() === 'true';}@@ -384,6 +386,9 @@ export async function isGitRepo(repoPath) {* @param {string} id unique session id*/export async function createDisposableWorktree(repoPath, parentDir, id) {+ if (typeof repoPath !== 'string' || repoPath.trim() === '') {+ return { error: 'no repo path — refusing to isolate against the autofixer\u2019s own working directory' };+ }const path = join(parentDir, id);await mkdir(parentDir, { recursive: true }).catch(() => {});const { code, stderr } = await execGit(['worktree', 'add', '--detach', path, 'HEAD'], repoPath);diff --git a/server/lib/tempPathGuard.js b/server/lib/tempPathGuard.jsindex 9e1869f49c..d99ba1b7e6 100644--- a/server/lib/tempPathGuard.js+++ b/server/lib/tempPathGuard.js@@ -36,8 +36,15 @@ function tempRoots() {return real === raw ? [raw] : [raw, real];}-const isUnder = (child, parent) =>- child === parent || child.startsWith(parent.endsWith(sep) ? parent : `${parent}${sep}`);+// Windows paths compare case-insensitively, and a TEMP env var spelled with+// different casing than a resolved path would otherwise read as "not temp".+const comparable = (value) => (process.platform === 'win32' ? value.toLowerCase() : value);++function isUnder(child, parent) {+ const c = comparable(child);+ const p = comparable(parent);+ return c === p || c.startsWith(p.endsWith(sep) ? p : `${p}${sep}`);+}/*** True when `target` is an absolute path inside the OS temp dir.@@ -47,9 +54,8 @@ const isUnder = (child, parent) =>export function isTempPath(target) {if (typeof target !== 'string' || target.length === 0 || !isAbsolute(target)) return false;const resolved = resolve(target);- const candidates = resolved === realpathOrSelf(resolved)- ? [resolved]- : [resolved, realpathOrSelf(resolved)];+ const real = realpathOrSelf(resolved);+ const candidates = real === resolved ? [resolved] : [resolved, real];return tempRoots().some((root) => candidates.some((candidate) => isUnder(candidate, root)));}