chitralverma opened a new pull request, #9353:
URL: https://github.com/apache/opendal/pull/9353

   # Which issue does this PR close?
   
   Closes #9352.
   
   # Rationale for this change
   
   `opendal_capability` is a caller-allocated struct, so its field order and 
size are part of the C ABI. #9315 froze the order of its 98 fields in 
`dev/src/generate/c.rs`, which keeps C positional initializers working after a 
rebuild. Every new core capability still needs a manual append to that list, 
though, and an appended field can still grow the struct that 
`opendal_operator_info_get_capability` writes into caller storage.
   
   The next release already breaks this API: the getter moved to an output 
pointer (#8513), and the struct grew from 104 to 152 bytes on Linux x86-64. 
Moving to one function per capability in the same release gives C and Zig 
callers one migration instead of two. Afterwards, a new capability only adds a 
symbol. #9352 has the full proposal.
   
   This is a draft for the maintainers' decision on #9352.
   
   # What changes are included in this PR?
   
   - `dev/src/generate/c.rs` and its templates render, in core order and with 
no frozen list:
     - `bindings/c/src/capability.rs`: one 
`opendal_operator_info_capability_<name>()` function per core capability. Flags 
return `bool`; limits return `uintptr_t`, 0 when the operator defines no limit.
     - `bindings/go/capability.go`: the `Capability` struct with every existing 
method, `newCapability`, and one FFI binding per function.
     - `bindings/go/capability_fixture_test.go`: a test fixture that answers 
every capability function from a `Capability` value.
   
     `FROZEN_CAPABILITY_ORDER` and `frozen_order` are removed.
   - `bindings/c`: `opendal_capability`, its `From` conversion, and 
`opendal_operator_info_get_capability` are removed. The C tests and the test 
framework read capabilities through the functions.
   - `bindings/go`: `Info()` reads capabilities through `newCapability`. The 
C/Go layout probe and its CI step are removed, because no struct crosses the 
ABI any more. Go resolves every capability function when it loads 
`libopendal_c`, so the Go smoke and behavior tests fail if the C library lacks 
one.
   - `bindings/zig`: `OperatorInfo.capability()` returns `opendal.Capability`, 
a struct built at compile time with one field per capability function in the 
header.
   - `dev/src/generate/c/options.rs`: C option docs name the capability 
functions, for example 
`opendal_operator_info_capability_list_with_start_after()`, and its test checks 
that each named function is declared in `opendal.h`.
   - Upgrade notes in `bindings/c/upgrade.md`, `bindings/go/upgrade.md`, and 
the Zig section of `core/core/src/docs/upgrade.md`.
   
   Tests:
   
   - `bindings/c/tests/capability.cpp`: `static_assert`s that each of the 57 
capabilities released in C binding 0.47.8 (OpenDAL v0.59.5), copied from that 
release's header, has a function with the expected signature.
   - `bindings/go/capability_test.go`: the 59 `Capability` methods released in 
v0.59.5 keep their signatures, and each capability, set alone, reaches only its 
own field and method.
   - `dev`: every core capability renders exactly one C function and one Go 
binding, field, and method, and the rendered `capability.rs` is already 
rustfmt-stable, because `ci_bindings_go.yml` regenerates it without running 
rustfmt.
   - `bindings/c/tests/opinfo.cpp` and the Zig test read memory's capabilities 
through the new API, including a limit that reads as 0.
   
   # Are there any user-facing changes?
   
   Yes, for C and Zig. Go code does not change.
   
   - C: replace `opendal_capability` and `opendal_operator_info_get_capability` 
with the per-capability functions. Each of the 57 fields released in v0.59.5 
has a function with the same name; `delete_` becomes 
`opendal_operator_info_capability_delete`. The 41 capabilities added since then 
have functions too.
   - Zig: `OperatorInfo.capability()` keeps field access such as `cap.read`; 
`cap.delete_` becomes `cap.delete`.
   - Go: `Capability` methods are unchanged. The binding and its 
`opendal-go-services` companions must still be upgraded together.
   
   # Breaking changes
   
   Affected packages: bindings/c, bindings/zig
   
   Migration:
   - C: replace `opendal_capability cap; 
opendal_operator_info_get_capability(info, &cap);` and each `cap.<name>` read 
with `opendal_operator_info_capability_<name>(info)`. `cap.delete_` becomes 
`opendal_operator_info_capability_delete(info)`. Limits return `uintptr_t`, 0 
when undefined. Rebuild against the matching `opendal.h` and `libopendal_c`. 
See `bindings/c/upgrade.md`.
   - Zig: `OperatorInfo.capability()` returns `opendal.Capability`; read 
`cap.delete` in place of `cap.delete_`.
   - Go: no source change. Upgrade the Go binding together with every 
`opendal-go-services` companion; an older companion library fails `Operator` 
creation with an error that names the missing capability function.
   
   # AI Usage Statement
   
   - Harness: Claude Code (in T3 Code)
   - Model: Claude Opus 5.5 (`claude-opus-5-5`)
   - Effort: xhigh
   - Role: Proposed the change after #9315, then implemented the generator, 
binding, test, CI, and documentation changes and drafted this description and 
#9352. The author reviews the change. Each new test was shown to fail under a 
scratch mutation: a C function reading the wrong core field; a Go value read 
through a neighbour's function; a Go method returning another field; a released 
Go method renamed or retyped; limits returning `uint64_t`; and C functions 
renamed while the option docs keep the old names. The rustfmt-stability check 
failed on the first template layout until the generator matched rustfmt.
   - Assumption: the C++ gtest suite's `static_assert`s stand in for C callers, 
because both compile against the same `opendal.h`.
   - Not run locally: the Go behavior tests against `opendal-go-services` 
companions, and the Windows CI jobs.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to