Repository navigation
Commit 5d99234
fix: one resolved identity; report the upgrade that actually happened (#1305)
Addresses the CHANGES_REQUESTED review on 40779c5. Its three MAJOR findings are not
independent — they are two invariants this change had not finished — so they are fixed
together rather than patched individually.
**One identity, resolved once.** Ownership was verified in `method()`, then independently
re-probed in `preflight()`, again when building the install command, and once more in
`uninstall`. Each was a separate manager query that could fail or race independent of the
one before it, and `owningPackageOrScoped()` turned a later failure into a silent
substitution of the scoped package name. For a confirmed UNSCOPED install that meant
upgrade installed a second, scoped copy while the real one stayed stale — reporting
success — and uninstall deleted the user's data, then removed a package that was never
installed. `identity()` now resolves once and is memoised for the process; nothing it
reads can change while the binary is running. `packageFor()` uses the verified owner, and
when a caller forces `--method`, or ownership is unconfirmed, it logs that it is assuming
the scoped name rather than substituting quietly.
That also answers the third finding: an upgrade previously spawned ~7 manager subprocesses
because every call site re-derived the answer. It is now a single query (two spawns for
npm), while keeping verification before any mutating action.
**Report what actually happened.** Telemetry recorded `status: "success"` and the CLI
printed "Upgrade complete" BEFORE checking whether the running binary had changed; a
mismatch only wrote a log warning. The check also used `text()`, which swallows a failed
spawn and returns "", and an empty string was read as "nothing to verify" — so an upgrade
that left the binary unrunnable reported success. Verification now runs first, via `run()`
so the exit status is visible, and distinguishes three outcomes: a non-zero exit (the
binary cannot start) and a contradicting version both fail the upgrade and record an error;
exit 0 with no output is reported as unverifiable rather than being claimed either way.
Review minors, all fixed:
* uninstall no longer tells the user to "re-run" a command whose binary they have just
removed; it names the data/config/cache/state directories to delete by hand.
* per-manager removal and upgrade syntax — `bun remove -g` and `yarn global remove` are
not `<manager> uninstall -g`.
* Windows recovery text no longer prints POSIX-only paths and `curl … | bash`; it uses
`%USERPROFILE%\.altimate\bin` and the PowerShell installer.
* `--method` no longer offers `choco`/`scoop`, which `Installation.upgrade()` always
refuses. Help snapshot updated.
* the ambiguous trailing "(or altimate-code)" is now an explicit sentence about the
scoped vs unscoped package name.
* `bunGlobalRoot()` falls back to BUN_INSTALL when a configured `install.globalBinDir`
breaks the derivation, and returns "" when bun reports nothing.
* stale comment claiming the failure log "stays local" — the claim `redactSecrets()`'s
own docblock calls false — removed.
* `ownership.test.ts` no longer leaks a temp directory per run; short-token redaction
shapes pinned.
Known limitation, deliberate: only the manager the path points at is queried. Probing every
manager would resolve a custom layout whose directory carries no recognisable segment, but
it multiplies the subprocess count this change exists to reduce, to rescue a case that
already degrades safely to notify-only.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent 40779c5 commit 5d99234
7 files changed
Lines changed: 211 additions & 74 deletions
File tree
- packages/opencode
- src
- cli/cmd
- installation
- test
- cli/help/__snapshots__
- installation
- install
- release-validation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
64 | 75 | | |
65 | 76 | | |
66 | 77 | | |
| |||
0 commit comments