This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new c414b3abd7 fix(bindings/c,go): keep opendal_capability field order 
append-only (#9315)
c414b3abd7 is described below

commit c414b3abd7f39f5d729c72df260815ff901791d0
Author: Chitral Verma <[email protected]>
AuthorDate: Sat Nov 28 21:28:56 2026 +0530

    fix(bindings/c,go): keep opendal_capability field order append-only (#9315)
    
    * fix(bindings/c,go): keep opendal_capability field order append-only
    
    Render the C opendal_capability struct and the Go opendalCapability
    mirror in a frozen field order instead of core order. The 57 fields
    released in C binding 0.47.8 (OpenDAL v0.59.5) come first in their
    released order, followed by the 41 fields added since, in core order.
    Generation fails when a core field is not in the frozen list or a
    listed field is missing from core, so a new core field must be
    appended explicitly.
    
    Positional initializers written against the released header keep their
    meaning when rebuilt, and the released fields keep their v0.59.5
    offsets. The binary ABI still differs from v0.59.5: the struct grew and
    opendal_operator_info_get_capability writes through an output pointer.
    
    Add a dev test that compares the rendered C and Go field declarations
    with literals copied from v0.59.5, dev tests for both generation
    errors, and C gtests that initialize opendal_capability by position.
    Update the C and Go upgrade guides.
    
    Closes #9264.
    
    Signed-off-by: Chitral Verma <[email protected]>
    
    * docs(bindings/c,go): note that appended capability fields can grow the 
struct
    
    opendal_operator_info_get_capability writes the whole struct into
    caller-provided storage, so a field appended in a later release can make
    a caller built with an older header allocate too little space. Say so in
    the C and Go upgrade notes, and keep the header, library, Go binding, and
    opendal-go-services companions on the same version.
    
    Signed-off-by: Chitral Verma <[email protected]>
    
    ---------
    
    Signed-off-by: Chitral Verma <[email protected]>
---
 bindings/c/CMakeLists.txt       |   1 +
 bindings/c/include/opendal.h    | 276 +++++++++++++--------------
 bindings/c/src/capability.rs    | 212 ++++++++++-----------
 bindings/c/tests/capability.cpp | 190 +++++++++++++++++++
 bindings/c/upgrade.md           |  42 ++++-
 bindings/go/capability.go       | 406 ++++++++++++++++++++--------------------
 bindings/go/upgrade.md          |  16 +-
 dev/src/generate/c.rs           | 364 ++++++++++++++++++++++++++++++++++-
 8 files changed, 1043 insertions(+), 464 deletions(-)

diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt
index 4966bd1a48..5502f5dafb 100644
--- a/bindings/c/CMakeLists.txt
+++ b/bindings/c/CMakeLists.txt
@@ -93,6 +93,7 @@ target_link_libraries(getting_started opendal_c_shared)
 set(GTEST_SRCS
     tests/bdd.cpp
     tests/cancel.cpp
+    tests/capability.cpp
     tests/error_msg.cpp
     tests/list.cpp
     tests/logging.cpp
diff --git a/bindings/c/include/opendal.h b/bindings/c/include/opendal.h
index 899be77ff1..f71d39b87b 100644
--- a/bindings/c/include/opendal.h
+++ b/bindings/c/include/opendal.h
@@ -860,14 +860,6 @@ typedef struct opendal_capability {
    * Indicates if conditional stat operations using If-None-Match are 
supported.
    */
   bool stat_with_if_none_match;
-  /**
-   * Indicates if conditional stat operations using version match are 
supported.
-   */
-  bool stat_with_if_version_match;
-  /**
-   * Indicates if conditional stat operations using version non-match are 
supported.
-   */
-  bool stat_with_if_version_not_match;
   /**
    * Indicates if conditional stat operations using If-Modified-Since are 
supported.
    */
@@ -904,22 +896,6 @@ typedef struct opendal_capability {
    * Indicates if conditional read operations using If-None-Match are 
supported.
    */
   bool read_with_if_none_match;
-  /**
-   * Indicates if conditional read operations using version match are 
supported.
-   */
-  bool read_with_if_version_match;
-  /**
-   * Indicates if conditional read operations using version non-match are 
supported.
-   */
-  bool read_with_if_version_not_match;
-  /**
-   * Indicates if conditional read operations using If-Modified-Since are 
supported.
-   */
-  bool read_with_if_modified_since;
-  /**
-   * Indicates if conditional read operations using If-Unmodified-Since are 
supported.
-   */
-  bool read_with_if_unmodified_since;
   /**
    * Indicates if Cache-Control header override is supported during read 
operations.
    */
@@ -933,17 +909,17 @@ typedef struct opendal_capability {
    */
   bool read_with_override_content_type;
   /**
-   * Indicates if versions read operations are supported.
+   * Indicates if conditional read operations using If-Modified-Since are 
supported.
    */
-  bool read_with_version;
+  bool read_with_if_modified_since;
   /**
-   * Indicates if suffix read operations are supported.
+   * Indicates if conditional read operations using If-Unmodified-Since are 
supported.
    */
-  bool read_with_suffix;
+  bool read_with_if_unmodified_since;
   /**
-   * Indicates if the operator supports requesting stored full-file checksum 
metadata. Stat and read responses may include that metadata when requested.
+   * Indicates if versions read operations are supported.
    */
-  bool read_with_checksum;
+  bool read_with_version;
   /**
    * Indicates if the operator supports write operations.
    */
@@ -960,10 +936,6 @@ typedef struct opendal_capability {
    * Indicates if append operations are supported.
    */
   bool write_can_append;
-  /**
-   * Indicates if an open, non-append writer can copy eligible byte ranges 
from existing objects without transferring the copied bytes through the client. 
Whole-object copy is a separate capability.
-   */
-  bool write_can_copy_from;
   /**
    * Indicates if Content-Type can be specified during write operations.
    */
@@ -976,10 +948,6 @@ typedef struct opendal_capability {
    * Indicates if Content-Encoding can be specified during write operations.
    */
   bool write_with_content_encoding;
-  /**
-   * Indicates if a write can store Content-Language and a subsequent stat can 
retrieve it.
-   */
-  bool write_with_content_language;
   /**
    * Indicates if Cache-Control can be specified during write operations.
    */
@@ -992,14 +960,6 @@ typedef struct opendal_capability {
    * Indicates if conditional write operations using If-None-Match are 
supported.
    */
   bool write_with_if_none_match;
-  /**
-   * Indicates if conditional write operations using version match are 
supported.
-   */
-  bool write_with_if_version_match;
-  /**
-   * Indicates if conditional write operations using version non-match are 
supported.
-   */
-  bool write_with_if_version_not_match;
   /**
    * Indicates if write operations can be conditional on object non-existence.
    */
@@ -1008,14 +968,6 @@ typedef struct opendal_capability {
    * Indicates if custom user metadata can be attached during write operations.
    */
   bool write_with_user_metadata;
-  /**
-   * Indicates if writes can set a lifetime for the new file.
-   */
-  bool write_with_expires;
-  /**
-   * Indicates if non-append writes support native verification with a 
checksum algorithm selected by the service. Verification may cover only 
individual upload requests, parts, or blocks. Support for caller-selected 
algorithms and full-object verification depends on the service and write mode. 
OpenDAL rejects unsupported explicit checksum requests before performing I/O.
-   */
-  bool write_with_checksum;
   /**
    * Maximum size supported for multipart uploads. For example, AWS S3 
supports up to 5GiB per part in multipart uploads.
    *
@@ -1050,6 +1002,138 @@ typedef struct opendal_capability {
    * Indicates if recursive delete operations are supported.
    */
   bool delete_with_recursive;
+  /**
+   * Indicates if copy operations are supported.
+   */
+  bool copy;
+  /**
+   * Indicates if conditional copy operations with if-not-exists are supported.
+   */
+  bool copy_with_if_not_exists;
+  /**
+   * Indicates if conditional copy operations with if-match are supported.
+   */
+  bool copy_with_if_match;
+  /**
+   * Indicates if copy operations from a specific source version are supported.
+   */
+  bool copy_with_source_version;
+  /**
+   * Indicates if copy operations can be split into multiple server-side tasks.
+   */
+  bool copy_can_multi;
+  /**
+   * Maximum size supported for segmented copy tasks.
+   *
+   * If it is not set, this will be zero.
+   */
+  uintptr_t copy_multi_max_size;
+  /**
+   * Minimum size required for segmented copy tasks.
+   *
+   * If it is not set, this will be zero.
+   */
+  uintptr_t copy_multi_min_size;
+  /**
+   * Indicates if rename operations are supported.
+   */
+  bool rename;
+  /**
+   * Indicates if list operations are supported.
+   */
+  bool list;
+  /**
+   * Indicates if list operations support result limiting.
+   */
+  bool list_with_limit;
+  /**
+   * Indicates if list operations support continuation from a specific point.
+   */
+  bool list_with_start_after;
+  /**
+   * Indicates if recursive listing is supported.
+   */
+  bool list_with_recursive;
+  /**
+   * Indicates if listing with versions included is supported.
+   */
+  bool list_with_versions;
+  /**
+   * Indicates if listing with deleted files included is supported.
+   */
+  bool list_with_deleted;
+  /**
+   * Indicates if presigned URL generation is supported.
+   */
+  bool presign;
+  /**
+   * Indicates if presigned URLs for read operations are supported.
+   */
+  bool presign_read;
+  /**
+   * Indicates if presigned URLs for stat operations are supported.
+   */
+  bool presign_stat;
+  /**
+   * Indicates if presigned URLs for write operations are supported.
+   */
+  bool presign_write;
+  /**
+   * Indicates if presigned URLs for delete operations are supported.
+   */
+  bool presign_delete;
+  /**
+   * Indicate if the operator supports shared access.
+   */
+  bool shared;
+  /**
+   * Indicates if conditional stat operations using version match are 
supported.
+   */
+  bool stat_with_if_version_match;
+  /**
+   * Indicates if conditional stat operations using version non-match are 
supported.
+   */
+  bool stat_with_if_version_not_match;
+  /**
+   * Indicates if conditional read operations using version match are 
supported.
+   */
+  bool read_with_if_version_match;
+  /**
+   * Indicates if conditional read operations using version non-match are 
supported.
+   */
+  bool read_with_if_version_not_match;
+  /**
+   * Indicates if suffix read operations are supported.
+   */
+  bool read_with_suffix;
+  /**
+   * Indicates if the operator supports requesting stored full-file checksum 
metadata. Stat and read responses may include that metadata when requested.
+   */
+  bool read_with_checksum;
+  /**
+   * Indicates if an open, non-append writer can copy eligible byte ranges 
from existing objects without transferring the copied bytes through the client. 
Whole-object copy is a separate capability.
+   */
+  bool write_can_copy_from;
+  /**
+   * Indicates if a write can store Content-Language and a subsequent stat can 
retrieve it.
+   */
+  bool write_with_content_language;
+  /**
+   * Indicates if conditional write operations using version match are 
supported.
+   */
+  bool write_with_if_version_match;
+  /**
+   * Indicates if conditional write operations using version non-match are 
supported.
+   */
+  bool write_with_if_version_not_match;
+  /**
+   * Indicates if writes can set a lifetime for the new file.
+   */
+  bool write_with_expires;
+  /**
+   * Indicates if non-append writes support native verification with a 
checksum algorithm selected by the service. Verification may cover only 
individual upload requests, parts, or blocks. Support for caller-selected 
algorithms and full-object verification depends on the service and write mode. 
OpenDAL rejects unsupported explicit checksum requests before performing I/O.
+   */
+  bool write_with_checksum;
   /**
    * Indicates if conditional delete operations using If-Match are supported.
    */
@@ -1072,18 +1156,6 @@ typedef struct opendal_capability {
    * If it is not set, this will be zero.
    */
   uintptr_t delete_max_size;
-  /**
-   * Indicates if copy operations are supported.
-   */
-  bool copy;
-  /**
-   * Indicates if conditional copy operations with if-not-exists are supported.
-   */
-  bool copy_with_if_not_exists;
-  /**
-   * Indicates if conditional copy operations with if-match are supported.
-   */
-  bool copy_with_if_match;
   /**
    * Indicates if conditional copy operations with if-none-match are supported.
    */
@@ -1096,10 +1168,6 @@ typedef struct opendal_capability {
    * Indicates if conditional copy operations using version non-match are 
supported.
    */
   bool copy_with_if_version_not_match;
-  /**
-   * Indicates if copy operations from a specific source version are supported.
-   */
-  bool copy_with_source_version;
   /**
    * Indicates if copy operations can replace the destination's user metadata.
    */
@@ -1112,22 +1180,6 @@ typedef struct opendal_capability {
    * Indicates if copy operations can replace the destination's 
Content-Language.
    */
   bool copy_with_content_language;
-  /**
-   * Indicates if copy operations can be split into multiple server-side tasks.
-   */
-  bool copy_can_multi;
-  /**
-   * Maximum size supported for segmented copy tasks.
-   *
-   * If it is not set, this will be zero.
-   */
-  uintptr_t copy_multi_max_size;
-  /**
-   * Minimum size required for segmented copy tasks.
-   *
-   * If it is not set, this will be zero.
-   */
-  uintptr_t copy_multi_min_size;
   /**
    * Indicates if the operator supports composing complete source objects.
    */
@@ -1192,66 +1244,14 @@ typedef struct opendal_capability {
    * Indicates if conditional restore operations using if-not-exists are 
supported.
    */
   bool restore_with_if_not_exists;
-  /**
-   * Indicates if rename operations are supported.
-   */
-  bool rename;
   /**
    * Indicates if conditional rename operations with if-not-exists are 
supported.
    */
   bool rename_with_if_not_exists;
-  /**
-   * Indicates if list operations are supported.
-   */
-  bool list;
-  /**
-   * Indicates if list operations support result limiting.
-   */
-  bool list_with_limit;
-  /**
-   * Indicates if list operations support continuation from a specific point.
-   */
-  bool list_with_start_after;
-  /**
-   * Indicates if recursive listing is supported.
-   */
-  bool list_with_recursive;
-  /**
-   * Indicates if listing with versions included is supported.
-   */
-  bool list_with_versions;
-  /**
-   * Indicates if listing with deleted files included is supported.
-   */
-  bool list_with_deleted;
   /**
    * Indicates if listing with a glob pattern is supported by this service 
stack.
    */
   bool list_with_glob;
-  /**
-   * Indicates if presigned URL generation is supported.
-   */
-  bool presign;
-  /**
-   * Indicates if presigned URLs for read operations are supported.
-   */
-  bool presign_read;
-  /**
-   * Indicates if presigned URLs for stat operations are supported.
-   */
-  bool presign_stat;
-  /**
-   * Indicates if presigned URLs for write operations are supported.
-   */
-  bool presign_write;
-  /**
-   * Indicates if presigned URLs for delete operations are supported.
-   */
-  bool presign_delete;
-  /**
-   * Indicate if the operator supports shared access.
-   */
-  bool shared;
 } opendal_capability;
 
 /**
diff --git a/bindings/c/src/capability.rs b/bindings/c/src/capability.rs
index 822f1272be..a6c66139d9 100644
--- a/bindings/c/src/capability.rs
+++ b/bindings/c/src/capability.rs
@@ -35,10 +35,6 @@ pub struct opendal_capability {
     pub stat_with_if_match: bool,
     /// Indicates if conditional stat operations using If-None-Match are 
supported.
     pub stat_with_if_none_match: bool,
-    /// Indicates if conditional stat operations using version match are 
supported.
-    pub stat_with_if_version_match: bool,
-    /// Indicates if conditional stat operations using version non-match are 
supported.
-    pub stat_with_if_version_not_match: bool,
     /// Indicates if conditional stat operations using If-Modified-Since are 
supported.
     pub stat_with_if_modified_since: bool,
     /// Indicates if conditional stat operations using If-Unmodified-Since are 
supported.
@@ -57,26 +53,18 @@ pub struct opendal_capability {
     pub read_with_if_match: bool,
     /// Indicates if conditional read operations using If-None-Match are 
supported.
     pub read_with_if_none_match: bool,
-    /// Indicates if conditional read operations using version match are 
supported.
-    pub read_with_if_version_match: bool,
-    /// Indicates if conditional read operations using version non-match are 
supported.
-    pub read_with_if_version_not_match: bool,
-    /// Indicates if conditional read operations using If-Modified-Since are 
supported.
-    pub read_with_if_modified_since: bool,
-    /// Indicates if conditional read operations using If-Unmodified-Since are 
supported.
-    pub read_with_if_unmodified_since: bool,
     /// Indicates if Cache-Control header override is supported during read 
operations.
     pub read_with_override_cache_control: bool,
     /// Indicates if Content-Disposition header override is supported during 
read operations.
     pub read_with_override_content_disposition: bool,
     /// Indicates if Content-Type header override is supported during read 
operations.
     pub read_with_override_content_type: bool,
+    /// Indicates if conditional read operations using If-Modified-Since are 
supported.
+    pub read_with_if_modified_since: bool,
+    /// Indicates if conditional read operations using If-Unmodified-Since are 
supported.
+    pub read_with_if_unmodified_since: bool,
     /// Indicates if versions read operations are supported.
     pub read_with_version: bool,
-    /// Indicates if suffix read operations are supported.
-    pub read_with_suffix: bool,
-    /// Indicates if the operator supports requesting stored full-file 
checksum metadata. Stat and read responses may include that metadata when 
requested.
-    pub read_with_checksum: bool,
     /// Indicates if the operator supports write operations.
     pub write: bool,
     /// Indicates if multiple write operations can be performed on the same 
object.
@@ -85,34 +73,22 @@ pub struct opendal_capability {
     pub write_can_empty: bool,
     /// Indicates if append operations are supported.
     pub write_can_append: bool,
-    /// Indicates if an open, non-append writer can copy eligible byte ranges 
from existing objects without transferring the copied bytes through the client. 
Whole-object copy is a separate capability.
-    pub write_can_copy_from: bool,
     /// Indicates if Content-Type can be specified during write operations.
     pub write_with_content_type: bool,
     /// Indicates if Content-Disposition can be specified during write 
operations.
     pub write_with_content_disposition: bool,
     /// Indicates if Content-Encoding can be specified during write operations.
     pub write_with_content_encoding: bool,
-    /// Indicates if a write can store Content-Language and a subsequent stat 
can retrieve it.
-    pub write_with_content_language: bool,
     /// Indicates if Cache-Control can be specified during write operations.
     pub write_with_cache_control: bool,
     /// Indicates if conditional write operations using If-Match are supported.
     pub write_with_if_match: bool,
     /// Indicates if conditional write operations using If-None-Match are 
supported.
     pub write_with_if_none_match: bool,
-    /// Indicates if conditional write operations using version match are 
supported.
-    pub write_with_if_version_match: bool,
-    /// Indicates if conditional write operations using version non-match are 
supported.
-    pub write_with_if_version_not_match: bool,
     /// Indicates if write operations can be conditional on object 
non-existence.
     pub write_with_if_not_exists: bool,
     /// Indicates if custom user metadata can be attached during write 
operations.
     pub write_with_user_metadata: bool,
-    /// Indicates if writes can set a lifetime for the new file.
-    pub write_with_expires: bool,
-    /// Indicates if non-append writes support native verification with a 
checksum algorithm selected by the service. Verification may cover only 
individual upload requests, parts, or blocks. Support for caller-selected 
algorithms and full-object verification depends on the service and write mode. 
OpenDAL rejects unsupported explicit checksum requests before performing I/O.
-    pub write_with_checksum: bool,
     /// Maximum size supported for multipart uploads. For example, AWS S3 
supports up to 5GiB per part in multipart uploads.
     ///
     /// If it is not set, this will be zero.
@@ -133,6 +109,74 @@ pub struct opendal_capability {
     pub delete_with_version: bool,
     /// Indicates if recursive delete operations are supported.
     pub delete_with_recursive: bool,
+    /// Indicates if copy operations are supported.
+    pub copy: bool,
+    /// Indicates if conditional copy operations with if-not-exists are 
supported.
+    pub copy_with_if_not_exists: bool,
+    /// Indicates if conditional copy operations with if-match are supported.
+    pub copy_with_if_match: bool,
+    /// Indicates if copy operations from a specific source version are 
supported.
+    pub copy_with_source_version: bool,
+    /// Indicates if copy operations can be split into multiple server-side 
tasks.
+    pub copy_can_multi: bool,
+    /// Maximum size supported for segmented copy tasks.
+    ///
+    /// If it is not set, this will be zero.
+    pub copy_multi_max_size: usize,
+    /// Minimum size required for segmented copy tasks.
+    ///
+    /// If it is not set, this will be zero.
+    pub copy_multi_min_size: usize,
+    /// Indicates if rename operations are supported.
+    pub rename: bool,
+    /// Indicates if list operations are supported.
+    pub list: bool,
+    /// Indicates if list operations support result limiting.
+    pub list_with_limit: bool,
+    /// Indicates if list operations support continuation from a specific 
point.
+    pub list_with_start_after: bool,
+    /// Indicates if recursive listing is supported.
+    pub list_with_recursive: bool,
+    /// Indicates if listing with versions included is supported.
+    pub list_with_versions: bool,
+    /// Indicates if listing with deleted files included is supported.
+    pub list_with_deleted: bool,
+    /// Indicates if presigned URL generation is supported.
+    pub presign: bool,
+    /// Indicates if presigned URLs for read operations are supported.
+    pub presign_read: bool,
+    /// Indicates if presigned URLs for stat operations are supported.
+    pub presign_stat: bool,
+    /// Indicates if presigned URLs for write operations are supported.
+    pub presign_write: bool,
+    /// Indicates if presigned URLs for delete operations are supported.
+    pub presign_delete: bool,
+    /// Indicate if the operator supports shared access.
+    pub shared: bool,
+    /// Indicates if conditional stat operations using version match are 
supported.
+    pub stat_with_if_version_match: bool,
+    /// Indicates if conditional stat operations using version non-match are 
supported.
+    pub stat_with_if_version_not_match: bool,
+    /// Indicates if conditional read operations using version match are 
supported.
+    pub read_with_if_version_match: bool,
+    /// Indicates if conditional read operations using version non-match are 
supported.
+    pub read_with_if_version_not_match: bool,
+    /// Indicates if suffix read operations are supported.
+    pub read_with_suffix: bool,
+    /// Indicates if the operator supports requesting stored full-file 
checksum metadata. Stat and read responses may include that metadata when 
requested.
+    pub read_with_checksum: bool,
+    /// Indicates if an open, non-append writer can copy eligible byte ranges 
from existing objects without transferring the copied bytes through the client. 
Whole-object copy is a separate capability.
+    pub write_can_copy_from: bool,
+    /// Indicates if a write can store Content-Language and a subsequent stat 
can retrieve it.
+    pub write_with_content_language: bool,
+    /// Indicates if conditional write operations using version match are 
supported.
+    pub write_with_if_version_match: bool,
+    /// Indicates if conditional write operations using version non-match are 
supported.
+    pub write_with_if_version_not_match: bool,
+    /// Indicates if writes can set a lifetime for the new file.
+    pub write_with_expires: bool,
+    /// Indicates if non-append writes support native verification with a 
checksum algorithm selected by the service. Verification may cover only 
individual upload requests, parts, or blocks. Support for caller-selected 
algorithms and full-object verification depends on the service and write mode. 
OpenDAL rejects unsupported explicit checksum requests before performing I/O.
+    pub write_with_checksum: bool,
     /// Indicates if conditional delete operations using If-Match are 
supported.
     pub delete_with_if_match: bool,
     /// Indicates if conditional delete operations using If-None-Match are 
supported.
@@ -145,36 +189,18 @@ pub struct opendal_capability {
     ///
     /// If it is not set, this will be zero.
     pub delete_max_size: usize,
-    /// Indicates if copy operations are supported.
-    pub copy: bool,
-    /// Indicates if conditional copy operations with if-not-exists are 
supported.
-    pub copy_with_if_not_exists: bool,
-    /// Indicates if conditional copy operations with if-match are supported.
-    pub copy_with_if_match: bool,
     /// Indicates if conditional copy operations with if-none-match are 
supported.
     pub copy_with_if_none_match: bool,
     /// Indicates if conditional copy operations using version match are 
supported.
     pub copy_with_if_version_match: bool,
     /// Indicates if conditional copy operations using version non-match are 
supported.
     pub copy_with_if_version_not_match: bool,
-    /// Indicates if copy operations from a specific source version are 
supported.
-    pub copy_with_source_version: bool,
     /// Indicates if copy operations can replace the destination's user 
metadata.
     pub copy_with_user_metadata: bool,
     /// Indicates if copy operations can replace the destination's 
Content-Type.
     pub copy_with_content_type: bool,
     /// Indicates if copy operations can replace the destination's 
Content-Language.
     pub copy_with_content_language: bool,
-    /// Indicates if copy operations can be split into multiple server-side 
tasks.
-    pub copy_can_multi: bool,
-    /// Maximum size supported for segmented copy tasks.
-    ///
-    /// If it is not set, this will be zero.
-    pub copy_multi_max_size: usize,
-    /// Minimum size required for segmented copy tasks.
-    ///
-    /// If it is not set, this will be zero.
-    pub copy_multi_min_size: usize,
     /// Indicates if the operator supports composing complete source objects.
     pub compose: bool,
     /// Indicates if Content-Type can be specified during composition.
@@ -207,36 +233,10 @@ pub struct opendal_capability {
     pub restore_with_version: bool,
     /// Indicates if conditional restore operations using if-not-exists are 
supported.
     pub restore_with_if_not_exists: bool,
-    /// Indicates if rename operations are supported.
-    pub rename: bool,
     /// Indicates if conditional rename operations with if-not-exists are 
supported.
     pub rename_with_if_not_exists: bool,
-    /// Indicates if list operations are supported.
-    pub list: bool,
-    /// Indicates if list operations support result limiting.
-    pub list_with_limit: bool,
-    /// Indicates if list operations support continuation from a specific 
point.
-    pub list_with_start_after: bool,
-    /// Indicates if recursive listing is supported.
-    pub list_with_recursive: bool,
-    /// Indicates if listing with versions included is supported.
-    pub list_with_versions: bool,
-    /// Indicates if listing with deleted files included is supported.
-    pub list_with_deleted: bool,
     /// Indicates if listing with a glob pattern is supported by this service 
stack.
     pub list_with_glob: bool,
-    /// Indicates if presigned URL generation is supported.
-    pub presign: bool,
-    /// Indicates if presigned URLs for read operations are supported.
-    pub presign_read: bool,
-    /// Indicates if presigned URLs for stat operations are supported.
-    pub presign_stat: bool,
-    /// Indicates if presigned URLs for write operations are supported.
-    pub presign_write: bool,
-    /// Indicates if presigned URLs for delete operations are supported.
-    pub presign_delete: bool,
-    /// Indicate if the operator supports shared access.
-    pub shared: bool,
 }
 
 impl From<core::Capability> for opendal_capability {
@@ -245,8 +245,6 @@ impl From<core::Capability> for opendal_capability {
             stat: value.stat,
             stat_with_if_match: value.stat_with_if_match,
             stat_with_if_none_match: value.stat_with_if_none_match,
-            stat_with_if_version_match: value.stat_with_if_version_match,
-            stat_with_if_version_not_match: 
value.stat_with_if_version_not_match,
             stat_with_if_modified_since: value.stat_with_if_modified_since,
             stat_with_if_unmodified_since: value.stat_with_if_unmodified_since,
             stat_with_override_cache_control: 
value.stat_with_override_cache_control,
@@ -256,34 +254,24 @@ impl From<core::Capability> for opendal_capability {
             read: value.read,
             read_with_if_match: value.read_with_if_match,
             read_with_if_none_match: value.read_with_if_none_match,
-            read_with_if_version_match: value.read_with_if_version_match,
-            read_with_if_version_not_match: 
value.read_with_if_version_not_match,
-            read_with_if_modified_since: value.read_with_if_modified_since,
-            read_with_if_unmodified_since: value.read_with_if_unmodified_since,
             read_with_override_cache_control: 
value.read_with_override_cache_control,
             read_with_override_content_disposition: 
value.read_with_override_content_disposition,
             read_with_override_content_type: 
value.read_with_override_content_type,
+            read_with_if_modified_since: value.read_with_if_modified_since,
+            read_with_if_unmodified_since: value.read_with_if_unmodified_since,
             read_with_version: value.read_with_version,
-            read_with_suffix: value.read_with_suffix,
-            read_with_checksum: value.read_with_checksum,
             write: value.write,
             write_can_multi: value.write_can_multi,
             write_can_empty: value.write_can_empty,
             write_can_append: value.write_can_append,
-            write_can_copy_from: value.write_can_copy_from,
             write_with_content_type: value.write_with_content_type,
             write_with_content_disposition: 
value.write_with_content_disposition,
             write_with_content_encoding: value.write_with_content_encoding,
-            write_with_content_language: value.write_with_content_language,
             write_with_cache_control: value.write_with_cache_control,
             write_with_if_match: value.write_with_if_match,
             write_with_if_none_match: value.write_with_if_none_match,
-            write_with_if_version_match: value.write_with_if_version_match,
-            write_with_if_version_not_match: 
value.write_with_if_version_not_match,
             write_with_if_not_exists: value.write_with_if_not_exists,
             write_with_user_metadata: value.write_with_user_metadata,
-            write_with_expires: value.write_with_expires,
-            write_with_checksum: value.write_with_checksum,
             write_multi_max_size: value.write_multi_max_size.unwrap_or(0),
             write_multi_min_size: value.write_multi_min_size.unwrap_or(0),
             write_total_max_size: value.write_total_max_size.unwrap_or(0),
@@ -291,24 +279,49 @@ impl From<core::Capability> for opendal_capability {
             delete: value.delete,
             delete_with_version: value.delete_with_version,
             delete_with_recursive: value.delete_with_recursive,
+            copy: value.copy,
+            copy_with_if_not_exists: value.copy_with_if_not_exists,
+            copy_with_if_match: value.copy_with_if_match,
+            copy_with_source_version: value.copy_with_source_version,
+            copy_can_multi: value.copy_can_multi,
+            copy_multi_max_size: value.copy_multi_max_size.unwrap_or(0),
+            copy_multi_min_size: value.copy_multi_min_size.unwrap_or(0),
+            rename: value.rename,
+            list: value.list,
+            list_with_limit: value.list_with_limit,
+            list_with_start_after: value.list_with_start_after,
+            list_with_recursive: value.list_with_recursive,
+            list_with_versions: value.list_with_versions,
+            list_with_deleted: value.list_with_deleted,
+            presign: value.presign,
+            presign_read: value.presign_read,
+            presign_stat: value.presign_stat,
+            presign_write: value.presign_write,
+            presign_delete: value.presign_delete,
+            shared: value.shared,
+            stat_with_if_version_match: value.stat_with_if_version_match,
+            stat_with_if_version_not_match: 
value.stat_with_if_version_not_match,
+            read_with_if_version_match: value.read_with_if_version_match,
+            read_with_if_version_not_match: 
value.read_with_if_version_not_match,
+            read_with_suffix: value.read_with_suffix,
+            read_with_checksum: value.read_with_checksum,
+            write_can_copy_from: value.write_can_copy_from,
+            write_with_content_language: value.write_with_content_language,
+            write_with_if_version_match: value.write_with_if_version_match,
+            write_with_if_version_not_match: 
value.write_with_if_version_not_match,
+            write_with_expires: value.write_with_expires,
+            write_with_checksum: value.write_with_checksum,
             delete_with_if_match: value.delete_with_if_match,
             delete_with_if_none_match: value.delete_with_if_none_match,
             delete_with_if_version_match: value.delete_with_if_version_match,
             delete_with_if_version_not_match: 
value.delete_with_if_version_not_match,
             delete_max_size: value.delete_max_size.unwrap_or(0),
-            copy: value.copy,
-            copy_with_if_not_exists: value.copy_with_if_not_exists,
-            copy_with_if_match: value.copy_with_if_match,
             copy_with_if_none_match: value.copy_with_if_none_match,
             copy_with_if_version_match: value.copy_with_if_version_match,
             copy_with_if_version_not_match: 
value.copy_with_if_version_not_match,
-            copy_with_source_version: value.copy_with_source_version,
             copy_with_user_metadata: value.copy_with_user_metadata,
             copy_with_content_type: value.copy_with_content_type,
             copy_with_content_language: value.copy_with_content_language,
-            copy_can_multi: value.copy_can_multi,
-            copy_multi_max_size: value.copy_multi_max_size.unwrap_or(0),
-            copy_multi_min_size: value.copy_multi_min_size.unwrap_or(0),
             compose: value.compose,
             compose_with_content_type: value.compose_with_content_type,
             compose_with_content_disposition: 
value.compose_with_content_disposition,
@@ -325,21 +338,8 @@ impl From<core::Capability> for opendal_capability {
             restore: value.restore,
             restore_with_version: value.restore_with_version,
             restore_with_if_not_exists: value.restore_with_if_not_exists,
-            rename: value.rename,
             rename_with_if_not_exists: value.rename_with_if_not_exists,
-            list: value.list,
-            list_with_limit: value.list_with_limit,
-            list_with_start_after: value.list_with_start_after,
-            list_with_recursive: value.list_with_recursive,
-            list_with_versions: value.list_with_versions,
-            list_with_deleted: value.list_with_deleted,
             list_with_glob: value.list_with_glob,
-            presign: value.presign,
-            presign_read: value.presign_read,
-            presign_stat: value.presign_stat,
-            presign_write: value.presign_write,
-            presign_delete: value.presign_delete,
-            shared: value.shared,
         }
     }
 }
diff --git a/bindings/c/tests/capability.cpp b/bindings/c/tests/capability.cpp
new file mode 100644
index 0000000000..f6333974e9
--- /dev/null
+++ b/bindings/c/tests/capability.cpp
@@ -0,0 +1,190 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <cstddef>
+#include <utility>
+#include <vector>
+
+#include "gtest/gtest.h"
+
+extern "C" {
+#include "opendal.h"
+}
+
+namespace {
+
+// A positional initializer written against the C binding 0.47.8 header
+// (OpenDAL v0.59.5) must keep its meaning: the 57 fields released there come
+// first, in their released order.
+TEST(CapabilityTest, PositionalInitializerKeepsReleasedOrder)
+{
+    // stat .. stat_with_version are the first 9 fields, followed by read.
+    opendal_capability cap = { true, false, false, false, false, false, false, 
false, false, true };
+    EXPECT_TRUE(cap.stat);
+    EXPECT_FALSE(cap.stat_with_if_match);
+    EXPECT_FALSE(cap.stat_with_version);
+    EXPECT_TRUE(cap.read);
+    EXPECT_FALSE(cap.stat_with_if_version_match);
+}
+
+TEST(CapabilityTest, PositionalInitializerReachesReleasedLimits)
+{
+    // write .. write_with_user_metadata are fields 18 to 29, followed by
+    // write_multi_max_size, write_multi_min_size, and write_total_max_size.
+    opendal_capability cap = { false, false, false, false, false, false, 
false, false, false,
+        false, false, false, false, false, false, false, false, false,
+        true, false, false, false, false, false, false, false, false, false, 
false, false,
+        1, 2, 3, true };
+    EXPECT_TRUE(cap.write);
+    EXPECT_EQ(cap.write_multi_max_size, 1u);
+    EXPECT_EQ(cap.write_multi_min_size, 2u);
+    EXPECT_EQ(cap.write_total_max_size, 3u);
+    EXPECT_TRUE(cap.create_dir);
+    EXPECT_FALSE(cap.delete_);
+}
+
+constexpr std::size_t kFrozenFields = 98;
+
+// Reads every frozen opendal_capability field by name, in declaration order.
+// The first 57 are the fields released in C binding 0.47.8 (OpenDAL v0.59.5);
+// the rest were added after that release. New fields are only appended after
+// these.
+std::vector<std::size_t> FrozenFields(const opendal_capability& c)
+{
+    return {
+        c.stat,
+        c.stat_with_if_match,
+        c.stat_with_if_none_match,
+        c.stat_with_if_modified_since,
+        c.stat_with_if_unmodified_since,
+        c.stat_with_override_cache_control,
+        c.stat_with_override_content_disposition,
+        c.stat_with_override_content_type,
+        c.stat_with_version,
+        c.read,
+        c.read_with_if_match,
+        c.read_with_if_none_match,
+        c.read_with_override_cache_control,
+        c.read_with_override_content_disposition,
+        c.read_with_override_content_type,
+        c.read_with_if_modified_since,
+        c.read_with_if_unmodified_since,
+        c.read_with_version,
+        c.write,
+        c.write_can_multi,
+        c.write_can_empty,
+        c.write_can_append,
+        c.write_with_content_type,
+        c.write_with_content_disposition,
+        c.write_with_content_encoding,
+        c.write_with_cache_control,
+        c.write_with_if_match,
+        c.write_with_if_none_match,
+        c.write_with_if_not_exists,
+        c.write_with_user_metadata,
+        c.write_multi_max_size,
+        c.write_multi_min_size,
+        c.write_total_max_size,
+        c.create_dir,
+        c.delete_,
+        c.delete_with_version,
+        c.delete_with_recursive,
+        c.copy,
+        c.copy_with_if_not_exists,
+        c.copy_with_if_match,
+        c.copy_with_source_version,
+        c.copy_can_multi,
+        c.copy_multi_max_size,
+        c.copy_multi_min_size,
+        c.rename,
+        c.list,
+        c.list_with_limit,
+        c.list_with_start_after,
+        c.list_with_recursive,
+        c.list_with_versions,
+        c.list_with_deleted,
+        c.presign,
+        c.presign_read,
+        c.presign_stat,
+        c.presign_write,
+        c.presign_delete,
+        c.shared,
+        c.stat_with_if_version_match,
+        c.stat_with_if_version_not_match,
+        c.read_with_if_version_match,
+        c.read_with_if_version_not_match,
+        c.read_with_suffix,
+        c.read_with_checksum,
+        c.write_can_copy_from,
+        c.write_with_content_language,
+        c.write_with_if_version_match,
+        c.write_with_if_version_not_match,
+        c.write_with_expires,
+        c.write_with_checksum,
+        c.delete_with_if_match,
+        c.delete_with_if_none_match,
+        c.delete_with_if_version_match,
+        c.delete_with_if_version_not_match,
+        c.delete_max_size,
+        c.copy_with_if_none_match,
+        c.copy_with_if_version_match,
+        c.copy_with_if_version_not_match,
+        c.copy_with_user_metadata,
+        c.copy_with_content_type,
+        c.copy_with_content_language,
+        c.compose,
+        c.compose_with_content_type,
+        c.compose_with_content_disposition,
+        c.compose_with_content_encoding,
+        c.compose_with_cache_control,
+        c.compose_with_user_metadata,
+        c.compose_with_if_match,
+        c.compose_with_if_none_match,
+        c.compose_with_if_version_match,
+        c.compose_with_if_version_not_match,
+        c.compose_with_if_not_exists,
+        c.compose_with_source_version,
+        c.compose_with_source_if_match,
+        c.restore,
+        c.restore_with_version,
+        c.restore_with_if_not_exists,
+        c.rename_with_if_not_exists,
+        c.list_with_glob
+    };
+}
+
+// Positionally initializes the first `sizeof...(I)` fields; only the one at
+// `pos` is nonzero.
+template <std::size_t... I>
+opendal_capability OnlyTrueAt(std::size_t pos, std::index_sequence<I...>)
+{
+    return opendal_capability { (I == pos)... };
+}
+
+TEST(CapabilityTest, PositionalInitializerSetsEachFrozenField)
+{
+    for (std::size_t pos = 0; pos < kFrozenFields; ++pos) {
+        std::vector<std::size_t> expected(kFrozenFields, 0);
+        expected[pos] = 1;
+        EXPECT_EQ(FrozenFields(OnlyTrueAt(pos, 
std::make_index_sequence<kFrozenFields>())), expected)
+            << "only positional initializer " << pos << " is set";
+    }
+}
+
+} // namespace
diff --git a/bindings/c/upgrade.md b/bindings/c/upgrade.md
index b19b73f9ae..db35dc95ba 100644
--- a/bindings/c/upgrade.md
+++ b/bindings/c/upgrade.md
@@ -2,12 +2,42 @@
 
 ## `opendal_capability` ABI change
 
-`opendal_capability` now exposes every core capability. On Linux x86-64,
-the struct grew from 104 to 152 bytes and field offsets changed.
-
-Rebuild C and Zig consumers using `opendal.h` and `libopendal_c` from the
-same OpenDAL source version. Mixing binaries built against the old layout
-with the new library is unsupported.
+`opendal_capability` now exposes every core capability. The 57 fields
+released in C binding 0.47.8 (OpenDAL v0.59.5) keep their names, types, and
+order, so their offsets are unchanged, and the new fields follow them. On
+Linux x86-64, the struct grew from 104 to 152 bytes.
+
+`opendal_operator_info_get_capability` now writes the capability into
+caller-provided storage instead of returning it by value, like the other
+functions described in [Output parameters](README.md#output-parameters):
+
+```c
+// Before
+opendal_capability cap = opendal_operator_info_get_capability(info);
+
+// After
+opendal_capability cap;
+opendal_operator_info_get_capability(info, &cap);
+```
+
+New fields are only appended to `opendal_capability`, so source that
+initializes it by position keeps its meaning when rebuilt. Prefer designated
+initializers, which do not depend on field order:
+
+```c
+opendal_capability cap = { .stat = true, .read = true };
+```
+
+These changes break binary compatibility. Rebuild C and Zig consumers using
+`opendal.h` and `libopendal_c` from the same OpenDAL source version. Mixing
+binaries built against an older header with the new library is unsupported.
+
+Later releases keep this field order but can still break binary
+compatibility. Appending a field can increase `sizeof(opendal_capability)`, and
+`opendal_operator_info_get_capability` writes the whole struct into
+caller-provided storage, so a caller built with an older header may allocate
+too little space. C and Zig consumers must keep `opendal.h` and `libopendal_c`
+on the same version in every upgrade.
 
 # Upgrade to v0.45
 
diff --git a/bindings/go/capability.go b/bindings/go/capability.go
index 67bc32d1ff..1b742384e3 100644
--- a/bindings/go/capability.go
+++ b/bindings/go/capability.go
@@ -25,8 +25,6 @@ type opendalCapability struct {
        stat                               uint8
        statWithIfMatch                    uint8
        statWithIfNoneMatch                uint8
-       statWithIfVersionMatch             uint8
-       statWithIfVersionNotMatch          uint8
        statWithIfModifiedSince            uint8
        statWithIfUnmodifiedSince          uint8
        statWithOverrideCacheControl       uint8
@@ -36,34 +34,24 @@ type opendalCapability struct {
        read                               uint8
        readWithIfMatch                    uint8
        readWithIfNoneMatch                uint8
-       readWithIfVersionMatch             uint8
-       readWithIfVersionNotMatch          uint8
-       readWithIfModifiedSince            uint8
-       readWithIfUnmodifiedSince          uint8
        readWithOverrideCacheControl       uint8
        readWithOverrideContentDisposition uint8
        readWithOverrideContentType        uint8
+       readWithIfModifiedSince            uint8
+       readWithIfUnmodifiedSince          uint8
        readWithVersion                    uint8
-       readWithSuffix                     uint8
-       readWithChecksum                   uint8
        write                              uint8
        writeCanMulti                      uint8
        writeCanEmpty                      uint8
        writeCanAppend                     uint8
-       writeCanCopyFrom                   uint8
        writeWithContentType               uint8
        writeWithContentDisposition        uint8
        writeWithContentEncoding           uint8
-       writeWithContentLanguage           uint8
        writeWithCacheControl              uint8
        writeWithIfMatch                   uint8
        writeWithIfNoneMatch               uint8
-       writeWithIfVersionMatch            uint8
-       writeWithIfVersionNotMatch         uint8
        writeWithIfNotExists               uint8
        writeWithUserMetadata              uint8
-       writeWithExpires                   uint8
-       writeWithChecksum                  uint8
        writeMultiMaxSize                  uint
        writeMultiMinSize                  uint
        writeTotalMaxSize                  uint
@@ -71,24 +59,49 @@ type opendalCapability struct {
        delete                             uint8
        deleteWithVersion                  uint8
        deleteWithRecursive                uint8
+       copy                               uint8
+       copyWithIfNotExists                uint8
+       copyWithIfMatch                    uint8
+       copyWithSourceVersion              uint8
+       copyCanMulti                       uint8
+       copyMultiMaxSize                   uint
+       copyMultiMinSize                   uint
+       rename                             uint8
+       list                               uint8
+       listWithLimit                      uint8
+       listWithStartAfter                 uint8
+       listWithRecursive                  uint8
+       listWithVersions                   uint8
+       listWithDeleted                    uint8
+       presign                            uint8
+       presignRead                        uint8
+       presignStat                        uint8
+       presignWrite                       uint8
+       presignDelete                      uint8
+       shared                             uint8
+       statWithIfVersionMatch             uint8
+       statWithIfVersionNotMatch          uint8
+       readWithIfVersionMatch             uint8
+       readWithIfVersionNotMatch          uint8
+       readWithSuffix                     uint8
+       readWithChecksum                   uint8
+       writeCanCopyFrom                   uint8
+       writeWithContentLanguage           uint8
+       writeWithIfVersionMatch            uint8
+       writeWithIfVersionNotMatch         uint8
+       writeWithExpires                   uint8
+       writeWithChecksum                  uint8
        deleteWithIfMatch                  uint8
        deleteWithIfNoneMatch              uint8
        deleteWithIfVersionMatch           uint8
        deleteWithIfVersionNotMatch        uint8
        deleteMaxSize                      uint
-       copy                               uint8
-       copyWithIfNotExists                uint8
-       copyWithIfMatch                    uint8
        copyWithIfNoneMatch                uint8
        copyWithIfVersionMatch             uint8
        copyWithIfVersionNotMatch          uint8
-       copyWithSourceVersion              uint8
        copyWithUserMetadata               uint8
        copyWithContentType                uint8
        copyWithContentLanguage            uint8
-       copyCanMulti                       uint8
-       copyMultiMaxSize                   uint
-       copyMultiMinSize                   uint
        compose                            uint8
        composeWithContentType             uint8
        composeWithContentDisposition      uint8
@@ -105,21 +118,8 @@ type opendalCapability struct {
        restore                            uint8
        restoreWithVersion                 uint8
        restoreWithIfNotExists             uint8
-       rename                             uint8
        renameWithIfNotExists              uint8
-       list                               uint8
-       listWithLimit                      uint8
-       listWithStartAfter                 uint8
-       listWithRecursive                  uint8
-       listWithVersions                   uint8
-       listWithDeleted                    uint8
        listWithGlob                       uint8
-       presign                            uint8
-       presignRead                        uint8
-       presignStat                        uint8
-       presignWrite                       uint8
-       presignDelete                      uint8
-       shared                             uint8
 }
 
 // Capability represents the set of operations and features supported by an 
Operator.
@@ -154,16 +154,6 @@ func (c *Capability) StatWithIfNoneMatch() bool {
        return c.inner.statWithIfNoneMatch == 1
 }
 
-// StatWithIfVersionMatch reports: Indicates if conditional stat operations 
using version match are supported.
-func (c *Capability) StatWithIfVersionMatch() bool {
-       return c.inner.statWithIfVersionMatch == 1
-}
-
-// StatWithIfVersionNotMatch reports: Indicates if conditional stat operations 
using version non-match are supported.
-func (c *Capability) StatWithIfVersionNotMatch() bool {
-       return c.inner.statWithIfVersionNotMatch == 1
-}
-
 // StatWithIfModifiedSince reports: Indicates if conditional stat operations 
using If-Modified-Since are supported.
 func (c *Capability) StatWithIfModifiedSince() bool {
        return c.inner.statWithIfModifiedSince == 1
@@ -209,26 +199,6 @@ func (c *Capability) ReadWithIfNoneMatch() bool {
        return c.inner.readWithIfNoneMatch == 1
 }
 
-// ReadWithIfVersionMatch reports: Indicates if conditional read operations 
using version match are supported.
-func (c *Capability) ReadWithIfVersionMatch() bool {
-       return c.inner.readWithIfVersionMatch == 1
-}
-
-// ReadWithIfVersionNotMatch reports: Indicates if conditional read operations 
using version non-match are supported.
-func (c *Capability) ReadWithIfVersionNotMatch() bool {
-       return c.inner.readWithIfVersionNotMatch == 1
-}
-
-// ReadWithIfModifiedSince reports: Indicates if conditional read operations 
using If-Modified-Since are supported.
-func (c *Capability) ReadWithIfModifiedSince() bool {
-       return c.inner.readWithIfModifiedSince == 1
-}
-
-// ReadWithIfUnmodifiedSince reports: Indicates if conditional read operations 
using If-Unmodified-Since are supported.
-func (c *Capability) ReadWithIfUnmodifiedSince() bool {
-       return c.inner.readWithIfUnmodifiedSince == 1
-}
-
 // ReadWithOverrideCacheControl reports: Indicates if Cache-Control header 
override is supported during read operations.
 func (c *Capability) ReadWithOverrideCacheControl() bool {
        return c.inner.readWithOverrideCacheControl == 1
@@ -244,19 +214,19 @@ func (c *Capability) ReadWithOverrideContentType() bool {
        return c.inner.readWithOverrideContentType == 1
 }
 
-// ReadWithVersion reports: Indicates if versions read operations are 
supported.
-func (c *Capability) ReadWithVersion() bool {
-       return c.inner.readWithVersion == 1
+// ReadWithIfModifiedSince reports: Indicates if conditional read operations 
using If-Modified-Since are supported.
+func (c *Capability) ReadWithIfModifiedSince() bool {
+       return c.inner.readWithIfModifiedSince == 1
 }
 
-// ReadWithSuffix reports: Indicates if suffix read operations are supported.
-func (c *Capability) ReadWithSuffix() bool {
-       return c.inner.readWithSuffix == 1
+// ReadWithIfUnmodifiedSince reports: Indicates if conditional read operations 
using If-Unmodified-Since are supported.
+func (c *Capability) ReadWithIfUnmodifiedSince() bool {
+       return c.inner.readWithIfUnmodifiedSince == 1
 }
 
-// ReadWithChecksum reports: Indicates if the operator supports requesting 
stored full-file checksum metadata. Stat and read responses may include that 
metadata when requested.
-func (c *Capability) ReadWithChecksum() bool {
-       return c.inner.readWithChecksum == 1
+// ReadWithVersion reports: Indicates if versions read operations are 
supported.
+func (c *Capability) ReadWithVersion() bool {
+       return c.inner.readWithVersion == 1
 }
 
 // Write reports: Indicates if the operator supports write operations.
@@ -279,11 +249,6 @@ func (c *Capability) WriteCanAppend() bool {
        return c.inner.writeCanAppend == 1
 }
 
-// WriteCanCopyFrom reports: Indicates if an open, non-append writer can copy 
eligible byte ranges from existing objects without transferring the copied 
bytes through the client. Whole-object copy is a separate capability.
-func (c *Capability) WriteCanCopyFrom() bool {
-       return c.inner.writeCanCopyFrom == 1
-}
-
 // WriteWithContentType reports: Indicates if Content-Type can be specified 
during write operations.
 func (c *Capability) WriteWithContentType() bool {
        return c.inner.writeWithContentType == 1
@@ -299,11 +264,6 @@ func (c *Capability) WriteWithContentEncoding() bool {
        return c.inner.writeWithContentEncoding == 1
 }
 
-// WriteWithContentLanguage reports: Indicates if a write can store 
Content-Language and a subsequent stat can retrieve it.
-func (c *Capability) WriteWithContentLanguage() bool {
-       return c.inner.writeWithContentLanguage == 1
-}
-
 // WriteWithCacheControl reports: Indicates if Cache-Control can be specified 
during write operations.
 func (c *Capability) WriteWithCacheControl() bool {
        return c.inner.writeWithCacheControl == 1
@@ -319,16 +279,6 @@ func (c *Capability) WriteWithIfNoneMatch() bool {
        return c.inner.writeWithIfNoneMatch == 1
 }
 
-// WriteWithIfVersionMatch reports: Indicates if conditional write operations 
using version match are supported.
-func (c *Capability) WriteWithIfVersionMatch() bool {
-       return c.inner.writeWithIfVersionMatch == 1
-}
-
-// WriteWithIfVersionNotMatch reports: Indicates if conditional write 
operations using version non-match are supported.
-func (c *Capability) WriteWithIfVersionNotMatch() bool {
-       return c.inner.writeWithIfVersionNotMatch == 1
-}
-
 // WriteWithIfNotExists reports: Indicates if write operations can be 
conditional on object non-existence.
 func (c *Capability) WriteWithIfNotExists() bool {
        return c.inner.writeWithIfNotExists == 1
@@ -339,16 +289,6 @@ func (c *Capability) WriteWithUserMetadata() bool {
        return c.inner.writeWithUserMetadata == 1
 }
 
-// WriteWithExpires reports: Indicates if writes can set a lifetime for the 
new file.
-func (c *Capability) WriteWithExpires() bool {
-       return c.inner.writeWithExpires == 1
-}
-
-// WriteWithChecksum reports: Indicates if non-append writes support native 
verification with a checksum algorithm selected by the service. Verification 
may cover only individual upload requests, parts, or blocks. Support for 
caller-selected algorithms and full-object verification depends on the service 
and write mode. OpenDAL rejects unsupported explicit checksum requests before 
performing I/O.
-func (c *Capability) WriteWithChecksum() bool {
-       return c.inner.writeWithChecksum == 1
-}
-
 // WriteMultiMaxSize reports: Maximum size supported for multipart uploads. 
For example, AWS S3 supports up to 5GiB per part in multipart uploads.
 func (c *Capability) WriteMultiMaxSize() uint {
        return c.inner.writeMultiMaxSize
@@ -384,6 +324,166 @@ func (c *Capability) DeleteWithRecursive() bool {
        return c.inner.deleteWithRecursive == 1
 }
 
+// Copy reports: Indicates if copy operations are supported.
+func (c *Capability) Copy() bool {
+       return c.inner.copy == 1
+}
+
+// CopyWithIfNotExists reports: Indicates if conditional copy operations with 
if-not-exists are supported.
+func (c *Capability) CopyWithIfNotExists() bool {
+       return c.inner.copyWithIfNotExists == 1
+}
+
+// CopyWithIfMatch reports: Indicates if conditional copy operations with 
if-match are supported.
+func (c *Capability) CopyWithIfMatch() bool {
+       return c.inner.copyWithIfMatch == 1
+}
+
+// CopyWithSourceVersion reports: Indicates if copy operations from a specific 
source version are supported.
+func (c *Capability) CopyWithSourceVersion() bool {
+       return c.inner.copyWithSourceVersion == 1
+}
+
+// CopyCanMulti reports: Indicates if copy operations can be split into 
multiple server-side tasks.
+func (c *Capability) CopyCanMulti() bool {
+       return c.inner.copyCanMulti == 1
+}
+
+// CopyMultiMaxSize reports: Maximum size supported for segmented copy tasks.
+func (c *Capability) CopyMultiMaxSize() uint {
+       return c.inner.copyMultiMaxSize
+}
+
+// CopyMultiMinSize reports: Minimum size required for segmented copy tasks.
+func (c *Capability) CopyMultiMinSize() uint {
+       return c.inner.copyMultiMinSize
+}
+
+// Rename reports: Indicates if rename operations are supported.
+func (c *Capability) Rename() bool {
+       return c.inner.rename == 1
+}
+
+// List reports: Indicates if list operations are supported.
+func (c *Capability) List() bool {
+       return c.inner.list == 1
+}
+
+// ListWithLimit reports: Indicates if list operations support result limiting.
+func (c *Capability) ListWithLimit() bool {
+       return c.inner.listWithLimit == 1
+}
+
+// ListWithStartAfter reports: Indicates if list operations support 
continuation from a specific point.
+func (c *Capability) ListWithStartAfter() bool {
+       return c.inner.listWithStartAfter == 1
+}
+
+// ListWithRecursive reports: Indicates if recursive listing is supported.
+func (c *Capability) ListWithRecursive() bool {
+       return c.inner.listWithRecursive == 1
+}
+
+// ListWithVersions reports: Indicates if listing with versions included is 
supported.
+func (c *Capability) ListWithVersions() bool {
+       return c.inner.listWithVersions == 1
+}
+
+// ListWithDeleted reports: Indicates if listing with deleted files included 
is supported.
+func (c *Capability) ListWithDeleted() bool {
+       return c.inner.listWithDeleted == 1
+}
+
+// Presign reports: Indicates if presigned URL generation is supported.
+func (c *Capability) Presign() bool {
+       return c.inner.presign == 1
+}
+
+// PresignRead reports: Indicates if presigned URLs for read operations are 
supported.
+func (c *Capability) PresignRead() bool {
+       return c.inner.presignRead == 1
+}
+
+// PresignStat reports: Indicates if presigned URLs for stat operations are 
supported.
+func (c *Capability) PresignStat() bool {
+       return c.inner.presignStat == 1
+}
+
+// PresignWrite reports: Indicates if presigned URLs for write operations are 
supported.
+func (c *Capability) PresignWrite() bool {
+       return c.inner.presignWrite == 1
+}
+
+// PresignDelete reports: Indicates if presigned URLs for delete operations 
are supported.
+func (c *Capability) PresignDelete() bool {
+       return c.inner.presignDelete == 1
+}
+
+// Shared reports: Indicate if the operator supports shared access.
+func (c *Capability) Shared() bool {
+       return c.inner.shared == 1
+}
+
+// StatWithIfVersionMatch reports: Indicates if conditional stat operations 
using version match are supported.
+func (c *Capability) StatWithIfVersionMatch() bool {
+       return c.inner.statWithIfVersionMatch == 1
+}
+
+// StatWithIfVersionNotMatch reports: Indicates if conditional stat operations 
using version non-match are supported.
+func (c *Capability) StatWithIfVersionNotMatch() bool {
+       return c.inner.statWithIfVersionNotMatch == 1
+}
+
+// ReadWithIfVersionMatch reports: Indicates if conditional read operations 
using version match are supported.
+func (c *Capability) ReadWithIfVersionMatch() bool {
+       return c.inner.readWithIfVersionMatch == 1
+}
+
+// ReadWithIfVersionNotMatch reports: Indicates if conditional read operations 
using version non-match are supported.
+func (c *Capability) ReadWithIfVersionNotMatch() bool {
+       return c.inner.readWithIfVersionNotMatch == 1
+}
+
+// ReadWithSuffix reports: Indicates if suffix read operations are supported.
+func (c *Capability) ReadWithSuffix() bool {
+       return c.inner.readWithSuffix == 1
+}
+
+// ReadWithChecksum reports: Indicates if the operator supports requesting 
stored full-file checksum metadata. Stat and read responses may include that 
metadata when requested.
+func (c *Capability) ReadWithChecksum() bool {
+       return c.inner.readWithChecksum == 1
+}
+
+// WriteCanCopyFrom reports: Indicates if an open, non-append writer can copy 
eligible byte ranges from existing objects without transferring the copied 
bytes through the client. Whole-object copy is a separate capability.
+func (c *Capability) WriteCanCopyFrom() bool {
+       return c.inner.writeCanCopyFrom == 1
+}
+
+// WriteWithContentLanguage reports: Indicates if a write can store 
Content-Language and a subsequent stat can retrieve it.
+func (c *Capability) WriteWithContentLanguage() bool {
+       return c.inner.writeWithContentLanguage == 1
+}
+
+// WriteWithIfVersionMatch reports: Indicates if conditional write operations 
using version match are supported.
+func (c *Capability) WriteWithIfVersionMatch() bool {
+       return c.inner.writeWithIfVersionMatch == 1
+}
+
+// WriteWithIfVersionNotMatch reports: Indicates if conditional write 
operations using version non-match are supported.
+func (c *Capability) WriteWithIfVersionNotMatch() bool {
+       return c.inner.writeWithIfVersionNotMatch == 1
+}
+
+// WriteWithExpires reports: Indicates if writes can set a lifetime for the 
new file.
+func (c *Capability) WriteWithExpires() bool {
+       return c.inner.writeWithExpires == 1
+}
+
+// WriteWithChecksum reports: Indicates if non-append writes support native 
verification with a checksum algorithm selected by the service. Verification 
may cover only individual upload requests, parts, or blocks. Support for 
caller-selected algorithms and full-object verification depends on the service 
and write mode. OpenDAL rejects unsupported explicit checksum requests before 
performing I/O.
+func (c *Capability) WriteWithChecksum() bool {
+       return c.inner.writeWithChecksum == 1
+}
+
 // DeleteWithIfMatch reports: Indicates if conditional delete operations using 
If-Match are supported.
 func (c *Capability) DeleteWithIfMatch() bool {
        return c.inner.deleteWithIfMatch == 1
@@ -409,21 +509,6 @@ func (c *Capability) DeleteMaxSize() uint {
        return c.inner.deleteMaxSize
 }
 
-// Copy reports: Indicates if copy operations are supported.
-func (c *Capability) Copy() bool {
-       return c.inner.copy == 1
-}
-
-// CopyWithIfNotExists reports: Indicates if conditional copy operations with 
if-not-exists are supported.
-func (c *Capability) CopyWithIfNotExists() bool {
-       return c.inner.copyWithIfNotExists == 1
-}
-
-// CopyWithIfMatch reports: Indicates if conditional copy operations with 
if-match are supported.
-func (c *Capability) CopyWithIfMatch() bool {
-       return c.inner.copyWithIfMatch == 1
-}
-
 // CopyWithIfNoneMatch reports: Indicates if conditional copy operations with 
if-none-match are supported.
 func (c *Capability) CopyWithIfNoneMatch() bool {
        return c.inner.copyWithIfNoneMatch == 1
@@ -439,11 +524,6 @@ func (c *Capability) CopyWithIfVersionNotMatch() bool {
        return c.inner.copyWithIfVersionNotMatch == 1
 }
 
-// CopyWithSourceVersion reports: Indicates if copy operations from a specific 
source version are supported.
-func (c *Capability) CopyWithSourceVersion() bool {
-       return c.inner.copyWithSourceVersion == 1
-}
-
 // CopyWithUserMetadata reports: Indicates if copy operations can replace the 
destination's user metadata.
 func (c *Capability) CopyWithUserMetadata() bool {
        return c.inner.copyWithUserMetadata == 1
@@ -459,21 +539,6 @@ func (c *Capability) CopyWithContentLanguage() bool {
        return c.inner.copyWithContentLanguage == 1
 }
 
-// CopyCanMulti reports: Indicates if copy operations can be split into 
multiple server-side tasks.
-func (c *Capability) CopyCanMulti() bool {
-       return c.inner.copyCanMulti == 1
-}
-
-// CopyMultiMaxSize reports: Maximum size supported for segmented copy tasks.
-func (c *Capability) CopyMultiMaxSize() uint {
-       return c.inner.copyMultiMaxSize
-}
-
-// CopyMultiMinSize reports: Minimum size required for segmented copy tasks.
-func (c *Capability) CopyMultiMinSize() uint {
-       return c.inner.copyMultiMinSize
-}
-
 // Compose reports: Indicates if the operator supports composing complete 
source objects.
 func (c *Capability) Compose() bool {
        return c.inner.compose == 1
@@ -554,77 +619,12 @@ func (c *Capability) RestoreWithIfNotExists() bool {
        return c.inner.restoreWithIfNotExists == 1
 }
 
-// Rename reports: Indicates if rename operations are supported.
-func (c *Capability) Rename() bool {
-       return c.inner.rename == 1
-}
-
 // RenameWithIfNotExists reports: Indicates if conditional rename operations 
with if-not-exists are supported.
 func (c *Capability) RenameWithIfNotExists() bool {
        return c.inner.renameWithIfNotExists == 1
 }
 
-// List reports: Indicates if list operations are supported.
-func (c *Capability) List() bool {
-       return c.inner.list == 1
-}
-
-// ListWithLimit reports: Indicates if list operations support result limiting.
-func (c *Capability) ListWithLimit() bool {
-       return c.inner.listWithLimit == 1
-}
-
-// ListWithStartAfter reports: Indicates if list operations support 
continuation from a specific point.
-func (c *Capability) ListWithStartAfter() bool {
-       return c.inner.listWithStartAfter == 1
-}
-
-// ListWithRecursive reports: Indicates if recursive listing is supported.
-func (c *Capability) ListWithRecursive() bool {
-       return c.inner.listWithRecursive == 1
-}
-
-// ListWithVersions reports: Indicates if listing with versions included is 
supported.
-func (c *Capability) ListWithVersions() bool {
-       return c.inner.listWithVersions == 1
-}
-
-// ListWithDeleted reports: Indicates if listing with deleted files included 
is supported.
-func (c *Capability) ListWithDeleted() bool {
-       return c.inner.listWithDeleted == 1
-}
-
 // ListWithGlob reports: Indicates if listing with a glob pattern is supported 
by this service stack.
 func (c *Capability) ListWithGlob() bool {
        return c.inner.listWithGlob == 1
 }
-
-// Presign reports: Indicates if presigned URL generation is supported.
-func (c *Capability) Presign() bool {
-       return c.inner.presign == 1
-}
-
-// PresignRead reports: Indicates if presigned URLs for read operations are 
supported.
-func (c *Capability) PresignRead() bool {
-       return c.inner.presignRead == 1
-}
-
-// PresignStat reports: Indicates if presigned URLs for stat operations are 
supported.
-func (c *Capability) PresignStat() bool {
-       return c.inner.presignStat == 1
-}
-
-// PresignWrite reports: Indicates if presigned URLs for write operations are 
supported.
-func (c *Capability) PresignWrite() bool {
-       return c.inner.presignWrite == 1
-}
-
-// PresignDelete reports: Indicates if presigned URLs for delete operations 
are supported.
-func (c *Capability) PresignDelete() bool {
-       return c.inner.presignDelete == 1
-}
-
-// Shared reports: Indicate if the operator supports shared access.
-func (c *Capability) Shared() bool {
-       return c.inner.shared == 1
-}
diff --git a/bindings/go/upgrade.md b/bindings/go/upgrade.md
index 59dd0e96a5..aef1833af7 100644
--- a/bindings/go/upgrade.md
+++ b/bindings/go/upgrade.md
@@ -6,10 +6,13 @@
 
 #### `opendal_capability` layout and `opendal-go-services` companions
 
-The Go binding mirrors the native `opendal_capability` struct, whose layout
-changed in this release. Existing `Capability` methods keep their names and
-signatures. See the [C upgrade 
guide](../c/upgrade.md#opendal_capability-abi-change)
-for the layout change.
+The Go binding mirrors the native `opendal_capability` struct and reads it
+through `opendal_operator_info_get_capability`. In this release the struct
+appends new fields after the released ones and grows in size, and the function
+writes it into caller-provided storage instead of returning it by value.
+Existing `Capability` methods keep their names and signatures. See the
+[C upgrade guide](../c/upgrade.md#opendal_capability-abi-change) for the
+layout change.
 
 **Migration:**
 
@@ -18,6 +21,11 @@ together. Each companion ships a `libopendal_c` that must 
match the ABI expected
 by the Go binding. If you build the library yourself, use the matching OpenDAL
 sources. Mixing old and new layouts is unsupported.
 
+Later releases can append fields and grow `opendal_capability` again. The Go
+binding allocates the struct from its own mirror, so a companion `libopendal_c`
+that is newer than the binding may write past it. Upgrade the binding and its
+companions together in every release.
+
 #### `context.Context` parameter on I/O operations
 
 All `Operator` I/O methods and non-stdlib handle methods now accept 
`context.Context` as their first parameter to support cooperative cancellation 
and deadlines via `opendal_cancel_token`:
diff --git a/dev/src/generate/c.rs b/dev/src/generate/c.rs
index a8fccc00b5..4c57b26ea4 100644
--- a/dev/src/generate/c.rs
+++ b/dev/src/generate/c.rs
@@ -18,14 +18,14 @@
 //! Generator for the C binding and the Go binding, which mirrors the C ABI.
 //!
 //! The Go binding loads `libopendal_c` through purego and reads
-//! `opendal_capability` by memory layout, so both sides are rendered from the
-//! same ordered field list to keep the layouts in lockstep.
+//! `opendal_capability` by memory layout, so both sides are rendered in the
+//! same frozen field order to keep the layouts in lockstep.
 
 mod options;
 
 use super::capability;
 use super::metadata::{self, MetadataKind};
-use anyhow::Result;
+use anyhow::{Context, Result, bail};
 use minijinja::value::Serde;
 use minijinja::{Environment, context};
 use serde::Serialize;
@@ -78,9 +78,156 @@ pub fn generate(workspace_dir: &Path) -> Result<()> {
     options::generate(workspace_dir)
 }
 
+/// Core names of the `opendal_capability` fields, in their declaration order.
+///
+/// C callers may initialize the struct by position, and the Go mirror reads it
+/// by memory layout. The first 57 fields keep the order released in C binding
+/// 0.47.8 (OpenDAL v0.59.5). This order is append-only: generation fails until
+/// every core field is listed, so append each new core field to the end of
+/// this list.
+const FROZEN_CAPABILITY_ORDER: &[&str] = &[
+    "stat",
+    "stat_with_if_match",
+    "stat_with_if_none_match",
+    "stat_with_if_modified_since",
+    "stat_with_if_unmodified_since",
+    "stat_with_override_cache_control",
+    "stat_with_override_content_disposition",
+    "stat_with_override_content_type",
+    "stat_with_version",
+    "read",
+    "read_with_if_match",
+    "read_with_if_none_match",
+    "read_with_override_cache_control",
+    "read_with_override_content_disposition",
+    "read_with_override_content_type",
+    "read_with_if_modified_since",
+    "read_with_if_unmodified_since",
+    "read_with_version",
+    "write",
+    "write_can_multi",
+    "write_can_empty",
+    "write_can_append",
+    "write_with_content_type",
+    "write_with_content_disposition",
+    "write_with_content_encoding",
+    "write_with_cache_control",
+    "write_with_if_match",
+    "write_with_if_none_match",
+    "write_with_if_not_exists",
+    "write_with_user_metadata",
+    "write_multi_max_size",
+    "write_multi_min_size",
+    "write_total_max_size",
+    "create_dir",
+    "delete",
+    "delete_with_version",
+    "delete_with_recursive",
+    "copy",
+    "copy_with_if_not_exists",
+    "copy_with_if_match",
+    "copy_with_source_version",
+    "copy_can_multi",
+    "copy_multi_max_size",
+    "copy_multi_min_size",
+    "rename",
+    "list",
+    "list_with_limit",
+    "list_with_start_after",
+    "list_with_recursive",
+    "list_with_versions",
+    "list_with_deleted",
+    "presign",
+    "presign_read",
+    "presign_stat",
+    "presign_write",
+    "presign_delete",
+    "shared",
+    "stat_with_if_version_match",
+    "stat_with_if_version_not_match",
+    "read_with_if_version_match",
+    "read_with_if_version_not_match",
+    "read_with_suffix",
+    "read_with_checksum",
+    "write_can_copy_from",
+    "write_with_content_language",
+    "write_with_if_version_match",
+    "write_with_if_version_not_match",
+    "write_with_expires",
+    "write_with_checksum",
+    "delete_with_if_match",
+    "delete_with_if_none_match",
+    "delete_with_if_version_match",
+    "delete_with_if_version_not_match",
+    "delete_max_size",
+    "copy_with_if_none_match",
+    "copy_with_if_version_match",
+    "copy_with_if_version_not_match",
+    "copy_with_user_metadata",
+    "copy_with_content_type",
+    "copy_with_content_language",
+    "compose",
+    "compose_with_content_type",
+    "compose_with_content_disposition",
+    "compose_with_content_encoding",
+    "compose_with_cache_control",
+    "compose_with_user_metadata",
+    "compose_with_if_match",
+    "compose_with_if_none_match",
+    "compose_with_if_version_match",
+    "compose_with_if_version_not_match",
+    "compose_with_if_not_exists",
+    "compose_with_source_version",
+    "compose_with_source_if_match",
+    "restore",
+    "restore_with_version",
+    "restore_with_if_not_exists",
+    "rename_with_if_not_exists",
+    "list_with_glob",
+];
+
+/// Order the core capability fields by `FROZEN_CAPABILITY_ORDER`.
+///
+/// Fails if a core field is not listed, so a new field cannot take an
+/// unreviewed position, and if a listed field no longer exists in core,
+/// because dropping it would shift every later field.
+fn frozen_order(
+    mut fields: Vec<capability::CapabilityField>,
+) -> Result<Vec<capability::CapabilityField>> {
+    if let Some(field) = fields
+        .iter()
+        .find(|f| !FROZEN_CAPABILITY_ORDER.contains(&f.name.as_str()))
+    {
+        bail!(
+            "new core capability `{}` must be appended to 
FROZEN_CAPABILITY_ORDER in dev/src/generate/c.rs",
+            field.name
+        );
+    }
+    FROZEN_CAPABILITY_ORDER
+        .iter()
+        .map(|name| {
+            let index = fields
+                .iter()
+                .position(|f| f.name == *name)
+                .with_context(|| {
+                    format!("FROZEN_CAPABILITY_ORDER field `{name}` is missing 
from core")
+                })?;
+            Ok(fields.swap_remove(index))
+        })
+        .collect()
+}
+
 fn generate_capability(workspace_dir: &Path) -> Result<()> {
+    for (relative, rendered) in render_capability(workspace_dir)? {
+        fs::write(workspace_dir.join(relative), format!("{rendered}\n"))?;
+    }
+    Ok(())
+}
+
+/// Render every capability output as `(path relative to workspace, content)`.
+fn render_capability(workspace_dir: &Path) -> Result<Vec<(&'static str, 
String)>> {
     let source = workspace_dir.join("core/core/src/types/capability.rs");
-    let parsed = capability::parse(&source)?;
+    let parsed = frozen_order(capability::parse(&source)?)?;
 
     let width = parsed
         .iter()
@@ -111,13 +258,14 @@ fn generate_capability(workspace_dir: &Path) -> 
Result<()> {
         ("capability_rs", "bindings/c/src/capability.rs"),
         ("capability_go", "bindings/go/capability.go"),
     ];
+    let mut rendered = Vec::with_capacity(outputs.len());
     for (template, relative) in outputs {
-        let rendered = env
+        let content = env
             .get_template(template)?
             .render(context! { fields => Serde(&fields) })?;
-        fs::write(workspace_dir.join(relative), format!("{rendered}\n"))?;
+        rendered.push((relative, content));
     }
-    Ok(())
+    Ok(rendered)
 }
 
 fn generate_metadata(workspace_dir: &Path) -> Result<()> {
@@ -220,6 +368,208 @@ fn lower_first(s: &str) -> String {
 mod tests {
     use super::*;
 
+    /// `opendal_capability` fields released in C binding 0.47.8 (OpenDAL
+    /// v0.59.5), copied from `bindings/c/src/operator_info.rs` at `v0.59.5`.
+    const RELEASED_C_FIELDS: [&str; 57] = [
+        "stat: bool",
+        "stat_with_if_match: bool",
+        "stat_with_if_none_match: bool",
+        "stat_with_if_modified_since: bool",
+        "stat_with_if_unmodified_since: bool",
+        "stat_with_override_cache_control: bool",
+        "stat_with_override_content_disposition: bool",
+        "stat_with_override_content_type: bool",
+        "stat_with_version: bool",
+        "read: bool",
+        "read_with_if_match: bool",
+        "read_with_if_none_match: bool",
+        "read_with_override_cache_control: bool",
+        "read_with_override_content_disposition: bool",
+        "read_with_override_content_type: bool",
+        "read_with_if_modified_since: bool",
+        "read_with_if_unmodified_since: bool",
+        "read_with_version: bool",
+        "write: bool",
+        "write_can_multi: bool",
+        "write_can_empty: bool",
+        "write_can_append: bool",
+        "write_with_content_type: bool",
+        "write_with_content_disposition: bool",
+        "write_with_content_encoding: bool",
+        "write_with_cache_control: bool",
+        "write_with_if_match: bool",
+        "write_with_if_none_match: bool",
+        "write_with_if_not_exists: bool",
+        "write_with_user_metadata: bool",
+        "write_multi_max_size: usize",
+        "write_multi_min_size: usize",
+        "write_total_max_size: usize",
+        "create_dir: bool",
+        "delete: bool",
+        "delete_with_version: bool",
+        "delete_with_recursive: bool",
+        "copy: bool",
+        "copy_with_if_not_exists: bool",
+        "copy_with_if_match: bool",
+        "copy_with_source_version: bool",
+        "copy_can_multi: bool",
+        "copy_multi_max_size: usize",
+        "copy_multi_min_size: usize",
+        "rename: bool",
+        "list: bool",
+        "list_with_limit: bool",
+        "list_with_start_after: bool",
+        "list_with_recursive: bool",
+        "list_with_versions: bool",
+        "list_with_deleted: bool",
+        "presign: bool",
+        "presign_read: bool",
+        "presign_stat: bool",
+        "presign_write: bool",
+        "presign_delete: bool",
+        "shared: bool",
+    ];
+
+    /// The `opendalCapability` mirror of `RELEASED_C_FIELDS`, copied from
+    /// `bindings/go/types.go` at `v0.59.5`.
+    const RELEASED_GO_FIELDS: [&str; 57] = [
+        "stat uint8",
+        "statWithIfMatch uint8",
+        "statWithIfNoneMatch uint8",
+        "statWithIfModifiedSince uint8",
+        "statWithIfUnmodifiedSince uint8",
+        "statWithOverrideCacheControl uint8",
+        "statWithOverrideContentDisposition uint8",
+        "statWithOverrideContentType uint8",
+        "statWithVersion uint8",
+        "read uint8",
+        "readWithIfMatch uint8",
+        "readWithIfNoneMatch uint8",
+        "readWithOverrideCacheControl uint8",
+        "readWithOverrideContentDisposition uint8",
+        "readWithOverrideContentType uint8",
+        "readWithIfModifiedSince uint8",
+        "readWithIfUnmodifiedSince uint8",
+        "readWithVersion uint8",
+        "write uint8",
+        "writeCanMulti uint8",
+        "writeCanEmpty uint8",
+        "writeCanAppend uint8",
+        "writeWithContentType uint8",
+        "writeWithContentDisposition uint8",
+        "writeWithContentEncoding uint8",
+        "writeWithCacheControl uint8",
+        "writeWithIfMatch uint8",
+        "writeWithIfNoneMatch uint8",
+        "writeWithIfNotExists uint8",
+        "writeWithUserMetadata uint8",
+        "writeMultiMaxSize uint",
+        "writeMultiMinSize uint",
+        "writeTotalMaxSize uint",
+        "createDir uint8",
+        "delete uint8",
+        "deleteWithVersion uint8",
+        "deleteWithRecursive uint8",
+        "copy uint8",
+        "copyWithIfNotExists uint8",
+        "copyWithIfMatch uint8",
+        "copyWithSourceVersion uint8",
+        "copyCanMulti uint8",
+        "copyMultiMaxSize uint",
+        "copyMultiMinSize uint",
+        "rename uint8",
+        "list uint8",
+        "listWithLimit uint8",
+        "listWithStartAfter uint8",
+        "listWithRecursive uint8",
+        "listWithVersions uint8",
+        "listWithDeleted uint8",
+        "presign uint8",
+        "presignRead uint8",
+        "presignStat uint8",
+        "presignWrite uint8",
+        "presignDelete uint8",
+        "shared uint8",
+    ];
+
+    fn workspace_dir() -> std::path::PathBuf {
+        Path::new(env!("CARGO_MANIFEST_DIR")).join("..")
+    }
+
+    fn core_fields() -> Vec<capability::CapabilityField> {
+        
capability::parse(&workspace_dir().join("core/core/src/types/capability.rs"))
+            .expect("parse core capability")
+    }
+
+    fn rendered(path: &str) -> String {
+        render_capability(&workspace_dir())
+            .unwrap()
+            .into_iter()
+            .find(|(relative, _)| *relative == path)
+            .map(|(_, content)| content)
+            .expect("rendered output")
+    }
+
+    /// Field declarations of the struct opened by `open`, without Rust's
+    /// `pub` and trailing comma and with whitespace collapsed.
+    fn struct_fields(source: &str, open: &str) -> Vec<String> {
+        let body = source.split_once(open).expect("struct start").1;
+        let body = body.split_once("\n}").expect("struct end").0;
+        body.lines()
+            .map(str::trim)
+            .filter(|line| !line.is_empty() && !line.starts_with("//"))
+            .map(|line| {
+                line.trim_start_matches("pub ")
+                    .trim_end_matches(',')
+                    .split_whitespace()
+                    .collect::<Vec<_>>()
+                    .join(" ")
+            })
+            .collect()
+    }
+
+    #[test]
+    fn test_rendered_capability_keeps_released_prefix() {
+        let c = struct_fields(
+            &rendered("bindings/c/src/capability.rs"),
+            "pub struct opendal_capability {",
+        );
+        let go = struct_fields(
+            &rendered("bindings/go/capability.go"),
+            "type opendalCapability struct {",
+        );
+        assert_eq!(c[..RELEASED_C_FIELDS.len()], RELEASED_C_FIELDS);
+        assert_eq!(go[..RELEASED_GO_FIELDS.len()], RELEASED_GO_FIELDS);
+        assert_eq!(c.len(), core_fields().len());
+        assert_eq!(go.len(), c.len());
+    }
+
+    #[test]
+    fn test_frozen_order_rejects_unlisted_core_field() {
+        let mut fields = core_fields();
+        fields.insert(
+            fields.len() / 2,
+            capability::CapabilityField {
+                name: "new_mid".to_string(),
+                is_bool: true,
+                doc: String::new(),
+            },
+        );
+        let err = frozen_order(fields).unwrap_err().to_string();
+        assert!(
+            err.contains("`new_mid` must be appended to 
FROZEN_CAPABILITY_ORDER"),
+            "{err}"
+        );
+    }
+
+    #[test]
+    fn test_frozen_order_rejects_missing_frozen_field() {
+        let mut fields = core_fields();
+        fields.retain(|f| f.name != "read");
+        let err = frozen_order(fields).unwrap_err().to_string();
+        assert!(err.contains("`read` is missing from core"), "{err}");
+    }
+
     #[test]
     fn test_go_names() {
         assert_eq!(to_pascal("write_multi_max_size"), "WriteMultiMaxSize");

Reply via email to