test(zippychord): property-based test suite (documents a backspace under-count bug)#2100
Draft
nightscape wants to merge 1 commit into
Draft
test(zippychord): property-based test suite (documents a backspace under-count bug)#2100nightscape wants to merge 1 commit into
nightscape wants to merge 1 commit into
Conversation
nightscape
commented
Jun 24, 2026
| @@ -0,0 +1,75 @@ | |||
| //! Deterministic regression shrunk from the zippychord property tests. | |||
Contributor
Author
There was a problem hiding this comment.
Should we delete minimisation unit tests?
proptest-state-machine stores the seeds of failing tests, so these would reproduce as well.
| ); | ||
| } | ||
|
|
||
| // --- Leading-space chord non-determinism reproduction -------------------- |
Contributor
Author
There was a problem hiding this comment.
Should we delete minimisation unit tests?
proptest-state-machine stores the seeds of failing tests, so these would reproduce as well.
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub enum Tr { |
Contributor
Author
There was a problem hiding this comment.
Give this a longer readable name.
| pub enum Tr { | ||
| ChordExpansion { | ||
| target: Target, | ||
| press: Vec<char>, |
Contributor
Author
There was a problem hiding this comment.
Imo ChordExpansion should be even more granular: A Vector of (time_after_initial_keypress, KeyPress / KeyRelease)
nightscape
force-pushed
the
zippychord-pbt
branch
from
June 26, 2026 08:31
e8ef5d7 to
e44fcc3
Compare
nightscape
force-pushed
the
zippychord-pbt
branch
from
June 26, 2026 08:32
e44fcc3 to
fb4d27e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a stateful property-based test suite for
zippychord(usingproptest-state-machine), plus two small bug fixes the testing surfaced. Treats zippychord as the state machine it is: a generated reference model drives a realKanataSUT and asserts the net typed text after every transition.Commits
fix(zippychord)–zchd_resetdidn't clearzchd_same_hold_activation_count(only cleared on a clean all-keys-released). A reset mid-activation left it stale, and it gates the common-prefix backspacing logic.test(sim_tests)– clear the globalPRESSED_KEYSat the start of the sim helper, so the new state-machine test (which drives that global and can panic mid-scenario while shrinking) can't contaminate other tests.test(zippychord)– the property-based suite itself.The oracle (why this isn't circular)
The oracle is split between generator and reference: a
ChordExpansiontransition carries which chord it activates (so the expansion text is known by construction), while the reference state only does coarse placement (fresh append / followup replace / disabled passthrough / free-typing literal). It deliberately does not reimplement the keystroke-level eager/overlap/backspace accounting — that's the code under test — so the bug surfaces instead of being mirrored.The bug it documents (RED)
When an activation reuses characters from a prior eager activation via the common-prefix optimization, those reused chars aren't counted for deletion, so a following overlapping/followup activation backspaces too few characters and leaves stray text.
repro_overlap_underdelete): dictb→"c",b→"cfbcc",bd→"fee "; pressingb, SPACE, dyields"cfee "instead of"fee ".Notes
src/tests/sim_tests/ZIPPY_PBT_NOTES.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01D2JYVbtxCmQMMDLL39FeHz