proxy: add redacted diagnostics #37

Merged
wmc merged 1 commit from codex/structured-proxy-diagnostics into main 2026-06-23 09:24:17 +00:00
Owner

Summary

  • Add bounded, redacted in-memory proxy diagnostic events for parser, routing/auth, upstream status, upstream transport, invalid upstream body, and streaming conversion failures.
  • Keep only the latest 20 diagnostics in AppStore and surface the latest safe summary through the proxy status help text.
  • Document diagnostic privacy boundaries in README and update TODO with the completed slice plus coverage follow-up.

Security notes

  • Diagnostics use canned messages and sanitized metadata only: category, optional safe provider ID, allowlisted method, canonical path, and optional status code.
  • Unknown provider paths, query strings, headers, bearer tokens, upstream URLs, request bodies, upstream response bodies, and raw error descriptions are not retained.
  • Streaming diagnostics capture a pre-sanitized context, not the full HTTP request.

Verification

  • RED: focused diagnostic tests initially failed before implementation because ProxyDiagnosticEvent/onDiagnosticEvent/AppStore diagnostic history did not exist.
  • RED: malformed request parser diagnostic test initially timed out before parser diagnostics were emitted.
  • DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcodebuild test -project CodexModelSwitcher.xcodeproj -scheme CodexModelSwitcher -configuration Debug -destination platform=macOS -derivedDataPath /tmp/CodexModelSwitcher-DerivedData-diagnostics-coverage CODE_SIGNING_ALLOWED=NO -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyEmitsDiagnosticsForParserLimitAndFramingFailures -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyStreamingTruncatedUpstreamFrameEmitsSanitizedFailureEvent -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyStreamingOversizedUpstreamFrameEmitsSanitizedFailureEvent -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyStreamingUpstreamTransportErrorEmitsSanitizedFailureEvent -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyRedactsUnconvertibleSuccessUpstreamResponseBody
  • DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcodebuild test -project CodexModelSwitcher.xcodeproj -scheme CodexModelSwitcher -configuration Debug -destination platform=macOS -derivedDataPath /tmp/CodexModelSwitcher-DerivedData-diagnostics-proxy-final CODE_SIGNING_ALLOWED=NO -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests
  • DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcodebuild test -project CodexModelSwitcher.xcodeproj -scheme CodexModelSwitcher -configuration Debug -destination platform=macOS -derivedDataPath /tmp/CodexModelSwitcher-DerivedData-diagnostics-appstore-final CODE_SIGNING_ALLOWED=NO -only-testing:CodexModelSwitcherTests/AppStoreTests
  • DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer scripts/verify.sh
  • git diff --check
  • Subagent review: initial High/Medium sanitization/request-retention/callback findings fixed; follow-up Important coverage finding fixed; final re-review found no Critical or Important blockers.
## Summary - Add bounded, redacted in-memory proxy diagnostic events for parser, routing/auth, upstream status, upstream transport, invalid upstream body, and streaming conversion failures. - Keep only the latest 20 diagnostics in AppStore and surface the latest safe summary through the proxy status help text. - Document diagnostic privacy boundaries in README and update TODO with the completed slice plus coverage follow-up. ## Security notes - Diagnostics use canned messages and sanitized metadata only: category, optional safe provider ID, allowlisted method, canonical path, and optional status code. - Unknown provider paths, query strings, headers, bearer tokens, upstream URLs, request bodies, upstream response bodies, and raw error descriptions are not retained. - Streaming diagnostics capture a pre-sanitized context, not the full HTTP request. ## Verification - RED: focused diagnostic tests initially failed before implementation because ProxyDiagnosticEvent/onDiagnosticEvent/AppStore diagnostic history did not exist. - RED: malformed request parser diagnostic test initially timed out before parser diagnostics were emitted. - `DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcodebuild test -project CodexModelSwitcher.xcodeproj -scheme CodexModelSwitcher -configuration Debug -destination platform=macOS -derivedDataPath /tmp/CodexModelSwitcher-DerivedData-diagnostics-coverage CODE_SIGNING_ALLOWED=NO -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyEmitsDiagnosticsForParserLimitAndFramingFailures -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyStreamingTruncatedUpstreamFrameEmitsSanitizedFailureEvent -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyStreamingOversizedUpstreamFrameEmitsSanitizedFailureEvent -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyStreamingUpstreamTransportErrorEmitsSanitizedFailureEvent -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests/testProxyRedactsUnconvertibleSuccessUpstreamResponseBody` - `DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcodebuild test -project CodexModelSwitcher.xcodeproj -scheme CodexModelSwitcher -configuration Debug -destination platform=macOS -derivedDataPath /tmp/CodexModelSwitcher-DerivedData-diagnostics-proxy-final CODE_SIGNING_ALLOWED=NO -only-testing:CodexModelSwitcherTests/CompatibilityProxyServerTests` - `DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcodebuild test -project CodexModelSwitcher.xcodeproj -scheme CodexModelSwitcher -configuration Debug -destination platform=macOS -derivedDataPath /tmp/CodexModelSwitcher-DerivedData-diagnostics-appstore-final CODE_SIGNING_ALLOWED=NO -only-testing:CodexModelSwitcherTests/AppStoreTests` - `DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer scripts/verify.sh` - `git diff --check` - Subagent review: initial High/Medium sanitization/request-retention/callback findings fixed; follow-up Important coverage finding fixed; final re-review found no Critical or Important blockers.
wmc merged commit cf20808009 into main 2026-06-23 09:24:17 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
wmc/CodexModelSwitcher!37
No description provided.