Skip to content

fix(mcpx/cache): Scan skips beside-file leases so Prune can never delete a live lease (#3112) - #3728

Merged
dezren39 merged 3 commits into
mainfrom
queue/5637-3112-cache-lease-scan
Nov 1, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/5637-3112-cache-lease-scan

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #3112. Queue task 5637.

Problem

internal/cache.Scan only skipped names starting with the bare .lease- prefix, but a lease for a single-file entry lives beside it as <entry>.lease-<random> (leaseLocation). A nil-match scan (Cache.List, the runner's pruneWorkDirs) therefore returned the lease file as an entry with Leased: false — corrupting eviction accounting and letting Prune/Evict select the lease file itself as a victim and delete the pin from a live, in-use entry (the #2566 finding-3 failure, through the lease file rather than the entry).

Fix

Scan collects the listing up front and skips a non-directory name when it is a beside-file lease: the name before a .lease- infix is a file in the same listing (isBesideLease). Recognition is independent of match (including nil), so a victim list containing a lease file is now impossible rather than rechecked. A genuine entry whose name merely contains the infix, with no such sibling, stays an entry; directory-entry leases (inside the entry) and the #2566 protections are untouched.

Tests

  • TestScanSkipsBesideFileLease — a leased file entry scans as exactly one entry with Leased: true under a nil match; no lease-named entry is returned.
  • TestPruneNeverRemovesBesideFileLease — the probe shape (lease aged oldest, Prune(MaxEntries: 1)): nothing is removed, the lease file and the entry survive, and the entry stays leased.
  • go test ./internal/cache -count=1 — ok; go test ./internal/runner -count=1 — ok (laptop).

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 14:35
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d904b47e-766f-439b-b94e-f80512563a8f
Commits

Reviewing files that changed from the base of the PR and between ee417e9 and 07c1801.

Files selected for processing: 2
  • pkgs/mcpx/internal/cache/cache.go
  • pkgs/mcpx/internal/cache/cache_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@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: 5bcc05ae15

ℹ️ 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 pkgs/mcpx/internal/cache/cache_test.go Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-01T15:35:06.647549Z 07c1801 Manual request
ℹ️ 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.

…ex P1 on #3728, #3112)

Table cases distinguishing the sibling-aware classifier from an unconditional .lease- substring filter: infix name with no sibling stays an entry; infix name with a directory sibling stays an entry (directory leases live inside); a non-nil match that accepts the lease name but excludes its sibling still skips the lease (recognition precedes match); a directory entry with an inside lease scans once with Leased=true. go test ./internal/cache ./internal/runner -count=1 PASS (also after merging current main).
@dezren39

dezren39 commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

@codex review

Fix round for the Codex P1 (lease-classifier permutation coverage) is in head 07c1801, thread replied to and resolved. Note on CI: the basic:lint and stress failures on this PR are the pre-existing pkgs/mcpx internal/conformance test-package compile break (failingReads vs mcpserver.Backend Complete, features_test.go:308), verified in this run's CI logs and proven on clean main by earlier shifts — internal/cache is untouched by it; cache + runner suites pass on the laptop. Requesting re-review of 07c1801.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 07c1801b43

ℹ️ 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".

@dezren39
dezren39 merged commit 70a595a into main Nov 1, 2026
10 of 12 checks passed
@dezren39
dezren39 deleted the queue/5637-3112-cache-lease-scan branch November 1, 2026 20:57
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.

mcpx(cache): Scan counts a file entry's lease file as an entry — Prune can delete the live lease and strip the pin from an in-use entry

1 participant