Session Guarantees Check
Session Guarantees Check
Session guarantees describe what a single client should observe over time. You are given a sequence of operations for a single session on one key. Each operation includes the version observed or produced by the system.
Guarantees:
- Read Your Writes (RYW): every read must see at least the latest write from the same session.
- Monotonic Reads (MR): read versions must be non-decreasing over time.
- Monotonic Writes (MW): write versions must be non-decreasing over time.
- Writes Follow Reads (WFR): each write must be at least the latest read version previously observed by the session.
Return booleans indicating whether each guarantee holds for the entire session.
Types
type Op struct {
Kind string // "read" or "write"
Version int
}
Function signature
func SessionGuarantees(ops []Op) (ryw bool, mr bool, mw bool, wfr bool)
Example
ops = [
write v=5,
read v=4,
read v=6,
write v=7,
]
RYW = false (read 4 < last write 5)
MR = true
MW = true
WFR = true
Constraints
0 <= len(ops) <= 1000000 <= Version <= 1_000_000
Run tests to see results
No issues detected