From ffc582292548e1692f32287d039370875f114b62 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Fri, 20 Nov 2026 02:05:54 -0800 Subject: [PATCH 01/28] docs(desktop): document the missing-Node.js bootstrap recovery The Known Issues section covers the fresh-Mac-without-Python failure (runtime_install_exit_2) but not its Node analog: the bundled runtime installer exits 1 when no usable Node.js is reachable, and the boot page renders the install-and-repair guidance without a documented recovery path. Add the parallel entry with the bounded search paths, the Finder-versus-nvm visibility caveat and self-service steps, and align the Prerequisites Node bullet with the runtime's actual 22.22.3+ (24 LTS recommended) requirement instead of the dashboard-build-only floor. Fixes #9133 Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index deac5411c4..087680b9b5 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -498,6 +498,35 @@ Self-service: serves your terminal runtime) checks that host's installation. It cannot diagnose this Mac App's local bootstrap; only the App's own diagnostics do. +### Fresh Mac without a usable Node.js stays on the boot screen + +The App's automatic runtime installation can also fail with +`runtime_install_exit_1` when no usable Node.js is reachable: the candidate's +`doctor --deep --installation-only` validation treats the managed TypeScript +Effect runtime as required, and it fails closed while `node` is missing. The +App does not bundle Node; Node.js 22.22.3 or newer is required and 24 LTS is +recommended, matching the CLI installation guide. + +The installer and the owned services resolve `node` through the same bounded +search path (`~/.local/bin`, `/opt/homebrew/bin`, `/usr/local/bin`, the +Homebrew keg-only `node@24`/`node@22` prefixes, then the inherited process +PATH). Finder does not load the interactive shell profile, so Node installed +through nvm/fnm/volta stays invisible to the App even though it works in a +terminal. + +Self-service: + +1. Check the boot screen error code or Recovery & updates → Diagnostics + (`error_code: runtime_install_exit_1`, `environment.node_found` / + `node_version` confirm the missing runtime). +2. Install Node.js 22.22.3+ — for example `brew install node` (the keg-only + `brew install node@24` is also covered by the search path) or via the + official nodejs.org installer. An nvm/fnm/volta installation needs a plain + installation or a `~/.local/bin` symlink the App can resolve. +3. Press **Repair this version** (or reopen the App); the environment probe + refreshes and the live supervisor reconnects the same window without a + second App restart. + The updater accepts only fixed official HTTPS channels, not browser-provided commands, paths or download URLs. Its signing private key is confined to the release secret; the App embeds the public key. PR validation has no signing @@ -606,7 +635,10 @@ Session 与委派受众保持不变,不混合不同私聊或扩大权限。借 - A working Python interpreter for runtime installation; existing managed installations preserve their interpreter. Windows requires a separately installed LoopX CLI. Set `LOOPX_BIN` only for deliberate runtime overrides. -- Node.js 20.19+ or 22.12+ for dashboard builds. +- Node.js 22.22.3 or newer (24 LTS recommended) for the managed TypeScript + runtime the installed App bootstraps; Node.js 20.19+ or 22.12+ only covers + dashboard builds. See Known Issues when a fresh Mac stops on the boot screen + without it. - Rust stable and the platform-specific Tauri build dependencies. Linux requires WebKitGTK 4.1 and GTK 3 development packages. See the From 5805c263496a43d6b066b44a84c674a9c846dbe3 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Mon, 23 Nov 2026 20:41:36 -0800 Subject: [PATCH 02/28] docs(desktop): cover an older Node.js that still wins the App search The missing-Node known-issue entry only told readers to install Node.js. When an older `node` already sits earlier in the App's bounded search path (for example `~/.local/bin/node` reporting 22.22.2), a later Homebrew or keg-only install does not displace it, Core keeps reporting `node_unavailable`, and the same `runtime_install_exit_1` returns. Split self-service by what Diagnostics report: `node_found: false` needs an installation; `node_found: true` with a version below 22.22.3 needs the winning entry updated where it wins. Diagnostics report the version but not the path, so the entry lists the search order and tells the reader to confirm the reported version before repairing. Also align the entry with the search path as it now stands on main, which discovers nvm installations on disk (#9184): the order gains the `NVM_BIN` and nvm locations, and only fnm/volta remain invisible to a Finder launch. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 54 +++++++++++++++------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index caa844b4f2..766e865f16 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -518,27 +518,47 @@ diagnose this Mac App's local bootstrap; only the App's own diagnostics do. The App's automatic runtime installation can also fail with `runtime_install_exit_1` when no usable Node.js is reachable: the candidate's `doctor --deep --installation-only` validation treats the managed TypeScript -Effect runtime as required, and it fails closed while `node` is missing. The -App does not bundle Node; Node.js 22.22.3 or newer is required and 24 LTS is -recommended, matching the CLI installation guide. - -The installer and the owned services resolve `node` through the same bounded -search path (`~/.local/bin`, `/opt/homebrew/bin`, `/usr/local/bin`, the -Homebrew keg-only `node@24`/`node@22` prefixes, then the inherited process -PATH). Finder does not load the interactive shell profile, so Node installed -through nvm/fnm/volta stays invisible to the App even though it works in a -terminal. +Effect runtime as required, and it fails closed while `node` is missing or +older than the required minimum. The App does not bundle Node; Node.js 22.22.3 +or newer is required and 24 LTS is recommended, matching the CLI installation +guide. + +The installer and the owned services resolve `node` through one bounded search +path, in this order: `~/.local/bin`, an `NVM_BIN` the inherited PATH still +selects, `/opt/homebrew/bin`, `/usr/local/bin`, the Homebrew keg-only +`node@24` and `node@22` prefixes, the inherited process PATH, and last the nvm +installations found on disk. Finder does not load the interactive shell +profile, so a Node that only fnm or volta puts on the shell PATH stays +invisible to the App even though it works in a terminal. Self-service: 1. Check the boot screen error code or Recovery & updates → Diagnostics - (`error_code: runtime_install_exit_1`, `environment.node_found` / - `node_version` confirm the missing runtime). -2. Install Node.js 22.22.3+ — for example `brew install node` (the keg-only - `brew install node@24` is also covered by the search path) or via the - official nodejs.org installer. An nvm/fnm/volta installation needs a plain - installation or a `~/.local/bin` symlink the App can resolve. -3. Press **Repair this version** (or reopen the App); the environment probe + (`error_code: runtime_install_exit_1`, then `environment.node_found` and + `node_version`). The boot screen names the missing Node.js only when + `node_found` is `false`, so read the version from Diagnostics. +2. `node_found` is `false`: no `node` is reachable. Install Node.js 22.22.3+, + for example `brew install node` (the keg-only `brew install node@24` is + also covered by the search path) or via the official nodejs.org installer. + An fnm/volta installation needs a plain installation or a `~/.local/bin` + symlink the App can resolve. +3. `node_found` is `true` with a `node_version` older than 22.22.3: the App + reaches a Node that is too old, and Core reports the same + `node_unavailable`. Installing another version does not fix this by itself. + The App runs the `node` from the first search path entry that holds one, + for example a `~/.local/bin/node` ahead of every Homebrew location, and + Diagnostics report the version but not the path. Check that order, then + update the winning entry: upgrade it in place, or point it at the supported + installation with + `ln -sf /opt/homebrew/opt/node@24/bin/node ~/.local/bin/node` + (`/usr/local/opt/node@24/bin/node` with Intel Homebrew). `node_found` of + `true` with no `node_version` means the App found a `node` it could not read + a version from; replace it with a supported release the same way. +4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The + environment reading refreshes every 30 seconds, or reopen the App. + `node --version` in a terminal only verifies the interactive shell, which + can select a Node the App does not. +5. Press **Repair this version** (or reopen the App); the environment probe refreshes and the live supervisor reconnects the same window without a second App restart. From 1c1ebe5a3809ebe4b8e1fa6291d2fc8108562354 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Mon, 23 Nov 2026 21:43:15 -0800 Subject: [PATCH 03/28] docs(desktop): guard the Node launcher replacement against a missing target The recovery step pointed `~/.local/bin/node` at the keg-only `node@24` path with a bare `ln -sf`. BSD `ln -sf` exits 0 when that target does not exist, so a reader whose supported Node lives elsewhere would trade the original launcher for a dangling link, and a later Node on the search path could let diagnostics pass without the original file ever being restored. The step now sends the reader to a binary they have confirmed, chains the version check ahead of any move, and keeps the old file as `node.before-loopx`. An entry that reports no version is to be inspected before it is replaced. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 766e865f16..c97cd8e836 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -548,12 +548,26 @@ Self-service: The App runs the `node` from the first search path entry that holds one, for example a `~/.local/bin/node` ahead of every Homebrew location, and Diagnostics report the version but not the path. Check that order, then - update the winning entry: upgrade it in place, or point it at the supported - installation with - `ln -sf /opt/homebrew/opt/node@24/bin/node ~/.local/bin/node` - (`/usr/local/opt/node@24/bin/node` with Intel Homebrew). `node_found` of - `true` with no `node_version` means the App found a `node` it could not read - a version from; replace it with a supported release the same way. + update the winning entry. Point it at a supported Node you have confirmed, + such as `/opt/homebrew/opt/node@24/bin/node` after `brew install node@24` + (`/usr/local/opt/node@24/bin/node` with Intel Homebrew) or the path your own + supported Node is installed at, and keep the old file. Do not use `ln -sf` + on its own: it succeeds even when its target is missing and leaves a + dangling link in place of the original. + + ```bash + node= && + "$node" --version && + mv ~/.local/bin/node ~/.local/bin/node.before-loopx && + ln -s "$node" ~/.local/bin/node + ``` + + The first two lines stop the sequence when that binary is missing. Read the + version they print and continue only for 22.22.3 or newer; the old file is + kept as `node.before-loopx` either way. `node_found` of `true` with no + `node_version` means the App found a `node` it could not read a version + from: inspect that entry with `ls -l` and the same `--version` call before + replacing it the same way. 4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The environment reading refreshes every 30 seconds, or reopen the App. `node --version` in a terminal only verifies the interactive shell, which From 6516e9fe2ccf0f492cf2a4e555d219c2bf5998dc Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Mon, 23 Nov 2026 23:01:42 -0800 Subject: [PATCH 04/28] docs(desktop): make the Node replacement self-guarding and retry-safe The recovery step had two gaps. The version check and the replacement were separate blocks, so pasting both ran the move even when the candidate was older than 22.22.3 (`--version` succeeds for any runnable node). And the timestamped backup replaced a previous backup on retry, losing it. The step is now one chained command: `--version` prints the candidate, a numeric guard re-checks the same version against 22.22.3, and the move and link only run when every earlier line succeeded. The backup name is timestamped per attempt, so retries accumulate instead of overwriting. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index c97cd8e836..6c6cb9274b 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -555,19 +555,25 @@ Self-service: on its own: it succeeds even when its target is missing and leaves a dangling link in place of the original. + Run the block below in one Terminal window; every line is chained, so the + sequence stops before anything is moved when the candidate is missing or + older than 22.22.3. `--version` prints the candidate for you to read, and + the third line re-checks the same version numerically. + ```bash node= && "$node" --version && - mv ~/.local/bin/node ~/.local/bin/node.before-loopx && + "$node" -e "const [maj,min,pat]=process.versions.node.split('.').map(Number);process.exit(maj>22||(maj===22&&(min>22||(min===22&&pat>=3)))?0:1)" && + mv ~/.local/bin/node ~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && ln -s "$node" ~/.local/bin/node ``` - The first two lines stop the sequence when that binary is missing. Read the - version they print and continue only for 22.22.3 or newer; the old file is - kept as `node.before-loopx` either way. `node_found` of `true` with no - `node_version` means the App found a `node` it could not read a version - from: inspect that entry with `ls -l` and the same `--version` call before - replacing it the same way. + The backup name is timestamped, so a retry keeps every earlier backup + instead of overwriting one; restore by copying the newest + `node.before-loopx-*` back over `~/.local/bin/node`. `node_found` of `true` + with no `node_version` means the App found a `node` it could not read a + version from: inspect that entry with `ls -l` and the same `--version` call + before replacing it the same way. 4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The environment reading refreshes every 30 seconds, or reopen the App. `node --version` in a terminal only verifies the interactive shell, which From 89639195ce85451a2ee038bd4701e4e3ebcbe377 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 06:26:26 -0800 Subject: [PATCH 05/28] docs(desktop): verify the Node backup and make restore self-contained The fifth review round verified the older-Node precedence guidance and the missing-target protection, and confirmed the first repair keeps the original bytes. Two gaps remained in the recovery half: two repairs inside the same second chose the same timestamped backup name and the second `mv` replaced the first backup, and the restore line copied through the launcher symlink, which follows it and rewrites the supported Node binary other tools share. The replacement now fails closed on an existing backup name (`[ ! -e ] && [ ! -L ]` ahead of the move), and the restore removes the launcher entry before copying the newest backup in, so `cp` creates a fresh regular file instead of writing through the link. `shasum` brackets the restore and no longer depends on the repair-time variable. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 37 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 6c6cb9274b..acc8459b2d 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -564,16 +564,39 @@ Self-service: node= && "$node" --version && "$node" -e "const [maj,min,pat]=process.versions.node.split('.').map(Number);process.exit(maj>22||(maj===22&&(min>22||(min===22&&pat>=3)))?0:1)" && - mv ~/.local/bin/node ~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && + backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && + [ ! -e "$backup" ] && [ ! -L "$backup" ] && + mv ~/.local/bin/node "$backup" && ln -s "$node" ~/.local/bin/node ``` - The backup name is timestamped, so a retry keeps every earlier backup - instead of overwriting one; restore by copying the newest - `node.before-loopx-*` back over `~/.local/bin/node`. `node_found` of `true` - with no `node_version` means the App found a `node` it could not read a - version from: inspect that entry with `ls -l` and the same `--version` call - before replacing it the same way. + If the backup name already exists — two repairs within the same second — + the test stops the chain before anything is moved and the original stays in + place; run the block again a second later. + + To restore a backup, replace the launcher directory entry instead of + copying through the link, or `cp` would follow the link and overwrite the + supported Node binary that other tools share: + + ```bash + newest=$(ls -t ~/.local/bin/node.before-loopx.* | head -1) && + shasum "$newest" && + rm ~/.local/bin/node && + cp "$newest" ~/.local/bin/node && + shasum "$newest" ~/.local/bin/node + ``` + + The two `shasum` lines must match: the first reads the backup, the second + reads the restored launcher. Removing the link entry before `cp` is what + keeps the supported Node binary safe — the copy creates a fresh regular + file instead of following the link into a binary other tools share. + + The `shasum` lines bracket the copy: the first is the backup you are + restoring, the second must match it after the copy, proving the candidate + binary behind the removed link kept its original bytes. `node_found` of + `true` with no `node_version` means the App found a `node` it could not + read a version from: inspect that entry with `ls -l` and the same + `--version` call before replacing it the same way. 4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The environment reading refreshes every 30 seconds, or reopen the App. `node --version` in a terminal only verifies the interactive shell, which From c40472744ab9266f5589534784ec8d99f5074767 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 08:07:15 -0800 Subject: [PATCH 06/28] docs(desktop): reserve the Node backup atomically and restore its entry type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The recovery steps still had two holes. The existence check and the move were separate lines, so two repairs started in the same second (from two Terminal windows) both passed the check and the second move replaced the only backup — a symlink by then — losing the original launcher bytes. And the restore copied the backup through `cp` without regard to its entry type: when the original launcher was itself a symlink into a version manager, the copy turned the restored entry into a regular file pinned to one version, losing the route. The replacement reserves the backup slot with `mkdir`, which is atomic and exclusive: the losing repair stops with the original launcher untouched. The restore now preserves the backup's entry type — a symlink is recreated with the same target so version-manager updates keep being followed, a regular file is copied byte for byte — and removes the current entry before the copy so nothing writes through the link into the supported binary. The `shasum` bracket reads the backup's launcher and the restored entry; the sequence no longer depends on the repair-time variable. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 55 +++++++++++++--------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index acc8459b2d..76bff47913 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -565,38 +565,47 @@ Self-service: "$node" --version && "$node" -e "const [maj,min,pat]=process.versions.node.split('.').map(Number);process.exit(maj>22||(maj===22&&(min>22||(min===22&&pat>=3)))?0:1)" && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && - [ ! -e "$backup" ] && [ ! -L "$backup" ] && - mv ~/.local/bin/node "$backup" && + mkdir "$backup" && + mv ~/.local/bin/node "$backup/node" && ln -s "$node" ~/.local/bin/node ``` - If the backup name already exists — two repairs within the same second — - the test stops the chain before anything is moved and the original stays in - place; run the block again a second later. + The backup is a directory created atomically: a second repair in the same + second (from this window or another one) fails its `mkdir` and stops with + the original launcher untouched, so concurrent attempts cannot overwrite + each other's only copy of the original. Each attempt owns one directory + holding the launcher it replaced. - To restore a backup, replace the launcher directory entry instead of - copying through the link, or `cp` would follow the link and overwrite the - supported Node binary that other tools share: + To restore a backup, replace the launcher directory entry in the way that + preserves the backup's own entry type, and never copy through the current + link — `cp` would follow it and rewrite the supported Node binary that + other tools share: ```bash - newest=$(ls -t ~/.local/bin/node.before-loopx.* | head -1) && - shasum "$newest" && + newest=$(ls -td ~/.local/bin/node.before-loopx.* | head -1) && + shasum "$newest/node" && rm ~/.local/bin/node && - cp "$newest" ~/.local/bin/node && - shasum "$newest" ~/.local/bin/node + if [ -L "$newest/node" ]; then + ln -s "$(readlink "$newest/node")" ~/.local/bin/node + else + cp "$newest/node" ~/.local/bin/node + fi && + shasum "$newest/node" "$HOME/.local/bin/node" ``` - The two `shasum` lines must match: the first reads the backup, the second - reads the restored launcher. Removing the link entry before `cp` is what - keeps the supported Node binary safe — the copy creates a fresh regular - file instead of following the link into a binary other tools share. - - The `shasum` lines bracket the copy: the first is the backup you are - restoring, the second must match it after the copy, proving the candidate - binary behind the removed link kept its original bytes. `node_found` of - `true` with no `node_version` means the App found a `node` it could not - read a version from: inspect that entry with `ls -l` and the same - `--version` call before replacing it the same way. + The two `shasum` lines bracket the restore: the first reads the backup's + launcher, the second reads the restored entry through its route, and the + two must match. The backup keeps the launcher's own entry type: a symlink + is recreated with the same target, so a later version-manager update is + still followed; a regular file is copied byte for byte. Removing the + current entry before the copy is what keeps the supported Node binary + safe — nothing writes through the link into a binary other tools share. + To double-check the candidate itself, checksum the path you chose as + ``; the restore never writes to it. + + `node_found` of `true` with no `node_version` means the App found a `node` + it could not read a version from: inspect that entry with `ls -l` and the + same `--version` call before replacing it the same way. 4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The environment reading refreshes every 30 seconds, or reopen the App. `node --version` in a terminal only verifies the interactive shell, which From 4ca152c641466f438ab5b6669f742d52dcd026b9 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 09:11:17 -0800 Subject: [PATCH 07/28] docs(desktop): restore relative-symlink backups and a missing launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The restore aborted in two real states. A backup whose launcher was a relative symlink (../../toolchain/node) could not be qualified from the backup subdirectory — the same raw value resolves elsewhere — so the first checksum exited 1 and the repaired launcher stayed in place with the original route lost. And an interrupted repair leaves no launcher at all, so the unconditional `rm` exited 1 before the restore branch ran. The restore no longer dereferences the backup: it reads the raw link value and recreates it at the original location, where a relative link resolves exactly as it did before the repair, and copies regular backups byte for byte. The entry is removed with `rm -f` so a missing launcher restores directly instead of aborting. The final `shasum` on the restored entry is the readback that the original routing works again. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 76bff47913..45da3287d7 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -579,29 +579,31 @@ Self-service: To restore a backup, replace the launcher directory entry in the way that preserves the backup's own entry type, and never copy through the current link — `cp` would follow it and rewrite the supported Node binary that - other tools share: + other tools share. A missing launcher is a recoverable state too: an + interrupted repair leaves only the backup, and `rm -f` accepts that. ```bash newest=$(ls -td ~/.local/bin/node.before-loopx.* | head -1) && - shasum "$newest/node" && - rm ~/.local/bin/node && + rm -f ~/.local/bin/node && if [ -L "$newest/node" ]; then ln -s "$(readlink "$newest/node")" ~/.local/bin/node else cp "$newest/node" ~/.local/bin/node fi && - shasum "$newest/node" "$HOME/.local/bin/node" + shasum ~/.local/bin/node ``` - The two `shasum` lines bracket the restore: the first reads the backup's - launcher, the second reads the restored entry through its route, and the - two must match. The backup keeps the launcher's own entry type: a symlink - is recreated with the same target, so a later version-manager update is - still followed; a regular file is copied byte for byte. Removing the - current entry before the copy is what keeps the supported Node binary - safe — nothing writes through the link into a binary other tools share. - To double-check the candidate itself, checksum the path you chose as - ``; the restore never writes to it. + The backup keeps the launcher's own entry type and raw link value: a + symlink is recreated with its original target string at the original + location, so a relative link resolves exactly as it did before the repair + and a later version-manager update of its target is still followed; a + regular file is copied byte for byte. The final `shasum` reads the + restored entry through its route and is the readback that the original + routing works again. Removing the current entry before the copy is what + keeps the supported Node binary safe — nothing writes through the link + into a binary other tools share. To double-check the candidate itself, + checksum the path you chose as ``; the restore + never writes to it. `node_found` of `true` with no `node_version` means the App found a `node` it could not read a version from: inspect that entry with `ls -l` and the From 45d124e009293c7433d9eec508e7521ed8bfec10 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 10:03:26 -0800 Subject: [PATCH 08/28] docs(desktop): qualify the Node restore entry before removing the launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rollback removed the current launcher before knowing whether the selected backup was restorable. An interrupted repair leaves an empty backup directory, and the newest match could also be an older flat-file backup — in both cases the old sequence removed the working launcher and then failed, leaving nothing. The restore now builds the restored entry beside the launcher first: a backup symlink is recreated with its raw value where the original launcher lived (so a relative link resolves exactly as it did before the repair), a regular backup is copied byte for byte, and `--version` qualifies the staged entry where it will live. Only then does the sequence remove the current launcher and move the staged entry into place. Unusable backups stop the chain with the working launcher intact. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 45da3287d7..82c7ec08f7 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -583,16 +583,32 @@ Self-service: interrupted repair leaves only the backup, and `rm -f` accepts that. ```bash - newest=$(ls -td ~/.local/bin/node.before-loopx.* | head -1) && - rm -f ~/.local/bin/node && - if [ -L "$newest/node" ]; then - ln -s "$(readlink "$newest/node")" ~/.local/bin/node + newest=$(ls -td ~/.local/bin/node.before-loopx.* 2>/dev/null | head -1) && + [ -n "$newest" ] && + staged=~/.local/bin/node.restored."$(date +%Y%m%d-%H%M%S)" && + if [ -d "$newest" ]; then src="$newest/node"; else src="$newest"; fi && + if [ -L "$src" ]; then + ln -s "$(readlink "$src")" "$staged" else - cp "$newest/node" ~/.local/bin/node + cp "$src" "$staged" fi && + "$staged" --version && + rm -f ~/.local/bin/node && + mv "$staged" ~/.local/bin/node && shasum ~/.local/bin/node ``` + The restore builds the restored entry beside the launcher first, so a + backup symlink's raw value is recreated where the original launcher lived + and a relative link resolves exactly as it did before the repair; the + `--version` line then qualifies that entry where it will live. Only after + that does the sequence remove the current launcher and move the staged + entry into place. If no backup exists, the newest one is empty — an + interrupted repair leaves exactly that — or its entry cannot run, the + chain stops with the working launcher still in place and a `node.restored-*` + scratch entry to delete. If the newest backup is unusable but an older one + is complete, restore that older one by naming it instead of `newest`. + The backup keeps the launcher's own entry type and raw link value: a symlink is recreated with its original target string at the original location, so a relative link resolves exactly as it did before the repair From ce1a23e285c7f216ff6b531b5a8a4a85fd83b7a3 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 10:56:34 -0800 Subject: [PATCH 09/28] docs(desktop): normalize the Node candidate to an absolute path before the move MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The repair verified the candidate with the Terminal's current directory in scope, but the final `ln -s "$node" ~/.local/bin/node` resolved the same relative value against `~/.local/bin` — a runnable relative candidate such as `./toolchain/node` produced a dangling launcher while both version checks passed. The chain now rewrites `node` to its absolute path (`cd` + `pwd` over `dirname`/`basename`) after the version guard and re-runs `--version` on the normalized path before anything is moved, and the final line runs the installed launcher link as its own readback. A candidate that only works from the Terminal's current directory therefore fails before the original launcher is touched. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 82c7ec08f7..9e81e2582d 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -564,12 +564,22 @@ Self-service: node= && "$node" --version && "$node" -e "const [maj,min,pat]=process.versions.node.split('.').map(Number);process.exit(maj>22||(maj===22&&(min>22||(min===22&&pat>=3)))?0:1)" && + node="$(cd "$(dirname "$node")" && pwd)/$(basename "$node")" && + "$node" --version && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && mkdir "$backup" && mv ~/.local/bin/node "$backup/node" && - ln -s "$node" ~/.local/bin/node + ln -s "$node" ~/.local/bin/node && + "$HOME/.local/bin/node" --version ``` + The chain normalizes the candidate to an absolute path before anything is + moved: a relative value such as `./toolchain/node` works in the Terminal's + current directory but would dangle from `~/.local/bin`, where the link + actually lives. The second `--version` runs the normalized path and the + final line runs the installed launcher link as its own readback — both must + succeed, and any failure stops before the original launcher is moved. + The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with the original launcher untouched, so concurrent attempts cannot overwrite From f23e07270cec8c6ed42c12ca82d5aa9986e39b27 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 11:30:22 -0800 Subject: [PATCH 10/28] docs(desktop): restore the original launcher when the final check fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two candidate shapes pass the earlier checks and still fail the final version readback through the installed link: an alias that points back at the launcher being replaced (the new link becomes a loop), and a wrapper that locates its toolchain relative to its own directory (it stops working from ~/.local/bin). Both left an unusable launcher in place. The repair now runs the final `--version` through the installed link while the original entry sits in the backup directory, inside an if/else: on success the update stands and the original stays as the recovery artifact; on failure the original entry is moved back — `mv` keeps its entry type, so a symlink route or a regular file returns exactly as it was — the backup directory is removed, and the block exits nonzero. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 9e81e2582d..9930463258 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -569,10 +569,27 @@ Self-service: backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && mkdir "$backup" && mv ~/.local/bin/node "$backup/node" && - ln -s "$node" ~/.local/bin/node && - "$HOME/.local/bin/node" --version + if ln -s "$node" ~/.local/bin/node && + "$HOME/.local/bin/node" --version; then + echo "Node launcher updated to $node (previous entry kept in $backup)" + else + mv "$backup/node" ~/.local/bin/node && + rmdir "$backup" && + echo "The candidate failed the final check; the original launcher was restored." && + exit 1 + fi ``` + The final `--version` runs through the installed link while the original + entry is safely inside the backup directory. Some candidates only pass the + earlier checks: an alias that points back at the launcher being replaced + turns the new link into a loop, and a wrapper that locates Node relative to + its own directory stops working from `~/.local/bin`. Either makes the final + check fail, and the `else` branch then restores the original entry — `mv` + keeps its entry type, so a symlink route or regular file comes back + exactly as it was — and exits nonzero. On success the original entry stays + in the backup directory as the recovery artifact. + The chain normalizes the candidate to an absolute path before anything is moved: a relative value such as `./toolchain/node` works in the Terminal's current directory but would dangle from `~/.local/bin`, where the link From 41ec8de7984248dcf3a0ea542c4fe3771a3780e3 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 12:23:28 -0800 Subject: [PATCH 11/28] docs(desktop): check the installed Node version by its printed value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The final check ran the installed launcher with the numeric floor as a `node -e` argument. A wrapper that does not forward arguments — it prints its own version line and exits 0 — passed that check while resolving an older Node, so Core's probe kept reporting `unsupported` after a repair that announced success. Both floor checks now compare the printed version line instead: `--version` prints the candidate (or the installed launcher), and `awk` compares it numerically against 22.22.3. That works for a real node and for any wrapper that prints a version, whether or not it forwards arguments. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 9930463258..be7489a859 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -563,14 +563,15 @@ Self-service: ```bash node= && "$node" --version && - "$node" -e "const [maj,min,pat]=process.versions.node.split('.').map(Number);process.exit(maj>22||(maj===22&&(min>22||(min===22&&pat>=3)))?0:1)" && + printf '%s\n' "$("$node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;exit !(a[1]>22||(a[1]==22&&(a[2]>22||(a[2]==22&&a[3]>=3))))}' && node="$(cd "$(dirname "$node")" && pwd)/$(basename "$node")" && "$node" --version && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && mkdir "$backup" && mv ~/.local/bin/node "$backup/node" && if ln -s "$node" ~/.local/bin/node && - "$HOME/.local/bin/node" --version; then + "$HOME/.local/bin/node" --version && + printf '%s\n' "$("$HOME/.local/bin/node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;exit !(a[1]>22||(a[1]==22&&(a[2]>22||(a[2]==22&&a[3]>=3))))}'; then echo "Node launcher updated to $node (previous entry kept in $backup)" else mv "$backup/node" ~/.local/bin/node && @@ -580,22 +581,21 @@ Self-service: fi ``` - The final `--version` runs through the installed link while the original - entry is safely inside the backup directory. Some candidates only pass the - earlier checks: an alias that points back at the launcher being replaced - turns the new link into a loop, and a wrapper that locates Node relative to - its own directory stops working from `~/.local/bin`. Either makes the final - check fail, and the `else` branch then restores the original entry — `mv` - keeps its entry type, so a symlink route or regular file comes back - exactly as it was — and exits nonzero. On success the original entry stays - in the backup directory as the recovery artifact. - - The chain normalizes the candidate to an absolute path before anything is - moved: a relative value such as `./toolchain/node` works in the Terminal's - current directory but would dangle from `~/.local/bin`, where the link - actually lives. The second `--version` runs the normalized path and the - final line runs the installed launcher link as its own readback — both must - succeed, and any failure stops before the original launcher is moved. + The final two checks run through the installed link while the original + entry is safely inside the backup directory: `--version` proves the entry + executes, and the numeric guard re-checks the same 22.22.3 floor through + it — a wrapper that runs but resolves an older Node fails the second line + and is treated exactly like an execution failure. Some candidates only + pass the earlier checks: an alias that points back at the launcher being + replaced turns the new link into a loop, and a wrapper that locates Node + relative to its own directory stops working from `~/.local/bin`. Either + makes the final check fail, and the `else` branch then restores the + original entry — `mv` keeps its entry type, so a symlink route or regular + file comes back exactly as it was — and exits nonzero. On success the + original entry stays in the backup directory as the recovery artifact. + The pre-move checks qualify the candidate from the Terminal; the installed + link is qualified after the swap, with the restore above as the undo path + for that last step. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From 997b23b8a4be37b008a2cf324c4a06288639d6e9 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 13:02:34 -0800 Subject: [PATCH 12/28] docs(desktop): match the version floor to Core's prerelease qualification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The numeric awk floor split the version on dots, pluses and hyphens and compared the first three fields, so `v22.22.3-rc.1` — a prerelease sitting exactly on the 22.22.3 minimum — passed both checks while Core's `probe_node` classifies the same string as `unsupported` (`version == MINIMUM_NODE_VERSION and prerelease is not None`). Both floor checks now follow Core's qualification: the base triple must reach 22.22.3, and a base exactly on the minimum is rejected when the version carries a prerelease suffix (`index($0, "-")`). Build metadata without a hyphen still qualifies. A position-selecting launcher that reports the prerelease through the installed link now fails the final check and takes the existing restore path instead of announcing success. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index be7489a859..a57660f394 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -563,7 +563,7 @@ Self-service: ```bash node= && "$node" --version && - printf '%s\n' "$("$node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;exit !(a[1]>22||(a[1]==22&&(a[2]>22||(a[2]==22&&a[3]>=3))))}' && + printf '%s\n' "$("$node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;maj=a[1]+0;min=a[2]+0;pat=a[3]+0;if(maj<22)exit 1;if(maj==22&&min<22)exit 1;if(maj==22&&min==22&&pat<3)exit 1;if(maj==22&&min==22&&pat==3&&index($0,"-")>0)exit 1;exit 0}' && node="$(cd "$(dirname "$node")" && pwd)/$(basename "$node")" && "$node" --version && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && @@ -571,7 +571,7 @@ Self-service: mv ~/.local/bin/node "$backup/node" && if ln -s "$node" ~/.local/bin/node && "$HOME/.local/bin/node" --version && - printf '%s\n' "$("$HOME/.local/bin/node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;exit !(a[1]>22||(a[1]==22&&(a[2]>22||(a[2]==22&&a[3]>=3))))}'; then + printf '%s\n' "$("$HOME/.local/bin/node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;maj=a[1]+0;min=a[2]+0;pat=a[3]+0;if(maj<22)exit 1;if(maj==22&&min<22)exit 1;if(maj==22&&min==22&&pat<3)exit 1;if(maj==22&&min==22&&pat==3&&index($0,"-")>0)exit 1;exit 0}'; then echo "Node launcher updated to $node (previous entry kept in $backup)" else mv "$backup/node" ~/.local/bin/node && From 0c1e4b7e56b9dfef22805201b3ec23bb774d484c Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 13:43:08 -0800 Subject: [PATCH 13/28] docs(desktop): qualify the whole Node version output, not just one line The version judgment piped the captured output through grep and awk line by line, so a launcher whose first output line was a valid version passed the checks even when later lines made the full output something Core's `probe_node` would reject as `invalid_version`. `node_qualifies` now rejects multi-line (or carriage-return-bearing) output before any matching, and the shape check runs on the whole captured string: exactly one `v?[maj.min.pat]` line with an optional prerelease after `-` and an optional build after `+`. The floor then applies Core's qualification, including the build-versus-prerelease distinction that keeps `22.22.3+build-5` qualifying while a prerelease sitting on the minimum is rejected. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 57 +++++++++++++++------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index a57660f394..7c4db0e1ba 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -562,16 +562,41 @@ Self-service: ```bash node= && + node_qualifies() { + case "$1" in + *$'\n'* | *$'\r'*) return 1 ;; + esac + printf '%s\n' "$1" | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$' || return 1 + printf '%s\n' "$1" | awk ' + { + sub(/^v/, "") + n = split($0, a, /[.+-]/) + if (n < 3) exit 1 + maj = a[1] + 0; min = a[2] + 0; pat = a[3] + 0 + if (maj < 22) exit 1 + if (maj == 22 && min < 22) exit 1 + if (maj == 22 && min == 22 && pat < 3) exit 1 + if (maj == 22 && min == 22 && pat == 3) { + plus = index($0, "+") + dash = index($0, "-") + if (dash > 0 && (plus == 0 || dash < plus)) exit 1 + } + exit 0 + }' + } "$node" --version && - printf '%s\n' "$("$node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;maj=a[1]+0;min=a[2]+0;pat=a[3]+0;if(maj<22)exit 1;if(maj==22&&min<22)exit 1;if(maj==22&&min==22&&pat<3)exit 1;if(maj==22&&min==22&&pat==3&&index($0,"-")>0)exit 1;exit 0}' && + node_ver="$("$node" --version)" && + node_qualifies "$node_ver" && node="$(cd "$(dirname "$node")" && pwd)/$(basename "$node")" && "$node" --version && + node_ver="$("$node" --version)" && + node_qualifies "$node_ver" && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && mkdir "$backup" && mv ~/.local/bin/node "$backup/node" && if ln -s "$node" ~/.local/bin/node && - "$HOME/.local/bin/node" --version && - printf '%s\n' "$("$HOME/.local/bin/node" --version)" | awk '{sub(/^v/,"");n=split($0,a,/[.+-]/);if(n<3)exit 1;maj=a[1]+0;min=a[2]+0;pat=a[3]+0;if(maj<22)exit 1;if(maj==22&&min<22)exit 1;if(maj==22&&min==22&&pat<3)exit 1;if(maj==22&&min==22&&pat==3&&index($0,"-")>0)exit 1;exit 0}'; then + installed_ver="$("$HOME/.local/bin/node" --version)" && + node_qualifies "$installed_ver"; then echo "Node launcher updated to $node (previous entry kept in $backup)" else mv "$backup/node" ~/.local/bin/node && @@ -581,21 +606,17 @@ Self-service: fi ``` - The final two checks run through the installed link while the original - entry is safely inside the backup directory: `--version` proves the entry - executes, and the numeric guard re-checks the same 22.22.3 floor through - it — a wrapper that runs but resolves an older Node fails the second line - and is treated exactly like an execution failure. Some candidates only - pass the earlier checks: an alias that points back at the launcher being - replaced turns the new link into a loop, and a wrapper that locates Node - relative to its own directory stops working from `~/.local/bin`. Either - makes the final check fail, and the `else` branch then restores the - original entry — `mv` keeps its entry type, so a symlink route or regular - file comes back exactly as it was — and exits nonzero. On success the - original entry stays in the backup directory as the recovery artifact. - The pre-move checks qualify the candidate from the Terminal; the installed - link is qualified after the swap, with the restore above as the undo path - for that last step. + `node_qualifies` is the single version judgment shared by the candidate + and the installed link, and it follows `probe_node()`: the whole captured + output must be exactly one `v?[maj.min.pat]` line — extra output lines + fail the newline check before anything is matched — with an optional + prerelease after `-` and an optional build after `+`; malformed fields or + missing segments fail the shape check. The base triple must reach + 22.22.3, and a base sitting exactly on the minimum is rejected when a + prerelease is present, while `22.22.3+build-5`, whose hyphen belongs to + the build metadata, still qualifies. The installed link is qualified + through the same function after the swap, with the `else` branch above as + the undo path. The two `--version` lines remain as the readback prints. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From dc3a0f1c17d979da70b313acd7896fbedd9d2969 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 14:15:18 -0800 Subject: [PATCH 14/28] docs(desktop): trim the Node version output before the qualification checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Core's `probe_node` strips the whole captured output first and then applies its fullmatch and floor, so a launcher whose version line uses CRLF line endings or carries surrounding whitespace is `ready` for Core. The README's qualification rejected the carriage return and outer whitespace before its own checks, refusing launchers Core accepts — including after the link swap, where the restore was the only way back. `node_qualifies` now follows Core's order: the whole captured output is trimmed of surrounding whitespace and carriage returns first, and the single-line, shape, and floor checks run on that normalized result. Extra non-empty lines inside the output still fail, and the restore path is unchanged. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 7c4db0e1ba..e899a40dee 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -563,11 +563,12 @@ Self-service: ```bash node= && node_qualifies() { - case "$1" in - *$'\n'* | *$'\r'*) return 1 ;; + normalized="$(printf '%s' "$1" | tr -d '\r' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + case "$normalized" in + '' | *$'\n'*) return 1 ;; esac - printf '%s\n' "$1" | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$' || return 1 - printf '%s\n' "$1" | awk ' + printf '%s\n' "$normalized" | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$' || return 1 + printf '%s\n' "$normalized" | awk ' { sub(/^v/, "") n = split($0, a, /[.+-]/) @@ -607,16 +608,17 @@ Self-service: ``` `node_qualifies` is the single version judgment shared by the candidate - and the installed link, and it follows `probe_node()`: the whole captured - output must be exactly one `v?[maj.min.pat]` line — extra output lines - fail the newline check before anything is matched — with an optional - prerelease after `-` and an optional build after `+`; malformed fields or - missing segments fail the shape check. The base triple must reach - 22.22.3, and a base sitting exactly on the minimum is rejected when a - prerelease is present, while `22.22.3+build-5`, whose hyphen belongs to - the build metadata, still qualifies. The installed link is qualified - through the same function after the swap, with the `else` branch above as - the undo path. The two `--version` lines remain as the readback prints. + and the installed link, and it follows `probe_node()`'s order: the whole + captured output is trimmed of its surrounding whitespace and carriage + returns first, and the single-line, shape, and floor checks then run on + that normalized result — a CRLF or whitespace-padded launcher output + qualifies exactly as the plain form does. Extra non-empty lines inside + the output still fail, the base triple must reach 22.22.3, and a base + sitting exactly on the minimum is rejected when a prerelease is present, + while `22.22.3+build-5`, whose hyphen belongs to the build metadata, + still qualifies. The installed link is qualified through the same + function after the swap, with the `else` branch above as the undo path. + The two `--version` lines remain as the readback prints. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From 6d787f66ddd63d9c66ca32a73911d998fd554229 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 15:31:05 -0800 Subject: [PATCH 15/28] docs(desktop): trim the Node output at its boundaries and cover first creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three recovery gaps remained. The output cleanup deleted every carriage return, so a version whose interior contained one was repaired into a qualifying string Core still rejects as invalid. The replacement assumed `~/.local/bin/node` already existed and the `mv` failed when nvm put an old Node first with no local launcher present. And the Diagnostics panel cannot read a version out of build metadata, which blocked the confirmation step. `node_trim` now strips only the leading and trailing whitespace of the whole captured output — interior characters are preserved, so an interior carriage return fails the shape check exactly as it fails Core's fullmatch. The repair branches on whether the launcher exists: the existing entry is backed up and can be restored on failure, and a missing launcher is created for the first time with a remove-the-link undo. The confirmation step documents that a blank Diagnostics version with a Core ready state is the build-metadata case and points at the validated candidate. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 72 ++++++++++++++-------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index e899a40dee..ead35ea689 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -563,9 +563,9 @@ Self-service: ```bash node= && node_qualifies() { - normalized="$(printf '%s' "$1" | tr -d '\r' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + normalized="$(node_trim "$1")" case "$normalized" in - '' | *$'\n'*) return 1 ;; + '' | *$'\n'* | *$'\r'*) return 1 ;; esac printf '%s\n' "$normalized" | grep -Eq '^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$' || return 1 printf '%s\n' "$normalized" | awk ' @@ -585,40 +585,62 @@ Self-service: exit 0 }' } + node_trim() { + n="${1#"${1%%[![:space:]]*}"}" + printf '%s' "${n%"${n##*[![:space:]]}"}" + } "$node" --version && - node_ver="$("$node" --version)" && + node_ver="$(node_trim "$("$node" --version)")" && node_qualifies "$node_ver" && node="$(cd "$(dirname "$node")" && pwd)/$(basename "$node")" && "$node" --version && - node_ver="$("$node" --version)" && + node_ver="$(node_trim "$("$node" --version)")" && node_qualifies "$node_ver" && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && mkdir "$backup" && - mv ~/.local/bin/node "$backup/node" && - if ln -s "$node" ~/.local/bin/node && - installed_ver="$("$HOME/.local/bin/node" --version)" && - node_qualifies "$installed_ver"; then - echo "Node launcher updated to $node (previous entry kept in $backup)" + if [ -e ~/.local/bin/node ] || [ -L ~/.local/bin/node ]; then + mv ~/.local/bin/node "$backup/node" && + if ln -s "$node" ~/.local/bin/node && + installed_ver="$(node_trim "$("$HOME/.local/bin/node" --version)")" && + node_qualifies "$installed_ver"; then + echo "Node launcher updated to $node (previous entry kept in $backup)" + else + mv "$backup/node" ~/.local/bin/node && + rmdir "$backup" && + echo "The candidate failed the final check; the original launcher was restored." && + exit 1 + fi else - mv "$backup/node" ~/.local/bin/node && - rmdir "$backup" && - echo "The candidate failed the final check; the original launcher was restored." && - exit 1 + if ln -s "$node" ~/.local/bin/node && + installed_ver="$(node_trim "$("$HOME/.local/bin/node" --version)")" && + node_qualifies "$installed_ver"; then + echo "Node launcher created at ~/.local/bin/node (remove the link to undo)" + else + rm -f ~/.local/bin/node && + echo "The candidate failed the final check; nothing was changed." && + exit 1 + fi fi ``` - `node_qualifies` is the single version judgment shared by the candidate - and the installed link, and it follows `probe_node()`'s order: the whole - captured output is trimmed of its surrounding whitespace and carriage - returns first, and the single-line, shape, and floor checks then run on - that normalized result — a CRLF or whitespace-padded launcher output - qualifies exactly as the plain form does. Extra non-empty lines inside - the output still fail, the base triple must reach 22.22.3, and a base - sitting exactly on the minimum is rejected when a prerelease is present, - while `22.22.3+build-5`, whose hyphen belongs to the build metadata, - still qualifies. The installed link is qualified through the same - function after the swap, with the `else` branch above as the undo path. - The two `--version` lines remain as the readback prints. + `node_trim` follows `probe_node()`'s boundary handling: it removes the + leading and trailing whitespace of the whole captured output — including + CRLF endings and blank leading lines — and leaves every interior + character alone, so an interior carriage return fails the shape check + exactly as it fails Core's fullmatch. `node_qualifies` is the single + version judgment shared by the candidate and the installed link: the + normalized output must be exactly one `v?[maj.min.pat]` line with an + optional prerelease after `-` and an optional build after `+`; malformed + fields or missing segments fail. The base triple must reach 22.22.3, and + a base sitting exactly on the minimum is rejected when a prerelease is + present, while `22.22.3+build-5`, whose hyphen belongs to the build + metadata, still qualifies. The installed link is qualified through the + same function after the swap; the two failure branches above are the undo + paths, and the `--version` lines remain as the readback prints. When + `~/.local/bin/node` does not exist yet — an nvm-managed old Node can be + first in the search order with no local launcher — the `else` branch + creates the link for the first time, and removing that link undoes the + whole step. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From 78332868dc3deac99c052ed66e223462dc72646d Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 16:06:21 -0800 Subject: [PATCH 16/28] docs(desktop): read the installed version through the link and create the parent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous edit captured the installed version before the link existed — the capture ran after the launcher was moved into the backup and before `ln -s`, so every replacement failed with a missing-file error and the fresh-HOME branch never created anything. The capture now follows the link: `ln -s` installs the entry, then `installed_raw` reads through it, `node_trim` normalizes, and `node_qualifies` applies the floor — all inside the branch's condition, so a wrapper that prints a qualifying version but exits nonzero fails the check and the original launcher is restored. The backup creation uses `mkdir -p` so a HOME without `~/.local/bin` can still follow the recovery. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index ead35ea689..3cafe93218 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -590,18 +590,20 @@ Self-service: printf '%s' "${n%"${n##*[![:space:]]}"}" } "$node" --version && - node_ver="$(node_trim "$("$node" --version)")" && + raw_ver="$("$node" --version)" && + node_ver="$(node_trim "$raw_ver")" && node_qualifies "$node_ver" && node="$(cd "$(dirname "$node")" && pwd)/$(basename "$node")" && - "$node" --version && - node_ver="$(node_trim "$("$node" --version)")" && + raw_ver="$("$node" --version)" && + node_ver="$(node_trim "$raw_ver")" && node_qualifies "$node_ver" && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && - mkdir "$backup" && + mkdir -p "$backup" && if [ -e ~/.local/bin/node ] || [ -L ~/.local/bin/node ]; then mv ~/.local/bin/node "$backup/node" && if ln -s "$node" ~/.local/bin/node && - installed_ver="$(node_trim "$("$HOME/.local/bin/node" --version)")" && + installed_raw="$("$HOME/.local/bin/node" --version)" && + installed_ver="$(node_trim "$installed_raw")" && node_qualifies "$installed_ver"; then echo "Node launcher updated to $node (previous entry kept in $backup)" else @@ -612,7 +614,8 @@ Self-service: fi else if ln -s "$node" ~/.local/bin/node && - installed_ver="$(node_trim "$("$HOME/.local/bin/node" --version)")" && + installed_raw="$("$HOME/.local/bin/node" --version)" && + installed_ver="$(node_trim "$installed_raw")" && node_qualifies "$installed_ver"; then echo "Node launcher created at ~/.local/bin/node (remove the link to undo)" else @@ -699,7 +702,13 @@ Self-service: 4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The environment reading refreshes every 30 seconds, or reopen the App. `node --version` in a terminal only verifies the interactive shell, which - can select a Node the App does not. + can select a Node the App does not. When Diagnostics reports + `node_found: true` with a blank `node_version` — the App's numeric parser + cannot read a version carrying build metadata, while Core already + qualified the same binary — the repair block above has validated that + exact binary against the floor; press **Repair this version** and treat + the blank field as the build-metadata display case rather than a + blocker. 5. Press **Repair this version** (or reopen the App); the environment probe refreshes and the live supervisor reconnects the same window without a second App restart. From 6e3155684583f6f195c6ec40891cd2f4980ddd5a Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 16:31:17 -0800 Subject: [PATCH 17/28] docs(desktop): exclusive backup slot and a narrower blank-version exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous edit used `mkdir -p` for the backup directory, so a second repair in the same second accepted the existing backup directory and its `mv` replaced the preserved original launcher inside it. And the blank Diagnostics version sent every reader to Repair, while a blank version can also mean a failed or unparseable probe. The existing-entry branch reserves the backup slot with a plain `mkdir` (atomic and exclusive — a same-second rerun stops there with the original preserved), and only the first-creation branch creates the parent with `mkdir -p`. The confirmation step now directs the reader to Repair only when the repair block itself succeeded — it verified the actual hit entry with an exiting `--version`, confirmed the raw version carries build metadata, and qualified it against the floor — and routes any other blank version through the earlier replace-or-restore steps. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 3cafe93218..07b55883c9 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -598,8 +598,8 @@ Self-service: node_ver="$(node_trim "$raw_ver")" && node_qualifies "$node_ver" && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && - mkdir -p "$backup" && if [ -e ~/.local/bin/node ] || [ -L ~/.local/bin/node ]; then + mkdir "$backup" && mv ~/.local/bin/node "$backup/node" && if ln -s "$node" ~/.local/bin/node && installed_raw="$("$HOME/.local/bin/node" --version)" && @@ -613,6 +613,7 @@ Self-service: exit 1 fi else + mkdir -p ~/.local/bin && if ln -s "$node" ~/.local/bin/node && installed_raw="$("$HOME/.local/bin/node" --version)" && installed_ver="$(node_trim "$installed_raw")" && @@ -702,13 +703,14 @@ Self-service: 4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The environment reading refreshes every 30 seconds, or reopen the App. `node --version` in a terminal only verifies the interactive shell, which - can select a Node the App does not. When Diagnostics reports - `node_found: true` with a blank `node_version` — the App's numeric parser - cannot read a version carrying build metadata, while Core already - qualified the same binary — the repair block above has validated that - exact binary against the floor; press **Repair this version** and treat - the blank field as the build-metadata display case rather than a - blocker. + can select a Node the App does not. A blank `node_version` with + `node_found: true` covers several states: the build-metadata display gap, + a launcher that failed during the probe, or output the parser could not + read. Only continue to **Repair this version** when the repair block + itself succeeded — it verified the actual hit entry with an exiting + `--version`, confirmed the raw version carries build metadata, and + qualified it against the floor. Any other blank version follows the + earlier replace-or-restore steps instead. 5. Press **Repair this version** (or reopen the App); the environment probe refreshes and the live supervisor reconnects the same window without a second App restart. From e7fd55b8e61b86744685868f4259d96e59702189 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 18:40:20 -0800 Subject: [PATCH 18/28] docs(desktop): conditional Node cleanup and a qualification-driven readback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first-creation failure branch removed `~/.local/bin/node` unconditionally. When two windows interleave — one in the existing-entry branch whose final check fails and restores the original launcher, the other in the first-creation branch whose `ln` then fails with "File exists" — that `rm -f` deleted the just-restored original launcher. The failure branch now removes an entry only when it is still this operation's own candidate link (`[ -L ]` plus `readlink` equality); a restored regular file or a foreign symlink stays in place. Step 4 now routes by the repair block's own readback instead of the Diagnostics display: the repair qualifies the actual hit entry (exit 0, the raw version satisfying the floor — plain 22.22.3, build metadata, or a prerelease above the floor all qualify — and `probe_node()` reading the same binary as `ready`), so a blank `node_version` there is the App's numeric display gap whenever the repair printed its success line; the restore message sends the reader to the earlier steps instead. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 07b55883c9..1351cd8249 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -700,17 +700,17 @@ Self-service: `node_found` of `true` with no `node_version` means the App found a `node` it could not read a version from: inspect that entry with `ls -l` and the same `--version` call before replacing it the same way. -4. Confirm Diagnostics reports a `node_version` of 22.22.3 or newer. The - environment reading refreshes every 30 seconds, or reopen the App. - `node --version` in a terminal only verifies the interactive shell, which - can select a Node the App does not. A blank `node_version` with - `node_found: true` covers several states: the build-metadata display gap, - a launcher that failed during the probe, or output the parser could not - read. Only continue to **Repair this version** when the repair block - itself succeeded — it verified the actual hit entry with an exiting - `--version`, confirmed the raw version carries build metadata, and - qualified it against the floor. Any other blank version follows the - earlier replace-or-restore steps instead. +4. Confirm the result through the repair block's own readback. The repair + qualifies the actual hit entry: its `--version` must exit 0, the raw + version must satisfy the floor — a plain 22.22.3, build metadata, or a + prerelease above the floor all qualify — and Core's `probe_node()` then + reads the same binary as `ready`. A blank `node_version` in Diagnostics + is the App's numeric display gap, not a qualification failure: when the + repair printed its success line, press **Repair this version**; when it + printed the restore message, follow the earlier replace-or-restore steps + instead. The environment reading refreshes every 30 seconds, or reopen + the App. `node --version` in a terminal only verifies the interactive + shell, which can select a Node the App does not. 5. Press **Repair this version** (or reopen the App); the environment probe refreshes and the live supervisor reconnects the same window without a second App restart. From 5c68713a23d2a1755e07d5bbfb9d5aa4f7154c9f Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 19:10:33 -0800 Subject: [PATCH 19/28] docs(desktop): distinguish a lost link race from a failed qualification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first-creation failure branch removed `~/.local/bin/node` whenever the qualification failed — including the case where the `ln -s` itself failed because another window's repair had just created the entry. Both windows picking the same candidate made the raw-value equality check match the other window's link, and the cleanup deleted a working launcher. The branch now nests: a failed `ln -s` means another window's repair owns the entry, and that path only reports and exits — it never removes anything. Only a link this operation actually created can reach the qualification-failure cleanup, where removing it restores the pre-repair state. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 1351cd8249..babf6310cf 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -614,14 +614,21 @@ Self-service: fi else mkdir -p ~/.local/bin && - if ln -s "$node" ~/.local/bin/node && - installed_raw="$("$HOME/.local/bin/node" --version)" && - installed_ver="$(node_trim "$installed_raw")" && - node_qualifies "$installed_ver"; then - echo "Node launcher created at ~/.local/bin/node (remove the link to undo)" + created=0 + if ln -s "$node" ~/.local/bin/node; then + created=1 + if installed_raw="$("$HOME/.local/bin/node" --version)" && + installed_ver="$(node_trim "$installed_raw")" && + node_qualifies "$installed_ver"; then + echo "Node launcher created at ~/.local/bin/node (remove the link to undo)" + else + rm -f ~/.local/bin/node && + echo "The candidate failed the final check; nothing was changed." && + exit 1 + fi else - rm -f ~/.local/bin/node && - echo "The candidate failed the final check; nothing was changed." && + # the entry already exists: another window's successful repair owns it + echo "Another repair created the launcher; nothing was changed." && exit 1 fi fi @@ -639,12 +646,12 @@ Self-service: a base sitting exactly on the minimum is rejected when a prerelease is present, while `22.22.3+build-5`, whose hyphen belongs to the build metadata, still qualifies. The installed link is qualified through the - same function after the swap; the two failure branches above are the undo + same function after the swap; the failure branches above are the undo paths, and the `--version` lines remain as the readback prints. When `~/.local/bin/node` does not exist yet — an nvm-managed old Node can be - first in the search order with no local launcher — the `else` branch - creates the link for the first time, and removing that link undoes the - whole step. + first in the search order with no local launcher — the first-creation + branch creates the link; its `ln` failure means another window's repair + already created and qualified one, and that entry is left in place. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From 23945f9d915279aac41349696be7d7a368d10f06 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 19:47:33 -0800 Subject: [PATCH 20/28] docs(desktop): inode ownership guard on the first-creation cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: window A's first creation installs the link, but A's final version check is still pending when window B's existing-entry replacement swaps in its own qualifying entry and exits 0. A's late final check then fails, and the failure branch's `rm -f` deleted B's verified entry. The first-creation branch now records the created link's inode and its failure cleanup removes the entry only when the inode still matches — an atomic ownership proof. A later window's swap changes the inode, so the late failure leaves that window's verified entry in place; a failure of A's own link still removes it. The existing-entry branch keeps its exclusive-backup protection unchanged. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index babf6310cf..417fe0e77a 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -614,15 +614,18 @@ Self-service: fi else mkdir -p ~/.local/bin && - created=0 if ln -s "$node" ~/.local/bin/node; then - created=1 + created_ino="$(stat -f %i ~/.local/bin/node)" && if installed_raw="$("$HOME/.local/bin/node" --version)" && installed_ver="$(node_trim "$installed_raw")" && node_qualifies "$installed_ver"; then echo "Node launcher created at ~/.local/bin/node (remove the link to undo)" else - rm -f ~/.local/bin/node && + # undo only when the entry is still this operation's own link; a + # later window's swap has a different inode and stays in place + if [ "$(stat -f %i ~/.local/bin/node 2>/dev/null)" = "$created_ino" ]; then + rm -f ~/.local/bin/node + fi && echo "The candidate failed the final check; nothing was changed." && exit 1 fi From 76fbbd047cda98cbe9eccfc1ba2fe4634f39dc6d Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 20:22:12 -0800 Subject: [PATCH 21/28] docs(desktop): guard the replacement rollback by launcher ownership MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: with an old launcher present, window A moves it into its exclusive backup and installs a candidate whose final check is still pending; window B then replaces A's installed link with its own qualifying candidate and exits 0. A's final check fails and the failure branch moved the original back unconditionally, overwriting B's verified launcher — the working Node regressed from B's 24.21.0 to the 22.22.2 original. The replacement branch now records the installed link's inode and the failure rollback moves the original back only while the entry is still absent or still the failed attempt's own link. A later window's swap has a different inode and stays in place, with the failed attempt's backup kept for the documented manual restore; a vanished entry still restores. Same atomic ownership proof as the first-creation branch, avoiding a lockfile whose stale state from a killed window would block future repairs. Step 4 routes the newer-kept message to Repair this version. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 417fe0e77a..56b331ca3d 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -602,14 +602,22 @@ Self-service: mkdir "$backup" && mv ~/.local/bin/node "$backup/node" && if ln -s "$node" ~/.local/bin/node && + installed_ino="$(stat -f %i ~/.local/bin/node)" && installed_raw="$("$HOME/.local/bin/node" --version)" && installed_ver="$(node_trim "$installed_raw")" && node_qualifies "$installed_ver"; then echo "Node launcher updated to $node (previous entry kept in $backup)" else - mv "$backup/node" ~/.local/bin/node && - rmdir "$backup" && - echo "The candidate failed the final check; the original launcher was restored." && + # restore only when nothing else owns the entry: absent, or still + # this operation's own link; a later window's swap stays in place + if { [ ! -e ~/.local/bin/node ] && [ ! -L ~/.local/bin/node ]; } || + [ "$(stat -f %i ~/.local/bin/node 2>/dev/null)" = "$installed_ino" ]; then + mv "$backup/node" ~/.local/bin/node && + rmdir "$backup" && + echo "The candidate failed the final check; the original launcher was restored." + else + echo "The candidate failed the final check; a newer launcher from another repair was kept, and the previous launcher is still in $backup." + fi && exit 1 fi else @@ -656,11 +664,15 @@ Self-service: branch creates the link; its `ln` failure means another window's repair already created and qualified one, and that entry is left in place. - The backup is a directory created atomically: a second repair in the same - second (from this window or another one) fails its `mkdir` and stops with - the original launcher untouched, so concurrent attempts cannot overwrite - each other's only copy of the original. Each attempt owns one directory - holding the launcher it replaced. + The backup is a directory created atomically: a second repair in the same + second (from this window or another one) fails its `mkdir` and stops with + the original launcher untouched, so concurrent attempts cannot overwrite + each other's only copy of the original. Each attempt owns one directory + holding the launcher it replaced. The failure rollback respects the same + ownership: the original is moved back only while the entry is still absent + or still the failed attempt's own link — a later window's verified launcher + has a different inode and stays in place, and the failed attempt keeps its + backup for the manual restore below. To restore a backup, replace the launcher directory entry in the way that preserves the backup's own entry type, and never copy through the current @@ -716,7 +728,8 @@ Self-service: prerelease above the floor all qualify — and Core's `probe_node()` then reads the same binary as `ready`. A blank `node_version` in Diagnostics is the App's numeric display gap, not a qualification failure: when the - repair printed its success line, press **Repair this version**; when it + repair printed its success line, or the message that a newer launcher + from another repair was kept, press **Repair this version**; when it printed the restore message, follow the earlier replace-or-restore steps instead. The environment reading refreshes every 30 seconds, or reopen the App. `node --version` in a terminal only verifies the interactive From 493846dc08760ccb972041435fdea1b778343cfc Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 21:21:36 -0800 Subject: [PATCH 22/28] docs(desktop): serialize the whole Node repair behind one lock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: the inode comparison and the file action are separate steps, so a window whose final check fails could compare (still the owner), then lose the compare-then-act race when another window swaps its verified launcher in before the restore or delete fires — the inode guard alone cannot close a check-then-act gap. The whole repair now runs inside one exclusive lock: a fixed-name `mkdir` at ~/.local/bin/.node-loopx-repair is taken before either branch and released by an EXIT trap, so a second window stops with "Another repair is in progress; nothing was changed." instead of interleaving its move, install, final check or rollback between this window's steps. A repair killed outright can leave the lock; after 15 minutes an attempt removes and retakes it, and the prose says how to clear a persisting lock by hand. The inode checks stay as the guard for the one overlap the lock cannot close — a suspended window whose stale lock was retaken. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 31 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 56b331ca3d..a5c85d2fc1 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -597,6 +597,20 @@ Self-service: raw_ver="$("$node" --version)" && node_ver="$(node_trim "$raw_ver")" && node_qualifies "$node_ver" && + mkdir -p ~/.local/bin && + lock=~/.local/bin/.node-loopx-repair && + if mkdir "$lock" 2>/dev/null; then + trap 'rm -rf "$lock"' EXIT + else + if [ "$(( $(date +%s) - $(stat -f %m "$lock" 2>/dev/null || date +%s) ))" -gt 900 ] && + rm -rf "$lock" && + mkdir "$lock" 2>/dev/null; then + trap 'rm -rf "$lock"' EXIT + else + echo "Another repair is in progress; nothing was changed." && + exit 1 + fi + fi && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && if [ -e ~/.local/bin/node ] || [ -L ~/.local/bin/node ]; then mkdir "$backup" && @@ -621,7 +635,6 @@ Self-service: exit 1 fi else - mkdir -p ~/.local/bin && if ln -s "$node" ~/.local/bin/node; then created_ino="$(stat -f %i ~/.local/bin/node)" && if installed_raw="$("$HOME/.local/bin/node" --version)" && @@ -664,8 +677,20 @@ Self-service: branch creates the link; its `ln` failure means another window's repair already created and qualified one, and that entry is left in place. - The backup is a directory created atomically: a second repair in the same - second (from this window or another one) fails its `mkdir` and stops with + The whole repair runs inside one lock: the block takes + `~/.local/bin/.node-loopx-repair` with an exclusive `mkdir` before either + branch and releases it on exit, so a second window stops with + "Another repair is in progress; nothing was changed." instead of + interleaving its move, install, final check or rollback between this + window's steps. Rerun the block after the other window finishes. A repair + killed outright can leave the lock behind; after 15 minutes an attempt + removes and retakes it, and if the message persists while no repair is + running, remove that directory by hand. The inode checks inside the two + branches then guard the only overlap the lock cannot close — a suspended + window whose stale lock was retaken by another one. + + The backup is a directory created atomically: a second repair in the same + second (from this window or another one) fails its `mkdir` and stops with the original launcher untouched, so concurrent attempts cannot overwrite each other's only copy of the original. Each attempt owns one directory holding the launcher it replaced. The failure rollback respects the same From efca33f52c7cf3a8db4a7fb4ef35ae24e622530c Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 22:08:27 -0800 Subject: [PATCH 23/28] docs(desktop): release the repair lock only when its holder exits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: the takeover judged a lock stale by directory mtime alone, so it could be stolen from a merely suspended window; that window later completed its compare-then-act cleanup and deleted the verified launcher the takeover window had installed, reporting that nothing was changed. The lock now records the holder's process id. A second window retakes it only after checking that the recorded process no longer exists — a suspended window is alive and keeps the lock, and a killed window's lock is removed and retaken, so the mutex releases with the holder's exit in both cases. The takeover also requires a numeric pid, and a missing or non-numeric pid file stops the second window with the in-progress message instead of touching the lock (the harness caught my first version silently exiting on a missing pid file through the && chain). The mtime-based takeover path is gone. The inode checks remain as the guard for the manual-removal overlap the prose documents. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index a5c85d2fc1..f9c6a481d1 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -600,11 +600,15 @@ Self-service: mkdir -p ~/.local/bin && lock=~/.local/bin/.node-loopx-repair && if mkdir "$lock" 2>/dev/null; then + echo "$$" > "$lock/pid" && trap 'rm -rf "$lock"' EXIT else - if [ "$(( $(date +%s) - $(stat -f %m "$lock" 2>/dev/null || date +%s) ))" -gt 900 ] && + holder_pid="$(cat "$lock/pid" 2>/dev/null)" || holder_pid= + case "$holder_pid" in ''|*[!0-9]*) holder_pid= ;; esac + if [ -n "$holder_pid" ] && ! kill -0 "$holder_pid" 2>/dev/null && rm -rf "$lock" && mkdir "$lock" 2>/dev/null; then + echo "$$" > "$lock/pid" && trap 'rm -rf "$lock"' EXIT else echo "Another repair is in progress; nothing was changed." && @@ -677,17 +681,19 @@ Self-service: branch creates the link; its `ln` failure means another window's repair already created and qualified one, and that entry is left in place. - The whole repair runs inside one lock: the block takes - `~/.local/bin/.node-loopx-repair` with an exclusive `mkdir` before either - branch and releases it on exit, so a second window stops with - "Another repair is in progress; nothing was changed." instead of - interleaving its move, install, final check or rollback between this - window's steps. Rerun the block after the other window finishes. A repair - killed outright can leave the lock behind; after 15 minutes an attempt - removes and retakes it, and if the message persists while no repair is - running, remove that directory by hand. The inode checks inside the two - branches then guard the only overlap the lock cannot close — a suspended - window whose stale lock was retaken by another one. + The whole repair runs inside one lock: the block takes + `~/.local/bin/.node-loopx-repair` with an exclusive `mkdir` before either + branch, records the shell's process id inside it, and releases it on exit, + so a second window stops with "Another repair is in progress; nothing was + changed." instead of interleaving its move, install, final check or + rollback between this window's steps. Rerun the block after the other + window finishes. A repair killed outright can leave the lock behind; an + attempt retakes it only after checking that the recorded process id no + longer exists — a window that is merely suspended is still alive and + keeps holding the lock. If the message persists while no repair is + running, remove that directory by hand. The inode checks inside the two + branches then guard the one overlap this cannot close: the lock removed + by hand while a suspended window still holds the entry. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From f8f8447b5fac1ff8c0166877f2bc58df70d4209a Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 22:56:12 -0800 Subject: [PATCH 24/28] docs(desktop): run the Node repair in its own subshell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: pasted into an interactive Bash or Zsh, the block's EXIT trap bound to the whole terminal — a successful repair returned to the prompt still holding the lock (the idle terminal's pid also blocks the holder-liveness takeover), a second terminal's immediate retry failed until the first terminal exited, and the caller's own pre-registered EXIT hook was replaced by ours. The whole repair now runs inside one subshell. The exclusive mkdir, the pid record and the EXIT cleanup belong to that subshell's lifetime: the lock releases when the repair finishes, the failure exits never close the user's terminal, and any EXIT hook the caller had registered stays untouched. The recorded pid identifies the terminal session that started the repair, so a terminal killed outright is still retaken once its process is gone. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index f9c6a481d1..f638846d2d 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -561,6 +561,7 @@ Self-service: the third line re-checks the same version numerically. ```bash + ( node= && node_qualifies() { normalized="$(node_trim "$1")" @@ -660,6 +661,7 @@ Self-service: exit 1 fi fi + ) ``` `node_trim` follows `probe_node()`'s boundary handling: it removes the @@ -681,19 +683,21 @@ Self-service: branch creates the link; its `ln` failure means another window's repair already created and qualified one, and that entry is left in place. - The whole repair runs inside one lock: the block takes - `~/.local/bin/.node-loopx-repair` with an exclusive `mkdir` before either - branch, records the shell's process id inside it, and releases it on exit, - so a second window stops with "Another repair is in progress; nothing was - changed." instead of interleaving its move, install, final check or - rollback between this window's steps. Rerun the block after the other - window finishes. A repair killed outright can leave the lock behind; an - attempt retakes it only after checking that the recorded process id no - longer exists — a window that is merely suspended is still alive and - keeps holding the lock. If the message persists while no repair is - running, remove that directory by hand. The inode checks inside the two - branches then guard the one overlap this cannot close: the lock removed - by hand while a suspended window still holds the entry. + The whole repair runs inside one lock inside its own subshell. The block + takes `~/.local/bin/.node-loopx-repair` with an exclusive `mkdir` before + either branch, records the terminal's process id inside it, and releases + the lock when the subshell exits — so the repair never closes your + terminal, not even when a check fails, any EXIT hook you had registered + stays yours, and a second window stops with "Another repair is in + progress; nothing was changed." instead of interleaving its move, install, + final check or rollback between this window's steps. Rerun the block after + the other window finishes. A repair whose terminal is killed outright can + leave the lock behind; an attempt retakes it only after checking that the + recorded process id no longer exists — a window that is merely suspended + is still alive and keeps holding the lock. If the message persists while + no repair is running, remove that directory by hand. The inode checks + inside the two branches then guard the one overlap this cannot close: the + lock removed by hand while a suspended window still holds the entry. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From 39032e2f4660a42ec7500809ad1806a9e2179a1f Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 23:33:35 -0800 Subject: [PATCH 25/28] docs(desktop): record the repair subshell as the lock holder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: the lock recorded the terminal's process id, but the work runs in the subshell. An interrupted repair — the subshell killed outright, exit 137 — left the lock behind while the recorded holder, the idle terminal, stayed alive, so the holder-liveness takeover refused every retry until the terminal was closed. The lock now records the repair subshell's own process id, looked up through a child's parent pid (POSIX $$ keeps reporting the parent inside a subshell, so $PPID of a spawned child is the portable way in both Bash and Zsh). The mutex owner and the working boundary are the same process: killing the repair kills the recorded holder and the next attempt retakes the lock; a normal exit still releases it by trap; a suspended repair is still alive and keeps holding it. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index f638846d2d..1fbee99ca6 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -601,7 +601,7 @@ Self-service: mkdir -p ~/.local/bin && lock=~/.local/bin/.node-loopx-repair && if mkdir "$lock" 2>/dev/null; then - echo "$$" > "$lock/pid" && + sh -c 'echo $PPID' > "$lock/pid" && trap 'rm -rf "$lock"' EXIT else holder_pid="$(cat "$lock/pid" 2>/dev/null)" || holder_pid= @@ -609,7 +609,7 @@ Self-service: if [ -n "$holder_pid" ] && ! kill -0 "$holder_pid" 2>/dev/null && rm -rf "$lock" && mkdir "$lock" 2>/dev/null; then - echo "$$" > "$lock/pid" && + sh -c 'echo $PPID' > "$lock/pid" && trap 'rm -rf "$lock"' EXIT else echo "Another repair is in progress; nothing was changed." && @@ -685,19 +685,22 @@ Self-service: The whole repair runs inside one lock inside its own subshell. The block takes `~/.local/bin/.node-loopx-repair` with an exclusive `mkdir` before - either branch, records the terminal's process id inside it, and releases - the lock when the subshell exits — so the repair never closes your - terminal, not even when a check fails, any EXIT hook you had registered - stays yours, and a second window stops with "Another repair is in - progress; nothing was changed." instead of interleaving its move, install, - final check or rollback between this window's steps. Rerun the block after - the other window finishes. A repair whose terminal is killed outright can - leave the lock behind; an attempt retakes it only after checking that the - recorded process id no longer exists — a window that is merely suspended - is still alive and keeps holding the lock. If the message persists while - no repair is running, remove that directory by hand. The inode checks - inside the two branches then guard the one overlap this cannot close: the - lock removed by hand while a suspended window still holds the entry. + either branch, records the repair subshell's own process id inside it — + looked up through a child's parent pid, so the recorded holder is exactly + the process doing the work — and releases the lock when that subshell + exits. The repair therefore never closes your terminal, not even when a + check fails, any EXIT hook you had registered stays yours, and a second + window stops with "Another repair is in progress; nothing was changed." + instead of interleaving its move, install, final check or rollback between + this window's steps. Rerun the block after the other window finishes. A + repair interrupted without its cleanup — its subshell killed outright — + can leave the lock behind; an attempt retakes it only after checking that + the recorded repair process no longer exists, and a repair that is merely + suspended is still alive and keeps holding the lock. If the message + persists while no repair is running, remove that directory by hand. The + inode checks inside the two branches then guard the one overlap this + cannot close: the lock removed by hand while a suspended window still + holds the entry. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From e57747ecfe47d070cb19e2ef2631340fe397ef85 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Tue, 24 Nov 2026 23:57:37 -0800 Subject: [PATCH 26/28] docs(desktop): drop the automatic repair-lock takeover MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: two windows can both observe the same exited holder pid; the first retakes the lock and enters its final check, and the second — whose takeover decision was made before the first took over — then rm -rf's the directory anyway, deleting the first window's freshly held lock, replacing the launcher, and exiting 0 while the first window's final check is still pending. Two successes, zero exclusivity. Per the review's primary option, the automatic takeover is gone. The lock is now exactly: an exclusive mkdir, the subshell's EXIT trap release, and a manual-removal fallback — the stop message tells the user to remove the directory by hand once ps confirms no repair shell remains, and the prose keeps the ps check explicit. The pid file and every liveness-based removal path are deleted, so no window can ever remove a lock another window currently holds. An interrupted repair's lock stops all later attempts until the user's confirmed cleanup. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 44 ++++++++-------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 1fbee99ca6..7a0317ad44 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -601,20 +601,11 @@ Self-service: mkdir -p ~/.local/bin && lock=~/.local/bin/.node-loopx-repair && if mkdir "$lock" 2>/dev/null; then - sh -c 'echo $PPID' > "$lock/pid" && trap 'rm -rf "$lock"' EXIT else - holder_pid="$(cat "$lock/pid" 2>/dev/null)" || holder_pid= - case "$holder_pid" in ''|*[!0-9]*) holder_pid= ;; esac - if [ -n "$holder_pid" ] && ! kill -0 "$holder_pid" 2>/dev/null && - rm -rf "$lock" && - mkdir "$lock" 2>/dev/null; then - sh -c 'echo $PPID' > "$lock/pid" && - trap 'rm -rf "$lock"' EXIT - else - echo "Another repair is in progress; nothing was changed." && - exit 1 - fi + echo "Another repair is in progress; nothing was changed." && + echo "If no repair is actually running, remove $lock by hand and run this again." && + exit 1 fi && backup=~/.local/bin/node.before-loopx."$(date +%Y%m%d-%H%M%S)" && if [ -e ~/.local/bin/node ] || [ -L ~/.local/bin/node ]; then @@ -685,22 +676,19 @@ Self-service: The whole repair runs inside one lock inside its own subshell. The block takes `~/.local/bin/.node-loopx-repair` with an exclusive `mkdir` before - either branch, records the repair subshell's own process id inside it — - looked up through a child's parent pid, so the recorded holder is exactly - the process doing the work — and releases the lock when that subshell - exits. The repair therefore never closes your terminal, not even when a - check fails, any EXIT hook you had registered stays yours, and a second - window stops with "Another repair is in progress; nothing was changed." - instead of interleaving its move, install, final check or rollback between - this window's steps. Rerun the block after the other window finishes. A - repair interrupted without its cleanup — its subshell killed outright — - can leave the lock behind; an attempt retakes it only after checking that - the recorded repair process no longer exists, and a repair that is merely - suspended is still alive and keeps holding the lock. If the message - persists while no repair is running, remove that directory by hand. The - inode checks inside the two branches then guard the one overlap this - cannot close: the lock removed by hand while a suspended window still - holds the entry. + either branch and releases the lock when that subshell exits. The repair + therefore never closes your terminal, not even when a check fails, any + EXIT hook you had registered stays yours, and a second window stops with + "Another repair is in progress; nothing was changed." instead of + interleaving its move, install, final check or rollback between this + window's steps. Rerun the block after the other window finishes. There is + no automatic takeover: a repair interrupted without its cleanup — its + subshell killed outright — leaves the lock in place and every later + attempt stops with the message above. When nothing is actually running + (check with `ps` that no repair shell remains), remove that directory by + hand and run the block again. The inode checks inside the two branches + then guard the one overlap this cannot close: the lock removed by hand + while a suspended window still holds the entry. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From 2b8c8022767e26a767bf8e3b2e7fc9a1eedb9814 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Wed, 25 Nov 2026 00:43:44 -0800 Subject: [PATCH 27/28] docs(desktop): make the lock cleanup target its own instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The round's interleaving: window A held the lock mid-repair; the user performed the documented manual recovery (removed the lock, started a new repair), and window C acquired a fresh lock and entered its final check; then A's subshell exited 0 and its EXIT trap ran `rm -rf` on the lock path unconditionally — deleting C's freshly acquired lock while C was still checking its installed result. The cleanup is now instance-targeted, using the same inode ownership proof as the launcher rollback: at acquisition the lock records its own directory inode, and the EXIT trap removes the directory only while the current inode still matches. While the instance is the window's own, no other window can acquire, so the check-then-act gap cannot swallow a replacement; a later window's lock has a different inode and survives this repair's exit, and its own trap removes it. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 7a0317ad44..893ec3151f 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -601,7 +601,8 @@ Self-service: mkdir -p ~/.local/bin && lock=~/.local/bin/.node-loopx-repair && if mkdir "$lock" 2>/dev/null; then - trap 'rm -rf "$lock"' EXIT + lock_ino="$(stat -f %i "$lock")" && + trap 'if [ "$(stat -f %i "$lock" 2>/dev/null)" = "$lock_ino" ]; then rm -rf "$lock"; fi' EXIT else echo "Another repair is in progress; nothing was changed." && echo "If no repair is actually running, remove $lock by hand and run this again." && @@ -686,9 +687,11 @@ Self-service: subshell killed outright — leaves the lock in place and every later attempt stops with the message above. When nothing is actually running (check with `ps` that no repair shell remains), remove that directory by - hand and run the block again. The inode checks inside the two branches - then guard the one overlap this cannot close: the lock removed by hand - while a suspended window still holds the entry. + hand and run the block again. The cleanup is instance-targeted: it + removes the lock only while the directory is still the instance this + repair created — a lock a later window acquired after your manual removal + has a different inode and survives this repair's exit. The launcher-entry + inode checks in the two branches guard the rollback the same way. The backup is a directory created atomically: a second repair in the same second (from this window or another one) fails its `mkdir` and stops with From 6c3397e9b27e91681a02536d2c155bf13d37c0ba Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Wed, 25 Nov 2026 01:10:27 -0800 Subject: [PATCH 28/28] docs(desktop): take the repair lock for the backup restore The round's interleaving: the manual restore section ran without the repair lock, so while window A's repair held the lock with its final version check pending, a restore in another window staged a backup entry, removed the launcher, moved its restore into place and exited 0; A's final check then passed on whatever entry it read, and both operations reported success with the launcher actually regressed to the unsupported 22.22.2 backup. The restore block now runs inside the same boundary as the repair: one subshell that takes the same exclusive lock with the instance-targeted EXIT cleanup, stops with the in-progress message while a repair holds it, and applies the same ps-confirmed manual-removal fallback. Both operations' successful readbacks can no longer straddle a replacement. The no-concurrency controls are unchanged: a regular-file backup restores as a regular file, a symlink backup recreates its raw link value at the original location. Signed-off-by: Lihua <1017343802@qq.com> --- apps/desktop/loopx-control-plane/README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/desktop/loopx-control-plane/README.md b/apps/desktop/loopx-control-plane/README.md index 893ec3151f..bd41f618c2 100644 --- a/apps/desktop/loopx-control-plane/README.md +++ b/apps/desktop/loopx-control-plane/README.md @@ -706,10 +706,25 @@ Self-service: To restore a backup, replace the launcher directory entry in the way that preserves the backup's own entry type, and never copy through the current link — `cp` would follow it and rewrite the supported Node binary that - other tools share. A missing launcher is a recoverable state too: an - interrupted repair leaves only the backup, and `rm -f` accepts that. + other tools share. The restore takes the same lock as the repair below, + so it stops while a repair is running and cannot replace a launcher that + another window is still checking; the same ps-confirmed manual removal + applies if a lock was left by an interrupted repair. A missing launcher + is a recoverable state too: an interrupted repair leaves only the + backup, and `rm -f` accepts that. ```bash + ( + mkdir -p ~/.local/bin && + lock=~/.local/bin/.node-loopx-repair && + if mkdir "$lock" 2>/dev/null; then + lock_ino="$(stat -f %i "$lock")" && + trap 'if [ "$(stat -f %i "$lock" 2>/dev/null)" = "$lock_ino" ]; then rm -rf "$lock"; fi' EXIT + else + echo "Another repair is in progress; nothing was changed." && + echo "If no repair is actually running, remove $lock by hand and run this again." && + exit 1 + fi && newest=$(ls -td ~/.local/bin/node.before-loopx.* 2>/dev/null | head -1) && [ -n "$newest" ] && staged=~/.local/bin/node.restored."$(date +%Y%m%d-%H%M%S)" && @@ -723,6 +738,7 @@ Self-service: rm -f ~/.local/bin/node && mv "$staged" ~/.local/bin/node && shasum ~/.local/bin/node + ) ``` The restore builds the restored entry beside the launcher first, so a