OCaml evaluator for page dispatch + handler aser, 83/83 Playwright tests

Major architectural change: page function dispatch and handler execution
now go through the OCaml kernel instead of the Python bootstrapped evaluator.

OCaml integration:
- Page dispatch: bridge.eval() evaluates SX URL expressions (geography, marshes, etc.)
- Handler aser: bridge.aser() serializes handler responses as SX wire format
- _ensure_components loads all .sx files into OCaml kernel (spec, web adapter, handlers)
- defhandler/defpage registered as no-op special forms so handler files load
- helper IO primitive dispatches to Python page helpers + IO handlers
- ok-raw response format for SX wire format (no double-escaping)
- Natural list serialization in eval (no (list ...) wrapper)
- Clean pipe: _read_until_ok always sends io-response on error

SX adapter (aser):
- scope-emit!/scope-peek aliases to avoid CEK special form conflict
- aser-fragment/aser-call: strings starting with "(" pass through unserialized
- Registered cond-scheme?, is-else-clause?, primitive?, get-primitive in kernel
- random-int, parse-int as kernel primitives; json-encode, into via IO bridge

Handler migration:
- All IO calls converted to (helper "name" args...) pattern
- request-arg, request-form, state-get, state-set!, now, component-source etc.
- Fixed bare (effect ...) in island bodies leaking disposer functions as text
- Fixed lower-case → lower, ~search-results → ~examples/search-results

Reactive islands:
- sx-hydrate-islands called after client-side navigation swap
- force-dispose-islands-in for outerHTML swaps (clears hydration markers)
- clear-processed! platform primitive for re-hydration

Content restructuring:
- Design, event bridge, named stores, phase 2 consolidated into reactive overview
- Marshes split into overview + 5 example sub-pages
- Nav links use sx-get/sx-target for client-side navigation

Playwright test suite (sx/tests/test_demos.py):
- 83 tests covering hypermedia demos, reactive islands, marshes, spec explorer
- Server-side rendering, handler interactions, island hydration, navigation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 17:22:51 +00:00
parent 5b6e883e6d
commit 71c2003a60
33 changed files with 1848 additions and 852 deletions

View File

@@ -60,7 +60,7 @@
(dict :label "Delivery" :href "/sx/(applications.(cssx.delivery))")
(dict :label "Async CSS" :href "/sx/(applications.(cssx.async))")
(dict :label "Live Styles" :href "/sx/(applications.(cssx.live))")
(dict :label "Comparisons" :href "/sx/(applications.(cssx.comparisons))")
(dict :label "Comparisons" :href "/sx/(applications.(cssx.comparison))")
(dict :label "Philosophy" :href "/sx/(applications.(cssx.philosophy))")))
(define essays-nav-items (list
@@ -252,25 +252,36 @@
(dict :label "Mother Language" :href "/sx/(etc.(plan.mother-language))"
:summary "SX as its own compiler. OCaml as substrate (closest to CEK), Koka as alternative (compile-time linearity), ultimately self-hosting. One language, every target.")))
(define reactive-examples-nav-items (list
{:label "Counter" :href "/sx/(geography.(reactive.(examples.counter)))"}
{:label "Temperature" :href "/sx/(geography.(reactive.(examples.temperature)))"}
{:label "Stopwatch" :href "/sx/(geography.(reactive.(examples.stopwatch)))"}
{:label "Imperative" :href "/sx/(geography.(reactive.(examples.imperative)))"}
{:label "Reactive List" :href "/sx/(geography.(reactive.(examples.reactive-list)))"}
{:label "Input Binding" :href "/sx/(geography.(reactive.(examples.input-binding)))"}
{:label "Portals" :href "/sx/(geography.(reactive.(examples.portal)))"}
{:label "Error Boundary" :href "/sx/(geography.(reactive.(examples.error-boundary)))"}
{:label "Refs" :href "/sx/(geography.(reactive.(examples.refs)))"}
{:label "Dynamic Class" :href "/sx/(geography.(reactive.(examples.dynamic-class)))"}
{:label "Resource" :href "/sx/(geography.(reactive.(examples.resource)))"}
{:label "Transitions" :href "/sx/(geography.(reactive.(examples.transition)))"}
{:label "Stores" :href "/sx/(geography.(reactive.(examples.stores)))"}
{:label "Event Bridge" :href "/sx/(geography.(reactive.(examples.event-bridge-demo)))"}
{:label "defisland" :href "/sx/(geography.(reactive.(examples.defisland)))"}
{:label "Tests" :href "/sx/(geography.(reactive.(examples.tests)))"}
{:label "Coverage" :href "/sx/(geography.(reactive.(examples.coverage)))"}))
(define reactive-islands-nav-items (list
(dict :label "Examples" :href "/sx/(geography.(reactive.examples))"
(dict :label "Examples" :href "/sx/(geography.(reactive.(examples)))"
:summary "Live interactive islands — click the buttons, type in the inputs."
:children (list
{:label "Counter" :href "/sx/(geography.(reactive.examples))#demo-counter"}
{:label "Temperature" :href "/sx/(geography.(reactive.examples))#demo-temperature"}
{:label "Stopwatch" :href "/sx/(geography.(reactive.examples))#demo-stopwatch"}
{:label "Reactive List" :href "/sx/(geography.(reactive.examples))#demo-reactive-list"}
{:label "Input Binding" :href "/sx/(geography.(reactive.examples))#demo-input-binding"}
{:label "Portals" :href "/sx/(geography.(reactive.examples))#demo-portal"}
{:label "Error Boundary" :href "/sx/(geography.(reactive.examples))#demo-error-boundary"}
{:label "Refs" :href "/sx/(geography.(reactive.examples))#demo-refs"}
{:label "Dynamic Class" :href "/sx/(geography.(reactive.examples))#demo-dynamic-class"}
{:label "Resource" :href "/sx/(geography.(reactive.examples))#demo-resource"}
{:label "Transitions" :href "/sx/(geography.(reactive.examples))#demo-transition"}
{:label "Shared Stores" :href "/sx/(geography.(reactive.examples))#demo-stores"}
{:label "Event Bridge" :href "/sx/(geography.(reactive.examples))#demo-event-bridge"}))
(dict :label "Marshes" :href "/sx/(geography.(reactive.marshes))"
:summary "Where reactivity and hypermedia interpenetrate — server writes to signals, reactive transforms, client state modifies hypermedia.")))
:children reactive-examples-nav-items)))
(define marshes-examples-nav-items (list
{:label "Hypermedia Feeds State" :href "/sx/(geography.(marshes.hypermedia-feeds))"}
{:label "Server Writes to Signals" :href "/sx/(geography.(marshes.server-signals))"}
{:label "sx-on-settle" :href "/sx/(geography.(marshes.on-settle))"}
{:label "Signal-Bound Triggers" :href "/sx/(geography.(marshes.signal-triggers))"}
{:label "Reactive View Transform" :href "/sx/(geography.(marshes.view-transform))"}))
(define bootstrappers-nav-items (list
(dict :label "Overview" :href "/sx/(language.(bootstrapper))")
@@ -417,7 +428,8 @@
{:label "Spreads" :href "/sx/(geography.(spreads))"
:summary "Child-to-parent communication across render boundaries — spread, collect!, reactive-spread, built on scopes."}
{:label "Marshes" :href "/sx/(geography.(marshes))"
:summary "Where reactivity and hypermedia interpenetrate — server writes to signals, reactive transforms reshape server content, client state modifies how hypermedia is interpreted."}
:summary "Where reactivity and hypermedia interpenetrate — server writes to signals, reactive transforms reshape server content, client state modifies how hypermedia is interpreted."
:children marshes-examples-nav-items}
{:label "Isomorphism" :href "/sx/(geography.(isomorphism))" :children isomorphism-nav-items}
{:label "CEK Machine" :href "/sx/(geography.(cek))" :children cek-nav-items})}
{:label "Language" :href "/sx/(language)"