agentleFS
DatabricksKnown publisherdatabricks/zerobus-sdk/rust/CLAUDE.md

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…

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
  1. Very specific:

    Ingest in a loop, then flush() once: Never wait_for_offset() per record (a round-trip each).

    line 56
  2. Very specific:

    User-facing change: update rust/NEXT_CHANGELOG.md, rust/README.md, rust/examples/, and /// docs (they render on docs.rs).

    line 60

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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 test is a feature matrix. Workspace minus SDK+JNI, then SDK --all-features, then SDK --no-default-features, then zerobus-jni --all-features. Plain cargo test --workspace skips avro and no-default-features.
  • examples/avro isn't in CI (workspace-excluded). Check it with cd examples/avro && cargo test.
  • A tests/src/ file runs only if listed as [[test]] in tests/Cargo.toml; otherwise it builds only when a registered target mods it.

FFI and JNI rules

  • Regenerate the header after FFI changes. ffi/build.rs writes zerobus.h. After editing rust/ffi/src, run cargo build -p zerobus-ffi and 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 between mod lines 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) and EXPECTED_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 FFI catch_unwind guards 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, TlsConfig externally.
  • Additive-safe: new pub items, new #[non_exhaustive] enum variants / struct fields, feature-gated modules. Don't derive Copy on 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. A rustls-webpki/webpki-roots floor distrusting compromised CAs (crates not imported). Bindings must keep it on; a default-features = false build must restore the distrust itself.
  • test-hooks — test-only; not in shipped artifacts (but a whole-workspace cargo build enables 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 — Drop aborts 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. Never wait_for_offset() per record (a round-trip each). The watermark is monotonic, so waiting on the last offset confirms the run; or use an ack_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 (no ffi/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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.