strix icon indicating copy to clipboard operation
strix copied to clipboard

runtime: resolve staged local-dir path to avoid symlink rejection on macOS

Open utkutugrul opened this issue 4 months ago • 1 comments

Problem

stage_symlink_safe_dir() in strix/runtime/local_dir_staging.py exists specifically to give LocalDir a symlink-free path to upload. But the staging directory it creates is never resolved:

staged = Path(tempfile.mkdtemp(prefix=_STAGING_PREFIX))

tempfile.mkdtemp() honors $TMPDIR. On macOS, the default $TMPDIR (e.g. /var/folders/xx/yyyy/T/) resolves through /var, which is itself a symlink to /private/var. Since LocalDir rejects any symlink component in its source path, every local-dir scan whose source tree contains at least one symlink fails on macOS with:

agents.sandbox.errors.LocalDirReadError: failed to read local dir artifact: ...
  reason: symlink_not_supported

i.e. the function that exists to avoid this exact error trips it itself, on every macOS machine, for any repo with an in-tree symlink (common in JS/TS monorepos, venvs, etc.). In the TUI this currently surfaces as the run failing near-instantly in the background while the screen stays on "Loading..." indefinitely (a separate UX issue, not addressed here).

Fix

Resolve the staged path before returning it:

staged = Path(tempfile.mkdtemp(prefix=_STAGING_PREFIX)).resolve()

Testing

Added test_staged_path_has_no_symlink_ancestor, which monkeypatches tempfile.mkdtemp to return a path behind a symlink (reproducing the /var -> /private/var shape without depending on host OS layout) and asserts the returned staged path has no symlink ancestors. Fails without the fix, passes with it. Full existing suite for this module (tests/test_local_dir_staging.py) still passes (8/8).

Note

This looks distinct from #843 (large-repo copy failures reported on Linux/WSL): that report doesn't show the symlink-rejection signature, so it's likely a different failure mode in the same staging/copy pipeline. Mentioning in case it's a useful data point, not claiming to fix it here.

utkutugrul avatar Jul 22 '26 20:07 utkutugrul

Greptile Summary

This PR canonicalizes local-directory staging paths before upload. The main changes are:

  • Resolve temporary staging directories to remove symlinked ancestors.
  • Add a macOS-style regression test using a symlinked temporary-directory path.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
strix/runtime/local_dir_staging.py Resolves the staging path while keeping staging writes, upload, and cleanup on the same directory.
tests/test_local_dir_staging.py Adds focused coverage for temporary directories reached through a symlinked ancestor.

Reviews (1): Last reviewed commit: "runtime: resolve staged local-dir path t..." | Re-trigger Greptile

greptile-apps avatar Jul 22 '26 20:07 greptile-apps