|
| 1 | +<!--- |
| 2 | + Copyright 2026-present Alibaba Inc. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +--> |
| 16 | + |
| 17 | +# AGENTS.md |
| 18 | + |
| 19 | +This file provides repository-specific instructions for coding agents working on Paimon C++. |
| 20 | +For contributor-facing setup and the complete coding conventions, also read [`CONTRIBUTING.md`](CONTRIBUTING.md) and [`docs/code-style.md`](docs/code-style.md). |
| 21 | + |
| 22 | +## Scope |
| 23 | + |
| 24 | +These instructions apply to the entire repository. More deeply nested `AGENTS.md` files, if added later, may provide additional or more specific instructions for their directory trees. |
| 25 | + |
| 26 | +Keep the requested scope exact. Do not include unrelated refactors, formatting changes, API redesigns, dependency updates, or generated files in a focused change. |
| 27 | + |
| 28 | +## Repository Layout |
| 29 | + |
| 30 | +- `include/paimon/`: public C++ API headers. |
| 31 | +- `src/paimon/`: core implementation and most unit tests. |
| 32 | +- `test/inte/`: end-to-end integration tests. |
| 33 | +- `benchmark/`: benchmarks and benchmark-specific tests. |
| 34 | +- `examples/`: example programs. |
| 35 | +- `docs/` and `apidoc/`: user documentation and API documentation. |
| 36 | +- `cmake_modules/` and `build_support/`: CMake helpers and build infrastructure. |
| 37 | +- `ci/`: scripts used by continuous integration. |
| 38 | +- `test/test_data/`: checked-in test fixtures. |
| 39 | +- `third_party/`: third-party sources and patches. |
| 40 | +- `build/`, `build-release/`, and `output/`: generated or local build output. |
| 41 | + |
| 42 | +Do not edit `third_party/`, checked-in fixtures, generated output, or Git LFS objects unless the task explicitly requires it. Never add files from local build directories to a change. |
| 43 | + |
| 44 | +## Working Rules |
| 45 | + |
| 46 | +1. Inspect the current implementation, nearby tests, and relevant CMake target before editing. |
| 47 | +2. Search for an existing helper or established pattern before adding a new abstraction. |
| 48 | +3. Preserve user changes and untracked local files. Do not discard, overwrite, or reformat unrelated work. |
| 49 | +4. Prefer the smallest change that fully implements or fixes the requested behavior. |
| 50 | +5. Add or update a focused regression test for behavior changes when practical. |
| 51 | +6. Do not claim a build or test passed unless the corresponding command completed successfully. |
| 52 | +7. Do not commit, push, amend commits, or create a pull request unless explicitly requested. |
| 53 | + |
| 54 | +When changing a public API, check the declaration under `include/paimon/`, its implementation, symbol visibility, documentation, callers, and tests together. |
| 55 | + |
| 56 | +## C++ Requirements |
| 57 | + |
| 58 | +The full rules are in [`docs/code-style.md`](docs/code-style.md). In particular: |
| 59 | + |
| 60 | +- Use C++17; do not introduce C++20 or later features. |
| 61 | +- Use `Status` and `Result<T>` for fallible operations. Do not use exceptions for production error propagation. |
| 62 | +- Propagate errors with the project macros, including `PAIMON_RETURN_NOT_OK` and `PAIMON_ASSIGN_OR_RAISE`. |
| 63 | +- Use an explicit type, not `auto`, as the declaration in `PAIMON_ASSIGN_OR_RAISE` and `PAIMON_ASSIGN_OR_RAISE_FROM_ARROW`. |
| 64 | +- Prefer `std::unique_ptr` for sole ownership and use `std::shared_ptr` only for genuine shared ownership. |
| 65 | +- Use `static Create()` plus a private constructor when object initialization can fail. |
| 66 | +- Mark new public API symbols with `PAIMON_EXPORT`. |
| 67 | +- Reuse helpers under `src/paimon/common/utils/` instead of duplicating utility code. |
| 68 | +- Follow `.clang-format`; do not manually restyle unrelated code. |
| 69 | +- Add the repository's Apache 2.0 license header to every new source or documentation file. |
| 70 | + |
| 71 | +## Build and Test |
| 72 | + |
| 73 | +Use an existing configured build directory when it is compatible with the change. To configure a new debug build with tests: |
| 74 | + |
| 75 | +```bash |
| 76 | +cmake -S . -B build \ |
| 77 | + -DCMAKE_BUILD_TYPE=Debug \ |
| 78 | + -DPAIMON_BUILD_TESTS=ON |
| 79 | +``` |
| 80 | + |
| 81 | +Start with the narrowest relevant validation: |
| 82 | + |
| 83 | +```bash |
| 84 | +cmake --build build --target <test-target> -j "$(nproc)" |
| 85 | +./build/debug/<test-binary> --gtest_filter='<Suite.Test>' |
| 86 | +``` |
| 87 | + |
| 88 | +Then broaden validation in proportion to the change: |
| 89 | + |
| 90 | +```bash |
| 91 | +# All unit tests |
| 92 | +cmake --build build --target unittest -j "$(nproc)" |
| 93 | + |
| 94 | +# Formatting, lint, and repository checks for changed files |
| 95 | +pre-commit run --files <changed-files> |
| 96 | +git diff --check |
| 97 | +``` |
| 98 | + |
| 99 | +For changes to build configuration, public APIs, shared infrastructure, or cross-module behavior, run the relevant wider test suite. The CI-equivalent build entry point is `ci/scripts/build_paimon.sh`; it may rebuild all dependencies and take substantially longer than a focused local target. |
| 100 | + |
| 101 | +If a required check cannot be run because of missing dependencies, unsupported hardware, or time constraints, report exactly what was and was not run. |
| 102 | + |
| 103 | +## Testing Conventions |
| 104 | + |
| 105 | +- Use GoogleTest and name test files `*_test.cpp`. |
| 106 | +- Place unit tests next to the corresponding implementation unless an existing target establishes another location. |
| 107 | +- Extend an existing test target when appropriate instead of creating a new executable for one small test. |
| 108 | +- Test externally observable behavior and failure cases; avoid coupling tests to incidental implementation details. |
| 109 | +- Use existing test utilities and temporary-directory helpers. Do not write tests that depend on developer-specific absolute paths. |
| 110 | +- Keep fixtures deterministic and small. Do not rewrite existing fixture data unless the task explicitly calls for it. |
| 111 | +- Use `ASSERT_*` when later assertions depend on the condition succeeding. |
| 112 | + |
| 113 | +## Delivery |
| 114 | + |
| 115 | +Before handing off a change: |
| 116 | + |
| 117 | +1. Review `git diff` for accidental or unrelated edits. |
| 118 | +2. Run `git diff --check`. |
| 119 | +3. Run the narrowest relevant build and test, plus any wider checks justified by the risk. |
| 120 | +4. Summarize the changed behavior and list the exact validation commands that ran. |
| 121 | +5. Call out skipped validation, remaining risks, or follow-up work explicitly. |
| 122 | +6. When explicitly asked to commit, follow the Conventional Commits requirements in [`CONTRIBUTING.md`](CONTRIBUTING.md#commit-messages-and-pull-request-titles). |
| 123 | +7. When explicitly asked to open a pull request, follow [`CONTRIBUTING.md`](CONTRIBUTING.md#commit-messages-and-pull-request-titles), use a Conventional Commits title, and complete every applicable section of [`.github/PULL_REQUEST_TEMPLATE.md`](.github/PULL_REQUEST_TEMPLATE.md). |
0 commit comments