From f9a984b4e1fbaa52b38b4223581175724580da04 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 03:53:24 +0000 Subject: [PATCH 1/5] Initial plan From 189a0bb7adbe3419a34ba4bf366ffad6f7ee4aa1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 04:08:42 +0000 Subject: [PATCH 2/5] chore: plan largefunc refactors for console, github, parser packages Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/agentics-maintenance.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/agentics-maintenance.yml b/.github/workflows/agentics-maintenance.yml index e2527b3b7ca..35b466e740c 100644 --- a/.github/workflows/agentics-maintenance.yml +++ b/.github/workflows/agentics-maintenance.yml @@ -107,6 +107,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Scripts @@ -152,6 +153,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Scripts @@ -239,6 +241,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Scripts @@ -285,6 +288,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Scripts @@ -593,6 +597,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Scripts @@ -681,6 +686,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Scripts @@ -725,6 +731,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Scripts @@ -815,6 +822,7 @@ jobs: with: sparse-checkout: | actions + clean: false persist-credentials: false - name: Setup Node.js From e93a8c194d06aa10934572f27623718c99a2efc9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 04:11:18 +0000 Subject: [PATCH 3/5] refactor: extract helpers to reduce largefunc findings in console, github, parser Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/console/console.go | 47 +++++++++--------- pkg/github/label_objective_mapping.go | 68 +++++++++++++++------------ pkg/parser/schema_suggestions.go | 41 ++++++++-------- 3 files changed, 82 insertions(+), 74 deletions(-) diff --git a/pkg/console/console.go b/pkg/console/console.go index b1e7d5a08ab..2e32e57a02b 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -215,29 +215,7 @@ func RenderTable(config TableConfig) string { } dataRowCount := len(config.Rows) - - styleFunc := func(row, col int) lipgloss.Style { - if !ttyCheck() { - return lipgloss.NewStyle() - } - if row == table.HeaderRow { - headerStyle := styles.TableHeader - return headerStyle.PaddingLeft(1).PaddingRight(1) - } - if config.ShowTotal && len(config.TotalRow) > 0 && row == dataRowCount { - totalStyle := styles.TableTotal - return totalStyle.PaddingLeft(1).PaddingRight(1) - } - if row%2 == 0 { - cellStyle := styles.TableCell - return cellStyle.PaddingLeft(1).PaddingRight(1) - } - return lipgloss.NewStyle(). - Foreground(styles.ColorForeground). - Background(styles.ColorTableAltRow). - PaddingLeft(1). - PaddingRight(1) - } + styleFunc := buildTableStyleFunc(config, ttyCheck, dataRowCount) borderStyle := lipgloss.NewStyle() if ttyCheck() { @@ -257,6 +235,29 @@ func RenderTable(config TableConfig) string { return output.String() } +// buildTableStyleFunc returns the lipgloss style function used by RenderTable. +func buildTableStyleFunc(config TableConfig, ttyCheck func() bool, dataRowCount int) func(int, int) lipgloss.Style { + return func(row, col int) lipgloss.Style { + if !ttyCheck() { + return lipgloss.NewStyle() + } + if row == table.HeaderRow { + return styles.TableHeader.PaddingLeft(1).PaddingRight(1) + } + if config.ShowTotal && len(config.TotalRow) > 0 && row == dataRowCount { + return styles.TableTotal.PaddingLeft(1).PaddingRight(1) + } + if row%2 == 0 { + return styles.TableCell.PaddingLeft(1).PaddingRight(1) + } + return lipgloss.NewStyle(). + Foreground(styles.ColorForeground). + Background(styles.ColorTableAltRow). + PaddingLeft(1). + PaddingRight(1) + } +} + // FormatCommandMessage formats a command execution message func FormatCommandMessage(command string) string { return applyStyle(styles.Command, "$ ") + command diff --git a/pkg/github/label_objective_mapping.go b/pkg/github/label_objective_mapping.go index 3e5fcd8e618..c7d636eba4d 100644 --- a/pkg/github/label_objective_mapping.go +++ b/pkg/github/label_objective_mapping.go @@ -64,43 +64,53 @@ func (om *ObjectiveMapping) ComputeObjectiveValue(issueLabels []string) int { switch logic { case "sum": - total := 0 - for _, v := range matchingValues { - total += v - } - labelObjectiveMappingLog.Printf("Computed objective value via sum: labels=%v, value=%d", matchedLabels, total) - return total - + return om.computeValueSum(matchingValues, matchedLabels) case "first": - // Return first issue label that's in priority_labels - if len(om.PriorityLabels) > 0 { - for _, issueLabel := range issueLabels { - for _, priorityLabel := range om.PriorityLabels { - if strings.EqualFold(issueLabel, priorityLabel) { - normalizedIssue := strings.ToLower(strings.TrimSpace(issueLabel)) - if val, ok := om.LabelToValue[normalizedIssue]; ok { - labelObjectiveMappingLog.Printf("Computed objective value via issue label priority: label=%s, value=%d", issueLabel, val) - return val - } + return om.computeValueFirst(issueLabels, matchingValues, matchedLabels) + default: // "max" + return om.computeValueMax(matchingValues, matchedLabels) + } +} + +func (om *ObjectiveMapping) computeValueSum(matchingValues []int, matchedLabels []string) int { + total := 0 + for _, v := range matchingValues { + total += v + } + labelObjectiveMappingLog.Printf("Computed objective value via sum: labels=%v, value=%d", matchedLabels, total) + return total +} + +func (om *ObjectiveMapping) computeValueFirst(issueLabels []string, matchingValues []int, matchedLabels []string) int { + // Return first issue label that's in priority_labels + if len(om.PriorityLabels) > 0 { + for _, issueLabel := range issueLabels { + for _, priorityLabel := range om.PriorityLabels { + if strings.EqualFold(issueLabel, priorityLabel) { + normalizedIssue := strings.ToLower(strings.TrimSpace(issueLabel)) + if val, ok := om.LabelToValue[normalizedIssue]; ok { + labelObjectiveMappingLog.Printf("Computed objective value via issue label priority: label=%s, value=%d", issueLabel, val) + return val } } } } - // Fallback to first matching label - result := matchingValues[0] - labelObjectiveMappingLog.Printf("Computed objective value via first match: labels=%v, value=%d", matchedLabels, result) - return result + } + // Fallback to first matching label + result := matchingValues[0] + labelObjectiveMappingLog.Printf("Computed objective value via first match: labels=%v, value=%d", matchedLabels, result) + return result +} - default: // "max" - maxVal := matchingValues[0] - for _, v := range matchingValues { - if v > maxVal { - maxVal = v - } +func (om *ObjectiveMapping) computeValueMax(matchingValues []int, matchedLabels []string) int { + maxVal := matchingValues[0] + for _, v := range matchingValues { + if v > maxVal { + maxVal = v } - labelObjectiveMappingLog.Printf("Computed objective value via max: labels=%v, value=%d", matchedLabels, maxVal) - return maxVal } + labelObjectiveMappingLog.Printf("Computed objective value via max: labels=%v, value=%d", matchedLabels, maxVal) + return maxVal } // DefaultObjectiveMapping returns the built-in default label-to-value mapping. diff --git a/pkg/parser/schema_suggestions.go b/pkg/parser/schema_suggestions.go index dcd14371da9..672fcd17950 100644 --- a/pkg/parser/schema_suggestions.go +++ b/pkg/parser/schema_suggestions.go @@ -650,10 +650,19 @@ func findFieldLocationsInSchema(schemaDoc any, targetField, currentPath string) allLocations := collectSchemaPropertyPaths(schemaDoc, "", 0) targetLower := strings.ToLower(targetField) - seen := make(map[string]struct { - }) + exactMatches := collectExactFieldMatches(allLocations, targetField, currentPath) + if len(exactMatches) > 0 { + schemaSuggestionsLog.Printf("Found %d exact schema locations for field '%s'", len(exactMatches), targetField) + return exactMatches + } - // Collect exact matches first + fuzzyMatches := collectFuzzyFieldMatches(allLocations, targetLower, currentPath) + schemaSuggestionsLog.Printf("Found %d fuzzy schema locations for field '%s'", len(fuzzyMatches), targetField) + return fuzzyMatches +} + +func collectExactFieldMatches(allLocations []schemaFieldLocation, targetField, currentPath string) []schemaFieldLocation { + seen := make(map[string]struct{}) var exactMatches []schemaFieldLocation for _, loc := range allLocations { if loc.SchemaPath == currentPath { @@ -663,43 +672,33 @@ func findFieldLocationsInSchema(schemaDoc any, targetField, currentPath string) if setutil.Contains(seen, key) { continue } - seen[key] = struct { - }{} - + seen[key] = struct{}{} if strings.EqualFold(loc.FieldName, targetField) { loc.Distance = 0 exactMatches = append(exactMatches, loc) } } + return exactMatches +} - if len(exactMatches) > 0 { - schemaSuggestionsLog.Printf("Found %d exact schema locations for field '%s'", len(exactMatches), targetField) - return exactMatches - } - - // Fall back to fuzzy matching with a stricter distance threshold for high confidence - seenFuzzy := make(map[string]struct { - }) +func collectFuzzyFieldMatches(allLocations []schemaFieldLocation, targetLower, currentPath string) []schemaFieldLocation { + seen := make(map[string]struct{}) var fuzzyMatches []schemaFieldLocation for _, loc := range allLocations { if loc.SchemaPath == currentPath { continue } key := loc.FieldName + "|" + loc.SchemaPath - if setutil.Contains(seenFuzzy, key) { + if setutil.Contains(seen, key) { continue } - seenFuzzy[key] = struct { - }{} - + seen[key] = struct{}{} dist := LevenshteinDistance(targetLower, strings.ToLower(loc.FieldName)) if dist > 0 && dist <= maxPathSearchDistance { loc.Distance = dist fuzzyMatches = append(fuzzyMatches, loc) } } - - // Sort fuzzy matches by distance (ascending), then path for stable output slices.SortFunc(fuzzyMatches, func(a, b schemaFieldLocation) int { if a.Distance != b.Distance { if a.Distance < b.Distance { @@ -716,8 +715,6 @@ func findFieldLocationsInSchema(schemaDoc any, targetField, currentPath string) return 0 } }) - - schemaSuggestionsLog.Printf("Found %d fuzzy schema locations for field '%s'", len(fuzzyMatches), targetField) return fuzzyMatches } From 6a9b96a9fd39c4e544b2923f53652f379b0316ca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 04:12:54 +0000 Subject: [PATCH 4/5] refactor: add doc comments to extracted helper functions Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/console/console.go | 2 ++ pkg/github/label_objective_mapping.go | 5 +++++ pkg/parser/schema_suggestions.go | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/pkg/console/console.go b/pkg/console/console.go index 2e32e57a02b..cb5dfa156a5 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -236,6 +236,8 @@ func RenderTable(config TableConfig) string { } // buildTableStyleFunc returns the lipgloss style function used by RenderTable. +// config supplies the ShowTotal/TotalRow flags; ttyCheck detects terminal output; +// dataRowCount is the number of data rows (excluding any total row). func buildTableStyleFunc(config TableConfig, ttyCheck func() bool, dataRowCount int) func(int, int) lipgloss.Style { return func(row, col int) lipgloss.Style { if !ttyCheck() { diff --git a/pkg/github/label_objective_mapping.go b/pkg/github/label_objective_mapping.go index c7d636eba4d..eb7c50356d5 100644 --- a/pkg/github/label_objective_mapping.go +++ b/pkg/github/label_objective_mapping.go @@ -72,6 +72,7 @@ func (om *ObjectiveMapping) ComputeObjectiveValue(issueLabels []string) int { } } +// computeValueSum adds all matching label values and logs the result. func (om *ObjectiveMapping) computeValueSum(matchingValues []int, matchedLabels []string) int { total := 0 for _, v := range matchingValues { @@ -81,6 +82,9 @@ func (om *ObjectiveMapping) computeValueSum(matchingValues []int, matchedLabels return total } +// computeValueFirst returns the value for the highest-priority matching label. +// It walks issueLabels in priority order; if none match, it falls back to the +// first label in matchingValues. func (om *ObjectiveMapping) computeValueFirst(issueLabels []string, matchingValues []int, matchedLabels []string) int { // Return first issue label that's in priority_labels if len(om.PriorityLabels) > 0 { @@ -102,6 +106,7 @@ func (om *ObjectiveMapping) computeValueFirst(issueLabels []string, matchingValu return result } +// computeValueMax returns the highest value among all matching labels. func (om *ObjectiveMapping) computeValueMax(matchingValues []int, matchedLabels []string) int { maxVal := matchingValues[0] for _, v := range matchingValues { diff --git a/pkg/parser/schema_suggestions.go b/pkg/parser/schema_suggestions.go index 672fcd17950..96f544f6fb1 100644 --- a/pkg/parser/schema_suggestions.go +++ b/pkg/parser/schema_suggestions.go @@ -661,6 +661,9 @@ func findFieldLocationsInSchema(schemaDoc any, targetField, currentPath string) return fuzzyMatches } +// collectExactFieldMatches returns all locations in allLocations where the field +// name case-insensitively equals targetField, excluding the currentPath location. +// Duplicate (fieldName, schemaPath) pairs are suppressed. func collectExactFieldMatches(allLocations []schemaFieldLocation, targetField, currentPath string) []schemaFieldLocation { seen := make(map[string]struct{}) var exactMatches []schemaFieldLocation @@ -681,6 +684,9 @@ func collectExactFieldMatches(allLocations []schemaFieldLocation, targetField, c return exactMatches } +// collectFuzzyFieldMatches returns locations whose field names are within +// maxPathSearchDistance Levenshtein edits of targetLower, excluding currentPath. +// Results are sorted by distance ascending, then by schema path for stable output. func collectFuzzyFieldMatches(allLocations []schemaFieldLocation, targetLower, currentPath string) []schemaFieldLocation { seen := make(map[string]struct{}) var fuzzyMatches []schemaFieldLocation From 372ba91bf6b7c357437725bfc4266aa703e2b5bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Jul 2026 05:12:25 +0000 Subject: [PATCH 5/5] fix: correct computeValueFirst doc comment and revert unrelated workflow clean:false changes Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/agentics-maintenance.yml | 8 -------- pkg/github/label_objective_mapping.go | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/agentics-maintenance.yml b/.github/workflows/agentics-maintenance.yml index 35b466e740c..e2527b3b7ca 100644 --- a/.github/workflows/agentics-maintenance.yml +++ b/.github/workflows/agentics-maintenance.yml @@ -107,7 +107,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Scripts @@ -153,7 +152,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Scripts @@ -241,7 +239,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Scripts @@ -288,7 +285,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Scripts @@ -597,7 +593,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Scripts @@ -686,7 +681,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Scripts @@ -731,7 +725,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Scripts @@ -822,7 +815,6 @@ jobs: with: sparse-checkout: | actions - clean: false persist-credentials: false - name: Setup Node.js diff --git a/pkg/github/label_objective_mapping.go b/pkg/github/label_objective_mapping.go index eb7c50356d5..54c87f72b9a 100644 --- a/pkg/github/label_objective_mapping.go +++ b/pkg/github/label_objective_mapping.go @@ -82,9 +82,9 @@ func (om *ObjectiveMapping) computeValueSum(matchingValues []int, matchedLabels return total } -// computeValueFirst returns the value for the highest-priority matching label. -// It walks issueLabels in priority order; if none match, it falls back to the -// first label in matchingValues. +// computeValueFirst returns the value for the first issue label that appears in PriorityLabels. +// It iterates issueLabels in their existing order and returns the value for the first one +// found in PriorityLabels; if none match, it falls back to the first value in matchingValues. func (om *ObjectiveMapping) computeValueFirst(issueLabels []string, matchingValues []int, matchedLabels []string) int { // Return first issue label that's in priority_labels if len(om.PriorityLabels) > 0 {