Repository navigation
🐛 fix(history): evict dead repos first, then the largest repo's oldest (#713) - #716
Merged
Merged
Conversation
Three cases the oldest-first rule gets wrong: an entry whose repo is gone must go before an older live one, only one of them goes per overflow (a repo on an unmounted disk is missing, not gone), and a repo flooding the journal pays with its own entries before another repo loses its only one. The rotation test now creates its repo dir, so it keeps exercising the all-live path.
#713) On overflow the journal dropped the oldest entry whatever its repo, so entries that can never be undone (temporary repos a consumer's tests removed worktrees in) pushed out real ones, and one busy repo could flush another's history. The evicted entry is now the oldest whose repo_root is confirmed missing (try_exists is Ok(false); an unreadable root counts as present), otherwise the oldest of the repo holding the most entries. Still one entry per append, nothing purged on write. A single-repo journal rotates exactly as before.
The daemon consumers page gains the variables a tool driving gwm from its test suite must set (GWM_HISTORY_FILE, GWM_TRUST_LEDGER, GWM_NO_GLOBAL_CONFIG, XDG_CONFIG_HOME for aliases.toml, GWM_AGENTS_HOME), in EN and FR. The gwm history reference states the new eviction order, and the changelog records the fix.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
…he unverifiable root (#713) Review of #716: the flooding test appended to the busy repo, which is also the largest, so a rule keyed on the appended entry's repo passed it. The quiet repo now overflows too and must cost the busy repo, not itself (killed that mutant). A unix-only test seals a repo's parent (mode 000) so try_exists errors: the entry must not be evicted as gone (killed a !exists() mutant). The module doc stops describing oldest-first rotation.
…e every one (#713) A smaller repo that overflows takes from the largest until they are level; the rustdoc claimed a flooding repo pays before another loses anything, which only holds for the repo that is ahead.
…om, the parity limit (#713) Review of #716. The default [worktree] base is {home}/cc-worktree/{repo}, which no GWM_* variable moves, so the recipe now gives the test repo a .gwm.toml that keeps worktrees in the scratch dir, as gwm's own suite does. A malformed aliases.toml prints a warning on every call rather than failing it. The global config.toml is written by the TUI's Settings and Keys panels, refused under GWM_NO_GLOBAL_CONFIG. The history reference and the changelog say repos end up with an even share at worst.
…r permission tests (#713) Root ignores the mode bits, so the sealed root stays checkable and the precondition panicked. Same convention as tests/worktree_integration.rs: restore, print why, return.
…entry (#713) Eviction runs from remove_verified_recording, inside gwm remove's point of no return; a journaled repo on a hung mount stalled it once per entry of that repo. The gone set is now computed over distinct repo roots.
The changelog links the consumers page by absolute URL (a repo-relative link 404s once the entry moves to changelogs/<version>.md). The history reference says a missing repo includes an unmounted disk. The isolation section no longer calls worktrees the only write no variable moves (the daemon socket is another, covered by --socket). The rustdoc's parity claim allows for a tie.
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.
Description
The undo journal (
history.toml) is capped at 100 entries across all repos and dropped the oldest one on overflow, whatever its repo. Entries that can never be undone (a consumer's test suite removing worktrees in temporary repos) pushed out real, older ones, and one busy repo could flush another repo's history. On overflow the journal now drops the oldest entry whose repo is confirmed gone, otherwise the oldest entry of the repo holding the most entries. The variables that keep a tool's tests off the user's state are documented for consumers.Closes #713
Type of change
Changes
src/history.rs:Journal::appendpicks the evicted entry througheviction_index: (1) the oldest entry whoserepo_rootis confirmed missing (try_exists()isOk(false); a root that cannot be checked counts as present), (2) otherwise the oldest entry of the repo holding the most entries. Still one entry per append and only on overflow, so a repo on an unmounted disk keeps its entries until the room is needed. For a single-repo journal, (2) is plain oldest-first, as before.tests/history_tests.rs: three tests, each red onorigin/devfor its own assertion (gone entry evicted before an older live one; one gone entry per overflow, not all; a flooding repo pays before a quiet one). The rotation test now creates its repo dir so it still covers the all-live path.docs/5.integrations/4.daemon-consumers.md(EN + FR): a section listing what isolates gwm when a consumer's tests run it:GWM_HISTORY_FILE,GWM_TRUST_LEDGER,GWM_NO_GLOBAL_CONFIG,XDG_CONFIG_HOME(the user'saliases.tomlis read on every invocation andGWM_NO_GLOBAL_CONFIGdoes not cover it),GWM_AGENTS_HOME, plusGWM_ALLOW_BOOTSTRAP,GWM_GH/GWM_GLABand the daemon's--socket.docs/3.cli/1.reference.md(EN + FR): thegwm historyparagraph states the new eviction order instead of "the oldest is dropped".CHANGELOG.md: entry under[Unreleased] / Fixed.Tests
cargo testpasses locally (--no-fail-fast, 111test result: ok, 0 failed)cargo fmt --checkpassescargo clippy -- -D warningspasses (--all-targets)tests/(TDD: a PR adding behaviour without tests is sent back)Checklist
<type>/#<issue>-<description>## [Unreleased]examples/gwm.toml.exampleupdated if config schema changed: no schema changeunwrap()on user-facing paths (returnGwmErrorinstead)println!in TUI render code (status bar only)Linked issues / docs
Notes for reviewers
HashMapcount on overflow, and each of the two rules has its own red test.gcprune window may already point at a pruned commit. Age is not a reliable proxy for that (gc may never have run), so the rule does not guess.gwm history --allshows them.cargo auditis red ondevitself right now (RUSTSEC-2026-0459, RUSTSEC-2026-0486), independently of this diff; it is fixed in its own PR.