RFC-7740: Operator Composition#7740
Merged
Merged
Conversation
PsiACE
approved these changes
Jun 12, 2026
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.
I made some very important changes during the early stage of OpenDAL, especially the design of the current
Accesstrait. Unfortunately, those design decisions based on wrong results because I was using anAMD Ryzen 9 5950Xat the time, and it was affected by a bug I later discovered via https://xuanwo.io/2023/04-rust-std-fs-slower-than-python/. This means I overestimated the cost of the vtable and indirect calls.However, when I found the bug, we had already moved too far forward. We had to keep going and had no way to turn back.
Now, thanks to all the AI tools, we have a chance to correct this design and build a new solid foundation for OpenDAL to move forward.
This new design will make OpenDAL more scalable, with no need to play with Rust type systems. It will also allow OpenDAL to build a stable ABI so that we can link to the same dynlib. Furthermore, it will allow languages like Python to split packages instead of bundling all services and layers into one.
OpenDAL is still new, let's rock!
Which issue does this PR close?
N/A.
Tracking issue: #7741.
Rationale for this change
OpenDAL's composition model has accumulated several structural problems that share one root:
Access+AccessDyn, five*Dynop-body traits) bridged byTypeEraseLayer, while everyOperatorcall already goes throughArc<dyn AccessDyn>.AccessorInfofor the HTTP client, executor, and capability. The imperativeupdate_*API erases composition history, which produces real defects today:HttpClientLayersilently destroys HTTP instrumentation depending on layer order,op.clone().layer(...)leaks context mutations back into the original operator (the Java binding hits this path), double-applied layers have undefined context semantics, andset_native_capabilitycan silently drop capability transforms.This RFC proposes rebuilding the composition model in one shot: an object-safe
Servicetrait (renamingAccess), a hook-based object-safeLayer, anOperatorthat holds base providers plus a layer list and replays the composition on every mutation, and an explicitServiceContextparameter on every operation method. All mutable shared state, the dual-trait machinery,OperatorBuilder, andfinish()are deleted.What changes are included in this PR?
A new RFC document
core/core/src/docs/rfcs/7740_operator_composition.md, registered in the rustdoc RFC index.Are there any user-facing changes?
None in this PR itself. The proposed design is a major breaking change to the raw API; the impact and migration story are detailed in the RFC's Drawbacks and "No compatibility logic" sections.
AI Usage Statement
This RFC was drafted with Claude Code (claude-fable-5) under the author's direction; the design and all decisions in it are the author's.