Skip to content
CAI
Software that uses CAICheck a score

couchbase/couchdb

32.8

Weak · 2 October 2026

52k

lines of production code

Erlang

with C, JavaScript

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a distributed document database engine built on Erlang that manages data persistence, replication, and querying. It provides core capabilities for storing and retrieving documents, executing MapReduce views via a high-performance C++ NIF, and synchronizing state across nodes using the Data Change Protocol (DCP). The platform includes infrastructure for asynchronous audit logging, view merging, and comprehensive testing across multiple languages to ensure reliability.

How it got here

2008–2009 — CMake build system migration

15 changes.

The project migrated its build infrastructure from autotools to CMake, automating the generation of configuration files, startup scripts, and service definitions for Unix, macOS, and Windows. This transition standardized installation paths and service management while introducing comprehensive testing and benchmarking suites for core storage, view servers, and performance metrics.

2011–2012 — NIF-based view engine and parser rewrite

14 changes.

This period focused on rewriting CouchDB's view infrastructure using Erlang NIFs to improve performance, introducing a new C++-based MapReduce subsystem with V8 integration and a YAJL-based view parser. It also established the set view engine with barrier-based concurrency control and a distributed view merger subsystem to handle cross-node query aggregation.

2014–2025 — DCP integration and build system migration

12 changes.

This period focused on establishing CouchDB as a standalone DCP consumer by implementing client modules, protocol definitions, and comprehensive testing. Concurrently, the project modernized its infrastructure by migrating the core Erlang source and native modules to a CMake-based build system while introducing asynchronous audit logging and optimizing map-reduce function analysis.

Features

Add ETap TAP testing module for Erlang

The ETap testing library (version 0.3.4) has been added to the project, providing a Test Anything Protocol (TAP) interface for Erlang components. This includes the core \etap.erl\ module and a CMake build configuration, enabling developers to run structured test suites with plan management, assertions, and diagnostic output.

src/etap · high confidence

Add Snappy compression Erlang NIF module

This change introduces a new Erlang NIF module (\snappy\) that wraps the Snappy compression library, providing \compress\, \decompress\, \uncompressed\_length\, and \is\_valid\ functions for use within CouchDB. The implementation includes a C++ NIF source (\snappy\_nif.cc\) and a compatibility header (\erl\_nif\_compat.h\) to support Erlang/OTP versions from R13B04 onwards. The build system has been updated to use CMake to compile the native library, ensuring correct installation paths and disabling sanitizers for the dynamic module to ensure compatibility with the Erlang VM.

src/snappy · high confidence

Add ejson Erlang NIF for JSON encoding and decoding

Introduces the ejson application, an Erlang NIF library that provides high-performance JSON encoding and decoding capabilities. The implementation includes C source files for parsing (using the YAJL library) and generating JSON, along with Erlang wrapper modules that expose encode, decode, and validation functions to the Erlang VM. The build system is configured via CMake to compile the NIF module and install it into the CouchDB Erlang library path.

src/ejson · high confidence

Added default configuration file for CouchDB init script

A new etc/default/couchdb file has been introduced to provide default environment variables for the CouchDB init script. This configuration sets the service user to 'couchdb', redirects standard output and error to /dev/null, and defines a respawn timeout of 5 seconds, ensuring consistent startup behavior for the service.

etc/default · high confidence

Initial commit of core Erlang source files and application definitions

This change introduces the foundational Erlang source code for CouchDB, including application definitions and modules for the view parser (\couch\_view\_parser\), map-reduce operations (\mapreduce\), and internal HTTP and replication records. It establishes the build structure for these components, which rely on NIFs (Native Implemented Functions) for performance-critical tasks, and defines the data structures used for HTTP client interactions and replication state management.

(repo-wide) · high confidence

Introduce Couch DCP protocol definitions and type specifications

Added new Erlang header files defining the constants, opcodes, flags, and data structures for the Couchbase DCP (Data Change Protocol) interface. This includes specific support for extended attributes (xattr) in both raw and JSON formats, as well as compressed variants, enabling the system to handle these document types correctly during replication. The changes also establish type specifications for DCP statuses, data types, and partition sequences, providing the foundational definitions required for collection-aware DCP connections and sequence number handling.

_src/couch\dcp/include · high confidence

Introduce MapReduce subsystem as an Erlang NIF

Adds a new MapReduce component implemented as an Erlang NIF (native implemented function) to handle view indexing. This introduces C++ source files (mapreduce.cc, mapreduce\_nif.cc) that integrate the V8 JavaScript engine for executing map and reduce functions, along with a CMake build system (CMakeLists.txt) to compile the module. The implementation includes compatibility layers for different Erlang/OTP versions (erl\_nif\_compat.h) and custom memory allocators (nif\_stl\_allocator.h) to interface between C++ STL containers and the Erlang NIF environment.

src/mapreduce · high confidence

Introduce new CouchDB view merger subsystem

Adds a new \couch\_index\_merger\ application that provides a distributed view merging capability. This includes the core merger logic (\couch\_index\_merger\, \couch\_view\_merger\), an HTTP handler for merging view queries (\couch\_httpd\_view\_merger\), a streaming parser for view responses (\couch\_http\_view\_streamer\), and a query volume logger (\couch\_query\_logger\). The subsystem supports merging MapReduce and spatial views across multiple nodes, handling row sorting, error aggregation, and debug information streaming.

_src/couch\_index\merger/src · high confidence

Introduce set view engine with barrier-based concurrency control

The set view engine is now a distinct application within CouchDB, introducing a new \couch\_index\_barrier\ module to manage concurrency limits for index updates. This component, along with the new \couch\_set\_view\ application structure, provides the foundation for the updated MapReduce view system, including dedicated modules for development views, design document caching, and HTTP handling.

_src/couch\_set\view/src · high confidence

Introduction of asynchronous audit logging to Memcached

The new couch\_audit module introduces asynchronous audit logging, capturing events such as view CRUD operations, configuration changes, and access denials. Audit records are queued in memory and sent to a Memcached server via a dedicated TCP connection, with automatic reconnection and queue limiting (dropping records if the queue exceeds 5000 items) to handle connection failures gracefully.

_src/couch\audit/src · high confidence

Introduction of standalone CouchDB DCP client and consumer modules

This change introduces a new set of Erlang modules in the \src/couch\_dcp/src\ directory to support Data Change Protocol (DCP) operations within a standalone CouchDB environment. The \couch\_dcp\_client\ module implements a gen\_server-based DCP client capable of managing vbucket streams, handling sequence number retrieval, and processing stream events. The \couch\_dcp\_consumer\ module provides functionality for parsing and encoding DCP commands, including mutations, deletions, and snapshot markers, with specific support for extended attributes (xattrs). Additionally, \couch\_dcp\_fake\_server\ offers a mock DCP server for testing purposes, while \cb\_auth\_info\ provides a simplified authentication interface to bypass dialyzer warnings when running without the full Couchbase stack. These components enable CouchDB to function as a DCP consumer independent of the core Couchbase server infrastructure.

_src/couch\dcp/src · high confidence

New NIF-based JSON and EJSON comparison functions

Added a new C-based NIF module (couch\_ejson\_compare) that provides high-performance comparison logic for both raw JSON strings and CouchDB's extended JSON (EJSON) format. This implementation replaces or supplements previous Erlang-based comparisons by leveraging the ICU library for Unicode-aware string collation and includes specific handling for EJSON type ordering (atoms, numbers, binaries, lists, objects) and recursion depth limits to prevent stack exhaustion during view key sorting.

_src/couchdb/priv/couch\_ejson\compare · high confidence

New header files for view merger records and specifications

This change introduces two new Erlang header files, couch\_index\_merger.hrl and couch\_view\_merger.hrl, which define the core data structures for the view merger component. The couch\_index\_merger.hrl file defines records for merged index specifications (including SSL options and connection timeouts), index merge operations, merge parameters, and HTTP database connections. The couch\_view\_merger.hrl file defines records for view merge operations and view specifications, including support for distinguishing between production and development views via a category field.

_src/couch\_index\merger/include · high confidence

New init script template for CouchDB service management

A new init script template (etc/init/couchdb.tpl.in) has been added to manage the CouchDB service lifecycle. This script supports standard start, stop, restart, and status commands, sourcing configuration from /etc/default/couchdb and allowing runtime options via the COUCHDB\_OPTIONS variable. It handles process execution as a specific user if configured, manages the run directory, and integrates with LSB init functions for consistent logging and status reporting.

etc/init · high confidence

Windows installer now supports installing CouchDB as a Windows Service

The Windows installation package has been updated to include an Inno Setup script that allows users to install CouchDB as a Windows Service during setup. This service runs under the LocalSystem account, is configured to start automatically, and includes logic to restart automatically on failure. The installer also handles necessary dependencies like MSVC redistributables and OpenSSL DLLs, and provides options to start the service immediately after installation.

etc/windows · high confidence

Architecture

Migration to CMake build system

The project has switched its build system from autotools to CMake, requiring CMake 3.13 or later. This change introduces a new CMakeLists.txt configuration, updates the .gitignore to handle CMake-generated artifacts (such as CMakeFiles and Testing directories), and adds a rebar.config for Erlang dependency management. The build process now uses CTest for running tests and integrates Dialyzer for static analysis, while maintaining compatibility with existing Erlang source structures.

(repo-wide) · high confidence

Behavioural changes

CouchDB 1.2.0a build system and versioning update

The CouchDB module now uses CMake for building, introducing a new CMakeLists.txt that configures the application source and sets the version to 1.2.0a. The internal header file couch\_db.hrl has been updated to define the latest disk version as 11 and includes macros for JSON encoding/decoding via the ejson application, as well as logging and record definitions for documents and database headers.

src/couchdb · high confidence

CouchDB configuration files migrated to CMake build system

The CouchDB configuration files (default.ini, local.ini, and their development variants) are now generated from .in templates during the CMake build process. This change introduces CMake variable substitution (e.g., ${CMAKE\_INSTALL\_PREFIX}) into the configuration files, ensuring that paths for database directories, logs, and Erlang libraries are correctly resolved at install time rather than being hardcoded. It also standardizes the installation of these configuration files into the etc/couchdb directory.

etc/couchdb · high confidence

CouchDB core source files migrated to CMake build system

The CouchDB Erlang source files in src/couchdb/src have been restructured to support compilation via CMake and rebar3. This includes the introduction of a new couch.app.src manifest that defines the application modules, registered processes, and dependencies (such as crypto, ssl, and mochiweb), and the addition of couch\_app.erl to manage the application lifecycle and configuration file loading. These changes replace the previous build configuration, ensuring the core database engine is built and initialized consistently within the new build pipeline.

src/couchdb/src · high confidence

CouchDB launchd plist now generated via CMake on macOS

The launchd service configuration for macOS is now built using CMake instead of the previous build system. A new CMakeLists.txt and a template plist file (org.apache.couchdb.plist.tpl.in) are introduced to generate the final launch daemon plist at build time, installing it to Library/LaunchDaemons. The generated plist configures CouchDB to run as the couchdb user, sets environment variables (HOME and DYLD\_LIBRARY\_PATH), and directs both standard output and standard error to /dev/null. It also enables RunAtLoad and KeepAlive to ensure the service starts on boot and remains running.

etc/launchd · high confidence

CouchDB log rotation configuration is now generated via CMake

The system now uses CMake to generate the CouchDB logrotate configuration file from a template (couchdb.tpl.in) during the build process. This ensures the log rotation settings (weekly rotation, 10 rotations, copytruncate, compression) are correctly placed in the etc/logrotate.d directory relative to the installation prefix, replacing any previous static or manually managed configuration.

etc/logrotate.d · high confidence

CouchDB startup scripts are now generated via CMake

The bin directory now uses CMake to generate the \couchdb\ and \couchjs\ startup scripts from templates (\\*.tpl.in\) during the build process, replacing the previous static script files. This change introduces platform-specific handling, generating a \couchdb.bat\ wrapper for Windows and shell scripts for Unix-like systems, while also updating the build system to no longer require cURL for building and adding a \make dev\ target for easier development launches.

bin · high confidence

Integrated YAJL JSON parser and generator into Couch View Parser

The view parser now uses the YAJL library for JSON processing, replacing the previous implementation. This change introduces a new C-based JSON lexer, parser, and generator (yajl.c, yajl\_lex.c, yajl\_gen.c, etc.) with support for streaming parsing, configurable memory allocation, and proper handling of JSON string escaping and UTF-8 validation. Users benefit from more robust JSON parsing behavior, including correct preservation of escape sequences in strings and proper handling of unescaped JSON object keys, as well as improved performance for view merging and parsing operations.

_src/couch\_view\parser/yajl · high confidence

Introduce versioned set view index headers and partition version tracking

The set view index header format has been upgraded to version 2, introducing explicit versioning for index files. This change adds support for tracking partition versions (failover logs) and managing unindexable sequences, enabling more reliable snapshot requests and consistent state management during partition transitions. Users benefit from improved stability when querying views with stale=false, as the system can now better handle partition state changes and replica synchronization without losing consistency.

_src/couch\_set\view/include · high confidence

Map-reduce functions now detect unused document parameters and disallow eval

The system now analyzes map functions to determine if the document parameter is actually used. If the document is unused, the system can optimize document loading by skipping unnecessary data retrieval. Additionally, the use of the \eval\ function in map functions is now detected and prohibited, as it prevents accurate analysis of document usage.

src/mapreduce/jsfunctions · high confidence

Migration to CMake build system and updated NIF configuration

The CouchDB build process for the priv directory has been migrated from the previous system to CMake, introducing a new CMakeLists.txt that defines the build targets and dependencies. This change includes configuring the couch\_ejson\_compare NIF to link against platform\_cbassert\_unsanitized and explicitly disabling sanitizers for this module to ensure compatibility with the Erlang VM. Additionally, correct rpath settings are now applied for Unix and macOS platforms to ensure proper library loading, and the stat\_descriptions.cfg is generated from a template to expose updated metrics such as authentication cache hits and misses.

src/couchdb/priv · high confidence

Mochiweb source files replaced with new implementations

The source files in src/mochiweb/src have been replaced with a new set of modules, including mochifmt, mochijson2, and mochitemp. This change updates the underlying HTTP library implementation, which may affect how the server handles requests and responses.

src/mochiweb/src · medium confidence

New C++ NIF-based Couch View Parser

The Couch View Parser is now implemented as a standalone C++ Erlang NIF module (couch\_view\_parser\_nif) built with CMake. This change replaces the previous implementation with a YAJL-based parser that uses Erlang's enif\_alloc/enif\_free for memory management and explicitly disables sanitizers to ensure compatibility with the Erlang VM. The new parser supports chunked JSON parsing via a context-based API (startContext, parseChunk, nextState) and handles view response fields including rows, debug info, and errors.

_src/couch\_view\parser · high confidence

Unused variable detection now returns AST alongside variable list

The \unused\ utility in \src/mapreduce/jsfunctions/unused\ has been updated to return both the Abstract Syntax Tree (AST) and the list of unused variables. This change, implemented in \index.js\ and supported by the new \context.js\ module, allows consumers of this function to access the parsed structure of the source code in addition to the analysis results, facilitating more advanced code inspection or transformation workflows.

src/mapreduce/jsfunctions/unused · high confidence

Test coverage

Add DCP unit tests for view groups, client behavior, and rollback scenarios; Added MapReduce test suite; Added Python test suite and test utilities for set views; Added benchmark suite for CouchDB performance testing; Added functional tests for node-to-node encryption in views; Added test infrastructure for set views; Added test suite for the view query server; Added unit tests for the CouchDB view parser; Expanded test suite for CouchDB set views; Initial ETAP test suite for core storage and document modules; New CI infrastructure for CouchDB views testing; New JavaScript test runner and build infrastructure.

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 34 → 33 (-1.0)
  • Rubric changed (rubric-2026.09.12 → rubric-2026.09.18) — scores are not directly comparable.

Lenses

  • Code Health 32 → 32 (-0.1)
  • Architecture 100 → 88 (-12.1)
  • Maturity 24 → 24 (+0.0)
  • Readiness 37 → 32 (-4.6)
  • Security 53 → 53 (+0.0)
  • Event-Driven 53 → 53 (+0.0)
  • Event Sourcing 100 → 100 (+0.0)

Resolved (3)

  • Coverage not measured — no coverage collector is wired up
  • Off-boarding risk: anonymized user #1
  • Off-boarding risk: anonymized user #2

New (48)

  • Off the main sequence: lhttpc
  • Off the main sequence: mochiweb
  • Off the main sequence: oauth
  • Off-boarding risk: anonymized user #1
  • Off-boarding risk: anonymized user #2
  • Projects may be oversized for their cohesion
  • esprima.advance (cognitive 22) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.advance (cyclomatic 21) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.collectToken (cognitive 20) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.getComplexIdentifier (cognitive 27) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parse (cognitive 26) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parse (cyclomatic 23) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseAssignmentExpression (cognitive 21) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseClassBody (cognitive 61) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseClassBody (cyclomatic 21) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseForStatement (cognitive 57) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseForStatement (cyclomatic 29) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseFunctionDeclaration (cognitive 18) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseFunctionExpression (cognitive 18) (src/mapreduce/jsfunctions/esprima.js)
  • esprima.parseFunctionSourceElements (cognitive 18) (src/mapreduce/jsfunctions/esprima.js)
  • …and 28 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

couchbase/couchdb 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 2 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 896d9678e277096b0e00d6df599ac36a1735972e — the exact code this score is about.
  • Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-e569280dd5e2.