Skip to content

Data Liberation: Budget portable media from the remaining artifact capacity - #4675

Merged
chubes4 merged 1 commit into
feat/site-artifact-import-clifrom
fix/dla-portable-media-budget
Aug 26, 2026
Merged

Data Liberation: Budget portable media from the remaining artifact capacity#4675
chubes4 merged 1 commit into
feat/site-artifact-import-clifrom
fix/dla-portable-media-budget

Conversation

@aagam-shah

Copy link
Copy Markdown
Contributor

What

The capture export now budgets portable media from the capacity left under the artifact limit, instead of a fixed 160 MiB that ignores everything else in the artifact.

Why

Routes, captured render dependencies, and reports share the 192 MiB artifact with media. The export selected media against its own cap only, so a media-heavy capture could pass selection and then throw "Portable capture exceeds compiler limits" while writing artifact.json. That discards the whole capture instead of degrading.

Now the export reserves the staged route HTML, the captured non-script resources, and the report files already on disk, and gives media only what is left (still capped at 160 MiB). Media that does not fit is retained external, as before. The receipt reports the effective max_bytes and the reserved_bytes behind it.

ExportCaptureOptions.limits lets a caller or a test override the limits without touching the defaults.

Re-exporting a real 28-page Wix capture selects the same 167 files (24.3 MB) with 145 MB reserved and a 56 MB media budget; the artifact is byte-for-byte the same size.

How to test

  • cd packages/data-liberation-agent && npx vitest run src/lib/capture-export.test.ts (new test: "keeps portable media within the artifact capacity left after routes and resources")
  • Check capture-receipt.jsonportableMedia.reserved_bytes after a studio create --from <url>.

Bundles were rebuilt from this source.

Part of the studio create --from work in #3952.

AI assistance: Claude Code (Claude Fable 5) found the budget gap and drafted the change. Aagam Shah directed the work and is responsible for it.

🤖 Generated with Claude Code

The export selected portable media against its own 160 MiB cap without
knowing how many bytes the routes, captured render dependencies, and
reports already take. On a 28-page Wix capture the media filled that cap
and the artifact writer then threw "Portable capture exceeds compiler
limits" against the 192 MiB total, discarding a three-minute capture
instead of degrading.

Reserve the staged route HTML, the captured non-script resources, and the
report files that already exist on disk, and give media only what is left
under the artifact limit (still capped at 160 MiB). The reservation is an
upper bound: media that does not fit is retained external, as before,
rather than failing the export. The receipt reports the effective
`max_bytes` and the `reserved_bytes` behind it, and the artifact header
carries the effective total limit.

`ExportCaptureOptions.limits` lets a caller (and the test) override the
artifact and media limits without touching the compiler defaults.

Re-exporting the same Wix capture selects the same 167 files (24.3 MB)
with 145 MB reserved and a 56 MB media budget; the artifact is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@aagam-shah

Copy link
Copy Markdown
Contributor Author

Note on CI: the red "Unit Tests" job is inherited from the base branch. PR #3952's own build (buildkite 21303) fails the same job, and the failing suites are all in apps/studio and packages/ui (15 files, 104 tests locally on the untouched base). "Data Liberation" and "Lint" pass here.

@chubes4
chubes4 merged commit 95d781c into feat/site-artifact-import-cli Aug 26, 2026
8 of 9 checks passed
@chubes4
chubes4 deleted the fix/dla-portable-media-budget branch August 26, 2026 02:04
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.

2 participants