Repository navigation
Description
Describe the bug
Files projected into the sandbox lose their POSIX permissions. A script that is 0755 on the host arrives as 0644 inside the sandbox, so running it directly fails:
$ ./bin/run.sh
sh: 1: ./bin/run.sh: Permission denied
The projection payload is a tar archive that the backend extracts with tar -xf, so the entry mode is exactly what the file ends up with. WorkspaceProjectionApplier creates each entry with new TarArchiveEntry(rel) and never calls setMode, so every projected file carries the tar default (0644).
The same class of loss exists on the direct materialization path: WorkspaceSpecApplier copies LocalFileEntry / LocalDirEntry bytes with Files.copy and no attributes, which creates the target with the platform default permissions — so a 0755 script configured through the workspace spec also lands 0644.
There is a second half to this: the projection hash is computed over paths and content only, so a chmod that leaves the bytes alone does not change the hash and the projection is skipped. Even once the mode is carried in the archive, a permission-only change would not re-project.
To Reproduce
-
Make a projected script executable on the host:
chmod 0755 skills/demo/bin/run.sh
-
Add a
workspace_projectionentry that includes theskillsroot:WorkspaceProjectionEntry projection = new WorkspaceProjectionEntry(); projection.setSourceRoot("/host/workspace"); projection.setIncludeRoots(List.of("skills"));
-
Start the sandbox and run the script:
./skills/demo/bin/run.sh
Expected behavior
A projected file keeps the permission it has on the host: 0755 arrives 0755 and ./bin/run.sh runs. Files whose host filesystem cannot express POSIX permissions (a Windows host) keep 0644, and a permission-only change on the host re-projects.
Error messages
sh: 1: ./bin/run.sh: Permission denied
Environment
- AgentScope Java version: 2.1.0-SNAPSHOT (
upstream/mainatc1d482900) - Module:
agentscope-harness - Backend: docker (any backend that extracts the projection payload with
tar -xf) - Host OS: Linux/macOS for the executable-bit case; a Windows host has no POSIX permission bits to inherit
Additional context
Uploads are intentionally out of scope: SandboxBackedFilesystem's archive and DockerSandbox.uploadFile's docker-cp path write content at 0644 by contract ("uploads must stay readable when the container runs as a non-root user") and have no source path to inherit from.
I have a fix ready and will link the pull request.
Activity
fix(harness): keep workspace file permissions when projecting and mat…