From daf76c3e5b3a321429eeb8c922bbb0e982c01226 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 6 Mar 2026 22:30:26 +0000 Subject: [PATCH] Add predictive component prefetching plan to sx-docs 4-phase design: server endpoint for on-demand component defs, SX-specced client prefetch logic (hover/viewport triggers), boundary declarations, and bootstrap integration. Co-Authored-By: Claude Opus 4.6 --- sx/sx/nav-data.sx | 4 +- sx/sx/plans.sx | 168 +++++++++++++++++++++++++++++++++++++++++++ sx/sxc/pages/docs.sx | 1 + 3 files changed, 172 insertions(+), 1 deletion(-) diff --git a/sx/sx/nav-data.sx b/sx/sx/nav-data.sx index 29f34eb..537d021 100644 --- a/sx/sx/nav-data.sx +++ b/sx/sx/nav-data.sx @@ -112,7 +112,9 @@ (dict :label "Reader Macros" :href "/plans/reader-macros" :summary "Extensible parse-time transformations via # dispatch — datum comments, raw strings, and quote shorthand.") (dict :label "SX-Activity" :href "/plans/sx-activity" - :summary "A new web built on SX — executable content, shared components, parsers, and logic on IPFS, provenance on Bitcoin, all running within your own security context."))) + :summary "A new web built on SX — executable content, shared components, parsers, and logic on IPFS, provenance on Bitcoin, all running within your own security context.") + (dict :label "Predictive Prefetching" :href "/plans/predictive-prefetch" + :summary "Prefetch missing component definitions before the user clicks — hover a link, fetch its deps, navigate client-side."))) (define bootstrappers-nav-items (list (dict :label "Overview" :href "/bootstrappers/") diff --git a/sx/sx/plans.sx b/sx/sx/plans.sx index 059977d..2798e7a 100644 --- a/sx/sx/plans.sx +++ b/sx/sx/plans.sx @@ -594,6 +594,174 @@ (td :class "px-3 py-2 text-stone-700" "Content addressing — shared with component CIDs") (td :class "px-3 py-2 text-stone-600" "2, 3")))))))) +;; --------------------------------------------------------------------------- +;; Predictive Component Prefetching +;; --------------------------------------------------------------------------- + +(defcomp ~plan-predictive-prefetch-content () + (~doc-page :title "Predictive Component Prefetching" + + (~doc-section :title "Context" :id "context" + (p "Phase 3 of the isomorphic roadmap added client-side routing with component dependency checking. When a user clicks a link, " (code "try-client-route") " checks " (code "has-all-deps?") " — if the target page needs components not yet loaded, the client falls back to a server fetch. This works correctly but misses an opportunity: " (strong "we can prefetch those missing components before the click happens.")) + (p "The page registry already carries " (code ":deps") " metadata for every page. The client already knows which components are loaded via " (code "loaded-component-names") ". The gap is a mechanism to " (em "proactively") " resolve the difference — fetching missing component definitions so that by the time the user clicks, client-side routing succeeds.")) + + (~doc-section :title "Current State" :id "current-state" + (div :class "overflow-x-auto rounded border border-stone-200 mb-4" + (table :class "w-full text-left text-sm" + (thead (tr :class "border-b border-stone-200 bg-stone-100" + (th :class "px-3 py-2 font-medium text-stone-600" "Layer") + (th :class "px-3 py-2 font-medium text-stone-600" "What exists") + (th :class "px-3 py-2 font-medium text-stone-600" "Where"))) + (tbody + (tr :class "border-b border-stone-100" + (td :class "px-3 py-2 text-stone-700" "Page registry") + (td :class "px-3 py-2 text-stone-700" "Each page carries " (code ":deps (\"~card\" \"~essay-foo\" ...)")) + (td :class "px-3 py-2 font-mono text-sm text-violet-700" "helpers.py →