Skip to content

Bug: detect symlink cycles during vg build/scan walks with an actionable error #271

Closed

Description

@vibgrate-team

Context

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

  1. Detect revisiting the same real path/inode via symlinks during build/scan walks.
  2. Fail closed with a clear error naming the cycle members (or the link that closed it) and suggesting --ignore / a narrower root.
  3. 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.

Activity

  1. added
    bug
    on Sep 24, 2026
  2. vibgrate-team commented on Oct 6, 2026

    @vibgrate-team
    ContributorAuthor

    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:

    1. 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.
    2. 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.
    3. 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions