Repository navigation
feat(volume): expose Volume options through the C ABI, ADBC, NAPI and PyO3 - #521
Conversation
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 4 Low · 1 Nit
Mostly solid, with 1 medium and 3 low concerns. The bindings follow the core Volume API consistently, and cancel and close paths are wired and tested in NAPI and the C ABI.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit — The new tests were inserted between existing doc comments and the items they describe (also
base()in napi/src/database.rs), so the comments now describe the wrong function. Move each new test above the orphaned doc comment. (Found by Claude Opus 5.5 · confirmed by the judge)
a427fd3 to
427de46
Compare
fc2bd4e to
e004300
Compare
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium · 2 Low · 1 Nit
Mostly solid: 1 medium and 3 low issues. The FFI enum layout matches the C header (repr(C), 0/1/2), and the ADBC SocketTimeout path rejects zero. The main gap is Python KernelError attributes that are missing on errors that aren't local file errors.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit — The new tests were inserted between existing doc comments and the items they document (
base()in napi/src/database.rs, and the request-timeout test in src/c_abi/session.rs), so the comments now attach to the wrong item. Move each new test above the doc comment. (Found by Claude Opus 5.5 · confirmed by the judge) - 🔵 Low — The cancellation test fires the canceller before completion starts, so it only exercises the already-cancelled branch rather than interruption of a running C-ABI transfer. Add a delayed storage response, wait until the request arrives, then cancel from another thread and assert bounded completion with Cancelled and unchanged destination contents. (Found by GPT-6.1 Sol · the judge couldn't confirm it)
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/c_abi/result.rs:670—outis left unwritten on the invalid-JSON, invalidated-handle and transfer-failure paths, so a C caller that reads it after an error sees uninitialized memory
Judge's evidence:std::ptr::write(out, outcome);
e004300 to
f33d06d
Compare
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Nit
Looks good, with 1 low concern. Volume completion, cancellation and the timeout mappings are consistent across the C ABI, ADBC, NAPI and PyO3, and the zero-means-no-limit setting matches the kernel's idle_limit filter. The C ABI, NAPI and ADBC each have a cancel-during-transfer test.
Other findings
- ⚪ Nit — The docstring says cancelling or closing the parent
ExecutedAsyncStatementstops a running transfer, butpyo3/tests/test_volume.pyhas no cancel-during-transfer test. The C ABI, NAPI and ADBC bindings each have one. Add a slow-storage test that cancels from another thread and asserts a CancelledKernelError. (Found by Claude Opus 5.5 · confirmed by the judge)
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 2 low concerns. The bindings carry the Volume options and the error details through consistently, and zero (C ABI) and None (NAPI) both mean no idle limit, because src/volume.rs:166 treats a zero limit as no limit.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
pyo3/src/statement.rs:91—set_volume_options(None, input_bytes=b"...")dropsinput_byteswithout any error, so a caller who supplies upload bytes but forgets the paths gets no hint.
Judge's evidence:/// ''allowed_paths=None'' clears them, so a Volume statement returns its
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 2 Low · 1 Nit
Looks good: 2 low concerns. The bindings wire StatementSpec::volume consistently, and Duration::ZERO meaning no limit matches volume.rs:166.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit — On the bound-row path, a rejected row drops
executedwithout the explicitclose()the unbound paths run.ExecutedStatement::dropspawns a fire-and-forget close, so nothing leaks, but the two paths are inconsistent. Closeexecutedbefore returning the error. (Found by Claude Opus 5.5 · confirmed by the judge)
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 3 Low
Mostly solid. I found one medium concern about the changed NAPI close() semantics and one low one about cleanup in the ADBC bound-row error path. The C ABI, PyO3 and ADBC wiring line up with the kernel's zero/None idle-limit semantics.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/c_abi/result.rs:639— Both new is_volume_operation accessors leave a writable*outunchanged on invalid or invalidated handles, unlike the existing sentinel-initializing C ABI acce
Judge's evidence:return store_invalid_arg("kernel_result_stream_is_volume_operation: null pointer");
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium
Looks good, with 1 medium concern. The bindings forward the Volume options and local error details consistently, and the C ABI, PyO3 and ADBC changes come with tests. The NAPI change where close() cancels a running call has no test. Nit: an extra blank line was added in include/databricks_kernel.h after kernel_session_config_set_request_timeout.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/c_abi/result.rs:635— Both new Volume flag getters leave a writable out parameter unchanged on failure, so an invalidated handle can leave a previously true flag visible instead of a
Judge's evidence:return store_invalid_arg("kernel_result_stream_is_volume_operation: null pointer");
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low · 1 Nit
Looks good, with 2 low concerns. Each binding passes the Volume options into StatementSpec::volume and cancels or closes the transfer correctly. New tests cover the options reaching the transfer and the local error details in every binding.
Other findings
- ⚪ Nit — The test only sets the option to
[]. The newget_optionbranch and clearing with JSONnull(which the README documents) have no test. Add a round-trip test: set an array, read the same JSON back, setnull, then expectNotFound. (Found by Claude Opus 5.5 · confirmed by the judge)
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium
Looks good, with one low concern. The Volume options reach the transfer in all four bindings, and new tests cover each one along with the cancel paths. The async volume flag does not check owner_released the way the other accessors on that type do.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- 🟡 Medium — If cancellation fails while
awaitResult()is polling a running query,close()discards that failure and waits for the same mutex until the query finishes or times out, hiding the reason it cannot interrupt the call. Propagate the cancellation error before waiting (or provide an independent local interruption path), and test a failed cancel RPC against a continuously running statement. (Found by GPT-6.1 Sol · the judge couldn't confirm it)
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/statement/executed_async.rs:585—is_volume_operationreadspending_resultwithout checkingowner_released. Its siblings do check it (the accessor near line 571 andtake_pending_resulta
Judge's evidence:self.owner_released.store(true, Ordering::Release); self.clear_pending_result();
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
✅ No issues identified.
🔀 3 findings considered and dismissed by the judge
- 🔵 Low
src/c_abi/statement.rs:885— An invalidated executed handle returns an error without initializing*out, leaving a previously true Volume marker intact, unlike the status accessor's sentin
Judge's evidence:if !handle.exec.is_valid() { - 🔵 Low
src/statement/executed_async.rs:584—is_volume_operationreadspending_resultwithout checkingowner_released. If the parent re-executes or closes through the shared flag, the handle still re
Judge's evidence:self.owner_released.store(true, Ordering::Release); self.clear_pending_result(); - 🔵 Low
napi/src/async_statement.rs:401—let _ = in_flight.cancel().awaitdrops the cancel error, andclose()then waits oninner.lock(). If the cancel RPC fails,close()waits for the whole tr
Judge's evidence:let _ = in_flight.cancel().await;
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good, with 2 low concerns. The Volume options wiring across the C ABI, ADBC, NAPI and PyO3 is consistent and well tested. The two remaining issues are a missing owner-invalidation check and one cleanup path that skips the explicit close.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.
🔀 2 findings considered and dismissed by the judge
- 🔵 Low
adbc/src/statement.rs:920— In the bound-row loop, whenrequire_staging_optionfails insideand_then, theExecutedStatementis dropped without the explicitclose()that the unbound
Judge's evidence:// The kernel closes dropped executed handles asynchronously. Waiting - 🟡 Medium
src/c_abi/statement.rs:469— C ABI tests only call this setter with a null handle and inject local errors directly, leaving option forwarding and worker-to-caller error propagation untested
Judge's evidence:stmt.spec().volume(options);
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 3 Low · 1 Nit
Looks good, with 4 low concerns. The bindings forward the Volume options consistently and have focused tests. What remains is cleanup consistency on the ADBC bound-row error path, a cancel error that NAPI close() discards, catch_ffi coverage on the new C getters, and missing tests for the ADBC option's read-back, null-clear and invalid-JSON handling.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit — The ADBC test does not cover the get_option round-trip, clearing with JSON null, or the InvalidArguments status for malformed JSON, although the README documents all three. Add assertions for them. (Found by Claude Opus 5.5 · confirmed by the judge)
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/c_abi/error.rs:175— The three newkernel_get_last_error_*extern "C" getters skipcatch_ffi. A panic inLAST_ERROR.with(for example, a TLS access during thread teardown) wou
Judge's evidence:LAST_ERROR.with(|cell| cell.borrow().local_os_error)
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low · 1 Nit
Looks good, with 1 low concern. The C ABI, ADBC, NAPI and PyO3 changes all set StatementSpec::volume, and each binding has tests at the right tier. The FFI accessors are wrapped in catch_ffi and guard against null arguments.
This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit —
close()falls into the cancel branch whenevertry_lockfails, including when only a briefstatus()call or anotherclose()holdsinner, so it sends a needless server cancel and ignores any cancel error. The effect is minor because close ends the statement anyway. Fix: skip the cancel whenclosedis already set, and log the cancel error. (Found by Claude Opus 5.5 · confirmed by the judge)
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Nit
Looks good, no blocking issues. I checked the C ABI null guards and last-error lifetime, the async Volume marker's lifecycle, the ADBC execute_update guard and its bound-row cleanup, and NAPI close() cancelling a call that is still running. Each binding has matching tests.
Other findings
- ⚪ Nit — pyo3/Cargo.toml adds
tokio-utilonly to reachtokio_util::bytes::Bytes. Depending onbytes = "1"directly would state that dependency more clearly. (Found by Claude Opus 5.5 · the judge disputed it but couldn't back that up, so it's kept)
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Medium · 1 Low · 1 Nit
Looks good: 2 low concerns. The Volume options, markers and local error details reach each binding consistently and have targeted wiremock tests. NAPI's close() now cancels before closing, which matches what the docs describe.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.
Other findings
- ⚪ Nit — The new is_volume_operation accessors leave
outuntouched on error paths, unlike sibling accessors such as status, which write a default first. Write false to a non-nulloutbefore validating the handle. (Found by GPT-6.1 Sol · confirmed by the judge) - 🟡 Medium — Awaiting the detached canceller waits for the server cancel RPC even after local cancellation releases the transfer's lock, so a slow or retrying cancel endpoint can still stall close despite the transfer having stopped. Dispatch cancellation independently or race it against acquiring inner, allowing close to proceed once the in-flight operation releases its lock. (Found by GPT-6.1 Sol · the judge couldn't confirm it)
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
src/c_abi/error.rs:176— The three newkernel_get_last_error_*getters areextern "C"functions that do not usecatch_ffi, unlike the other new entry points. A panic in them, for
Judge's evidence:LAST_ERROR.with(|cell| cell.borrow().local_os_error)
… PyO3 Each binding sets StatementSpec::volume before executing, so a Volume PUT, GET or REMOVE runs its file transfer inside the execution, and the binding's existing cancel and close paths stop it. - C ABI: kernel_statement_set_volume_options, the is_volume_operation flags on executed statements and result streams, and the last-error code, OS error and local path accessors. - PyO3: Statement.set_volume_options with optional upload bytes taken without copying, is_volume_operation, and local error attributes on KernelError. - NAPI: ExecuteOptions.volume, isVolumeOperation and local error fields; socketTimeoutMs 0 keeps the kernel default, and AsyncStatement.close() cancels a call that still holds the statement. - ADBC: the staging_allowed_local_paths statement option; execute_update on a Volume statement without it fails with InvalidState. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
The test parks awaitResult() on a stalled Volume GET and checks that close() cancels it and returns. Also drops a blank line left in the C header. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
kernel_executed_async_statement_is_volume_operation reports whether the last status poll succeeded for a statement the server marks as a Volume PUT, GET or REMOVE. Reading its result stream runs the file transfer, so a host that polls an async statement can run only that read off its polling thread and return any other result on the same poll. The get_result_stream doc now says it runs the transfer. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
is_volume_operation now checks owner_released, as take_pending_result does, so it cannot report a status response the released owner no longer serves. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
… trip A C ABI test sets the Volume options on a live statement, checks that a GET writes the file, and checks that a missing PUT source reports its error code, OS error and path to the calling thread. The ADBC test now reads the option back, clears it with JSON null and rejects other JSON, as the README says. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
…rker kernel_executed_async_statement_is_volume_operation now checks the handle's validity, as kernel_executed_statement_is_volume_operation does, so after the parent statement is re-executed or closed it reports InvalidStatementHandle instead of a cached marker. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
close() awaited the server cancel request before taking the statement, so a slow or retrying cancel endpoint held it after the transfer had already stopped locally. The cancel now runs as its own task. The C ABI is_volume_operation accessors also write false to out before reporting an error, as get_result_stream writes null. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
Verdict: 1 Low
Looks good — 2 low concerns. The bindings forward the Volume options consistently, and tests cover the main transfer, error-detail and cancel paths.
This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge — see the findings below.
🔀 1 finding considered and dismissed by the judge
- 🔵 Low
napi/src/async_statement.rs:391—close()now cancels the server statement whenevertry_lockfails, so any call holdinginnertriggers it, including a shortstatus()poll. It also uses t
Judge's evidence:// A call still running holds 'inner' until it returns, such as an
…eams The live GET now reads kernel_executed_statement_is_volume_operation and kernel_result_stream_is_volume_operation on the stream borrowed from the executed handle, and the async test reads it on the stream the async read owns, so both stream shapes are covered. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
There was a problem hiding this comment.
🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).
✅ No issues identified.
🔀 3 findings considered and dismissed by the judge
- 🔵 Low
napi/src/async_statement.rs:402—close()starts the cancel with ambienttokio::spawn, whileDropin the same file usesruntime::try_get_handle(). The cancel also fires whenever any call
Judge's evidence:tokio::spawn(async move { let _ = in_flight.cancel().await; }); - 🔵 Low
src/statement/executed_async.rs:588—pending_result.lock().is_ok_and(...)turns a poisoned mutex intoOk(false), so the C ABI reports a non-Volume statement and the host may run the transfer-be
Judge's evidence:let mut pending = self.pending_result.lock().ok()?; - 🔵 Low
adbc/src/statement.rs:920— In the bound-row path, whenrequire_staging_optionfails, the successfully executed statement is dropped without an explicitexecuted.close(), so cleanup re
Judge's evidence:// The kernel closes dropped executed handles asynchronously. Waiting drop(executed);
Description
Exposes the Volume file transfers from #520 in each binding. A binding sets the kernel's
StatementSpec::volume, so executing a VolumePUT,GETorREMOVEmoves the file, and the binding's existing cancel and close paths stop it.kernel_statement_set_volume_options(stmt, allowed_paths_json, remove_not_found_is_success)kernel_executed_statement_is_volume_operation,kernel_executed_async_statement_is_volume_operation,kernel_result_stream_is_volume_operation, andkernel_get_last_error_code/_local_os_error/_local_pathStatement.set_volume_options(allowed_paths, remove_not_found_is_success=False, input_bytes=None)is_volume_operation;local_os_errorandlocal_pathonKernelErrorExecuteOptions.volume:{ allowedPaths, removeNotFoundIsSuccess? }isVolumeOperation;localOsError,localErrorKindandlocalPathon errorsadbc.databricks.statement.staging_allowed_local_pathsexecute_updateon a Volume statement without the option fails withInvalidStatekernel_executed_async_statement_is_volume_operationreports the marker from the successful status poll, so a host that polls, such as ODBC in async mode, can run only that read off its polling thread.PUT '__input_stream__'fails.socketTimeoutMs: 0now keeps the kernel default instead of setting a zero request timeout.AsyncStatement.close()now cancels a call that still holds the statement, such as anawaitResult()running a transfer, instead of waiting for it.Builds on #520, now in main. Supersedes #513.
Testing
Run locally on main with #511: fmt, clippy with
-D warningsand the tests pass: root 1,424, NAPI 96, ADBC 103, and PyO3 32 Rust and 34 Python tests (live tests skipped).make c-abi-testpasses, and every commit builds all four crates.primary_keys_rejects_invalid_current_namespace_and_closes_lookupfails about 1 run in 10 on main as well, and this PR does not touch it.New tests check that each binding's options reach the transfer and that local error details reach the caller. They also cover:
InvalidStateand cancel paths, and the option's read-back, JSONnullclear and invalid-JSON error;socketTimeoutMs: 0;close()cancelling anawaitResult()that is still running a transfer.Additional notes
napi/index.d.tsadds only the new declarations, taken from@napi-rs/cli@3.8.2output. Regenerating the whole file with that CLI changes its layout.This pull request and its description were written by Isaac.