Skip to content

Simplify the hotfix supervisor lifecycle - #271

Merged
gilesknap merged 2 commits into
mainfrom
simplify-supervisor
Sep 15, 2026
Merged

gilesknap merged 2 commits into
mainfrom
simplify-supervisor

Conversation

@gilesknap

@gilesknap gilesknap commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Summary

The hotfix supervisor mixed request dispatch, startup waiting and debugger completion in one nested loop. Extract those responsibilities into named helpers, centralize state/hold updates, and share child spawning and PID bookkeeping between normal startup and debugger Launch. Keep the existing lifecycle protocol, probe ownership and descendant cleanup.

Sharing startup fixes Launch inheriting the supervisor's private 077 umask instead of the application's original mask (for example 027). Health checks now have a one-second forced-kill grace after their existing five-second timeout, so a check that ignores TERM cannot block lifecycle requests indefinitely.

Validation

  • 31 tests pass, including failed/cancelled startup recovery, unsafe request rejection, stale debugger heartbeats, detached inferior cleanup, supervisor shutdown, TERM-resistant children and health checks, normal/debugger exit codes, and real FIFO input/output through the lifecycle client.
  • Existing restart-context tests now verify debugger Launch preserves the startup umask.
  • Pre-commit checks, Pyright and Bash syntax validation pass.
  • No live Kubernetes or VS Code acceptance run was performed.

The runtime grows from 229 to 243 lines: the simplification removes duplicated responsibilities and nested control flow rather than compressing the shell text.

Summary by CodeRabbit

  • Bug Fixes

    • Improved supervisor recovery when startup or health checks fail or are cancelled.
    • Ensured unresponsive child processes are terminated before restart.
    • Improved handling of normal process exits and debugger completion, heartbeat, and shutdown events.
    • Preserved application permissions during debugger launches and restarts.
    • Improved request handling and FIFO stream relaying for more reliable lifecycle control.
  • Tests

    • Added coverage for failure recovery, process termination, debugger workflows, and runtime permission preservation.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c69415e3-b5a8-4fbf-a30a-bf645998334c

📥 Commits

Reviewing files that changed from the base of the PR and between 1b1f23e and 0cf6eb8.

📒 Files selected for processing (1)
  • tests/test_lifecycle_failures.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 32328677-b78c-446e-92d8-94c11dba7669

📥 Commits

Reviewing files that changed from the base of the PR and between 1ca50c6 and 1b1f23e.

📒 Files selected for processing (4)
  • Charts/podbench-hotfix-claim/files/podbench.sh
  • tests/conftest.py
  • tests/test_lifecycle_failures.py
  • tests/test_lifecycle_runtime.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The supervisor script now uses separate functions for process spawning, child monitoring, startup health checks, and request handling. New tests exercise failure recovery, debugger lifecycle paths, safe-mode behavior, stream relaying, and umask preservation.

Changes

Supervisor lifecycle

Layer / File(s) Summary
Process state and spawning
Charts/podbench-hotfix-claim/files/podbench.sh
Supervisor variables and arrays are local. Hold synchronization is centralized in set_state(). Process spawning restores the original umask for normal and debugger children.
Lifecycle and request dispatch
Charts/podbench-hotfix-claim/files/podbench.sh
Child checks, startup health checks, request routing, debugger handling, and the main loop use separate local functions. Health probes use a kill-after timeout.
Runtime fixtures and lifecycle tests
tests/conftest.py, tests/test_lifecycle_failures.py, tests/test_lifecycle_runtime.py
Tests run the shipped script in isolated paths and cover failure recovery, cancellation, health timeouts, child replacement, debugger completion, safe-mode requests, stream relaying, and umask preservation.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant ControlRequest
  participant podbench_supervise
  participant ApplicationChild
  ControlRequest->>podbench_supervise: submit start, stop, restart, or launch request
  podbench_supervise->>ApplicationChild: spawn or terminate process
  ApplicationChild-->>podbench_supervise: health result, heartbeat, or exit status
  podbench_supervise-->>ControlRequest: write response and updated state
Loading

Merge Risk: ⚪ Minimal · up to 1b1f2

The lifecycle refactor does not show an actionable current-head failure. It is mergeable after normal validation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title, "Simplify the hotfix supervisor lifecycle," accurately and concisely describes the main refactoring changes to the supervisor lifecycle.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch simplify-supervisor

Comment @coderabbitai help to get the list of available commands.

@gilesknap
gilesknap merged commit 95bab00 into main Sep 15, 2026
12 checks passed
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