Commit Graph

476 Commits

Author SHA1 Message Date
7357988af6 Rebuild hyperscript WASM bytecode bundles (hs-*.sxbc + manifest)
Updates the pre-bundled HS tokenizer/parser/compiler/runtime/integration
sx + sxbc pairs plus module-manifest.json in shared/static/wasm/sx/,
matching the current HS source after recent patches (call command,
event destructuring, halt/append, break/continue, CSS block syntax, etc.).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 09:09:56 +00:00
5c42f4842b Tests: cek-try-seq / htmx / hs-diag / perform-chain + node HS runners
New spec tests: test-cek-try-seq (CEK try/seq), test-htmx (htmx
directive coverage, 292L), test-hs-diag, test-perform-chain (IO
suspension chains).

tests/hs-*.js: Node.js-side hyperscript runners for browser-mode
testing (hs-behavioral-node, hs-behavioral-runner, hs-parse-audit,
hs-run-timed).

Vendors shared/static/scripts/htmx.min.js.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 09:09:27 +00:00
fc24cc704d GraphQL: query/mutation/fragments/vars/executor + parser spec + tests
New graphql application. 676-line test-graphql.sx covers parser, executor,
fetch-gql integration. lib/graphql.sx (686L) is the core parser/AST;
lib/graphql-exec.sx (219L) runs resolvers. applications/graphql/spec.sx
declares the application. sx/sx/applications/graphql/ provides the doc
pages (parser, queries, mutation, fragments, vars, fetch-gql, executor).

Includes rebuilt sx_browser.bc.js / sx_browser.bc.wasm.js bundles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 09:08:00 +00:00
3ba819d9ae HS parser/compiler/runtime: fix 8 parse errors, add/remove arrays, return guard
Parser:
- `add VALUE to :var` → (add-value) for array append
- `remove VALUE from :var` → (remove-value) for array removal
- `toggle .foo for 10ms` → (toggle-class-for) with duration
- `append VALUE` without `to` → implicit target (it)
- `set {obj} on target` → (set-on) for object property spread
- `repeat in` body: remove spurious nil (body at index 3→2)
- Keywords followed by `(` parsed as function calls (fixes `increment()`)

Compiler:
- Handle add-value, remove-value, toggle-class-for, set-on AST nodes
- Local variables (`set :var`) use `define` instead of `set!`

Runtime:
- hs-add-to!: append value to list
- hs-remove-from!: filter value from list
- hs-set-on!: spread dict properties onto target
- `as String` for lists: comma-join (JS Array.toString compat)

Tests:
- eval-hs/eval-hs-with-me: guard for hs-return exceptions
  (return compiles to raise, needs handler to extract value)

Parse errors: 20→12 (8 fixed). Remaining: 6 embedded HTML quotes
(tokenizer), 6 transition template values `(expr)px`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 11:06:46 +00:00
d4f74b5b02 Make starts-with? and ends-with? tolerate non-string args (return false)
Previously these primitives threw Eval_error if either arg was non-string.
Now they return false, preventing crashes when DOM attributes return nil
values during element processing (e.g. htmx-boot-subtree! iterating
elements with undefined attribute names).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 07:41:42 +00:00
f78a97960f Fix starts-with? crash: guard with string? check on attribute name
orchestration.sx process-elements iterates DOM attributes and calls
starts-with? on the name. Some attributes have nil names (e.g. from
malformed elements). Added (string? name) guard before starts-with?.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 07:33:05 +00:00
de90cd04f2 Add hs-htmx module to WASM build — htmx activation was missing
The htmx-boot-subtree! function (defined in lib/hyperscript/htmx.sx)
was never loaded in the browser because hs-htmx.sx wasn't in the
bundle or compile-modules lists. Added to:
- bundle.sh: copy htmx.sx as hs-htmx.sx to dist
- compile-modules.js: compile to hs-htmx.sxbc, add to deps and lazy list

This was the root cause of "Load Content" button not working —
hx-* attributes were never activated because htmx-boot-subtree!
was undefined.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 07:21:41 +00:00
b5387c069f Test runner: increase wait times for iframe htmx activation
- reload-frame: wait 1500ms after wait-boot (was 500ms)
- wait-for-el: poll up to 25 tries / 5s (was 15 / 3s)
- Added log after wait-boot confirming iframe ready

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 06:58:38 +00:00
673be85743 HS fetch: 4→11/23 — POST options, Number format, route mock
Parser: fetch command consumes {method:"POST"}, with {opts}, and
handles as-format both before and after options.
Mock: Number format case-insensitive, /test route has number field.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 23:22:56 +00:00
84996d74e2 Test runner: return-value error handling, no guard/cek-try/throws
guard and cek-try both create CEK frames that don't survive async
perform/resume. Instead, run-action returns nil on success and an
error string on failure. The for-each loop checks the return value
and sets fail-msg. No exceptions cross async boundaries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 23:09:38 +00:00
db8e680caf Revert do→let/it chaining (caused 80-test regression)
The let/it wrapping changed semantics of ALL multi-command sequences,
breaking independent side-effect chains like (do (add-class) (add-class)).
Need a targeted approach — chain it only for then-separated commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 23:01:23 +00:00
0410812420 Async error handler: dispatch Eval_error to VM handler_stack in resume_vm
When an error occurs during resumed VM execution (after perform/hs-wait),
resume_vm now checks the VM's handler_stack. If a handler exists (from a
compiled guard form's OP_PUSH_HANDLER), it unwinds frames and jumps to
the catch block — exactly like OP_RAISE. This enables try/catch across
async perform/resume boundaries.

The guard form compiles to OP_PUSH_HANDLER which lives on the vm struct
and survives across setTimeout-based async resume. Previously, errors
during resume escaped to the JS console as unhandled exceptions.

Also restored guard in the test runner (was cek-try which doesn't survive
async) and restored error-throwing assertions in run-action.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 22:54:37 +00:00
ac193e8839 HS: do→let/it chaining, single-IO fetch, fetch URL parser, IO mock
Compiler: do-blocks now compile to (let ((it cmd1)) (let ((it cmd2)) ...))
instead of (do cmd1 cmd2 ...). This chains the `it` variable through
command sequences, enabling `fetch X then put it into me` pattern.
Each command's result is bound to `it` for the next command.

Runtime: hs-fetch simplified to single perform (io-fetch url format)
instead of two-stage io-fetch + io-parse-text/json.

Parser: fetch URL /path handled by reading /+ident tokens.
Default fetch format changed to "text" (was "json").

Test runner: mock fetch routes with format-specific responses.
io-fetch handler returns content directly based on format param.

Fetch tests still need IO suspension to chain through let continuations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 22:54:31 +00:00
b12ec746a2 Fix: replace guard with cek-try in test runner, clear stale reuse_stack
The guard form (call/cc + handler-bind expansion) doesn't survive async
IO suspension — the CEK continuation from guard's call/cc captures frames
that become invalid after the VM resumes from hs-wait. Replacing guard
with cek-try (which compiles to VM-native OP_PUSH_HANDLER/OP_POP_HANDLER)
avoids the CEK boundary crossing.

The test runner now executes: suspends on hs-wait, resumes, runs test
actions, and test assertions fire correctly. The "Not callable: nil"
error is eliminated. Remaining: test assertion errors from iframe content
not loading fast enough (timing issue, not a framework bug).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 18:10:10 +00:00
d8fec1305b Diagnostic: enhanced resume error with VM frame names, clear stale reuse on re-suspend
The Not callable: nil error happens on a stub VM (frames=[], sp=0) during
cek_resume with 12 CEK kont frames. The error is from a reactive signal
subscriber (reset! current ...) that triggers during run vm after resume.
The subscriber callback goes through CEK via cek_call_or_suspend and the
CEK continuation tries to call nil.

This is a reactive subscriber notification issue, not a perform/resume
frame management issue. The VM frames are correctly restored — the error
happens during a synchronous reset! call within the resumed VM execution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 16:27:04 +00:00
112eed50d0 Diagnostic: enhanced Not callable error with VM state context
Shows pending_cek, reuse_stack count, and frames count in the error.
Also transfers reuse_stack from _active_vm at VmSuspended catch sites.

Finding: the Not callable: nil happens during cek_resume (pending_cek=false,
kont=12 frames). The CEK continuation tries to call a letrec function that
is nil because letrec bindings are in VM local SLOTS, not in the CEK env.
The VM→CEK boundary crossing during suspension loses the local slot values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 15:49:04 +00:00
f276c4a56a Restore cek_run IO hooks and cek_step_loop error handling lost by bootstrap
bootstrap.py regenerated cek_run as a simple "raise if suspended" without
the _cek_io_resolver and _cek_io_suspend_hook checks. Also lost the
CekPerformRequest catch in cek_step_loop and step_limit checks.

This was the direct cause of "IO suspension in non-IO context" when island
click handlers called perform (via hs-wait). The CEK had no way to propagate
the suspension to the VM/JS boundary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 14:01:14 +00:00
aef92cc1f3 Fix _driveAsync to handle dict-format IO requests from callFn path
The callFn suspension returns requests as {op: "io-sleep", args: {items: [100]}}
(dict format) but _driveAsync only handled list format (op-name arg ...).
Result: io-sleep/wait resumes never fired — tests hung after first suspension.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 13:40:43 +00:00
c0b001d3c2 Fix VM reuse_stack lost across stub VM boundary on IO suspension
Root cause: when perform fires inside a VM closure chain (call_closure_reuse),
the caller frames are saved to reuse_stack on the ACTIVE VM. But the
_cek_io_suspend_hook and _cek_eval_lambda_ref create a NEW stub VM for the
VmSuspended exception. On resume, resume_vm runs on the STUB VM which has
an empty reuse_stack — the caller frames are orphaned on the original VM.

Fix: transfer reuse_stack from _active_vm to the stub VM before raising
VmSuspended. This ensures resume_vm -> restore_reuse can find and restore
the caller's frames after async resume via _driveAsync/setTimeout.

Also restore step_limit/step_count refs dropped by bootstrap.py regeneration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 13:31:55 +00:00
0e152721cc Remove cek_resume debug tracing, rebuild WASM
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 13:08:43 +00:00
c641b445f8 Fix: local bindings now shadow HTML tag special forms in browser evaluator
Root cause: sx_browser.ml registered all HTML tags (a, b, i, p, s, u, g, etc.)
as custom special forms. The evaluator's step_eval_list checked custom special
forms BEFORE checking local env bindings. So (let ((a (fn () 42))) (a))
matched the HTML tag <a> instead of calling the local function a.

Fix: skip custom special forms AND render-check when the symbol is bound in
the local env. Added (not (env-has? env name)) guard to both checks in
step-eval-list (spec/evaluator.sx and transpiled sx_ref.ml).

This was the root cause of "[sx] resume: Not callable: nil" — after hs-wait
resumed, calling letrec-bound functions like wait-boot (which is not an HTML
tag) worked, but any function whose name collided with an HTML tag failed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 12:53:09 +00:00
8c85e892c2 Fix callable? type mismatch, restore 20 HS test regressions, add host-* server stubs
callable? in boot-helpers.sx checked for "native-fn" but type-of returns
"function" for NativeFn — broke make-spread and all native fn dispatch
in aser. Restore 20 behavioral tests replaced with NOT IMPLEMENTED stubs
by the test regeneration commit. Add host-* platform primitive stubs to
sx_server.ml so boot-helpers.sx loads without errors server-side.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:15:55 +00:00
76f7e3b68a HS: return/guard, repeat while/until, if-then fix, script extraction
Parser: if-then consumes 'then' keyword before parsing then-body.
Compiler: return→raise, def→guard, repeat while/until dispatch.
Runtime: hs-repeat-while, hs-repeat-until.
Test gen: script block extraction for def functions.
repeat suite: 10→13/30.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 21:33:55 +00:00
97818c6de1 HS compiler: return via raise/guard, def param fix
- return compiles to (raise (list "hs-return" value)) instead of
  silently discarding the return keyword
- def wraps function body in guard that catches hs-return exceptions,
  enabling early exit from repeat-forever loops via return
- def params correctly extract name from (ref name) AST nodes

Note: IO suspension kernel changes reduced baseline from 519→487.
The HS parser/compiler/runtime fixes are all intact.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:55:20 +00:00
ca9196a693 Stub VM uses real globals for CEK resume after IO suspension
The _cek_io_suspend_hook creates a stub VM to carry the suspended CEK
state. Previously used empty globals, which caused "Not callable: nil"
when the CEK resume needed platform functions. Now uses _default_vm_globals
(set to _vm_globals by sx_browser.ml) so all platform functions and
definitions are available during resume.

Remaining issue: still getting "resume: Not callable: nil" — the CEK
continuation env may not include letrec bindings from the island body.
The suspension point is inside reload-frame → hs-wait, and the resume
needs to call wait-boot (a letrec binding).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:26:38 +00:00
d981e5f620 Remove debug logging from sx_browser.ml and sx-platform.js
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:08:01 +00:00
1bce1b701b Fix IO suspension in both cek_run and cek_run_iterative
The _cek_io_suspend_hook was only added to cek_run_iterative (line 986)
but the actual code path went through cek_run (line 624). Added the hook
check to both functions.

This fixes the "IO suspension in non-IO context" error that blocked
hs-wait/perform from propagating through event handler → trampoline →
eval_expr call chains. IO suspension now converts to VmSuspended via the
hook, which the value_to_js wrapper catches and drives with _driveAsync.

+42 OCaml test passes (3924→3966). IO suspension verified working in
browser WASM: dom-on click handler → hs-wait → perform → suspend →
_driveAsync → setTimeout → resume.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:43:07 +00:00
e12e84a4c7 WASM rebuild: IO suspension hook + all pending fixes
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:35:06 +00:00
98fbd5cf40 HS parser: possessive 's style property access (517→519/831)
parse-poss-tail now handles style token type after 's operator.
#div2's *color, #foo's *width etc. now correctly produce
(style prop owner) AST which compiles to dom-set/get-style.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 16:07:52 +00:00
4981e9a32f HS runtime: add Set/Map coercions to hs-coerce
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 15:28:29 +00:00
6f374fabce WASM rebuild: VM reuse_stack fix + boot.sxbc hydration + island preload
Recompiled WASM kernel (wasm_of_ocaml) to include the VM reuse_stack
fix from sx_vm.ml. Recompiled boot.sxbc with the clear-and-replace
hydration (replaceChildren + nil hydrating scope + dom-append).

sx-platform.js deployed with island preload, isMultiDefine fix, and
K.load error checking.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 15:21:11 +00:00
fc76a42403 HS: take attr semantics fix, +6 tests (509→515/831)
- Parser: take @attr=value with replacement restored (was reverted)
- Runtime: take @attr bare doesn't remove from scope (hyperscript keeps
  source attr, only sets on target). Only take @attr=val with replacement
  modifies scope elements.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 14:11:18 +00:00
6bd45daed6 hydrate-island: clear SSR children, render fresh DOM, append to island
Islands now: (1) clear SSR children via replaceChildren, (2) push nil
hydrating scope (disables hydration cursor walk that causes mismatch
errors), (3) render-to-dom creates fresh DOM with live event handlers,
(4) dom-append attaches the rendered DOM to the island element.

This fixes the hydrate-mismatch:div error caused by SSR/client attribute
differences (~tw generates different class strings server vs client).

NOTE: needs WASM rebuild (sx_build target=wasm) to compile boot.sxbc.
The .sx source is updated but the bytecoded module is stale.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 14:00:12 +00:00
8819d7cbd1 HS fixes: multi-property transition, take attr with-val, empty form, css-value parsing
- Parser: multi-property transition (width from 0px to 100px height from...)
  with collect-transitions loop. CSS value parsing uses parse-atom + manual
  number+unit concat to avoid greedy string-postfix chaining.
- Compiler: take! passes attr-val and with-val (restored from revert)
- Runtime: hs-empty-target! handles FORM by iterating child inputs,
  hs-starts-with-ic/hs-ends-with-ic for case-insensitive comparison

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 13:44:59 +00:00
faa65e15d8 Revert "hydrate-island: clear-and-replace instead of hydration walk"
This reverts commit ca077b429b.
2026-04-16 13:44:54 +00:00
ca077b429b hydrate-island: clear-and-replace instead of hydration walk
Islands now clear SSR children before render-to-dom and append the
fresh DOM result. Avoids hydrate-mismatch errors from SSR/client
attribute differences (~tw generates different class strings).

The hydrating scope is set to nil (no cursor walk) so render-to-dom
creates new DOM nodes instead of trying to reuse SSR elements.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 13:35:45 +00:00
c9634ba649 VM: fix nested IO suspension frame corruption, island hydration preload
VM frame merging bug: call_closure_reuse now saves caller continuations
on a reuse_stack instead of merging frames. resume_vm restores them in
innermost-first order. Fixes frame count corruption when nested closures
suspend via OP_PERFORM. Zero test regressions (3924/3924).

Island hydration: hydrate-island now looks up components from (global-env)
instead of render-env, triggering the symbol resolve hook. Added JS-level
preload-island-defs that scans DOM for data-sx-island and loads definitions
from the content-addressed manifest BEFORE hydration — avoids K.load
reentrancy when the resolve hook fires inside env_get.

loadDefinitionByHash: fixed isMultiDefine check — defcomp/defisland bodies
containing nested (define ...) forms no longer suppress name insertion.
Added K.load return value checking for silent error string returns.

sx_browser.ml: resolve hook falls back to global_env.bindings when
_vm_globals miss (sync gap). Snapshot reuse_stack alongside pending_cek.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 13:23:35 +00:00
684a46297d HS behavioral tests: 478→509/831 (57%→61%), parser/compiler/runtime fixes
Parser: am-a/am-not-a type checks, transition element/selector targeting,
take @attr=value with replacement, toggle my/the possessive, <selector/>
syntax in parse-atom, the-of for style/attr/class/selector, when-clause
filtering for add, starts/ends-with ignoring case.

Compiler: take attr passthrough, toggle-style nil→me default, scoped
querySelectorAll for add/remove/toggle-class, has-class? entry, matches?
extracts selector from (query sel), add-class-when with for-each filter,
starts/ends-with-ic entries, hs-add replaces + for polymorphic add.

Runtime: hs-take! proper attr values, hs-type-check Element/Node via
host-typeof, hs-toggle-style! opacity 0↔1, hs-coerce +8 coercions
(Keys/Values/Entries/Reversed/Unique/Flat/JSON/Object), hs-query-all
bypasses broken dom-query-all (WASM auto-converts arrays), hs-matches?
handles DOM el.matches(selector), hs-add list+string+number polymorphic,
hs-starts/ends-with-ic for case-insensitive comparison.

DOM mock: mkStyle() with setProperty/getPropertyValue, fndAll.item().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 12:53:43 +00:00
4aa49e42e8 htmx demos working: activation, fetch, swap, OOB filtering, test runner page
- htmx-boot-subtree! wired into process-elements for auto-activation
- Fixed cond compilation bug in hx-verb-info (Clojure-style flat cond)
- Platform io-fetch upgraded: method/body/headers support, full response dict
- Replaced perform IO ops with browser primitives (set-timeout, browser-confirm, etc)
- SX→HTML rendering in hx-do-swap with OOB section filtering
- hx-collect-params: collects input name/value for all methods
- Handler naming: ex-{slug} convention, removed perform IO dependencies
- Test runner page at (test.(applications.(htmx))) with iframe-based runner
- Header "test" link on every page linking to test URL
- Page file restructure: 285 files moved to URL-matching paths (a/b/c/index.sx)
- page-functions.sx: ~100 component name references updated
- _test added to skip_dirs, test- file prefix convention for test files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 11:56:15 +00:00
4f02f82f4e HS parser: fix number+comparison keyword collision, eval-hs uses hs-compile
Parser: skip unit suffix when next ident is a comparison keyword
(starts, ends, contains, matches, is, does, in, precedes, follows).
Fixes "123 starts with '12'" returning "123starts" instead of true.

eval-hs: use hs-compile directly instead of hs-to-sx-from-source with
"return " prefix, which was causing the parser to consume the comparison
as a string suffix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 11:29:01 +00:00
745e78ab05 HS parser: 'does not start/end with' negation support
Parser now handles 'does not start with' and 'does not end with'
comparison operators, compiling to (not (starts-with? ...)) and
(not (ends-with? ...)) respectively.

Test runner: host-set!/host-get stringify innerHTML/textContent.

437/831 (52.6%) — parser fix doesn't change count yet (comparison tests
use 'is a' type checks which need separate fix).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 20:19:33 +00:00
e5e3e90ee7 HS compiler: emit-set handles @attr of target expressions
Adds attribute reference case to the 'of' branch in emit-set:
(set @bar of #div2 to "foo") now compiles to (dom-set-attr target "bar" "foo")
instead of falling through to the broken (set! (host-get ...)) catchall.

417/831 (50.2%), +2 from attr-of fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 19:47:30 +00:00
b1666a5fe2 HS tests: VM step limit fix, callFn error propagation, compiler emit-set fixes
- sx_vm.ml: VM timeout now compares vm_insn_count > step_limit instead of
  unconditionally throwing after 65536 instructions when limit > 0
- sx_browser.ml: Expose setStepLimit/resetStepCount APIs on SxKernel;
  callFn now returns {__sx_error, message} on Eval_error instead of null
- compiler.sx: emit-set handles array-index targets (host-set! instead of
  nth) and 'of' property chains (dom-set-prop with chain navigation)
- hs-run-fast.js: New Node.js test runner with step-limit timeouts,
  SX-level guard for error detection, insertAdjacentHTML mock,
  range selection (HS_START/HS_END), wall-clock timeout in driveAsync
- hs-debug-test.js: Single-test debugger with DOM state inspection
- hs-verify.js: Assertion verification (proves pass/fail detection works)

Test results: 415/831 (50%), up from 408/831 (49%) baseline.
Fixes: set my style["color"], set X of Y, put at end of (insertAdjacentHTML).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 19:27:03 +00:00
1d83ccba3c Content-addressed on-demand loading: Merkle DAG for all browser assets
Replace the monolithic 500KB <script data-components> block with a 25KB
JSON manifest mapping names to content hashes. Every definition —
components, islands, macros, client libraries, bytecode modules, and
WASM binaries — is now content-addressed and loaded on demand.

Server (sx_server.ml):
- build_hash_index: Merkle DAG over all definitions — topological sort,
  hash leaves first, component refs become @h:{hash} in instantiated form
- /sx/h/{hash} endpoint: serves definitions with Cache-Control: immutable
- Per-page manifest in <script data-sx-manifest> with defs + modules + boot
- Client library .sx files hashed as whole units (tw.sx, tw-layout.sx, etc.)
- .sxbc modules and WASM kernel hashed individually

Browser (sx-platform.js):
- Content-addressed boot: inline script loads kernel + platform by hash
- loadDefinitionByHash: recursive dep resolution with @h: rewriting
- resolveHash: 3-tier cache (memory → localStorage → fetch /sx/h/{hash})
- __resolve-symbol extended for manifest-based component + library loading
- Cache API wrapper intercepts .wasm fetches for offline caching
- Eager pre-loading of plain symbol deps for CEK evaluator compatibility

Shell template (shell.sx):
- Monolithic <script data-components> removed
- data-sx-manifest script with full hash manifest
- Inline bootstrap replaces <script src="...?v="> with CID-based loading

Second visit loads zero bytes from network. Changed content gets a new
hash — only that item refetched (Merkle propagation).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 10:14:39 +00:00
4cac08d56f HS: contains/matches ignoring case support — 425→426
- Parser: contains/matches with ignoring case modifier
- Compiler: contains-ignore-case? → hs-contains-ignore-case?
- Compiler: matches-ignore-case? → hs-matches-ignore-case?
- Runtime: downcase-based case-insensitive contains/matches

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:45:57 +00:00
c05d8788c7 HS parser: is/is-not ignoring case, eq-ignore-case runtime — 423→425
- Parse `is X ignoring case` → (eq-ignore-case left right)
- Parse `is not X ignoring case` → (not (eq-ignore-case left right))
- Compiler: eq-ignore-case → hs-eq-ignore-case
- Runtime: hs-eq-ignore-case using downcase/str

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:38:12 +00:00
eaf3c88a36 HS runtime: empty/swap/compound events, host-set! fix — 403→423 (51%)
- Fix host-set → host-set! in emit-inc/emit-dec (increment/decrement properties)
- Implement empty/clear command: parser dispatch, compiler, polymorphic runtime
- Implement swap command: parser dispatch, compiler (let+do temp swap pattern)
- Add parse-compound-event-name: joins dot/colon tokens (example.event, htmx:load)
- Add hs-compile to source parser (was only in WASM deploy copy)
- Add clear/swap to tokenizer keywords and cmd-kw? list
- Generator: fix run() with extra args, String.raw support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:17:43 +00:00
e2fe070dd4 Fix :ref callback bug in adapter-dom — Pretext island fully working
Root cause: adapter-dom.sx line 345 handled :ref by calling
(dict-set! attr-val "current" el), assuming React-style ref objects.
Callback-style refs (fn (el) ...) passed a function, not a dict,
causing dict-set! to fail with "dict key val" error.

Fix: (if (callable? attr-val) (attr-val el) (dict-set! attr-val "current" el))
Supports both callback refs and dict refs.

Pretext island now fully working:
- 3 controls: width slider, font size slider, algorithm toggle
- Knuth-Plass + greedy line breaking via bytecode-compiled library
- canvas.measureText for pixel-perfect browser font metrics
- Effect-based imperative DOM rendering (createElement + appendChild)
- Reactive: slider drag → re-measure → re-break → re-render

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 08:26:48 +00:00
429c2b59f9 Hyperscript test generator: repeat loop fix, assert= arg order, quote handling
- Don't insert 'then' inside for-in loop bodies or after 'repeat N times'
  (fixes repeat from 1/30 → 5/30)
- Allow HS sources ending with " when they don't contain embedded HTML
  (fixes set from 6/25 → 10/25, enables 18 previously-skipped tests)
- Fix assert= argument order: (actual expected), not (expected actual)
  (error messages now correctly report Expected/Got)

395 → 402/831 (+7)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 22:51:20 +00:00
1884c28763 Fix browser compat: sublist replaces 3-arg slice, manual sum replaces reduce
- Added sublist helper (portable list extraction, avoids 3-arg slice
  which fails in browser WASM kernel)
- Replaced reduce + 0 lwid with manual sum loop (reduce has browser
  compat issues with dict-set! error in call stack)
- Imperative DOM update via effect for clean paragraph re-rendering
  on signal changes (clear container, create new spans)
- String slice in hyphenate-word kept (works on strings)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 18:31:34 +00:00