Commit Graph

387 Commits

Author SHA1 Message Date
1f49242ae3 sx: step 5 — OCaml AdtValue + define-type + match
Native algebraic data type representation in the OCaml SX evaluator.
Replaces the dict-based shim that simulated ADT values via tagged dicts.

- sx_types.ml: add AdtValue variant + adt_value record (av_type, av_ctor,
  av_fields). type_of returns the type name (e.g. "Maybe"); inspect renders
  as a constructor call (e.g. "(Just 42)" or "(Nothing)").
- sx_runtime.ml: get_val handles AdtValue with :_adt/:_type/:_ctor/:_fields
  keys for back-compat with spec-level match-pattern code.
- sx_primitives.ml: dict? returns true for AdtValue (so existing match
  dispatch keeps working); new adt? predicate distinguishes ADT values.
- sx_ref.ml: sf_define_type now constructs AdtValue instead of Dict.
  Predicates (Name?, Ctor?) and accessors (Ctor-field) match on AdtValue
  with proper type/ctor name and field index checks.
- spec/tests/test-adt.sx: 3 new tests covering type-of, adt?, and inspect.

Tests: 4532 passed (was 4529 + 3 new), 1339 failed (unchanged baseline).
All 43 ADT tests pass on the native representation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 22:54:33 +00:00
b19f2017d0 GUEST-plan: claim step 2 — prefix.sx
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 22:47:22 +00:00
57cfee8267 GUEST-plan: log step 1 done
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 22:46:58 +00:00
0eced4c34c plan: record step 4 commit hash 2026-05-06 22:27:36 +00:00
b7ad5152d8 sx: step 4 — parser spans satisfied by step 3 tokenizer fix
Verified all 4 hs-upstream-core/sourceInfo tests now pass without any parser
changes. The parser already had `link-next-cmds` (sets `:next` on each command
in a CommandList when hs-span-mode is true) and `:true-branch` extraction in
`parse-cmd` for if statements; Step 3's `:end`/`:line` token fields were the
only missing pieces.

Probed via sx_eval against the parser:
  (hs-line-at "if true\n  log 'it was true'\n    log 'it was true'"
              (list :true-branch :next))
returns "    log 'it was true'" — matches the expected upstream behaviour.

Test runner output:
  PASS: hs-upstream-core/sourceInfo > debug
  PASS: hs-upstream-core/sourceInfo > get line works for statements
  PASS: hs-upstream-core/sourceInfo > get source works for expressions
  PASS: hs-upstream-core/sourceInfo > get source works for statements
2026-05-06 22:27:26 +00:00
1824058aa3 plan: record step 3 commit hash
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 22:14:17 +00:00
023bc2d80c sx: step 3 — add :end and :line to hs tokenizer tokens
Extend hs-make-token to (type value pos &rest extras) producing dicts
{:pos :end :line :value :type}. End defaults to pos+len(value); line
defaults to 1. Both tokenize loops now track current-line via newline
counting in advance!. hs-emit! and t-emit! pass the right end and
start-line to the constructor; redundant dict-set! after construction
removed.

Mirror copied to shared/static/wasm/sx/hs-tokenizer.sx (byte-identical).

Verify: (hs-make-token "NUMBER" "1" 0) returns
  {:pos 0 :end 1 :line 1 :value "1" :type "NUMBER"}.

OCaml suite: 4529 pass, 1339 pre-existing failures (baseline). All
4/4 hs-upstream-core/sourceInfo tests now pass (was 2/4 — closes E38).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 22:14:10 +00:00
ccf8a0fb90 GUEST-plan: claim step 1 — conformance.sx
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 22:02:31 +00:00
c265c6e376 GUEST-plan: log step 0 done
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 22:02:08 +00:00
d25cb1223e plan: record step 2 commit hash
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 21:45:52 +00:00
e80e655b51 sx: step 2 — restore frame locals on browser VmSuspension resume
In `resume_vm`'s `restore_reuse`, the saved sp captured by
`call_closure_reuse` was ignored when restoring the caller frame after the
async callback finished. The suspended callee's locals/temps stayed on the
value stack above saved_sp, so subsequent LOCAL_GET/SET in the caller
frame (e.g. letrec sibling bindings waiting on the suspending call) read
stale callee data instead of their own slots. Sibling bindings appeared
nil after a perform/resume cycle on the JIT path used by the WASM
browser kernel.

Fix: after popping the callback result and restoring saved_frames, reset
`vm.sp <- saved_sp` (when sp is above), then push the callback result.
Mirrors the OP_RETURN+sp-reset discipline that sync `call_closure_reuse`
already follows.

New tests in `spec/tests/test-letrec-resume.sx` cover single binding,
sibling bindings, mutual recursion siblings, and nested letrec —
all four pass. Full OCaml run_tests: 4529/5868 (was 4525/5864), zero
regressions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 21:45:44 +00:00
e85a828de8 plan: record step 1 commit hash 2026-05-06 21:30:27 +00:00
882a4b76cb sx: step 1 — fix JIT call_closure_reuse for closure returns
In `call_closure_reuse`, the success path used a bare `pop vm` that relied on
OP_RETURN having left the stack at exactly `saved_sp + 1`. When the callee
returns a closure (or hits the bytecode-exhausted fallback path), `vm.sp` can
end up inconsistent with the parent frame's expected layout, corrupting
intermediate values such as parser combinator state in `parse-bind`/`many`/
`seq`.

Fix: read the result at the expected slot, then explicitly reset
`vm.sp <- saved_sp` before returning so the parent frame sees a clean stack
regardless of what the callee left behind.

OCaml run_tests baseline: 4525/5864 unchanged. WASM kernel tests: 24/29
unchanged. No regressions.
2026-05-06 21:30:19 +00:00
d39ef786ba GUEST-plan: claim step 0 — baseline snapshot
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 21:04:19 +00:00
40f0e73386 briefing: tick Phase 4, update progress log — env-as-value complete
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 44s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 19:13:45 +00:00
16cf4d9316 plans: sx-improvements roadmap + loop briefing (14 steps)
Phases: bug fixes (JIT combinator, letrec+resume), E38 source info
completion, native ADTs (define-type/match), plugin system, performance.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 19:01:23 +00:00
eaab8db840 merge: architecture → hs-f (R7RS steps 4-6, IO suspension, JIT, language libs)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 56s
Brings in 306 commits from architecture:
- R7RS: call/cc, raise/guard, records, parameters, syntax-rules, define-library/import
- IO suspension: perform/resume, third CEK phase
- JIT expansion: component/island JIT, OP_SWAP, exception handler stack, scope forms
- OCaml: HTML renderer, Python bridge, epoch protocol, sx_scope.ml
- Language libs: common-lisp, erlang, forth, apl, prolog, tcl, smalltalk, ruby

Conflict resolution: hs-f version kept for all hyperscript .sx files (superseding
architecture's smaller additions). Architecture's platform.py kept with hs-f's
domListen _driveAsync fix applied.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 18:54:06 +00:00
8a009df4a3 haskell: merge loops/haskell — Phases 1–6 complete (775 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 54s
Parser, layout, desugar, lazy eval, ADTs, HM inference, typeclasses
(Eq/Ord/Show/Num/Functor/Monad), real IO monad, full Prelude. 775/775
green across 13 program suites.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 18:28:12 +00:00
2249863d2d tcl: Phase 3 OCaml primitives — file I/O + clock; refresh prolog scoreboard
file-read/write/append/exists?/glob + clock-seconds/milliseconds/format
registered in sx_primitives.ml; unix dep added to dune. Unlocks Tcl
open/read/puts-to-file, glob, clock seconds/format commands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 18:27:48 +00:00
859361d86a plans: haskell-completeness phases 7-16 + updated loop briefing
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
String=[Char] via pure-SX views, show, error, numeric tower,
Data.Map, Data.Set, records, IORef, exceptions. Briefing updated
to point at new plan; old phases 1-6 plan untouched.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 17:40:53 +00:00
09d65d2d7b haskell: 13 new program suites + scoreboard 156/156 (775 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 24s
collatz, palindrome, maybe, fizzbuzz, anagram, roman, binary, either,
primes, zipwith, matrix, wordcount, powers — all 18/18 programs green.
conformance.sh PROGRAMS array updated; scoreboard.md regenerated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 17:02:02 +00:00
f86d07401d plans: tick Phase 6 prelude + progress log (635/635)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 15:51:36 +00:00
74e020359f plans: tick Phase 1 apply in tcl-sx-completion 2026-05-06 15:37:40 +00:00
db52a6d77c plans: tick Phase 1 regexp/regsub in tcl-sx-completion 2026-05-06 15:31:55 +00:00
679b45e3fc plans: tick Phase 1 float expr, add progress log to tcl-sx-completion 2026-05-06 15:20:17 +00:00
b0c135412a chore: scoreboard 1478/1496 (+1 or-from listener)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 15:17:43 +00:00
9f57234d1e scoreboard: 1477/1496 (+1, F7 hs-on nil-target guard)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 14:03:33 +00:00
041cb9f3ef haskell: getLine/getContents/readFile/writeFile + 0-arity builtin force (+12 tests, 587/587)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 13:43:13 +00:00
096faf2c40 plans: tcl-sx-completion — phased plan for remaining Tcl limitations
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 17s
Phase 1: zero-cost wins (float/regex/apply/arrays, no SX changes)
Phase 2: lib/fiber.sx (pure SX fibers via call/cc + set!)
Phase 3: small OCaml additions (file-read, clock-seconds, etc.)
Phase 4: env-as-value (optional architectural cleanup)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 13:21:59 +00:00
578e54f06d haskell: real IO monad — putStrLn/print/putStr + hk-run-io (+10 tests, 575/575)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 20s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 13:10:42 +00:00
82d16597e0 scoreboard: 1476/1496 after computed property names fix
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 13:09:33 +00:00
6d8f366439 HS: scoreboard — 1475/1496 (98.6%) after step-limit fix
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 12:35:36 +00:00
1c45262577 haskell: deriving (Eq, Show) for ADTs (+11 tests, 565/565)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Parser parses optional deriving clause; only appended to AST when non-empty.
hk-bind-decls! data arm generates dictShow_Con / dictEq_Con per constructor.
hk-binop == and /= now deep-force both sides (SX dict equality is by
reference — two thunks wrapping the same value compared as not-equal without
this). Three token-type fixes in the deriving parser (lparen/rparen/comma,
not "special").

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 12:25:51 +00:00
cfe5371354 HS: scoreboard — E38 sourceInfo +2, E39 correction
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 46s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 12:08:44 +00:00
c93fe4453a HS: scoreboard — E36 commit hash
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 11:44:31 +00:00
623529d3be HS: socket feature (E36) — WebSocket wrapper + RPC proxy (+16 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Parser: socket feature (name, url, with timeout, on message, json/raw).
Runtime: hs-socket-register!, hs-socket-normalise-url, hs-socket-bind-name!,
  hs-socket-reconnect!, hs-socket-rpc!, hs-socket-resolve-rpc! — full
  WebSocket lifecycle with reconnect, pending-map RPC, and timeout.
Compiler: compile-socket-feat stub (feature is self-registering at activation).
Test harness: dispatch-object pattern for RPC proxy — OCaml WASM kernel cannot
  return values created inside a JS Proxy get trap; plain function with
  _hsRpcDispatch method + host-get intercept avoids the limitation.
Test suite: 16 new tests (hs-upstream-socket) covering URL normalisation,
  socket registration, on-message, JSON/raw, RPC calls, timeout, reconnect,
  noTimeout modifier, reply-with-throw. 16/16 pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 11:44:13 +00:00
bf190b8fc4 tcl: merge loops/tcl — complete Tcl 8.6 subset (329 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Phases 1-6: Dodekalogue tokenizer/parser, eval engine, expr mini-language,
string/list/dict commands, proc + uplevel/upvar (the headline showcase),
catch/try/throw, namespaces + ensembles, generator coroutines, idiom corpus.

Resolved add/add conflicts by taking loops/tcl (the complete tested impl)
over the architecture branch's earlier prototype.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 11:36:59 +00:00
74ce9e7c75 merge loops/prolog: complete Prolog-on-SX implementation
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 47s
590 tests passing across 29 suites. Brings in: parser, runtime,
query API, compiler, conformance harness, integration suite, and
hs-bridge (combined hook + factory styles).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 11:20:44 +00:00
bc45b7abf5 tcl: tick Phase 6 checkboxes, update progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 11:06:05 +00:00
6c1a953c80 plans: tick standard classes + progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s
2026-05-06 10:57:41 +00:00
ea064346e1 tcl: tick Phase 5 checkboxes, update progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 10:21:47 +00:00
5e0fcb9316 tcl: tick Phase 4 checkboxes, update progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 09:59:09 +00:00
afddc92c70 tcl: update progress log with conformance/classic programs entry
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 38s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 09:45:07 +00:00
95f96efb78 tcl: conformance.sh + scoreboard, annotate classic programs
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Adds lib/tcl/conformance.sh: runs .tcl programs through the epoch
protocol, compares against # expected: annotations, writes
scoreboard.json and scoreboard.md. All 3 classic programs pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 09:44:44 +00:00
cffd3bec83 tcl: tick Phase 3 core checkboxes, update progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 09:31:17 +00:00
985671cd76 hs: query targets, prolog hook, loop scripts, new plans, WASM regen
Hyperscript compiler/runtime:
- query target support in set/fire/put commands
- hs-set-prolog-hook! / hs-prolog-hook / hs-prolog in runtime
- runtime log-capture cleanup

Scripts: sx-loops-up/down, sx-hs-e-up/down, sx-primitives-down
Plans: datalog, elixir, elm, go, koka, minikanren, ocaml, hs-bucket-f,
       designs (breakpoint, null-safety, step-limit, tell, cookies, eval,
       plugin-system)
lib/prolog/hs-bridge.sx: initial hook-based bridge draft
lib/common-lisp/tests/runtime.sx: CL runtime tests

WASM: regenerate sx_browser.bc.js from updated hs sources

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 09:19:56 +00:00
a49b1a9f79 tcl: tick dict/60+ tests checkboxes, update progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 38s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 09:00:39 +00:00
fb51620a4c plans: tick dict-passing elaborator + progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s
2026-05-06 08:57:23 +00:00
0dbf9b9f73 tcl: tick list commands checkbox, update progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 44s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 08:54:47 +00:00
a26be0bfd0 tcl: tick string commands checkbox, update progress log
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 08:49:17 +00:00