Skip to content

[plan] Split gateway_logs.go into focused files #23904

Description

@github-actions

Objective

Split pkg/cli/gateway_logs.go (1,332 lines) into four focused files without changing any public APIs or function signatures.

Context

From discussion #23903 (Repository Quality: File Size Discipline). This file mixes four distinct concerns: type definitions, RPC parsing, log processing, and metrics rendering — violating the 300-line hard limit documented in AGENTS.md.

Approach

  1. Create pkg/cli/gateway_log_types.go — move all type definitions and constants (GatewayLogEntry, DifcFilteredEvent, GuardPolicyEvent, GatewayServerMetrics, GatewayToolMetrics, GatewayMetrics, RPCMessageEntry, rpc* types, etc.)
  2. Create pkg/cli/gateway_log_parser.go — move parseRPCMessages, findRPCMessagesPath, parseGatewayLogs and related helpers
  3. Create pkg/cli/gateway_log_processor.go — move processGatewayLogEntry, getOrCreateServer, getOrCreateTool, calculateGatewayAggregates, buildGuardPolicySummary
  4. Create pkg/cli/gateway_log_renderer.go — move renderGatewayMetricsTable, getSortedServerNames, and any other render helpers
  5. Remove or reduce gateway_logs.go if it becomes empty/redundant
  6. Keep the logger variable (var gatewayLogsLog) in the most appropriate file

Rules

  • Keep the same package (package cli)
  • Do NOT change any function signatures, type names, or package-level variable names
  • Run make fmt after changes
  • Run go test ./pkg/cli/ -run ".*[Gg]ateway.*" to validate
  • Run make agent-finish before committing

Acceptance Criteria

  • pkg/cli/gateway_log_types.go contains all type/const definitions
  • pkg/cli/gateway_log_parser.go contains parsing functions
  • pkg/cli/gateway_log_processor.go contains processing functions
  • pkg/cli/gateway_log_renderer.go contains render functions
  • Original gateway_logs.go removed or reduced to a thin file
  • All gateway-related tests pass
  • Each new file is under 350 lines

Generated by Plan Command for issue #discussion #23903 ·

  • expires on Apr 3, 2026, 2:40 PM UTC

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions