Skip to content

Conversation

@jorgecuesta
Copy link
Contributor

Summary

  • Add qos/heuristic package for tiered response analysis to detect errors in response payloads without full JSON parsing
  • Fix backend 5xx reputation bug where successful relay with backend 5xx was recording "ok" reputation signal
  • Wire heuristic detection to reputation system so payload errors affect endpoint scores

Changes

Heuristic Response Analysis (qos/heuristic/)

New package with tiered analysis approach:

  • Tier 1 - Structural: Empty responses, HTML error pages, XML, non-JSON, malformed JSON (~224ns)
  • Tier 2 - Protocol: JSON-RPC result vs error field detection, REST error patterns
  • Tier 3 - Indicators: Blockchain-specific errors, rate limits, connection errors, auth failures

Backend 5xx Reputation Fix (protocol/shannon/context.go)

  • handleEndpointSuccess now checks endpointResponse.HTTPStatusCode
  • Backend 5xx records CriticalErrorSignal (-25) instead of success (+1)
  • 4xx errors NOT penalized (often user's fault - bad requests, auth issues)

Gateway Heuristic-to-Reputation Integration (gateway/http_request_context_handle_request.go)

  • checkResponseSuccess() returns heuristic result alongside success status
  • recordHeuristicErrorToReputation() records correcting signals when heuristic detects payload errors
  • High confidence (≥95%): MajorError (-10)
  • Lower confidence: MinorError (-3)

Cleanup

  • Removed unused hydrateLogger and hydrateLoggerWithPayload functions

Test plan

  • All unit tests pass
  • Linter passes
  • Deploy to staging and verify:
    • Backend 5xx responses show critical_error reputation signal in metrics
    • Heuristic-detected errors show major_error or minor_error in metrics
    • Dashboard Mean Score correlates with Success %

- Add qos/heuristic package for tiered response analysis:
  - Tier 1: Structural checks (empty, HTML, XML, non-JSON, malformed)
  - Tier 2: Protocol-specific analysis (JSON-RPC result vs error fields)
  - Tier 3: Error pattern detection (blockchain-specific, rate limits, etc.)

- Fix backend 5xx reputation bug in protocol/shannon/context.go:
  - Backend 5xx responses now record CriticalErrorSignal (-25) instead of success
  - 4xx errors not penalized (often user's fault)

- Wire heuristic detection to reputation in gateway:
  - When heuristic detects payload error despite HTTP 200, record correcting signal
  - High confidence errors: MajorError (-10)
  - Lower confidence errors: MinorError (-3)

- Cleanup: Remove unused hydrateLogger and hydrateLoggerWithPayload functions
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