You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): fall back to exclusive copy when Android SELinux blocks hardlinks - #42200
On Android (Termux, arm64, Node v26.13.1), SELinux blocks link(2) with EACCES/EPERM, breaking fs.link, fs.linkSync, and fs.promises.link calls (e.g., lockfile and atomic link operations).
Change
Add an Android-only hardlink fallback (apps/server/src/androidCompat.ts, invoked early in runCliCommand() in apps/server/src/binMain.ts) that wraps fs.link, fs.linkSync, and fs.promises.link when process.platform === "android". When link(2) fails with EACCES or EPERM, it falls back to copyFile / copyFileSync / fs.promises.copyFile with COPYFILE_EXCL so EEXIST semantics are preserved, calls NodeModule.syncBuiltinESMExports(), and guards against double-patching. Non-Android platforms are untouched.
Add unit tests (apps/server/src/androidCompat.test.ts) covering non-Android no-op behavior, EACCES/EPERM fallback across sync/callback/promise APIs, error propagation for non-SELinux errors (EEXIST), and idempotency.
Split from the original combined PR: the companion ffi-rs1.3.2 -> 1.3.7 bump is now in #44856 (full native Termux setup also depends on upstream microsoft/node-pty#1019). Creating the fork, commits, and this PR were all done using T3 Code itself running inside Termux via t3 serve and controlled from the T3 Code Android app (the web UI was also tested and used to configure Antigravity).
Scope
Focused, Android-only compatibility fix (process.platform === "android") with zero runtime impact on macOS, Linux, or Windows. No prior issue was filed because the failure is a straightforward EACCES/EPERM error from link(2) under Android SELinux.
Verification
Verified directly on Android arm64 (Termux, Node v26.13.1, pnpm 12.14.0):
Live T3 Code server on Android/Termux: Started the server in Termux with t3 serve, controlled it via the T3 Code Android app (creating the fork, commits, and PRs from it), and also tested the web UI directly, including configuring Antigravity through the web UI.
Real Android SELinux hardlink fallback E2E: Ran patchAndroidHardlinkFallback() against real node:fs / node:fs/promises on temporary files in Termux; verified linkSync, link, and promises.link fall back to copying content and still fail with EEXIST when the destination already exists.
Unit test assertions: Verified all 4 cases from apps/server/src/androidCompat.test.ts (non-Android no-op, EACCES/EPERM fallback with COPYFILE_EXCL, EEXIST propagation without copy, and idempotency).
oxlint on apps/server/src/androidCompat.ts, apps/server/src/androidCompat.test.ts, and apps/server/src/binMain.ts: 0 warnings, 0 errors.
oxfmt --check on all 3 files: all formatted cleanly.
Could not run locally:vp (vite-plus) does not ship an android-arm64 native binding yet, so vp run check:changed and running Vitest via vp test run could not be executed in Termux and rely on GitHub Actions CI.
Written with Gemini 4 Neon via Antigravity (running inside T3 Code on Android/Termux).
Reviewing files that changed from the base of the PR and between b0ea153 and d88892a.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The server adds an Android-only fallback from blocked hardlink operations to exclusive file copies. The CLI applies the patch before command dispatch. Tests cover supported platforms, error handling, and repeated patching.
Changes: Android hardlink fallback
Layer / File(s)
Summary
Implement and activate the Android fallback apps/server/src/androidCompat.ts, apps/server/src/binMain.ts, apps/server/src/androidCompat.test.ts
The patch wraps callback, synchronous, and promise hardlink APIs. On Android, EACCES and EPERM trigger a copy with COPYFILE_EXCL; other errors propagate. The CLI applies the patch before command dispatch. Tests cover platform behavior, error handling, and repeated patching.
This change adds a narrowly scoped Android fallback for blocked hardlinks and leaves other platforms unchanged. No actionable merge-blocking risk was found in the supplied changes.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Title check
The title "fix(server): fall back to exclusive copy when Android SELinux blocks hardlinks" follows conventional commit form and names the main change: an Android-only fallback from hardlink to exclusi…
Description check
The description follows the template's sections: Problem, Change, Scope, and Verification. It explains the SELinux EACCES/EPERM failure, the Android-only fallback with COPYFILE_EXCL, and the unit test…
Full details: Title check
Explanation
The title "fix(server): fall back to exclusive copy when Android SELinux blocks hardlinks" follows conventional commit form and names the main change: an Android-only fallback from hardlink to exclusive copy when SELinux blocks link(2). It matches the androidCompat.ts patch, binMain.ts invocation, and tests. It omits the companion ffi-rs bump, which the description says was split out, so that omission is expected.
Full details: Description check
Explanation
The description follows the template's sections: Problem, Change, Scope, and Verification. It explains the SELinux EACCES/EPERM failure, the Android-only fallback with COPYFILE_EXCL, and the unit tests. It gives a scope justification for not filing an issue and lists concrete verification, including Termux runs and static checks. It also notes that vp-based checks could not run locally and rely on CI. It does not include a linked issue or a maintainer request, but the template allows a short explanation for small fixes. The template's model/harness attribution line is present, though it is set as a sentence at the end.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 99076b7 and b0ea153.
Files selected for processing: 1
apps/server/src/binMain.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
noah1510
changed the title
fix(server): fix ffi-rs startup crash and hardlink locking on Android/Termux
fix(server): fall back to exclusive copy when Android SELinux blocks hardlinks
Nov 28, 2026
…hardlinks
Android SELinux blocks link(2) with EACCES/EPERM, breaking file locking and atomic copy operations that rely on fs.link*.
Patch node:fs link, linkSync, and promises.link on Android early in runCliCommand() to fall back to exclusive copyFile (COPYFILE_EXCL) while preserving EEXIST semantics, and add unit tests covering fallback, error propagation, and idempotency.
Co-authored-by: Antigravity (Gemini 4 Neon) <noreply@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:M30-99 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Android (Termux, arm64, Node
v26.13.1), SELinux blockslink(2)withEACCES/EPERM, breakingfs.link,fs.linkSync, andfs.promises.linkcalls (e.g., lockfile and atomic link operations).Change
apps/server/src/androidCompat.ts, invoked early inrunCliCommand()inapps/server/src/binMain.ts) that wrapsfs.link,fs.linkSync, andfs.promises.linkwhenprocess.platform === "android". Whenlink(2)fails withEACCESorEPERM, it falls back tocopyFile/copyFileSync/fs.promises.copyFilewithCOPYFILE_EXCLsoEEXISTsemantics are preserved, callsNodeModule.syncBuiltinESMExports(), and guards against double-patching. Non-Android platforms are untouched.apps/server/src/androidCompat.test.ts) covering non-Android no-op behavior,EACCES/EPERMfallback across sync/callback/promise APIs, error propagation for non-SELinux errors (EEXIST), and idempotency.Split from the original combined PR: the companion
ffi-rs1.3.2->1.3.7bump is now in #44856 (full native Termux setup also depends on upstream microsoft/node-pty#1019). Creating the fork, commits, and this PR were all done using T3 Code itself running inside Termux viat3 serveand controlled from the T3 Code Android app (the web UI was also tested and used to configure Antigravity).Scope
Focused, Android-only compatibility fix (
process.platform === "android") with zero runtime impact on macOS, Linux, or Windows. No prior issue was filed because the failure is a straightforwardEACCES/EPERMerror fromlink(2)under Android SELinux.Verification
Verified directly on Android arm64 (Termux, Node
v26.13.1, pnpm12.14.0):t3 serve, controlled it via the T3 Code Android app (creating the fork, commits, and PRs from it), and also tested the web UI directly, including configuring Antigravity through the web UI.patchAndroidHardlinkFallback()against realnode:fs/node:fs/promiseson temporary files in Termux; verifiedlinkSync,link, andpromises.linkfall back to copying content and still fail withEEXISTwhen the destination already exists.apps/server/src/androidCompat.test.ts(non-Android no-op,EACCES/EPERMfallback withCOPYFILE_EXCL,EEXISTpropagation without copy, and idempotency).tsc --noEmit(strict,exactOptionalPropertyTypes,noUncheckedIndexedAccess,verbatimModuleSyntax,erasableSyntaxOnly) onapps/server/src/androidCompat.ts: 0 errors.oxlintonapps/server/src/androidCompat.ts,apps/server/src/androidCompat.test.ts, andapps/server/src/binMain.ts: 0 warnings, 0 errors.oxfmt --checkon all 3 files: all formatted cleanly.vp(vite-plus) does not ship anandroid-arm64native binding yet, sovp run check:changedand running Vitest viavp test runcould not be executed in Termux and rely on GitHub Actions CI.Written with Gemini 4 Neon via Antigravity (running inside T3 Code on Android/Termux).