Skip to content

mcpx(source): a symlink loop entry aborts the whole @dir: resolve — ELOOP is neither skipped like a dangling link nor pinned like a permission error #7693

Closed

Description

@developing-today

Problem

In mcpx's directory source walk, one symlink loop entry makes the whole @dir: resolve fail — while the two neighboring bad-link cases are tolerated:

  • a dangling symlink is skipped (pkgs/mcpx/internal/source/source.go:174-180: os.Stat failure is continued past only when errors.Is(err, fs.ErrNotExist), comment "A dangling link has no regular target to read");
  • a directory cycle (a dir symlink pointing back to an ancestor) is skipped by the os.SameFile ancestor guard in the same walk (source.go:152-157);
  • a symlink loop (a link to itself, or two links pointing at each other) makes os.Stat fail with ELOOP ("too many levels of symbolic links"), which is neither of the above: source.go:181 returns the error and the entire directory resolution aborts with zero files read — including every healthy regular file sitting next to the loop.

A loop link, like a dangling link, has no regular target to read. The current split — tolerate a missing target and a directory cycle, but let a loop target deny the whole source — is an untested gap, not a pinned decision: the pinned cases in the shipped tests are dangling-skip (source_test.go:245 TestDirectorySkipsDanglingLinkAndFollowsLinkOutsideRoot), directory-cycle-safety (source_test.go:191), and permission-error propagation (source_unix_test.go:73 TestDirectoryReportsInaccessibleSymlinkTarget, which pins EACCES as a returned error and must keep behaving that way). No test covers the ELOOP case.

Evidence (verified this run, laptop, main 8a0a1c0)

Probe at ~/git/fleet/probe-mcpx-eloop on the laptop: the real pkgs/mcpx/internal/source/source.go copied verbatim (md5 768194633188160a349eafd555defe53, identical to the file on main) into a standalone module, driven through the exported source.Resolve("@dir:"+root, …):

  • control (regular.ts + dangling.ts → missing): resolves OK, files = [regular.ts] — matches the shipped pin;
  • self-loop (regular.ts + loop.ts → loop.ts): fails — reading …/loop.ts: stat …/loop.ts: too many levels of symbolic links, zero files returned;
  • pair loop (regular.ts + a.ts → b.ts, b.ts → a.ts): fails the same way at a.ts, zero files returned;
  • control (directory back-link to the root itself): resolves OK, files = [regular.ts] — the ancestor guard tolerates the directory cycle.

So one stray looped link (easily produced by a bad ln -s pair or a tool that links a directory's contents into itself at file level) takes down every launcher/prefix/hook that reads its source from that directory, with an error that names the link but gives no way to keep the healthy remainder.

Related: closed #1727 covered non-regular files in directory sources (FIFO/socket/symlink-to-directory); this is the distinct remaining Stat-error class for file entries. The Go source lives only in this repo (pkgs/mcpx); dezren39/darwin-nix only wraps/launches the built mcpx, so no cross-repo set applies. Found via a pr-diff-review REVIEW-FINDING on PR #3744 that was left as decide-and-test material; verified independently this run before filing.

Why it matters

@dir: sources feed mcpx launchers, prefixes, and error hooks. A single looped symlink — which the directory-cycle guard already proves the walk intends to survive at directory level — currently denies the whole source instead of just the unreadable entry. Robustness here should be uniform: an entry with no readable regular target is skipped (dangling, loop), while genuinely informative errors (permission) still surface, per the existing pin.

Acceptance criteria

  • A directory containing a self-loop symlink or a mutually-looping symlink pair, plus at least one regular file, resolves successfully and returns exactly the regular files (the loop entries skipped), for both the self-loop and pair-loop shapes.
  • Regression tests for both loop shapes land in pkgs/mcpx/internal/source (mirroring the style of TestDirectorySkipsDanglingLinkAndFollowsLinkOutsideRoot), and fail on the pre-fix code.
  • The pinned permission behavior is unchanged: TestDirectoryReportsInaccessibleSymlinkTarget still passes — only the ELOOP class changes disposition, not EACCES or other Stat errors (or, if the fix deliberately widens/narrows which Stat errors skip, the disposition of each class is named in the PR and the affected pins updated with rationale).
  • The existing source suite (go test ./pkgs/mcpx/internal/source/..., or the package's normal CI route) is green with the new tests.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 8, 2026
  2. developing-today commented on Nov 8, 2026

    @developing-today
    ContributorAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-08 06:50 CST
    • Found via: filed this run
    • Task: File the verified mcpx(source) symlink-loop (ELOOP) gap: one loop entry aborts the whole @dir: resolve while dangling links and directory cycles are skipped; reproduced with the real source.go in a laptop probe (controls pass, both loop shapes fail whole-resolve), permission-error pin explicitly preserved in the acceptance criteria.
    • Expectation: effort/s — triage confirms the ELOOP-skip disposition, then a small fix plus regression tests for both loop shapes.
    • Links: probe ~/git/fleet/probe-mcpx-eloop (laptop); body file creator-b-2026-11-08-0650/issue-mcpx-eloop-body.md in the goal hidden_files.
  3. added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 8, 2026
  4. dezren39 commented on Nov 10, 2026

    @dezren39
    Member

    🤖 Agent note · triaged

    • Agent: triage-step
    • State: triaged
    • Verdict: work kind task/small-fix · priority/normal · effort/s · kind/bug
    • Priority why: priority/normal retained from filing — brief line 5: one bad entry aborting a whole resolve is a bounded correctness bug.
    • First step: In pkgs/mcpx/internal/source/source.go's walk, treat an ELOOP error from os.Stat like the dangling-link skip (alongside fs.ErrNotExist at :174-180).
    • Acceptance: A @dir: tree containing a symlink loop resolves with the loop entry skipped (and counted/reported consistently with the other tolerated cases); mcpx source tests green.
    • Fix packet: repo-health:v1:fix:developing-today/code:issue:7693 → queue repo-health-code-pilot, task 14506 (enqueued by triage-step this run).
  5. 14 remaining items

  6. added and removed
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 11, 2026
  7. dezren39 commented on Nov 11, 2026

    @dezren39
    Member

    Lane code-b, task 14506 — implementation complete, parked on CI for PR #8451.

  8. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 11, 2026
  9. dezren39 commented on Nov 11, 2026

    @dezren39
    Member

    Agent note — picked up task 14506 and parked it again for 20 minutes: PR #8451 remains open with basic CI checks queued since 02:38 UTC. Resume by checking CI and review fresh, then merge if verified. Existing parked and assigned labels remain in place.

  10. dezren39 commented on Nov 11, 2026

    @dezren39
    Member

    state: parked (CI wait; Codex dispositioned clean)
    task 14506 (small_fix) — issue #7693 — lane tmp-code-y, 2026-11-11

    Resumed task 14506 at its recorded next step and re-verified fresh: issue #7693 OPEN, no hard-stop labels, no status/needs-triage; PR #8451 OPEN on branch queue/14506-7693-eloop-skip, head aba3c8a. Codex gate: Codex review summary on PR #8451 for commit aba3c8a reports code review COMPLETED, has_any_findings=false, has_unresolved_findings=false — no findings to disposition. Check rollup at this read: 17 QUEUED, 3 SKIPPED, 1 NEUTRAL — the fleet CI queue stall, not a PR failure.

    Terminal for this shift: task 14506 parked as a CI wait on PR #8451. Resume: when PR #8451 checks complete, merge PR #8451, verify the fix on main, then complete task 14506 and close issue #7693.

  11. added a commit that references this issue on Nov 11, 2026
  12. removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    work/assignedQueue worker lifecycle state
    on Nov 11, 2026
  13. dezren39 commented on Nov 11, 2026

    @dezren39
    Member

    🤖 Agent note · done

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

    app/mcpxPackage/app: mcpx (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions