Skip to content

Conversation

@ilaborie
Copy link
Owner

Summary

  • Add JSONPath (RFC 9535) support for wildcard redaction patterns like $.items[*].id
  • Introduce trait-based Redactor API supporting static values and closures
  • Add RedactOptions for configurable behavior (e.g., allow_empty_match)
  • Add redact_remove() method to completely remove fields
  • Add mise coverage task using cargo-llvm-cov
  • Improve test coverage from 93.90% to 95.03%

Changes

Redaction Features

  • JSONPath wildcards: Redact all matching fields with patterns like $.users[*].id, $..timestamp
  • Closure support: Use |path, value| ... for dynamic, context-aware redaction
  • Path removal: New redact_remove() and redact_remove_with() methods
  • Empty match handling: RedactOptions { allow_empty_match: true } for optional fields

Developer Experience

  • New mise run coverage task for code coverage reports
  • Comprehensive documentation with examples in tutorial chapter 6

Test Coverage

  • 72 new unit tests across 4 files
  • call_parameters.rs: 81% → 100%
  • redaction/mod.rs: 63% → 96%
  • result.rs: 72% → 83%
  • test_server.rs: 75% → 88%

Test plan

  • All existing tests pass (cargo nextest run --all-features)
  • New redaction tests pass
  • Documentation examples compile
  • OpenAPI spec validates (mise spectral)
  • Code coverage improved

🤖 Generated with Claude Code

ilaborie and others added 5 commits December 20, 2025 09:14
This commit adds support for wildcard paths in the redaction feature,
allowing users to redact multiple values at once (e.g., all IDs in an array).

Key changes:
- Add `serde_json_path` dependency for JSONPath support
- Create `PathSelector` enum supporting both JSON Pointer and JSONPath
- Auto-detect syntax based on path prefix (`$` = JSONPath, `/` = Pointer)
- Add `RedactOptions` for configurable empty match behavior
- Add `redact_replace_with` and `redact_remove_with` methods
- Reorganize redaction code into `redaction/` folder

Example usage:
```rust
.redact_replace("$.observations[*].id", "stable-uuid")?
.redact_replace("$.observations[*].created_at", "2024-01-01T00:00:00Z")?
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Replace `redact_replace` method with unified `redact` method that accepts
any type implementing the `Redactor` trait:

- Static values: `&str`, `String`, `serde_json::Value`
- Closures: `Fn(&str, &Value) -> Value`

The closure receives both the path and current value, allowing for
path-aware transformations (e.g., extracting array indices) or
value-based transformations (ignore path with `_`).

Example usage:
```rust
// Static value
.redact("/id", "stable-uuid")?

// Closure for path-aware transformation
.redact("$.items[*].id", |path, _val| {
    let idx = path.split('/').nth(1).unwrap_or("0");
    json!(format!("id-{idx}"))
})?
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…documentation

- Update tutorial chapter_6.rs with:
  - Path syntax auto-detection explanation
  - JSONPath wildcards section with syntax table and examples
  - Function-based redaction section (index-aware and value-based)
  - RedactOptions section for optional fields
  - Updated key points summary

- Update lib.rs crate documentation with:
  - Path syntax overview
  - JSONPath wildcards example
  - Dynamic transformations with closures example
  - Redactor trait in See Also section

- Add closure-based example method to client.rs:
  - list_observations_with_indexed_ids() demonstrating index-aware IDs

- Add integration test for closure-based redaction:
  - test_closure_based_redaction_with_index verifying obs-0, obs-1, etc.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add a coverage task that uses cargo-llvm-cov with nextest as the test
runner. Runs with all features and supports extra args (--open, --html).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add 72 new unit tests across 4 files:

- call_parameters.rs: 18 tests for CallParameters methods (81% → 100%)
- result.rs: 23 tests for RawResult and RawBody (72% → 83%)
- redaction/mod.rs: 24 tests for RedactOptions and RedactionBuilder (63% → 96%)
- test_server.rs: 14 tests for HealthStatus and TestServerConfig (75% → 88%)

Total coverage improved from 93.90% to 95.03%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ilaborie ilaborie merged commit 13f60fe into main Dec 20, 2025
7 checks passed
@ilaborie ilaborie deleted the feat/explore_redaction_path branch December 20, 2025 10:42
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.

2 participants