feat(ai): add Google Gemini provider + improved error handling#166
feat(ai): add Google Gemini provider + improved error handling#166sivaangayarkanni wants to merge 2 commits into
Conversation
Add complete Google Gemini API integration as a new LLM provider: - Implement GeminiProvider with HTTP-based API client - Add comprehensive test suite with 7 test cases - Update provider factory to support gemini provider - Support configurable model, temperature, and max tokens - Default to gemini-1.5-flash model feat(bpf): add enhanced error handling with contextual hints Add LoadError type and classification utilities: - WrapLoadError() for enriching errors with context - classifyLoadError() with 11+ error pattern mappings - Helper functions: IsPermissionError, IsBTFError, IsVerifierError - Actionable user-facing fix hints for common BPF load failures - Complete test coverage with 20+ test cases feat(ai): enhance correlation analysis with new patterns Add 3 new correlation patterns to fallback analyzer: - Memory + cgroup memory detection - Scheduler + syscall correlation - TCP + memory buffer exhaustion detection Signed-off-by: Sivaangayarkanni <siva.21.baba@gmail.com>
1abef82 to
37702d6
Compare
btwshivam
left a comment
There was a problem hiding this comment.
the gemini provider is clean raw net/http, but ci is red and the PR carries unrelated changes: it rewrites the front-page readme (drops the comparison table and the k8s positioning, that GTM content is live on main, pull it out), and adds an unrelated internal/bpf/errors.go package. fix the ci failures and split the scope.
| } | ||
|
|
||
| // Scheduler + syscall → CPU contention causing syscall queueing. | ||
| if signals["sched"] && signals["syscall"] { |
There was a problem hiding this comment.
these new correlation pairs are why TestDetectSimpleCorrelations/all_four_pairs fails (got 5, want 4), that's the red Test job. new correlation rules need the test updated in the same change, and this is separate from a gemini provider, split it out.
|
|
||
| type geminiRequest struct { | ||
| Contents []geminiContent `json:"contents"` | ||
| GenerationConfig geminiGenerationConfig `json:"generationConfig"` |
There was a problem hiding this comment.
not gofmt-clean (double space before the struct tag), that's the red Lint job. run gofmt.
| } | ||
|
|
||
| // Build the URL with API key. | ||
| url := fmt.Sprintf("%s/models/%s:generateContent?key=%s", |
There was a problem hiding this comment.
the api key goes in the url query string, so it lands in any proxy or client request log. gemini accepts x-goog-api-key, send it as a header so the key stays out of the url.
| }, nil | ||
| } | ||
|
|
||
| // ─── Gemini API Types ─────────────────────────────────────────────────────── |
There was a problem hiding this comment.
box-drawing section header and an em-dash in the comments, drop both per the comment style (plain lowercase, no decoration, no em-dash).
| // Copyright 2026 Optiqor contributors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package bpf |
There was a problem hiding this comment.
a whole new bpf load-error package is unrelated to a gemini provider. pull it into its own PR.
What
Added Google Gemini as a new AI provider, introduced 3 new AI correlation patterns, and improved error handling with a structured
LoadErrortype and helper functions.Why
Fixes #165
How
gemini.goandgemini_test.gowith pure HTTP integration (no SDK).fallback.gowith 3 new correlation patterns.errors.gowithLoadErrortype + helper functions (IsPermissionError,IsBTFError,IsVerifierError).Testing
go build ./...passesgo test ./...passesgo vet ./...passesgolangci-lint run ./...passessudo ./bin/kerno doctor --aisudo ./bin/bpf-verify --read 5sconfirms 6/6 programs still load./scripts/verify.shpasses (or specific phase:./scripts/verify.sh quality)Checklist
feat(ai): add Google Gemini provider + improved error handling)git commit -s)scripts/verify.sh