Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
686e7f1
fix(shared): search cwd for empty POSIX PATH components
Motaghi Oct 31, 2026
4b1f3c5
fix(shared): scope relative PATH caches to the working directory
Motaghi Oct 31, 2026
4255544
no-mistakes(review): Scope macOS Git caches to relative PATH cwd
Motaghi Oct 31, 2026
f838d61
no-mistakes(lint): Format shell regression test destructuring
Motaghi Oct 31, 2026
29c7cd2
fix(shared): keep absolute PATH lookup working when cwd cannot be read
Motaghi Nov 17, 2026
aebdce8
fix(server): anchor cwd provider executables before scoped launch
maria-rcks Nov 18, 2026
0881188
fix(shared): anchor executables found through empty PATH components
Motaghi Nov 18, 2026
15855b7
Merge main into behmot/posix-empty-path-components-20261031
Motaghi Nov 19, 2026
78aec4c
fix(shared,server): keep absolute agent paths as spelled and probe th…
Motaghi Nov 19, 2026
22aef07
test(server): skip the symlinked-parent agentScope case where symlink…
Motaghi Nov 19, 2026
6e62d1c
fix(server): anchor relative agent paths for systemd-run without coll…
Motaghi Nov 19, 2026
9f21982
Merge main into behmot/posix-empty-path-components-20261031
Motaghi Nov 22, 2026
81e9154
fix(shared): share the cwd snapshot with PATH searches and launch the…
Motaghi Nov 22, 2026
669eac2
Merge main into behmot/posix-empty-path-components-20261031
Motaghi Nov 22, 2026
fcf8241
Merge remote-tracking branch 'origin/main' into behmot/posix-empty-pa…
juliusmarminge Nov 23, 2026
49c91bb
test(shared): trim empty PATH component tests to the regressions
juliusmarminge Nov 23, 2026
6dfeac2
fix(shared): keep relative PATH probes valid after the cwd is renamed
juliusmarminge Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions apps/server/src/process/agentScope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, describe, expect, it } from "@effect/vitest";
import { AgentScope } from "@t3tools/shared/AgentScope";
import * as HostProcess from "@t3tools/shared/HostProcess";
import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
Expand Down Expand Up @@ -186,8 +187,12 @@ const exitedAgent = (

const stopsOf = (calls: ReadonlyArray<ReadonlyArray<string>>) =>
calls.filter(([, verb]) => verb === "stop");
const launchCodex = (scope: Effect.Success<typeof make>, threadId: string) =>
makeCodexAppServerSpawnCommand({ command: "agent", args: ["app-server"], threadId }).pipe(
const launchCodex = (
scope: Effect.Success<typeof make>,
threadId: string,
env?: NodeJS.ProcessEnv,
) =>
makeCodexAppServerSpawnCommand({ command: "agent", args: ["app-server"], threadId, env }).pipe(
Effect.provideService(AgentScope, scope),
Effect.provideService(HostProcess.Platform, "linux"),
Effect.map((command) => {
Expand Down Expand Up @@ -227,7 +232,14 @@ describe("AgentScope service", () => {
units.set(unitOf(agent), { activeState: "failed", result: "oom-kill" });
expect(yield* scope.oomKilled("a")).toBe(true);

const codex = yield* launchCodex(scope, "a");
const executable = String(agent.args.at(-1));
const codex = yield* launchCodex(scope, "a", {
PATH: NodePath.relative(process.cwd(), NodePath.dirname(executable)),
});
// Anchored to the cwd for systemd-run, with its ".." kept; it names the same file.
const anchored = String(codex.args.at(-2));
expect(NodePath.isAbsolute(anchored)).toBe(true);
expect(NodePath.resolve(anchored)).toBe(executable);
expect(codex.args).toContain("--property=OOMPolicy=continue");
expect(codex.args).not.toContain("--property=OOMPolicy=stop");
expect(codex.args).toContain("--property=TimeoutStopSec=10s");
Expand All @@ -243,6 +255,33 @@ describe("AgentScope service", () => {
),
);

it.effect.skipIf(!symlinksSupported)(
"keeps a symlinked parent in absolute and relative executable paths",
() =>
withFakeSystemd(({ scope }) =>
Effect.gen(function* () {
const plain = yield* scope.wrap({ command: "agent", args: [], name: "t", threadId: "s" });
const bin = NodePath.dirname(String(plain.args.at(-1)));
NodeFS.mkdirSync(NodePath.join(bin, "real", "sub"), { recursive: true });
NodeFS.writeFileSync(NodePath.join(bin, "real", "agent"), "", { mode: 0o755 });
NodeFS.symlinkSync(NodePath.join(bin, "real", "sub"), NodePath.join(bin, "link"));
// The kernel follows the link before "..", so this names real/agent, not bin/agent.
const command = `${NodePath.join(bin, "link")}/../agent`;
const wrapped = yield* scope.wrap({ command, args: [], name: "t", threadId: "s" });
expect(wrapped.args.at(-1)).toBe(command);
// A relative path is anchored to the cwd the same way, without collapsing "..".
const relative = `${NodePath.relative(process.cwd(), NodePath.join(bin, "link"))}/../agent`;
const anchored = yield* scope.wrap({
command: relative,
args: [],
name: "t",
threadId: "s",
});
expect(anchored.args.at(-1)).toBe(`${process.cwd()}${NodePath.sep}${relative}`);
}),
),
);

it.effect.each([{ oomPolicy: true }, { oomPolicy: false }])(
"Force stop kills a thread's own scope but never a shared Codex scope (OOM policy $oomPolicy)",
({ oomPolicy }) =>
Expand Down
10 changes: 9 additions & 1 deletion apps/server/src/process/agentScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,15 @@ export const make = Effect.gen(function* () {
...(owned ? [] : ["--collect"]),
],
};
return { ...agentScopeCommand({ command: resolved, args, scope: systemdScope }), unit };
// systemd-run does not search the caller's cwd, so anchor a relative path to it. Keep ".."
// as spelled: collapsing it would skip a symlinked parent directory.
const executable = path.isAbsolute(resolved)
? resolved
: `${process.cwd()}${path.sep}${resolved}`;
return {
...agentScopeCommand({ command: executable, args, scope: systemdScope }),
unit,
};
}),
oomKilled,
stop,
Expand Down
Loading
Loading