|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +This file defines guidance for coding agents acting as C++ developers in this repository. |
| 6 | +The goal is to make safe, minimal, style-consistent changes to dripline-cpp. |
| 7 | + |
| 8 | +## Repository Scope |
| 9 | + |
| 10 | +- Main library code: `library/` |
| 11 | +- CLI executables: `executables/` (`dl-agent`, `dl-mon`) |
| 12 | +- Example services/endpoints: `examples/` |
| 13 | +- Unit/integration tests: `testing/` |
| 14 | +- Docs sources: `documentation/source/` |
| 15 | +- Bundled dependency and build framework: `scarab/` |
| 16 | + |
| 17 | +## Architecture At A Glance |
| 18 | + |
| 19 | +- `core` owns AMQP connectivity and send/listen primitives. |
| 20 | +- `message` and derived types (`msg_request`, `msg_reply`, `msg_alert`) implement protocol objects and chunking. |
| 21 | +- `receiver` and `listener` manage chunk assembly and concurrent processing. |
| 22 | +- `endpoint` implements request dispatch and lockout semantics. |
| 23 | +- `service` composes endpoint + listener/receiver + heartbeater + scheduler. |
| 24 | +- `hub` maps message specifiers to user-registered handlers. |
| 25 | +- `agent` and `monitor` provide CLI-oriented message send/observe tooling. |
| 26 | + |
| 27 | +## Build And Test Workflow |
| 28 | + |
| 29 | +Preferred local workflow (from repo root): |
| 30 | + |
| 31 | +1. Configure |
| 32 | + - `cmake -S . -B build` |
| 33 | +2. Build |
| 34 | + - `cmake --build build -j` |
| 35 | +3. Run tests |
| 36 | + - `./build/testing/run_dl_tests` |
| 37 | + |
| 38 | +Common options: |
| 39 | + |
| 40 | +- `-DDripline_ENABLE_TESTING=ON` |
| 41 | +- `-DDripline_ENABLE_EXECUTABLES=ON` |
| 42 | +- `-DDripline_BUILD_EXAMPLES=ON` |
| 43 | +- `-DDripline_BUILD_PYTHON=ON` (only when needed) |
| 44 | + |
| 45 | +If you add new source files, update the corresponding `CMakeLists.txt` target lists. |
| 46 | + |
| 47 | +## Coding Style (Observed In This Codebase) |
| 48 | + |
| 49 | +Follow existing style in the touched file. Do not reformat unrelated code. |
| 50 | + |
| 51 | +### Formatting |
| 52 | + |
| 53 | +- Use 4-space indentation; no tabs. |
| 54 | +- Put opening braces on the next line for classes/functions/control blocks. |
| 55 | +- Use the project's spacing pattern, e.g. `if( condition )`, `catch( const std::exception& e )`. |
| 56 | +- Keep lines reasonably readable; avoid large-scale wrapping churn. |
| 57 | + |
| 58 | +### File Structure |
| 59 | + |
| 60 | +- Header/source pairs use `.hh` and `.cc`. |
| 61 | +- Header guards are uppercase with `_HH_` suffix (example pattern: `DRIPLINE_FOO_HH_`). |
| 62 | +- Most files include a top block comment with file name, date, author; preserve existing header blocks. |
| 63 | + |
| 64 | +### Includes |
| 65 | + |
| 66 | +- In `.cc` files, include the matching local header first. |
| 67 | +- Then include project headers, then external/library headers, then standard headers. |
| 68 | +- Preserve the local ordering conventions in each file when editing. |
| 69 | + |
| 70 | +### Namespaces And Types |
| 71 | + |
| 72 | +- Core namespace is `dripline`. |
| 73 | +- Prefer existing alias style in a file (`using`, `typedef`) instead of forcing one style. |
| 74 | +- Keep API/export macros where used (`DRIPLINE_API`, `DRIPLINE_API_EXPORTS`). |
| 75 | + |
| 76 | +### Class And Member Conventions |
| 77 | + |
| 78 | +- Member fields commonly use `f_` prefix (`f_status`, `f_channel`, etc.). |
| 79 | +- Accessor macros from Scarab are widely used (`mv_accessible`, `mv_referrable`, etc.); use them consistently in nearby code. |
| 80 | +- Keep move/copy semantics explicit where already established. |
| 81 | + |
| 82 | +### Error Handling And Logging |
| 83 | + |
| 84 | +- Prefer explicit exception types used by this project (`dripline_error`, `connection_error`, AMQP exceptions). |
| 85 | +- Preserve message-rich error text using stream-style construction. |
| 86 | +- Use logger macros already present in the file (`LOGGER`, `LDEBUG`, `LINFO`, `LWARN`, `LERROR`). |
| 87 | + |
| 88 | +### Const And Parameter Passing |
| 89 | + |
| 90 | +- Prefer `const` correctness and pass heavy objects by `const &`. |
| 91 | +- Follow existing pointer ownership style (`std::shared_ptr`, project typedefs). |
| 92 | + |
| 93 | +## Testing Expectations For Changes |
| 94 | + |
| 95 | +- Add or update tests in `testing/` when behavior changes. |
| 96 | +- Prefer focused tests near related existing suites (agent/core/service/message/etc.). |
| 97 | +- Do not weaken existing assertions to make tests pass. |
| 98 | + |
| 99 | +## Agent Working Rules |
| 100 | + |
| 101 | +- Make minimal, targeted edits. |
| 102 | +- Preserve public behavior unless the task explicitly changes behavior. |
| 103 | +- Avoid speculative refactors during bug fixes. |
| 104 | +- Update docs/comments when behavior or configuration changes. |
| 105 | +- Keep cross-component compatibility in mind (`dripline-python`, protocol constants, and wire expectations). |
| 106 | + |
| 107 | +## When Unsure |
| 108 | + |
| 109 | +- Prefer consistency with nearest surrounding code over generic modern C++ style advice. |
| 110 | +- If patterns conflict across files, match the pattern used in the file you are editing. |
0 commit comments