5cc4c8d fixes the AppCentric problem from my last review, so this is ready for a human reviewer. I found one smaller gap in the new options struct, noted inline. It isn't a blocker.
I checked the new CloudAppOptions (cloud.go:466-504) against each of the three problems:
MIREN_CLUSTER: Cluster is now a plain short:"C" long:"cluster" field with no env tag. Without -C, the {cluster} placeholder stays empty and cloudInput fails with --cluster is required before any request goes out. The "runtime cluster environment is not a Cloud ID" case in TestCloudAppContextInvoke sets MIREN_CLUSTER, then asserts that error and zero requests.LoadCluster, so setup() in global.go only reaches its LoadConfig branch, and that just reads the client config. TestCloudAppDoesNotDialRuntime uses a live UDP listener to check that no packets go out.Validate only fills App from app.toml and never prompts. TestCloudAppMissingNameDoesNotInitialize asserts the --app is required error and that no .miren directory is created.I'm resolving my thread.
New, non-blocking: CloudAppOptions.Validate doesn't have the sandbox guard that AppCentric.Validate has (app.go, the MIREN_RUNTIME_APP block). Inside a sandbox, MIREN_APP is injected as an alias for the sandbox's own app name. AppCentric notices this and defers to the local app.toml. The new code returns as soon as o.App is non-empty. So miren cloud app show, run in a sandbox from another app's directory, shows the sandbox's app instead of the one in app.toml. The description says these commands keep MIREN_APP/app.toml selection, and this is the one case where they don't. The test explicitly clears MIREN_RUNTIME_APP, so it never exercises this path. The effect is narrow and read-only, but it's cheap to fix. Details are in the inline comment.
The org-ID thread at cloud.go:272 is still waiting for a person to close it.
I'm not recommending approval without a human review. This PR adds a large set of commands that write to an external service, and the tests check them against mocks built on the same assumptions about Cloud's API as the code. Your source-level checks against the Cloud handlers help. Someone familiar with Cloud should still look over the write paths before merge: member role PUT, cluster PATCH, invite PATCH, subdomain assign, and token revoke.
o.App is set skips the sandbox guard in AppCentric.Validate (app.go, the MIREN_RUNTIME_APP / RuntimeEnvAliases block). Inside a sandbox, MIREN_APP is injected as the sandbox's own app name. mflags copies it into o.App, so this returns before app.toml is ever read. Running cloud app show from another app's directory inside a sandbox then targets the sandbox's app instead of the app.toml in front of the user. AppCentric exists partly to prevent exactly that.Suggested fix: load the local config first. Then, when MIREN_RUNTIME_APP is set, o.App equals both it and the legacy MIREN_APP, and the config has a name, use the config's name. The cleanest way is probably to pull that check out of AppCentric.Validate into a small shared helper, so the two copies can't drift apart. A test case with MIREN_RUNTIME_APP=env-web and MIREN_APP=env-web that expects local-web would cover it. Today TestCloudAppContextInvoke clears MIREN_RUNTIME_APP.
Posted to the PR's comment threads when you submit.
(reply & resolve: addressed) 5cc4c8d fixes all three problems:
CloudAppOptions is now its own struct, and its Cluster field has no env binding.
There's no LoadCluster hook for setup() to call.
Validate only fills the app name from app.toml, so a missing name ends in --app is required instead of an init prompt.
The environment case in TestCloudAppContextInvoke now sets MIREN_CLUSTER and expects --cluster is required with zero requests, which is what I asked for. The UDP-listener test and the no-.miren test also cover the other two directly. Thanks, I'm resolving this.
I've left a separate, smaller note at line 477: the sandbox MIREN_RUNTIME_APP guard didn't carry over to the new struct.
Verdict: ready
{
"owner": "mirendev",
"repo": "runtime",
"number": 1359,
"verdict": "ready",
"event": "comment",
"summary": "5cc4c8d fixes the `AppCentric` problem from my last review, so this is ready for a human reviewer. I found one smaller gap in the new options struct, noted inline. It isn't a blocker.\n\nI checked the new `CloudAppOptions` (`cloud.go:466-504`) against each of the three problems:\n\n- **`MIREN_CLUSTER`:** `Cluster` is now a plain `short:\"C\" long:\"cluster\"` field with no `env` tag. Without `-C`, the `{cluster}` placeholder stays empty and `cloudInput` fails with `--cluster is required` before any request goes out. The \"runtime cluster environment is not a Cloud ID\" case in `TestCloudAppContextInvoke` sets `MIREN_CLUSTER`, then asserts that error and zero requests.\n- **Runtime dial:** the struct has no `LoadCluster`, so `setup()` in `global.go` only reaches its `LoadConfig` branch, and that just reads the client config. `TestCloudAppDoesNotDialRuntime` uses a live UDP listener to check that no packets go out.\n- **Init prompt:** `Validate` only fills `App` from `app.toml` and never prompts. `TestCloudAppMissingNameDoesNotInitialize` asserts the `--app is required` error and that no `.miren` directory is created.\n\nI'm resolving my thread.\n\n**New, non-blocking:** `CloudAppOptions.Validate` doesn't have the sandbox guard that `AppCentric.Validate` has (`app.go`, the `MIREN_RUNTIME_APP` block). Inside a sandbox, `MIREN_APP` is injected as an alias for the sandbox's own app name. `AppCentric` notices this and defers to the local `app.toml`. The new code returns as soon as `o.App` is non-empty. So `miren cloud app show`, run in a sandbox from another app's directory, shows the sandbox's app instead of the one in `app.toml`. The description says these commands keep `MIREN_APP`/`app.toml` selection, and this is the one case where they don't. The test explicitly clears `MIREN_RUNTIME_APP`, so it never exercises this path. The effect is narrow and read-only, but it's cheap to fix. Details are in the inline comment.\n\nThe org-ID thread at `cloud.go:272` is still waiting for a person to close it.\n\nI'm not recommending approval without a human review. This PR adds a large set of commands that write to an external service, and the tests check them against mocks built on the same assumptions about Cloud's API as the code. Your source-level checks against the Cloud handlers help. Someone familiar with Cloud should still look over the write paths before merge: member role PUT, cluster PATCH, invite PATCH, subdomain assign, and token revoke.",
"comments": [
{
"path": "cli/commands/cloud.go",
"line": 477,
"side": "RIGHT",
"body": "Returning early whenever `o.App` is set skips the sandbox guard in `AppCentric.Validate` (`app.go`, the `MIREN_RUNTIME_APP` / `RuntimeEnvAliases` block). Inside a sandbox, `MIREN_APP` is injected as the sandbox's own app name. mflags copies it into `o.App`, so this returns before `app.toml` is ever read. Running `cloud app show` from another app's directory inside a sandbox then targets the sandbox's app instead of the `app.toml` in front of the user. `AppCentric` exists partly to prevent exactly that.\n\nSuggested fix: load the local config first. Then, when `MIREN_RUNTIME_APP` is set, `o.App` equals both it and the legacy `MIREN_APP`, and the config has a name, use the config's name. The cleanest way is probably to pull that check out of `AppCentric.Validate` into a small shared helper, so the two copies can't drift apart. A test case with `MIREN_RUNTIME_APP=env-web` and `MIREN_APP=env-web` that expects `local-web` would cover it. Today `TestCloudAppContextInvoke` clears `MIREN_RUNTIME_APP`."
}
],
"replies": [
{
"thread_id": "PRRT_kwDONZ__ss6xToBS",
"body": "5cc4c8d fixes all three problems:\n\n- `CloudAppOptions` is now its own struct, and its `Cluster` field has no `env` binding.\n- There's no `LoadCluster` hook for `setup()` to call.\n- `Validate` only fills the app name from `app.toml`, so a missing name ends in `--app is required` instead of an init prompt.\n\nThe environment case in `TestCloudAppContextInvoke` now sets `MIREN_CLUSTER` and expects `--cluster is required` with zero requests, which is what I asked for. The UDP-listener test and the no-`.miren` test also cover the other two directly. Thanks, I'm resolving this.\n\nI've left a separate, smaller note at line 477: the sandbox `MIREN_RUNTIME_APP` guard didn't carry over to the new struct.",
"resolve": true,
"resolve_reason": "addressed"
}
],
"posted_to_pr": true,
"head_sha": "5cc4c8d5942ef95ed732487afac4a1b2dc5b738c"
}GitHub now reports the branch as mergeable, so the blocker from my last review is gone. Your source check of the enrollment handler shows it accepts an empty POST, which settles my other concern. I'm dropping both.
The new commit, 6a098ef (RFD-120 alignment), adds one problem that I think should be fixed before handoff.
cloud app * reads MIREN_CLUSTER as a Cloud cluster XID. CloudAppOptions (cloud.go:469-472) now embeds AppCentric, and with it ConfigCentric, whose Cluster field is tagged env:"MIREN_CLUSTER". When -C is omitted, that env var fills {cluster} in cloudAppPath. Everywhere else in the runtime, MIREN_CLUSTER holds a local cluster name or an address;sha1:… string. Your own guide says -C takes "Cloud cluster IDs, not local configuration names". So in any shell or CI job that sets MIREN_CLUSTER for normal commands, miren cloud app show puts that value into the Cloud path, and the user gets a confusing 404 instead of "--cluster is required". TestCloudAppContextInvoke's "environment" case asserts this behaviour (env-cluster ends up in the path), so the test currently protects the bug.
The same embedding brings two more AppCentric hooks into these read-only commands:
setup() in global.go calls the promoted LoadCluster(). With -C <xid>, GetCluster fails and falls through to setupClusterFromAddress, which resolves <xid>:8443 and attempts a QUIC dial (10s timeout) before the Cloud request runs. The error is quietly discarded, so the call only costs time.Cmd.Invoke runs the promoted AppCentric.Validate. In a terminal, outside an app directory and without -a, that offers to run miren init and create .miren/app.toml in the current directory.My suggested fix: give the cloud app commands their own small options struct. Keep -a/MIREN_APP/-d and the app.toml name lookup, give it a plain -C/--cluster with no env binding, and don't embed AppCentric itself. Then flip the "environment" test so that MIREN_CLUSTER with no -C yields "--cluster is required".
The rest of the commit holds up. Every destructive command takes --yes/-y, the new top-level nouns don't collide with any existing runtime command, and TestCloudOrganizationResolution covers the default, missing, duplicate, ID-skip and lookup-error paths for org resolution. The org-ID thread at cloud.go is still waiting for a human to resolve it.
Once the issue above is fixed, I'd still want a human reviewer before merge, for the reasons in my last review. This PR adds many commands that write to an external service, and the tests use mocks built on the same assumptions about Cloud's API as the code.
cli/commands/cloud.go:471 — Embedding AppCentric here pulls in ConfigCentric.Cluster (short:"C" long:"cluster" env:"MIREN_CLUSTER"), and that field fills {cluster} in cloudAppPath. Three things follow:
With MIREN_CLUSTER=prod (a local name) and no -C, cloud app show sends /apps/prod/<app> to Cloud and gets a 404 instead of failing with --cluster is required.
With -C <xid>, setup() (global.go) calls the promoted AppCentric.LoadCluster(). That treats the XID as a host: setupClusterFromAddress resolves <xid>:8443 and attempts a QUIC dial with a 10s timeout, all before the Cloud request runs.
Cmd.Invoke runs the promoted AppCentric.Validate. In a terminal, with no app config and no -a, it offers to miren init in the current directory.
A dedicated struct would avoid all three. Give it App/Dir with the same tags as AppCentric, plus a Cluster with short:"C" long:"cluster" and no env, and add a small helper that defaults the app name from appconfig. TestCloudAppContextInvoke's "environment" case currently expects MIREN_CLUSTER in the Cloud path. It should assert --cluster is required instead.
Verdict: not_ready
The new commit, 1d91966, adds cloud cluster cloud-init and does what the description says. The blocker is that GitHub now reports this branch as not mergeable against main. Several of the touched files are shared generated docs (docs/command-sidebar.json, docs/docs/commands.md) or a registration point (cli/commands/commands.go), so after rebasing, regenerate the command docs with go generate rather than resolving those files by hand. I found no defect in the code itself.
On the new command:
Text is set, progress and identity messages go to stderr through the same ProgressToStderr path that --json uses. The selected field is written to stdout byte-for-byte. Anything other than a nonempty string is an error, and nothing reaches stdout. TestCloudInitOutput covers each of these: stdout equals the snippet exactly, "Using identity" appears on stderr, --json returns the whole document, and nil, "" and true for user_data each fail with empty stdout. Putting umask 077 before the redirect in the guide also matters, because the output carries a credential.cloud-init can't drift from enroll-token create. Both are built in one loop from the same path, inputs and option struct, so TTL and tag handling stay identical.For the human reviewer: run with no flags, miren cloud cluster cloud-init sends a POST with no body and no Content-Type. cloudInput returns an untyped nil body, and request() only sets the header when there's a body. The guide's main example runs it this way, and so does the "reuse a live token" path. The source check posted in the PR comments covers several write endpoints but not the enroll-token handler, and the mock accepts an empty body. Someone who knows Cloud should confirm that handler accepts an empty POST rather than failing on a JSON decode with EOF. If it doesn't, the bare invocation fails with a 400, and so does enroll-token create with no flags.
Org-ID thread at cloud.go:248: your check of the Cloud source answered my technical question, and nothing in this commit changes that. I asked a human to judge it, so the thread stays open for a person to resolve.
Approval: I'm not recommending approval without a human reviewer. The PR adds many commands that write to an external service, including this one, which creates a credential. The tests use mocks built on the same contract assumptions as the code, and the empty-body POST above is one of those assumptions.
Verdict: not_ready
The one new commit, 64021c9, adds organization selection and readable cloud me output, and it holds up. The verdict stays READY. One assumption needs a human to confirm, and I've marked it inline.
What matters in the new commit:
CloudCommand calls cloudInput with a nil resolver first, so bad inputs are rejected without a network call. TestCloudValidationAndErrors and TestCloudResourceValidation still assert zero requests.--force check still runs before any network call.cluster approve, where it's a required body field. No command has an optional org filter, so defaulting to your only organization can't narrow a query nobody asked to narrow.organization is safe. Any value without the org- prefix goes through name lookup, so only a server-returned ID reaches the path. The "dot name is resolved" test covers this.TestCloudOrganizationResolution covers names in the path and body, defaults, destructive defaults, ambiguous and missing names, empty and multiple memberships, and lookup failure. It asserts the exact request sequence each time. TestCloudMeTextOutput covers the new renderer, including the "Not reported" fallbacks, and checks that --json still returns the full document.For the human reviewer (inline at cloud.go:238): whether a value counts as an ID or a name now depends only on the org- prefix. The fixtures and docs assume org-… IDs. But the existing code calls these organization_xid, and cluster add matches on name or XID equality with no prefix check. If real Cloud org IDs aren't prefixed, an ID copied from cloud org list will fail with "not found" on every org-scoped command. That would be a regression, because before this commit --organization took the ID as-is. Someone who knows Cloud's ID format can settle this quickly. Adding org.ID == organization to the lookup loop would make it safe either way.
Approval: I'm still not recommending approval without a human reviewer, for the same reason as before. The PR adds many commands, writes included, against an external service, and the tests use mocks built on the same contract assumptions the code makes. The org-ID format is one more of those assumptions.
org- prefix. If Cloud org IDs are bare XIDs, -o <id> falls through to name lookup and fails with "organization … not found". The existing organization_xid naming hints they might be. That failure would hit every org-scoped command for anyone who copies an ID from cloud org list, and those IDs worked before this commit. Can someone who knows Cloud confirm org IDs really are org--prefixed?You can make this safe either way cheaply: in the resolver loop, also accept org.ID == organization, which is what cluster_add.go:181 already does. Keep the prefix shortcut so prefixed IDs still skip the lookup. Anything else that exactly matches an ID would then resolve instead of erroring.
Verdict: ready
Both framework concerns from my last review are fixed in 95698c1, and each fix has a test that would catch a regression.
cloud.go:124-139): the code now walks to the selector's parent and refuses to write unless that parent is an object. Only a missing or null leaf becomes "". TestCloudPartialUpdatesRejectUnexpectedEnvelope covers null, [], {}, a null envelope and an array envelope for both account update and group update, and checks that no write goes out. The null-avatar case in TestCloudPartialUpdates still passes, so optional fields behave as before.cloudapi.go:161-164): the no-follow policy now applies only to non-GET methods. TestReadRequestsFollowRedirects covers redirected ListClusters and ClusterOnline reads, and the approval-replay test is still there.On the API contract questions, your comment says you checked the Cloud handlers and route registrations. That covers the write paths and body fields, the user and group envelopes, and the cluster-channel online route. It also covers the nine DELETEs: each returns either 204 with no body or 200 with JSON. I can't see the Cloud source from here, so I'm relying on your check. Given it, I'm fine with EOF on a 2xx staying an error.
You also found that the existing ClusterOnline client calls a route current Cloud doesn't register. That predates this PR and isn't made worse here, so it's reasonable to leave it out. But it probably means the cloud-reachability check behind miren cluster add's picker fails today, so it's worth its own ticket.
Nothing I found blocks taking this out of draft. I'm still not recommending approval without a human reviewer, for the same reason as before. The PR adds about 50 commands, many of them writes and destructive operations, against an external service. Your contract check was against Cloud's source, not a live instance, and the tests here use mocks built from those same assumptions. Someone who knows Cloud can confirm that check much faster than I can.
Posted to the PR's comment threads when you submit.
cloud.go:128-135 now fails with "unexpected response shape … refusing to overwrite" before any PUT, and missing or null leaves still become "". The new envelope-rejection test asserts zero writes for both account and group updates, which is what I asked for. Thanks.CheckRedirect override now runs only when method != http.MethodGet, so ListClusters and ClusterOnline follow redirects as they did before, and mutations still don't. Both behaviours have regression tests. Resolving.Verdict: ready
This does what the ticket asks: you can list orgs (cloud org list), approve a cluster registration (cloud cluster approve), and see app visibility (cloud app list/show/deployments/routes/logs). The extra resource commands use the same framework, so each one is mostly a few lines of data in cloud_resources.go. I think it's ready to go from draft to human review. I'm not recommending approval without one, though. It adds roughly 50 commands, many of them writes, against an external API, and nothing in this repo lets me check the paths, envelope keys or body field names against what Cloud actually serves. The tests use mock servers built from those same assumptions.
Parts of the framework that hold up:
cloudInput escapes every path placeholder with url.PathEscape and rejects ./... The web/blue ?#% case checks the escaped path.--description together with --clear-description.--force is passed. TestCloudResourceValidation covers each of them and asserts that zero requests are made.For the human reviewer:
"" when a field is missing (cloud.go:127-130, see inline). If the GET response doesn't have the shape the selector expects, the replacement PUT clears fields the user never touched.cloudapi.go:163, see inline). ListClusters and ClusterOnline no longer follow 3xx responses.org member set-role, cluster update, invite update, subdomain assign and account token revoke-all.user.* and group.* preserve selectors.cloud cluster online calls /api/v1/cluster-channel/clusters/{id}/online, while the existing ClusterOnline client calls /api/v1/clusters/{id}/online. The docs say the new one applies access rules, so this looks deliberate, but it's worth confirming that both routes exist.request() returns early only on 204 (cloudapi.go:178). A 200 with an empty body reaches decoder.Decode and gets reported as failed to parse response: EOF after the delete has already succeeded. If any of these endpoints can do that, treat io.EOF on a 2xx as success."" in the replacement PUT. For an optional field that is already null (like avatar_url), that's fine, and TestCloudPartialUpdates relies on it. But cloudField also returns nil when the envelope itself is missing or has a different shape. For example, if /api/v1/me ever returns the profile at the top level, or under profile instead of user, then cloud account update --name X would PUT email: "". That clears or rejects a field the user never mentioned, with no warning.I'd make this stricter. Treat "the parent of the selector is not an object" as an error (something like "unexpected response shape from GET %s; refusing to overwrite"), and only default to "" when the parent exists and the leaf is absent or null. That keeps today's optional-field behaviour and turns a schema mismatch into a loud failure instead of silent data loss.
request(), so it now also applies to get(). That means ListClusters (used by miren cluster add and login auto-config) and ClusterOnline fail on a 3xx response where they used to follow it. Refusing to replay the approval POST is right. Could someone who knows the Cloud deployment confirm that no issuer URL saved by miren login currently depends on following a redirect (http→https, apex→API host)? If one does, the existing cluster add flow starts failing with cloud returned status 30x. If you'd rather not depend on that, you could limit the no-follow policy to non-GET methods.Verdict: ready