Repository navigation
Commit 2708fc8
fix: resolve install ownership from the manager; refuse destructive actions when unresolved (#1305)
Three-model review (round 3) returned blocker-grade findings that all traced to the same
root cause: identity was being inferred from the path string. A path cannot distinguish a
top-level global install from a transitive dependency, and it cannot say which of our two
published wrappers owns a platform package. Ownership is now a filesystem fact obtained
from the package manager.
`ownerOf(root, execPath)` asks which of `@altimateai/altimate-code` / `altimate-code`
actually contains the running binary, and covers both real shapes:
(a) the binary inside the wrapper — postinstall hard-links it to
`<wrapper>/bin/.altimate-code` and the shims run that first;
(b) the binary as one of our platform packages stored BESIDE the wrapper — pnpm's
isolated store, hoisting, every Windows install (postinstall exits early there), and
any install run with `--ignore-scripts`.
(b) is bounded to that manager's own tree so a project-local binary cannot borrow a global
wrapper's identity, and it refuses when BOTH wrappers are installed rather than guessing.
`Installation.method()` returns a package-manager identity only when ownership is
confirmed; otherwise `unknown`. That made `unknown` much more common, which exposed the
consumer that had never been re-examined:
**`uninstall` now refuses before removing anything when ownership is unresolved.** It was
deleting data, config, cache and state unconditionally while skipping both the binary and
the package removal — so an unverifiable install lost everything the user cared about and
stayed installed, silently. It now stops and prints per-manager removal instructions.
**The CLI upgrade dead end is gone.** "Install anyways?" passed `unknown` straight to
`Installation.upgrade()`, which refuses it, so both answers ended in `UpgradeFailedError`.
Replaced with actionable instructions. `UNSUPPORTED_UPGRADE_METHODS` is shared so the CLI
and both HTTP routes reject the same set — the v2 handler had drifted to `unknown` only.
`upgrade()` refuses yarn/scoop/choco at the choke point and the scoop/choco branches are
deleted; they installed upstream's `opencode` package, not ours.
Diagnostics are redacted before reaching any sink — the logger fans out to stderr under
OPENCODE_PRINT_LOGS and to an OTLP collector when one is configured, so "it stays local"
was never true. Masks now cover `Basic` blobs, quoted JSON keys and bare URL userinfo, and
the post-upgrade `running:` field is redacted like every other subprocess-derived value.
KNOWN OUTSTANDING — deliberately not fixed here, tracked for a follow-up:
* `owningPackageOrScoped()` still falls back to the scoped name when a second manager
query disagrees with the one `method()` already made. An unscoped install could then be
upgraded under the scoped name, installing a duplicate. The fix is to resolve one
identity and thread it through rather than re-deriving it per call site.
* `resolveInstall()` picks a single candidate manager from path shape and only that one
is queried, so a custom bun/pnpm directory without the expected segment resolves to
npm, finds no owner, and degrades to `unknown`. Path shape should order which managers
to ask, not decide the answer.
* The standalone upgrade path still writes `$HOME/.altimate/bin` regardless of where the
running binary lives.
* Coverage is unit-level; there is no test across detection → upgrade → uninstall.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>1 parent 6ee55b6 commit 2708fc8
8 files changed
Lines changed: 412 additions & 118 deletions
File tree
- packages/opencode
- src
- cli/cmd
- installation
- server/routes
- instance/httpapi/handlers
- test
- installation
- install
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
65 | 85 | | |
66 | 86 | | |
67 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
68 | 93 | | |
69 | 94 | | |
70 | 95 | | |
| |||
83 | 108 | | |
84 | 109 | | |
85 | 110 | | |
86 | | - | |
| 111 | + | |
87 | 112 | | |
88 | 113 | | |
89 | 114 | | |
| |||
103 | 128 | | |
104 | 129 | | |
105 | 130 | | |
106 | | - | |
| 131 | + | |
107 | 132 | | |
108 | 133 | | |
109 | 134 | | |
| |||
135 | 160 | | |
136 | 161 | | |
137 | 162 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
142 | 167 | | |
143 | 168 | | |
144 | 169 | | |
145 | 170 | | |
146 | 171 | | |
147 | 172 | | |
148 | 173 | | |
149 | | - | |
| 174 | + | |
150 | 175 | | |
151 | 176 | | |
152 | 177 | | |
| |||
186 | 211 | | |
187 | 212 | | |
188 | 213 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
193 | 218 | | |
194 | 219 | | |
195 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
69 | 67 | | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
0 commit comments