Currently write_note / edit_note have no staleness check. If two agents edit the same note concurrently, last-write-wins and one side's changes are silently lost.
CouchDB already tracks _rev on every document. Suggestion:
- Return the
_rev (as an opaque revision token) from read_note / get_note_metadata.
- Accept an optional
expected_revision on write_note / edit_note. If provided and stale, reject with something like { error: "stale_revision", current_revision: "..." } so the caller can re-read and retry.
Optional keeps current ergonomics; opt-in gives careful agents a safety net.
Currently
write_note/edit_notehave no staleness check. If two agents edit the same note concurrently, last-write-wins and one side's changes are silently lost.CouchDB already tracks
_revon every document. Suggestion:_rev(as an opaquerevisiontoken) fromread_note/get_note_metadata.expected_revisiononwrite_note/edit_note. If provided and stale, reject with something like{ error: "stale_revision", current_revision: "..." }so the caller can re-read and retry.Optional keeps current ergonomics; opt-in gives careful agents a safety net.