From a4377668bedc41eee8b18e4d67550e1f8ebb726a Mon Sep 17 00:00:00 2001 From: giles Date: Tue, 3 Mar 2026 16:52:12 +0000 Subject: [PATCH] Add isomorphic SX architecture migration plan Documents the 5-phase plan for making the sx s-expression layer a universal view language that renders on either client or server, with pages as cached components and data-only navigation. Co-Authored-By: Claude Opus 4.6 --- docs/isomorphic-sx-plan.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/isomorphic-sx-plan.md b/docs/isomorphic-sx-plan.md index fcf6569..9e48846 100644 --- a/docs/isomorphic-sx-plan.md +++ b/docs/isomorphic-sx-plan.md @@ -358,3 +358,41 @@ Each service migrates independently, no coordination needed: 3. Enable SSR for bots (Phase 2) — per-page opt-in 4. Client data primitives (Phase 4) — global once sx.js updated 5. Data-only navigation (Phase 5) — automatic for any `defpage` route + +--- + +## Why: Architectural Rationale + +The end state is: **sx.js is the only JavaScript in the browser.** All application code — components, pages, routing, event handling, data fetching — is expressed in sx, evaluated by the interpreter, with behavior mediated through bound primitives. + +### Benefits + +**Single language everywhere.** Components, pages, routing, event handling, data fetching — all sx. No context-switching between JS idioms and template syntax. One language for the entire frontend and the server rendering path. + +**Portability.** The same source runs on any VM that implements the ~50-primitive interface. Today: Python + JS. Tomorrow: WASM, edge workers, native mobile, embedded devices. Coupled to a primitive contract, not to a specific runtime. + +**Smaller wire transfer.** S-expressions are terser than equivalent JS. Combined with content-addressed caching (hash/localStorage), most navigations transfer zero code — just data. + +**Inspectability.** The sx source is the running program — no build step, no source maps, no minification. View source shows exactly what executes. The AST is the structure the evaluator walks. Debugging is tracing a tree. + +**Controlled surface area.** The only JS that runs is sx.js. Everything else is mediated through defined primitives. No npm supply chain. No third-party scripts with ambient DOM access. Components can only do what primitives allow — the capability surface is fully controlled. + +**Hot-reloadable everything.** Components are data (cached AST). Swapping a definition is replacing a dict entry. No module system, no import graph, no HMR machinery. Already works for .sx file changes in dev mode — extends to behaviors too. + +**AI-friendly.** S-expressions are trivially parseable and generatable. An LLM produces correct sx far more reliably than JS/JSX — fewer syntax edge cases, no semicolons/braces/arrow-function ambiguities. The codebase becomes more amenable to automated generation and transformation. + +**Security boundary.** No `eval()`, no dynamic `