[typist] π€ Typist β Go Type Consistency Analysis #41012
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Typist - Go Type Analysis. A newer discussion is available at Discussion #41218. |
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 repository: github/gh-aw β 944 non-test
.gofiles underpkg/, 833 struct definitions.Executive Summary
Good news first: gh-aw is a well-typed codebase. The overwhelming majority of
interface{}/anyusage (~2,125map[string]any, 1,455 of them inpkg/workflow) is legitimate β it's how the compiler parses dynamic YAML frontmatter, wheremap[string]anyis the idiomatic right call. The code already defines named string types (EngineName,FeatureFlag,JobName,MCPServerID,GitHubIntegrityLevel), so strong typing is clearly valued.The real (small) wins: a handful of exact-field duplicate structs that are near-zero-risk deletions, one clear consistency bug (a
stringfield that should reuse the existingGitHubIntegrityLevelenum), and several enum-likeconstclusters that would gain compile-time safety from a one-line named type. Exact same-name collisions are all intentional_wasm.gobuild-tag variants ortype X = pkg.Xaliases β not real duplication. Fixing the exact duplicates plus theLLMProvider/GitHubIntegrityLeveltyping are the highest-leverage moves. A tidy codebase that could get a little tidier. πFull Analysis Report
Duplicated Types β 10 real clusters (3 exact, 5 near, 2 low-value)
Exact-field duplicates (delete / merge β lowest risk):
pkg/cli/experiments_command.go:34ExperimentState/:40ExperimentRunRecordare byte-identical (incl. JSON tags) to the unexportedexperimentStateJSON/experimentRunRecordatpkg/cli/audit_report_experiments.go:35/:42, same package. Both modelpick_experiment.cjs'sstate.json. β Delete the unexported pair, reuse the exported.pkg/workflow/antigravity_logs.go:14AntigravityResponseandpkg/workflow/gemini_logs.go:14GeminiResponseare 100% identical (Response string,Stats map[string]any), and theirParseLogMetricsmethods are near-identical. β Extract one sharedCLIJSONResponse.pkg/actionpins/actionpins.go:46ContainerPinβ‘pkg/workflow/safe_update_manifest.go:33GHAWManifestContainer(Image/Digest/PinnedImage, onlyomitemptydiffers). β ReuseContainerPinor alias it.releaseWithVersionis declared as a function-local type twice in the same file (pkg/cli/update_actions.go:324and:458). β Hoist to one package-level type.Near-duplicate clusters (embed a shared base)
actionpins.go:38ActionPinβsafe_update_manifest.go:24GHAWManifestAction(Repo/Version/SHA). Manifest type should embedActionPin.pkg/cli/token_usage.go:74ModelTokenUsage,:89ModelTokenUsageRow,:382agentUsageEntryall shareInput/Output/CacheRead/CacheWriteTokens;AICvsAICreditsis the same concept twice. β Extract embeddedTokenCounts.pkg/constants/engine_constants.go:134SystemSecretSpecis a 4-field subset ofpkg/cli/engine_secrets.go:27SecretRequirement. β Use[]SecretRequirement.pkg/cli/logs_models.go:147MissingToolSummaryβ:167MissingDataSummaryshare 6/7 fields (differ only byToolvsDataType). β SharedsummaryAggregateBase.generate_action_metadata_command.go:46ActionInputβactionpins.go:31ActionYAMLInputshareDescription/Required/Default.dependabot.go:58/64/70NpmDependency/PipDependency/GoDependencyβ oneDependency;update_types.go:11/17casing-only dup;audit_comparison.go:44/50Int/String delta β genericDelta[T].Rejected false positives: engine wrappers (already embed
BaseEngine), MCP layer types (already embedBaseMCPServerConfig), per-tool finding structs, domain stats, diff entries β distinct concepts.Untyped Usages
Category 1 β field that should be a concrete type (consistency bug, 1-line fix):
pkg/workflow/tools_types.go:368EndorserMinIntegrity stringβGitHubIntegrityLevel. Its siblingMinIntegrity GitHubIntegrityLevel(:325) already uses the named type (defined:287-297) for the same"approved"/"unapproved"/"merged"domain.Category 2 β
constenum clusters β named string types (strongest category):pkg/workflow/llm_provider.go:10-14type LLMProvider stringengine.go:49 EngineConfig.LLMProvider string+ manyprovider stringparams would all become typed across routing logic.pkg/cli/mcp_registry_types.go:107-110MCPServerStatuspkg/cli/mcp_registry_types.go:113-116MCPArgumentTypepkg/cli/outcomes_history.go:19-23historySourcepkg/cli/env_command.go:24-28defaultsScopepkg/cli/logs_safe_output_chains.go:16-20temporaryIDMapStatuspkg/cli/token_usage.go:122-123modelMismatchReasonCategory 3 β
anyparams/returns: few clean wins; most read from amap[string]anynode soanyis the correct boundary. Marginal:dependabot.go:559/586normalizers,stringutil.go:54 ParseVersionValue.Category 4 β type-assertion clusters β typed parse structs w/
UnmarshalYAML:pkg/workflow/observability_otlp.go:523-556and:599-632β endpoint union asserted in two duplicated functions βOTLPEndpoint.pkg/workflow/role_checks.go:100-213βOnEventConfig{Roles, Bots, Labels []string}.pkg/workflow/stop_after.go:447-486βSkipIfCheckFailingConfig.pkg/workflow/compiler_jobs.go:758-809βJobConfig{Timeout, Concurrency}.π― Recommended Actions (impact Γ· effort)
EndorserMinIntegrityβGitHubIntegrityLevel; addtype LLMProvider string.pkg/clienum clusters.Run
make testafter each change.Detection: Serena semantic analysis + ripgrep + parallel agent verification. Date: 2026-06-23.
Beta Was this translation helpful? Give feedback.
All reactions