fix: treat current search root as local

Merged
LL
2mo ago
+117-7

Summary

  • short-circuit canonical current-root aliases before external Git-root probing
  • return the configured root's original path form after the normalized comparison
  • cover non-Git absolute-root, dot-root, distinct non-Git, and restricted-root behavior

Closes #227

Verification

  • red phase on the parent commit: the restricted same-root case failed with not_a_git_root
  • focused restriction regression: 1 passed
  • full aft_search_contract_test module: 42 passed
  • cargo +1.93.0 check -p agent-file-tools --tests
  • cargo +1.93.0 fmt --all -- --check
  • live NDJSON tool_call probe with restrict_to_project_root: true: path: "." found the non-Git workspace symbol, while a distinct Git root returned path_outside_root

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with 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.

  • Normalize the requested path and the configured root once before comparison; when equal, return the configured root’s original path form.
  • Normalize upfront so Git probing uses a non-verbatim path on Windows; remove the now-redundant later normalization.
  • Tests: non-Git same-root and "." return byte-identical responses to default search; with restrict_to_project_root=true, same-root is allowed and external roots are rejected; external non-Git roots still return not_a_git_root.

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.

  • Normalizes the requested path before comparing it with the configured project root.
  • Returns the configured root directly when both paths identify the same location.
  • Adds coverage for non-Git roots, dot aliases, root restrictions, and distinct external paths.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

FilenameOverview
crates/aft/src/readonly_artifacts.rsNormalizes the nearest existing requested path and short-circuits when it identifies the configured project root.
crates/aft/tests/integration/aft_search_contract_test.rsAdds regression coverage for same-root aliases in non-Git and root-restricted search configurations.

Reviews (2): Last reviewed commit: "fix: treat current search root as local" | Re-trigger Greptile