Skip to content

👻 Export Analyzer accessors and update progress types for MCP server#926

Merged
JonahSussman merged 4 commits into
konveyor:mainfrom
JonahSussman:mcp-analyzer-exports
Apr 16, 2026
Merged

👻 Export Analyzer accessors and update progress types for MCP server#926
JonahSussman merged 4 commits into
konveyor:mainfrom
JonahSussman:mcp-analyzer-exports

Conversation

@JonahSussman

@JonahSussman JonahSussman commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add 4 exported methods to the Analyzer interface: Providers(), RuleSets(), Cache(), CachedRuleSets() — enabling the upcoming MCP server to query analyzer internals without reimplementing
  • Update progress type references to match current analyzer-lsp HEAD (ProgressReporterReporter, ProgressEventEvent, reporters moved to progress/reporter sub-package)
  • Bump analyzer-lsp dependency to latest upstream main
  • Adapt lib.GetProviderClient calls for new *progress.Progress parameter

Trunk config update

The analyzer-lsp dependency bump requires go 1.25, which broke trunk's golangci-lint (v1.61.0, built with go 1.23). Updated trunk config:

  • go@1.23.0go@1.25.0
  • golangci-lint@1.61.0golangci-lint@1.64.8 (v2 has a module path change that trunk can't install yet)
  • All other linters upgraded to latest via trunk upgrade check

Test plan

  • 6 new unit tests for exported methods (analyzer_exports_test.go)
  • All 26 existing tests pass with no regressions
  • Build compiles cleanly
  • trunk check --ci passes with no new issues

Context

The Konveyor MCP server (konveyor/enhancements#259) is being built in a separate repo (konveyor-ecosystem/analyzer-mcp) that imports kai-analyzer in-process. These exports let the MCP server access providers, rulesets, and cached results directly rather than reimplementing.

Add 4 exported methods to the Analyzer interface (Providers, RuleSets,
Cache, CachedRuleSets) so the upcoming MCP server can query analyzer
internals without reimplementing. Update progress type references to
match current analyzer-lsp HEAD (ProgressReporter->Reporter,
ProgressEvent->Event) and bump the analyzer-lsp dependency.

Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
@coderabbitai

coderabbitai Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR updates the codebase to use a newer analyzer-lsp API where progress.ProgressReporter is replaced with progress.Reporter and progress.ProgressEvent is replaced with progress.Event. The Go toolchain is bumped to 1.25 with updated XML dependencies, and new accessor methods are added to the Analyzer interface for exposing internal providers, rulesets, and cache.

Changes

Cohort / File(s) Summary
Dependency Updates
kai_analyzer_rpc/go.mod
Updated Go toolchain from 1.23.12 to 1.25, bumped analyzer-lsp from alpha to beta, and updated XML-related dependencies (antchfx/xmlquery and antchfx/xpath).
Progress Reporter API Migration
kai_analyzer_rpc/main.go, kai_analyzer_rpc/main_test.go, kai_analyzer_rpc/pkg/rpc/server.go, kai_analyzer_rpc/pkg/rpc/server_windows.go, kai_analyzer_rpc/pkg/service/multi_progress_reporter.go, kai_analyzer_rpc/pkg/service/pipe_analyzer.go, kai_analyzer_rpc/pkg/service/rpc_progress_reporter.go, kai_analyzer_rpc/pkg/service/rpc_progress_reporter_test.go
Replaced progress.ProgressReporter with progress.Reporter and progress.ProgressEvent with progress.Event across constructor signatures, method signatures, struct fields, and test code. Updated imports to use progressreporter package for reporter constructors.
Analyzer Interface Extension
kai_analyzer_rpc/pkg/service/analyzer.go, kai_analyzer_rpc/pkg/service/analyzer_exports_test.go
Added four new accessor methods to Analyzer interface: Providers(), RuleSets(), Cache(), and CachedRuleSets(). Implemented these methods and added comprehensive test coverage validating provider access, ruleset retrieval, incident caching, and cached ruleset reconstruction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through progress streams so bright, 🐰
From ProgressReporter to Reporter in flight,
New interface methods fetch providers with glee,
While caches and rulesets dance wild and free!
With Go 1.25 and dependencies renewed,
The analyzer's foundation is fresh and improved! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: exporting Analyzer accessors and updating progress types. Both aspects are clearly reflected in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
kai_analyzer_rpc/pkg/service/rpc_progress_reporter_test.go (1)

121-125: ⚠️ Potential issue | 🟡 Minor

Fail fast when payload type assertion fails in tests.

At Line 121 and Line 152, field assertions only run when notification.args is progress.Event; if not, the test silently passes. Add explicit failure branches to avoid false positives.

✅ Suggested test hardening
-		if eventArg, ok := notification.args.(progress.Event); ok {
+		if eventArg, ok := notification.args.(progress.Event); ok {
 			if eventArg.Stage != stages[i] {
 				t.Errorf("notification %d: expected stage %s, got %s", i, stages[i], eventArg.Stage)
 			}
+		} else {
+			t.Fatalf("notification %d: expected args type progress.Event, got %T", i, notification.args)
 		}
-	if eventArg, ok := notifications[0].args.(progress.Event); ok {
+	if eventArg, ok := notifications[0].args.(progress.Event); ok {
 		if eventArg.Current != 5 {
 			t.Errorf("expected current 5, got %d", eventArg.Current)
 		}
 		if eventArg.Total != 10 {
 			t.Errorf("expected total 10, got %d", eventArg.Total)
 		}
 		if eventArg.Percent != 50.0 {
 			t.Errorf("expected percent 50.0, got %f", eventArg.Percent)
 		}
+	} else {
+		t.Fatalf("expected args type progress.Event, got %T", notifications[0].args)
 	}

Also applies to: 152-162

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@kai_analyzer_rpc/pkg/service/rpc_progress_reporter_test.go` around lines 121
- 125, The test silently skips checks when notification.args is not a
progress.Event; change both type-assertion blocks (the ones using "if eventArg,
ok := notification.args.(progress.Event); ok { ... }") to fail fast by adding an
else branch that calls t.Fatalf (or t.Errorf followed by return) with the actual
type information, e.g. report that notification.args was not a progress.Event
and include its type/value; make the same change for the second occurrence (the
block that inspects stages and other fields) so the test cannot pass silently
when the payload type assertion fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@kai_analyzer_rpc/pkg/service/analyzer.go`:
- Around line 236-246: The accessors Providers(), RuleSets(), and Cache() expose
live mutable internals (a.initedProviders, a.discoveryRulesets,
a.violationRulesets, a.cache); change them to return defensive copies or
immutable snapshots instead: for Providers() return a newly allocated map with
copied entries from a.initedProviders; for RuleSets() return copies of the
slices (copy the slice header and underlying elements into new slices) for
discoveryRulesets and violationRulesets; for Cache() either return an immutable
snapshot/clone of a.cache or expose a read-only interface method (e.g.,
Snapshot() or ReadOnlyIncidentsCache) that prevents callers from mutating the
analyzer's internal cache. Ensure you use the existing symbol names (Providers,
RuleSets, Cache, initedProviders, discoveryRulesets, violationRulesets, cache)
when making the changes.

---

Outside diff comments:
In `@kai_analyzer_rpc/pkg/service/rpc_progress_reporter_test.go`:
- Around line 121-125: The test silently skips checks when notification.args is
not a progress.Event; change both type-assertion blocks (the ones using "if
eventArg, ok := notification.args.(progress.Event); ok { ... }") to fail fast by
adding an else branch that calls t.Fatalf (or t.Errorf followed by return) with
the actual type information, e.g. report that notification.args was not a
progress.Event and include its type/value; make the same change for the second
occurrence (the block that inspects stages and other fields) so the test cannot
pass silently when the payload type assertion fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 299cf035-3b25-4881-a190-f5557b3bab01

📥 Commits

Reviewing files that changed from the base of the PR and between 81d3d43 and 54a836f.

⛔ Files ignored due to path filters (1)
  • kai_analyzer_rpc/go.sum is excluded by !**/*.sum
📒 Files selected for processing (11)
  • kai_analyzer_rpc/go.mod
  • kai_analyzer_rpc/main.go
  • kai_analyzer_rpc/main_test.go
  • kai_analyzer_rpc/pkg/rpc/server.go
  • kai_analyzer_rpc/pkg/rpc/server_windows.go
  • kai_analyzer_rpc/pkg/service/analyzer.go
  • kai_analyzer_rpc/pkg/service/analyzer_exports_test.go
  • kai_analyzer_rpc/pkg/service/multi_progress_reporter.go
  • kai_analyzer_rpc/pkg/service/pipe_analyzer.go
  • kai_analyzer_rpc/pkg/service/rpc_progress_reporter.go
  • kai_analyzer_rpc/pkg/service/rpc_progress_reporter_test.go

Comment thread kai_analyzer_rpc/pkg/service/analyzer.go
The analyzer-lsp dependency bump requires go 1.25. Update trunk's go
runtime and golangci-lint accordingly.

Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Providers(), RuleSets(), and Cache() now return copies instead of live
internal references, preventing callers from mutating analyzer state.

Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
@JonahSussman JonahSussman changed the title Export Analyzer accessors and update progress types for MCP server 👻 Export Analyzer accessors and update progress types for MCP server Apr 16, 2026
@JonahSussman
JonahSussman merged commit 29ae739 into konveyor:main Apr 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants