Priority
High — composability, test isolation, LSP/dev correctness, and future embedded API safety.
Context
runtime/envfile.LoadIntoEnv parses .env files and writes entries directly into the process environment with os.Setenv. It also keeps package-global state to remember values that were previously applied by the loader.
Project-aware CLI commands call this while loading gowdk.config.go.
Problem
Loading a project configuration mutates process-global state.
This has several risks:
- Two project loads in the same process can influence each other.
- Tests can pass or fail depending on load order.
- A future daemon, LSP session, or embedded compiler API cannot safely load multiple workspaces concurrently.
- Dev rebuilds reuse a process with sticky env-file state.
- Subprocesses inherit an environment shaped by prior project loads unless every caller carefully filters it.
The current package-global appliedValues map makes env loading a process lifecycle concern rather than a workspace input.
Proposed direction
Parse env files into an explicit immutable environment overlay instead of mutating os.Environ.
Example model:
type Environment struct {
Process map[string]string
File map[string]string
}
func (env Environment) Lookup(name string) (string, bool)
func (env Environment) ForSubprocess(base []string) []string
Configuration validation, executable config helpers, build-data helpers, generated app tests, and other subprocesses should receive an explicit environment from the workspace plan.
Acceptance criteria
Related
Priority
High — composability, test isolation, LSP/dev correctness, and future embedded API safety.
Context
runtime/envfile.LoadIntoEnvparses.envfiles and writes entries directly into the process environment withos.Setenv. It also keeps package-global state to remember values that were previously applied by the loader.Project-aware CLI commands call this while loading
gowdk.config.go.Problem
Loading a project configuration mutates process-global state.
This has several risks:
The current package-global
appliedValuesmap makes env loading a process lifecycle concern rather than a workspace input.Proposed direction
Parse env files into an explicit immutable environment overlay instead of mutating
os.Environ.Example model:
Configuration validation, executable config helpers, build-data helpers, generated app tests, and other subprocesses should receive an explicit environment from the workspace plan.
Acceptance criteria
.envor.env.<GOWDK_ENV>does not callos.Setenvduring project loading.Related