Skip to content

fix(cli): avoid duplicating env-file values in Compose YAML - #1769

Merged
rohitg00 merged 1 commit into
rohitg00:mainfrom
zack-dev-cm:fix/1764-compose-env-origin-v2
Nov 16, 2026
Merged

rohitg00 merged 1 commit into
rohitg00:mainfrom
zack-dev-cm:fix/1764-compose-env-origin-v2

Conversation

@zack-dev-cm

@zack-dev-cm zack-dev-cm commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1764.

The CLI now uses the existing env-origin tracker to omit file-only values from its allowlisted worker environment entries. The filtered env file still supplies those values. Current shell and CLI overrides, including --tools changes after hydration, keep their precedence. The full hydrated environment still configures the state-save interval and Windows PATH.

Five subprocess regressions exercise the actual CLI, YAML I/O and worker hydration with a stubbed engine and synthetic values. Unchanged main fails three cases; the patch passes all five.

Validation:

  • Required build, generators, skills/docs checks and CI evaluation type check pass.
  • Local full suite: 4,923 passed, 13 failed, 7 skipped. All 13 complete mesh failures match the saved unchanged-main baseline. No assertions, DNS or URL guards were changed.
  • Packed release gate: 10/10 pass. Required packaged startup gate: 17/17 pass on the same tarball; the installed artifact remains unchanged.
  • Hosted CI on this commit: Linux Node 20, 22, 24 and 26 jobs passed, including the full suite and all five new cases. The macOS Node 20 job also passed; validation on the remaining macOS jobs is still unverified.

Summary by CodeRabbit

  • Bug Fixes
    • Environment values set in the shell now take precedence over values in the configured environment file when starting workers.
    • Environment-file values remain available to workers, and the --tools option continues to override conflicting environment values.

Use existing environment-origin tracking to keep file-only values in the selected env file instead of repeating them as explicit worker overrides. Preserve current shell and CLI overrides, including --tools changes made after hydration, and retain the full effective environment for derived state and PATH settings.

Add CLI regressions for file-only values, equal and different shell overrides, missing env files and CLI tool-selection precedence.

Signed-off-by: zack-dev-cm <112114097+zack-dev-cm@users.noreply.github.com>
@vercel

vercel Bot commented Nov 12, 2026

Copy link
Copy Markdown

@zack-dev-cm is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When an environment file exists, the CLI now passes Compose environment overrides that exclude values identified as coming from that file. Compose rendering uses the override map when provided and retains the existing filtering and sorting. Integration tests cover environment precedence and related settings.

Changes: Compose environment precedence

Layer / File(s) Summary
Pass filtered environment overrides
src/cli.ts
When the environment file exists, the CLI passes process environment entries whose keys are not identified as env-file values.
Render and verify Compose environment
src/cli/compose-project.ts, test/cli-compose-env-precedence.test.ts
Compose rendering uses the override map when provided and falls back to workerEnvironment otherwise. Integration tests check shell and env-file precedence, tool selection, API-key filtering, and save-interval handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • Issue 1765 — The change omits env-file-only values from the generated Compose environment, but does not implement the issue’s separate DPAPI encryption request.

Possibly related PRs

Suggested reviewers: guibeira, rohitg00

Merge Risk: Minimal · up to 74e9a

This change stops env-file-only values from being copied into the generated worker Compose YAML. Shell and CLI overrides keep precedence, and the filtered env file still supplies the file-only values. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the CLI now stops env-file-only values from being copied into the generated worker Compose YAML. It uses the conventional fix(cli) prefix and is specific enough for a …
Linked Issues check Passed Issue #1764 requires that env-file-only provider keys and AGENTMEMORY_SECRET be omitted from worker-compose.yaml environment:, while still reaching the worker through the filtered env file. Shell-set …
Out of Scope Changes check Passed The diff touches three areas: src/cli.ts (import of isEnvFileValue and the workerEnvironmentOverrides option), src/cli/compose-project.ts (new optional option and one source-selection change), and the…
Full details: Title check

Explanation

The title names the main change: the CLI now stops env-file-only values from being copied into the generated worker Compose YAML. It uses the conventional fix(cli) prefix and is specific enough for a teammate scanning history. The changeset adds workerEnvironmentOverrides, filters env-file-only keys from the worker environment, and adds a regression test, all of which match the title.

Full details: Linked Issues check

Explanation

Issue #1764 requires that env-file-only provider keys and AGENTMEMORY_SECRET be omitted from worker-compose.yaml environment:, while still reaching the worker through the filtered env file. Shell-set values must still appear in environment: and keep precedence. The full hydrated environment must still feed AGENTMEMORY_STATE_SAVE_INTERVAL_MS.

Evidence at head:

  • src/cli.ts (startIiiBin): when envPath exists, passes workerEnvironmentOverrides built from process.env, filtered by !isEnvFileValue(key). The envFile option is unchanged.
  • src/cli/compose-project.ts (renderWorkerCompose): explicit environment entries read from workerEnvironmentOverrides ?? workerEnvironment. The allowlist and reserved-name filters still apply. workerEnvironment remains the full env for other reads, so the state-save interval is unchanged.
  • src/config.ts: isEnvFileValue(key) returns true only when the key was hydrated from the file and process.env still equals the hydrated value. Shell-set keys are never hydrated, so they stay in overrides. A CLI change after hydration (for example --tools) yields a different value, so it stays in overrides.

The new subprocess test (test/cli-compose-env-precedence.test.ts) covers the five cases named in the PR description. I did not run it. The linked issue suggests a test file name, but it does not require one. Windows PATH handling is in the full environment path and was not changed by the diff.

Full details: Out of Scope Changes check

Explanation

The diff touches three areas: src/cli.ts (import of isEnvFileValue and the workerEnvironmentOverrides option), src/cli/compose-project.ts (new optional option and one source-selection change), and the new precedence test. Each change serves the objective of #1764. No unrelated behavior, credential-store reading, or other refactoring appears in the reviewed diff. The PR description also reports validation results. I did not verify those results, and they are not coding requirements.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 51e2b4e9-8433-4632-a421-980dff8ab56d
Commits

Reviewing files that changed from the base of the PR and between cf9a738 and 74e9ac2.

Files selected for processing: 3

  • src/cli.ts
  • src/cli/compose-project.ts
  • test/cli-compose-env-precedence.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@rohitg00
rohitg00 merged commit 3f77962 into rohitg00:main Nov 16, 2026
2 of 3 checks passed
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.

Worker Compose writes provider API keys from the env file into worker-compose.yaml in plaintext

2 participants