Skip to content

Improve AGENTS.md with comprehensive development guide#3428

Open
soloestoy wants to merge 1 commit intovalkey-io:unstablefrom
soloestoy:update-agents-md
Open

Improve AGENTS.md with comprehensive development guide#3428
soloestoy wants to merge 1 commit intovalkey-io:unstablefrom
soloestoy:update-agents-md

Conversation

@soloestoy
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: zhaozhao.zz <zhaozhao.zz@alibaba-inc.com>
Copy link
Copy Markdown
Contributor

@hpatro hpatro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>` |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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>`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use clang-format, I believe the symlink should exist to appropriate version.

Suggested change
- After modifying C/C++ files, run: `clang-format-18 -i <modified files>`
- After modifying C/C++ files, run: `clang-format -i <modified files>`

Comment on lines +64 to +65
make -j4 BUILD_TLS=yes # With TLS support
make -j4 SANITIZER=address # With AddressSanitizer
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we provide similar $(nproc) suggestion like you have done below for CMake ?

Suggested change
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

Comment on lines +18 to +34
## 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 |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this help ? Generally the agents are able to discover the right files for me.

Copy link
Copy Markdown
Member

@madolson madolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**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):**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't push to the unstable branch, it has branch protections.

Suggested change
- Never push directly to the `unstable` branch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helps avoiding it on the fork where the branch protection isn't active for everyone.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I now wonder if we need the "never push directly to valkey-io" either, you can't push there either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants