Conversation
…state/daft
`execute_yaml_hook_with_rc` always wrote invocation/job records under
`daft_state_dir().join("jobs").join(repo_hash)`. Even after #448 routed
the repo identity through `ctx.git_dir`, every yaml_executor test still
created a fresh repo UUID and a matching orphan directory in the user's
real `~/.local/state/daft/jobs/`. Each `cargo test` accumulated more.
Inject the state base instead. `LogStore::for_repo_in(repo_hash, base)`
parameterizes the write root; `for_repo` keeps the production behavior
by delegating with `daft_state_dir()`. `HookContext` gains an optional
`state_dir` (set via `with_state_dir`) that the executor consults
before falling back to the global. Tests set it to the same tempdir
they already use as `git_dir`, so all on-disk side effects stay
inside the tempdir.
Adds a regression test that runs the executor end-to-end from the
test fixture, then asserts (a) the LogStore base under the tempdir
exists and (b) no matching UUID dir leaked into `daft_state_dir()`.
Fixes #478
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/claude review |
|
Claude finished @avihut's task in 2m 48s —— View job PR Review: fix(hooks): stop yaml_executor unit tests from leaking into ~/.local/state/daftTasks:
SummaryThe fix is well-designed and correct. The dependency-injection approach (threading Observations
|
Summary
LogStore::for_repo_in(repo_hash, base)parameterizes the state-dir base. Existingfor_repokeeps its production behavior by delegating withdaft_state_dir().HookContextgains an optionalstate_dir(set viawith_state_dir) thatexecute_yaml_hook_with_rcconsults before falling back to the global state dir.make_ctx_with_dirnow setsstate_dirto the same tempdir it already uses asgit_dir, so yaml_executor unit tests no longer write under~/.local/state/daft/jobs/.Pre-#448 the leak was visible: cwd-based
compute_repo_id()made unit tests pollute the current repo's UUID dir under whatever repo the test runner sat in. #448 fixed the cwd issue but left a quieter leak — everycargo testof yaml_executor still wrote a fresh orphan UUID directory into the user's real state dir. This PR closes that.Out of scope:
daft repo removeanddaft reposubcommand category #448feature/newresidue. Usedaft hooks jobs prune --older-than 1dto clear stale entries.daft hooks jobs --alloutput (no aggregate view, noprune --worktree/--hookfilter). Tracked separately.Fixes #478
Test plan
mise run test:unit— full suite greenmise run clippy— zero warningsmise run fmt:check— cleantest_execute_yaml_hook_honors_state_dir_overridepasses after the fixLogStore writes should have landed under the tempdir state base) when thefor_repo_inredirect is reverted, confirming it actually catches the regression🤖 Generated with Claude Code