From d4e8c24b2f23a645a3dc018c3c06b6af9da7f5ce Mon Sep 17 00:00:00 2001 From: Lap Tran Date: Wed, 11 Nov 2026 12:29:27 -0500 Subject: [PATCH 1/4] fix(home): converge backpass and acpx to the latest npm release on rebuild Both npm globals were installed only when the binary was missing, so a rebuild never moved them and the installed copies drifted behind the registry. Read the installed version and the registry's latest instead, and install only when they differ. The running-process guard skips a package while one of its own processes is alive, the registry lookup and the install warn and continue on failure so the switch never aborts, and one shared function serves both packages. --- home.nix | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/home.nix b/home.nix index 31591cb..d9d8dc4 100644 --- a/home.nix +++ b/home.nix @@ -384,9 +384,13 @@ in # to a harness you already authenticated, so acpx is a hard runtime dep and # must be on PATH. Homebrew node v26 satisfies backpass (>= 22.5) and acpx # (>= 22.13). Neither is a Homebrew formula: install via Homebrew's npm, - # never Nix's npm (EACCES on the store). Skip-if-present so a rebuild never - # pulls a new version mid-session; refresh manually with - # /opt/homebrew/bin/npm update -g backpass acpx + # never Nix's npm (EACCES on the store). Both track the registry's latest on + # every rebuild: for each package the installed version is compared with the + # published one, and an install runs only when they differ, so a current copy + # is left alone and a stale one converges. The registry lookup and the install + # are optional steps - a failure there warns and the switch continues. A + # package with a live process is never replaced mid-session: that switch skips + # it and names the follow-up. home.activation.backpass = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail # Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node` @@ -398,12 +402,45 @@ in echo "backpass: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2 exit 1 fi - if [ ! -x /opt/homebrew/bin/acpx ]; then - "$npm" install -g acpx@latest - fi - if [ ! -x /opt/homebrew/bin/backpass ]; then - "$npm" install -g backpass - fi + # Converge one npm global to the registry's latest. $1 is the package name, + # $2 is the pgrep pattern that identifies a live process of that package. + # The running-process guard comes first, because an install rewrites the + # package directory under a running process. Every optional failure returns + # 0, so `set -e` never aborts the switch and later blocks still run. + converge_npm_global() { + pkg="$1" + live="$2" + if pgrep -f "$live" >/dev/null 2>&1; then + echo "$pkg: $pkg is running - leaving the installed copy untouched. Finish or stop it, then rerun the rebuild to update." >&2 + return 0 + fi + # Installed version from npm's own global record; empty means absent. The + # `|| true` keeps `set -e` quiet when npm exits non-zero over extraneous + # packages. + installed="$("$npm" ls -g --depth=0 2>/dev/null | sed -n "s/.*[[:space:]]$pkg@\([^[:space:]]*\).*/\1/p" | head -n 1 || true)" + # Registry lookup is optional: an offline or timed-out lookup warns and + # keeps the installed copy. + latest="$("$npm" view "$pkg" version --fetch-timeout=15000 --fetch-retries=1 2>/dev/null | tr -d "[:space:]" || true)" + if [ -z "$latest" ]; then + echo "$pkg: cannot read the latest version from the npm registry (offline?) - keeping the installed copy, rebuild continues" >&2 + return 0 + fi + if [ "$installed" = "$latest" ]; then + echo "$pkg: already at $latest" + return 0 + fi + current="$installed" + [ -n "$current" ] || current=none + echo "$pkg: updating $current -> $latest" + # Install failure is optional too: warn and keep the old copy. + if "$npm" install -g "$pkg@$latest"; then + echo "$pkg: installed $latest" + else + echo "$pkg: install of $latest failed - keeping the installed copy, rebuild continues" >&2 + fi + } + converge_npm_global backpass "node_modules/backpass/bin/backpass.js" + converge_npm_global acpx "node_modules/acpx/dist/cli.js" ''; # kunchenguid/no-mistakes gate (git push no-mistakes) - declarative install + daemon + global config From 9addc502fac3d162d2df614c6668654a8ba35f10 Mon Sep 17 00:00:00 2001 From: Lap Tran Date: Wed, 11 Nov 2026 12:39:56 -0500 Subject: [PATCH 2/4] no-mistakes(review): always install latest backpass and acpx on rebuild --- home.nix | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/home.nix b/home.nix index d9d8dc4..bd914bd 100644 --- a/home.nix +++ b/home.nix @@ -387,10 +387,12 @@ in # never Nix's npm (EACCES on the store). Both track the registry's latest on # every rebuild: for each package the installed version is compared with the # published one, and an install runs only when they differ, so a current copy - # is left alone and a stale one converges. The registry lookup and the install - # are optional steps - a failure there warns and the switch continues. A - # package with a live process is never replaced mid-session: that switch skips - # it and names the follow-up. + # is left alone and a stale one converges. The switch therefore always brings + # both packages to the latest published version, whether or not a process of + # that package is running: a running process keeps the code it already loaded + # and picks the new version up at its next start, so the switch prints that as + # a notice and still installs. The registry lookup and the install are optional + # steps - a failure there warns and the switch continues. home.activation.backpass = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail # Activation PATH lacks /opt/homebrew/bin, so npm's `#!/usr/bin/env node` @@ -403,17 +405,13 @@ in exit 1 fi # Converge one npm global to the registry's latest. $1 is the package name, - # $2 is the pgrep pattern that identifies a live process of that package. - # The running-process guard comes first, because an install rewrites the - # package directory under a running process. Every optional failure returns - # 0, so `set -e` never aborts the switch and later blocks still run. + # $2 is the pgrep pattern that identifies a live process of that package, + # used only to explain that a live process keeps its loaded code. Every + # optional failure returns 0, so `set -e` never aborts the switch and later + # blocks still run. converge_npm_global() { pkg="$1" live="$2" - if pgrep -f "$live" >/dev/null 2>&1; then - echo "$pkg: $pkg is running - leaving the installed copy untouched. Finish or stop it, then rerun the rebuild to update." >&2 - return 0 - fi # Installed version from npm's own global record; empty means absent. The # `|| true` keeps `set -e` quiet when npm exits non-zero over extraneous # packages. @@ -427,16 +425,20 @@ in fi if [ "$installed" = "$latest" ]; then echo "$pkg: already at $latest" - return 0 - fi - current="$installed" - [ -n "$current" ] || current=none - echo "$pkg: updating $current -> $latest" - # Install failure is optional too: warn and keep the old copy. - if "$npm" install -g "$pkg@$latest"; then - echo "$pkg: installed $latest" else - echo "$pkg: install of $latest failed - keeping the installed copy, rebuild continues" >&2 + current="$installed" + [ -n "$current" ] || current=none + echo "$pkg: updating $current -> $latest" + # Install failure is optional too: warn and keep the old copy. + if "$npm" install -g "$pkg@$latest"; then + echo "$pkg: installed $latest" + else + echo "$pkg: install of $latest failed - keeping the installed copy, rebuild continues" >&2 + return 0 + fi + fi + if pgrep -f "$live" >/dev/null 2>&1; then + echo "$pkg: a running process keeps the code it already loaded - $latest takes effect at its next start" >&2 fi } converge_npm_global backpass "node_modules/backpass/bin/backpass.js" From 9598499dcffe22e16805b8723f06416b88bf959e Mon Sep 17 00:00:00 2001 From: Lap Tran Date: Wed, 11 Nov 2026 12:49:41 -0500 Subject: [PATCH 3/4] no-mistakes(review): match real backpass and acpx launch paths --- home.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/home.nix b/home.nix index bd914bd..0d08f34 100644 --- a/home.nix +++ b/home.nix @@ -405,10 +405,10 @@ in exit 1 fi # Converge one npm global to the registry's latest. $1 is the package name, - # $2 is the pgrep pattern that identifies a live process of that package, - # used only to explain that a live process keeps its loaded code. Every - # optional failure returns 0, so `set -e` never aborts the switch and later - # blocks still run. + # $2 is the pgrep pattern matching that package's command line as launched + # from the global bin, used only to explain that a live process keeps its + # loaded code. Every optional failure returns 0, so `set -e` never aborts the + # switch and later blocks still run. converge_npm_global() { pkg="$1" live="$2" @@ -441,8 +441,8 @@ in echo "$pkg: a running process keeps the code it already loaded - $latest takes effect at its next start" >&2 fi } - converge_npm_global backpass "node_modules/backpass/bin/backpass.js" - converge_npm_global acpx "node_modules/acpx/dist/cli.js" + converge_npm_global backpass "/opt/homebrew/bin/backpass" + converge_npm_global acpx "/opt/homebrew/bin/acpx" ''; # kunchenguid/no-mistakes gate (git push no-mistakes) - declarative install + daemon + global config From 5bf1e0509126ff1d9c4e6a24ea0d0ddca2ac4196 Mon Sep 17 00:00:00 2001 From: Lap Tran Date: Wed, 11 Nov 2026 13:08:13 -0500 Subject: [PATCH 4/4] no-mistakes(document): correct stale backpass skip reference in comment --- home.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/home.nix b/home.nix index 0d08f34..eca9d5a 100644 --- a/home.nix +++ b/home.nix @@ -497,11 +497,12 @@ in # ~/.config/opencode/skills: home-manager owns that path with force = true and # mkOutOfStoreSymlink into the mutable dotfiles checkout, so a rebuild would # clobber the CLI's link and CLI writes would land in the git checkout. Skip - # when installed, like backpass, so a rebuild never pulls a new skill - # version mid-session. The skill's own README still requires an OS-enforced - # sandbox before it may run target-controlled builds, tests, browsers, or - # fuzzers. That sandbox is home/bin/security-audit-sandbox; without it, those - # leads stay `needs_validation`. + # when installed, unlike backpass which tracks the latest release, so a + # rebuild never pulls a new skill version mid-session. The skill's own README + # still requires an OS-enforced sandbox before it may run target-controlled + # builds, tests, browsers, or fuzzers. That sandbox is + # home/bin/security-audit-sandbox; without it, those leads stay + # `needs_validation`. # Install and refresh commands, plus the sandbox docs, are in readme.md. home.activation.securityAuditSkill = lib.hm.dag.entryAfter [ "writeBoundary" ] '' set -euo pipefail