π¬ Repository Quality Improvement Report β Large File Decomposition Debt (2026-03-31) #23730
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #23903. |
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 β Large File Decomposition Debt
Analysis Date: 2026-03-31
Focus Area: Large File Decomposition Debt (Custom)
Strategy Type: Custom β Repository-Specific
Custom Area: Yes β This focus area was selected because
AGENTS.mdexplicitly states a hard limit of 300 lines for source files and a recommended split at 200 lines. Analysis reveals 174 files currently exceed the 300-line threshold, with the worst offenders reaching over 1,300 lines. This represents a significant and measurable technical debt unique to this codebase.Executive Summary
The gh-aw codebase is healthy in many respects (test-to-source ratio >2:1, full lint/format enforcement, strong CI), but a significant pattern of oversized files has accumulated. The project's own
AGENTS.mddocumentation sets a hard limit of 300 lines per file with a recommended target of 100β200 lines and a decision tree for splitting β yet 174 production source files exceed that hard limit, and 80 exceed 500 lines.The largest violations are concentrated in
pkg/cli/(29 files >500 lines) andpkg/workflow/(41 files >500 lines). The worst single file,gateway_logs.goat 1,332 lines, contains four distinct responsibility domains: RPC message parsing, guard policy handling, log aggregation, and rendering.pkg/constants/constants.goat 1,083 lines mixes semantic type definitions with constants for ten different subsystems.Splitting these files into cohesive, single-responsibility units will improve navigability for new contributors, reduce merge conflict risk, make selective testing easier, and bring the codebase into alignment with its own stated guidelines.
Full Analysis Report
Focus Area: Large File Decomposition Debt
Current State Assessment
Metrics Collected:
gateway_logs.go)pkg/workflowfiles >500 linespkg/clifiles >500 linespkg/parserfiles >500 linesStrengths
//go:buildtagsAreas for Improvement
pkg/cli/gateway_logs.go(1,332 lines) β four distinct domains in one file (High)pkg/constants/constants.go(1,083 lines) β mixes type aliases and constants across 10+ subsystems (High)pkg/cli/audit_report_render.go(1,045 lines) β rendering split across JSON and 20+ console section functions (Medium)pkg/cli/logs_report.go(1,011 lines) β data builder and renderer combined (Medium)Top 20 Files Exceeding Limits
pkg/cli/gateway_logs.gopkg/constants/constants.gopkg/cli/audit_report_render.gopkg/cli/logs_report.gopkg/cli/trial_command.gopkg/workflow/checkout_manager.gopkg/workflow/compiler_safe_outputs_config.gopkg/workflow/cache.gopkg/cli/logs_orchestrator.gopkg/workflow/frontmatter_types.gopkg/workflow/compiler_orchestrator_workflow.gopkg/parser/remote_fetch.gopkg/workflow/frontmatter_extraction_yaml.gocmd/gh-aw/main.gopkg/workflow/compiler_jobs.gopkg/cli/pr_command.gopkg/workflow/domains.gopkg/parser/schema_suggestions.gopkg/workflow/compiler_yaml_main_job.gopkg/workflow/compiler_yaml.goπ€ Tasks for Copilot Agent
Task 1: Split
pkg/cli/gateway_logs.gointo domain-cohesive filesPriority: High
Estimated Effort: Medium
Focus Area: Large File Decomposition
Description:
pkg/cli/gateway_logs.go(1,332 lines) contains four distinct responsibility domains:GatewayLogEntry,GatewayMetrics,RPCMessageEntryand related structsparseRPCMessages,buildToolCallsFromRPCMessagesparseGatewayLogs,calculateGatewayAggregates,buildGuardPolicySummary,isGuardPolicyErrorCoderenderGatewayMetricsTable,displayAggregatedGatewayMetricsSplit this file into three cohesive files:
pkg/cli/gateway_logs_types.goβ all type definitionspkg/cli/gateway_logs_parser.goβ parsing functionspkg/cli/gateway_logs_render.goβ rendering and display functionsgateway_logs.gofor orchestration/aggregation logicAcceptance Criteria:
go test ./pkg/cli/...)make fmt && make lintpassesCode Region:
pkg/cli/gateway_logs.goTask 2: Split
pkg/constants/constants.gointo domain-specific filesPriority: High
Estimated Effort: Medium
Focus Area: Large File Decomposition
Description:
pkg/constants/constants.go(1,083 lines) contains constants for many unrelated subsystems. Split it into domain-specific files:pkg/constants/constants_types.goβ semantic type aliases and their methods (LineLength, Version, FeatureFlag, URL, ModelName, JobName, StepID, etc.)pkg/constants/constants_engines.goβ engine-specific constants (Copilot, Claude, Codex, Gemini, Playwright versions and defaults)pkg/constants/constants_sandbox.goβ firewall/sandbox constants (AWF*, firewall paths, registries, containers)pkg/constants/constants_jobs.goβ GitHub Actions job names, step IDs, job/step priority fieldspkg/constants/constants.goβ retain CLI prefix, workspace paths, and general constantsAcceptance Criteria:
constants.goreduced to β€300 linesgo test ./pkg/constants/...)make fmt && make lintpassesCode Region:
pkg/constants/constants.goTask 3: Split
pkg/cli/audit_report_render.gointo render-domain filesPriority: High
Estimated Effort: Medium
Focus Area: Large File Decomposition
Description:
pkg/cli/audit_report_render.go(1,045 lines) contains ~25 rendering functions across JSON output, console rendering, and 20+ section-specific renderers (overview, metrics, tool usage, MCP, guard policies, firewall, etc.). These can be cleanly split by rendering target and domain:pkg/cli/audit_render_json.goβrenderJSONpkg/cli/audit_render_overview.goβ high-level overview sections (renderConsole, renderOverview, renderMetrics, renderEngineConfig)pkg/cli/audit_render_security.goβ security-domain sections (renderGuardPolicySummary, renderFirewallAnalysis, renderRedactedDomainsAnalysis, renderPolicyAnalysis)pkg/cli/audit_render_tools.goβ tool usage sections (renderToolUsageTable, renderMCPToolUsageTable, renderMCPServerHealth)pkg/cli/audit_report_render.goβ keep remaining sections and shared helpersAcceptance Criteria:
make fmt && make lintpassesgo test ./pkg/cli/...passesCode Region:
pkg/cli/audit_report_render.goTask 4: Split
pkg/cli/logs_report.gointo builder and renderer filesPriority: Medium
Estimated Effort: Small
Focus Area: Large File Decomposition
Description:
pkg/cli/logs_report.go(1,011 lines) contains two distinct concerns that should be separated:buildLogsData,buildToolUsageSummary,buildMissingToolsSummary,buildMCPFailuresSummary,buildAccessLogSummary,buildFirewallLogSummary,buildRedactedDomainsSummary,buildMCPToolUsageSummary,buildCombinedErrorsSummaryrenderLogsJSON,renderLogsConsole,writeSummaryFileAcceptance Criteria:
logs_report.goreduced to β€500 linesmake fmt && make lintpassesgo test ./pkg/cli/...passesCode Region:
pkg/cli/logs_report.goTask 5: Add file-size enforcement to CI
Priority: Medium
Estimated Effort: Small
Focus Area: Large File Decomposition
Description:
The 300-line hard limit is documented in
AGENTS.mdbut not enforced by CI. New files are added without automated checks, allowing the debt to grow silently. Adding a simple script that warns (or fails) when a newly introduced file exceeds the limit will prevent regression.Add a
scripts/check-file-sizes.shscript that:.gofiles exceeding 500 lines (more lenient threshold to avoid immediate failures from existing violations)Integrate this check into the
Makefileasmake check-file-sizesand optionally add it to the CI workflow.Acceptance Criteria:
scripts/check-file-sizes.shexists and is executablemake check-file-sizestarget added toMakefileCode Region:
scripts/,MakefileRun
make check-file-sizesto verify the script works. The script should succeed (exit 0) since all current violations are known.Beta Was this translation helpful? Give feedback.
All reactions