Repository navigation
Description
Lane 17 of NobleFactor/noblefactor-engprod#217, ahead of #228 — "a serious bug that should be corrected while it's fresh" (2026-09-23).
Ruled (USER, 2026-09-23): "the manifest must be a record of what the tool owns and self install must
implicitly uninstall, if it detects a prior install" — and "this must be true for every app."
The defect
runSelfInstall (cmd/internal/cli/selfinstall.go:216) runs seven steps — open the prefix, binary, man
pages, completions, config, post-install hooks, then write the manifest. It never reads the prior
manifest. writeManifest (:632) builds its entry list from scratch and WriteFiles it: a plain
overwrite, not a merge and not a diff.
So for any file the previous install placed at a path this install no longer writes:
- Nothing removes it.
CopyDiroverwrites same-path files and never removes absent ones. - It is dropped from the manifest, which was just overwritten.
self uninstallafter star self uninstall deletes the whole share/star/extensions directory, including extensions it never installed #917 removes only what the manifest records — so nothing can ever reach it again.
self uninstall itself is not broken. runSelfUninstall (:461) reads the manifest and, per entry,
hashes the file: missing → skip, hash differs → skip and leave it, else remove; then cleanEmptyDirs and
the manifest goes. That is deliberate and correct. It is complete and precise for the last install, and
blind to every one before it.
The accurate statement of the bug is therefore not "uninstall is broken" but:
The manifest is a snapshot of the last install, not a record of what the tool owns.
This is writ's bug, in the other half of the codebase
#916 found the same defect class in writ and #913 ruled it:
A deploy adds to the record and replaces nothing.
Here an install overwrites the record and removes nothing. The consequence is identical — a record that
stops describing what is owned, and entries that nothing will ever retire. writ's ruling gives the verb, and
this issue adopts it rather than inventing a second vocabulary for the same idea: self install replaces
the record. Each install is one lifetime.
It is not only path moves
Any install whose file set shrinks or is renamed strands the difference:
- an extension renamed or dropped from the source tree;
- a man page no longer generated;
- a completion for a shell not selected this time;
- a binary or directory rename.
Worked example, 2026-09-23. star's data moved under devlore/ (#918, shipped as #921). Re-installing
wrote the five com.noblefactor.devlore.* extensions to
~/.local/share/devlore/star/extensions/ and overwrote the manifest. The 24 files the previous install had
written to ~/.local/share/star/extensions/ were left on disk and disowned in the same operation. Nothing
would ever have collected them; they were removed by hand. #920 removes the deprecated probes, which closes
the shadowing risk — a stale extension silently loading when the new copy is missing — but not the
accretion, and does nothing for the non-path cases above.
Every app, by construction
Four products build through cli.NewRootCmd, which wires NewSelfCmd with this same
runSelfInstall/runSelfUninstall pair:
| Product | Root |
|---|---|
lore |
cmd/lore/lore/root.go:27 |
star |
cmd/star/star/root.go:167 |
writ |
cmd/writ/writ/root.go:27 |
devlore-test |
cmd/devlore-test/devloretest/root.go:32 |
The ruling therefore lands in one function and holds for all four. No per-product work.
What the design must settle
- Implicit uninstall, not a diff. The ruling says
self installuninstalls a prior install, which is one
already-tested code path rather than new difference logic. The order withinrunSelfInstalland what
happens when the install then fails partway — leaving the tool absent — needs deciding; nothing here is
transactional today. - No prior manifest is the normal first install, not the error
runSelfUninstallraises today
(:470-474, "no manifest found … was it installed with 'self install'?"). - The hash-mismatch skip, under implicit uninstall. Leaving an edited file is right for an explicit
uninstall. Under an implicit one, a changed file at a path the new install does not write is left and
disowned again — the accretion this issue is about. Report it, refuse, or accept it? - Config, cache and writ layer directories are not in the manifest (steps 4 and 6). Implicit uninstall
must not reach them;self uninstalldoes not either. - Windows: a running executable cannot be removed. Overwriting one is already constrained; removing it
is stricter.make installruns the freshly built binary frombuild/, butstar self installinvoked
from the installed copy is a real case on an ARM64 Windows box.
Acceptance
-
self installover a prior install leaves no file the prior install placed and this one does not - The manifest after any install lists exactly what is on disk for that tool under the prefix
- A first install — no prior manifest — is not an error
- A file whose hash does not match the manifest is handled as ruled, and the behaviour is stated in the
command's documentation - Config and cache are untouched by the implicit uninstall
- A test installs a fixture tool, changes its file set, re-installs, and asserts the old paths are gone
and the manifest matches the tree — for at least one product, since the path is shared - The behaviour is documented where writ's lifetime ruling is, so the two read as one model
Related
#917 (self uninstall removes only what its manifest records — the precondition that made this visible) ·
#918 and #921 (the path move that exposed it) · #920 (removes the deprecated probes; closes shadowing, not
accretion) · #916 and #913 (writ's identical defect and the ruling this borrows) · #922 (deploy replaces the
record) · noblefactor-ops#227 (where the 24 stranded files were found)
Plan and design documents
| Kind | Document |
|---|---|
| Plan | docs/plans/fix/933-self-install-never-reconciles.md |
Activity
chore(plan): #933 reads complete
fix(cli): self install replaces the record, retiring what it no longe…