[repository-quality] 🎯 Repository Quality Improvement Report - Large File Decomposition Debt (2026-08-24) #55409
Replies: 0 comments
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-08-24
Focus Area: Large File Decomposition Debt (Go source file size vs. repo's own guideline)
Strategy Type: Custom
Custom Area: Yes — the repo's own
developer-code-organizationskill documents a strict "100–500 lines, one file per functionality" convention withcreate_issue.go/create_pull_request.goas exemplars, but a scan shows 32 non-test files exceed 800 lines (2–10x the guideline), concentrated in the two largest packages (pkg/cli,pkg/workflow). This is a repo-specific process drift worth surfacing rather than a generic "code quality" pass.Executive Summary
gh-aw's own coding conventions call for small, focused Go files (100–500 lines) organized by functionality, with named exemplars likecreate_issue.go(160 lines). A repository-wide scan found 32 non-test.gofiles exceeding 800 lines — some over double the upper guideline — withpkg/cli(15 files) andpkg/workflow(12 files) accounting for the vast majority. The largest offenders arepkg/workflow/safe_outputs_handler_registry.go(1091 lines, a single 49-entry map of handler builder closures),pkg/workflow/awf_config.go(1090 lines, 19 functions mixing schema validation, config building, and policy resolution),pkg/cli/add_command.go(1078 lines, 32 functions spanning command wiring, tracking, and validation), andpkg/cli/logs_metrics.go/pkg/cli/audit_report.go/pkg/cli/audit_diff.go(~1000–1060 lines each).These files are actively maintained (
safe_outputs_handler_registry.goandawf_config.gowere both touched today), so decomposition debt is accumulating in high-churn areas rather than settling in stable legacy code — precisely where the file-size guideline provides the most value for review-ability and merge-conflict avoidance. The recommended remediation splits each flagged file along its natural functional seams (e.g., one file per handler category in the registry, schema/build/policy separation inawf_config.go) following the existing "many small files" pattern already used elsewhere in the codebase.Full Analysis Report
Focus Area: Large File Decomposition Debt
Current State Assessment
The codebase totals 288,104 source LOC across 1,303 non-test Go files (average ~221 LOC/file), which is healthy in aggregate — but the distribution is skewed: 32 files (2.5% of files) exceed 800 lines, several approaching or exceeding 1,100.
Metrics Collected:
pkg/workflow/safe_outputs_handler_registry.go(1,091 lines)pkg/clifiles >800 linespkg/workflowfiles >800 linesdeveloper-code-organizationskill)Findings
Strengths
create_issue.go,add_comment.go), showing the convention is known and achievable — it's a matter of applying it consistently to newer/growing files.Areas for Improvement
pkg/workflow/safe_outputs_handler_registry.go(1,091 lines) is a singlehandlerRegistrymap literal with 49 inline closures — this actively fights the "one file per entity" pattern used elsewhere (e.g.,create_issue.go).pkg/workflow/awf_config.go(1,090 lines, 19 top-level functions) mixes schema validation (validateAWFConfigJSON), config construction (BuildAWFConfigJSON), and policy/domain resolution (resolveModelPolicyForAWFConfig,intersectModelPolicyRules) in one file — these are separable concerns.pkg/cli/add_command.go(1,078 lines, 32 functions) spans command flag registration, workflow resolution, file tracking, and compilation triggering — a prime candidate for splitting by responsibility.pkg/cli/audit_report.go(1,049) andpkg/cli/audit_diff.go(1,017) are twin large files in the audit subsystem that could share apkg/cli/audit/extraction pattern already partially started (audit_diff_render.goexists).Detailed Analysis
The
safe_outputs_handler_registry.gomap (lines 58–1091) defines one closure per safe-output handler key (create_issue,add_comment,create_pull_request, etc.), each building a config map from typed fields via a fluent builder. This structure is naturally partitionable: splitting into files grouped by output category (e.g.,handler_registry_issues.go,handler_registry_pull_requests.go,handler_registry_projects.go) with the registry itself only assembling references would bring each file under 300 lines and make future handler additions low-risk. The 4 helper functions at the top (resolveHandlerGitHubToken, etc.) already live cleanly outside the map and can stay in a slimsafe_outputs_handler_registry.gocore file that imports the split registries viainit()-time merges or direct map literals per file.awf_config.go's 19 functions cluster into three groups by name prefix and purpose: schema/validation (getCompiledAWFConfigSchema,validateAWFConfigJSON,normalizeTemplatableModelFallbackEnabled), the main builder (BuildAWFConfigJSON,buildAWFConfigSchemaURL), and policy/domain resolution (resolveModelPolicyForAWFConfig,intersectModelPolicyRules,unionModelPolicyRules,extractPlatformType,extractModelFallback,hasCustomLLMAPITarget,extractDefaultAiCreditsPricing,resolveAWFContainerAgentTimeoutMinutes,buildAWFTopologyAttachList,splitDomainList). Extracting the policy/domain group intoawf_config_policy.goalone would remove roughly 250–300 lines from the primary file.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Split safe-output handler registry by category
Priority: High
Estimated Effort: Medium
Focus Area: Code Organization
Description:
pkg/workflow/safe_outputs_handler_registry.go(1,091 lines) contains a singlehandlerRegistrymap with 49 inline builder closures for every safe-output handler type. Split the map entries into multiple files grouped by logical category (issues/comments, pull requests, labels/reviewers, projects, misc/dispatch), keeping the shared helper functions (resolveHandlerGitHubToken,resolveApproveWorkflowRunGitHubToken,resolveHandlerGitHubTokenWithStepID,handlerSupportsPerHandlerGitHubAppToken) and the top-levelhandlerRegistryvariable declaration in a slim core file that merges the category maps together.Acceptance Criteria:
safe_outputs_handler_registry.goreduced to under 300 lines (core helpers + registry assembly only)safe_outputs_handler_registry_issues.go,safe_outputs_handler_registry_pull_requests.go,safe_outputs_handler_registry_projects.go,safe_outputs_handler_registry_misc.go), each under 500 linespkg/workflowpass unchanged (no behavior change, pure extraction)make fmtrun after the splitCode Region:
pkg/workflow/safe_outputs_handler_registry.go(lines 58–1091, thehandlerRegistrymap literal)Task 2: Extract policy/domain resolution logic from awf_config.go
Priority: Medium
Estimated Effort: Small
Description:
pkg/workflow/awf_config.go(1,090 lines) mixes three concerns: schema validation, AWF config building, and model-policy/domain resolution. Extract the policy/domain resolution functions (resolveModelPolicyForAWFConfig,intersectModelPolicyRules,unionModelPolicyRules,extractPlatformType,extractModelFallback,hasCustomLLMAPITarget,extractDefaultAiCreditsPricing,resolveAWFContainerAgentTimeoutMinutes,buildAWFTopologyAttachList,splitDomainList) into a new filepkg/workflow/awf_config_policy.go.Acceptance Criteria:
awf_config.goreduced by ~250-300 linespkg/workflow/awf_config_policy.gofile created containing the extracted functions, package-levelvar/const dependencies moved or kept accessiblego build ./...andgo test ./pkg/workflow/...pass with no functional changesmake fmtrun after the splitCode Region:
pkg/workflow/awf_config.go(lines 827–1029, policy/domain resolution functions)Task 3: Decompose add_command.go by responsibility
Priority: Medium
Estimated Effort: Medium
Description:
pkg/cli/add_command.go(1,078 lines, 32 functions) spans cobra command wiring, workflow resolution/tracking, git-attributes handling, and compilation triggering. Split into focused files: command wiring/flags, workflow add orchestration (tracking + resolution), and post-add compilation/reporting.Acceptance Criteria:
add_command.goreduced to under 500 lines (command definition + flag registration only)add_workflow_tracking.go(git-attributes +FileTrackerhelpers:prepareGitAttributesTracking,trackGitAttributesIfCreated,addWorkflowsWithTracking,addWorkflowWithTracking) andadd_workflow_compile.go(compileAddedWorkflow,reportAddWorkflowStart,validateWorkflowDestination)go build ./...andgo test ./pkg/cli/...pass unchangedmake fmtrun after the splitCode Region:
pkg/cli/add_command.go(lines 296–528, workflow tracking/compilation helpers)Task 4: Consolidate audit_report.go and audit_diff.go under a shared package pattern
Priority: Low
Estimated Effort: Large
Description:
pkg/cli/audit_report.go(1,049 lines) andpkg/cli/audit_diff.go(1,017 lines) are two large sibling files in the audit subsystem; a third file,audit_diff_render.go(858 lines), already exists as a partial split of rendering logic out ofaudit_diff.go. Apply the same rendering/logic separation toaudit_report.go, and review whether both files' data-model/struct definitions can move to a sharedaudit_types.goto reduce duplication and individual file size.Acceptance Criteria:
audit_report.gosplit so report-generation logic and rendering/formatting logic live in separate files (e.g.,audit_report.go+audit_report_render.go), mirroring the existingaudit_diff.go/audit_diff_render.gopatterngo build ./...andgo test ./pkg/cli/... -run Auditpass unchangedmake fmtrun after the splitCode Region:
pkg/cli/audit_report.go(entire file, 1,049 lines)📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
safe_outputs_handler_registry.goby handler category — Priority: HighShort-term Actions (This Month)
awf_config.go— Priority: Mediumadd_command.goby responsibility — Priority: MediumLong-term Actions (This Quarter)
📈 Success Metrics
pkg/clifiles >800 lines: 15 → Target: <8Next Steps
Generated by Repository Quality Improvement Agent
Next analysis: 2026-08-25 — Focus area selected by diversity algorithm
All reactions