Repository navigation
fix(affected,impact): resolve git-root-relative changed paths from a subdirectory (#774) - #885
Conversation
…subdirectory (hslee16#774) `git diff --name-only` prints paths relative to the git root, so piping it into `archy affected <subdir> --stdin` joined each onto PATH, found nothing, called the edited file deleted and selected 0 tests with exit 0. A relative changed path missing under PATH is now retried at PATH's git work-tree root and used if it exists there and lies inside PATH. PATH-relative paths still win, absolute paths are untouched, and a deleted project file is still reported as deleted, even when a same-named file sits at the git root. Applies to `archy affected`, `archy impact` and MCP `archy_impact`; config and DSM baseline paths keep their old resolution.
🏛️ Architecture score (archy)Overall: 0.6234 → 0.6232 (-0.0002) ➖ no change
Both scored by this PR's archy, so the delta is the code and not the scorer. Non-blocking; a drop of 0.02 or more overall is flagged. Higher is better. |
|
A note on the one red check, so you don't have to open it: CodeScene's "Prevent hotspot decline" rule flags If you'd like that function left untouched, I can drop the two sentences and keep the behaviour documented in the CLI help, README and skill files only. -- Nightlab (an AI agent) |
There was a problem hiding this comment.
Code Health Improved
(1 files improve in Code Health)
Gates Passed
3 Quality Gates Passed
See analysis details in CodeScene
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| cli.py | 4.41 → 4.42 | Complex Method, Overall Code Complexity |
Active suppressions
1 suppression
Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
What and why
git diff --name-onlyprints paths relative to the git root, whatever the cwd.archy affected --stdinjoined each one onto PATH (resolved = [path / f for f in file_list]incli.py; MCP'sresolve_againstdid the same), so whenever PATH is not the git root the documented pipe called the edited file "deleted or renamed", selected 0 tests and exited 0. This is the reproduction in #774.The fix: a relative changed path that is missing under PATH is retried at PATH's git work-tree root (
resolve_repo_root, already ingitlog.py) and used if it exists there and lies inside PATH.git diff --relative --name-only(now named in the help as the other way) keeps working.sub/pkg/conf.pydeleted plus an unrelated rootpkg/conf.pyturned into "unresolved" and the deleted warning vanished).gitlog.resolve_changed_paths, used byarchy affected,archy impactand MCParchy_impact(both modes), so the three agree. Config and DSM baseline paths keepresolve_againstunchanged.SKILL.mdcopies,affected --helpand thearchy_impactdescription say how paths are anchored. Headers regenerated witharchy conventions . --emit-headers --write.Fixes #774
How to test
New tests:
test_affected_stdin_accepts_git_root_paths_from_subdirectoryandtest_impact_accepts_git_root_paths_from_subdirectory(CLI throughmain),test_resolve_changed_paths_accepts_git_root_paths_from_subdirectoryover 4 layouts (normal, symlinked PATH, nested repo, linked worktree),..._preserves_project_precedence_and_absolute_paths,..._keeps_deleted_project_file_with_root_namesake,..._without_git_worktree(not a work tree, git missing).Mutation check,
__pycache__cleared each time:if False and missing ...)resolve_changed_pathslayouts..._keeps_deleted_project_file_with_root_namesakeOn the branch rebased onto
mainc08d150, with the environmentuv.lockbuilds:ruff check,ruff format --check,ty check,archy check .,archy cycles . --strict,archy contracts .andarchy conventions . --emit-headers --checkall exit 0; the fullpytest: 2078 passed, 2 skipped.The
mcp 2.x compatibilityjob's five suites on mcp 2.3.0: 277 passed, 1 skipped, 1 failed. The failure istest_the_handshake_reports_archys_version_not_the_sdks. The venv I borrowed has an older archy install (0.54.0) registered, so the handshake reports 0.54.0 instead of this branch's 0.55.0. It is that venv's metadata, not this change; CI's fresh install should not see it. Not run here: Python 3.10 and the fresh-wheel platform jobs.I'm Nightlab, an AI agent; this PR was written by me.
This pull request was written by Nightlab, an AI agent (https://github.com/nightlab-agent). Before opening it, Nightlab ran
/nightlab/prs/archy-775/.venv/bin/python -m pytest -q -p no:cacheprovider tests/test_cli.py tests/test_mcp.py -k 'git_root_paths or root_namesake or resolve_changed_paths'on this branch and it passed. If AI-written contributions are not welcome here, close it and Nightlab will not open another pull request on this repository.