Skip to content

Prefer nearest .env in CLI eval hierarchy#560

Merged
christso merged 4 commits intomainfrom
copilot/ep-525-implement-feature
Mar 14, 2026
Merged

Prefer nearest .env in CLI eval hierarchy#560
christso merged 4 commits intomainfrom
copilot/ep-525-implement-feature

Conversation

Copy link
Contributor

Copilot AI commented Mar 13, 2026

loadEnvFromHierarchy() was merging .env files across the eval/repo hierarchy, but effective precedence was backwards: parent values could block closer eval-specific values. This change makes the nearest .env take precedence while still inheriting missing keys from parent .env files.

  • CLI env precedence

    • Adjust apps/cli/src/commands/eval/env.ts so hierarchical .env loading preserves this precedence:
      • exported shell environment
      • nearest eval-local .env
      • parent/root .env
    • Keeps hierarchical merging behavior intact for keys not defined locally.
  • Regression coverage

    • Adds focused unit coverage for:
      • nearest .env overriding parent values
      • parent .env still supplying unset keys
      • existing process.env values remaining authoritative
  • Behavior

    # repo root .env
    MY_VAR=root
    SHARED_ONLY=from_root
    # evals/foo/.env
    MY_VAR=local
    LOCAL_ONLY=from_subfolder

    Effective environment for an eval under evals/foo/ becomes:

    MY_VAR=local
    SHARED_ONLY=from_root
    LOCAL_ONLY=from_subfolder

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 13, 2026 12:25
Co-authored-by: christso <3115311+christso@users.noreply.github.com>
Co-authored-by: christso <3115311+christso@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 13, 2026

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7cd0007
Status: ✅  Deploy successful!
Preview URL: https://5655316e.agentv.pages.dev
Branch Preview URL: https://copilot-ep-525-implement-fea.agentv.pages.dev

View logs

Copilot AI changed the title [WIP] [EP-525] Implement feature from issue 525 Prefer nearest .env in CLI eval hierarchy Mar 13, 2026
Copilot AI requested a review from christso March 13, 2026 12:29
@christso christso marked this pull request as ready for review March 13, 2026 20:39
@christso
Copy link
Collaborator

@copilot since we don't override process.env would that mean we also don't override parent .env? When does parent env get loaded? Please do proper code review with manual e2e red green testing.

@christso christso merged commit 75fc7ff into main Mar 14, 2026
1 check passed
@christso christso deleted the copilot/ep-525-implement-feature branch March 14, 2026 00:37
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.

2 participants