Skip to content

feat: add --port flag to azlin for bastion tunnel reuse (#2897)#2937

Merged
rysweet merged 3 commits intomainfrom
fix/2897-bastion-tunnel-reuse
Mar 8, 2026
Merged

feat: add --port flag to azlin for bastion tunnel reuse (#2897)#2937
rysweet merged 3 commits intomainfrom
fix/2897-bastion-tunnel-reuse

Conversation

@rysweet
Copy link
Owner

@rysweet rysweet commented Mar 7, 2026

Summary

  • Adds --port <N> option to azlin exec and azlin start CLI commands to reuse an existing bastion tunnel instead of creating a new one per SSH session
  • VMOptions.tunnel_port stores the port; Executor._azlin_port_args() injects --port <N> into all azlin subcommands (cp, connect, ssh)
  • SessionManager._execute_ssh_command accepts optional tunnel_port for the same purpose
  • Both .claude/tools/amplihack/remote/ and amplifier-bundle/tools/amplihack/remote/ are kept in sync

Motivation

Currently each azlin connect, azlin cp, and azlin ssh call creates a new bastion tunnel, adding overhead per operation. With --port, users can establish one tunnel upfront and reuse it for the session's lifetime.

Usage

# Establish tunnel externally on port 2222, then reuse it:
amplihack remote exec --port 2222 auto "my task"
amplihack remote start --port 2222 "my task"

Test Plan

  • 13 outside-in tests in tests/outside_in/test_bastion_tunnel_reuse.py cover:
    • VMOptions.tunnel_port defaults to None, accepts integer
    • Executor._azlin_port_args() returns [] or ['--port', 'N']
    • transfer_context includes --port in azlin cp command when set
    • check_tmux_status includes --port in azlin connect command when set
    • CLI exec and start accept --port flag without error
    • --port is wired into VMOptions.tunnel_port and Executor(tunnel_port=...)
    • No regression when --port is not provided
  • All 13 tests pass: uv run pytest tests/outside_in/test_bastion_tunnel_reuse.py -v

Quality Audit

  • Security: tunnel_port is int | None; click validates type=int at CLI boundary; no injection risk
  • Simplicity: _azlin_port_args() is a minimal helper eliminating 6 repetitive conditionals
  • No dead code: every new line is exercised by tests
  • Module boundaries: VMOptions (config) → Executor (executes) → cli.py (wires) — clean
  • Backward compatible: all new params default to None; existing callers unaffected

🤖 Generated with Claude Code

Reduces connection overhead by allowing SSH sessions to reuse an
existing bastion tunnel instead of creating a new one per command.

Changes:
- VMOptions.tunnel_port: new optional int field
- Executor.__init__ accepts tunnel_port; _azlin_port_args() helper
  injects --port <N> into all azlin subcommands (cp, connect, ssh)
- SessionManager._execute_ssh_command accepts tunnel_port parameter
- CLI: --port option added to both 'exec' and 'start' commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

🤖 Auto-fixed version bump

The version in pyproject.toml has been automatically bumped to the next patch version.

If you need a minor or major version bump instead, please update pyproject.toml manually and push the change.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

Repo Guardian - Passed

All files in this PR are durable repository content:

  • Python source files implementing the --port flag feature for azlin tunnel reuse
  • Test files with proper outside-in test coverage
  • Configuration file update (pyproject.toml version bump)

No ephemeral content detected.

AI generated by Repo Guardian

@rysweet rysweet force-pushed the fix/2897-bastion-tunnel-reuse branch from 4579583 to 7180bd6 Compare March 8, 2026 01:30
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

🤖 Auto-fixed version bump

The version in pyproject.toml has been automatically bumped to the next patch version.

If you need a minor or major version bump instead, please update pyproject.toml manually and push the change.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

Repo Guardian - Passed

All files in this PR are durable repository content:

  • Python source files implementing the --port flag feature for azlin tunnel reuse
  • Test files with proper outside-in test coverage
  • Configuration file update (pyproject.toml version bump)

No ephemeral content detected.

AI generated by Repo Guardian

AI generated by Repo Guardian

@rysweet rysweet merged commit 23eb273 into main Mar 8, 2026
2 checks passed
rysweet added a commit that referenced this pull request Mar 8, 2026
* feat: add --port flag to azlin for bastion tunnel reuse (#2897)

Reduces connection overhead by allowing SSH sessions to reuse an
existing bastion tunnel instead of creating a new one per command.

Changes:
- VMOptions.tunnel_port: new optional int field
- Executor.__init__ accepts tunnel_port; _azlin_port_args() helper
  injects --port <N> into all azlin subcommands (cp, connect, ssh)
- SessionManager._execute_ssh_command accepts tunnel_port parameter
- CLI: --port option added to both 'exec' and 'start' commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: trigger full CI pipeline

* [skip ci] chore: Auto-bump patch version

---------

Co-authored-by: Ubuntu <azureuser@deva.ftnmxvem3frujn3lepas045p5c.xx.internal.cloudapp.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

1 participant