[typist] π€ Typist β Go Type Consistency Analysis #38833
Closed
Replies: 1 comment
-
|
This discussion was automatically closed because it expired on 2026-06-13T12:47:37.464Z.
|
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.
-
Repository: github/gh-aw Β· 910 non-test
.gofiles underpkg/Β· ~795 type definitionsExecutive Summary
Good news first: this codebase is in genuinely good shape on type discipline. Most of the "obvious" duplication targets have already been consolidated β MCP server configs embed a shared
pkg/types.BaseMCPServerConfig, the 25+ safe-output configs embedBaseSafeOutputConfig, and production code has standardized onanyoverinterface{}(literalinterface{}survives only in linter testdata).That said, I found a handful of real, verified opportunities. The standout: a pair of byte-identical struct definitions for the experiment
state.jsonformat in two files of the samepkg/clipackage β a textbook "delete one, reuse the other" win. There's also a cluster of near-identical report structs inlogs_models.go, two MCP-metrics types that disagree on whether a duration is astringorfloat64, a missingGitHubMCPModestring enum, and thegithubTool anycluster inmcp_github_config.go(~19 params that always immediately assert tomap[string]any). None are emergencies β this is polish.Full Analysis Report
Duplicated Type Definitions
Stats: 11 verified clusters (field bodies compared, not just names) β 2 exact, 7 near, 2 semantic. A shared name alone was not treated as a duplicate; many same-named
Configtypes are legitimately distinct and are not reported.π΄ Cluster 1 & 2 (exact): experiment
state.jsontypesExperimentState/experimentStateJSONandExperimentRunRecord/experimentRunRecordare byte-identical structs (same fields, same JSON tags) that both deserialize thestate.jsonwritten bypick_experiment.cjs, in the same package.pkg/cli/experiments_command.go:32,38vspkg/cli/audit_report_experiments.go:35,42experimentStateJSON/experimentRunRecord, reuse the exported pair. No new import. ~30 min. Removes silent schema-drift between the two copies.π Cluster 3 (near):
MissingToolSummary/MissingDataSummary6 of 7 fields identical (only
ToolvsDataTypediffers).pkg/cli/logs_models.go:148,168.missingItemAggregationbase struct, embed in both. ~1h. The aggregation/display logic is duplicated alongside them.π‘ Cluster 4 (near):
MissingToolReport/MissingDataReport/NoopReport/MCPFailureReportAll four share the provenance trailer
Timestamp,WorkflowName,RunID int64.pkg/cli/logs_models.go:110,120,128,139.RunProvenancestruct. ~1h.π‘ Clusters 5 & 6 (near): MCP metrics modeled twice
MCPServerStats/GatewayServerMetrics(audit_report.go:199vsgateway_logs_types.go:85) andMCPToolSummary/GatewayToolMetrics(audit_report.go:171vsgateway_logs_types.go:97) β same per-server/per-tool MCP metrics from two pipelines that disagree on duration typing (stringvsfloat64).Lower-priority clusters 7β11
AccessLogSummary/FirewallLogSummary(logs_report_firewall.go:12,22) β ~5 shared count/domain fields; extract aDomainTrafficSummarybase.DomainAnalysis/FirewallAnalysis(access_log.go:33,firewall_log.go:131) β both embedDomainBuckets; partly consolidated already.updateFailure/actionUpdateFailure/imageFailure(update_types.go:11,17,update_container_pins.go:25) β all{identifier, reason}pairs; tiny and local.AuditComparisonIntDelta/AuditComparisonStringDelta(audit_comparison.go:44,50) β identical shape differing only in element type; candidate for a genericDelta[T].SourceSpec/RepoSpec(spec.go:26,19) β overlapping repo+ref(+path) specs; align to reduce conversion glue.Untyped Usages
Stats: literal
interface{}in production = 0 β Β·anyparams ~208 (103 files) Β·anyreturns 13 Β·anyfields 31 Β·map[string]any2,111 (350 files) Β· constants mostly typed well β .π Cat 1 β
anyparams (the top fix):githubTool any~19 occurrences across 7 files (
pkg/workflow/mcp_github_config.go:85,139,164,183,205,584,...+ callers inmcp_renderer_github.go,mcp_setup_generator.go,compiler_difc_proxy.go). Every getter immediately doesgithubTool.(map[string]any); the value always comes fromdata.Tools["github"](eitherfalseor a map).type GitHubToolConfig map[string]any(disabled βnil); retype the getters. Removes ~19 repeated assertions.role_checks.go:136,180,186re-implement a "string | []any | []string β []string" union ~5Γ; one shared helper shrinks the surface (theanystays β real YAML union).unmarshalConfig(config_helpers.go:172),marshalEnvValue,formatYAMLValue,pkg/typeutil/convert.go,pkg/loggervarargs β legitimately generic.β Cat 2 β
anyreturn types (13): all genuine sum types at the schema/YAML layer (schema_suggestions.go,schema_compiler.go:217,trigger_parser.go:721,templatables.go:118). No action.π‘ Cat 3 β
anystruct fields (mixed)frontmatter_types.go:329,342,344,382(RunsOn/Imports/Include/Checkout),step_types.go:28,pkg/types/input_definition.go:18.mcp_tools_privileged.go:253-254(RunID,RunIDOrURL),logs_models.go:304-305(RunID,RunNumber) β usejson.Numberor a smallStringOrInt.β Cat 4 β
map[string]any(2,111): idiomatic frontmatter/output-tree handling, schema-validated inpkg/parser/schema_*.go. No action (flagged so the count isn't mistaken for debt).π’ Cat 5 β one real constant gap: missing
GitHubMCPModeenumconstants.goalready types durations (time.Duration) and credit limits (int64) well. But transport/mode values are compared as raw string literals:mcp_github_config.go:110-114,130("local"/"remote"/"gh-proxy"/"cli"),mcp_scripts_parser.go:64. Definetype GitHubMCPMode stringwith named constants so the compiler catches typos that today fail silently asfalse.Recommendations (prioritized)
state.jsonduplicates (Clusters 1&2), reuse exported types. ~30 min. High.GitHubToolConfig, retype the ~19mcp_github_config.gogetters. ~3-4h. High.RunProvenance+missingItemAggregationbases inlogs_models.go(Clusters 3&4). ~2h. Medium.GitHubMCPModestring enum + type the GitHub-APIRunID/RunNumberfields. ~1h. Low-Med.After each:
go build ./...andgo test ./.... Clusters 7β11 are optional cleanup-of-opportunity.Metadata
910 files Β· ~795 types Β· 11 clusters (2 exact / 7 near / 2 semantic) Β·
anyparams ~208, returns 13, fields 31,map[string]any2,111 Β· method: ripgrep extraction + field-body verification + Serena spot checks Β· 2026-06-12.References: Β§27415555013
Beta Was this translation helpful? Give feedback.
All reactions