fix(dream-agent-key): complete DREAM_AGENT_KEY lifecycle on macOS + docs#1013
Merged
Lightheartdevs merged 1 commit intoLight-Heart-Labs:mainfrom Apr 27, 2026
Conversation
Two related gaps in the DREAM_AGENT_KEY lifecycle (independent 32-byte hex secret, introduced as its own key by PR Light-Heart-Labs#979): 1. .env.example never mentioned DREAM_AGENT_KEY. Anyone reading the example config would not know the key exists or that it's installer- generated. Adds a commented documentation line next to DASHBOARD_API_KEY with generation hint and a warning that rotation breaks host-agent authentication. 2. macOS env-generator's reinstall/upgrade path (.env exists, no --force) only upserts LLAMA_CPU_LIMIT and LLAMA_CPU_RESERVATION, leaving pre-Light-Heart-Labs#979 installs without a DREAM_AGENT_KEY. The host agent then falls back to DASHBOARD_API_KEY, defeating Light-Heart-Labs#979's intent of making the two secrets independent. The fix mirrors the Linux pattern (installers/phases/06-directories.sh:208 — _env_get-or-generate) expressed as an idempotent upsert: if the existing .env lacks DREAM_AGENT_KEY, generate a fresh one via new_secure_hex 32 and upsert it. Idempotent on re-run; preserves any existing key. Fresh-install path (Path B, heredoc) is unchanged and still writes DREAM_AGENT_KEY on green-field installs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
What
Two related gaps in the
DREAM_AGENT_KEYlifecycle (the independent 32-byte hex secret introduced by PR #979):.env.example— adds a commented documentation entry forDREAM_AGENT_KEYnext to the existingDASHBOARD_API_KEYentry, with a generation hint and a warning that rotation breaks host-agent authentication.installers/macos/lib/env-generator.sh— closes the upgrade gap: pre-PR-fix(security): generate dedicated DREAM_AGENT_KEY in installers #979 installs that re-run the installer without--forcepreviously skippedDREAM_AGENT_KEYentirely. The host agent then fell back toDASHBOARD_API_KEY, defeating fix(security): generate dedicated DREAM_AGENT_KEY in installers #979's intent of making the two secrets independent. Fix adds an idempotent upsert inside the existing early-return block.Why
After PR #979 made
DREAM_AGENT_KEYa distinct secret fromDASHBOARD_API_KEY, the lifecycle was only complete on Linux (installers/phases/06-directories.sh:208—_env_get-or-generate). Windows landed in a separate PR. macOS was left with an inconsistency: fresh installs generated the key (via the heredocENVEOFpath), but reinstalls/upgrades skipped the upsert and left pre-#979 installs without it..env.examplealso never mentioned the key, making it invisible to anyone reading the example config.How
.env.example: one commented documentation line inserted between the existing# DASHBOARD_API_KEY=and the Qdrant section. Matches the style of surrounding commented-key entries.env-generator.sh: inside theif [[ -f "$env_path" ]] && [[ "$force_overwrite" != "true" ]]early-return block, immediately beforereturn 0, adds:_env_get-or-generate pattern, expressed as an idempotent upsert. Re-runs produce no-ops. Fresh-install Path B (heredoc) is unchanged.Testing
bash -n installers/macos/lib/env-generator.sh— cleanshellcheck installers/macos/lib/env-generator.sh— no new warnings (all pre-existing SC2034/SC2153/SC2006 are far from the edit)Manual test steps (macOS)
.envlackingDREAM_AGENT_KEY, re-run installer without--force→ key is generated and upserted;DASHBOARD_API_KEYpreserved.DREAM_AGENT_KEY(idempotent)..envabsent or--force) → key is still written via the existing heredoc path; no regression.Platform Impact
installers/phases/06-directories.sh:208already had the equivalent_env_get-or-generate pattern.Get-EnvOrNewin its PowerShell env-generator.Known Considerations
.env.schema.jsonline 269's description forDREAM_AGENT_KEYstill mentions "falls back toDASHBOARD_API_KEYif unset", which is stale post-#979 (the two are fully independent now). Out-of-scope for this PR; worth a small follow-up to correct the description.