startsWith

fun startsWith(prefix: Key): Boolean

Whether this key begins with prefix. An empty prefix matches every key.

This is the whole of what a prefix range needs, and it exists because the arithmetic does not work. The obvious spelling of "every key under p" is a range, and this API has no bound that can express one: [p, q] is inclusive at both ends, while a prefix range's upper end is inherently exclusive — and there is no inclusive one to reach for, because keys have no maximum length, so p, p + 0x00, p + 0xFF, p + 0xFF 0xFF … continue without a greatest element. Raising the prefix's last byte gives the exclusive bound and is therefore exactly one key too generous when it is handed to an inclusive to: scanning [receipt/, receipt0] returns receipt0, which is not under receipt/ at all.

That failure is silent — a scan that returns one key too many, a deleteRange that retires a neighbouring namespace's first key — so the engine does not offer the arithmetic and asks callers to name the prefix instead. See DocumentStore.scanPrefix and DocumentStore.deletePrefix, which are the supported way to say it.