Improve AGENTS.md with comprehensive development guide#3428
Improve AGENTS.md with comprehensive development guide#3428soloestoy wants to merge 1 commit intovalkey-io:unstablefrom
Conversation
Signed-off-by: zhaozhao.zz <zhaozhao.zz@alibaba-inc.com>
hpatro
left a comment
There was a problem hiding this comment.
Overall LGTM. I feel the source code layout would be difficult to maintain. So, if it's not that helpful in your experience, I would prefer leaving it out.
| |---|---| | ||
| | Build fails with jemalloc errors | `make distclean && make` | | ||
| | `commands.def` out of sync | `python utils/generate-command-code.py` | | ||
| | `clang-format` CI check fails | `clang-format-18 -i <modified files>` | |
There was a problem hiding this comment.
| | `clang-format` CI check fails | `clang-format-18 -i <modified files>` | | |
| | `clang-format` CI check fails | `clang-format -i <modified files>` | |
I was facing some problem in my macos where the agent didn't find the right tool.
| - Never push directly to the `unstable` branch. | ||
| - If your fork does not exist, create one before pushing. | ||
| - All commits must include a DCO sign-off: `git commit -s` | ||
| - For large features, open an Issue for discussion before submitting a PR. |
There was a problem hiding this comment.
| - For large features, open an Issue for discussion before submitting a PR. | |
| - For large features, open an issue for discussion before submitting a PR. |
|
|
||
| - Follow conventions in `DEVELOPMENT_GUIDE.md`. | ||
| - CI enforces `clang-format-18` on `*.c`, `*.h`, `*.cpp`, `*.hpp`. | ||
| - After modifying C/C++ files, run: `clang-format-18 -i <modified files>` |
There was a problem hiding this comment.
Let's use clang-format, I believe the symlink should exist to appropriate version.
| - After modifying C/C++ files, run: `clang-format-18 -i <modified files>` | |
| - After modifying C/C++ files, run: `clang-format -i <modified files>` |
| make -j4 BUILD_TLS=yes # With TLS support | ||
| make -j4 SANITIZER=address # With AddressSanitizer |
There was a problem hiding this comment.
Shall we provide similar $(nproc) suggestion like you have done below for CMake ?
| make -j4 BUILD_TLS=yes # With TLS support | |
| make -j4 SANITIZER=address # With AddressSanitizer | |
| make -j$(nproc) BUILD_TLS=yes # With TLS support | |
| make -j$(nproc) SANITIZER=address # With AddressSanitizer |
| ## Source code layout | ||
|
|
||
| | Module | Key files | Description | | ||
| |---|---|---| | ||
| | Server core | server.c, server.h | Main loop, initialization, global state | | ||
| | Networking | networking.c, anet.c, socket.c, connection.c, io_threads.c | TCP, connection management, multi-threaded I/O | | ||
| | Event loop | ae.c, ae_epoll.c, ae_kqueue.c | Event-driven engine (epoll/kqueue backends) | | ||
| | Data structures | dict.c, hashtable.c, sds.c, quicklist.c, listpack.c, intset.c, rax.c | Internal data structures | | ||
| | Data type commands | t_string.c, t_hash.c, t_list.c, t_set.c, t_zset.c, t_stream.c | Per-type command implementations | | ||
| | Persistence | rdb.c, aof.c | RDB snapshots and AOF journaling | | ||
| | Replication | replication.c | Primary/replica replication | | ||
| | Cluster | cluster.c, cluster_legacy.c, cluster_migrateslots.c | Cluster mode | | ||
| | Sentinel | sentinel.c | High-availability sentinel | | ||
| | Scripting | eval.c, script.c, scripting_engine.c | Lua scripting | | ||
| | Modules | module.c, module.h | Module system | | ||
| | Memory | zmalloc.c, defrag.c, lazyfree.c, allocator_defrag.c | Memory management | | ||
| | Security | acl.c, tls.c | ACL and TLS | |
There was a problem hiding this comment.
Does this help ? Generally the agents are able to discover the right files for me.
madolson
left a comment
There was a problem hiding this comment.
My opinion is effectively restating https://www.philschmid.de/writing-good-agents, which tries to summarize the best practices from https://arxiv.org/abs/2602.11988. Less is more for AGENTS.md files. So mostly suggesting removing things.
| - Third-party dependencies in `deps/`: jemalloc, libvalkey, lua, linenoise, hdr_histogram, fast_float | ||
| - Command definitions: `src/commands/*.json` (427+ entries in JSON format) | ||
|
|
||
| ## Source code layout |
There was a problem hiding this comment.
I don't think there is strong evidence that layouts help agents. Would consider removing this.
| - Comments should explain non-obvious behavior and rationale, not restate the code | ||
| - Functions should have documentation comments | ||
|
|
||
| **License header** — all new files must include: |
There was a problem hiding this comment.
| **License header** — all new files must include: | |
| **License header** — all new code files must include: |
Conversely, should we add a style checker to enforce this?
| make valgrind # Valgrind-compatible build | ||
| ``` | ||
|
|
||
| **CMake build (alternative):** |
There was a problem hiding this comment.
Why alternatives? I think the research says you should be prescriptive to a single approach
| - Integration tests: `tests/` (Tcl) | ||
| - Top-level `Makefile` forwards most targets into `src/Makefile` | ||
| - Third-party dependencies in `deps/`: jemalloc, libvalkey, lua, linenoise, hdr_histogram, fast_float | ||
| - Command definitions: `src/commands/*.json` (427+ entries in JSON format) |
There was a problem hiding this comment.
| - Command definitions: `src/commands/*.json` (427+ entries in JSON format) | |
| - Command definitions: `src/commands/*.json` |
| Always push to the user's fork. Never push to the upstream valkey-io/valkey repository. Never push directly to unstable. If a user fork does not exist, ask the contributor to create one. | ||
|
|
||
| - Always push to your personal fork. **Never push directly to `valkey-io/valkey`.** | ||
| - Never push directly to the `unstable` branch. |
There was a problem hiding this comment.
You can't push to the unstable branch, it has branch protections.
| - Never push directly to the `unstable` branch. |
There was a problem hiding this comment.
Helps avoiding it on the fork where the branch protection isn't active for everyone.
There was a problem hiding this comment.
That's not a valkey specific thing though? Again, my opinion is we should include as little as possible that agents can't infer. Agents can infer that you shouldn't push to default branch.
There was a problem hiding this comment.
Actually, I now wonder if we need the "never push directly to valkey-io" either, you can't push there either.
No description provided.