Skip to content

Commit bfd5284

Browse files
test: skip symlink fixtures where the host cannot create symlinks
On Windows without Developer Mode, seven tests failed with EPERM while creating symlinks during fixture setup. Guard them with the existing symlinksSupported probe, matching the other symlink tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e923627 commit bfd5284

4 files changed

Lines changed: 220 additions & 204 deletions

File tree

‎apps/server/src/project/AgentSessionScanner.test.ts‎

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -330,36 +330,38 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
330330
}),
331331
);
332332

333-
it.effect("returns the imported project ID through a realpath alias", () =>
334-
Effect.gen(function* () {
335-
const path = yield* Path.Path;
336-
const fileSystem = yield* FileSystem.FileSystem;
337-
const claudeHomePath = yield* makeTempDir("t3code-claude-home-");
338-
const codexHomePath = yield* makeTempDir("t3code-codex-home-");
339-
const workspace = yield* makeTempDir("t3code-workspace-");
340-
const linkParent = yield* makeTempDir("t3code-scanner-links-");
341-
const workspaceAlias = path.join(linkParent, "workspace-alias");
342-
yield* fileSystem.symlink(workspace, workspaceAlias);
333+
it.effect.skipIf(!symlinksSupported)(
334+
"returns the imported project ID through a realpath alias",
335+
() =>
336+
Effect.gen(function* () {
337+
const path = yield* Path.Path;
338+
const fileSystem = yield* FileSystem.FileSystem;
339+
const claudeHomePath = yield* makeTempDir("t3code-claude-home-");
340+
const codexHomePath = yield* makeTempDir("t3code-codex-home-");
341+
const workspace = yield* makeTempDir("t3code-workspace-");
342+
const linkParent = yield* makeTempDir("t3code-scanner-links-");
343+
const workspaceAlias = path.join(linkParent, "workspace-alias");
344+
yield* fileSystem.symlink(workspace, workspaceAlias);
343345

344-
yield* writeTranscript({
345-
filePath: path.join(claudeHomePath, "projects", "-slug", "a.jsonl"),
346-
contents: claudeSessionLine(workspaceAlias),
347-
mtimeMs: Date.parse("2026-01-01T00:00:00.000Z"),
348-
});
346+
yield* writeTranscript({
347+
filePath: path.join(claudeHomePath, "projects", "-slug", "a.jsonl"),
348+
contents: claudeSessionLine(workspaceAlias),
349+
mtimeMs: Date.parse("2026-01-01T00:00:00.000Z"),
350+
});
349351

350-
const result = yield* runScan({
351-
claudeHomePath,
352-
codexHomePath,
353-
importedWorkspaceRoots: [workspace],
354-
});
352+
const result = yield* runScan({
353+
claudeHomePath,
354+
codexHomePath,
355+
importedWorkspaceRoots: [workspace],
356+
});
355357

356-
expect(result.candidates[0]).toMatchObject({
357-
path: workspace,
358-
projectId: ProjectId.make("project-1"),
359-
alreadyImported: true,
360-
git: null,
361-
});
362-
}),
358+
expect(result.candidates[0]).toMatchObject({
359+
path: workspace,
360+
projectId: ProjectId.make("project-1"),
361+
alreadyImported: true,
362+
git: null,
363+
});
364+
}),
363365
);
364366

365367
it.effect("merges case aliases and preserves the persisted project path", () =>
@@ -873,29 +875,31 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
873875
}),
874876
);
875877

876-
it.effect("excludes sandboxes reached through a symlink into the worktrees dir", () =>
877-
Effect.gen(function* () {
878-
const path = yield* Path.Path;
879-
const claudeHomePath = yield* makeTempDir("t3code-claude-home-");
880-
const codexHomePath = yield* makeTempDir("t3code-codex-home-");
881-
const configBaseDir = yield* makeTempDir("t3code-scanner-base-");
882-
const linkParent = yield* makeTempDir("t3code-scanner-links-");
883-
const fileSystem = yield* FileSystem.FileSystem;
878+
it.effect.skipIf(!symlinksSupported)(
879+
"excludes sandboxes reached through a symlink into the worktrees dir",
880+
() =>
881+
Effect.gen(function* () {
882+
const path = yield* Path.Path;
883+
const claudeHomePath = yield* makeTempDir("t3code-claude-home-");
884+
const codexHomePath = yield* makeTempDir("t3code-codex-home-");
885+
const configBaseDir = yield* makeTempDir("t3code-scanner-base-");
886+
const linkParent = yield* makeTempDir("t3code-scanner-links-");
887+
const fileSystem = yield* FileSystem.FileSystem;
884888

885-
const worktreeCwd = path.join(configBaseDir, "worktrees", "t3code", "wt-3");
886-
yield* fileSystem.makeDirectory(worktreeCwd, { recursive: true });
887-
const symlinkCwd = path.join(linkParent, "innocent-project");
888-
yield* fileSystem.symlink(worktreeCwd, symlinkCwd);
889-
yield* writeTranscript({
890-
filePath: path.join(claudeHomePath, "projects", "-slug", "a.jsonl"),
891-
contents: claudeSessionLine(symlinkCwd),
892-
mtimeMs: Date.parse("2026-01-01T00:00:00.000Z"),
893-
});
889+
const worktreeCwd = path.join(configBaseDir, "worktrees", "t3code", "wt-3");
890+
yield* fileSystem.makeDirectory(worktreeCwd, { recursive: true });
891+
const symlinkCwd = path.join(linkParent, "innocent-project");
892+
yield* fileSystem.symlink(worktreeCwd, symlinkCwd);
893+
yield* writeTranscript({
894+
filePath: path.join(claudeHomePath, "projects", "-slug", "a.jsonl"),
895+
contents: claudeSessionLine(symlinkCwd),
896+
mtimeMs: Date.parse("2026-01-01T00:00:00.000Z"),
897+
});
894898

895-
const result = yield* runScan({ claudeHomePath, codexHomePath, configBaseDir });
899+
const result = yield* runScan({ claudeHomePath, codexHomePath, configBaseDir });
896900

897-
expect(result.candidates).toEqual([]);
898-
}),
901+
expect(result.candidates).toEqual([]);
902+
}),
899903
);
900904

901905
it.effect("finds the cwd on a later line when the first records carry none", () =>

‎apps/server/src/serverSettings.test.ts‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
UsageLimitSourceId,
1212
} from "@t3tools/contracts";
1313
import { createModelSelection } from "@t3tools/shared/model";
14+
import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
1415
import { assert, it } from "@effect/vitest";
1516
import * as Deferred from "effect/Deferred";
1617
import * as Effect from "effect/Effect";
@@ -235,26 +236,28 @@ it.layer(NodeServices.layer)("server settings", (it) => {
235236
}).pipe(Effect.provide(layerServerSettings())),
236237
);
237238

238-
it.effect("saves through a symlinked settings file without replacing the link", () =>
239-
Effect.gen(function* () {
240-
const config = yield* ServerConfig.ServerConfig;
241-
const fs = yield* FileSystem.FileSystem;
242-
const path = yield* Path.Path;
243-
const service = yield* ServerSettingsModule.ServerSettingsService;
244-
const dotfiles = yield* fs.makeTempDirectoryScoped({ prefix: "t3-settings-dotfiles-" });
245-
const linkedSettingsPath = path.join(dotfiles, "settings.json");
246-
yield* fs.writeFileString(linkedSettingsPath, `{ "responseStreamingMode": "turn" }`);
247-
yield* fs.remove(config.settingsPath, { force: true });
248-
yield* fs.symlink(linkedSettingsPath, config.settingsPath);
239+
it.effect.skipIf(!symlinksSupported)(
240+
"saves through a symlinked settings file without replacing the link",
241+
() =>
242+
Effect.gen(function* () {
243+
const config = yield* ServerConfig.ServerConfig;
244+
const fs = yield* FileSystem.FileSystem;
245+
const path = yield* Path.Path;
246+
const service = yield* ServerSettingsModule.ServerSettingsService;
247+
const dotfiles = yield* fs.makeTempDirectoryScoped({ prefix: "t3-settings-dotfiles-" });
248+
const linkedSettingsPath = path.join(dotfiles, "settings.json");
249+
yield* fs.writeFileString(linkedSettingsPath, `{ "responseStreamingMode": "turn" }`);
250+
yield* fs.remove(config.settingsPath, { force: true });
251+
yield* fs.symlink(linkedSettingsPath, config.settingsPath);
249252

250-
yield* service.updateSettings({ responseStreamingMode: "paragraph" });
253+
yield* service.updateSettings({ responseStreamingMode: "paragraph" });
251254

252-
assert.equal(yield* fs.readLink(config.settingsPath), linkedSettingsPath);
253-
const persisted = yield* decodeServerSettingsJson(
254-
yield* fs.readFileString(linkedSettingsPath),
255-
);
256-
assert.equal(persisted.responseStreamingMode, "paragraph");
257-
}).pipe(Effect.provide(layerServerSettings())),
255+
assert.equal(yield* fs.readLink(config.settingsPath), linkedSettingsPath);
256+
const persisted = yield* decodeServerSettingsJson(
257+
yield* fs.readFileString(linkedSettingsPath),
258+
);
259+
assert.equal(persisted.responseStreamingMode, "paragraph");
260+
}).pipe(Effect.provide(layerServerSettings())),
258261
);
259262

260263
it.effect("retries a failed settings read instead of keeping the failure", () =>

‎packages/provider-acp/src/server/clientPolicy.test.ts‎

Lines changed: 93 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @effect-diagnostics nodeBuiltinImport:off
22
import * as NodeServices from "@effect/platform-node/NodeServices";
33
import { assert, describe, it } from "@effect/vitest";
4+
import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
45
import * as Effect from "effect/Effect";
56
import * as FileSystem from "effect/FileSystem";
67
import * as Path from "effect/Path";
@@ -122,100 +123,104 @@ describe("acpPermissionDisposition", () => {
122123
}
123124
});
124125

125-
it.effect("denies mutations through workspace symlinks that escape the writable roots", () =>
126-
Effect.gen(function* () {
127-
const fileSystem = yield* FileSystem.FileSystem;
128-
const path = yield* Path.Path;
129-
const workspace = yield* fileSystem.makeTempDirectoryScoped({
130-
prefix: "t3-acp-permission-workspace-",
131-
});
132-
const outside = yield* fileSystem.makeTempDirectoryScoped({
133-
prefix: "t3-acp-permission-outside-",
134-
});
135-
const outsideFile = path.join(outside, "existing.ts");
136-
yield* fileSystem.writeFileString(outsideFile, "outside");
137-
yield* fileSystem.symlink(outsideFile, path.join(workspace, "linked-file.ts"));
138-
yield* fileSystem.symlink(outside, path.join(workspace, "linked-directory"));
126+
it.effect.skipIf(!symlinksSupported)(
127+
"denies mutations through workspace symlinks that escape the writable roots",
128+
() =>
129+
Effect.gen(function* () {
130+
const fileSystem = yield* FileSystem.FileSystem;
131+
const path = yield* Path.Path;
132+
const workspace = yield* fileSystem.makeTempDirectoryScoped({
133+
prefix: "t3-acp-permission-workspace-",
134+
});
135+
const outside = yield* fileSystem.makeTempDirectoryScoped({
136+
prefix: "t3-acp-permission-outside-",
137+
});
138+
const outsideFile = path.join(outside, "existing.ts");
139+
yield* fileSystem.writeFileString(outsideFile, "outside");
140+
yield* fileSystem.symlink(outsideFile, path.join(workspace, "linked-file.ts"));
141+
yield* fileSystem.symlink(outside, path.join(workspace, "linked-directory"));
139142

140-
const realPolicy: AcpRuntimePolicy = {
141-
runtimeMode: "full-access",
142-
cwd: workspace,
143-
approvalPolicy: "never",
144-
sandboxPolicy: {
145-
type: "workspaceWrite",
146-
writableRoots: [],
147-
networkAccess: false,
148-
},
149-
};
143+
const realPolicy: AcpRuntimePolicy = {
144+
runtimeMode: "full-access",
145+
cwd: workspace,
146+
approvalPolicy: "never",
147+
sandboxPolicy: {
148+
type: "workspaceWrite",
149+
writableRoots: [],
150+
networkAccess: false,
151+
},
152+
};
150153

151-
assert.equal(
152-
acpPermissionDisposition(
153-
realPolicy,
154-
permissionRequest("edit", [{ path: "linked-file.ts" }]),
155-
),
156-
"deny",
157-
);
158-
assert.equal(
159-
acpPermissionDisposition(
160-
realPolicy,
161-
permissionRequest("edit", [{ path: "linked-directory/new-file.ts" }]),
162-
),
163-
"deny",
164-
"a missing leaf below an escaping directory symlink must not be auto-approved",
165-
);
166-
assert.equal(
167-
acpPermissionDisposition(
168-
realPolicy,
169-
permissionRequest("edit", [{ path: "linked-directory/../escaped-file.ts" }]),
170-
),
171-
"deny",
172-
"physical symlink traversal must be resolved before parent segments",
173-
);
174-
}).pipe(Effect.provide(NodeServices.layer)),
154+
assert.equal(
155+
acpPermissionDisposition(
156+
realPolicy,
157+
permissionRequest("edit", [{ path: "linked-file.ts" }]),
158+
),
159+
"deny",
160+
);
161+
assert.equal(
162+
acpPermissionDisposition(
163+
realPolicy,
164+
permissionRequest("edit", [{ path: "linked-directory/new-file.ts" }]),
165+
),
166+
"deny",
167+
"a missing leaf below an escaping directory symlink must not be auto-approved",
168+
);
169+
assert.equal(
170+
acpPermissionDisposition(
171+
realPolicy,
172+
permissionRequest("edit", [{ path: "linked-directory/../escaped-file.ts" }]),
173+
),
174+
"deny",
175+
"physical symlink traversal must be resolved before parent segments",
176+
);
177+
}).pipe(Effect.provide(NodeServices.layer)),
175178
);
176179

177-
it.effect("allows existing and new files beneath canonical writable roots", () =>
178-
Effect.gen(function* () {
179-
const fileSystem = yield* FileSystem.FileSystem;
180-
const path = yield* Path.Path;
181-
const workspace = yield* fileSystem.makeTempDirectoryScoped({
182-
prefix: "t3-acp-permission-workspace-",
183-
});
184-
const workspaceLinkParent = yield* fileSystem.makeTempDirectoryScoped({
185-
prefix: "t3-acp-permission-link-parent-",
186-
});
187-
const workspaceLink = path.join(workspaceLinkParent, "workspace-link");
188-
yield* fileSystem.makeDirectory(path.join(workspace, "src"), { recursive: true });
189-
yield* fileSystem.writeFileString(path.join(workspace, "src", "existing.ts"), "existing");
190-
yield* fileSystem.symlink(workspace, workspaceLink);
180+
it.effect.skipIf(!symlinksSupported)(
181+
"allows existing and new files beneath canonical writable roots",
182+
() =>
183+
Effect.gen(function* () {
184+
const fileSystem = yield* FileSystem.FileSystem;
185+
const path = yield* Path.Path;
186+
const workspace = yield* fileSystem.makeTempDirectoryScoped({
187+
prefix: "t3-acp-permission-workspace-",
188+
});
189+
const workspaceLinkParent = yield* fileSystem.makeTempDirectoryScoped({
190+
prefix: "t3-acp-permission-link-parent-",
191+
});
192+
const workspaceLink = path.join(workspaceLinkParent, "workspace-link");
193+
yield* fileSystem.makeDirectory(path.join(workspace, "src"), { recursive: true });
194+
yield* fileSystem.writeFileString(path.join(workspace, "src", "existing.ts"), "existing");
195+
yield* fileSystem.symlink(workspace, workspaceLink);
191196

192-
const realPolicy: AcpRuntimePolicy = {
193-
runtimeMode: "full-access",
194-
cwd: workspaceLink,
195-
approvalPolicy: "never",
196-
sandboxPolicy: {
197-
type: "workspaceWrite",
198-
writableRoots: [],
199-
networkAccess: false,
200-
},
201-
};
197+
const realPolicy: AcpRuntimePolicy = {
198+
runtimeMode: "full-access",
199+
cwd: workspaceLink,
200+
approvalPolicy: "never",
201+
sandboxPolicy: {
202+
type: "workspaceWrite",
203+
writableRoots: [],
204+
networkAccess: false,
205+
},
206+
};
202207

203-
assert.equal(
204-
acpPermissionDisposition(
205-
realPolicy,
206-
permissionRequest("edit", [{ path: "src/existing.ts" }]),
207-
),
208-
"allow",
209-
);
210-
assert.equal(
211-
acpPermissionDisposition(
212-
realPolicy,
213-
permissionRequest("edit", [{ path: "src/generated/new-file.ts" }]),
214-
),
215-
"allow",
216-
"non-existent descendants of a real in-root ancestor remain writable",
217-
);
218-
}).pipe(Effect.provide(NodeServices.layer)),
208+
assert.equal(
209+
acpPermissionDisposition(
210+
realPolicy,
211+
permissionRequest("edit", [{ path: "src/existing.ts" }]),
212+
),
213+
"allow",
214+
);
215+
assert.equal(
216+
acpPermissionDisposition(
217+
realPolicy,
218+
permissionRequest("edit", [{ path: "src/generated/new-file.ts" }]),
219+
),
220+
"allow",
221+
"non-existent descendants of a real in-root ancestor remain writable",
222+
);
223+
}).pipe(Effect.provide(NodeServices.layer)),
219224
);
220225
});
221226

0 commit comments

Comments
 (0)