Skip to content

enhancement(pii): allow bounded metric string attributes - #920

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
mnajafian-nv:feat/metric-string-attribute-allowlist
Aug 27, 2026
Merged

enhancement(pii): allow bounded metric string attributes#920
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
mnajafian-nv:feat/metric-string-attribute-allowlist

Conversation

@mnajafian-nv

@mnajafian-nv mnajafian-nv commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Overview

Allow the trajectory_context PII-redaction preset to preserve explicitly approved, bounded string values in typed metric attributes. All unlisted attributes and unexpected values remain redacted.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Add metric_string_attribute_allowlist to the built-in PII-redaction configuration.
  • Require exact, case-sensitive matches on both attribute name and value.
  • Evaluate string-array elements independently.
  • Keep the allowlist empty by default and restrict it to typed metric attributes.
  • Reject blank keys, empty value lists, blank values, duplicates, and use without the trajectory_context preset.
  • Document the configuration and add regressions covering validation, redaction boundaries, and serialization.

Validation:

  • cargo test -p nemo-relay-pii-redaction
  • cargo test -p nemo-relay-pii-redaction --features schema metric_string -- --nocapture
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all
  • just docs
  • uv run pre-commit run --all-files

Where should the reviewer start?

Start with crates/pii-redaction/src/trajectory.rs, where approved metric attribute values are preserved while all other strings remain redacted. Configuration and validation are in crates/pii-redaction/src/component.rs, with contract coverage in crates/pii-redaction/tests/unit/component_tests.rs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

N/A

Summary by CodeRabbit

  • New Features

    • Added an allowlist for preserving approved metric string attributes and values in the trajectory_context PII redaction preset.
    • Supports exact, case-sensitive matching for individual strings and string-array elements.
  • Bug Fixes

    • Added validation to reject malformed allowlists or use outside the supported preset.
  • Documentation

    • Documented configuration, defaults, matching behavior, and usage examples.

Signed-off-by: mnajafian-nv <mnajafian@nvidia.com>
@mnajafian-nv mnajafian-nv self-assigned this Aug 27, 2026
@mnajafian-nv
mnajafian-nv requested review from a team as code owners August 27, 2026 06:39
@github-actions github-actions Bot added size:M PR is medium Feature a new feature lang:rust PR changes/introduces Rust code labels Aug 27, 2026
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 4be7187d-c5ed-4edc-8754-6ba37ab95405

📥 Commits

Reviewing files that changed from the base of the PR and between a362f71 and 28e7d76.

📒 Files selected for processing (6)
  • crates/pii-redaction/README.md
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • docs/configure-plugins/pii-redaction/configuration.mdx

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: Rust / Test (macos-arm64)
  • GitHub Check: Rust / Test (linux-amd64)
  • GitHub Check: Rust / Test (windows-arm64)
  • GitHub Check: Rust / Test (windows-amd64)
  • GitHub Check: Rust / Test (linux-arm64)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (42)
Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

⚙️ CodeRabbit configuration file

Files:

  • docs/configure-plugins/pii-redaction/configuration.mdx
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • crates/pii-redaction/tests/unit/component_tests.rs
If a language surface changed, always run that language's test target even when

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
- [ ] Do all bindings expose the same logical knobs and semantics?

📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
**Run tests for every language affected by your changes.** If your change touches the core Rust crate, run tests across all bindings since they all depend on it.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Use title case consistently for technical documentation headings and table headers; avoid quotation marks, ampersands, and exclamation marks in headings, while preserving official product, event, research, and whitepaper title case.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-technical-docs.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
If any Rust code changed, always run `just test-rust`.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
In MDX files, top-of-file comments must use JSX comment delimiters:

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • docs/configure-plugins/pii-redaction/configuration.mdx
**Formatting**: `cargo fmt` (rustfmt defaults)

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
If any Rust code changed, also run `cargo fmt --all`.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Use `Json = serde_json::Value` in Rust-facing runtime APIs where the existing code expects JSON payloads.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
- [ ] Branch scope is coherent and reviewable

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Every commit in a pull request must include a Developer Certificate of Origin sign-off.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Format changed files with the language-native formatter before the final

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Keep NeMo Relay optional

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Tool execution callbacks and each execution-intercept `next` continuation

📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
All source files must include an SPDX license header.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Rust and Python SDKs expose every supported registration surface.

📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
6. **Validation**

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Use `test-ffi-surface`.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Relevant package or crate `README.md` files updated when examples or binding guidance changed

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • crates/pii-redaction/README.md
- [ ] Any Rust change ran `just test-rust`

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Keep stable public wrappers at the `scripts/` root in docs and examples. Reference namespaced helper paths only when documenting internal maintenance work.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
Prefer the documented public API, not internal shortcuts

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
Use the naming conventions appropriate to each language: Rust `snake_case`, C FFI exports prefixed `nemo_relay_`, Go `PascalCase`, Node.js `camelCase`, Python `snake_case`.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Follow binding naming conventions: Rust and Python `snake_case`, C FFI exports prefixed `nemo_relay_`, Go `PascalCase` for public APIs, Node.js `camelCase`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Use `just docs` for docs-site builds and `just docs-linkcheck` when links

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • docs/configure-plugins/pii-redaction/configuration.mdx
Run `just docs` when the docs site changed; `./scripts/build-docs.sh html` remains the compatibility wrapper

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Files:

  • docs/configure-plugins/pii-redaction/configuration.mdx
- [ ] SPDX license header on any new files

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
- Update docs and examples in the same branch.

📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • docs/configure-plugins/pii-redaction/configuration.mdx
  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Update docs and examples.

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Files:

  • docs/configure-plugins/pii-redaction/configuration.mdx
Always spell `NVIDIA` in all caps. Do not use `Nvidia`, `nvidia`, `nVidia`, `nVIDIA`, or `NV`.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

Files:

  • crates/pii-redaction/README.md
Link the first mention of a product name when the destination helps the reader.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

Files:

  • crates/pii-redaction/README.md
Spell `NVIDIA` in all caps. Do not use `Nvidia`, `nvidia`, or `NV`.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

Files:

  • crates/pii-redaction/README.md
For documentation-only changes, prefer `contribute-docs` plus targeted command checks.

📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)

Files:

  • docs/configure-plugins/pii-redaction/configuration.mdx
Format commands, code elements, expressions, package names, file names, and paths as inline code.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

Files:

  • crates/pii-redaction/README.md
MDX top-of-file SPDX comments must use {/* ... */} delimiters instead of HTML comment delimiters (Must-Fix)

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Files:

  • docs/configure-plugins/pii-redaction/configuration.mdx
Run `cargo fmt --all` for all FFI work since it is Rust work

📄 CodeRabbit inference engine (.agents/skills/test-ffi-surface/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
Run `cargo fmt --all` when Rust files are changed as part of Node work

📄 CodeRabbit inference engine (.agents/skills/test-node-binding/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
When Rust files changed as part of Go work, also run `cargo fmt --all`, `just test-rust`, and `cargo clippy --workspace --all-targets -- -D warnings`

📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)

Files:

  • crates/pii-redaction/src/builtin.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/src/component.rs
  • crates/pii-redaction/src/trajectory.rs
🔇 Additional comments (6)
crates/pii-redaction/src/component.rs (1)

6-6: LGTM!

Also applies to: 222-224, 240-240, 398-401, 670-670, 773-773, 972-987, 1107-1118, 1142-1173

crates/pii-redaction/src/builtin.rs (1)

26-26: LGTM!

Also applies to: 86-89, 115-128

crates/pii-redaction/src/trajectory.rs (1)

6-6: LGTM!

Also applies to: 58-75, 207-213, 229-293, 333-348

crates/pii-redaction/tests/unit/component_tests.rs (1)

204-218: LGTM!

Also applies to: 291-406, 419-432, 1364-1435, 1866-1870

crates/pii-redaction/README.md (1)

152-167: LGTM!

docs/configure-plugins/pii-redaction/configuration.mdx (1)

243-243: LGTM!

Also applies to: 271-297


Walkthrough

The trajectory preset now supports a validated metric string attribute allowlist. Exact allowlisted values are preserved in metric attributes and string arrays. Other strings remain redacted. Configuration and behavior tests and documentation were added.

Changes

Trajectory metric allowlist

Layer / File(s) Summary
Configuration contract and preset wiring
crates/pii-redaction/src/component.rs, crates/pii-redaction/src/builtin.rs
Adds the allowlist field, default, editor metadata, recognized configuration entries, validation rules, and trajectory preset wiring.
Metric value sanitization
crates/pii-redaction/src/trajectory.rs
Preserves exact allowlisted metric strings and array elements. Non-allowlisted strings are replaced.
Validation coverage and configuration documentation
crates/pii-redaction/tests/unit/component_tests.rs, crates/pii-redaction/README.md, docs/configure-plugins/pii-redaction/configuration.mdx
Tests defaults, serialization, invalid configurations, exact matching, and redaction behavior. Documentation describes case-sensitive matching and scope.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 28e7d

This change narrowly allows explicitly approved bounded metric string values while keeping other values redacted and the default allowlist empty; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant BuiltinBackendConfig
  participant TrajectorySanitizer
  participant MetricEnvelope
  BuiltinBackendConfig->>TrajectorySanitizer: pass metric_string_attribute_allowlist
  TrajectorySanitizer->>MetricEnvelope: sanitize metric attributes
  MetricEnvelope-->>TrajectorySanitizer: preserve exact allowlisted strings
  MetricEnvelope-->>TrajectorySanitizer: replace other strings
Loading

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Title check ❌ Error The title clearly describes the main change and meets the length and casing rules, but enhancement is not an allowed Conventional Commits type. Replace enhancement with an allowed type, such as feat: feat(pii): allow bounded metric string attributes
Docstring Coverage ⚠️ Warning Docstring coverage is 46.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 4 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description includes the required overview, confirmations, details, reviewer guidance, validation commands, and change scope. The Related Issues section uses N/A instead of an action keyword and…
Full details: Docstring Coverage

Explanation

Docstring coverage is 46.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 4 files. (2 skipped: 2 unsupported.)

Full details: Description check

Explanation

The description includes the required overview, confirmations, details, reviewer guidance, validation commands, and change scope. The Related Issues section uses N/A instead of an action keyword and issue reference, but the description is otherwise complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

@willkill07 willkill07 changed the title feat: allow bounded metric string attributes enhancement(pii): allow bounded metric string attributes Aug 27, 2026
@github-actions github-actions Bot added Improvement improvement to existing functionality and removed Feature a new feature labels Aug 27, 2026
@willkill07

Copy link
Copy Markdown
Member

/merge

@rapids-bot
rapids-bot Bot merged commit f4d084f into NVIDIA:main Aug 27, 2026
36 checks passed
@mnajafian-nv
mnajafian-nv deleted the feat/metric-string-attribute-allowlist branch August 27, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement improvement to existing functionality lang:rust PR changes/introduces Rust code size:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants