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
- Create
pkg/cli/gateway_log_types.go — move all type definitions and constants (GatewayLogEntry, DifcFilteredEvent, GuardPolicyEvent, GatewayServerMetrics, GatewayToolMetrics, GatewayMetrics, RPCMessageEntry, rpc* types, etc.)
- Create
pkg/cli/gateway_log_parser.go — move parseRPCMessages, findRPCMessagesPath, parseGatewayLogs and related helpers
- Create
pkg/cli/gateway_log_processor.go — move processGatewayLogEntry, getOrCreateServer, getOrCreateTool, calculateGatewayAggregates, buildGuardPolicySummary
- Create
pkg/cli/gateway_log_renderer.go — move renderGatewayMetricsTable, getSortedServerNames, and any other render helpers
- Remove or reduce
gateway_logs.go if it becomes empty/redundant
- 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
Generated by Plan Command for issue #discussion #23903 · ◷
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
pkg/cli/gateway_log_types.go— move all type definitions and constants (GatewayLogEntry,DifcFilteredEvent,GuardPolicyEvent,GatewayServerMetrics,GatewayToolMetrics,GatewayMetrics,RPCMessageEntry, rpc* types, etc.)pkg/cli/gateway_log_parser.go— moveparseRPCMessages,findRPCMessagesPath,parseGatewayLogsand related helperspkg/cli/gateway_log_processor.go— moveprocessGatewayLogEntry,getOrCreateServer,getOrCreateTool,calculateGatewayAggregates,buildGuardPolicySummarypkg/cli/gateway_log_renderer.go— moverenderGatewayMetricsTable,getSortedServerNames, and any other render helpersgateway_logs.goif it becomes empty/redundantvar gatewayLogsLog) in the most appropriate fileRules
package cli)make fmtafter changesgo test ./pkg/cli/ -run ".*[Gg]ateway.*"to validatemake agent-finishbefore committingAcceptance Criteria
pkg/cli/gateway_log_types.gocontains all type/const definitionspkg/cli/gateway_log_parser.gocontains parsing functionspkg/cli/gateway_log_processor.gocontains processing functionspkg/cli/gateway_log_renderer.gocontains render functionsgateway_logs.goremoved or reduced to a thin file