Skip to content

fix: address code review feedback on runbook executor - #11

Merged
itenev merged 4 commits into
mainfrom
feat/runbook-executor
Jun 8, 2026
Merged

fix: address code review feedback on runbook executor#11
itenev merged 4 commits into
mainfrom
feat/runbook-executor

Conversation

@loki-hermes-agent

@loki-hermes-agent loki-hermes-agent Bot commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Implements the runbook executor (Task 14) to execute diagnostics and actions defined in YAML runbooks, and addresses subsequent code review feedback.

Key Changes:

  • Created src/agentic_node_ops/executor.py with robust command execution.
  • Fixed child process leak on timeout using start_new_session=True and os.killpg (with SIGKILL fallback).
  • Switched to shell=False with shlex.split() by default to prevent shell injection, adding a shell_required flag to RunbookAction for explicit opt-in.
  • Added graceful ValueError handling in _parse_timeout with a 30s default.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Pre-Review Findings and Resolutions

  • Linting/formatting (ruff check --fix && ruff format) applied before pre-review.
  • Any runbook loading/YAML changes include an end-to-end test loading the physical file. (N/A for this PR, executor tests use safe mock commands).
  • Design contracts verified (single-writer boundary maintained, no new violations introduced).
  • Findings flagged by Hermes:
    • Initial implementation used subprocess.run with shell=True, risking child process leaks on timeout and shell injection from YAML strings.
  • Resolutions applied:
    • Replaced with subprocess.Popen + os.killpg for safe process group termination.
    • Defaulted to shell=False with shlex.split(), adding explicit shell_required opt-in for privileged actions.

Testing

  • All existing tests pass (pytest -v --cov=agentic_node_ops --cov=webhook_receiver — 161 tests passed, 90% coverage)
  • New tests added for new functionality (tests/test_executor.py includes 10 tests covering command success/failure/timeout, process group kill verification, shell injection prevention, and graceful timeout parsing)
  • Manual verification steps (if applicable): N/A (fully covered by unit tests)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (docs/hermes-implementation-plan.md)
  • My changes generate no new warnings or errors

loki-hermes-agent[bot] added 2 commits June 8, 2026 20:11
- Add execute_command with robust timeout handling
- Add run_diagnostics for TIER 1 automatic execution
- Add execute_action with privileged action blocking
- Add 6 tests covering success, failure, timeout, and privilege checks
- Update hermes-implementation-plan.md to mark Task 14 complete
- Fix child process leak on timeout using start_new_session + os.killpg
- Switch to shell=False with shlex.split() by default to prevent shell injection
- Add shell_required flag to RunbookAction for explicit opt-in to shell=True
- Add graceful ValueError handling in _parse_timeout with 30s default
@loki-hermes-agent loki-hermes-agent Bot changed the title feat: implement runbook executor (Task 14) fix: address code review feedback on runbook executor Jun 8, 2026
@itenev
itenev merged commit 292edfe into main Jun 8, 2026
2 checks passed
@itenev
itenev deleted the feat/runbook-executor branch June 8, 2026 23:29
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