algoisto
CRDTs, sync, and a deterministic chaos simulator — the local-first stack in pure Python.
Current version: 2.0.0
algoisto provides the building blocks for applications that work offline and converge after replicas reconnect:
Register: last-writer-wins registerCounter: positive/negative PN-CounterORSet: observed-remove setText: tombstone-based RGA textReplica: one actor's local document stateHub: in-process state synchronizationChaos: seeded drop, reorder, and duplicate simulation
All modules are implemented in pure Python with no runtime dependencies.
Installation
pip install algoisto
For development:
pip install -e ".[dev]"
pytest
Two replicas, offline edits, convergence
from algoisto import Hub, Replica
hub = Hub()
alice = hub.register(Replica("alice"))
bob = hub.register(Replica("bob"))
alice.text.insert(0, "hello ")
alice.commit()
bob.text.insert(0, "world")
bob.commit()
hub.flush()
hub.sync_all()
print(alice.text) # converges to the same text
print(bob.text)
Hostile network simulation
from algoisto import Chaos, Hub, Replica
chaos = Chaos(
seed=42,
drop_rate=0.3,
reorder_rate=0.5,
duplicate_rate=0.2,
)
hub = Hub(chaos)
alice = hub.register(Replica("alice"))
bob = hub.register(Replica("bob"))
for _ in range(20):
alice.text.insert(len(alice.text), "a")
alice.commit()
bob.counter.increment()
bob.commit()
hub.flush()
for _ in range(100):
hub.sync_all()
if str(alice.text) == str(bob.text):
break
print(chaos.stats)
Direct CRDT usage
from algoisto import Counter, ORSet, Register, Text
name = Register("alice")
name.set("Ada")
visits = Counter("alice")
visits.increment(3)
visits.decrement()
tags = ORSet("alice")
tags.add("offline")
tags.remove("offline")
document = Text("alice")
document.insert(0, "hello")
document.insert(5, " world")
document.append("!")
document.replace("world", "local-first")
Stable text anchors
TextAnchor stores a cursor position relative to an RGA element rather than a
raw numeric offset. Resolve it after edits or merges to find its current
position. Tombstones keep deleted anchor elements available for resolution;
the anchor's element must have been received by the replica resolving it.
from algoisto import Text, TextAnchor
document = Text("alice")
document.append("hello world")
cursor = document.anchor_at(6)
document.insert(0, "Say ")
print(document.resolve_anchor(cursor)) # 10: still just before "world"
# Store and restore anchors alongside application state.
saved_cursor = cursor.to_dict()
restored_cursor = TextAnchor.from_dict(saved_cursor)
assert document.resolve_anchor(restored_cursor) == 10
anchor_at(index) accepts positions from 0 through len(text), inclusive.
resolve_anchor(anchor) returns the corresponding current character boundary.
Text.replace(old, new, count=-1) replaces non-overlapping matches and returns
the number replaced. Empty search strings and counts below -1 raise
ValueError; count=0 performs no replacements.
Text.append(text) inserts at the current end. Text.insert(index, text) and
Text.delete(index, length=1) provide indexed editing.
CLI
algoisto demo --seed 7 --rounds 20
algoisto version
The demo runs a seeded edit workload through a hostile in-process network and reports whether replicas converge.
Examples
Ten runnable scripts are available in examples/:
| Script | Demonstrates |
|---|---|
01_crdt_primitives.py |
Register, counter, and set basics |
02_text_editing.py |
Append, replace, and text edits |
03_offline_replicas.py |
Editing on disconnected replicas and syncing |
04_concurrent_registers.py |
Deterministic register conflict resolution |
05_observed_remove_set.py |
Concurrent additions with observed-remove semantics |
06_counter_merge.py |
Merging independent counter updates |
07_collaborative_text.py |
Merging concurrent text edits |
08_snapshot_roundtrip.py |
Saving and restoring a replica snapshot as JSON |
09_seeded_network_chaos.py |
Reproducible lossy, reordered network delivery |
10_stable_cursor.py |
Persisting and resolving a cursor anchor through edits |
Run any example from the repository root:
python examples/03_offline_replicas.py
API overview
| Type | Purpose |
|---|---|
Register |
Merge by Lamport timestamp; actor id breaks ties |
Counter |
Merge per-actor positive and negative totals |
ORSet |
Add unique tags and remove only observed tags |
Text |
RGA text with insert, append, delete, replace, and cursor anchors |
TextAnchor |
Serializable, element-relative cursor position for collaborative text |
Replica |
Hold and snapshot all CRDT document state |
Hub |
Queue, deliver, and merge state snapshots |
Chaos |
Add reproducible network faults from a seed |
Why algoisto
The package name combines "algo" and "isto". It is a small, dependency-free toolkit for the algorithms behind local-first software: state convergence, synchronization, and deterministic distributed-system testing.
Metadata
Release files for algoisto 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| algoisto-2.0.0.tar.gz | 12.2 kB | With provenance | Details for algoisto-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| algoisto-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for algoisto-2.0.0-py3-none-any.whl |
Total release size: 23.2 kB
Release files / algoisto-2.0.0.tar.gz
| Download URL | algoisto-2.0.0.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e05458bad84366b88670f8844a184cb5a7b2f8ab649ed40915d8177ea8ee0d48
|
|
BLAKE2b-256 checksum How to use checksums |
aa084ae537b07e2ea6133751113472d14ba9949f34cea97a2885327594cfd79b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logRelease files / algoisto-2.0.0-py3-none-any.whl
| Download URL | algoisto-2.0.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fad4615163dd55cc348810205d2e4b7fc8a81d78ebf33fc6dc52ac31adf871bf
|
|
BLAKE2b-256 checksum How to use checksums |
df27cc956806514262130f88e51df619348cd930da6542421dfa8c0be075373d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logSecurity for algoisto 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for algoisto-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.