feat: Batch Script Mode for Automated Workflows
メンテナーはふだん 1 日以内に返信
@inureyes がすでに取り組んでいます。
2025年12月16日 から。
評価
この issue はまだ評価されていません。
説明
Overview
Implement a comprehensive Batch Script Mode that allows users to execute complex, multi-step operations across cluster nodes using script files. This feature will enable automated workflows, conditional execution, error handling, and sophisticated orchestration patterns while maintaining bssh's focus on parallel execution and simplicity.
Technical Approach
The implementation will follow a dual-format approach, supporting both YAML-based declarative scripts and a custom DSL for more dynamic operations. The script engine will leverage the existing executor infrastructure while adding new capabilities for state management, conditional logic, and error recovery.
Architecture Design
- Script Parser Layer: Flexible parser supporting both YAML and custom DSL formats
- Execution Engine: State-aware runtime with support for variables, conditions, and loops
- Integration Layer: Seamless integration with existing commands (exec, upload, download, ping)
- Session Manager: Persistent connection management for script execution
- Result Aggregator: Intelligent result collection with support for conditional branching
Why This Approach
- Dual Format Support: YAML for simple declarative scripts, DSL for complex logic
- Leverages Existing Infrastructure: Reuses executor, SSH client, and command modules
- Progressive Enhancement: Simple scripts work immediately, advanced features are optional
- Maintainability: Clear separation between parsing, execution, and state management
- Performance: Connection reuse within script execution for efficiency
- Security: Sandboxed execution with explicit variable scoping
Implementation Phases
Phase 1: Core Infrastructure
- Create script module structure at
src/script/ - Implement YAML script parser (
src/script/yaml_parser.rs) - Design script data structures (
src/script/types.rs) - Implement script validator (
src/script/validator.rs)
Phase 2: Execution Engine
- Build core execution engine (
src/script/engine.rs) - Implement state management (
src/script/state.rs) - Add error handling and recovery (
src/script/error_handler.rs) - Create execution context manager (
src/script/context.rs)
Phase 3: Advanced Features
- Implement conditional execution (
src/script/conditions.rs) - Add loop support (
src/script/loops.rs) - Build template engine (
src/script/template.rs) - Implement built-in functions (
src/script/functions.rs)
Phase 4: Custom DSL Implementation
- Design DSL syntax and grammar
- Implement DSL lexer (
src/script/dsl/lexer.rs) - Build DSL parser (
src/script/dsl/parser.rs) - Create DSL to internal representation converter (
src/script/dsl/converter.rs)
Phase 5: Integration and CLI
- Add batch subcommand to CLI (
src/cli.rs) - Integrate with existing executor (
src/executor.rs) - Implement script output management
- Add interactive script debugger
Phase 6: Security and Performance
- Implement security controls (
src/script/security.rs) - Add performance optimizations
- Build script repository support
Phase 7: Testing and Documentation
- Write comprehensive unit tests
- Create integration tests
- Develop example scripts
- Write user documentation
Example Script Formats
YAML Format Example
name: System Update Script
version: 1.0
description: Update and restart services across cluster
variables:
service_name: nginx
backup_dir: /tmp/backups
defaults:
on_error: continue
timeout: 300
parallel: 5
steps:
- name: Create backup directory
command: mkdir -p {{ backup_dir }}
- name: Check service status
command: systemctl status {{ service_name }}
register: service_status
ignore_errors: true
- name: Stop service if running
command: systemctl stop {{ service_name }}
when: service_status.exit_code == 0
- name: Update packages
command: |
apt-get update
apt-get upgrade -y {{ service_name }}
become: true
Custom DSL Format Example
script "System Update" {
var service = "nginx"
var backup_dir = "/tmp/backups"
defaults {
on_error = continue
timeout = 5m
parallel = 5
}
// Create backup directory on all nodes
exec "mkdir -p ${backup_dir}"
// Check service status and store result
status = exec "systemctl status ${service}" {
ignore_errors = true
}
// Conditional execution based on status
if (status.success) {
exec "systemctl stop ${service}"
}
// Update packages with retry logic
retry(3, delay: 10s) {
exec """
apt-get update
apt-get upgrade -y ${service}
""" with sudo
}
}
Dependencies
serde_yaml- Already present for YAML parsingpestornom- For DSL parsing (new dependency)handlebarsortera- For template engine (optional, could build custom)- Existing bssh infrastructure (executor, SSH client, config management)
Success Criteria
- Successfully parse and execute YAML-based scripts with basic flow control
- Support for variables, conditions, and loops in both formats
- Error handling with configurable strategies (fail-fast, continue, retry)
- Performance: Minimal overhead compared to direct command execution
- Security: Sandboxed execution with no arbitrary code execution
- Compatibility: All existing bssh commands work within scripts
- Usability: Clear error messages and debugging capabilities
- Documentation: Comprehensive guides with real-world examples
Use Cases
- System updates across clusters
- Log collection and aggregation
- Rolling deployment patterns
- Health check and monitoring
- Backup and restore operations
Related Work
- Original task document:
.claude/tasks/todo/2_batch_script_mode.md
- 主要言語
- Rust
- スター
- 65
- フォーク
- 7
- 平均マージ
- 47分
- マージ済み PR(30日)
- 11
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lablup/bssh のほかの issue
-
priority:medium status:backlog type:bug
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
メンテナーはふだん 1 日以内に返信
-
priority:high status:in-progress type:enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
Add network-ping command for fast ICMP connectivity testing再び着手できるかも @inureyes が 286 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンpriority:low status:backlog type:enhancement
メンテナーはふだん 1 日以内に返信
-
feat: Implement real-time streaming output with interactive multi-node UI対応中かも @inureyes が 334 日前に担当しました。 オープンpriority:medium status:backlog type:enhancement
メンテナーはふだん 1 日以内に返信
-
feat: Advanced Batch Orchestration with Enterprise-grade Error Handling再び着手できるかも @inureyes が 286 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンpriority:low status:backlog type:enhancement
メンテナーはふだん 1 日以内に返信
似ている issue
-
backend::vllm diffusion multimodal
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
lambdaclass/ethrex#7329 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
shadowsocks/shadowsocks-rust#2186 · コメント 1 件 ·
-
C-bug S-awaiting-triage
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
juspay/hyperswitch#14479 ·
メンテナーはふだん 1 日以内に返信