docs(phase-38): add 38-VERIFICATION.md goal-backward verification report
This commit is contained in:
@@ -2079,7 +2079,14 @@ Plans:
|
|||||||
3. `vue-journal-layer` exposes an app-extensible embed provider registry that renders the SSR static fallback unchanged, lazy-hydrates registered providers on viewport entry (`IntersectionObserver`) with `script-src 'self'` CSP compliance, reserves height (no CLS), and exposes `prefers-reduced-motion`.
|
3. `vue-journal-layer` exposes an app-extensible embed provider registry that renders the SSR static fallback unchanged, lazy-hydrates registered providers on viewport entry (`IntersectionObserver`) with `script-src 'self'` CSP compliance, reserves height (no CLS), and exposes `prefers-reduced-motion`.
|
||||||
4. Unit tests (Go + Vitest, last plan) and README/docs updates pass green.
|
4. Unit tests (Go + Vitest, last plan) and README/docs updates pass green.
|
||||||
|
|
||||||
**Plans:** 0 plans
|
**Plans:** 3 plans
|
||||||
|
|
||||||
Plans:
|
Plans:
|
||||||
- [ ] TBD (run `/msd-discuss-phase 38` then `/msd-plan-phase 38` to break down)
|
**Wave 1**
|
||||||
|
- [x] 38-01-PLAN.md — `sm-journal-plugin` Go `EmbedRegistry` (built-in `youtube` + Go API + YAML `golem15.journal.embed_providers`), pair-aware `(data-embed, data-id)` + `data-aspect`/`data-height` + UGC fallback sanitizer, and adaptive Blog Editor (`embedProviders` in `RequestOptions`, Media Library fallback picker, fallback-preserving TipTap `Embed` node & preview, rebuilt `assets/dist/`)
|
||||||
|
|
||||||
|
**Wave 2** *(blocked on Wave 1 completion)*
|
||||||
|
- [x] 38-02-PLAN.md — `vue-journal-layer` dual embed provider registry (`app.config.ts` + `registerJournalEmbedProvider`), registry-driven pair-aware `htmlGate.ts`, `expandEmbeds` preserving SSR fallbacks & YouTube SSR `<iframe>`, and `IntersectionObserver` lazy hydration runtime (`useJournalEmbedHydration` in `PostBody.vue` / `CategoryHeader.vue`, CLS reservation, `prefers-reduced-motion`, Vue async component + DOM `mount`, error fallback)
|
||||||
|
|
||||||
|
**Wave 3** *(blocked on Waves 1–2 completion)*
|
||||||
|
- [x] 38-03-PLAN.md — Unit tests last & verification gates (Go `-race` + Vitest in `sm-journal-plugin`, `node --test` + playground build + `smoke:ssr` in `vue-journal-layer`, synced `editor-corpus.json`, READMEs, `scripts/check-phase38.sh`, `38-VALIDATION.md`)
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
---
|
||||||
|
phase: 38-extensible-journal-embed-providers
|
||||||
|
verified: 2026-11-28T14:53:00+01:00
|
||||||
|
status: passed
|
||||||
|
score: 17/17 must-haves verified
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 38: Extensible Journal Embed Providers — Verification Report
|
||||||
|
|
||||||
|
**Phase Goal:** Replace hardcoded `youtube`-only embed handling in `sm-journal-plugin` and `vue-journal-layer` with a generic, app-extensible embed provider registry so any SummerCMS site can register custom CSP-safe embeds (such as interactive visualizations, calculators, or additional video/audio providers) with SSR static fallback (`<img>` + `<figcaption>`) and lazy `IntersectionObserver` hydration.
|
||||||
|
**Verified:** 2026-11-28T14:53:00+01:00
|
||||||
|
**Status:** `passed`
|
||||||
|
**Re-verification:** No — goal-backward verification across Plans `38-01`, `38-02`, `38-03`, and post-review `--fix --all` (`38-REVIEW.md` clean).
|
||||||
|
|
||||||
|
## Goal Achievement
|
||||||
|
|
||||||
|
### Observable Truths (`must_haves.truths` across Plans 38-01 through 38-03)
|
||||||
|
|
||||||
|
| # | Plan | Truth | Status | Evidence |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| 1 | 38-01 | `classes.EmbedRegistry` pre-registers `youtube` (`^[A-Za-z0-9_-]{11}$`, URL mode) by default, is published on `backpack.App` in `Plugin.Register`, and merges YAML config `golem15.journal.embed_providers` in `Plugin.Boot` (failing boot on invalid provider keys, reserved keys, or uncompilable regex patterns) (D-02). | VERIFIED | `../sm-journal-plugin/classes/embed_registry.go:70-81,95-194`, `plugin.go:52-90`, `config/config.yaml:44`; proven by `TestEmbedRegistryDefaultAndRegistration` (including WR-04 `constructor`/`prototype` rejection). |
|
||||||
|
| 2 | 38-01 | `classes.EmbedRegistryFrom(app)` returns the app-scoped registry (or default `youtube`-only registry when `app == nil`), with thread-safe cached `*bluemonday.Policy` construction so concurrent tests with distinct registries never race (D-02, D-03). | VERIFIED | `../sm-journal-plugin/classes/embed_registry.go:85-92,238-268` (`sync.RWMutex` + double-checked lazy `Policy()`); proven under `-race` by `TestEmbedRegistryConcurrentIsolationRace`. |
|
||||||
|
| 3 | 38-01 | Pair-aware `(data-embed, data-id)` validation runs after bluemonday across `FormatHTML`, `SanitizeHTML`, `SanitizeHTMLReport`, `FormatTranslation`, and `CheckHTML`: mismatched or incomplete pairs strip `data-embed`, `data-id`, `data-aspect`, and `data-height` and are reported/rejected (D-03). | VERIFIED | `../sm-journal-plugin/classes/format_html.go:373-456` (`enforceEmbedPairs` wired through `sanitizeHTML`); proven by `TestEmbedRegistryPairAwareSanitizationAndFallbackXSS` & `classes/editor_policy_test.go`. |
|
||||||
|
| 4 | 38-01 | `<figure data-embed="..." data-id="...">` allows optional `data-aspect` and `data-height` and preserves UGC-allowed fallback children (`<img>`, `<figcaption>`, safe phrasing/links) while stripping `script`, `style`, `iframe`, `svg`, event handlers, and unsafe URLs (D-04, D-05). | VERIFIED | `../sm-journal-plugin/classes/embed_registry.go:27-28`, `format_html.go:62-73`; proven by `TestEmbedRegistryPairAwareSanitizationAndFallbackXSS`. |
|
||||||
|
| 5 | 38-01 | `classes.BlogEditorTypes` (`decodeBlogHTMLFor`, `loadBlogHTMLFor`, `blogRequestOptions`), `/_journal/api/v1` post write handlers, and `journal:import-posts` all sanitize using `EmbedRegistryFrom(app)` while package-level helpers remain backward-compatible for `youtube` (D-02, D-03). | VERIFIED | `classes/blog_editor.go:90-95,170-224,317-321`, `controllers/api/posts_helpers.go:537,593,796`, `console/import_posts.go:72,106-108`, `controllers/posts.go:354`. |
|
||||||
|
| 6 | 38-01 | `blogRequestOptions` emits `embedProviders` alongside `headingLevels` and `genericAnchors`; `element.ts` keeps the single URL input unchanged when only `youtube` is registered and shows an adaptive provider selector + ID + Media Library fallback picker + caption + aspect/height when custom providers exist (D-06). | VERIFIED | `classes/blog_editor.go:218-222`, `assets/src/blogeditor/element.ts:211-216,628-827` (plus WR-03 dedicated `embedAspectInvalid`/`embedHeightInvalid` & custom URL-mode degradation); proven by `TestBlogRequestOptionsEmbedProviders` & `tests/blogeditor/embed.test.ts`. |
|
||||||
|
| 7 | 38-01 | TipTap `Embed` node (`extensions.ts`) and `preview.ts` model, round-trip, and preview `<figure data-embed>` with fallback `<img>`/`<figcaption>` and `data-aspect`/`data-height` without dropping to `RawHtml`, and `assets/dist/blogeditor.{js,css}` are rebuilt cleanly (D-06). | VERIFIED | `assets/src/blogeditor/extensions.ts:352-589`, `preview.ts:133-194,222-225` (including IN-02 scoped `.embed-card--youtube img`); proven by `tests/blogeditor/embed.test.ts` (264/264 Vitest) & `scripts/check-dist.sh`. |
|
||||||
|
| 8 | 38-02 | Consuming Nuxt apps can register custom embed providers via `app.config.ts` (`journal.embeds`) and/or `registerJournalEmbedProvider` / `defineJournalEmbedProviders` on both SSR and client, with `youtube` pre-registered by default (D-07, D-09). | VERIFIED | `../vue-journal-layer/app/utils/embedRegistry.ts:93-107,213-246`, `app/plugins/journal-embeds.ts:1-19` (including IN-01 `WeakSet` sync guard); proven by `tests/embeds.test.ts`. |
|
||||||
|
| 9 | 38-02 | `htmlGate.ts` reads the active (or override) embed registry, enforces pair-aware `(data-embed, data-id)` validation, allows `data-aspect`/`data-height` only on validated `<figure data-embed>`, and keeps UGC fallback children (`<img>` with `srcset`/`sizes`, `<figcaption>`) while stripping `script`/`style`/`iframe`/`svg`/event handlers (D-04, D-05, D-07). | VERIFIED | `../vue-journal-layer/app/utils/htmlGate.ts:133-138,249-292`; proven by `tests/embeds.test.ts` & `tests/htmlGate.test.ts`. |
|
||||||
|
| 10 | 38-02 | `expandEmbeds` keeps built-in `youtube` SSR `<iframe>` (`youtube-nocookie.com`) byte-identical by default, allows overriding `youtube`, and preserves SSR fallback markup inside client-hydrated `<figure data-embed>` with `journal-embed journal-embed--<provider>` classes and CLS `aspect-ratio`/`min-height` inline styles (D-08, D-09). | VERIFIED | `../vue-journal-layer/app/utils/embeds.ts:97-169`; proven by `tests/embeds.test.ts` & 97/97 `pnpm smoke:ssr` checks. |
|
||||||
|
| 11 | 38-02 | `useJournalEmbedHydration` (wired into `PostBody.vue` and `CategoryHeader.vue`) observes validated `<figure data-embed>` via `IntersectionObserver`, reserves height before swapping, exposes reactive `prefers-reduced-motion`, supports Vue async components (inheriting `appContext` captured synchronously in `setup()`) and plain DOM `mount(el, ctx)` (attached to DOM before mount), cleans up on unmount/HTML change, and restores SSR fallback on error/abort (D-08). | VERIFIED | `../vue-journal-layer/app/composables/useJournalEmbedHydration.ts:1-294` (including WR-01 synchronous `appContext` & WR-02 attached-DOM mount with fallback restoration), `PostBody.vue:76`, `CategoryHeader.vue:19`; proven by `tests/embedHydration.test.ts`. |
|
||||||
|
| 12 | 38-02 | Strictly `script-src 'self'` CSP compliant (zero `eval`, `new Function`, or inline `<script>` injection) and prototype-pollution safe (`Map` / `Object.hasOwn` + `RESERVED_PROVIDER_KEYS`) (D-08). | VERIFIED | `embedRegistry.ts:17,127,165`, `htmlGate.ts:251-257`, `useJournalEmbedHydration.ts` (zero `eval`/`Function`/`<script>`); proven by `tests/embeds.test.ts`. |
|
||||||
|
| 13 | 38-03 | Go unit tests in `sm-journal-plugin` cover `EmbedRegistry`, YAML boot merge, fail-loud invalid keys/regexes/modes, pair-aware sanitization, CSS-injection rejection, UGC fallback + XSS stripping, `blogRequestOptions.embedProviders`, and concurrent `-race` isolation. | VERIFIED | `../sm-journal-plugin/classes/embed_registry_test.go` (445 lines); `go test -race -short ./...` PASS across all 6 test packages. |
|
||||||
|
| 14 | 38-03 | Blog Editor Vitest tests cover dynamic `embedProviders`, adaptive dialog, Media Library fallback picker, TipTap `Embed` fallback round-trip, and `previewBody` cards. | VERIFIED | `../sm-journal-plugin/tests/blogeditor/embed.test.ts` (10 files, 264/264 Vitest PASS). |
|
||||||
|
| 15 | 38-03 | `vue-journal-layer` `node --test` suites cover dual registration, prototype-pollution rejection, pair-aware `htmlGate.ts`, `expandEmbeds` SSR fallback + YouTube override, and `hydrateEmbedFigure` / `useJournalEmbedHydration` lifecycle. | VERIFIED | `../vue-journal-layer/tests/embeds.test.ts` & `tests/embedHydration.test.ts` (211/211 `node --test` PASS). |
|
||||||
|
| 16 | 38-03 | `editor-corpus.json` is byte-identical across `sm-journal-plugin` and `vue-journal-layer`, and both repos' READMEs document the extensible embed API with neutral examples (zero consuming app names). | VERIFIED | Stage 3 `cmp -s` PASS; `../sm-journal-plugin/README.md` & `../vue-journal-layer/README.md` use neutral `viz`/`acme` examples (IN-03 summary bullets updated). |
|
||||||
|
| 17 | 38-03 | `scripts/check-phase38.sh` passes all 5 fail-closed stages, `38-VALIDATION.md` & `38-REVIEW.md` (`status: clean`) are recorded, and zero release tags, tag pushes, consumer bumps, or changelog posts were executed (`AGENTS.md` rule 5). | VERIFIED | `bash scripts/check-phase38.sh` re-run after `--fix --all` -> `ALL STAGES PASSED`; latest tags unchanged (`summercms.go`: `v0.6.10`, `sm-journal-plugin`: `v0.5.0`, `vue-journal-layer`: `v0.8.2`); clean `git status -s` in both sibling repos. |
|
||||||
|
|
||||||
|
**Score:** 17/17 truths verified.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Roadmap Success Criteria Check
|
||||||
|
|
||||||
|
1. `sm-journal-plugin` (`classes/format_html.go`) validates `<figure data-embed="<provider>" data-id="<id>">` against a configurable/registered embed provider map (`youtube` registered by default) and preserves static fallback `<img>` and `<figcaption>` inside the figure without allowing arbitrary `script`/`style`/`iframe`/`svg` — **PASS**.
|
||||||
|
2. The Blog Editor (`assets/src/blogeditor/embed.ts`) reads registered embed providers dynamically rather than hardcoding only `youtube`, preserving existing YouTube authoring unchanged — **PASS**.
|
||||||
|
3. `vue-journal-layer` exposes an app-extensible embed provider registry that renders the SSR static fallback unchanged, lazy-hydrates registered providers on viewport entry (`IntersectionObserver`) with `script-src 'self'` CSP compliance, reserves height (no CLS), and exposes `prefers-reduced-motion` — **PASS**.
|
||||||
|
4. Unit tests (Go `-race` + Vitest + `node --test` + SSR smoke) and README/docs updates pass green — **PASS**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Post-Wave Lifecycle Status
|
||||||
|
|
||||||
|
1. All 3 phase waves complete (`38-01`, `38-02`, `38-03`) — **DONE**.
|
||||||
|
2. Phase code review (`/msd-code-review 38`) — **DONE** (`38-REVIEW.md`).
|
||||||
|
3. Review fixes (`/msd-code-review 38 --fix --all` + re-verified `scripts/check-phase38.sh`) — **DONE** (`38-REVIEW.md` `status: clean`).
|
||||||
|
4. Goal-backward verification (`38-VERIFICATION.md`) — **PASSED (17/17)**.
|
||||||
|
5. Release tagging, pushing tags, downstream consumer bumps, and changelog posts — **NOT EXECUTED** (awaiting explicit user go-ahead per `AGENTS.md` / `CLAUDE.md` rule 5).
|
||||||
Reference in New Issue
Block a user