Fix review agent and hook working directory for worktree commits#559
Fix review agent and hook working directory for worktree commits#559wesm merged 9 commits intoroborev-dev:mainfrom
Conversation
roborev: Combined Review (
|
No, this specific bug report is not true for the current code.
So “run from a subdirectory in a normal checkout stores subdirectory as The suggested regression test is still a reasonable hardening test, but this specific medium-severity finding appears to be a false positive. |
- feat(storage): add worktree_path column migration (#1) - Persist WorktreePath in EnqueueJob INSERT and returned struct (#1) - Read worktree_path in ClaimJob, GetJobByID, and ListJobs (#1) - Detect worktree and pass WorktreePath in handleEnqueue (#1) - feat(daemon): use worktree path for agent cwd and prompt building (#1) - test(storage): verify ReenqueueJob preserves worktree_path (#1) - feat(daemon): use worktree path for hook working directory (#1) - fix(daemon): address PR review feedback for worktree path handling (#1)
9f1246e to
4821cd0
Compare
roborev: Combined Review (
|
…ix jobs (#1) - Bump Postgres schema to v9, add worktree_path column with migration - Add WorktreePath to SyncableJob and PulledJob structs - Include worktree_path in push (UpsertJob), pull (PullJobs), and pull-upsert (UpsertPulledJob) queries - Propagate parentJob.WorktreePath when enqueuing fix jobs - Add sync round-trip and fix-job propagation tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…, and batch sync (#1) - Add WorktreePath to Event.MarshalJSON so SSE/webhook payloads include the field - Load repo-specific hook config from worktree path when available, so the correct .roborev.toml is used - Add worktree_path to BatchUpsertJobs SQL (the main sync push path) - Add MarshalJSON serialization tests for worktree_path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend TestIntegration_BatchUpsertJobs to verify worktree_path survives a BatchUpsertJobs push and PullJobs pull cycle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
- Add git.ValidateWorktreeForRepo() that resolves the main repo root from a worktree path and compares it (with symlink resolution) to the expected repo root - Use filepath.Clean on both paths in handleEnqueue worktree detection to avoid normalization false positives - Replace os.Stat checks in worker and hook runner with ValidateWorktreeForRepo, closing the trust boundary gap for stale/synced paths - Consolidate hook config loading and working directory resolution into a single effectiveRepo path Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
#1) - Use valid UUID for PullJobs excludeMachineID (fixes CI failure) - Assert worktree_path directly via SQL before PullJobs round-trip - ValidateWorktreeForRepo now also verifies the path is a checkout root via GetRepoRoot, rejecting nested subdirectories - Add subdirectory regression test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
|
False positive. Will merge this once CI green |
The variable holds the result of git rev-parse --show-toplevel, not a raw working directory. The old name misled reviewers into thinking subdirectory invocations could produce incorrect worktree detection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thank you @wesm - I've been enjoying using this service and was delighted to be able to contribute |
roborev: Combined Review (
|
… reuse by worktree (#1) - Resolve branch exclusion config from checkoutRoot instead of repoRoot so worktree-specific .roborev.toml rules apply - Add worktree_path to FindReusableSessionCandidates query filter so sessions from different worktrees of the same repo/branch are not reused across checkouts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pass checkoutRoot instead of repoRoot to findReusableSessionID so reuse_review_session and lookback settings are read from the worktree's .roborev.toml, consistent with branch exclusion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
roborev: Combined Review (
|
Summary
When commits are made in git worktrees, roborev resolved the path to the main repository root before passing it to review agents and hooks. This caused two problems: review agents searched the main checkout (wrong branch) instead of the worktree, producing false positives for files that only existed on the feature branch; and post-review hooks like
roborev refineran in the main repo root, refusing to operate because it detected themainbranch instead of the feature branch.worktree_pathcolumn toreview_jobsto persist the originating worktree path per jobhandleEnqueueby comparingGetRepoRootvsGetMainRepoRootWorktreePathas the agent's working directory and prompt builder path, with fallback to the main repo root if the worktree no longer existsroborev refineoperates on the correct branchChanges
roborev install-hook uninstallto uninstall the hook #1)roborev install-hook uninstallto uninstall the hook #1)roborev install-hook uninstallto uninstall the hook #1)roborev install-hook uninstallto uninstall the hook #1)roborev install-hook uninstallto uninstall the hook #1)roborev install-hook uninstallto uninstall the hook #1)roborev install-hook uninstallto uninstall the hook #1)roborev install-hook uninstallto uninstall the hook #1)