fix(sites): don't list the snippet dir in ReadWritePaths when web.enable is off - #198
Open
defangdevs wants to merge 1 commit into
Open
fix(sites): don't list the snippet dir in ReadWritePaths when web.enable is off#198defangdevs wants to merge 1 commit into
defangdevs wants to merge 1 commit into
Conversation
7b687b9 added /var/lib/agent-box-sites/<user> to the agent unit's ReadWritePaths unconditionally, but the tmpfiles rule that creates that directory lives inside `mkIf (cfg.enable && cfg.web.enable)`. web.enable is a mkEnableOption, so on a default box the path never exists and systemd fails the whole namespace setup: agent-box-agent.service: Failed to set up mount namespacing: /var/lib/agent-box-sites/agent: No such file or directory agent-box-agent.service: Failed at step NAMESPACE ... 226/NAMESPACE The unit then never starts at all — no tmux sessions on any web-less deployment — and it restart-loops (counter passed 427 in CI). This broke tests/memory-protection.nix on master, the one test that runs with web off, which is how it surfaced. Guard the entry on cfg.web.enable, matching what gates the tmpfiles rule. Deliberately still no `-` prefix: a dir that is genuinely missing while web IS on should stay loud rather than silently reverting to the EROFS the parent commit fixed. memory-protection now asserts the entry is absent, so the web-off case has an explicit guard instead of only failing via wait_for_unit. Verified by evaluating both node configs: web off -> ["/home/agent"] web on -> ["/home/agent" "/var/lib/agent-box-sites/agent"] Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014Kq2nqcWR5Y6aryf8WzWbs
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Master is red and, more importantly, a default (web-less) agent-box no longer starts any agent sessions.
What broke
7b687b9 (the fix for #195,
~/sitesbeing read-only in the agent's own namespace) added/var/lib/agent-box-sites/<user>to the agent unit'sReadWritePathsunconditionally. The tmpfiles rule that creates that directory lives insidemkIf (cfg.enable && cfg.web.enable), andweb.enableis amkEnableOption— default off. With web off the path never exists, andProtectSystem=strictnamespace setup fails hard:The unit never starts — no tmux sessions at all — and restart-loops (the counter passed 427 in the CI run).
tests/memory-protection.nix, the only test that runs with web off, timed out onwait_for_unit: https://github.com/defangdevs/agent-box/actions/runs/31016454644The parent commit's reasoning ("tmpfiles-created at sysinit, long before this unit, so no
-prefix") is right about ordering — it just doesn't hold when the rule isn't emitted at all.The fix
Guard the entry on
cfg.web.enable, mirroring what gates the tmpfiles rule.Deliberately still no
-prefix: a directory that is genuinely missing while web is on should fail loudly rather than silently reverting to the EROFS that #195 was about.Verification
Both node configs evaluated directly, no VM boot needed:
ReadWritePathsmemory-protection)["/home/agent"]self-serve-domain)["/home/agent" "/var/lib/agent-box-sites/agent"]So the #195 flow keeps working where it applies, and the web-off box boots again.
memory-protectionnow asserts the entry is absent, so the web-off case has an explicit guard instead of only failing indirectly viawait_for_unit.Also run natively on aarch64:
module-generated-up-to-date(regeneratedmodules/agent-box.nixfrom.nix.in), thety/rufftestScript gate, and adrvPatheval of all seven VM tests.Note: the deploy-test leg is expected-red on master for unrelated reasons (#186/#190).
Opened from a webhook triage session that picked up the #195 close event.
🤖 Generated with Claude Code
https://claude.ai/code/session_014Kq2nqcWR5Y6aryf8WzWbs