Add privacy-preserving JSONL RPC message logger#173
Conversation
- Created jsonl_logger.go with JSONLLogger implementation - Logs all RPC messages to rpc-messages.jsonl in JSONL format - Privacy-preserving: sanitizes secrets in JSON payloads - Supports nested structures and arrays - Comprehensive test coverage in jsonl_logger_test.go - Integrated with existing RPC logging (LogRPCRequest/Response) - Initialized in root.go alongside other loggers Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot format, lint |
- Removed complex recursive sanitization logic - Now applies regex patterns directly to the entire JSON string - Added JSON-specific regex pattern for field:value pairs - Simpler, more efficient implementation as suggested - All tests pass including new JSON-specific sanitization Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done! Simplified to apply regex patterns directly to the entire JSON payload string in one shot. Removed the complex recursive traversal logic and added a JSON-specific regex pattern for |
Done! |
- Convert if-else chain to tagged switch statement in jsonl_logger_test.go - Addresses QF1003 staticcheck warning - All tests pass, golangci-lint clean Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed! Converted if-else chain to switch statement to address staticcheck QF1003 warning. golangci-lint now passes with 0 issues. (commit 44d349d) |
|
@copilot regex the entire string, regardless of JSON in one run. |
- Changed Payload field to json.RawMessage (stores raw sanitized bytes) - Apply regex sanitization directly to entire string without parsing - No intermediate JSON unmarshaling/marshaling for valid JSON - Invalid JSON wrapped in error object for valid JSONL output - More efficient: single regex pass on raw string - All tests updated and passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done! Now applying regex to the entire string in one pass without any JSON parsing/unparsing. Changed Payload to |
| return json.RawMessage(wrappedBytes) | ||
| } | ||
|
|
||
| return json.RawMessage(sanitized) |
There was a problem hiding this comment.
@copilot Marshall, unmarshal to ensure single line JSON
There was a problem hiding this comment.
Done! Added marshal/unmarshal step to compact JSON and ensure single-line output for JSONL format compliance. Multi-line JSON is now compacted by unmarshaling to interface{} and marshaling back, removing all newlines/whitespace. Added test to verify. (commit 60d4bc5)
- Added marshal/unmarshal step to compact JSON (removes newlines/whitespace) - Ensures JSONL format compliance (one JSON object per line) - Added test for multi-line JSON compacting - All tests pass Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implementation: Privacy-Preserving JSONL RPC Message Logger
Summary
Successfully implemented a privacy-preserving JSONL RPC message logger with simplified regex-based sanitization and strict JSONL format compliance.
Implementation Complete
jsonl_logger.gowith simplified sanitizationjson.RawMessageroot.goalongside other loggersKey Changes
Simplified approach with JSONL compliance:
json.RawMessagefor efficiencyJSONL Format Compliance
Performance Benefits
File Locations
rpc-messages.jsonlin configured log directory/tmp/gh-aw/mcp-logs/rpc-messages.jsonlOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.