UnreadableGrants

class UnreadableGrants(val probe: suspend () -> Unit, val probeWrite: suspend () -> Unit, val restore: suspend () -> Boolean)

What Durable.makeGrantsUnreadable did: the grants record is out of reach until restore runs.

One arm, and non-nullable. Unlike UnreadableKey there is no CannotOccur: a store that keeps its grants across a restart keeps them in a medium, and every medium can fail a read — a permission, a protection class, a closing connection. The store with nothing to fault is the one that keeps nothing, which is the fixture's KeepsNothing arm, and the property checks that it forgets. A nullable hook, or a CannotOccur arm here, would let the store this property exists to catch — one that reads a failed read as "no grants" — opt out by declaring it.

The rig leaves the medium able to take a new record, because that is the case that loses data: a medium that refused every write as well would refuse the mistaken rewrite on the store's behalf, and the property would pass a store that tried it. probeWrite is how the property checks it: a rig that faulted the whole directory instead of the one record would fail it.

What it cannot detect

Only the fault the rig produces: a store that refuses a permission failure correctly and reads an I/O error as "no grants" passes. And restore's answer is the fixture's own witness, so a fixture that always answered false would blind the write check. The read after the restore still catches a write that changed the record, but not one that rewrote the same grants.

Parameters

probe

reads the grants record straight off the medium, bypassing the store; while the record is unreadable it must throw. The property requires that it does, so a rig that broke nothing reds rather than passes.

probeWrite

writes a sibling record — never the grants record — straight to the medium through the same backend, in the same place, while the grants record is unreadable; it must return. The property requires that it does, so a rig that faulted the whole medium reds rather than leaves the rewrite check with nothing to catch.

restore

puts the record back within reach, and answers whether anything wrote, replaced or removed the record while it was unreadable. The suite calls it exactly once, in a finally.

Constructors

Link copied to clipboard
constructor(probe: suspend () -> Unit, probeWrite: suspend () -> Unit, restore: suspend () -> Boolean)

Properties

Link copied to clipboard
val probe: suspend () -> Unit
Link copied to clipboard
val probeWrite: suspend () -> Unit
Link copied to clipboard
val restore: suspend () -> Boolean