Skip to content

test(proxy): integration tests for session correlation audit and header agreement#199

Open
SasSwart wants to merge 1 commit intosasswart/feat-proxy-inject-session-headersfrom
sasswart/test-session-correlation-integration
Open

test(proxy): integration tests for session correlation audit and header agreement#199
SasSwart wants to merge 1 commit intosasswart/feat-proxy-inject-session-headersfrom
sasswart/test-session-correlation-integration

Conversation

@SasSwart
Copy link
Copy Markdown
Contributor

@SasSwart SasSwart commented May 1, 2026

PR Map

  1. feat(audit): session ID generation, sequence counter, and BoundaryLog wiring #196
  2. feat(config): session correlation header injection configuration #197
  3. feat(proxy): inject session ID and sequence number headers on matching requests #198
  4. 👉🏼 This PR

RFC: Bridge ↔ Boundaries Correlation

Integration tests for session correlation, requested during review of #196. The existing unit tests in #198 verify header injection and audit capture independently; these tests verify both sides together across realistic multi-request scenarios.

Depends on #198.

Changes

  • proxy/proxy_session_correlation_integration_test.go: New test file with 8 integration tests and supporting helpers.

Test scenarios

Test What it verifies
LLMRequestAuditAndHeadersAgree Audit sequence number == forwarded header value on inject-target requests
NonLLMRequestAuditedWithoutHeaders Allowed non-inject-target requests are audited but carry no correlation headers
DeniedRequestAuditedNeverForwarded Denied requests consume a sequence number but are never forwarded
MixedRequestsSequenceOrdering Interleaved LLM, non-LLM, and denied requests advance the counter monotonically
SequenceGapRevealsAgenticLoop Gap between two LLM sequence numbers equals the count of intermediate tool-use requests
SpoofedHeadersOverwrittenWithCorrectSequence Client-supplied headers are replaced; audit event still agrees with header
DisabledCorrelationNoHeadersNoPreallocatedSequence Disabled correlation means no headers and no pre-allocated sequence number
ConcurrentRequestsUniqueSequenceNumbers 10 concurrent requests each get a unique, dense sequence number

Test helpers

  • multiRequestCapturingBackend: like the existing headerCapturingBackend but records headers from every request (not just the last), needed for multi-request scenarios.
  • sessionCorrelationIntegrationSetup: shared setup that wires a proxy with two httptest backends (LLM inject target + non-LLM), a capturingAuditor, and a shared SequenceCounter.

Note

This PR was authored by Coder Agents.

…er agreement

Add integration tests that verify the core invariants of session
correlation across the proxy, auditor, and forwarded request headers
working together. These tests fill the gap identified during review
of the session correlation PR stack (#196, #197, #198) where unit
tests verified each component in isolation but did not verify them
in concert.

New test file: proxy/proxy_session_correlation_integration_test.go

Tests added:
- LLMRequestAuditAndHeadersAgree: audit sequence number matches
  the forwarded header value on inject-target requests.
- NonLLMRequestAuditedWithoutHeaders: allowed non-inject-target
  requests are audited but carry no correlation headers.
- DeniedRequestAuditedNeverForwarded: denied requests consume a
  sequence number but are never forwarded.
- MixedRequestsSequenceOrdering: interleaved LLM, non-LLM, and
  denied requests all advance the counter monotonically.
- SequenceGapRevealsAgenticLoop: gap between two LLM sequence
  numbers precisely equals intermediate tool-use requests.
- SpoofedHeadersOverwrittenWithCorrectSequence: client-supplied
  headers are replaced and the audit event still agrees.
- DisabledCorrelationNoHeadersNoPreallocatedSequence: disabled
  correlation means no headers and no pre-allocated sequence.
- ConcurrentRequestsUniqueSequenceNumbers: concurrent requests
  each get a unique, dense sequence number.
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