You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: detect symlink cycles during vg build/scan walks with an actionable error #271
Symlink cycles (or link farms that revisit the same inode) can hang or thrash a local walk. Docs for ignore/exclude patterns live in #162; this ticket is the behavioral safety rail: detect cycles, exit non-zero with an actionable message, and stay deterministic (no unbounded wall-clock spin).
What to do
Detect revisiting the same real path/inode via symlinks during build/scan walks.
Fail closed with a clear error naming the cycle members (or the link that closed it) and suggesting --ignore / a narrower root.
Add a tiny fixture + test that asserts the error path (no flake, no sleep-based timing).
Acceptance
Symlink cycle → actionable error + non-zero exit; no hang as the primary UX
Message points at ignore/narrow-root remedies
Deterministic tests; DCO; pnpm test green
Mentoring notes
Coordinate wording with #162 docs and the unsafe-root rails in #258 so operators see one coherent story.
Grounding from the current walkers before building a cycle detector.
Neither walk follows symlinks today. discover in src/engine/discover.ts (used by vg build) and the scan walkers in src/core-open/utils/fs.ts read directories with readdir(..., { withFileTypes: true }) and only recurse when Dirent.isDirectory() is true. That check does not follow links, so a symlinked directory is never entered and a cycle cannot make the walk revisit itself. A symlinked file also fails Dirent.isFile() and is skipped.
So the gap is not a hang. Symlinked directories and files are dropped silently, and nothing tells the operator.
Suggested rescope:
Add a regression test: a fixture with a directory symlink pointing at its parent, asserting that vg build and vg scan finish with a deterministic result and do not descend into the link. This locks in the current safe behaviour.
Decide the user-facing behaviour for skipped links. The smallest useful change is one stable, sorted notice listing skipped symlinks (count plus the first few paths), with no change to the output files.
If following symlinks is wanted later, make it opt-in and track visited real paths (realpath, or dev/ino from stat). A cycle then fails with the actionable error this issue describes, pointing at --exclude or a narrower root, in the same wording as the unsafe-root checks in DOCS.md.
Activity
vibgrate-team commentedon Oct 6, 2026
Grounding from the current walkers before building a cycle detector.
Neither walk follows symlinks today.
discoverinsrc/engine/discover.ts(used byvg build) and the scan walkers insrc/core-open/utils/fs.tsread directories withreaddir(..., { withFileTypes: true })and only recurse whenDirent.isDirectory()is true. That check does not follow links, so a symlinked directory is never entered and a cycle cannot make the walk revisit itself. A symlinked file also failsDirent.isFile()and is skipped.So the gap is not a hang. Symlinked directories and files are dropped silently, and nothing tells the operator.
Suggested rescope:
vg buildandvg scanfinish with a deterministic result and do not descend into the link. This locks in the current safe behaviour.realpath, ordev/inofromstat). A cycle then fails with the actionable error this issue describes, pointing at--excludeor a narrower root, in the same wording as the unsafe-root checks in DOCS.md.