Skip to content

inspect: Add the ability for wrappers to inherit sensitivity#2816

Open
smalis-msft wants to merge 2 commits intomicrosoft:mainfrom
smalis-msft:inspect-inherit-sens
Open

inspect: Add the ability for wrappers to inherit sensitivity#2816
smalis-msft wants to merge 2 commits intomicrosoft:mainfrom
smalis-msft:inspect-inherit-sens

Conversation

@smalis-msft
Copy link
Contributor

@smalis-msft smalis-msft commented Feb 18, 2026

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 of req.respond.

Any third-party wrapper structs would need to be updated on their own, this inheritance is not automatic.

@smalis-msft smalis-msft requested a review from a team as a code owner February 18, 2026 20:17
Copilot AI review requested due to automatic review settings February 18, 2026 20:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RequestParams with parent_sensitivity and 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.

#[derive(Inspect)]
struct Qux {
#[inspect(safe)]
a: u32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to add a third level, to make sure that any children of Qux with unspecified sensitivity are still hidden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this definitely should have more tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants