Skip to content

Remove the 10 MiB skill-tree byte limit for skills with supporting assets - #6267

Merged
ymichael merged 2 commits into
get-bb:mainfrom
artwist-polyakov:bb/remove-skill-tree-byte-limit
Oct 26, 2026
Merged

ymichael merged 2 commits into
get-bb:mainfrom
artwist-polyakov:bb/remove-skill-tree-byte-limit

Conversation

@artwist-polyakov

@artwist-polyakov artwist-polyakov commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

A skill folder larger than 10 MiB could prevent every thread from starting, even when most of its size was supporting assets rather than instructions. The server included the skill in the catalog, but the daemon rejected the required tree with Skill tree exceeds max byte count 10485760. Registry installation separately rejected the same folders with Skill tree exceeds installation limits.

What changed

  • Remove the whole-folder byte cap from daemon skill collection, streamed manifest validation, and server registry installation.
  • Preserve file-count, directory-count, depth, path, symlink, and content-integrity checks. Instruction-file read limits are unchanged.
  • Apply the fix on top of Transfer skill trees by manifest, fetching only missing files #6330's streamed transfers. Large skills still cost disk space, hashing time, and bandwidth; this change does not impose a replacement byte budget.
  • Bump the host daemon protocol from 253 to 254 so connected machines update instead of continuing to reject oversized skills.

How you verified

  • Reproduced the streamed-tree regression against current main: an 11 MiB asset failed with Skill tree exceeds max byte count 10485760. The same regression passes with this change and verifies the complete staged bytes.
  • Added registry installation coverage for an 11 MiB supporting asset.
  • Verified through the isolated worktree app with a real Codex thread: the original failure is visible in its history, and the updated streaming implementation completes a new turn with STREAMING_OK. The staged asset is 11,534,336 bytes and its SHA-256 matches the source.
  • Host daemon tests: 76 files, 841 passed, 12 skipped. Host daemon contract tests: 5 files, 77 passed.
  • Focused server skills, public project skills, and internal skill-tree tests: 9 files, 133 passed.
  • Turbo typechecks for the server, daemon, and daemon contract pass. Production worktree build, formatting checks, and git diff --check pass.

Fixes #6240

AGENT GENERATED

…sets

Supporting assets are staged to disk and read on demand, not sent to the
model, yet the host daemon rejected any skill tree over 10 MiB. User,
plugin and built-in skills arrive as required trees, so one large skill
failed every thread start and turn, and bb skill install refused the
same skills. The file-count and depth limits stay.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-25T12:13:33.001311Z 8728680 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

ymichael added a commit that referenced this pull request Oct 26, 2026
## Human comments

## What was wrong

Server-owned skills (global, plugin and built-in) went to the host
daemon as one JSON document with every file base64-encoded. The server
re-read the tree, and the daemon parsed, decoded, hashed and rewrote it,
holding the whole tree in memory at each step. The daemon also kept a
per-tree cache of file contents with no byte budget. Any edit, even one
line of SKILL.md, re-sent the entire tree including large assets. The
server computed tree hashes by synchronously reading every file on each
thread start and turn submit.

Follows #6332 (merged), which added attachment streaming and the shared
`verified-file-transfer.ts` helper. This PR covers only the skill-tree
transfer and extends that helper.

## What changed

- **Contract (`HOST_DAEMON_PROTOCOL_VERSION` 252 → 253):**
- The tree hash is now v2: sha256 over each file's path, mode, size and
content sha256, defined once in `@bb/host-daemon-contract/skill-tree`
for both server and daemon.
- `GET /internal/skills/tree/:hash` returns a manifest (path, mode,
size, sha256 per file).
- New `POST /internal/skills/tree/:hash/content` streams the requested
files back to back. The base64 tree response is removed.
- **Server:**
- `SkillTreeRegistry.readTree` hashes files asynchronously with streamed
reads. If a file changes while it is being hashed, it retries up to 3
times and takes size and mode from the stat the hash matched.
- It keeps metadata-only manifests by hash. A root's previous hash is
dropped when its content changes.
- The content route refuses (404) any file whose stat changed since it
was hashed.
- There is deliberately no per-file hash cache. It saved about 20 ms per
resolution for 36 MiB of skills, and about 1–2 ms at typical sizes, and
its invalidation was the most error-prone part.
- **Daemon:**
- Pulls validate the manifest (hash, path safety, depth, count, 10 MiB
budget). Files the local store already has with the same sha256 are
copied and re-verified, and only the rest are downloaded, in one
streamed request.
- Each file is verified for size and sha256 and written fully. On
failure nothing is published and partial files are removed.
- Stored trees keep a `manifest.json`. The collected-tree cache holds
metadata only, bounded by tree and file counts.
- Staging copies from disk with verification. The source is opened
lazily, so a missing file can't surface as an unhandled stream error.
Staging retries up to 3 times if a host source changes mid-stage.
- **Unchanged on purpose:** the daemon's 10 MiB per-skill limit (#6267
is where that is decided). No CLI, SDK, plugin API or config changes.

## How you verified

- **Tests:**
- Bad downloads: manifest hash mismatch, unsafe paths, wrong content,
truncated and over-long streams — each leaves nothing in the store.
- Edits and reuse: only changed files are fetched after an edit, and a
corrupted stored copy is re-downloaded.
- Concurrency and rebuild: concurrent stages pull a tree once, and the
stage rebuilds after store eviction.
- Copy safety: a missing source with a failing destination raises no
unhandled error. This test fails without the fix.
- Server routes: manifest, content and path validation, refusal of
changed files, and dropping superseded hashes.
  - Contract: v2 hash ordering and field binding.
- **Manual repro:** a 200 MiB file appended mid-hash. The old code
recorded the pre-append size; the fix records the final size.
- **Commands:** `turbo run typecheck` and `turbo run test` for
`@bb/host-daemon-contract`, `@bb/host-daemon` and `@bb/server`.
- **Benchmark:** real server on loopback HTTP plus the real daemon
client and staging code. "Before" was measured on the base commit.

  | Scenario | Before | After |
  |---|---|---|
  | 9 MiB skill, first pull, wire bytes | 12.0 MiB | 9.0 MiB |
| Same skill after a one-line SKILL.md edit, wire bytes | 12.0 MiB | ~0
|
| Skill pull, peak live heap (GC while sampling) | ≥ 24.8 MiB | 2.3 MiB
|
| Catalog resolve, 4 × 9 MiB skills | 15 ms, blocking the event loop |
23 ms, async |

- **Live run** on a `pnpm start:worktree` instance with a real Codex
thread:
  - A 9 MiB skill asset was staged with a matching sha256.
- After a SKILL.md edit and a follow-up turn, the daemon logged 1 file
downloaded (182 bytes) and 1 reused.

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

> AGENT GENERATED

---------

Co-authored-by: review <review@local>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit dbb5945 into get-bb:main Oct 26, 2026
49 checks passed
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.

Remove the hard-coded 10 MiB skill-tree limit for skills with supporting assets

2 participants