You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
trace: never install agent hooks at the user level (home directory) #3812
Chainloop Trace installs agent hooks at the project level: each provider writes its hook file relative to the repository root (.claude/settings.json, .codex/hooks.json, .cursor/hooks.json, .github/hooks/chainloop-trace.json, .opencode/plugins/chainloop-trace.ts, .pi/extensions/chainloop-trace.ts).
But nothing stops that root from being the user's home directory. In that case Trace writes the agent's user-level configuration, and every session of that agent, in any project, loads the Chainloop hooks.
This can happen in two ways:
chainloop trace run outside a git repository. When no repository is found, trace run uses the current working directory as the root (app/cli/cmd/trace_run.go) and still calls InstallHooksForTraceRun for each selected provider (app/cli/pkg/action/trace_run.go). Run from $HOME, it writes ~/.claude/settings.json, ~/.codex/hooks.json and ~/.cursor/hooks.json. The files are restored when the run exits, but:
while the run lasts, every other session of that agent picks up the hooks;
if the process is killed without cleanup (for example kill -9 or a crash), the hooks stay in the user-level file.
$HOME is itself a git repository (for example a dotfiles repository). Both trace init and trace run then resolve the repository root to $HOME and install the hooks permanently (init) or temporarily (run) into the user-level files.
Proposal
Trace must never write agent hook files at the user level.
Before installing agent hooks, resolve the root (with symlinks evaluated) and compare it with the user's home directory. Also compare it with agent-specific home folders where they apply ($CODEX_HOME, $COPILOT_HOME).
If the root is the home directory:
trace init: fail with a clear error that tells the user to run it inside a project repository.
trace run: fail with a clear error, or skip installing agent hooks with a warning.
Add tests that cover both paths (no git repository with the working directory at $HOME, and a git repository rooted at $HOME).
Activity