Repository navigation
repl_env: add managed child queries with bounded cleanup - #1527
Open
jucamohedano wants to merge 6 commits into
Open
jucamohedano wants to merge 6 commits into
jucamohedano wants to merge 6 commits into
Conversation
Add opt-in process supervision and rlm_query(blocking=False), with bounded shutdown, nested worker ownership, callback isolation, and regression coverage. Refs openenv#1478
Keep all 58 regression cases while using unit checks for routing, budgets, observer errors, and lifecycle locking. Preserve real-process cleanup and nesting coverage and the unchanged pre-submit timeout.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e2b89d8. Configure here.
Record the computed answer before stopping managed children. Cover FINAL() and answer-dictionary finalization while keeping cleanup failures blocking execution, child creation, and reset.
This branch has not been deployed
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
Adds opt-in background child queries to
repl_envthroughrlm_query(..., blocking=False). Parents can continue working while children run, then inspect or collect their results.Managed cleanup confirms worker process exit—or reports failure—instead of treating a cancellation request as proof that execution stopped.
Refs #1478.
Behavior
rlm_query(prompt)continues to block and return an answer by default.rlm_query(prompt, blocking=False)returns an episode-scoped handle and requires managed mode.rlm_status,rlm_result, andrlm_waitsupport inspection and result collection. A wait timeout does not cancel the child.Parent finalization, reset, and close stop admission and request cooperative shutdown. Remaining workers receive SIGTERM and then SIGKILL after configurable grace periods. Cleanup waits for confirmed process exit; failure blocks environment reuse.
Lifecycle transitions are serialized. Observer callbacks run separately so blocked or failing callbacks cannot prevent worker cleanup.
Scope and possible follow-ups
repl_env, with no new runtime dependencies or environment transport changes.Type of Change
Alignment Checklist
.claude/docs/PRINCIPLES.mdand this PR aligns with our principles.claude/docs/INVARIANTS.mdand no invariants are violated/pre-submit-pr(orbash .claude/hooks/lint.shand tests) and addressed all issuesThe prescribed checks were run. The final checkbox remains unchecked because the repository-wide lint hook reports existing upstream findings, detailed below.
RFC Status
repl_env#1478Test Plan
The suite combines unit tests for API routing and bookkeeping with real-process tests for shutdown, nesting, and failure recovery. Model responses are scripted; no GPU or model API credentials are required.
Coverage includes:
FINAL(...)and answer-dictionary finalization, with execution, child creation, and reset still blocked.With the CI test dependencies installed:
Validation results
These local results cover the current fix and regression tests. GitHub CI will also validate the published head.
Existing upstream lint findings
The repository-wide lint hook still reports 44 formatting files and two import-sort findings. All remaining findings also occur on upstream main; none concern files changed by this PR.
Claude Code Review
A separate Codex-assisted manual review covered the implementation, repository principles, and invariants. No Claude Code review is claimed.
Note
Medium Risk
Opt-in, but the change adds POSIX multiprocess supervision, signal-based teardown, and new REPL APIs that affect recursive execution and episode lifecycle; mistakes could leak workers or block environment reuse.
Overview
Adds opt-in managed child queries to
repl_envso parents can keep executing REPL code while recursive subtasks run in supervised worker processes. Blockingrlm_query(prompt)behavior is unchanged;rlm_query(..., blocking=False)returns an episode handle and is wired throughManagedChildConfig,ManagedChildren, andManagedChildBackend, withrlm_status/rlm_result/rlm_waitinjected into the REPL namespace.LocalRLMRunnerandcreate_server_recursive_controllercan enable managed mode (mutually exclusive with a custombackend_factory).LocalREPLEnv/REPLEnvironmentaccept an optionalrecursive_controllerso server and in-process paths share the same recursion wiring. Lifecycle rules stop or reap workers on finalize, reset, and close, with cooperative shutdown escalating to SIGTERM/SIGKILL; failed cleanup surfacesChildCleanupErrorand blocks reuse.Docs for the REPL environment are tightened and expanded for managed usage; system prompts note the keyword-only
blockingflag. A large Linux-focused regression suite covers limits, nesting, cleanup, and callbacks.Reviewed by Cursor Bugbot for commit e2b89d8. Bugbot is set up for automated code reviews on this repo. Configure here.