From cf87f28265e369547a741fd61fd5746275d54114 Mon Sep 17 00:00:00 2001 From: Valentin Kovalenko Date: Thu, 30 Jul 2026 18:49:10 -0600 Subject: [PATCH] Add code design rules for AI --- .agents/references/code-design.md | 11 +++++++++++ AGENTS.md | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 .agents/references/code-design.md diff --git a/.agents/references/code-design.md b/.agents/references/code-design.md new file mode 100644 index 0000000000..336f924551 --- /dev/null +++ b/.agents/references/code-design.md @@ -0,0 +1,11 @@ +--- +name: code-design +description: Design rules for implementation code in the MongoDB Java Driver. Use when adding or modifying an internal program element, or changing the implementation of a public API program element. +--- +# Code Design + +## Executors + +- When instantiating an executor, prefer the `MongoThreadPoolExecutor` and `MongoScheduledThreadPoolExecutor` implementations. +- Any task executed, submitted, or scheduled via an executor must not allow an `Exception` to be propagated; + `Error`s should generally not be caught, but if they are, they must still be propagated. diff --git a/AGENTS.md b/AGENTS.md index 6924f1b138..7f7a4928c9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,6 +25,7 @@ The default branch is `main` (not `master`). Always use `main` when comparing, d - Preserve existing comments — only remove if provably incorrect - No rewrites without explicit permission - When stuck or uncertain: stop, explain, propose alternatives, ask +- When authoring or reviewing changes: consult the relevant `.agents/references/` file for each area the changes touch ## Build @@ -71,6 +72,12 @@ public API classes must be thread-safe unless annotated otherwise. See [`.agents/references/api-design`](.agents/references/api-design.md) for stability annotations, design principles, and the full nullability and thread safety conventions. +## Code Design + +Applies to implementation code — internal packages, method bodies, and private or package-access program elements. + +See [`.agents/references/code-design`](.agents/references/code-design.md) for the rules. + ## Do Not Modify Without Human Approval - Wire protocol / authentication handshakes (`com.mongodb.internal.connection`)