[GH-ISSUE #4720] [Feature]: Attributed fetch + per-extension traffic visibility for full-page personal extensions #2591

Closed
opened 2026-10-21 05:50:52 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Aug 7, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4720

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

In #4703, a phone-hosted instance served ~204 requests/min (multi-GB/hour) for two hours-plus, and the source was only identifiable by downloading and dissecting a 266 MB HAR: a full-page personal extension (a memo/notes board) was re-scanning every chat's messages (GET /chats/<id>/messages?limit=100 × 18 chats, back-to-back sweeps with ~0.15 s pause between sweeps) and its traffic was indistinguishable from Marinara's own.

The full-page tier is an explicit "fully trust" grant, and that's the right model — but trust covers intent, not bugs. The memo extension's author almost certainly never intended an unthrottled full-table rescan; the user had no way to see that an extension was responsible (nothing in the UI attributes traffic), and the symptom presented as "Marinara drains my battery / eats my data plan," landing on this issue tracker.

Mechanically, the gap is visible in the injector: full-page extensions receive a frozen host API (__marinaraRunFullPageExtension → FullPageExtensionApi in packages/client/src/components/layout/PersonalExtensionInjector.tsx) that provides attributed storage, logging, and managed timers — but no fetch. Extensions reach the API through the page's raw window.fetch, so nothing counts, attributes, or bounds their requests.

Proposed solution

Layered visibility first, enforcement only where it doesn't break the trust model:

  1. Attributed api.fetch on the full-page host API. Extend the existing frozen FullPageExtensionApi with a fetch that wraps window.fetch, tagging and counting requests (count + transferred bytes) per extension id — same pattern as the API's managed setTimeout/setInterval. Extension-authoring docs should present it as the expected way to call the local API (raw window.fetch keeps working; full-page code can always reach it — this is visibility, not a jail).
  2. Per-extension traffic counters in the UI. Show request count / bytes (session totals and a recent-rate figure) per extension in Settings → Personal Extensions, next to the existing enable toggles. A sustained-high-rate badge (e.g. > 60 req/min for several minutes) turns "my phone is warm" into "the memo extension made 12,000 requests this hour" — the diagnosis in #4703 took a 266 MB HAR; this makes it one glance.
  3. Server-side anomaly notice (stretch, catches raw-fetch extensions too). The server already knows request rates per route; a cheap counter on the heavy read endpoints (message lists) that logs a warning — and optionally surfaces a one-time client toast — when a single client sustains a pathological read rate (e.g. > 100 message-list reads/min for 5+ minutes), with wording that points at personal extensions as a likely cause. This is attribution-free, so it works even for extensions that bypass api.fetch, and it is a diagnosis aid rather than a limiter.

Explicitly not proposed: hard rate limits on full-page extensions. Their fetches are same-origin page fetches — indistinguishable from the app's own without cooperation — and the tier's consent screen already frames it as full trust. The #4703 failure was invisibility, not malice; bounding a trusted-but-buggy extension is the extension author's fix once the user can see the problem.

Alternatives considered

  • Hard per-extension budgets enforced by the host: only enforceable for code that cooperates (uses api.fetch); a non-cooperating script escapes to window.fetch, so enforcement would give false confidence while breaking legitimate bursty extensions. Visibility gets ~all of the value with none of the false promises.
  • Moving chat/message reads into a capability-gated host API (like the sandboxed tier's context snapshots): architecturally cleanest, but it's a breaking change for every existing full-page extension and a much bigger project than this problem needs.
  • Doing nothing (status quo): the next runaway extension lands as another multi-week "Marinara drains my battery" investigation. #4629 (the runtime's own 2 s poll) and #4703 (this) suggest extension-adjacent traffic already has a track record.

Additional context

  • Root-cause analysis with the HAR breakdown: https://github.com/Pasta-Devs/Marinara-Engine/issues/4703#issuecomment-5219132238 (24 sweeps × 18 chats in 125 s; bracketed by GET/PATCH /api/personal-extensions/<id>/storage).
  • The sandboxed browser tier is unaffected (opaque-origin iframe, no network); the server tier is OS-sandboxed without network. This is specifically about the full-page tier.
  • Related history: #4629 (extension runtime polling), #4628/#4630 (battery investigation the reporter's symptom initially landed in).

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kolacheee on GitHub (Aug 7, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4720 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? In #4703, a phone-hosted instance served ~204 requests/min (multi-GB/hour) for two hours-plus, and the source was only identifiable by downloading and dissecting a 266 MB HAR: a **full-page personal extension** (a memo/notes board) was re-scanning every chat's messages (`GET /chats/<id>/messages?limit=100` × 18 chats, back-to-back sweeps with ~0.15 s pause between sweeps) and its traffic was indistinguishable from Marinara's own. The full-page tier is an explicit "fully trust" grant, and that's the right model — but trust covers *intent*, not *bugs*. The memo extension's author almost certainly never intended an unthrottled full-table rescan; the user had no way to see that an extension was responsible (nothing in the UI attributes traffic), and the symptom presented as "Marinara drains my battery / eats my data plan," landing on this issue tracker. Mechanically, the gap is visible in the injector: full-page extensions receive a frozen host API (`__marinaraRunFullPageExtension` → `FullPageExtensionApi` in `packages/client/src/components/layout/PersonalExtensionInjector.tsx`) that provides attributed **storage, logging, and managed timers** — but no fetch. Extensions reach the API through the page's raw `window.fetch`, so nothing counts, attributes, or bounds their requests. ## Proposed solution Layered visibility first, enforcement only where it doesn't break the trust model: 1. **Attributed `api.fetch` on the full-page host API.** Extend the existing frozen `FullPageExtensionApi` with a `fetch` that wraps `window.fetch`, tagging and counting requests (count + transferred bytes) per extension id — same pattern as the API's managed `setTimeout`/`setInterval`. Extension-authoring docs should present it as the expected way to call the local API (raw `window.fetch` keeps working; full-page code can always reach it — this is visibility, not a jail). 2. **Per-extension traffic counters in the UI.** Show request count / bytes (session totals and a recent-rate figure) per extension in Settings → Personal Extensions, next to the existing enable toggles. A sustained-high-rate badge (e.g. > 60 req/min for several minutes) turns "my phone is warm" into "the memo extension made 12,000 requests this hour" — the diagnosis in #4703 took a 266 MB HAR; this makes it one glance. 3. **Server-side anomaly notice (stretch, catches raw-fetch extensions too).** The server already knows request rates per route; a cheap counter on the heavy read endpoints (message lists) that logs a warning — and optionally surfaces a one-time client toast — when a single client sustains a pathological read rate (e.g. > 100 message-list reads/min for 5+ minutes), with wording that points at personal extensions as a likely cause. This is attribution-free, so it works even for extensions that bypass `api.fetch`, and it is a diagnosis aid rather than a limiter. Explicitly **not** proposed: hard rate limits on full-page extensions. Their fetches are same-origin page fetches — indistinguishable from the app's own without cooperation — and the tier's consent screen already frames it as full trust. The #4703 failure was invisibility, not malice; bounding a trusted-but-buggy extension is the extension author's fix once the user can see the problem. ## Alternatives considered - **Hard per-extension budgets enforced by the host**: only enforceable for code that cooperates (uses `api.fetch`); a non-cooperating script escapes to `window.fetch`, so enforcement would give false confidence while breaking legitimate bursty extensions. Visibility gets ~all of the value with none of the false promises. - **Moving chat/message reads into a capability-gated host API** (like the sandboxed tier's context snapshots): architecturally cleanest, but it's a breaking change for every existing full-page extension and a much bigger project than this problem needs. - **Doing nothing** (status quo): the next runaway extension lands as another multi-week "Marinara drains my battery" investigation. #4629 (the runtime's own 2 s poll) and #4703 (this) suggest extension-adjacent traffic already has a track record. ## Additional context - Root-cause analysis with the HAR breakdown: https://github.com/Pasta-Devs/Marinara-Engine/issues/4703#issuecomment-5219132238 (24 sweeps × 18 chats in 125 s; bracketed by `GET/PATCH /api/personal-extensions/<id>/storage`). - The sandboxed browser tier is unaffected (opaque-origin iframe, no network); the server tier is OS-sandboxed without network. This is specifically about the full-page tier. - Related history: #4629 (extension runtime polling), #4628/#4630 (battery investigation the reporter's symptom initially landed in). ## Template check - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 7, 2026):

SpicyMarinara/Codex is implementing this in draft PR #4736 on agent/assigned-issues-4718-4734.

<!-- gh-comment-id:5222378179 --> @SpicyMarinara commented on GitHub (Aug 7, 2026): SpicyMarinara/Codex is implementing this in draft PR #4736 on `agent/assigned-issues-4718-4734`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2591
No description provided.