#366·plandex

REPL: switching plans (`plandex cd`/`new`) keeps the previous plan's cached config — auto-exec/auto-apply verdicts bleed across plans

Author: TardfyouCreated Sep 23, 2026Updated Sep 23, 2026

Summary

In the CLI REPL, the plan config is cached in a package-level global that is never invalidated by plan id. After switching plans with plandex cd or new, subsequent tell/apply runs reuse the previous plan's config — so a plan you configured as full-auto silently applies auto-exec/auto-apply/auto-debug to the newly selected plan.

Code path (main @ e2d7720)

  • app/cli/lib/plan_config.go:14-31 — var cachedPlanConfig *shared.PlanConfig; MustGetCurrentPlanConfig() returns the cache if non-nil, regardless of CurrentPlanId; SetCachedPlanConfig only sets.
  • app/cli/cmd/cd.go:100,106 — cd only writes the current plan + reloads it; the REPL config and the global cache are not reset.
  • app/cli/cmd/repl.go:41,65 — REPL keeps replConfig across plan switches.
  • Consumption: app/cli/cmd/plan_exec_helpers.go:178,193,196 — tellAutoApply=config.AutoApply, noExec=!config.CanExec, autoExec=config.AutoExec.

Scenario

  1. Work on plan A configured auto-apply/auto-exec (full auto).
  2. In the same REPL: cd <plan-B> where plan B is confirmation-gated.
  3. tell --apply "..." → plan B's generated _apply.sh executes without confirmation because A's cached config is still in effect.

Impact

A human approval decision made for one plan is applied to a different plan's effects — the confirmation gate for plan B is silently bypassed (verdict-to-effect mismatch across plan boundaries).

Suggested fix

Key the cache by plan id (invalidate on cd/new/delete), or fetch config per-invocation in the REPL.

Notes

Verified statically against main @ e2d7720 (2025-10-03, latest).


Reported by Chengzhi Yi (GitHub @Tardfyou) — [email protected]. Offline analysis of the public repository; no system was accessed.