Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(AGENTS.md): document Rust unit test layout conventions

Steven Enamakelcf8cfb0943cb
diff --git a/AGENTS.md b/AGENTS.md
index a70864f89a..a3ecd63200 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -131,6 +131,16 @@ coverage must be at least 80 percent.
- Frontend unit tests are colocated as `*.test.ts` or `*.test.tsx` under
`app/src/`. Use Vitest and test behavior rather than implementation.
+- Rust unit tests are never inline. Put them in a sibling `<module>_tests.rs`
+ (`mod_tests.rs` beside a `mod.rs`) declared at the bottom of the module with
+ `#[cfg(test)]` and `#[path = "<module>_tests.rs"]` above `mod tests;`. The file
+ starts with `use super::*;` and carries no `#[cfg(test)]` of its own. Never name
+ one `test.rs`, `tests.rs` or `<module>_test.rs`, and never write an inline
+ `#[cfg(test)] mod tests { ... }` (`pnpm rust:layout` fails on both). The same
+ rule binds every `vendor/` submodule: `node scripts/externalize-inline-tests.mjs
+ <repo-root> --write` converts one mechanically, and a crate root directly in
+ `src/bin/` keeps its tests in `src/bin/<stem>/` because Cargo builds any `.rs`
+ placed straight in `src/bin/` as a binary.
- Rust domain tests live beside their modules. Use
`scripts/test-rust-with-mock.sh` for tests that need the shared mock backend.
- JSON-RPC behavior belongs in Rust E2E tests, commonly