Metadata-Version: 2.4
Name: walls
Version: 0.1.18
Summary: Wall in Claude Code agents to the current folder using Apptainer/Singularity containers
Author-email: Your Name <your@email.com>
License: MIT
Project-URL: Homepage, https://github.com/munch-group/walls
Project-URL: Repository, https://github.com/munch-group/walls
Project-URL: Documentation, https://munch-group.org/walls
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0
Requires-Dist: tomli>=2.0; python_version < "3.11"
Requires-Dist: tomli-w>=1.0
Dynamic: license-file

# walls

`walls` runs Claude Code (or anything else) in an [Apptainer/Singularity](https://apptainer.org) container where **only the current folder is writable**. It is meant for large shared file servers, where you, and so any agent you start, can write to many files that belong to many people.

```bash
cd /faststorage/project/my-analysis
walls            # bash in a box; the folder is at /work. Now run: claude
```

## What the box can and cannot touch

| Host | Inside the box |
| --- | --- |
| Current folder | read-write at `/work` |
| `$HOME` | `~/claude-home` (shared by all boxes; holds the Claude Code install and login) |
| `/tmp`, `/var/tmp` | private per folder, kept in `~/claude-work/<folder>-<hash>` |
| Extra folders (`--ro`, `--rw`, `mounts.*`) | at their real paths, read-only unless asked otherwise |
| Host `PATH` (optional) | read-only, at the real paths |
| Everything else on the host | not mounted (`--contain --no-mount hostfs,bind-paths`) |
| Host processes | not visible and not signalable from inside the box (see below) |

The main goal is to shield the rest of the file system from Claude sessions. Shielding boxes from each other matters less: they share `~/claude-home`, so one box can read what another left there.

To make that boundary hold, walls refuses to:

- wall in `/` or your home folder,
- give write access to a folder that contains walls' own folders (claude home, scratch, images, config).

All configuration lives in `~/.config/walls/config.toml`, outside any walled folder. Settings for a single folder are stored there too, under `[folders."<path>"]`, so nothing running inside a box can change what the next box may see.

## Install

```bash
pip install git+https://github.com/munch-group/walls   # or, once released: conda install -c munch-group walls
walls setup                # creates ~/claude-home and ~/claude-work, pulls the image, installs Claude Code
walls doctor               # checks that everything is in place
```

`walls setup` pulls `docker://mcr.microsoft.com/vscode/devcontainers/universal:linux` (several GB). If your home quota is small, point `APPTAINER_CACHEDIR` and `APPTAINER_TMPDIR` at a scratch disk first.

## Usage

```bash
walls                              # interactive bash in a box
walls /data/ref /data/db           # ...plus read-only access to these folders
walls --rw ../shared-results       # ...plus read-write access to this one
walls -- claude                    # run a command instead of a shell
walls --host-path --aliases        # one-off: mount host PATH, import bash aliases
walls --dry-run                    # print the apptainer command and rcfile, start nothing
```

### Images

```bash
walls image pull                                   # the default image
walls image pull docker://ubuntu:24.04 --name ubuntu
walls image build my.def --name custom --fakeroot
walls image list
walls image use ubuntu [--folder]                  # default for all boxes, or for this folder
walls image rm ubuntu
```

### Claude Code

```bash
walls claude install     # official installer, run inside a box with HOME=~/claude-home
walls claude update
```

### Configuration

```bash
walls config show [--effective] [--folder [DIR]]
walls config get  shell.import_aliases
walls config set  shell.import_aliases true             # globally
walls config set  path.mount_host_path true --folder    # only for the current folder
walls config add  mounts.ro /faststorage/project/ref --folder
walls config remove mounts.ro /faststorage/project/ref --folder
walls config unset path.mount_host_path --folder
walls config folders [--prune]                          # folders with their own settings
walls config edit                                       # $EDITOR, validated afterwards
```

Settings are applied in this order, each overriding the one before:

1. built-in defaults
2. global settings
3. the current folder's settings
4. command-line flags

List settings (such as `mounts.ro`) from different levels are combined rather than replaced.

| Key | Default | Meaning |
| --- | --- | --- |
| `paths.claude_home` | `~/claude-home` | `$HOME` inside every box (global only) |
| `paths.work_root` | `~/claude-work` | per-box scratch (global only) |
| `paths.image_dir` | `~/.local/share/walls/images` | where named `.sif` images live (global only) |
| `image.default` | `universal_linux` | image name or `.sif` path |
| `image.source` | `docker://mcr.microsoft.com/vscode/devcontainers/universal:linux` | what `walls image pull` fetches |
| `apptainer.binary` | `auto` | `apptainer`, falling back to `singularity` |
| `apptainer.private_pid` | `true` | give the box its own process and IPC namespaces (`--pid --ipc`); no box is started on hosts that refuse this |
| `apptainer.extra_args` | `[]` | extra arguments passed to `apptainer exec` |
| `mounts.ro` / `mounts.rw` | `[]` | extra folders, mounted at their real paths |
| `shell.import_aliases` | `false` | copy the aliases from your host `bash` into the box |
| `shell.prompt` | magenta `[$BOX]` plus working dir | `PS1` inside the box |
| `shell.env_pass` | `TERM`, `COLORTERM` | host environment variables passed into the box |
| `path.mount_host_path` | `false` | mount the host `PATH` read-only and append it to the box `PATH` |
| `path.exclude` | `/bin`, `/sbin`, `/usr/*`, ... | `PATH` entries never mounted (the image provides these) |

**Aliases.** With `shell.import_aliases`, walls reads the aliases that `bash -ic 'alias -p'` reports on the host. They are defined in the box after `~/claude-home/.bashrc` has been sourced. An alias that refers to a host path only works if that path is mounted.

**Host PATH.** For a `PATH` entry ending in `/bin`, walls mounts the parent prefix so that the rest of the installation is available too: a conda env's `bin/python` needs the env's `lib/`. The parent is not used if it is `/`, a top-level folder, or your home folder. Host entries are appended after the box's own `PATH`, so the image's tools win. An entry is skipped with a warning if mounting it would hide something in the box home, e.g. `~/.local`, where Claude Code is installed. An empty folder in the box home does not count: the container runtime leaves one behind as the mount point.

**glibc.** A host program runs in the box only if the image's glibc is at least as new as the one the program was built for. When a box starts with host `PATH` mounts, walls warns if this machine's glibc is newer than the image's. `walls doctor` goes further and lists each mounted host program that needs a newer glibc than the image has. The image's glibc version is read once per image file and remembered in `~/.cache/walls/image-glibc.json`. Only glibc is checked: a host program can still fail in the box because a shared library it needs is not mounted.

**The walled folder.** The wall protects what is outside the folder, not the folder from what happens in it. A program in a box can change anything in the walled folder and in every folder mounted read-write, and whatever it leaves there runs with your full access when you later run it on the host. That goes for scripts, a `Makefile`, notebooks and task definitions, and also for git: a hook in `.git/hooks` or a setting in `.git/config` is run by ordinary `git` commands, and a shell prompt that shows git status is enough to trigger one. So after a box has worked in a folder, treat the folder's contents as you would code from someone else: look at what changed (`git status`, `git diff`) before you run it on the host, and note that `git diff` does not show changes inside `.git`. The same holds for `~/claude-home`, which every box can write to: walls only ever runs what is in it inside a box.

**Processes.** A box gets its own process and IPC namespaces (`--pid --ipc`): it sees only its own processes and cannot signal any on the host. This needs a host that lets a user namespace mount a new `/proc`. A host refuses when files are mounted over parts of `/proc`, as on some cluster front ends. On such a host walls starts no box and says why; it does not fall back to a weaker box. Start the box on a host that allows it instead, for example a compute node with `srun --pty walls`. `walls doctor` tells you whether the current host allows it.

To start a box on such a host anyway, switch the separation off with `walls --no-private-pid` or `apptainer.private_pid false`. A program in that box can list all host processes with their command lines and send signals to (and so kill) your own host processes. There is no in-between that works: a box without any `/proc` hides the host's processes, but Claude Code does not start in it.

**User namespace.** walls always starts Apptainer in a user namespace (`--userns`) and fails if the host does not allow that; it never uses Apptainer's setuid mode. The user namespace is what keeps a box from reading host files through `/proc/<pid>/root`.

**Network.** The network is not walled in. A box shares the host's network, so a program in it has the same network reach as you have on that host: the internet, other machines on the local network, every service that listens on the host's `localhost` (on a shared machine that includes other users' services), and abstract unix sockets. This breaks the wall if one of those services acts for you without asking who is calling, such as a Jupyter server without a token, a Dask or Ray scheduler, or a development server. Do not run such services on a host while a box is running there. Files that hold credentials for services, such as SSH keys and Jupyter tokens, are not visible in a box unless you mount them.

walls starts a box with a clean environment, so the host's proxy variables (`HTTPS_PROXY` and the like) are not set in it. On a host that reaches the internet only through a proxy, add them to `shell.env_pass`.

## How it works

`walls` resolves the settings, then writes a small bash rcfile to `~/claude-work/<box>/walls.bashrc`, which is mounted read-only at `/walls/bashrc`. That rcfile sources `~/claude-home/.bashrc` and then sets the prompt, `PATH` and aliases. Finally walls replaces itself with:

```bash
apptainer exec --userns --contain --cleanenv --pid --ipc --no-mount bind-paths,hostfs \
  --home ~/claude-home:/home/$USER --workdir ~/claude-work/<box> --writable-tmpfs \
  --bind $PWD:/work --pwd /work --bind <extra mounts> <image>.sif bash --rcfile /walls/bashrc -i
```

Run `walls --dry-run` to see the exact command for the current folder.
