diff --git a/.deploy/mta.yaml b/.deploy/mta.yaml index 1acecd9f1..1443d9f3e 100644 --- a/.deploy/mta.yaml +++ b/.deploy/mta.yaml @@ -259,7 +259,7 @@ modules: # Wipe each static dir BEFORE cp'ing fresh content. Hugo public, qa, admin-ui, # analytics-ui, scanner-ui all need this; everything not under static/ here # (e.g. node_modules, package.json) is preserved. - - rm -rf static/admin-ui static/analytics-ui static/scanner-ui static/explore-ui static/channel-atlas-ui static/data-inspector-ui static/qa + - rm -rf static/admin-ui static/analytics-ui static/scanner-ui static/explore-ui static/channel-atlas-ui static/data-inspector-ui static/qa static/prerelease # CAP-sourced Hugo sections (concepts, developer-advocates, browse) are # generated at build time from /build/* endpoints. Because `cp -r` is # union (see comment above), a build against a backend with FEWER rows @@ -274,6 +274,9 @@ modules: - mkdir -p static/qa - cp -r ../hugo/public-qa/. static/qa/ - rm -rf static/qa/tutorials + - mkdir -p static/prerelease + - cp -r ../hugo/public-prerelease/. static/prerelease/ + - rm -rf static/prerelease/tutorials - npm --prefix ../app/admin-shell install - npm --prefix ../app/admin-shell run build - mkdir -p static/admin-ui diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 224121ef3..926783d43 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -136,7 +136,7 @@ jobs: # Cache .tutorial-cache/ across runs so fetch-tutorials does not re-pull # ~1400 tutorials from GitHub on every CI run. Without this, mbt's 10-min # per-command timeout fires during the QA-channel fetch (the second of - # two fetches in the build sequence). Mirrors rebuild-content.yml's + # three fetches in the build sequence). Mirrors rebuild-content.yml's # caching pattern. # Cache key is keyed to the fetcher implementation (scripts/fetch-tutorials.ts # + scripts/parsers/), NOT to deploy.yml. Workflow file edits don't change @@ -180,13 +180,13 @@ jobs: # Prefetch tutorials OUTSIDE the mbt before-all phase. mbt enforces a # 10-minute timeout for the entire before-all sequence; cold-cache CI - # runs do TWO ~6-min full fetches (prod + QA) which blow past 10 min. + # runs do THREE ~6-min full fetches (prod + QA + prerelease) which blow past 10 min. # Doing the fetches as separate workflow steps removes them from mbt's # cap, AND populates the actions/cache@v4 directories for any future # mbt invocation in the same job (mbt's own fetch step then hits a # warm cache and finishes in seconds). # - # Both fetches run sequentially since they share the GitHub API rate + # All fetches run sequentially since they share the GitHub API rate # limit budget; in parallel they'd compete for tokens. Each is gated # by `if: failure()` is NOT used — we WANT a hard failure if discovery # breaks (otherwise mbt would re-fetch anyway and surface the same @@ -209,6 +209,13 @@ jobs: CAP_BASE_URL: ${{ steps.cap-url.outputs.url }} SNIPPETS_ENABLED_REPOS: meta-tutorials + - name: Prefetch prerelease tutorials (warms .tutorial-cache-prerelease) + run: npm run fetch-tutorials -- --target hugo --channel prerelease + env: + GITHUB_TOKEN: ${{ secrets.TUTORIALS_GITHUB_TOKEN || github.token }} + CAP_BASE_URL: ${{ steps.cap-url.outputs.url }} + SNIPPETS_ENABLED_REPOS: meta-tutorials + # [#797] Hugo safeHTML XSS-guard. Sweeps hugo/layouts/**/*.{html,xml,xsl} # for unmarked `| safeHTML` / `| safeHTMLAttr` / `printf "<...%s"` usages # and fails CI if any occurrence lacks a `` diff --git a/approuter/xs-app.json b/approuter/xs-app.json index 51e6452e5..89579084e 100644 --- a/approuter/xs-app.json +++ b/approuter/xs-app.json @@ -567,6 +567,13 @@ "destination": "srv-api", "authenticationType": "xsuaa" }, + { + "source": "^/content/tutorials-prerelease/(.*)$", + "target": "/content/tutorials-prerelease/$1", + "destination": "srv-api", + "authenticationType": "xsuaa", + "scope": "$XSAPPNAME.Tutorial.PreRelease" + }, { "source": "^/content/(.*)$", "target": "/content/$1", @@ -672,6 +679,27 @@ "authenticationType": "xsuaa", "scope": "$XSAPPNAME.Tutorial.Author" }, + { + "source": "^/tutorials-prerelease/_nav\\.json$", + "target": "/content/tutorials-prerelease/_nav", + "destination": "srv-api", + "authenticationType": "xsuaa", + "scope": "$XSAPPNAME.Tutorial.PreRelease" + }, + { + "source": "^/tutorials-prerelease/?$", + "target": "/prerelease/index.html", + "localDir": "static", + "authenticationType": "xsuaa", + "scope": "$XSAPPNAME.Tutorial.PreRelease" + }, + { + "source": "^/tutorials-prerelease/((?:css|js|img|fonts|vendor)/.*)$", + "target": "/$1", + "localDir": "static", + "authenticationType": "xsuaa", + "scope": "$XSAPPNAME.Tutorial.PreRelease" + }, { "source": "^/tutorials-prerelease/(.*)$", "target": "/content/tutorials-prerelease/$1", diff --git a/docs/superpowers/plans/2026-11-21-prerelease-navigator.md b/docs/superpowers/plans/2026-11-21-prerelease-navigator.md new file mode 100644 index 000000000..3038c5b10 --- /dev/null +++ b/docs/superpowers/plans/2026-11-21-prerelease-navigator.md @@ -0,0 +1,306 @@ +# Pre-release Navigator Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Give `Tutorial.PreRelease` role-holders a scope-gated navigator to browse/filter/search ROLE_GATED tutorials, instead of needing a direct link per tutorial. + +**Architecture:** A live gated nav feed on `srv-api` (ROLE_GATED-filtered, served behind the existing `{gated:true}` seam), a QA-style build-time `prerelease` Hugo channel for the navigator shell (client-side search, reusing the existing island), and a prerequisite fix to the pre-existing public `semantic_search` ROLE_GATED leak. No schema change, no new XSUAA scope, no new CAP app. + +**Tech Stack:** CAP Node.js (`@sap/cds`), Express handlers in `packages/content/`, Hugo + Vue 3 islands, SAP approuter (`xs-app.json`), XSUAA, SQLite (unit tests) / HANA (hybrid/prod). + +**Spec:** `docs/superpowers/specs/2026-11-21-prerelease-navigator-design.md` + +## Global Constraints + +- **Base + target branch: `origin/DEV`** (never `main`). PRs target DEV. +- **No schema change** — `visibility` enum + `Tutorials.visibility` already exist on DEV. +- **No `xs-security.json` change** — scope `$XSAPPNAME.Tutorial.PreRelease`, role-template `TutorialPreRelease`, role-collection `"Tutorials PreRelease"` already exist (#3099). No `cf update-service` needed. +- **Gated trust = server-side mount**, never a client-settable header (matches #3099 `{gated:true}` at `srv/server.js:850`). +- **Gated responses must not enter a public/shared cache** — `Cache-Control: private, no-store`, never written to the slug-keyed in-process cache. +- **Channel selection is build-time** (`site.Params.`), mirroring QA — not a runtime switch. +- **CQN `.where({slug:{in:[...]}})` over large slug sets blows HANA's packet cap** — reuse the unbounded-fetch + Node-filter pattern already in `navHandlerFallback`. +- Unit tests run on in-memory SQLite (`npm test -- `); full suite is hook-blocked locally (CI runs it). + +## Review Focus + +- **Standalone (mission-less) ROLE_GATED tutorial** must appear in the gated navigator — the feed must NOT derive from the mission-scoped `NavigatorCatalog`. (Task 2 test.) +- **A LISTED tutorial must NEVER appear in the gated feed**, and a ROLE_GATED tutorial must never appear in the public `__nav__`/fallback. (Task 2 test.) +- **Public anonymous `semantic_search` must not return any ROLE_GATED slug** — on both HANA and SQLite branches. (Task 1 test.) +- **Gated nav feed response is `private, no-store`** and absent from the shared cache (no public-hit leak). (Task 2 test.) +- **An unauthenticated request to `/tutorials-prerelease/` and `/tutorials-prerelease/_nav.json` is refused by the approuter scope** (403), not served. (Task 5 — integration/e2e; approuter scope not unit-testable.) + +--- + +### Task 1: Fix public `semantic_search` ROLE_GATED leak + +Independent, must land (prerequisite). The public anonymous semantic tutorial corpus filters only on `status` + ContentCurrent presence; ROLE_GATED tutorials leak to anyone. + +**Files:** +- Modify: `srv/lib/semantic-search.js` (tutorial corpus query, ~lines 168-196 — both the HANA raw-SQL branch and the SQLite CQL branch) +- Test: `srv/__tests__/lib/semantic-search-visibility.test.js` (create) + +**Interfaces:** +- Produces: no new export; the existing semantic tutorial-search entrypoint now excludes ROLE_GATED on the public path. + +- [ ] **Step 1: Write the failing test** + +Seed two tutorials with embeddings: one `visibility='LISTED'`, one `visibility='ROLE_GATED'`, both `status='ACTIVE'` and both present in `ContentCurrent`. Call the semantic tutorial search path (the function invoked by the `semantic_search` action; import it directly from `semantic-search.js`). Assert the LISTED slug may be returned and the ROLE_GATED slug is **never** in the result set. + +```js +test('public semantic search excludes ROLE_GATED tutorials', async () => { + // seed LISTED + ROLE_GATED tutorials, both ACTIVE + in ContentCurrent, with embeddings + const results = await searchTutorials(db, queryVecForBoth, { topK: 10 }); + const slugs = results.map(r => r.slug); + expect(slugs).not.toContain('pre-release-secret'); +}); +``` + +- [ ] **Step 2: Run test to verify it fails** + +Run: `npm test -- srv/__tests__/lib/semantic-search-visibility.test.js` +Expected: FAIL — ROLE_GATED slug present in results. + +- [ ] **Step 3: Add the visibility predicate to both branches in `srv/lib/semantic-search.js`** + +HANA branch: add to the SQL `WHERE` alongside the existing status gate — `AND (t."VISIBILITY" IS NULL OR t."VISIBILITY" <> 'ROLE_GATED')`. SQLite branch: add to the `.where(...)` on the `Tutorials` index fetch — `status (null/ACTIVE) and (visibility is null or visibility <> 'ROLE_GATED')`. Keep the existing `filterServableSlugs` call unchanged. + +- [ ] **Step 4: Run test to verify it passes** + +Run: `npm test -- srv/__tests__/lib/semantic-search-visibility.test.js` +Expected: PASS. + +- [ ] **Step 5: Commit** + +```bash +git add srv/lib/semantic-search.js srv/__tests__/lib/semantic-search-visibility.test.js +git commit -m "fix(search): exclude ROLE_GATED from public semantic_search (#3168, #3099 leak)" +``` + +--- + +### Task 2: Live gated nav feed handler + +**Files:** +- Modify: `packages/content/content-store.js` (add `preReleaseNavHandler`; extract the slug-set→tutorial-nav assembly from `navHandlerFallback` ~lines 1765-1900 into a shared helper; export the new handler via `_defaults` + the module export block ~line 2327/2355) +- Modify: `srv/server.js` (mount near line 850, beside the existing `/content/tutorials-prerelease/*slug` gated serve mount) +- Test: `srv/__tests__/lib/prerelease-nav.test.js` (create) + +**Interfaces:** +- Consumes: Task 1 unaffected. +- Produces: `preReleaseNavHandler(req, res)` — Express handler returning `{ version, count, tutorials }` where each tutorial is `{ slug, title, time, level, stepCount, displayTags, ... }` (identical shape to `navHandlerFallback`). Mounted at CAP `GET /content/tutorials-prerelease/_nav`. + +- [ ] **Step 1: Write the failing test** + +Seed three tutorials in `ContentCurrent` + `Tutorials`: `listed-a` (LISTED), `gated-standalone` (ROLE_GATED, **not** in any published mission), `gated-b` (ROLE_GATED). Invoke `preReleaseNavHandler` with a mock req/res. Assert: +- `tutorials` contains `gated-standalone` and `gated-b` (standalone ROLE_GATED IS listed — Review Focus); +- `tutorials` does NOT contain `listed-a`; +- the response `Cache-Control` header is `private, no-store`; +- each returned item has `slug`, `title`, `time`, `level`, `stepCount`, `displayTags`. + +Also assert the inverse on the public path: call the existing `navHandler`/fallback over the same seed and confirm neither ROLE_GATED slug appears. + +```js +test('gated nav feed returns only ROLE_GATED incl. standalone, no-store', async () => { + const res = mockRes(); + await preReleaseNavHandler(mockReq(), res); + const slugs = res.body.tutorials.map(t => t.slug); + expect(slugs).toEqual(expect.arrayContaining(['gated-standalone', 'gated-b'])); + expect(slugs).not.toContain('listed-a'); + expect(res.headers['Cache-Control']).toBe('private, no-store'); +}); +``` + +- [ ] **Step 2: Run test to verify it fails** + +Run: `npm test -- srv/__tests__/lib/prerelease-nav.test.js` +Expected: FAIL — `preReleaseNavHandler` not defined. + +- [ ] **Step 3: Extract the assembly helper and implement `preReleaseNavHandler`** + +Refactor `navHandlerFallback` so the slug-set→tutorial-nav-object assembly (the `allTutRows` fetch, step counts, display tags, and the final `{ slug, title, time, level, stepCount, displayTags }` mapping) is a shared helper `buildNavTutorials(slugSet, { visibilityFilter })` that filters `allTutRows` by `status !== 'INACTIVE'` and, when `visibilityFilter === 'ROLE_GATED'`, keeps only `t.visibility === 'ROLE_GATED'` (else keeps `visibility` LISTED-or-null and excludes ROLE_GATED — this **hardens** the cold-start fallback path, which has no visibility filter today; the normal public path serves the pre-baked `__nav__` blob that already excludes ROLE_GATED at build time, so this is defense-in-depth, not a change to the hot path). `preReleaseNavHandler` enumerates `ContentCurrent` slugs (reusing the fallback's ContentCurrent read), calls `buildNavTutorials(slugSet, { visibilityFilter: 'ROLE_GATED' })`, sets `Cache-Control: private, no-store`, and returns `{ version, count, tutorials }`. Do NOT read or write the shared slug-keyed `cache`. Export `preReleaseNavHandler`. + +- [ ] **Step 4: Run test to verify it passes** + +Run: `npm test -- srv/__tests__/lib/prerelease-nav.test.js` +Expected: PASS. + +- [ ] **Step 5: Mount the handler in `srv/server.js`** + +Near line 850 (the existing gated serve mount), add: `app.get('/content/tutorials-prerelease/_nav', (req, res) => preReleaseNavHandler(req, res));` and add `preReleaseNavHandler` to the import from `./lib/content-store.js`. + +- [ ] **Step 6: Run the broader content-store nav tests to confirm no public regression** + +Run: `npm test -- srv/__tests__/lib/` (nav/content-store scope) +Expected: PASS — public `navHandler` still LISTED-only. + +- [ ] **Step 7: Commit** + +```bash +git add packages/content/content-store.js srv/server.js srv/__tests__/lib/prerelease-nav.test.js +git commit -m "feat(prerelease): live gated nav feed for ROLE_GATED tutorials (#3168)" +``` + +--- + +### Task 3: `prerelease` build channel (fetch + config + scripts) + +Mirror the QA channel plumbing. Build-time, no runtime switch. + +**Files:** +- Modify: `scripts/fetch-tutorials.ts` (extend `Channel` union + `--channel` validation line ~79-96; add `prerelease` cache/content/nav/static dir cases; filter the cataloged set to `visibility='ROLE_GATED'` for the `prerelease` channel, reading visibility off `/build/catalog`) +- Create: `hugo.prerelease.toml` (copy `hugo.qa.toml`; `dataDir = "data-prerelease"`, `params.prerelease = true`, prefix/baseURL for `/tutorials-prerelease/`) +- Create: `scripts/sync-island-manifest-prerelease.cjs` (copy `scripts/sync-island-manifest-qa.cjs`, retargeted to the prerelease data/public dirs) — or parameterize the QA one if trivial +- Modify: `package.json` scripts: add `fetch-tutorials:prerelease`, `build:prerelease`, `prerelease:full` (mirror `fetch-tutorials:qa`/`build:qa`/`qa:full`); wire `build:prerelease` into `build:all` +- Modify: `scripts/verify-qa-build.ts` → generalize or add `verify-prerelease-build` target for `hugo/public-prerelease` +- Test: `scripts/__tests__/fetch-tutorials-channel.test.ts` (create or extend existing channel test) + +**Interfaces:** +- Consumes: `/build/catalog` payload (already carries `visibility` per tutorial). +- Produces: `hugo/data-prerelease/` (nav/browse data, ROLE_GATED only), `hugo/public-prerelease/` (built site incl. `index.html`), and the channel accepted by `--channel prerelease`. + +- [ ] **Step 1: Write the failing test** + +Assert `parseChannel(['--channel','prerelease'])` returns `'prerelease'` (currently throws `Unknown channel`), and that the prerelease dir helpers (`getQaCacheDir`/`getHugoContentDir`/`getNavJsonDir` or their generalized forms) return `*-prerelease`/`static-prerelease` paths for the prerelease channel. + +```ts +test('prerelease channel parses and maps to prerelease dirs', () => { + expect(parseChannel(['--channel','prerelease'])).toBe('prerelease') + expect(getHugoContentDir('prerelease')).toMatch(/prerelease/) +}) +``` + +- [ ] **Step 2: Run test to verify it fails** + +Run: `npm test -- scripts/__tests__/fetch-tutorials-channel.test.ts` +Expected: FAIL — `Unknown channel: prerelease`. + +- [ ] **Step 3: Extend the channel union + dir helpers + visibility filter** + +`Channel = 'prod' | 'qa' | 'prerelease'`; accept it in `parseChannel`; add `prerelease` cases to the cache/content/nav/static dir helpers (`data-prerelease`, `static-prerelease`, `public-prerelease`). In the catalog→content step, when `channel === 'prerelease'` keep only tutorials whose catalog `visibility === 'ROLE_GATED'` (prod keeps LISTED, qa keeps its contribution set). Reuse the QA degraded-cache guard pattern if it applies. + +- [ ] **Step 4: Run test to verify it passes** + +Run: `npm test -- scripts/__tests__/fetch-tutorials-channel.test.ts` +Expected: PASS. + +- [ ] **Step 5: Create `hugo.prerelease.toml`, the manifest-sync script, and the `package.json` scripts** + +Copy `hugo.qa.toml` → `hugo.prerelease.toml` (set `dataDir`, `params.prerelease`, baseURL/prefix). Add scripts mirroring QA. Wire `build:prerelease` into `build:all` beside `build:qa`. + +- [ ] **Step 6: Build the channel end-to-end (smoke)** + +Run: `scripts/quiet-run.sh npm run fetch-tutorials:prerelease && scripts/quiet-run.sh npm run build:prerelease` +Expected: exit 0; `hugo/public-prerelease/tutorials-prerelease/index.html` (or the configured shell path) exists. (Requires `CAP_BASE_URL` pointing at a backend with a seeded ROLE_GATED tutorial, or an empty-but-valid build.) + +- [ ] **Step 7: Commit** + +```bash +git add scripts/fetch-tutorials.ts hugo.prerelease.toml scripts/sync-island-manifest-prerelease.cjs package.json scripts/verify-*.ts scripts/__tests__/fetch-tutorials-channel.test.ts +git commit -m "feat(prerelease): QA-style prerelease build channel (#3168)" +``` + +--- + +### Task 4: Navigator template `prerelease` branch + +**Files:** +- Modify: `hugo/layouts/tutorial-navigator/list.html` (add `prerelease` to the channel conditions: the `{{ if not site.Params.qa }}` discovery-section gate at line 30/179, and the island data-attr line at line 41) +- Test: manual/visual via the Task 3 build output (template logic has no unit harness; covered by the Task 6 e2e). + +**Interfaces:** +- Consumes: `site.Params.prerelease` (set by `hugo.prerelease.toml`), Task 2's `_nav.json` at `/tutorials-prerelease/_nav.json`. +- Produces: a navigator shell that mounts the island with `data-nav-base="/tutorials-prerelease"`, `data-href-base="/tutorials-prerelease"`, `data-client-search="true"`, and no `data-search-base` (client search). + +- [ ] **Step 1: Extend the discovery-section gate** + +Change `{{ if not site.Params.qa }}` (lines ~30, ~179) to also suppress the homepage/discovery sections for prerelease: `{{ if and (not site.Params.qa) (not site.Params.prerelease) }}`. + +- [ ] **Step 2: Extend the island data-attr line (line ~41)** + +Add a prerelease branch mirroring the QA one: when `site.Params.prerelease`, emit `data-nav-base="/tutorials-prerelease" data-href-base="/tutorials-prerelease" data-client-search="true"` and a "Pre-release" heading/badge. (No `data-search-base` — client search, confirmed: `TutorialNavigator.vue:27` + `useSearch.ts:18-21`.) Also update the `$hrefBase` SSR assignment (line ~198) to set `/tutorials-prerelease` when prerelease. + +- [ ] **Step 3: Rebuild and eyeball the shell** + +Run: `scripts/quiet-run.sh npm run build:prerelease` +Expected: the built `index.html` contains the island mount node with the prerelease data-attrs and omits the discovery sections. + +- [ ] **Step 4: Commit** + +```bash +git add hugo/layouts/tutorial-navigator/list.html +git commit -m "feat(prerelease): navigator template prerelease channel branch (#3168)" +``` + +--- + +### Task 5: Approuter routes (scope-gated surface) + +**Files:** +- Modify: `approuter/xs-app.json` (add the prerelease route block BEFORE the existing `^/tutorials-prerelease/(.*)$` slug catch-all; mirror the QA static/index/asset/nav routes but `scope: "$XSAPPNAME.Tutorial.PreRelease"`) +- Modify: `.deploy/xs-app.json` if a synced copy exists (follow the #3099 `.deploy` sync convention — verify) + +**Interfaces:** +- Consumes: static shell from Task 3/4 (built into the prerelease static dir), live nav feed from Task 2 (`/content/tutorials-prerelease/_nav`). +- Produces: scope-gated routes: `/tutorials-prerelease/` (index shell), `/tutorials-prerelease/`, `/tutorials-prerelease/_nav.json`; existing slug route unchanged and LAST. + +- [ ] **Step 1: Add the route block (specific-before-catch-all ordering)** + +Insert, before the slug route (and matching how QA maps `/qa/*` in the static dir — confirm the static path for prerelease, e.g. `/prerelease/index.html`): +```jsonc +{ "source": "^/tutorials-prerelease/?$", "target": "/prerelease/index.html", + "localDir": "static", "authenticationType": "xsuaa", "scope": "$XSAPPNAME.Tutorial.PreRelease" }, +{ "source": "^/tutorials-prerelease/((?:css|js|img|fonts|vendor)/.*)$", "target": "/$1", + "localDir": "static", "authenticationType": "xsuaa", "scope": "$XSAPPNAME.Tutorial.PreRelease" }, +{ "source": "^/tutorials-prerelease/_nav\\.json$", "target": "/content/tutorials-prerelease/_nav", + "destination": "srv-api", "authenticationType": "xsuaa", "scope": "$XSAPPNAME.Tutorial.PreRelease" } +``` +Leave the existing `^/tutorials-prerelease/(.*)$` → `/content/tutorials-prerelease/$1` slug route as the LAST of the group. + +- [ ] **Step 2: Validate JSON** + +Run: `jq . approuter/xs-app.json > /dev/null && echo OK` +Expected: `OK` (no parse error). + +- [ ] **Step 3: Sync `.deploy` copy if the convention requires it** + +Verify whether `.deploy/xs-app.json` is a tracked synced copy (as `.deploy/xs-security.json` was in #3099, commit `e44fe7176`). If so, apply the same edit there. + +- [ ] **Step 4: Commit** + +```bash +git add approuter/xs-app.json .deploy/xs-app.json +git commit -m "feat(prerelease): scope-gated navigator approuter routes (#3168)" +``` + +--- + +### Task 6: e2e + deploy-path wiring + +**Files:** +- Create: `test/e2e/prerelease-navigator.spec.ts` (Playwright; self-skips without `SMOKE_BASE_URL` + `SMOKE_TECH_USER`/`PASSWORD`, per the repo e2e convention) +- Modify: deploy/rebuild wiring if `build:prerelease` isn't already carried by `build:all` + the MTA packaging of the static shell (verify Task 3 Step 5 covered `build:all`; confirm the MTA ships `public-prerelease`/the static shell) + +**Interfaces:** +- Consumes: the deployed gated surface. + +- [ ] **Step 1: Write the e2e spec** + +With an authenticated `Tutorial.PreRelease` role-holder session: load `/tutorials-prerelease/`, assert the navigator island renders with ≥1 card for a seeded ROLE_GATED tutorial, filter/search client-side narrows the list, and clicking a card navigates to `/tutorials-prerelease/:slug` and renders `
`+`

` (served tutorials render those, NOT `
` — per repo e2e note). Self-skip when the smoke env vars are absent. + +- [ ] **Step 2: Confirm deploy packaging** + +Verify `build:all` runs `build:prerelease` and the MTA approuter builder ships the prerelease static shell + assets (same mechanism as QA's `static-qa`). Document the baked-artifact wipe caution (rebuild-tarball / local-deploy-skip) in the PR description and, if a runbook touches QA channels, add a prerelease line. + +- [ ] **Step 3: Commit** + +```bash +git add test/e2e/prerelease-navigator.spec.ts +git commit -m "test(prerelease): e2e navigator smoke + deploy-path note (#3168)" +``` + +--- + +## Notes for the executor + +- **Known DEV bug to avoid reintroducing:** server-side `$search` KG-rerank 500s on HANA (broken simple-CASE). This plan uses **client-side** search (no server `$search` for prerelease), so it's avoided — do not add a server search service. +- After all tasks: run the scoped unit suites that were touched (`npm test -- srv/__tests__/lib/ scripts/__tests__/`) and open a PR to **DEV** (`gh pr create --base DEV`). Do not merge to `main`. diff --git a/docs/superpowers/specs/2026-11-21-prerelease-navigator-design.md b/docs/superpowers/specs/2026-11-21-prerelease-navigator-design.md new file mode 100644 index 000000000..316855a41 --- /dev/null +++ b/docs/superpowers/specs/2026-11-21-prerelease-navigator-design.md @@ -0,0 +1,149 @@ +# Pre-release Navigator — Design + +**Issue:** [sap-tutorials/tutorials-ims#3168](https://github.com/sap-tutorials/tutorials-ims/issues/3168) · Follow-up to [#3099](https://github.com/sap-tutorials/tutorials-ims/issues/3099) (Private Tutorials, merged to **DEV**) · Design, 2026-11-21. +**Parent design:** Private Tutorials — the `visibility` field + `ROLE_GATED` serve gate (merged on `origin/DEV`). + +**Base branch: `origin/DEV`.** #3099 lives on DEV, not `main`. All work here branches from and targets DEV. + +Adds a **scope-gated browse navigator** so holders of the `Tutorial.PreRelease` XSUAA scope can *browse, filter, and search* pre-release (ROLE_GATED) tutorials, instead of needing a direct link to `/tutorials-prerelease/:slug` for each one. + +--- + +## Intent & why + +#3099 gives role-holders **direct-link** access to pre-release tutorials at `/tutorials-prerelease/:slug`, gated by the `Tutorial.PreRelease` scope. There is intentionally **no listing surface** — ROLE_GATED tutorials are suppressed from the public navigator, search, and sitemap, and the gated prefix has only a slug catch-all route (no index, nav feed, or search). + +Consequence: a role-holder can only reach a pre-release tutorial if someone hands them the exact slug. This design adds the missing listing surface: a navigator behind the same scope that lists, filters, and searches ROLE_GATED tutorials only. + +## Goals + +- A **full navigator** (card grid + category/tag filters + free-text search) at a scope-gated route (`/tutorials-prerelease/`), showing **only** `ROLE_GATED` tutorials. +- Reuse the existing navigator Vue island + Hugo template by adding a **third channel** (`prerelease`), mirroring the QA channel's build-time mechanism exactly. +- Nav data served **live** from `srv-api` behind the existing server-side `{ gated: true }` trust seam (no new CAP app). +- **Search/filter is client-side** over the gated nav feed — the QA channel's proven posture (`data-client-search="true"`, no server search service). +- Cards click through to the existing gated slug route `/tutorials-prerelease/:slug`. +- **Prerequisite fix (in this PR):** close the public `semantic_search` ROLE_GATED leak (see §5) — a pre-existing #3099 anti-goal breach that must be fixed or this feature ships a net leak. + +## Non-goals + +- Server-side gated `$search` / a `PreReleaseSearchService` / a `SearchablePreReleaseItems` view — **dropped**. Search is client-side over the nav feed (QA model). Server search would add a sibling service + view + handler extraction + a gated `getFacets`, and inherit the known DEV `$search` KG-rerank 500 bug — not worth it for the small pre-release corpus. Revisit only if the pre-release set grows large. +- Per-user allowlists / per-event gating — role-scoped, all-or-nothing by `Tutorial.PreRelease` (inherited from #3099). +- A separate `srv-prerelease` CAP app / HDI container — pre-release reuses `srv-api` + the main model. +- Changing how pre-release tutorials are **served** (#3099 slug gate unchanged) or **authored** (visibility set on the admin Tutorials OP). +- Mission/Group pre-release listing — `visibility` is on `Tutorials` only. + +## Anti-goals (would make this a failure even if it "works") + +- A ROLE_GATED slug/title/body leaking to a caller **without** the `Tutorial.PreRelease` scope — via the gated nav feed, the (now public-fixed) semantic path, or a cacheable response. Fail **closed**, matching #3099. +- Flipping the public `/build/catalog`, `/content/nav`, or public `/search` to filter *in* ROLE_GATED, or gating them behind auth. Public surfaces stay LISTED-only and anonymous; pre-release gets **parallel** gated surfaces. +- The gated navigator coming up **empty** because its data source is mission-scoped — standalone ROLE_GATED tutorials (the common pre-release case) must be listable (see §2). +- A gated nav response entering a shared/public cache (the #3099 cache-leak class). + +## Constraints + +- **Base = `origin/DEV`.** PRs target DEV, never direct-merge to `main`. +- **Channel selection is BUILD-TIME, not runtime.** The navigator template switches on `site.Params.qa` — a Hugo site-config param resolved at build (`hugo/layouts/tutorial-navigator/list.html`). QA has a full separate pipeline: `fetch-tutorials:qa --channel qa`, `build:qa` (`hugo.qa.toml` → `hugo/public-qa`), `publish-content:qa`; its **index is served statically** from the approuter (`localDir: "static"` → `/qa/index.html`), not from CAP. There is no runtime channel switch in the island today. The pre-release channel must mirror this build-time mechanism — a runtime switch is net-new mechanism with no precedent and was rejected. +- The public `/content/nav` serves a **pre-baked `__nav__` BLOB** (LISTED-only, built at publish) — `navHandler` at `packages/content/content-store.js:1835`. No pre-release blob is published, so the gated feed must be **live**. +- **`navHandlerFallback` (`content-store.js:1765`) has NO visibility filter** — it enumerates `ContentCurrent` joined to `Tutorials`, filtering only `status !== 'INACTIVE'`. ROLE_GATED tutorials DO have ContentCurrent rows. So it cannot be reused as-is for the gated feed (would list LISTED + ROLE_GATED indiscriminately = leak). The gated feed needs an explicit `visibility='ROLE_GATED'` predicate. +- **`NavigatorCatalog` (`db/views.cds:76`) is mission-scoped** (INNER JOIN to published Missions). A standalone ROLE_GATED tutorial not in a published mission's completion path would never appear. The gated feed must NOT be built from `NavigatorCatalog`. +- The gated slug route rewrites `/tutorials-prerelease/*` → CAP `/content/tutorials-prerelease/*`, mounted with `{ gated: true }` (`srv/server.js:850`). Trust = server-side mount, not a client header. New gated endpoints reuse this. +- **XSUAA scope `Tutorial.PreRelease` already exists** (#3099: scope at `xs-security.json:39`, role-template `TutorialPreRelease:133`, role-collection `"Tutorials PreRelease":211`). **No xs-security change** — navigator routes reference the existing scope. No `cf update-service` gate. +- **Public search bypass points for the leak fix:** the lexical path (OData `$search` + `search_tutorials` MCP) goes through `SearchableItems`, which **does** filter `visibility='LISTED' or is null` (`views.cds:114`) — covered. The **semantic path** (`srv/lib/semantic-search.js:165-209`) filters only `status` ACTIVE + `filterServableSlugs` (ContentCurrent presence, no visibility — `servable-slugs.js`), and the `semantic_search` action is `@requires:'any'`. So public semantic currently leaks ROLE_GATED. §5 fixes this. + +--- + +## Approaches considered + +### Overall navigator + +- **Live gated nav feed on `srv-api` + QA-style build-time channel for the shell (CHOSEN).** New gated live nav handler behind `{ gated: true }`; a `prerelease` build channel mirroring QA (config, data dir, static shell); client-side search/filter over the feed. No new CAP app, no server search service. +- **Fully baked prerelease content channel incl. a baked nav blob (rejected).** Would add a published `__nav_prerelease__` blob + a publish-channel path; heavier and couples the nav feed to the content-publish cycle. The live feed is simpler and always current. +- **Client-filtered public catalog (rejected, #3099 leak).** Point the island at the anonymous `/build/catalog` and filter client-side — ROLE_GATED titles transit a public endpoint. Violates the leak anti-goal. + +### Shell channel mechanism + +- **Build-time `site.Params.prerelease` (CHOSEN).** Mirror QA exactly: `hugo.prerelease.toml`, `data-prerelease/`, `build:prerelease`, a static-served `/prerelease/index.html` shell, a `site.Params.prerelease` branch in the navigator template. Proven, but reintroduces a baked artifact into the deploy/rebuild path (documented risk below). +- **Runtime switch (rejected).** One baked page serving all channels via an approuter-injected marker consumed by the island. No baked artifact, but net-new mechanism with no precedent and more risk. Rejected in favor of matching the proven QA pattern. + +### Search posture + +- **Client-side over the gated nav feed (CHOSEN).** Exactly QA: `data-client-search="true"`, server `$search` disabled, island filters the already-fetched nav list. No `PreReleaseSearchService`, no sibling view, no gated `getFacets`. Avoids the DEV `$search` KG-rerank 500 bug. +- **Server-side role-gated search (rejected).** A sibling view + role-`@requires` service reusing the extracted lexical pipeline + a gated `getFacets`. True server search, but heavy and bug-inheriting for a small corpus. + +--- + +## The design + +### 1. Data model + +No schema change. `visibility` already exists on `Tutorials` (enum `Visibility { LISTED; UNLISTED; ROLE_GATED; }`). This design adds a view (optional), a live handler, a build channel, routes, a template branch, and the semantic leak fix. + +### 2. Gated nav feed (live) — `srv-api` + +- **Source (corrected):** a live query over `Tutorials WHERE visibility = 'ROLE_GATED' AND (status IS NULL OR status = 'ACTIVE')`, intersected with ContentCurrent presence (servable) — **not** `NavigatorCatalog` (mission-scoped) and **not** bare `navHandlerFallback` (no visibility filter). This lists standalone pre-release tutorials, which is the point. +- **Shape:** emit the **same tutorial-shaped nav JSON** the island's `_nav.json` consumer expects (the `navHandlerFallback` output shape: `slug`, `title`, `description`, `time`/`averageTimeToComplete`, `level`/`experienceTag`, `stepCount`, `displayTags`), so the island needs no shape changes — only a different base. Factor the tutorial-metadata-assembly part of `navHandlerFallback` into a shared helper parameterized by the slug set + visibility, and call it with the ROLE_GATED slug set. +- **Handler** `preReleaseNavHandler` in `packages/content/content-store.js`: returns `{ version, count, tutorials }`; set `Cache-Control: private, no-store` (gated content must not enter a public/shared cache — #3099 rule). The handler itself only ever returns ROLE_GATED rows (defense-in-depth), but the approuter scope on its route (§4) is the real gate. +- **Mount** `srv/server.js` (bootstrap, near line 850): `app.get('/content/tutorials-prerelease/_nav', (req,res)=>preReleaseNavHandler(req,res))`. +- *Optional view:* a `PreReleaseServableTutorials` view (`Tutorials` ⋈ `ContentCurrent` where `visibility='ROLE_GATED'`) if it reads cleaner than inline CQL — builder's call; the predicate is the load-bearing part. + +### 3. Shell — QA-style build-time `prerelease` channel + +Mirror the QA channel end to end: + +- **`hugo.prerelease.toml`** (copy `hugo.qa.toml`): `dataDir = "data-prerelease"`, `params.prerelease = true`, base URL/path for the gated prefix. +- **`fetch-tutorials.ts`:** extend the existing `--channel` switch (currently `qa`) with `prerelease`, filtering the fetched/cataloged set to `visibility='ROLE_GATED'` (reads visibility off `/build/catalog`, already carried), writing `hugo/data-prerelease/`. +- **`build:prerelease`** npm script (copy `build:qa`): island-manifest sync + `hugo --config ../hugo.prerelease.toml` → `hugo/public-prerelease` + a verify step. Wire into `build:all`/deploy as a sibling of the QA build. +- **Template** `hugo/layouts/tutorial-navigator/list.html`: add a `site.Params.prerelease` branch mirroring the `site.Params.qa` branch — render only the island, set `data-nav-base="/tutorials-prerelease"`, `data-client-search="true"`, `data-href-base="/tutorials-prerelease"`, a "Pre-release" heading/badge, and drop the homepage discovery sections. +- **Static shell:** the built `prerelease/index.html` is served from the approuter `localDir: "static"` behind the scope (§4), exactly like `/qa/index.html`. + +### 4. Approuter routes — `approuter/xs-app.json` + +Add a block mirroring the QA routes (~lines 626–674) but `scope: "$XSAPPNAME.Tutorial.PreRelease"`, inserted **before** the existing `/tutorials-prerelease/(.*)` slug catch-all (specific first; ordering is load-bearing): + +```jsonc +// static shell index +{ "source": "^/tutorials-prerelease/?$", "target": "/prerelease/index.html", + "localDir": "static", "authenticationType": "xsuaa", "scope": "$XSAPPNAME.Tutorial.PreRelease" }, +// static assets for the shell +{ "source": "^/tutorials-prerelease/((?:css|js|img|fonts|vendor)/.*)$", "target": "/$1", + "localDir": "static", "authenticationType": "xsuaa", "scope": "$XSAPPNAME.Tutorial.PreRelease" }, +// live gated nav feed +{ "source": "^/tutorials-prerelease/_nav\\.json$", "target": "/content/tutorials-prerelease/_nav", + "destination": "srv-api", "authenticationType": "xsuaa", "scope": "$XSAPPNAME.Tutorial.PreRelease" }, +// (existing slug route stays LAST) +{ "source": "^/tutorials-prerelease/(.*)$", "target": "/content/tutorials-prerelease/$1", ... } +``` + +No `xs-security.json` change — scope already exists. (Builder: confirm exact QA route set to mirror, incl. whether the static shell lives under `/prerelease/*` or `/tutorials-prerelease/*` in the static dir, matching how QA maps `/qa/*`.) + +### 5. Prerequisite: fix the public `semantic_search` ROLE_GATED leak + +Independent of the navigator, but **must ship in this PR** (else the feature is a net leak). The public anonymous `semantic_search` returns ROLE_GATED slugs/titles/body today because the tutorial corpus query (`semantic-search.js:165-209`) filters only `status` + ContentCurrent presence, with no visibility predicate. + +- Add a **visibility exclusion** to the semantic tutorial corpus: exclude `visibility='ROLE_GATED'` from the public path (both HANA raw-SQL branch and the SQLite CQL branch). Simplest: a `filterOutRoleGated(db, slugs)` applied alongside `filterServableSlugs`, OR add the predicate to the `Tutorials` join/index subquery in both branches. +- Covers only the **public** surface (the navigator is client-side, so it does not call `semantic_search` on a gated surface in v1 — no gated semantic path needed). +- Add a regression test: public `semantic_search` never returns a ROLE_GATED slug. + +### 6. Island — `hugo-apps/src/navigator/` + +- The island already reads `data-nav-base`/`data-search-base`/`data-href-base` with public defaults and supports `data-client-search="true"` (QA uses it: server search disabled, client filters the nav list). The prerelease channel sets `data-nav-base="/tutorials-prerelease"`, `data-href-base="/tutorials-prerelease"`, `data-client-search="true"` — **no island code change expected** beyond confirming no hardcoded `/tutorials/_nav.json` or `/search` fallback bypasses the gated bases. Verify; parameterize only if needed. +- Confirm client-side search/filter (category/tag + free text) works over the nav feed shape without `getFacets` (QA path derives facets client-side). If the island unconditionally calls `getFacets` even in client-search mode, that's a bug to fix in the prerelease (and QA) path — verify against `useSearch.ts`. + +--- + +## What's left to the builder + +- **Exact QA route mirror** in `xs-app.json` (which of the 6 QA routes map to prerelease; static-dir path mapping `/prerelease/*`). +- **Whether a `PreReleaseServableTutorials` view** reads cleaner than inline CQL in the handler — either is fine; the `visibility='ROLE_GATED'` + ContentCurrent predicate is the requirement. +- **`fetch-tutorials.ts` channel plumbing** — exact shape of the existing `--channel` switch and where the visibility filter slots in. +- **CAP `@requires` for any CAP surface:** decided — the live nav handler is a plain Express route behind the approuter scope (matching #3099's serve posture, no CAP `@requires`); if any CAP entity is exposed, use `@requires: 'Tutorial.PreRelease'` (matches the scope short-name convention `AdminService` uses for `Admin`). Defense-in-depth; approuter scope is the primary gate. +- **Deploy/rebuild wiring for the baked `prerelease` channel** — this is the documented operational risk: like QA, the static shell can be wiped by a content-rebuild tarball or skipped by a local deploy that doesn't run `build:prerelease`. Ensure `build:prerelease` is in `build:all` and the deploy packages `public-prerelease`/static shell. Call this out in the plan's rollout + the ops runbook. +- **`getFacets`-in-client-search** island behavior — verify and fix if it fetches server facets in client-search mode. +- Tests: unit — gated nav handler returns only ROLE_GATED + sets `private, no-store`; standalone (mission-less) ROLE_GATED tutorial IS listed; **public semantic_search excludes ROLE_GATED** (the §5 regression, both DB branches). Integration — `/tutorials-prerelease/` + `/_nav.json` 403 without scope, 200 with. e2e — role-holder loads navigator, filters/searches client-side, clicks through to a gated slug. + +## Rollout + +- DEV-first (base + target DEV). Inert until a tutorial is `ROLE_GATED` (default-`LISTED` safety from #3099). +- No new XSUAA scope → no `cf update-service` gate; deploy with new routes + handler + the baked `prerelease` channel. +- **Ship order:** (1) §5 public semantic leak fix (standalone, must land — arguably its own commit/PR cherry-pickable to a #3099 hotfix if you later want it on main faster); (2) live gated nav handler + mount (testable via `cds watch` with a seeded ROLE_GATED row); (3) `prerelease` build channel + template branch + approuter routes (makes the surface reachable); (4) e2e. Steps 1–2 change no public behavior; step 3 adds the gated surface. +- **Baked-artifact caution:** the `prerelease` static shell shares the QA channel's fragility (rebuild-tarball wipe, local-deploy skip). Verify the shell is present on DEV after deploy (XSUAA-gated, so `curl` can't check it anonymously — use an authenticated check or the e2e). diff --git a/hugo.prerelease.toml b/hugo.prerelease.toml new file mode 100644 index 000000000..270f497f0 --- /dev/null +++ b/hugo.prerelease.toml @@ -0,0 +1,66 @@ +# hugo.prerelease.toml — sibling of hugo/hugo.toml, used by `npm run build:prerelease` +# Prerelease Hugo config: reads from hugo/content-prerelease/, writes to hugo/public-prerelease/. +# Stripped of prod-only output formats (RSS, sitemap, robots, llms*) — prerelease is internal-only. +# Shows ROLE_GATED tutorials only — the navigator IS the root, same as QA. +# Invocation: cd hugo && hugo --config ../hugo.prerelease.toml --minify + +baseURL = "/tutorials-prerelease/" +languageCode = "en-us" +title = "[Prerelease] SAP Tutorials Preview" +contentDir = "content-prerelease" +dataDir = "data-prerelease" +staticDir = "static-prerelease" +publishDir = "public-prerelease" + +# Prerelease is internal-only — suppress sitemap. Taxonomy/term pages stay enabled +# because the home template references .Site.Taxonomies; we override their +# outputs below to drop RSS feeds. +disableKinds = ["sitemap"] + +# Defense-in-depth: even if future tasks ever generate non-tutorial pages under +# content-prerelease/, never render mission/group/me/search shells on prerelease. +ignoreFiles = ["^(missions|groups|me|search)/.*$"] + +[params] + prerelease = true + prereleaseBannerText = "Prerelease preview — ROLE_GATED tutorials not yet publicly listed." + +[build] + writeStats = true + +[markup] + [markup.goldmark] + [markup.goldmark.renderer] + unsafe = true + [markup.goldmark.parser] + [markup.goldmark.parser.attribute] + block = true + title = true + [markup.goldmark.extensions] + [markup.goldmark.extensions.passthrough] + enable = true + [markup.goldmark.extensions.passthrough.delimiters] + block = [['$$', '$$']] + inline = [['$', '$']] + [markup.highlight] + noClasses = false + codeFences = true + guessSyntax = false + lineNos = false + tabWidth = 2 + +# U1 Object Page floorplan as the default tutorial layout — mirrors prod cascade +# so prerelease pages render with the same visual fidelity. Path matches the content +# location (content-prerelease/tutorials/**), which Hugo resolves before applying baseURL. +[[cascade]] + layout = "u1-object-page" + [cascade._target] + path = "/tutorials/**" + kind = "page" + +[outputs] + home = ["HTML"] + section = ["HTML"] + page = ["HTML"] + taxonomy = ["HTML"] + term = ["HTML"] diff --git a/hugo/layouts/tutorial-navigator/list.html b/hugo/layouts/tutorial-navigator/list.html index e5d6b896d..168ede07c 100644 --- a/hugo/layouts/tutorial-navigator/list.html +++ b/hugo/layouts/tutorial-navigator/list.html @@ -27,7 +27,7 @@ {{- end -}}
- {{ if not site.Params.qa }} + {{ if and (not site.Params.qa) (not site.Params.prerelease) }}
@@ -38,7 +38,13 @@