Repository navigation
Conversation
LocalStorage serialized a HashMap directly, so every write emitted keys in a per-process random order. Any change, or none, rewrote the whole file, which makes storage.json and archive.json unusable under git or jj. Sort entries by numeric key on write (non-numeric keys last, lexically), matching the order the Node.js version's JSON.stringify produced. The on-disk schema and the in-memory types are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DsL2SpgcXHswgy5n42oi7Z
u64::from_str accepts "01" and "+1", so distinct keys could compare Equal and keep HashMap iteration order, which made the output nondeterministic again for hand-edited files. Break such ties lexically. Review finding (code-review on 748e42e). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DsL2SpgcXHswgy5n42oi7Z
JSON.stringify sorts only canonical array-index keys and keeps other keys in insertion order, so the match holds for taskbook's own IDs, not for arbitrary keys like "01". Review finding (code-review on 748e42e). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DsL2SpgcXHswgy5n42oi7Z
Each run left two tb-local-test-<uuid>/ trees in the system temp dir. Clean up at the end of each test, as config.rs's tests do. Review finding (code-review on 748e42e). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DsL2SpgcXHswgy5n42oi7Z
group_by_board and group_by_date push items while iterating a HashMap, so the CLI board view, --find, --list, --timeline and --archive list a group's items in a different order on every run. Node.js taskbook listed them in ID order (Object.keys). These tests fail on this commit by design; the next commit makes them pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DsL2SpgcXHswgy5n42oi7Z
group_by_board and group_by_date now walk items in ascending key order, using the same compare_keys that orders the storage file, so CLI listings no longer follow HashMap iteration order. Makes the tests from the previous commit pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DsL2SpgcXHswgy5n42oi7Z
Sort with item.id() instead of exporting the storage key comparator. The CLI, TUI and MCP now share one notion of ID order, and compare_keys stays private to the storage file format. Review finding (code-review on 973898a...cf0db59). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DsL2SpgcXHswgy5n42oi7Z
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.
Fixes #65.
LocalStoragenow writesstorage.jsonandarchive.jsonin ascending numeric key order, so the same data always produces the same bytes and a change to one item changes only that item's lines.Change
A small
SortedItemswrapper sorts the entries when they're serialized. Numeric keys come first in numeric order. Any non-numeric keys come after them in lexical order. Distinct keys with the same value, such as"1"and"01", are ordered lexically, so the output never depends onHashMapiteration order.The on-disk schema, the
StorageBackendtrait and the in-memory types are unchanged. For IDs taskbook generates, the order matches what the Node.js version wrote. The remote backend is not touched.Considered and left out
StorageBackendto aBTreeMap. This would make order deterministic everywhere, but it touchestaskbook.rs, the TUI, MCP and the remote backend. ABTreeMap<u64, _>would also reject non-numeric keys that load today.Testing
cargo fmt --checkandcargo clippy --workspace --all-targets -- -D warningsare clean.cargo test --workspacepasses.storage::local. The order and same-bytes tests fail when the sort is removed. The tie test failed before its fix.--check 3isComplete)--check 3twice (no net change)--delete 2The "before" numbers come from the 8-task reproduction in #65.