Repository navigation
refactor(sandbox): extract harness-runner subprocess from daemon dispatch - #4428
Closed
pedrofrxncx wants to merge 1 commit into
Closed
pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
Collaborator
Author
|
Closing as stale: this PR sat past the bot's 48h merge window, main has moved on, and its CI results no longer reflect the current base. This is a housekeeping close, not a rejection of the change — if the underlying problem still exists, the bot will find it again and open a fresh, rebased PR. [studio-bot:stale-close] |
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.
Summary
docs-design/sandbox-daemon-go-rewrite.md§3, §6): extracts claude-code/codex harness execution out of the daemon process into a supervisedharness-runnersubprocess, while the daemon stays TypeScript. Isolates the riskiest seam (agent-loop execution) before the language changes.entry.tsis now a tiny mode router —HARNESS_RUNNER_MODE=1runs the harness-runner, default runs the daemon (daemon-entry.ts, git-moved). Keeps one build artifact, since the daemon bundle is consumed as a single unit in three places (embedded in the mesh server, Docker image, desktop bundle).127.0.0.1:0, announces readiness on stdout, and servesPOST /run(per-spawn bearer token) streaming oneDispatchSSEEventper line, terminated by{"type":"done"}.routes/dispatch.tsis byte-for-byte untouched — auth, tombstones/410, SSRF allowlist, run registry, SSE-200-immediately, and closed-controller guards all stay in the daemon. All client-facing SSE framing is still produced daemon-side.harness_crashed+done; the next dispatch respawns — no re-dispatch storm). Killed on daemon shutdown (SIGTERM) and process exit (SIGKILL); a stdin-pipe watchdog in the runner covers daemon SIGKILL orphaning.Test plan
daemon.dispatch.e2e.test.ts(existing, unchanged) — 8 passdaemon.e2e.test.ts— 103 passdaemon.git.e2e.test.ts— 15 passdaemon.proxy.e2e.test.ts— 7 passdaemon.harness-runner.e2e.test.ts(fixture runner injected via newHARNESS_RUNNER_CMDenv) — 6 pass: verbatim chunk relay + done framing, error propagation, mid-stream runner death →harness_crashed+done, recovery on next dispatch, SIGKILL-orphan reapingdone; SIGTERM to the daemon killed the runner within 2sbun run checkandbun run fmtclean, lint 0 errorsmain; all suites re-verified green post-rebaseNote
The daemon bundle still contains harness code (single artifact by design for this step) — splitting it into a separate artifact is a natural byproduct once the Go daemon ships and this runner becomes the only TS left in the image.
Summary by cubic
Extracted harness execution from the daemon into a supervised
harness-runnersubprocess to isolate the agent loop while keeping the/dispatchAPI and SSE behavior unchanged.Refactors
harness-runner: a loopback HTTP server that streams NDJSONDispatchSSEEventlines fromPOST /runand ends with{"type":"done"}(per-spawn bearer token).entry.tsroutes modes;HARNESS_RUNNER_MODE=1runs the runner, otherwise the daemon viadaemon-entry.ts.routes/dispatch.tsstays the same; auth, allowlists, run registry, and SSE framing remain daemon-side.Migration
HARNESS_RUNNER_MODE(internal),HARNESS_RUNNER_CMD(tests/override).Written for commit b8de4a6. Summary will update on new commits.