[repository-quality] Repository Quality Improvement Report - Go Source File Decomposition (2026-05-15) #32379
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-05-16T13:26:45.671Z.
|
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 - Go Source File Decomposition
Analysis Date: 2026-05-15
Focus Area: Go Source File Decomposition
Strategy Type: Custom
Custom Area: Yes — this repository has a documented 300-line hard limit (AGENTS.md) with many files far exceeding it; decomposition opportunities are concrete and high-value.
Executive Summary
The
pkg/workflowandpkg/parserpackages contain 29 source files exceeding 800 lines, with 6 files over 1000 lines — far above the 300-line target documented inAGENTS.md. These oversized files accumulate multiple distinct responsibilities, making navigation, testing, and review significantly harder.The most impactful candidates for decomposition are
domains.go(1041 lines, 23 functions spanning ecosystems, engines, runtimes, and network),frontmatter_extraction_yaml.go(1153 lines, 13 functions mixing YAML extraction logic for triggers, permissions, and commands), andimport_field_extractor.go(1172 lines, 18 functions covering import validation, schema checking, and input substitution).Each identified decomposition follows clear conceptual seams already present in the code, meaning these are straightforward extract-and-rename operations rather than architectural rewrites. Addressing the top 5 would reduce average file size by roughly 30% in the affected packages and align the codebase with its own documented standards.
Full Analysis Report
Focus Area: Go Source File Decomposition
Current State Assessment
Metrics Collected:
import_field_extractor.go(1172 lines)Findings
Strengths
compiler_yaml_main_job.go)Areas for Improvement
pkg/parser/import_field_extractor.go(1172 lines): 18 functions across import accumulation, schema validation, input substitution, and observability config merging — 4 distinct domains in one filepkg/workflow/frontmatter_extraction_yaml.go(1153 lines): Functions for trigger YAML extraction, permissions extraction, if-condition parsing, and command/label config — clear split points at lines ~107 (triggers) and ~765 (permissions/conditions)pkg/workflow/domains.go(1041 lines): 23 functions mixing ecosystem domain tables, engine-specific defaults, runtime-based domains, HTTP MCP domain extraction, network permission domains, and API target domainspkg/workflow/cache.go(1006 lines): Cache key generation, cache config types, and cache YAML step generation are intermingledpkg/workflow/imports.go(795 lines): Merge operations for 6 different config types (tools, MCP servers, network, safe-outputs, features, env) could each live in their own fileDetailed Analysis
pkg/workflow/domains.go— Highest-Value SplitThis file has 23 functions across clearly separable concerns:
domains_ecosystem.godomains_engine_defaults.godomains_runtime.godomains_network.godomains.go(reduced to ~350 lines)pkg/parser/import_field_extractor.go— Most Complex File18 functions across:
Each section is independently testable and has its own data types.
pkg/workflow/frontmatter_extraction_yaml.go— Trigger vs Non-TriggerThe file's 1153 lines break into:
frontmatter_extraction_triggers.go: The massivecommentOutProcessedFieldsInOnSectionfunction (lines 107–711, ~600 lines alone) handles trigger YAML processingfrontmatter_extraction_conditions.go:extractPermissions,extractIfCondition, deployment conditionsfrontmatter_extraction_commands.go:extractCommandConfig,extractLabelCommandConfig🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items. Each task is independently executable and requires no coordination with others.
Improvement Tasks
Task 1: Split
pkg/workflow/domains.gointo Focused Sub-filesPriority: High
Estimated Effort: Medium
Focus Area: Go Source File Decomposition
Description:
domains.gois 1041 lines with 23 functions across 4 conceptually distinct domains. Split it into sub-files following the seams already present in the code, while keeping the package-level API identical (no exported symbol renames).Acceptance Criteria:
domains_ecosystem.go: ecosystem domain lookup tables andinit()registration (lines ~1–399)domains_engine_defaults.go:getOpenCodeDefaultDomains,getCrushDefaultDomains,getPiDefaultDomains,GetDefaultDomainsForEngine(~lines 233–399 + 750–811)domains_runtime.go:getDomainsFromRuntimesand related helpers (~lines 399–487)domains.goretains:GetAllowedDomains,matchesDomain,GetDomainEcosystem, HTTP MCP extraction, blocked/API-target domain functions (~350 lines)make build && make test-unitpass with no changes to exported APICode Region:
pkg/workflow/domains.goTask 2: Split
pkg/parser/import_field_extractor.gointo Focused Sub-filesPriority: High
Estimated Effort: Medium
Focus Area: Go Source File Decomposition
Description:
import_field_extractor.gois the largest file at 1172 lines with 18 functions. It mixes import accumulation, schema validation, input substitution, and observability merging. Each section is independently testable.Acceptance Criteria:
import_field_extractor.goretains:importAccumulatorstruct,newImportAccumulator,extractAllImportFields,prepareFrontmatter,extractEngineConfig,extractConfigFields,extractActivationFields,extractStepAndJobFields,extractFeatureAndObservabilityFields,toImportsResult,computeImportRelPath,validateGitHubAppJSON(~700 lines)import_schema_validation.go:validateWithImportSchema,validateObjectInput,validateImportInputType,applyImportSchemaDefaultsFromFrontmatter(~165 lines)import_input_substitution.go:substituteImportInputsInContentand any helpers (~90 lines)import_observability.go:extractOTLPEndpointsFromObsMap,mergeObservabilityConfigs(~120 lines)make build && make test-unitpass with no changes to exported APICode Region:
pkg/parser/import_field_extractor.goTask 3: Split
pkg/workflow/frontmatter_extraction_yaml.gointo Trigger vs Non-TriggerPriority: Medium
Estimated Effort: Medium
Focus Area: Go Source File Decomposition
Description:
frontmatter_extraction_yaml.gois 1153 lines. ThecommentOutProcessedFieldsInOnSectionfunction alone is ~600 lines (handling all trigger YAML processing). Extract triggers and conditions into focused files.Acceptance Criteria:
frontmatter_extraction_triggers.go:commentOutProcessedFieldsInOnSection,addZizmorIgnoreForWorkflowRun, and trigger-specific helpers (~700 lines)frontmatter_extraction_conditions.go:extractPermissions,extractIfCondition,extractDeploymentStatusStateCondition,isValidWorkflowRunConclusion,extractWorkflowRunConclusionCondition,extractExpressionFromIfString(~230 lines)frontmatter_extraction_commands.go:extractCommandConfig,extractLabelCommandConfig,isGitHubAppNestedField(~230 lines)frontmatter_extraction_yaml.goretains:indentYAMLLines,extractTopLevelYAMLSection(~110 lines)make build && make test-unitpassCode Region:
pkg/workflow/frontmatter_extraction_yaml.goTask 4: Split
pkg/workflow/imports.goby Merge DomainPriority: Medium
Estimated Effort: Small
Focus Area: Go Source File Decomposition
Description:
imports.go(795 lines) has 10+ merge functions each handling a separate config domain (tools, MCP servers, network, safe-outputs, features, env). Each could be a focused file or logically grouped.Acceptance Criteria:
imports_tools.go:MergeTools,MergeMCPServers(~100 lines)imports_network.go:MergeNetworkPermissions(~65 lines)imports_safe_outputs.go:MergeSafeOutputs,hasSafeOutputType,mergeSafeOutputConfig,mergeMessagesConfig,getSafeOutputTypeKeys(~500 lines)imports_features.go:MergeFeatures,mergeEnv(~80 lines)imports.goremoved or retained as empty package doc filemake build && make test-unitpassCode Region:
pkg/workflow/imports.goTask 5: Add File-Size Linter Check for New Validator Files
Priority: Low
Estimated Effort: Small
Focus Area: Go Source File Decomposition
Description: The 300-line guideline is documented but unenforced. Add a lightweight CI check (shell script or Go test) that fails if any
*_validation.gofile exceeds 300 lines, preventing future drift specifically for the validator category.Acceptance Criteria:
Makefileor.github/workflows/ci.ymlthat finds*_validation.gofiles exceeding 300 linesmake lintor a dedicatedmake check-file-sizestarget*_validation.gofiles all pass (or violations are documented as known exceptions)make agent-finishpasses end-to-endCode Region:
Makefile,.github/workflows/ci.ymlOption B — Go test in
pkg/workflow/orpkg/parser/:A table-driven test that opens each
*_validation.gofile and assertslineCount <= 300.Add the chosen check to:
Makefileascheck-validator-sizestargetlinttarget's dependency list (or a newchecktarget).github/workflows/ci.ymlif it has a dedicated lint jobRun
make agent-finishto confirm all CI gates pass.Beta Was this translation helpful? Give feedback.
All reactions