Skip to content

Commit e91b646

Browse files
committed
Further agents improvements - feedback from glean
1 parent 022bff8 commit e91b646

17 files changed

Lines changed: 233 additions & 116 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ local.properties
5555
# security-sensitive files
5656
*.gpg
5757

58+
# per-developer agent overrides
59+
.AGENTS.md
60+
5861
# bin build directories
5962
**/bin
6063

AGENTS.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# AGENTS.md - MongoDB Java Driver
22

33
Official MongoDB JVM driver monorepo (Java, Kotlin, Scala).
4-
Implements the
5-
[MongoDB Driver Specifications](https://github.com/mongodb/specifications).
6-
Each module has its own `AGENTS.md` with module-specific guidance.
4+
All changes require human review.
5+
Breaking changes to public API require a major version bump — always warn if binary
6+
compatibility is affected.
7+
Also consult `.AGENTS.md` / `~/.AGENTS.md` if present for local agent settings.
8+
9+
See [`.agents/skills/project-guide`](.agents/skills/project-guide/SKILL.md) for module
10+
structure and dependency graph.
11+
Each module has its own `AGENTS.md`.
712

813
## Core Rules
914

@@ -15,25 +20,24 @@ Each module has its own `AGENTS.md` with module-specific guidance.
1520
Only remove if provably incorrect.
1621
- No rewrites without explicit permission.
1722
- When stuck or uncertain: stop, explain, propose alternatives, ask.
18-
- All `com.mongodb.internal.*` / `org.bson.internal.*` is private API — never expose in
19-
public APIs.
2023

2124
## Build
2225

23-
- Gradle with Kotlin DSL. Build JDK: 17+. Source baseline: Java 8.
24-
- Versions: `gradle/libs.versions.toml`. Plugins:
25-
`buildSrc/src/main/kotlin/conventions/`.
26+
Gradle with Kotlin DSL. Build JDK: 17+. Source baseline: Java 8. Versions in
27+
`gradle/libs.versions.toml`.
2628

2729
```bash
2830
./gradlew check # Full validation (format + static checks + tests)
2931
./gradlew :driver-core:test # Single module tests
3032
./gradlew integrationTest -Dorg.mongodb.test.uri="mongodb://localhost:27017"
3133
```
3234

33-
## Formatting
35+
## Style
3436

35-
`check` runs `spotlessApply` automatically.
37+
`check` runs `spotlessApply` automatically — formatting is enforced.
3638
Do not reformat outside your changes.
39+
See [`.agents/skills/style-reference`](.agents/skills/style-reference/SKILL.md) for full
40+
rules.
3741

3842
- No `System.out.println` / `System.err.println` — use SLF4J
3943
- No `e.printStackTrace()` — use proper error handling
@@ -48,16 +52,30 @@ Do not reformat outside your changes.
4852
- Unit tests must not require a running MongoDB instance.
4953
- Descriptive method names or `@DisplayName`. Clean up in `@AfterEach`.
5054

51-
## Safety — Do Not Modify Without Review
55+
## API
56+
57+
All `com.mongodb.internal.*` / `org.bson.internal.*` is private API — never expose in
58+
public APIs. See [`.agents/skills/api-design`](.agents/skills/api-design/SKILL.md) for
59+
stability annotations and design principles.
60+
61+
## Do Not Modify Without Human Approval
5262

53-
- Wire protocol / authentication handshakes
54-
- Security-critical encryption code
63+
- Wire protocol / authentication handshakes (`com.mongodb.internal.connection`)
64+
- Connection pool core code (`com.mongodb.internal.connection.pool`)
65+
- Security-critical encryption code / JNA bindings (`mongodb-crypt`)
5566
- Public API contracts (breaking changes need major version bump)
5667
- BSON specification compliance
57-
- Credentials, secrets, `.evergreen/` config, release scripts
68+
- Spec test data submodule (`testing/resources/specifications/`)
69+
- Release/versioning scripts, `.evergreen/` config, credentials/secrets
70+
71+
See [`.agents/skills/evergreen`](.agents/skills/evergreen/SKILL.md) for CI validation
72+
and patch builds.
5873

5974
## Before Submitting
6075

6176
```bash
62-
./gradlew doc check scalaCheck
77+
./gradlew doc check scalaCheck # Docs + formatting (spotlessApply) + static checks + all tests
6378
```
79+
80+
Note: `check` includes `spotlessApply` for all modules.
81+
`buildSrc` uses `spotlessCheck` instead (no auto-fix).

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ $ mongod --dbpath ./data/db --logpath ./data/mongod.log --port 27017 --logappend
125125
If you encounter `"Too many open files"` errors when running the tests then you will need to increase
126126
the number of available file descriptors prior to starting mongod as described in [https://www.mongodb.com/docs/manual/reference/ulimit/](https://www.mongodb.com/docs/manual/reference/ulimit/)
127127

128+
## AI Agent Configuration
129+
130+
This repository uses [agentskills.io](https://agentskills.io) conventions for AI coding agent
131+
instructions. `AGENTS.md` is the canonical source of truth — tool-specific files like `CLAUDE.md`
132+
are generated references.
133+
134+
### Adding a nested AGENTS.md
135+
136+
1. Create an `AGENTS.md` in the target directory.
137+
2. Run `scripts/symlink-claude-md.sh` to generate the companion `CLAUDE.md`.
138+
3. Stage and commit both files.
139+
128140
## IntelliJ IDEA
129141

130142
A couple of manual configuration steps are required to run the code in IntelliJ:

bson-kotlin/AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ Kotlin extensions for the BSON library, providing idiomatic Kotlin codec support
44

55
**Depends on:** `bson`
66

7+
- Work here if: modifying Kotlin-specific BSON codecs or inline reified functions
8+
79
## Key Packages
810

911
- `org.bson.codecs.kotlin` — Kotlin-specific codecs with inline reified functions
12+
13+
## Build & Test
14+
15+
```bash
16+
./gradlew :bson-kotlin:test
17+
./gradlew :bson-kotlin:check
18+
```
19+
20+
For global rules see [root AGENTS.md](../AGENTS.md).

bson-kotlinx/AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@ Kotlinx serialization integration for BSON, providing a pluggable serialization
44

55
**Depends on:** `bson`
66

7+
- Work here if: modifying the kotlinx-serialization BSON codec integration
8+
79
## Key Packages
810

911
- `org.bson.codecs.kotlinx` — Kotlinx serialization BSON format support
1012
- `org.bson.codecs.kotlinx.utils` — Helper utilities
13+
14+
## Build & Test
15+
16+
```bash
17+
./gradlew :bson-kotlinx:test
18+
./gradlew :bson-kotlinx:check
19+
```
20+
21+
For global rules see [root AGENTS.md](../AGENTS.md).

bson-record-codec/AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ Java record codec support for BSON serialization.
55

66
**Depends on:** `bson`
77

8+
- Work here if: modifying Java record serialization support
9+
810
## Key Packages
911

1012
- `org.bson.codecs.record``RecordCodecProvider` and record field accessors
13+
14+
## Build & Test
15+
16+
```bash
17+
./gradlew :bson-record-codec:test
18+
./gradlew :bson-record-codec:check
19+
```
20+
21+
For global rules see [root AGENTS.md](../AGENTS.md).

bson-scala/AGENTS.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ macro-based codecs.
55

66
**Depends on:** `bson`
77

8-
**Supported Scala versions:** 2.11, 2.12, 2.13, 3 (configured in root
9-
`gradle.properties`). Default: 2.13.
8+
**Supported Scala versions:** 2.11, 2.12, 2.13, 3 (default: 2.13, configured in root
9+
`gradle.properties`).
1010

11-
See [README.md](./README.md) for full details on directory layout, formatting, and
12-
testing commands.
11+
- Work here if: modifying Scala BSON wrappers, macro codecs, or Scala collection support
1312

1413
## Key Packages
1514

1615
- `org.mongodb.scala.bson` — Core Scala BSON wrappers
1716
- `org.mongodb.scala.bson.codecs` — Macro-based codecs (Scala 2/3)
18-
- `org.mongodb.scala.bson.collection` — Immutable/mutable collection support
19-
- `org.mongodb.scala.bson.annotations` — Field annotations
2017

21-
## Before Submitting
18+
## Build & Test
2219

2320
```bash
24-
./gradlew spotlessApply # Fix formatting
25-
./gradlew :bson-scala:scalaCheck # Static checks + tests (default Scala version)
26-
./gradlew :bson-scala:scalaCheck -PscalaVersion=<version> # Test specific Scala version
21+
./gradlew :bson-scala:test
22+
./gradlew :bson-scala:scalaCheck # Static checks + tests (default Scala version)
23+
./gradlew :bson-scala:scalaCheck -PscalaVersion=<version> # Test specific Scala version
2724
```
25+
26+
For global rules see [root AGENTS.md](../AGENTS.md).
27+
See [README.md](./README.md) for directory layout details.

bson/AGENTS.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
# AGENTS.md - bson
22

3-
Core BSON (Binary JSON) library.
4-
This is the foundation module — all other modules depend on it.
3+
Core BSON (Binary JSON) library — the foundation module.
4+
All other modules depend on it.
55

66
**Depends on:** None (foundation module)
77

8-
## Key Packages
8+
- Work here if: adding/modifying BSON types, codecs, JSON conversion, or binary I/O
9+
- Do not: expose `org.bson.internal` types in public API
910

10-
- `org.bson` — Core BSON value types (`BsonDocument`, `BsonValue`, `BsonReader`,
11-
`BsonWriter`)
12-
- `org.bson.codecs` — Codec framework (`Encoder`, `Decoder`, `Codec`)
13-
- `org.bson.codecs.configuration` — Codec registry and provider infrastructure
14-
(`CodecRegistry`, `CodecProvider`)
15-
- `org.bson.codecs.pojo` — POJO codec support with conventions and property modeling
16-
- `org.bson.codecs.jsr310` — Java 8+ date/time codec support
17-
- `org.bson.json` — JSON conversion (`JsonReader`, `JsonWriter`, `JsonMode`)
18-
- `org.bson.io` — Binary I/O (`ByteBuffer`, `OutputBuffer`)
19-
- `org.bson.types` — Legacy types (`ObjectId`, `Decimal128`, etc.)
20-
- `org.bson.internal` — Private API (vector support, encoding utilities)
11+
## Key Packages
2112

22-
## Notes
13+
- `org.bson` — Core types (`BsonDocument`, `BsonValue`, `BsonReader`, `BsonWriter`)
14+
- `org.bson.codecs` — Codec framework (`Encoder`, `Decoder`, `Codec`, `CodecRegistry`)
15+
- `org.bson.codecs.pojo` — POJO codec support
16+
- `org.bson.json` — JSON conversion (`JsonReader`, `JsonWriter`)
17+
- `org.bson.internal` — Private API — do not expose
2318

24-
- JUnit 5 + Spock (Groovy) tests in both unit and functional dirs
19+
## Build & Test
2520

26-
## Key Patterns
21+
```bash
22+
./gradlew :bson:test
23+
./gradlew :bson:check
24+
```
2725

28-
- Codec-based serialization with type-safe `BsonValue` hierarchy
29-
- `BsonDocument` implements `Map<String, BsonValue>`
30-
- All public types in `org.bson` — internal types in `org.bson.internal`
26+
For global rules see [root AGENTS.md](../AGENTS.md).
27+
For API design see [api-design skill](../.agents/skills/api-design/SKILL.md).

driver-core/AGENTS.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,31 @@ Largest and most complex module.
66
**Depends on:** `bson`, `bson-record-codec`, optionally `bson-kotlin`, `bson-kotlinx`,
77
`mongodb-crypt`
88

9-
## Key Packages (Public API)
10-
11-
- `com.mongodb.client.model` — Operation models: `Filters`, `Updates`, `Projections`,
12-
`Aggregates`, `Sorts`, `Indexes`
13-
- `com.mongodb.client.model.search` — Atlas Search configuration
14-
- `com.mongodb.client.result` — Operation result types (`InsertOneResult`,
15-
`DeleteResult`, etc.)
16-
- `com.mongodb.connection``ClusterSettings`, `ClusterDescription`
17-
- `com.mongodb.event` — Listeners for commands, connections, servers, cluster events
18-
- `com.mongodb.session``ClientSession` interface
19-
- `com.mongodb.bulk``WriteModel` hierarchy
20-
21-
## Key Packages (Internal — Private API)
22-
23-
- `com.mongodb.internal.connection` — Socket, wire protocol, command execution
24-
- `com.mongodb.internal.operation` — Concrete operations (find, insert, aggregate, etc.)
25-
- `com.mongodb.internal.authentication` — SASL, SCRAM, X.509, OIDC
26-
- `com.mongodb.internal.async` — Async operation framework
27-
- `com.mongodb.internal.binding` — Server binding strategies
28-
- `com.mongodb.internal.client` — MongoClient/MongoDatabase/MongoCollection
29-
implementations
9+
- Work here if: modifying query builders (`Filters`, `Updates`, `Aggregates`),
10+
connection handling, wire protocol, server selection, or operation execution
11+
- Do not: block in async code paths, modify wire protocol or auth without human approval
12+
13+
## Key Packages
14+
15+
- `com.mongodb.client.model``Filters`, `Updates`, `Projections`, `Aggregates`,
16+
`Sorts`, `Indexes`
17+
- `com.mongodb.internal.connection` — Wire protocol, command execution (safety-critical)
18+
- `com.mongodb.internal.operation` — Concrete operations (find, insert, aggregate)
19+
- `com.mongodb.internal.authentication` — SASL, SCRAM, X.509, OIDC (safety-critical)
20+
21+
## Build & Test
22+
23+
```bash
24+
./gradlew :driver-core:test
25+
./gradlew :driver-core:check
26+
./gradlew :driver-core:generateMongoDriverVersion # If MongoDriverVersion is missing
27+
```
3028

3129
## Notes
3230

33-
- Most extensive test suite — JUnit 5 + Spock (Groovy) + Mockito.
31+
- Most extensive test suite — JUnit 5 + Spock + Mockito.
3432
Match surrounding patterns carefully.
35-
- `com.mongodb.internal.build.MongoDriverVersion` is auto-generated by the
36-
`com.github.gmazzo.buildconfig` Gradle plugin — run
37-
`./gradlew :driver-core:generateMongoDriverVersion` if missing
38-
- Never block in async code paths
39-
40-
## Key Patterns
33+
- `MongoDriverVersion` is auto-generated by the `com.github.gmazzo.buildconfig` plugin
4134

42-
- Static factory methods: `Filters.eq()`, `Updates.set()`, `Aggregates.match()`
43-
- Fluent builders: `MongoClientSettings.builder()` is the primary entry point for
44-
configuring clients
45-
- Abstract core with pluggable transports
35+
For global rules see [root AGENTS.md](../AGENTS.md).
36+
For API design see [api-design skill](../.agents/skills/api-design/SKILL.md).

driver-kotlin-coroutine/AGENTS.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ Kotlin Coroutines driver providing `suspend` function-based async API.
44

55
**Depends on:** `bson`, `driver-reactive-streams`, `bson-kotlin`
66

7+
- Work here if: modifying the Kotlin coroutine-based driver API
8+
- Do not: block in any code path — all suspend functions wrap `driver-reactive-streams`
9+
710
## Key Packages
811

912
- `com.mongodb.kotlin.client.coroutine` — Coroutine-based driver API (`MongoClient`,
1013
`MongoDatabase`, `MongoCollection`)
1114

12-
## Notes
15+
## Build & Test
16+
17+
```bash
18+
./gradlew :driver-kotlin-coroutine:test
19+
./gradlew :driver-kotlin-coroutine:check
20+
```
1321

14-
- Suspend functions wrapping `driver-reactive-streams` — never block
15-
- Built on `kotlinx-coroutines`
22+
For global rules see [root AGENTS.md](../AGENTS.md).

0 commit comments

Comments
 (0)