Skip to content

fix(weave): preserve typed message fields during PII redaction - #7699

Draft
ash0ts wants to merge 1 commit into
masterfrom
codex/hivemind-review-uri-pii
Draft

fix(weave): preserve typed message fields during PII redaction#7699
ash0ts wants to merge 1 commit into
masterfrom
codex/hivemind-review-uri-pii

Conversation

@ash0ts

@ash0ts ash0ts commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Why

I hit this while testing a private HiveMind chat review mirror with redact_pii=True.

The Conversation SDK currently serializes each typed Message, recursively sends every string through Presidio, and then validates the result back into the typed model. That means a false positive on a protocol value can corrupt the payload before any span is emitted. In the concrete failure, Presidio classified the literal "uri" discriminator from UriPart.type as a person name, changed it to "<PERSON>", and Pydantic rejected the message union.

This makes URI-backed conversation content impossible to log with PII redaction enabled, even when the URI itself contains no sensitive text.

What changed

  • Walk typed message parts directly instead of redacting a dumped protocol object.
  • Preserve roles, union discriminators, IDs, MIME/modality metadata, blobs, file references, and URIs byte-for-byte.
  • Continue using the same configured Presidio engines for user-authored text:
    • flat message content;
    • text and reasoning parts;
    • tool-call arguments; and
    • tool-call responses.
  • Keep configured field-name redaction behavior for those textual payload fields.
  • Add a regression where the fake analyzer deliberately marks the exact string "uri" as PII while also redacting an email in adjacent text. The resulting span must retain a valid UriPart and contain the redacted email.

Validation

  • 23 passed in tests/conversation/test_conversation_settings.py
  • Ruff lint passed
  • Ruff formatting check passed
  • git diff --check passed

This is a small companion fix for the review-mirror work in wandb/hivemind#8. It is independent of the proposed atomic historical-turn API and does not change OTLP delivery or idempotency semantics.

@ash0ts
ash0ts force-pushed the codex/hivemind-review-uri-pii branch from 0b58f67 to 769456d Compare August 6, 2026 15:45
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.85714% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
weave/utils/pii_redaction.py 67.85% 6 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

ash0ts commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Post-rebase validation

I cleaned this draft onto current master; it now contains exactly one commit and changes three files. The current branch result is 27 passing conversation-settings tests, plus clean Ruff lint, Ruff format, and git diff --check.

The HiveMind review mirror consumes the same fix on its combined pinned companion commit because it also needs the separate no-create initialization capability.

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.

1 participant