Files
buzz/crates
Duncan 30f302ca53 fix(acp): close Thufir pass-2 findings — busy-switch Unknown and Rejected switch outcome
Finding A: clear model_capabilities in SwitchModel worker handler so
return_agent preserves Unknown instead of restoring the outgoing model's
stale Supported snapshot. The pool was already set to Unknown in
handle_switch_model_control; the worker's own cleared field prevents the
cancelled return from overwriting it before the requeued switch lands.

Finding B: introduce ModelSwitchOutcome enum (Applied/Rejected) to replace
the overloaded Value::Null sentinel. On Rejected, the pre-switch capabilities
and cache are preserved (session is still on default model), switch_succeeded
is false, and a terminal control_result failure is emitted so Desktop
ModelPicker rejects the live pick immediately. The optionless-success and
rejection paths are now distinct: optionless success drops to Unknown, a
rejection preserves existing capabilities.

Two lifecycle regressions added (no manual capability injection):
- test_busy_switch_clears_capabilities_so_return_preserves_unknown: starts
  Supported, simulates SwitchModel handler clearing caps, calls return_agent,
  asserts Unknown preserved.
- test_switch_rpc_rejection_preserves_pre_switch_capabilities: scripted ACP
  returning a JSON-RPC error from the switch RPC; asserts pre-switch caps
  intact, modelOverridden false, control_result failure emitted.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-08-10 17:16:26 -04:00
..