Skip to content

refactor(logging): remove dead PII-masking knobs (LAB-3797) - #300

Open
27Bslash6 wants to merge 2 commits into
mainfrom
lab-3797-remove-dead-mask-sensitive-knobs
Open

27Bslash6 wants to merge 2 commits into
mainfrom
lab-3797-remove-dead-mask-sensitive-knobs

Conversation

@27Bslash6

@27Bslash6 27Bslash6 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR removes unused PII-masking configuration options from the logging and reliability profile modules, as indicated by the ticket LAB-3797.

Changes

Logging module (src/cachekit/logging.py)

  • Removed the mask_sensitive parameter from UltraOptimizedStructuredLogger.__init__ and the get_structured_logger factory function.
  • Simplified the logger instance cache to key solely on the logger name instead of a compound name:mask_sensitive key.
  • Deleted the unused mask_sensitive_patterns helper function (which masked SSNs, credit cards, emails, phone numbers, JWTs, and API keys) and the now-unused LONG_TOKEN_LENGTH_THRESHOLD constant.

Reliability profiles (src/cachekit/reliability/profiles.py)

  • Removed the mask_sensitive_data and lazy_pii_masking fields from ProfileConfig and all profile definitions (LOW_LATENCY, BALANCED, FULL).
  • Removed the _lazy_pii_masking entry from the optimized decorator config output.

Tests (tests/unit/test_structured_logging.py)

  • Removed the entire TestSensitiveDataMasking test class covering the deleted masking function.
  • Updated logger fixtures and tests to drop the mask_sensitive argument.
  • Updated the factory test to verify that get_structured_logger returns a single cached instance per name.

Secrets baseline (.secrets.baseline)

  • Removed baseline entries for the deleted test masking cases (base64 and JWT strings) and refreshed the generation timestamp.

Purpose

These masking knobs were dead code — the mask_sensitive/mask_sensitive_data/lazy_pii_masking flags were carried through configuration but not driving any active masking behavior in the logging path. Sensitive cache keys are already redacted unconditionally via redact_cache_key (as confirmed by the retained test_cache_key_always_redacted test). Removing these unused options simplifies the logging configuration surface and reduces maintenance overhead.


Based on the code changes, here's the pull request description:

Description

This PR updates the documentation string for the UltraOptimizedStructuredLogger class to accurately reflect its PII-masking behavior.

Changes

The docstring feature description was changed from the vague "Smart PII masking" to the more precise "PII key-name masking (password/token/secret/key/auth kwargs)".

Purpose

As indicated by the PR title (refactor(logging): remove dead PII-masking knobs), this change is part of a broader effort to remove dead/unused PII-masking configuration options. This docstring update clarifies that the logger only performs key-name-based masking on specific sensitive keyword arguments (such as password, token, secret, key, and auth), rather than implying more sophisticated "smart" masking capabilities that may no longer exist or were never fully implemented.

This makes the documentation align with the actual behavior of the logger, reducing potential confusion for developers about what masking is actually provided.

UltraOptimizedStructuredLogger.mask_sensitive, get_structured_logger's
mask_sensitive param, mask_sensitive_patterns, and
ProfileConfig.mask_sensitive_data/lazy_pii_masking toggled no behavior
after #264 replaced pattern-based key masking with blake2b digest
redaction. Left in place, they read as working PII controls to callers
setting mask_sensitive=False to see raw keys, or trusting True to
scrub SSN/email patterns from logs — neither happened.

BREAKING CHANGE: UltraOptimizedStructuredLogger.__init__ no longer
accepts mask_sensitive; get_structured_logger() no longer accepts
mask_sensitive and now keys _logger_instances on name alone;
mask_sensitive_patterns is removed; ProfileConfig.mask_sensitive_data
and ProfileConfig.lazy_pii_masking are removed. All were read by
nothing and toggled no behavior. Constructors/callers passing them now
raise TypeError instead of silently no-op'ing. Same removal shape as
L1CacheConfig.namespace_index in v0.18.0 and
L1CacheConfig.invalidation_enabled in v0.16.0 (LAB-520).
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 81 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 5fb0629d-6da8-4aef-8188-fd3028704f5a

📥 Commits

Reviewing files that changed from the base of the PR and between 81f97fb and 9fc273d.

📒 Files selected for processing (4)
  • .secrets.baseline
  • src/cachekit/logging.py
  • src/cachekit/reliability/profiles.py
  • tests/unit/test_structured_logging.py

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

@kodus-27b

This comment has been minimized.

Comment thread src/cachekit/logging.py
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/cachekit/logging.py 85.71% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

…-3797)

UltraOptimizedStructuredLogger's docstring still listed "Smart PII
masking" as a feature after this branch deleted the regex-pattern
masking it described. The surviving _mask_pii/_pii_keys mechanism is a
blunt keyword-name filter, not pattern-based masking — reword to match
what's actually left.
@kodus-27b

kodus-27b Bot commented Sep 17, 2026

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@27Bslash6

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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