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:
@@ -35,6 +35,7 @@ def _register_sx_helpers() -> None:
|
||||
"prove-data": _prove_data,
|
||||
"page-helpers-demo-data": _page_helpers_demo_data,
|
||||
"spec-explorer-data": _spec_explorer_data,
|
||||
"spec-explorer-data-by-slug": _spec_explorer_data_by_slug,
|
||||
"handler-source": _handler_source,
|
||||
})
|
||||
|
||||
@@ -329,6 +330,35 @@ def _collect_symbols(expr) -> set[str]:
|
||||
return result
|
||||
|
||||
|
||||
_SPEC_SLUG_MAP = {
|
||||
"parser": ("parser.sx", "Parser", "Tokenization and parsing"),
|
||||
"evaluator": ("eval.sx", "Evaluator", "Tree-walking evaluation"),
|
||||
"primitives": ("primitives.sx", "Primitives", "Built-in pure functions"),
|
||||
"render": ("render.sx", "Renderer", "Three rendering modes"),
|
||||
"special-forms": ("special-forms.sx", "Special Forms", "Special form dispatch"),
|
||||
"signals": ("signals.sx", "Signals", "Fine-grained reactive primitives"),
|
||||
"adapter-dom": ("adapter-dom.sx", "DOM Adapter", "Client-side DOM rendering"),
|
||||
"adapter-html": ("adapter-html.sx", "HTML Adapter", "Server-side HTML rendering"),
|
||||
"adapter-sx": ("adapter-sx.sx", "SX Adapter", "SX wire format serialization"),
|
||||
"engine": ("engine.sx", "SxEngine", "Pure logic for the browser engine"),
|
||||
"orchestration": ("orchestration.sx", "Orchestration", "Browser lifecycle"),
|
||||
"boot": ("boot.sx", "Boot", "Browser initialization"),
|
||||
"router": ("router.sx", "Router", "URL parsing and route matching"),
|
||||
"boundary": ("boundary.sx", "Boundary", "Language/platform boundary"),
|
||||
"continuations": ("continuations.sx", "Continuations", "Delimited continuations"),
|
||||
"types": ("types.sx", "Types", "Optional gradual type system"),
|
||||
}
|
||||
|
||||
|
||||
def _spec_explorer_data_by_slug(slug: str) -> dict | None:
|
||||
"""Look up spec by slug and return explorer data."""
|
||||
entry = _SPEC_SLUG_MAP.get(slug)
|
||||
if not entry:
|
||||
return None
|
||||
filename, title, desc = entry
|
||||
return _spec_explorer_data(filename, title, desc)
|
||||
|
||||
|
||||
def _spec_explorer_data(filename: str, title: str = "", desc: str = "") -> dict | None:
|
||||
"""Parse a spec file into structured metadata for the spec explorer.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user