Commit a49b4fa
Add thv upgrade check and list --check-upgrades (#5409)
* Add upgrade detection for registry workloads
CLI and API users have no way to discover when a newer version of a
registry-sourced MCP server is available; only Studio implements drift
detection, in its frontend. Introduce a backend package that all clients
can consume.
Add pkg/workloads/upgrade with a Checker that compares a running
workload's image tag against its registry entry (semver-aware, with a
string fallback) and reports environment-variable and configuration
(transport / permission-profile / network-isolation) drift. Comparison
degrades safely to "unknown" for :latest, digest refs, repository
changes, and non-registry-sourced workloads, so only a strictly-newer
tag on the same repository yields "upgrade-available".
This is the read-only detection core (RFC THV-0068, phase A); the apply
path, API endpoints, and CLI follow in later changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Address review feedback on upgrade detection
- Lowercase an uppercase "V" tag prefix so semver comparison works;
"V1.2.0" vs "V1.3.0" no longer falls through to undecidable and
hides a real upgrade.
- Drop the raw provider error from CheckResult.Reason (it is serialized
into the API response and can leak internal addressing); log it at
DEBUG and return a fixed string. Same for the CheckAll path.
- Add a defensive default to the comparison switch so an unexpected
value yields StatusUnknown rather than the least-safe StatusUpToDate.
- Stop reporting network-isolation drift: the registry has no
network-isolation field, so it fired for every isolated workload
regardless of the candidate version. Remove the ConfigDrift field
and the now-unused BoolChange type.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add upgrade-check REST endpoints for workloads
CLI, Studio, and automation need a single backend source of truth for
upgrade availability instead of each client reimplementing registry
drift detection. Expose the Phase A checker over the existing workloads
API.
Add GET /api/v1beta/workloads/upgrade-check (batch) and
GET /api/v1beta/workloads/{name}/upgrade-check (single). The batch
handler reuses the exact group/all authorization scoping of the list
endpoint and intersects it with the enumerated run configs, so it can
never report a workload outside the caller's scope. Responses carry only
non-sensitive CheckResult metadata; secret env-var defaults are cleared.
Both routes are read-only and skip image pulls, so they use the standard
timeout. Regenerate the OpenAPI spec.
The dedicated apply endpoint (POST .../upgrade) follows once the Applier
lands (RFC THV-0068, phase B).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Return 404 for unknown group in workload listing
FilterByGroup returns an empty slice (nil error) for a group that does
not exist, so a typo'd ?group= silently returned 200 with an empty list
instead of the documented 404. Check group existence explicitly via the
group manager before filtering, in both the upgrade-check and the
listWorkloads handlers, so the advertised 404 is real. Add a bulk
upgrade-check test covering the unknown-group path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Regenerate OpenAPI spec after dropping network-isolation drift
The upgrade detection change removed the ConfigDrift.NetworkIsolation
field and the BoolChange type, so regenerate the committed OpenAPI spec
to drop the stale schema and property. Fixes the Verify Swagger
Documentation CI check.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add thv upgrade check and list --check-upgrades
CLI users had no way to see whether their registry-sourced MCP servers
have newer versions available. Surface the upgrade checker on the
command line.
Add a thv upgrade command group with a check [name] subcommand: with a
name it prints a verbose report (candidate image, new env vars, and
permission/transport/network posture drift); with no name it prints a
table for all workloads. Add an opt-in --check-upgrades flag to thv list
that appends an upgrade column. Both reuse the pkg/workloads/upgrade
checker and only format results; the default list path is unchanged and
performs no registry lookup, so it stays offline-friendly. Bulk output
is sorted by name to match thv list.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Address review feedback on upgrade CLI
- Reject --check-upgrades together with --format mcpservers: that format
has no upgrade column, so the combination performed a registry lookup
per workload and discarded the result. Fail loudly in PreRunE instead.
- Guard the bulk-result loop against nil entries so it stays robust if
CheckAll's contract ever changes.
- Drop the network-isolation line from the posture-drift report; the
checker no longer reports it (the registry has no such field).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 16ce897 commit a49b4fa
8 files changed
Lines changed: 561 additions & 16 deletions
File tree
- cmd/thv/app
- docs/cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
| 59 | + | |
| 60 | + | |
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| 65 | + | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
62 | 82 | | |
63 | 83 | | |
64 | 84 | | |
| |||
81 | 101 | | |
82 | 102 | | |
83 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
84 | 114 | | |
85 | 115 | | |
86 | 116 | | |
87 | | - | |
| 117 | + | |
88 | 118 | | |
89 | 119 | | |
90 | 120 | | |
| |||
97 | 127 | | |
98 | 128 | | |
99 | 129 | | |
100 | | - | |
| 130 | + | |
101 | 131 | | |
102 | 132 | | |
103 | 133 | | |
104 | 134 | | |
105 | | - | |
106 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
107 | 173 | | |
108 | 174 | | |
109 | 175 | | |
| |||
112 | 178 | | |
113 | 179 | | |
114 | 180 | | |
115 | | - | |
116 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
117 | 198 | | |
118 | 199 | | |
119 | 200 | | |
120 | | - | |
121 | | - | |
122 | 201 | | |
123 | 202 | | |
124 | 203 | | |
| |||
150 | 229 | | |
151 | 230 | | |
152 | 231 | | |
153 | | - | |
154 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
155 | 235 | | |
156 | 236 | | |
157 | 237 | | |
158 | 238 | | |
159 | 239 | | |
160 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
161 | 245 | | |
162 | 246 | | |
163 | 247 | | |
| |||
168 | 252 | | |
169 | 253 | | |
170 | 254 | | |
171 | | - | |
| 255 | + | |
172 | 256 | | |
173 | 257 | | |
174 | 258 | | |
| |||
179 | 263 | | |
180 | 264 | | |
181 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
182 | 278 | | |
183 | 279 | | |
184 | 280 | | |
| |||
0 commit comments