[GH-ISSUE #5492] Staging Engines should read the catalog preview overlay so staging-only packages reach testers #3052

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

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

Originally assigned to: @kolacheee on GitHub.

The catalog repo shipped a two-tier system for holding packages back (Marinara-Agents #410 / PR #411). The Engine half was always meant to be a separate PR here, and it has not been written yet — so one of the two tiers currently does nothing useful.

What works today and what doesn't

INCOMPLETE_PACKAGE_IDS works fine: those packages are dropped from every catalog at generation time, so no Engine on any channel ever sees them. That is how Pixelforge is hidden right now, and I verified it is genuinely absent from all four published lanes on both branches.

STAGING_ONLY_PACKAGE_IDS is meant to be "testers can install it, stable users can't." Those packages are cut from the published lanes and written to a preview overlay at catalog/preview/v{major}/catalog.json (plus a legacy alias at catalog/preview/catalog.json, mirroring the published layout). But nothing in the Engine has ever heard of that path — git grep -i preview packages/server/src/services/capability-packages returns nothing. So a staging-only package is hidden from staging users too, making the tier equivalent to the incomplete tier.

Net effect: a package author who wants to ship to testers but not to stable has no working option. They either expose it to everyone or to nobody.

What needs to happen

A staging-channel Engine should fetch the overlay and merge it over the published catalog. A stable Engine must never request it.

Worth being explicit about why this cannot be solved on the catalog side: promotion is a wholesale staging → main byte-copy merge, so catalog/preview/ will exist on main, and the matching artifacts will exist under main/artifacts/. Both will return 200. Nothing server-side hides them. The entire containment guarantee is the Engine declining to construct that URL.

Things that will bite whoever implements this

These came out of tracing the current code, and each one is a real hazard rather than a style preference.

1. The legacy auto-install migration will mass-install everything in the merged catalog. This is the big one. migrateLegacyAvailability (packages/server/src/services/capability-packages/package-manager.service.ts:919-924) loops the entire catalog and calls installCatalogPackage(entry, true) on every entry, unattended, at startup, with activation on:

const catalog = await this.catalog();
const installedById = new Map((await this.installed()).map((item) => [item.id, item]));
for (const entry of catalog.packages) {
  if (installedById.get(entry.manifest.id)?.version === entry.manifest.version) continue;
  await installCatalogPackage(entry, true);
}

If the overlay is merged into catalog() without thought, every upgrading staging profile silently installs and activates every unfinished package. Preview entries need to be excluded from this path (and from migrateExtractedNoodleAvailability just below it) — or the merge has to happen somewhere narrower than catalog().

2. The channel classifier is deny-list shaped and will misfire. resolveOfficialAgentBranch (:86-96) returns main only for a falsy branch, literally "main", hotfix/*, or a canonical vX.Y.Z tag — everything else returns staging. A checkout on a branch named master resolves to staging, and the launchers explicitly treat master as a mainline name (start.bat sets ALLOW_DETACHED_FALLBACK for it). Reusing this function as the preview gate hands the overlay to anyone on an unusual branch name.

For the existing use this is harmless — a stable-ish user getting the staging catalog just sees a slightly newer package list. For the preview gate it is a leak. The preview gate should be stricter: an exact match on staging, ideally with the detached-HEAD ancestry probe that getUpdateChannelForCheckout (packages/server/src/routes/updates.routes.ts:186-191) already uses for the update channel. Note that one is async and module-private while CATALOG_URL is a module-load constant, so this needs a small restructure rather than a drop-in call.

3. Derive the overlay URL, do not string-patch it. The overlay URL should be produced by a function that returns null when the channel is not staging, so on a stable Engine there is no URL in existence to accidentally fetch. Please do not implement it by inserting /preview into CATALOG_URL — that turns a channel bug into a leak. It also needs to mirror the published derivation exactly, including the non-release-version fallback to the legacy alias.

4. A 404 is the normal steady state and must stay silent. With STAGING_ONLY_PACKAGE_IDS empty (its current state), the overlay does not exist. I confirmed live that raw.githubusercontent.com answers those paths with 404 and Content-Type: text/plain; charset=utf-8. Since safeFetch rejects a disallowed content type before the caller sees the status (packages/server/src/lib/security.ts:680-686), an overlay fetch that narrows allowedContentTypes to application/json will throw on every startup. The overlay fetch must catch, log at debug, and degrade to published-only — never propagate. Today catalog() is a single uncached fetch with no stale fallback, and any throw there 500s the Agents browser entirely.

5. Carry the tier by file path, not by a new field. The shared catalog schema is .strict() per entry, so adding a marker field to the published lane would break parsing on older installs. parseCapabilityCatalogWithCompat (added in #5091, present in 2.4.3) makes this per-entry tolerant on current releases, but installs at 2.4.2 and earlier still parse the whole array strictly. The Engine should mark an entry as preview-sourced based on which URL it came from.

6. Artifact validation already works — do not "fix" it. getOfficialAgentBranchFromCatalogUrl (:406-411) is a prefix test, so .../staging/catalog/preview/v2/catalog.json correctly resolves to branch staging and the artifact assertion accepts .../staging/artifacts/{id}-{version}.zip. No change needed. The corollary for the catalog repo: staging-only artifacts must stay at the flat artifacts/ root, since the URL rewrite would discard an artifacts/preview/... path.

7. Merge semantics worth pinning down. Published-wins on an id collision (drop the overlay copy and warn, rather than rejecting the whole catalog); re-sort the merged list, since the client does not sort; keep the published generatedAt.

8. isOfficialCatalogUrl accepts a preview URL on main. The regex at :112 matches /^\/Pasta-Devs\/Marinara-Agents\/(?:main|staging)\/catalog(?:\/|$)/u, which happily accepts .../main/catalog/preview/.... Not currently reachable, since nothing constructs that URL — but it means this function is not the thing protecting stable users, and it would stop being harmless if combined with a MARINARA_AGENT_CATALOG_URL override. Tightening it is cheap defense in depth.

Try it yourself

Current behavior, no build needed:

curl -s -o /dev/null -w "%{http_code}\n" https://raw.githubusercontent.com/Pasta-Devs/Marinara-Agents/staging/catalog/preview/v2/catalog.json

404, because no package is marked staging-only yet. To see the gap, add any package id to STAGING_ONLY_PACKAGE_IDS in the catalog repo's scripts/catalog-incomplete.mjs, rebuild that package, and confirm it vanishes from Agents → Download Agents on a staging Engine as well as a stable one. That second disappearance is the bug.

Suggested regression

The Engine has a scripts/regressions/ lane. A regression here should assert that a main-channel Engine never produces a preview URL (including for master, release/*, and detached tag checkouts), that a staging Engine does, and that a 404 overlay degrades to the published catalog without throwing.

Not urgent, but blocking a real request

Nothing is broken today — the tier is inert, and inertness is the safe direction. But contributors are already asking how to list a package for testers only, and right now the honest answer is that they cannot.

Originally created by @kolacheee on GitHub (Aug 24, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5492 Originally assigned to: @kolacheee on GitHub. The catalog repo shipped a two-tier system for holding packages back (Marinara-Agents #410 / PR #411). The Engine half was always meant to be a separate PR here, and it has not been written yet — so one of the two tiers currently does nothing useful. ## What works today and what doesn't `INCOMPLETE_PACKAGE_IDS` works fine: those packages are dropped from every catalog at generation time, so no Engine on any channel ever sees them. That is how Pixelforge is hidden right now, and I verified it is genuinely absent from all four published lanes on both branches. `STAGING_ONLY_PACKAGE_IDS` is meant to be "testers can install it, stable users can't." Those packages are cut from the published lanes and written to a **preview overlay** at `catalog/preview/v{major}/catalog.json` (plus a legacy alias at `catalog/preview/catalog.json`, mirroring the published layout). But nothing in the Engine has ever heard of that path — `git grep -i preview packages/server/src/services/capability-packages` returns nothing. So a staging-only package is hidden from staging users too, making the tier equivalent to the incomplete tier. Net effect: a package author who wants to ship to testers but not to stable has no working option. They either expose it to everyone or to nobody. ## What needs to happen A staging-channel Engine should fetch the overlay and merge it over the published catalog. A stable Engine must never request it. Worth being explicit about why this cannot be solved on the catalog side: promotion is a wholesale `staging` → `main` byte-copy merge, so `catalog/preview/` **will** exist on `main`, and the matching artifacts **will** exist under `main/artifacts/`. Both will return 200. Nothing server-side hides them. The entire containment guarantee is the Engine declining to construct that URL. ## Things that will bite whoever implements this These came out of tracing the current code, and each one is a real hazard rather than a style preference. **1. The legacy auto-install migration will mass-install everything in the merged catalog.** This is the big one. `migrateLegacyAvailability` (`packages/server/src/services/capability-packages/package-manager.service.ts:919-924`) loops the entire catalog and calls `installCatalogPackage(entry, true)` on every entry, unattended, at startup, with activation on: ```ts const catalog = await this.catalog(); const installedById = new Map((await this.installed()).map((item) => [item.id, item])); for (const entry of catalog.packages) { if (installedById.get(entry.manifest.id)?.version === entry.manifest.version) continue; await installCatalogPackage(entry, true); } ``` If the overlay is merged into `catalog()` without thought, every upgrading staging profile silently installs and activates every unfinished package. Preview entries need to be excluded from this path (and from `migrateExtractedNoodleAvailability` just below it) — or the merge has to happen somewhere narrower than `catalog()`. **2. The channel classifier is deny-list shaped and will misfire.** `resolveOfficialAgentBranch` (`:86-96`) returns `main` only for a falsy branch, literally `"main"`, `hotfix/*`, or a canonical `vX.Y.Z` tag — **everything else returns `staging`**. A checkout on a branch named `master` resolves to staging, and the launchers explicitly treat `master` as a mainline name (`start.bat` sets `ALLOW_DETACHED_FALLBACK` for it). Reusing this function as the preview gate hands the overlay to anyone on an unusual branch name. For the existing use this is harmless — a stable-ish user getting the staging *catalog* just sees a slightly newer package list. For the preview gate it is a leak. The preview gate should be stricter: an exact match on `staging`, ideally with the detached-HEAD ancestry probe that `getUpdateChannelForCheckout` (`packages/server/src/routes/updates.routes.ts:186-191`) already uses for the update channel. Note that one is async and module-private while `CATALOG_URL` is a module-load constant, so this needs a small restructure rather than a drop-in call. **3. Derive the overlay URL, do not string-patch it.** The overlay URL should be produced by a function that returns `null` when the channel is not staging, so on a stable Engine there is no URL in existence to accidentally fetch. Please do not implement it by inserting `/preview` into `CATALOG_URL` — that turns a channel bug into a leak. It also needs to mirror the published derivation exactly, including the non-release-version fallback to the legacy alias. **4. A 404 is the normal steady state and must stay silent.** With `STAGING_ONLY_PACKAGE_IDS` empty (its current state), the overlay does not exist. I confirmed live that raw.githubusercontent.com answers those paths with **`404` and `Content-Type: text/plain; charset=utf-8`**. Since `safeFetch` rejects a disallowed content type before the caller sees the status (`packages/server/src/lib/security.ts:680-686`), an overlay fetch that narrows `allowedContentTypes` to `application/json` will throw on every startup. The overlay fetch must catch, log at debug, and degrade to published-only — never propagate. Today `catalog()` is a single uncached fetch with no stale fallback, and any throw there 500s the Agents browser entirely. **5. Carry the tier by file path, not by a new field.** The shared catalog schema is `.strict()` per entry, so adding a marker field to the published lane would break parsing on older installs. `parseCapabilityCatalogWithCompat` (added in #5091, present in 2.4.3) makes this per-entry tolerant on current releases, but installs at 2.4.2 and earlier still parse the whole array strictly. The Engine should mark an entry as preview-sourced based on which URL it came from. **6. Artifact validation already works — do not "fix" it.** `getOfficialAgentBranchFromCatalogUrl` (`:406-411`) is a prefix test, so `.../staging/catalog/preview/v2/catalog.json` correctly resolves to branch `staging` and the artifact assertion accepts `.../staging/artifacts/{id}-{version}.zip`. No change needed. The corollary for the catalog repo: staging-only artifacts must stay at the flat `artifacts/` root, since the URL rewrite would discard an `artifacts/preview/...` path. **7. Merge semantics worth pinning down.** Published-wins on an id collision (drop the overlay copy and warn, rather than rejecting the whole catalog); re-sort the merged list, since the client does not sort; keep the published `generatedAt`. **8. `isOfficialCatalogUrl` accepts a preview URL on main.** The regex at `:112` matches `/^\/Pasta-Devs\/Marinara-Agents\/(?:main|staging)\/catalog(?:\/|$)/u`, which happily accepts `.../main/catalog/preview/...`. Not currently reachable, since nothing constructs that URL — but it means this function is not the thing protecting stable users, and it would stop being harmless if combined with a `MARINARA_AGENT_CATALOG_URL` override. Tightening it is cheap defense in depth. ## Try it yourself Current behavior, no build needed: ```bash curl -s -o /dev/null -w "%{http_code}\n" https://raw.githubusercontent.com/Pasta-Devs/Marinara-Agents/staging/catalog/preview/v2/catalog.json ``` 404, because no package is marked staging-only yet. To see the gap, add any package id to `STAGING_ONLY_PACKAGE_IDS` in the catalog repo's `scripts/catalog-incomplete.mjs`, rebuild that package, and confirm it vanishes from **Agents → Download Agents** on a staging Engine as well as a stable one. That second disappearance is the bug. ## Suggested regression The Engine has a `scripts/regressions/` lane. A regression here should assert that a main-channel Engine never produces a preview URL (including for `master`, `release/*`, and detached tag checkouts), that a staging Engine does, and that a 404 overlay degrades to the published catalog without throwing. ## Not urgent, but blocking a real request Nothing is broken today — the tier is inert, and inertness is the safe direction. But contributors are already asking how to list a package for testers only, and right now the honest answer is that they cannot.
Author
Owner

@kolacheee commented on GitHub (Aug 24, 2026):

Picked this up — draft PR #5493 (fix/5492-preview-catalog-overlay → staging) is open so the board shows it in progress. Owner: @kolacheee.

It implements the gate as an allow-list (exact staging) rather than reusing resolveOfficialAgentBranch, excludes the two unattended startup migrations from the overlay, and degrades silently on a missing or broken overlay. Item 8 (isOfficialCatalogUrl accepting a preview path) is deliberately left alone — reasoning in the PR description.

Still needs manual verification on a real staging and a real stable Engine before it leaves draft.

<!-- gh-comment-id:5399746829 --> @kolacheee commented on GitHub (Aug 24, 2026): Picked this up — draft PR #5493 (`fix/5492-preview-catalog-overlay` → `staging`) is open so the board shows it in progress. Owner: @kolacheee. It implements the gate as an allow-list (exact `staging`) rather than reusing `resolveOfficialAgentBranch`, excludes the two unattended startup migrations from the overlay, and degrades silently on a missing or broken overlay. Item 8 (`isOfficialCatalogUrl` accepting a preview path) is deliberately left alone — reasoning in the PR description. Still needs manual verification on a real staging and a real stable Engine before it leaves draft.
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#3052
No description provided.