tree: add AGENTS.md router and improve AI instruction files

Add AGENTS.md as a minimal router that directs AI agents to the
relevant instruction files based on what they are editing.

Improve the instruction files:

- cpp.instructions.md: clarify seastarx.hh scope (headers, not
  "many files"), explain std::atomic restriction (single-shard
  model, not "blocking"), scope macros prohibition to new ad-hoc
  only, add coroutine exception propagation pattern, add invariant
  checking section preferring throwing_assert() over SCYLLA_ASSERT
  (issue #7871)
- python.instructions.md: demote PEP 8 to fallback after local
  style, clarify that only wildcard imports are prohibited
- copilot-instructions.md: show configure.py defaults to dev mode,
  add frozen toolchain section, clarify --no-gather-metrics applies
  to test.py, fix Python test paths to use .py extension, add
  license header guidance for new files

Closes scylladb/scylladb#29023
This commit is contained in:
Piotr Szymaniak
2026-04-01 21:19:05 +02:00
committed by Avi Kivity
parent f77ff28081
commit 378bcd69e3
4 changed files with 46 additions and 21 deletions

View File

@@ -25,6 +25,8 @@ applyTo: "**/*.{cc,hh}"
- Use `seastar::gate` for shutdown coordination
- Use `seastar::semaphore` for resource limiting (not `std::mutex`)
- Break long loops with `maybe_yield()` to avoid reactor stalls
- Most Scylla code runs on a single shard where atomics are unnecessary
- Use Seastar message passing for cross-shard communication
## Coroutines
```cpp
@@ -36,10 +38,16 @@ seastar::future<T> func() {
## Error Handling
- Throw exceptions for errors (futures propagate them automatically)
- In coroutines, use `co_await coroutine::return_exception_ptr()` or `co_return coroutine::exception()` to avoid the overhead of throwing
- In data path: avoid exceptions, use `std::expected` (or `boost::outcome`) instead
- Use standard exceptions (`std::runtime_error`, `std::invalid_argument`)
- Database-specific: throw appropriate schema/query exceptions
## Invariant Checking
- Prefer `throwing_assert()` (`utils/assert.hh`), it logs and throws instead of aborting
- Use `SCYLLA_ASSERT` where critical to system stability where no clean shutdown is possible, it aborts
- Use `on_internal_error()` for should-never-happen conditions that should be logged with backtrace
## Performance
- Pass large objects by `const&` or `&&` (move semantics)
- Use `std::string_view` for non-owning string references
@@ -68,7 +76,7 @@ seastar::future<T> func() {
- Use `#pragma once`
- Include order: own header, C++ std, Seastar, Boost, project headers
- Forward declare when possible
- Never `using namespace` in headers (exception: `using namespace seastar` is globally available via `seastarx.hh`)
- Never `using namespace` in headers. Exception: most headers include `seastarx.hh`, which provides `using namespace seastar` project-wide.
## Documentation
- Public APIs require clear documentation
@@ -101,10 +109,8 @@ seastar::future<T> func() {
- `malloc`/`free`
- `printf` family (use logging or fmt)
- Raw pointers for ownership
- `using namespace` in headers
- Blocking operations: `std::sleep`, `std::read`, `std::mutex` (use Seastar equivalents)
- `std::atomic` (reserved for very special circumstances only)
- Macros (use `inline`, `constexpr`, or templates instead)
- New ad-hoc macros (prefer `inline`, `constexpr`, or templates; established project macros like `SCYLLA_ASSERT` are fine)
## Testing
When modifying existing code, follow TDD: create/update test first, then implement.