v1.2.2
Bug Fixes
Backend.AI Auto-detection Improvements (#66, #67)
- Fixed Backend.AI environment auto-detection to properly distinguish between SSH single-host mode and multi-node command execution
- Added comprehensive host detection heuristics:
- Special hostname detection:
localhost,localhost.localdomain - IPv4 address validation:
127.0.0.1,192.168.x.x, etc. - User@host format detection (contains
@) - Host:port format detection (contains
:) - SSH URI format detection (starts with
ssh://) - FQDN detection (multiple
.and no spaces) - IPv6 format detection (starts with
[)
- Special hostname detection:
- Users can now naturally use
bssh localhost "command"in Backend.AI environments - IPv4 addresses now work directly without special syntax
Improvements
Host Detection Logic
- Extracted testable
looks_like_host_specification()function for better maintainability - Added
is_ipv4_address()helper with strict validation (4 octets, each 0-255) - Performance optimized with early returns for most common patterns
- Added 16 comprehensive unit tests covering all detection patterns and edge cases
Documentation
- Updated ARCHITECTURE.md with detailed host detection heuristics documentation
- Added usage examples for SSH single-host mode in Backend.AI environments
- Documented detection order and performance optimizations
Technical Details
Test Coverage
- Added 16 new tests for host specification detection
- Total test count: 402 tests (all passing)
- Test categories:
- IPv4 validation (valid and invalid patterns)
- Localhost variations
- User@host, host:port, SSH URI formats
- FQDN and IPv6 detection
- Edge cases (empty strings, invalid inputs, special characters)
- Performance verification (early return optimization)
- Internationalized domain names
Implementation Details
- Heuristic-based approach balances pragmatism and safety
- Early return optimization: most common patterns checked first
- localhost check: O(1) string comparison
- IPv4 validation: O(4) = O(1) split + parse
- Overall performance impact: < 1μs per call
Files Modified
src/app/initialization.rs: Added detection functionssrc/app/initialization_tests.rs: Added comprehensive testssrc/app/mod.rs: Added test module referencesrc/main.rs: Changedclitomut clifor initializationARCHITECTURE.md: Updated documentation
Example Usage
export BACKENDAI_CLUSTER_HOSTS="node1,node2,node3"
# SSH single-host mode (all now work!)
bssh localhost "whoami" # ✅ 1 node
bssh 127.0.0.1 "whoami" # ✅ 1 node
bssh 192.168.1.100 "whoami" # ✅ 1 node
bssh user@host "whoami" # ✅ 1 node
bssh host:22 "whoami" # ✅ 1 node
bssh server.example.com "whoami" # ✅ 1 node
# Multi-node mode (still works)
bssh "whoami" # ✅ 3 nodesCI/CD Improvements
None
Dependencies
None
Breaking Changes
None
Known Issues
Simple Hostname Limitation: Simple hostnames without indicators (e.g., bssh myserver "command") cannot be automatically distinguished from commands. Use one of these methods:
bssh user@myserver "command"(add user@)bssh myserver:22 "command"(add port)bssh -H myserver "command"(explicit -H flag)
This limitation is minimal as localhost and all IP addresses now work directly.
What's Changed
Full Changelog: v1.2.1...v1.2.2