Skip to content

Keep client identity cache responsive during file lock waits - #11795

Merged
lawrencecchen merged 2 commits into
mainfrom
feat-identity-lock-contention
Sep 3, 2026
Merged

lawrencecchen merged 2 commits into
mainfrom
feat-identity-lock-contention

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

The client identity store now keeps its in-memory cache lock separate from owner-file waits and disk I/O. A cache generation check retries a transaction when another local update completes during the file-lock wait. The owner-file lease still covers the disk transaction and matching cache publication.

The first commit adds the regression test. It failed on the old code because a cached read timed out behind a contended owner-file lock. The second commit fixes the lock scope.

Tests:


Summary by cubic

Fixes the client identity store so cached reads don't block while another process holds the owner-file lock. The cache lock is no longer held across file-lock waits and disk I/O; a generation check retries the reload when a local update lands during the wait, and a commit that races a newer update returns an error instead of overwriting it.

Bug Fixes

  • The owner-file lease still covers the disk write and matching cache publication, preserving cross-process consistency.
  • Adds a regression test that failed on the old code because a cached read timed out behind a contended owner-file lock.

Written for commit f75f08f. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved responsiveness when reading client state while another process is using the state file.
    • Improved reliability for concurrent state updates, reducing the risk of stale data overwriting newer changes.
    • Ensured successfully saved state is immediately reflected in subsequent reads.

@cursor

cursor Bot commented Sep 3, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

@vercel

vercel Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cmux166 Ready Ready Preview Sep 3, 2026 5:17pm UTC
cmux41 Ready Ready Preview Sep 3, 2026 5:17pm UTC

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 147bf1a6-d806-4c25-8605-a520434e2973

📥 Commits

Reviewing files that changed from the base of the PR and between e4325ab and 63fda82.

📒 Files selected for processing (1)
  • cmux-tui/crates/cmux-remote/src/identity.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Changes

Client identity transactions

Layer / File(s) Summary
Synchronous cached state
cmux-tui/crates/cmux-remote/src/identity.rs
ClientIdentityStore now stores cached state behind StdMutex. known_daemons reads the cached map and preserves sorted output.
Generation-checked state transactions
cmux-tui/crates/cmux-remote/src/identity.rs
Client mutations reload and commit through generation-aware transactions. Reload retries after intervening commits. Commit publishes persisted state while retaining the owner lock.
Locking and persistence coverage
cmux-tui/crates/cmux-remote/src/identity.rs
Concurrency coverage verifies responsive cached reads during an external state-file lock. Test setup uses the synchronous cache and persistence helper.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 63fda

The identity store now keeps cached reads responsive during owner-file lock contention while retaining transactional cache publication; no current merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ClientIdentityStore
  participant StateFile
  participant ClientStateCache
  Client->>ClientIdentityStore: mutate client identity state
  ClientIdentityStore->>StateFile: acquire owner lock and reload state
  StateFile-->>ClientIdentityStore: return persisted state and generation
  ClientIdentityStore->>StateFile: commit generation-checked candidate
  StateFile-->>ClientIdentityStore: return persisted commit result
  ClientIdentityStore->>ClientStateCache: publish committed state
  ClientIdentityStore-->>Client: return mutation result
Loading
🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains what changed, why it changed, and how it was tested. However, it does not follow the repository template because it omits the required section headings, Demo Video information… Rewrite the description using the repository template. Add the Summary and Testing headings, include a Demo Video link or state why none is available, include the Review Trigger block, and complete the Checklist with the current testing and…
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (13 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: keeping the client identity cache responsive during owner-file lock waits.
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.
Cmux Swift Actor Isolation ✅ Passed PASS: The exact pull-request range changes no Swift files. It changes Rust, TypeScript, Python, and workflow files only, with the identity-store change in cmux-tui/crates/cmux-remote/src/identity.rs…
Cmux Swift Blocking Runtime ✅ Passed PASS: The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, which is Rust. The exact PR diff contains no .swift files or Swift production code. Therefore it does not introduce…
Cmux Browser Automation Off-Main ✅ Passed PASS. The pull request does not change browser socket automation. The diff changes cmux-tui/crates/cmux-remote/src/identity.rs for the two PR commits, and the full PR path list contains neither `Sou…
Cmux Expensive Synchronous Load ✅ Passed PASS: The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. git diff --name-status HEAD^^ HEAD reports one modified path, and no .swift paths appear in the PR d…
Cmux Cache Substitution Correctness ✅ Passed PASS: The described PR range changes only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. Both PR commits modify that file only. The custom check applies only to production Swift, TypeScri…
Cmux No Hacky Sleeps ✅ Passed PASS: The PR changes only cmux-tui/crates/cmux-remote/src/identity.rs, which is Rust. The custom check applies to TypeScript, JavaScript, shell, and non-Swift build/runtime scripts. It does not appl…
Cmux Algorithmic Complexity ✅ Passed PASS. The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, which is Rust code. The production changes add cache-generation checks, bounded lock scopes, state cloning, and direc…
Cmux Swift Concurrency ✅ Passed PASS: The pull-request diff contains only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. It contains no changed Swift paths and no added Swift concurrency patterns. The Swift-specific che…
Cmux Swift @Concurrent ✅ Passed PASS: The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. The exact HEAD^..HEAD diff contains no Swift files and no Swift concurrency annotations or call sites.…
Cmux Swift Package Boundaries ✅ Passed PASS. The pull-request patch changes only cmux-tui/crates/cmux-remote/src/identity.rs, which is Rust. It introduces no production Swift changes, so the Swift package-boundary rule is not applicable.
Full details: Description check

Explanation

The description explains what changed, why it changed, and how it was tested. However, it does not follow the repository template because it omits the required section headings, Demo Video information for this behavior change, Review Trigger block, and Checklist.

Resolution

Rewrite the description using the repository template. Add the Summary and Testing headings, include a Demo Video link or state why none is available, include the Review Trigger block, and complete the Checklist with the current testing and review status.

Full details: Cmux Swift Actor Isolation

Explanation

PASS: The exact pull-request range changes no Swift files. It changes Rust, TypeScript, Python, and workflow files only, with the identity-store change in cmux-tui/crates/cmux-remote/src/identity.rs. Therefore, it introduces no Swift actor-isolation issue covered by the rule.

Full details: Cmux Swift Blocking Runtime

Explanation

PASS: The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, which is Rust. The exact PR diff contains no .swift files or Swift production code. Therefore it does not introduce or expand any Swift blocking or timing-based synchronization primitive covered by swift-blocking-runtime.md.

Full details: Cmux Browser Automation Off-Main

Explanation

PASS. The pull request does not change browser socket automation. The diff changes cmux-tui/crates/cmux-remote/src/identity.rs for the two PR commits, and the full PR path list contains neither Sources/TerminalController.swift nor ControlCommandExecutionPolicy.swift. Added-line searches found no browser.*, WebKit, AppKit, socketWorkerMethods, or processV2Command changes. The rule is therefore inapplicable.

Full details: Cmux Expensive Synchronous Load

Explanation

PASS: The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. git diff --name-status HEAD^^ HEAD reports one modified path, and no .swift paths appear in the PR diff. The custom check applies only to production Swift changes that add or move expensive synchronous agent-history loads, so it is inapplicable.

Full details: Cmux Cache Substitution Correctness

Explanation

PASS: The described PR range changes only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. Both PR commits modify that file only. The custom check applies only to production Swift, TypeScript, and JavaScript changes, so its failure condition is not applicable.

Full details: Cmux No Hacky Sleeps

Explanation

PASS: The PR changes only cmux-tui/crates/cmux-remote/src/identity.rs, which is Rust. The custom check applies to TypeScript, JavaScript, shell, and non-Swift build/runtime scripts. It does not apply to Rust changes. The added timing assertions are also test-only scaffolding.

Full details: Cmux Algorithmic Complexity

Explanation

PASS. The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, which is Rust code. The production changes add cache-generation checks, bounded lock scopes, state cloning, and direct HashMap lookups. They do not add nested full-collection scans, per-target batch rescans, in-memory joins, or repeated filtering in the paths covered by the rule. The existing route-hint contains loop and daemon-list sorting are unchanged.

Full details: Cmux Swift Concurrency

Explanation

PASS: The pull-request diff contains only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. It contains no changed Swift paths and no added Swift concurrency patterns. The Swift-specific check is therefore inapplicable.

Full details: Cmux Swift `@Concurrent`

Explanation

PASS: The pull request changes only cmux-tui/crates/cmux-remote/src/identity.rs, a Rust file. The exact HEAD^..HEAD diff contains no Swift files and no Swift concurrency annotations or call sites. The Swift @concurrent check is therefore not applicable.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-identity-lock-contention

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

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

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@lawrencecchen
lawrencecchen force-pushed the feat-identity-lock-contention branch 2 times, most recently from 1e104ef to 63fda82 Compare September 3, 2026 06:09
@lawrencecchen
lawrencecchen force-pushed the feat-identity-lock-contention branch from 63fda82 to f75f08f Compare September 3, 2026 06:15
@lawrencecchen
lawrencecchen merged commit f4e3d4f into main Sep 3, 2026
42 of 46 checks passed
@lawrencecchen
lawrencecchen deleted the feat-identity-lock-contention branch September 3, 2026 06:31
rustybret pushed a commit to rustybret/bmux that referenced this pull request Sep 3, 2026
4e30be8 cloud: compact access screen with the app icon (manaflow-ai#11819)
2558039 fix(cmux-tui): restore rustfmt import order (manaflow-ai#11808)
f4e3d4f Keep client identity cache responsive during file lock waits (manaflow-ai#11795)
69dfcd1 fix(cmux-tui): make workspace clippy green and lint in every hosted lane (manaflow-ai#11796)
0f19be0 cloud: static model-plane env baked into the snapshot; create writes nothing into the guest (manaflow-ai#11813)
c03ec18 cloud: add authenticated public VM domains (manaflow-ai#11692)
e4325ab fix(cmux-tui): validate relay CLI values

# Conflicts:
#	.github/workflows/cmux-tui.yml
lawrencecchen added a commit that referenced this pull request Sep 3, 2026
* test(remote): cover client identity lock contention

* fix(remote): separate identity cache from file locking

This branch was successfully deployed

2 active deployments
Preview – cmux166 — f75f08fc Deployed Sep 3, 2026 by vercel[bot]
Preview – cmux41 — f75f08fc Deployed Sep 3, 2026 by vercel[bot]
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.

1 participant