fix: keep change tracking paths workspace-relative - #18
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthrough
ChangesWorkspace path normalization
Estimated code review effort: 3 (Moderate) | ~15–30 minutes Merge Risk: ⚪ Minimal · up to The change keeps workspace targets workspace-relative when the workspace root uses a different canonical path. It is localized, validated by the existing test suite and regression coverage, and no actionable merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 Clippy (1.97.1)Clippy execution failed Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fix change tracking paths becoming absolute when the workspace root resolves to a different canonical path.
This also fixes the six existing
change_trackingtest failures on macOS.Root cause
ChangeSession::begincanonicalizes the workspace root before collecting snapshots, but the paths stored inChangeTargetpreviously kept their original form.On macOS, temporary paths commonly expose this difference:
/var/folders/...may canonicalize to:
/private/var/folders/...This caused operations such as
path.strip_prefix(workspace_root)to fail because the target path and workspace root no longer shared the same prefix representation.When that happened, change tracking fell back to the original absolute path instead of producing a workspace-relative path.
Fix
When the workspace root is canonicalized, target paths that are inside the original workspace are now remapped onto the canonical workspace root while preserving their relative suffix.
For example:
/var/.../project/private/var/.../project/var/.../project/src/main.rsbecomes:
/private/var/.../project/src/main.rsbefore snapshot collection.
This keeps the workspace root and target paths in the same path namespace without canonicalizing individual targets or following file symlinks.
Regression coverage
Added a Unix regression test using a symlinked workspace root to reproduce the same class of path mismatch on platforms other than macOS.
The test verifies that change tracking still returns
tracked.txtinstead of an absolute path.Validation
Targeted change-tracking tests:
9 passed, 0 failed
Full test suite:
215 passed, 0 failed
Additional validation:
cargo build --release✅rustfmt --check✅git diff --check✅Scope
Only
src/change_tracking/mod.rsis changed.No ignore rules, diff generation, MCP behavior, or configuration formats are modified.
Summary by CodeRabbit