Rattrapante
An explicit Clojure interface to Automerge. JVM first, JDK 25+.
Documents are mutable Automerge replicas. Changes, object identities, text edits,
counter increments, forks, conflicts and peer sync remain visible in the API.
Native resources follow JVM reachability; callers do not allocate or free them.
An explicit materialize operation copies a subtree into persistent Clojure data.
Dependency (JDK 25+, Clojure 1.12+, macOS ARM64):
co.multiply/rattrapante {:mvn/version "0.1.1"}
Build and use locally
Prerequisites: JDK 25+, Clojure CLI, Babashka, Rustup, a C compiler (cc), curl
and tar. bb bindings regenerates the checked-in Java bindings using Babashka;
Node/npm are needed only for the optional JavaScript interoperability check.
rustup toolchain install 1.90.0 --profile minimal
bb native
bb java
bb test
bb build
JAVA_HOME must select JDK 25 or newer. Downstream JVMs must enable native access:
clojure -J--enable-native-access=ALL-UNNAMED -M
The :dev and :test aliases already set this flag. There are no preview flags.
For a consuming project, use {:local/root "/path/to/rattrapante"} after the
native build, or run bb install to install the library into local Maven.
The native source is Automerge JS 3.5.0 / Rust core 0.12.0, commit
4d2a8f6bfecfb7f1e4fca126e6d2122ac526f903. See native.edn.
bb native verifies the source archive checksum, uses our pinned Cargo lockfile,
builds the official C API as a shared library and checks its ABI layouts.
The build adds the checked-in native/bridge.rs module for Rust capabilities
missing from that C API. Its entry points share upstream's result ownership and
are included in the generated exact Java bindings.
Source and compiler outputs stay under target/; generated native resources
are ignored by Git. Meld is not a dependency.
The release JAR supports macOS ARM64 and Linux x86-64/ARM64 (glibc 2.34
or newer), and extracts its native binary when loaded. bb native builds this
machine's binary; bb native:linux builds both Linux binaries in Docker, in
pinned rust:1.90.0-slim-bookworm images, with Cargo's registry and target
directories kept in Docker volumes. bb build builds all three and refuses to
produce a JAR missing any of them, so releases are built on an Apple silicon Mac
with Docker. The build recipe also recognizes Windows x86-64/ARM64, untested.
Coding-agent skill
The repository includes a Rattrapante skill
for agents writing, reviewing or testing code that uses the library. It covers
transaction scope, document-owned handles, collaborative text, persistence,
acknowledged deltas and peer sync.
For Codex, copy plugins/rattrapante/skills/rattrapante into your consuming
project's .agents/skills/ directory; see the skill documentation.
The same SKILL.md can be used by other agents that support Agent Skills.
For Claude Code, the repository also provides a
plugin marketplace:
/plugin marketplace add multiplyco/rattrapante
/plugin install rattrapante@rattrapante
Documents and changes
(require '[co.multiply.rattrapante :as r])
(def doc (r/create))
(r/with-change [tx doc {:message "Create a note"}]
(let [note (r/put-object! tx r/root "note" :map)
body (r/put-object! tx note "body" :text)]
(r/put! tx note "title" "First note")
(r/put! tx note "views" (r/counter 0))
(r/splice-text! tx body 0 0 "Hello 😀")))
(def note (r/get doc r/root "note"))
(def body (r/get doc note "body"))
(r/with-change [tx doc]
(r/increment! tx note "views" 1)
(r/splice-text! tx body 5 0 ", world"))
(r/text doc body) ;=> "Hello, world 😀"
(r/materialize doc)
;=> {"note" {"title" "First note"
; "views" #co.multiply.rattrapante.Counter{:value 1}
; "body" "Hello, world 😀"}}
change! takes a document, optional options, and a callback. with-change is its
macro form. A successful callback commits one change and returns the callback's
result. An escaping exception rolls back its pending operations. A no-op callback
does not force an empty history entry. Options are :message and :time (epoch
seconds; timestamps stored as values instead use epoch milliseconds via Instant).
The change handle works only synchronously on the invoking thread. Escaped change
handles are rejected. Object handles obtained during a failed change are also
invalidated, so a rolled-back object ID cannot accidentally address a later object.
An exception caught inside the callback does not roll back earlier successful
operations: the callback can continue and commit them.