[typist] Type Consistency Analysis: Codebase Already Well-Consolidated, 3 Minor Opportunities #36887
Replies: 1 comment
-
|
Smoke beast was here. Tiny boots in dust. Test fire still warm. Warning Firewall blocked 6 domainsThe following domains were blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "accounts.google.com"
- "android.clients.google.com"
- "clients2.google.com"
- "contentautofill.googleapis.com"
- "safebrowsingohttpgateway.googleapis.com"
- "www.google.com"See Network Configuration for more information.
|
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· 2026-06-04Executive Summary
Good news first: this codebase is in unusually good shape on type consistency. I swept all 853 non-test
.gofiles underpkg/(excluding*_test.goandpkg/linters/*/testdata/fixtures), covering 867 type declarations, and found zero genuine cross-package type-name collisions that need deduplicating. Every repeated type name is either a build-tag variant inside the same package (ProgressBar,SpinnerWrapper,RepositoryFeatures— native vs._wasm.gostub) or already deliberately consolidated.The interesting part is how the duplication was already removed: the team consistently reaches for Go's two idiomatic tools — type aliases (
type X = pkg.Y) and struct embedding. The MCP config family embedstypes.BaseMCPServerConfig; the safe-output*Configfamily embedsBaseSafeOutputConfig;InputDefinition,SanitizeOptions,LogMetrics, and theactionpinstypes are single-source structs re-exported via aliases. That's exactly what a "consolidate duplicates" refactor produces, so there's little left to do.So this report is short on "fix this duplicate" and longer on a few small, high-confidence opportunities. Net impact is low-to-medium — polish, not rescue.
Full Analysis Report
Duplicated Type Definitions
Summary Statistics
testdata/)pkg/cli/audit_report.go)Cluster 1: MCP stat structs — the one real opportunity
Near-duplicate, single package · 3 occurrences · Impact: Low–Medium
All in
pkg/cli/audit_report.go::170type MCPToolSummary struct:184type MCPToolCall struct:198type MCPServerStats structAll three repeat the cluster
ServerName, input/output sizes,AvgDuration,ErrorCount.MCPToolSummaryandMCPServerStatsshare ~70–80% of the smaller struct's fields.Recommendation (with caveat): extract an embedded base (
TotalInputSize,TotalOutputSize int,AvgDuration string,ErrorCount int). Caveat: the three carry differentjson:andconsole:struct tags (e.g.console:"header:Total Input,format:number"), so per-struct column headers must be verified before/after — that's likely why it wasn't already factored out. Effort 1–2 h · Risk Low (tag-sensitive).Already-consolidated clusters (no action — listed so reviewers don't "re-fix")
View 10 already-consolidated clusters
types.BaseMCPServerConfigworkflow,parser)BaseEngine/UniversalLLMConsumerEngineCloseEntityConfigIssueReportingConfigtypes.InputDefinitionparser,workflow)workflow.LogMetrics/ToolCallInfocli)console.ErrorPositionworkflow.FieldLocationstringutil.SanitizeOptionsworkflow)actionpins.*(5 types)workflow)AddCommentsConfigAddCommentConfigPattern to keep: define once in the lowest-level package (
pkg/types,pkg/console,pkg/stringutil), alias/embed upward.Untyped Usages
Summary Statistics (non-test source)
map[string]any/map[string]interface{}: ~2,062 across 332 files[]any/[]interface{}: ~386anystruct fields (YAML unions): ~15Category 1:
map[string]anyat the YAML/JSON boundary — mostly idiomatic, don't chaseThe dominant pattern (~2,000 sites) is
map[string]anyfrom YAML frontmatter and JSON log parsing —ParseFrontmatterConfig,MergeTools,ExtractJSONTokenUsage. This is largely correct Go: at an arbitrary-YAML boundary there's no honest stronger type until you inspect the keys. The codebase already parses these maps into concrete structs early (FrontmatterConfig,EngineAuthConfig,RequestShape,TokenWeights) and centralizes scalar coercion inpkg/typeutil. No mass refactor. Only watch for maps passed through several layers before being typed.Category 2: Polymorphic
anystruct fields (YAML unions) — semi-intentionalA few fields are
anybecause the YAML genuinely accepts multiple shapes:On anycli/status_command.go:35,cli/list_workflows_command.go:25ContinueOnError anyworkflow/step_types.go:28Ports anyworkflow/service_ports.go:50DeduplicateByTitle anyworkflow/create_issue.go:19Default anytypes/input_definition.go:18These are real union types, so
anyis defensible. A custom type withUnmarshalYAMLwould move the type switch into one place instead of scattering.(bool)/.(string)across call sites. Low priority — worth it only for fields read in 3+ places (On,ContinueOnError).Category 3: Untyped network-port constants — clean, low-effort win
pkg/constants/constants.godeclares ports as untyped constants (DefaultMCPGatewayPort = 8080,MinNetworkPort = 1,MaxNetworkPort = 65535, the four*LLMGatewayPort, ...). Atype Port intwould make the domain explicit and let the valid range be type-checked.Caveat (Go idiom): untyped constants are deliberately flexible —
8080assigns toint/int32/a field without a cast.type Port intmeans consumers passing these tointparams or tostrconv/fmtmay need conversions. Judgement call: clarity + typed range vs. boundary casts. Effort 2–3 h · Impact Medium clarity.Not flagged (correct as-is)
error;anyin generic helpers (typeutil,console.RenderStruct(v any),sliceutil);map[string]anyat parse boundaries;*_test.goandtestdata/(out of scope).Recommendations (prioritized)
There is no Priority-1 "critical" item — the codebase lacks the duplicated-
Config-everywhere problem this analysis usually hunts. The below is optional polish by value/effort.pkg/cli/audit_report.go). Verifyjson/consoletags render identically. Effort 1–2 h · Risk Low.Porttype for thepkg/constantsport block; fix boundary conversions. Effort 2–3 h · Risk Low–Medium.UnmarshalYAMLunion types for the most-read fields (On,ContinueOnError) only. Effort 2–4 h each · Risk Medium.Keep doing (no work item): "define once in the lowest package, alias/embed upward" and "parse
map[string]anyinto a typed struct early."Implementation Checklist
MCPToolSummary/MCPServerStats/MCPToolCall; verify renderingtype Port int; retype port constants; fix conversions; run buildUnmarshalYAMLunions forOnandContinueOnError(optional)go test ./...and project linters after each changeAnalysis Metadata
pkg/, excl.testdata/) · Type declarations: 867map[string]anyusages (non-test): ~2,062duplicate-type-findersub-agent + Serena activation + ripgrep cross-checkReferences: §26951325683
Beta Was this translation helpful? Give feedback.
All reactions