Description
The frontmatter map[string]any parameter signature is repeated 290 times across 128 files, including UpdateWorkflowFrontmatter, the ~40 codemods in pkg/cli, and the Compiler.extract*FromOn helpers in pkg/workflow/pkg/parser. Each call site hand-rolls .(string)/.([]any) type assertions against the untyped map, which is error-prone and hard to discover/refactor safely.
Suggested Changes
- Define a named
type Frontmatter map[string]any (or a thin wrapper struct) with typed accessor methods, e.g. GetString(key string) (string, bool), GetStringSlice(key string) ([]string, bool), GetMap(key string) (Frontmatter, bool).
- Migrate
UpdateWorkflowFrontmatter and the Compiler.extract*FromOn helpers to use the new type first (highest-traffic call sites).
- Progressively migrate the ~40
pkg/cli codemods to use the typed accessors instead of raw assertions.
- This is additive (the underlying type is still
map[string]any), so it is a low-risk rename plus method-add rather than a breaking change.
Files Affected
- All files calling
UpdateWorkflowFrontmatter and Compiler.extract*FromOn (128 files total per source analysis)
- Suggested new file:
pkg/parser/frontmatter_type.go (or similar) for the type definition and accessors
Success Criteria
Frontmatter named type exists with typed accessor methods and unit tests
UpdateWorkflowFrontmatter and Compiler.extract*FromOn helpers migrated to use it
- No behavior change; all existing tests pass
Source
Extracted from Typist - Go Type Consistency Analysis #50840
Priority
High impact, moderate effort (4-6h per source analysis) - touches many files but additive/low-risk
🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · auto · 47.5 AIC · ⌖ 3.92 AIC · ⊞ 10.2K · ◷
Description
The
frontmatter map[string]anyparameter signature is repeated 290 times across 128 files, includingUpdateWorkflowFrontmatter, the ~40 codemods inpkg/cli, and theCompiler.extract*FromOnhelpers inpkg/workflow/pkg/parser. Each call site hand-rolls.(string)/.([]any)type assertions against the untyped map, which is error-prone and hard to discover/refactor safely.Suggested Changes
type Frontmatter map[string]any(or a thin wrapper struct) with typed accessor methods, e.g.GetString(key string) (string, bool),GetStringSlice(key string) ([]string, bool),GetMap(key string) (Frontmatter, bool).UpdateWorkflowFrontmatterand theCompiler.extract*FromOnhelpers to use the new type first (highest-traffic call sites).pkg/clicodemods to use the typed accessors instead of raw assertions.map[string]any), so it is a low-risk rename plus method-add rather than a breaking change.Files Affected
UpdateWorkflowFrontmatterandCompiler.extract*FromOn(128 files total per source analysis)pkg/parser/frontmatter_type.go(or similar) for the type definition and accessorsSuccess Criteria
Frontmatternamed type exists with typed accessor methods and unit testsUpdateWorkflowFrontmatterandCompiler.extract*FromOnhelpers migrated to use itSource
Extracted from Typist - Go Type Consistency Analysis #50840
Priority
High impact, moderate effort (4-6h per source analysis) - touches many files but additive/low-risk