inspect: Add the ability for wrappers to inherit sensitivity#2816
Open
smalis-msft wants to merge 2 commits intomicrosoft:mainfrom
Open
inspect: Add the ability for wrappers to inherit sensitivity#2816smalis-msft wants to merge 2 commits intomicrosoft:mainfrom
smalis-msft wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds sensitivity inheritance support for inspect “wrapper” helpers (notably iter_by_index/iter_by_key) by threading the current node’s sensitivity through request parameters so wrappers can apply it to synthesized child fields.
Changes:
- Extend
RequestParamswithparent_sensitivityand propagate it through request creation (including deferred inspection). - Expose
Response::parent_sensitivity()for wrappers to inherit sensitivity when emitting child fields. - Update
Iterated(iter_by_key/iter_by_index) to apply inherited sensitivity; add a regression test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| support/inspect/src/lib.rs | Track and expose inherited sensitivity; apply it in Iterated; add test. |
| support/inspect/src/initiate.rs | Initialize parent_sensitivity for root-built requests. |
| support/inspect/src/defer.rs | Preserve parent_sensitivity across deferred inspections. |
sluck-msft
reviewed
Feb 18, 2026
| #[derive(Inspect)] | ||
| struct Qux { | ||
| #[inspect(safe)] | ||
| a: u32, |
Contributor
There was a problem hiding this comment.
Do you want to add a third level, to make sure that any children of Qux with unspecified sensitivity are still hidden?
Contributor
Author
There was a problem hiding this comment.
Yeah this definitely should have more tests
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.
Certain inspect helper wrappers, like iter_by_index, previously had no way to set the sensitivity levels of the multiple child fields they would be synthesizing. This meant that we could set the sensitivity of a Vec, but we could not affect any of the contents of the Vec, making this ability effectively worthless. This PR adds tracking of the parent node's sensitivity level to RequestParams, allowing these wrappers to inherit the sensitivity of their parent when creating their children. This allows for something like
#[inspect(safe, iter_by_index)]to work as a consumer would likely expect.Other simpler wrappers, like AsHex, AsDebug, etc, are not affected by this limitation due to calling
req.value, instead ofreq.respond.Any third-party wrapper structs would need to be updated on their own, this inheritance is not automatic.