Skip to content

Auto-run approved plans with Ferment V2 - #1142

Draft
tautvydasLiekis wants to merge 1 commit into
masterfrom
feat/Auto-trigger-goal-mode-after-plan-
Draft

Auto-run approved plans with Ferment V2#1142
tautvydasLiekis wants to merge 1 commit into
masterfrom
feat/Auto-trigger-goal-mode-after-plan-

Conversation

@tautvydasLiekis

Copy link
Copy Markdown
Contributor

What was wrong

Approving a Plan-mode plan with Execute only sent the legacy execution trigger. With Ferment V2 enabled, the approved plan did not enter the persistent execution controller, and starting or resuming execution from Plan mode left write tools unavailable.

Fix

  • Route approved-plan execution through Ferment V2 when enabled, while preserving the legacy path when disabled.
  • Switch Plan to Auto before creating or resuming execution, and pause an active run when the user explicitly enters read-only Plan mode.
  • Persist approved-plan metadata and keep edits grounded in the approved artifact, with neutral named-plan presentation.
  • Apply programmatic permission-mode changes through the same tool, status, and event side effects as interactive changes.

Validation

  • 513 focused unit and integration tests passed.
  • TUI E2E: 11 Ferment V2 workflows and 4 plan-promotion workflows passed.
  • pnpm run check passed with two unrelated existing lint warnings.
  • pnpm run build:binary passed.
  • Live Kimi K3, DeepSeek Flash 0731, and GLM-5.2 runs passed Plan to Auto, Plan pause, resume to Auto, exact artifact verification, and completion.
  • Full pnpm run test: 9,759 passed and 10 skipped; three unrelated src/extensions/dap/integration.test.ts cases failed and reproduced when run alone.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • I have read CONTRIBUTING.md and agree to the CLA
  • Tests pass locally (pnpm run test) — see the unrelated DAP failures above
  • Lint passes (pnpm run check)
  • Documentation updated for the behavior change

@tautvydasLiekis tautvydasLiekis added the new feature Introduces a new feature label Sep 4, 2026
@kimchi-review

kimchi-review Bot commented Sep 4, 2026

Copy link
Copy Markdown

Kimchi Code Review

Property Value
Commit 369f6fa
Author @tautvydasLiekis
Files changed 21
Review status Completed
Comments 2 (1 critical, 1 info)
Duration 193s

Summary

📊 Review Score: 82/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 4/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — Comprehensive coverage: unit tests for the new PromptEditor indicator and gradient border, Ferment V2 command summary neutralization, approved-plan executor registry, reducer presentation round-tripping, permissions integration (auto/resume/pause, tool visibility, execute routing), and full E2E TUI tests for both manual Ferment V2 from plan mode and automatic approved-plan execution.

📝 Found 2 issue(s). See inline comments for details.

What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @getkimchi review — re-trigger a full review on the latest commit
  • @getkimchi summary — regenerate the PR summary
  • @getkimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

@kimchi-review kimchi-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Review Score: 82/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 4/5 (1 = trivial, 5 = very complex)

🧪 Tests: yes — Comprehensive coverage: unit tests for the new PromptEditor indicator and gradient border, Ferment V2 command summary neutralization, approved-plan executor registry, reducer presentation round-tripping, permissions integration (auto/resume/pause, tool visibility, execute routing), and full E2E TUI tests for both manual Ferment V2 from plan mode and automatic approved-plan execution.

📝 Found 2 issue(s). See inline comments for details.

@@ -410,6 +424,34 @@ export default function fermentV2Extension(pi: ExtensionAPI): void {
const cleared = clearCompletionDecision(currentFermentV2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨🔀 Concurrency

pauseActiveFermentV2ForPlanMode commits a paused Ferment V2 revision directly via commitFermentV2 without serializing through the per-session mutationTails queue used by serializeUserMutation. If the user switches to Plan mode (or the MODE_CHANGED event fires) while an approved-plan start or /ferment-v2 command is yielded inside serializeUserMutation, the pause mutates currentFermentV2 out from under the in-flight mutation. When that mutation resumes, assertUnchanged(captured) throws and the operation fails, even though ensureFermentV2ExecutionMode had already tried to switch to Auto.

💡 Suggestion: Route the pause through serializeUserMutation (or a shared session lock) so Plan-mode pauses cannot interleave with in-flight Ferment V2 mutations. For example, enqueue a source: "plan_mode" mutation that checks the active status again at execution time before calling setFermentV2Status.

if (getPermissionMode(sessionId)?.mode !== "plan") return
setPermissionMode(sessionId, { mode: "auto", initiatedBy: "user", source: "runtime" })
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️⚠️ Error Handling

pauseActiveFermentV2ForPlanMode fires abortEvaluation() with void and immediately checkpoints/commits the paused state. If the evaluator is slow to stop, a late turn result can still arrive after the pause is recorded. The downstream matchesFermentV2 guard will drop it, but the immediate "paused" notification may race with a final status/tool update, giving the user a briefly inconsistent view.

💡 Suggestion: Consider awaiting abortEvaluation() (or its settlement) before checkpointFermentV2 so the pause is committed only after the active evaluator has actually stopped, provided that does not introduce a re-entrant deadlock with abortEvaluation's own cleanup path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Introduces a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant