tests/core/properties.test.ts has three property-based tests over random event
sequences: no message is ever lost, no turn is emitted while a human holds the
conversation, and the dedupe window never grows past its bound.
There is a fourth property worth stating, and it is the one the library rests on:
a turn's deadline never lands past firstBufferedAt + maxWaitMs, whatever arrives
and in whatever order. It is what stops somebody who never stops typing from never
getting an answer.
Today that is covered by scenario tests in tests/core/typing.test.ts and
tests/core/turn.test.ts, which prove it for the sequences somebody thought to write
down.
Where to start
fast-check is already a dev dependency, and the file has the shape to copy. Generate a
sequence of message, typing and tick events with arbitrary timestamps, fold them
through reduce, and assert on deadline(state, policy) after every step where the
buffer is not empty.
Worth watching for: the property only says anything while something is buffered, and
firstBufferedAt is null when nothing is.
tests/core/properties.test.tshas three property-based tests over random eventsequences: no message is ever lost, no turn is emitted while a human holds the
conversation, and the dedupe window never grows past its bound.
There is a fourth property worth stating, and it is the one the library rests on:
a turn's deadline never lands past
firstBufferedAt + maxWaitMs, whatever arrivesand in whatever order. It is what stops somebody who never stops typing from never
getting an answer.
Today that is covered by scenario tests in
tests/core/typing.test.tsandtests/core/turn.test.ts, which prove it for the sequences somebody thought to writedown.
Where to start
fast-checkis already a dev dependency, and the file has the shape to copy. Generate asequence of
message,typingandtickevents with arbitrary timestamps, fold themthrough
reduce, and assert ondeadline(state, policy)after every step where thebuffer is not empty.
Worth watching for: the property only says anything while something is buffered, and
firstBufferedAtis null when nothing is.