fix(cli): prevent session hook from inheriting repository dotenv - #149
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
This PR updates the CLI startup dotenv-loading policy to ensure agent lifecycle hook commands do not load repository-controlled .env files, preventing those values from being inherited by detached subprocesses (notably background analyze) before the secret-scan gate runs.
Changes:
- Extend
should_load_dotenvto excludecli::Command::Hook { .. }in addition to existing exclusions. - Update the rustdoc rationale to include hook commands as a third exclusion case.
- Add a regression test ensuring
loomweave hook session-startdoes not load dotenv.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Sep 1, 2026
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.
Rebase of #143 (Codex) onto
release/1.6.0, the working release branch; #143 targeted literalmainand conflicted with theworktree analyzedotenv exclusion that landed in the meantime. Same single commit, conflict resolved by keeping both arms.What
should_load_dotenvnow also excludeshook(session-start). The hook spawns a detachedloomweave analyzewhen the index is stale, so loading a repository.envin the hook would hand repo-controlled values to that child in its inherited environment, bypassing the directanalyzeexclusion (the child's ownshould_load_dotenvonly prevents re-loading).session_start_hook_does_not_load_dotenvalongside the existing analyze / worktree-analyze / guidance cases.Review notes
.env: its only env handling is strippingGIT_*before spawning (hook.rs), so nothing is lost.cargo fmt --check,clippy -D warnings(loomweave-cli),nextest -p loomweave-cli(438 passed) locally.Supersedes #143.
🤖 Generated with Claude Code
https://claude.ai/code/session_0183ccEmYnCh5Nx2Y6weYfHy