You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Analysis of Go type consistency across 635 non-test source files in pkg/. The codebase is overall in excellent shape: interface{} has been fully eliminated from production code, and the architectural patterns for type reuse are well-designed. A small number of actionable improvements are identified below.
Executive Summary
619 type definitions analyzed across pkg/
8 duplicate type clusters found — most are intentional (build-tag stubs or proper aliasing)
Recommendation: Rename cli/audit_expanded.go's type to AuditEngineConfig or EngineAuditRecord to clearly distinguish it from the runtime workflow.EngineConfig.
The BaseMCPServerConfig file comment reads: "This base type is embedded by both parser.MCPServerConfig and workflow.MCPServerConfig to eliminate duplication." — this is the correct pattern.
Cluster 3: RepositoryFeatures — Build-Tag Stub ✅
Type: Identical struct redefined per build target Impact: None — idiomatic Go for platform splits
// Both define the same struct under different build constraints:// (go/redacted):build !wasm (full implementation + cache + mutex)// (go/redacted):build wasm (struct + no-op stub function)typeRepositoryFeaturesstruct {
HasDiscussionsboolHasIssuesbool
}
This is the standard Go approach for platform-specific implementations. The WASM file correctly provides a minimal stub. No change needed.
Same pattern as RepositoryFeatures — TUI structs have a full implementation for non-WASM targets and a lightweight stub for WASM builds. Intentional and correct.
Clusters 6–8: LogMetrics, FileTracker, LogParser — Not True Duplicates ✅
LogMetrics in cli/logs_models.go is = workflow.LogMetrics — a proper type alias
FileTracker is an interface in workflow and a concrete struct in cli — different purposes, same name by coincidence
LogParser is an interface in workflow/agentic_engine.go and a generic function type in cli/log_aggregation.go — different abstractions
Untyped Usages
interface{} — Fully Eliminated ✅
Production code count: 0
The codebase has fully migrated from interface{} to any. The only 2 remaining occurrences are in test files (mcp_server_compile_test.go).
any — Predominantly Justified, One Migration In Progress
Why any / map[string]any is valid here: GitHub Actions workflow YAML allows polymorphic values throughout (e.g., on: can be a string, list, or map; continue-on-error: can be bool or a template expression string; runs-on: can be a string or array). The Go YAML library requires any / map[string]any for these fields until a schema-driven discriminated union approach is implemented.
Active migration underway: pkg/workflow/frontmatter_types.go implements a FrontmatterConfig strongly-typed wrapper:
// Parses raw map into typed struct via JSON round-tripfuncParseFrontmatterConfig(frontmattermap[string]any) (*FrontmatterConfig, error)
// Reverse for backward compatibility during gradual migrationfunc (c*FrontmatterConfig) ToMap() map[string]any
The file comment notes: "This allows gradual migration from map[string]any to strongly-typed config." 13 call sites already use ParseFrontmatterConfig.
Struct fields typed as any by design (YAML polymorphism):
Field
File
Reason
Imports any
frontmatter_types.go:177
Can be string or []string
Include any
frontmatter_types.go:179
Can be string or []string
Checkout any
frontmatter_types.go:200
Can be object, array, or false
ContinueOnError any
step_types.go:25
bool or template expression string
Ports any
service_ports.go:50
Can be int, string, or map
ID any
gateway_logs.go:194
JSON-RPC IDs: string, number, or null
These are correct — Go unions or sum types don't exist in the current language, and any with type-switch handling is the idiomatic solution.
Untyped Constants — Idiomatic ✅
Count: ~119 package-level untyped constants
All are standard Go untyped literals (numeric thresholds, durations, string filenames). These are idiomatic Go — untyped constants provide implicit conversion flexibility and are not a code smell.
The ParseFrontmatterConfig / ToMap() pattern is the right approach. As more callers migrate from raw map[string]any to FrontmatterConfig, the dense any usages in compiler files will shrink organically. No immediate action required — the migration architecture is sound.
Priority 3 (Optional): Consider Typed ApplyFunc in Codemod Pattern
The codemod Apply field uses an anonymous function type repeated across 26 files:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Analysis of Go type consistency across 635 non-test source files in
pkg/. The codebase is overall in excellent shape:interface{}has been fully eliminated from production code, and the architectural patterns for type reuse are well-designed. A small number of actionable improvements are identified below.Executive Summary
pkg/EngineConfig)interface{}usages in production code — fully migrated toanyany/map[string]anyusages — largely justified by YAML polymorphism; one active migration underwayFull Analysis Report
Duplicated Type Definitions
Summary Statistics
Cluster 1:⚠️
EngineConfig— Naming CollisionType: Unrelated types with the same name in different packages
Impact: Medium — cognitive overhead, potential import confusion
pkg/workflow/engine.go:15pkg/cli/audit_expanded.go:19Definitions:
Recommendation: Rename
cli/audit_expanded.go's type toAuditEngineConfigorEngineAuditRecordto clearly distinguish it from the runtimeworkflow.EngineConfig.pkg/cli)Cluster 2:
MCPServerConfig— Intentional Divergence ✅Type: Two distinct types with the same name, intentionally extending a shared base
Impact: None — correctly designed
Both embed
types.BaseMCPServerConfigfrompkg/types/mcp.go, which is explicitly documented as the shared parent:The
BaseMCPServerConfigfile comment reads: "This base type is embedded by both parser.MCPServerConfig and workflow.MCPServerConfig to eliminate duplication." — this is the correct pattern.Cluster 3:
RepositoryFeatures— Build-Tag Stub ✅Type: Identical struct redefined per build target
Impact: None — idiomatic Go for platform splits
This is the standard Go approach for platform-specific implementations. The WASM file correctly provides a minimal stub. No change needed.
Clusters 4–5:
SpinnerWrapper,ProgressBar— Build-Tag Stubs ✅Same pattern as
RepositoryFeatures— TUI structs have a full implementation for non-WASM targets and a lightweight stub for WASM builds. Intentional and correct.Clusters 6–8:
LogMetrics,FileTracker,LogParser— Not True Duplicates ✅LogMetricsincli/logs_models.gois= workflow.LogMetrics— a proper type aliasFileTrackeris an interface inworkflowand a concrete struct incli— different purposes, same name by coincidenceLogParseris an interface inworkflow/agentic_engine.goand a generic function type incli/log_aggregation.go— different abstractionsUntyped Usages
interface{}— Fully Eliminated ✅Production code count: 0
The codebase has fully migrated from
interface{}toany. The only 2 remaining occurrences are in test files (mcp_server_compile_test.go).any— Predominantly Justified, One Migration In Progressmap[string]anyusages: ~1,439[]anyusages: ~295Dense files:
pkg/workflow/compiler_safe_outputs_config.gopkg/workflow/compiler_orchestrator_workflow.gopkg/workflow/frontmatter_types.gopkg/workflow/tools_parser.gopkg/workflow/tools.goWhy
any/map[string]anyis valid here: GitHub Actions workflow YAML allows polymorphic values throughout (e.g.,on:can be a string, list, or map;continue-on-error:can beboolor a template expression string;runs-on:can be a string or array). The Go YAML library requiresany/map[string]anyfor these fields until a schema-driven discriminated union approach is implemented.Active migration underway:
pkg/workflow/frontmatter_types.goimplements aFrontmatterConfigstrongly-typed wrapper:The file comment notes: "This allows gradual migration from map[string]any to strongly-typed config." 13 call sites already use
ParseFrontmatterConfig.Struct fields typed as
anyby design (YAML polymorphism):Imports anyfrontmatter_types.go:177[]stringInclude anyfrontmatter_types.go:179[]stringCheckout anyfrontmatter_types.go:200falseContinueOnError anystep_types.go:25boolor template expression stringPorts anyservice_ports.go:50ID anygateway_logs.go:194These are correct — Go unions or sum types don't exist in the current language, and
anywith type-switch handling is the idiomatic solution.Untyped Constants — Idiomatic ✅
Count: ~119 package-level untyped constants
All are standard Go untyped literals (numeric thresholds, durations, string filenames). These are idiomatic Go — untyped constants provide implicit conversion flexibility and are not a code smell.
Representative examples:
Refactoring Recommendations
Priority 1 (Actionable): Rename
EngineConfigincli/audit_expanded.goThe only genuine naming collision. Renaming this type improves code clarity with minimal effort.
Steps:
EngineConfig→AuditEngineConfiginpkg/cli/audit_expanded.gopkg/cli/(likely 5–10 locations)Estimated effort: 30–60 minutes
Risk: Low — type is package-private to
cliPriority 2 (Optional): Continue
FrontmatterConfigMigrationThe
ParseFrontmatterConfig/ToMap()pattern is the right approach. As more callers migrate from rawmap[string]anytoFrontmatterConfig, the denseanyusages in compiler files will shrink organically. No immediate action required — the migration architecture is sound.Priority 3 (Optional): Consider Typed
ApplyFuncin Codemod PatternThe codemod
Applyfield uses an anonymous function type repeated across 26 files:A named type alias could improve readability:
Estimated effort: 15 minutes
Benefit: Improved IDE navigation and documentation; all 26
Apply:literals would display asCodemodApplyFuncImplementation Checklist
EngineConfig→AuditEngineConfiginpkg/cli/audit_expanded.go(Priority 1)FrontmatterConfigmigration as new compiler code is written (Ongoing)CodemodApplyFuncnamed type tofix_codemods.go(Low effort)interface{}usages inmcp_server_compile_test.go(Minor)Analysis Metadata
interface{}in productionany/map[string]anyusagesReferences:
Beta Was this translation helpful? Give feedback.
All reactions