zerobus-sdk / rust
CLAUDE.md94 starsChanged 10 days agoApache-2.0View on GitHub
The core SDK; every Rust-backed SDK binds it: Root CLAUDE.md has the shared rules; this is the Rust-core delta. The JSON/protobuf engine is in sdk/src/stream/grpc/; Arrow Flight is in sdk/src/stream/arrow/ (feature arrow-flight). From rust/: make build / build-release, build-ffi (rebuilds zerobus.h), build-jni, lint, fmt, check. Not obvious: A public-surface change reaches: pub items → Rust consumers; FFI signatures/structs → Go/C++/.NET; JNI methods → Java; PyO3 (python/rust/src/lib.rs) and NAPI (typescript/src/lib.rs) wrap the SDK directly, so refactors can break them via changed…
In this repository6 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- cpp/CLAUDE.mdCLAUDE.md
- go/CLAUDE.mdCLAUDE.md
- java/CLAUDE.mdCLAUDE.md
- python/CLAUDE.mdCLAUDE.md
- typescript/CLAUDE.mdCLAUDE.md
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 56
Ingest in a loop, then
flush()once: Never wait_for_offset() per record (a round-trip each). - Very specific: line 60
User-facing change: update rust/NEXT_CHANGELOG.md, rust/README.md, rust/examples/, and /// docs (they render on docs.rs).
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust SDK — Contributor Guide (core)
The core SDK; every Rust-backed SDK binds it:
- Go, C++, .NET — via the C FFI (
rust/ffi/). - Java — via JNI (
rust/jni/). - Python, TypeScript — via PyO3 / NAPI-RS.
Root CLAUDE.md has the shared rules; this is the Rust-core delta. The JSON/protobuf engine is in sdk/src/stream/grpc/; Arrow Flight is in sdk/src/stream/arrow/ (feature arrow-flight).
Build and test
From rust/: make build / build-release, build-ffi (rebuilds zerobus.h), build-jni, lint, fmt, check. Not obvious:
make testis a feature matrix. Workspace minus SDK+JNI, then SDK--all-features, then SDK--no-default-features, thenzerobus-jni --all-features. Plaincargo test --workspaceskipsavroand no-default-features.examples/avroisn't in CI (workspace-excluded). Check it withcd examples/avro && cargo test.- A
tests/src/file runs only if listed as[[test]]intests/Cargo.toml; otherwise it builds only when a registered targetmods it.
FFI and JNI rules
- Regenerate the header after FFI changes.
ffi/build.rswriteszerobus.h. After editingrust/ffi/src, runcargo build -p zerobus-ffiand commit it. A non-additive change breaks Go/C++/.NET — treat it as public-API. - Don't let rustfmt reorder
ffi/src/lib.rs. The comments betweenmodlines block alphabetizing; that order is the header's declaration order. - Keep the JNI ABI version in sync. Bump
NATIVE_ABI_VERSION(jni/src/sdk.rs) andEXPECTED_NATIVE_ABI(NativeLoader.java) together on any native-signature change; a mismatch is rejected at load. - Leave
panic = "unwind"(root[profile.release]).panic = "abort"turns the FFIcatch_unwindguards into process aborts, and Cargo ignores member-crate profiles. - No ambient runtime — the FFI and JNI crates each run their own tokio runtime.
Public API and breaking changes
A public-surface change reaches: pub items → Rust consumers; FFI signatures/structs → Go/C++/.NET; JNI methods → Java; PyO3 (python/rust/src/lib.rs) and NAPI (typescript/src/lib.rs) wrap the SDK directly, so refactors can break them via changed paths/types.
- New trait methods need a default — users implement
HeadersProvider,AckCallback,TlsConfigexternally. - Additive-safe: new
pubitems, new#[non_exhaustive]enum variants / struct fields, feature-gated modules. Don't deriveCopyon a public event. - Deprecate before removing:
#[deprecated(since, note)], keep ≥1 minor, remove next major.
(Root owns the general semver rule.)
Feature flags
Off by default unless noted; these constraints aren't visible in Cargo.toml:
arrow-flight— Arrow Flight ingestion.avro— Avro (Beta). Ephemeral streams only; raises MSRV (apache-avro).eos— persistent streams (in dev). JSON + compiled protobuf only; no Arrow, Avro, dynamic protobuf, or multiplexing.zeroparser— zero-copy protobuf parser; opt-in (sdk/src/zeroparser/).internal-arrow-c-data— wrapper-only C Data importer; unstable, don't depend on it.webpki-version-floor— on by default. Arustls-webpki/webpki-rootsfloor distrusting compromised CAs (crates not imported). Bindings must keep it on; adefault-features = falsebuild must restore the distrust itself.test-hooks— test-only; not in shipped artifacts (but a whole-workspacecargo buildenables it via the tests crate).testing— test utils; the FFI crate enables it, so testing-gated items reach native artifacts.
MSRV: declared 1.70 is stale/unenforced — the default graph needs ~1.83, and arrow-flight/avro need 1.88. Not CI-gated; check before changing.
Errors, lifecycle, performance
- Classify every new error —
is_retryable()(errors.rs) flows through the FFI (CResult.is_retryable) to all wrappers. - Drop doesn't flush —
Dropaborts tasks and discards unacked data.close()/flush()first; check any wrapper/FFI path that drops a live stream. - Ingest in a loop, then
flush()once. Neverwait_for_offset()per record (a round-trip each). The watermark is monotonic, so waiting on the last offset confirms the run; or use anack_callback. (Root has the cross-SDK rule.)
Changelog, docs, release
- User-facing change: update
rust/NEXT_CHANGELOG.md,rust/README.md,rust/examples/, and///docs (they render on docs.rs). (Root owns the general rules.) - Releases: version in
rust/sdk/Cargo.toml. Go and C++ rebuild the FFI from source (noffi/v*wait; that release is for external C/FFI consumers); Java consumes the JNI build (release-jni). Coordinate when a core change touches FFI signatures or wrapper behavior.
Arrow Flight
See sdk/src/stream/arrow/README.md for recovery/ACK invariants — notably: don't reorder the biased select arms without a deterministic race test, and use test-hooks barriers / paused time (not sleeps) for timing tests.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

