Repository navigation
serve: a session's end stops its bash jobs, in a daemon too - #263
Merged
Merged
Conversation
A reaped (or otherwise ended) daemon session never stopped its bash jobs. The cell's runner cloned the whole ExecCell, job table included, and every running job's task holds that runner: task -> runner -> cell -> table -> job -> task. The table never dropped, so the job ran on, unreachable and silent, until the daemon exited (the stdio test passed only because process exit runs kill_live_jobs). - ExecCell splits its dispatch half (CellRoute: target + strict) from the job table; the runner and filesystem backend clone only the route, so there is no cycle. - serve_session stops its jobs explicitly as it returns (stop_all on the blocking pool, reported in a bash_jobs_stopped frame), whatever ended it. Test: bash_jobs_serve_daemon.rs reaps a detached daemon session and checks its adopted `nohup sleep &` dies while the daemon stays up (fails on main after 15 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk
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.
Fixes serve audit defect #7 (resource leak, from #253).
Problem
A reaped daemon session never stopped its
bashjobs.ExecCell::runner()returnedCellRunner(self.clone()), and the cell owned the job table; every running job's task holds the runner. So task → runner → cell → table → job → task: the table never dropped while a job ran. The job outlived its session, unreachable and silent, holding its port and the tenant's exec target until the daemon exited. ARCHITECTURE.md's "the session's end kills its jobs" was only true in stdio mode, where process exit runskill_live_jobs.Fix
ExecCellkeeps its dispatch half in aCellRoute(target + strict).CellRunnerandCellFsclone only the route, so the cycle is gone.serve_sessionstops its jobs explicitly as it returns, whatever ended it (EOF, reap, supersede, shutdown). It runsstop_allon the blocking pool, because the kills block and the daemon's runtime is current-thread, and reports them in abash_jobs_stoppedframe.Tests
crates/agent/tests/bash_jobs_serve_daemon.rs::a_reaped_session_stops_its_jobs: a daemon with a 1 s idle reap. The test detaches after the model leavesnohup sleep 89 &running, then checks the process dies while the daemon stays up. It fails on main: the job is still alive after 15 s.cargo fmt,clippy --all-targets -D warnings(agent + agent-core) anddprint checkare clean. The agent + agent-core nextest suites passed 3901/3902. The one failure,tool_reactor_stall::the_responsiveness_probe_catches_a_tool_that_blocks_without_cpu, is load-sensitive; it passes on rerun and this change doesn't touch it.🤖 Generated with Claude Code
https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk