Skip to content

Fix skill details for symlinked skill directories - #5556

Merged
ymichael merged 3 commits into
get-bb:mainfrom
dillonzq:bb/thr_mg3atqii27
Oct 17, 2026
Merged

ymichael merged 3 commits into
get-bb:mainfrom
dillonzq:bb/thr_mg3atqii27

Conversation

@dillonzq

@dillonzq dillonzq commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

Imported skills discovered through a symlinked directory retain their logical path. The Skills detail page and CLI then use that directory as the root for host.read_file_relative and host.list_files, whose host-side validation rejects symlink roots. A listed, readable Pi skill therefore shows Failed to load SKILL.md.; both bb skill show and bb skill files return HTTP 502. This remains reproducible with the file handler from upstream main at 05771e3c82404328854468f0fff7f0f8203e2076. The reproduction and investigation are in #5555. Merged #5519 fixes discovery, while this change fixes the subsequent detail reads.

What changed

  • Add a required followRootSymlink boolean to the two host file RPCs. The server opts in for skill content and file-list reads; other callers explicitly pass false.
  • When opted in, the host resolves the root before using the existing directory and relative-file validation. Relative reads stay confined to the resolved skill directory, dotfiles remain denied, and file listings continue to skip nested symlinks. Linked skills remain non-manageable.
  • Increment HOST_DAEMON_PROTOCOL_VERSION from 240 to 241 for the required wire fields, update existing callers and contract fixtures, and document the policy in docs/debugging-and-qa.md.
  • A followed root that no longer exists (removed target or dangling link) returns the usual missing-file ENOENT error instead of a raw filesystem error.
  • The existing SDK and CLI skill operations use the same server paths; there are no new user-facing flags or configuration.

How you verified

  • Reproduced the installed BB 0.46.0 failure using both bb skill show and bb skill files against a real Pi directory link. The target SKILL.md exists and resolves successfully.

  • Added an owner-boundary regression covering listing a linked directory, reading SKILL.md and a nested reference, hiding dotfiles, rejecting .., and rejecting a nested link escaping the resolved root. With host-files.ts taken from latest upstream main, it fails with Path "…/research" must not be a symlink; it passes with this fix.

  • Extended the server skill-detail test to check that both RPCs receive the explicit opt-in. Existing generic file-root rejection tests continue to pass with false.

  • After rebasing onto the checked upstream main, all 168 focused tests passed:

    pnpm exec turbo run test --filter=@bb/host-daemon -- test/command/workspace-dispatch.test.ts src/command-handlers/host-files.test.ts src/command-handlers/list-skills.test.ts
    pnpm exec turbo run test --filter=@bb/server -- test/public/public-project-skills.test.ts test/files/host-file-routes.test.ts test/internal/internal-environment-change.test.ts
    pnpm exec turbo run test --filter=@bb/host-daemon-contract -- test/contract.test.ts
    pnpm exec turbo run lint typecheck --filter=@bb/host-daemon --filter=@bb/server --filter=@bb/host-daemon-contract
  • Formatting and git diff --check passed. Source verification used Node 22.19.0 and pnpm 9.15.0 on macOS arm64. The installed desktop app was not replaced; post-fix browser/desktop UI verification has not been run.

  • Commandeered by a maintainer: merged current main (protocol 240 → 241) and added the missing-root handling above, with a dangling-link case in the regression test. Re-ran the focused host-daemon, server (8 files touching these RPCs), and contract suites plus lint/typecheck; all pass.

Fixes #5555

AGENT GENERATED

ymichael and others added 2 commits October 16, 2026 16:49
# Conflicts:
#	packages/host-daemon-contract/src/protocol.ts
#	packages/host-daemon-contract/test/contract.test.ts
Resolve the followed root inside readRootRelativeFileForTransport so a
dangling or removed skill directory returns ENOENT instead of a raw
filesystem error. Drop the duplicate absolute-path check and move the
docs paragraph to the end of the File Content Routes section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit b64c742 into get-bb:main Oct 17, 2026
46 checks passed
ymichael added a commit that referenced this pull request Oct 26, 2026
…read (#6335)

## Human comments

## What was wrong

`host.write_file` without `expectedSha256` overwrote its target in
place, so a crash or full disk partway through left a truncated file.
`host.read_file_relative` loaded whole files with no size limit and sent
them as one base64 WebSocket message. Both bugs came from duplicated
paths. There were two whole-file reads: `read_file_relative` was built
for the status-folder server, removed in June, and its only remaining
caller was the provider-skill read. There were also three hand-written
copies of the temp-file, hash-check, rename save, so a fix in one never
reached the others.

## What changed

- **One atomic save:** new dependency-free package `@bb/file-transfer`.
`verified-file-transfer.ts` (from #6332/#6330) moved into it unchanged,
apart from the `durable` and `mode` arguments below. A new `replaceFile`
does the whole save:
  1. check the expected hash;
2. write and fsync a fixed-length `.bb-write-<uuid>` temp file next to
the target;
  3. put it in place:
     - **no hash:** rename over the target;
     - **`expectedSha256: null`:** no-clobber link;
     - **a hash:** re-check, then rename.
- **Who uses it:** `writeHostFile` keeps only root confinement, parent
creation and error mapping. The server-owned skill save in
`skill-listing.ts` calls `replaceFile` directly instead of its own copy.
- **Modes:** an existing file keeps its mode exactly. A requested mode
on a new file goes through `open()`, so the umask applies, as on main.
- **Read-only folders:** an unconditional write falls back to
overwriting in place, as on main. A hash-checked save fails with
`EACCES`, as on main.
- **fsync:** `writeVerifiedFile` takes `durable` (user saves fsync;
attachments and skill trees don't) and an explicit create-or-exact
`mode`.
- **One whole-file read:** removed `host.read_file_relative`. The skill
read now uses `host.read_file`, which has the 25 MB (10 MB image) cap.
- **Symlinked skill folders:** `host.read_file` gains a required
`followRootSymlink` boolean, matching `host.list_files`, so linked skill
folders still resolve (#5556). Skill reads pass `true`; every other
caller passes `false`. The schema rejects `true` with a git `ref` or
without a `rootPath`.
- **Server-side path checks:** the server rejects absolute, `..` and
dotfile skill paths before calling the host, using the same check
server-owned skills already used.
  - **Errors:** an oversized skill file now returns 413 instead of 502.
- **Wire change:** `HOST_DAEMON_PROTOCOL_VERSION` goes from 255 to 256,
for the removed command and the new required field. `host.write_file`'s
fields and results are unchanged.
- **Docs:** updated the symlinked-skill paragraph in
`docs/debugging-and-qa.md`.
- **Behaviour note:** saves replace the file, so hard links, xattrs and
ACLs on an overwritten file aren't carried over. Hash-checked saves
already worked this way.

## How you verified

- **New tests:**
  - `@bb/file-transfer`:
    - an interrupted write leaves the original intact;
- read-only folder: an unconditional write lands in place, a
hash-checked save is refused;
    - a requested mode respects the umask;
    - a 240-character filename saves.
  - daemon: an oversized read under a followed root is rejected.
  - server:
    - oversized skill file → 413;
- absolute, `..` and dotfile skill paths are rejected without calling
the host;
- server-owned skill save writes on a fresh revision and returns 409 on
a stale one.
  - Each failed before its fix.
- **Commands:**
- `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`:
133/133 tasks pass.
- `pnpm exec turbo run test` for `@bb/file-transfer` (7),
`@bb/host-daemon-contract` (76), `@bb/host-daemon` (833, 12 skipped) and
`@bb/server` (3655 of 3656). The one server failure is a timeout in
`builtin-plugins.test.ts`, which nothing on this branch touches. A
different test in that file timed out on each full run, both under heavy
machine load, and that file's 28 tests pass when run alone.
- **Manual:** a `pnpm start:worktree` instance with a fixture project,
checked by a script of 24 CLI/API checks, all passing:
  - symlinked skill reads, the 27 MB → 413 case, rejected paths;
- daemon- and server-saved skills: fresh save lands, stale save returns
409, no temp files left behind;
  - `bb file write`: unconditional, stale hash, read-only folder;
  - the umask and long-filename cases.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: review <review@local>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Imported symlinked skills are listed but their details and files fail to load

2 participants