Repository navigation
[typist] π€ Typist β Go Type Consistency Analysis (pkg/) #38607
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Typist - Go Type Analysis. A newer discussion is available at Discussion #38833. |
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
Analysis of repository: github/gh-aw
Executive Summary
Good news first:
gh-awis in genuinely healthy shape. I swept all 873 non-test Go files underpkg/(β610 struct/interface definitions) and found zero real cross-package duplicate type names. The three names that appear twice (ProgressBar,SpinnerWrapper,RepositoryFeatures) are all legitimate//go:build wasmvs. native variants in the same package β the pattern you want, not duplication.The findings worth acting on are two small structural near-duplicates and a recurring habit of modeling the same semantic concept as untyped
anyin several places (RunsOn,On,Headers,GuardPolicies,Stats). One nice thing: the codebase has fully migrated offinterface{}(0 occurrences) to theanyalias. The win here is turning a handful of repeatedanyfields into small shared named types β deleting scattered assertions and documenting intent. None of this is urgent; treat it as a friendly polish pass.Full Analysis Report
Duplicated Type Definitions
Summary
pkg/, excl.*_test.go+testdata/) Β· Type defs: ~610Cluster 1:
AntigravityResponseβGeminiResponseβ structural duplicateIdentical field set, same
workflowpackage:pkg/workflow/antigravity_logs.go:13pkg/workflow/gemini_logs.go:13Fix: one shared
type EngineJSONResponse struct { Response string; Stats map[string]any }; bothParseLogMetricspaths unmarshal into it. Few refs, all in-file. Effort ~1h. This also covers the repeatedStatsfield below.Cluster 2:
TrialArtifactsβWorkflowTrialResultβ embed candidateWorkflowTrialResultreproduces all threeTrialArtifactsfields verbatim (down to the same commented-outAgentStdioLogsline):pkg/cli/trial_support.go:19βTrialArtifactspkg/cli/trial_types.go:6βWorkflowTrialResultFix: embed
TrialArtifactsinsideWorkflowTrialResultso the shared fields live in one place. Effort ~1h (confirm the embedded JSON layout matches consumers).Build-tag variants β reviewed, NOT flagged
Correct platform-specific implementations, no action:
ProgressBarβconsole/progress.go:31+progress_wasm.go:7SpinnerWrapperβconsole/spinner.go:92+spinner_wasm.go:10RepositoryFeaturesβworkflow/repository_features_validation.go:58+..._wasm.go:5Untyped Usages
Summary
interface{}: 0 (allanyβ good) Β·anytokens: ~3,450 Β·map[...]any: ~2,078anystruct fields: 31 Β·map[string]anystruct fields: 72 Β· func sigs w/any: ~866Most
anyuse is legitimate polymorphic frontmatter (the code even notes too dynamic to type). I only flag concepts modeled asanyin multiple places.Category 1: Repeated polymorphic fields deserving a named type
RunsOn any(GitHub Actionsruns-on; string/array/object) βworkflow/safe_jobs.go:20,workflow/frontmatter_types.go:329,cli/copilot_setup.go:150. β sharedtype RunsOn any(optionally withUnmarshalYAML).On any(workflowon:trigger) βcli/status_command.go:35,cli/jsonworkflow_to_markdown.go:38,cli/copilot_setup.go:158,cli/list_workflows_command.go:25. β one shared trigger type so the four CLI display paths agree.Headers any(HTTP headers) βworkflow/frontmatter_types.go:208&:238,parser/import_field_extractor.go:764. βmap[string]string(ormap[string][]string, likehttp.Header) removes the assertions.GuardPolicies map[string]anyβworkflow/mcp_renderer_types.go:84&:111,workflow/tools_types.go:427,workflow/mcp_config_types.go:54(+WriteSinkGuardPoliciesatmcp_renderer_types.go:21). β sharedtype GuardPolicies map[string]anyto hang validation on.Stats map[string]anyβworkflow/antigravity_logs.go:15,gemini_logs.go:15,pi_logs.go:36. β folded intoEngineJSONResponse(Cluster 1).Category 2: String-or-number JSON IDs
Accept either a JSON string or number, forcing per-site assertions /
fmt.Sprintf:cli/gateway_logs_types.go:148&:159βID anycli/logs_models.go:304-305βRunID/RunNumber anycli/mcp_tools_privileged.go:254-255βRunID/RunIDOrURL anyFix: a small
type FlexInt int64(orStringOrInt) with customUnmarshalJSONaccepting both forms; consumers get a real value, no assertions.Category 3: Untyped constants
Go untyped constants are idiomatic, so blanket-typing is not recommended β and I found none whose lack of a type creates a correctness risk. Only add a named type (e.g.
type Seconds int) where a unit is genuinely ambiguous at call sites, not mechanically.Recommendations (by priority)
EngineJSONResponse(replacesAntigravityResponse+GeminiResponse); embedTrialArtifactsinWorkflowTrialResult.RunsOn,On,GuardPolicies(and optionallyHeaders) types/aliases; adopt at listed sites.FlexInt/StringOrInt+ customUnmarshalJSON; adopt atID/RunID/RunNumber.After each step run
go build ./...and the test suite to confirm no breakage.Metadata
interface{}: 0pkg/References: Β§27347015436
All reactions