You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,42 @@ dbx sync -g django
164
164
dbx sync -a
165
165
```
166
166
167
+
**Spec Sync:**
168
+
169
+
Keep driver spec tests in sync with the [MongoDB specifications repository](https://github.com/mongodb/specifications):
170
+
171
+
```bash
172
+
# Check which specs are out of date
173
+
dbx spec status
174
+
175
+
# Sync all specs (pure file copy from specifications → test/)
176
+
dbx spec sync
177
+
178
+
# Sync specific specs
179
+
dbx spec sync crud sessions change-streams
180
+
181
+
# Sync and immediately apply all patches
182
+
dbx spec sync --apply-patches
183
+
184
+
# List active patches (tests excluded pending JIRA tickets)
185
+
dbx spec patch list
186
+
187
+
# Verify all patches still apply cleanly
188
+
dbx spec patch verify
189
+
190
+
# Create a patch for unimplemented tests (after syncing)
191
+
dbx spec patch create PYTHON-1234
192
+
193
+
# Remove a patch once the feature is implemented
194
+
dbx spec patch remove PYTHON-1234
195
+
```
196
+
197
+
The `dbx spec sync` command wraps `.evergreen/resync-specs.sh` in the driver repo, auto-detecting the `specifications` repo from your config. Patches in `.evergreen/spec-patch/PYTHON-XXXX.patch` are reverse-applied (`git apply -R`) to exclude tests for features not yet implemented; each patch is named after a pre-existing JIRA ticket.
198
+
199
+
The weekly bot PR (`[Spec Resync] MM-DD-YYYY`) is produced by this same file-copy operation. To reproduce it locally: `dbx spec sync` on `main`.
200
+
201
+
See the [full spec sync documentation](https://dbx-python-cli.readthedocs.io/en/latest/features/spec-sync.html) for details.
Copy file name to clipboardExpand all lines: docs/features/spec-sync.rst
+37-2Lines changed: 37 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -209,7 +209,7 @@ Compares JSON spec files in the driver repo against the local ``specifications``
209
209
-r, --repo Driver repository to inspect [default: mongo-python-driver]
210
210
--specs-dir Path to the MongoDB specifications repo (overrides auto-detection)
211
211
212
-
212
+
dbx spec patch list
213
213
~~~~~~~~~~~~~~~~~~~
214
214
215
215
Lists all active patch files and the test files each one affects. Add ``-v`` to see the individual filenames.
@@ -267,10 +267,42 @@ Runs ``git apply -R --allow-empty --whitespace=fix`` on all ``.evergreen/spec-pa
267
267
dbx spec patch apply -r django-mongodb-backend
268
268
dbx spec patch apply --dry-run # list what would be applied
269
269
270
+
dbx spec patch verify
271
+
~~~~~~~~~~~~~~~~~~~~~
272
+
273
+
Checks each ``.evergreen/spec-patch/*.patch`` file to confirm it still applies cleanly against the current working tree. Runs ``git apply --check -R`` on every patch and reports whether each one is clean or stale. Exits non-zero if any patch is stale.
274
+
275
+
.. code-block:: bash
276
+
277
+
dbx spec patch verify
278
+
dbx spec patch verify -r django-mongodb-backend
279
+
280
+
**Example output:**
281
+
282
+
.. code-block:: text
283
+
284
+
Verifying patches in mongo-python-driver:
285
+
✅ PYTHON-2673
286
+
✅ PYTHON-4261
287
+
❌ PYTHON-4918 [stale — does not apply cleanly]
288
+
289
+
1 stale patch(es) found.
290
+
291
+
A patch becomes stale when the spec file it covers has been changed since the patch was created — for example, because a previous resync PR already incorporated part of those changes, or because the upstream file was renamed or removed. Stale patches should be removed (``dbx spec patch remove``) or recreated (``dbx spec patch remove`` + sync + ``dbx spec patch create``).
292
+
270
293
Reviewing Automated Spec Sync PRs
271
294
----------------------------------
272
295
273
-
The ``mongodb-drivers-pr-bot`` opens a weekly pull request (e.g. *[Spec Resync] 04-13-2026*) that runs ``resync-all-specs.py`` against the latest ``specifications`` repo and submits the result. The PR body summarises three things you need to triage:
296
+
The ``mongodb-drivers-pr-bot`` opens a weekly pull request (e.g. *[Spec Resync] 04-13-2026*) that runs ``resync-all-specs.py`` against the latest ``specifications`` repo and submits the result.
297
+
298
+
**Key point:** a spec resync is a pure file copy — ``resync-specs.sh`` copies JSON test files from ``specifications`` into ``test/`` with no logic or decisions. The diff in the PR is fully reproducible: check out ``main`` and run ``dbx spec sync`` to get identical output. Any CI failures on a resync PR are content-driven (the new spec tests exercise behaviour the driver hasn't implemented yet) and must be resolved before merging.
299
+
300
+
When tests fail on a resync PR, the options are:
301
+
302
+
* **Implement the feature** — fix the driver code so the new tests pass.
303
+
* **Add a patch** — create a ``.evergreen/spec-patch/PYTHON-XXXX.patch`` that reverse-applies the new tests until a ticket is resolved. The patch must be named after a *pre-existing* JIRA ticket.
304
+
305
+
The PR body summarises three things you need to triage:
274
306
275
307
* **Changed specs** — spec test files that were updated upstream and need review
276
308
* **Patch errors** — existing ``.evergreen/spec-patch/`` files that no longer apply cleanly
@@ -320,6 +352,9 @@ Patch errors mean a patch file references test content that no longer matches wh
320
352
# stale paths that no longer exist after a rename/removal upstream
321
353
dbx -v spec patch list
322
354
355
+
# Check each patch individually — reports ✅ clean or ❌ stale
0 commit comments