feat: auto-load .env.<stackname> for per-stack env overrides#2129
feat: auto-load .env.<stackname> for per-stack env overrides#2129simple-agent-manager[bot] wants to merge 4 commits into
Conversation
Addresses review feedback from CTO-style code review: 1. Replace full Loader instantiation in stackEnvFiles with simple path resolution (filepath.Dir of config path or os.Getwd fallback). The previous approach created an entire compose Loader just to get a directory path — disproportionate overhead with subtle circular dependency risk. 2. Add slices.Contains guard in withEnvFiles() to prevent double-append. The function is called twice in newProjectOptions (before and after config path discovery), and without deduplication, stack env files would be appended twice. 3. Add Infof when a stack env file is loaded. Users need visibility into which files are affecting their deployment — a file's mere existence changing behavior is "action at a distance" that needs observability. 4. Add Debugf when an env file is filtered out (not in working dir). 5. Document the precedence model: compose-go's dotenv parser processes files in order with later files overriding earlier ones. Stack env files are appended after .env, giving them higher precedence. 6. Document WHY the directory check exists: it prevents stack env files resolved from cwd leaking into a project discovered via COMPOSE_FILE or directory walking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review Summary (3-round CTO adversarial review)I ran this PR through 3 rounds of back-and-forth with a skeptical CTO subagent. Here's what was found and addressed: Issues Found & Fixed (pushed as
|
lionello
left a comment
There was a problem hiding this comment.
Feels very, very sloppy. Agree with intent.
| @@ -0,0 +1,8 @@ | |||
| name: envstackfixture | |||
There was a problem hiding this comment.
rename folder to envstackfixture to avoid another level of indirection.
Closes #2128
Summary
Validation
Note: plain make lint currently fails during local Go bootstrap because the Makefile constructs an invalid go1.25.5.0 download URL from go.mod; GO-NO-DEP-GO=1 uses the installed go1.25.10 toolchain and passes.