[repository-quality] 🎯 Repository Quality Improvement Report - Monolithic File Risk in pkg/cli & pkg/workflow #54007
Closed
Replies: 1 comment
|
This discussion was automatically closed because it expired on 2026-08-20T13:13:19.743Z.
|
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-19
Focus Area: Monolithic Go File Risk Reduction (Code Organization / Maintainability)
Strategy Type: Custom
Custom Area: Yes — this is the first tracked run (no history in cache memory), and the pre-computed metrics flagged an unusually large concentration of 1000+ line Go files (12 files ≥1000 LOC, 165 files >800 LOC) concentrated almost entirely in
pkg/cliandpkg/workflow. This is a repo-specific structural risk rather than a generic quality checklist item, so a custom deep-dive was more valuable than a standard category this run.Executive Summary
This is the inaugural quality-improvement run for
gh-aw(no prior focus-area history was found in cache memory), so the pass established a baseline covering file size distribution, test-to-source ratio, and function density in the largest files. The repository is generally healthy — test LOC (543,766) nearly doubles source LOC (277,772), a strong 1.96:1 ratio — but a cluster of very large files stands out:pkg/cli/add_package_manifest.go(1330 lines, 69 functions) andpkg/parser/import_field_extractor.go(1045 lines, 51 functions) are dense with many small, loosely related functions, suggesting these files have accreted responsibilities over time and would benefit from splitting into focused sub-files by concern (following the project's owndeveloper-code-organizationskill guidance).By contrast,
pkg/workflow/safe_outputs_handler_registry.go(1074 lines) is mostly a single large declarative map literal (only 4 real functions) — its size is structural/data-driven rather than a complexity smell, so it was excluded from the refactor task list. The highest-value opportunities areadd_package_manifest.go,pkg/cli/audit.go(1098 lines, 49 functions),pkg/cli/logs_metrics.go(1062 lines, 14 functions with likely large functions), andpkg/parser/import_field_extractor.go. Splitting these along existing logical boundaries (already partially reflected in their function names) will reduce single-file cognitive load, ease code review, and align with the repo's stated code-organization conventions without changing any behavior.Full Analysis Report
Focus Area: Monolithic Go File Risk Reduction
Current State Assessment
Metrics Collected:
pkg/cli/add_package_manifest.go(1330 LOC, 69 funcs)context.TODO()refs, not backlog debt)pkg/clitotal filesFindings
Strengths
bootstrap_config.go,add_interactive_orchestrator.go).pkg/cliandpkg/workflowalready use per-concern file naming conventions (e.g.add_workflow_resolution.go,workflow_errors.go), so splitting large files has clear natural seams to follow.Areas for Improvement
pkg/cli/add_package_manifest.go(1330 LOC / 69 funcs) mixes manifest parsing, validation, and resolution logic in one file.pkg/cli/audit.go(1098 LOC / 49 funcs) is the primary entry point forgh aw auditbut bundles data collection, formatting, and orchestration together — companion filesaudit_report.go(1037) andaudit_diff.go(998) suggest the split pattern already exists butaudit.goitself hasn't been fully decomposed.pkg/cli/logs_metrics.go(1062 LOC, only 14 funcs) implies large average function size (~76 LOC/func) — a sign of functions doing too much rather than too many small helpers.pkg/parser/import_field_extractor.go(1045 LOC / 51 funcs) — extraction logic for many import field types is centralized in one file.pkg/workflow/safe_outputs_handler_registry.go(1074 LOC) is a declarative registry map, not complex logic — low refactor value.Detailed Analysis
The pattern across
pkg/cli/audit.go,pkg/cli/audit_report.go, andpkg/cli/audit_diff.goshows the team already splits large features into_report.go/_diff.gosiblings — this convention should simply be extended to the remaining monoliths. Foradd_package_manifest.go, the 69 functions are prime candidates for grouping intoadd_package_manifest_parse.go,add_package_manifest_validate.go, andadd_package_manifest_resolve.go(mirroring the existingadd_package_manifest_mapping_test.gosplit for tests). Forlogs_metrics.go, the low function-to-line ratio suggests looking for functions exceeding ~150 lines that could be broken into smaller named helpers before splitting files.import_field_extractor.go's 51 functions likely map one-to-one with import field types/tags, making a per-category split (e.g.import_field_extractor_scalar.go,import_field_extractor_composite.go) low-risk and mechanical.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Split
pkg/cli/add_package_manifest.goby responsibilityPriority: Medium
Estimated Effort: Medium
Focus Area: Code Organization
Description:
pkg/cli/add_package_manifest.gois 1330 lines with 69 functions covering manifest parsing, validation, and resolution. Split it into cohesive sub-files (e.g.add_package_manifest_parse.go,add_package_manifest_validate.go,add_package_manifest_resolve.go) without changing any exported behavior or function signatures.Acceptance Criteria:
make test-unitpasses unchangedmake fmtandgo build ./...succeedadd_package_manifest_test.goandadd_package_manifest_mapping_test.gorequire no changes beyond file location if any test helpers movedCode Region:
pkg/cli/add_package_manifest.goTask 2: Decompose
pkg/cli/audit.gofollowing the existing audit_report/audit_diff patternPriority: Medium
Estimated Effort: Medium
Focus Area: Code Organization
Description:
pkg/cli/audit.go(1098 lines, 49 functions) bundles orchestration, data collection, and formatting forgh aw audit. The package already splits related concerns intoaudit_report.goandaudit_diff.go— extend that same pattern toaudit.goitself by extracting data-collection and formatting helpers into new sibling files.Acceptance Criteria:
audit.goreduced to primarily command wiring/orchestrationaudit_collect.go,audit_format.go)go build ./...,make fmt, and targetedmake test-unitforpkg/clipassCode Region:
pkg/cli/audit.goTask 3: Break down oversized functions in
pkg/cli/logs_metrics.goPriority: Low
Estimated Effort: Small
Focus Area: Code Quality
Description:
pkg/cli/logs_metrics.gois 1062 lines with only 14 functions (~76 LOC/function average), suggesting some functions handle too many concerns. Identify functions over ~150 lines and refactor them into smaller, named helper functions to improve readability and testability, without splitting the file itself unless a natural seam emerges.Acceptance Criteria:
go build ./...,make fmt, targetedmake test-unitforpkg/clipassCode Region:
pkg/cli/logs_metrics.goTask 4: Split
pkg/parser/import_field_extractor.goby field categoryPriority: Low
Estimated Effort: Medium
Focus Area: Code Organization
Description:
pkg/parser/import_field_extractor.go(1045 lines, 51 functions) centralizes extraction logic for many different import field types. Split it into per-category files (e.g. scalar fields, composite/list fields, nested object fields) to make it easier to locate and extend field-extraction logic.Acceptance Criteria:
go build ./...,make fmt, and targetedmake test-unitforpkg/parserpassCode Region:
pkg/parser/import_field_extractor.go📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
pkg/cli/add_package_manifest.gointo responsibility-based files — Priority: Mediumpkg/cli/audit.gofollowing the existing audit_report/audit_diff split pattern — Priority: MediumShort-term Actions (This Month)
pkg/cli/logs_metrics.go— Priority: Lowpkg/parser/import_field_extractor.goby field category — Priority: LowLong-term Actions (This Quarter)
📈 Success Metrics
add_package_manifest.go) → under 600 LOC per file after splitNext Steps
Generated by Repository Quality Improvement Agent
Next analysis: 2026-08-20 — Focus area selected by diversity algorithm
All reactions