Repository navigation
feat(cli): enforce sandboxed plugin bundle size caps - #978
Conversation
Replaces the 5MB single-cap check with the three-cap enforcement from RFC 0001 §"Bundle size limits": total decompressed ≤ 256 KB, per-file decompressed ≤ 128 KB, and at most 20 files. Both the `bundle` command and the `publish` command now run the same validator, so a publisher hits the cap locally before the aggregator rejects the release at ingest. The publish-side fetch buffer drops from 5 MB to 384 KB (decompressed cap + tar headers + worst-case gzip overhead). The fetch error tells the user the gzipped fetch cap *and* the decompressed cap they actually need to satisfy, so retries aim at the right number. The tar entry filter uses `header.type === "file"` rather than a trailing-slash heuristic, matching what the staging-dir walk does (`item.isFile()`) and excluding symlinks/hardlinks/devices/ fifos from the file count. Mirrored into the legacy core CLI copy until phase 1 cutover.
🦋 Changeset detectedLatest commit: f4f27f6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-perf-coordinator | f4f27f6 | May 10 2026, 04:22 PM |
PR template validation failedPlease fix the following issues by editing your PR description:
See CONTRIBUTING.md for the full contribution policy. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-i18n | f4f27f6 | May 10 2026, 04:22 PM |
Scope checkThis PR changes 607 lines across 8 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | f4f27f6 | May 10 2026, 04:23 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | f4f27f6 | May 10 2026, 04:23 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | f4f27f6 | May 10 2026, 04:24 PM |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Pull request overview
This PR updates the registry CLI (and the mirrored legacy core CLI implementation) to enforce RFC 0001 sandboxed plugin bundle size limits consistently across both bundle and publish, replacing the previous single 5 MB total cap.
Changes:
- Introduces layered bundle caps (total decompressed, per-file decompressed, and file count) and a shared validation helper (
validateBundleSize) used by bothbundleandpublish. - Tightens the publish fetch buffering cap and re-validates decompressed tar entries after unpacking, with improved user-facing error messaging.
- Adds unit + integration tests (including real gzipped-tar round trips) plus a changeset documenting the breaking behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/registry-cli/tests/publish-tarball.test.ts | New integration tests that round-trip gzipped tarballs through the publish extractor and assert cap enforcement. |
| packages/registry-cli/tests/bundle-utils.test.ts | Expanded unit coverage for bundle entry collection, byte formatting, total size calculation, and cap validation behavior. |
| packages/registry-cli/src/commands/publish.ts | Enforces gzipped fetch cap, re-checks decompressed entries against RFC caps, and improves oversize error messaging. |
| packages/registry-cli/src/bundle/utils.ts | Replaces single total cap with RFC caps; adds entry collection + deterministic validation helpers and shared formatBytes. |
| packages/registry-cli/src/bundle/api.ts | Switches bundle flow from directory-total sizing to RFC cap validation over collected file entries. |
| packages/core/src/cli/commands/bundle.ts | Mirrors updated cap validation and improved bundle size logging in the legacy core CLI bundle command. |
| packages/core/src/cli/commands/bundle-utils.ts | Mirrors registry-cli bundle utils changes (RFC caps, entry collection, validation, formatting). |
| .changeset/cli-bundle-size-caps.md | Documents new caps and the intentional breaking behavior for consumers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async function buildTarball(files: Record<string, string | Uint8Array>): Promise<Uint8Array> { | ||
| for (const [name, body] of Object.entries(files)) { | ||
| const fullPath = join(stagingDir, name); | ||
| const dir = fullPath.slice(0, fullPath.lastIndexOf("/")); | ||
| if (dir !== stagingDir) await mkdir(dir, { recursive: true }); | ||
| await writeFile(fullPath, body); |
`fullPath.lastIndexOf("/")` breaks on Windows separators and returns -1
for files at the staging-dir root, in which case `slice(0, -1)` would
chop the last character off the path. `dirname()` handles both, and
`mkdir({recursive:true})` is a no-op when the directory exists, so the
extra existence check is unnecessary.
Caught by Copilot review on #978.
Catches deployment/suhail-ski up with emdash-cms/emdash main. Conflict in pnpm-lock.yaml resolved by taking upstream's lock and re-running pnpm install to pick up the @suhailski/57th-parallel template deps. Notable upstream changes folded in: - Plugin authoring CLI + manifest format (emdash-cms#1057, emdash-cms#1059) - Registry packages — lexicons, client, CLI (emdash-cms#923) - Migration 036 taxonomy preservation (emdash-cms#1086) - WXR import w/ WPML/Polylang translations (emdash-cms#1087) - TypeScript 6 upgrade, tsgo beta (emdash-cms#1074) - FTS5 corruption fix on publish (emdash-cms#768) - Plugin bundle size caps (emdash-cms#978) - And ~280 smaller fixes / chores CLI rebuilt against the new core. Verified by listing posts on suhail.ski — both tutorial posts come back as expected. 57th-parallel template untouched by upstream. Our 5 local commits preserved across the merge. Used --config.manage-package-manager-versions=false to bypass pnpm's self-switch to 11.1.3, which packages weirdly on Windows. The current shell's pnpm 10.12.4 worked fine against the merged manifests.
What does this PR do?
Implements the bundle size caps from RFC 0001 §"Bundle size limits" in the registry CLI. Replaces the existing single 5 MB total cap with three layered caps applied uniformly in both the
bundleandpublishflows:Sized against observed first-party sandboxed plugins (largest is
atprotoat ~37 KB built; most are under 20 KB) — roughly 7× headroom over real-world usage. The publish-side fetch buffer drops from 5 MB to 384 KB to fit the decompressed cap plus tar headers and worst-case gzip overhead.The publish CLI now re-validates decompressed entries against the same caps after fetching and unpacking the tarball, so a publisher hits the cap locally before the aggregator rejects the release at ingest. The fetch error tells the user both the gzipped fetch cap and the decompressed cap they actually need to satisfy, so retries aim at the right number. Tar entry filtering uses
header.type === "file"rather than a trailing-slash heuristic so symlinks/hardlinks/devices/FIFOs aren't counted toward the file cap, matching what the staging-dir walk does.Mirrored into the legacy core CLI copy (
packages/core/src/cli/commands/bundle-utils.ts+bundle.ts) until phase 1 cutover, per the in-file sync comment.Type of change
This implements the published
wip/plugin-rfcbranch's RFC 0001 §"Bundle size limits" subsection. The Discussion gate is the RFC itself.Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Test output
Notes for reviewers
The breaking-behavior side: any existing plugin between 256 KB and 5 MB that previously bundled fine will now be rejected by
bundleandpublish. The changeset calls this out. This is a deliberate cap tightening that's also the protocol contract — anything in that range would have been rejected by the aggregator at ingest anyway, so the CLI is just bringing the local-validation point in line with the published spec.Adversarial review pass run before opening; the two HIGH/MEDIUM findings (misleading fetch error, non-file filter counting symlinks) are fixed in this PR. Remaining LOW findings (empty bundle, dotfiles, fix-guidance message text) are noted but intentionally deferred — they're not regressions and not blockers per the project's review-codes-out-of-tests rule.