Commit Graph

1110 Commits

Author SHA1 Message Date
8d3ab040ef Fix WASM browser: broken links (&rest bytecode) + broken reactive counter (ListRef mutation)
Two bugs fixed:

1. Links: bytecode compiler doesn't handle &rest params — treats them as
   positional, so (first rest) gets a raw string instead of a list.
   Replaced &rest with explicit optional params in all bytecode-compiled
   web SX files (dom-query, dom-add-listener, browser-push-state, etc.).
   The VM already pads missing args with Nil.

2. Reactive counter: signal-remove-sub! used (filter ...) which returns
   immutable List, but signal-add-sub! uses (append!) which only mutates
   ListRef. Subscribers silently vanished after first effect re-run.
   Fixed by adding remove! primitive that mutates ListRef in-place.

Also:
- Added evalVM API to WASM kernel (compile + run through bytecode VM)
- Added scope tracing (scope-push!/pop!/peek/context instrumentation)
- Added Playwright reactive mode for debugging island signal/DOM state
- Replaced cek-call with direct calls in core-signals.sx effect/computed
- Recompiled all 23 bytecode modules

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 14:08:49 +00:00
553bbf123e Merge ocaml-vm: document VM debugging tools in CLAUDE.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 08:58:24 +00:00
2ee4d4324a Document VM debugging tools and island authoring rules in CLAUDE.md
Tools: vm-trace, bytecode-inspect, deps-check, prim-check,
test_boot.sh, sx-build-all.sh — with usage examples.

Island rules: (do ...) for multi-expression bodies, nested let for
cross-references, (deref (computed ...)) for reactive derived text,
effects in inner let for OCaml SSR compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 01:32:55 +00:00
31af9a5ca3 Merge ocaml-vm: 6 VM debugging and build tools
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 01:24:45 +00:00
dab81fc571 Add 6 VM/bytecode debugging and build tools
OCaml server commands:
- vm-trace: step-by-step bytecode execution trace (opcode, stack, depth)
- bytecode-inspect: disassemble compiled function (opcodes, constants, arity)
- deps-check: strict symbol resolution (resolved vs unresolved symbols)
- prim-check: verify CALL_PRIM opcodes match real primitives

Scripts:
- hosts/ocaml/browser/test_boot.sh: WASM boot test in Node.js
- scripts/sx-build-all.sh: full pipeline (OCaml + JS + tests)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 01:23:55 +00:00
0699de0144 Fix some primitive: return callback result, not element
List.find returns the element that matched, but SX some should return
the callback's truthy return value. This caused get-verb-info to return
"get" (the verb string) instead of the {method, url} dict.

Also added _active_vm tracking to VM for future HO primitive optimization,
and reverted get-verb-info to use some (no longer needs for-each workaround).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 01:13:52 +00:00
3e6898197d Fix get-verb-info: replace some with for-each to avoid bytecode closure bug
The some HO form passes callbacks through call_sx_fn which creates a new
VM that can't see the enclosing closure's captured variables (el). Replaced
with for-each + mutation which keeps everything in the same VM scope.

Also fixed destructuring param ((verb ...)) → plain param (verb).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:52:04 +00:00
c923a34fa8 Fix WASM browser click handlers: 8 bugs, 50 new VM tests
The sx-get links were doing full page refreshes because click handlers
never attached. Root causes: VM frame management bug, missing primitives,
CEK/VM type dispatch mismatch, and silent error swallowing.

Fixes:
- VM frame exhaustion: frames <- [] now properly pops to rest_frames
- length primitive: add alias for len in OCaml primitives
- call_sx_fn: use sx_call directly instead of eval_expr (CEK checks
  for type "lambda" but VmClosure reports "function")
- Boot error surfacing: Sx.init() now has try/catch + failure summary
- Callback error surfacing: catch-all handler for non-Eval_error exceptions
- Silent JIT failures: log before CEK fallback instead of swallowing
- vm→env sync: loadModule now calls sync_vm_to_env()
- sx_build_bytecode MCP tool added for bytecode compilation

Tests: 50 new tests across test-vm.sx and test-vm-primitives.sx covering
nested VM calls, frame integrity, CEK bridge, primitive availability,
cross-module symbol resolution, and callback dispatch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 00:37:21 +00:00
00de248ee9 WIP: bytecode module pre-compilation and loading infrastructure
- compile-modules.js: Node.js build tool, all 23 .sx files compile to .sxbc.json
- api_load_module with shared globals (beginModuleLoad/endModuleLoad batch API)
- api_compile_module for runtime compilation
- sx-platform.js: bytecode-first loader with source fallback, JSON deserializer
- Deferred JIT enable (setTimeout after boot)

Known issues:
- WASM browser: loadModule loads but functions not accessible (env writeback
  issue with interned keys)
- WASM browser: compileModule fails ("Not callable: nil" — compile-module
  function from bytecode not working correctly in WASM context)
- Node.js js_of_ocaml: full roundtrip works (compile → load → call)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:54:55 +00:00
cb7bbc9557 Bytecode module compiler: loadModule/compileModule APIs + build script
- sx_browser.ml: add api_load_module (execute pre-compiled bytecode on VM,
  copy defines back to env) and api_compile_module (compile SX source to
  bytecode via compile-module function)
- compile-modules.js: Node.js build tool that loads the js_of_ocaml kernel,
  compiles all 23 .sx platform files to bytecode, writes .sxbc.json files
- Serialization format: type-tagged JSON constants (s/n/b/nil/sym/kw/list/code)
  with nested code objects for lambda closures

All 23 files compile successfully (430K total bytecode JSON).
Next: wire up sx-platform.js to load bytecode instead of source.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:37:26 +00:00
2802dd99e2 Fix JIT nil-param crash: guard execute-request, restore error logging
- orchestration.sx: add nil guard for verb/url before calling do-fetch
  (prevents "Expected string, got nil" when verb info dict lacks method)
- sx_browser.ml: restore JIT error logging (Eval_error only, not all
  exceptions) so real failures are visible, silence routine fallbacks
- Rebuild WASM bundle with fixes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:22:06 +00:00
f33eaf8f3a Stepper: innerHTML batch update replaces per-span DOM manipulation
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>
2026-03-26 17:12:56 +00:00
226c01bbf6 Browser JIT: compile SX lambdas to bytecode VM in WASM kernel
- 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>
2026-03-26 17:04:39 +00:00
c72a5af04d WIP: pre-existing changes from WASM browser work + test infrastructure
Accumulated changes from WASM browser development sessions:
- sx_runtime.ml: signal subscription + notify, env unwrap tolerance
- sx_browser.bc.js: rebuilt js_of_ocaml browser kernel
- sx_browser.bc.wasm.js + assets: WASM browser kernel build
- sx-platform.js browser tests (test_js, test_platform, test_wasm)
- Playwright sx-inspect.js: interactive page inspector tool
- harness-web.sx: DOM assertion updates
- deploy.sh, Dockerfile, dune-project: build config updates
- test-stepper.sx: stepper unit tests
- reader-macro-demo plan update

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:40:38 +00:00
10576f86d1 WASM browser build: interned env keys, async kernel boot, bundled .sx platform
- Symbol interning in sx_types.ml: env lookups use int keys (intern/unintern)
  to avoid repeated string hashing in scope chain walks
- sx-platform.js: poll for SxKernel availability (WASM init is async)
- shell.sx: load sx_browser.bc.wasm.js when SX_USE_WASM=1
- bundle.sh: fix .sx file paths (web-signals.sx rename)
- browser/dune: target byte+js+wasm modes
- Bundle 23 .sx platform files for browser (dom, signals, router, boot, etc.)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 16:37:42 +00:00
589507392c Fix plans-nav-items: remove stale duplicate from nav-etc.sx
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>
2026-03-26 16:08:49 +00:00
3b4156c722 Merge ocaml-vm: sx-host plan (five IO primitives)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 14:17:51 +00:00
c0c6787189 Add sx-host plan: five irreducible IO primitives
read, write, store, retrieve, hash — the platform floor beneath every
host. Everything above (HTTP, SQL, TLS, protocols) is SX libraries
published to sx-pub. Any device that moves bytes can host SX.

Migration path: defhelper, SX config, protocol libraries, minimal
host binary, self-hosting. Relates to sx-web (connectivity), Mother
Language (evaluator), Rust/WASM (host impl), sx-pub (library source).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 14:16:59 +00:00
6f1810dc4e Merge branch 'ocaml-vm' into sx-tools 2026-03-26 12:18:53 +00:00
91d5de0554 sx-web plan: WebSocket + WebRTC peer-to-peer architecture
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>
2026-03-26 12:18:47 +00:00
c04f3ab7ce Document new MCP tools in sx-tools page and CLAUDE.md
- 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>
2026-03-26 12:12:03 +00:00
3ac8cb48f3 Merge branch 'ocaml-vm' into sx-tools 2026-03-26 12:11:27 +00:00
4bb4d47d63 Add shared signals over WebTransport to sx-web plan
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>
2026-03-26 12:11:15 +00:00
5ed984e7e3 Add 5 MCP tools, refactor nav-data, fix deep path bug, fix Playwright failures
Nav refactoring:
- Split nav-data.sx (32 forms) into 6 files: nav-geography, nav-language,
  nav-applications, nav-etc, nav-tools, nav-tree
- Add Tools top-level nav category with SX Tools and Services pages
- New services-tools.sx page documenting the rose-ash-services MCP server

JS build fixes (fixes 5 Playwright failures):
- Wire web/web-signals.sx into JS build (stores, events, resources)
- Add cek-try primitive to JS platform (island hydration error handling)
- Merge PRIMITIVES into getRenderEnv (island env was missing primitives)
- Rename web/signals.sx → web/web-signals.sx to avoid spec/ collision

New MCP tools:
- sx_trace: step-through CEK evaluation showing lookups, calls, returns
- sx_deps: dependency analysis — free symbols + cross-file resolution
- sx_build_manifest: show build contents for JS and OCaml targets
- sx_harness_eval extended: multi-file loading + setup expressions

Deep path bug fix:
- Native OCaml list-replace and navigate bypass CEK callback chain
- Fixes sx_replace_node and sx_read_subtree corruption on paths 6+ deep

Tests: 1478/1478 JS full suite, 91/91 Playwright

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 12:09:22 +00:00
4e88b8a9dd Merge ocaml-vm: reactive runtime demos, sx-web plan, build fixes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 09:22:22 +00:00
6e2696ca20 Add Cyst and Reactive Expressions demo pages under reactive islands
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>
2026-03-26 08:44:49 +00:00
dc72aac5b1 Add interactive tool playground to sx-tools page
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>
2026-03-26 08:34:20 +00:00
b98e5b83de Document full SX tool catalogue on sx-tools page
35 MCP tools across 8 categories with code examples for each:
- Comprehension (7): read_tree, summarise, read_subtree, get_context,
  find_all, get_siblings, validate
- Path-based editing (4): replace_node, insert_child, delete_node,
  wrap_node
- Smart editing (4): rename_symbol, replace_by_pattern, insert_near,
  rename_across
- Project-wide search (3): find_across, comp_list, comp_usage
- Development (7): pretty_print, write_file, build, test, format_check,
  macroexpand, eval
- Git integration (3): changed, diff_branch, blame
- Test harness (1): harness_eval
- Analysis (3): diff, doc_gen, playwright

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 08:30:34 +00:00
11f0098006 Allow sx_insert_child to insert multiple children at once
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>
2026-03-26 08:28:07 +00:00
2bfae33659 Document all new SX tools at top of sx-tools page
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>
2026-03-26 08:23:05 +00:00
9e079c9c19 Add (cyst) form: isolated reactive subtree that survives parent re-renders
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>
2026-03-26 08:13:27 +00:00
9ce40bdc4f Fix island preview: remove auto-parse, restore defcomp params
- 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>
2026-03-26 07:48:22 +00:00
2a1d3a34e7 Update CLAUDE.md with test harness and all 44 MCP tools
- 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>
2026-03-26 07:36:30 +00:00
296ba4cd57 Fix hypersx tab: remove black background from pre element
Override prose/code CSS that applies dark background to pre tags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 07:19:31 +00:00
4853513599 Fix defcomp parameter rendering in sx-tools render tab
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>
2026-03-26 07:11:31 +00:00
b53a0fabea Inline test runner: 5/5 temperature converter tests passing
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>
2026-03-26 01:51:30 +00:00
7a8a166326 Test runner: SSR fix, cek-try primitive, HTML entity handling
- 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>
2026-03-26 01:38:10 +00:00
5754a9ff9f Add inline test runner for temperature converter demo
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>
2026-03-26 01:00:07 +00:00
fea44f9fcc Add reactive runtime demos + sx-web federation plan
7 interactive island demos for the reactive runtime layers:
- L0 Ref (timer + DOM handle), L1 Foreign (canvas via host-call),
  L2 Machine (traffic light), L3 Commands (undo/redo),
  L4 Loop (bouncing ball), L5 Keyed Lists, L6 App Shell

Fix OCaml build: add (wrapped false) to lib/dune, remove Sx. qualifiers.
Fix JS build: include dom-lib + browser-lib in adapter compilation.

New plan: sx-web federated component web — browser nodes via WebTransport,
server nodes via IPFS, in-browser authoring, AI composition layer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 00:54:23 +00:00
4fa0850c01 Add test harness extensions: reactive signals + web/DOM mocking
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>
2026-03-26 00:47:50 +00:00
b104663481 Split signals: core spec (spec/signals.sx) + web extensions (web/signals.sx)
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>
2026-03-26 00:23:35 +00:00
b1690a92c4 Add SX test harness: mock IO platform for testing components
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>
2026-03-26 00:00:19 +00:00
4b733e71b0 Reactive expressions: auto-wrap deref-containing exprs in computed signals
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>
2026-03-25 23:59:03 +00:00
f7cf5dbd47 Live reactive island preview in render tab
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>
2026-03-25 23:51:59 +00:00
d8161050a8 Render tab: live island preview via effect + render-to-dom
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>
2026-03-25 23:37:36 +00:00
250bee69c7 Add rose-ash-services MCP server: 12 tools for service introspection
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>
2026-03-25 23:34:52 +00:00
6806343d0e Update CLAUDE.md with all 31 sx-tree MCP tools
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>
2026-03-25 23:27:05 +00:00
7047a5d7f3 Add git-aware SX tools: changed, diff_branch, blame, doc_gen, playwright
- 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>
2026-03-25 23:25:00 +00:00
76ce0c3ecb Add 15 new MCP tools to sx-tree: project-wide search, smart editing, dev workflow
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>
2026-03-25 23:19:10 +00:00
68c05dcd28 Add HyperSX view tab: indentation-based alternative syntax for SX
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>
2026-03-25 23:01:43 +00:00