Repository navigation
feat(executor): integrate fusion-executor Layer B (Phase 1, default-off) - #135
Merged
Merged
Conversation
Route foreground bash commands to fusion-executor (Layer B hands, Rust+PyO3, self-built built-in tools + sandbox) via UDS NDJSON-RPC. fusion-code src/services/llm/ = Layer A brain (SDK removed, self-built). This wires Layer A to Layer B. Phase 1 (PRD architecture/fusion-executor-prd.md): - src/services/executor/types.ts — TS types mirroring executor Rust models (snake_case serde verbatim): ExecutionRequest/ExecutionResult/Diagnostics/ ExecutorStreamChunk. Exit-code constants (0/-124/-1). - ExecutorClient.ts — UDS NDJSON-RPC client (NOT LSP Content-Length framing). Spawns the executor serve+sock persistent UDS server, spawn-gate prevents ENOENT, net.Socket + line buffer. Methods health/execute/executeStream (multi-frame share one id: chunk then done)/stop. Crash handling isStopping+onCrash. - ExecutorInstance.ts — state machine stopped to starting to running to stopping to error, MAX_CRASH_RECOVERY=3, lazy-require client. - manager.ts — module-scope singleton + generation counter + race-safe initPromise (mirrors lsp/manager.ts). Gate isEnvTruthy(FUSION_CODE_EXECUTOR_ENABLED), unset means init no-op (byte-identical). registerCleanup on init. - executorDriver.ts — BashTool delegation seam. callBashViaExecutor async generator: builds ExecutionRequest, executeStream chunk to progress protocol (callback to queue bridge, bursts coalesce, fullOutput preserved), terminal ExecutionResult to ExecResult (code=exit_code, interrupted=timed_out). isExecutorRouteable excludes run_in_background (issue #1) + _simulatedSedEdit. No client returns null (fail-open). Test injection seam. - BashTool.tsx — call() top lazy-require gate (isEnvTruthy guard keeps executor module graph out of disabled runtime path). Routeable calls callBashViaExecutor, else runShellCommand. Terminal null calls logExecutorFallback + in-process fallback. - main.tsx — initializeExecutorManager() after LSP init (same trust gate). Wire = NDJSON (executor fe-ipc writes serde_json::to_string(resp)+newline per frame), not vscode-jsonrpc Content-Length. Exit codes: 0=ok, -124=timeout, -1=blocked. Gate + fail-open: FUSION_CODE_EXECUTOR_ENABLED unset means BashTool uses runShellCommand, zero diff. Executor binary missing/init failed/crash means getExecutorClient() undefined, callBashViaExecutor returns null, in-process fallback, log warning. Background commands stay on fusion-code spawnShellTask (executor issue #1 no background API). Tests: 23 new (manager gate/disabled/fail-open/singleton; executorDriver routing/ mapping/streaming/fail-open). Injection seam avoids mock.module cross-file pollution. Gates: typecheck 0 errors, 431 tests pass, executor files lint clean (added to CI lint list), build:dev passes. Runtime gate confirmed in bundle (env unset to runShellCommand). Phase 2 (diagnostics slicing) + Phase 3 (git snapshot + atomic rollback) follow-up; Phase 3 blocked on executor issues #1/#2 upstream. Co-Authored-By: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 26, 2026
Update Executor seam section: Phase 1 now PR #135, add Phase 2/3 landed section (PR #139) covering diagnostics passthrough + slice-replace, cwd passing + opt-in auto_rollback_policy, bashDiagnostics helper, and the default-off byte-identical contract. Co-Authored-By: Claude Fable 5 <[email protected]>
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
Route foreground bash commands to fusion-executor (Layer B "hands" — Rust+PyO3, self-built built-in tools + sandbox) via UDS NDJSON-RPC. = Layer A "brain" (SDK removed, self-built). This PR wires Layer A → Layer B.
Audit:
audit/fusion-code-vs-executor-0825.md. PRD:architecture/fusion-executor-prd.md(3 phases; this is Phase 1 only, surgical, default-off, byte-identical when disabled).What lands
5 new files in
src/services/executor/(mirrors the LSP stack: client → instance → manager → driver):types.tsExecutorClient.tsfusion-executor --serve --sock, spawn-gate, line buffer, multi-frameexecute_streamExecutorInstance.tsmanager.tslsp/manager.ts),registerCleanupexecutorDriver.tscallBashViaExecutorasync generator (chunk→progress, result mapping),isExecutorRouteablegate, fail-open nullPlus:
BashTool.tsx—call()top lazy-require gate behindisEnvTruthy; routeable → executor, elserunShellCommand; terminal null → in-process fallbackmain.tsx—initializeExecutorManager()after LSP init (same trust gate).github/workflows/ci.yml— addsrc/services/executor/to new-files lint listCLAUDE.md+docs/model-providers.md— Executor seam sectionWire & protocol
serde_json::to_string(resp) + "\n"per frame), not vscode-jsonrpc Content-Lengthexecute_stream: multiple result frames share one request id —chunk...done0=ok,-124=timeout,-1=blocked/internalGate + fail-open
isEnvTruthy(process.env.FUSION_CODE_EXECUTOR_ENABLED)(1/true/yes/on). Default off → BashTool usesrunShellCommand, zero diff (byte-identical). Lazy-require keeps the executor module graph out of the disabled runtime path.getExecutorClient()undefined →callBashViaExecutorreturns null → BashTool falls back to in-processrunShellCommand, logs warning. User is never blocked.spawnShellTask(executor issue feat: add CreateArtifact/UpdateArtifact tools + artifact injection #1 — no background API).Tests (23 new)
manager.test.ts— env gate (truthy/falsy/unset), disabled byte-identical (init no-op), enabled-but-binary-missing fail-open, singleton + generation counterexecutorDriver.test.ts—isExecutorRouteable(5 cases), result mapping (normal/timeout/blocked), streaming chunk→progress (fullOutput accumulation), fail-open null, no-chunks 0 frames. Injection seam (_setExecutorClientForTesting) avoidsmock.modulecross-file pollution.Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 431 pass (23 new)bun run build:dev— passes; runtime gate confirmed in minified bundle (env unset → runShellCommand)Upstream
12 issues (#1–#12) filed on
dahai80/fusion-executorfor Layer B capability gaps (per issue→PR→code flow). Phase 3 (git snapshot + atomic rollback) blocked on executor issues #1/#2.Follow-up
executor.diagnosticsalready exposed;enable_rollback_snapshot=truelays groundwork)--serve)Co-Authored-By: Claude Fable 5 [email protected]