Skip to content

Remediate 14 collection/perf custom-lint findings - #51507

Merged
pelikhan merged 4 commits into
mainfrom
copilot/lint-monster-remediate-findings
Aug 9, 2026
Merged

Remediate 14 collection/perf custom-lint findings#51507
pelikhan merged 4 commits into
mainfrom
copilot/lint-monster-remediate-findings

Conversation

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

make golint-custom flagged 14 findings in the "collections and small perf/style" group: set-like map[string]bool, loop string concatenation, len(s) == 0 empty-string checks, and one sort.Slice. This applies the narrow fix at each flagged site with no behavior change.

Set-like maps → map[string]struct{} (8)

  • pkg/workflow/central_slash_command_workflow.gomergedEvents event-type sets, threaded through collectCentralCommandRoutes, collectCentralSlashCommandRoutes, collectCentralLabelCommandRoutes, writeCentralSlashEventsYAML, writeCentralSlashRoutePermissions, needsPullRequestsPermission
  • pkg/workflow/samples_validation.go, samples_replay.gosampleSidecarFields and stripSidecarFields
  • pkg/cli/runner_guard_activation_gate.gogatedJobsByFile, authorAssociationGatedJobs, anyJobGated
  • pkg/linters/globwalkignorederror/globwalkignorederror.gocheckedFuncs

Membership tests become comma-ok lookups; test assertions move from assert.True(t, gated["x"]) to assert.Contains(t, gated, "x").

Loop concatenation → strings.Builder (2)

  • pkg/workflow/copilot_engine_execution.go — heredoc-delimiter uniquifying loop
  • pkg/cli/mcp_tools_readonly.go — shellcheck diagnostic accumulator; flush now resets the builder and current != "" becomes current.Len() > 0

Empty-string checks (3)

  • pkg/workflow/copilot_logs.gocontent.Content != "", with outputSize computed inside the block
  • pkg/workflow/engine_definition.goid == "" || importPath == ""

Type-safe sort (1)

pkg/cli/compile_pipeline.go swaps the sort import for cmp/slices:

slices.SortFunc(features, func(a, b featureCount) int {
	if a.count != b.count {
		return cmp.Compare(b.count, a.count)
	}
	return cmp.Compare(a.name, b.name)
})

Note on scope

check-workflow-drift currently fails on main: 284 .lock.yml files regenerate with new process_safe_outputs_items_* outputs. This reproduces on a clean tree, so the regenerated lock files are excluded from this PR.


Run: https://github.com/github/gh-aw/actions/runs/31310371321> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 4.98 AIC · ⌖ 5.48 AIC · ⊞ 6.1K ·

Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Remediate small collection and performance custom-lint findings Remediate 14 collection/perf custom-lint findings Aug 9, 2026
Copilot AI requested a review from pelikhan August 9, 2026 04:03
@pelikhan
pelikhan marked this pull request as ready for review August 9, 2026 04:05
Copilot AI balanced review requested due to automatic review settings August 9, 2026 04:05

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

Modernizes collection and sorting patterns to resolve 14 custom-lint findings without changing behavior.

Changes:

  • Replaces set-like boolean maps with struct{} sets.
  • Uses strings.Builder and direct empty-string comparisons.
  • Replaces sort.Slice with type-safe slices.SortFunc.
Show a summary per file
File Description
pkg/workflow/samples_validation.go Modernizes sidecar field sets.
pkg/workflow/samples_replay.go Updates sidecar membership checks.
pkg/workflow/engine_definition.go Simplifies empty-string checks.
pkg/workflow/copilot_logs.go Uses direct content emptiness check.
pkg/workflow/copilot_engine_execution.go Builds unique heredoc delimiters efficiently.
pkg/workflow/central_slash_command_workflow.go Modernizes event-type sets.
pkg/workflow/central_slash_command_workflow_test.go Updates the set test helper.
pkg/linters/globwalkignorederror/globwalkignorederror.go Modernizes checked-function sets.
pkg/cli/runner_guard_activation_gate.go Modernizes gated-job sets.
pkg/cli/runner_guard_activation_gate_test.go Updates set membership assertions.
pkg/cli/mcp_tools_readonly.go Uses a builder for diagnostics.
pkg/cli/compile_pipeline.go Uses type-safe feature sorting.

Review details

Tip

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

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

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: low
  • Priority: medium
  • Score: 48/100 (impact 20 + urgency 10 + quality 18)
  • Recommended action: fast_track

Ready (non-draft), CI green, reviewer commented, small footprint (12 files), no-behavior-change lint remediation - good fast-track candidate.

Generated by 🔧 PR Triage Agent · auto · 58.3 AIC · ⌖ 2.48 AIC · ⊞ 8K ·

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.individual.githubcopilot.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.individual.githubcopilot.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #51507

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (61 additions detected, threshold is 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions github-actions Bot 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.

All 14 linter remediations are correct mechanical changes: map[string]bool to map[string]struct{} set idiom applied consistently, slices.SortFunc preserves sort order, strings.Builder usage is functionally equivalent, and test assertions are correctly updated. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 15.7 AIC · ⌖ 7.12 AIC · ⊞ 5.5K

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /codebase-design — approving with one minor observation.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ Consistent mechanical transformation: every map[string]bool set becomes map[string]struct{} with comma-ok membership tests — no missed sites
  • ✅ Test assertions updated correctly to assert.Contains (the right semantic match for struct-set membership)
  • strings.Builder swap in extractShellcheckDiagnostics is genuinely a hot path and the refactor is clean
  • slices.SortFunc + cmp.Compare is the idiomatic modern Go replacement for sort.Slice
  • ✅ Empty-string simplifications (id == "", content.Content != "") improve clarity with no behaviour change
  • globwalkignorederror split into two early returns improves readability without altering logic

Minor Observation

One inline comment on copilot_engine_execution.go: the strings.Builder for the heredoc delimiter conflict loop is over-engineered for a cold/trivial path — a nolint directive would be more readable.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 20.1 AIC · ⌖ 7.51 AIC · ⊞ 7.1K
Comment /matt to run again

delimiter.WriteString("_X")
}
heredocDelimiter := delimiter.String()

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.

[/codebase-design] The strings.Builder here is over-engineering for a loop that runs 0 times in normal operation. The linter rule targets hot-path accumulations; this is a cold-path conflict-avoidance suffix loop where string concatenation is perfectly readable.

💡 Consider a targeted nolint instead
heredocDelimiter := "GH_AW_ENGINE_COMMAND_EOF"
for strings.Contains(scriptContent, heredocDelimiter) { (nolint/redacted):loop-concat -- trivial cold path
    heredocDelimiter += "_X"
}

This keeps the intent clear and documents why the deviation is intentional.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reverted to plain string concatenation with //nolint:stringsconcatloop as suggested. Commit: pushed in the latest update.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: N/A — Test Maintenance

No behavioral tests were added or modified. This PR contains only test assertion refactoring and maintenance.

📊 Analysis Summary
Signal Value
Test Files Modified 2
New Test Functions 0
Modified Test Functions 0
Test Assertion Refactoring 5 lines
🚨 Violations 0
Behavioral Tests Added 0

Changed Files:

  • pkg/cli/runner_guard_activation_gate_test.go — Assertion pattern updates (4 lines)
  • pkg/workflow/central_slash_command_workflow_test.go — Helper function signature (1 line)

Changes Made:

  • Updated assertions from assert.True(t, gated["key"])assert.Contains(t, gated, "key") in TestAuthorAssociationGatedJobs
  • Changed helper function parameter type from map[string]bool to map[string]struct{} for improved memory efficiency

Verdict

passed. Test maintenance PR with no new or modified behavioral tests. All changes are refactoring and lint remediation. No violations detected.

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 10.8 AIC · ⌖ 3.21 AIC · ⊞ 7.7K ·
Comment /review to run again

@github-actions github-actions Bot 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.

✅ Test Quality Sentinel: Infrastructure/Test Maintenance approved. No behavioral tests were added or modified—this PR contains only test assertion refactoring and lint remediation. Zero violations detected.

@github-actions github-actions Bot 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.

Ponytail review — over-engineering pass only.

One finding: the heredoc-delimiter uniquifier switched from plain string concatenation to strings.Builder, but the loop appends _X at most a couple of times to a short constant string — strings.Builder buys nothing here over +=.

Everything else in this diff (set-like map[string]boolmap[string]struct{}, sort.Sliceslices.SortFunc, len(s)==0s=="") is a net simplification with no added abstraction, matching the PR title.

net: -3 lines possible.

Generated by ✂️ Ponytail Reviewer for #51507 · auto · 30.1 AIC · ⌖ 5.26 AIC · ⊞ 6.8K
Comment /ponytail to run again

for strings.Contains(scriptContent, delimiter.String()) {
delimiter.WriteString("_X")
}
heredocDelimiter := delimiter.String()

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.

test

for strings.Contains(scriptContent, delimiter.String()) {
delimiter.WriteString("_X")
}
heredocDelimiter := delimiter.String()

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.

L756-761: shrink: strings.Builder for a delimiter that appends _X at most a couple of times. Plain string concat is shorter and just as clear: heredocDelimiter := "GH_AW_ENGINE_COMMAND_EOF"; for strings.Contains(scriptContent, heredocDelimiter) { heredocDelimiter += "_X" }.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for this PR.
Please refresh the branch if GitHub can update it cleanly, address the maintainer-facing follow-up below, and run the pr-finisher skill before handing this back.
Open review context (newest first):

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 4.98 AIC · ⌖ 5.48 AIC · ⊞ 6.1K ·
Comment /souschef to run again

…ith nolint

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage nudge for this PR.
Please refresh the branch if GitHub can update it cleanly, address the maintainer-facing follow-up below, and run the pr-finisher skill before handing this b...

The CI failures are all infrastructure cache misses (stale checkout-cgo-* key) unrelated to the code changes. Addressed the review feedback at #discussion_r3743572545: reverted the strings.Builder in buildEngineCommandScriptSetup back to plain += with //nolint:stringsconcatloop -- trivial cold path, runs 0 times in normal operation.

Copilot AI requested a review from gh-aw-bot August 9, 2026 11:28
@pelikhan
pelikhan merged commit 91bc1b2 into main Aug 9, 2026
@pelikhan
pelikhan deleted the copilot/lint-monster-remediate-findings branch August 9, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lint-monster] remediate small collection/perf custom-lint findings

4 participants