Skip to content

refactor(sandbox-adapter): simplify sandboxEnv - #342

Merged
eersnington merged 1 commit into
chore/pi-move-database-envfrom
chore/sandbox-env-options
Oct 8, 2026
Merged

eersnington merged 1 commit into
chore/pi-move-database-envfrom
chore/sandbox-env-options

Conversation

@eersnington

@eersnington eersnington commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

sandboxEnv threw path errors and then caught them, repeated the same path check in six methods, and normalized the root on every call. It also took three strings by position, so root and cwd could be swapped without a type error.

-sandboxEnv(`${provider.name}:${c.actorId}`, root, connect, target.cwd)
+sandboxEnv(connect, { id: `${provider.name}:${c.actorId}`, root, cwd: target.cwd })
-readTextFile: async (path) => {
-	const resolved = inside(path); // try { resolveSandboxPath } catch → Result
-	if (!resolved.ok) return resolved;
-	return withSandbox(fileFailure(resolved.value), (sandbox) => read(sandbox, resolved.value, …));
-},
+readTextFile: (path, context) =>
+	onFile(path, context, (sandbox, target) => read(sandbox, target, …)),
  • checkedRoot checks the root once, when the env is built.
  • resolveInside returns a Result and never throws.
  • onPath takes a plain path. It no longer rechecks a result that every caller already checked.
  • A root with a trailing slash no longer rejects every path, because the root is resolved, not only normalized.

This is part 5 of 9 in a stack:

@eersnington eersnington changed the title refactor(sandbox-adapter): return sandbox path errors as results and take sandboxEnv options by name refactor(sandbox-adapter): simplify sandboxEnv Oct 8, 2026
@eersnington
eersnington force-pushed the chore/sandbox-env-options branch from 19ff3bc to edf6598 Compare October 8, 2026 15:40
@eersnington
eersnington added this pull request to stack #347 October 8, 2026 16:05
@eersnington
eersnington merged commit 8da8b3f into main Oct 8, 2026
0 of 6 checks passed
@eersnington
eersnington deleted the chore/sandbox-env-options branch October 8, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant