The overshoot detection was inverted — it returned workspace when the
workspace had hooks/, and vice versa. Both freeze-scope and audit-trail
have the same bug.
Correct approach: check whether the hook's relative path from the
workspace starts with 'hooks/'. If yes, the workspace IS the repo
(dev layout). If no, the plugin is nested inside the workspace
(production layout → return the plugin repo, which is the workspace root).
Also update docstring and test names/assertions to match corrected logic.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The overshoot detection was inverted — it checked repo/hooks instead of
workspace/hooks. This caused the function to return the workspace parent
when the plugin is installed in a workspace (normal case), instead of
the plugin repo itself. Fixed: check os.path.isdir(workspace + "/hooks")
to determine whether we walked too far.
Also:
- Update docstring to explain the production vs dev layout distinction
- Update TestGetRepoRoot: fix mock return values to match corrected logic
- Drop invalid test_real_repo_path_in_this_repo assertion (checks wrong path)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Commit f874929 added comprehensive test coverage (test_lib.py +
test_session_start_context.py) but omitted tests/README.md. This fills that gap.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The hook's REPO path used three dirname() calls from __file__, which
overshoots by one level when __file__ is absolute (Claude Code invokes
hooks with absolute paths). Fix: add get_repo_root() to _lib.py and
use it in session-start-context.py.
Also:
- Add TestGetRepoRoot to tests/test_lib.py (3 new cases)
- Append .pytest_cache/ to .gitignore
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>