feat: capture, persist, and strip Agent Firewall correlation headers in AI Bridge#26529
Draft
SasSwart wants to merge 1 commit into
Draft
Conversation
…in AI Bridge Wire the Agent Firewall correlation headers through the AI Bridge interception processor so that each interception is linked to its originating firewall session. Changes: - Add HeaderAgentFirewallSessionID and HeaderAgentFirewallSequenceNumber constants in coderd/aibridge. - Add AgentFirewallSessionID and AgentFirewallSequenceNumber fields to the recorder.InterceptionRecord struct. - Read and strip both headers in the interception processor (aibridge/bridge.go) before creating the interceptor, passing the values to RecordInterception. - Map the new fields through the dRPC translator to the proto request. - Strip Agent Firewall headers in PrepareClientHeaders as a safety net before upstream forwarding. - Add unit tests for header extraction, parsing edge cases, and the PrepareClientHeaders safety-net stripping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wire the Agent Firewall correlation headers (
X-Coder-Agent-Firewall-Session-IdandX-Coder-Agent-Firewall-Sequence-Number) through the AI Bridge interception processor so that each interception is linked to its originating firewall session.Closes https://linear.app/codercom/issue/AIGOV-259
Changes
Header constants (
coderd/aibridge/aibridge.go)HeaderAgentFirewallSessionIDandHeaderAgentFirewallSequenceNumberRecorder struct (
aibridge/recorder/types.go)AgentFirewallSessionID *stringandAgentFirewallSequenceNumber *int32onInterceptionRecordInterception processor (
aibridge/bridge.go)CreateInterceptorRecordInterceptionextractAgentFirewallHeadershelper parses the sequence number as int32, logs a warning on invalid inputdRPC translator (
coderd/aibridged/translator.go)RecordInterceptionRequestprotoUpstream safety net (
aibridge/intercept/client_headers.go)PrepareClientHeadersas defense-in-depth before upstream forwardingTests
TestExtractAgentFirewallHeaders: parsing edge cases (both present, absent, zero, invalid, overflow)TestPrepareClientHeaders/agent_firewall_headers_are_removed: safety-net strippingNotes
RecordInterceptionRequest) and DB columns (aibridge_interceptions.agent_firewall_session_id,agent_firewall_sequence_number) were added in AIGOV-252 / AIGOV-260. This PR fills the gap between the HTTP layer and those lower layers.int32(notint64as the RFC originally proposed). This PR follows the implemented type.aibridged/http.go; they must flow through to the bridge layer where they are read and consumed. The safety-net strip inPrepareClientHeaderscatches any residual headers before the upstream SDK call.Implementation plan
See the AIGOV-259 plan for the full implementation plan and design decisions.
Prerequisite issues (both Done):
Data flow:
request header→bridge.goreads + strips →InterceptionRecord→translator.go→ protoRecordInterceptionRequest→aibridgedserver.go→ DB