Do not run git commands in this repository unless the user explicitly asks for them.
- Do not fetch, pull, push, rebase, commit, stash, reset, or inspect git state without authorization.
- If a task would normally end with git operations, stop after local verification and report what remains.
The source of truth is the live repository state:
CMakeLists.txtCMakePresets.json- files under
rpc/,generator/,transports/,streaming/,tests/,types/, andtelemetry/
Do not rely on documents/ for correctness. It may be useful for background, but it is not authoritative.
documents/external-project-guide.md— start here when creating or working on a project that consumes Canopy viaadd_subdirectory. Contains working CMake boilerplate, IDL syntax, TCP server/client patterns, and a list of known CMake pitfalls.documents/transports/tcp.md— TCP transport overview.documents/architecture/— zone, service, and lifetime architecture.
Canopy is a modern C++ RPC library with generated proxy/stub code from IDL files. It supports multiple transport layers, optional coroutine builds, JSON schema metadata, enclave-related builds, demos, and benchmarks.
rpc/- core RPC library- public headers:
rpc/include/rpc - implementation:
rpc/src - generated/public interfaces:
rpc/interfaces
- public headers:
generator/- IDL code generatortransports/- transport implementations- current transport subdirectories include
direct,local,mock_test,sgx,streaming
- current transport subdirectories include
streaming/- coroutine-only streaming stack and teststypes/- additional types, including JSON supporttelemetry/- telemetry/logging supporttests/- host tests, fixtures, fuzz tests, unit tests, schema tests, serializer testssubcomponents/- reusable support components such asnetwork_config,spsc_queue, andhttp_serversubmodules/- third-party dependencies and parser components, includingidlparserdemos/- example programsbenchmarking/- benchmark targetscmake/- CMake modules
- Build outputs are preset-specific. Do not assume a single
build/directory. - Generated files appear under the active binary directory, typically in
<binaryDir>/generated/.
- CMake minimum version:
3.24 - Generator:
Ninja - Default compilers in presets:
clang/clang++ - Language standard:
- C++17 by default
- C++20 when
CANOPY_BUILD_COROUTINE=ON
Current top-level configure presets are defined in CMakePresets.json. The commonly useful ones are:
Debug-> binary dirbuild_debugDebug_AgressiveDebug_ASANDebug-clang-18Debug_GCCDebug_CoverageDebug_Hang_On_AssertDebug_Coroutine-> binary dirbuild_debug_coroutineDebug_Coroutine_ASANDebug_Coroutine-GCCDebug_Coroutines_With_No_LoggingDebug_Coroutine_With_Full_LoggingDebug_Coroutine_CoverageDebug_Coroutine_TidyRelease-> binary dirbuild_releaseRelease-clang-18Release_Coroutines-> binary dirbuild_release_coroutineRelease_Coroutine_with_No_loggingRelease_with_coroutines_GCCDebug_SGXDebug_SGX_SimRelease_SGXRelease_SGX_Sim
Use the exact preset names from CMakePresets.json. Do not normalize or rename them in instructions.
CANOPY_BUILD_TESTdefaults toONin the base preset.CANOPY_BUILD_DEMOSdefaults toON.CANOPY_BUILD_BENCHMARKINGdefaults toON.CANOPY_BUILD_COROUTINEdefaults toOFF.streaming/is only added when coroutine builds are enabled.tests/test_enclaveis only added whenCANOPY_BUILD_ENCLAVE=ON.tests/json_schema_testis only added whenNLOHMANN_JSON_CONFIG_INSTALL_DIRis defined.
cmake --preset Debug
cmake --preset Debug_Coroutine
cmake --preset Releasecmake --build build_debug
cmake --build build_debug_coroutine
cmake --build build_releaseTo build a specific target:
cmake --build build_debug --target rpc_test
cmake --build build_debug --target fuzz_test_main
cmake --build build_debug_coroutine --target io_uring_stream_testAfter editing IDL, rebuild the relevant target or rebuild the active binary directory.
cmake --build build_debug --target generator
cmake --build build_debug --target <interface_name>_idl
cmake --build build_debugDo not assume generated code lands in source directories. Check the active binary directory first.
Current directly named test executables include:
rpc_testserialiser_testfuzz_test_mainjson_schema_metadata_testwhen JSON schema test support is enabledmember_ptr_testpassthrough_testzone_address_test- multiple targets under
tests/std_test io_uring_stream_testin coroutine builds
Examples:
./build_debug/output/rpc_test --telemetry-console
./build_debug/output/fuzz_test_main 3
./build_debug/output/json_schema_metadata_test
./build_debug_coroutine/output/io_uring_stream_testNotes:
rpc_testsupports--telemetry-console.fuzz_test_mainis registered with CTest to run multiple iterations.memory_testsexists in the tree but is currently not added bytests/CMakeLists.txt.- VS Code test discovery is configured to match
build*/output/*.
Prefer running the smallest relevant target first, then broaden if needed.
- Follow
.clang-format. - The repository uses WebKit-derived formatting with:
IndentWidth: 4BreakBeforeBraces: AllmanPointerAlignment: LeftSortIncludes: false
- Preserve existing comments unless they are wrong or actively misleading.
- Keep naming and surrounding style consistent with the local file.
- Baseline code should remain valid in non-coroutine builds unless the change is explicitly coroutine-only.
- Canopy supports both blocking and coroutine builds.
CORO_TASK,CO_RETURN, andCO_AWAITare compatibility macros used across the codebase.- Coroutine-specific code paths are guarded by
CANOPY_BUILD_COROUTINE. - If you change shared logic, consider both:
DebugDebug_Coroutine
rpc::shared_ptrandstd::shared_ptrare not interchangeable.- Do not cast between
rpc::shared_ptrandstd::shared_ptr. - Do not use raw-pointer conversions to bridge them.
- Marshalled IDL interfaces use
rpc::shared_ptrorrpc::optimistic_ptr. - Core ownership outside the marshalled interface layer is usually
std::shared_ptr.
- Stub and proxy lifetime management is central to correctness.
- Hierarchical transports intentionally maintain parent/child lifetime links.
child_service, passthroughs, and service proxies all participate in transport lifetime management.- Changes touching transport shutdown, status propagation, service ownership, or cross-zone references need extra scrutiny.
Verify behaviour in code before restating architectural claims.
- Prefer structured logging macros such as
RPC_INFOandRPC_WARNING. - Telemetry is enabled in the
Debugpreset and disabled in several reduced-logging presets. CANOPY_USE_TELEMETRY_RAII_LOGGINGshould only be enabled deliberately for investigation because it is expensive.
- Validate repository facts from code and CMake, not from old prose.
- When changing build, generator, IDL, transport, or lifetime behaviour, inspect the nearest
CMakeLists.txtand implementation files first. - If code changes affect both coroutine and non-coroutine paths, verify both builds when practical.
- If a test or target is conditionally compiled, mention that condition explicitly in your handoff.
When ending a session:
- Run the relevant local verification for the files you changed.
- State clearly what you verified and what you did not verify.
- Do not perform git or remote issue-tracker actions unless the user explicitly requested them.
- Note any follow-up work that remains.