Skip to content

refactor(vt): split piped and inherited spawn handles and drop dead fspy branch - #1021

Merged
wan9chi merged 3 commits into
refactor/vt-select-typed-modesfrom
refactor/vt-spawn-mode-and-pipes
Nov 26, 2026
Merged

wan9chi merged 3 commits into
refactor/vt-select-typed-modesfrom
refactor/vt-spawn-mode-and-pipes

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Motivation

The process-spawning boundary in crates/vt/src/session/execute/ represented coupled stdio and tracking invariants as independent booleans and Options:

  • ChildHandle stored parallel stdout: Option<ChildStdout> and stderr: Option<ChildStderr>, allowing half-piped states and forcing two .take().expect("SpawnStdio::Piped yields a ...") unwraps in run_child to pair the handle back with Option<PipeSinks>.
  • ExecutionMode::spawn_config() returned (SpawnStdio, bool), making the invalid (SpawnStdio::Inherited, true) (inherited stdio + fspy) combination representable and leaving a dead SpawnStdio::Inherited branch inside spawn_fspy.
  • RunHandles stored independent sinks: Option<PipeSinks> and ipc: Option<IpcHandles>, even though cached execution always has both and uncached inherited execution has neither.

Changes

  • Replaced SpawnStdio, fspy: bool, ChildHandle, and spawn() in crates/vt/src/session/execute/spawn.rs with PipedMode (Plain | Tracked), coupled ChildPipes, ChildWait, PipedChild, InheritedChild, spawn_piped, and spawn_inherited.
  • Removed the dead SpawnStdio::Inherited arm from spawn_fspy so inherited stdio and fspy tracking cannot be combined at compile time.
  • Consolidated spawn, pipe drain, and IPC polling in ExecutionMode::spawn_and_run (with run_piped_child, wait_child, and Tracking::injected_envs), removing spawn_config, RunHandles, IpcHandles, and both .take().expect(...) unwraps in crates/vt/src/session/execute/mod.rs.

Stack created with GitHub Stacks CLI • Give Feedback 💬


Note

Medium Risk
Touches the core cached-task path where child I/O and IPC are polled together; behavior is preserved but concurrency and cache-update wiring moved.

Overview
Refactors the vt task spawn pipeline so stdio mode, fspy tracking, pipes, and IPC are expressed with types instead of separate flags and Options.

Spawn layer (spawn.rs): Replaces the single spawn() / ChildHandle / SpawnStdio API with spawn_piped and spawn_inherited, returning PipedChild (paired ChildPipes + wait) or InheritedChild. Piped fspy uses PipedMode::Plain | Tracked only on the piped path, removing the unreachable inherited+fspy branch in spawn_fspy.

Execute layer (mod.rs): Moves spawn, pipe drain, and (when cached) concurrent IPC polling into ExecutionMode::spawn_and_run, yielding mode-typed RunOutcome so uncached runs cannot carry IPC reports and cached runs must. Drops RunHandles, IpcHandles, and spawn_config; splits run_child into run_piped_child and wait_child. Tracking::injected_envs centralizes env injection for cached children.

Reviewed by Cursor Bugbot for commit d0b97c8. Bugbot is set up for automated code reviews on this repo. Configure here.

@wan9chi
wan9chi added this pull request to stack #1022 November 26, 2026 01:47
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  +0.14%  [ -4.97% ..  +5.20%]  overhead   +60.13%
dynamic/access             change  -0.41%  [ -6.86% ..  +4.72%]  overhead   +19.19%
dynamic/access-relative    change  -0.58%  [-14.58% .. +20.69%]  overhead   +65.72%
dynamic/access-contended   change  +2.06%  [ -8.85% .. +16.26%]  overhead   +12.80%
static/launch              change  -0.24%  [ -3.03% ..  +3.32%]  overhead  +203.77%
static/access              change  +0.66%  [ -3.69% .. +12.28%]  overhead +1443.14%
static/access-relative     change  +0.21%  [ -3.85% ..  +6.67%]  overhead +1998.37%
static/access-contended    change  +0.74%  [ -7.89% .. +11.56%]  overhead +1336.24%

macos

dynamic/launch             change  -0.36%  [ -3.68% ..  +2.99%]  overhead  +222.12%
dynamic/access             change  +0.00%  [ -1.62% ..  +3.02%]  overhead    +4.83%
dynamic/access-relative    change  -0.79%  [ -4.09% ..  +3.20%]  overhead  +245.75%
dynamic/access-contended   change  +0.19%  [ -1.64% ..  +1.57%]  overhead    +3.18%

windows

dynamic/launch             change  -0.45%  [ -2.44% ..  +1.66%]  overhead   +26.34%
dynamic/access             change  +0.18%  [ -1.16% ..  +0.97%]  overhead    +1.51%
dynamic/access-relative    change  +0.36%  [ -2.21% ..  +4.15%]  overhead    +1.85%
dynamic/access-contended   change  +0.53%  [ -1.93% ..  +8.67%]  overhead    +4.29%

wan9chi and others added 2 commits November 26, 2026 10:20
…spy branch

- Replace `SpawnStdio`, `fspy: bool`, and `ChildHandle`'s parallel
  `Option<ChildStdout>` / `Option<ChildStderr>` with `PipedMode` (`Plain` |
  `Tracked`), coupled `ChildPipes`, `PipedChild`, `InheritedChild`,
  `spawn_piped`, and `spawn_inherited`.
- Remove the dead `SpawnStdio::Inherited` arm from `spawn_fspy` so inherited
  stdio and fspy tracking cannot be combined at the type level.
- Consolidate spawn, pipe drain, and IPC driving in
  `ExecutionMode::spawn_and_run` with `run_piped_child` and `wait_child`,
  removing `ExecutionMode::spawn_config`, `RunHandles`, `IpcHandles`, and both
  `.take().expect(...)` unwraps in `execute/mod.rs`.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
…unwrapping

- Have `ExecutionMode::spawn_and_run` consume `self` and return a
  mode-typed `RunOutcome` (`Cached { state, outcome, ipc_result }` |
  `Uncached { outcome }`), eliminating the `(ChildOutcome, Option<Result<Reports, _>>)`
  cross-product and the second `match mode` in `run()`.
- Drop `stop_accepting: Option<&StopAccepting>` from `run_piped_child` and
  signal `stop_accepting` directly alongside `tokio::join!` with the IPC
  driver in the `Cached` arm.
- Extract `take_pipes` in `spawn.rs` so the `Stdio::piped()` unwrap
  invariant is stated once, and tighten inline comments in `execute/mod.rs`.

Co-authored-by: gemini-4-neon <noreply@google.com>
@wan9chi
wan9chi force-pushed the refactor/vt-spawn-mode-and-pipes branch from b65015b to 62db3c6 Compare November 26, 2026 02:22
Co-authored-by: gemini-4-neon <noreply@google.com>
@wan9chi
wan9chi merged commit 2bd878a into main Nov 26, 2026
34 of 36 checks passed
@wan9chi
wan9chi deleted the refactor/vt-spawn-mode-and-pipes branch November 26, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant