Skip to content

feat!: remove tokenDir — one env mechanism, user-owned - #153

Merged
defangdevs merged 3 commits into
masterfrom
feat/remove-token-dir
Jul 29, 2026
Merged

feat!: remove tokenDir — one env mechanism, user-owned#153
defangdevs merged 3 commits into
masterfrom
feat/remove-token-dir

Conversation

@defangdevs

Copy link
Copy Markdown
Owner

Removes the root-dropped tokenDir (/etc/agent-box/<user>.env unit-level EnvironmentFile) now that the user-owned ~/.config/agent-box/env covers the same need end-to-end: written via the settings page or agent-box-session env set (#144), re-read by the spawn wrapper at every session (re)start — so tokens apply at next spawn with no unit bounce.

Why drop it rather than keep both:

  • Two env mechanisms with different application semantics (unit restart vs next spawn) — the settings daemon's "Restart all" special-casing existed largely for tokenDir.
  • No security value: tokenDir contents end up in the agent's process environment anyway, so root-ownership never hid them from the user.
  • One less root-owned state dir for the Ubuntu/RHEL portability work to reimplement, and the rename migration loses its fragile rmdir-if-empty coupling to /etc/agent-box (the failure mode feat(sessions): kickoff prompts, resume-on-respawn, and full CLI parity #144's CI just hit).

Removed: tokenDir, manageTokenDir, the tmpfiles rules, the per-user EnvironmentFile entry, and the /etc/claude-box leg of the issue-70 migration that fed it. Kept: environmentFiles (global + per-user) for Nix-managed secret paths (agenix/sops-nix). Docs + hosts/bare-metal.nix updated to the new flow.

BREAKING / no migration by design (no deployed boxes rely on the old path): any existing /etc/agent-box/<user>.env stops being loaded after the next rebuild. Re-add with:

sudo -u <user> agent-box-session env set GH_TOKEN <value>

If this box's own GH_TOKEN was provisioned via tokenDir, re-add it the same way after self-updating.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KcxC9a8wWApTSdAxKfpkGs

lionello and others added 2 commits July 29, 2026 16:52
The root-dropped /etc/agent-box/<user>.env unit-level EnvironmentFile
is fully superseded by the user-owned ~/.config/agent-box/env, which
the spawn wrapper re-reads at every session (re)start and which is
writable through the settings page and `agent-box-session env set`.
Carrying both meant two mechanisms with different application
semantics (unit bounce vs next spawn), a root-owned state dir for the
portability work to reimplement, and an empty-dir guard in the rename
migration that anything touching /etc/agent-box could break.

Removes the tokenDir and manageTokenDir options, the tmpfiles rules,
the per-user EnvironmentFile entry, and the /etc/claude-box leg of the
issue-70 rename migration that fed it. environmentFiles (global and
per-user) stay for Nix-managed secret paths.

BREAKING: existing /etc/agent-box/<user>.env files stop being loaded
(no deployed boxes rely on this; re-add tokens with
`agent-box-session env set KEY value` as the user).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KcxC9a8wWApTSdAxKfpkGs
The subtest still asserted /etc/claude-box moves into /etc/agent-box —
the leg the previous commit removed. Assert the new contract instead:
the old token dir stays behind untouched and nothing recreates
/etc/agent-box, while the no-clobber web-state half is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KcxC9a8wWApTSdAxKfpkGs
Comment thread modules/agent-box.nix.in Outdated
Comment thread modules/agent-box.nix.in Outdated
Comment thread modules/agent-box.nix.in Outdated
Review feedback on #153: no deployed boxes predate the rename, so the
issue-70 one-shot migration (and its sessions-test subtest) goes away
entirely, and code comments stop referring to the removed tokenDir —
that history lives in the PR/issue text instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KcxC9a8wWApTSdAxKfpkGs
@defangdevs

Copy link
Copy Markdown
Owner Author

Addressed all three review comments in 3d5b98d: dropped the "former tokenDir" history from both code comments, and removed the issue-70 claude-box rename migration entirely (activation script + its sessions-test subtest) — another -87 lines. History stays here in the PR.

@defangdevs
defangdevs merged commit a528422 into master Jul 29, 2026
1 check passed
@defangdevs
defangdevs deleted the feat/remove-token-dir branch July 29, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants