feat: add network calls summary to AI session threads API - #27417
Conversation
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
a4d26be to
8959a08
Compare
SasSwart
left a comment
There was a problem hiding this comment.
Self review complete. Mostly explanation but there are a some nits and an rbac change that need to happen.
| -- Strip an optional scheme, then keep the host up to the first port, path, | ||
| -- query, or fragment delimiter. This assumes HTTP egress detail is a plain | ||
| -- scheme+host(+port) URL: it does not handle userinfo (user@host, which | ||
| -- would be captured into the host) or IPv6 literal hosts ([::1], where the | ||
| -- leading '[' is captured and the ':' terminates early). Boundary HTTP logs | ||
| -- do not currently emit those forms; revisit this extraction if they do. | ||
| SELECT substring(detail from '^(?:[A-Za-z][A-Za-z0-9+.-]*://)?([^/:?#]+)') AS domain | ||
| FROM session_boundary_logs |
There was a problem hiding this comment.
I don't like this at all. It's brittle and the use of regex here is a crutch for a weak data model. Nevertheless, I'm following @mtojek's advice and accepting that this is good enough for the immediate release and can be improved later.
There was a problem hiding this comment.
Add a follow-up issue for later 👍
| // NetworkCalls summarizes the Agent Firewall network calls made during the | ||
| // session. A nil value means the session did not pass through Agent | ||
| // Firewall, so network call monitoring was not active, which the UI | ||
| // surfaces as "Disabled". |
| } | ||
|
|
||
| func (q *querier) GetAIBridgeSessionTopDomains(ctx context.Context, arg database.GetAIBridgeSessionTopDomainsParams) ([]database.GetAIBridgeSessionTopDomainsRow, error) { | ||
| if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceAibridgeInterception); err != nil { |
There was a problem hiding this comment.
This is incorrect. It should use the resources defined for agent firewall instead.
Expose total and blocked network calls plus top destination domains on the AI session threads endpoint. Total and blocked reuse the existing Agent Firewall aggregation from the sessions list query; top domains are a new GetAIBridgeSessionTopDomains aggregation over boundary logs using the same interception-window correlation. Refs AIGOV-463 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…fetch Add multi-interception and shared-firewall-session tests asserting the network_calls summary total/blocked and top-domains counts partition correctly across consecutive windows and do not bleed across AI sessions that share one firewall session. Reduce the top-domains fetch to a single row, since the summary card renders only the most-contacted domain plus a "+N more" count derived from NetworkDomainCount (a window aggregate independent of the row cap). Document that the domain-extraction regex assumes scheme+host(+port) detail without userinfo or IPv6 literal hosts, and add a port-suffixed test row that pins host stripping. Refs AIGOV-463 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Cian Johnston <[email protected]>
63a4fff to
16d4f5d
Compare
Backend for the AI session network summary. Exposes total/blocked network calls and top destination domains on the session threads endpoint (
GET /api/v2/ai-gateway/sessions/{id}).Total and blocked reuse the existing Agent Firewall aggregation from the sessions list query, so the numbers match the sessions table. Top domains are a new server-side aggregation (
GetAIBridgeSessionTopDomains) over boundary logs, using the same interception-window correlation. There is no network-error state, matching the current data model.Frontend consuming these fields is in a separate stacked PR.
PR map (merge strictly bottom-up)
This change is a 4-PR stack. Each PR depends on all the ones below it, so merge in this exact order:
main)network_call_logs(base feat: show network request summary on AI session detail card #27418)Refs AIGOV-463
🤖 Generated with Claude Code