Isolation
The isolation level applies to the commands of the run tool. The file tools (read_file, write_file, edit_file, list_files, search) run in the daemon at each level, and they stay inside the work folder. The model calls run in the daemon.
--isolation of start sets the level. The default is isolation of config.json, else process. A level that the host cannot give makes start fail with the reason. jcode never falls back to a weaker level.
| Level | Protects | Does not protect |
|---|---|---|
none |
Nothing. | A command has the full power of the user: each file of the user, each credential in the home folder, the network, and each process of the user. |
process |
A command can change only the work folder, the paths of --write, and its scratch folder. It has no network unless --net. It has the memory limit of --mem and the process limits of a cgroup. |
A command can read each file that the user can read, also credentials. Linux only. |
cloud |
The whole agent runs on its own EC2 instance, which ends after the one task. The instance gets only the commits of the work folder, and gives back its commits as the branch jcode/ID. |
The instance reaches the internet on port 443, and can call the models of its allow list. Its commands run as root on the instance. |
vm |
A command runs in a new Linux guest. The guest sees only the work folder, at /mnt/share, and has no network unless --net. |
A fault of the guest kernel or of KVM. The work folder is shared: a command can change each file in it, also .git. |
none
The command runs with sh -c as a child of the daemon, in its own process group. Use it only with a brief and a model that you trust, or on a machine with no secret.
process
The command runs in a process thread of ztcl (thread::create -isolation process):
- Landlock: the command can write only the work folder, the paths of
--write, and the scratch folder of the agent (agents/ID/runof the state folder).TMPDIRis a folder there. - A new network namespace with no interface but
lo, unless--net. - A cgroup with the memory limit of
--memand a limit of processes.
The level needs Linux with Landlock, user namespaces, and cgroup v2. With ztcl 1.0.0-beta.7:
- a program can still look up names with the network off (ztcl#1328);
- the namespace has no loopback interface (ztcl#1333);
- at most 8 agents run a command at one time. A later ztcl has
--threads-process, andbin/jcodeasks for 64.
vm
Each command runs in a new guest of ztcl::vm: the signed guest image ztcl-guest (Linux with busybox), the memory of --mem (512 MB by default), and the work folder at /mnt/share. Before the command, jcode mounts a tmpfs on /bin with busybox and a link for each applet, so sh and #!/bin/sh work. The guest ends after the command; a stop, an interrupt, or a timeout deletes it.
The level needs KVM and the guest image in the store of ztcl::vm (Run an agent in a VM). With ztcl 1.0.0-beta.7:
- only the work folder is shared;
--writehas no effect; - the guest has no cgroups and no Landlock (ztcl#1315);
- the close of the channel of a command does not end its guest, so jcode deletes each guest itself (ztcl#1330).
cloud
The level needs AWS resources that the owner makes, and cloud in config.json; the design has each one. Each call to AWS assumes the role jcode-caller through the AWS profile of profile, so jcode never uses the rights of your user.
- The work folder must have no change that is not committed: the instance gets a git bundle of the branch.
- The work folder must have a git
user.nameanduser.email. The commits of the agent carry them. - The agent runs its commands at the level
noneon the instance. The instance is the sandbox: no inbound port, no SSH, and only port 443 out. send,stop, andinterruptwork as at the other levels, with a delay of some seconds.- At the end, the commits of the agent are on the branch
jcode/IDof the work folder.jcode costand the transcript have the cost of the instance. - Limits:
max_instances(8),day_usd(20 USD of instances in a day), andlimit_s(2 h; the instance shuts down at that time).jcode cloudlists the instances, and ends each one past its time limit.
--net
--net gives a command the network. With the network, a command can send each file that it can read to another host. At the level process, that is each file of the user. none, and --net at the level process, give the agent the power of the user.