mongodb/mongo-ruby-driver
55.1
Adequate · 6 November 2026
61.1k
lines of production code
Ruby
primary language
4
measurements over time
What this system is
Features
Add ActiveSupport integration support
The driver now includes a dedicated \lib/mongo/active\_support.rb\ file that requires \bson/active\_support\, enabling seamless integration with Ruby on Rails and other frameworks that rely on ActiveSupport for time and number handling.
lib/mongo · high confidence
Add KMS credential and master key document classes for AWS, KMIP, and Local providers
New classes have been introduced to handle provider-specific configuration for AWS, KMIP, and Local Key Management Service (KMS) providers. The \Mongo::Crypt::KMS::AWS::Credentials\ class now validates and stores AWS access keys, secret keys, and optional session tokens, converting them into the BSON format required by libmongocrypt. Similarly, \Mongo::Crypt::KMS::KMIP::Credentials\ manages KMIP endpoint configurations, while \Mongo::Crypt::KMS::Local::Credentials\ handles local master key storage. Additionally, \Mongo::Crypt::KMS::Local::MasterKeyDocument\ provides a uniform interface for defining the local provider context. These components enable the library to correctly format and transmit credentials to the respective KMS backends.
lib/mongo/crypt/kms/aws, lib/mongo/crypt/kms/kmip, lib/mongo/crypt/kms/local · high confidence
Add MONGODB-AWS authentication support
The driver now supports the MONGODB-AWS authentication mechanism. This change introduces a new authentication conversation class that handles the SASL exchange with the server, including nonce validation and final message construction. It also adds a credentials retriever that automatically discovers AWS credentials from multiple sources (client URI options, environment variables, EC2 instance metadata, ECS task metadata, and Web Identity) and a thread-safe cache to store these credentials, reducing redundant network calls to metadata endpoints.
lib/mongo/auth/aws · high confidence
Added GSSAPI Kerberos authentication conversation logic
The driver now includes the core logic for handling Kerberos (GSSAPI) authentication conversations with MongoDB servers. This change introduces the \Mongo::Auth::Gssapi::Conversation\ class, which manages the SASL handshake steps (initial challenge, evaluation, and finalization) by interacting with the \mongo\_kerberos\ native library. Users relying on GSSAPI authentication will now have the underlying protocol implementation available to establish secure connections.
lib/mongo/auth/gssapi · high confidence
Added connection pool fairness and driver benchmark profiles
Added two new profiling scripts to the \profile/\ directory: \connection\_pool\_fairness.rb\ and \driver\_bench.rb\. The fairness harness allows users to verify that the connection pool serves queries in a FIFO manner under heavy over-subscription, helping to detect thread starvation issues. The driver bench script provides a suite for running performance benchmarks.
profile · high confidence
Added mongo\_console executable for interactive MongoDB sessions
A new \bin/mongo\_console\ script has been added to provide an interactive Ruby console for MongoDB. The executable loads the \mongo\ library and includes the \Mongo\ namespace into the global object scope, making classes and constants available without qualification. It attempts to load the \pry\ gem first for an enhanced REPL experience, falling back to the standard \irb\ if \pry\ is unavailable, and aborts with an error if neither is present.
bin · high confidence
Introduce Client-Side Field-Level Encryption (CSFLE) implementation
Adds the core Ruby implementation for Client-Side Field-Level Encryption, enabling automatic and explicit document encryption and decryption. This change introduces the \Mongo::Crypt\ module, which wraps the \libmongocrypt\ C library via FFI bindings to manage the encryption state machine. It includes new classes for handling encryption contexts (auto and explicit), an \AutoEncrypter\ to integrate with \Mongo::Client\ for transparent encryption, and an \ExplicitEncrypter\ for manual field-level operations. The implementation supports key management via KMS providers, schema maps, and secure handling of binary data and memory pointers.
lib/mongo/crypt · high confidence
Introduce DriverBench benchmarking suite
Adds a new \profile/driver\_bench\ suite for measuring driver performance, including a base benchmarking framework, Rake tasks to download data and run benchmarks, and specific micro-benchmarks for BSON encoding/decoding, single and multi-document operations, parallel GridFS and LDJSON I/O, and client-side encryption decryption.
_profile/driver\bench · high confidence
Introduce GridFS read and write stream classes
Added new \Mongo::Grid::FSBucket::Stream::Read\ and \Mongo::Grid::FSBucket::Stream::Write\ classes to handle file I/O via streaming. The read stream supports iterating over or reading entire files, validates chunk sequence integrity, and caches file metadata. The write stream supports uploading data in chunks, allows aborting uploads to delete inserted chunks, and handles write concerns and timeouts.
lib/mongo/grid/stream · high confidence
Introduce OP\_MSG wire protocol support with compression and serialization infrastructure
The driver now implements the OP\_MSG wire protocol (replacing the legacy OP\_QUERY) via the new \Protocol::Msg\ class, enabling support for multiple payload sections and unacknowledged writes. This change includes a new \Protocol::Compressed\ class that wraps messages using Snappy, Zlib, or Zstandard compression algorithms, and a \Protocol::Registry\ to map op codes to message classes. Supporting infrastructure includes a \BitVector\ serializer for protocol flags, a \CachingHash\ to optimize BSON serialization performance, and updated \Message\ base class methods for compression and encryption hooks.
lib/mongo/protocol · high confidence
Introduce new event pub/sub system in lib/mongo/event
The \lib/mongo/event\ directory now contains the core components of a new event publishing and subscribing mechanism. This includes a base event class (\base.rb\) with an experimental summary method, a listener registry (\listeners.rb\) for managing event subscriptions, a publisher module (\publisher.rb\) for dispatching events to registered listeners, and a subscriber module (\subscriber.rb\) providing convenience methods for registering listeners. This change establishes the foundational infrastructure for the driver's new global event system.
lib/mongo/event · high confidence
Introduce server-side session tracking and pooling
Added \ServerSession\ and \SessionPool\ classes to manage MongoDB server-side sessions, enabling features like retryable writes and transactions. The \ServerSession\ class tracks session IDs, transaction numbers, and last-use timestamps, while the \SessionPool\ manages the lifecycle of these sessions, including checking them out, checking them back in, and sending \endSessions\ commands to the server to clean up idle or expired sessions.
lib/mongo/session · high confidence
New IndexView API for managing collection indexes
The driver introduces a dedicated Index::View class to manage indexes, replacing previous patterns with explicit methods: create\_one and create\_many for adding indexes, and drop\_one and drop\_all for removing them. This view supports modern index options including partial filters, hidden indexes, collation, wildcard projections, and commit quorums, while also allowing users to attach comments to index operations for better tracking.
lib/mongo/index · high confidence
New authentication mechanisms and refactored auth architecture
The driver introduces support for MONGODB-AWS authentication, SCRAM-SHA-256, and Kerberos (GSSAPI), alongside a complete refactor of the authentication system to use a unified conversation pattern. Existing mechanisms like SCRAM-SHA-1, MONGODB-CR, LDAP, and X.509 have been restructured into dedicated classes that inherit from a new \Base\ authenticator, which standardizes how authentication conversations are executed. The update also includes a new credential caching system to improve performance and implements SASLprep for password handling to ensure compliance with modern security standards.
lib/mongo/auth · high confidence
New builder classes for aggregation and map/reduce commands
Added dedicated builder classes (Aggregation and MapReduce) in the view builder layer to construct command specifications for aggregation pipelines and map/reduce operations. These builders handle option mapping (e.g., collation, hint, let, bypassDocumentValidation), read/write concern propagation, and session handling, centralizing the logic for generating the MongoDB commands from view options.
lib/mongo/collection/view/builder · high confidence
New log subscribers for CMAP, SDAM, and command monitoring events
The driver now includes dedicated log subscriber classes for Connection Management (CMAP), Server Discovery and Monitoring (SDAM), and command events. These subscribers (CmapLogSubscriber, CommandLogSubscriber, SDAMLogSubscriber, and their specific variants like ServerOpeningLogSubscriber and TopologyChangedLogSubscriber) allow users to receive and log detailed monitoring data, including connection pool status, server topology changes, and command execution details. A unified subscriber (UnifiedSdamLogSubscriber) is also provided as an experimental feature to subscribe to all SDAM events via a single client subscription point.
lib/mongo/monitoring · high confidence
New monitoring event classes for CMAP, SDAM, and security redaction
The driver now exposes a richer set of monitoring events for connection pool management, server discovery and monitoring (SDAM), and command security. New CMAP (Connection Management) events—such as connection checked in/out, pool created/cleared/closed, and connection ready/created/closed—allow users to track connection lifecycle and pool state changes. SDAM heartbeat events (started, succeeded, failed) now include details like round-trip time, associated errors, and whether the heartbeat was awaited, providing deeper visibility into server health checks. Additionally, the ServerDescriptionChanged event now supports an 'awaited' flag to indicate if the change resulted from an awaited hello response. Security-sensitive command monitoring is enhanced via the Secure module, which redacts specific commands (e.g., authenticate, saslStart) and hello commands with speculative authentication, ensuring sensitive data is not exposed in monitoring logs.
lib/mongo/monitoring/event · high confidence
New options mapping utility and redacted options class
The driver introduces a new \Mongo::Options::Mapper\ module to standardize how option keys and values are transformed (e.g., converting keys to strings or symbols) and a new \Mongo::Options::Redacted\ class that wraps sensitive configuration options. When sensitive options like \password\ or \pwd\ are inspected or converted to strings, their values are automatically replaced with \\<REDACTED\>\ to prevent accidental exposure in logs or error messages, while the mapper provides reusable logic for normalizing option hashes across the driver.
lib/mongo/options · high confidence
New search index management API for MongoDB collections
Users can now manage Atlas Search indexes directly through a new \Mongo::SearchIndex::View\ class. This addition provides methods to create single or multiple indexes (\create\_one\, \create\_many\), update existing indexes (\update\_one\), drop indexes (\drop\_one\), and list available indexes (\each\). The view supports filtering by index ID or name and allows specifying the index type (e.g., 'search' or 'vectorSearch') during creation, enabling programmatic control over search index configurations without leaving the Ruby driver.
_lib/mongo/search\index · high confidence
New socket implementations and OCSP verification support
The driver now includes dedicated socket classes for TCP, Unix domain sockets, and SSL/TLS connections, replacing previous generic socket handling. This change introduces OCSP (Online Certificate Status Protocol) verification for TLS connections, allowing the driver to check server certificate revocation status via OCSP responders, including support for caching responses and following redirects. The SSL socket implementation now performs certificate and OCSP verification after connection establishment, enhancing security for encrypted connections.
lib/mongo/socket · high confidence
Support for Azure Managed Identity in KMS
Users can now authenticate to Azure Key Vault using Managed Identity without manually providing tenant, client, or secret credentials. The driver automatically retrieves temporary access tokens from the Azure metadata service (169.254.169.254) when no explicit credentials are configured, and these requests respect the configured Client-Side Operations Timeout (CSOT) settings.
lib/mongo/crypt/kms/azure · high confidence
Support for Azure, GCP, KMIP, and named KMS providers
The KMS module now supports additional key management providers (Azure, GCP, KMIP, and Local) alongside the existing AWS provider, allowing users to create data keys using these cloud and protocol-based services. Additionally, the system now supports named KMS providers using a type:name format (e.g., "aws:name1"), enabling users to configure and reference multiple instances of the same provider type.
lib/mongo/crypt/kms · high confidence
Removals
Removal of legacy pure-Ruby BSON and ByteBuffer utilities
The legacy pure-Ruby BSON serialization/deserialization implementation and its underlying ByteBuffer utility have been removed from the codebase. This eliminates the manual byte-packing logic and the specific BSON type handling (such as NUMBER, NUMBER\_INT, OID, DATE, and BOOLEAN) previously managed by these classes, indicating a shift toward alternative serialization mechanisms or C extensions for BSON processing.
lib/mongo/util · high confidence
Architecture
Major rewrite of server connection, monitoring, and pool architecture
The server connectivity layer has been completely refactored to align with the Server Discovery and Monitoring (SDAM) and Connection Pooling (CMAP) specifications. This change introduces a new \Connection\ class that handles handshakes, authentication (including speculative auth), and compression negotiation, replacing the previous ad-hoc socket management. A dedicated \Monitor\ class now manages background heartbeat threads for server status updates, decoupled from the main connection pool. The \ConnectionPool\ has been rewritten to support configurable sizing, backpressure via \max\_connecting\ limits, and proper lifecycle management with background populator threads. Additionally, \AppMetadata\ is now sent during handshakes to identify the driver and wrapping libraries, and \Description\ objects are immutable and owned by the monitor to ensure consistent server state across the topology.
lib/mongo/server · high confidence
Refactored URI parsing with dedicated SRV protocol and options mapper classes
The URI parsing logic has been restructured into new, dedicated classes: \Mongo::URI::OptionsMapper\ handles the mapping and transformation of URI options to Ruby client options, and \Mongo::URI::SRVProtocol\ manages the specific parsing and DNS resolution for \mongodb+srv\ connection strings. This change isolates the SRV protocol implementation and centralizes option conversion logic, improving maintainability and adherence to the Initial DNS Seedlist Discovery specification.
lib/mongo/uri · high confidence
Behavioural changes
8 commits (1 fix) modifying lib/mongo/tracing
A change to existing behaviour in lib/mongo/tracing — 8 commits (1 fix), 4 files: “RUBY-3898 Remove dead cursor-pinning block, fix cursor id for OP\_MSG (\#3073)”; “RUBY-3612 OpenTelemetry (\#2957)”; “RUBY-3952 Cut allocations on the command tracing path (\#3127)”; and 5 more (refs \#3073, \#2957, \#3127, \#3038, \#3124, …).
lib/mongo/tracing · medium confidence · unverified
Change streams now automatically resume on transient errors
The ChangeStream implementation now includes built-in retry logic for transient failures. If a read operation fails with an error marked as resumable, the stream will automatically attempt to resume once, allowing applications to maintain continuity without requiring manual error handling for these specific cases.
_lib/mongo/collection/view/change\stream · high confidence
Comprehensive restructuring of the error handling module
The \lib/mongo/error\ directory has been completely reorganized to provide a unified and granular exception hierarchy. All error classes now inherit from \Mongo::Error\, replacing previous inheritance from \RuntimeError\ or \Timeout::Error\ for better consistency and catchability. New specific exceptions have been introduced for distinct failure scenarios, including \AuthError\ and its subclasses (\CredentialCheckError\, \InvalidServerAuthResponse\) for authentication issues, \BadLoadBalancerTarget\ for load-balancing misconfigurations, \ConnectionCheckOutTimeout\ for pool exhaustion, and \ConnectionPerished\ for network errors. The \BulkWriteError\ class has been enhanced to expose server addresses and detailed result documents. Additionally, modules like \ChangeStreamResumable\ and \WriteRetryable\ are now explicitly included in relevant error classes to standardize retry and resume behavior across the driver.
lib/mongo/error · high confidence
Deprecated legacy GridFS API in favor of new FSBucket stream interface
The legacy GridFS API (e.g., \Grid::File\, \FSBucket\#find\_one\, \FSBucket\#insert\_one\) is now marked as deprecated and will be removed in driver version 3.0. Users should migrate to the new \FSBucket\ stream-based interface, which provides \open\_upload\_stream\, \open\_download\_stream\, and related methods for more efficient and idiomatic file handling. The new API supports custom file IDs, metadata, and better error handling for write operations.
lib/mongo/grid · high confidence
Deprecation of the legacy GridFS File API in favor of FSBucket streams
The legacy GridFS file handling API, specifically the \Mongo::Grid::File::Info\ class and its associated metadata handling, is now marked as deprecated. Users will see a deprecation warning indicating that this API will be removed in driver version 3.0 and should migrate to the 'stream' API available on an \FSBucket\ instance instead. This change affects how file metadata and document information are accessed, shifting users away from the older \Grid::File\ structure toward the newer bucket-based streaming interface.
lib/mongo/grid/file · high confidence
Evergreen CI infrastructure restructured and expanded
The \.evergreen\ directory has been reorganized into a modular structure with dedicated configuration files (e.g., \config.yml\, \axes.yml.erb\, \standard.yml.erb\) and shared shell functions, replacing the previous monolithic setup. This change introduces support for testing against Ruby 4.0 and MongoDB 9.0, adds specific build variants for Client-Side Operation Timeout (CSOT) and OpenTelemetry (OTel) specs, and expands AWS authentication testing to include EC2 instance profiles and ECS task provisioning. Additionally, the configuration now includes a scheduled 'ruby-dev' variant to catch incompatibilities with upcoming Ruby releases and updates the test matrix to cover recent MongoDB versions (8.2, 8.0, 7.0) and various topologies including load-balanced sharded clusters.
.evergreen · high confidence
Implement PLAIN SASL conversation for LDAP authentication
The LDAP authentication mechanism now uses a dedicated conversation class to manage the PLAIN SASL handshake. This change introduces a structured flow where the client initiates authentication by sending a specific login message containing the user credentials, replacing the previous ad-hoc message construction with a standardized conversation pattern.
lib/mongo/auth/ldap · high confidence
Introduce new connection address resolution and client-side operation timeout (CSOT) infrastructure
The driver now uses a dedicated address resolution layer (lib/mongo/address.rb and submodules for IPv4, IPv6, and Unix sockets) to handle host name resolution and socket creation, ensuring that DNS changes are noticed immediately. Additionally, a new client-side operation timeout (CSOT) mechanism is introduced via lib/mongo/csot\_timeout\_holder.rb, allowing operations to enforce deadlines and raise TimeoutError when exceeded, while a CachingCursor implementation optimizes repeated query performance by serving documents from memory.
mongo · high confidence
Introduction of dedicated cursor and socket reaper components
The library now includes dedicated \CursorReaper\ and \SocketReaper\ classes within the cluster management layer to handle resource cleanup. The \CursorReaper\ actively tracks active cursor IDs to ensure that cursors garbage collected without being exhausted are properly killed, preventing cursor leaks. The \SocketReaper\ periodically closes idle sockets across the cluster's connection pools to free up resources. These components replace previous ad-hoc cleanup logic with a more structured approach to managing server-side resources.
lib/mongo/cluster/reapers · high confidence
Isolate monitoring connection metadata and behavior
The server monitor now uses a dedicated connection class and a specialized app metadata object. The new AppMetadata class inherits from the standard app metadata but explicitly removes authentication mechanisms, ensuring that the background monitoring socket does not attempt SCRAM authentication. The new Monitor::Connection class manages these sockets, enforcing that they use the connect timeout as the socket timeout and supporting compression algorithms like zstd, snappy, and zlib. This separation ensures monitoring traffic is handled independently of user application connections.
lib/mongo/server/monitor · high confidence
Major driver architecture overhaul with new configuration and TLS hooks
The core library entry point has been completely rewritten to support a modernized architecture. Users now benefit from global TLS context hooks, allowing them to modify SSL/TLS settings (such as cipher suites) for every new connection via \Mongo.tls\_context\_hooks\. The driver introduces a centralized configuration system (\Mongo::Config\) with global options like \csfle\_convert\_to\_ruby\_types\ and \include\_server\_address\_in\_errors\, accessible directly on the \Mongo\ module. Additionally, the driver now includes built-in support for Client-Side Field Level Encryption (via \Mongo::ClientEncryption\), OCSP cache clearing, and a new caching cursor implementation, replacing the previous legacy loading structure.
lib · high confidence
New server feature detection and load balancer description classes
The driver now includes dedicated classes for managing server capabilities and load balancer topology. The new \Features\ class centralizes the mapping of MongoDB features (such as \merge\_out\_on\_secondary\, \get\_more\_comment\, \retryable\_write\_error\_label\, and \commit\_quorum\) to specific wire protocol versions, providing instance methods like \merge\_out\_on\_secondary\_enabled?\ to check support. It also enforces compatibility by raising errors if the server is too old or too new for the driver's supported wire version range (9–29) and warning if a deprecated wire version is in use. Additionally, a new \LoadBalancer\ class has been added to represent the assumed description of servers behind load balancers, storing the server address.
lib/mongo/server/description · high confidence
Refactored Collection::View and added Queryable Encryption support
The collection query interface has been restructured into modular components (Readable, Writable, Explainable, etc.) to improve maintainability and extend functionality. This change introduces native support for Queryable Encryption (QE2), including automatic creation and dropping of auxiliary encryption collections and indices, with wire version checks to ensure server compatibility. The View API now standardizes option handling, supporting collation, hint, and timeout configurations directly on the view, while deprecating legacy options like snapshot and maxScan.
lib/mongo/collection · high confidence
Refactored Collection::View into modular components
The Collection::View implementation has been restructured into distinct modules (Readable, Writable, Explainable, Iterable, Immutable) and specialized classes (Aggregation, ChangeStream, MapReduce) to improve code organization and maintainability. This refactoring introduces new capabilities such as ChangeStream support for real-time data notifications, explicit Aggregation pipeline handling with options like $merge and $out, and deprecation warnings for the legacy MapReduce operation. Users will see cleaner separation of concerns in how queries, aggregations, and write operations are constructed and executed, with improved handling of cursor lifecycles, caching, and retry logic across these new components.
lib/mongo/collection/view · high confidence
Refactored MongoDB operations to use the OpMsg protocol and a unified execution layer
The internal operation layer in lib/mongo/operation has been restructured to standardize on the MongoDB op\_msg wire protocol. All core operations (such as find, aggregate, insert, delete, and commands) now delegate to dedicated OpMsg subclasses that handle command construction and execution. This change introduces a new Operation::Context class to manage execution state, including transaction pinning, session handling, and Client-Side Operation Timeouts (CSOT). Additionally, result parsing has been consolidated into specific Result classes for each operation, and legacy wire protocols (OP\_KILL\_CURSORS, OP\_INSERT, etc.) have been removed.
lib/mongo/operation · high confidence
Refactored bulk write operations to support collation, array filters, and hint options
The bulk write implementation has been refactored to correctly handle the collation, array\_filters, and hint options for update and delete operations. This change introduces new internal modules (Combineable, Transformable, Validatable) and combiners (OrderedCombiner, UnorderedCombiner) to group and transform operations before sending them to the server. The BulkWrite::Result class now includes an acknowledged? method and properly aggregates server addresses, ensuring that users receive accurate feedback on write acknowledgment and operation counts across mixed clusters.
_lib/mongo/bulk\write · high confidence
Refactored cluster topology into a class hierarchy with load-balanced support
The cluster topology logic has been restructured from a monolithic implementation into a base class (\Topology::Base\) with specific subclasses for each state: \Single\, \ReplicaSetNoPrimary\, \ReplicaSetWithPrimary\, \Sharded\, \Unknown\, and the new \LoadBalanced\ topology. This change introduces a \LoadBalanced\ mode that enforces a single-server cluster and always reports readable/writable availability, while separating replica set states to distinguish between primary discovery phases. The refactoring also standardizes topology validation, server selection, and compatibility checks across all topology types, ensuring that unknown servers do not incorrectly affect topology compatibility and that logical session timeouts are calculated correctly based on data-bearing servers.
lib/mongo/cluster/topology · high confidence
Refactored connection pool internals with dedicated generation and populator managers
The connection pool implementation has been restructured to improve modularity and correctness. A new GenerationManager class now explicitly handles connection generation tracking and lifecycle management for pipe file descriptors, including logic to scope generations to specific services in load-balanced mode and safely close scheduled file descriptors. Additionally, the Populator class has been extracted into its own file to clearly define its role in maintaining the minimum pool size via a background thread, separating this responsibility from the main pool logic.
_lib/mongo/server/connection\pool · high confidence
Refactored retry logic with client backpressure and overload handling
The retry mechanism in the MongoDB driver has been refactored to introduce client-side backpressure and improved handling of server overload errors. A new backpressure module implements exponential backoff with jitter for retry delays, respecting a server-provided base backoff time when available. The retry workers (read and write) now distinguish between modern and legacy retry paths, with the write worker specifically adding logic to retry operations on overload errors (SystemOverloadedError) using the new backoff strategy. This change improves resilience during transient server load by preventing immediate retry storms.
lib/mongo/retryable · high confidence
Refactored server discovery and monitoring into dedicated topology and SDAM flow classes
The cluster's server discovery and monitoring logic has been restructured to improve clarity and spec compliance. A new \PeriodicExecutor\ class now manages the background threads that trigger monitoring tasks at regular intervals. The complex logic for handling Server Discovery and Monitoring (SDAM) events has been extracted into a dedicated \SdamFlow\ class, which centralizes the processing of server description changes, topology transitions (such as moving from Unknown to ReplicaSet or Sharded), and event publishing. Additionally, a \Topology\ module and its associated subclasses (e.g., \Single\, \LoadBalanced\, \ReplicaSetWithPrimary\) provide a structured way to define and manage cluster topology types, replacing previous ad-hoc state handling.
lib/mongo/cluster · high confidence
Refactored write concern implementation with new base class and validation
The write concern logic has been restructured into a new class hierarchy under \Mongo::WriteConcern\, introducing a \Base\ class that centralizes option handling and validation. This change enforces stricter rules, such as prohibiting the \:journal\ option in favor of \:j\, preventing invalid combinations like \:w =\> 0\ with \:j\ or \:fsync\, and rejecting negative \:w\ values. Two specific implementations, \Acknowledged\ and \Unacknowledged\, now inherit from this base, providing distinct behaviors for the \get\_last\_error\ command and the \acknowledged?\ check, ensuring consistent option transformation and error reporting for write operations.
_lib/mongo/write\concern · high confidence
Removed legacy MongoDB message classes
The internal MongoDB driver implementation has removed several low-level message classes (GetMoreMessage, InsertMessage, KillCursorsMessage, Message, MessageHeader, MsgMessage, QueryMessage, RemoveMessage, UpdateMessage) and the opcodes definition file. This refactoring eliminates the previous per-operation message object structure, simplifying the internal communication layer with the database.
lib/mongo/message · high confidence
Rename ReadPreference to ServerSelector and deprecate hedged reads
The internal server selection logic has been refactored to use the \ServerSelector\ module (with classes like \ServerSelector::Primary\, \Secondary\, \Nearest\, etc.) instead of the previous \ReadPreference\ naming, aligning with MongoDB driver specifications. Additionally, the \hedge\ option for enabling hedged reads is now deprecated with a warning, as hedged reads are deprecated in MongoDB Server 8.0 and will be removed in a future version.
_lib/mongo/server\selector · high confidence
Replaced legacy demo script with comprehensive CRUD and aggregation examples
The previous \examples/demo.rb\ script, which used an internal \XGen::Mongo::Driver\ interface, has been removed and replaced with a new set of standalone example scripts (\aggregate.rb\, \create.rb\, \delete.rb\, \index.rb\, \query.rb\, and \update.rb\). These new examples demonstrate standard MongoDB operations using the public API, including inserting documents, querying with various operators and logical conditions, updating and deleting records, creating indexes, and performing aggregation pipelines.
examples · high confidence
SCRAM-SHA-1 conversation implementation with cached salted password
The SCRAM-SHA-1 authentication flow now uses a dedicated conversation class that implements the key derivation (HI) and salted password calculation using OpenSSL's PBKDF2-HMAC-SHA1. To improve performance, the resulting salted password is cached via a credential cache, ensuring it is not recalculated for every authentication attempt within the same session.
lib/mongo/auth/scram · high confidence
SRV record monitoring and resolution behavior changes
The SRV monitor now enforces a 'log-and-continue' policy for invalid or mismatched SRV records, ensuring that DNS resolution errors do not crash the background monitoring thread. Additionally, the driver now supports limiting the number of mongos servers used in sharded cluster connections via the srv\_max\_hosts option, and allows valid SRV hostnames with fewer than three domain parts.
lib/mongo/srv · high confidence
X.509 authentication now supports speculative authentication
The X.509 authentication flow has been refactored to support speculative authentication attempts. The new \lib/mongo/auth/x509/conversation.rb\ implementation exposes a \speculative\_auth\_document\ method that returns the initial handshake document, allowing the client to attempt authentication before the server has fully established the connection state. This change aligns the X.509 mechanism with the broader conversation pattern used by other auth mechanisms, potentially improving connection establishment performance.
lib/mongo/auth/x509 · high confidence
Test coverage
1 commit adding/updating tests in spec/mongo/operation/map\_reduce; 31 commits adding/updating tests in spec/mongo/operation/insert; 7 commits adding/updating tests in spec/mongo/operation/create; 79 commits adding/updating tests in spec/mongo/operation; 8 commits adding/updating tests in spec/mongo/operation/aggregate; 9 commits adding/updating tests in spec/mongo/tracing; Add transaction spec test runner infrastructure; Added AWS Lambda test harness for Ruby MongoDB driver; Added AWS test utility support classes for EC2 and ECS provisioning; Added Atlas connectivity tests; Added CRUD spec test runner infrastructure; Added SDAM event verification helpers for tests; Added comprehensive test coverage for Collection::View modules; Added comprehensive test coverage for the Field Level Encryption (FLE) Ruby bindings; Added connectivity tests for Atlas Secure Frontend Processor (SFP); Added integration tests for FaaS environment detection; Added integration tests for authentication, AWS credentials, and bulk operations; Added integration tests for retryable write operations; Added shared integration tests for retryable write behaviors; Added shared test suites for app metadata, authentication, protocol, server selection, and sessions; Added spec runners for MongoDB driver specification tests; Added stress tests for connection pool, fork reconnection, and cleanup; Added test coverage for AWS authentication components; Added test coverage for GridFS chunk and file info components; Added test coverage for GridFS components; Added test coverage for GridFS read and write streams; Added test coverage for Mongo::Collection::View equality, cloning, and iteration; Added test coverage for MongoDB Ruby driver error classes; Added test coverage for MongoDB authentication mechanisms; Added test coverage for MongoDB server selector modes; Added test coverage for URI options mapping and SRV protocol validation; Added test coverage for address parsing and validation; Added test coverage for bulk write combinators and result handling; Added test coverage for cluster reapers and topology initialization; Added test coverage for cluster topology types; Added test coverage for server-side components; Added test coverage for session management and transaction retry logic; Added test coverage for socket connection and TLS configuration; Added test for clean exit with SRV URI; Added test infrastructure for change stream specifications; Added test suite documentation and Kerberos authentication tests; Added test suite for Mongo::Auth::User::View; Added test suite for core driver components; Added tests for Azure KMS credentials retrieval; Added tests for CMAP monitoring event summaries; Added tests for Client Side Operations Timeout with encryption; Added tests for FaaS environment detection and handshake metadata truncation; Added tests for KMIP MasterKeyDocument serialization; Added tests for KMS credential validation; Added tests for LDAP conversation SASL start behavior; Added tests for Mongo::Options::Redacted behavior; Added tests for Mongo::WriteConcern::Acknowledged and Unacknowledged; Added tests for MongoDB monitoring event classes; Added tests for MongoDB monitoring log subscribers; Added tests for SASL StringPrep validation; Added tests for SRV monitor, resolver, and result validation; Added tests for Server Monitor AppMetadata and Connection timeout behavior; Added tests for X.509 authentication conversation logic; Added tests for client backpressure and overload retry behavior; Added tests for server wire version range and feature checks; Added tests for the Mongo::Index::View API; Added tests for the MongoDB Client-Side Encryption FFI bindings; Added tests for the event publisher and subscriber components; Added unit tests for SCRAM and SCRAM-SHA-256 authentication conversations; Added unit tests for connection pool internals; Added unit tests for wire protocol message classes; Expanded integration tests for client-side encryption; Expanded spec test coverage for driver features; New test infrastructure for client lifecycle and authorization; Removal of legacy test suite files; Unified test runner implementation for MongoDB specifications; Updated test certificates for TLS and OCSP verification.
Dependencies
Initialize drivers-evergreen-tools submodule
The repository now includes the \drivers-evergreen-tools\ submodule, initialized at commit \ec0b1497b3d351acbfc4fd7579bf3de4de0a1046\. This change establishes the external tooling dependency required for the project's CI/CD and testing infrastructure.
.mod · high confidence
New gemfiles for testing specific dependencies and features
Added new gemfiles to support testing against specific versions and features: \bson\_4-stable.gemfile\ and \bson\_master.gemfile\ for testing against the \bson-ruby\ repository branches, \bson\_min.gemfile\ for testing with \bson\ version 4.14.1, \mongo\_kerberos.gemfile\ for Kerberos authentication testing, \snappy\_compression.gemfile\ for Snappy compression support, and \zstd\_compression.gemfile\ for Zstandard compression support. These files leverage a new \standard.rb\ helper that defines common development, testing, and feature-specific dependencies.
gemfiles · high confidence
Update minimum Ruby version and BSON dependency
The driver now requires Ruby 2.7 or higher and depends on BSON version 4.14.1 or newer (up to but not including 6.0.0).
(dependencies) · high confidence
Housekeeping
Repository initialization and development tooling setup
The repository has been initialized with a comprehensive set of configuration files and documentation to standardize the development workflow. This includes a new \.rubocop.yml\ configuration targeting Ruby 2.7 with performance, rake, and rspec plugins, alongside a generated \.rubocop\_todo.yml\ to manage existing style offenses. A new \Rakefile\ replaces the previous test task with a structured RSpec-based test suite, including tasks for building the gem, running RuboCop, and managing Evergreen CI configurations. Documentation is standardized through new \README.md\, \CONTRIBUTING.md\, and \AGENTS.md\ files, while build artifacts and sensitive data are excluded via updated \.gitignore\ and new \.dockerignore\ files. The project structure is further defined by \.rspec\ for test formatting, \.yardopts\ for API documentation generation, and \product.yml\ for version metadata.
(repo-wide) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 50 → 55 (+5.4)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 65 → 65 (+0.0)
- Architecture 87 → 87 (-0.0)
- Maturity 37 → 53 (+16.3)
- Readiness 64 → 64 (+0.0)
- Security 54 → 49 (-5.5)
Resolved (11)
- Documentation: no installation or build instructions (README.md)
- Documentation: no project overview (README.md)
- Documentation: no usage examples (README.md)
- Hotspot: lib/mongo/session.rb (lib/mongo/session.rb)
- Inconsistent naming for getter/setter pair. Ruby convention typically uses the same name for both (e.g., credentials for both getter and setter, or get_credentials/set_credentials if explicit). Using credentials for getter and credentials= for setter is standard, but the presence of fetch and instance methods nearby creates ambiguity about whether credentials is a simple accessor or a cached lookup.
- Off-boarding risk: anonymized user #1
- Off-boarding risk: anonymized user #2
- Orphaned file (lib/mongo/operation/map_reduce/result.rb)
- Orphaned file (lib/mongo/protocol/serializers.rb)
- Redundant methods with overlapping intent. list_mongo_databases appears to be a specific variant or alias of list_databases, but the parameter signature differs (name_only is explicit in the former, implicit or handled via opts in the latter). This creates confusion for users on which method to use for listing databases.
- While not a naming inconsistency per se, the presence of == and hash on User suggests value equality semantics, but User contains sensitive data (passwords, mechanisms). If == compares all fields including passwords, it may be a security risk or performance issue. If it compares only identity fields, the naming == is misleading compared to eql? or identity_match?.
New (8)
- High secret: WD-SECRET-0005 (.evergreen/functions.sh)
- High: security finding (details withheld)
- Medium: security finding (details withheld)
- Medium: security finding (details withheld)
- Off-boarding risk: anonymized user #2
- Off-boarding risk: anonymized user #1
- Orphaned file (lib/mongo/srv/resolver.rb)
- Rotate the exposed credentials — git history can't be un-committed
Changes since last survey
- 10 commits — 10 feature/other, 0 fixes
By area
- lib/mongo — 5 commits
- (root) — 2 commits
- spec/spec_tests — 2 commits
- profile/driver_bench — 1 commit
Notable commits
- change: Bump version to 2.26.1 (#3128)
- change: RUBY-3813 Support KMS connect callback for HTTP proxies (#3119)
- change: RUBY-3821 Remove pre-4.2 spec test fixtures (#3117)
- change: RUBY-3952 Add no more to spans that are not recording (#3124)
- change: RUBY-3952 Benchmark OpenTelemetry configurations with DriverBench (#3121)
- change: RUBY-3952 Cache tracing values that do not change (#3126)
- change: RUBY-3952 Cut allocations on the command tracing path (#3127)
- change: RUBY-3952 Skip span work for spans with invalid contexts (#3123)
- change: RUBY-3982 Enable Lint/UnreachableCode cop (#3114)
- change: RUBY-3986 Mandate raising writeConcernError (change SHOULD to MUST) (#3125)
Architecture
- Unchanged — 0 containers · 1 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
mongodb/mongo-ruby-driver was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 6 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit ebea65f5b03cc3732c4f469f53c1fc47e1ad64a0 — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.2+preprod-5c4e66d9318b.