fix(cli): delete only removes tb when it is tracebloc's own alias#171
Merged
Conversation
`removeSelf` deleted any sibling file named `tb` (guard was only `tb !=
exe`), with no check that it was tracebloc's own symlink. If a user had an
unrelated `tb` on the same PATH dir tracebloc installed into (another
tool's binary, or a symlink elsewhere), `tracebloc delete` removed it —
wrong-target deletion of a file tracebloc never created.
Make delete symmetric with install. The installer refuses to clobber a
pre-existing `tb` (install.sh: creates it only when absent or when
`readlink tb == PREFIX/tracebloc`). Delete now mirrors that: new
aliasStatus() removes `tb` only when it is a symlink resolving to this
binary; a regular file or a symlink pointing elsewhere is left in place
with a note ("isn't tracebloc's `tb` alias"). Relative targets resolve
against the link dir, and an EvalSymlinks fallback covers the case where
the binary itself is a symlink (Intel Homebrew).
Found in the FR review of the offboarding surface; not a Bugbot finding.
Tests: TestDelete_OwnTBAlias_Removed (real tb->binary symlink is removed),
TestDelete_ForeignTBAlias_Left (a foreign regular-file `tb` is NOT removed
and is reported), and the full-sequence test now lays down a real symlink.
The foreign-tb test is verified to fail without the guard. Suite + vet green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
aptracebloc
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tracebloc delete(offboarding) removed any sibling file namedtb, guarded only bytb != exe— with no check that it was tracebloc's own alias. If a user had an unrelatedtbon the same PATH dir tracebloc installed into (another tool's binary, or a symlink pointing elsewhere), offboarding deleted it — wrong-target deletion of a file tracebloc never created.This came out of the FR review of the offboarding surface (§7.10). It's not a Bugbot finding — Bugbot's five findings on #164 are all resolved (by #165, #168, #169); this is the one the review caught that they didn't.
Fix — make delete symmetric with install
The installer already refuses to clobber a pre-existing
tb(scripts/install.sh: creates it only when absent, or whenreadlink tb == PREFIX/tracebloc). Delete now mirrors that ownership test:aliasStatus(tb, exe) (exists, ours bool)—tbis ours only when it's a symlink resolving to this binary.tbalias." (mirrors the installer's "already exists and isn't ours" message).EvalSymlinksfallback covers the binary itself being a symlink (Intel Homebrew).Tests
TestDelete_OwnTBAlias_Removed— a realtb → traceblocsymlink is removed.TestDelete_ForeignTBAlias_Left— a foreign regular-filetbis not removed, is reported, and is untouched on disk. Verified to fail without the guard (unfixedremoveSelfdeletes it).internal/...suite +go vetgreen.Targets
developper convention.🤖 Generated with Claude Code