Skip to content

fix(status): dispatch to remote host like health does - #505

Merged
gfargo-horizon-agent[bot] merged 2 commits into
mainfrom
agent/strut-2256-strut-501-mcp-strut-status-queries-local
Aug 2, 2026
Merged

fix(status): dispatch to remote host like health does#505
gfargo-horizon-agent[bot] merged 2 commits into
mainfrom
agent/strut-2256-strut-501-mcp-strut-status-queries-local

Conversation

@gfargo-horizon-agent

@gfargo-horizon-agent gfargo-horizon-agent Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What

cmd_status and cmd_health share the same remote-dispatch mechanism (should_dispatch_remote/run_remote_strut), but cmd_status had two asymmetries that could leave a topology-mapped stack querying the local Docker daemon instead of the VPS, and that would silently drop --json when it did dispatch remotely — both directly affecting the strut_status MCP tool, which always requests --json.

Why

Closes #501
Plane: OSS-2256

How

  • cmd_status now guards validate_env_file with a -f check, matching cmd_health. A stack resolved purely through strut.conf [stacks]/[hosts] topology (VPS_HOST supplied by topology, no base per-env file on disk) is a valid config for a read-only command — it shouldn't hard-fail with "Env file not found" before ever reaching should_dispatch_remote.
  • cmd_status's remote-dispatch branch now forwards --json to the SSH'd invocation, matching cmd_health. Previously the flag was silently dropped, so a remote strut_status --json call returned the SSH session's raw output instead of what the caller asked for.
  • Updated tests/test_cmd_status_remote.bats: replaced the old "fails gracefully when env file missing" test (which asserted the hard-fail) with tests asserting the new tolerant behavior (dispatches to SSH when VPS_HOST is set even without an env file; falls back to local when it isn't), plus a new test asserting --json is forwarded on remote dispatch.

Testing

  • Manually exercised cmd_status/cmd_health end-to-end against a synthetic project with strut.conf [hosts]/[stacks] topology and a stubbed ssh, confirming status now dispatches remotely (with --json forwarded) both with and without a base .prod.env file present.
  • bats tests/ — not runnable in this sandbox (no bats/shellcheck available); relying on CI.
  • CI: pending

🤖 Generated by the harbor agent loop. Reviewed by a human before merge.

Closes #501

cmd_status differed from cmd_health in two ways that broke the MCP
strut_status tool for stacks resolved purely through strut.conf
[stacks]/[hosts] topology (no base per-env file on disk):

- validate_env_file was called unconditionally, so a missing env file
  hard-failed status instead of falling through to should_dispatch_remote
  the way health does.
- the remote dispatch branch didn't forward --json, so a remote status
  call (which the MCP tool always requests) silently dropped the flag.

Both are now handled the same way cmd_health already does it.
The previous fix for cmd_status skipped validate_env_file whenever the
env file didn't exist, which silently let a local run through even
when --env pointed at a typo'd/nonexistent name (broke
tests/test_cli_env_parsing.bats). Move validate_env_file back so it's
only skipped ahead of the should_dispatch_remote check (needed for a
topology-only stack with no base per-env file), and still runs
unconditionally once we know we're staying local.

@gfargo-horizon-agent gfargo-horizon-agent Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎 Agent review (sonnet) — LGTM

REVIEW: LGTM
RESOLVES: full

The PR closes the two remaining asymmetries between cmd_status and cmd_health (env-file validation ordering and --json forwarding on remote dispatch), verified by tracing should_dispatch_remote/topology_apply_to_env to confirm VPS_HOST is already exported by the entrypoint before cmd_status runs, so moving validate_env_file after the dispatch check is safe. Tests are updated to match the new tolerant behavior and add explicit --json-forwarding coverage.

@gfargo-horizon-agent
gfargo-horizon-agent Bot merged commit ae3c7b8 into main Aug 2, 2026
3 checks passed
@gfargo-horizon-agent
gfargo-horizon-agent Bot deleted the agent/strut-2256-strut-501-mcp-strut-status-queries-local branch August 2, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: strut_status queries local Docker instead of remote host

0 participants