agentenv

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const UserEnv = "GOLEM_AGENT_USER"

The shem itself stays root: it holds the push credential, and dropping it would mean the credential lives somewhere the agent can reach anyway. UserEnv names the unprivileged account the agent runs as.

Variables

This section is empty.

Functions

func DropPrivileges

func DropPrivileges(cmd *exec.Cmd)

applyAgentCredentials makes cmd run as the unprivileged agent account, and rewrites the identity variables so the tools it starts agree about who it is. HOME especially: it is on agentenv's allow-list and would otherwise arrive as /root, which the dropped process cannot write, and Claude Code stores its state under HOME. DropPrivileges makes cmd run as the unprivileged agent account when one is configured, and is a no-op otherwise.

func EnsureOwnership

func EnsureOwnership(root string) error

ensureAgentOwnership gives the agent account ownership of everything under root that it does not already own.

The shem runs as root and creates the clone, the ticket directory and the worktree, so without this the dropped agent cannot write the code it is employed to write. Entries already owned are skipped, so the common case — a repository prepared on an earlier run — walks the tree without touching it.

Failures are reported but not fatal: a repository the agent cannot write fails loudly in the phase that follows, which is a better error than refusing to start. EnsureOwnership gives the agent account ownership of everything under root that it does not already own. No-op when no account is configured.

func Environ

func Environ() []string

Environ is Filter over this process's own environment. It is what every agent exec site passes to cmd.Env.

func Filter

func Filter(parent []string) []string

Filter reduces parent (an os.Environ()-shaped slice) to what an agent subprocess is allowed to see.

func FilterForGolemCLI

func FilterForGolemCLI(parent []string) []string

FilterForGolemCLI applies the agent allow-list and retains only its policy directive for the trusted Golem CLI to apply to its own children.

func FilterPairs

func FilterPairs(m map[string]string) []string

FilterPairs returns operator-declared variables as KEY=VALUE pairs, minus golem's own. The allow-list does not apply: the operator named them.

func GolemCLIEnviron

func GolemCLIEnviron() []string

GolemCLIEnviron is for a trusted nested Golem CLI, not an agent process. The CLI may run a gate, which filters its own child environment again. Keep the operator's allow-list policy across that boundary so explicitly allowed build/test variables survive the second filter; Filter still strips the policy itself before any agent or gate command runs.

func IsGolemOwned

func IsGolemOwned(name string) bool

IsGolemOwned reports whether name is golem's own configuration, which never reaches an agent.

func User

func User() *agentAccount

resolveAgentUser returns the account to run agents as, or nil to run them as this process does.

nil is returned when the process is not root (nothing to drop — this is CLI mode, `go run`, and every test) or when the account does not exist. The container case is the one that matters, and it is verified there: running the agent as root is what makes GOLEM_GITHUB_TOKEN readable out of /proc/1/environ, so a silent fallback to root would quietly restore exactly the exposure this exists to close. It is therefore logged loudly. User returns the resolved unprivileged agent account, or nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL