Repository navigation
fix(sleep): match a symlinked project directory when harvesting - #465
Open
ni (nniiovoo) wants to merge 1 commit into
Open
ni (nniiovoo) wants to merge 1 commit into
ni (nniiovoo) wants to merge 1 commit into
Conversation
_project_matches compared the session's cwd with the project using os.path.abspath only. Claude Code records the physical cwd, while --project keeps the path as typed, so --project "$(pwd)" from a symlinked ~/code/app (or /tmp/x on macOS) found none of the project's sessions, and a run still moved the checkpoint. When the plain comparison fails, the same checks now run on the realpath of both paths, for an explicit scope list too. A session with no recorded cwd is not resolved, a path realpath rejects falls back to abspath, and _ancestor_in_scope also refuses the realpath of $HOME so a symlinked $HOME stays out of scope (microsoft#294). Fixes microsoft#464 Signed-off-by: NNIIOVO <haimingni44@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #464
_project_matchescompared the session's cwd with the project usingos.path.abspathonly. Claude Code records the physical cwd, while--projectkeeps the path as typed. So--project "$(pwd)"from a symlinked~/code/app(or/tmp/xon macOS) found none of the project's sessions, and arunstill moved the checkpoint.What changes:
_project_matches, so they get this too.realpathrejects (a NUL in a malformed record) falls back toabspathinstead of aborting the harvest._ancestor_in_scopenow refuses the realpath of$HOMEas well as its abspath. Otherwise a symlinked$HOMEwould let$HOMEsessions back into every project below it (sleep: --scope invoked harvests every $HOME-rooted session into every project (unbounded ancestor match) #294).Tests:
tests/test_harvest_symlinked_project.py. It covers:harvest()with the typed (logical) project path.$HOMEstays out of scope, a NUL path doesn't raise, and a session with no cwd isn't matched through the symlink. The 3 bug tests fail on main, and the 4 guards pass on both.tests/test_sleep_adopt_skill_subset.pyalso fail on main.