Repository navigation
Run a process in the live view - #446
Merged
Merged
Conversation
ViewSession.Spawn runs a LocalExec binary as another process in the Session's live view while the Harness runs. The view's launcher starts it from its restricted thread on a control-socket request, with stdio passed by SCM_RIGHTS, and reports its exit over the same socket. Launch and Spawn return ErrNotLocalExec; Spawn also returns ErrNoLiveView and ErrViewEnded.
The restricted thread now only forks. Reaping, the drain and the exit run on another goroutine, and signals and spawns no longer share a lock with a fork. Requests carry IDs, so a pending spawn never blocks a signal and Spawn honours its context. Spawned processes are known by ID until reaped, the group kill on exit is gone, the command travels over a pipe, and ErrViewEnded merges into ErrNoLiveView.
A view admits one spawn at a time, and a spawn waiting for its turn holds no descriptors; Spawn makes the stdio pipes. The restricted thread only forks. While it forks, the SIGCHLD-driven reaper reaps registered children only, so a child that exits before its registration keeps its pid. The launcher holds off garbage collection during a fork, which a world stall would otherwise turn into a frozen launcher. Control sends honour their context and a socket shutdown, replies and exits go through one writer, and only an ended view maps to ErrNoLiveView.
The launcher's forking thread enters the command's directory itself, as the process's user and with signals blocked, before it forks, so the child inherits it and does nothing before its exec that waits on the world. A slow directory then blocks that thread in an ordinary syscall that holds no P, and garbage collection no longer needs to be paused around the fork.
…xt win a spawn A failed chdir or exec no longer carries the caller's directory or path back over the control socket, so no reply grows with what a caller passed; the daemon fills the path in from its own command. A control write that fails ends the launcher, as a failed read does, so no request waits for a reply that will not come. Spawn checks its context once the reply is in and sends a spawn whose context has ended through the late-process cleanup.
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.
Runtime–Harness protocol change:
ViewSession.Spawnruns aLocalExecbinary as another process in a Session's live view while its Harness runs. The first caller is MiniMax Code's Subagent history reader, which must run with the Harness's isolation: never on the agent host outside the view, and never in a second view. That caller is a separate PR, stacked on this one.Protocol
apps/daemon/internal/agent/harness.goaddsViewSession.Spawnand two typed outcomes,ErrNotLocalExecandErrNoLiveView.contracts/agents-api/harness-onboarding.md§ Spawn, and its zh translation with a currentsource_hash.Mechanism (
sessionview)no_new_privsand the same seccomp filter;The daemon never calls
setns. The command travels on a pipe and the stdio descriptors travel withSCM_RIGHTS.Testing
Privileged sessionview and agenthost suites, with the 7 spawn tests ×50 on all CPUs and with
--cpuset-cpus=0.The MiniMax Code qualification row 9 (Subagents in a view) passes with the stacked caller PR.
Blind review took three rounds. Round 3's two findings are fixed in 6af05a3: the bounded reply, and a context cancelled before
Spawn.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.