[typist] Type Consistency Analysis: zero duplicate types, a few enum-typing opportunities #37108
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-06-06T12:33:19.888Z.
|
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.
-
🔤 Typist — Go Type Consistency Analysis
Repository:
github/gh-aw· 880 non-test.gofiles underpkg/(~682 type definitions) · 2026-06-05Executive Summary
Good news first:
gh-awis already a remarkably type-disciplined codebase. I swept every non-test Go file underpkg/hunting for copy-pasted types and weakinterface{}plumbing — and the obvious problems simply aren't there. There are zero genuine cross-package duplicate struct definitions: every type name that shows up in two packages is a deliberate alias (type X = pkg.X), a build-tag (WASM vs native) variant, or one unrelated name collision. The MCP config types already share a base via embedding (types.BaseMCPServerConfig) rather than copy-paste.The untyped story is similar. There is no
interface{}debt in production code (the only hits live in linter test fixtures), and the ~3,300anyusages are overwhelmingly legitimate — JSON/YAML frontmatter parsing, recursive marshalling, and reflection registries that should stay dynamic. So instead of a long refactor list, the real opportunities are a tight, high-confidence set: a handful of untyped string-enum constants that deserve named types, plus a few fixed-schemamap[string]anyfrontmatter fields that would read better as structs. Low-risk polish, not firefighting. Nicely done, team. 👏Full Analysis Report
Duplicated Type Definitions
Genuine cross-package duplicate clusters: 0 (13 cross-directory name matches inspected — all benign).
ActionPin/ActionPinsData/SHAResolveretc. (pkg/actionpins/actionpins.go→ aliased inpkg/workflow/action_pins.go);InputDefinition(pkg/types/input_definition.go:15→pkg/workflow/inputs.go:18,pkg/parser/import_processor.go:89);LogMetrics/ToolCallInfo(pkg/workflow/metrics.go→pkg/cli/logs_models.go);SanitizeOptions(pkg/stringutil/sanitize.go:53→pkg/workflow/strings.go:97).RepositoryFeatures,SpinnerWrapper(pkg/console/spinner.go:96/spinner_wasm.go:10),ProgressBar(pkg/console/progress.go:31/progress_wasm.go:7).LogParser— aninterfaceinpkg/workflow/agentic_engine.go:182vs a genericfunctype inpkg/cli/log_aggregation.go:37. No consolidation possible.pkg/types/mcp.go:6 BaseMCPServerConfigis embedded bypkg/parser/mcp.go:38 RegistryMCPServerConfig; thepkg/workflowandpkg/clivariants are domain-specific and don't copy its fields.Out of scope (low value):
pkg/clihas several same-package report/summary structs with similar shapes but distinct serialization (e.g.ToolUsageSummary,MCPToolUsageSummary,MCPToolUsageData). Same-package, cosmetic — leave as-is.Untyped Usages
Counts:
interface{}in production = 0 (5 hits only inpkg/linters/uncheckedtypeassertion/testdata/) ·any≈ 3,334 (mostly idiomatic) ·map[string]any≈ 1,986 (mostly correct frontmatter).Category 1 —
anyin signatures: essentially nothing to fixAlmost every
anyparameter is genuinely polymorphic and should stayany:pkg/typeutil/convert.go:48,95,133(accept int/float/string from JSON/YAML),pkg/parser/frontmatter_hash.go:46(recursive canonicaliser),pkg/workflow/safe_output_handlers.go:17(func() anyreflection registry),pkg/logger/slog_adapter.go:86(slogcontract). The only mechanicalany → concretecandidates are threesync.Mapcast sites (pkg/parser/virtual_fs.go:75,96→*FrontmatterResult;pkg/workflow/repository_features_validation.go:185,216→*RepositoryFeatures) — all forced by the stdlibsync.MapAPI, so idiomatic as written. No action required.Category 2 —
map[string]anythat could be structs: 5 fixed-schema frontmatter fieldsMost
map[string]anyis correct dynamic frontmatter (the team annotates the dynamic ones, e.g.On/Jobscarry "too dynamic to type"). The exceptions inpkg/workflow/frontmatter_types.gomap to fixed GitHub Actions schemas:frontmatter_types.go:311Concurrency*ConcurrencyConfig{ Group string; CancelInProgress bool }frontmatter_types.go:332Container*ContainerConfig{ Image string; Env map[string]string; Ports/Volumes []string; Options string }frontmatter_types.go:333Servicesmap[string]ContainerConfigfrontmatter_types.go:334Cache*CacheConfig{ Key string; Path/RestoreKeys []string }frontmatter_types.go:331Environment*EnvironmentConfig{ Name string; URL string }Leave as-is (correctly dynamic):
On,Jobs,Features,Secrets,Experiments,ImportSchema, andvar x map[string]anyunmarshal targets.Category 3 — Untyped constants carrying semantic meaning (the richest category)
A few closed string enums are declared as bare
string:pkg/cli/mcp_registry_types.go:108-109StatusActive/StatusInactivebare strings (compared atmcp_registry.go:135)type ServerStatus stringpkg/cli/mcp_registry_types.go:114-115+Argument.Type(:71)stringfieldtype ArgumentType stringpkg/workflow/mcp_scripts_parser.go:64MCPScriptsModeHTTP = "http"type MCPScriptsMode stringpkg/workflow/mcp_scripts_parser.go:56MCPScriptParam.Type string // string,number,boolean,array,objecttype JSONSchemaType string+ 5 constsOptional (correct as ints, but typing prevents range/unit mix-ups):
type Port uint16for the network ports inpkg/constants/constants.go:105-135;time.Duration/TimeUnitfor the mixed-unit caps inpkg/workflow/time_delta.go:486-498; self-documenting byte-size literals (512 * 1000,1 << 20) inpkg/workflow/compiler.go:25-38.🎯 Recommendations
ServerStatus+ArgumentTypeinpkg/cli/mcp_registry_types.go(retypeArgument.Type, update comparison atmcp_registry.go:135);MCPScriptsMode+JSONSchemaTypeinpkg/workflow/mcp_scripts_parser.go. Benefit: compile-time validation, no stray values.Concurrency/Container/Services/Cache/Environmentinfrontmatter_types.go; keep the dynamic fields as-is.type Port uint16, normalized byte-size literals — only when touching nearby code.Checklist
ServerStatus/ArgumentTypenamed types (+ retypeArgument.Type, update comparisons)MCPScriptsMode/JSONSchemaTypenamed typestype Port uint16; normalize byte-size literalsgo build ./...+ full test suite after each changeDetection: ripgrep extraction + per-type body inspection + Serena project context, manually verified.
References: §27014455894
Beta Was this translation helpful? Give feedback.
All reactions