Add Rails engine for remote eval server#114
Merged
David Elner (delner) merged 6 commits intomainfrom Mar 19, 2026
Merged
Conversation
David Elner (delner)
requested changes
Mar 12, 2026
Collaborator
David Elner (delner)
left a comment
There was a problem hiding this comment.
Overall I think this is off to a great start! I left some comments of some changes that are probably worth making, the most important of which would be sorting out names/namespaces.
I also would request that we add:
- A readme update: probably to the existing Dev Server section, perhaps as its own subsection. We can highlight Running as a Rack app vs Running as a Rails Engine.
- A Rails generator that scans the
evaluators/folder and generates thebraintrust_serverconfig for the Engine: presumably it would link "slug --> Evaluator class" for each found where the slug is a formatted class name by default. The sum UX would then be (1) define your Evaluators inevaluators/then (2) run the generator.
453a771 to
9120389
Compare
David Elner (delner)
previously requested changes
Mar 17, 2026
Collaborator
David Elner (delner)
left a comment
There was a problem hiding this comment.
Looking really good! I particularly like the service object helpers. Most of my code feedback is minor. The only change I think we should make before merging this is adding something to the README. Otherwise I'm happy with this.
ec09057 to
dc91e2e
Compare
Exposes the same eval dev server endpoints (health, list, eval) as a
mountable Rails engine so Rails apps can embed the server without a
separate Rack process.
- Extract Services::ListService and Services::EvalService from Rack
handlers so business logic is shared between Rack and Rails adapters
- Add Braintrust::Server::Rails::Engine (ActionController::API,
ActionController::Live for SSE streaming, isolate_namespace)
- Reuse existing auth strategies and CORS middleware unchanged
- Add rails-server appraisal (actionpack ~> 8.0 + rack-test)
- Add service unit tests and Rails engine/controller integration tests
Usage:
# config/initializers/braintrust_server.rb
Braintrust::Server::Rails::Engine.configure do |config|
config.evaluators = { "my-eval" => MyEval.new }
config.auth = :clerk_token
end
# config/routes.rb
mount Braintrust::Server::Rails::Engine, at: "/braintrust"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7b3cd28 to
d7a8424
Compare
David Elner (delner)
approved these changes
Mar 19, 2026
Collaborator
David Elner (delner)
left a comment
There was a problem hiding this comment.
Very happy with this. Thank you Stephen Belanger (@Qard) for your diligence (and patience!) getting this put together :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Services::ListServiceandServices::EvalServicefrom the existing Rack handlers so business logic is shared between the Rack and Rails adapters with no duplicationBraintrust::Server::Rails::Engine— a mountableRails::EngineusingActionController::APIandActionController::Livefor SSE streamingClerkToken,NoAuth) and CORS middleware unchangedrails-serverappraisal (actionpack ~> 8.0,rack-test) and full test coverage for services and engine controllersUsage
Test plan
bundle exec appraisal server rake test— existing Rack server tests pass (0 failures)bundle exec appraisal rails-server rake test— new Rails engine tests pass (0 failures)bundle exec standardrb— linting clean🤖 Generated with Claude Code