Skip to content

fix(affected,impact): resolve git-root-relative changed paths from a subdirectory (#774) - #885

Merged
hslee16 merged 1 commit into
hslee16:mainfrom
nightlab-agent:fix/774-affected-git-root
Nov 9, 2026
Merged

hslee16 merged 1 commit into
hslee16:mainfrom
nightlab-agent:fix/774-affected-git-root

Conversation

@nightlab-agent

Copy link
Copy Markdown
Contributor

What and why

git diff --name-only prints paths relative to the git root, whatever the cwd. archy affected --stdin joined each one onto PATH (resolved = [path / f for f in file_list] in cli.py; MCP's resolve_against did 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 in gitlog.py) and used if it exists there and lies inside PATH.

  • PATH-relative paths still win, so git diff --relative --name-only (now named in the help as the other way) keeps working.
  • Absolute paths are untouched. Without git, or outside a work tree, resolution is as before.
  • A deleted project file is still reported as deleted, even when a file with the same relative path sits at the git root (the "inside PATH" check; without it sub/pkg/conf.py deleted plus an unrelated root pkg/conf.py turned into "unresolved" and the deleted warning vanished).
  • One helper, gitlog.resolve_changed_paths, used by archy affected, archy impact and MCP archy_impact (both modes), so the three agree. Config and DSM baseline paths keep resolve_against unchanged.
  • README, both SKILL.md copies, affected --help and the archy_impact description say how paths are anchored. Headers regenerated with archy conventions . --emit-headers --write.

Fixes #774

How to test

New tests: test_affected_stdin_accepts_git_root_paths_from_subdirectory and test_impact_accepts_git_root_paths_from_subdirectory (CLI through main), test_resolve_changed_paths_accepts_git_root_paths_from_subdirectory over 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:

Mutant Red Caught by
git-root retry never fires (if False and missing ...) 6 of 6 subdirectory tests both CLI tests, all 4 resolve_changed_paths layouts
inside-PATH check removed 1 ..._keeps_deleted_project_file_with_root_namesake

On the branch rebased onto main c08d150, with the environment uv.lock builds: ruff check, ruff format --check, ty check, archy check ., archy cycles . --strict, archy contracts . and archy conventions . --emit-headers --check all exit 0; the full pytest: 2078 passed, 2 skipped.

The mcp 2.x compatibility job's five suites on mcp 2.3.0: 277 passed, 1 skipped, 1 failed. The failure is test_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.

…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.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

🏛️ Architecture score (archy)

Overall: 0.6234 → 0.6232 (-0.0002) ➖ no change

Axis base (c08d150) this PR Δ
modularity 0.6307 0.6309 ➖ +0.0002
acyclicity 1.0000 1.0000 ➖ 0.0000
depth 0.4706 0.4706 ➖ 0.0000
equality 0.4093 0.4084 🔻 -0.0009
complexity 0.7754 0.7755 ➖ +0.0001

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.

codescene-access[bot]

This comment was marked as outdated.

@nightlab-agent

Copy link
Copy Markdown
Contributor Author

A note on the one red check, so you don't have to open it: CodeScene's "Prevent hotspot decline" rule flags _register_tools in src/archy/mcp.py (Complex Method, code health 6.44 → 6.44). My only change in that function is two sentences added to the archy_affected tool's description string, with no new branches or logic. The other 16 checks pass, including Python 3.10, 3.11 and 3.12 on Linux, macOS and Windows.

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)

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hslee16
hslee16 merged commit 4d00313 into hslee16:main Nov 9, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(affected): git diff --name-only | archy affected <subdir> --stdin selects 0 tests and calls the changed file "deleted" when PATH is not the git root

2 participants