🔧 Semantic Function Clustering Analysis
Analysis of github/gh-aw — non-test .go files under pkg/ (986 files). Method: cross-package function-name clustering + Serena/gopls-assisted symbol inspection.
Overview
The codebase is already well-organized. It follows a strict one-feature-per-file convention (codemod_*.go, compile_*.go, logs_*.go, audit_*.go, gateway_logs_*.go), a dedicated stringutil package for shared string helpers, and consistent *_wasm.go build-tag splits. A full duplicate sweep across all top-level functions surfaced only one genuine cross-package near-duplicate plus a couple of low-priority indirection cleanups. No misplaced-function (outlier) issues of note were found.
Most apparent name collisions were false positives and are called out below so future runs don't re-flag them.
Key finding — duplicate compileSchema boilerplate
The JSON-schema compile boilerplate (NewCompiler → AddResource → Compile) is implemented twice, unexported, in two packages:
pkg/parser/schema_compiler.go:121 — func compileSchema(schemaJSON, schemaURL string) (*jsonschema.Schema, error)
pkg/workflow/schema_utils.go:14 — func compileSchema(schemaJSON, schemaURL string) (*jsonschema.Schema, error)
The bodies are functionally identical (differ only in log lines and error-message wording). workflow already imports parser (one-directional; parser does not import workflow), so consolidation is safe.
Recommendation: export the parser implementation (e.g. parser.CompileSchema) — or extract a small shared schemautil package — and have pkg/workflow/schema_utils.go delegate to it. Callers of the workflow copy: samples_validation.go:82, awf_config.go:94, schema_validation.go:64.
Impact: removes one duplicated implementation; low effort (~30 min), no behavior change.
Low-priority: delegating wrappers that add indirection
These are already correct (they forward to stringutil) but add a layer that callers could skip. Keep if the extra logging / API stability is intentional:
pkg/parser/schema_suggestions.go:231 FindClosestMatches and :241 LevenshteinDistance → forward to stringutil.*
pkg/workflow/strings.go:97 SanitizeName → forwards to stringutil.SanitizeName
Optional cleanup: point call sites directly at stringutil and drop the wrappers, unless the local Printf logging is desired.
False positives (NOT duplicates — do not refactor)
- Build-tag pairs — same signature in
foo.go (//go:build !js && !wasm) and foo_wasm.go (//go:build js || wasm). Legitimate platform variants: all pkg/console/* Format*/Render*/Print*/Spinner/Progress/ConfirmAction/isTTY; pkg/workflow/github_cli*.go ExecGH*/RunGH*; git_helpers*.go RunGitCombined/findGitRoot; docker_validation*.go isDockerDaemonRunning; pkg/parser/remote_fetch*.go ResolveIncludePath/IsWorkflowSpec/isWorkflowSpec; pkg/parser/github*.go GetGitHubToken.
- Interface implementations across engine/type variants —
RenderMCPConfig, GetSupportedEnvVarKeys, GetInstallationSteps, GetExecutionSteps, String, Error, UnmarshalJSON, IsValid, etc. (9× each). Expected polymorphism, not duplication.
- Cobra command handlers — 39×
run, one per command file. Idiomatic.
- Linter testdata fixtures — e.g.
pkg/linters/errormessage/testdata/.../NewValidationError. Intentional test inputs.
- Same-name / different-purpose —
extractToolsFromFrontmatter exists in parser ((string, error)) and workflow (map[string]any); different contracts, name collision only.
Next actions
Analysis metadata
Generated by 🔧 Semantic Function Refactoring · 192.7 AIC · ⌖ 7.77 AIC · ⊞ 9.2K · ◷
🔧 Semantic Function Clustering Analysis
Analysis of
github/gh-aw— non-test.gofiles underpkg/(986 files). Method: cross-package function-name clustering + Serena/gopls-assisted symbol inspection.Overview
The codebase is already well-organized. It follows a strict one-feature-per-file convention (
codemod_*.go,compile_*.go,logs_*.go,audit_*.go,gateway_logs_*.go), a dedicatedstringutilpackage for shared string helpers, and consistent*_wasm.gobuild-tag splits. A full duplicate sweep across all top-level functions surfaced only one genuine cross-package near-duplicate plus a couple of low-priority indirection cleanups. No misplaced-function (outlier) issues of note were found.Most apparent name collisions were false positives and are called out below so future runs don't re-flag them.
Key finding — duplicate
compileSchemaboilerplateThe JSON-schema compile boilerplate (
NewCompiler → AddResource → Compile) is implemented twice, unexported, in two packages:pkg/parser/schema_compiler.go:121—func compileSchema(schemaJSON, schemaURL string) (*jsonschema.Schema, error)pkg/workflow/schema_utils.go:14—func compileSchema(schemaJSON, schemaURL string) (*jsonschema.Schema, error)The bodies are functionally identical (differ only in log lines and error-message wording).
workflowalready importsparser(one-directional;parserdoes not importworkflow), so consolidation is safe.Recommendation: export the
parserimplementation (e.g.parser.CompileSchema) — or extract a small sharedschemautilpackage — and havepkg/workflow/schema_utils.godelegate to it. Callers of the workflow copy:samples_validation.go:82,awf_config.go:94,schema_validation.go:64.Impact: removes one duplicated implementation; low effort (~30 min), no behavior change.
Low-priority: delegating wrappers that add indirection
These are already correct (they forward to
stringutil) but add a layer that callers could skip. Keep if the extra logging / API stability is intentional:pkg/parser/schema_suggestions.go:231FindClosestMatchesand:241LevenshteinDistance→ forward tostringutil.*pkg/workflow/strings.go:97SanitizeName→ forwards tostringutil.SanitizeNameOptional cleanup: point call sites directly at
stringutiland drop the wrappers, unless the localPrintflogging is desired.False positives (NOT duplicates — do not refactor)
foo.go(//go:build !js && !wasm) andfoo_wasm.go(//go:build js || wasm). Legitimate platform variants: allpkg/console/*Format*/Render*/Print*/Spinner/Progress/ConfirmAction/isTTY;pkg/workflow/github_cli*.goExecGH*/RunGH*;git_helpers*.goRunGitCombined/findGitRoot;docker_validation*.goisDockerDaemonRunning;pkg/parser/remote_fetch*.goResolveIncludePath/IsWorkflowSpec/isWorkflowSpec;pkg/parser/github*.goGetGitHubToken.RenderMCPConfig,GetSupportedEnvVarKeys,GetInstallationSteps,GetExecutionSteps,String,Error,UnmarshalJSON,IsValid, etc. (9× each). Expected polymorphism, not duplication.run, one per command file. Idiomatic.pkg/linters/errormessage/testdata/.../NewValidationError. Intentional test inputs.extractToolsFromFrontmatterexists inparser((string, error)) andworkflow(map[string]any); different contracts, name collision only.Next actions
compileSchemaimplementations (Priority 1, low effort)stringutildelegating wrappers inparser/workflowif the extra logging isn't neededAnalysis metadata
pkg/)compileSchema)[lint-monster]issues ([lint-monster] Function-length refactoring backlog (2026-06-30) #42403, [lint-monster] Non-workflow function-length refactoring (2026-06-29) #42162) track function length, a separate concern — no overlap and no[refactor]-prefixed issues existed to close.