{"id":51101783,"url":"https://github.com/tailrecursion/chasma","last_synced_at":"2026-06-24T11:30:48.598Z","repository":{"id":365731710,"uuid":"1092187558","full_name":"tailrecursion/chasma","owner":"tailrecursion","description":"A tiny transactional actor runtime in Clojure","archived":false,"fork":false,"pushed_at":"2026-06-18T15:24:08.000Z","size":26,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-18T17:20:13.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tailrecursion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-08T06:40:19.000Z","updated_at":"2026-06-18T15:25:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tailrecursion/chasma","commit_stats":null,"previous_names":["tailrecursion/chasma"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/tailrecursion/chasma","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailrecursion%2Fchasma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailrecursion%2Fchasma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailrecursion%2Fchasma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailrecursion%2Fchasma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tailrecursion","download_url":"https://codeload.github.com/tailrecursion/chasma/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tailrecursion%2Fchasma/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34731243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-24T11:30:46.330Z","updated_at":"2026-06-24T11:30:48.590Z","avatar_url":"https://github.com/tailrecursion.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chasma\n\nA tiny transactional actor runtime in Clojure, inspired by [David McClain's Lisp Actors](https://github.com/dbmcclain/Lisp-Actors/tree/main#).\n\n**Note: This library is in active early development, highly experimental, and subject to change.**\n\n## Problem\n\nCoordinating concurrent workflows typically requires explicit thread management, shared-state locks, or callback graphs. These approaches are brittle under contention and make it difficult to reason about when effects become visible. Chasma provides per-actor behaviors, transactional turns, and automatic retries so message handlers can stay pure and deterministic.\n\n## Quick Example\n\n```clojure\n(require '[tailrecursion.chasma :as ch])\n\n(defn counter [n]\n  (fn [cmd]\n    (case cmd\n      :inc (ch/become! ch/*self* (counter (inc n)))\n      :get (ch/*reply* n)\n      nil)))\n\n(defn demo []\n  (let [u (ch/start! (ch/universe))\n        c (ch/lane (ch/spawn u (counter 0)))]\n    (try\n      (ch/send! c :inc)\n      (ch/send! c :inc)\n      ;; print 2\n      (println (deref (ch/ask c :get)))\n      (finally\n        (ch/stop! u)))))\n\n;; Mutually recursive even/odd predicates (SICP-style)\n(def u (ch/start! (ch/universe)))\n(def evenA (ch/spawn u))\n(def oddA  (ch/spawn u))\n\n(defn even-beh\n  ([n] (even-beh n ch/*sender*))\n  ([n cust]\n   (if (zero? n)\n     (ch/send! cust true)\n     (ch/send! oddA (dec n) cust))))\n\n(defn odd-beh\n  ([n] (odd-beh n ch/*sender*))\n  ([n cust]\n   (if (zero? n)\n     (ch/send! cust false)\n     (ch/send! evenA (dec n) cust))))\n\n(ch/become! evenA even-beh oddA odd-beh)\n\n(println @(ch/ask evenA 42)) ;; =\u003e true\n(println @(ch/ask oddA 17)) ;; =\u003e true\n(ch/stop! u)\n```\n\n## API Overview\n\n| Var | Description |\n| --- | ----------- |\n| `universe` | Creates a stopped runtime universe. Accepts `{:threads n :pump-poll-ms n :retry-base-ms n :retry-max-ms n :effect-error-handler f}`. |\n| `start! universe` | Starts a universe; idempotent and returns the universe. |\n| `stop! universe` | Stops a universe and shuts down its worker pool; idempotent and returns the universe. |\n| `spawn universe behavior-fn` | Creates an actor whose behavior is a variadic fn. Returns an `Actor` record. |\n| `spawn universe` | Creates a no-op actor in a universe. |\n| `spawn behavior-fn` | Inside a turn only, creates an actor in `*universe*`. |\n| `lane actor` | Creates a private serialized target for an actor in the actor's universe. |\n| `send! target \u0026 msg` | Enqueues a message to an actor or lane target. |\n| `become! actor new-beh ...` | Schedules one or more behavior changes. Inside a turn it buffers until commit; outside it applies atomically. |\n| `ask target \u0026 msg` | Sends a request to an actor or lane target and returns a `java.util.concurrent.CompletableFuture` (supports `deref`). |\n| `on-commit! \u0026 body` | Defers the body so it runs once, after the current turn commits successfully (must be called inside a turn). |\n\n## Execution Model\n\n- A `Universe` owns a queue, worker pool, retry settings, and lifecycle. Actors and lanes are bound to one universe.\n- Each delivery runs inside an implicit transaction buffer. All outbound `send!` and `ask` deliveries and any number of same-universe `become!` updates made during a behavior execute only after the behavior returns successfully.\n- A thrown exception or compare-and-set failure during commit discards the buffered effects and re-enqueues the message with bounded exponential backoff.\n- `on-commit!` schedules irreversible effects (logging, IO, etc.) and can only be invoked inside a turn; failures before commit drop the effect entirely. Once state has committed, `on-commit!` failures are reported and do not retry the turn.\n- `lane` creates a serialized target/capability for an actor. Mail sent through one lane is processed FIFO, one full delivery turn at a time; separate lanes for the same actor remain independent.\n- Messages sent while an actor is executing through a lane preserve that lane as the reply capability, so callees can reply through the same serialized target.\n- `send!` and `ask` infer delivery ownership from the target. Stopped universes reject new sends and asks.\n\n## Dynamic Vars\n\nAvailable inside every behavior:\n\n| Var | Meaning |\n| --- | ------- |\n| `*universe*` | The universe currently executing. |\n| `*self*` | The actor envelope currently executing. |\n| `*sender*` | Reply target/capability for the current message, such as an actor, lane, or `nil`. |\n| `*reply*` | Convenience fn `(fn [v])` that sends a reply back to `*sender*`. |\n| `*tx*` | Internal transaction buffer (implementation detail, provided for completeness). |\n\n## Development\n\nThe project is built with `deps.edn`. Run the test suite with:\n\n```bash\nclojure -M:test\n```\n\nRun the WebSocket chat demo with:\n\n```bash\nclojure -M:chat\n```\n\nThen open `http://localhost:8080/`. The demo uses Undertow through the\n`:chat` alias only; Undertow is not a core library dependency.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftailrecursion%2Fchasma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftailrecursion%2Fchasma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftailrecursion%2Fchasma/lists"}