fix: treat current search root as local - #232
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
747be8c to
843f79e
Compare
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/aft/src/readonly_artifacts.rs">
<violation number="1" location="crates/aft/src/readonly_artifacts.rs:77">
P2: When the configured project_root is a subdirectory of a larger git repository, the new short-circuit returns project_root for a same-root request and skips the git probe, but any sub-path inside project_root still resolves through git_toplevel and returns the enclosing repo toplevel. The same function therefore returns different roots for the workspace root versus paths under it, which were consistent before this change. Consider limiting the local short-circuit to non-Git roots, or applying the same local handling to sub-paths, so the resolved root is consistent within the configured workspace.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| // symlinks remain local without requiring the workspace itself to be Git. | ||
| let existing = crate::inspect::job::canonicalize_normalized(&existing); | ||
| if existing == crate::inspect::job::canonicalize_normalized(project_root) { | ||
| return Ok(project_root.to_path_buf()); |
There was a problem hiding this comment.
P2: When the configured project_root is a subdirectory of a larger git repository, the new short-circuit returns project_root for a same-root request and skips the git probe, but any sub-path inside project_root still resolves through git_toplevel and returns the enclosing repo toplevel. The same function therefore returns different roots for the workspace root versus paths under it, which were consistent before this change. Consider limiting the local short-circuit to non-Git roots, or applying the same local handling to sub-paths, so the resolved root is consistent within the configured workspace.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/aft/src/readonly_artifacts.rs, line 77:
<comment>When the configured project_root is a subdirectory of a larger git repository, the new short-circuit returns project_root for a same-root request and skips the git probe, but any sub-path inside project_root still resolves through git_toplevel and returns the enclosing repo toplevel. The same function therefore returns different roots for the workspace root versus paths under it, which were consistent before this change. Consider limiting the local short-circuit to non-Git roots, or applying the same local handling to sub-paths, so the resolved root is consistent within the configured workspace.</comment>
<file context>
@@ -67,18 +67,21 @@ pub(crate) fn resolve_git_root_from_user_path(
+ // symlinks remain local without requiring the workspace itself to be Git.
+ let existing = crate::inspect::job::canonicalize_normalized(&existing);
+ if existing == crate::inspect::job::canonicalize_normalized(project_root) {
+ return Ok(project_root.to_path_buf());
+ }
+
</file context>
There was a problem hiding this comment.
Thanks for checking this. The differing behavior is intentional under the contract accepted in #227. aft_search.path selects another project root; it is explicitly not a subtree filter. Only a canonical path exactly equal to the configured root is an alias for omitting path, so it must stay local before Git probing. Any distinct path keeps the pre-existing git rev-parse --show-toplevel routing.
Applying the local short-circuit to descendants would also swallow paths that select a nested child Git repository, violating the accepted requirement that child/external Git roots preserve their current routing. Limiting the short-circuit to non-Git configured roots would conversely break the same-root alias contract when the configured workspace is a subdirectory of a larger repository. The restriction regression in this PR intentionally locks the boundary: the configured root is allowed, while a distinct Git root remains refused. No code change is needed here.
Summary
Closes #227
Verification
not_a_git_rootaft_search_contract_testmodule: 42 passedcargo +1.93.0 check -p agent-file-tools --testscargo +1.93.0 fmt --all -- --checktool_callprobe withrestrict_to_project_root: true:path: "."found the non-Git workspace symbol, while a distinct Git root returnedpath_outside_rootNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Treats search requests that alias the configured project root (including "." and symlinks) as local, skipping external Git-root probing. Previously these aliases could be treated as external, returning not_a_git_root or path_outside_root in non-Git workspaces or with restrict_to_project_root enabled.
Written for commit 843f79e. Summary will update on new commits.
Greptile Summary
This PR treats canonical aliases of the configured search root as local, avoiding unnecessary Git-root probing while preserving the configured root’s original path form.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (2): Last reviewed commit: "fix: treat current search root as local" | Re-trigger Greptile