Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Problem

The labels field is defined in the JSON schema and documented in frontmatter.md, but missing from the FrontmatterConfig struct. This causes labels to pass through as untyped data without compile-time validation.

Changes

Struct field addition (pkg/workflow/frontmatter_types.go)

  • Added Labels []string field with json:"labels,omitempty" tag
  • Positioned with core workflow fields (name, description, engine, etc.)

Serialization (ToMap() method)

  • Serialize labels array when non-empty for round-trip compatibility

Test coverage (pkg/workflow/frontmatter_types_test.go)

  • Parse labels from frontmatter: []any{"automation", "ci", "diagnostics"}config.Labels
  • Round-trip preservation: struct → map → struct maintains label values

Usage

frontmatter := map[string]any{
    "name":   "test-workflow",
    "labels": []any{"automation", "ci"},
}

config, _ := ParseFrontmatterConfig(frontmatter)
// config.Labels is now []string{"automation", "ci"} with type safety

reconstructed := config.ToMap()
// reconstructed["labels"] preserves the array
Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Add missing 'labels' field to FrontmatterConfig struct</issue_title>
<issue_description>## Description

The JSON schema defines labels as an array of strings for categorizing workflows (main_workflow_schema.json lines 36-48), and documentation describes this field (frontmatter.md:57-65), but the FrontmatterConfig struct in pkg/workflow/frontmatter_types.go lacks a Labels field.

Impact on Stability

  • Type Safety: Labels defined in workflow frontmatter are not parsed into the typed config struct
  • Data Loss: Labels pass through as raw frontmatter data but lack compile-time validation
  • User Confusion: Users may define labels expecting them to be processed, but they're silently ignored in typed operations

Suggested Changes

File: pkg/workflow/frontmatter_types.go

Add the Labels field to FrontmatterConfig struct:

type FrontmatterConfig struct {
    // ... existing fields ...
    Labels []string `json:"labels,omitempty"`
    // ... existing fields ...
}

File: pkg/workflow/frontmatter_types.go (ToMap method)

Ensure Labels is serialized in ToMap():

if len(c.Labels) > 0 {
    m["labels"] = c.Labels
}

Success Criteria

  • Labels []string field added to FrontmatterConfig
  • Field properly serialized in ToMap() method
  • Existing tests pass
  • No breaking changes to existing workflows

Files Affected

  • pkg/workflow/frontmatter_types.go - Add Labels field and serialization
  • pkg/workflow/frontmatter_types_test.go - Add test coverage (if not already present)

Source

Extracted from Schema Consistency Check discussion github/gh-aw#14607

Priority

Medium - Improves type safety and prevents silent data loss, but not blocking production workflows.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 10, 2026, 9:15 AM UTC

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Add Labels []string field to FrontmatterConfig struct for workflow categorization
- Add Labels serialization in ToMap() method to support round-trip conversion
- Add test for parsing labels array from frontmatter
- Add test for round-trip conversion preserving labels
- All existing tests pass without modification

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add missing 'labels' field to FrontmatterConfig struct Add missing labels field to FrontmatterConfig struct Feb 9, 2026
Copilot AI requested a review from pelikhan February 9, 2026 10:38
@pelikhan pelikhan marked this pull request as ready for review February 9, 2026 10:43
Copilot AI review requested due to automatic review settings February 9, 2026 10:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the typed FrontmatterConfig representation with the documented/schema-supported labels frontmatter field so workflow labels are parsed and serialized with compile-time type safety.

Changes:

  • Added Labels []string to FrontmatterConfig with json:"labels,omitempty".
  • Updated FrontmatterConfig.ToMap() to serialize labels when non-empty.
  • Added tests verifying label parsing and ToMap() preservation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/workflow/frontmatter_types.go Adds Labels field to the typed config and includes it in ToMap() serialization.
pkg/workflow/frontmatter_types_test.go Adds coverage for parsing labels from frontmatter and ensuring ToMap() preserves them.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan pelikhan merged commit ab2d64e into main Feb 9, 2026
131 checks passed
@pelikhan pelikhan deleted the copilot/add-labels-field-frontmatterconfig branch February 9, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Add missing 'labels' field to FrontmatterConfig struct

2 participants