You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #4103 — removal of the prior azure_data_cosmos_native (which wrapped azure_data_cosmos)
Tracking issue
TBD
1. Background
The Cosmos DB Rust workspace previously contained sdk/cosmos/azure_data_cosmos_native, a C-ABI
wrapper crate that exposed the high-levelazure_data_cosmos SDK surface (typed
clients: CosmosClient, Database, Container) over a C API generated with cbindgen,
built as cdylib/staticlib, packaged with pkg-config (azurecosmos.pc.in), and
exercised by a CMake-driven C test harness (c_tests/*.c).
That crate was deleted in PR #4103 ("Cosmos: remove azure_data_cosmos_native", issue #4090 — perpetual
rebuild churn). Per the PR description, the deletion is intentionally temporary: it
will be restored later when doing work on the native wrapper for the driver. This
spec defines that restoration.
The new wrapper differs from the deleted one in three fundamental ways:
It wraps the driver, not the SDK. The driver (azure_data_cosmos_driver) is
the schema-agnostic core implementation, deliberately designed for cross-language
reuse (per AGENTS.md §"Multi-Crate Strategy"). Wrapping the
driver — not azure_data_cosmos — removes the serde::Serialize / Deserialize
item-type bound from the FFI surface and matches the documented architectural intent.
Data plane is byte-oriented. Per the AGENTS.md "Schema-Agnostic Data Plane"
section, request bodies are &[u8] and response bodies are Vec<u8>. The C API
accepts and returns opaque buffers; serialization is the consuming language SDK's
responsibility.
Single-dispatch operation surface. The driver exposes CosmosDriver::execute_operation as the canonical
data-plane entry point (one Rust function dispatching all operation kinds). The C
API mirrors that shape, which collapses what was previously dozens of typed C
functions into a small, stable surface.
2. Motivation
Cross-language SDK reuse is the raison d'être of the driver crate (see README.md and lib.rs crate doc-comment). Without
a C ABI surface, that goal is aspirational rather than realized.
Validation of the driver's public API. Building a real, non-Rust consumer
surfaces ergonomic issues (lifetimes leaking through, missing constructors,
re-export gaps) that pure-Rust use does not.
Foundation for Java / .NET / Python SDKs. The native wrapper is the only
supported integration path for SDKs in other languages; today there is none.
Recovers the test harness lost in Cosmos: remove azure_data_cosmos_native #4103. The C test programs
(version.c, error_handling.c, item_crud.c, context_memory_management.c)
exercised end-to-end FFI scenarios (lifetime, error propagation, payload round-trip)
that have no equivalent in the current Rust-only tests.
3. Goals
G1. Ship a cdylib and staticlib exposing a stable C ABI for the driver's
data-plane and control-plane surface, with a cbindgen-generated header.
G2. Provide a C/CMake build harness (CMakeLists.txt, pkg-config, DiscoverTests.cmake) so the wrapper is consumable from non-Rust toolchains.
G3. Provide an opaque-handle, _free-everything C API consistent with idiomatic FFI
conventions (no Rust types leaked, no panics across the boundary).
G4. Provide a tokio-based runtime hosting layer so callers can submit async work
without depending on a Rust runtime in their own process.
G5. Reach functional parity (data-plane CRUD, query/feed iteration, transactional
batch, diagnostics readback, fault injection toggles) with the driver's Rust API.
G6. Deliver a CMake-driven C test harness mirroring the four programs from Cosmos: remove azure_data_cosmos_native #4103
(version, error handling, item CRUD, context/memory management), plus new tests
for query/feed iteration and diagnostics.
G7. Wire the new crate back into the workspace, dictionaries, dependency-verification
exemption list, and design-struct/pre-commit skill scopes — i.e., undo the
surgical removals made by Cosmos: remove azure_data_cosmos_native #4103.
NG1. Wrapping azure_data_cosmos. The high-level typed Rust SDK is not the
wrap target. Item-type generic surfaces stay Rust-only.
NG2. Streaming I/O across the FFI. Cosmos enforces a 4 MB / 16 MB request /
response payload cap; buffered byte slices are sufficient (mirrors AGENTS.md §
"Streaming").
NG3. A Java / .NET / Python language binding. That work consumes this wrapper;
it is not part of this spec.
NG4. A non-tokio runtime. A runtime/ module exists for future pluggability,
but only the tokio backend ships in v1.
NG5. Source-compatibility with the deleted azure_data_cosmos_native C header.
The new header has a different shape (driver-oriented, byte-buffer data plane);
it is not a drop-in replacement for the deleted azurecosmos.h.
5. Stakeholders
Cosmos Rust SDK team — owns the crate, header, and CI.
Cross-language SDK teams (Java/.NET/Python) — primary consumers, will exercise
this surface against real workloads.
Driver crate maintainers — must accept additional public-API stability
obligations once the wrapper ships (re-exports / signature changes become
ABI-affecting).
Tokio Runtime::new_multi_thread() hosting (runtime/tokio.rs)
CMake harness + pkg-config + DiscoverTests.cmake
Patterns to discard / redesign:
Typed cosmos_client.rs / database_client.rs / container_client.rs surfaces
(replace with a single dispatch over CosmosDriver::execute_operation).
Any item-shape coupling (none should leak; data plane is const uint8_t* + size_t).
The "native" part of the crate name (use azure_data_cosmos_driver_native to make
the wrap target unambiguous and to avoid collision with the historical name).
All entry points are #[no_mangle] pub unsafe extern "C" and named with the
prefix azure_cosmos_driver_<noun>_<verb> (e.g. azure_cosmos_driver_create, azure_cosmos_driver_response_free).
Every entry point returns an int32_t status code (AZ_COSMOS_DRIVER_OK = 0,
negative for errors). Out-parameters via *mut *mut T for handles, *mut size_t
for byte counts.
Every entry point is wrapped in std::panic::catch_unwind; any panic returns AZ_COSMOS_DRIVER_E_PANIC and stores the panic message in the last-error TLS.
All handles are opaque (typedef struct AzureCosmosDriver AzureCosmosDriver;),
constructed by _create, destroyed by _free. Double-free is UB but _free(NULL)
is a no-op.
Strings into the wrapper are NUL-terminated UTF-8 const char*. Strings out are
borrowed from a handle (caller copies) or owned strings returned with a paired _string_free function — never both, and the contract is documented per call.
Byte buffers are (const uint8_t* data, size_t len) going in and (const uint8_t* data, size_t len) borrowed from a CosmosResponse handle going
out (freed with the response handle).
Threading: handles are Send + Sync unless explicitly documented otherwise. The
runtime, driver, and response handles are safe to share across threads.
wraps a Stream<Item = CosmosResponse> (poll on the runtime)
8. Public API stability obligations on the driver
Wrapping the driver creates a chain: any breaking change to driver public types that
appear in this wrapper's translation layer becomes ABI-affecting. To keep the
wrapper resilient:
Translate driver enums (status codes, operation kinds, consistency levels) into wrapper-ownedrepr(C) enums in src/abi.rs. Never re-#[repr(C)] a driver
type directly.
Keep options ingestion JSON-shaped (options_json: &[u8]) rather than struct-
shaped at the FFI; the wrapper deserializes into DriverOptions internally. This
insulates the C header from driver field additions.
Pin the driver dependency as path = "..." in v1; in v2 consider version = "x.y"
with a strict compatibility band.
9. Build & packaging
cdylib and staticlib outputs.
build.rs runs cbindgen and writes to include/azure_data_cosmos_driver.h.
Header is checked in (so reviewers and downstream consumers see ABI diffs in
PRs).
azurecosmosdriver.pc.in produces a pkg-config file at install time
(-lazure_data_cosmos_driver_native -ldl -lpthread -lm).
CMakeLists.txt provides:
cargo build --release invocation,
add_library(... IMPORTED) for the resulting artifact,
add_executable per C test, linked against the imported library,
include(cmake/DiscoverTests.cmake) to register tests with ctest.
10. Runtime model
A single AzureCosmosDriverRuntime opaque handle owns a tokio multi-thread runtime
(default: worker_threads = num_cpus, configurable later via JSON options).
All async driver calls are dispatched onto that runtime via Handle::block_on from
a non-runtime thread (the FFI caller's thread). No callback-based async in v1; the
C entry points are blocking from the caller's perspective. (Async-callback variants
may follow in v2; tracked separately.)
One runtime can be shared by multiple drivers; lifetime is enforced by ref-count
inside the wrapper (Arc<TokioRuntime>).
11. Error handling
Wrapper-owned repr(C) error code enum, populated by translating azure_core::Error categories.
Last-error TLS holding (status, message); each entry point clears it on entry and
populates it on failure.
Panics across the FFI boundary are caught and converted to AZ_COSMOS_DRIVER_E_PANIC; panic = "abort" is not set so catch_unwind can do its job.
Cosmos sub-status code, activity id, and RU charge are surfaced on the AzureCosmosDriverResponse for both success and error responses (mirrors AGENTS.md
"Cosmos-specific errors should provide" list).
CI lane: Linux + macOS + Windows × cosmos emulator container (where available).
13. Avoiding the rebuild churn that motivated #4090
Issue #4090 reported that azure_data_cosmos_native rebuilt on every cargo test invocation. Mitigations:
build.rs uses cargo:rerun-if-changed= for the exact set of header-affecting
source files only (not a directory wildcard).
cbindgen output is written to a target-relative path (OUT_DIR) for compilation,
but copied to the checked-in include/ only when content changes (write-if-diff).
The crate is not added to the default workspace test plan; CI invokes it
explicitly. Default cargo test from the workspace root excludes it via default-members configuration in the workspace Cargo.toml.
CMake step is opt-in (separate CI job), not invoked by cargo test.
diagnostics.c passes; fault injection configurable from C.
P6 — CI & release
Cross-OS CI matrix; pkg-config; checked-in header; CHANGELOG; README.
Crate publishes from CI; downstream language SDK can consume from artifact.
16. Acceptance criteria
A1. sdk/cosmos/azure_data_cosmos_driver_native/ exists with the layout in §7.1 and
builds cleanly on Linux, macOS, and Windows.
A2. cargo build -p azure_data_cosmos_driver_native --release produces both cdylib
and staticlib artifacts.
A3. cargo fmt -p azure_data_cosmos_driver_native -- --check and cargo clippy -p azure_data_cosmos_driver_native --all-features --all-targets
are clean.
A4. cbindgen regeneration is idempotent; running cargo build does not modify include/azure_data_cosmos_driver.h unless source changed (guards #4090).
A5. All seven C tests in §12.2 pass under ctest against the Cosmos emulator
(where available) on the CI matrix.
A6. The wrapper does not depend on azure_data_cosmos; only on azure_data_cosmos_driver, azure_core, tokio, tracing, and cbindgen
(build-only). Verified by cargo tree snapshot in CI.
A7. The wrapper exposes no Rust types in its public C header and no unsafe extern
function panics across the boundary (validated by error_handling.c's panic
sub-test).
A8. Every *_create / *_new entry point has a corresponding *_free; double-free
is documented as UB but _free(NULL) is verified to be a no-op.
A9. The §14 workspace re-integration changes are merged in the same PR as the new
crate.
A10. README and CHANGELOG cover: build instructions, runtime/lifetime model, error
handling contract, supported phases (per §15), and an honest support-model
statement (community/GitHub support — same as the driver crate).
A11. CHANGELOG follows cosmos.changelog.instructions.md.
A12. Default workspace cargo test does not build or run this crate (per §13);
dedicated CI lane does.
17. Open questions
Q1. Header naming: azure_data_cosmos_driver.h (verbose, matches crate) or azurecosmosdriver.h (compact, matches the deleted convention)? Recommend the
former for clarity; revisit if downstream consumers object.
Q2. Should execute_operation accept the driver's OperationKind enum as an int32_t (compact, but version-coupled) or as a string discriminator
("create_item", etc.) (string-stable across driver bumps)? Recommend integer
with a wrapper-owned repr(C) enum + an integer-stability test.
Q3. How should token-credential refresh be expressed across the FFI? The
callback in §7.4 is one option; an alternative is a "push" model where the host
language pre-fetches and sets a token. Recommend the callback pattern for v1.
Q4. Should v1 ship async callback entry points in addition to the blocking
ones? Recommend deferring to v2 to keep the v1 surface small.
Q5. What is the public-API stability commitment for the C header in v1?
Pre-1.0 (free to break) or stable from day one? Recommend pre-1.0; bump to 1.0
only after at least one downstream consumer has shipped.
18. Risks
R1. ABI churn from driver evolution. Mitigated by the wrapper-owned enum
pattern (§8) and JSON options ingestion.
R2. Rebuild churn returns. Mitigated by §13 build-script hygiene; gated by
acceptance criterion A4.
R3. Tokio runtime conflicts with host language runtime. Documented in
README; the runtime handle is explicit so callers can manage one process-wide.
R4. Panics leaking across the FFI. Mitigated by catch_unwind wrapper macro
in abi.rs; gated by acceptance criterion A7.
R5. Header drift between checked-in copy and source. Mitigated by CI step
that runs cargo build and fails if git diff include/ is non-empty.
19. References
PR #4103 — removal of the
prior azure_data_cosmos_native.
Issue #4090 — rebuild
churn that motivated the removal.
AGENTS.md — Multi-Crate Strategy & Schema-Agnostic Data Plane
sections.
azure_data_cosmos_driver_native— Native (C ABI) Wrapper Specsdk/cosmos/azure_data_cosmos_driver_nativeazure_data_cosmos_driverazure_data_cosmos_native(which wrappedazure_data_cosmos)1. Background
The Cosmos DB Rust workspace previously contained
sdk/cosmos/azure_data_cosmos_native, a C-ABIwrapper crate that exposed the high-level
azure_data_cosmosSDK surface (typedclients:
CosmosClient,Database,Container) over a C API generated withcbindgen,built as
cdylib/staticlib, packaged withpkg-config(azurecosmos.pc.in), andexercised by a CMake-driven C test harness (
c_tests/*.c).That crate was deleted in PR #4103 ("Cosmos: remove
azure_data_cosmos_native",issue #4090 — perpetual
rebuild churn). Per the PR description, the deletion is intentionally temporary: it
will be restored later when doing work on the native wrapper for the driver. This
spec defines that restoration.
The new wrapper differs from the deleted one in three fundamental ways:
azure_data_cosmos_driver) isthe schema-agnostic core implementation, deliberately designed for cross-language
reuse (per AGENTS.md §"Multi-Crate Strategy"). Wrapping the
driver — not
azure_data_cosmos— removes theserde::Serialize/Deserializeitem-type bound from the FFI surface and matches the documented architectural intent.
section, request bodies are
&[u8]and response bodies areVec<u8>. The C APIaccepts and returns opaque buffers; serialization is the consuming language SDK's
responsibility.
CosmosDriver::execute_operationas the canonicaldata-plane entry point (one Rust function dispatching all operation kinds). The C
API mirrors that shape, which collapses what was previously dozens of typed C
functions into a small, stable surface.
2. Motivation
README.md and
lib.rscrate doc-comment). Withouta C ABI surface, that goal is aspirational rather than realized.
surfaces ergonomic issues (lifetimes leaking through, missing constructors,
re-export gaps) that pure-Rust use does not.
supported integration path for SDKs in other languages; today there is none.
azure_data_cosmos_native#4103. The C test programs(
version.c,error_handling.c,item_crud.c,context_memory_management.c)exercised end-to-end FFI scenarios (lifetime, error propagation, payload round-trip)
that have no equivalent in the current Rust-only tests.
3. Goals
cdylibandstaticlibexposing a stable C ABI for the driver'sdata-plane and control-plane surface, with a
cbindgen-generated header.CMakeLists.txt,pkg-config,DiscoverTests.cmake) so the wrapper is consumable from non-Rust toolchains._free-everything C API consistent with idiomatic FFIconventions (no Rust types leaked, no panics across the boundary).
without depending on a Rust runtime in their own process.
batch, diagnostics readback, fault injection toggles) with the driver's Rust API.
azure_data_cosmos_native#4103(version, error handling, item CRUD, context/memory management), plus new tests
for query/feed iteration and diagnostics.
exemption list, and design-struct/pre-commit skill scopes — i.e., undo the
surgical removals made by Cosmos: remove
azure_data_cosmos_native#4103.hygiene; see §13).
4. Non-goals
azure_data_cosmos. The high-level typed Rust SDK is not thewrap target. Item-type generic surfaces stay Rust-only.
response payload cap; buffered byte slices are sufficient (mirrors AGENTS.md §
"Streaming").
it is not part of this spec.
runtime/module exists for future pluggability,but only the tokio backend ships in v1.
azure_data_cosmos_nativeC header.The new header has a different shape (driver-oriented, byte-buffer data plane);
it is not a drop-in replacement for the deleted
azurecosmos.h.5. Stakeholders
this surface against real workloads.
obligations once the wrapper ships (re-exports / signature changes become
ABI-affecting).
6. Reference: prior implementation (PR #4103, deleted)
The deleted
azure_data_cosmos_nativehad this layout (kept here so the new crate cancopy what was sound and discard what was schema-coupled):
Reusable patterns (carry forward verbatim or with light edits):
[lib] crate-type = ["cdylib", "staticlib"]cbindgenbuild-script header generationpanic = "abort"policy at the FFI boundary, plusstd::panic::catch_unwindwrapping everyextern "C"entry point*_get_last_error_messageaccessor pattern (error.rs)CStr/CStringhelpers (string.rs)Runtime::new_multi_thread()hosting (runtime/tokio.rs)pkg-config+DiscoverTests.cmakePatterns to discard / redesign:
cosmos_client.rs/database_client.rs/container_client.rssurfaces(replace with a single dispatch over
CosmosDriver::execute_operation).const uint8_t*+size_t)."native"part of the crate name (useazure_data_cosmos_driver_nativeto makethe wrap target unambiguous and to avoid collision with the historical name).
7. Proposed crate
7.1 Layout
7.2
Cargo.tomlshape7.3 ABI conventions (codified in
src/abi.rs)#[no_mangle] pub unsafe extern "C"and named with theprefix
azure_cosmos_driver_<noun>_<verb>(e.g.azure_cosmos_driver_create,azure_cosmos_driver_response_free).int32_tstatus code (AZ_COSMOS_DRIVER_OK = 0,negative for errors). Out-parameters via
*mut *mut Tfor handles,*mut size_tfor byte counts.
std::panic::catch_unwind; any panic returnsAZ_COSMOS_DRIVER_E_PANICand stores the panic message in the last-error TLS.typedef struct AzureCosmosDriver AzureCosmosDriver;),constructed by
_create, destroyed by_free. Double-free is UB but_free(NULL)is a no-op.
const char*. Strings out areborrowed from a handle (caller copies) or owned strings returned with a paired
_string_freefunction — never both, and the contract is documented per call.(const uint8_t* data, size_t len)going in and(const uint8_t* data, size_t len)borrowed from aCosmosResponsehandle goingout (freed with the response handle).
Send + Syncunless explicitly documented otherwise. Theruntime, driver, and response handles are safe to share across threads.
7.4 Surface (header sketch)
7.5 Mapping to driver Rust API
azure_cosmos_driver_runtime_createtokio::runtime::Runtimeinruntime::tokio; wrap inCosmosDriverRuntimeazure_cosmos_driver_createCosmosDriverBuilder::new(endpoint, credential, options).build()(then.initialize())azure_cosmos_driver_executeCosmosDriver::execute_operation(req)(cosmos_driver.rs:1143)azure_cosmos_driver_response_bodyCosmosResponse::bodyazure_cosmos_driver_response_diagnostics_jsonserde_json::to_string(&resp.diagnostics)(driverDiagnosticsContext)azure_cosmos_driver_feed_*Stream<Item = CosmosResponse>(poll on the runtime)8. Public API stability obligations on the driver
Wrapping the driver creates a chain: any breaking change to driver public types that
appear in this wrapper's translation layer becomes ABI-affecting. To keep the
wrapper resilient:
wrapper-owned
repr(C)enums insrc/abi.rs. Never re-#[repr(C)]a drivertype directly.
options_json: &[u8]) rather than struct-shaped at the FFI; the wrapper deserializes into
DriverOptionsinternally. Thisinsulates the C header from driver field additions.
path = "..."in v1; in v2 considerversion = "x.y"with a strict compatibility band.
9. Build & packaging
cdylibandstaticliboutputs.build.rsrunscbindgenand writes toinclude/azure_data_cosmos_driver.h.Header is checked in (so reviewers and downstream consumers see ABI diffs in
PRs).
azurecosmosdriver.pc.inproduces a pkg-config file at install time(
-lazure_data_cosmos_driver_native -ldl -lpthread -lm).CMakeLists.txtprovides:cargo build --releaseinvocation,add_library(... IMPORTED)for the resulting artifact,add_executableper C test, linked against the imported library,include(cmake/DiscoverTests.cmake)to register tests withctest.10. Runtime model
AzureCosmosDriverRuntimeopaque handle owns a tokio multi-thread runtime(default:
worker_threads = num_cpus, configurable later via JSON options).Handle::block_onfroma non-runtime thread (the FFI caller's thread). No callback-based async in v1; the
C entry points are blocking from the caller's perspective. (Async-callback variants
may follow in v2; tracked separately.)
inside the wrapper (
Arc<TokioRuntime>).11. Error handling
repr(C)error code enum, populated by translatingazure_core::Errorcategories.(status, message); each entry point clears it on entry andpopulates it on failure.
AZ_COSMOS_DRIVER_E_PANIC;panic = "abort"is not set socatch_unwindcan do its job.AzureCosmosDriverResponsefor both success and error responses (mirrors AGENTS.md"Cosmos-specific errors should provide" list).
12. Testing
12.1 Rust unit tests (in-crate)
tests/abi_smoke.rs— handle round-trip, panic-guard behaviour, last-error TLS.tests/options_translation.rs— JSON options →DriverOptionsparity.12.2 C integration tests (CMake /
ctest)version.cazure_cosmos_driver_versionmatchesCARGO_PKG_VERSION.error_handling.ccontext_memory_management.citem_crud.cexecute_operation, body byte-equality.query_feed.cbatch.cdiagnostics.cDiagnosticsContextJSON shape, RU & activity-id presence.12.3 Live tests
RUSTFLAGS='--cfg test_category="emulator"'(mirrors driverconvention).
13. Avoiding the rebuild churn that motivated #4090
Issue #4090 reported that
azure_data_cosmos_nativerebuilt on everycargo testinvocation. Mitigations:build.rsusescargo:rerun-if-changed=for the exact set of header-affectingsource files only (not a directory wildcard).
cbindgenoutput is written to a target-relative path (OUT_DIR) for compilation,but copied to the checked-in
include/only when content changes (write-if-diff).explicitly. Default
cargo testfrom the workspace root excludes it viadefault-membersconfiguration in the workspaceCargo.toml.cargo test.14. Workspace re-integration (undoing PR #4103 surgically)
Files to re-edit (each previously had the native crate removed):
Cargo.toml(workspace)"sdk/cosmos/azure_data_cosmos_driver_native"tomembers.eng/dict/crates.txtazure_data_cosmos_driver_native.eng/dict/rust-custom.txtcbindgen.eng/scripts/verify-dependencies.rs("azure_data_cosmos_driver_native", "cbindgen")exemption.sdk/cosmos/.cspell.jsoncmake,cstring,ctest,libazurecosmosdriver,makefiles,msvc,winget,**/*.hoverrides.sdk/cosmos/AGENTS.mdazure_data_cosmos_driver_nativeconsumer bullet under "Multi-Crate Strategy"; add a tokio-runtime note for the new crate.sdk/cosmos/azure_data_cosmos_driver/README.mdazure_data_cosmos_driver_native)" phrasing.sdk/cosmos/azure_data_cosmos_driver/src/lib.rssdk/cosmos/.github/skills/cosmos-design-struct/SKILL.mdazure_data_cosmos_driver_nativeto scope.sdk/cosmos/.github/skills/cosmos-pre-commit-validation/SKILL.mdazure_data_cosmos_driver_nativeto scope.15. Phased delivery
version.ctest passes on Linux/macOS/Windows.context_memory_management.canderror_handling.cpass.execute_operation+ response readback.item_crud.c(point CRUD round-trip) passes against emulator.query_feed.candbatch.cpass; continuation tokens round-trip.DiagnosticsContextJSON readback; fault injection feature flag.diagnostics.cpasses; fault injection configurable from C.16. Acceptance criteria
A1.
sdk/cosmos/azure_data_cosmos_driver_native/exists with the layout in §7.1 andbuilds cleanly on Linux, macOS, and Windows.
A2.
cargo build -p azure_data_cosmos_driver_native --releaseproduces bothcdyliband
staticlibartifacts.A3.
cargo fmt -p azure_data_cosmos_driver_native -- --checkandcargo clippy -p azure_data_cosmos_driver_native --all-features --all-targetsare clean.
A4.
cbindgenregeneration is idempotent; runningcargo builddoes not modifyinclude/azure_data_cosmos_driver.hunless source changed (guards #4090).A5. All seven C tests in §12.2 pass under
ctestagainst the Cosmos emulator(where available) on the CI matrix.
A6. The wrapper does not depend on
azure_data_cosmos; only onazure_data_cosmos_driver,azure_core,tokio,tracing, andcbindgen(build-only). Verified by
cargo treesnapshot in CI.A7. The wrapper exposes no Rust types in its public C header and no
unsafe externfunction panics across the boundary (validated by
error_handling.c's panicsub-test).
A8. Every
*_create/*_newentry point has a corresponding*_free; double-freeis documented as UB but
_free(NULL)is verified to be a no-op.A9. The §14 workspace re-integration changes are merged in the same PR as the new
crate.
A10. README and CHANGELOG cover: build instructions, runtime/lifetime model, error
handling contract, supported phases (per §15), and an honest support-model
statement (community/GitHub support — same as the driver crate).
A11. CHANGELOG follows cosmos.changelog.instructions.md.
A12. Default workspace
cargo testdoes not build or run this crate (per §13);dedicated CI lane does.
17. Open questions
azure_data_cosmos_driver.h(verbose, matches crate) orazurecosmosdriver.h(compact, matches the deleted convention)? Recommend theformer for clarity; revisit if downstream consumers object.
execute_operationaccept the driver'sOperationKindenum as anint32_t(compact, but version-coupled) or as a string discriminator(
"create_item", etc.) (string-stable across driver bumps)? Recommend integerwith a wrapper-owned
repr(C)enum + an integer-stability test.callback in §7.4 is one option; an alternative is a "push" model where the host
language pre-fetches and sets a token. Recommend the callback pattern for v1.
ones? Recommend deferring to v2 to keep the v1 surface small.
Pre-1.0 (free to break) or stable from day one? Recommend pre-1.0; bump to 1.0
only after at least one downstream consumer has shipped.
18. Risks
pattern (§8) and JSON options ingestion.
acceptance criterion A4.
README; the runtime handle is explicit so callers can manage one process-wide.
catch_unwindwrapper macroin
abi.rs; gated by acceptance criterion A7.that runs
cargo buildand fails ifgit diff include/is non-empty.19. References
prior
azure_data_cosmos_native.churn that motivated the removal.
sections.
azure_data_cosmos_driver/src/lib.rs— current driver public surface.azure_data_cosmos_driver/src/driver/cosmos_driver.rs—
execute_operationentry point.GATEWAY_20_SPEC.md — sibling driver design specs (format reference).