Skip to content

[dead-code] chore: remove dead functions — 1 function removed#43212

Merged
pelikhan merged 4 commits into
mainfrom
chore/dead-code-removal-hasmodelpricingresolver-437451664ba8954e
Jul 4, 2026
Merged

[dead-code] chore: remove dead functions — 1 function removed#43212
pelikhan merged 4 commits into
mainfrom
chore/dead-code-removal-hasmodelpricingresolver-437451664ba8954e

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the dead exported method HasModelPricingResolver() from workflow.Compiler and replaces its test-only usage with a package-private reflection helper that preserves behavioral coverage without re-exporting internal state.

Changes

pkg/workflow/compiler_types.go

  • Removed exported method HasModelPricingResolver() bool from *Compiler.
    • Method was never used outside tests; it leaked a visibility window into private state (modelPricingResolver field) with no production caller.

pkg/cli/compile_compiler_setup_test.go

  • Added reflect import.
  • Added package-private helper hasModelPricingResolver(compiler *workflow.Compiler) bool that uses reflect.ValueOf to inspect the private modelPricingResolver field — preserving the same assertions without requiring a public API.
  • Updated TestCreateAndConfigureCompiler_RegistersModelPricingResolverByDefault and TestCreateAndConfigureCompiler_SkipsModelPricingResolverWhenDisabled to call the new helper instead of the removed method.
  • Helper is annotated with a comment requiring field-name synchronisation with workflow.Compiler.

API Surface

Symbol Package Change
(*Compiler).HasModelPricingResolver() pkg/workflow Removed

Motivation

Dead exported functions add noise to the public API surface, can be mistakenly relied upon by callers, and create maintenance burden. The method existed solely to support two test assertions; inlining the check via reflection keeps the coverage intact without widening the API.

Test Impact

No tests removed. Both compiler-setup tests continue to assert the same invariants via the reflection helper. No behavioural change.

Generated by PR Description Updater for #43212 · 31.7 AIC · ⌖ 6.08 AIC · ⊞ 4.7K ·

Remove HasModelPricingResolver from Compiler since it has no
callers outside test files. Remove its two exclusive test
functions that tested nothing else.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review July 3, 2026 15:29
Copilot AI review requested due to automatic review settings July 3, 2026 15:29
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

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

No ADR enforcement needed: PR #43212 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

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

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. All test changes are pure deletions (removal of two test functions for the dead HasModelPricingResolver function). Test Quality Sentinel skipped.

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

Removes a dead exported helper (Compiler.HasModelPricingResolver) from the workflow compiler API and deletes the CLI tests that depended on that helper.

Changes:

  • Removed (*workflow.Compiler).HasModelPricingResolver from pkg/workflow/compiler_types.go.
  • Removed two tests in pkg/cli/compile_compiler_setup_test.go that asserted models.dev pricing resolver registration via that helper.
Show a summary per file
File Description
pkg/workflow/compiler_types.go Removes the HasModelPricingResolver method from Compiler.
pkg/cli/compile_compiler_setup_test.go Removes tests that validated models.dev pricing resolver setup behavior via the removed method.

Review details

Tip

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

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

}
}

// TestSetupRepositoryContext_ValidScheduleSeedLocksSlug verifies that when

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.

Covered by commit 8c41a0a: I restored behavioral coverage in pkg/cli/compile_compiler_setup_test.go for both default resolver wiring and DisableModelsDevLookup skip behavior in createAndConfigureCompiler.

@github-actions github-actions Bot mentioned this pull request Jul 3, 2026

@github-actions github-actions Bot left a comment

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.

LGTM

Dead code removal is clean and complete:

  • HasModelPricingResolver() had no callers in the codebase — safe to remove.
  • The two deleted tests only exercised this dead getter; they provide no coverage value once the function is gone.
  • The underlying field (modelPricingResolver), its setter, and all real usage paths remain intact.

No actionable issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 14 AIC · ⌖ 6.09 AIC · ⊞ 4.9K

@github-actions github-actions Bot left a comment

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.

Skills-Based Review 🧠

Applied /codebase-design — this is a clean, well-executed dead code removal. Approving.

📋 Key Themes & Highlights

Key Themes

  • Clean removal: HasModelPricingResolver() had zero remaining call sites — confirmed by go build and go vet
  • Tests correctly removed: The two tests that validated the deleted method are properly removed alongside it

Positive Highlights

  • ✅ Automated dead-code analysis correctly identified a predicate with no callers
  • SetModelPricingResolver (the setter) and the underlying modelPricingResolver field remain — the capability is preserved, only the unnecessary public predicate was removed
  • ✅ Verification checklist complete (go build, go vet, make fmt)
  • ✅ 0 additions / 19 deletions — pure shrinkage, no regression risk

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 28.9 AIC · ⌖ 5.58 AIC · ⊞ 6.6K
Comment /matt to run again

@github-actions github-actions Bot left a comment

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.

Non-blocking observation: test coverage gap on DisableModelsDevLookup

The dead-code removal is correct — HasModelPricingResolver has no remaining callers and the production change is clean. One concern worth addressing before or shortly after merge: the two deleted tests were the only coverage for the DisableModelsDevLookup conditional in compile_compiler_setup.go. That branch is now invisible to the test suite.

🔎 Code quality review by PR Code Quality Reviewer · 60 AIC · ⌖ 5.03 AIC · ⊞ 5.4K
Comment /review to run again

@@ -8,20 +8,6 @@
"github.com/github/gh-aw/pkg/workflow"

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.

Test coverage for DisableModelsDevLookup branch is now zero: the two removed tests were the only safety net verifying that createAndConfigureCompiler wires (or skips) SetModelPricingResolver based on DisableModelsDevLookup.

💡 Why this matters and suggested fix

The conditional at compile_compiler_setup.go:119-125:

if config.DisableModelsDevLookup {
    // no resolver registered
} else {
    compiler.SetModelPricingResolver(FindOrFetchModelPricing)
}

...is now completely untested at the CLI setup level. If the condition is accidentally inverted, the else branch dropped, or the wrong resolver wired in a future refactor, nothing will catch it.

Options:

  1. Keep a package-internal (unexported) helper instead of deleting the method entirely:
// in compiler_types.go — unexported, tests-only visibility via same package
func (c *Compiler) hasModelPricingResolver() bool {
    return c.modelPricingResolver != nil
}
  1. Replace the deleted tests with ones that inspect resolver behaviour indirectly (compile a minimal workflow that needs pricing and assert the resolver is/isn't called).
  2. At minimum, add a comment in the test file noting that this branch is intentionally not covered at the unit level.

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.

Addressed in 8c41a0a with restored CLI setup tests, and documented the remaining reflective coupling note in 0a49da8. The DisableModelsDevLookup branch now has explicit test coverage again.

@pelikhan

pelikhan commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@copilot run pr-finisher skill

Ran the pr-finisher pass on this PR. No additional code changes were needed on top of af82885, and local validation passed (make fmt, make lint, make test-unit, make test, make recompile). CI on the current agent head still needs a maintainer-triggered rerun before merge.

Copilot AI requested a review from pelikhan July 3, 2026 16:06
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the latest review feedback about preserving coverage for DisableModelsDevLookup, verify whether the branch needs a refresh from main, and rerun checks once ready.

Run: https://github.com/github/gh-aw/actions/runs/28671435759

Generated by 👨‍🍳 PR Sous Chef · 7.24 AIC · ⌖ 3.05 AIC · ⊞ 6.6K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 3, 2026 16:26
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@copilot please run the pr-finisher skill, address the latest review feedback about preserving coverage for DisableModelsDevLookup, verify whether the branch needs a refresh from main, and rerun...

Implemented and pushed coverage restoration for DisableModelsDevLookup in pkg/cli/compile_compiler_setup_test.go via 8c41a0a (tests restored) and 0a49da8 (follow-up note on reflective coupling). Verified branch freshness: local origin/main...HEAD is 2 3 (branch is behind main by 2 commits). Re-ran checks locally after final changes: make fmt, make lint, make test-unit, make test, and make recompile all pass.

Copilot AI requested a review from gh-aw-bot July 3, 2026 16:32
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

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

Generated by 👨‍🍳 PR Sous Chef · 7.23 AIC · ⌖ 3.11 AIC · ⊞ 6.6K ·
Comment /souschef to run again

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

...

Ran a fresh pr-finisher pass on current HEAD 43f4bdc after updating from main.

  • Reviewed unresolved in-scope feedback: the two open review threads are already addressed by 8c41a0a (coverage restored) and 0a49da8 (follow-up test note), and I’ve replied on both threads.
  • Branch is now up to date with main (origin/main...HEAD = 0 4).
  • Re-ran checks locally: make fmt ✅, make test-unit ✅, make test ✅, make recompile ✅.
  • make lint is currently failing on pkg/workflow/arc_dind_artifacts.go:18 (stringscutprefix modernize suggestion) from upstream commit 332d5e2 merged from main, not from this PR’s dead-code/test-coverage changes.

CI on this branch head remains maintainer-triggered; please re-run required workflows after this pass.

@pelikhan pelikhan merged commit d005c9b into main Jul 4, 2026
1 check passed
@pelikhan pelikhan deleted the chore/dead-code-removal-hasmodelpricingresolver-437451664ba8954e branch July 4, 2026 03:09
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.

4 participants