Skip to content

Add EVE (shared atom) and DOM proxy support to cljs-thread#4

Open
johnmn3 wants to merge 5 commits intomasterfrom
claude/eve-external-progress-report-XiYvG
Open

Add EVE (shared atom) and DOM proxy support to cljs-thread#4
johnmn3 wants to merge 5 commits intomasterfrom
claude/eve-external-progress-report-XiYvG

Conversation

@johnmn3
Copy link
Copy Markdown
Owner

@johnmn3 johnmn3 commented Mar 10, 2026

This PR introduces two major features to cljs-thread:

Summary

Adds EVE — a SharedArrayBuffer-backed atom system for lock-free inter-thread state sharing — and a DOM proxy layer that enables transparent DOM access from worker threads. Also includes comprehensive documentation, test infrastructure, and example applications (ray tracer and Reagami counter).

Key Changes

EVE (Shared Atoms)

  • src/cljs_thread/eve.cljs — Public API for creating and managing SharedArrayBuffer-backed atoms
  • src/cljs_thread/eve.clj — Compile-time macro support for EVE operations
  • WASM modules (resources/wasm/wasm_mem.wat, resources/wasm_slab/slab_bitmap.wat) — Low-level memory operations and slab bitmap allocation with SIMD acceleration
  • Enables multiple threads to safely share mutable state without locks via atomic operations

DOM Proxy System

  • src/cljs_thread/dom/proxy.cljs — ES6 Proxy factory for transparent DOM access from workers
  • src/cljs_thread/dom/registry.cljs — Screen-side handle registry mapping DOM objects to integer identifiers
  • src/cljs_thread/dom/events.cljs — Event listener forwarding between worker and screen threads
  • src/cljs_thread/dom/install.cljs — Worker-side proxy installation
  • src/cljs_thread/dom.cljs — Public API for DOM operations from workers
  • Workers can now access DOM via in macro, with event callbacks staying on the worker thread

Go Blocks & Async Support

  • src/cljs_thread/go.clj and src/cljs_thread/go.cljs — Compile-time CPS transform for implicit go blocks
  • Rewrites @expr (deref) into parking continuations instead of blocking
  • Allows synchronous-looking code between async deref points

Testing Infrastructure

  • src/cljs_thread/test.clj and related modules — Unified test runner with auto-discovery
  • test/cljs_thread/*_test.cljs — Comprehensive test suite covering atoms, DOM proxy, async primitives, and integration scenarios
  • E2E tests (test/e2e/*.spec.js) — Playwright-based browser automation tests

Example Applications

  • Ray Tracer (ex/raytracer/) — Tile-based ray tracing using pmap with shared atom results
  • Reagami Counter (ex/reagami_counter/) — Reactive counter demonstrating shared atom updates across threads

Documentation

  • doc/01-getting-started.md through doc/23-internals.md — Complete user and contributor guides
  • CLAUDE.md — Internal development notes
  • CONTRIBUTING.md — Contribution guidelines
  • CHANGELOG.md — Version history

Core Library Updates

  • src/cljs_thread/core.cljs — Added atom export and on-when macro support
  • src/cljs_thread/in.cljs — Enhanced with EVE integration and improved serialization
  • src/cljs_thread/macro_impl.clj — Extended macro infrastructure
  • src/cljs_thread/future.clj and .cljs — Improved async handling
  • README.md — Updated to reflect new features ("Two steps closer to threads on the web")

Build & Configuration

  • shadow-cljs.edn — Test runner configuration with auto-generated discovery
  • deps.edn — Updated dependencies and test aliases
  • package.json — NPM configuration for E2E testing
  • .clj-kondo/config.edn — Linter rules for new macros

Notable Implementation Details

  • SIMD-accelerated memory operations in WASM for efficient buffer copying and bitmap scanning
  • **Identity

https://claude.ai/code/session_018fBeDxZWXp5XkrsXLaa5Xf

John Michael Newman III and others added 5 commits March 10, 2026 03:16
… dep

Restructure this branch to use eve as an external dependency rather than
a bundled eve/ subdir. The eve library now lives at SeniorCareMarket-com/eve.

Changes:
- deps.edn: eve/eve now a git dep (SeniorCareMarket-com/eve sha 237a6eba)
- package.json: remove native addon build infra; add eve-native npm git dep;
  remove node-gyp-build/prebuildify/node-addon-api; remove gypfile
- Remove binding.gyp (native addon is in the eve dep, not here)
- Remove build.clj, cljdoc.edn (belong to the eve library)
- Remove bench/ (eve benchmark data, not cljs-thread)
- Remove private scripts (ccweb-setup.sh, etc.)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When eve became an external git dep, its test namespaces (eve.deftype-test,
eve.map-test, etc.) are no longer on the classpath. Add the gitlibs-resolved
test path to :node-test extra-paths so the thread-test runner can find them.

All 317 tests pass with 31,062 assertions, 0 failures.

https://claude.ai/code/session_018fBeDxZWXp5XkrsXLaa5Xf
- Remove hardcoded /root/.gitlibs paths from deps.edn aliases
- Remove :main-opts from :thread-test alias (eve.test-runner is in eve repo)
- Fix core.cljs require: cljs-thread.eve.shared-atom → eve.shared-atom
- Strip eve repo test namespaces from thread-test-main.cljs runner,
  keeping only slab-tier tests that don't need the fat kernel
  (worker-tier tests need the discovery runner: clj -M:thread-test)

node-test: 13 tests, 113 assertions, 0 failures
thread-test: 5 tests, 11 assertions, 0 failures

https://claude.ai/code/session_018fBeDxZWXp5XkrsXLaa5Xf
The test runner (eve.test-runner) was generic infrastructure that
happened to live in the eve repo. Port it to cljs-thread.test-runner
so cljs-thread can run its own tests via:

  clj -M:thread-test                    # all tests
  clj -M:thread-test :tier pure :node   # pure tier via node
  clj -M:thread-test :dry-run           # show test plan
  clj -M:thread-test :list              # list discovered namespaces

Discovers 23 test namespaces (6 pure, 17 worker).
Pure tier: 17 tests, 127 assertions, 0 failures.

https://claude.ai/code/session_018fBeDxZWXp5XkrsXLaa5Xf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants