Skip to content

Sync Gateway 4.x: version vectors (CV) instead of revtree _rev - #14

Merged
Fujio-Turner merged 1 commit into
masterfrom
sg-4.x
Nov 17, 2026
Merged

Fujio-Turner merged 1 commit into
masterfrom
sg-4.x

Conversation

@Fujio-Turner

Copy link
Copy Markdown
Owner

Summary

Moves the tester to Sync Gateway 4.x version vectors. Documents are now versioned by their Current Version (_cv, e.g. 18e8e11501350000@+RTUz3ZWvU8ktL6AuG0csA), not by the revision-tree _rev. The 3.x code is kept on the sg-3.x-rest branch.

Version vector changes

  • PUT sends the document's current _cv in the body. DELETE sends ?rev=<URL-encoded CV>. CVs contain @, + and /, and an unencoded + gets a 400.
  • Any _rev, _cv or _revisions in input JSON files is stripped. The tester always sends the live CV.
  • CHANGES adds version_type=cv, so rows show {"cv": ...}.
  • GET_RAW logs the _vv xattr (src, ver, cvCas).
  • New CONFLICT / CONFLICT_ADMIN operation: writes with a stale CV and logs [success] when SG returns 409.
  • Logs a warning if the target SG is older than 4.x.

Other improvements

  • Failed requests log the HTTP status and SG's reason (for example the sync function's forbidden message) where they used to log null. The [success]/[failed] log format is unchanged.
  • If a user can write a doc but not read it, the tester reads the CV through the admin port, so the write is still tested.
  • Fixes: the input doc was mutated across users; CHANGES and PURGE ignored scope and collection; the default sgAdminPassword and logPathToWriteTo values were swapped.
  • PURGE and GET_RAW run once per doc as admin.
  • The operation loop is refactored into one method per operation.
  • Tests use a temp dir (they previously deleted jsons/) and cover the 4.x behaviour. There are 20 tests and flake8 passes.
  • docker/ adds a local stack: Couchbase Server 8.0.3, SG 4.1.2, a sample sync function and user bob.
  • README gets an SG 4.x section (3.x vs 4.x table) and Docker instructions.

Test plan

  • pytest: 20 passed
  • flake8 clean
  • End to end against SG 4.1.2 in Docker (docker/setup.sh) with the default config.json, and with test docs that hit 403 (missing role, admin required, sync function throw), 404 and 409

🤖 Generated with Claude Code

- PUT sends the current _cv in the body; DELETE sends ?rev=<URL-encoded CV>
- Strip _rev/_cv/_revisions from input docs before writing
- CHANGES uses version_type=cv; GET_RAW logs the _vv xattr
- New CONFLICT / CONFLICT_ADMIN op: stale CV write, expects 409
- Failed requests log HTTP status + SG reason instead of null
- Fall back to admin read for CV when a user can write but not read
- Fix: input doc mutated across users; CHANGES/PURGE ignored scope/collection;
  swapped default sgAdminPassword/logPathToWriteTo
- PURGE and GET_RAW run once per doc as admin
- Refactor operation loop into per-operation methods
- Tests use a temp dir (no longer delete jsons/), cover 4.x behaviour
- docker/ stack: Couchbase Server 8.0.3 + Sync Gateway 4.1.2
- README: SG 4.x section, Docker instructions; CI triggers on sg-4.x

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fujio-Turner
Fujio-Turner merged commit 3f8d747 into master Nov 17, 2026
4 checks passed
Fujio-Turner added a commit that referenced this pull request Nov 17, 2026
main now matches master (including the SG 4.x version-vector work from #14).
Everything only on main was already superseded on master: superLinter.yml
(replaced by main.yml), the old test/ dir (now tests/), jsons/job:12345.json
(renamed to job-12345.json), and an older example sync function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fujio-Turner Fujio-Turner mentioned this pull request Nov 17, 2026
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant