[repository-quality] 🎯 Repository Quality Improvement Report - Monolithic File Decomposition & Single-Responsibility Violations #52059
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #52298. |
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.
Analysis Date: 2026-08-11
Focus Area: Monolithic File Decomposition (Code Organization / Code Quality hybrid)
Strategy Type: Custom
Custom Area: Yes — the standard "Code Organization" category was too generic; the repo's own metrics show a specific, actionable pattern (25 files >900 LOC, several with 40-55 top-level functions) that a generic category wouldn't surface with concrete file targets.
Executive Summary
gh-aw's Go codebase (272K source LOC vs. 529K test LOC — a healthy ~1.9x test ratio) has accumulated a cluster of oversized, multi-responsibility files. 25 non-test.gofiles exceed 900 lines, and 87 exceed 600 lines. Several of these —pkg/workflow/compiler_types.go(55 top-level functions),pkg/parser/import_field_extractor.go(51),pkg/cli/audit.go(49), andpkg/cli/add_package_manifest.go(47) — mix unrelated concerns (option builders, compiler state mutators, command wiring, business logic) in a single file, making them slow to navigate, risky to review, and prone to merge conflicts given their high edit frequency (update_actions.goandcompiler_custom_jobs.goare both actively churned, per git log).None of these files are missing test coverage (all three sampled have dedicated
_test.gofiles), so the risk is not correctness but maintainability: reviewers must scroll through hundreds of unrelated lines to find a single symbol, and the high function count per file makesgrep-based navigation the primary discovery tool instead of package structure. Thepkg/workflowandpkg/clipackages carry most of this weight (3,185 files total inpkg/), suggesting these two packages have grown faster than their internal organization has kept pace.We recommend a set of surgical splits (not full rewrites) that group functions by concern — e.g., separating
compiler_types.go's builder/option functions from itsCompilerstruct mutators, and splittingaudit.go's CLI command wiring from its audit execution/report logic. Each task below targets one file with a clear split boundary and preserves existing tests by relocating them alongside their functions.Full Analysis Report
Focus Area: Monolithic File Decomposition & Single-Responsibility Violations
Current State Assessment
The codebase organizes logic primarily by package (
pkg/workflow,pkg/cli,pkg/parser), but within packages many files have grown into de facto "kitchen sink" modules. This was measured directly rather than inferred:Metrics Collected:
compiler_types.go)switchstatement count (pkg/cli + pkg/workflow)Findings
Strengths
_test.gocompanions, so splitting is low-risk from a coverage standpoint.workflow,cli,parser) is sound; the problem is intra-package file granularity, not overall architecture.Areas for Improvement
pkg/workflow/compiler_types.gohas 55 top-level functions mixingCompilerOptionbuilders (WithVerbose,WithEngineOverride, ...) with*Compilermethod mutators (SetSkipValidation,SetContext, ...) — two distinct concerns (functional-options construction vs. runtime state mutation) in one 900+ line file.pkg/cli/audit.go(49 functions, 1095 LOC) mixes Cobra command registration (NewAuditCommand,registerAuditCommandFlags) with core audit execution logic (AuditWorkflowRun,runAuditMulti) and low-level error classification helpers (isPermissionError,isPermissionErrorStr).pkg/parser/import_field_extractor.go(1045 LOC, 51 functions) is the largest file inpkg/parser, disproportionate to the package's typical file size, suggesting extraction-related logic should be split by field type or extraction phase.pkg/cli/add_package_manifest.go(997 LOC, 47 functions) andpkg/cli/update_actions.go(1144 LOC, actively churned per git log) are both largeclifiles under continuous edit, increasing merge-conflict risk for concurrent contributors.switchstatement density (720 across two packages) suggests some dispatch logic could be table-driven or moved to smaller per-case files, though this is secondary to the file-size issue.Detailed Analysis
The four target files below were chosen because each has (a) a clear, mechanical split boundary along existing naming/semantic lines, (b) existing test coverage that can be relocated without new test-writing effort, and (c) high enough LOC/function-count to meaningfully reduce review and navigation burden once split.
🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Split
pkg/workflow/compiler_types.gointo options and mutators filesPriority: High
Estimated Effort: Medium
Focus Area: Monolithic File Decomposition
Description:
pkg/workflow/compiler_types.go(1000+ lines, 55 top-level functions) mixes two distinct concerns: (1)CompilerOptionfunctional-option constructors (e.g.WithVerbose,WithEngineOverride,WithSkipValidation,WithNoEmit,WithFailFast,WithWorkflowIdentifier,WithVersion) and (2)*Compilerstruct method setters/getters (e.g.SetSkipValidation,SetContext,SetModelPricingResolver,SetRequireDocker,SetQuiet,SetBatchMode,GetExperimentalFeatureUsage). Split intopkg/workflow/compiler_options.go(allWith*functional options and theCompilerOptiontype) and keepcompiler_types.gofor theCompilerstruct definition,NewCompiler, and its methods. Move corresponding test cases fromcompiler_types_test.gointo a newcompiler_options_test.gofollowing the same split.Acceptance Criteria:
pkg/workflow/compiler_options.gocreated containing allWith*option constructor functions and theCompilerOptiontype aliaspkg/workflow/compiler_types.goretains onlyCompilerstruct,NewCompiler, andSet*/Get*methodsgo build ./...andgo test ./pkg/workflow/...pass with no behavior changeCode Region:
pkg/workflow/compiler_types.go(lines 1–220, functional options section)Task 2: Split
pkg/cli/audit.gointo command wiring, execution, and error-classification filesPriority: High
Estimated Effort: Medium
Focus Area: Monolithic File Decomposition
Description:
pkg/cli/audit.go(1095 lines, 49 functions) combines three distinct responsibilities: Cobra CLI command registration (NewAuditCommand,registerAuditCommandFlags,runAuditCommand,getAuditCommandOptions,resolveAuditCommandArgs), core audit execution (runAuditSingle,runAuditMulti,AuditWorkflowRun,newAuditRunConfig,resolveAuditHostname,resolveAuditOutputDir,ensureAuditNotCancelled,applyAuditRepoFlag), and low-level error classification helpers (isPermissionErrorStr,isPermissionError). Split intopkg/cli/audit_command.go(Cobra wiring) andpkg/cli/audit_errors.go(error classification helpers), keepingaudit.gofor the coreAuditWorkflowRunexecution logic.Acceptance Criteria:
pkg/cli/audit_command.gocreated withNewAuditCommand,registerAuditCommandFlags,runAuditCommand,getAuditCommandOptions,resolveAuditCommandArgspkg/cli/audit_errors.gocreated withisPermissionErrorStr,isPermissionErrorpkg/cli/audit.goretainsrunAuditSingle,runAuditMulti,AuditWorkflowRun,newAuditRunConfig,resolveAuditHostname,resolveAuditOutputDir,ensureAuditNotCancelled,applyAuditRepoFlaggo build ./...andgo test ./pkg/cli/...pass with no behavior change; no public API changesCode Region:
pkg/cli/audit.go(lines 94–300)Task 3: Extract error-classification and helper logic from
pkg/parser/import_field_extractor.goPriority: Medium
Estimated Effort: Medium
Focus Area: Monolithic File Decomposition
Description:
pkg/parser/import_field_extractor.go(1045 lines, 51 functions) is disproportionately large compared to typical files inpkg/parser. Identify the logically distinct extraction phases/field-type groups within this file (e.g., string-field extraction vs. list/map-field extraction vs. validation helpers) and split into 2 focused files, e.g.pkg/parser/import_field_extractor.go(core dispatch/entry points) andpkg/parser/import_field_validators.go(validation-only helper functions).Acceptance Criteria:
go build ./...andgo test ./pkg/parser/...pass with no behavior changeCode Region:
pkg/parser/import_field_extractor.goTask 4: Split Cobra command registration out of
pkg/cli/add_package_manifest.goPriority: Medium
Estimated Effort: Small
Description:
pkg/cli/add_package_manifest.go(997 lines, 47 functions) is one of several large, actively-edited files inpkg/cli(alongsideupdate_actions.goat 1144 lines). Reduce merge-conflict risk and improve navigability by separating the Cobra command/flag registration boilerplate from the core package-manifest business logic (manifest parsing, generation, and validation functions), following the same pattern used for theaudit.gosplit in Task 2.Acceptance Criteria:
pkg/cli/add_package_manifest_command.gopkg/cli/add_package_manifest.gogo build ./...andgo test ./pkg/cli/...pass with no behavior changeCode Region:
pkg/cli/add_package_manifest.go📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
pkg/workflow/compiler_types.goandpkg/cli/audit.go(Tasks 1–2) — Priority: HighShort-term Actions (This Month)
pkg/parser/import_field_extractor.goandpkg/cli/add_package_manifest.go(Tasks 3–4) — Priority: MediumLong-term Actions (This Quarter)
📈 Success Metrics
Next Steps
Generated by Repository Quality Improvement Agent
Next analysis: 2026-08-12 — Focus area selected by diversity algorithm
All reactions