mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5087] [MERGED] fix(capability-packages): ETag + 304 for package delivery; immutable version-pinned assets #6621
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6621
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5087
Author: @kolacheee
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5082-capability-package-cache📝 Commits (7)
266d3e1Merge pull request #5020 from Pasta-Devs/staging9ce7528Merge upstream Pasta-Devs/Marinara-Engine staging (through #5068) into main37e835ffix(capability-packages): cache validators for package delivery — ETag + 304, immutable pinned assets (#5082)2027142Merge remote-tracking branch 'upstream/staging' into fix/5082-capability-package-cache5f7f666test(capability-packages): assert nosniff survives the 304 early return29c61fdMerge remote-tracking branch 'upstream/staging' into fix/5082-capability-package-cachea4d9399fix(capability-packages): route-scoped rate limit for package file serving📊 Changes
6 files changed (+287 additions, -12 deletions)
View changed files
📝
docs/development/optional-agent-packages.md(+10 -0)📝
package.json(+2 -1)📝
packages/server/src/middleware/rate-limit.ts(+9 -0)📝
packages/server/src/routes/capability-packages.routes.ts(+52 -10)📝
packages/server/src/services/capability-packages/package-manager.service.ts(+10 -1)➕
scripts/regressions/capability-package-cache.regression.ts(+204 -0)📄 Description
Closes #5082
Why
Every installed Agent package's client bundle is fully re-downloaded on every app load:
/api/capability-packages/:id/clientsendsCache-Control: no-cache, must-revalidatewith noETag/Last-Modified, so the browser has nothing to revalidate against and must re-fetch the whole body each time. For anyone with World Maps installed that's the full hierarchical-maps bundle on every app open — on phones too — and it makes bundle size a per-boot tax for any future package that ships more client code or art (e.g. a game-surface Experience).The fix costs no freshness: every served package file already has a trusted content hash in
manifest.files[](the serve path re-verifies the bytes against it on every read), which is a perfect strong ETag.What changed
packages/server/src/services/capability-packages/package-manager.service.ts:clientEntrypoint()andbrowserTabAsset()now also return the manifest-declaredsha256for the served file (the declaration they already locate; no new lookups, no behavior change).packages/server/src/routes/capability-packages.routes.ts:GET /:id/client— sendsETag: "<manifest sha256>"and answers a matchingIf-None-Matchwith304. Cache-Control staysno-cache, must-revalidate— deliberately notimmutableeven though the URL carries?v=: a package author (or the catalog) can republish the same version string with different bytes during development, and an immutable client bundle would pin the stale copy with no eviction short of a hard reload.no-cache+ ETag keeps "always revalidate" while making the revalidation answer304instead of re-sending the body.GET /:id/assets/*— same ETag +304support; additionally, when the request carries?v=equal to the installed version, the response ispublic, max-age=31536000, immutable(path + version + manifest hash pin the exact bytes). Requests without the pin keep today'sprivate, no-cache, must-revalidatebyte-for-byte.X-Content-Type-Options: nosniffretained on all responses, including304s.scripts/regressions/capability-package-cache.regression.ts(wired asregression:capability-cache, included inregression:issues): 200-with-ETag,304on exact/weak/listIf-None-Match, full body on mismatch, a different validator after a version update (stale validator must not mask a new bundle), immutable-only-when-pinned asset behavior, and the preserved 404s for unknown packages / undeclared assets.docs/development/optional-agent-packages.md: short "Delivery and caching" note.No client changes: the dynamic
import()inuse-capability-packages.tsrides the normal browser HTTP cache (it already appends?v=<version>, so the cache key was correct all along), and a304revalidation is transparent to it — pinned by the existing capability-client-version-refresh regression.No storage-format change (HTTP headers only). Root
package.jsondiff touchesscriptsonly;pnpm version:checkpasses.Validation
pnpm checkpnpm regression:capability-cache(new)regression:issues)pnpm regression:static-cache(client-static header contract untouched)pnpm version:check200with anETag; a reload sendsIf-None-Matchand gets304with no body; installing a package update returns200with a differentETagand the new bundle hot-swaps as before.Docs note: the
docs/development/optional-agent-packages.mdedit needs a docs-i18n mirror — intended to be batched into the pending round-8 catch-up rather than a standalone[docs-i18n]issue.Summary by CodeRabbit
New Features
304 Not Modifiedresponses.Bug Fixes
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.