diff --git a/.agents/skills/api-design/SKILL.md b/.agents/skills/api-design/SKILL.md new file mode 100644 index 00000000000..23e89ebe457 --- /dev/null +++ b/.agents/skills/api-design/SKILL.md @@ -0,0 +1,31 @@ +--- +name: api-design +description: API stability annotations, design principles, and patterns for the MongoDB Java Driver. Use when adding or modifying public API surface — new classes, methods, interfaces, or changing method signatures. +--- +# API Design + +## API Stability Annotations + +- `@Alpha` — Early development, may be removed. + Not recommended for production use. +- `@Beta` — Subject to change or removal. + It's not recommended for Libraries to depend on these APIs. +- `@Evolving` — May add abstract methods in future releases. + Safe to use, but implementing/extending bears upgrade risk. +- `@Sealed` — Must not be extended or implemented by consumers. + Safe to use, but not to subclass. +- `@Deprecated` — Supported until next major release but should be migrated away from. + +## Design Principles + +- **Deep modules:** Prefer simple interfaces with powerful implementations over shallow wrappers. +- **Information hiding:** Bury complexity behind simple interfaces. +- **Pull complexity downward:** Make the implementer work harder so callers work less. +- **General-purpose over special-case:** Fewer flexible methods over many specialized ones. +- **Define errors out of existence:** Design APIs so errors cannot happen rather than detecting and handling them. + +## Key Patterns + +- Static factory methods: `Filters.eq()`, `Updates.set()`, `Aggregates.match()` +- Fluent builders: `MongoClientSettings.builder()` is the primary entry point +- Abstract core with pluggable transports diff --git a/.agents/skills/evergreen/SKILL.md b/.agents/skills/evergreen/SKILL.md new file mode 100644 index 00000000000..37b73a03f78 --- /dev/null +++ b/.agents/skills/evergreen/SKILL.md @@ -0,0 +1,36 @@ +--- +name: evergreen +description: Evergreen CI infrastructure, configuration validation. Use when modifying .evergreen/ config, preparing to submit changes or understanding the Evergreen test matrix. +disable-model-invocation: true +allowed-tools: Bash(evergreen *) +--- +# Evergreen + +## Evergreen (MongoDB Internal CI) + +Primary CI runs on MongoDB’s Evergreen system. +Configuration lives in `.evergreen/`. + +- Do not modify `.evergreen/` configuration without review +- Evergreen runs the full test matrix across MongoDB versions, OS platforms, and JDK versions + +## Validating Evergreen Configuration + +After modifying `.evergreen/` files, validate the config locally: + +```bash +evergreen validate .evergreen/.evg.yml +``` + +Always run this before submitting changes to `.evergreen/` to catch syntax errors and invalid task definitions. + +## Testing with a Patch Build + +To test your changes on Evergreen before merging, create a patch build: + +```bash +evergreen patch -u +``` + +This uploads your uncommitted and committed local changes as a patch build on Evergreen, allowing you to run the full CI +test matrix against your branch. diff --git a/.agents/skills/project-guide/SKILL.md b/.agents/skills/project-guide/SKILL.md new file mode 100644 index 00000000000..a068414426e --- /dev/null +++ b/.agents/skills/project-guide/SKILL.md @@ -0,0 +1,63 @@ +--- +name: project-guide +description: Project structure, dependency graph, and guide for finding the right project to work in. Use when starting a task and unsure which project owns the relevant code, or when you need to understand cross-project dependencies. +--- +# Project Guide + +## Project Structure + +| Project | Purpose | +| --- | --- | +| `bson` | BSON library (core serialization) | +| `bson-kotlin` | Kotlin BSON extensions | +| `bson-kotlinx` | Kotlin serialization BSON codec | +| `bson-record-codec` | Java record codec support | +| `bson-scala` | Scala BSON extensions | +| `driver-core` | Core driver internals (connections, protocol, operations) | +| `driver-sync` | Synchronous Java driver | +| `driver-legacy` | Legacy MongoDB Java driver API | +| `driver-reactive-streams` | Reactive Streams driver | +| `driver-kotlin-coroutine` | Kotlin Coroutines driver | +| `driver-kotlin-extensions` | Kotlin driver extensions | +| `driver-kotlin-sync` | Kotlin synchronous driver | +| `driver-scala` | Scala driver | +| `mongodb-crypt` | Client-side field-level encryption | +| `bom` | Bill of Materials for dependency management | +| `testing` | Shared test resources and MongoDB specifications | +| `buildSrc` | Gradle convention plugins and build infrastructure | +| `driver-benchmarks` | JMH and custom performance benchmarks (not published) | +| `driver-lambda` | AWS Lambda test application (not published) | +| `graalvm-native-image-app` | GraalVM Native Image compatibility testing (not published) | + +## Dependency Graph (simplified) + +``` +bson + ├── bson-kotlin + ├── bson-kotlinx + ├── bson-record-codec + ├── bson-scala + └── driver-core + ├── driver-sync + │ ├── driver-legacy + │ ├── driver-kotlin-sync + │ └── driver-lambda + ├── driver-reactive-streams + │ ├── driver-kotlin-coroutine + │ └── driver-scala + └── driver-kotlin-extensions +``` + +## Finding the Right Module + +- **BSON serialization/codecs:** `bson` (or `bson-kotlin`/`bson-kotlinx`/`bson-scala` for language-specific) +- **Query builders, filters, aggregates:** `driver-core` (`com.mongodb.client.model`) +- **Sync Java API:** `driver-sync` +- **Reactive API:** `driver-reactive-streams` +- **Kotlin coroutines:** `driver-kotlin-coroutine` +- **Kotlin DSL builders:** `driver-kotlin-extensions` +- **Scala driver:** `driver-scala` +- **Connection, protocol, auth internals:** `driver-core` (`com.mongodb.internal.*`) +- **Build plugins, formatting, test infra:** `buildSrc` + +Each module has its own `AGENTS.md` with module-specific packages, patterns, and notes. diff --git a/.agents/skills/spec-tests/SKILL.md b/.agents/skills/spec-tests/SKILL.md new file mode 100644 index 00000000000..5ba9041cfbc --- /dev/null +++ b/.agents/skills/spec-tests/SKILL.md @@ -0,0 +1,40 @@ +--- +name: spec-tests +description: How to work with MongoDB specification tests — structure, rules, and adding new spec test support. Use when implementing or modifying behavior defined by the MongoDB Driver Specifications. +--- +# MongoDB Specification Tests + +## Overview + +The driver implements the [MongoDB Driver Specifications](https://github.com/mongodb/specifications). +Specification test data files live in `testing/resources/specifications/` — a git submodule. + +## Rules + +- **Do not modify spec test data files** (JSON/YAML in `testing/resources/specifications/`) — managed upstream +- Test runners (Java code) may be modified to fix bugs or add support for new spec tests +- Update the submodule via `git submodule update` + +## Structure + +Spec test data is organized by specification area: + +- CRUD, SDAM, auth, CSFLE, retryable operations, and more +- Each spec area has JSON/YAML test data files defining inputs and expected outputs +- Driver test runners parse these files and execute against the driver + +## Test Data Location + +``` +testing/ + resources/ + specifications/ # Git submodule — do not edit directly + logback-test.xml # Shared logback configuration for tests +``` + +## Adding Spec Test Support + +1. Check `testing/resources/specifications/` for the relevant spec test data +2. Find existing test runners in the module (look for `*SpecificationTest*` or similar) +3. Extend existing patterns — each module handles spec tests slightly differently +4. Ensure tests run with `./gradlew check` or the module’s test task diff --git a/.agents/skills/style-reference/SKILL.md b/.agents/skills/style-reference/SKILL.md new file mode 100644 index 00000000000..fa9adfe85f2 --- /dev/null +++ b/.agents/skills/style-reference/SKILL.md @@ -0,0 +1,55 @@ +--- +name: style-reference +description: Detailed code style rules for Java, Kotlin, Scala, and Groovy in the MongoDB Java Driver. Use when you need specific formatting rules beyond the basics in root AGENTS.md — e.g., line length, import ordering, brace style. +--- +# Style Reference + +## Java Style Rules + +- **Max line length:** 140 characters +- **Indentation:** 4 spaces (no tabs) +- **Line endings:** LF (Unix) +- **Charset:** UTF-8 +- **Star imports:** Prohibited (AvoidStarImport) +- **Final parameters:** Required (FinalParameters checkstyle rule) +- **Braces:** Required for all control structures (NeedBraces) +- **Else placement:** `} else {` on the same line (Palantir Java Format default) +- **Copyright header:** Every Java / Kotlin / Scala file must contain `Copyright 2008-present MongoDB, Inc.` +- **Formatter:** Palantir Java Format + +## Kotlin Style Rules + +- **Formatter:** ktfmt dropbox style, max width 120 +- **Static analysis:** detekt + +## Scala Style Rules + +- **Formatter:** scalafmt +- **Supported versions:** 2.11, 2.12, 2.13, 3 (default: 2.13) + +## Groovy Style Rules + +- **Static analysis:** CodeNarc + +## Javadoc / KDoc / Scaladoc + +- All public classes and interfaces **must** have class-level Javadoc (enforced by checkstyle) +- Public methods should have Javadoc with `@param`, `@return`, and `@since` tags +- Use `@since X.Y` to indicate the version when the API was introduced +- Use `@mongodb.driver.manual