Skip to content

refactor(workflow): extract helpers to fix function-length lint violations#44008

Merged
pelikhan merged 8 commits into
mainfrom
copilot/lint-monster-function-length-refactoring-again
Jul 8, 2026
Merged

refactor(workflow): extract helpers to fix function-length lint violations#44008
pelikhan merged 8 commits into
mainfrom
copilot/lint-monster-function-length-refactoring-again

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Addresses a slice of the largefunc lint backlog (limit: 60 lines) in pkg/workflow. Four functions just over the limit were split into focused helpers with no behavior changes.

Extractions

  • action_resolver.goResolveSHA (67→~52 lines): extracted lookupEmbeddedActionPin, which encapsulates the embedded-pin semver matching loop
  • antigravity_tools.gocomputeAntigravityToolsCore (65→~35 lines): extracted appendBashTools, which handles the bash neutral-tool → run_shell_command expansion including wildcard and per-command cases
  • build_input_schema.gobuildInputSchema (69→~56 lines): extracted buildChoiceInputProperty (enum/choice schema) and buildInputProperty (scalar schema), removing an inline map-construction block repeated for choice vs. non-choice paths
  • codex_engine.gogetShellEnvironmentPolicyVars (61→~27 lines): extracted addMCPToolEnvVars, which owns the switch mapping known MCP tool names (github, agentic-workflows, safe-outputs, custom) to their required environment variables

All new helpers are package-private and co-located with the refactored function.


Generated by 👨‍🍳 PR Sous Chef · 11.9 AIC · ⌖ 7.75 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 3.94 AIC · ⌖ 7.46 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 4.03 AIC · ⌖ 8.11 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 7.79 AIC · ⌖ 6.55 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 8.05 AIC · ⌖ 8.96 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 9.66 AIC · ⌖ 5.93 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 7, 2026 11:03
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…r helpers

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Consolidate function-length refactoring findings refactor(workflow): extract helpers to fix function-length lint violations Jul 7, 2026
Copilot AI requested a review from pelikhan July 7, 2026 11:09
@github-actions github-actions Bot mentioned this pull request Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Triage · Run §28868091227

Field Value
Category refactor
Risk Low
Score 28 / 100
Action defer

Score breakdown: Impact 10 · Urgency 5 · Quality 13

Rationale: Draft. Extracts helpers from 4 over-limit functions in pkg/workflow (+135/-109, 4 files). Pure refactor, no behavior change. Low urgency — promote from draft then batch with other lint/refactor PRs.

Labels: pr-type:refactor pr-risk:low pr-priority:low pr-action:defer

Generated by 🔧 PR Triage Agent · 119.4 AIC · ⌖ 6.65 AIC · ⊞ 5.4K ·

@pelikhan pelikhan marked this pull request as ready for review July 7, 2026 14:22
Copilot AI review requested due to automatic review settings July 7, 2026 14:22
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

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

Refactors several pkg/workflow functions that slightly exceeded the largefunc lint limit by extracting focused, package-private helpers while preserving existing behavior and keeping the logic co-located.

Changes:

  • Extracted embedded action-pin semver matching into lookupEmbeddedActionPin from ActionResolver.ResolveSHA.
  • Extracted bash neutral-tool expansion into appendBashTools from computeAntigravityToolsCore.
  • Extracted JSON Schema property construction into buildChoiceInputProperty and buildInputProperty from buildInputSchema.
  • Extracted MCP-tool environment-variable collection into addMCPToolEnvVars from CodexEngine.getShellEnvironmentPolicyVars.
Show a summary per file
File Description
pkg/workflow/action_resolver.go Extracts embedded action-pin lookup into a helper to reduce ResolveSHA length without changing resolution behavior.
pkg/workflow/antigravity_tools.go Extracts bash tool mapping/expansion logic into appendBashTools to shorten computeAntigravityToolsCore.
pkg/workflow/build_input_schema.go Extracts schema property construction helpers to reduce duplication and shorten buildInputSchema.
pkg/workflow/codex_engine.go Extracts MCP tool → required env var mapping into addMCPToolEnvVars to shorten getShellEnvironmentPolicyVars.

Review details

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Low

@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.

The four extractions are clean behavioral-preserving refactors. Each helper is well-named, co-located, and package-private.

Specifically verified:

  • lookupEmbeddedActionPin: semver loop moved intact; resolverLog is package-level and accessible.
  • appendBashTools: early-return on wildcard is equivalent to the original hasWildcard flag — per-command iteration is correctly skipped in both cases.
  • buildChoiceInputProperty: (nil, false) fall-through preserves the original "no options → scalar string" path.
  • addMCPToolEnvVars: no CodexEngine fields used; correctly promoted to a package-level function.

No behavior changes detected. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 26.4 AIC · ⌖ 5.79 AIC · ⊞ 4.8K

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (135 new lines in pkg/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/44008-extract-helpers-comply-largefunc-lint-limit.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-44008: Extract Package-Private Helpers to Comply with the largefunc Lint Limit

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 0042-use-postgresql.md for PR #42).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · 39.9 AIC · ⌖ 11.9 AIC · ⊞ 4.2K ·
Comment /review to run again

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address outstanding review feedback, and rerun checks once the branch is up to date.

...

PR is merge-ready. Here's the current state:

  • Reviews — Both unresolved threads were addressed in commit b299c85 (code changes + replies in place). resolveReviewThread returns 403 from this agent; a maintainer needs to resolve the two threads manually. No remaining code changes needed.
    • PRRT_kwDOPc1QR86O8wkK: TestLookupEmbeddedActionPin added to action_resolver_test.go covering precise-match, semver-range, unknown-repo, and incompatible-version cases.
    • PRRT_kwDOPc1QR86O8wkS: appendBashTools refactored to true single-pass loop (accumulator pattern discards pre-wildcard entries on wildcard hit).
  • Checks (local)make fmt / make lint / make test-unit all pass on HEAD.
  • Checks (CI) — Stale after agent push; prior run (28894422744) is all green. Needs human re-trigger to confirm HEAD.
  • Mergeableopen, not draft, mergeable_state: clean.

Hand-off: A maintainer should resolve the two review threads and re-trigger CI (close/reopen or workflow_dispatch) before merging.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, make the PR merge-ready, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 7.79 AIC · ⌖ 6.55 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, make the PR merge-ready, and rerun checks once the branch is up to date.

...

No new action needed — the PR remains in the same state as the last run:

  • Reviews — Both threads addressed in b299c85; replies posted. resolveReviewThread returns 403 from this agent; a maintainer must resolve them manually.
  • Checks (local)make fmt / make lint / make test-unit all pass on HEAD (3f8b0ec).
  • Checks (CI) — Last full run (28894422744) is all green. CI on HEAD is unverified until a human re-triggers it.
  • Mergeableopen, not draft, mergeable_state: clean.

Hand-off: A maintainer needs to resolve the two review threads and re-trigger CI before merging.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, make this PR merge-ready, address all unresolved review feedback, and rerun checks once the branch is up to date.

Unresolved review threads to address (newest first):

Generated by 👨‍🍳 PR Sous Chef · 8.05 AIC · ⌖ 8.96 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, make this PR merge-ready, address all unresolved review feedback, and rerun checks once the branch is up to date.

Unresolved review threads to address (ne...

Both threads were fully addressed in commit b299c85 and already have replies:

  • r3537330408: TestLookupEmbeddedActionPin is in action_resolver_test.go (four test cases).
  • r3537330417: appendBashTools uses a true single-pass loop with early return on wildcard.

The threads remain unresolved only because resolveReviewThread returns 403 from this agent — a maintainer needs to resolve them manually. No code changes remain outstanding.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, make this PR merge-ready, address all unresolved review feedback, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 9.66 AIC · ⌖ 5.93 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, make this PR merge-ready, address all unresolved review feedback, and rerun checks once the branch is up to date.

...

No change in state since the last run. All review feedback is addressed in b299c85; the two threads remain unresolved only because resolveReviewThread returns 403 from this agent. A maintainer must resolve them manually — no further code changes are needed.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

\n@copilot please run the skill, make this PR merge-ready, address all unresolved review feedback, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 13 AIC · ⌖ 12.3 AIC · ⊞ 7.1K ·
Comment /souschef to run again

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Triage (updated)

Field Value
Category refactor
Risk 🟢 Low
Score 35/100 (impact:15 urgency:8 quality:12)
Action batch_review — Batch: pr-batch:code-quality
Carry-over x2 (promoted from draft)

Rationale: Promoted from draft. Clean function-length lint refactor (230+/109−, 6 files). Added to code-quality batch with #44051. Review together.

Run §28909358158

Generated by 🔧 PR Triage Agent · 112.1 AIC · ⌖ 6.5 AIC · ⊞ 5.4K ·

@pelikhan pelikhan merged commit b7af75b into main Jul 8, 2026
34 checks passed
@pelikhan pelikhan deleted the copilot/lint-monster-function-length-refactoring-again branch July 8, 2026 01:39
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.4

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] Function-length refactoring backlog (2026-07-07)

4 participants