feat(route): expose affinity context after upstream attempts - #652
Conversation
📝 WalkthroughWalkthrough
ChangesRoute affinity metadata
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/app/app_test.go`:
- Around line 36-52: Add table-driven cases to
TestRouteSelectorHooksExposeSuccessfulRouteAffinityContext for a missing
workflow, missing resolution, and AliasApplied == false. For each case, invoke
routeSelectorHooks.OnRequestStart and OnRequestEnd with the existing request
context, then verify outcome.Source is empty while outcome.SessionID remains
"session-a"; retain the current alias-applied case and its expected "smart"
source.
🪄 Autofix
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e13340b4-9214-4426-bf27-3c4bcc2bdc55
📒 Files selected for processing (3)
ext/route.gointernal/app/app.gointernal/app/app_test.go
| func TestRouteSelectorHooksExposeSuccessfulRouteAffinityContext(t *testing.T) { | ||
| selector := &routeObservationSelector{} | ||
| hooks := routeSelectorHooks(selector) | ||
| ctx := core.WithSessionID(context.Background(), "session-a") | ||
| ctx = core.WithWorkflow(ctx, &core.Workflow{Resolution: &core.RequestModelResolution{ | ||
| Requested: core.NewRequestedModelSelector("smart", ""), | ||
| ResolvedSelector: core.ModelSelector{Provider: "openai", Model: "gpt"}, | ||
| AliasApplied: true, | ||
| }}) | ||
| ctx = hooks.OnRequestStart(ctx, llmclient.RequestInfo{Provider: "openai", Model: "gpt"}) | ||
| hooks.OnRequestEnd(ctx, llmclient.ResponseInfo{Provider: "openai", Model: "gpt", StatusCode: http.StatusOK}) | ||
|
|
||
| if selector.outcome.Source != "smart" || selector.outcome.SessionID != "session-a" { | ||
| t.Fatalf("route affinity context = %q/%q, want smart/session-a", | ||
| selector.outcome.Source, selector.outcome.SessionID) | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Add cases for workflows without an applied alias.
This test covers only the alias-applied path. Add table-driven cases for a missing workflow, a missing resolution, and AliasApplied == false. Verify that Source is empty and SessionID remains available.
As per coding guidelines, “Tests should cover request translation, response normalization, error handling, default configuration, and provider-specific parameter mapping.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/app/app_test.go` around lines 36 - 52, Add table-driven cases to
TestRouteSelectorHooksExposeSuccessfulRouteAffinityContext for a missing
workflow, missing resolution, and AliasApplied == false. For each case, invoke
routeSelectorHooks.OnRequestStart and OnRequestEnd with the existing request
context, then verify outcome.Source is empty while outcome.SessionID remains
"session-a"; retain the current alias-applied case and its expected "smart"
source.
Source: Coding guidelines
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Confidence Score: 5/5
What T-Rex did
Reviews (1): Last reviewed commit: "feat(route): expose affinity context on ..." | Re-trigger Greptile |
Adds virtual-model source and session metadata to route outcomes so extensions can update prompt-cache affinity after the attempt that actually succeeds, including failover attempts.\n\nThis is the small core companion required by GoModel Pro PR #10.\n\nTests:
go test ./ext ./internal/app; full pre-commit suite passed.Summary by CodeRabbit
New Features
Improvements