CLI cluster resolution inconsistency: ConfigCentric commands ignore per-app cluster context
Problem
miren cluster current and non-app-centric commands (like miren route list) resolve the "current cluster" through different code paths, leading to confusing behavior where the reported current cluster doesn't match what commands actually target.
Reproduction
~/src/github.com/phinze/media-stuff $ miren cluster current
miren01
~/src/github.com/phinze/media-stuff $ miren route list
# Shows routes from "garden" cluster, not miren01
Root Cause
Two base structs handle cluster resolution differently:
AppCentric(used bycluster current,deploy,app, etc.): resolves via per-app state in~/.config/miren/app-state.toml→ globalactive_clusterConfigCentric(used byroute list, and other non-app commands): resolves via-Cflag →MIREN_CLUSTERenv → globalactive_cluster— completely ignores per-app state
When a user has switched clusters in an app directory (which saves to app-state.toml), cluster current reports the per-app cluster, but ConfigCentric commands silently use the global default instead.
Desired Behavior
What miren cluster current reports should be what all commands in that directory actually use. A user should never be surprised by a command targeting a different cluster than what cluster current says.
Scope
This issue should include a full sweep of the CLI surface area to ensure current cluster is correctly and consistently handled in every case:
- Audit all commands — catalog which commands use
AppCentricvsConfigCentricand identify every place where cluster resolution diverges from whatcluster currentreports. - Unify resolution — ensure
ConfigCentric.LoadCluster()also consults per-app state when a.miren/app.tomlis present in the directory tree, so all commands in an app directory agree on the cluster. - Improve
cluster currentoutput — consider showing both app-level and global cluster when they differ, so the user can understand the full state. - Add tests — cover the resolution priority chain for both
AppCentricandConfigCentricto prevent future regressions.
Key files
cli/commands/app.go—AppCentric.LoadCluster()(lines 105-138)cli/commands/config.go—ConfigCentric.LoadCluster()(lines 67-118)cli/commands/cluster_current.go—ClusterCurrentcommandappconfig/appstate.go— per-app state storage