Repository navigation
feat(bindings/ocaml): generate Metadata from core - #9132
Draft
chitralverma wants to merge 1 commit into
Draft
chitralverma wants to merge 1 commit into
chitralverma wants to merge 1 commit into
Conversation
3 of 9 tasks
chitralverma
force-pushed
the
feat/generate-ocaml-metadata
branch
from
November 27, 2026 08:23
e0459a9 to
ae02bb1
Compare
Part of apache#9129. Signed-off-by: Chitral Verma <chitralverma@gmail.com>
chitralverma
force-pushed
the
feat/generate-ocaml-metadata
branch
from
November 27, 2026 09:06
ae02bb1 to
ac7ef02
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #9129.
Rationale for this change
The OCaml
Metadatamodule was hand-copied from core across the Rust FFI accessors (src/operator/metadata.rs) and the public module inlib/operator.ml{,i}. It exposed 8 accessors, so newer core fields such asversion,is_deleted, anduser_metadatawere missing. This PR generates it fromcore/core/src/types/metadata.rsusing the shared parser indev/src/generate/metadata.rs.What changes are included in this PR?
dev/src/generate/ocaml.rs+dev/src/generate/ocaml/metadata_*.j2: newgenerate -l ocamltarget that renders:bindings/ocaml/src/operator/metadata.rs: one#[ocaml::func]accessor per core accessor, plus theentry_modevariant.bindings/ocaml/lib/metadata.ml{,i}: the publicMetadatamodule, with odoc taken from core.checksumis not exposed: the shared parser skips it until bindings mirrorChecksum.is_fileandis_dirare skipped by the shared parser because core derives them frommode. The OCaml generator adds them back aftermodeso the existing API stays.lib/operator.ml{,i}:operator.mlaliases the generated module (module Metadata = Metadata), andoperator.mliexposes it structurally (module Metadata : module type of Metadata), soOperator.Metadata.*keeps working and downstream wrappers that re-includeMetadatastill matchmodule type of Opendal.Operator(the same fix as feat(bindings/ocaml): generate Capability from core #9128).test/test.mladds a compile-time regression check for such a wrapper.src/operator.ml{,i}: theexternaldeclarations are regenerated byocaml-buildduringdune build..ocamlformat-ignore: ignores the generatedlib/metadata.ml{,i}, the same as the existingsrc/**entry.ci_odev.ymlrunsgenerate -l ocamlandcargo fmtfor OCaml incheck_generated.ci_bindings_ocaml.ymlalso runs when core metadata or the generator changes, and checks for generated-code drift afterdune runtest.test/test.ml: assertsmodeandis_deletedfor a file and a directory.This overlaps with #9128 (OCaml
Capability), which addsdev/src/generate/ocaml.rs, registersocamlinmod.rs, and makes the same CI changes. Whichever lands second will need a small rebase to merge the twogeneratefunctions.Are there any user-facing changes?
Yes, additions only.
Operator.Metadatagains:mode : metadata -> entry_mode, whereentry_mode = File | Dir | Unknownmirrors coreEntryMode. A variant fits OCaml better than a string and is easy to match on.is_current : metadata -> bool optionandis_deleted : metadata -> bool.cache_control,content_encoding,content_language, andversion, allstring option.user_metadata : metadata -> (string * string) list option, an association list copied from core.Existing accessors keep their names, types, and behavior.
last_modifiedis stillint64 optionin seconds. Docs now come from core, so some doc strings changed wording.Breaking changes
None.
AI Usage Statement