- Language: C++23 (library + example executables).
- Build system: CMake with presets, vcpkg toolchain, optional libtorch.
- No Cursor or Copilot rules found in .cursor/rules/, .cursorrules, or .github/copilot-instructions.md.
- Public headers: include/libpolicyts/**
- Sources: src/**
- Examples: examples/** (bfs, levints, lubyts, multits, phs)
- Formatting: .clang-format (Google-based, 4 spaces, 120 columns)
- Configure release:
cmake --preset=release - Build release:
cmake --build --preset=release -- -j8 - Configure debug:
cmake --preset=debug - Build debug:
cmake --build --preset=debug -- -j8
- Build a single example target:
cmake --build --preset=release --target bfscmake --build --preset=debug --target levints
- Presets expect vcpkg via
VCPKG_ROOTand custom triplets/toolchain. - Optional libtorch uses
LIBTORCH_ROOT(see readme.md for how to set). - Presets enable examples + torch by default (LIBPOLICYTS_BUILD_EXAMPLES/TORCH=ON).
- Formatting:
clang-format -i <file>(uses .clang-format). - No clang-tidy target is defined in CMake; lint is manual.
- No automated test targets or CTest configuration in this repo.
- There is a
include/libpolicyts/test_runner.hutility, but no test executable targets. - Use example executables for smoke tests if needed.
- Use include guards in headers with the pattern
LIBPTS_<PATH>_H_. - Top-of-file comments follow
// File: ...and// Description: .... - Keep namespaces explicit, e.g.
namespace libpts::algorithm::bfs { ... }.
- Indent width: 4 spaces; tabs disabled.
- Column limit: 120.
- Braces: custom; no mandatory brace insertion.
- Allow single-line
ifwithoutelseonly; short lambdas allowed. - Pointer/reference alignment: right (
Type *ptr,Type &ref). - Include sorting: case-insensitive, grouped by category (libpolicyts, quoted, external, std).
- Prefer
#include <libpolicyts/...>for project headers. - Include order should follow clang-format categories:
<libpolicyts/...>"..."local headers- External
<...>with extensions - External library headers (catch2/boost/pybind/absl/spdlog)
- Standard
<...>without extensions
- Rely on clang-format for regrouping and sorting.
- Use
std::size_tfor sizes and indices where appropriate. - Use
constreferences for non-trivial parameters. - Use
constexprfor compile-time constants. - Prefer
autowhen type is verbose and obvious from RHS, but keep readability. - Expose ownership explicitly with
std::unique_ptr/std::shared_ptr.
- Types:
PascalCase(classes/structs/enums, e.g.SearchInput,Status). - Functions/methods:
lower_snake_case(e.g.set_solution_trajectory). - Variables/fields:
lower_snake_case. - Constants:
UPPER_SNAKE_CASEfor compile-time constants. - Namespaces:
lower_snake_case(e.g.libpts::clustering).
- Logging uses
spdlogorSPDLOG_*macros. - Fatal errors sometimes call
std::exit(1)after logging. - Some paths throw
std::logic_errorfor invalid usage. - Prefer logging a clear error before returning early or exiting.
- Avoid unnecessary copies; use move where it clarifies ownership transfer.
- Use
std::views/std::rangesfor iteration when it improves clarity. - Use
[[nodiscard]]on accessors that should not be ignored.
- Concepts are used to constrain templates (
IsEnv,IsBFSModel). - Keep concept requirements explicit and documented inline with comments.
- Add comments only for non-obvious logic or external API constraints.
- Prefer short, direct comments near the relevant code.
LIBPOLICYTS_BUILD_EXAMPLES=ONimpliesLIBPOLICYTS_BUILD_ENVIRONMENTS=ON.- If you enable environments or torch, missing dependencies are fatal at configure time.
- Use the presets to avoid missing vcpkg/toolchain configuration.
- Keep new headers in
include/libpolicyts/...and source insrc/.... - Add new public headers to
LIBPOLICYTS_PUBLIC_HEADERSin CMakeLists.txt. - Ensure any new example target is added under
examples/and wired into CMake.
- Release configure/build:
cmake --preset=release && cmake --build --preset=release -- -j8 - Debug configure/build:
cmake --preset=debug && cmake --build --preset=debug -- -j8 - Single example build:
cmake --build --preset=release --target bfs - Format:
clang-format -i include/libpolicyts/algorithm/bfs.h
- No standard test runner or lint pipeline is defined; avoid inventing ones.
- If you add tests, consider adding CTest targets or a dedicated test CMakeLists.