v1.6.1

Filesystem Write Guard

Last updated


How agent-driven writes are checked against the path policy, and how commands get write access outside $HOME.
Agenvoy does not rely on go-pkg's own IsDenied check: go-pkg/filesystem.New receives only the exclude list, never a denied map, so that check has nothing to match. The write policy is enforced on the agenvoy side before any agent-driven write: write_file (write, patch, mode=remove), restore_file and rm resolve their targets through boundary.ResolveWrite, and download_file, generate_image and generate_audio call boundary.CheckWrite on the output path before writing it (the latter two with os.WriteFile, mode 0600). Both reject a path on denied_path and, since v1.5.0, a path inside the read-only ~/.config/agenvoy (only download/ is writable) with [Denied] path: ... is read-only; the check covers the path as given and its resolved real path, so a symlink cannot route around it. A new write path that skips boundary.CheckWrite escapes the policy — this is forbidden. Agenvoy's own in-process writes (write_skill, write_tool, write_hook, configuration) are the deliberate exception.
The internal/filesystem package retains only path computation, runtime limits, and domain wrappers. It does not duplicate read/write logic.
Outside $HOME, run_command and background_command need the paths declared up front: the call carries write_paths (absolute paths only), the user approves them with the system password, and only then are they bound read-write into the sandbox for that session. A path inside ~/.config/agenvoy other than download/ cannot be listed (since v1.5.0 it is rejected as read-only, and no approval lifts it). A write to an unapproved path fails with an explicit message, and a permission error on an unbound path outside $HOME gets a hint to re-run with write_paths rather than a bare error the model would misread as an ownership problem. Since v1.3.2, when a sandboxed command fails with a permission marker (permission denied, operation not permitted, read-only file system, EACCES, not writable) and the output names no path outside $HOME to grant through write_paths, the result appends advice that treats leaving the sandbox as the last resort, not the default retry (since v1.3.11; from v1.3.2 to v1.3.10 it told the agent to re-run at once with sandbox: false): a connection or auth failure such as Permission denied (publickey) or could not resolve host → network: true, or report the credential problem; a write → a path under the work directory, or write_paths for the path that failed; a task that genuinely needs a system socket, device or service, or a root-owned target → sandbox: false or argv ['sudo', ...], approved with the system password; otherwise report what was blocked and stop. Since v1.5.1 the hints are unified for run_command and background_command: every failed sandboxed call, and a successful one whose output reads as a network error or carries a permission marker, gets them appended in order — for a network: false call, "if this is a network problem, re-run with network: true" (or, while Command network is disabled, "tell the user to enable /config → Command network"); the write_paths hint for unbound paths outside $HOME; then "if the sandbox caused this, re-run with sandbox: false", which asks for the system password. The separate last-resort advice was Removed in v1.5.1.