fix: preserve background control lifecycle status - #138
Conversation
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new "paused" state to the background workflow run states and updates the run store and manager to handle it alongside the existing "stopped" and "suspended" states. Corresponding unit tests have also been added. The feedback suggests adding "paused" to BACKGROUND_TERMINAL_STATES to prevent late operator stop requests from overwriting the paused status, and adding a regression test to verify this behavior.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| BACKGROUND_RUN_STATES = frozenset({"queued", "running", "succeeded", "failed", "stopped", "suspended"}) | ||
| BACKGROUND_RUN_STATES = frozenset({"queued", "running", "succeeded", "failed", "stopped", "paused", "suspended"}) | ||
| BACKGROUND_TERMINAL_STATES = frozenset({"succeeded", "failed", "stopped", "suspended"}) |
There was a problem hiding this comment.
The new paused state is a terminal state for the process-local worker thread (similar to suspended), meaning the worker thread has exited and the background snapshot is now authoritative terminal history for that execution.
If paused is not included in BACKGROUND_TERMINAL_STATES, a late operator stop request (via store.stop) will overwrite the paused status to stopped and erase the original pause error payload. To maintain consistency with how suspended is handled, paused should be added to BACKGROUND_TERMINAL_STATES.
| BACKGROUND_TERMINAL_STATES = frozenset({"succeeded", "failed", "stopped", "suspended"}) | |
| BACKGROUND_TERMINAL_STATES = frozenset({"succeeded", "failed", "stopped", "paused", "suspended"}) |
|
|
||
| assert finished.status == "paused" | ||
| assert finished.result is None | ||
| assert finished.error == paused_error |
There was a problem hiding this comment.
To ensure that a late operator stop on a paused run correctly preserves the paused status and its error payload (similar to how suspended runs are tested in test_background_stop_after_suspended_preserves_terminal_error_and_status), we should add a regression test for this scenario.
assert finished.error == paused_error
def test_background_stop_after_paused_preserves_terminal_error_and_status():
with tempfile.TemporaryDirectory() as tmp:
store = BackgroundRunStore(Path(tmp) / "background-runs")
store.begin("wfs_stop_after_paused", script=SCRIPT, args={"value": "hold"})
paused_error = {"type": "WorkflowPaused", "code": "run_paused", "message": "operator pause"}
store.finish("wfs_stop_after_paused", ScriptRunResult(ok=False, error=paused_error, paused=True))
stopped = store.stop("wfs_stop_after_paused", reason="late operator stop")
assert stopped.status == "paused"
assert stopped.result is None
assert stopped.error == paused_error
assert stopped.stopped_reason is None|
Verdict: Approve at exact head 9fd2f0c. No blockers found. Coverage:
Evidence:
Bot feedback + learning:
Verification run locally:
|
|
Formal GitHub approval was rejected because the authenticated account owns the PR, so recording the review gate as a PR comment instead. Verdict: Approve at exact head f074183. No blockers found. Coverage:
Evidence:
Verification run locally:
Bot feedback + learning:
|
Summary
ScriptRunResult.stoppedas backgroundstoppedinstead of collapsing it tofailed.pausedlifecycle support so current-run workflow_control pause denials match script-store status.Test plan
PYTHONPATH=.:src uv run --extra dev pytest -q tests/test_background.py tests/test_controls.py tests/test_run.py tests/test_capabilities.pyPYTHONPATH=.:src uv run --extra dev pytest -qPYTHONPATH=.:src uv run --extra dev python -m compileall -q __init__.py src/hermes_workflows testsuv build(passes with pre-existing setuptools license deprecation warnings)Fixes the post-merge PR #82 background lifecycle blocker from t_9894076e.