Skip to content

feat(prerelease): scope-gated pre-release navigator (#3168) - #3170

Merged
Thomas Jung (jung-thomas) merged 11 commits into
DEVfrom
worktree-issue-3168-prerelease-navigator
Nov 22, 2026
Merged

Thomas Jung (jung-thomas) merged 11 commits into
DEVfrom
worktree-issue-3168-prerelease-navigator

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Closes #3168. Follow-up to #3099 (Private Tutorials).

What

A scope-gated navigator so holders of the Tutorial.PreRelease XSUAA scope can browse, filter, and search pre-release (ROLE_GATED) tutorials at /tutorials-prerelease/, instead of needing a direct link per tutorial. Built on the #3099 visibility model.

How (6 tasks + a security fix)

  1. Live gated nav feed — preReleaseNavHandler (packages/content/content-store.js) at CAP /content/tutorials-prerelease/_nav, lists only ROLE_GATED tutorials via a live query (not the mission-scoped NavigatorCatalog, so standalone pre-release tutorials appear), Cache-Control: private, no-store, never uses the shared slug cache, and fail-closed (404 unless the server-side {gated:true} mount flag is set).
  2. QA-style prerelease build channel — hugo.prerelease.toml, data-prerelease/, build:prerelease, --channel prerelease filtering to ROLE_GATED; client-side search (no server search service — mirrors QA).
  3. Navigator template site.Params.prerelease branch (client-search island, Pre-release badge).
  4. Approuter routes — /tutorials-prerelease/ index + assets + _nav.json, all scoped Tutorial.PreRelease, and a scoped ^/content/tutorials-prerelease/(.*)$ route above the anonymous ^/content/(.*)$ catch-all.
  5. Deploy wiring — MTA static-shell copy (both mta.yaml files), build:prerelease in deploy-mta.cjs + CI, e2e smoke spec.

Security fix (prerequisite + pre-existing gap)

  • Public semantic_search leak (closed): the anonymous semantic endpoint returned ROLE_GATED slugs/titles/step-text to anyone (filtered only status + ContentCurrent, no visibility). Now excludes ROLE_GATED on both HANA and SQLite branches. This was a live Research "Private" Tutorials #3099 anti-goal breach, independent of this feature.
  • ⚠️ Pre-existing Research "Private" Tutorials #3099 gap this PR also closes: the anonymous ^/content/(.*)$ approuter route sat above the scoped prerelease routes, so a direct hit on /content/tutorials-prerelease/<slug> served gated tutorial bytes anonymously (and this feature's /_nav would have leaked the catalog). The new scoped ^/content/tutorials-prerelease/(.*)$ route (placed above the catch-all) closes both. Research "Private" Tutorials #3099 owners: worth confirming no other gated /content/* surface has the same exposure class.

Testing

  • Feature unit suites: 50/50 pass (gated nav incl. standalone + no-store + 404-guard; semantic ROLE_GATED exclusion both DBs; channel filter for all visibility values; verify-build prerelease marker).
  • e2e spec self-skips without smoke env (post-DEV-deploy CI).
  • Full local suite has 10 failures — all a pre-existing fresh-worktree asset-build issue (missing generated CSS → Hugo minify type error), identical on origin/DEV, untouched by this PR. CI runs them with assets built.

Follow-up notes

  • No schema change, no new XSUAA scope (reuses Research "Private" Tutorials #3099's), no new CAP app.
  • The baked prerelease static shell shares the QA channel's rebuild-wipe fragility — verify present after deploy (XSUAA-gated, so use an authenticated check / the e2e, not anonymous curl).

Design + plan: docs/superpowers/specs/2026-11-21-prerelease-navigator-design.md, docs/superpowers/plans/2026-11-21-prerelease-navigator.md.

- Extract `buildNavTutorials(slugSet, contentRows, {visibilityFilter})` from
  `navHandlerFallback` — shared helper used by both the public cold-start fallback
  and the new gated live feed.
- Visibility filter: 'ROLE_GATED' keeps only ROLE_GATED tutorials; default public
  path excludes ROLE_GATED (defense-in-depth; hardens the fallback — hot path uses
  the baked __nav__ blob, unchanged).
- Add `preReleaseNavHandler` — enumerates ContentCurrent/ContentFiles slugs, calls
  buildNavTutorials with ROLE_GATED filter, sets Cache-Control: private, no-store.
  Does NOT read/write the shared slug-keyed cache (#3099 cache-leak rule).
- Export via _defaults + module re-exports in packages/content/content-store.js,
  and re-export from srv/lib/content-store.js shim.
- Mount at GET /content/tutorials-prerelease/_nav in srv/server.js, registered
  BEFORE the *slug wildcard so `_nav` is not swallowed as a slug.
- TDD: 3 tests in srv/__tests__/lib/prerelease-nav.test.js — RED first, then GREEN.
  All 135 tests pass (21 test files, no regressions).
- Extend Channel union to 'prod' | 'qa' | 'prerelease' in fetch-tutorials.ts
- parseChannel accepts --channel prerelease (throws Unknown channel on unknown)
- getQaCacheDir → .tutorial-cache-prerelease
- getHugoContentDir → hugo/content-prerelease
- getNavJsonDir → hugo/static-prerelease/tutorials
- browseDataFile → hugo/data-prerelease/browse.json
- buildAllCards uses /tutorials-prerelease prefix for prerelease
- main(): writes content-prerelease/_index.md + tutorial-navigator/_index.md
- main(): filters allTutorials to visibility===ROLE_GATED for prerelease channel
- main(): skips discovery baseline upload (non-prod, same as qa)
- main(): allows feed drift on fast-path reuse (same as qa)
- main(): dimensionsPath → hugo/data-prerelease/image_dimensions.json
- New hugo.prerelease.toml: dataDir=data-prerelease, params.prerelease=true, baseURL=/tutorials-prerelease/
- New scripts/sync-island-manifest-prerelease.cjs: copies island_manifest.json to data-prerelease/
- package.json: fetch-tutorials:prerelease, build:prerelease, publish-content:prerelease, prerelease:full
  build:prerelease reuses verify-qa-build.ts (takes dir as argv[2]) for public-prerelease
- TDD: scripts/__tests__/fetch-tutorials-channel.test.ts, 16 tests pass (green after impl)
- Full channel build deferred to deploy-time (CAP_BASE_URL not set locally)
- Note: build:prerelease not in build:all, same as QA pattern; deploy wiring is Task 6
- Extend both `{{ if not site.Params.qa }}` gates to also suppress the
  browse-pill and homepage discovery sections (hero, featured, recent,
  topics) when `site.Params.prerelease` is set.
- Add `{{ else if site.Params.prerelease }}` branch on the island mount
  node: emits `data-nav-base="/tutorials-prerelease"`,
  `data-href-base="/tutorials-prerelease"`, `data-client-search="true"`.
  No `data-search-base` (prerelease uses client-side search only —
  `clientSearch=true` in TutorialNavigator.vue disables server search).
- Add a "Pre-release" fd-object-status badge above the island mount so
  holders know they are on the gated surface.
- Add `$hrefBase = "/tutorials-prerelease"` assignment in the SSR
  featured-rail block (defensive; that section is already gated off for
  prerelease, but keeps the value consistent).
…unit test (#3168)

Item A — verify-qa-build.ts prerelease channel awareness:
- Extract shared `checkBrowseDataTag` and `checkNoHomeSections` helpers to
  avoid duplication between QA and prerelease checks.
- Add `checkPrereleaseIndex` exported function that checks prerelease-specific
  markers: `data-nav-base="/tutorials-prerelease"` + `data-client-search="true"`
  (no `data-search-base` required — prerelease uses client-side search only).
- Make `main()` detect prerelease from the public-dir arg (path contains
  "prerelease") and dispatch to the right check + manifest path
  (`data-prerelease/island_manifest.json`).
- Keep `checkQaIndex` behavior 100% unchanged; all 6 existing tests still pass.
- Add 6 new `checkPrereleaseIndex` tests in verify-qa-build.test.ts.

Item B — ROLE_GATED visibility filter unit test:
- Extract `keepForChannel(visibility, channel)` pure predicate from the
  inline filter in `main()` and export it. The predicate encodes:
    prerelease → only ROLE_GATED pass
    prod       → ROLE_GATED excluded (mirrors semantic-search exclusion, #3168)
    qa         → all pass (repo-scoped, not visibility-scoped)
- Wire up `main()` to use `keepForChannel` for all non-qa channels, replacing
  the previous prerelease-only inline filter.
- Add 18 new `keepForChannel` tests in fetch-tutorials-channel.test.ts covering
  all channels × all visibility values + mixed-catalog scenarios.
- TDD evidence: `keepForChannel` import in the test file failed until the export
  was added; tests went red first.

All tests: 44 pass (32 channel-filter + 12 verify-qa-build).
…oke (#3168)

- .deploy/mta.yaml: add static/prerelease to wipe-first list; add
  mkdir/cp/rm-tutorials block after QA block (approuter builder)
- mta.yaml: add npm run build:prerelease + mkdir/cp/rm-tutorials block
  after QA block (CI before-all)
- scripts/deploy-mta.cjs: add Step 2.8 (fetch-tutorials:prerelease +
  build:prerelease) between Step 2.7 (QA) and Step 3 (mbt), mirroring
  the QA channel pattern exactly
- .github/workflows/deploy.yml: add Prefetch prerelease tutorials step
  after QA prefetch (warms .tutorial-cache-prerelease before mbt build)
- test/e2e/prerelease-navigator.spec.ts: new Playwright smoke spec; P1
  asserts /tutorials-prerelease/ loads + island mounts; P2 asserts
  client-side search narrows results; P3 asserts slug page renders
  <main>+<h1>; self-skips without SMOKE_BASE_URL + credentials
…il-closed nav handler (#3168)

C1 (Critical): /content/tutorials-prerelease/* was reachable anonymously via the
broad catch-all route ^/content/(.*)$ (authenticationType: none) at index ~83 in
xs-app.json. The new scoped routes for /tutorials-prerelease/* were at indices 98-101,
so the catch-all always won for direct /content/tutorials-prerelease/* requests,
exposing both the _nav listing and the gated-bytes serve path.

Fix part 1 (PRIMARY gate — approuter): add route for ^/content/tutorials-prerelease/(.*)$
with authenticationType: xsuaa + scope: Tutorial.PreRelease, placed ABOVE the anonymous
^/content/(.*)$ catch-all. This closes the _nav listing leak AND the pre-existing #3099
gated-bytes exposure via the content mount.

Fix part 2 (DEFENSE-IN-DEPTH — handler fail-closed): preReleaseNavHandler now accepts
{ gated = false } and returns 404 immediately when gated !== true. The server.js mount
passes { gated: true } via closure; no client-settable header or param can spoof this.
Mirrors the existing serveStoredSlug { gated } pattern from #3099.

TDD: new test asserts 404 + no tutorial data without flag (was RED); passing with flag
(GREEN). Existing tests updated to pass { gated: true }. 5/5 tests pass.
…tch steps (#3168)

T6: Three comments in deploy.yml referenced 'two fetches' (prod + QA) after a third
prerelease fetch step was added. Updated to 'three fetches' (prod + QA + prerelease).
Comment-only change, no functional impact.
@jung-thomas
Thomas Jung (jung-thomas) merged commit 0766b84 into DEV Nov 22, 2026
7 of 8 checks passed
@jung-thomas
Thomas Jung (jung-thomas) deleted the worktree-issue-3168-prerelease-navigator branch November 22, 2026 05:30
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.

1 participant