feat(tmuxx): scrub inherited lab service env from spawned sessions #212
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab!212
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/204"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #204
What
Spawned tmux sessions now receive exactly the explicit
spawnEnvallow-list (unchanged, still via-e) plus a minimal baseline forwarded from the lab process:PATH,HOME,TERM,TERMINFO_DIRS,LANG/LANGUAGE/LC_*,LOCALE_ARCHIVE. Everything else in the service environment — EnvironmentFile secrets like aLAB_DBDSN, systemd unit internals — is scrubbed from every pane.How
Tmux.cmd()pinscmd.Envto the baseline on every tmux client invocation, so the tmux server (started implicitly by whichever wrapper call runs first) is born with a clean global environment and no client call can reintroduce a secret. This mirrors whatgitxalready does for git subprocesses.Startadditionally sweeps non-baseline variables out of an already-running server's global environment (show-environment -g→ chainedset-environment -g -u): a server born under a pre-fix lab outlives service restarts (parked sessions keep it alive), so on upgraded hosts a scrubbed client alone would keep leaking into new panes. On post-fix servers this is one cheap no-op call per Start.TERMINFO_DIRSandLOCALE_ARCHIVEare in the baseline because on NixOS they are what makeTERMand the locale actually resolve — without them the spec's PATH/HOME/TERM/locale baseline doesn't function.newSessionArgs, the-eemission, the prlimit wrapper, and all MUST-NOT-CHANGE v0 behaviours are untouched.spawnEnvcontents unchanged.Acceptance criteria
TestTmux_startScrubsProcessEnvFromPane(fresh server) andTestTmux_startScrubsLegacyServerGlobalEnv(pre-fix dirty server, seeded by bypassing the wrapper)TestTmux_startLoginShapeKeepsBaseline(nil extraEnv keeps HOME/PATH);GIT_SSH_COMMAND/askpass ride the vault-materialized credEnv through-eand survivecmd.Envnon-nil and the baseline filter (TestCmd_scrubsEnvToBaseline,TestBaselineEnv_filtersProcessEnv,TestIsBaselineVar,TestIsEnvName)Regression tests were mutation-checked: with the fix reverted, the canary tests fail (pane env shows the planted secret).
Verification
go test ./...green (integration tests ran against real tmux 3.6a on private sockets),go vet ./...clean,gofmtclean,go build ./...OK.Review notes
An 8-angle review pass surfaced one latent seam, deliberately out of scope per the issue's fences: operator-set
CODEX_HOME/CLAUDE_CONFIG_DIRoverrides previously reached pane CLIs only via the accidental full-env inheritance this PR removes; lab-side code still honors them. No deployment sets them today — filed as #211 for the provider spawn-env layer. Theunknown variabletolerance in the legacy sweep is phrasing-dependent but tmux is nix-pinned at 3.6a where chained unsets exit 0 (empirically verified).🤖 Generated with Claude Code
[autoland] verdict: pass
Validated PASS. Relied on the green ci / native check (success, 8m39s — go test ./... incl. real-tmux integration tests, go vet, gofmt, go build); did not re-run it.
Closes #204, self-owned headafk/204.spawnEnvuntouched, container runner left alone.