Skip to content

[dead-code] chore: remove dead functions — 5 functions removed - #55418

Merged
pelikhan merged 3 commits into
mainfrom
gh-aw/pre-created/32738169288-1
Aug 24, 2026
Merged

[dead-code] chore: remove dead functions — 5 functions removed#55418
pelikhan merged 3 commits into
mainfrom
gh-aw/pre-created/32738169288-1

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Removed 5 unreachable functions identified by deadcode ./cmd/... ./internal/tools/..., plus their exclusive tests.

Functions Removed

Function File
Sort pkg/scanfindings/scanfindings.go
CountAtLeast pkg/scanfindings/scanfindings.go
mcpGatewayMountsUseRunnerToolCache pkg/workflow/mcp_setup_gateway.go
Miner.Train pkg/agentdrain/miner.go
ResolveRisk pkg/intent/governance.go

Tests Removed

  • TestSort, TestSortOrdersBySeverityWithinSameLocation, TestCountAtLeast (pkg/scanfindings)
  • TestMcpGatewayMountsUseRunnerToolCache (pkg/workflow)
  • TestTrain, TestTrainEmptyLine (pkg/agentdrain), TestSpec_PublicAPI_Miner_Train (pkg/agentdrain) — other Train call sites rewritten to use TrainEvent
  • TestResolveRisk_* (7 tests) and TestEdgeCase_EmptyDomainsAndPriority (pkg/intent)

Verification

  • go build ./...
  • go vet ./...
  • go vet -tags=integration ./...
  • make fmt
  • go test ./pkg/scanfindings/... ./pkg/workflow/... ./pkg/agentdrain/... ./pkg/intent/...

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

Generated by 🧹 Dead Code Removal Agent · copilot · auto · 111.5 AIC · ⌖ 12.9 AIC · ⊞ 9.6K ·

  • expires on Aug 27, 2026, 6:40 AM UTC-08:00

github-actions Bot and others added 3 commits August 24, 2026 14:22
Remove unreachable functions identified by deadcode analyzer:
- scanfindings.Sort, scanfindings.CountAtLeast
- workflow.mcpGatewayMountsUseRunnerToolCache
- agentdrain.Miner.Train
- intent.ResolveRisk

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot changed the title [WIP] [dead-code] Dead Code Removal Agent: work in progress [dead-code] chore: remove dead functions — 5 functions removed Aug 24, 2026
@pelikhan
pelikhan marked this pull request as ready for review August 24, 2026 16:09
Copilot AI balanced review requested due to automatic review settings August 24, 2026 16:09
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

🧠 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 24, 2026

Copy link
Copy Markdown
Contributor Author

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

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

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Ponytail Reviewer failed. Please review the logs for details.

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.

Generated by Ponytail Reviewer for #55418

@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 — changes approved.

📋 Key Themes & Highlights

Key Themes

  • Clean API reduction: removing exported dead symbols (Sort, CountAtLeast, ResolveRisk, Miner.Train) shrinks the public surface, which is a net positive for navigability.
  • Safe migration: the only non-trivial change is replacing raw-string Miner.Train call sites in tests with structured TrainEvent calls — the rewrite is correct and consistent.
  • Tooling-backed: deadcode verification via deadcode ./cmd/... ./internal/tools/... gives high confidence these symbols are truly unreachable.

Positive Highlights

  • ✅ Every removed function has its exclusive tests removed too — no orphaned test coverage.
  • TestClusters and TestConcurrency correctly migrated to TrainEvent rather than simply deleted.
  • ✅ PR description is thorough: lists each function, its package, and confirms build/vet/fmt/test passed.
  • mcpGatewayMountsUseRunnerToolCache removed along with its mount-escape edge-case tests — the logic remains in the still-used collectMCPServerConfiguredMounts.

Minor Observation

Sort and CountAtLeast in pkg/scanfindings are documented as providing stable, deterministic ordering and severity thresholding. These are generally useful utilities. If there is a planned scanner integration that might need them, parking them in an internal helper package rather than deleting them could save re-work — but this is informational only and does not block merging.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet46 · 18.2 AIC · ⌖ 9.79 AIC · ⊞ 7.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.

Clean dead-code removal. All 5 functions deleted alongside their tests, and the one surviving test migrated from Train to TrainEvent. No remaining callers. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet46 · 15.9 AIC · ⌖ 8.95 AIC · ⊞ 6.2K

@github-actions

Copy link
Copy Markdown
Contributor Author

Comment Memory

reviewed_at: 2026-08-24T16:12:00Z
review_event: REQUEST_CHANGES
top_themes:
  - stale public API docs after exported symbol removals
  - README/spec sync broken across agentdrain, scanfindings, and intent
  - sub-agent unavailable in sandbox; direct review only
files_reviewed:
  - pkg/agentdrain/miner.go
  - pkg/agentdrain/miner_test.go
  - pkg/agentdrain/spec_test.go
  - pkg/intent/governance.go
  - pkg/intent/governance_formal_test.go
  - pkg/scanfindings/scanfindings.go
  - pkg/scanfindings/scanfindings_test.go
  - pkg/workflow/mcp_gateway_mount_policy_test.go
  - pkg/workflow/mcp_setup_gateway.go
comment_count: 3

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · pi · gpt54 · 15.2 AIC · ⌖ 7.07 AIC · ⊞ 7K ·
Comment /review 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.

REQUEST_CHANGES

The code deletions themselves are mostly straightforward, but this PR leaves the repository's published package specs behind in multiple places. Removing exported symbols while keeping them documented as public API is a merge-blocking maintenance bug because it teaches users and automation to depend on functions that no longer exist.

Blocking themes
  • pkg/agentdrain/README.md still documents (*Miner).Train
  • pkg/scanfindings/README.md still documents and demonstrates Sort / CountAtLeast
  • pkg/intent/README.md still documents ResolveRisk
  • the attempted grumpy-coder sub-agent did not run in this environment (grumpy-coder executable missing), so this review is based on direct analysis only

🔎 Code quality review by PR Code Quality Reviewer · pi · gpt54 · 15.2 AIC · ⌖ 7.07 AIC · ⊞ 7K
Comment /review to run again

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 five functions identified as unused, deletes their tests, and migrates remaining miner tests to TrainEvent.

Changes:

  • Removes scan-finding helpers, risk resolution, raw-line training, and an MCP mount helper.
  • Deletes corresponding unit and API-contract tests.
  • Migrates remaining miner tests from Train to TrainEvent.
Show a summary per file
File Description
pkg/workflow/mcp_setup_gateway.go Removes the unused mount-cache detector.
pkg/workflow/mcp_gateway_mount_policy_test.go Removes its dedicated tests.
pkg/scanfindings/scanfindings.go Removes sorting and counting APIs.
pkg/scanfindings/scanfindings_test.go Removes associated API tests.
pkg/intent/governance.go Removes risk classification.
pkg/intent/governance_formal_test.go Removes formal risk invariants.
pkg/agentdrain/spec_test.go Removes the raw-line training contract test.
pkg/agentdrain/miner.go Removes Miner.Train.
pkg/agentdrain/miner_test.go Removes training tests and migrates callers.

Review details

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

  • Files reviewed: 9/9 changed files
  • Comments generated: 4
  • Review effort level: Balanced

@@ -169,38 +167,6 @@ func Render(w io.Writer, findings []Finding) {
}
}

Comment thread pkg/agentdrain/miner.go
@@ -42,20 +42,6 @@ func NewMiner(cfg Config) (*Miner, error) {
}, nil
}

Comment thread pkg/intent/governance.go
@@ -18,45 +18,6 @@ var ErrToolDenied = errors.New("intent: tool denied by policy")
// AllowedTools is non-nil (restricted) and does not contain the requested tool.
var ErrToolNotAllowed = errors.New("intent: tool not allowed by policy")

Comment on lines 14 to +17
// Formal test suite derived from specs/intent-attribution-agent-governance.md,
// focusing on the Risk classification (ResolveRisk) and Enforcement
// (Authorizer.AuthorizeTool) sections, plus fail-closed policy compilation for
// unlinked/ambiguous attribution. Each test corresponds to a named predicate or
// invariant in the behavioral coverage map.

// TestResolveRisk_ExplicitOverride (P1/P2 — RiskExplicitOverride)
// Invariant: an explicit intent.Risk always wins over derived rules, even with
// conflicting domains/priority that would otherwise resolve differently.
func TestResolveRisk_ExplicitOverride(t *testing.T) {
rec := intent.IntentRecord{
Risk: "low",
Domains: []string{"security", "production"},
Priority: "critical",
}
assert.Equal(t, "low", intent.ResolveRisk(rec),
"P1/P2: explicit risk must win over derived rules")
}

// TestResolveRisk_SecurityCriticalIsHigh (P3 — RiskSecurityCriticalHigh)
// Invariant: domains contains security AND priority == critical => high.
func TestResolveRisk_SecurityCriticalIsHigh(t *testing.T) {
rec := intent.IntentRecord{
Domains: []string{"security"},
Priority: "critical",
}
assert.Equal(t, "high", intent.ResolveRisk(rec),
"P3: security+critical must resolve to high")
}

// TestResolveRisk_ProductionIsHigh (P4 — RiskProductionHigh)
// Invariant: domains contains production => high, independent of priority.
func TestResolveRisk_ProductionIsHigh(t *testing.T) {
cases := []string{"", "low", "critical", "unrecognized"}
for _, priority := range cases {
t.Run("priority="+priority, func(t *testing.T) {
rec := intent.IntentRecord{
Domains: []string{"production"},
Priority: priority,
}
assert.Equal(t, "high", intent.ResolveRisk(rec),
"P4: production domain must resolve to high regardless of priority")
})
}
}

// TestResolveRisk_InfrastructureIsMedium (P5 — RiskInfrastructureMedium)
// Invariant: domains contains infrastructure => medium.
func TestResolveRisk_InfrastructureIsMedium(t *testing.T) {
rec := intent.IntentRecord{Domains: []string{"infrastructure"}}
assert.Equal(t, "medium", intent.ResolveRisk(rec),
"P5: infrastructure domain must resolve to medium")
}

// TestResolveRisk_DocumentationIsLow (P6 — RiskDocumentationLow)
// Invariant: domains contains documentation => low.
func TestResolveRisk_DocumentationIsLow(t *testing.T) {
rec := intent.IntentRecord{Domains: []string{"documentation"}}
assert.Equal(t, "low", intent.ResolveRisk(rec),
"P6: documentation domain must resolve to low")
}

// TestResolveRisk_UnknownDefault (P7 — RiskUnknownDefault)
// Invariant: no matching rule (empty, unrecognized domain, security without
// critical priority) => unknown.
func TestResolveRisk_UnknownDefault(t *testing.T) {
cases := []struct {
name string
rec intent.IntentRecord
}{
{"empty", intent.IntentRecord{}},
{"unrecognized_domain", intent.IntentRecord{Domains: []string{"marketing"}}},
{"security_without_critical", intent.IntentRecord{Domains: []string{"security"}, Priority: "low"}},
{"security_no_priority", intent.IntentRecord{Domains: []string{"security"}}},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, "unknown", intent.ResolveRisk(tc.rec),
"P7: non-matching input must resolve to unknown")
})
}
}

// TestResolveRisk_PrecedenceOrder (P8 — RiskPrecedenceOrder)
// Invariant: security+critical takes precedence when multiple domains overlap.
func TestResolveRisk_PrecedenceOrder(t *testing.T) {
rec := intent.IntentRecord{
Domains: []string{"documentation", "infrastructure", "production", "security"},
Priority: "critical",
}
assert.Equal(t, "high", intent.ResolveRisk(rec),
"P8: security+critical must take precedence over other overlapping domains")
}
// focusing on Enforcement (Authorizer.AuthorizeTool) sections, plus fail-closed
// policy compilation for unlinked/ambiguous attribution. Each test corresponds
// to a named predicate or invariant in the behavioral coverage map.
@github-actions github-actions Bot mentioned this pull request Aug 24, 2026
@pelikhan
pelikhan merged commit 174f6d0 into main Aug 24, 2026
109 of 133 checks passed
@pelikhan
pelikhan deleted the gh-aw/pre-created/32738169288-1 branch August 24, 2026 16:20
@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.87.5

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.

2 participants