Skip to content

fix(skills): a skill folder that links to itself is listed with a problem, not a failed list - #265

Open
connorburgess wants to merge 4 commits into
spacesheep-dev:mainfrom
connorburgess:fix/skills-symlink-loop
Open

connorburgess wants to merge 4 commits into
spacesheep-dev:mainfrom
connorburgess:fix/skills-symlink-loop

Conversation

@connorburgess

@connorburgess connorburgess commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Updated against v0.8.19 / main e8bfe999 on 2026-12-05. Current validation and refresh details.

What

One skill folder with a folder link back into itself (for example a -> ., or sub/up -> ..) no longer breaks the whole Skills list. The other skills are listed as usual, and the looping skill appears with the problem symlink loop "<path>". Install, pack and adopt refuse that skill, as they already refuse a link that escapes the skill folder.

Why

scanSkillDir's walk in server/ui/skillsCore.ts follows a folder link whenever its real target is inside the skill root, and that includes the root itself. It read through the growing link path (a/a/a/...) until readdirSync threw ELOOP: too many symbolic links encountered (32 levels on macOS). Nothing caught the error, so discoverLocalSkills threw and GET /api/ui/skills failed for every skill. inspectLocalSkill failed the same way. A long chain of folder links that never loops (d0/next -> ../d1, d1/next -> ../d2, and so on) ran into the same ELOOP, because the path it read through grew with each link.

The fix:

  • walk reads each folder through its real path, so the path it reads through never grows.
  • It keeps the folders on the current descent. A folder link back to one of them is reported, not followed.
  • Folders are compared by their realpathSync.native spelling, so a link written ../SUB still matches sub on a case-insensitive disk. Where the native call fails, as it does on some Windows virtual drives, they are compared by the plain real path.
  • Links to other folders inside the skill are followed as before. Skills without loops list, order and hash exactly as before.

Original proof (before the v0.8.18 refresh)

New tests in server/ui/skills.test.ts (skillsCore symlink loops). They are skipped on Windows, where creating symlinks needs extra rights, using the skipIf(process.platform === "win32") pattern from server/tls-status.test.ts. The case test runs only on a case-insensitive disk (macOS default). On a case-sensitive disk that link is just broken, so the test skips itself.

On this branch (npx vitest run server/ui/skills.test.ts --reporter verbose):

 ✓ skillsCore local library > installs, discovers, inspects, links/unlinks, adopts without clobbering, packs, and manages collections
 ✓ skillsCore symlink loops > lists the other skills and reports a link to the skill folder itself as a problem
 ✓ skillsCore symlink loops > lists the other skills and reports a link to its own parent folder as a problem
 ✓ skillsCore symlink loops > follows a long chain of folder links that never loops
 ✓ skillsCore symlink loops > catches a loop whose link spells the folder in another case
 ✓ skillsCore symlink loops > still follows a link to a sibling folder inside the skill
 ✓ registerSkills HTTP routes > enforces loopback-only for local mutations and supports full demo mode lifecycle
      Tests  7 passed (7)

The same tests with server/ui/skillsCore.ts from main (1a475e8):

 ✓ skillsCore local library > ...
 × skillsCore symlink loops > lists the other skills and reports a link to the skill folder itself as a problem
 × skillsCore symlink loops > lists the other skills and reports a link to its own parent folder as a problem
 × skillsCore symlink loops > follows a long chain of folder links that never loops
 × skillsCore symlink loops > catches a loop whose link spells the folder in another case
 ✓ skillsCore symlink loops > still follows a link to a sibling folder inside the skill
 ✓ registerSkills HTTP routes > ...
Error: ELOOP: too many symbolic links encountered, scandir '…/.agents/skills/loop/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a…'
Error: ELOOP: too many symbolic links encountered, scandir '…/.agents/skills/loop/sub/up/sub/up/sub/up/sub/up/sub/up/sub/…'
Error: ELOOP: too many symbolic links encountered, scandir '…/.agents/skills/loop/d0/next/next/next/next/next/next/next/n…'
Error: ELOOP: too many symbolic links encountered, scandir '…/.agents/skills/loop/sub/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x…'
      Tests  4 failed | 3 passed (7)

Checks on macOS, Node 22:

  • npm run typecheck: passes.
  • npm run lint: exit 0. It reports 135 warnings, the same count as on main, and none in the two changed files (npx biome check server/ui/skills.test.ts server/ui/skillsCore.ts: no diagnostics).
  • npm test: on this branch Tests 1 failed | 3371 passed | 2 skipped (3374). The one failure is server/control/remote.parity.test.ts ("machines, sends, refusals, jobs, … row for row": TestTimeoutError: Test timed out in 15000ms). It fails the same way on unmodified main 1a475e8 (Tests 1 failed | 3366 passed | 2 skipped (3369), the same test, the same 15000 ms timeout).
    • In one of my two branch runs, web/src/files/model.break.test.ts ("rebuilds a 20k-line file with 50 edits well under a second") also failed, at 1139 ms against its 1 s limit, under the load of the full run. It passed in the other full run, and on its own (Tests 26 passed (26)). It does not touch skills.

Not done here, and not changed by this pull request:

  • A skill folder with many links to the same folder is still walked once per link. Today that is bounded only by the 500-file and size limits.
  • A skill with more than 500 files can still lose its SKILL.md to the file cap.
  • Any other error inside the walk, such as an unreadable subfolder (EACCES), still fails the list.
  • linkLocalSkill does not check these problems before linking a skill into a harness.

All of these behave the same on main.

An entry is now included under Unreleased in CHANGELOG.md. Other open PRs also add release notes; those entries may need combining as the PRs land.

Checklist

  • Every commit is signed off (git commit -s): the DCO is the only paperwork.
  • npm run typecheck && npm run lint && npm test pass; npm run test:e2e for a UI change. (Not a UI change. For npm test, see Proof: the one failure also fails on main.)
  • New source files start with // SPDX-License-Identifier: Apache-2.0. (No new files.)
  • No secret, real address, hostname or home path in code, fixtures or screenshots (screenshots come from --demo).
  • A change to shared/* names the wire-contract change in the description. (No shared/* change.)
  • A line under Unreleased in CHANGELOG.md.

…blem, not a failed list

Symptom: one skill folder holding a link back to itself (`a -> .`) or to
a folder above the link (`sub/up -> ..`) made the whole Skills list fail.
GET /api/ui/skills returned an error for every skill instead of listing
them, and inspecting the skill failed the same way.

Cause: scanSkillDir's walk followed any folder link whose target stays
inside the skill root, the root itself included, and read through the
growing link path (a/a/a/...). readdirSync threw ELOOP after about 32
levels, and nothing caught it, so discoverLocalSkills threw. A long chain
of folder links that never loops hit the same ELOOP.

Fix: walk reads each folder through its real path and keeps the folders
on the current descent, keyed by realpathSync.native (the plain real
path where that call fails) so a link that spells a folder in another
case still matches on a case-insensitive disk. A folder link back to one of them is reported as
`symlink loop "<path>"` and not followed. That problem starts with
"symlink ", so install, pack and adopt refuse the skill the way they
already refuse a link that escapes it. Skills without loops list and
hash as before.

Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
@connorburgess

Copy link
Copy Markdown
Contributor Author

My new pull request #266 (link-only skill installs no longer delete the skill's own library folder) also changes server/ui/skillsCore.ts. It changes installLocalSkillFromDir, linkLocalSkill, unlinkLocalSkill and adoptLocalSkill, while this one changes scanSkillDir; its tests are in a new file, so server/ui/skills.test.ts is untouched there. git merge-tree --write-tree finds no conflict between the two heads.

Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
@connorburgess

Copy link
Copy Markdown
Contributor Author

The skill directory symlink-loop fix still applies to SessionPipe GUI v0.8.18. Merged current main (d16a2c01) into this branch; the refreshed head is 5bada416. The affected files have not changed upstream, and the original change is preserved.

Added the previously deferred Unreleased changelog entry.

Validation on this head, macOS / Node 22.23.2:

  • npm run typecheck, npm run lint, and npm run build passed. Lint has the same 135 warnings and one informational diagnostic as current main, with no errors.
  • npx vitest run --maxWorkers=2 server/ui/skills.test.ts: 7 tests passed.

GitHub CI run 47453785987 for head 5bada416 is not green. Passed: typecheck · lint · unit · build, e2e (control channel), e2e (phone · duo), e2e (desktop 1/3), e2e (desktop 3/3). Failed: e2e (desktop 2/3), typecheck · lint · unit · build · e2e.

Desktop shard 2 failed new-session.spec.ts:455, “a file refused for too many at once offers Try again only once the wait is over”: filling the new-session textarea timed out before the upload assertion. The PR changes skill directory traversal, not the new-session UI. Three local repetitions of that test passed on unmodified main and three passed on this head (npx playwright test test/e2e/new-session.spec.ts --project=desktop --grep "a file refused for too many at once" --repeat-each=3 --workers=2). This did not reproduce the runner failure or establish its cause.

A maintainer needs to rerun/investigate the failed desktop job and aggregate gate before merging. The upstream job-rerun API rejects this account with HTTP 403 for insufficient repository permissions.

Also checked the combined source/test changes from all 19 refreshed PRs on the same main: no source conflicts; typecheck, lint and build passed; all 252 unit-test files passed (3,439 tests, two skipped). This was a local integration check, separate from the individual PR run above. Release-note entries may still need combining as PRs land.

Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
@connorburgess

Copy link
Copy Markdown
Contributor Author

Merged current main (e8bfe999, v0.8.19) into this branch; the head is now b28c95dd. The merge needed one resolution, in CHANGELOG.md: this PR's Unreleased entry stays above the new 0.8.19 section. No source file of this PR changed upstream.

CI run 47497346826 for head b28c95dd passed every job: typecheck · lint · unit · build, e2e (desktop 1/3), e2e (desktop 2/3), e2e (desktop 3/3), e2e (phone · duo), e2e (control channel) and the aggregate typecheck · lint · unit · build · e2e gate.

The earlier run 47453785987 on 5bada416 failed e2e (desktop 2/3) at new-session.spec.ts:455, where locator.fill on the new-session textarea ran out the 45 s test timeout on both attempts; new-session.spec.ts:308 and plan-review.spec.ts:272 failed once in the same job and passed on retry. This PR changes only server/ui/skillsCore.ts and its test, and all three pass in the new run with the same source, so I read it as a slow runner. I could not reproduce it locally.

Locally on b28c95dd (macOS, Node 22.23.2): npm run typecheck, npm run lint (135 warnings, no errors, as on main) and npm run build passed; npx vitest run server/ui/skills.test.ts: 7 tests passed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant