Replace update-code-highlight's O(n²) for-each loop (79 nth calls +
79 dom-set-attr FFI crossings) with a single innerHTML set via join/map.
Builds the HTML string in WASM, one FFI call to set innerHTML.
858ms → 431ms (WASM) → 101ms (JIT) → 76ms (innerHTML batch)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Wire up jit_call_hook in sx_browser.ml (same pattern as server)
- Deferred JIT: _jit_enabled flag, enabled after boot-init completes
(prevents "Undefined symbol" errors from compiling during .sx loading)
- enable-jit! native function called by sx-platform.js after boot
- sx-platform.js: async WASM kernel polling + JIT enable after init
- Error logging for JIT compile failures and runtime fallbacks
Performance: 858ms → 431ms (WASM CEK) → 101ms (WASM JIT)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nav-etc.sx had its own plans-nav-items (35 entries) that loaded after
nav-data.sx (36 entries) and silently overwrote it, hiding sx-host.
All nav items are now solely defined in nav-data.sx.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace WebTransport-only design with three-transport model:
- Browser↔server: WebSocket (works today, no infrastructure changes)
- Browser↔browser: WebRTC data channels (true P2P, NAT traversal)
- Server↔server: HTTP federation (existing sx-pub)
Home nodes relay WebRTC signaling. Reliable channels for chat/components,
unreliable channels for game state/cursor positions. Transport-agnostic
protocol layer — upgrade to WebTransport later with zero SX changes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add Debugging & analysis section to tool catalogue (sx_trace, sx_deps,
sx_build_manifest)
- Update harness entry to mention multi-file and setup support
- Update tool count from 35+ to 40+
- Add tool table to CLAUDE.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 2d: shared-signal primitive — local signal writes propagate to
peers via WebTransport rooms. Same deref/reset!/swap! API, networking
invisible to the reactive layer. LWW default, CRDT opt-in.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two new demo pages with live interactive islands:
Cyst (/geography/reactive/examples/cyst):
Parent island with a cyst inside. Parent + button increments parent
count, cyst + button increments cyst count. Cyst state survives
parent re-renders. Shows the isolation boundary in action.
Reactive Expressions (/geography/reactive/examples/reactive-expressions):
Temperature signal with 5 expression types all updating live:
bare deref, str+deref, arithmetic+deref, full conversion string,
conditional. Demonstrates that any expression containing deref
auto-tracks signal dependencies.
Both verified reactive with Playwright clicks on the live server.
Nav entries added to reactive-examples-nav-items.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New defisland ~sx-tools/tool-playground: paste SX source, click a tool
button, see the output. 7 tools run client-side in the browser:
summarise, read-tree, find-all, validate, get-context, serialize,
hypersx.
Each uses the same SX functions the MCP server uses: sx-parse for
parsing, tree walking for annotation/summarise/find, sx-serialize for
round-trip, sx->hypersx for alternative syntax.
Pre-loaded with a sample defcomp. Users can paste any SX and explore
all the comprehension tools interactively.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously only the first parsed expression was inserted. Now all
expressions in new_source are spliced at the given index. e.g.
new_source="(a) (b) (c)" inserts all three as siblings.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Added 7 new documentation sections with code examples:
- Cyst: isolated reactive subtrees that survive parent re-renders
- Reactive expressions: auto-wrapping deref-containing exprs in computed
- Live island preview: paste defisland, get working reactive preview
- HyperSX: indentation-based alternative syntax viewer
- Inline test runner: browser-embedded test execution with pass/fail
- Test harness: three-layer test infrastructure (core/reactive/web)
- Core signals: spec-level reactive primitives, zero platform deps
Each section has code examples. The test runner section links to the
live temperature converter demo with 5/5 inline tests.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New language feature: (cyst [:key id] body...) creates a DOM container
with its own island scope that persists across parent reactive re-renders.
On first render, the body is evaluated in a fresh with-island-scope and
the resulting DOM is cached. On subsequent renders, the cached DOM node
is returned if still connected to the document.
This solves the fundamental problem of nesting reactive islands inside
other islands' render trees — the child island's DOM (with its event
handlers and signal subscriptions) survives when the parent re-renders.
Implementation: *memo-cache* dict keyed by cyst id. render-dom checks
isConnected before returning cached node. Each cyst gets its own
disposer list via with-island-scope.
Usage in sx-tools: defisland render preview now wrapped in (cyst :key
full-name ...). Real mouse clicks work — counter increments, temperature
converts, computed signals update. Verified on both local and live site.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Removed auto-parse on source change (the (reset! parsed ...) at top
of letrec body). Only Parse button triggers parsing now.
- Split defcomp/defisland render: defcomp uses parameter substitution
with bindings signal, defisland uses live component call.
- Removed stopPropagation wrapper (didn't help).
Island previews are reactive — signals, computed, swap! all work.
Known: Playwright's click (which triggers focus change from textarea)
resets the island. Direct JS clicks and PointerEvent dispatches work
correctly. Real islands on demo pages work perfectly with mouse clicks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Added sx_harness_eval to the MCP tools table
- Added spec/harness.sx to the specification files list
- Added full test harness design section (sessions, interceptors, IO log,
assertions, extensibility, platform-specific extensions, CID-based
component/test association)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The island preview refactoring replaced both defcomp and defisland
handling with sx-load-components + component call. This broke parameter
substitution for defcomp (which uses bindings signal for live preview).
Split the cond: defcomp uses the original subst approach (extract params,
read bindings, substitute symbols in body). defisland uses the live
preview via sx-load-components + native render-dom-island.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixed three fundamental issues:
1. cek-try arg passing: handler was called with raw string instead of
(List [String msg]), causing "lambda expects 1 args, got N" errors
2. Silent island hydration failures: hydrate-island now wraps body
render in cek-try, displaying red error box with stack trace instead
of empty div. No more silent failures.
3. swap! thunk leak: apply result wasn't trampolined, storing thunks
as signal values instead of evaluated results
Also fixed: assert= uses = instead of equal? for value comparison,
assert-signal-value uses deref instead of signal-value, HTML entity
decoding in script tag test source via host-call replaceAll.
Temperature converter demo page now shows live test results:
✓ initial celsius is 20
✓ computed fahrenheit = celsius * 1.8 + 32
✓ +5 increments celsius
✓ fahrenheit updates on celsius change
✓ multiple clicks accumulate
1116/1116 OCaml tests pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- render-html-island wraps body SSR in cek-try (graceful fallback to
empty container when island body has DOM/signal code)
- defcomp placeholder pattern: server renders safe placeholder div
with data-sx-island, browser hydrates the actual island
- cek-try primitive added to both server and browser OCaml kernels
- assert/assert= added to spec/harness.sx for standalone use
- Test source stored in <script type="text/sx-test" data-for="...">
with HTML entity decoding via host-call replaceAll
Temperature converter: 5 tests embedded in demo page. Test runner
hydrates and finds tests but body render is empty — needs debugging
of the specific construct that silently fails in render-to-dom.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Temperature converter tests (6 tests): initial value, computed
fahrenheit derivation, +5/-5 click handlers, reactive propagation,
multiple click accumulation.
New components:
- sx/sx/reactive-islands/test-runner.sx — reusable defisland that
parses test source, runs defsuite/deftest forms via cek-eval, and
displays pass/fail results with re-run button
- sx/sx/reactive-islands/test-temperature.sx — standalone test file
Added cek-try primitive to both browser (sx_browser.ml) and server
(sx_server.ml) for safe test execution with error catching.
Browser bundle now includes harness files (harness.sx,
harness-reactive.sx, harness-web.sx) for inline test execution.
Known: SSR renders test runner body instead of placeholder, causing
arity error on complex str expressions. Needs island SSR handling fix.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
web/harness-reactive.sx — signal testing (no DOM dependency):
assert-signal-value, assert-signal-has-subscribers,
assert-signal-subscriber-count, assert-computed-dep-count,
assert-computed-depends-on, simulate-signal-set!/swap!,
make-test-signal (signal + history tracking), assert-batch-coalesces
web/harness-web.sx — web platform testing (mock DOM, no browser):
mock-element, mock-set-text!, mock-append-child!, mock-set-attr!,
mock-add-listener!, simulate-click, simulate-input, simulate-event,
assert-text, assert-attr, assert-class, assert-no-class,
assert-child-count, assert-event-fired, assert-no-event,
event-fire-count, make-web-harness
Both extend spec/harness.sx. The reactive harness uses spec/signals.sx
directly — works on any host. The web harness provides lightweight DOM
stubs that record operations for assertion, no real browser needed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Core reactive primitives (signal, deref, reset!, swap!, computed, effect,
batch, notify-subscribers, dispose-computed, with-island-scope,
register-in-scope) moved to spec/signals.sx — pure SX, zero platform
dependencies. Usable by any host: web, CLI, embedded, server, harness.
Web extensions (marsh scopes, stores, event bridge, resource) remain in
web/signals.sx, which now depends on spec/signals.sx.
Updated all load paths:
- hosts/ocaml/bin/sx_server.ml — loads spec/signals.sx before web/signals.sx
- hosts/ocaml/bin/run_tests.ml — loads both in order
- hosts/ocaml/browser/bundle.sh + sx-platform.js — loads core-signals.sx first
- shared/sx/ocaml_bridge.py — loads spec/signals.sx before web extensions
1116/1116 OCaml tests pass. Browser reactive island preview works.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
spec/harness.sx — spec-level test harness with:
- Mock platform (30+ default IO mocks: fetch, query, DOM, storage, etc.)
- Session management (make-harness, harness-reset!, harness-set!/get)
- IO interception (make-interceptor, install-interceptors)
- IO log queries (io-calls, io-call-count, io-call-nth, io-call-args)
- IO assertions (assert-io-called, assert-no-io, assert-io-count, etc.)
15 harness tests passing on both OCaml (1116/1116) and JS (15/15).
Loaded automatically by both test runners.
MCP tool: sx_harness_eval — evaluate SX with mock IO, returns result + IO trace.
The harness is extensible: new platforms just add entries to the platform dict.
Components can ship with deftest forms that verify IO behavior against mocks.
Tests are independent objects that can be published separately (by CID).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Added contains-deref? predicate to adapter-dom.sx. When rendering a text
expression that contains (deref ...) inside an island scope, the adapter
now wraps it in (reactive-text (computed (fn () (eval-expr expr env)))).
This tracks signal dependencies through arbitrary expressions like
(str (deref celsius) "°C") and (+ (* (deref celsius) 1.8) 32).
Previously only bare (deref sig) was reactive. Now compound expressions
like string interpolation and arithmetic over signals update in real
time. The temperature converter preview in sx-tools is fully reactive:
clicking +5/-5 updates both °C and °F displays live.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
defisland expressions are now rendered as fully reactive live previews.
The component is registered via sx-load-components, then called through
the native render-dom-island adapter path — same code path as real
islands on the page.
Bare (deref sig) expressions are fully reactive — clicking buttons
updates signal values and DOM updates in real time. Compound expressions
like (str (deref c) "°C") render statically (cek-reactive-text only
tracks bare deref). Next: auto-wrap deref-containing expressions in
computed signals for full reactive expression support.
Also cleaned up stale effect and preview-el signal from earlier attempts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
defisland expressions in the render tab are now evaluated through
render-to-dom inside with-island-scope, producing real DOM with signal
bindings. The rendered output persists in a stable container managed by
an effect, outside the reactive render tree.
Known limitation: signal subscriptions don't fire on button clicks yet —
the reactive wiring needs investigation into how deferred (setTimeout)
execution contexts interact with CEK signal tracking. Static rendering
(initial values) works correctly.
Also: removed stale effect that attempted hydrate-island approach.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Python-based MCP server (tools/mcp_services.py) for understanding the
microservice topology via static analysis:
- svc_status: Docker container status
- svc_routes: HTTP route table from blueprint scanning
- svc_calls: inter-service dependency graph (fetch_data/call_action/etc)
- svc_config: environment variables from docker-compose
- svc_models: SQLAlchemy models, columns, relationships
- svc_schema: live defquery/defaction manifest from running services
- alembic_status: migration count per service
- svc_logs/svc_start/svc_stop: service lifecycle
- svc_queries/svc_actions: SX query and action definitions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tool table was listing only the original 11 tools. Now documents all 31
including smart editing, project-wide search, dev workflow, and git integration.
Also updated the protocol to mention pattern-based editing and sx_write_file.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- sx_changed: list .sx files changed since a ref with structural summaries
- sx_diff_branch: structural diff of all .sx changes vs base ref
- sx_blame: git blame for .sx files, optionally focused on a tree path
- sx_doc_gen: generate component docs from defcomp/defisland signatures
- sx_playwright: run Playwright browser tests with structured results
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New comprehension tools:
- sx_find_across: search pattern across all .sx files in a directory
- sx_comp_list: list all definitions (defcomp/defisland/defmacro/defpage/define)
- sx_comp_usage: find all uses of a component across files
- sx_diff: structural diff between two .sx files (ADDED/REMOVED/CHANGED)
- sx_eval: REPL — evaluate SX expressions in the MCP server env
Smart read_tree enhancements:
- Auto-summarise large files (>200 lines)
- focus param: expand only matching subtrees, collapse rest
- max_depth/max_lines/offset for depth limiting and pagination
Smart editing tools:
- sx_rename_symbol: rename all occurrences of a symbol in a file
- sx_replace_by_pattern: find+replace first/all pattern matches
- sx_insert_near: insert before/after a pattern match (top-level)
- sx_rename_across: rename symbol across all .sx files (with dry_run)
- sx_write_file: create .sx files with parse validation
Development tools:
- sx_pretty_print: reformat .sx files with indentation (also used by all edit tools)
- sx_build: build JS bundle or OCaml binary
- sx_test: run test suites with structured pass/fail results
- sx_format_check: lint for empty bindings, missing bodies, duplicate params
- sx_macroexpand: evaluate expressions with a file's macro definitions loaded
Also: updated hook to block Write on .sx files, added custom explore agent.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sx->hypersx transform converts parsed SX to a readable indentation-based
format: CSS selector shorthand (div.card#main), signal sugar (@count,
signal(), :=, <-), string interpolation ("Count: {@count}"), and
structural keywords (when, if, let, map, for).
Implemented as pure SX in web/lib/hypersx.sx, loaded in browser via
js_of_ocaml platform. Added as "hypersx" tab in the tree editor.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Register cond-scheme? as OCaml primitive — was defined in spec/evaluator.sx
but never exposed to the browser runtime, causing render.sx to crash with
"Undefined symbol: cond-scheme?" on every SX response. This broke URL
updates on navigation (handle-history never ran after the rendering error).
Tree editor render tab now extracts &key params from defcomp/defisland
definitions and shows input fields. Values substitute into the rendered
preview live as you type. Inputs live outside the reactive cond branch
so signal updates don't steal focus.
sx-tools page function accepts &key params (title, etc.) forwarded to
the overview component.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The render tab now correctly renders HTML tag expressions as live DOM
(div, h2, p, ul, etc. with Tailwind classes). Non-HTML expressions
(defcomp, define, etc.) are shown as serialized SX text.
Previous version tried eval-expr which errored silently in the browser.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Named paths let you navigate by structure name instead of opaque indices.
Both formats work in all MCP tools:
- Index: "(0 3 2)"
- Named: "defisland > let > letrec"
The server detects ">" in the path string and calls resolve-named-path
(SX function) which walks the tree matching child names at each level.
New SX functions: resolve-named-path, split-path-string, find-child-by-name.
MCP server: added trim/split primitives, resolve_path dispatcher.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tree editor island now has 4 tabs: tree, context, validate, render.
The render tab evaluates SX source as live HTML — type a (div (h2 "Hello"))
and see it rendered immediately.
MCP server paths changed from JSON arrays [0,2,1] to SX strings "(0 2 1)".
Fixes serialization issues and is more natural for an SX tool. The
json_to_path function now parses SX via sx-parse.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 4: defisland ~sx-tools/tree-editor — interactive tree viewer
embedded in the SX Tools page. Features:
- Textarea with :bind for SX source input
- Parse button to re-parse on demand
- Tree view: annotated tree with path labels, clickable nodes
- Context view: enclosing chain from root to selected node
- Validate view: structural integrity checks (catches missing body etc.)
MCP server fixes: added ident-start?, ident-char?, make-keyword,
escape-string, sx-expr-source — needed by parser.sx when loaded
into the MCP evaluator.
Also: .mcp.json for Claude Code MCP server config, CLAUDE.md protocol
for structural .sx file editing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 1-3 of the SX Tools plan — structural reading, editing, and
MCP server for .sx files.
lib/tree-tools.sx — Pure SX functions for tree comprehension and editing:
Comprehension: annotate-tree, summarise, read-subtree, get-context,
find-all, get-siblings, validate, navigate
Editing: replace-node, insert-child, delete-node, wrap-node, tree-set
Helpers: list-replace, list-insert, list-remove, replace-placeholder
lib/tests/test-tree-tools.sx — 107 tests covering all functions.
hosts/ocaml/bin/mcp_tree.ml — MCP server (stdio JSON-RPC) exposing
11 tools. Loads tree-tools.sx into the OCaml evaluator, parses .sx
files with the native parser, calls SX functions for tree operations.
The MCP server can be configured in Claude Code's settings.json as:
"mcpServers": { "sx-tree": { "command": "path/to/mcp_tree.exe" } }
1429 tests passing (1322 existing + 107 new tree-tools).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two bugs caused code blocks to render empty across the site:
1. ~docs/code component had parameter named `code` which collided with
the HTML <code> tag name. Renamed to `src` and updated all 57
callers. Added font-mono class for explicit monospace.
2. Batched IO dispatch in ocaml_bridge.py only skipped one leading
number (batch ID) but the format has two (epoch + ID):
(io-request EPOCH ID "name" args...). Changed to skip all leading
numbers so the string name is correctly found. This fixes highlight
and other batchable helpers returning empty results.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two paren bugs in home-stepper.sx caused the home page to render blank:
1. Line 222 had one extra ) that prematurely closed the letrec bindings
list — rebuild-preview and do-back became body expressions instead
of bindings, making them undefined in scope.
2. Lines 241-308 were outside the let/letrec scope entirely — the outer
let closed at line 240, so freeze-scope, cookie restore, source
parsing, and the entire div rendering tree had no access to signals
or letrec functions.
Also hardens defisland to wrap multi-expression bodies in (begin ...),
matching the Python-side fix from 9f0c541. Both spec/evaluator.sx and
the OCaml transpiled sx_ref.ml are updated.
Adds SX Tools essay under Applications — the revised plan for structural
tree reading/editing tools for .sx files, motivated by this exact bug.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Brings in sx-pub federated publishing protocol (Phases 1-4):
- DB models, IPFS publishing, federation, anchoring
- Live dashboard UI on the plan page
- Dev infrastructure (docker-compose, dev-pub.sh)
Conflicts: sx-browser.js (kept ocaml-vm rebuild), sx-pub.sx (kept sx-pub version with dashboard)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
defcomp/defisland with multi-expression bodies (let, letrec,
freeze-scope, effect) had only the LAST expression stored as body.
The browser received a truncated defisland missing let/letrec/signal
bindings, causing "Undefined symbol: code-tokens" on hydration.
Fix: body_exprs = expr[body_start:], wrapped in (begin ...) if
multiple. Also clear stale pickle cache on code changes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>