[repository-quality] Repository Quality Improvement Report — Large File Decomposition Debt (2026-04-14) #26221
Closed
Replies: 2 comments 1 reply
-
|
/plan |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #26431. |
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-04-14
Focus Area: Large File Decomposition Debt (Custom)
Strategy Type: Custom — first run, no prior history
Rationale: The AGENTS.md documents an explicit hard limit of 300 lines per file with a target of 100–200 lines. Auditing compliance with this policy surfaces concrete, high-impact refactoring opportunities that directly improve maintainability and reviewability.
Executive Summary
Analysis of the 675 non-test Go source files reveals significant decomposition debt: 179 files (26.5%) exceed the documented 300-line hard limit, including 6 files at 1,000+ lines. The worst offenders are concentrated in
pkg/cli/(audit and logs subsystems) andpkg/workflow/(compiler pipeline). These files mix multiple logical domains and would benefit from the naming convention{domain}_{subdomain}.godocumented in AGENTS.md.The good news is that the codebase already demonstrates disciplined splitting in many places (e.g., the compile pipeline is decomposed into
compile_config.go,compile_validation.go,compile_orchestrator.go, etc.). The tasks below bring the remaining hot-spots in line with that same pattern, prioritising the six files that violate the hard limit first.Full Analysis Report
Focus Area: Large File Decomposition Debt
Current State Assessment
Metrics Collected:
Top Offenders (≥ 1 000 lines):
pkg/cli/audit_report_render.gopkg/workflow/compiler_orchestrator_workflow.gopkg/cli/logs_orchestrator.gopkg/cli/gateway_logs.gopkg/cli/logs_report.gopkg/workflow/compiler_safe_outputs_config.goFindings
Strengths
{domain}_{subdomain}.go) are consistently applied where splitting has already occurred.Areas for Improvement
pkg/cli/audit_report_render.gomixes 10+ render domains (overview, metrics, jobs, tools, MCP, firewall, guard policies, key findings, recommendations, redacted domains, created items). Each domain independently satisfies the "2+ distinct domains" splitting criterion.pkg/cli/gateway_logs.gomixes RPC message parsing, gateway log parsing, tool call extraction, and aggregation — 4 independent concerns.pkg/cli/logs_report.gohas 15+ independentbuild*functions for completely separate report sections that do not share state.🤖 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 for Claude to process.
Task 1: Split
audit_report_render.goby render domainPriority: High
Estimated Effort: Medium
Focus Area: Large File Decomposition
Code Region:
pkg/cli/audit_report_render.go(1 139 lines)Description:
audit_report_render.gocontains 10+ logically independent render functions. Split it into focused files following theaudit_report_render_{domain}.gonaming pattern. Each split file should contain the functions for exactly one render domain.Suggested split:
audit_report_render_overview.go—renderOverview,renderMetricsaudit_report_render_jobs.go—renderJobsTableaudit_report_render_tools.go—renderToolUsageTable,renderMCPToolUsageTableaudit_report_render_firewall.go—renderFirewallAnalysis,renderRedactedDomainsAnalysisaudit_report_render_guard.go—renderGuardPolicySummaryaudit_report_render_findings.go—renderKeyFindings,renderRecommendations,renderCreatedItemsTablerenderConsole,renderJSON, andrenderAuditComparisonin the original file (entry points)Acceptance Criteria:
audit_report_render.gois ≤ 300 lines after the splitmake build && make test-unitpass without errorsmake fmt && make lintpass without errorsTask 2: Split
gateway_logs.goby concernPriority: High
Estimated Effort: Medium
Focus Area: Large File Decomposition
Code Region:
pkg/cli/gateway_logs.go(1 066 lines)Description:
gateway_logs.gomixes four independent concerns: type definitions, RPC message parsing, gateway log parsing, MCP tool-call extraction, and aggregation. Split into files aligned with each concern.Suggested split:
gateway_logs_types.go— all type/struct definitions (lines ~1–103)gateway_logs_rpc.go—parseRPCMessages,findRPCMessagesPath,buildToolCallsFromRPCMessagesgateway_logs_parsing.go—parseGatewayLogs,processGatewayLogEntry,getOrCreateServer,getOrCreateToolgateway_logs_aggregation.go—calculateGatewayAggregates,buildGuardPolicySummarygateway_logs_mcp.go—extractMCPToolUsageDataAcceptance Criteria:
gateway_logs.gois ≤ 300 lines (or removed if entirely replaced)make build && make test-unitpass without errorsmake fmt && make lintpass without errorsTask 3: Split
logs_report.goby report sectionPriority: Medium
Estimated Effort: Medium
Focus Area: Large File Decomposition
Code Region:
pkg/cli/logs_report.go(1 065 lines)Description:
logs_report.gocontains 15+ independent builder functions, each constructing a completely separate section of the logs report. These functions share no state and can be cleanly separated.Suggested split:
logs_report_tools.go—buildToolUsageSummary,isValidToolNamelogs_report_mcp.go—buildMCPFailuresSummary,buildMCPToolUsageSummarylogs_report_firewall.go—buildFirewallLogSummary,buildRedactedDomainsSummary,buildAccessLogSummary,aggregateDomainStats,convertDomainsToSortedSliceslogs_report_errors.go—buildCombinedErrorsSummary,buildMissingToolsSummary,buildMissingDataSummarybuildLogsData,renderLogsConsole,renderLogsJSON,writeSummaryFile, and helper types inlogs_report.goAcceptance Criteria:
logs_report.gois ≤ 300 linesmake build && make test-unitpass without errorsmake fmt && make lintpass without errorsTask 4: Split
compiler_safe_outputs_config.goby handler groupPriority: Medium
Estimated Effort: Medium
Focus Area: Large File Decomposition
Code Region:
pkg/workflow/compiler_safe_outputs_config.go(1 035 lines)Description:
compiler_safe_outputs_config.gogenerates theGH_AW_SAFE_OUTPUTS_HANDLER_CONFIGenv variable consumed by the JavaScript safe-outputs runner. It mixes builder infrastructure, individual handler config functions, and the top-level orchestrator. Split by handler group.Suggested split:
compiler_safe_outputs_builder.go—handlerConfigBuilderstruct and all its methodscompiler_safe_outputs_handlers.go— individual handler config generators (issues, PRs, comments, discussions, etc.)GenerateSafeOutputsHandlerConfigin the original fileAcceptance Criteria:
compiler_safe_outputs_config.gois ≤ 300 linesmake build && make test-unitpass without errorsmake fmt && make lintpass without errorsTask 5: Evaluate and decompose
pkg/workflow/frontmatter_types.goPriority: Low
Estimated Effort: Small
Focus Area: Large File Decomposition
Code Region:
pkg/workflow/frontmatter_types.go(957 lines)Description:
frontmatter_types.gocontains both type definitions and parsing logic in a single file. Per AGENTS.md conventions, parsing functions should live in a separate file when the combination exceeds the threshold.Suggested split:
typeandstructdeclarations infrontmatter_types.go(target ≤ 300 lines)ParseFrontmatterConfig,parseRuntimesConfig,parsePermissionsConfig, and other parse functions tofrontmatter_parsing.goAcceptance Criteria:
frontmatter_types.gocontains only type/struct declarations and is ≤ 300 linesfrontmatter_parsing.gois ≤ 300 linesmake build && make test-unitpass without errorsmake fmt && make lintpass without errors📊 Historical Context
Previous Focus Areas
This is the first recorded run.
🎯 Recommendations
Immediate Actions (This Week)
audit_report_render.go— largest single violation at 1 139 lines, cleanest domain boundaries — Priority: Highgateway_logs.go— 4 orthogonal concerns, straightforward extraction — Priority: HighShort-term Actions (This Month)
logs_report.go— 15+ independent builder functions — Priority: Mediumcompiler_safe_outputs_config.go— clear builder / handler separation — Priority: MediumLong-term Actions (This Quarter)
frontmatter_types.go— types vs. parsing separation — Priority: Low📈 Success Metrics
Track these metrics to measure improvement in Large File Decomposition Debt:
Next Steps
References:
Beta Was this translation helpful? Give feedback.
All reactions