diff --git a/.cdsrc.json b/.cdsrc.json index 37a8c597f..40bf22d11 100644 --- a/.cdsrc.json +++ b/.cdsrc.json @@ -62,6 +62,17 @@ ] } }, + { + "for": "nodejs", + "src": "srv-sage", + "dest": "srv-sage", + "options": { + "model": [ + "srv-sage", + "db" + ] + } + }, { "for": "cds-caching" } diff --git a/.deploy/mta.yaml b/.deploy/mta.yaml index 1acecd9f1..e6ef2319d 100644 --- a/.deploy/mta.yaml +++ b/.deploy/mta.yaml @@ -10,7 +10,7 @@ ID: tutorials-ims # Bump this on each release you deploy — it's the version shown by `cf mtas` # and in the mtar filename (tutorials-ims_.mtar). Deploy is manual: # `cd .deploy && mbt build && cf deploy mta_archives/tutorials-ims_.mtar -e ../deploy/.mtaext -f`. -version: 1.44.3 +version: 1.44.4 # Top-level parameters (overridable per-env via deploy/.mtaext). parameters: diff --git a/.github/workflows/content-drift-check.yml b/.github/workflows/content-drift-check.yml index bd738fdc2..e8c85b784 100644 --- a/.github/workflows/content-drift-check.yml +++ b/.github/workflows/content-drift-check.yml @@ -166,6 +166,16 @@ jobs: env: GITHUB_TOKEN: ${{ steps.app-token.outputs.token || secrets.TUTORIALS_GITHUB_TOKEN }} CAP_BASE_URL: ${{ steps.env.outputs.srv_url }} + # Enable `::include` snippet resolution from repo `_snippets/` dirs. + # fetchSnippets() (scripts/parsers/github.ts) is gated by this var and + # returns an empty map when unset — which makes every repo-snippet + # `::include` throw directive/include-not-found at compose time. Since + # compose errors are now fatal (commit 38c13118b), the drift job's + # Fetch step hard-fails before verify.log is ever written, surfacing as + # a false "drift" alarm (e.g. directive-content-reuse's + # ::include[btp-trial-setup]). Must mirror rebuild-content.yml so the + # composed source matches what the gated rebuild publishes. + SNIPPETS_ENABLED_REPOS: meta-tutorials # The CLI's --verify-only path under PR #591 hashes # `.tutorial-cache/.md` (or `.tutorial-cache-qa/.md`) directly diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b5e31dd11..224121ef3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -197,12 +197,17 @@ jobs: GITHUB_TOKEN: ${{ secrets.TUTORIALS_GITHUB_TOKEN || github.token }} NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_READ_TOKEN || secrets.GITHUB_TOKEN }} CAP_BASE_URL: ${{ steps.cap-url.outputs.url }} + # Enable `::include` snippet resolution (fetchSnippets gate). Unset => + # empty map => repo-snippet `::include` throws include-not-found, now + # fatal (38c13118b). Mirror rebuild-content.yml. See deploy.yml below. + SNIPPETS_ENABLED_REPOS: meta-tutorials - name: Prefetch QA tutorials (warms .tutorial-cache-qa) run: npm run fetch-tutorials -- --target hugo --channel qa 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 @@ -270,6 +275,11 @@ jobs: # "TypeError: fetch failed" since no local CAP runs in CI. The # build is target-aware so qa fetches its own QA-channel catalog. CAP_BASE_URL: ${{ steps.cap-url.outputs.url }} + # mta.yaml's before-all re-runs the composing fetch-tutorials during + # `mbt build`, so the snippet gate must be set here too — otherwise + # repo-snippet `::include` throws include-not-found (now fatal) inside + # the MTA build even though the prefetch steps above resolved it. + SNIPPETS_ENABLED_REPOS: meta-tutorials # APPROUTER_URL for asset-hash-retention (Task 5): allows mta.yaml's # before-all retention step to fetch the currently-deployed approuter's # _retained-assets.json and carry hashed bundles forward. Maps per-env diff --git a/.github/workflows/rebuild-content-qa.yml b/.github/workflows/rebuild-content-qa.yml index b9c8c2b67..b4119b2da 100644 --- a/.github/workflows/rebuild-content-qa.yml +++ b/.github/workflows/rebuild-content-qa.yml @@ -177,6 +177,12 @@ jobs: # (catalog content is the same; QA channel only differs in tutorial # source repos via ONLY_CONTRIBUTION_REPOS=true). CAP_BASE_URL: ${{ secrets.CAP_SRV_URL_DEV }} + # Enable `::include` snippet resolution from repo `_snippets/` dirs. + # fetchSnippets() (scripts/parsers/github.ts) returns an empty map when + # this is unset, making every repo-snippet `::include` throw + # directive/include-not-found at compose time — now fatal (38c13118b). + # Mirror rebuild-content.yml so QA composes identically to prod. + SNIPPETS_ENABLED_REPOS: meta-tutorials TUTORIAL_SLUG: ${{ github.event.client_payload.slug || inputs.slug }} # Multi-slug (N-tutorial push) companion to TUTORIAL_SLUG. The notify # template emits a validated comma-separated client_payload.slugs when diff --git a/.gitignore b/.gitignore index bbe5e43c2..258fd606d 100644 --- a/.gitignore +++ b/.gitignore @@ -195,9 +195,11 @@ playwright-report/ srv/lib/_shared/ srv-mcp/lib/_shared/ srv-qa/lib/_shared/ +srv-sage/lib/_shared/ # BTP→BAIP audit run artifacts (export/report/changeset/applied) /btp-audit/ # Discovery sync working drafts — local only, never committed. .sync-draft/ +srv-sage/lib/parsers.bundle.mjs diff --git a/CLAUDE.md b/CLAUDE.md index 5821c3f64..0af1cff9a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -159,4 +159,4 @@ The load-bearing few. **Full detail for every relocated item → [tutorials-ims- - **External channels subsystem** — `Channels` entity (`db/channels.cds`) is the source of truth; re-ingest via `npm run seed-channels`; directory at `/channels` (baked by `fetch-channels` in `build:all`); verb-lane fill via `npm run promote-channels`; community items never land in `START_HERE`. → [channels.md](docs/developers/reference/channels.md). - **TechEd sessions subsystem (#2312)** — new `TechEd*` entities (`db/external/teched.cds`, NOT reused `CommunityEvents`), loaded via a **`using` side-effect** in `db/external-content.cds` (don't delete the import); RainFocus ingest (`POST https://events.rainfocus.com/api/sessions`, headers `rfapiprofileid`/`rfwidgetid` per venue from `RAINFOCUS_{TE26,TEV26}_PROFILE`/`_WIDGET` env — live-confirmed defaults baked in, IDs may rotate; speakers embedded in `participants[]`, tracks in `attributevalues[attribute=="Track"]`, offset-paginated); idempotent seed via `scripts/seed-teched.cjs`; public `/build/teched` feed; corrected fetcher + delta cron jobs shipped in #2332; `/teched/` page + island, KG projection, embeddings, and Devtoberfest cross-linking are later units. → [teched.md](docs/developers/reference/teched.md). - **Signed provenance envelope (#2245)** — `PROVENANCE_ENVELOPE_ENABLED` (DB config, default OFF, DEV-first); two anonymous Express endpoints (`/content/tutorials/:slug/provenance` and `/.well-known/tutorial-provenance/jwks.json`); signing key = `PROVENANCE_SIGNING_KEY` credstore secret (Ed25519 PKCS8 PEM); rotate via `/admin-ui/#secrets`. Fail-open. → gotchas.md "Signed provenance envelope". -- **Optimized draft deletion `draft_admin_integrity` is OFF (#2909 / #2993, CAP 10.2)** — `cds.fiori.draft_admin_integrity: false` in package.json (all profiles). It was briefly enabled but shipped to PROD WITHOUT the required HANA `ON DELETE CASCADE` constraints, orphaning draft rows and making missions un-editable (`DRAFT_ALREADY_EXISTS` / `Not Found`, no discard affordance) — the 2026-11-02 PROD outage. Disabled for all profiles; draft deletion uses the pre-10.2 per-row `after('DELETE')` child hooks + `after('DISCARD')` root reconcile. The real draft shadow tables are `ADMINSERVICE_*_DRAFTS` (NOT `com_sap_developers_ims_*_drafts`). Orphan sweep: `scripts/cleanup-draft-orphans.cjs --commit` (deletes draft rows whose `DraftAdministrativeData_DraftUUID` has no admin-data parent; preserves live drafts). Re-enabling the `dad` strategy is blocked on an unresolved HDI make-graph problem for the cascade `.hdbconstraint` (inline FK → error 8250014; standalone constraint → 8212001 on delta deploy) — tracked in #2993; the flag must stay OFF until that deploys cleanly to a real HANA container. → gotchas.md "Optimized draft deletion". Re-enable runbook: docs/developers/operations/draft-integrity-reenable.md. +- **Optimized draft deletion `draft_admin_integrity` is OFF (#2909 / #2993, CAP 10.2)** — `cds.fiori.draft_admin_integrity: false` in package.json (all profiles). It was briefly enabled but shipped to PROD WITHOUT the required HANA `ON DELETE CASCADE` constraints, orphaning draft rows and making missions un-editable (`DRAFT_ALREADY_EXISTS` / `Not Found`, no discard affordance) — the 2026-11-02 PROD outage. Disabled for all profiles; draft deletion uses the pre-10.2 per-row `after('DELETE')` child hooks + `after('DISCARD')` root reconcile. The real draft shadow tables are `ADMINSERVICE_*_DRAFTS` (NOT `com_sap_developers_ims_*_drafts`). Orphan sweep: `scripts/cleanup-draft-orphans.cjs --commit` (deletes draft rows whose `DraftAdministrativeData_DraftUUID` has no admin-data parent; preserves live drafts). Re-enable is in progress under #2993: constraints are CAP-native (`createDraftAdminDataConstraints` in `@sap/cds-compiler` 7.2.1, 46 × `NOT VALIDATED ON DELETE CASCADE`) — the real blocker was the project root deduping `@sap/cds-compiler` to 7.0.1 (no draft-constraint code); fixed by a `package.json` overrides pin. Build-level proof done (46 constraints emit locally); deploy-level proof (HANA delta deploy + preflight `verified (46/46)` + dad-hook audit) is pending. Flag stays OFF until the HANA deploy is green. → gotchas.md "Optimized draft deletion". Re-enable runbook: docs/developers/operations/draft-integrity-reenable.md. diff --git a/approuter/xs-app.json b/approuter/xs-app.json index c4101e21a..70151a52a 100644 --- a/approuter/xs-app.json +++ b/approuter/xs-app.json @@ -302,6 +302,13 @@ "destination": "srv-api", "authenticationType": "xsuaa" }, + { + "source": "^/admin/data-privacy/(.*)$", + "target": "/admin/data-privacy/$1", + "destination": "srv-api", + "authenticationType": "xsuaa", + "scope": "$XSAPPNAME.Admin" + }, { "source": "^/admin/(.*)$", "target": "/admin/$1", diff --git a/db/last-dev/csn.json b/db/last-dev/csn.json index 4acd32589..f00464bf7 100644 --- a/db/last-dev/csn.json +++ b/db/last-dev/csn.json @@ -8008,7 +8008,7 @@ } }, "meta": { - "creator": "CDS Compiler v7.0.1", + "creator": "CDS Compiler v7.2.1", "compilerCsnFlavor": "$internal", "flavor": "inferred", "sap.changelog.enhanced": true, diff --git a/deploy/mta-sage-dev.mtaext b/deploy/mta-sage-dev.mtaext new file mode 100644 index 000000000..6206b659d --- /dev/null +++ b/deploy/mta-sage-dev.mtaext @@ -0,0 +1,14 @@ +_schema-version: 3.3.0 +# DEV extension for the SAGE backend MTA (mta-sage.yaml). +# No parameter overrides needed for DEV — tutorials-xsuaa is the correct +# XSUAA instance name in the dev space. This file exists as a parallel to +# mcp-dev.mtaext so the deploy command is symmetric: +# mbt build -f mta-sage.yaml -t mta_archives +# cf deploy mta_archives/*.mtar -e deploy/mta-sage-dev.mtaext -f +# +# Deploy DEV (from origin/DEV; cf target -s dev FIRST): +# git fetch origin && git checkout origin/DEV +# mbt build -f mta-sage.yaml -t mta_archives +# cf deploy mta_archives/*.mtar -e deploy/mta-sage-dev.mtaext -f +ID: tutorials-sage-dev +extends: tutorials-sage diff --git a/deploy/mta-sage-prod.mtaext b/deploy/mta-sage-prod.mtaext new file mode 100644 index 000000000..f35dc752e --- /dev/null +++ b/deploy/mta-sage-prod.mtaext @@ -0,0 +1,25 @@ +_schema-version: 3.3.0 +# PROD extension for the SAGE backend MTA (mta-sage.yaml). +# +# tutorials-xsuaa service-name → xsuaa-imsprod. DEV+PROD share one +# subaccount, so prod's XSUAA instance has a distinct name (xsuaa-imsprod, +# with xsappname 'tutorials-prod'); it is deployed and OWNED by the main +# tutorials-ims MTA (see deploy/prod.mtaext). srv-sage adopts it as an +# existing service for the XSUAA-fallback leg of its hybrid auth. The base +# mta-sage.yaml hardcodes service-name: tutorials-xsuaa (the DEV name), +# which does not exist in prod — without this override the SAGE MTA deploy +# fails to resolve the existing service. We only rename the binding target; +# we do NOT set config-path here (the main MTA owns + configures +# xsuaa-imsprod from xs-security-prod.json). +# +# Deploy PROD (from origin/main; cf target -s prod FIRST): +# git fetch origin && git checkout origin/main +# mbt build -f mta-sage.yaml -t mta_archives +# cf deploy mta_archives/*.mtar -e deploy/mta-sage-prod.mtaext -f +ID: tutorials-sage-prod +extends: tutorials-sage + +resources: + - name: tutorials-xsuaa + parameters: + service-name: xsuaa-imsprod diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 17010771b..59604c4d5 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -222,6 +222,7 @@ export default defineConfig({ { text: 'Content rollback', link: '/developers/operations/content-rollback' }, { text: 'Rotate CONTENT_API_KEY', link: '/developers/operations/rotate-content-api-key' }, { text: 'Runtime config', link: '/developers/operations/runtime-config' }, + { text: 'SAGE IAS setup', link: '/developers/operations/sage-ias-setup' }, { text: 'Scheduler troubleshooting', link: '/developers/operations/scheduler-troubleshooting' }, { text: 'Secrets tracking', link: '/developers/operations/secrets-tracking' }, { text: 'Sign-in SSO re-auth follow-up', link: '/developers/operations/signin-sso-reauth-followup' }, diff --git a/docs/developers/operations/draft-integrity-reenable.md b/docs/developers/operations/draft-integrity-reenable.md index 16dac409d..512d734d8 100644 --- a/docs/developers/operations/draft-integrity-reenable.md +++ b/docs/developers/operations/draft-integrity-reenable.md @@ -1,18 +1,22 @@ # Safely Re-enabling `draft_admin_integrity` on Production -**Status:** DEFERRED — This runbook documents the SAFE re-enable procedure for `cds.fiori.draft_admin_integrity`. The flag is currently **disabled** (`false` in `package.json`). Re-enable ONLY after all green checks — another outage is unacceptable. This runbook exists so it CAN be done safely when the decision is made; it is NOT an instruction to do it now. +**Status:** IN PROGRESS (build-level proof done; deploy-level pending live HANA) — This runbook documents the SAFE re-enable procedure for `cds.fiori.draft_admin_integrity`. The flag is currently **disabled** (`false` in `package.json`). Re-enable ONLY after all green checks — another outage is unacceptable. This runbook exists so it CAN be done safely when the decision is made; it is NOT an instruction to do it now. **Context:** - Issue #2909: introduced the flag (CAP 10.2) + missing cascade constraints → PROD outage. - Issue #2968: added the preflight check `srv/lib/draft-integrity-preflight.js`. - Issue #2992: disabled the flag for all profiles and fixed the preflight (it had queried non-existent `com_sap_developers_ims_*_drafts` names instead of the real `ADMINSERVICE_*_DRAFTS` discovered from `SYS.TABLE_COLUMNS`). - Issue #2994: added the orphan cleanup sweep `scripts/cleanup-draft-orphans.cjs`. -- Issue #2993 (this work): added the build-time FK injection `scripts/patch-draft-cascade-constraints.cjs`, the gate test `test/admin-drafts-cascade-gate.test.js`, and this runbook. +- Issue #3003: reverted a hand-rolled constraint attempt (`scripts/patch-draft-cascade-constraints.cjs`) that blocked all MTA deploys (HDI errors 8250014 / 8212001 / 8212012). Hand-rolling is the rejected approach; do not reintroduce it. +- Issue #2993 (this work): pinned `@sap/cds-compiler` to 7.2.1 (root had deduped to 7.0.1, which has no draft-constraint code) so CAP emits the 46 native cascade constraints through the `hdbmigrationtable` build path; added the gate test `test/admin-drafts-cascade-gate.test.js`. **Key facts:** -- The inline FK (`FOREIGN KEY ... ON DELETE CASCADE` inside the `COLUMN TABLE (...)` body) is created **ENFORCED** by HANA — `NOT VALIDATED` is an `ALTER TABLE` affordance only and cannot be specified inline. This means orphaned draft rows **must be swept BEFORE the constraint-bearing HDbtable is deployed**, or HANA will reject the deploy. +- CAP's compiler (`createDraftAdminDataConstraints` in `@sap/cds-compiler` 7.2.1, `lib/transform/forRelationalDB.js`) emits the draft cascade constraints **natively** when `cds.fiori.draft_admin_integrity: true` + non-plain `sqlDialect`. The `package.json` `overrides` pin (`"@sap/cds-compiler": "7.2.1"`) ensures the right compiler is used; without it the root deduped to 7.0.1 (no draft constraint code). +- There are exactly **46 constraints**, one per `*_drafts` shadow table: `ON DELETE CASCADE`, **NOT VALIDATED**, ENFORCED, INITIALLY DEFERRED. FK: `AdminService__drafts.DraftAdministrativeData_DraftUUID → DRAFT_DraftAdministrativeData(DraftUUID)`. +- The constraints are **NOT VALIDATED** — pre-existing orphan rows do **not** block the deploy. The old "sweep orphans before deploy" premise was specific to hand-rolled ENFORCED inline FKs (reverted in #3003) and is void for the native path. - `CDS_*` env-var overrides do NOT reach `cds.fiori.draft_admin_integrity` on deployed builds — only the baked `package.json` value counts. -- Preflight is HANA-only and fail-open; SQLite unit tests do not require cascade FKs. +- Constraint generation is independent of `cds.features.assert_integrity` (the global FK switch). Do not enable that flag; it is a non-goal. +- Preflight is HANA-only and fail-open; SQLite unit tests do not require cascade constraints. --- @@ -22,58 +26,59 @@ - [ ] You have `cf login` credentials for the target environment (DEV first, then PROD). - [ ] Node.js 22+ and `npm` are installed locally. - [ ] `@sap/cds-dk` is globally available (`cds --version`). +- [ ] `cds build --production` emits 46 `AdminService.*_drafts_DraftAdministrativeData.hdbconstraint` files into `gen/db` (build-level proof; verified locally in #2993 Task 1). --- -## Step 1: Sweep Orphaned Drafts (Dry-Run First) +## Step 1: Verify Build Emits 46 Constraints -The inline FK is ENFORCED — HANA will reject deploying the constraint if orphaned draft rows already exist in the schema. Sweep orphans **before** deploying the constraint-bearing build. +Confirm the local build produces the 46 native cascade constraints. **This does NOT require live HANA.** -**Locally, with credentials bound to the target environment:** +```bash +npm run build:all +# or for the CAP-only build: +cds build --production +``` -1. Set up the service binding (one-time): - ```bash - npm run bind:setup # if this is your first hybrid run - ``` +After the build, count the constraint files: -2. Run a dry-run to inspect any orphans: - ```bash - npx cds bind --exec -- node scripts/cleanup-draft-orphans.cjs --dry-run - ``` +```bash +ls gen/db/src/gen/ | grep -c '\.hdbconstraint$' +``` -3. **Expected output:** Zero orphans found: - ``` - Scanning for orphaned drafts... - Found 0 orphaned draft rows. (All clean.) - ``` +**Expected:** `46` + +If the count is wrong: +- Confirm `@sap/cds-compiler` resolves to 7.2.1 (`node -e "console.log(require('@sap/cds-compiler/package.json').version)"` from the project root). +- Confirm `package.json` has `"overrides": { "@sap/cds-compiler": "7.2.1" }` (or equivalent `resolutions`). +- Run `npm install` and retry. -4. **If orphans are found**, inspect them (the script prints details) and decide whether to proceed. If you expect orphans from the #2909 outage: - - Commit/note the findings. - - Run WITHOUT `--dry-run` to delete: - ```bash - npx cds bind --exec -- node scripts/cleanup-draft-orphans.cjs --commit - ``` - - Verify the count matches the dry-run scan. - - Re-run dry-run to confirm zero before proceeding. +**Do NOT proceed to Step 2 if the count is not 46.** --- -## Step 2: Deploy with Cascade Constraints (Flag Still `false`) +## Step 2: Deploy to Target HANA (Constraints, Flag Still `false`) -The Task 1 patch `scripts/patch-draft-cascade-constraints.cjs` already injects `ON DELETE CASCADE` foreign keys into the 46 draft tables in the generated `gen/db/src/gen/AdminService.*_drafts.hdbtable` files. +The constraints are **NOT VALIDATED** — they deploy safely over any existing schema, even if orphaned draft rows are present. No pre-sweep is required as a deploy precondition. -**On the target environment (DEV or PROD), after Step 1 confirms zero orphans:** +Before deploying, crack the mtar archive and confirm the `.hdbconstraint` files are present (same pattern as the Step 3.5 admin-bundle check in `scripts/check-shipped-admin-bundle.cjs`): -1. Ensure the MTA includes the latest `cds build --production` output with the patched constraints. -2. Deploy the MTA as usual (e.g., `npm run deploy -- --env dev` or via CI/CD): - ```bash - npm run build:all - cd .deploy && mbt build && cf deploy mta_archives/*.mtar -e ../deploy/dev.mtaext -f - ``` -3. The FK is enforced — a clean schema (zero orphans from Step 1) is the precondition for the deploy to succeed. -4. Verify deployment success and CAP service startup. +```bash +# After mbt build completes: +unzip -l .deploy/mta_archives/*.mtar | grep hdbconstraint | wc -l +``` + +**Expected:** `46` -**Note:** The constraints land on every build already (while `draft_admin_integrity` is `false`). This step ensures they have deployed to the target environment HANA schema with a clean baseline. +Deploy to DEV first: + +```bash +export CAP_BASE_URL="https://tutorial-system-dev-tutorials-srv.cfapps.eu10-005.hana.ondemand.com" +npm run build:all +cd .deploy && mbt build && cf deploy mta_archives/*.mtar -e ../deploy/dev.mtaext -f +``` + +**Verify deployment success and CAP service startup before proceeding.** --- @@ -83,99 +88,132 @@ After deployment, the CAP service logs startup messages. Look for the preflight **Expected log:** ``` -[draft-integrity-preflight] verified (N/N) +[draft-integrity-preflight] verified (46/46) ``` -where N is the count of verified draft tables (typically 46 for Admin/Mission/Group/Author services + compositions). + +The preflight discovers tables from `SYS.TABLE_COLUMNS` at runtime — it does not use a hardcoded list. **If you see a WARN instead:** ``` [draft-integrity-preflight] ⚠ missing: ``` -**STOP.** The constraints are incomplete or not deployed. Do not proceed to Step 4. Investigate: -- Is the MTA's `gen/db` module serving the patched HDbtable files? -- Did the HANA HDI deployment succeed (check `cf logs --recent`)? -- Run `cds build --production` locally and verify `gen/db/src/gen/AdminService.*_drafts.hdbtable` files contain the `ON DELETE CASCADE` clause. +**STOP.** The constraints are incomplete or not deployed. Investigate: +- Is the mtar's `gen/db` module serving the `.hdbconstraint` files? Re-check Step 2 — was the mtar verified to contain 46 `.hdbconstraint` files before deploy? +- Did the HANA HDI deployment succeed? Check `cf logs --recent`. +- Confirm `@sap/cds-compiler` version in the deployed build (check package-lock.json on the branch that was built). ---- +**Do NOT proceed to Step 4 until the preflight logs `verified (46/46)`.** -## Step 4: Run the Gate Test (Mission Draft Lifecycle) +### Optional: baseline orphan check -The gate test `test/admin-drafts-cascade-gate.test.js` verifies that Mission draftEdit + discard leaves zero orphaned child drafts. +The NOT VALIDATED constraints mean pre-existing orphans do not block deployment. However, running a dry-run gives a clean baseline reading for the smoke step later: -**Locally:** ```bash -npx vitest run test/admin-drafts-cascade-gate.test.js +npm run bind:setup # if this is your first hybrid run +npx cds bind --exec -- node scripts/cleanup-draft-orphans.cjs --dry-run ``` -**Expected:** All tests pass (green), including: -- Draft creation, edit, and discard lifecycle. -- Zero orphaned `Missions.drafts` rows after discard. -- Zero orphaned `CompletionPathItems.drafts` rows after parent discard. - -**If the test fails,** re-examine Step 1–3. Do NOT proceed to Step 5 until this test is green. +This is informational only — it is not a deploy gate. --- -## Step 5: Flip the Flag in `package.json` - -**ONLY after Steps 1–4 are green on the target environment**, update the flag: +## Step 4: Flip the Flags in `package.json` -1. Edit `package.json`: - - Line ~461: find the `"cds": { "fiori": { ... } }` block and set `"draft_admin_integrity": true`. - - Line ~486: find the `"[development]": { "cds": { "fiori": { ... } } }` block and set `"draft_admin_integrity": true`. +**ONLY after Steps 1–3 are green on DEV**, update the three flags: -2. Example (before): +1. Edit `package.json` — find the `"cds": { "fiori": { ... } }` block (two occurrences: top-level and `[development]`) and set: ```json "cds": { "fiori": { - "draft_admin_integrity": false - } - } - ``` - Example (after): - ```json - "cds": { - "fiori": { - "draft_admin_integrity": true + "draft_admin_integrity": true, + "draft_orphan_cleanup": true + }, + "drafts": { + "deleteStrategy": "dad" } } ``` -3. Commit and push the change: +2. Commit and push: ```bash git add package.json - git commit -m "feat(config): enable draft_admin_integrity globally (#2993)" + git commit -m "feat(config): enable draft_admin_integrity + orphan_cleanup + dad (#2993)" git push origin ``` -4. Run a fresh build with the flag ON: +3. Rebuild and redeploy DEV: ```bash npm run build:all + cd .deploy && mbt build && cf deploy mta_archives/*.mtar -e ../deploy/dev.mtaext -f ``` -5. Deploy to the target environment: +--- + +## Step 5: Audit `after('DISCARD')` / `after('DELETE')` Reconcile Hooks Under `dad` + +**This step is PROD-blocking.** CAP's `dad` (Draft Admin Data) delete strategy changes which event handlers fire during draft deletion — the DB cascade may bypass app-level reconcile hooks. + +This project has custom reconcile handlers: +- `srv/lib/completion-reconcile.js` +- `srv/lib/pipeline-log-reconciler.js` +- `srv/lib/topic-cluster-reconcile.js` + +These are tested in `test/admin-drafts-discard-reconcile.test.js` under the flag-OFF path. Under `dad`, verify they still fire: + +1. Run the existing reconcile test suite: ```bash - cd .deploy && mbt build && cf deploy mta_archives/*.mtar -e ../deploy/dev.mtaext -f + npx vitest run test/admin-drafts-discard-reconcile.test.js ``` + This is a SQLite-level test and is flag-agnostic — passing it is necessary but not sufficient. + +2. **Add a HANA-level test** (or perform a manual verification on DEV) confirming each `after('DISCARD')` / `after('DELETE')` reconcile side effect still fires after a `dad` draft discard. The SQLite gate test cannot catch a bypass; HANA is required. + +**Do NOT proceed to Step 6 (PROD) until the hook audit on DEV is confirmed.** + +--- + +## Step 6: Run the Gate Test (Mission Draft Lifecycle) + +The gate test `test/admin-drafts-cascade-gate.test.js` verifies that Mission draftEdit + discard leaves zero orphaned child drafts. This test runs against local SQLite — it confirms business logic under the flag, not the deployed HANA schema. The Step 3 preflight and Step 5 hook audit cover the HANA side. + +```bash +npx vitest run test/admin-drafts-cascade-gate.test.js +``` + +**Expected:** All tests pass, including: +- Draft creation, edit, and discard lifecycle. +- Zero orphaned `Missions.drafts` rows after discard. +- Zero orphaned `CompletionPathItems.drafts` rows after parent discard. + +**If the test fails,** re-examine Steps 1–5. Do NOT proceed to Step 7 until this test is green. --- -## Step 6: Smoke Test – Mission Discard on Deployed Environment +## Step 7: Smoke Test – Mission Discard on Deployed DEV -After the re-deployed service is running with the flag `true`, verify the behavior end-to-end: +After the re-deployed DEV service is running with the flags `true`, verify end-to-end: 1. **Via Admin UI** (`/admin-ui/#/admin/missions`): - - Create or open an existing Mission draft. - - Edit it (add a step, change the title, etc.). - - Click **Discard** (or equivalent button). - - Expected: Discard succeeds; no orphaned rows left in `Missions.drafts` or child composition tables. + - Open an existing Mission draft (or create one). + - Edit it (change the title or add a step). + - Click **Discard** (or equivalent). + - Expected: Discard succeeds; no orphaned rows in `Missions.drafts` or child composition tables. -2. **Verify no errors in the server logs:** +2. **Verify in the server logs:** ```bash - cf logs --recent | grep -i error + cf logs --recent | grep -i "error\|draft" ``` -3. **If discard fails or errors appear,** rollback the flag to `false`, redeploy, and investigate the error. Escalate to the team. +3. **If discard fails or errors appear,** roll back (see Rollback Plan below) and investigate before attempting PROD. + +--- + +## Environment Order + +**Always test DEV first (Steps 1–7), then repeat Step 2 → Step 5 on PROD.** + +- **DEV:** Lower risk; catch any logic gaps before production. +- **PROD:** Only after DEV smoke passes for at least 2–4 hours without incident. --- @@ -183,10 +221,12 @@ After the re-deployed service is running with the flag `true`, verify the behavi If any step fails or the deployed service encounters errors: -1. Revert the flag to `false` in `package.json` (Steps 1–2): +1. Revert the flags in `package.json`: ```json - "draft_admin_integrity": false + "draft_admin_integrity": false, + "draft_orphan_cleanup": false ``` + (Remove `deleteStrategy: dad` or revert to its prior value.) 2. Commit, push, and redeploy: ```bash @@ -197,18 +237,16 @@ If any step fails or the deployed service encounters errors: cd .deploy && mbt build && cf deploy mta_archives/*.mtar -e ../deploy/.mtaext -f ``` -3. The enforced constraints remain in the schema but the flag controls whether the runtime relies on them. With the flag `false` the app-level reconcile path runs instead, so the deployed constraints are dormant but harmless. +3. The cascade constraints remain in the schema but are inert without the flag — no orphan risk. The app-level reconcile path resumes. -4. Investigate the root cause before attempting re-enable again. Involve the team. - ---- - -## Environment Order - -**Always test DEV first, then PROD.** +4. If orphaned drafts accumulated during the flag-ON window, sweep them: + ```bash + npx cds bind --exec -- node scripts/cleanup-draft-orphans.cjs --dry-run + # Review output, then: + npx cds bind --exec -- node scripts/cleanup-draft-orphans.cjs --commit + ``` -- **DEV:** Lower risk; catch any logic gaps before production. -- **PROD:** Only after DEV smoke test passes for at least 2–4 hours without incident. +5. Investigate and involve the team before retrying. --- @@ -218,7 +256,8 @@ If any step fails or the deployed service encounters errors: - **#2968:** Added the preflight check `srv/lib/draft-integrity-preflight.js`. - **#2992:** Disabled the flag for all profiles and fixed the preflight (queried non-existent `com_sap_developers_ims_*_drafts` instead of real `ADMINSERVICE_*_DRAFTS` from `SYS.TABLE_COLUMNS`). - **#2994:** Added the orphan cleanup sweep `scripts/cleanup-draft-orphans.cjs`. -- **#2993:** Added the build-time FK injection `scripts/patch-draft-cascade-constraints.cjs`, the gate test `test/admin-drafts-cascade-gate.test.js`, and this runbook. +- **#3003:** Reverted hand-rolled constraint script (`scripts/patch-draft-cascade-constraints.cjs`) — blocked MTA deploys with HDI errors 8250014 / 8212001 / 8212012; do not reintroduce. +- **#2993 (this work):** Pinned `@sap/cds-compiler` to 7.2.1 so CAP emits 46 native `NOT VALIDATED` cascade constraints through the `hdbmigrationtable` build path; added gate test; rewrote this runbook. --- diff --git a/docs/developers/operations/mta-deployment.md b/docs/developers/operations/mta-deployment.md index f7d9b9120..b91f2664c 100644 --- a/docs/developers/operations/mta-deployment.md +++ b/docs/developers/operations/mta-deployment.md @@ -4,7 +4,7 @@ Complete deployment procedure for standing up the tutorials-ims stack in a CF sp ## Architecture -The stack is **two separately-deployed MTAs** sharing one set of service instances: +The stack is **three separately-deployed MTAs** sharing one set of service instances: ```text tutorials-ims MTA (.deploy/mta.yaml — the main MTA; OWNS the service instances) @@ -17,21 +17,29 @@ tutorials-ims MTA (.deploy/mta.yaml — the main MTA; OWNS the service instance tutorials-mcp MTA (mta-mcp.yaml at repo root — the MCP microservice; ADOPTS the services above) └── tutorials-srv-mcp (type: nodejs — serves ONLY the authenticated /mcp-auth/* surface) -Resources (created/owned by the MAIN MTA; the MCP MTA references them as existing-service): -├── tutorials-hana (HDI container — com.sap.xs.hdi-container) -├── tutorials-xsuaa (XSUAA application — org.cloudfoundry.managed-service) -├── tutorials-identity (IAS — public PKCE client for the MCP app) -├── tutorials-destination (Destination lite — org.cloudfoundry.managed-service) -├── tutorials-credstore (Credential Store — holds deploy-time secrets) -├── tutorials-mail (optional — fails gracefully if plan unavailable) -├── tutorials-audit-log (optional) -└── tutorials-cloud-logging (optional) +tutorials-sage MTA (mta-sage.yaml at repo root — the SAGE isolated backend; ADOPTS the services above) +└── tutorials-srv-sage (type: nodejs — serves ONLY the SAGE author operations surface) + +Resources (created/owned by the MAIN MTA; the MCP and SAGE MTAs reference them as existing-service): +├── tutorials-hana (HDI container — com.sap.xs.hdi-container) +├── tutorials-xsuaa (XSUAA application — org.cloudfoundry.managed-service) +├── tutorials-identity (IAS — public PKCE client for the MCP app) +├── tutorials-destination (Destination lite — org.cloudfoundry.managed-service) +├── tutorials-credstore (Credential Store — holds deploy-time secrets) +├── tutorials-mail (optional — fails gracefully if plan unavailable) +├── tutorials-audit-log (optional) +└── tutorials-cloud-logging (optional) + +Resources (created/owned OUT-OF-BAND; the SAGE MTA references as existing-service): +└── tutorials-sage-identity (IAS — dedicated public PKCE client for the SAGE VS Code extension; + provisioned per docs/developers/operations/sage-ias-setup.md) ``` The approuter (main MTA) fronts both backends: `/mcp-auth/*` is proxied to the external `tutorials-srv-mcp` app via the `srv-mcp-api` destination (`${srv-mcp-url}`), everything else -to the local `srv-api`. The MCP MTA creates **no** service instances of its own — it declares -each resource as `org.cloudfoundry.existing-service` and adopts the main MTA's instances. +to the local `srv-api`. The MCP and SAGE MTAs create **no** service instances of their own — they declare +each resource as `org.cloudfoundry.existing-service` and adopt the main MTA's instances (plus +`tutorials-sage-identity` for the SAGE MTA, which is provisioned out-of-band). ## Prerequisites @@ -109,6 +117,37 @@ space so those instances exist before the MCP MTA tries to adopt them. The appro discovery/routing env (`srv-mcp-url`, `XSUAA_MCP_URL`, `MCP_ISSUER_KIND`) stays in the **main** MTA's `deploy/*.mtaext` (the approuter lives in the main MTA). +### SAGE MTA (`tutorials-sage`) + +The SAGE isolated backend (`/author/*` + `/preview/render`) ships as a **separate MTA** (`mta-sage.yaml` at +repo root, module `tutorials-srv-sage`). It is **not** part of the main MTA archive. +There is **no orchestrated path** — deploy it by hand: + +```bash +# From repo root (the descriptor's before-all runs from root, no `cd ..`) +mbt build -f mta-sage.yaml -t mta_archives +cf deploy mta_archives/*.mtar -e deploy/mta-sage-dev.mtaext -f # DEV +# PROD: cf deploy mta_archives/*.mtar -e deploy/mta-sage-prod.mtaext -f +``` + +| Env | SAGE MTA ext | MTA ID (ext) | Notes | +| --- | --- | --- | --- | +| dev | `deploy/mta-sage-dev.mtaext` | `tutorials-sage-dev` | No overrides needed — `tutorials-xsuaa` is the DEV XSUAA name | +| prod | `deploy/mta-sage-prod.mtaext` | `tutorials-sage-prod` | Overrides `tutorials-xsuaa` → `service-name: xsuaa-imsprod` (PROD XSUAA, xsappname `tutorials-prod`) | + +**Service adoption:** every `resources:` entry in `mta-sage.yaml` is +`org.cloudfoundry.existing-service` (`tutorials-sage-identity`, `tutorials-xsuaa`, +`tutorials-hana`). The SAGE MTA creates no instances — it adopts the ones the **main MTA +owns**, plus the dedicated IAS instance provisioned by the [sage-ias-setup.md](sage-ias-setup.md) +runbook. **Deploy the main MTA first** on a fresh space — `tutorials-hana`, `tutorials-xsuaa`, +and `tutorials-sage-identity` must all exist before `mta-sage.yaml` can adopt them. On an +existing space the instances are already present; deploy order does not matter. + +**Before deploying the SAGE MTA for the first time:** ensure `tutorials-sage-identity` has +been provisioned out-of-band per [sage-ias-setup.md](sage-ias-setup.md) Step 2. This is a +dedicated IAS public-client instance (PKCE-only, no `client_credentials`) separate from the +shared `tutorials-identity` used by the MCP surface. + ## Step 2: Populate Data (First Deploy Only) After a fresh HDI deploy, mission/group slugs are empty. The build pipeline needs slugs to generate pages. @@ -217,8 +256,10 @@ curl -s -o /dev/null -w "%{http_code}" "$APPROUTER/tutorials/abap-dev-get-starte |------|---------| | `.deploy/mta.yaml` | Main MTA (`tutorials-ims`) deployment descriptor | | `mta-mcp.yaml` | MCP MTA (`tutorials-mcp`) descriptor — the separate `/mcp-auth/*` app | +| `mta-sage.yaml` | SAGE MTA (`tutorials-sage`) descriptor — the isolated SAGE author backend | | `deploy/dev.mtaext` | Main-MTA DEV extension (debug logging, app name suffix, `srv-mcp-url`) | | `deploy/mcp-dev.mtaext` / `deploy/mcp-prod.mtaext` | MCP-MTA env extensions | +| `deploy/mta-sage-dev.mtaext` / `deploy/mta-sage-prod.mtaext` | SAGE-MTA env extensions | | `xs-security.json` | XSUAA scopes, role templates, role collections | | `approuter/xs-app.json` | AppRouter route definitions (incl. the `/mcp-auth/*` → `srv-mcp-api` route) | | `.cdsrc-private.json` | Local hybrid bindings (gitignored) | diff --git a/docs/developers/operations/sage-ias-setup.md b/docs/developers/operations/sage-ias-setup.md new file mode 100644 index 000000000..0ec1d9f71 --- /dev/null +++ b/docs/developers/operations/sage-ias-setup.md @@ -0,0 +1,228 @@ +# SAGE IAS Public-Client Setup Runbook + +This runbook provisions a **dedicated IAS public-client instance** (`tutorials-sage-identity`) for the SAGE VS Code extension. SAGE authenticates to IAS via secret-less PKCE (which IAS supports; XSUAA cannot be a public client) and then calls the isolated `srv-sage` backend. + +This is a **Tom-run, out-of-band** provisioning step — no `cf` commands are scripted into version control. The resulting `clientid` and IAS tenant URL are needed for Task 6 (live sign-in verification) and for the SAGE extension's `imsAuth.ts` configuration. + +--- + +## Why a dedicated instance? + +SAGE gets its own `tutorials-sage-identity` instance rather than reusing the shared `tutorials-identity` for audience isolation: an IAS token minted for SAGE's `clientid` cannot be accepted by the MCP or browser surfaces, and vice versa. This mirrors how `tutorials-srv-mcp` is isolated from `tutorials-srv`. + +--- + +## Prerequisites + +- `cf login` targeting the correct space (re-check `cf target` before every mutating command — see [ias-setup.md § CF target drift](ias-setup.md)) +- The IAS service plan `application` must be entitled in the subaccount + +--- + +## Step 1 — Verify CF target before provisioning + +```bash +cf target +# Confirm: space = tutorials-system/dev (for DEV) +# space = tutorials-system/prod (for PROD) +# If wrong: cf target -o tutorials-system -s dev +``` + +--- + +## Step 2 — Create the SAGE IAS instance + +Run **once per space** (DEV and PROD are separate instances, yielding separate `clientid` values). + +### DEV + +```bash +cf target -o tutorials-system -s dev +cf create-service identity application tutorials-sage-identity -c '{ + "oauth2-configuration": { + "grant-types": [ + "authorization_code", + "authorization_code_pkce_s256", + "refresh_token" + ], + "public-client": true, + "redirect-uris": [ + "vscode://sap-tutorials.sage-tutorial-extension/**", + "http://localhost:*/oauth/callback", + "http://127.0.0.1:*/oauth/callback" + ] + } +}' +``` + +### PROD + +```bash +cf target -o tutorials-system -s prod +cf create-service identity application tutorials-sage-identity -c '{ + "oauth2-configuration": { + "grant-types": [ + "authorization_code", + "authorization_code_pkce_s256", + "refresh_token" + ], + "public-client": true, + "redirect-uris": [ + "vscode://sap-tutorials.sage-tutorial-extension/**", + "http://localhost:*/oauth/callback", + "http://127.0.0.1:*/oauth/callback" + ] + } +}' +``` + +**Configuration notes:** + +| Field | Value | Reason | +|---|---|---| +| `grant-types` | `authorization_code`, `authorization_code_pkce_s256`, `refresh_token` | `client_credentials` intentionally omitted — SAGE is a user-facing client, not M2M. **`authorization_code` (the base grant) MUST be present** alongside `authorization_code_pkce_s256`: the IAS broker rejects `refresh_token` unless at least one base grant type (`authorizationCode`/password/implicit/jwtBearer/saml2Bearer) is also set — a PKCE-only list fails with `400 "Refresh flow can only be set, if at least one grant type is set from…"`. This matches the working `tutorials-identity` config (ias-setup.md §M2M). If the broker returns `invalid_grant_type`, check the IAS plan is `application` not `broker`. | +| `public-client` | `true` | No client secret ever — matches the PKCE contract; XSUAA cannot do this, IAS can | +| `redirect-uris` | `vscode://sap-tutorials.sage-tutorial-extension/**` | VS Code custom-scheme callback (required for PKCE in-extension) | +| `redirect-uris` | `http://localhost:*/oauth/callback`, `http://127.0.0.1:*…` | Local dev / test runner loopback | + +> **Do NOT add `client_credentials` to this instance** — SAGE is a user-facing VS Code extension. The local `localhost` URIs are for development and test; they are harmless for a public client. + +--- + +## Step 3 — Read back the clientid and IAS tenant URL + +After creation, extract the credentials that the extension and backend need. + +```bash +# Create a temporary service key to read the credentials +cf create-service-key tutorials-sage-identity sk-read + +# Strip the CF header so jq can parse +cf service-key tutorials-sage-identity sk-read | sed -n '/{/,$p' > sage-sk.json + +# Print the values you need +jq -r '"clientid: " + .credentials.clientid' sage-sk.json +jq -r '"url: " + .credentials.url' sage-sk.json + +# Clean up — the key is not needed further; credentials are read once +cf delete-service-key tutorials-sage-identity sk-read -f +rm -f sage-sk.json +``` + +> **`sage-sk.json` is transient** — it must be removed immediately after use and never committed (the `rm -f` above covers the happy path). If this block exits early (e.g. `jq` not found, CF error), clean up manually: +> ```bash +> cf delete-service-key tutorials-sage-identity sk-read -f && rm -f sage-sk.json +> ``` + +The `url` field is the IAS tenant root (e.g. `https://atxgsg7zi.accounts.ondemand.com`). +The `clientid` is the OAuth2 client identifier SAGE presents in its PKCE flow. + +Record both values: + +| Value | Where used | +|---|---| +| `clientid` (DEV) | `imsAuth.ts` `clientId` field for the DEV/testing build of SAGE | +| `clientid` (PROD) | `imsAuth.ts` `clientId` field for the stable PROD build of SAGE | +| `url` (IAS tenant root) | `authUrl` → `/oauth2/authorize`, `tokenUrl` → `/oauth2/token` | + +> **Never commit these values to source** — they are runtime config in the extension's `package.json` contributes or environment-specific build constants, not in VCS. `sage-sk.json` is a transient file; remove it immediately after use. + +--- + +## Step 4 — Add or update redirect URIs (if updating an existing instance) + +If the instance already exists and you need to add or change redirect URIs (e.g. a new VS Code extension ID), use `cf update-service`. Always carry forward all existing URIs additively — omitting a URI removes it and breaks live sessions: + +```bash +cf update-service tutorials-sage-identity -c '{ + "oauth2-configuration": { + "grant-types": [ + "authorization_code", + "authorization_code_pkce_s256", + "refresh_token" + ], + "public-client": true, + "redirect-uris": [ + "vscode://sap-tutorials.sage-tutorial-extension/**", + "http://localhost:*/oauth/callback", + "http://127.0.0.1:*/oauth/callback" + ] + } +}' +``` + +> **Note:** `cf update-service -c` replaces the entire `oauth2-configuration` object. Always include the full desired config in a single call, not just the delta. + +--- + +## Step 5 — Adopt the instance in `mta-sage.yaml` + +The `srv-sage` MTA adopts `tutorials-sage-identity` as an `existing-service` (the same pattern used by the MCP MTA for `tutorials-identity`). The relevant stanza in `mta-sage.yaml` will look like: + +```yaml +resources: + - name: tutorials-sage-identity + type: org.cloudfoundry.existing-service + parameters: + service-name: tutorials-sage-identity +``` + +And the `tutorials-srv-sage` module binds it: + +```yaml +modules: + - name: tutorials-srv-sage + ... + requires: + - name: tutorials-sage-identity + - name: tutorials-hana + - name: tutorials-xsuaa # hybrid fallback — DEV name +``` + +> **PROD XSUAA name differs.** On DEV the XSUAA instance is `tutorials-xsuaa`; on PROD it is `xsuaa-imsprod`. The `mta-sage.yaml` PROD variant (or `.mtaext` override) must reference `xsuaa-imsprod` as the `existing-service` name — using `tutorials-xsuaa` on PROD will fail the deploy with a "service not found" error: +> +> ```yaml +> # deploy/mta-sage-prod.mtaext (or prod resource block) +> resources: +> - name: tutorials-xsuaa +> parameters: +> service-name: xsuaa-imsprod # override for PROD space +> ``` + +**Deploy the main MTA before the SAGE MTA** on a fresh space — `tutorials-sage-identity` must exist before `mta-sage.yaml` can adopt it. On an existing space the instances are already there; order does not matter. + +--- + +## Step 6 — Verify the instance is a public client + +Read back the **instance's own `oauth2-configuration`** and confirm `public-client: true` persisted. This is the authoritative per-client check: + +```bash +cf service tutorials-sage-identity --params | sed -n '/{/,$p' \ + | jq '."oauth2-configuration" | {public_client: .["public-client"], grant_types: .["grant-types"], redirect_uris: .["redirect-uris"]}' +# Expect: public_client = true, grant_types includes "authorization_code" + "authorization_code_pkce_s256", redirect_uris includes the vscode:// URI +``` + +> **Do NOT rely on the tenant `.well-known/openid-configuration`** for this. That endpoint reports **tenant-wide** capabilities (`token_endpoint_auth_methods_supported` lists `tls_client_auth`, `client_secret_basic`, etc.) and will **not** show `none` even when a specific app is correctly a public client — public-client is a per-application property, not a tenant-wide auth method. An earlier version of this runbook checked the tenant metadata for `none`; that check is wrong and was removed. + +If `public-client` is not `true`, re-run Step 2's `cf update-service` with the correct config. + +--- + +## Rollback / decommission + +```bash +# Delete the instance (removes all service keys and bindings first) +cf delete-service tutorials-sage-identity -f +``` + +The main `tutorials-srv` and `tutorials-srv-mcp` are unaffected — they bind `tutorials-identity`, not `tutorials-sage-identity`. + +--- + +## References + +- Design spec: [`docs/superpowers/specs/2026-11-19-sage-ias-isolated-backend-design.md`](../../superpowers/specs/2026-11-19-sage-ias-isolated-backend-design.md) +- Shared IAS + M2M runbook: [`docs/developers/operations/ias-setup.md`](ias-setup.md) — covers `tutorials-identity`, M2M service keys, CF-target-drift warning +- MTA deployment guide: [`docs/developers/operations/mta-deployment.md`](mta-deployment.md) — covers `existing-service` adoption and deploy order +- IAS PKCE public-client constraint: `mta-mcp.yaml:64` comment + design spec §"Root cause" diff --git a/docs/developers/operations/testing-endpoints.md b/docs/developers/operations/testing-endpoints.md index 5c1cad796..ba4e7cc03 100644 --- a/docs/developers/operations/testing-endpoints.md +++ b/docs/developers/operations/testing-endpoints.md @@ -158,6 +158,8 @@ When `EXPOSE_CAP_UI=true` is set on the CAP srv app, these are accessible throug | `/admin/analytics/` | AnalyticsService — `@analytics.exposed` entity surface + `runSelectQuery` action | XSUAA + `Admin` | | `/admin/exports/$metadata` | ExportsService OData metadata | XSUAA + `Admin` | | `/admin/exports/` | ExportsService — `exportLegacyData(format)` action | XSUAA + `Admin` | +| `/admin/data-privacy/$metadata` | DataPrivacyService OData metadata | XSUAA + `Admin` | +| `/admin/data-privacy/` | DataPrivacyService — `exportDataSubject(userId)` function | XSUAA + `Admin` | | `/display/$metadata` | DisplayService OData metadata | XSUAA | | `/display/` | DisplayService — read-only data for event dashboards | XSUAA | | `/drawings/$metadata` | DrawingService OData metadata | XSUAA + `Admin` | diff --git a/docs/superpowers/plans/2026-11-13-ai-graded-yellow-ux.md b/docs/superpowers/plans/2026-11-13-ai-graded-yellow-ux.md new file mode 100644 index 000000000..eecc97117 --- /dev/null +++ b/docs/superpowers/plans/2026-11-13-ai-graded-yellow-ux.md @@ -0,0 +1,265 @@ +# AI-Graded Yellow UX + Reset Fixes — 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:** Make a Yellow (partial) AI-graded answer an explicit, interactive state (editable box + Resubmit/Continue-anyway, no silent unlock), stop the reload-as-fake-green bug, and allow resetting tutorial progress at any point. + +**Architecture:** Three loosely-coupled changes. (1) `grading.ts` persistence migrates from `{correct:boolean}` to `{outcome:'pass'|'accepted'}` with a legacy read shim. (2) `Validation.vue` stops auto-unlocking on `accepted`: it keeps the textbox editable and gates the unlock behind a new `onContinueAnyway()`; reload rehydrates Yellow as Yellow. (3) The CAP `doResetTutorialProgress` handler drops its 100%-complete 409 gate; the `TutorialReset.vue` button shows at any progress. The old #2446 409 guard is replaced by a new rollup/points regression test. + +**Tech Stack:** Vue 3 (`