Skip to content

Commit a8baa75

Browse files
sanchitrkclaude
andcommitted
refactor(harness): drop Location.Ref; location is always the mount cwd
Ref.directory let a Location point somewhere other than the mount's cwd, where tools actually run. Only a test fixture set it, and Location.layerWith and defaultLayer took a Ref with no callers at all. Remove all three; the fixture mounts the remote sandbox at the repo instead, as the runner mounts at the session directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 823a2e0 commit a8baa75

3 files changed

Lines changed: 9 additions & 26 deletions

File tree

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import { Effect, Layer } from "effect";
2-
import { Database } from "../db/db.ts";
32
import { Git } from "../git/git.ts";
43
import { Project } from "../project/project.ts";
54
import { Repo } from "../repo/repo.ts";
65
import { SandboxIO } from "../sandbox/io.ts";
7-
import { Sandbox } from "../sandbox/sandbox.ts";
86
import { AbsolutePath } from "../schema.ts";
97
import { Space } from "../space/space.ts";
108
import { Worktree } from "../worktree/worktree.ts";
11-
import { Info, type Ref, Service } from "@codeworksh/plugin/location";
9+
import { Info, Service } from "@codeworksh/plugin/location";
1210

1311
/**
1412
* Where work happens: a directory inside a space.
1513
*
16-
* The shape (`Ref`, `Info`) and the service tag live in `@codeworksh/plugin`, because a resolved
14+
* The shape (`Info`) and the service tag live in `@codeworksh/plugin`, because a resolved
1715
* `Info` is on every plugin context and `Service` is half of a plugin's `Mount`. Resolving one
1816
* needs Project, Space, Repo, Worktree and Git, so the layers stay here.
1917
*/
@@ -23,19 +21,18 @@ export {
2321
Info,
2422
type Interface,
2523
NotDirectoryError,
26-
Ref,
2724
Service,
2825
} from "@codeworksh/plugin/location";
2926

3027
// `SandboxIO.Current` in the requirements is what makes "mount first" a
3128
// type-level fact rather than a convention: this Layer cannot be built outside a
3229
// mount, so there is never a Location without one underneath.
33-
export const layer = (ref: Ref = {}) =>
30+
export const layer = () =>
3431
Layer.effect(
3532
Service,
3633
Effect.gen(function* () {
3734
const instance = yield* SandboxIO.Current;
38-
const directory = AbsolutePath.make(ref.directory ?? instance.cwd);
35+
const directory = AbsolutePath.make(instance.cwd);
3936
const project = yield* Project.Service;
4037
const resolved = yield* project.resolveOrCreate(directory);
4138
return Service.of(
@@ -49,8 +46,8 @@ export const layer = (ref: Ref = {}) =>
4946
* folded in. What remains is exactly the mount and the database — for callers
5047
* that already hold both, such as the runner and `Session.create`.
5148
*/
52-
export const layerMounted = (ref: Ref = {}) =>
53-
layer(ref).pipe(
49+
export const layerMounted = () =>
50+
layer().pipe(
5451
Layer.provide(
5552
Project.layer.pipe(
5653
Layer.provide(Layer.mergeAll(Repo.layer, Worktree.layer, Space.layer)),
@@ -59,9 +56,4 @@ export const layerMounted = (ref: Ref = {}) =>
5956
),
6057
);
6158

62-
export const layerWith = <E, RIn>(ref: Ref, sandbox: Sandbox.Sandbox<E, RIn>) =>
63-
layerMounted(ref).pipe(Layer.provide(sandbox), Layer.provide(Database.defaultLayer));
64-
65-
export const defaultLayer = (ref: Ref, path: string) => layerWith(ref, Sandbox.defaultLayer(path));
66-
6759
export * as Location from "./location.ts";

‎packages/harness/test/fixtures/remote.spec.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { SandboxIO } from "../../src/sandbox/io.ts";
1212
import { Sandbox } from "../../src/sandbox/sandbox.ts";
1313
import { type ISandboxExe, Shell } from "../../src/sandbox/shell/shell.ts";
1414
import { SandboxStore } from "../../src/sandbox/store.ts";
15-
import { AbsolutePath } from "../../src/schema.ts";
1615
import { Session } from "../../src/session/session.ts";
1716
import { fromSandboxShell, ToolShell, ToolShellTimeout } from "../../src/tool/shell.ts";
1817
import { Hash } from "../../src/util/hash.ts";
@@ -393,6 +392,7 @@ export const remoteSandboxSpec = (options: RemoteSandboxSpecOptions) => {
393392
driver: options.kind,
394393
id: mappedEnvId,
395394
defaultCwd: options.cwd,
395+
cwd: repo,
396396
}),
397397
),
398398
);
@@ -410,10 +410,7 @@ export const remoteSandboxSpec = (options: RemoteSandboxSpecOptions) => {
410410
}),
411411
),
412412
).pipe(Layer.provide(database));
413-
const location = Location.layerMounted({ directory: AbsolutePath.make(repo) }).pipe(
414-
Layer.provide(sandbox),
415-
Layer.provide(registered),
416-
);
413+
const location = Location.layerMounted().pipe(Layer.provide(sandbox), Layer.provide(registered));
417414
// provideMerge, not provide: `registered` and the block below
418415
// share the one in-memory database.
419416
const application = Layer.merge(location, Session.layer).pipe(

‎packages/plugin/src/location.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { SpaceSchema } from "./space.ts";
1414
* equal to or beneath that root. Sessions sharing a space share the project;
1515
* worktree relationships stay a Project concern beneath it.
1616
*
17-
* **Both halves come from the mount, so `Ref` is overrides and nothing else.**
17+
* **Both halves come from the mount, and nothing overrides them.**
1818
* A Location is a directory *within* a mounted namespace — the mount has to be
1919
* resolved first, the way a volume is mounted before any path on it means
2020
* anything — and once it is, the namespace and the working directory are already
@@ -26,12 +26,6 @@ import { SpaceSchema } from "./space.ts";
2626
* which belong to the harness; a plugin receives a resolved `Info` on its context and asks for
2727
* {@link Service} when it needs the live one.
2828
*/
29-
export const Ref = Schema.Struct({
30-
/** Defaults to the mount's cwd. Set it to work in a subdirectory of the mount. */
31-
directory: Schema.optional(AbsolutePath),
32-
}).annotate({ identifier: "Location.Ref" });
33-
export type Ref = typeof Ref.Type;
34-
3529
export class Info extends Schema.Class<Info>("Location.Info")({
3630
/** The absolute cwd tools run in; `space.location` is the root it lives under. */
3731
directory: AbsolutePath,

0 commit comments

Comments
 (0)