Repository navigation
Description
Implement GitHub issue #7693 in developing-today/code: 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
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.Statfailure is continued past only whenerrors.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.SameFileancestor 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.Statfail with ELOOP ("too many levels of symbolic links"), which is neither of the above:source.go:181returns 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 ofTestDirectorySkipsDanglingLinkAndFollowsLinkOutsideRoot), and fail on the pre-fix code. - The pinned permission behavior is unchanged:
TestDirectoryReportsInaccessibleSymlinkTargetstill 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.
Rules from the repo owner: (1) Deliver the finished work as a pull request in this run; put "Fixes #7693" in the PR description so the issue closes on merge. (2) Cover the whole set in the one PR: if the issue names a set (files, subcommands, cases), fix every member, and batch any directly related dependency updates into the same PR — never one PR per item or per dependency. (3) Run the relevant tests and checks before opening the PR. (4) Merging is permitted but never required: merge only when checks pass and you are reasonably certain the PR is correct and low-risk — otherwise leave it open, and state your confidence and what a human should check. (5) If you hit a genuine blocker (missing credentials, a decision only the owner can make), stop and say exactly what is needed in your final summary instead of guessing. (6) Detached-session clause: never use the question tool — if you hit a question, record it and the default you chose in your final summary and keep working.
Launched by pm-dispatch for developing-today/code. Queue task and OpenCode session ids follow in a comment below.
Activity
developing-today commentedon Nov 8, 2026
Dispatch launch FAILED at enqueue before a queue task was created, so this dispatch never became real. Closing this tracking issue as not planned so it does not linger as an orphan (#4917).
Error: queue RPC enqueue_repo_task failed (HTTP 503): {"code":"PGRST002","details":null,"hint":null,"message":"Could not query the database for the schema cache. Retrying."}