Repository navigation
Record a Per-Fetch Token in hub.owned So a Menu Removes Only the Hub It Fetched - #2542
Conversation
…It Fetched Each fetch in menu.ps1 and menu.sh now writes a token unique to that fetch into the shared hub.owned marker, and the exit cleanup removes the cached hub only when the marker still holds this session's own token, checked under the hub lock. A session that fetched earlier no longer deletes a tree another session sharing the same cache directory fetched since, a -Keep session's included. menu.sh had the same gap as menu.ps1, and both menus share one marker through a common cache directory, so both write the same form: the token text, which each side compares after trimming the trailing newline. Closes #1093 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…und Trip Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🔵 Needs a closer look
Resolve the two outstanding menu.sh token-generation and cross-menu CRLF cleanup findings.
0 open findings
What changed in this PR
This PR adds per-fetch ownership tokens so shared hub-cache cleanup removes only the cache fetched by the current session.
Changes:
- Adds token recording and validation to both menu implementations.
- Adds cleanup tests covering ownership, refetches, empty markers, and line endings.
menu.shstill requires token-generation failure handling and CRLF normalization.
| File | Reviewed changes |
|---|---|
tests/test_bootstrap.py |
Adds shared cleanup ownership tests for both menus. |
host-setup/menu.sh |
Adds random fetch tokens and ownership-gated cleanup. |
host-setup/menu.ps1 |
Adds GUID fetch tokens and ownership validation. |
🧠 Review effort: Lite
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2542 +/- ##
========================================
Coverage 58.40% 58.40%
========================================
Files 16 16
Lines 8090 8090
========================================
Hits 4725 4725
Misses 3365 3365
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…nges the Cache fetch_hub_locked runs with errexit suspended, so a failed /dev/urandom read would otherwise mark the fetch with an empty token that no cleanup ever matches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A recorded local strict-review pass covers head |
|
Copilot's round on e921ba5 opened no thread, but its headline named two outstanding
|
## Summary Promotes one change from `develop`. - #2542: `menu.ps1` and `menu.sh` each write a token unique to the fetch into the shared `hub.owned` marker. The exit cleanup, holding the hub lock, removes the cached hub only when the marker still holds the session's own token. A session that fetched earlier no longer deletes a tree another session sharing the cache directory fetched since, a `-Keep` / `--keep` session's included. In `menu.sh` the token is read before the fetch changes anything, and a failed read fails the fetch, since errexit is suspended there. Closes #1093. ## Verification - The new `TestMenuHubCleanup` (bash) and `TestPowerShellMenuHubCleanup` (pwsh, real lock) cases pass on Windows, and the full suite passes under Git Bash (2270 tests, 100 skipped). Mutation checks fail the new cases in both menus. CI covers the Linux side. - #2542 took three recorded local strict-review passes, and the last two raised nothing. Copilot ran one round, which opened no thread. Its headline named two `menu.sh` findings. The token-read failure was fixed in 912b557, and cross-menu CRLF was declined with evidence, since a session only ever compares the marker with its own token. The reader gap that let the digest pass that headline is filed as #2544. - Pre-existing and out of scope: #2541, the freshness check ignoring `--ref`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Refs #1093.
menu.ps1andmenu.shshare a hub cache,$DIR/hub, marked by$DIR/hub.owned. A session's exit cleanup removed that tree whenever its own process-localHUB_FETCHEDwas true and the marker existed. A session that fetched earlier could therefore delete a tree another session sharing the directory fetched since, a-Keep/--keepsession's included.menu.ps1and 16 bytes of/dev/urandomas hex inmenu.sh.Test-HubFetchedHere/hub_fetched_here). A session that has no token, or finds an empty marker, removes nothing.menu.shlacks this shape. It does not: it has the same marker and the same cleanup gate, and both menus can share one--dir, so both are fixed here.Known limit
An older copy of either menu, one fetched before this lands, still deletes whenever any marker exists. Until it is replaced, it can remove a tree a new session fetched. Nothing here can close that, since an old copy never reads the token.
Verification (Windows host)
TestMenuHubCleanup(bash, run under Git Bash withflockstubbed) andTestPowerShellMenuHubCleanup(pwsh, under the real lock) share one set of cases. Two of them run a real fetch withgitstubbed: a session's own fetch is removed at exit, and a fetch by another session made since survives the first session's exit.scripts/docker_lint.py.menu.shunder real bash andmenu.ps1under Linux pwsh.The review also found one pre-existing defect, filed as #2541: the freshness check ignores
--ref.🤖 Generated with Claude Code