Skip to content

Refactor duplicated pkg/cli outcome and stats helpers - #51948

Merged
pelikhan merged 9 commits into
mainfrom
copilot/refactor-pkg-cli-semantic-clustering
Aug 11, 2026
Merged

Refactor duplicated pkg/cli outcome and stats helpers#51948
pelikhan merged 9 commits into
mainfrom
copilot/refactor-pkg-cli-semantic-clustering

Conversation

Copilot AI commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

pkg/cli had duplicated outcome-evaluation logic across issue, PR, and comment evaluators, plus scattered helper functions in unrelated files. This refactor consolidates those helper clusters while preserving existing evaluator behavior.

  • Outcome evaluation helpers
    • Centralized human comment counting for issues, PRs, and comment replies.
    • Shared close-provenance lookup for lifecycle bot classification.
    • Consolidated label-name extraction paths.
report.HumanComments = countHumanComments(comments)

closedByBot, err := isLatestCloseByBot(ctx, number, repo, closeStickyGHAPIGetArray)
  • Statistics helpers

    • Moved shared math helpers into stats_helpers.go.
    • Replaced the hand-rolled median sort with slices.Sort.
  • Trial result helpers

    • Moved safe-output error extraction, trial aggregation, and control-character sanitization out of trial_types.go.
  • Focused coverage

    • Added helper-level tests for comment counting, close provenance, label conversion, and percentage edge cases.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.54 AIC · ⌖ 6.39 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Run: https://github.com/github/gh-aw/actions/runs/31469629212> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.98 AIC · ⌖ 5.15 AIC · ⊞ 8.5K ·

Comment /souschef to run again

Copilot AI and others added 7 commits August 11, 2026 05:49
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor pkg/cli to resolve duplicate clusters in outcome_eval_* Refactor duplicated pkg/cli outcome and stats helpers Aug 11, 2026
Copilot AI requested a review from pelikhan August 11, 2026 06:07
@pelikhan
pelikhan marked this pull request as ready for review August 11, 2026 06:21
Copilot AI balanced review requested due to automatic review settings August 11, 2026 06:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Consolidates duplicated evaluator, statistics, and trial-result helpers while preserving existing behavior.

Changes:

  • Centralizes comment counting, close provenance, and label extraction.
  • Groups shared statistics helpers and improves median sorting.
  • Separates trial-result logic from trial type declarations and adds focused tests.
Show a summary per file
File Description
pkg/cli/trial_types.go Retains trial type declarations only.
pkg/cli/trial_result_helpers.go Houses trial aggregation, extraction, and sanitization helpers.
pkg/cli/stats_helpers.go Centralizes shared statistical functions.
pkg/cli/stats_helpers_test.go Tests percentage edge cases.
pkg/cli/outcome_eval.go Shares label conversion and removes local median logic.
pkg/cli/outcome_eval_test.go Tests consolidated outcome helpers.
pkg/cli/outcome_eval_pr.go Uses shared human-comment counting.
pkg/cli/outcome_eval_issue.go Uses shared comment and close-provenance helpers.
pkg/cli/outcome_eval_helpers.go Defines common outcome-evaluation helpers.
pkg/cli/outcome_eval_generic.go Delegates lifecycle close lookup.
pkg/cli/outcome_eval_comment.go Uses shared reply counting.
pkg/cli/forecast_montecarlo.go Removes relocated statistics helpers.
pkg/cli/audit_math_helpers.go Removes relocated percentage calculation.

Review details

Tip

Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 13/13 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for this PR. The branch has already been refreshed for a follow-up pass. Please review the latest state, check for any unresolved review feedback or failing checks, and run the pr-finisher skill to move this toward maintainer-ready status. Run details: https://github.com/github/gh-aw/actions/runs/31465177236

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.54 AIC · ⌖ 6.39 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

Triage: Refactor duplicated pkg/cli outcome and stats helpers

  • Category: refactor
  • Risk: medium (13 files, +333/-227, touches core outcome-evaluation logic used across issue/PR/comment flows)
  • Score: 68/100 (impact 32, urgency 16, quality 20)
  • Recommended action: fast_track

Notes: CI green (all checks passing), AI reviewer left comments (unresolved). Behavior-preserving refactor with new focused tests, but touches shared eval helpers used repo-wide — warrants human review before merge, not auto-merge.

Generated by 🔧 PR Triage Agent · auto · 25.5 AIC · ⌖ 2.31 AIC · ⊞ 7.8K ·

Copilot AI requested a review from gh-aw-bot August 11, 2026 06:51
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for this PR. The branch was already refreshed recently. Please review the latest state, check for any unresolved review feedback or failing checks, and run the pr-finisher skill to move this toward maintainer-ready status. Run details: https://github.com/github/gh-aw/actions/runs/31469629212

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.98 AIC · ⌖ 5.15 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for this PR. A recent sous-chef nudge already exists on this PR, so this run is recording it as skipped for cooldown/duplicate handling.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.6 AIC · ⌖ 5.12 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor | Risk: medium | Score: 65/100 (impact 30, urgency 15, quality 20)
  • Action: fast_track
  • CI green, AI review commented, no blocking concerns. Moderate-size internal refactor (333+/227-, 13 files) consolidating pkg/cli helpers; behavior preserved per description.

Generated by 🔧 PR Triage Agent · auto · 38.6 AIC · ⌖ 2.76 AIC · ⊞ 7.8K ·

@pelikhan
pelikhan merged commit 7b68493 into main Aug 11, 2026
30 checks passed
@pelikhan
pelikhan deleted the copilot/refactor-pkg-cli-semantic-clustering branch August 11, 2026 13:51
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

4 participants