Repository Quality Improvement Report - File Size & Responsibility Decomposition Debt #23125
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #23243. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🎯 Repository Quality Improvement Report - File Size & Responsibility Decomposition Debt
Analysis Date: 2026-03-26
Focus Area: File Size & Responsibility Decomposition Debt
Strategy Type: Custom (first run)
Custom Area: Yes — This codebase has an explicit 300-line hard limit for validators in
AGENTS.md, and a broader spirit of "prefer many smaller files grouped by functionality." This custom focus area examines how well the current codebase adheres to that principle, and identifies the highest-value decomposition targets.Executive Summary
The gh-aw codebase contains 626 source files averaging 236 lines each — broadly healthy. However, 171 files (27%) exceed the 300-line threshold stated in
AGENTS.md, 55 files (9%) exceed 600 lines, and 6 files (1%) exceed 1,000 lines. While the 300-line hard limit is explicitly stated for validators, the project's own documentation emphasizes "prefer many smaller files grouped by functionality" and "add new files for new features rather than extending existing ones." The largest files have accumulated multiple distinct responsibilities over time, making them harder to review, test, and modify safely.The five most actionable decomposition targets are:
pkg/cli/gateway_logs.go(1,332 lines, combining type definitions, RPC parsing, log parsing, metrics, and table rendering),pkg/cli/audit_report_render.go(1,045 lines, 25 render functions across unrelated audit domains),pkg/constants/constants.go(1,099 lines, mixing semantic type machinery with all project constants),pkg/workflow/safe_outputs_tools_filtering.go(1,037 lines, 6 large functions across filtering and generation responsibilities), andcmd/gh-aw/main.go(860 lines, containing inline cobra command definitions that belong in thepkg/clipattern already established).Full Analysis Report
Focus Area: File Size & Responsibility Decomposition Debt
Current State Assessment
Metrics Collected:
gateway_logs.goat 1,332 linesaudit_report_render.goTop 10 largest source files:
pkg/cli/gateway_logs.gopkg/constants/constants.gopkg/cli/audit_report_render.gopkg/workflow/safe_outputs_tools_filtering.gopkg/cli/logs_report.gopkg/cli/trial_command.gopkg/workflow/checkout_manager.gopkg/workflow/compiler_safe_outputs_config.gopkg/cli/logs_orchestrator.gopkg/workflow/frontmatter_types.goFindings
Strengths
pkg/workflow/validator pattern (100+ separate validation files) demonstrates excellent decomposition{domain}_{subdomain}_validation.go) are well-applied in validatorsAreas for Improvement
pkg/cli/gateway_logs.gomixes 5 distinct responsibilities in 1,332 lines [Critical]pkg/cli/audit_report_render.gocontains 25 functions spanning unrelated audit domains [High]pkg/constants/constants.gois a 1,099-line god file mixing types and values [High]cmd/gh-aw/main.goembeds cobra subcommand logic instead of delegating topkg/cli[Medium]pkg/workflow/safe_outputs_tools_filtering.gocombines filtering and tool generation [Medium]Detailed Analysis
gateway_logs.gois particularly problematic: it defines 10+ types (GatewayLogEntry,DifcFilteredEvent,GuardPolicyEvent,GatewayServerMetrics,GatewayToolMetrics,GatewayMetrics,RPCMessageEntry, etc.), implements RPC message parsing (~200 lines), gateway log parsing (~250 lines), metrics computation (~150 lines), and table rendering (~400 lines) all in one file. Every one of these is a distinct concern testable in isolation.audit_report_render.gohas 25render*functions covering completely separate audit domains:renderOverview,renderMetrics,renderJobsTable,renderToolUsageTable,renderMCPToolUsageTable,renderGuardPolicySummary,renderFirewallAnalysis,renderPerformanceMetrics,renderPolicyAnalysis,renderEngineConfig,renderPromptAnalysis,renderSessionAnalysis,renderMCPServerHealth,renderSafeOutputSummary, and more. Each cluster of 3-4 render functions could stand alone.constants/constants.gocontains the semantic type definitions (LineLength,Version,FeatureFlag,URL,ModelName,JobName,StepID,EngineName,DocURL) along with theirString()/IsValid()methods (already noted in AGENTS.md as having intentional duplication), followed by all project constants covering engines, container images, runtime versions, directories, timeouts, and feature flags.cmd/gh-aw/main.godefines 7+ cobra commands inline (newCmd,removeCmd,enableCmd,disableCmd,compileCmd,runCmd,versionCmd) at 860 lines, while thepkg/clipackage has well-established patterns for command files.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: The following tasks are designed for GitHub Copilot coding agent execution. Please split these into individual work items.
Improvement Tasks
Task 1: Split
pkg/cli/gateway_logs.gointo focused filesPriority: High
Estimated Effort: Medium
Focus Area: File Decomposition
Description:
gateway_logs.gois 1,332 lines combining five distinct concerns: struct type definitions, constants, RPC message parsing, gateway log entry processing, metrics computation, and table rendering. This file should be split into focused files following the repository's existing conventions.Acceptance Criteria:
pkg/cli/gateway_log_types.go(~150 lines)parseRPCMessages,buildToolCallsFromRPCMessages) moved topkg/cli/gateway_log_rpc.go(~250 lines)parseGatewayLogs,processGatewayLogEntry, aggregate helpers) moved topkg/cli/gateway_log_parser.go(~300 lines)render*and table rendering functions moved topkg/cli/gateway_log_render.go(~400 lines)Code Region:
pkg/cli/gateway_logs.goTask 2: Split
pkg/cli/audit_report_render.goby audit domainPriority: High
Estimated Effort: Medium
Focus Area: File Decomposition
Description:
audit_report_render.gocontains 25render*functions across completely unrelated audit domains (tools, security, performance, engine config, etc.) totalling 1,045 lines. Group related render functions into domain-focused files.Acceptance Criteria:
renderJSON,renderConsole,renderAuditComparison,renderOverviewstay in a coreaudit_report_render.go(~200 lines)renderToolUsageTable,renderMCPToolUsageTable,renderMCPServerHealth) extracted toaudit_render_tools.go(~200 lines)renderGuardPolicySummary,renderFirewallAnalysis,renderRedactedDomainsAnalysis,renderPolicyAnalysis) extracted toaudit_render_security.go(~200 lines)renderMetrics,renderJobsTable,renderPerformanceMetrics,renderSafeOutputSummary) extracted toaudit_render_metrics.go(~200 lines)renderKeyFindings,renderRecommendations,renderEngineConfig,renderPromptAnalysis,renderSessionAnalysis,renderCreatedItemsTable) extracted toaudit_render_analysis.go(~250 lines)Code Region:
pkg/cli/audit_report_render.goTask 3: Decompose
pkg/constants/constants.goby domainPriority: High
Estimated Effort: Small
Focus Area: File Decomposition
Description:
pkg/constants/constants.gois 1,099 lines mixing semantic type machinery (9 named types + their methods) with all project constants (engine versions, container images, runtime versions, directory paths, timeout values, feature flags). The type definitions and method implementations (already noted as intentionally duplicated inAGENTS.md) should be separated from the constant values.Acceptance Criteria:
String()/IsValid()methods extracted topkg/constants/constants_types.gopkg/constants/constants_engines.goDefaultGhAwMount,DefaultNodeAlpineLTSImage, registry URLs, etc.) grouped inpkg/constants/constants_containers.goDefaultNodeVersion,DefaultPythonVersion,DefaultGoVersion, etc.) grouped inpkg/constants/constants_runtimes.goGhAwRootDir,AWFAuditDir, etc.) and timeouts stay in a reducedconstants.gomake agent-finishpassesCode Region:
pkg/constants/constants.goTask 4: Move cobra subcommand definitions out of
cmd/gh-aw/main.goPriority: Medium
Estimated Effort: Medium
Focus Area: File Decomposition / CLI Architecture
Description:
cmd/gh-aw/main.gois 860 lines containing 7 cobravarcommand definitions (newCmd,removeCmd,enableCmd,disableCmd,compileCmd,runCmd,versionCmd) inline. The repository already has a richpkg/cli/package with proper command files (add_command.go,compile_command.go, etc.). Themain.goentrypoint should be thin, delegating to constructors inpkg/cli/.Acceptance Criteria:
main.goreduced to ≤150 lines, containing only: root command definition, flag registration (init()), andmain()new,remove,enable,disable,run,version) moved to dedicated files incmd/gh-aw/or exposed as constructors frompkg/cli/compileCmd(the largest at ~120 lines) moved topkg/cli/compile_command.goor integrated with the existing compile command path./gh-aw --helpand subcommand behaviors unchangedmake agent-finishpassesCode Region:
cmd/gh-aw/main.goTask 5: Split
pkg/workflow/safe_outputs_tools_filtering.gointo filtering and generationPriority: Medium
Estimated Effort: Small
Focus Area: File Decomposition
Description:
safe_outputs_tools_filtering.go(1,037 lines, 6 functions) combines tool filtering (deciding which tools are enabled,computeEnabledToolNames) with tool generation (constructing JSON tool definitions,generateFilteredToolsJSON,generateDynamicTools,generateToolsMetaJSON) and repo parameter injection (addRepoParameterIfNeeded,computeRepoParamForTool). These are separate concerns.Acceptance Criteria:
computeEnabledToolNames) stays in a reducedsafe_outputs_tools_filtering.goaddRepoParameterIfNeeded,computeRepoParamForTool, ~90 lines) extracted tosafe_outputs_tools_repo.gogenerateFilteredToolsJSON,generateDynamicTools,generateToolsMetaJSON, types) extracted tosafe_outputs_tools_generator.gomake agent-finishpassesCode Region:
pkg/workflow/safe_outputs_tools_filtering.go📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
gateway_logs.go(1,332 lines) — 4-way split, highest complexity reduction — Priority: Highaudit_report_render.go(1,045 lines, 25 functions) — 5-way split by render domain — Priority: Highconstants.go(1,099 lines) — 5-way split by constant domain — Priority: HighShort-term Actions (This Month)
main.go— move command definitions topkg/cli— Priority: Mediumsafe_outputs_tools_filtering.go— separate filtering from generation — Priority: MediumLong-term Actions (This Quarter)
make lintrule) that warns when any new*_test.go-excluded.gofile exceeds 400 lines — prevents regressionpkg/cli/trial_command.go(1,007 lines),pkg/workflow/checkout_manager.go(987 lines), andpkg/workflow/compiler_safe_outputs_config.go(968 lines) for further decomposition📈 Success Metrics
Track these metrics to measure improvement in File Size & Responsibility Decomposition Debt:
pkg/cli/: ~10 → ≤ 6main.goline count: 860 → ≤ 150Next Steps
References:
Beta Was this translation helpful? Give feedback.
All reactions