Add generic background service execution for persistent Bash commands#301
Open
mmprotest wants to merge 1 commit into
Open
Add generic background service execution for persistent Bash commands#301mmprotest wants to merge 1 commit into
mmprotest wants to merge 1 commit into
Conversation
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.
Motivation
Description
villani_code/services.pyimplementing aServiceManagerandServiceRecordwith lifecycle APIs:start_service,stop_service,get_service_status, andlist_services, pluscleanup_services_started_afterfor mission-time cleanup.is_likely_service_command, patterns and hint list), and bounded readiness probing is implemented (probe_service_readiness) using TCP connect and optional HTTP GET with per-attempt diagnostics.Bashcommands through service mode insidevillani_code/tools.pysoBashcalls that look like servers are launched detached (non-blocking), have stdout/stderr captured to.villani_code/services/*.log, and immediately return a structured service result (mode: "service",servicemetadata). Short-lived commands continue to use the existing blocking shell path (mode: "command").ServiceManageronRunner(invillani_code/state.py), passing it into tool execution (state_tooling.execute_tool_with_lifecycle) and performing best-effort cleanup of services started during a mission completion/error paths, and extended Bash result decoding to includemodeandservicefields.service_launch_requested,service_process_spawned,service_readiness_probe_attempt,service_readiness_succeeded/service_readiness_failed,service_stopped). Platform-specific process-group handling is isolated in the spawn/stop paths (start_new_session+killpgon POSIX, process-group creation/terminate on Windows).Testing
tests/test_services.pywhich includes classification unit tests, readiness probe unit test, an integration test that startspython -m http.server, probes it, and stops it, and regression tests verifying persistent commands return immediately and short-lived commands preserve the original execution path; these tests passed locally underpytest.pytest -q tests/test_services.py tests/test_tools_patch_debug_events.py tests/test_trace_summary.py::test_bash_tool_finalization_from_tool_resultcompleted successfully (all passed), andpytest -q tests/test_trace_runtime_path.py tests/test_trace_summary.pyalso completed successfully (all passed).Codex Task