Skip to content

Split gateway_logs.go into concern-aligned files#26296

Merged
pelikhan merged 2 commits intomainfrom
copilot/split-gateway-logs-by-concern
Apr 14, 2026
Merged

Split gateway_logs.go into concern-aligned files#26296
pelikhan merged 2 commits intomainfrom
copilot/split-gateway-logs-by-concern

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

pkg/cli/gateway_logs.go had grown to 1,066 lines mixing types, RPC parsing, gateway log parsing, aggregation, and MCP extraction into a single file.

Split

File Lines Responsibility
gateway_logs_types.go 236 Structs, constants, isGuardPolicyErrorCode, guardPolicyReasonFromCode, getOrCreateServer/Tool
gateway_logs_rpc.go 381 parseRPCMessages, findRPCMessagesPath, buildToolCallsFromRPCMessages
gateway_logs_parsing.go 224 parseGatewayLogs, processGatewayLogEntry
gateway_logs_aggregation.go 54 calculateGatewayAggregates, buildGuardPolicySummary
gateway_logs_mcp.go 219 extractMCPToolUsageData + extracted helpers extractToolCallsFromGatewayLog, buildMCPSummaryStats
gateway_logs.go 9 Redirect comment + package declaration

extractMCPToolUsageData was lightly refactored to extract extractToolCallsFromGatewayLog and buildMCPSummaryStats as private helpers, keeping gateway_logs_mcp.go under 300 lines. No logic changes.

gateway_logs_rpc.go lands at 381 lines — slightly over the 300-line target — because buildToolCallsFromRPCMessages is substantive and belongs with its sibling RPC functions.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw GO111MODULE g_.a git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile /usr/bin/git 159673/b174/_pkggit wDwi/8TvZlM4P0nfrev-parse 159673/b174=> git (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ode_modules/.bin-lang=go1.25 GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name .js' --ignore-path .prettierigno--workflow GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE k/_temp/uv-pytho--limit GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --get remote.origin.url /usr/bin/git o actions/setup-git GO111MODULE 64/pkg/tool/linu--show-toplevel /usr/bin/git remo�� -v 64/pkg/tool/linufeature-branch /usr/bin/git _.a GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha e: ${{ secrets.TOKEN }} /home/REDACTED/go/pkg/mod/golang.org/x/oauth2@v0.3--json /usr/bin/infocmp -json GO111MODULE 64/bin/go infocmp -1 xterm-color go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile -json GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha g_.a b-AbBFuh- ache/go/1.25.8/x64/pkg/tool/linu-buildmode=exe GOINSECURE util GOMODCACHE ache/go/1.25.8/xrepos/{owner}/{repo}/actions/runs/12345/artifacts env EklR7_A7a GO111MODULE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE l/buffer GOMODCACHE ortcfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel 64/pkg/tool/linu/home/REDACTED/work/gh-aw/gh-aw/pkg/timeutil/format_test.go /usr/bin/git _.a GO111MODULE ntdrain.test git rev-�� --show-toplevel ntdrain.test /usr/bin/git -json APhUuwu-5 x_amd64/vet git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel /opt/hostedtoolcache/go/1.25.8/x1 /usr/bin/git 8S7L/I4JaKxC4SUxgit -trimpath /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel 2254622/b425/importcfg /usr/bin/git k/gh-aw/gh-aw/.ggit k/gh-aw/gh-aw/pkrev-parse /usr/lib/git-cor--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha --show-toplevel ache/go/1.25.8/x64/pkg/tool/linu-extld=gcc /usr/bin/git xH4IQXLy2 GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git 5631-41141/test-git rg/x/text@v0.36.rev-parse ache/go/1.25.8/x--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq .object.sha go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build956159673/b233/importcfg -pack /home/REDACTED/go/pkg/mod/github.com/yosida95/uritemplate/v3@v3.0.2/compile.go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq .object.sha -json GO111MODULE es/.bin/node GOINSECURE GOMOD GOMODCACHE go ode_�� -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go ode_�� -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha remove origin /usr/bin/git rity4196278273/0git GO111MODULE 1/x64/bin/sh git rev-�� --show-toplevel go 2254622/b451/vet.cfg /lib/wasm/wasm_egit GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha 2254622/b452/_pkg_.a origin 2254622/b452=> ay_c2680897977/0git GO111MODULE ache/go/1.25.8/x--show-toplevel git rev-�� 1GuG/n9tIfN3pcVBFpNCK1GuG go /usr/bin/git .js' --ignore-pagit GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha sistency_GoAndJavaScript3354738218/001/test-empty-frontmatter.md -importcfg 1/x64/bin/node -s -w -buildmode=exe /usr/lib/git-core/git t-ha�� ithub/workflows/archie.md -q /usr/bin/git ntent.md GO111MODULE 64/bin/go git (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v7
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha 5631-41141/test-2563832858/.github/workflows vce9/Iw7fHw9tzQV_56Gjvce9 ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linuTest User /hom�� 159673/b242/_pkg_.a rn9z/FXv0oohNOW0KmEF_rn9z 159673/b242=> **/*.json t/internal/tag ../../../.pretti--show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu-test.v=true (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha 3945325700 --check outil.test **/*.ts 159673/b011/asm.rev-parse ache/go/1.25.8/x--show-toplevel outil.test 5722�� GOPATH=$(go env GOPATH); \ if command -v golangci-lint >/dev/nulgo1.25.8 _hWR/zuzHXkfxSXMaNsjT_hWR e/git-upload-pack tierignore scripts/**/*.js 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linurev-parse (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha 159673/b227/_pkg_.a GOPROXY 159673/b227=> iles use Prettiegit l/ascii 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link 1596�� ai-moderator.md -ZkR/Y5KUpR6ZrQZn8hJV-ZkR 1/x64/bin/node npx prettier --wgit go 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linurev-parse (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha add myorg /usr/bin/git repo4027432330/0git o x_amd64/compile git conf�� user.name Test User /usr/bin/git .js' --ignore-pagit GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha sistency_GoAndJavaScript3354738218/001/test-frontmatter-with-env-template-expressions.md 78ByPuFdRyAS-MkVro-o/78ByPuFdRyAS-MkVro-o /usr/bin/infocmp -goversion go1.25.8 -c=4 infocmp -1 r-test1939624266/test1.md r-test1939624266/test2.lock.yml /usr/bin/gh -json GO111MODULE 64/bin/go gh (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha -aw/git/ref/tags/v2.0.0 QLX65JRSUvpCHrYwEuIi/QLX65JRSUvpCHrYwEuIi /usr/bin/git -goversion go1.25.8 -c=4 /usr/bin/git conf�� --get-regexp ^remote\..*\.gh-resolved$ /usr/bin/git ntent.md GO111MODULE 64/bin/go git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a 06SIChxms x_amd64/compile GOINSECURE ack GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 SUy_HbpQE 64/pkg/tool/linu-importcfg GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu/home/REDACTED/work/gh-aw/gh-aw/scripts/lint_error_messages_test.go k/gh�� 3009165052/.github/workflows KjIdi_zAe ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE pproxy erignore ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 4179246611/.github/workflows GO111MODULE de_modules/.bin/node GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env til.go o 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a AUUx1O_e3 /opt/hostedtoolcache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name GO111MODULE de_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env '**/*.ts' '**/*.json' --ignore-path ../../../.pr**/*.json GO111MODULE 64/bin/sh GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE o 64/src/internal/--show-toplevel 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name GO111MODULE ules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env '**/*.ts' '**/*.json' --ignore-path ../../../.pr**/*.json GO111MODULE 1/x64/bin/sh GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env 546280735 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD bis 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 0/internal/stringset/set.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile k/gh�� _.a GO111MODULE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD erignore ache/go/1.25.8/x64/pkg/tool/linu-importcfg (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name GO111MODULE ndor/bin/sh GOINSECURE GOMOD GOMODCACHE go env 4179246611/.github/workflows GO111MODULE bin/node GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env 546280735 go ache/go/1.25.8/x64/pkg/tool/linux_amd64/cgo GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/cgo (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD bis 64/pkg/tool/linux_amd64/compile k/gh�� _.a dq87ptaK6 ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm GOINSECURE til erignore ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 4179246611/.github/workflows GO111MODULE ules/.bin/node GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env 546280735 GO111MODULE x_amd64/link GOINSECURE bidirule bis x_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 ohNRO1y8b 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile k/gh�� 3009165052/.github/workflows GO111MODULE k GOINSECURE age erignore ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 4179246611/.github/workflows GO111MODULE ode GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env _.a m0O72i2Jk /opt/hostedtoolcache/go/1.25.8/x-test.short=true GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 l.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD bis 64/pkg/tool/linux_amd64/compile 64/s�� _.a 34i--fWCy ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD erignore ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 4179246611/.github/workflows GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path -c=4 -nolocalimports -importcfg /tmp/go-build1572254622/b411/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/fileutil/fileutil.go /home/REDACTED/work/gh-aw/gh-aw/pkg/fileutil/tar.go env -json GO111MODULE node GOINSECURE GOMOD GOMODCACHE s not exist yet"-trimpath (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile ache�� rity1118235133/001 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE o 64/src/runtime/auser.email 64/pkg/tool/linutest@example.com (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel 64/pkg/tool/linux_amd64/compile /usr/bin/git _.a sYAOo28ie ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/xremote.origin.url /usr/bin/git uxEBM6ljh GO111MODULE ache/go/1.25.8/xgit-upload-pack 'origin' git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha edOutput3456969026/001 lNGu_38wk 64/pkg/tool/linux_amd64/vet GOINSECURE on GOMODCACHE 64/pkg/tool/linux_amd64/vet m/_n�� -obugO3Wj GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha on' --ignore-pat-p GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json 4 x_amd64/compile GOINSECURE GOMOD GOMODCACHE iE8t3kR/vbNrLVZ2rev-parse (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha re GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE k/gh-aw/gh-aw/actions/node_modules/.bin/node GOINSECURE GOMOD GOMODCACHE go k/gh�� ExpressionCompiledOutput884520512/001 GO111MODULE sh GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha efaultBranchFromLsRemoteWithRealGitcustom_branchremote.origin.url efaultBranchFromLsRemoteWithRealGitcustom_branch1305725009/001' e_modules/.bin/node GOINSECURE GOMOD GOMODCACHE go k/gh�� RequiresMinIntegrity3639679959/001 GO111MODULE tnet/tools/bash GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha _.a GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD bis 64/pkg/tool/linux_amd64/vet 64/s�� 64/src/runtime/ints.s yZeOx_cnJ ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env y_with_repos=public_312154244/001 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion .prettierignore git 64/bin/go gcc -###�� y_with_repos=public_1454718708/001 c /usr/bin/git - ../../../**/*.jsinit 64/bin/go git (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE wasm.s (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE odules/npm/node_-lang=go1.25 GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /sh GOINSECURE GOMOD GOMODCACHE go env h ../../../.prettierignore GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build1572254622/b397/cli.test /tmp/go-build1572254622/b397/cli.test -test.testlogfile=/tmp/go-build1572254622/b397/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true -nolocalimports -importcfg /tmp/go-build956159673/b196/importcfg -pack env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /tmp/go-build559809216/b001/cli.test /tmp/go-build559809216/b001/cli.test -test.paniconexit0 -test.timeout=10m0s -test.count=1 /hom�� --write ../../../**/*.jsGOMOD 64/bin/go --ignore-path ../../../.pretti-c /usr/bin/git go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /tmp/go-build190384759/b001/cli.test /tmp/go-build190384759/b001/cli.test -test.paniconexit0 -test.count=1 -test.timeout=1m0s env 4179246611/.github/workflows GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go 8d51�� 1617249346 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name .js' --ignore-path .prettierignore GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE /opt/hostedtoolcache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 14, 2026 that may be closed by this pull request
5 tasks
- gateway_logs_types.go: types, constants, getOrCreateServer/Tool
- gateway_logs_rpc.go: parseRPCMessages, findRPCMessagesPath, buildToolCallsFromRPCMessages
- gateway_logs_parsing.go: parseGatewayLogs, processGatewayLogEntry
- gateway_logs_aggregation.go: calculateGatewayAggregates, buildGuardPolicySummary
- gateway_logs_mcp.go: extractMCPToolUsageData + helpers
- gateway_logs.go: trimmed to 9-line redirect comment

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6511a367-acec-46d8-acb3-e1a6ded26ffa

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Split gateway_logs.go into concern-aligned files Split gateway_logs.go into concern-aligned files Apr 14, 2026
Copilot AI requested a review from pelikhan April 14, 2026 22:06
@pelikhan pelikhan marked this pull request as ready for review April 14, 2026 22:20
Copilot AI review requested due to automatic review settings April 14, 2026 22:20
@github-actions github-actions bot mentioned this pull request Apr 14, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors MCP gateway log parsing by splitting the previously monolithic pkg/cli/gateway_logs.go into smaller, concern-aligned files while keeping existing parsing/rendering behavior.

Changes:

  • Split gateway log parsing/types/RPC parsing/aggregation/MCP extraction into dedicated gateway_logs_*.go files.
  • Kept gateway_logs.go as a small stub with a redirecting comment and package declaration.
  • Light refactor in MCP extraction by introducing private helpers for tool-call extraction and summary stat building.
Show a summary per file
File Description
pkg/cli/gateway_logs_types.go Extracted shared structs/constants and common helpers for gateway/RPC parsing.
pkg/cli/gateway_logs_rpc.go Moved RPC parsing and rpc-messages tool-call reconstruction logic.
pkg/cli/gateway_logs_parsing.go Moved gateway.jsonl parsing + entry processing and rpc fallback wiring.
pkg/cli/gateway_logs_aggregation.go Moved aggregation and guard-policy summarization logic.
pkg/cli/gateway_logs_mcp.go Moved MCP tool usage extraction orchestration + helper extraction.
pkg/cli/gateway_logs.go Replaced prior monolithic implementation with a redirect comment.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 6/6 changed files
  • Comments generated: 4

Comment on lines +185 to +195
// Calculate max input/output sizes from individual tool calls
for _, tc := range mcpData.ToolCalls {
if tc.ServerName == serverName && tc.ToolName == toolName {
if tc.InputSize > summary.MaxInputSize {
summary.MaxInputSize = tc.InputSize
}
if tc.OutputSize > summary.MaxOutputSize {
summary.MaxOutputSize = tc.OutputSize
}
}
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildMCPSummaryStats computes MaxInputSize/MaxOutputSize by scanning all mcpData.ToolCalls for every (server, tool) pair, which is O(#toolCalls × #tools) and can become noticeably slow on large logs. Consider computing max input/output sizes in a single pass (e.g., build a map keyed by server+tool while iterating ToolCalls) and then populating summaries from that map.

Copilot uses AI. Check for mistakes.
Comment on lines +257 to +284
// Collect requests first to pair with responses
type rawEntry struct {
entry RPCMessageEntry
req rpcRequestPayload
resp rpcResponsePayload
valid bool
}
var entries []rawEntry

scanner := bufio.NewScanner(file)
buf := make([]byte, maxScannerBufferSize)
scanner.Buffer(buf, maxScannerBufferSize)

for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
continue
}
var e RPCMessageEntry
if err := json.Unmarshal([]byte(line), &e); err != nil {
continue
}
entries = append(entries, rawEntry{entry: e, valid: true})
}
if err := scanner.Err(); err != nil {
return nil, fmt.Errorf("error reading rpc-messages.jsonl: %w", err)
}

Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildToolCallsFromRPCMessages reads the entire rpc-messages.jsonl into an in-memory entries slice before processing. For large log artifacts this can significantly increase memory usage and delay output. Consider streaming: parse line-by-line, record pending OUT requests in a map, and emit tool calls as IN responses arrive, then emit any remaining pending requests at EOF.

Copilot uses AI. Check for mistakes.
ServerID string `json:"server_id"`
ToolName string `json:"tool_name"`
ErrorCode int `json:"error_code"`
Reason string `json:"reason"` // e.g., "repository_not_allowed", "min_integrity"
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment for GuardPolicyEvent.Reason lists example values like "repository_not_allowed" / "min_integrity", but the code and tests use values such as "repo_not_allowed" and "integrity_below_minimum" (see guardPolicyReasonFromCode and gateway_logs_test.go). Updating the comment to match the actual reason strings would avoid confusion for future maintainers/consumers.

Suggested change
Reason string `json:"reason"` // e.g., "repository_not_allowed", "min_integrity"
Reason string `json:"reason"` // e.g., "repo_not_allowed", "integrity_below_minimum"

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +40
for _, evt := range metrics.GuardPolicyEvents {
// Categorize by error code
switch evt.ErrorCode {
case guardPolicyErrorCodeIntegrityBelowMin:
summary.IntegrityBlocked++
case guardPolicyErrorCodeRepoNotAllowed:
summary.RepoScopeBlocked++
case guardPolicyErrorCodeAccessDenied:
summary.AccessDenied++
case guardPolicyErrorCodeBlockedUser:
summary.BlockedUserDenied++
case guardPolicyErrorCodeInsufficientPerms:
summary.PermissionDenied++
case guardPolicyErrorCodePrivateRepoDenied:
summary.PrivateRepoDenied++
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildGuardPolicySummary categorizes blocked events solely by evt.ErrorCode, but guard policy events parsed from gateway.jsonl (GUARD_POLICY_BLOCKED) populate Reason/Message and leave ErrorCode at its zero value. This results in TotalBlocked being non-zero while the breakdown counters (IntegrityBlocked/RepoScopeBlocked/etc.) stay at 0, so the rendered "Block Reasons" section will be empty for gateway.jsonl-derived data. Consider also categorizing by evt.Reason when ErrorCode is 0 (e.g., map "integrity_below_minimum", "repo_not_allowed", etc.), or otherwise ensure ErrorCode is set during gateway.jsonl parsing.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit b048b08 into main Apr 14, 2026
76 checks passed
@pelikhan pelikhan deleted the copilot/split-gateway-logs-by-concern branch April 14, 2026 22:25
@github-actions
Copy link
Copy Markdown
Contributor


Warning

The push_to_pull_request_branch operation failed: Failed to fetch branch copilot/split-gateway-logs-by-concern: The process '/usr/bin/git' failed with exit code 128. The code changes were not applied.

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (1,121 new lines in pkg/cli/) but does not have a linked Architecture Decision Record (ADR).

AI has analyzed the PR diff and generated a draft ADR to help you get started:

📄 Draft ADR: docs/adr/26296-split-gateway-logs-into-concern-aligned-files.md

What to do next

  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and verify the alternatives reflect what you actually considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-26296: Split gateway_logs.go into Concern-Aligned Files

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.


📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 26296-split-gateway-logs-into-concern-aligned-files.md for PR #26296).

🔒 This PR cannot merge until an ADR is linked in the PR body.

Note

🔒 Integrity filter blocked 1 item

The following item were blocked because they don't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · ● 178K ·

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.

[plan] Split gateway_logs.go by concern

3 participants