[typist] Typist - Go Type Consistency Analysis #26855
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-04-18T11:43:11.441Z.
|
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.
-
Analysis of the
github/gh-awrepository across 211 non-test Go files inpkg/(717 total across the repo). The codebase has zero legacyinterface{}usages — it has fully adopted theanyalias — but has 1,929anyoccurrences, 4 critical naming conflicts, and several opportunities for stronger typing.Executive Summary
anyusages: 1,929 lines (1,503map[string]any, 326[]any, remainder in function signatures)The
anyusage is heavily concentrated in YAML/JSON unmarshaling, JSON schema validation, and dynamic tool configuration — areas where dynamic types are architecturally justified. However, the naming conflicts create real maintainability risk.Full Analysis Report
Duplicated Type Definitions
Summary Statistics
Cluster 1:
MCPServerConfig— Critical ConflictType: Naming conflict — both embed
types.BaseMCPServerConfigbut have incompatible extension fieldsOccurrences: 2
Impact: High — different serialization tags (json vs yaml), different field sets
Locations:
pkg/parser/mcp.go:33— Parser-facing definitionpkg/workflow/tools_types.go:395— Workflow-facing definitionDefinition Comparison:
Recommendation: Rename to distinguish roles.
pkg/parser/mcp.go→RegistryMCPServerConfig(orParsedMCPServerConfig)pkg/workflow/tools_types.go→CompiledMCPServerConfig(orWorkflowMCPServerConfig)Cluster 2:
EngineConfig— Critical ConflictType: Completely different structures sharing a name
Occurrences: 2
Impact: High — runtime config (30+ fields, no JSON tags) vs audit report struct (9 JSON-tagged fields)
Locations:
pkg/workflow/engine.go:17— Runtime engine configurationpkg/cli/audit_expanded.go:19— Audit log serializationDefinition Comparison:
Recommendation: Rename the CLI audit type to reflect its actual purpose.
pkg/cli/audit_expanded.go→AuditEngineConfigorEngineAuditRecordCluster 3:
RepoConfig— Critical ConflictType: Completely different structures sharing a name
Occurrences: 2
Impact: Medium — maintenance config vs trial run repository context
Locations:
pkg/workflow/repo_config.go:78— Workflow maintenance configpkg/cli/trial_types.go:24— Trial run repo contextDefinition Comparison:
Recommendation: Rename the trial types to be unambiguous.
pkg/cli/trial_types.go→TrialRepoContextorTrialRepoConfigCluster 4:
FileTracker— Interface/Struct ConflictType: Interface defined in workflow, concrete struct defined in CLI — same name
Occurrences: 2
Impact: Medium — naming confusion between abstraction and implementation
Locations:
pkg/workflow/compiler_types.go:52— Minimal interfacepkg/cli/file_tracker.go:19— Full struct implementationDefinition Comparison:
Recommendation: Follow Go conventions for interface/implementation naming.
FileCreationTracker(focused on its single method), ORFileTrackerImplorCLIFileTrackerClusters 5–7: Platform-Specific Splits (Acceptable)
These type name pairs are separated by
//go:build js || wasmbuild tags — intentional and correct:ProgressBarpkg/console/progress.go:31pkg/console/progress_wasm.go:7SpinnerWrapperpkg/console/spinner.go:96pkg/console/spinner_wasm.go:10RepositoryFeaturespkg/workflow/repository_features_validation.go:57pkg/workflow/repository_features_validation_wasm.go:5No action needed — this is the standard Go build constraint pattern.
Untyped
anyUsagesSummary Statistics
map[string]anyusages[]anyusagesanyin function parametersanystruct fieldsCategory 1: YAML Unmarshaling (Architecturally Justified)
Impact: Low risk — standard Go pattern for YAML/JSON
Files:
pkg/parser/frontmatter_content.go,pkg/workflow/compiler_jobs.go, and ~30 othersThe root cause is
yaml.Unmarshalproducingmap[string]any:Existing mitigation: The codebase already introduced
ToolsConfigas a typed wrapper:Recommendation: Extend this pattern to other repeated
map[string]anypatterns (e.g.,FrontmatterResult.Frontmatter,TriggerData.Filters).Category 2: Schema Navigation (Justified but Improvable)
Impact: Medium risk — deep type assertion chains, runtime panic risk if
okcheck missedTop files:
pkg/parser/schema_suggestions.go(34 usages),pkg/parser/import_field_extractor.go(33 usages)Current pattern requires chained type assertions:
Recommendation: Extract a
SchemaNodehelper type:Category 3: Function Parameters with
any(Improvable)Impact: Medium — reduces IDE autocomplete and call-site type checking
Count: ~25 functions across the codebase
Key examples:
processBuiltinMCPToolpkg/parser/mcp.go:253toolValue anytoolValue map[string]anyParseMCPConfigpkg/parser/mcp.go:482mcpSection anymcpSection map[string]anyvalidateStringPropertypkg/parser/mcp_property_validation.go:25value anyvalue stringorvalue map[string]anygenerateExampleFromSchemapkg/parser/schema_suggestions.goanyjson.RawMessagenormalizeForJSONSchemapkg/workflow/tools_parser.gov anyreturnsanyjson.RawMessageRecommendation: Replace
anyparameters withmap[string]anywhere that is always the actual type — this is a safe narrowing with zero behavior change.Category 4: Struct Fields with
any(Improvable)Impact: Medium — fields typed as
anylose compile-time safetyFrontmatterResult(parser/)Frontmattermap[string]anyFrontmatterData(typed struct)Toolsmap[string]any*ToolsConfig(already exists)MCPServerConfig(workflow)GuardPoliciesmap[string]anyGuardPolicyConfigstructservice_ports.goPortsanyPortSpec(string | int | []int union via interface)Refactoring Recommendations
Priority 1 — High Impact, Low Effort: Rename Conflicting Types
Actions:
pkg/cli/audit_expanded.go: RenameEngineConfig→AuditEngineConfigpkg/cli/trial_types.go: RenameRepoConfig→TrialRepoContextpkg/parser/mcp.go: RenameMCPServerConfig→RegistryMCPServerConfigpkg/workflow/compiler_types.goorpkg/cli/file_tracker.go: ResolveFileTrackernamingEstimated effort: 4–6 hours total
Risk: Low — purely mechanical rename with no semantic change
Priority 2 — Medium Impact: Narrow
anyParameters tomap[string]anyWhere function parameters typed
anyalways receivemap[string]any, change the signature. This is a no-op at runtime but improves IDE tooling and prevents misuse.Estimated effort: 2–3 hours
Risk: Very low — narrowing a parameter type is backward compatible within a package
Priority 3 — Higher Effort: Introduce Typed Wrappers
Extend the existing
ToolsConfigpattern:FrontmatterDatatyped struct to replacemap[string]anyin frontmatter resultsSchemaNodehelper type for schema navigationGuardPolicyConfigstruct for MCP guard policiesEstimated effort: 8–16 hours (requires updating callers)
Risk: Medium — requires coordinated changes across multiple files
Implementation Checklist
EngineConfiginpkg/cli/audit_expanded.go→AuditEngineConfigRepoConfiginpkg/cli/trial_types.go→TrialRepoContextMCPServerConfiginpkg/parser/mcp.go→RegistryMCPServerConfigFileTrackernaming conflict (interface vs struct)anyparameters tomap[string]anyinpkg/parser/mcp.goSchemaNodehelper type for schema navigationToolsConfigpattern to coverFrontmatterResult.FrontmatterAnalysis Metadata
anyusage locationsmap[string]anycountinterface{}countReferences: Workflow Run §24563067306
Beta Was this translation helpful? Give feedback.
All reactions