Repository navigation
Conversation
- source builds fast-forward their build checkout and rebuild with go build - release builds fast-forward ~/.gap/checkout and swap in the latest checksummed release - refuse an off-branch or dirty checkout before changing anything; never downgrade - document the command in README and cmd/gap/AGENTS.md
- status tests failed on machines with recall installed once the probe printed a count
There was a problem hiding this comment.
Caution
gap self-update can silently overwrite ignored local files when upstream starts tracking the same path. Fix that before shipping the updater.
Approach: A separate command for updating GAP is the right split from gap update, but the checkout refresh and source build need to protect local work and keep it out of the replacement binary.
Reviewed changes — Reviewed the CLI wiring, both installation paths, and the user-facing docs and tests.
- Source installs: Check the branch and tracked files, fast-forward the retained checkout, and rebuild the executable.
- Release installs: Resolve the latest release, compare versions, verify the platform archive against
checksums.txt, and atomically replace the executable. - Docs and tests: Document
gap self-updateand the follow-upgap sync; add Git and HTTP fixtures and isolate tests from the host’s Recall installation.
Risk: 6/10 (High) — Needs:Human. A path collision is uncommon, but it can permanently erase local files. A source rebuild can also include local changes that aren’t in the commit it reports.
Verification: The focused TestSelfUpdate tests, gofmt -l, go vet ./..., and a release-style CGO_ENABLED=0 go build -trimpath passed. go test ./... failed four TUI process-lifecycle tests; three reproduced on both the base and PR head, and TestTUIRunCleanExitFailsWhenAHookExitsOnSignal passed on both isolated reruns. With pinned Node, npm ci and npm run for typecheck, build, links, og-image, contrast, toc, logo-round, flash, hero-start, hero-spin, and check:docs all passed. No deployment was run.
gpt-6.2-sol | 𝕏
|
|
||
| func versionParts(v string) [3]int { | ||
| var p [3]int | ||
| core, _, _ := strings.Cut(strings.TrimPrefix(v, "v"), "-") |
There was a problem hiding this comment.
Dropping the prerelease suffix makes an installed 4.1.0-rc.1 compare equal to the final v4.1.0, so the updater reports “already at” and leaves the release candidate installed. Compare valid SemVer values after normalizing the v prefix, and cover prerelease-to-final promotion and build metadata in the tests.
- build from a detached copy of the fetched commit, not the live checkout - refuse a fast-forward that would overwrite an ignored local file - compare versions with golang.org/x/mod/semver so 4.1.0-rc.1 updates to 4.1.0 - say a fast-forward can bring in a newer distro gap.lock - shadow recall on the test PATH with a failing stub
There was a problem hiding this comment.
Caution
gap self-update can report success for a source install and leave the replacement binary unable to find its checkout. The recommended follow-up, gap sync, then fails if there is no fallback checkout.
Approach: Building from a clean worktree keeps local files out of the binary, but the replacement must still point to the retained checkout.
Reviewed changes — Reviewed 5c19ebd against the previous review at 4241210.
- Isolated source builds. Built the selected commit in a temporary detached worktree and added coverage for excluding untracked files.
- Protected ignored files. Made fast-forward merges refuse ignored-file collisions and tested that the file and
HEADstay unchanged. - Corrected version precedence. Switched release comparisons to SemVer and tested promotion from a release candidate to the final release.
- Clarified docs and test isolation. Distinguished upstream distro pins from user locks and replaced PATH filtering with a Recall shim.
Risk: 6/10 (High) — Needs:Human. The regression affects documented Go installs outside ~/.gap/checkout. After updating, GAP can fail to sync or pick up a different checkout if the fallback exists.
Verification: A real source rebuild in a disposable checkout reproduced the failure. gofmt -l, go vet ./..., CGO_ENABLED=0 go build -trimpath, and go test ./cmd/gap -run '^(TestSelfUpdate|TestInitBreadcrumb|TestStatus)' -count=1 passed. go test ./... failed the same four TUI process-lifecycle tests reported at 4241210. Under Node 22.23.5, npm ci and npm run for typecheck, build, links, og-image, contrast, toc, logo-round, flash, hero-start, hero-spin, and check:docs passed. No deployment was run.
gpt-6.2-sol | 𝕏
| return err | ||
| } | ||
| defer git(root, "worktree", "remove", "--force", src) | ||
| return buildGap(src, out) |
There was a problem hiding this comment.
The replacement binary records the temporary worktree as its source checkout, then buildCommit deletes that worktree. I confirmed that gap self-update succeeded in a disposable source install, but the replacement's gap source failed because it fell back to a missing ~/.gap/checkout; gap sync uses the same lookup.
Technical details
# Preserve the retained checkout in source rebuilds
## Affected sites
- `cmd/gap/selfupdate.go:185–191` — builds from the temporary worktree and removes it before the new binary runs.
- `cmd/gap/main.go:430–442` — `sourceRoot()` derives the checkout from `runtime.Caller` unless `sourceRootFor` is set; `syncAll()` calls it at line 58.
- `scripts/install.sh:125–134` — Go installs use `~/.gap/checkouts/gap.*` or a local clone, not `~/.gap/checkout`.
- `cmd/gap/selfupdate_test.go:47–53` — stubs the compiler and overrides source discovery, so the fixture cannot detect the regression.
## Required outcome
- Keep compiling only the selected commit, but make the replacement use the same retained checkout as its predecessor. Add a real-build regression test that checks `gap source` after replacement without a fallback checkout.- bake the retained checkout into the build with -X main.sourceRootFor - assert the build names the real checkout, not the temporary copy
There was a problem hiding this comment.
Important
Source updates fail when the retained checkout path contains whitespace.
Reviewed changes — Reviewed 905d5f8 against the previous review at 5c19ebd.
- Preserved checkout discovery: Passed the retained checkout to the source build through a linker setting and updated the compiler stub assertion.
Risk: 5/10 (Medium) — Needs:Human. Source updates fail for valid checkout paths containing spaces; the existing binary remains in place, but the checkout may already have advanced. Full verification also remains incomplete.
Verification: Focused self-update tests, go vet ./..., formatting, and a release-style Go build passed. go test ./... timed out twice after 120 seconds. Site npm ci, typecheck, build, links, og-image, contrast, toc, logo-round, flash, and check:docs passed; hero-start and hero-spin each timed out after 120 seconds. No deployment was run.
gpt-6.1-terra | 𝕏
| releaseBase = "https://github.com/edheltzel/GAP/releases" | ||
| selfPath = os.Executable | ||
| buildGap = func(src, root, out string) error { | ||
| cmd := exec.Command("go", "build", "-ldflags", "-X main.sourceRootFor="+root, "-o", out, "./cmd/gap") |
There was a problem hiding this comment.
A retained checkout path containing whitespace is split into multiple linker arguments, so gap self-update fails its build after advancing the checkout. Quote the -X value for Go's -ldflags parser and cover a real source build from a path with spaces; go build -ldflags '-X main.sourceRootFor=/tmp/a b' reproduces the failure.
- quote main.sourceRootFor so a checkout path with spaces or an apostrophe builds - build the real binary from such paths and check gap source

Closes todo #126 (self-update before the v4.1.0 release).
gap self-update: source build fast-forwards its build checkout (origin primary branch) and rebuilds the running binary withgo build; release build fast-forwards~/.gap/checkout, downloads the latest release for this OS/arch, verifies it againstchecksums.txt, and swaps it in atomically.gap update); printsgap syncas the next step.TestMaindropsrecallfrom PATH, so status tests pass on machines with Recall installed.Proof: 7 self-update tests (fast-forward + rebuild, dirty/branch refusal, verified download, checksum mismatch, no downgrade, already latest); end to end against the real GitHub release (0.5.0 -> v0.5.1) and a real fast-forward + rebuild;
go test ./...passes.