diff --git a/bin/gs b/bin/gs index daed4f2..4b66779 100755 --- a/bin/gs +++ b/bin/gs @@ -393,6 +393,11 @@ cmd_sync() { # Stale GOROOT/GOBIN from a removed version manager breaks every go build. if [ -n "${GOROOT:-}" ] && [ ! -d "$GOROOT" ]; then unset GOROOT; fi if [ -n "${GOBIN:-}" ] && [ ! -d "$(dirname "$GOBIN")" ]; then unset GOBIN; fi + # gentle-ai's beta upgrade (run by gentle-shell upgrade) does its own `go install` + # of the pre-v3 Engram module path. With a go env GOBIN of ~/.local/bin that build + # overwrites the engram symlink with Engram v1, so every child of the sync installs + # into ~/go/bin instead; gs's own builds name their GOBIN explicitly. + export GOBIN="$HOME/go/bin" mkdir -p "$bin" "$HOME/.local/bin" "$(dirname "$reg")" if is_workshop; then # Workshop runs the Pi bundled in the clone (node_modules): no legacy @@ -459,6 +464,9 @@ cmd_sync() { fi ln -sfn "$bin/$name" "$HOME/.local/bin/$name" done + # The integrations need `engram instance-id` (Engram >= v2.0.0-rc.11); a pre-v3 + # build on PATH blocks every memory read, so the sync must not report success. + "$HOME/.local/bin/engram" instance-id >/dev/null 2>&1 || sync_failed 'engram lacks instance-id (pre-v3)' local ai_bin if is_workshop; then local tmp; tmp=$(mktemp "$(dirname "$reg")/.dev-binary.XXXXXX") diff --git a/docs/gs-sync.md b/docs/gs-sync.md index 17ee3c9..4bce75b 100644 --- a/docs/gs-sync.md +++ b/docs/gs-sync.md @@ -110,6 +110,16 @@ on the calling shell (a shell opened before a dotfiles update, or a host that does not load them). A value already set in the environment wins. `zsh/cortex-dotfiles.zsh` also exports it for `gentle-ai` runs outside `gs sync`. +`GENTLE_AI_ENGRAM_BIN` does not cover `gentle-ai upgrade` on the beta channel +(run by `gentle-shell upgrade`): it still runs that `go install` and writes into +the effective `GOBIN`. On a host with `go env -w GOBIN=~/.local/bin`, the v1 +build replaced the `~/.local/bin/engram` symlink. `gs sync` therefore exports +`GOBIN=~/go/bin` for every step it runs; its own builds set `GOBIN` explicitly. +To protect runs outside `gs sync` as well, keep `go env GOBIN` off `~/.local/bin`. + +After relinking, `gs sync` runs `~/.local/bin/engram instance-id` and reports +`INCOMPLETE — failed: engram lacks instance-id (pre-v3)` when that fails. + Check: `engram version` reports 3.x after `gs sync` and after starting Pi. ## Tests diff --git a/tests/gs_test.sh b/tests/gs_test.sh index 558b71e..2a39921 100755 --- a/tests/gs_test.sh +++ b/tests/gs_test.sh @@ -41,6 +41,9 @@ EOF printf '#!/bin/sh\n[ "$1" = --version ] && echo "gentle-ai 1.0.0"\nexit 0\n' > "$HOME/ai" chmod +x "$HOME/ai" printf '{"path":"%s"}\n' "$HOME/ai" > "$HOME/.pi/gentle-ai/dev-binary.json" + # Engram built by gs sync; ENGRAM_PRE_V3=1 makes it a pre-v3 build without instance-id. + printf '#!/bin/sh\ncase "$1" in\n version) echo "engram 3.6.1" ;;\n instance-id) [ "${ENGRAM_PRE_V3:-}" = 1 ] && exit 1; echo abc ;;\nesac\nexit 0\n' > "$HOME/.local/share/gentle-ai/main/engram" + chmod +x "$HOME/.local/share/gentle-ai/main/engram" if [ "$1" = consumer ]; then NPM="$HOME/.local/lib/node_modules/gentle-pi" make_pkg "$NPM" 4.5.1-main.feee99d88dae @@ -50,7 +53,7 @@ EOF #!/bin/sh case "\$1" in --version) printf 'gentle-shell %s\n' "\$(cat "$NPM/VERSION")" ;; - upgrade) [ -n "\${UPGRADE_TO:-}" ] && echo "\$UPGRADE_TO" > "$NPM/VERSION"; exit "\${UPGRADE_RC:-0}" ;; + upgrade) echo "upgrade GOBIN=\${GOBIN:-unset}" >> "$CALLS"; [ -n "\${UPGRADE_TO:-}" ] && echo "\$UPGRADE_TO" > "$NPM/VERSION"; exit "\${UPGRADE_RC:-0}" ;; esac EOF chmod +x "$S/gentle-shell-impl" @@ -285,5 +288,18 @@ OUT=$("$GS" sync 2>&1); rc=$? check "sync: unreachable GitHub only warns that freshness is unverified" \ '[ $rc -eq 0 ] && [[ "$OUT" == *"freshness unverified"* ]]' +# gentle-ai's beta upgrade runs `go install` of the pre-v3 Engram module path; with a +# go env GOBIN of ~/.local/bin it overwrote the engram symlink with Engram v1. +setup consumer; remote_main HEAD +: > "$CALLS"; OUT=$(GOBIN="$HOME/.local/bin" "$GS" sync 2>&1) +check "sync: go installs run by the upgrade land in ~/go/bin, never ~/.local/bin" \ + 'grep -qx "upgrade GOBIN=$HOME/go/bin" "$CALLS"' + +setup consumer; remote_main HEAD; main=$(sha_of) +echo "4.5.2-main.${main:0:12}" > "$NPM/VERSION" +OUT=$(ENGRAM_PRE_V3=1 "$GS" sync 2>&1); rc=$? +check "sync: an engram without instance-id (pre-v3) is INCOMPLETE, exit 1" \ + '[ $rc -eq 1 ] && [[ "$OUT" == *"INCOMPLETE"*"engram lacks instance-id (pre-v3)"* ]]' + printf '\n%s\n' "$([ $fails -eq 0 ] && echo 'all passed' || echo "$fails failed")" exit $fails