Skip to content

Unify command execution under shell - #520

Open
fazxes wants to merge 26 commits into
mainfrom
fazxes/shell-managed-execution
Open

Unify command execution under shell#520
fazxes wants to merge 26 commits into
mainfrom
fazxes/shell-managed-execution

Conversation

@fazxes

@fazxes fazxes commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the procedural terminal schema with shell.run, shell.wait, shell.write, shell.stop, and shell.list.
  • Complete short commands inline and retain long, zero-yield, and TTY commands under one managed session ID.
  • Wait up to 30 seconds for initial completion and use bounded five-second follow-up observations by default.
  • Generate fx-owned execution handles so reused provider call IDs cannot collide with later commands.
  • Use compact shell-prefixed durable TTY IDs while retaining existing authority and persistence checks.
  • Treat an explicitly requested stop as a successful control action instead of presenting the process signal as a command failure.
  • Let a running shell.run explicitly hand control back to the user for cross-turn work, without forcing a same-turn wait or stop.
  • Preserve the original user instruction during that handoff response and restore normal tool choice on the next user turn.
  • Accept terminal-host handshakes before durable catalog recovery finishes, and preserve shared state if startup fails with clients still attached.
  • Give the dedicated terminal host a bounded 1024-descriptor soft budget, capped by the kernel hard limit, so macOS GUI launches can recover the 64-session catalog.
  • Enforce TTY deadlines from command start and report known timeouts without indeterminate status.
  • Reindex durable model-managed and direct-human TTY sessions when an fx session resumes, while retaining durable authority checks.
  • Preserve incremental and final output with bounded inline results and full replay handles.
  • Keep overlapping command output isolated and show running work through Ctrl-X and across /clear.
  • Stop the agent loop after the same Shell action fails in consecutive batches.
  • Support up to 64 live managed executions with process-tree cleanup on exit, stop, and timeout.
  • Migrate legacy background ownership to inert history after token-validated cleanup.
  • Remove the monitor, detached-background, and direct terminal lifecycle implementations.
  • Keep Shell behavior consistent across the TUI, CLI, ACP, no-save, and browser surfaces.

Verification

  • Full Zig test suite, formatting checks, and ReleaseSafe build.
  • Deterministic Shell, terminal-host, permission, ACP, rendering, cancellation, resume, and stress E2Es.
  • ReleaseSafe cross-builds for Linux and macOS on x86_64 and arm64 through CI.
  • Real Ghostty run under its inherited 256-descriptor limit, covering short, retained background, wait, interactive TTY, timeout, list, and cleanup flows.
  • Three fresh Luna TUI runs of the canonical two-turn retained-process scenario, all passing both phases with exact output markers and cleanup.
  • Bare direct Codex control using the same Luna model, xhigh effort, fast tier, and canonical scenario.

@fazxes fazxes added the type: improvement Improves existing user-facing behavior label Aug 29, 2026
@vercel-security-reviewer

Copy link
Copy Markdown

@fazxes
fazxes marked this pull request as ready for review August 29, 2026 10:12
@fazxes
fazxes force-pushed the fazxes/shell-managed-execution branch 2 times, most recently from b5eac33 to b98ac38 Compare August 31, 2026 17:58
@fazxes
fazxes force-pushed the fazxes/shell-managed-execution branch 2 times, most recently from 41d3eef to c0065fa Compare August 31, 2026 22:55
Replace the terminal and background command surfaces with one managed shell lifecycle. Preserve process ownership, PTY input, output replay, legacy session cleanup, and Ctrl-X visibility through the existing runtime boundaries.
Keep native captured-command admission unavailable when threads are absent and use a bounded tombstone counter supported by WASM.
Remove scenarios for the deleted background command and keep one direct assertion that the old command is no longer registered.
Exercise the browser workspace through shell run and keep its strict completion-only boundary assertions current.
Keep help-menu and persistence fixtures aligned after removing the background command.
Document the completion-only shell run contract exposed by the embedded workspace.
Assert that unrecoverable legacy terminal calls resume as inert summaries without structured replay.
Assert structured command results and use the registered shell action in saved permission fixtures.
Propagate cancelled initial runs through the existing agent interruption path and align streamed TUI fixtures with shell results.
Use shell run in external path fixtures and assert structured command results in terminal-ownership coverage.
Stop benchmarking the deleted background command while preserving the existing startup budget.
Carry cancelled managed-command snapshots through the existing result boundary and update current shell fixtures across the full E2E matrix.
Stream managed output through the existing lifecycle edge, prioritize framed replay in Ctrl-O, and refresh the remaining current-shell E2E contracts.
Preserve final TTY output, isolate overlapping command lifecycles, and keep managed results bounded. Align observation defaults, capacity, and descendant cleanup with the tested shell workflow.
Accept host handshakes before durable recovery, reindex persisted TTY sessions, and enforce TTY deadlines from command start. Fail closed on execution identity collisions, preserve indeterminate loss, and stop repeated shell failures.
Update the byte-exact built-in schema digest after rebasing onto the consolidated capability and Exa tool surface.
Update command output assertions for nested shell detail rows and durable replay files.
Include the execution route and effective shell in permission fingerprints, and reject direct-only authority before PTY startup.
Keep the shell registry changes while retaining main's removed memory surface and regression coverage.
Record the rebased shell schema after retaining main's memory-tool removal.
Treat requested terminal stops as successful control actions.
Let a running shell command return control without forcing a same-turn wait or stop.
Keep provider tool summaries exhaustive over the current history variants.
@fazxes
fazxes force-pushed the fazxes/shell-managed-execution branch from 1e86cac to db902ab Compare September 1, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: improvement Improves existing user-facing behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant