fix(resync): skip and report missing registry seats#328
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b72b0b90-8727-4262-905a-0031e9db5a6b) |
|
Warning Review limit reached
Next review available in: 2 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
@coderabbitai review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18216c0098
ℹ️ 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".
| } catch (error) { | ||
| if (!(error instanceof AgentNotFoundError)) { | ||
| throw error; | ||
| } | ||
| skipped.push({ |
There was a problem hiding this comment.
Evict skipped missing-state records before continuing
When updateManagedSurfaceRegistration proves the state file is missing, this catch records repair_skipped but leaves the stale AgentRecord in this.agents. In the common case where that in-memory record already matches the discovered surface/workspace, the later listMerged() call has no metadata patch to trigger evictMissingStateAgent, so the missing seat is still returned as a managed, addressable agent and suppresses orphan/auto-discovery reporting even though it has no persisted state. Remove the missing in-memory record before continuing with the rest of the repair.
Useful? React with 👍 / 👎.
Summary
resync_agentsdiff.repair_skippedTDD evidence
Agent not foundtext was incorrectly accepted by the initial message-based boundaryELOOPstate path was incorrectly classified as absent byexistsSyncVerification
env -u CMUX_SOCKET_PATH -u CMUX_DAEMON_SOCKET bun run test— 104 files, 2,162 tests passedenv -u CMUX_SOCKET_PATH -u CMUX_DAEMON_SOCKET bun run typecheckenv -u CMUX_SOCKET_PATH -u CMUX_DAEMON_SOCKET bun run buildgit diff --checkNo sidebar render or placement code changed. All tests were hermetic; no live cmux/agent session was accessed or mutated.
Do not merge;
@cmuxlayerRethink-leadowns review and merge.Note
Medium Risk
Changes agent registry repair and resync diff behavior during discovery repair; incorrect skip vs abort logic could leave stale seats or block healthy resyncs, though tests enforce fail-closed on non-absence errors.
Overview
resync_agentsno longer aborts the whole run when one seat’s on-disk state is missing while the in-memory registry still references it. Per-surface repair failures are isolated: only a typedAgentNotFoundError(proven absent state) is recorded indiff.repair_skippedwith surface, agent, seat, and reason; other seats continue to repair and ghost eviction proceeds.Missing-state detection is tightened so “no state file” is not inferred from unreadable paths.
StateManager.hasStateFilereads the state file strictly (ENOENT/ENOTDIR → absent) and can resolve aliased state dirs;getMissingStateSentineluses that instead ofreadState, so filesystem faults (e.g.ELOOP) still fail closed and abort resync with no diff.updateManagedSurfaceRegistrationmaps update failures to the same sentinel only when absence is strictly proven; generic “Agent not found” text when state still exists still aborts.Reviewed by Cursor Bugbot for commit 18216c0. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Skip and report missing registry seats during
resync_agentsrepairAgentRegistry.repairFromDiscoverynow catchesAgentNotFoundErrorper seat, records a skip entry, and continues processing rather than aborting the entire repair. The repair summary gains askippedarray alongsiderepairedandevicted.AgentRegistry.repairExistingRecordwrapsstateMgr.updateRecordfailures and reclassifies them asAgentNotFoundErrorwhen no state file exists, allowing upstream logic to skip gracefully.StateManager.hasStateFileis added to check agent state existence by scanning state directories, used to distinguish truly missing agents from transient read errors.resync_agentstool response now includes arepair_skippedfield populated from the skipped entries.readState, so agents with unreadable state files may now be classified as missing and skipped instead of surfacing an error.Macroscope summarized 18216c0.