Xuanwo opened a new pull request, #8898:
URL: https://github.com/apache/opendal/pull/8898
# Which issue does this PR close?
Closes #8852.
# Rationale for this change
`CorrectnessCheckLayer` sat at the bottom of the default `Operator` stack
below user layers, adding an extra `Service` hop plus `CheckWrapper` around
`Deleter` and `Composer` while duplicating capability checks that already run
at the `Operator` boundary. Because the bottom layer checked the underlying
service's capability instead of the composed operator's effective capability,
`CapabilityOverrideLayer` could not enable capabilities (`=true`) without being
rejected below, and the two validation paths had already drifted apart (`copy`
metadata checks ran at `Operator` but not in `CorrectnessService::copy`).
Removing `CorrectnessCheckLayer` and consolidating capability validation
into `raw::ops` (`Op*::check` and `Op*::from_options`) gives a single source of
truth at the `Operator` boundary, keeps `RouteLayer` revalidating against each
target route's capability, and removes redundant manual option guards in layers
like `ImmutableIndexLayer`.
# What changes are included in this PR?
- Remove `pub(crate) CorrectnessCheckLayer`, `CorrectnessService`, and
`CheckWrapper` (`core/core/src/layers/correctness_check.rs`) and remove
`CorrectnessCheckLayer` from `Operator::from_builder`.
- Add public `Op*::check(&self, capability: &Capability) -> Result<()>`
methods on `OpStat`, `OpRead` (`check` and `check_compose_source`), `OpWrite`,
`OpDelete`, `OpList`, `OpCopy` (including copy metadata checks), `OpCompose`,
`OpRename`, `OpRestore`, and `OpPresign`.
- Fold capability validation into `Op*::from_options` across all
option-taking `Op*` types (`OpStat::from_options`, `OpRead::from_options`,
`OpRead::from_reader_options`, `OpRead::from_compose_source_options`,
`OpWrite::from_options`, `OpDelete::from_options`, `OpList::from_options`,
`OpCopy::from_options`, `OpCompose::from_options`, `OpRename::from_options`,
`OpRestore::from_options`), and route every `Operator`, `Deleter`, `Composer`,
`Writer::copy_from_options`, and `ReadContext::stat_content_length` entrypoint
through them.
- Add capability validation for `Operator::presign_stat*` and
`Operator::presign_read*` matching `stat` and `read`.
- Revalidate `Op*` arguments in `RouteLayer` (`RouteService` and
`RouteDeleter`) against each routed target service's capability via
`Op*::check`.
- Remove redundant manual `versions`/`deleted`/`glob` checks in
`ImmutableIndexLayer` (`ImmutableIndexService::list`).
- Document the `raw::Service`, `raw::Layer`, and `Op*::check` capability
validation contract in rustdoc.
- Relocate existing capability validation tests to
`core/core/src/types/operator/capability_tests.rs` and add regression suites
covering:
- `CapabilityOverrideLayer` enabling (`=true`) and restricting (`=false`)
capabilities on the default `Operator` stack.
- `RouteLayer` (`RouteService` and `RouteDeleter`) revalidating operations
against target route capabilities.
- `Writer::copy_from_options` rejecting unsupported read options.
- `presign_stat` and `presign_read` option capability validation.
- Update internal callers (`oss` batch deleter, `gcs` unit tests, and the
metadata benchmark) to construct `Op*` with appropriate capabilities.
# Are there any user-facing changes?
- **`presign_stat` and `presign_read` capability validation tightening:**
`Operator::presign_stat_with` / `presign_stat_options` and
`Operator::presign_read_with` / `presign_read_options` now validate version and
conditional options against `stat_with_*` and `read_with_*` capabilities before
calling the service, matching `stat`, `read`, `presign_write`, and
`presign_delete`. Callers passing options not advertised by the operator's
effective capability now receive `ErrorKind::Unsupported` instead of having the
request forwarded to the service.
- **`CapabilityOverrideLayer` `=true` overrides:** Enabling a capability
with `CapabilityOverrideLayer` on an operator constructed via `Operator::new`
now takes effect end-to-end instead of being rejected by a lower
`CorrectnessCheckLayer`.
- **Raw `Service` / `Op*::from_options` contract:**
`Op*::from_options(&capability, options)` now validates correctness-critical
options against `capability` and returns `ErrorKind::Unsupported` when required
capability flags are false. Callers driving `raw::Service` directly without
`Operator` do not receive automatic capability validation and can call
`Op*::check(&capability)` explicitly when needed.
# Breaking changes
# AI Usage Statement
- Harness: pi
- Model: Gemini 4 Neon
- Effort: High
- Role: Implemented the refactor, rustdoc updates, and regression tests
based on the approved Option A design for #8852.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]