Feature: MCP Sandbox Path Rewriting As an actor runtime executing in a sandboxed workspace I want file paths in MCP tool arguments and responses rewritten So that MCP tools operate on correct paths inside the sandbox # ------------------------------------------------------------------- # Argument Rewriting (Host -> Sandbox) # ------------------------------------------------------------------- Scenario: Rewrite host path to sandbox path in arguments Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite tool arguments with key "file_path" and value "/home/user/project/src/main.py" Then the rewritten arguments should have "file_path" equal to "/workspace/src/main.py" Scenario: Non-matching paths pass through unchanged Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite tool arguments with key "file_path" and value "/other/location/file.py" Then the rewritten arguments should have "file_path" equal to "/other/location/file.py" Scenario: Non-path string values are not rewritten Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite tool arguments with key "title" and value "My Document" Then the rewritten arguments should have "title" equal to "My Document" Scenario: Nested dict paths are rewritten Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite nested tool arguments with outer key "config" inner key "source" and value "/home/user/project/cfg.yaml" Then the rewritten nested argument "config.source" should equal "/workspace/cfg.yaml" Scenario: List of paths are rewritten Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite tool arguments with key "files" and path list "/home/user/project/a.py,/home/user/project/b.py" Then the rewritten argument "files" should be a list with 2 rewritten paths Scenario: Host root path itself maps to sandbox root Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite tool arguments with key "dir" and value "/home/user/project" Then the rewritten arguments should have "dir" equal to "/workspace" # ------------------------------------------------------------------- # Response Rewriting (Sandbox -> Host) # ------------------------------------------------------------------- Scenario: Rewrite sandbox path to host path in response Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite tool response with key "output_file" and value "/workspace/build/out.txt" Then the rewritten response should have "output_file" equal to "/home/user/project/build/out.txt" Scenario: Non-matching sandbox response paths pass through Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite tool response with key "output_file" and value "/tmp/other.txt" Then the rewritten response should have "output_file" equal to "/tmp/other.txt" Scenario: Nested response paths are rewritten Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I rewrite nested tool response with outer key "result" inner key "path" and value "/workspace/dist/app.js" Then the rewritten nested response "result.path" should equal "/home/user/project/dist/app.js" # ------------------------------------------------------------------- # Roundtrip # ------------------------------------------------------------------- Scenario: Roundtrip rewrite preserves original path Given a sandbox path rewriter with host root "/home/user/project" and sandbox root "/workspace" When I roundtrip rewrite tool arguments with key "file" and value "/home/user/project/src/main.py" Then the roundtrip path should equal "/home/user/project/src/main.py"