

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1234567# Dragonfly Code Review Instructions89Dragonfly is a high-performance, Redis-compatible in-memory data store written in C++20 with a unique shared-nothing, fiber-based architecture. Code reviews must prioritize correctness, security, and architectural compliance specific to this threading model.1011## Review Priorities1213### 🔴 CRITICAL (Block merge immediately)1415**Threading Model Violations** (causes deadlocks/crashes):16- ❌ **NEVER** use `std::thread`, `std::mutex`, `std::condition_variable`, or standard library threading primitives17- ✅ **ALWAYS** use fiber-aware equivalents: `util::fb2::Mutex`, `util::fb2::Fiber`, `util::fb2::CondVar` from `util/fibers/`1819**Architecture Violations**:20- ❌ Cross-shard data access without proper synchronization21- ✅ Per-shard operations only (see `src/server/db_slice.cc` for patterns)2223**Security Vulnerabilities**:24- Authentication/authorization bypass in ACL code (`src/server/acl/`)25- Exposed secrets, credentials in code or logs26- Buffer overflows, use-after-free, memory safety issues2728**Correctness Issues**:29- Race conditions in fiber scheduling30- Logic errors in transaction handling (`src/server/transaction.cc`)31- Data corruption risks in DashTable operations (`src/core/dash.h`)3233### 🟡 IMPORTANT (Requires discussion)3435**Code Quality**:36- Missing error handling (should return `OpStatus` from `facade/op_status.h`)37- Obvious memory leaks (check ASAN reports)38- Performance bottlenecks in hot paths (unnecessary allocations, N+1 patterns)3940**Test Coverage**:41- New features without tests (both C++ unit tests and Python integration tests)42- Changes to critical paths (transactions, replication, cluster) without test coverage43- Modified code that fails existing tests4445**Style Violations** (severe only):46- Not following naming conventions: `snake_case` variables, `PascalCase` functions, `kPascalCase` constants47- Code that won't pass pre-commit hooks (clang-format, 100 char limit)4849### 🟢 SUGGESTIONS (Non-blocking, comment only if obvious)5051- Over-engineering: adding abstraction layers, feature flags, or configurability not requested52- Missing comments on complex fiber synchronization logic53- Premature optimization without profiling5455## Dragonfly-Specific Patterns5657### ✅ DO: Correct Patterns5859**Threading & Synchronization**:60```cpp61// ✅ CORRECT: Fiber-aware mutex62util::fb2::Mutex mutex_;63std::lock_guard<util::fb2::Mutex> lock(mutex_);6465// ✅ CORRECT: Fiber-aware operations66util::fb2::Fiber fb = util::fb2::Fiber("name", [&] { /* work */ });67```686970**Per-Shard Design**:71```cpp72// ✅ CORRECT: Operate on shard-local data73void DbSlice::SomeOperation() {74 // Access only this shard's data75 auto& db_slice = cntx->ns->GetCurrentDbSlice();76}77```7879### ❌ DON'T: Anti-Patterns8081**Threading**:82```cpp83// ❌ WRONG: Standard library threading (causes deadlocks!)84std::mutex mutex_;85std::thread worker;86std::condition_variable cv_;87```8889**Global State**:90```cpp91// ❌ WRONG: Global mutable state (breaks shared-nothing architecture)92static std::unordered_map<string, int> global_cache;93```9495**Build Commands**:96- ❌ Don't suggest `./tools/docker/build.sh` or `make` for incremental builds97- ✅ Use `cd build-dbg && ninja <target>` instead9899## Code Review Checklist100101When reviewing Dragonfly code, verify:1021031. **Architecture Compliance**:104 - [ ] No standard library threading primitives (`std::thread`, `std::mutex`)105 - [ ] No global mutable state106 - [ ] Fiber-aware synchronization used correctly107 - [ ] Follows per-shard, shared-nothing design1081092. **Security**:110 - [ ] No OWASP vulnerabilities (injection, XSS, auth bypass)111 - [ ] No hardcoded secrets or credentials112 - [ ] Input validation on command arguments113 - [ ] Safe memory operations (no buffer overflows)1141153. **Testing**:116 - [ ] New functionality has test coverage117 - [ ] Tests build and pass: `cd build-dbg && ninja <test> && ./<test>`118 - [ ] No test regressions1191204. **Style & Formatting**:121 - [ ] Follows naming conventions (snake_case vars, PascalCase functions)122 - [ ] Will pass pre-commit checks (clang-format, 100 char limit)123 - [ ] Code compiles without warnings (CI uses `-Werror`)1241255. **Helio Submodule**:126 - [ ] No direct edits to `helio/` directory (it's a git submodule)127128## Common False Positives to Ignore129130These are **NOT** issues in Dragonfly's design. Do not comment on:1311321. **Single-threaded-looking code**: Per-shard operations intentionally avoid locks1332. **Custom allocators**: mimalloc is used intentionally for performance1343. **Manual memory management**: Required for performance-critical paths1354. **Complex template metaprogramming**: DashTable uses advanced C++20 features1365. **Missing const**: Not always applicable in high-performance code137138## Review Style Guidelines1391401. **Be specific**: Reference file:line, explain WHY it's wrong1412. **Show examples**: Demonstrate the correct pattern with code1423. **Prioritize**: Security and correctness over style1434. **Link to docs**: Reference `docs/df-share-nothing.md`, `docs/transaction.md`, etc.1445. **Be concise**: Dragonfly team values focused, actionable feedback145146## Example Review Comments147148**❌ BAD - Too noisy**:149> "Consider using auto here for type inference"150151**✅ GOOD - Actionable and specific**:152> "🔴 CRITICAL: Line 42 uses `std::mutex`. This will cause fiber deadlocks. Replace with `util::fb2::Mutex` from helio/util/fibers/. See src/server/set_family.cc:123 for correct pattern."153154**✅ GOOD - Security focused**:155> "🔴 SECURITY: Line 58 doesn't validate `user_input` before passing to eval(). Vulnerable to command injection. Add validation or use SafeEval()."156157**✅ GOOD - Architecture violation**:158> "🟡 ARCHITECTURE: Line 91 accesses global `cache_map`. Dragonfly uses shared-nothing design - each shard must have its own cache. See docs/df-share-nothing.md"159160---161162**Key Files Reference**: See AGENTS.md for complete codebase structure, build commands, and testing procedures.163
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| dragonflydb/dragonfly.github/copilot-instructions.md · 31k | Copilot instructions | stylegitdo-notagent-behaviour | 50/100 | 13 days ago | |
| dragonflydb/dragonflyAGENTS.md · 31k | AGENTS.md | setupbuildtestlint-format+10 | 96/100 | 13 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| pytorch/pytorch.github/copilot-instructions.md · 102k | Copilot instructions | setupbuildteststyle+5 | 100/100 | 14 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 25 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 14 days ago | |
| iloveitaly/llm-ide-rules.github/copilot-instructions.md · 13 | Copilot instructions | teststyledo-notagent-behaviour+1 | 92/100 | 14 days ago | |
| bytedance/deer-flow.github/copilot-instructions.md · 80k | Copilot instructions | setupbuildtestlint-format+6 | 89/100 | 14 days ago | |
| gasbasd/mtg-utils.github/copilot-instructions.md · 0 | Copilot instructions | setupbuildtestlint-format+3 | 89/100 | 8 days ago | |
| tesseract-ocr/tesseract.github/copilot-instructions.md · 76k | Copilot instructions | setupbuildtestlint-format+5 | 89/100 | 14 days ago | |
| Significant-Gravitas/AutoGPT.github/copilot-instructions.md · 187k | Copilot instructions | setupbuildtestlint-format+10 | 88/100 | 9 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/dragonflydb-dragonfly-github-instructions-code-review-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.