Skip to content

feat(repo): prune dead protected-cache entries on save - #204

Merged
tonibergholm-codento merged 3 commits into
mainfrom
cache-hygiene
Oct 19, 2026
Merged

tonibergholm-codento merged 3 commits into
mainfrom
cache-hygiene

Conversation

@tonibergholm

@tonibergholm tonibergholm commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Closes the protected-cache hygiene follow-on in ROADMAP.md.

ProtectedCache::save now skips entries whose file is no longer on disk (deleted, renamed, outside the sparse view). The cache file stays bounded by the protected files present instead of growing for the life of the repo. Lookups compare the keyed tag of plaintext read from the file, so an entry for an absent file is never consulted; a dropped entry costs at most one re-seal if the path returns.

Verification: new test save_drops_entries_for_files_no_longer_on_disk; cargo clippy --workspace --all-targets -- -D warnings clean; cargo test --workspace 982 passed, 0 failed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Cache data now excludes files that have been deleted, renamed, or are no longer present in the checkout. If a file returns, it may need to be sealed again.

ProtectedCache::save skips entries whose file is gone from the checkout, so
.sc/protected-cache and .sc/ws/cache-<i> stay bounded by the protected files
present. A lookup compares the keyed tag of plaintext read from the file, so an
entry for an absent file is never consulted; dropping it costs at most one
re-seal.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T14:05:20.351551Z 6a244bf New commits
🔒 Security Review ✅ Completed 2026-10-19T14:07:54.197005Z 6a244bf New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e61dde28-0544-4afa-857e-4cc1a3f03d97
📥 Commits

Reviewing files that changed from the base of the PR and between 3df290c and 6a244bf.

📒 Files selected for processing: 2
  • ROADMAP.md
  • crates/repo/src/cache.rs
+-----------------------------------------------------------------+
| I have no memory of this place...but I'll find the bugs anyway. |
+-----------------------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 813915a2-5d7a-4ee2-8f01-6fbe76b4118e
📥 Commits

Reviewing files that changed from the base of the PR and between 3df290c and 6a5dd78.

📒 Files selected for processing: 2
  • ROADMAP.md
  • crates/repo/src/cache.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

ProtectedCache::save now omits entries whose paths do not resolve to files. A regression test covers deleted, renamed, and directory paths. The roadmap marks protected-cache hygiene as shipped.

Changes: Protected cache hygiene

Layer / File(s) Summary
Prune non-file entries during save
crates/repo/src/cache.rs, ROADMAP.md
ProtectedCache::save skips paths that are not files. A regression test verifies that only surviving and renamed files remain cached. The roadmap marks the change as shipped.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 6a5dd

The cache-pruning change appears ready to merge after normal checks.

Security architecture risk: ⚪ Minimal · up to 6a5dd

Pruning affects only local cache metadata. Protected-content reuse still requires matching plaintext identity, and missing cache entries cause resealing rather than lost content. No material security risk was identified as introduced or worsened by this change.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The changed persistence policy applies to local main-checkout and workspace protected caches. The cache stores metadata and keyed tags, not plaintext content.

Security Findings and Attack Paths

  • inferred — No introduced control bypass was identified in the inspected path. Changing file existence can now remove a persisted cache record, but cannot turn a plaintext mismatch into a cache hit or make an unlanded blob authoritative.

Trust Boundaries and Controls

  • observed — Cache identity remains tied to a local per-repository key. The repository factory supplies the checkout root and cache destination; the new filter neither changes that destination nor grants additional write authority.

Resilience and Maintainability Implications

  • inferred — Filesystem races and concurrent cache replacement can preserve or discard advisory records, but subsequent reuse still requires plaintext identity and prior-blob agreement. Whole-file last-writer-wins behavior predates this PR; pruning does not make the cache authoritative over repository content.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: pruning dead protected-cache entries during save.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d0925b35a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/repo/src/cache.rs Resolved
Codex: is_file() follows symlinks, so a file replaced by a symlink (or under a
symlinked directory) kept a dead entry the walker can never consult. Check each
path component with symlink_metadata instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@tonibergholm-codento tonibergholm-codento left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required checks green on 6a244bf; reviewer and Codex findings fixed and resolved.

@tonibergholm-codento
tonibergholm-codento merged commit 69df01f into main Oct 19, 2026
7 of 8 checks passed
@tonibergholm
tonibergholm deleted the cache-hygiene branch October 19, 2026 14:17
tonibergholm-codento added a commit that referenced this pull request Oct 20, 2026
* fix(repo,cli): accept bracketed IPv6 hosts in sc+http(s):// urls (#219)

ScHttpUrl::parse split on the first ':' and rejected [::1]:7777. It now
unbrackets the host (kept bare for TLS name checks and the pin key) and
re-brackets it for the connect address, Host header, pin file and display.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs(repo,cli): reword the .sc gate claim and fix rustdoc warnings (#219)

Since #207 the 404 for a missing repo follows the auth gate. Plain code spans
replace links from public docs to private items; two clap doc comments no
longer parse as HTML or an intra-doc link.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* test(repo): cover the --theirs carry edges and ws cache pruning (#219)

Theirs-side resolve carry (#205): rebase --continue, a convergent blob on
their side, the seal fallback when their wrap list is missing, and the
documented under-grant after a grant on our side. Protected-cache pruning
(#204): a live workspace's .sc/ws/cache-<i> drops a deleted protected file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(repo,cli): canonical IPv6 pin keys, accurate gate wording, IPv6 pin CLI test (#219)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(repo): read pin-file keys with the URL authority grammar (#219)

A bracketed DNS name such as [example.com]:8730 had its brackets stripped and
became a live pin. parse_line now uses split_authority, so brackets must hold
an IPv6 literal and anything else is skipped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants