Repository navigation
fix(agent-sync): reconcile native publication outcomes - #2590
Conversation
📝 WalkthroughWalkthroughThe change makes native no-clobber publication injectable and failure-aware across manifests and GENIE_HOME creation. Uninstall cleanup now uses lock-preserving install-state removal instead of empty-directory deletion, with tests covering native failures and swapped-in GENIE_HOME directories. ChangesAgent sync publication and uninstall
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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.
Code Review
This pull request introduces native Darwin support for atomic, no-clobber file and directory publishing using renamex_np via dlopen, alongside comprehensive test coverage and dependency injection seams for testing native platform fallbacks. It also removes the automatic cleanup of empty GENIE_HOME directories during uninstallation. The feedback highlights a critical issue where closing the libc handle inside the returned Darwin rename function makes it single-use, which could lead to failures if the function is invoked multiple times.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/agent-sync.ts`:
- Around line 6246-6270: Extract the shared staged-to-target publishing closure
from the Darwin and Linux branches into a helper such as
makeAgentSyncHomePublisher, accepting the resolved rename function and
preserving the existing lstatSafe detail selection and NoClobberPublishError
message. Have both branches return this helper after resolving their
platform-specific renamer, leaving platform detection and null handling
unchanged.
- Around line 6240-6271: Update resolveNativeAgentSyncHomePublisher to use the
shared platform value from options.homePublishDeps.platform instead of reading
process.platform directly, while preserving the existing Darwin and Linux branch
behavior and fallback handling.
- Around line 2134-2184: Cache the result of the Darwin opener capability probe
used by resolveDarwinRenameExclusive, so defaultDarwinRenameOpener does not
perform dlopen/dlclose for every publish call. Memoize it once per process or
sync run while preserving dependency-injected darwinOpener behavior and the
existing portable fallback when FFI setup is unavailable.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: c05dc20b-08c9-447b-993a-a0f837c62f92
📒 Files selected for processing (4)
src/genie-commands/uninstall.test.tssrc/genie-commands/uninstall.tssrc/lib/agent-sync.test.tssrc/lib/agent-sync.ts
💤 Files with no reviewable changes (1)
- src/genie-commands/uninstall.ts
Context
Post-merge closure for review findings discovered while #2588 was still being audited. This branch is rebased onto current
dev, including #2588 and the adjacent #2589 lock-quarantine repair.Fixes
renamex_npand Linuxrenameat2regular-file publication behind one exact-outcome reconciler.mkdircommit when Darwin FFI setup is unavailable.GENIE_HOMEreplacement is never deleted.Validation
bun test src/lib/agent-sync.test.ts -t 'claude agent fan-out|cross-process sync lock'— 64 passbun test src/genie-commands/uninstall.test.ts— 74 passbun run check:fast— passgit diff --check origin/dev...HEAD— passScope note
The pre-existing shared
publishDirectoryViaNameClaimclaim-to-rename advisory remains outside this regular-file and dedicated lock-home repair. Neither portable path changed here reaches that primitive.Summary by CodeRabbit
Bug Fixes
Tests