Skip to content

Refactor three pkg/workflow largefunc hotspots into local helpers#43195

Open
pelikhan with Copilot wants to merge 6 commits into
mainfrom
copilot/lint-monster-function-length-refactoring
Open

Refactor three pkg/workflow largefunc hotspots into local helpers#43195
pelikhan with Copilot wants to merge 6 commits into
mainfrom
copilot/lint-monster-function-length-refactoring

Conversation

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

This trims a small slice of the function-length backlog in pkg/workflow by removing three largefunc findings without changing behavior. The refactor stays local to the existing package and focuses on helper extraction around existing control flow.

  • Action resolver

    • Extracts embedded-pin lookup from ResolveSHA into a dedicated helper.
    • Keeps the existing resolution order intact: failed-run short-circuit, cache hit, embedded pin, then GitHub API fallback.
    • Preserves the existing behavior that embedded pins are resolved in-memory and are not written back to the on-disk cache.
  • Antigravity tool mapping

    • Splits bash tool expansion from computeAntigravityToolsCore into focused helpers.
    • Isolates wildcard detection from per-command mapping.
    • Keeps canonical run_shell_command(...) generation unchanged, including normalization of entries like jq *.
  • Input schema generation

    • Extracts per-input schema construction from buildInputSchema.
    • Separates metadata extraction (description, required) from property assembly.
    • Preserves existing handling for number, boolean, choice, and fallback-to-string cases.
  • Targeted regression coverage

    • Adds coverage for embedded action pin resolution staying out of cache persistence.
    • Adds coverage for invalid choice.options shapes falling back to plain string properties.
    • Adds coverage for non-string bash command entries being ignored during Antigravity tool expansion.

Example of the extracted ResolveSHA flow:

if sha, found := r.cache.GetByCacheKey(cacheKey); found {
	return sha, nil
}

if sha, found := r.resolveFromEmbeddedPins(repo, version); found {
	return sha, nil
}

return r.resolveFromGitHub(ctx, repo, version)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Hey @copilot-swe-agent 👋 — thanks for picking up the lint-monster function-length backlog in pkg/workflow and pkg/cli! The PR is well-scoped and clearly tied to the tracking issue. A couple of things to address before it's reviewable:

  • Add actual code changes — the PR currently has 0 additions and 0 deletions. The remediation plan is solid, but the refactoring work (helper extraction, control-flow simplification) needs to land in the diff before reviewers can evaluate it.
  • Include or update tests — once the helpers are extracted, confirm that existing tests still pass and add targeted tests for any new helper functions that have non-trivial logic.
  • Validate with make golint-custom — the issue checklist asks for confirmation that the refactored functions no longer appear in the largefunc findings; include that output (or a summary of removed findings) in the PR description.

If you'd like a hand completing this, here's a ready-to-use prompt:

Complete the function-length refactoring for the first suggested slice from the lint-monster tracking issue (github/gh-aw#42880).

Slice to address:
- pkg/workflow/action_resolver.go (ResolveSHA, 67 lines)
- pkg/workflow/antigravity_tools.go
- pkg/workflow/build_input_schema.go

Steps:
1. Extract helpers to reduce each function below the lint threshold. Keep helpers in the same package; do not create shared abstractions unless clearly justified.
2. Preserve all existing behavior and tests.
3. Run `make golint-custom` and confirm the targeted functions no longer appear in the largefunc findings.
4. Update this PR description with the list of functions removed from the backlog and any recommended follow-up slices.

Generated by ✅ Contribution Check · 116.2 AIC · ⌖ 16 AIC · ⊞ 6.3K ·

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor shared function lengths in pkg/workflow and pkg/cli Refactor three pkg/workflow largefunc hotspots into local helpers Jul 3, 2026
Copilot AI requested a review from pelikhan July 3, 2026 13:35
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

PR Triage

Field Value
Category refactor (function-length)
Risk Medium
Score 30 (impact 12 + urgency 8 + quality 10)
Action defer

Breakdown: Extracts 3 largefunc hotspots in pkg/workflow into local helpers. Draft. 186 add/108 del. No behavior change claimed but untested refactor in workflow core. Low urgency.

Next: Promote to ready when tests confirm no regressions; consider batching with other lint-monster refactors.

Generated by 🔧 PR Triage Agent · 86.6 AIC · ⌖ 10.9 AIC · ⊞ 5.5K ·

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

This pull request refactors three pkg/workflow “largefunc” hotspots by extracting local helper functions while aiming to preserve existing behavior, and adds targeted regression tests around the refactored flows.

Changes:

  • Extracted per-input schema construction into helpers for buildInputSchema.
  • Split Antigravity bash tool expansion into appendAntigravityBashTools plus a dedicated wildcard detector.
  • Extracted embedded action pin resolution from ActionResolver.ResolveSHA into resolveFromEmbeddedPins, and added regression coverage around cache non-persistence.
Show a summary per file
File Description
pkg/workflow/build_input_schema.go Extracts per-input schema building into helper functions.
pkg/workflow/build_input_schema_test.go Adds coverage for invalid choice.options shape falling back to plain string schema.
pkg/workflow/antigravity_tools.go Extracts bash tool mapping/wildcard detection into helpers.
pkg/workflow/antigravity_engine_test.go Adds coverage for ignoring non-string bash command entries during tool expansion.
pkg/workflow/action_resolver.go Extracts embedded-pin lookup into a dedicated resolver helper.
pkg/workflow/action_resolver_test.go Adds regression coverage ensuring embedded pins do not write to the on-disk action cache.

Review details

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment on lines +48 to +50
inputType = "string"
inputDescription, inputRequired := getInputSchemaMetadata(inputName, inputDefMap, descriptionFn)
if typeStr, ok := inputDefMap["type"].(string); ok {

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.

Fixed in the latest commit. Changed := to var inputDescription string + = assignment so inputRequired correctly assigns to the named return variable without shadowing.

Comment thread pkg/workflow/action_resolver_test.go Outdated
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, add and link the required ADR in the PR body, refresh the branch from main if needed, and rerun checks once updates are pushed.

Generated by 👨‍🍳 PR Sous Chef · 5.58 AIC · ⌖ 7.65 AIC · ⊞ 6.7K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 4, 2026 03:53
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…ionPinByRepo, add ADR, fix pre-existing lint/golden issues

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

Copilot AI commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, add and link the required ADR in the PR body, refresh the branch from main if needed, and rerun checks once updates are pushed.

...

Done:

  • ADR added: docs/adr/43195-refactor-workflow-largefunc-hotspots.md — covers the three helper extractions, alternatives considered, and behavioral invariants preserved.
  • Review threads addressed: fixed named return shadowing in build_input_schema.go and switched to GetLatestActionPinByRepo() in the test.
  • Branch already up-to-date with main (merge commit 51a5887 was already present).
  • Pre-existing issues fixed: modernize lint in arc_dind_artifacts.go and stale WASM golden for the playwright-cli version bump — both came in via the main merge.
  • Local validation: make agent-report-progress passes cleanly.

CI needs a human re-trigger (close/reopen or workflow_dispatch) since agent pushes do not trigger workflows.

Copilot AI requested a review from gh-aw-bot July 4, 2026 04:07
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] lint-monster: function-length refactoring backlog

4 participants