Repository navigation
feat(runtime): incremental Merkle workspace index for run-snapshot change detection - #191
Merged
Merged
Conversation
…ange detection Adds qq_core::WorkspaceIndex (workspace/index.rs) over the search/tree walker: build hashes every admitted file and directory; refresh against a previous index reuses a file's hash when size and mtime are unchanged and the mtime is strictly older than the previous walk, so a checkpoint on a quiet tree is a walk with no reads; diff yields sorted added/modified/ deleted paths. A budget-stopped build is IndexOutcome::Partial, which has no root hash and cannot be diffed. Hashes are qq_protocol::ContentHash; directory hashes cover child names so a moved subtree keeps its hash. Reworked from the contribution in #172: chunking dropped (no consumer), hex-String hashes replaced, partial root hash removed, incremental refresh added. EntryKind::File gains modified from the metadata call the walker already makes; search_walk is unchanged within noise. Bench workspace_index, 10k files / 17.6 MB, original -> reworked: build 52.0 -> 26.1 ms; diff 73 -> 35 us; refresh_quiet 6.8 ms with every hash reused; refresh_one_edit 7.3 ms. Co-Authored-By: romy <[email protected]>
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.
Stacked on #172 (base is its head branch; retarget to
mainonce #172 merges).What
qq_core::WorkspaceIndex(crates/qq-core/src/workspace/index.rs): a Merkle index over the same contained, ignore-aware walkersearch/treeuse, reworked from the index in #172. It is the change-detection primitivedocs/plans/run-snapshots.md§ Change Detection needs for the shadow store's dirty scan. Not a tool; no protocol change; no new dependencies.buildhashes every admitted file (SHA-256) and every directory over its children (kind\0name\0digest\nunder a versioned tag). Names, not paths, so a moved subtree keeps its hash.refresh(&previous)reuses a file's hash when size and mtime are unchanged and the mtime is strictly older than the previous walk (git's same-tick guard). A checkpoint on a quiet tree is a walk with zero reads.diffmerges two complete indexes into sortedadded/modified/deleted.IndexOutcome::Partial: noroot_hash, cannot be diffed. Completeness is in the type, not a flag.qq_protocol::ContentHash(32 bytes), not hexStrings.EntryKind::Filegainsmodified, read from themetadata()call the walker already makes.Changes from the #172 version
Dropped: per-file line chunking (no consumer;
tool-layer.mdNon-Goals excludes a persistent search index),root_hashon partial builds, hex-string hashes,pub ListError. Added: incrementalrefresh, name-based directory hashing (the original comment claimed this; the code hashed full paths), moved toworkspace/. Pinned fixture root hash recomputed independently in Python.Measured
cargo bench -p qq-core --bench workspace_index, 10k files / 17.6 MB, 20 iterations × 3 runs, back to back on one machine:build_10kdiff_10k_one_modifiedrefresh_10k_quietreused=10000 bytes_read=0)refresh_10k_one_editsearch_walkunchanged within noise (themodifiedfield costs no extra syscall).Verification
cargo fmt --check,cargo clippy --workspace --all-targets --all-features -D warnings,cargo test --workspace(1895 passed). 10 focused tests: pinned root, ancestor propagation, moved subtree, sorted diff,.qqignore, refresh reuse / same-size change / racy mtime / no mtime, refresh across adds and deletes, partial on each budget axis, symlinks never followed, missing root.Notes
docs/plans/progress/tool-layer.md2026-09-25 entry.