fix: eliminate daemon-env.json — derive env at spawn time#119
Merged
Conversation
Rewrite buildSpawnEnv() to source ~/.zshenv at spawn time instead of loading stale JSON. Remove saveEnvironment(), loadSavedEnvironment(), and ENV_FILE. Simplify buildSpawnEnv signature (drop first param). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c-h-
commented
Mar 7, 2026
Collaborator
Author
c-h-
left a comment
There was a problem hiding this comment.
Review: CI green, docs clean, one concern before merge.
buildSpawnEnv() does sourceZshEnv() || process.env — if sourcing ~/.zshenv succeeds, it replaces the daemon's process.env instead of merging with it. Any env vars only in process.env (temporary exports, launchd-injected vars, test/runtime vars) get dropped unless they're also in ~/.zshenv.
Issue #118's intended contract was the opposite: start with process.env, layer ~/.zshenv on top, then apply opts.env.
Suggested fix: merge zsh-derived env onto process.env, not replace:
const zshEnv = sourceZshEnv();
const base = { ...process.env, ...(zshEnv ?? {}) };Add a test proving a process.env-only var survives when sourceZshEnv() succeeds.
Collaborator
Author
|
Addressed this review:
Local verification passed:
|
c-h-
pushed a commit
that referenced
this pull request
Mar 10, 2026
Features: - Phase 1 ACP adoption — Codex adapter via ACP transport (#127) - Callback metadata + lifecycle webhooks (#123) - ADR-001: adopt ACP as primary agent interface (#126) - Stateless daemon core (#117) Fixes: - Eliminate pending- session IDs — resolve real ID at launch (#131) - Webhook numeric exit_status + compatible HMAC headers (#128) - Daemon env derivation at spawn time (#119) - Binary resolve util update (#121) Docs: - Full documentation audit and alignment (#132)
c-h-
added a commit
that referenced
this pull request
Mar 10, 2026
Features: - Phase 1 ACP adoption — Codex adapter via ACP transport (#127) - Callback metadata + lifecycle webhooks (#123) - ADR-001: adopt ACP as primary agent interface (#126) - Stateless daemon core (#117) Fixes: - Eliminate pending- session IDs — resolve real ID at launch (#131) - Webhook numeric exit_status + compatible HMAC headers (#128) - Daemon env derivation at spawn time (#119) - Binary resolve util update (#121) Docs: - Full documentation audit and alignment (#132) Co-authored-by: Doink (OpenClaw) <charlie+doink@kindo.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buildSpawnEnv()to source~/.zshenvat spawn time via/bin/zsh -cinstead of loading staledaemon-env.jsonsaveEnvironment(),loadSavedEnvironment(), andENV_FILEconst fromsrc/utils/daemon-env.tssaveEnvironment()call from daemon startup insrc/daemon/server.tsbuildSpawnEnvsignature (drops unused first param) across all 5 adapter callersgetCommonBinDirs()andbuildSpawnEnv()Closes #118
Test plan
npm run typecheck— zero errorsnpm run lint— zero errorsnpm run build— succeedsnpm test— all 474 tests pass (including 6 new)🤖 Generated with Claude Code