feat: Add run execution management with runtime adapters (ISSUE-005)#7
Open
feat: Add run execution management with runtime adapters (ISSUE-005)#7
Conversation
This PR implements execution management for runbox, adding the ability to spawn, monitor, and control running processes in different runtimes. ## Changes ### Run Structure Extension - Added `status`, `runtime`, `handle`, `log_ref`, `timeline`, `exit_code` fields - Added `RunStatus` enum (Pending, Running, Exited, Failed, Killed, Unknown) - Added `RuntimeHandle` enum for runtime-specific data - Added `LogRef` and `Timeline` structs - Backwards compatible with existing Run JSON files ### RuntimeAdapter Trait - Defined trait for runtime adapters with spawn/stop/attach/is_alive methods - Implemented `BackgroundAdapter` for background processes (pid/pgid management) - Implemented `TmuxAdapter` for tmux session/window management ### CLI Commands - `runbox run --runtime bg|tmux`: Start runs in specified runtime - `runbox ps [--status <status>]`: List runs with status reconciliation - `runbox stop <run_id>`: Stop a running process - `runbox logs <run_id> [-f] [-n <lines>]`: View run logs - `runbox attach <run_id>`: Attach to tmux window (tmux only) - `runbox show <run_id>`: Enhanced output with all new fields ### Other - Added logs directory to storage - Added `short_id()` method to Run for abbreviated IDs - Added `reconcile_runs()` for status consistency checking - Added `find_run()` helper for short ID lookup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes per updated spec: - Add reconcile_reason field to Run struct - RuntimeAdapter.stop() now has force parameter (SIGTERM vs SIGKILL) - TmuxAdapter spawn uses -c for cwd, env prefix, bash -lc - CAS-style updates: only update status when Running - Don't overwrite ended_at if already set - Record reconcile_reason when marking as Unknown - CLI stop command now has --force flag 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ps,stop,logs,attachruncommand with--runtime bg|tmuxoptionshowcommand with detailed run informationKey Features
Runtime Adapters
CLI Commands
runbox run -t <template> --runtime bg|tmuxrunbox ps [--status running]runbox stop <run_id>runbox logs <run_id> [-f]runbox attach <run_id>runbox show <run_id>Architecture
Test plan
runbox run --runtime bgwith a templaterunbox psto list runsrunbox stopto stop a runrunbox logs -fto follow logsrunbox run --runtime tmux(requires tmux)runbox attach(requires tmux)Related Issues
🤖 Generated with Claude Code