Repository (mirror): https://github.com/couchbase/kv_engine Primary code review system: https://review.couchbase.org
This document defines expectations for:
- Automated coding agents
- Human contributors
- Reviewers
kv_engine uses Gerrit (review.couchbase.org) for all change submission, validation, and approval.
GitHub is a mirror only. Do NOT open GitHub Pull Requests.
Welcome to the Couchbase KV-Engine project.
The committed README.md provides a high-level overview of the project and is a good starting point for new contributors. For more detailed information on architecture, protocols, and other topics, please refer to the various documentation files linked from the README:
@instructions/README.md
All changes must be submitted via:
https://review.couchbase.org
-
Sync with latest target branch (typically
master) -
Create a local topic branch (if
repois available):`repo start name-of-topic-branch` -
Make atomic, focused commits
-
Always create suitable unit tests
-
Run local build and tests
-
Sync with upstream and rebase the change. If
repois available:repo sync . repo rebase . -
Push to Gerrit (substitute master for correct branch when working on named branches):
git push gerrit HEAD:refs/for/masterAlternatively, if the
repotool is available:repo upload --cbr . -
CI validation runs automatically on jenkins servers that are monitoring for new code pushed to gerrit. 8. Review feedback is asynchronous
Language: C++ (up to C++20 supported)
Guidelines:
- Prefer modern C++ where appropriate (C++17/20 features are supported)
- Use RAII, smart pointers, and standard library facilities where they improve safety and clarity
- Structured bindings,
std::optional,std::variant,constexpr, and other modern features are acceptable - Don't use C-style arrays, use
std::arrayorstd::vectorinstead - Don't use single character variable names
- Always use braces for control structures, even if they are optional
- Match the surrounding style within the modified module. This is particularly important as the style of ep-engine differs vastly from the style of daemon code.
- It is acceptable to use older constructs if required for consistency with the existing code in that area
- Avoid unnecessary large-scale modernization in unrelated code
- Maintain cross-platform compatibility
- New source files must use the current year in the banner comment.
- The
C++ Core Guidelines<http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines>are also a key part of our coding style. - If in doubt, full coding standards are defined by
docs/CodingStandards.rst. - Always build (see building hints and testing hints) before running tests!
The project uses CMake for build configuration.
- To build all code (including all tests) use the target
kv_engine_everythingwhich can be invoked frombuild/ - Prefer to reuse an existing build directory and do incremental builds.
- Do not create a new build directory unless asked.
- Check for an existing
build/directory in the directory above thekv_enginegit repository.
- Prefer
ninjawhen building. - If configuring a new build prefer
ninjaas build tool (cmake -G Ninja)
When making code changes just to code engines/ep a preferred test stragtegy is:
- From the
build/kv_enginedirectory run engine_ep_unit_tests tests e.g.ctest -R ep-engine_ep_unit_tests - From the
build/kv_enginedirectory run ep_testsuite e.g.ctest -R ep_testsuite
Only run step 2 if step 1 is successful.
If in doubt that the code changes are covered by the above the entire test suite
can be invoked e.g. from build/kv_engine just run ctest
Agents must not:
- Change file formats silently
- Break backward compatibility unintentionally
- Reformat large areas of code
- Submit speculative refactors
- Bypass Gerrit workflow
- Create new build directories unless asked
All commit messages must:
- Start with:
MB-XXXXX: Short summary - Be wrapped at 72 characters per line
- Include a clear explanation of:
- What changed
- Why it changed
- Risk or compatibility impact
- Don't add a 'Co-authored-by' tag for automated agents. The author information is already captured in the commit metadata.
Example:
MB-12345: Fix incorrect StoredValue::size calculation
Correct off-by-one error in StoredValue::size when the value is
compressed.
Do NOT manually add or generate a Change-Id.
A local Gerrit commit-msg hook is expected to already be installed and will
automatically add the required Change-Id footer when the commit is created
or amended.
Agents must not fabricate or modify the Change-Id.
When amending an existing commit (e.g. to update the commit message or add
further changes), preserve the Change-Id line exactly as it appears in the
original commit message. Dropping or replacing the Change-Id on an amended
commit would create a new Gerrit review instead of updating the existing one.
All functional changes must include:
- New or updated unit tests
- Passing test suite locally
- No unintended regression in file format compatibility