Skip to content

[Code Quality] Add explicit types to 225 untyped constants #12793

@github-actions

Description

@github-actions

Description

The codebase contains 225 untyped constants that lack explicit type declarations. Adding semantic type aliases (like type FilePath string, type Label string) would improve type safety, code clarity, and prevent mixing different string categories.

Identified by

Typist Report - Go Type Consistency Analysis #12725

Current Issues

Untyped Constants Examples:

// pkg/workflow/bundler_file_mode.go
const ScriptsBasePath = "/opt/gh-aw/actions"                // No type
const SetupActionDestination = "/opt/gh-aw/actions"         // No type

// pkg/constants/constants.go
const AgenticCampaignLabel = "agentic-campaign"             // No type
const CampaignLabelPrefix = "z_campaign_"                   // No type
const SafeOutputArtifactName = "safe-output"                // No type

Suggested Changes

Define semantic type aliases and apply to constants:

// Define semantic types
type FilePath string
type Label string
type ArtifactName string
type FileName string
type DomainName string

// Apply to constants
const ScriptsBasePath FilePath = "/opt/gh-aw/actions"
const AgenticCampaignLabel Label = "agentic-campaign"
const SafeOutputArtifactName ArtifactName = "safe-output"

Target Categories

Based on analysis, these categories contain untyped constants:

  • Path constants (~50) → type FilePath string
  • Label constants (~30) → type Label string
  • Artifact name constants (~20) → type ArtifactName string
  • Domain/URL constants (~40) → type DomainName string
  • Container image constants (~15) → type ContainerImage string
  • Other identifiers (~70) → Various semantic types

Files Affected

  • pkg/constants/constants.go - Primary file with most constants
  • pkg/workflow/bundler_file_mode.go
  • pkg/workflow/safe_inputs_parser.go
  • pkg/workflow/engine_output.go
  • pkg/workflow/copilot_engine.go
  • Other files with constants

Good Pattern to Follow

The codebase already has correctly typed constants:

// pkg/constants/constants.go - Already properly typed! ✅
const DefaultAgenticWorkflowTimeout = 20 * time.Minute
const DefaultToolTimeout = 60 * time.Second
const DefaultMCPStartupTimeout = 120 * time.Second

Apply this same pattern (explicit types) to string constants.

Success Criteria

  • All 225 untyped constants have explicit type declarations
  • Semantic type aliases defined (FilePath, Label, ArtifactName, etc.)
  • Function signatures updated to use semantic types where appropriate
  • Type safety prevents mixing different string categories
  • All tests pass after changes

Benefits

  • Type Safety: Can't accidentally pass wrong type (FilePath vs Label)
  • Semantic Clarity: Code is self-documenting (it's a file path, not just a string)
  • Validation: Easier to add validation functions on types
  • Consistency: Matches existing pattern for time.Duration constants

Estimated Effort

6-8 hours (systematic refactoring across multiple files)

Priority

Medium - Code quality improvement with clear benefits

References

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 13, 2026, 5:15 PM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions