Skip to content

feat: let embedders pass KeySelector and KeyPoolFilter through the HTTP server - #8577

Open
jeremym-tanium wants to merge 2 commits into
maximhq:devfrom
jeremym-tanium:feat/http-server-key-selection
Open

jeremym-tanium wants to merge 2 commits into
maximhq:devfrom
jeremym-tanium:feat/http-server-key-selection

Conversation

@jeremym-tanium

Copy link
Copy Markdown
Contributor

Summary

Core accepts KeySelector and KeyPoolFilter on schemas.BifrostConfig, but BifrostHTTPServer.Bootstrap builds that config without them, so a program embedding the HTTP server cannot supply key-selection policy to core. This passes both hooks through.

Changes

  • transports/bifrost-http/server/server.go: add KeySelector and KeyPoolFilter fields to BifrostHTTPServer and pass both to bifrost.Init in Bootstrap. Nil keeps core's defaults.
  • transports/changelog.md: entry under Features.

ReloadConfig is unchanged, since core keeps the hooks set at Init across reloads.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

make setup-workspace
cd transports
go build ./bifrost-http/server/
go test ./bifrost-http/server/

The package's tests pass apart from TestAgentGatewayRoutesRegisteredAfterStartupInitialization, which fails the same way on dev at 6d3fbac without this change. There is no new test: the change passes two values through Bootstrap, which needs a full config to exercise.

Screenshots/Recordings

N/A

Breaking changes

  • Yes
  • No

Related issues

Closes #8576

Security considerations

None. The hooks are set by the embedding program in code, not through config or the API.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between add2d48 and 40d36ff.

Files selected for processing: 1
  • transports/bifrost-http/server/server.go
Files skipped from review as they are similar to previous changes: 1
  • transports/bifrost-http/server/server.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features
    • Applications embedding the HTTP server can configure custom key-selection and key-pool filtering policies before startup. These policies are applied when the server initializes, giving integrations control over how keys are selected and filtered. If either policy is not configured, the existing default behavior applies. This configuration is available to applications that embed the server.

BifrostHTTPServer now exposes KeySelector and KeyPoolFilter. Bootstrap forwards both values to the Bifrost client configuration. If either value is nil, core defaults apply. The changelog documents this behavior.

Changes: HTTP server key policy

Layer / File(s) Summary
Expose and pass key-selection hooks
transports/bifrost-http/server/server.go, transports/changelog.md
BifrostHTTPServer adds KeySelector and KeyPoolFilter fields. Bootstrap forwards them to the Bifrost client configuration. The changelog documents the forwarding and default behavior.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Possibly related issues

  • Deterministic priority-based API key selection: this change adds hooks for key selection and filtering, but does not implement the requested priority policy.
Merge Risk: Minimal · up to 40d36

Embedders can configure the key hooks before startup, and configuration reloads retain them. No merge-blocking issue was found.

Security architecture risk: Low · up to 0a28a

The hooks are supplied by trusted embedding code before startup, not by HTTP callers, and unset hooks preserve existing behavior. The main limitation is inherited: pool filtering is best-effort and does not cover every selection path, so it should not be treated as a complete authorization boundary.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The callbacks are stored on the initialized core client, so their effects extend to credential selection for requests sharing that client, rather than being confined to Bootstrap. Their actual tenant and environment scope depends on the embedding application and its configured provider pools.

Trust Boundaries and Controls

  • observed — Hook authority comes from trusted embedding code through pre-startup function fields, not HTTP request data. Existing account-key eligibility checks remain upstream of normal selection; the separate direct-key mechanism still requires its server-side enablement setting.

Resilience and Maintainability Implications

  • observed — Filter failure prioritizes continued selection over strict veto enforcement: both initial and renewed rotating-pool filtering log callback errors and continue with eligible unfiltered keys. This is inherited core behavior, not a new fallback introduced by the transport change.

Hardening Proposals

  • proposed — Clarify that pool filtering is currently best-effort and path-dependent. If embedders need an authorization boundary, define that guarantee separately, including fail-closed errors and consistent enforcement across fixed, rotating and realtime/WebSocket selection paths.
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: allowing HTTP server embedders to pass KeySelector and KeyPoolFilter to core.
Description check Passed The description covers the purpose, implementation, affected area, testing steps and result, breaking-change status, related issue, security considerations, and checklist. It also explains why no new …
Linked Issues check Passed Issue #8576 requires BifrostHTTPServer fields for KeySelector and KeyPoolFilter, set before Bootstrap, and passed to bifrost.Init. The reviewed changes add both exported fields and pass both…
Out of Scope Changes check Passed The reviewed changes only add the requested HTTP server fields, wire them through Bootstrap, and document the behavior in the changelog. These changes support issue #8576. No unrelated change is sho…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Description check

Explanation

The description covers the purpose, implementation, affected area, testing steps and result, breaking-change status, related issue, security considerations, and checklist. It also explains why no new test was added and why ReloadConfig is unchanged.

Full details: Linked Issues check

Explanation

Issue #8576 requires BifrostHTTPServer fields for KeySelector and KeyPoolFilter, set before Bootstrap, and passed to bifrost.Init. The reviewed changes add both exported fields and pass both values during Bootstrap. The changelog states that unset values use core defaults. SessionAffinity is optional context in the issue and is not required.

Full details: Out of Scope Changes check

Explanation

The reviewed changes only add the requested HTTP server fields, wire them through Bootstrap, and document the behavior in the changelog. These changes support issue #8576. No unrelated change is shown.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@coderabbitai
coderabbitai Bot requested a review from akshaydeo October 15, 2026 15:30
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 15, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 20, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 23, 2026
…TP server

Core accepts KeySelector and KeyPoolFilter on BifrostConfig, but the HTTP
transport builds that config inside Bootstrap without them, so a program
embedding the HTTP server cannot supply key-selection policy. Add both as
fields on BifrostHTTPServer and pass them to bifrost.Init. Nil keeps core's
defaults.

Affected packages: transports
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[High impact] Adds embedder hooks into core key-selection logic.

Add the required regression tests before merging.

Findings

  1. P2 Hook wiring lacks tests ▶

Reviews (2) · Last reviewed commit: "chore: trailing one-line comments for th..." · Reviewed by Greptile

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 27, 2026
Per AGENTS.md, struct field comments stay short and trailing; the
set-before-Bootstrap requirement moves to Bootstrap's doc comment.

Affected packages: transports
Comment on lines +3428 to +3429
KeySelector: s.KeySelector,
KeyPoolFilter: s.KeyPoolFilter,

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.

P2 Hook wiring lacks tests

Bootstrap now passes KeySelector and KeyPoolFilter to core, but the PR adds no tests for either hook. The repository requires every behavior change to include regression tests. Add coverage showing that both supplied hooks reach core and that nil preserves the defaults. This repository requirement must be satisfied before merging.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

This branch has not been deployed

No deployments
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.

[Feature]: Let embedders pass KeySelector and KeyPoolFilter through the HTTP server

1 participant