Skip to content

fix(cli): prevent session hook from inheriting repository dotenv - #149

Merged
tachyon-beep merged 1 commit into
release/1.6.0from
fix/hook-no-dotenv
Sep 1, 2026
Merged

fix(cli): prevent session hook from inheriting repository dotenv#149
tachyon-beep merged 1 commit into
release/1.6.0from
fix/hook-no-dotenv

Conversation

@tachyon-beep

Copy link
Copy Markdown
Collaborator

Rebase of #143 (Codex) onto release/1.6.0, the working release branch; #143 targeted literal main and conflicted with the worktree analyze dotenv exclusion that landed in the meantime. Same single commit, conflict resolved by keeping both arms.

What

  • should_load_dotenv now also excludes hook (session-start). The hook spawns a detached loomweave analyze when the index is stale, so loading a repository .env in the hook would hand repo-controlled values to that child in its inherited environment, bypassing the direct analyze exclusion (the child's own should_load_dotenv only prevents re-loading).
  • Regression test session_start_hook_does_not_load_dotenv alongside the existing analyze / worktree-analyze / guidance cases.

Review notes

  • The hook does not consume anything from .env: its only env handling is stripping GIT_* 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

Copilot AI lite review requested due to automatic review settings September 1, 2026 18:53
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_dotenv to exclude cli::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-start does not load dotenv.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tachyon-beep
tachyon-beep merged commit efcfdd6 into release/1.6.0 Sep 1, 2026
6 checks passed
@tachyon-beep
tachyon-beep deleted the fix/hook-no-dotenv branch September 1, 2026 19:04
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