Repository navigation
feat(executor): Phase 2 diagnostics slicing + Phase 3 git snapshot/rollback - #139
Merged
Merged
Conversation
…llback Phase 2 (diagnostics): preserve the server-side traceback slice the executor auto-populates on ExecutionResult.diagnostics, and on the failure path replace the full bash output with that compact slice to cut tokens fed to the model. Phase 1 dropped diagnostics in mapResult; this threads it through ExecResult into BashTool's ShellError.stderr. Phase 3 (snapshot + rollback): pass cwd in buildRequest so the executor can build a git snapshot (non-repo returns null safely, snapshot_id kept for debug). auto_rollback is opt-in via a SEPARATE env gate FUSION_CODE_EXECUTOR_AUTO_ROLLBACK (default off) — auto-rollback reverts the working tree on exit!=0 + file damage, which would undo the model's legit edits in an edit-test-fail coding loop. When rolled back, prefix a <note> so the model knows its edits were reverted. enable_rollback_snapshot stays on unconditionally; max_consecutive_failures is a dead field (Rust never reads it — caller owns the failure-count loop). default-off byte-identical: FUSION_CODE_EXECUTOR_ENABLED unset -> isExecutorRouteable false -> executorDriver never runs; in-process path leaves diagnostics/autoRolledBack/snapshotId undefined -> formatDiagnosticsForModel returns the full output unchanged. New pure helper src/tools/BashTool/bashDiagnostics.ts (extracted for unit testing, no BashTool module-graph dependency) + 8 tests. 8 new executorDriver tests covering mapResult passthrough (diagnostics/ snapshot_id/auto_rolled_back) and buildRequest (cwd, auto_rollback policy on/off, enable_rollback_snapshot regression). Gates: typecheck 0 errors, lint clean, 460 tests pass, build:dev pass. 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]>
dahai80
added a commit
that referenced
this pull request
Aug 26, 2026
… PR #139 (#141) PRD line 160 intent ("snapshot before executor call, rollback on failure") is already satisfied by PR #139's in-band per-command auto-rollback (buildRequest sends auto_rollback_policy; executor snapshots at call-start, rolls back on exit!=0 + file-damage diff>0). The file-damage guard is safer than PRD's blind retry-3x (only reverts when files are damaged, not on legit edit-test-fail). The client-orchestrated whole-turn variant (explicit snapshot_create/rollback RPC + turn lifecycle wiring) is architecturally inferior: loses the model's good edits, needs a new failure counter in query.ts, and the REPL query loop discards the terminal return value (no capture path). Recording this as an explicit decision, not backlog. Co-authored-by: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 27, 2026
Caller-owned turn-level git snapshot at submitMessage entry + /rollback manual command. Complementary to in-band auto-rollback (PR #139): in-band = single-call self-contained + opt-in; turn-boundary = caller owns the snapshot, model/user decides to /rollback — safer for the edit-test-fail coding loop. - types.ts: SnapshotResult/RollbackResult wire types - ExecutorClient.ts: snapshotCreate/rollback client methods (UDS RPC) - ExecutorInstance.ts: methods with ensureStarted health gate - executorDriver.ts: ExecutorClientLike test seam extended - turnSnapshot.ts (new): turn-boundary manager — takeTurnSnapshot (fail-soft, non-repo no-op), recordTurnFailure (counter, threshold 3), lastHint (staged hint drain), rollbackToTurn, ring of 5 - QueryEngine.ts: takeTurnSnapshot at submitMessage entry; case 'user' is_error scan + hint injection to mutableMessages - commands/rollback/ (new): /rollback [turnId] local-jsx command - tests: 21 unit tests (fake client: take/rollback, failure counter, non-repo no-op, ring bounds, default-off byte-identical) Gate: default off, FUSION_CODE_EXECUTOR_TURN_SNAPSHOT=1 (strict truthy). Byte-identical when env unset — takeTurnSnapshot no-op returns null, no client calls, no ring entry, no hint. Double-gate with FUSION_CODE_EXECUTOR_ENABLED (executor must be on too). 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
fusion-code-side wiring for fusion-executor Phase 2 + Phase 3 (executor v0.2.0, upstream blockers cleared). Surgical, default-off, fail-open.
Phase 2 (diagnostics): preserve the server-side traceback slice the executor auto-populates on
ExecutionResult.diagnostics(slicer prefers stderr, tail 30 lines, regex TS/Python/Node/Bun/Rust/Go/Swift). Phase 1 dropped it inmapResult; this threads it throughExecResultinto BashTool's failure path. On failure, replace the full bash output with the compact slice to cut tokens fed to the model (PRD Phase 2 goal).Phase 3 (snapshot + rollback): pass
cwdinbuildRequestso the executor can build a git snapshot (non-repo returns null safely;snapshot_idkept for debug).auto_rollbackis opt-in via a separate env gateFUSION_CODE_EXECUTOR_AUTO_ROLLBACK(default off) — auto-rollback reverts the working tree onexit!=0+ file damage, which would undo the model's legit edits in an edit-test-fail coding loop. When rolled back, prefix a<note>so the model knows its edits were reverted.enable_rollback_snapshotstays on unconditionally;max_consecutive_failuresis a dead field (Rust never reads it — caller owns the failure-count loop).Changes
src/utils/ShellCommand.ts—ExecResult+3 optional fields (diagnostics,autoRolledBack,snapshotId). InlineDiagnosticsstructural type (noexecutor/typesimport — keeps utils < services dependency direction, no circular dep).src/services/executor/executorDriver.ts—mapResultpreserves diagnostics/snapshot/rollback;buildRequestpassescwd+ opt-inauto_rollback_policy; twologForDebugginglines for diagnostics + rollback state.src/tools/BashTool/BashTool.tsx— failure path usesformatDiagnosticsForModelto slice-replace full output + prefix rollback<note>.src/tools/BashTool/bashDiagnostics.ts(new) — pure helper, extracted for unit testing.src/__tests__/tools/BashTool/bashDiagnostics.test.ts(new) — 8 tests.src/__tests__/services/executor/executorDriver.test.ts— 8 new tests (mapResult passthrough + buildRequest cwd/policy).Why default-off / byte-identical
FUSION_CODE_EXECUTOR_ENABLEDunset →isExecutorRouteablefalse → executorDriver never runs; in-process path leavesdiagnostics/autoRolledBack/snapshotIdundefined →formatDiagnosticsForModelreturns the full output unchanged. No behavior change unless executor + rollback envs are explicitly set.E2E verified (real executor binary, v0.2.0)
diagnosticsauto-filled (error_type=ValueError,file_path,line_number,code_snippet,raw_trace); model receives slice not full traceback.auto_rollback_policyundefined, no rollback,snapshot_idpopulated (debug).FUSION_CODE_EXECUTOR_AUTO_ROLLBACK=1): git-repo destructive failure →auto_rolled_back=true, working tree reverted, model sees<note>Working tree auto-reverted...</note>.snapshot_id=null, auto-rollback no-op (safe).Gates
bun run typecheck— 0 errorsbun test src/__tests__/— 460 passbunx biome check(executor files) — cleanbun run build:dev— passCloses #139.