Skip to content

fix(deploy): give shell stages HOME under systemd (#24) - #25

Merged
jerryfane merged 1 commit into
mainfrom
ops/service-home
Nov 6, 2026
Merged

jerryfane merged 1 commit into
mainfrom
ops/service-home

Conversation

@jerryfane

Copy link
Copy Markdown
Contributor

Closes #24. Gap reported by jarvis (gitmoot msg 409366, gitmoot/gitmoot#2542).

  • deploy/stagehand.service: Environment=HOME=/root. The live stagehand serve environment (from /proc) is LANG, PATH and USER only, and baseEnv (internal/cli/cli.go:257) passes HOME only when the runner has it.
  • README: the systemd example sets HOME; there is a note on why; the stage-environment line now matches baseEnv (LANG is always C.UTF-8).

Deploy: install the unit, daemon-reload, restart once no run is active, check /proc/<pid>/environ and that a stage sees HOME. Roll back: the previous unit is in backup/stagehand.service.pre-events (plus the trigger flag).

@jerryfane
jerryfane merged commit 7b933f3 into main Nov 6, 2026
2 checks passed
@jerryfane

Copy link
Copy Markdown
Contributor Author

Agent: g7-review
Runtime: omp
Job: local-review-review-router-18e5895e32965966-1

Decision: approved
Summary: Reviewed the complete two-file diff from base dceb0a8 to exact head afdde93. No P0-P2 findings. The deployment unit is otherwise unchanged apart from explanatory comments. Production-binary smoke checks confirmed shell HOME propagation and sandboxd guest HOME=/home/user without host-environment leakage. Nonblocking documentation caveat: README.md:190 incorrectly makes PATH conditional; baseEnv supplies a fallback when PATH is unset or empty. The frozen prior-verdict file contains no findings for PR #25. Sandbox restrictions prevented local CGO/race checks and offline systemd verification; exact-head CI independently verified vet and race tests, but not unit verification. No repository files were modified or live services accessed.

Tests Run

  • CGO_ENABLED=0 go build -trimpath -o /root/.gitmoot/cache/tools/read-only/d5775d8ea96bb1e3/runtime-state/stagehand-pr25-afdde930-review ./cmd/stagehand && /root/.gitmoot/cache/tools/read-only/d5775d8ea96bb1e3/runtime-state/stagehand-pr25-afdde930-review version -> passed; output: stagehand dev.
  • go vet ./... -> sandbox-blocked: runtime/cgo could not read /usr/include/stdc-predef.h (Permission denied).
  • go test -race -count=1 ./... -> sandbox-blocked during runtime/cgo compilation: /usr/include/stdc-predef.h (Permission denied).
  • CGO_ENABLED=0 go vet ./... -> passed.
  • CGO_ENABLED=0 go test -count=1 ./... -> passed across all packages, including internal/cli, internal/engine, internal/shellexec, and internal/agentexec.
  • Python subprocess smoke invoking the built stagehand binary with --home add <fixture.yaml>, then --home run -> four cases passed: HOME=/root propagation; absent HOME/TZ omission; absent PATH fallback; empty HOME/PATH/TZ handling. LANG was C.UTF-8 despite a different runner locale; an unlisted secret canary was omitted.
  • Python subprocess smoke invoking the production CLI with an isolated sandboxd configuration and local HTTP fixture -> passed: successful agent attempt sent HOME=/home/user, guest PATH, and LANG=C.UTF-8; host /root, TZ, and secret canary were absent; VM fixture was destroyed.
  • systemd-analyze verify --man=no /tmp/gmr-df6aede3/stagehand-pr25-review-l6029bnp/stagehand.service -> sandbox-blocked: Failed to setup working directory: Permission denied. Scratch unit differed only in its ExecStart executable path; no service was started.
  • CI-verified: go vet ./... -> success; run 42274388777 job 128086834279
  • CI-verified: go test -race -count=1 ./... -> success; run 42274388777 job 128086834279

Raw runtime output was retained in local Gitmoot state and is not posted here.

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.

stagehand.service gives shell stages no HOME

1 participant