A protocol, and an implementation with tests.