Submit an issue View all issues Source
MIR-832

CLI cluster resolution inconsistency: ConfigCentric commands ignore per-app cluster context

Done public
phinze phinze Opened Mar 17, 2026 Updated Mar 19, 2026

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 by cluster current, deploy, app, etc.): resolves via per-app state in ~/.config/miren/app-state.toml → global active_cluster
  • ConfigCentric (used by route list, and other non-app commands): resolves via -C flag → MIREN_CLUSTER env → global active_clustercompletely 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:

  1. Audit all commands — catalog which commands use AppCentric vs ConfigCentric and identify every place where cluster resolution diverges from what cluster current reports.
  2. Unify resolution — ensure ConfigCentric.LoadCluster() also consults per-app state when a .miren/app.toml is present in the directory tree, so all commands in an app directory agree on the cluster.
  3. Improve cluster current output — consider showing both app-level and global cluster when they differ, so the user can understand the full state.
  4. Add tests — cover the resolution priority chain for both AppCentric and ConfigCentric to prevent future regressions.

Key files

  • cli/commands/app.goAppCentric.LoadCluster() (lines 105-138)
  • cli/commands/config.goConfigCentric.LoadCluster() (lines 67-118)
  • cli/commands/cluster_current.goClusterCurrent command
  • appconfig/appstate.go — per-app state storage