Add local-first Python and Kotlin SDKs wrapping atomic_lib - #1277
Add local-first Python and Kotlin SDKs wrapping atomic_lib#1277joepio wants to merge 11 commits into
Conversation
945611c to
efde1d6
Compare
|
I asked @ANONYMOUSZED-beep to check out this, since they opened #1276 (python docs) |
|
Thanks for the ping. I checked out PR #1277 locally and reviewed the Python SDK branch. The PR looks reasonable from inspection, and the GitHub CI status is green on the current head commit. I tried running the Python SDK tests locally with No obvious blocker from my review. The only caveat is that my local verification was limited by host build tooling rather than a failure in the PR itself. |
efde1d6 to
d16da91
Compare
|
@ANONYMOUSZED-beep thanks for checking it out. The
If you install the C++ workload you should be able to run the suite locally the same way. Happy to hear how it feels against the scripting / query use cases you described on #1276 — this SDK is local-first (redb + Iroh), not an HTTP client in front of a server. |
Python talks to the same Rust store as the WASM and Flutter bindings: redb on disk, signed Loro commits, no HTTP server required. v1 covers setup, create/read/update/query/delete, and reopen-after-flush. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
Indexed queries need Query::drive. Persistence tests drop every Store and Resource handle before reopen so redb can release its file lock. destroy tests use Folder, which has no extra required properties. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
… surface. Do not clone python/src. Extract atomic_lib::sdk first so Kotlin, Swift, and the Android Binder host share one API. PyO3 and FRB stay for their languages. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
…n, not a ban. Iroh already works in atomic_lib and Flutter. New language bindings should not ship peer_sync as the primary API. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
Local CRUD without realtime peer sync is not the product. Same surface Flutter already wraps, plus a two-process pytest. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
start_peer is process-global; a prior in-memory start stole the node from the P2P test. wait_for must construct timeout inside block_on. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
Same product surface as the Python SDK: local redb, signed Loro commits, and process-global Iroh (startPeer / syncWith / live save). The ffi crate is excluded from the workspace. Resource.destroyResource avoids UniFFI's Disposable.destroy collision. JVM JUnit covers CRUD plus a two-process Iroh sync; Android AAR is later. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
uv run pytest is now the documented path and works from python/ (uv.lock, dependency-groups). A host without Visual Studio Build Tools still cannot link the PyO3 extension; GitHub Actions runs the same command on windows-latest, which has MSVC, and on ubuntu-latest. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
d16da91 to
3170fb4
Compare
|
Correction on the last note — that “not an HTTP client” line was too strong. HTTP is part of an Atomic SDK, not a competing product. Schema validation resolves Class and Property resources: the core ontology is bundled in the local store so Folder/PlainText and the rest work offline, but anything that isn’t already there is fetched as JSON-AD over HTTP. What this SDK was missing is treating that as a first-class surface: a server URL, search, and |
…otlin SDKs. The stores were already calling atomic_lib's HTTP GET for unknown https:// subjects (that is how Class/Property validation loads remote schema). Document and wrap that path, plus optional server= for /search and POST /commit. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
…ect. Fetched https:// resources are stored by their own subject, which can differ from the request URL, so has() is checked against resource.subject. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
|
You're right — any Atomic SDK should have HTTP, and this one already did under the hood. The core ontology is bundled so Folder / PlainText / That's now an explicit part of the API, same on Python and Kotlin:
Local redb + Iroh stay the default. HTTP is in addition, not instead. |
Related Issues
Adds a Python SDK (
python/, importatomic_data) and a Kotlin / UniFFI SDK (ffi/, packagedev.atomicdata). No issue number.Rebased onto latest
develop.Checklist
What
Local-first SDKs that wrap
atomic_lib— the same pattern as the WASM (wasm-bindgen) and Flutter (flutter_rust_bridge) bindings. Not HTTP-only clients: the default is a local redb store plus Iroh P2P, and the same HTTP pathsatomic_libalready has.get("https://…")GETs JSON-AD and caches it. That is how unknown Class / Property URLs are validated. The core ontology (Folder, PlainText,name, …) is bundled, so those work offline.server=origin: AtomicServer/searchandsave_remote()/saveRemote()(POST/commit).did:ad:remote saves need this origin;https://subjects post to their own host.A server is not required for local CRUD or Iroh sync. Writes are signed Loro commits. Two devices converge over Iroh the same way Flutter does.
Python (
python/, PyO3 + maturin)Store.open(path, server=None)/Store.in_memory(server=None)— redb on disk or in memorysetup,load_agent,create/get/search/query/delete,flushResourcewith.save()/.save_remote()/.destroy()start_peer(),announce(),sync_with(node_id),wait_for(), live push on saveatomic_data.urlsfor well-known class and property URLscd python && uv sync && uv run pytest -q. From source this compiles Rust. On Windows that needs Visual Studio Build Tools (MSVClink.exe); GNU/MinGW is not supported. GitHub ActionsPython SDKruns the same command on ubuntu-latest and windows-latest.Kotlin (
ffi/, UniFFI)Same product surface, generated for the JVM (
dev.atomicdata):Store.open(path, server)/Store.inMemory(server)setup,loadAgent,create/get/search/query/delete,flushResourcewithset/get/save/saveRemote/destroyResource/toJsonstartPeer(),announce(),syncWith(nodeId),waitFor(), live push on saveUrlsconstants matching PythondestroyResource()is not nameddestroy()because UniFFI already uses that for FFI handle teardown.start_peer/startPeeris process-global (one Iroh Router / NodeID per OS process). Two nodes = two processes.Both crates are excluded from the Cargo workspace (same reason as
flutter/rust) so workspace clippy/nextest do not compile PyO3 / UniFFI / Iroh on every Rust CI run.Python stays on PyO3. Kotlin is the UniFFI entry; Swift and the Android Binder host can generate from
ffi/later. Android AAR /cargo-ndkis not in this PR.Test
uv run pytest(HTTP schemaget(),search()without a server,save_remote()error path, two-OS-process Iroh sync)cargo testcases inffi/./gradlew test), including HTTP schemaget()and a two-OS-process Iroh sync