Metadata-Version: 2.4
Name: nexus-crdt
Version: 0.1.0
Summary: Nexus — leaderless CRDT state synchronization (LWW-Register, OR-Set, RGA text) with a TLV op log and Merkle history
Author: Nexus CRDT
License: MIT
Keywords: crdt,sync,collaborative,lww,or-set,rga,lamport
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: hypothesis>=6; extra == "test"
Dynamic: license-file

# nexus-crdt (Python)

Nexus — leaderless CRDT state synchronization for Python ≥ 3.10. Pure
standard library: `__slots__` everywhere, full typing (TypedDict, Protocol),
`pickle`-able state, and `asyncio` helpers for I/O-bound sync.

```bash
pip install nexus-crdt
```

```python
from nexus import NexusMap

m = NexusMap("server-1")
m.set("title", "Hello")
m.or_set("tags").add("crdt")
m.text("doc").insert(0, "hello")

m.merge(remote_frame)          # bytes — converges; simultaneous writes never raise
m.encode()                     # canonical TLV frame (byte-compatible with JS/PHP)
m.merkle_root()                # SHA-256 Merkle digest of the op history
```

## asyncio

```python
from nexus import NexusMap, async_merge, serve_state, fetch_state

await async_merge(m, ws.recv())                # merge without blocking the loop
server, port = await serve_state(m)            # tiny length-prefixed TCP relay
frame = await fetch_state("127.0.0.1", port, m.encode())
```

## pickling

`pickle.dumps(m)` captures the whole state (canonical frame + actor) and is
safe across processes/versions of the app.

Tests: `pip install -e ".[test]" pytest-asyncio && pytest` (pytest +
hypothesis fuzzing + shared cross-language vectors).
