Skip to content

feat: compile generated MDX documents as templates - #2071

Merged
domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:codex/strong-mdx-templates-2059
Oct 14, 2026
Merged

domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:codex/strong-mdx-templates-2059

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Compile both generated MDX document functions as Octane templates. Add strong and overridableTags options, and pass the website's shared Strong policy with only table/pre overridable. Provider, document-prop, named-component and layout precedence remain intact; omitting the tag list retains full host override support.

The real website comparison exposed an existing runtime defect: client navigation mounted native table sections through DocTable, and the fragment parser discarded their rows. Parse the roots in template context before adding an inert wrapper, preserving custom-element construction/connection order. Include owning runtime and MDX regressions plus website navigation/HMR coverage.

Part of #2059; this does not close the wider migration issue.

Validation

  • pnpm format:check — scoped pnpm format:files:check used.
  • pnpm typecheck — focused MDX/Docusaurus public and package types, changed-file types, runtime and website types used.
  • pnpm test — focused suites below; full matrix runs in CI.
  • MDX + Docusaurus: 125 tests; final stricter hydration/text-identity/source-map checks: 15 tests.
  • Runtime fragments/components/staging and integrated Strong render values: 254 tests in development and production. New table regression failed before the fix.
  • Public provider browser comparison against pinned main 479118fb2: development/production × default/restricted tags, SSR adoption, mapping precedence, retained counter state, removal and unmount. All 12 screenshot pairs are byte-identical.
  • Packed-consumer helper tests: 45; source-publication check, changesets, staged DOM gate and repository sync.
  • perf-review: no mechanical candidates or unresolved independent-review findings. The owning production mount benchmark and all six applicable ratio guards pass, preserving per-row/update/reorder work; one additional append occurs only when first parsing a fragment. Chromium checks preserve custom-element order, foreign-document adoption and hydration identity. The CI paired benchmark records all 64 work counters unchanged and all 20 timing comparisons within its ±3% noise criterion. Representative complete core apps grow by 5–44 B gzip (TSRX starter +10 B, JSX starter +30 B, full framework +14 B); this small parser-fix cost is included in the net website saving below. No latency claim.
  • concise-code: authored source +228/−130 lines (runtime +12/−10). Reuses MDX's printer/source-map extension and core template HMR; removes the bespoke MDX HMR shim. No new parser, dependency, runtime flag, or per-render state. Two changeset files cover the public options and parser fix. A parallel legacy descriptor pipeline and website table workaround were rejected.
  • Actual website HMR against main, using the native watcher: two real MDX edits retain the surrounding counter state; fresh SSR reload and hydration pass on both, with no page/console errors.
  • Matched desktop/narrow production website checks: all 16 documentation routes preserve authored SSR/hydrated content, all three homepage samples, tables, exact clipboard text, SPA navigation, package tabs, binding filters and all nine Core API demos. No semantic differences; 17/19 initial screenshots are byte-identical. The two differences were the moving native gallery and a tiny table raster difference; a settled real-navigation table comparison is byte-identical, with matching geometry and styles.
  • Current-head CI and benchmark workflow pass on c3719be8d: required lint, typecheck, test (24); all four parity shards; 54,057 sharded tests passed (two skipped), 616 Chromium tests, and all 105 website tests including live MDX HMR. Publication validates 123 tarballs and strict TypeScript 5.9/6/7.1 consumer lanes. Bugbot reports no issues; no unresolved review comments.

Matched production builds (2d2bac446 → c3719be8d), same dependency versions and configuration:

Complete public JavaScript Main PR Delta
Files 614 614 0
Raw bytes 19,667,507 19,400,827 −266,680
gzip bytes 4,414,940 4,351,312 −63,628 (−1.44%)

Every emitted .js/.mjs/.cjs under the public output is included, including copied runtimes; gzip level 9 is summed per file. Server output, maps and non-JS assets are excluded. The four binary Lynx containers are recorded separately: raw unchanged, gzip +4 bytes. No runtime-speed claim.

Risk / follow-ups

  • Both production builds reproduce the same existing Lynx teardown diagnostics when leaving the homepage after its native preview runs: two callDestroyLifetimeFun console errors and two undefined page errors per viewport. This comparison is behavior-equivalent, not error-free; no unrelated workaround was added. The candidate has zero failed requests; main cancelled 15 native-gallery PNG requests while navigating away, with zero in its narrow run. Those navigation cancellations are recorded separately from the passing content/control assertions.
  • All 19 website MDX modules compile with Strong checks and zero generated descriptor-factory calls under the website options. Arbitrary authored expressions and imported components are outside that descriptor-free claim.
  • Full dynamic host overriding can increase output for heavily highlighted documents; restricted host lists avoid those slots. Default complete fixture bundles shrink in the measured plain-MDX examples, but this is not a universal size guarantee.
  • Mapped nested children follow Octane's opaque template-body contract; render them instead of inspecting/cloning descriptors. Single literal children remain strings. README/status document this distinction.
  • Exact authored executable/diagnostic mappings remain covered. Native static-text hoists retain the core compiler's coarse mapping; maps still omit embedded source content.
  • The core fixture's existing MathML intrinsic type errors also reproduce on pinned main when that fixture is explicitly selected for typechecking; shipped runtime and changed website/package checks pass.
  • Current head includes release main 2d2bac446. MDX/Docusaurus tests and types, runtime/website types, sync, formatting and the production website comparison were rerun after integration. Independent input comparison confirms the earlier provider/HMR, core-regression and DOM-work evidence is unaffected by release metadata and the version export; earlier HMR screenshots retain the old version badge. Complete MDX fixture bundles were rebuilt and retain their measured reductions.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · implementation host com-79386.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Changes the MDX compile output shape and template DOM parsing used for hydration and table wrappers; broad test coverage but affects default content rendering and dev HMR behavior.

Overview
Generated MDX document functions (_createMdxContent and MDXContent) now compile as Octane templates on client and server via a rewritten recmaOctaneAdapter that uses MDX’s printer extension (OctaneTemplateBody) instead of treating the body as ordinary JSX. Document HMR moves to core template HMR (the bespoke MDX hmr() shim is removed), with Strong diagnostics and optional overridableTags forwarded through compileMdx / octaneMdx so sites can fix most markdown hosts as static templates while still overriding listed tags (default: all hosts overridable).

Octane runtime fixes multi-root template parsing: HTML is parsed in template context before wrapping in octane-frag, so thead / tbody / rows survive when table sections are passed as children through a component wrapper (e.g. doc site table overrides).

Docs, binding status, and tests cover mapping precedence, Shiki/hydration, source maps, Vite option forwarding, website table/pre + Strong, and MDX hot reload without remounting sibling UI.

Reviewed by Cursor Bugbot for commit c3719be. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability labels Oct 14, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 14, 2026 23:12
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

  • 🔴 bundle-size: 65 value(s) increased
  • 🔴 bundle-reachability: 63 value(s) increased

Compares 2d2bac446, the merge commit's first parent with a3cc03eb4 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.683 3.633 −3.9% −15.5% … +8.0% ⚪ within noise
octane-tsrx replace 9.975 9.200 −6.2% −9.6% … +1.6% ⚪ within noise
octane-tsrx add 3.692 3.200 ±0.0% −4.1% … +6.9% ⚪ within noise
octane-tsrx update 0.160 0.182 −1.1% −10.3% … +8.9% ⚪ within noise
octane-tsrx select 0.007 0.007 +2.7% −0.8% … +10.4% ⚪ within noise
octane-tsrx swap 0.022 0.023 +1.9% −3.1% … +7.8% ⚪ within noise
octane-tsrx remove 0.021 0.021 +1.2% −7.6% … +5.5% ⚪ within noise
octane-tsrx runlots 33.933 37.925 +2.8% −8.1% … +14.7% ⚪ within noise
octane-tsrx select_lots 0.007 0.007 ±0.0% −1.3% … +1.8% ⚪ within noise
octane-tsrx clear 46.817 48.333 +2.0% −3.1% … +6.7% ⚪ within noise
octane-jsx run 3.675 3.550 ±0.0% −2.7% … +2.5% ⚪ within noise
octane-jsx replace 7.617 7.958 +4.2% −5.0% … +9.5% ⚪ within noise
octane-jsx add 3.083 3.133 −0.0% −3.4% … +3.1% ⚪ within noise
octane-jsx update 0.277 0.272 −1.3% −4.0% … +0.9% ⚪ within noise
octane-jsx select 0.154 0.149 −2.2% −3.9% … −1.2% ⚪ within noise
octane-jsx swap 0.208 0.208 −2.4% −6.2% … +0.0% ⚪ within noise
octane-jsx remove 0.192 0.195 +1.1% ±0.0% … +2.9% ⚪ within noise
octane-jsx runlots 31.367 30.175 −2.2% −4.4% … −0.3% ⚪ within noise
octane-jsx select_lots 1.713 1.744 −0.4% −5.7% … +2.8% ⚪ within noise
octane-jsx clear 55.183 54.908 +0.9% −4.3% … +9.8% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

target metric base head Δ
octane-tsrx js_raw 87,307 87,374 +67 (+0.1%) 🔴
octane-tsrx js_gzip 29,120 29,130 +10 (+0.0%) 🔴
octane-tsrx js_brotli 26,045 26,022 −23 (−0.1%) 🟢
octane-tsrx app_gzip 2,334 2,336 +2 (+0.1%) 🔴
octane-tsrx app_brotli 2,039 2,041 +2 (+0.1%) 🔴
octane-tsrx fw_raw 80,355 80,422 +67 (+0.1%) 🔴
octane-tsrx fw_gzip 26,786 26,794 +8 (+0.0%) 🔴
octane-tsrx fw_brotli 24,006 23,981 −25 (−0.1%) 🟢
octane-tsrx todo_js_raw 100,047 100,114 +67 (+0.1%) 🔴
octane-tsrx todo_js_gzip 33,722 33,731 +9 (+0.0%) 🔴
octane-tsrx todo_js_brotli 30,028 30,008 −20 (−0.1%) 🟢
octane-tsrx todo_app_gzip 2,235 2,234 −1 (−0.0%) 🟢
octane-tsrx todo_app_brotli 1,898 1,896 −2 (−0.1%) 🟢
octane-tsrx todo_fw_raw 95,408 95,475 +67 (+0.1%) 🔴
octane-tsrx todo_fw_gzip 31,487 31,497 +10 (+0.0%) 🔴
octane-tsrx todo_fw_brotli 28,130 28,112 −18 (−0.1%) 🟢
octane-tsrx chat_js_raw 99,383 99,450 +67 (+0.1%) 🔴
octane-tsrx chat_js_gzip 33,631 33,641 +10 (+0.0%) 🔴
octane-tsrx chat_js_brotli 30,021 30,034 +13 (+0.0%) 🔴
octane-tsrx chat_app_gzip 2,723 2,724 +1 (+0.0%) 🔴
octane-tsrx chat_app_brotli 2,389 2,394 +5 (+0.2%) 🔴
octane-tsrx chat_fw_raw 93,606 93,673 +67 (+0.1%) 🔴
octane-tsrx chat_fw_gzip 30,908 30,917 +9 (+0.0%) 🔴
octane-tsrx chat_fw_brotli 27,632 27,640 +8 (+0.0%) 🔴
octane-tsrx weather_js_raw 134,104 134,171 +67 (+0.0%) 🔴
octane-tsrx weather_js_gzip 44,482 44,490 +8 (+0.0%) 🔴
octane-tsrx weather_js_brotli 39,330 39,295 −35 (−0.1%) 🟢
octane-tsrx weather_app_gzip 7,880 7,879 −1 (−0.0%) 🟢
octane-tsrx weather_fw_raw 111,948 112,015 +67 (+0.1%) 🔴
octane-tsrx weather_fw_gzip 36,602 36,611 +9 (+0.0%) 🔴
octane-tsrx weather_fw_brotli 32,651 32,616 −35 (−0.1%) 🟢
octane-tsrx bindings_js_raw 680,503 680,570 +67 (+0.0%) 🔴
octane-tsrx bindings_js_gzip 224,143 224,150 +7 (+0.0%) 🔴
octane-tsrx bindings_js_brotli 190,627 190,747 +120 (+0.1%) 🔴
octane-tsrx bindings_app_gzip 115,660 115,661 +1 (+0.0%) 🔴
octane-tsrx bindings_app_brotli 96,136 96,155 +19 (+0.0%) 🔴
octane-tsrx bindings_fw_raw 332,776 332,843 +67 (+0.0%) 🔴
octane-tsrx bindings_fw_gzip 108,483 108,489 +6 (+0.0%) 🔴
octane-tsrx bindings_fw_brotli 94,491 94,592 +101 (+0.1%) 🔴
octane-tsrx wayfinder_js_raw 457,405 457,472 +67 (+0.0%) 🔴
octane-tsrx wayfinder_js_gzip 148,858 148,867 +9 (+0.0%) 🔴
octane-tsrx wayfinder_js_brotli 128,927 128,939 +12 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_raw 146,056 146,123 +67 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_gzip 48,984 48,989 +5 (+0.0%) 🔴
octane-tsrx threadline_oxc_js_brotli 42,984 42,973 −11 (−0.0%) 🟢
octane-tsrx threadline_esbuild_js_raw 173,291 173,391 +100 (+0.1%) 🔴
octane-tsrx threadline_esbuild_js_gzip 58,188 58,200 +12 (+0.0%) 🔴
octane-tsrx threadline_esbuild_js_brotli 50,799 50,823 +24 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_raw 540,867 540,934 +67 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_gzip 169,393 169,400 +7 (+0.0%) 🔴
octane-tsrx pagecraft_oxc_js_brotli 143,248 143,245 −3 (−0.0%) 🟢
octane-tsrx pagecraft_esbuild_js_raw 591,065 591,165 +100 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_gzip 188,782 188,826 +44 (+0.0%) 🔴
octane-tsrx pagecraft_esbuild_js_brotli 159,607 159,700 +93 (+0.1%) 🔴
octane-tsrx full_fw_raw 569,336 569,434 +98 (+0.0%) 🔴
octane-tsrx full_fw_gzip 172,283 172,297 +14 (+0.0%) 🔴
octane-tsrx full_fw_brotli 145,115 145,127 +12 (+0.0%) 🔴
octane-jsx js_raw 166,542 166,609 +67 (+0.0%) 🔴
octane-jsx js_gzip 54,036 54,066 +30 (+0.1%) 🔴
octane-jsx js_brotli 47,377 47,365 −12 (−0.0%) 🟢
octane-jsx app_gzip 2,857 2,858 +1 (+0.0%) 🔴
octane-jsx app_brotli 2,411 2,421 +10 (+0.4%) 🔴
octane-jsx fw_raw 158,271 158,338 +67 (+0.0%) 🔴
octane-jsx fw_gzip 51,179 51,208 +29 (+0.1%) 🔴
octane-jsx fw_brotli 44,966 44,944 −22 (−0.0%) 🟢
octane-jsx shell_js_raw 389,760 389,858 +98 (+0.0%) 🔴
octane-jsx shell_js_gzip 122,469 122,483 +14 (+0.0%) 🔴
octane-jsx shell_js_brotli 104,573 104,509 −64 (−0.1%) 🟢
octane-jsx shell_app_gzip 767 766 −1 (−0.1%) 🟢
octane-jsx shell_app_brotli 670 672 +2 (+0.3%) 🔴
octane-jsx shell_fw_raw 388,667 388,765 +98 (+0.0%) 🔴
octane-jsx shell_fw_gzip 121,702 121,717 +15 (+0.0%) 🔴
octane-jsx shell_fw_brotli 103,903 103,837 −66 (−0.1%) 🟢
octane-jsx shell_client_js_raw 324,111 324,209 +98 (+0.0%) 🔴
octane-jsx shell_client_js_gzip 101,286 101,306 +20 (+0.0%) 🔴
octane-jsx shell_client_js_brotli 87,372 87,305 −67 (−0.1%) 🟢
octane-jsx shell_client_app_gzip 768 770 +2 (+0.3%) 🔴
octane-jsx shell_client_app_brotli 663 654 −9 (−1.4%) 🟢
octane-jsx shell_client_fw_raw 323,010 323,108 +98 (+0.0%) 🔴
octane-jsx shell_client_fw_gzip 100,518 100,536 +18 (+0.0%) 🔴
octane-jsx shell_client_fw_brotli 86,709 86,651 −58 (−0.1%) 🟢
octane-jsx full_fw_raw 569,336 569,434 +98 (+0.0%) 🔴
octane-jsx full_fw_gzip 172,283 172,297 +14 (+0.0%) 🔴
octane-jsx full_fw_brotli 145,115 145,127 +12 (+0.0%) 🔴

9 other measured values are unchanged.

Public-import reachability bundles (bytes)

target metric base head Δ
cli-spa-starter raw 80,675 80,742 +67 (+0.1%) 🔴
cli-spa-starter gzip 27,784 27,791 +7 (+0.0%) 🔴
cli-spa-starter brotli 24,742 24,744 +2 (+0.0%) 🔴
root-static-specialized raw 52,720 52,787 +67 (+0.1%) 🔴
root-static-specialized gzip 17,975 17,986 +11 (+0.1%) 🔴
root-static-specialized brotli 16,358 16,317 −41 (−0.3%) 🟢
root-chained-jsx raw 54,055 54,122 +67 (+0.1%) 🔴
root-chained-jsx gzip 18,366 18,374 +8 (+0.0%) 🔴
root-chained-jsx brotli 16,673 16,684 +11 (+0.1%) 🔴
root-static raw 148,071 148,138 +67 (+0.0%) 🔴
root-static gzip 48,045 48,058 +13 (+0.0%) 🔴
root-static brotli 42,279 42,310 +31 (+0.1%) 🔴
root-static-local raw 52,620 52,687 +67 (+0.1%) 🔴
root-static-local gzip 17,918 17,931 +13 (+0.1%) 🔴
root-static-local brotli 16,277 16,292 +15 (+0.1%) 🔴
root-callback-local raw 54,436 54,503 +67 (+0.1%) 🔴
root-callback-local gzip 18,447 18,458 +11 (+0.1%) 🔴
root-callback-local brotli 16,747 16,800 +53 (+0.3%) 🔴
hooks-state raw 62,063 62,130 +67 (+0.1%) 🔴
hooks-state gzip 20,896 20,906 +10 (+0.0%) 🔴
hooks-state brotli 18,957 18,969 +12 (+0.1%) 🔴
prop-attributes raw 59,167 59,234 +67 (+0.1%) 🔴
prop-attributes gzip 20,023 20,034 +11 (+0.1%) 🔴
prop-attributes brotli 18,119 18,182 +63 (+0.3%) 🔴
context raw 68,921 68,988 +67 (+0.1%) 🔴
context gzip 23,025 23,033 +8 (+0.0%) 🔴
context brotli 20,788 20,799 +11 (+0.1%) 🔴
hydrate-root raw 108,102 108,169 +67 (+0.1%) 🔴
hydrate-root gzip 35,599 35,610 +11 (+0.0%) 🔴
hydrate-root brotli 31,492 31,514 +22 (+0.1%) 🔴
deferred-hydration raw 190,918 190,985 +67 (+0.0%) 🔴
deferred-hydration gzip 61,045 61,051 +6 (+0.0%) 🔴
deferred-hydration brotli 53,219 53,243 +24 (+0.0%) 🔴
hydrate-frame raw 340,069 340,136 +67 (+0.0%) 🔴
hydrate-frame gzip 108,088 108,093 +5 (+0.0%) 🔴
hydrate-frame brotli 92,874 92,827 −47 (−0.1%) 🟢
suspense-transition raw 123,010 123,072 +62 (+0.1%) 🔴
suspense-transition gzip 39,478 39,484 +6 (+0.0%) 🔴
suspense-transition brotli 35,027 35,026 −1 (−0.0%) 🟢
component-owned-effects raw 55,537 55,604 +67 (+0.1%) 🔴
component-owned-effects gzip 18,856 18,867 +11 (+0.1%) 🔴
component-owned-effects brotli 17,094 17,105 +11 (+0.1%) 🔴
binding-hooks raw 64,717 64,784 +67 (+0.1%) 🔴
binding-hooks gzip 22,057 22,064 +7 (+0.0%) 🔴
binding-hooks brotli 19,958 19,993 +35 (+0.2%) 🔴
split-shell raw 414,572 414,639 +67 (+0.0%) 🔴
split-shell gzip 132,800 132,805 +5 (+0.0%) 🔴
split-shell brotli 114,362 114,430 +68 (+0.1%) 🔴
split-shell-runtime raw 331,727 331,794 +67 (+0.0%) 🔴
split-shell-runtime gzip 105,307 105,315 +8 (+0.0%) 🔴
split-shell-runtime brotli 89,782 89,854 +72 (+0.1%) 🔴
binding-mantine-hooks-vite raw 62,720 62,787 +67 (+0.1%) 🔴
binding-mantine-hooks-vite gzip 21,315 21,325 +10 (+0.0%) 🔴
binding-mantine-hooks-vite brotli 19,355 19,349 −6 (−0.0%) 🟢
binding-mantine-hooks-esbuild raw 74,408 74,506 +98 (+0.1%) 🔴
binding-mantine-hooks-esbuild gzip 25,882 25,896 +14 (+0.1%) 🔴
binding-mantine-hooks-esbuild brotli 23,271 23,305 +34 (+0.1%) 🔴
binding-apollo-client-vite raw 331,396 331,463 +67 (+0.0%) 🔴
binding-apollo-client-vite gzip 103,182 103,190 +8 (+0.0%) 🔴
binding-apollo-client-vite brotli 90,517 90,478 −39 (−0.0%) 🟢
binding-apollo-client-esbuild raw 366,678 366,776 +98 (+0.0%) 🔴
binding-apollo-client-esbuild gzip 116,929 116,946 +17 (+0.0%) 🔴
binding-apollo-client-esbuild brotli 102,045 102,185 +140 (+0.1%) 🔴
binding-usehooks-ts-vite raw 63,502 63,569 +67 (+0.1%) 🔴
binding-usehooks-ts-vite gzip 21,530 21,537 +7 (+0.0%) 🔴
binding-usehooks-ts-vite brotli 19,514 19,524 +10 (+0.1%) 🔴
binding-usehooks-ts-esbuild raw 75,176 75,274 +98 (+0.1%) 🔴
binding-usehooks-ts-esbuild gzip 26,120 26,136 +16 (+0.1%) 🔴
binding-usehooks-ts-esbuild brotli 23,517 23,511 −6 (−0.0%) 🟢

51 other measured values are unchanged.

@domgan-oai
domgan-oai merged commit 2623e7a into octanejs:main Oct 14, 2026
33 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant