TCGA-A6-1234_patientX.svs). Before any log line, manifest, or bundle component leaves the customer environment it is passed through this module. By default every recognized field (ANONYMIZED_FIELDS) is replaced by a stable hash, so a given slide keeps a consistent pseudonym across every artifact and “which slide failed” correlation survives. The digest is unsalted and truncated by design, so this is pseudonymization for support triage, not cryptographic anonymity: a party who can enumerate the identifier space can confirm a value (see ADR-005). The per-field policy is configurable via AnonymizationConfig: a field can instead be redacted entirely or kept verbatim. Paths and URIs embedded in free text are always redacted. Nothing is ever transmitted automatically — the helpers only rewrite values in place.
Entry points:
AnonymizationConfig, the policy controlling each field’sStrategy(DEFAULT_CONFIGhashes every recognized field);AnonymizingFilter, alogging.Filterthat scrubs log records in place; and- the pure helpers
hash_identifier,redact_text,scrub_user_paths,anonymize_value, andanonymize_mapping, reused by the support-bundle builder to scrub files on disk.
REDACTION_MARKER
Replacement token substituted for every redacted value.USER_PATH_MARKER
Placeholder substituted for the user name in a home-directory path, so a diagnostic path keeps its structure (for example.venv/bin/python3) without exposing whose account it is.
HASH_PREFIX
Prefix marking a value that has been replaced by a one-way hash pseudonym.HASH_FIELDS
Identifier fields that act as correlation keys. Hashing (rather than redacting) these preserves the “which slide failed” link across every log line, manifest, and ledger entry without directly exposing the underlying identity (though the unsalted, truncated hash is pseudonymization, not cryptographic anonymity).PII_FIELDS
Path-like fields. Their values embed directory structure and user names beyond the bare identity; hashing keeps them correlatable while removing the layout. Configure them toStrategy.REDACT to drop them instead.
ANONYMIZED_FIELDS
Every field anonymized by default. Each is hashed unless anAnonymizationConfig override selects a different strategy.
Strategy
HASH
Replace with a stable one-way hash, preserving cross-artifact correlation.REDACT
Replace withREDACTION_MARKER, removing the value entirely.
KEEP
Keep verbatim; only embedded paths, URIs, and user names are scrubbed.AnonymizationConfig
default strategy applies to every field in ANONYMIZED_FIELDS; overrides selects a different strategy for named fields. DEFAULT_CONFIG hashes every recognized field, so all identifiers and paths become stable pseudonyms while remaining correlatable.
Attributes:
default- Strategy applied to recognized fields without an override.overrides- Field-name to strategy mapping that wins overdefault.
strategy_for
key.
The field name being anonymized.
key if one exists, the default strategy for
any recognized field, otherwise Strategy.KEEP.
DEFAULT_CONFIG
Default policy: hash every recognized field.redact_text
s3:///file:// URIs, with REDACTION_MARKER. Non-matching text is returned unchanged.
Arbitrary text that may embed slide paths or file names.
scrub_user_paths
/home/<name> or /Users/<name> path with USER_PATH_MARKER, leaving the rest of the path intact so its diagnostic value (for example a virtual-environment or project layout) survives. /root and paths outside a home directory are left unchanged.
Arbitrary text that may embed home-directory paths, for example an interpreter path or a temp-directory location.
hash_identifier
HASH_PREFIX followed by the leading digest characters. Values that already match the SDK pseudonym shape are returned unchanged, making anonymization idempotent when logs were redacted at emission and again at export. The result is deterministic, so the same identifier maps to the same pseudonym across every log line and bundle artifact, preserving the “which slide failed” correlation. The digest is unsalted and truncated by design (stable pseudonyms, short log lines), so it is pseudonymization for support triage, not cryptographic anonymity: a party who can enumerate the identifier space can confirm a value (see ADR-005).
The identifier to pseudonymize, for example a slide or patient ID. Non-string values are hashed by their
str form."sha256:<hex>".
anonymize_value
key is resolved from config: a recognized field is hashed (hash_identifier) or redacted, and a kept field keeps its value with embedded slide paths, absolute paths, URIs, and home-directory user names scrubbed. A None value is never hashed.
The field name associated with
value.The field value to inspect.
The anonymization policy. Defaults to
DEFAULT_CONFIG, which hashes every recognized field.anonymize_mapping
anonymize_value to every entry, recursing into nested mappings and sequences. The input is not mutated.
The mapping to anonymize, for example a manifest or ledger.
The anonymization policy. Defaults to
DEFAULT_CONFIG.AnonymizingFilter
bioptimus.observability.logging.log_event, the record message, and any positional message arguments, so PII never reaches a handler’s formatter. Recognized fields are hashed or redacted per the configured AnonymizationConfig. The filter always returns True — it never drops records.
filter
The log record to scrub. It is mutated in place.
True always, so the record continues through the handler.
