Skip to content

Conversation

@pranavgaikwad
Copy link
Contributor

@pranavgaikwad pranavgaikwad commented Nov 21, 2025

Requires konveyor/analyzer-lsp#975

Summary by CodeRabbit

  • Improvements
    • Providers are now aggregated and prepared with computed per-provider conditions before rule execution, improving reliability and consistency of rule processing.
    • Provider preparation reports errors without aborting execution and preserves existing sequencing of compilation, preparation, then execution.
  • Chores
    • Updated analyzer and external provider packages to newer versions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

Walkthrough

Aggregates provider-specific conditions returned by rule loading, updates parser.LoadRules to return those conditions, merges them into a per-provider map, and invokes Prepare(ctx, conditions) on providers referenced by rules prior to rule execution. Also updates go.mod to bump two dependencies.

Changes

Cohort / File(s) Summary
Provider preparation (bin)
cmd/analyze-bin.go
Collects provConditions from parser.LoadRules, merges into providerConditions, then for providers in needProviders calls Prepare(ctx, conditions) and logs non-blocking errors; minor formatting adjustments.
Provider preparation (hybrid)
cmd/analyze-hybrid.go
Propagates provConditions through result handling, accumulates per-provider conditions, runs Prepare(ctx, conditions) for needed providers before execution, and includes short sync/wait; minor formatting tweaks.
Parser API & callers
parser/..., cmd/* (call sites)
parser.LoadRules signature changed to add provConditions map[string][]provider.ConditionsByCap; callers updated to unpack and merge the new return value.
Dependencies
go.mod
Bumps github.com/konveyor/analyzer-lsp and the Java external provider module to v0.9.0-alpha.1.0.20251122145207-25a951d7e1d9 (require lines updated).

Sequence Diagram(s)

sequenceDiagram
    participant Main
    participant Parser as LoadRules
    participant Acc as ProviderConditions
    participant Provider as Provider.Prepare
    participant Engine as RuleEngine

    Main->>Parser: LoadRules(ruleFiles...)
    Parser-->>Main: ruleSets, needProviders, provConditions, err
    Main->>Acc: merge provConditions into providerConditions
    Note over Main,Provider: Post-load provider preparation (non-blocking errors)
    loop for each provider ∈ providerConditions ∩ needProviders
        Main->>Provider: Prepare(ctx, aggregatedConditions)
        alt success
            Provider-->>Main: ok
        else failure
            Provider-->>Main: error (logged)
        end
    end
    Main->>Engine: Execute rules with prepared providers
    Engine-->>Main: Results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Check correct aggregation/merge semantics for provConditions (concurrency/synchronization).
  • Verify all parser.LoadRules call sites updated to handle the extra return value.
  • Confirm Prepare called only for providers present in needProviders and that errors are logged without aborting.
  • Validate go.mod version updates and any transitive effects.

Suggested reviewers

  • jmle
  • aufi

Poem

🐇 I hopped through rules both near and far,
Gathered conditions — each little star,
I prepped the providers, tuned and spry,
Then watched the engine blink and fly,
A bump, a merge, and off I dart 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references the main change (calling Prepare() for providers) but includes an emoji which adds noise rather than clarity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 709df66 and a8aa58b.

📒 Files selected for processing (1)
  • cmd/analyze-hybrid.go (6 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-08T15:06:52.056Z
Learnt from: abrugaro
Repo: konveyor/kantra PR: 524
File: cmd/dump-rules.go:0-0
Timestamp: 2025-08-08T15:06:52.056Z
Learning: In konveyor/kantra cmd/dump-rules.go (Go/Cobra), the dump-rules command should not use package-level variables for flags (output, overwrite). Flags must be defined as local variables inside NewDumpRulesCommand to avoid shared mutable state across commands/tests.

Applied to files:

  • cmd/analyze-hybrid.go
📚 Learning: 2025-06-26T14:08:58.555Z
Learnt from: aufi
Repo: konveyor/kantra PR: 500
File: cmd/static-report.go:88-94
Timestamp: 2025-06-26T14:08:58.555Z
Learning: In the konveyor/kantra codebase, there's a known pattern where Go maps are iterated by value-only (for _, item := range map), causing modifications to struct fields like `Extras = nil` to not persist. This appears in multiple places including static-report functionality and is acknowledged as a systemic issue to be addressed later rather than fixed piecemeal.

Applied to files:

  • cmd/analyze-hybrid.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build & test from commit
🔇 Additional comments (5)
cmd/analyze-hybrid.go (5)

744-748: Data race fix implemented correctly.

The addition of the provConditions field to ruleLoadResult resolves the data race flagged in previous reviews. Each rule-loading goroutine now returns its provider conditions via the channel, and the main goroutine merges them safely after all workers complete.


791-796: Provider conditions merge completes the data race fix.

This merge logic correctly aggregates provider conditions from all rule-loading goroutines on the main thread. All map writes are now serialized, eliminating the concurrent access issue from earlier versions.


857-859: Proper progress reporter cleanup pattern.

The progress cancellation and synchronization correctly ensures the progress reporter goroutine exits cleanly before continuing, preventing goroutine leaks.


761-761: LoadRules signature verified as correct.

The code correctly expects a 4-value return from LoadRules. Analyzer-lsp PR #975 was merged on November 21, 2025, and the analyzer-lsp version pinned in go.mod (v0.9.0-alpha.1.0.20251122145207-25a951d7e1d9) includes this change. The final LoadRules signature in the merged PR is: func (r *RuleParser) LoadRules(filepath string) ([]engine.RuleSet, map[string]provider.InternalProviderClient, map[string][]provider.ConditionsByCap, error), which matches the expected return values at line 761 and line 277 of analyze-bin.go.


817-823: Verify that Prepare() blocks until providers are fully initialized.

The code calls Prepare() on each provider and logs errors but continues. Based on past review comments, a hardcoded sleep was removed. Please confirm that the Prepare() method now blocks until the provider is ready, or if additional synchronization (health checks, wait groups) is needed before proceeding to rule execution.

Run the following script to examine the Prepare() method contract in the analyzer-lsp dependency:


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
go.mod (1)

138-148: Personal fork replace directives likely need an explicit plan

The replace entries point github.com/konveyor/analyzer-lsp (and the Java external provider module) to github.com/pranavgaikwad/analyzer-lsp.... That’s fine for local development, but if this is merged to main it permanently couples Kantra to a personal fork/version.

If this is only to test the new Prepare/conditions plumbing, consider either:

  • Switching back to an upstream tag/commit before merging, or
  • Documenting that Kantra intentionally depends on this fork and why.

Please confirm the intended long‑term source for these modules.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 85ab637 and 25b3313.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • cmd/analyze-bin.go (3 hunks)
  • cmd/analyze-hybrid.go (5 hunks)
  • go.mod (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build & test from commit
🔇 Additional comments (7)
cmd/analyze-hybrid.go (4)

269-283: Network provider BinaryPath comment-only change is fine

BinaryPath: "" with the clarified comment still correctly indicates network mode; no behavioral change here.


395-407: Builtin provider config change is reasonable

Setting Location: a.input and AnalysisMode: provider.AnalysisMode(a.mode) explicitly for the builtin provider in hybrid mode aligns it with the containerless setup and looks correct.


815-822: Provider preparation loop is correct once aggregation is made race‑free

Preparing each needProviders[name] with its aggregated conditions is the right place and scope for the new Prepare phase. Once providerConditions is populated without races, this block looks good; error logging without aborting matches the rest of the flow.


856-859: Progress cancellation comment/spacing change is benign

The explicit progressCancel() then <-progressDone pattern is unchanged behaviorally; only the comment/spacing were adjusted. No issues here.

cmd/analyze-bin.go (3)

265-291: Sequential aggregation of provider conditions looks correct

In the containerless flow, providerConditions := map[string][]provider.ConditionsByCap{} (Line 269) is built synchronously inside the for _, f := range a.rules loop. The aggregation loop over provConditions (Lines 285-290) correctly:

  • Initializes an empty slice per provider on first sighting.
  • Appends all ConditionsByCap entries across rule files.

Since rule loading here is not parallelized, there’s no concurrency concern for this map.


277-299: Provider Prepare phase is wired in as intended

Unpacking provConditions from parser.LoadRules (Line 277) and later iterating providerConditions to call provider.Prepare(ctx, conditions) for each provider in needProviders (Lines 293-299) correctly ensures that:

  • Every provider actually used by the loaded rules is prepared.
  • Preparation happens after all rules are loaded and conditions aggregated.
  • Failures in Prepare are logged but don’t abort analysis, which matches the existing “best-effort” philosophy elsewhere.

If you ever want provider‑prep failures to be fatal, this would be the place to switch from log‑and‑continue to returning an error.


331-334: Progress cancellation comment-only tweak is fine

The explicit progressCancel() followed by <-progressDone matches the hybrid flow and keeps the progress reporter goroutine cleaned up; the change here is purely comment/spacing.

@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

❌ Patch coverage is 5.40541% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.24%. Comparing base (85ab637) to head (a8aa58b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/analyze-hybrid.go 8.00% 23 Missing ⚠️
cmd/analyze-bin.go 0.00% 12 Missing ⚠️

❌ Your patch status has failed because the patch coverage (5.40%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #635      +/-   ##
==========================================
- Coverage   36.41%   36.24%   -0.18%     
==========================================
  Files          34       34              
  Lines        4257     4277      +20     
==========================================
  Hits         1550     1550              
- Misses       2535     2555      +20     
  Partials      172      172              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Pranav Gaikwad <[email protected]>
Signed-off-by: Pranav Gaikwad <[email protected]>
@snyk-io
Copy link

snyk-io bot commented Nov 24, 2025

Snyk checks have failed. 118 issues have been found so far.

Status Scanner Critical High Medium Low Total (118)
Open Source Security 5 44 44 10 103 issues
Licenses 0 0 15 0 15 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Signed-off-by: Pranav Gaikwad <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 012d119 and 709df66.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • cmd/analyze-hybrid.go (6 hunks)
  • go.mod (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-08T15:06:52.056Z
Learnt from: abrugaro
Repo: konveyor/kantra PR: 524
File: cmd/dump-rules.go:0-0
Timestamp: 2025-08-08T15:06:52.056Z
Learning: In konveyor/kantra cmd/dump-rules.go (Go/Cobra), the dump-rules command should not use package-level variables for flags (output, overwrite). Flags must be defined as local variables inside NewDumpRulesCommand to avoid shared mutable state across commands/tests.

Applied to files:

  • cmd/analyze-hybrid.go
📚 Learning: 2025-06-26T14:08:58.555Z
Learnt from: aufi
Repo: konveyor/kantra PR: 500
File: cmd/static-report.go:88-94
Timestamp: 2025-06-26T14:08:58.555Z
Learning: In the konveyor/kantra codebase, there's a known pattern where Go maps are iterated by value-only (for _, item := range map), causing modifications to struct fields like `Extras = nil` to not persist. This appears in multiple places including static-report functionality and is acknowledged as a systemic issue to be addressed later rather than fixed piecemeal.

Applied to files:

  • cmd/analyze-hybrid.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build & test from commit
🔇 Additional comments (2)
cmd/analyze-hybrid.go (1)

743-797: Data race fix successfully implemented.

The previous data race on providerConditions has been correctly resolved. The code now:

  1. Adds provConditions to the ruleLoadResult struct (line 747)
  2. Sends each goroutine's provConditions via the channel (lines 766-772)
  3. Merges all results on the main goroutine after completion (lines 791-796)

This ensures all map writes happen on a single goroutine, eliminating the race condition.

go.mod (1)

138-139: I need to gather more information about PR #975 and verify the modules are actually available in the Go registry.

Let me verify module availability and check PR #975 details directly:

Let me get more details on PR #975 and verify the module files/commit history:Based on my verification:

The dependency versions are correctly aligned with the required PR.

PR #975 was merged on 2025-11-21T20:21:39Z, and commit 25a951d7e1d9 exists in the analyzer-lsp repository with a timestamp of 2025-11-22T14:52:07Z. The pseudo-version encoding in go.mod (v0.9.0-alpha.1.0.20251122145207-25a951d7e1d9) correctly reflects this commit's timestamp and short SHA, confirming the dependency references the post-merge state of analyzer-lsp.

Both dependencies are alpha pseudo-versions pointing to the same commit, which is appropriate for tracking development commits before official tagged releases.

Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right to me

@dymurray dymurray closed this Nov 24, 2025
@dymurray dymurray reopened this Nov 24, 2025
@dymurray dymurray merged commit 668f58e into konveyor:main Nov 24, 2025
9 of 13 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.

3 participants