-
Notifications
You must be signed in to change notification settings - Fork 308
Description
Description
Add explicit types to 225 untyped constants across the codebase to improve type safety and semantic clarity. Currently, constants lack explicit type declarations, making them error-prone when used in function parameters or assignments.
Current Problem
225 untyped constants lack semantic clarity and type safety:
Examples of untyped constants:
// pkg/workflow/bundler_file_mode.go
const ScriptsBasePath = "/opt/gh-aw/actions" // Line 40
const SetupActionDestination = "/opt/gh-aw/actions" // Line 43
// pkg/workflow/safe_inputs_parser.go
const SafeInputsDirectory = "/opt/gh-aw/safe-inputs" // Line 55
// pkg/constants/constants.go
const AgenticCampaignLabel = "agentic-campaign" // Line 248
const CampaignLabelPrefix = "z_campaign_" // Line 253
const SafeOutputArtifactName = "safe-output" // Line 488Problems:
- No type safety (can accidentally mix different string types)
- Lack of semantic meaning (is it a path, label, or URL?)
- Can't add validation methods on types
- Difficult to enforce constraints at compile time
Proposed Solution
Define semantic type aliases:
// Define semantic types
type FilePath string
type Label string
type ArtifactName string
type FileName string
type DomainName string
type ContainerImage string
// Add explicit types to constants
const ScriptsBasePath FilePath = "/opt/gh-aw/actions"
const AgenticCampaignLabel Label = "agentic-campaign"
const SafeOutputArtifactName ArtifactName = "safe-output"Benefits:
- Type safety prevents mixing different string categories
- Self-documenting code
- Can add helper methods (e.g.,
Path.IsAbsolute(),Label.IsValid()) - Better IDE support and autocomplete
Target Categories
50+ path constants → type FilePath string
ScriptsBasePath,SetupActionDestination,SafeInputsDirectory,RedactedURLsLogPath, etc.
30+ label constants → type Label string
AgenticCampaignLabel,CampaignLabelPrefix, etc.
20+ artifact name constants → type ArtifactName string
SafeOutputArtifactName,AgentOutputArtifactName, etc.
40+ domain/URL constants → type DomainName string or type URL string
- Various domain allowlists and URLs
15+ container image constants → type ContainerImage string
- Container registry references
Gold Standard Example
Already properly typed constants (keep this pattern):
// pkg/constants/constants.go - Already excellent! ✅
const DefaultAgenticWorkflowTimeout = 20 * time.Minute // Line 397
const DefaultToolTimeout = 60 * time.Second // Line 400
const DefaultMCPStartupTimeout = 120 * time.Second // Line 403These constants use Go's time.Duration type properly. Apply this same pattern to other constants.
Implementation Approach
- Phase 1: Create semantic type aliases in appropriate packages
- Phase 2: Update constant declarations to use explicit types
- Phase 3: Update function signatures to use semantic types where appropriate
- Phase 4: Run tests to ensure no regressions
Start with high-impact categories:
- Path constants (most common, high risk of mistakes)
- Label constants (used in GitHub API calls)
- Then expand to other categories
Success Criteria
- All 225 untyped constants have explicit type declarations
- Semantic type aliases created for common categories (FilePath, Label, etc.)
- Function signatures updated to use semantic types where beneficial
- All tests pass (
make test-unit) -
make agent-finishpasses without errors - No breaking changes to public APIs
Priority
Medium - Improves type safety and code clarity
Estimated Effort
Small (6-8 hours) - Systematic but straightforward refactoring
Source
Extracted from Typist Report: Go Type Consistency Analysis #12725 (Category 2: Untyped Constants)
Workflow Run: §21513776826
AI generated by Discussion Task Miner - Code Quality Improvement Agent
- expires on Feb 13, 2026, 9:09 PM UTC